import{s as F,n as G,o as V}from"../chunks/scheduler.d6170356.js";import{S as O,i as K,g as p,s as n,r as Q,A as ee,h as o,f as a,c as l,j as A,u as N,x as w,k as Y,y as te,a as s,v as Z,d as D,t as W,w as X}from"../chunks/index.fcd4cc08.js";import{C as ae}from"../chunks/CodeBlock.7b16bdef.js";import{H as se}from"../chunks/Heading.8660bd0e.js";function ne(q){let i,U,M,_,r,v,c,R="You can use URL query parameters as a data sharing mechanism, for instance to be able to deep-link into an app with a specific state.",x,h,k="On a Space page (<code>https://huggingface.co/spaces/&lt;user&gt;/&lt;app&gt;</code>), the actual application page (<code>https://*.hf.space/</code>) is embedded in an iframe. The query string and the hash attached to the parent page URL are propagated to the embedded app on initial load, so the embedded app can read these values without special consideration.",C,d,P=`In contrast, updating the query string and the hash of the parent page URL from the embedded app is slightly more complex.
If you want to do this in a Docker or static Space, you need to add the following JS code that sends a message to the parent page that has a <code>queryString</code> and/or <code>hash</code> key.`,L,m,b,u,I="<strong>This is only for Docker or static Spaces.</strong>",S,f,z="For Streamlit apps, Spaces automatically syncs the URL parameters. Gradio apps can read the query parameters from the Spaces page, but do not sync updated URL parameters with the parent page.",J,g,E="Note that the URL parameters of the parent page are propagated to the embedded app <em>only</em> on the initial load. So <code>location.hash</code> in the embedded app will not change even if the parent URL hash is updated using this method.",$,y,B=`An example of this method can be found in this static Space,
<a href="https://huggingface.co/spaces/whitphx/static-url-param-sync-example" rel="nofollow"><code>whitphx/static-url-param-sync-example</code></a>.`,j,T,H;return r=new se({props:{title:"How to handle URL parameters in Spaces",local:"how-to-handle-url-parameters-in-spaces",headingTag:"h1"}}),m=new ae({props:{code:"Y29uc3QlMjBxdWVyeVN0cmluZyUyMCUzRCUyMCUyMi4uLiUyMiUzQiUwQWNvbnN0JTIwaGFzaCUyMCUzRCUyMCUyMi4uLiUyMiUzQiUwQSUwQXdpbmRvdy5wYXJlbnQucG9zdE1lc3NhZ2UoJTdCJTBBJTIwJTIwJTIwJTIwcXVlcnlTdHJpbmclMkMlMEElMjAlMjAlMjAlMjBoYXNoJTJDJTBBJTdEJTJDJTIwJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyMiklM0I=",highlighted:`<span class="hljs-keyword">const</span> queryString = <span class="hljs-string">&quot;...&quot;</span>;
<span class="hljs-keyword">const</span> hash = <span class="hljs-string">&quot;...&quot;</span>;

<span class="hljs-variable language_">window</span>.<span class="hljs-property">parent</span>.<span class="hljs-title function_">postMessage</span>({
    queryString,
    hash,
}, <span class="hljs-string">&quot;https://huggingface.co&quot;</span>);`,wrap:!1}}),{c(){i=p("meta"),U=n(),M=p("p"),_=n(),Q(r.$$.fragment),v=n(),c=p("p"),c.textContent=R,x=n(),h=p("p"),h.innerHTML=k,C=n(),d=p("p"),d.innerHTML=P,L=n(),Q(m.$$.fragment),b=n(),u=p("p"),u.innerHTML=I,S=n(),f=p("p"),f.textContent=z,J=n(),g=p("p"),g.innerHTML=E,$=n(),y=p("p"),y.innerHTML=B,j=n(),T=p("p"),this.h()},l(e){const t=ee("svelte-u9bgzb",document.head);i=o(t,"META",{name:!0,content:!0}),t.forEach(a),U=l(e),M=o(e,"P",{}),A(M).forEach(a),_=l(e),N(r.$$.fragment,e),v=l(e),c=o(e,"P",{"data-svelte-h":!0}),w(c)!=="svelte-13bdlzr"&&(c.textContent=R),x=l(e),h=o(e,"P",{"data-svelte-h":!0}),w(h)!=="svelte-12t98gf"&&(h.innerHTML=k),C=l(e),d=o(e,"P",{"data-svelte-h":!0}),w(d)!=="svelte-ngy7gm"&&(d.innerHTML=P),L=l(e),N(m.$$.fragment,e),b=l(e),u=o(e,"P",{"data-svelte-h":!0}),w(u)!=="svelte-1pi7s18"&&(u.innerHTML=I),S=l(e),f=o(e,"P",{"data-svelte-h":!0}),w(f)!=="svelte-mvq3g"&&(f.textContent=z),J=l(e),g=o(e,"P",{"data-svelte-h":!0}),w(g)!=="svelte-zn49j8"&&(g.innerHTML=E),$=l(e),y=o(e,"P",{"data-svelte-h":!0}),w(y)!=="svelte-1ft72d"&&(y.innerHTML=B),j=l(e),T=o(e,"P",{}),A(T).forEach(a),this.h()},h(){Y(i,"name","hf:doc:metadata"),Y(i,"content",le)},m(e,t){te(document.head,i),s(e,U,t),s(e,M,t),s(e,_,t),Z(r,e,t),s(e,v,t),s(e,c,t),s(e,x,t),s(e,h,t),s(e,C,t),s(e,d,t),s(e,L,t),Z(m,e,t),s(e,b,t),s(e,u,t),s(e,S,t),s(e,f,t),s(e,J,t),s(e,g,t),s(e,$,t),s(e,y,t),s(e,j,t),s(e,T,t),H=!0},p:G,i(e){H||(D(r.$$.fragment,e),D(m.$$.fragment,e),H=!0)},o(e){W(r.$$.fragment,e),W(m.$$.fragment,e),H=!1},d(e){e&&(a(U),a(M),a(_),a(v),a(c),a(x),a(h),a(C),a(d),a(L),a(b),a(u),a(S),a(f),a(J),a(g),a($),a(y),a(j),a(T)),a(i),X(r,e),X(m,e)}}}const le='{"title":"How to handle URL parameters in Spaces","local":"how-to-handle-url-parameters-in-spaces","sections":[],"depth":1}';function pe(q){return V(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class he extends O{constructor(i){super(),K(this,i,pe,ne,F,{})}}export{he as component};
