UNPKG

decocms

Version:

Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools

558 lines • 153 kB
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-DFekY7v1.js","assets/index-ztdGKvBm.js","assets/index-DOMlzk_A.css","assets/chat-context-DFEln8mI.js","assets/use-panel-navigate-0z93k6Ut.js","assets/thread-route-CfpvvkkL.js","assets/use-project-scope-BwqdbGG4.js","assets/repository-binding-D_Xc1yRH.js","assets/use-mcp-client-2MG3LveS.js","assets/auth-C82OPjUx.js","assets/use-view-draft-kind-BopwZu5H.js","assets/use-blog-view-DMfZjkz0.js","assets/use-organization-settings-C2vcrj4S.js","assets/schema-Bb-DbvPZ.js","assets/task-board-i6qU2BVR.js","assets/thread-intent-DyZ5A9F9.js","assets/delay-CnY5UFtP.js","assets/backoff-CrEUbyZT.js","assets/watch-sse-pool-DdfLfQcH.js","assets/session-runtime-DBl1Hlcw.js","assets/use-entitlements-Gn1rhCN5.js","assets/use-ai-providers-Ct2xvYDX.js","assets/use-current-view-DBmQQ8uy.js","assets/use-in-settings-CFQ9B3W2.js","assets/use-decopilot-events-43RPCkUH.js","assets/use-org-fs-D9dHgOYs.js","assets/useInfiniteQuery-Ypmdjx1e.js","assets/infiniteQueryObserver-C3KEOANj.js","assets/save-status-DhQhbNh0.js","assets/Image01-BcIZ5mtf.js","assets/Trash01-BxBhF2b8.js","assets/Upload01-q-rKSvZf.js","assets/use-never-published-BJeGnEQC.js","assets/use-voice-input-BMrsODyI.js","assets/popover-C4oz5B-L.js","assets/drawer-CROtV2u4.js","assets/tooltip-Bm0P1gm_.js","assets/index-CDQbtG2e.js","assets/use-mobile-C_hdQY5I.js","assets/agent-icon-BYWtutu9.js","assets/AlertCircle-BlMH0XE7.js","assets/UserCheck01-k-4bTA2h.js","assets/Tool01-BCJ5kyrz.js","assets/ArrowUp-D5DDc3Cp.js","assets/ArrowLeft-B0PZnf1E.js","assets/ArrowRight-mzMrxxYI.js","assets/BookOpen01-DU-B3R7s.js","assets/Globe04-CeAQ1YNm.js","assets/CheckCircle-DZ8MNpCP.js","assets/ChevronDown-XsLJSrfl.js","assets/ChevronSelectorVertical-CB0fn1Nq.js","assets/ChevronUp-BQktpZWC.js","assets/UserSquare-CafFh5_d.js","assets/LinkBroken01-DfUhihLM.js","assets/CreditCard01-MY4ouqtl.js","assets/File02-DaYek2y9.js","assets/MessageCircle01-BG1RhOiZ.js","assets/SwitchHorizontal01-CMdpIiQk.js","assets/Eye-kjjhS0vP.js","assets/Fingerprint04-B2fDIuT8.js","assets/Key01-CaJGjh13.js","assets/LayoutLeft-DDtN-od-.js","assets/Minus-hZzPDO0w.js","assets/Monitor01-DMFbvudn.js","assets/Sun-O9TdKcV_.js","assets/Play-BCFOaioW.js","assets/Plus-DWySsEmB.js","assets/SearchMd-BD2qldmS.js","assets/ShoppingBag01-BbjW7cod.js","assets/Users01-DM58_gUL.js","assets/XClose-CmTuu4UN.js","assets/Zap-CBJ7My90.js","assets/index-CJKec1wg.js","assets/checkbox-QUuOza1H.js","assets/select-CxXZwsSr.js","assets/index-BdQq_4o_.js","assets/ai-providers-logos-DD3qZ33J.js","assets/openai-compatible-presets-BKGfVqEx.js","assets/site-editor-toast-Dq7SmLyr.js","assets/content-changes-BFwm7dNe.js","assets/sandbox-url-D3mC8qhT.js","assets/use-sandbox-events-E6fWuIsO.js","assets/use-blocks-v8-project-BPvEDyS9.js","assets/utils-COdvgYqW.js","assets/sandbox-git-api-BsG4EzUP.js","assets/hosted-reconcile-rjhKNGnc.js","assets/blocks-tab-states-8lUCpJRf.js","assets/empty-state-I_cTbW85.js","assets/search-input-BQ8Dp8aD.js","assets/tabs-nQ7_UOyl.js","assets/active-indicator-CCMhAsc_.js","assets/use-debounced-value-DO5dvp6c.js","assets/use-file-configs-3gwPBXwK.js","assets/asset-utils-DP9aQr9Q.js","assets/usage-stats-B0_Yl-r0.js","assets/utils-CVEq3hMx.js","assets/markdown-CJR_ooUO.js","assets/use-copy-DT4_uVrH.js","assets/gateway-client-B4qzR3sF.js","assets/form-DlZ0KMAb.js","assets/label-8UxgpYiA.js","assets/switch-B81oLbqr.js","assets/toggle-group-yQeAFu4u.js","assets/match-site-slug-config-B47_xZCi.js","assets/parse-sections-Bun2U10n.js","assets/held-block-view-QD0AvQ2Q.js","assets/calendar-DNzaYWCQ.js","assets/textarea-viSdm6BE.js","assets/editor-classes-DYlqLnQ7.js","assets/task-key-Bt60Ndov.js","assets/sortable.esm-CKl9Rez4.js","assets/category-tree-DGOo1BAt.js","assets/sandbox-start-errors-BK_aDCyt.js","assets/pair-DmyTA2cC.js","assets/collapsible-CadTVXY4.js","assets/use-task-board-items-D2aUd0HA.js","assets/config-LEYSFIMn.js","assets/task-route-C3cK6F8S.js","assets/project-index-C2IrSomv.js","assets/shell-layout-UF80oiAz.js","assets/use-deployment-admin-Cr4LWHG9.js","assets/admin-fetch-BhTJlAsX.js","assets/use-org-notice-Bg0zOPPj.js","assets/command-C3tlrKUq.js","assets/index-DMpANy5-.js","assets/integration-icon-Bo-3z9o3.js","assets/project-icon-fQqckccl.js","assets/use-navigate-to-agent-Cw8_3uU5.js","assets/new-project-dialog-BW6Lh52P.js","assets/repository-picker-CSaozawA.js","assets/github-icon-Bq9Ot22_.js","assets/collection-search-DkVgkcUC.js","assets/new-project-store-DID5OVrt.js","assets/legacy-admin-welcome-dialog-plmLACwz.js","assets/required-auth-layout-Cwtu4iIe.js","assets/use-org-sso-_fzcS8V-.js","assets/shell-layout-CE2Eihra.css","assets/content-blocks-o63cs2vh.js","assets/mcp-app-renderer-DU6s3Olv.js","assets/types-5-cDe_8u.js","assets/omit-server-managed-metadata-L5IhjRZB.js","assets/sheet-C-umRrOH.js","assets/use-connection-CcG4QE1K.js","assets/use-mcp-prompts-qJSiAdA5.js","assets/use-thread-outputs-BK5BfLdO.js","assets/file-type-icon-CdjLDWdN.js","assets/section-array-field-uECXIzc8.js","assets/named-rule-step-BUKBZ8bi.js","assets/slider-Cqj9bgcu.js","assets/index-MkoN5oFR.js","assets/tooltipContext-CSDtg0Lk.js","assets/CategoricalChart-wSsXuALZ.js","assets/index-rjS4IUT9.js","assets/combobox-2rKAfmHD.js","assets/scroll-area-Dm3EbBj1.js","assets/monaco-editor-CLzWWWtl.js","assets/editor-ipOJFDhA.js","assets/use-delete-block-BDYGRW7T.js","assets/use-section-preview-base-CWHJYT12.js","assets/mustache-CNuJ7AZ0.js","assets/seo-editor-XFI4kpN6.js","assets/use-apply-named-rule-BXltW_Uu.js","assets/use-move-blocks-Bu_TrzH9.js","assets/variant-matcher-override-BAo9iF1F.js"])))=>i.map(i=>d[i]);
import{c as le,j as r,r as R,m as Re,b as Se,B as _e,aJ as ps,bn as gt,aK as De,bo as So,bp as Po,bq as jo,br as Eo,v as en,D as tn,K as sn,w as nn,x as rn,e as No,h as it,I as Vs,y as Co,bb as To,a6 as gs,ba as Ro,b8 as Jr,bs as vr,i as Yr,au as Ws,aw as qs,a9 as Qr,P as Gs,E as Lo,t as ms,b9 as Ao,q as Oo}from"./index-ztdGKvBm.js";import{u as an,N as _o}from"./save-status-DhQhbNh0.js";import{b as $o,c as lt,r as Xr,l as Zr,f as Fo,g as Do,w as Bo}from"./chat-context-DFEln8mI.js";import{t as Mo}from"./ChevronDown-XsLJSrfl.js";import{H as zo,I as Io,C as on,J as Ko,b as Uo,K as xr,L as Ho,M as ea,N as Vo,O as ta}from"./agent-icon-BYWtutu9.js";import{s as Wo}from"./File02-DaYek2y9.js";import{b as qo,n as Go}from"./UserSquare-CafFh5_d.js";import{s as sa}from"./Plus-DWySsEmB.js";import{a as na,b as ra,P as aa}from"./popover-C4oz5B-L.js";import{e as We,b as qe,c as ln,f as cn,a as dn,C as un}from"./command-C3tlrKUq.js";import{a as Jo,c as Yo,b as Qo}from"./repository-binding-D_Xc1yRH.js";import{a as bt}from"./sandbox-lifecycle-context-DbNrw8-a.js";import{a as Xo,n as Zo,u as ei,f as br,H as ti,g as $s,P as si}from"./frame-navigation-DMXKoo4B.js";import{r as ni}from"./session-runtime-DBl1Hlcw.js";import{u as oa}from"./use-voice-input-BMrsODyI.js";import{l as ri,m as ai,n as oi,o as ii,q as li,t as ci,u as Ut,j as vs,v as ia,i as tt,w as di,x as fn,y as la,k as ca,z as ui,A as fi,B as da,C as pi,c as ua,b as fa,D as mi,h as Ve,E as hi,d as gi,g as vi,F as xi,G as bi,H as yr,I as yi,J as wr,K as wi,L as ki,M as kr,N as Sr,O as Pr,P as jr,Q as Er,R as Fs,S as Si,U as Pi,V as ji,W as Ei,e as Ni}from"./site-editor-toast-Dq7SmLyr.js";import{u as pa}from"./use-mobile-C_hdQY5I.js";import{T as st,I as Nr}from"./toolbar-icon-button-Cz-oOJ1w.js";import{T as nt,a as rt,c as at}from"./tooltip-Bm0P1gm_.js";import{w as os,i as Ci}from"./variant-matcher-override-BAo9iF1F.js";import{s as xt,n as pn,a as mn,f as Be,e as Ti,v as ma,u as ha,h as Ri,i as Li,B as Ai,S as Oi,C as _i,b as $i,c as Fi,d as Di,g as Bi,N as Mi,j as zi,r as Ii,k as Ki,l as Cr,p as Ui}from"./blocks-tab-states-8lUCpJRf.js";import{a as Hi}from"./use-fast-preview-draft-url-CpggWNTk.js";import{g as Vi,c as Tr,B as Ds,P as Wi,r as qi,R as Gi,S as Ji,l as Yi,m as Qi,p as Xi}from"./parse-sections-Bun2U10n.js";import{g as Zi}from"./section-array-field-uECXIzc8.js";import{u as el}from"./shell-layout-UF80oiAz.js";import{u as hn,b as tl}from"./use-sandbox-events-E6fWuIsO.js";import{s as sl,p as nl,W as rl,n as al,S as Bs}from"./category-tree-DGOo1BAt.js";import{u as Js}from"./useQueries-GZbpaWZ_.js";import{i as ga}from"./ArrowRight-mzMrxxYI.js";import{a as ol,c as il}from"./blog-preview-url-N6iQgPQK.js";import{u as ll,b as va}from"./use-never-published-BJeGnEQC.js";import{u as xa}from"./blocks-preview-workspace-context-ZEZYfsWp.js";import{u as cl,H as dl}from"./held-block-view-QD0AvQ2Q.js";import{MonacoCodeEditor as ba}from"./monaco-editor-CLzWWWtl.js";import{c as ya,u as wa}from"./hosted-reconcile-rjhKNGnc.js";import{d as ka}from"./utils-COdvgYqW.js";import{R as Rr,a as is,b as Lr}from"./resizable-DNBx7bMi.js";import{g as Sa}from"./use-org-notice-Bg0zOPPj.js";import{u as ul}from"./use-blocks-v8-project-BPvEDyS9.js";import{s as fl,L as pl,R as Pa,D as Ar,w as Ys}from"./device-hint-B3WnBHYf.js";import{s as ml}from"./UserCheck01-k-4bTA2h.js";import{L as hl}from"./label-8UxgpYiA.js";import{T as gl,a as Or}from"./toggle-group-yQeAFu4u.js";import{i as vl,l as xl,D as bl}from"./named-rule-step-BUKBZ8bi.js";import{b as yl}from"./sandbox-url-D3mC8qhT.js";import{r as wl,R as kl}from"./virtual-mcp-CAb2l-zV.js";import{d as Sl}from"./delay-CnY5UFtP.js";import{s as ja}from"./XClose-CmTuu4UN.js";import{o as Pl}from"./omit-server-managed-metadata-L5IhjRZB.js";import{a as Ms,b as jl,w as El,n as _r}from"./app-preview-url-9Od4s8Sz.js";import{u as Nl}from"./use-organization-settings-C2vcrj4S.js";import{a as zs}from"./agent-capabilities-CyWfHGWp.js";import{E as Cl}from"./empty-state-I_cTbW85.js";import{G as $r}from"./github-icon-Bq9Ot22_.js";import{R as Tl}from"./new-project-dialog-BW6Lh52P.js";import{r as Rl}from"./preview-source-BsRLGWUP.js";import{A as Ll,a as Al,b as Ol}from"./alert-CxbB9CEj.js";import{u as _l}from"./use-task-metadata-DZBgcb3y.js";function $l(t){const e=le.c(10),{waiting:s}=t,n=s?"true":"false";let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("span",{className:"flex size-10 items-center justify-center rounded-xl bg-muted text-muted-foreground sm:size-12",children:r.jsx(zo,{className:"size-5 sm:size-6"})}),e[0]=o):o=e[0];let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("span",{className:"h-px w-full border-t border-dashed border-muted-foreground/40"}),e[1]=c):c=e[1];let d;e[2]!==s?(d=s&&r.jsx("span",{"data-testid":"connection-dot",className:"absolute top-0 size-2 animate-[connection-shuttle_1.8s_var(--ease-in-out-cubic)_infinite_alternate] rounded-full bg-foreground"}),e[2]=s,e[3]=d):d=e[3];let i;e[4]!==d?(i=r.jsxs("span",{className:"relative flex h-2 w-16 items-center sm:w-20",children:[c,d]}),e[4]=d,e[5]=i):i=e[5];let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("span",{className:"flex size-10 items-center justify-center rounded-xl bg-muted text-muted-foreground sm:size-12",children:r.jsx(Io,{className:"size-5 sm:size-6"})}),e[6]=a):a=e[6];let l;return e[7]!==n||e[8]!==i?(l=r.jsxs("div",{"aria-hidden":"true","data-testid":"connection-wire","data-waiting":n,className:"flex items-center gap-2",children:[o,i,a]}),e[7]=n,e[8]=i,e[9]=l):l=e[9],l}function Fl(t){const e=le.c(22),{index:s,numbered:n,step:o,heading:c}=t,d=R.useId();let i;e[0]!==s||e[1]!==n?(i=n&&r.jsx("span",{"aria-hidden":"true",className:"flex size-6 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-medium tabular-nums text-foreground",children:s}),e[0]=s,e[1]=n,e[2]=i):i=e[2];let a;e[3]!==c||e[4]!==d||e[5]!==o.title?(a=r.jsx(c,{id:d,className:"text-sm font-medium text-foreground",children:o.title}),e[3]=c,e[4]=d,e[5]=o.title,e[6]=a):a=e[6];let l;e[7]!==i||e[8]!==a?(l=r.jsxs("div",{className:"flex items-center gap-3",children:[i,a]}),e[7]=i,e[8]=a,e[9]=l):l=e[9];const g=n&&"sm:pl-9";let f;e[10]!==g?(f=Re("flex min-w-0 flex-col gap-3",g),e[10]=g,e[11]=f):f=e[11];let p;e[12]!==o.body?(p=o.body&&r.jsx("p",{className:"text-sm text-muted-foreground",children:o.body}),e[12]=o.body,e[13]=p):p=e[13];let m;e[14]!==o.after||e[15]!==f||e[16]!==p?(m=r.jsxs("div",{className:f,children:[p,o.after]}),e[14]=o.after,e[15]=f,e[16]=p,e[17]=m):m=e[17];let v;return e[18]!==d||e[19]!==l||e[20]!==m?(v=r.jsxs("li",{"aria-labelledby":d,className:"surface flex flex-col gap-3 p-4 sm:p-5",children:[l,m]}),e[18]=d,e[19]=l,e[20]=m,e[21]=v):v=e[21],v}const Dl=[];function hs(t){const e=le.c(20),{title:s,lead:n,waiting:o,alerts:c,steps:d,footer:i,headingLevel:a}=t,l=d===void 0?Dl:d,g=a===void 0?1:a,f=g===1?"h1":"h2",p=o&&l.length===0?"status":void 0;let m;e[0]!==o?(m=r.jsx($l,{waiting:o}),e[0]=o,e[1]=m):m=e[1];let v;e[2]!==f||e[3]!==s?(v=r.jsx(f,{tabIndex:-1,className:"text-balance text-lg font-medium text-foreground outline-none sm:text-xl",children:s}),e[2]=f,e[3]=s,e[4]=v):v=e[4];let y;e[5]!==n?(y=n&&r.jsx("p",{className:"text-pretty text-sm text-muted-foreground",children:n}),e[5]=n,e[6]=y):y=e[6];let h;e[7]!==p||e[8]!==m||e[9]!==v||e[10]!==y?(h=r.jsxs("header",{role:p,className:"flex flex-col items-center gap-3 text-center",children:[m,v,y]}),e[7]=p,e[8]=m,e[9]=v,e[10]=y,e[11]=h):h=e[11];let x;e[12]!==g||e[13]!==l?(x=l.length>0&&r.jsx("ol",{className:"flex flex-col gap-3",children:l.map((b,w)=>r.jsx(Fl,{index:w+1,numbered:l.length>1,step:b,heading:g===1?"h2":"h3"},b.title))}),e[12]=g,e[13]=l,e[14]=x):x=e[14];let C;return e[15]!==c||e[16]!==i||e[17]!==h||e[18]!==x?(C=r.jsx("div",{className:"h-full w-full overflow-y-auto",children:r.jsxs("div",{className:"mx-auto flex min-h-full w-full max-w-xl flex-col justify-center gap-6 px-4 py-8 sm:py-12",children:[h,c,x,i]})}),e[15]=c,e[16]=i,e[17]=h,e[18]=x,e[19]=C):C=e[19],C}function Bl(t){const e=le.c(43),{wait:s,hosts:n,invalidLink:o}=t,c=o===void 0?!1:o,d=Se();let i;e[0]!==c||e[1]!==d?(i=c&&r.jsx(Ll,{variant:"warning",children:r.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[r.jsx(Al,{className:"line-clamp-none text-foreground",children:d("decoServe.link.invalidTitle")}),r.jsx(Ol,{children:d("decoServe.link.invalidBody")})]})}),e[0]=c,e[1]=d,e[2]=i):i=e[2];const a=i;if(s.kind==="problem"){let w;e[3]!==d||e[4]!==s.host||e[5]!==s.problem?(w=fl(d,s.problem,s.host),e[3]=d,e[4]=s.host,e[5]=s.problem,e[6]=w):w=e[6];const{title:N,body:k}=w;let S;e[7]!==k?(S=r.jsx(Pa,{text:k}),e[7]=k,e[8]=S):S=e[8];let E;e[9]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx(Ar,{className:"border-t border-border pt-4",links:["troubleshooting","serve"]}),e[9]=E):E=e[9];let T;return e[10]!==a||e[11]!==S||e[12]!==N?(T=r.jsx(hs,{headingLevel:2,waiting:!1,title:N,lead:S,alerts:a,footer:E}),e[10]=a,e[11]=S,e[12]=N,e[13]=T):T=e[13],T}const l=s.kind==="looking",g=l&&!s.paused;let f;e[14]!==d?(f=d("decoServe.waiting.title"),e[14]=d,e[15]=f):f=e[15];let p;e[16]!==d?(p=d("decoServe.waiting.lead"),e[16]=d,e[17]=p):p=e[17];let m;e[18]!==a||e[19]!==s.kind?(m=(a||s.kind==="denied")&&r.jsxs(r.Fragment,{children:[a,s.kind==="denied"&&r.jsx(pl,{})]}),e[18]=a,e[19]=s.kind,e[20]=m):m=e[20];let v;e[21]!==d?(v=d("decoServe.waiting.connect.title"),e[21]=d,e[22]=v):v=e[22];let y;e[23]!==d?(y=d("decoServe.waiting.connect.body"),e[23]=d,e[24]=y):y=e[24];let h;e[25]!==n||e[26]!==l||e[27]!==d||e[28]!==s.kind||e[29]!==s.onStart||e[30]!==s.paused?(h=s.kind==="needs-gesture"?r.jsx(_e,{variant:"outline",className:"self-start",onClick:s.onStart,children:d("decoServe.guide.start")}):l&&r.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:s.paused?d("decoServe.guide.paused"):d("decoServe.guide.looking",{hosts:n})}),e[25]=n,e[26]=l,e[27]=d,e[28]=s.kind,e[29]=s.onStart,e[30]=s.paused,e[31]=h):h=e[31];let x;e[32]!==v||e[33]!==y||e[34]!==h?(x=[{title:v,body:y,after:h}],e[32]=v,e[33]=y,e[34]=h,e[35]=x):x=e[35];let C;e[36]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(Ar,{className:"border-t border-border pt-4",links:["siteEditor","serve","troubleshooting"]}),e[36]=C):C=e[36];let b;return e[37]!==x||e[38]!==g||e[39]!==f||e[40]!==p||e[41]!==m?(b=r.jsx(hs,{headingLevel:2,waiting:g,title:f,lead:p,alerts:m,steps:x,footer:C}),e[37]=x,e[38]=g,e[39]=f,e[40]=p,e[41]=m,e[42]=b):b=e[42],b}function Ml(t,e){switch(t.kind){case"needs-permission":return{kind:"denied"};case"problem":return{kind:"problem",problem:t.problem,host:e};default:return{kind:"looking"}}}const zl=15e3,Il=3e3;function Kl(t){const{candidates:e,probe:s,onFound:n,onChange:o,doc:c=document,setTimer:d=(w,N)=>setTimeout(w,N),clearTimer:i=w=>clearTimeout(w),timeoutMs:a=Il}=t;let l={status:"searching",firstRoundDone:!1,problem:null},g=!1,f=!1,p=0,m=null,v=null;const y=()=>c.visibilityState==="hidden",h=w=>{l={...l,...w},o(l)},x=async w=>{v=new AbortController;const N=v,k=d(()=>N.abort(),a);try{return await s(w,N.signal),!0}catch(S){if(g)return!1;const E=ai(S);return E.reason!=="not-answering"?h({problem:{...E,endpoint:w}}):l.problem?.endpoint===w&&h({problem:null}),!1}finally{i(k),v=null}},C=async()=>{if(m=null,!(g||f)){if(e.length===0){h({status:"stopped",firstRoundDone:!0});return}if(y()){h({status:"paused"});return}f=!0,l.status!=="searching"&&h({status:"searching"});for(const w of e){if(g)break;if(await x(w)){if(f=!1,g)return;g=!0,c.removeEventListener("visibilitychange",b),h({status:"found",firstRoundDone:!0}),n(w);return}}if(f=!1,!g){if(p+=1,l.firstRoundDone||h({firstRoundDone:!0}),y()){h({status:"paused"});return}m=d(()=>{C()},ri(p,zl))}}};function b(){if(!g){if(y()){m!==null&&(i(m),m=null),f||h({status:"paused"});return}m!==null&&i(m),p=0,C()}}return c.addEventListener("visibilitychange",b),o(l),C(),()=>{g=!0,m!==null&&i(m),v?.abort(),c.removeEventListener("visibilitychange",b)}}function Ul(t,e){return ii(t,e)}const Hl=["loopback-network","local-network-access"];async function Vl(){if(oi(window.location.origin))return null;for(const t of Hl)try{return await navigator.permissions.query({name:t})}catch{}return null}let Ea=null,Fr=!1;const Is=new Set;function Wl(t){if(Is.add(t),!Fr){Fr=!0;const e=s=>{Ea=s;for(const n of Is)n()};Vl().then(s=>{if(!s)return e("unsupported");e(s.state),s.addEventListener("change",()=>e(s.state))})}return()=>Is.delete(t)}const ql={status:"stopped",firstRoundDone:!1,problem:null},Ks=new Map;function Gl(t){const e=Ks.get(t);if(e)return e;let s={status:"searching",firstRoundDone:!1,problem:null};const n=new Set;let o=null;const c={onFound:()=>{},getSnapshot:()=>s,subscribe:d=>(n.add(d),o??=Kl({candidates:t.split(" "),probe:Ul,onFound:i=>c.onFound(i),onChange:i=>{s=i;for(const a of n)a()}}),()=>{n.delete(d),!(n.size>0)&&(o?.(),o=null,Ks.delete(t))})};return Ks.set(t,c),c}function Na(){return R.useSyncExternalStore(Wl,Br,Br)}const Jl=()=>()=>{},Dr=()=>ql,Br=()=>Ea;function Pf(t){const e=le.c(9),{candidates:s,onFound:n}=t,[o,c]=R.useState(!1),d=Na(),a=(d==="granted"||d==="unsupported"||d==="prompt"&&o)&&s.length>0;let l;e[0]!==a||e[1]!==s||e[2]!==n?(l=a?Gl(s.join(" ")):null,l&&(l.onFound=n),e[0]=a,e[1]=s,e[2]=n,e[3]=l):l=e[3];const g=R.useSyncExternalStore(l?.subscribe??Jl,l?.getSnapshot??Dr,l?.getSnapshot??Dr),f=d==="prompt"&&!o;let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=()=>c(!0),e[4]=p):p=e[4];let m;return e[5]!==d||e[6]!==g||e[7]!==f?(m={state:g,access:d,needsGesture:f,start:p},e[5]=d,e[6]=g,e[7]=f,e[8]=m):m=e[8],m}const Mr={mode:"none",iframeBase:null,showBlockingOverlay:!1,showWakingPill:!1};function Yl(t){const{previewState:e,progressStatus:s,fastPreviewActive:n=!1,fastPreviewReady:o=!1,codingSession:c=!1,hostedDraft:d=!1}=t,i=c?null:t.previewServerUrl;return t.localPreviewUrl?{mode:"sandbox",iframeBase:t.localPreviewUrl,showBlockingOverlay:!1,showWakingPill:!1}:e.kind==="suspended"||e.kind==="errored"?Mr:d&&t.hostedPointerPending&&!o?{...Mr,showDecidingLoader:!0}:n&&o&&i?{mode:"production",iframeBase:i,showBlockingOverlay:!1,showWakingPill:!1}:n&&d&&i?{mode:"production",iframeBase:i,showBlockingOverlay:!1,showWakingPill:!1}:!n&&e.kind==="iframe"&&s!=="doing"?{mode:"sandbox",iframeBase:e.previewUrl,showBlockingOverlay:!1,showWakingPill:!1}:i?{mode:"production",iframeBase:i,showBlockingOverlay:!1,showWakingPill:!0}:{mode:"none",iframeBase:null,showBlockingOverlay:!0,showWakingPill:!1}}const Ql=1500,Xl=500;function Zl({iframe:t,reload:e,waitMs:s=Ql,confirmMs:n=Xl}){let o;const c=()=>{clearTimeout(d),o=setTimeout(e,n)};t.addEventListener("load",c,{once:!0});const d=setTimeout(()=>{t.removeEventListener("load",c),e()},s);return()=>{clearTimeout(d),clearTimeout(o),t.removeEventListener("load",c)}}const ec=ps({tag:De(),id:De(),classes:De(),text:De(),html:De(),manifestKey:De().nullable(),componentName:De().nullable(),parents:De(),url:De(),path:De(),viewport:ps({width:gt(),height:gt()}),position:ps({x:gt(),y:gt()})}),tc=`(function() {
  if (window.__visualEditorActive) return;
  window.__visualEditorActive = true;

  var cursorStyle = document.createElement("style");
  cursorStyle.textContent = "* { cursor: default !important; }";
  document.head.appendChild(cursorStyle);

  var highlight = document.createElement("div");
  highlight.style.cssText = "position:fixed;pointer-events:none;outline:2px solid #a855f7;background:rgba(168,85,247,0.08);border-radius:2px;z-index:2147483647;display:none;";
  document.body.appendChild(highlight);

  var badge = document.createElement("div");
  badge.style.cssText = "position:fixed;pointer-events:none;background:#a855f7;color:white;font:11px/1 monospace;padding:2px 6px;border-radius:2px;z-index:2147483647;display:none;white-space:nowrap;max-width:240px;overflow:hidden;text-overflow:ellipsis;";
  document.body.appendChild(badge);

  var lastTarget = null;
  var rafPending = false;
  var moveHandler = function(e) {
    if (rafPending) return;
    rafPending = true;
    var target = e.target;
    requestAnimationFrame(function() {
      rafPending = false;
      var el = target;
      if (!el || el === highlight || el === badge) return;
      if (el === lastTarget) return;
      lastTarget = el;
      var r = el.getBoundingClientRect();
      // A CSS zoom on <body> scales the overlay's lengths again; the rect is already zoomed.
      var z = document.body.currentCSSZoom || 1;
      var top = r.top / z;
      var left = r.left / z;
      highlight.style.display = "block";
      highlight.style.top = top + "px";
      highlight.style.left = left + "px";
      highlight.style.width = r.width / z + "px";
      highlight.style.height = r.height / z + "px";
      var tag = el.tagName.toLowerCase();
      var id = el.id ? "#" + el.id : "";
      var cls = el.className && typeof el.className === "string"
        ? "." + el.className.trim().split(/\\s+/).slice(0, 2).join(".")
        : "";
      badge.textContent = tag + id + cls;
      badge.style.display = "block";
      badge.style.top = Math.max(0, top - 20) + "px";
      badge.style.left = left + "px";
    });
  };
  document.addEventListener("mousemove", moveHandler, true);

  var outHandler = function(e) {
    if (!e.relatedTarget || e.relatedTarget === document.documentElement) {
      highlight.style.display = "none";
      badge.style.display = "none";
      lastTarget = null;
    }
  };
  document.addEventListener("mouseout", outHandler, true);

  var clickHandler = function(e) {
    e.preventDefault();
    e.stopImmediatePropagation();
    var el = e.target;
    if (!el || el === highlight || el === badge) return;

    highlight.style.outline = "2px solid #a855f7";
    highlight.style.background = "rgba(168,85,247,0.15)";
    setTimeout(function() {
      highlight.style.outline = "2px solid #a855f7";
      highlight.style.background = "rgba(168,85,247,0.08)";
    }, 400);

    var tag = el.tagName.toLowerCase();
    var id = el.id || "";
    var classes = el.className && typeof el.className === "string" ? el.className.trim() : "";
    var text = (el.textContent || "").trim().slice(0, 200);
    var html = (el.outerHTML || "").slice(0, 800).replace(/\\svalue=("[^"]*"|'[^']*'|\\S+)/gi, "");

    var closestSection = el.closest("section[data-manifest-key]");
    var manifestKey = closestSection ? closestSection.getAttribute("data-manifest-key") : null;

    var ancestor = el;
    var componentName = null;
    for (var i = 0; i < 10 && ancestor; i++) {
      if (ancestor.dataset) componentName = ancestor.dataset.componentName || componentName;
      ancestor = ancestor.parentElement;
    }

    var parents = [];
    var p = el.parentElement;
    for (var j = 0; j < 4 && p && p !== document.body; j++) {
      var pTag = p.tagName ? p.tagName.toLowerCase() : "";
      var pId = p.id ? "#" + p.id : "";
      var pCls = p.className && typeof p.className === "string"
        ? "." + p.className.trim().split(/\\s+/)[0]
        : "";
      parents.unshift(pTag + pId + pCls);
      p = p.parentElement;
    }

    window.parent.postMessage({
      type: "visual-editor::element-clicked",
      payload: {
        tag: tag, id: id, classes: classes, text: text, html: html,
        manifestKey: manifestKey, componentName: componentName,
        parents: parents.join(" > "),
        url: window.location.href, path: window.location.pathname,
        viewport: { width: window.innerWidth, height: window.innerHeight },
        position: { x: Math.round(e.clientX), y: Math.round(e.clientY) }
      }
    }, "*");
  };
  document.addEventListener("click", clickHandler, true);

  window.addEventListener("message", function(e) {
    // Only Studio's own postMessage (source === this frame's parent) may drive the bridge — a nested/downstream frame's forged message can't deactivate the editor.
    if (e.source !== window.parent) return;
    // Parent-driven clear: the cross-origin iframe can't self-detect a frame exit.
    if (e.data && e.data.type === "visual-editor::clear-hover") {
      highlight.style.display = "none";
      badge.style.display = "none";
      lastTarget = null;
      return;
    }
    if (e.data && e.data.type === "visual-editor::deactivate") {
      highlight.remove();
      badge.remove();
      cursorStyle.remove();
      document.removeEventListener("mousemove", moveHandler, true);
      document.removeEventListener("mouseout", outHandler, true);
      document.removeEventListener("click", clickHandler, true);
      window.__visualEditorActive = false;
    }
  });
})();`;function sc(t,e){const s=t.map(()=>null),n=[];for(let y=0;y<t.length;y++)t[y]!==null&&n.push(y);const o=n.length,c=e.length;if(!o||!c)return s;const d=(y,h)=>{const x=t[n[y]??0];return!x||!x.length?1:x.indexOf(e[h]??"")>=0?2:0},i=[],a=[];for(let y=0;y<=o;y++)i.push(new Array(c+1).fill(0)),a.push(new Array(c+1).fill(2));for(let y=1;y<=o;y++){const h=i[y-1]??[],x=i[y]??[],C=a[y]??[];for(let b=1;b<=c;b++){let w=h[b]??0,N=2;const k=x[b-1]??0;k>w&&(w=k,N=0);const S=d(y-1,b-1),E=(h[b-1]??0)+S;S>0&&E>w&&(w=E,N=1),x[b]=w,C[b]=N}}let l=0,g=o,f=c;for(;g>0&&f>0;){const y=a[g]?.[f]??2;y===1?(s[n[g-1]??0]=f-1,l++,g--,f--):y===0?f--:g--}const p=new Array(c).fill(!1);for(const y of n){const h=s[y];h!=null&&(p[h]=!0)}const m=(y,h)=>{const x=t[y];return!!x&&x.length>0&&x.indexOf(e[h]??"")>=0},v=(y,h)=>{for(const x of n){const C=s[x];if(!(C==null||e[C]!==e[h])&&x<y!=C<h)return!1}return!0};for(const y of n)if(s[y]===null){for(let h=0;h<c;h++)if(!p[h]&&m(y,h)&&v(y,h)){s[y]=h,p[h]=!0,l++;break}}if(l===0&&c===o)for(let y=0;y<o;y++)s[n[y]??0]=y;return s}const nc=ps({sectionIndex:gt(),manifestKey:De(),clickSeq:gt()}),rc=`(function() {
  if (window.__cmsEditorActive) return;
  window.__cmsEditorActive = true;

  // Preserve scroll across variant-override navigations and save-reloads.
  // Selecting a variant rebuilds the iframe src (new x-deco-matchers-override)
  // or reloads it, which would otherwise jump to the top. We persist the scroll
  // offset to sessionStorage (survives reload, same-origin) keyed by pathname
  // (the override only changes the query, so the key is stable), then restore it
  // on the next load — retried for ~1s so it outlasts re-hydration and lazy
  // sections that grow the page after load. The recency guard avoids restoring a
  // stale offset on a genuinely fresh visit.
  var SCROLL_KEY = "__cms_preview_scroll:" + location.pathname;
  var saveScroll = function() {
    try {
      sessionStorage.setItem(SCROLL_KEY, JSON.stringify({
        x: window.scrollX, y: window.scrollY, t: Date.now()
      }));
    } catch (_) {}
  };
  var saveScrollPending = false;
  window.addEventListener("scroll", function() {
    if (saveScrollPending) return;
    saveScrollPending = true;
    requestAnimationFrame(function() { saveScrollPending = false; saveScroll(); });
  }, { passive: true });
  (function restoreScroll() {
    var raw = null;
    try { raw = sessionStorage.getItem(SCROLL_KEY); } catch (_) {}
    if (!raw) return;
    var saved = null;
    try { saved = JSON.parse(raw); } catch (_) { return; }
    if (!saved || (Date.now() - saved.t) > 10000) return;
    if (!saved.x && !saved.y) return;
    var attempts = 0;
    var apply = function() {
      attempts++;
      window.scrollTo(saved.x || 0, saved.y || 0);
      if (attempts < 8) setTimeout(apply, 120);
    };
    apply();
  })();

  var highlight = document.createElement("div");
  highlight.style.cssText = "position:absolute;pointer-events:none;outline:2px solid #06b6d4;background:rgba(6,182,212,0.06);border-radius:2px;z-index:2147483647;display:none;";
  document.body.appendChild(highlight);

  var badge = document.createElement("div");
  badge.style.cssText = "position:absolute;pointer-events:none;background:#06b6d4;color:white;font:11px/1 monospace;padding:2px 6px;border-radius:2px;z-index:2147483647;display:none;white-space:nowrap;max-width:240px;overflow:hidden;text-overflow:ellipsis;";
  document.body.appendChild(badge);

  var isTopLevelSection = function(el) {
    return el && el.parentElement
      ? !el.parentElement.closest("section[data-manifest-key]")
      : true;
  };

  // All top-level page sections in DOM order (deco renders page sections as
  // <section data-manifest-key>; nested islands/sections carry the attribute
  // too, hence the top-level filter). This is the full DOM run, framework
  // sections included — getAllSections() narrows it to the editable window.
  var topLevelSections = function() {
    return Array.from(document.querySelectorAll("section[data-manifest-key]"))
      .filter(isTopLevelSection);
  };

  // Acceptable DOM keys per section; [] = wildcard, null = renders nothing.
  var sectionCandidates = [];

  // Stringified from section-alignment.ts so both sides share one copy.
  var alignSections = ${sc.toString()};

  // Indexed like the decofile array; unmapped entries stay null (not clickable).
  var computeAlignment = function(tops) {
    var domKeys = tops.map(function(s) { return s.getAttribute("data-manifest-key"); });
    return alignSections(sectionCandidates, domKeys).map(function(idx) {
      return idx === null ? null : tops[idx];
    });
  };

  // Editable sections, indexed to match the decofile array the panel uses.
  // Recomputed from the live DOM each call (cheap, rAF-throttled) so it
  // self-heals as client-rendered/lazy sections mount. Until the editor sends
  // candidates, fall back to the full top-level run.
  var getAllSections = function() {
    var tops = topLevelSections();
    return sectionCandidates.length ? computeAlignment(tops) : tops;
  };

  // Resolve to the OUTERMOST page-level section (clicking nested content still
  // maps to the top-level section the panel indexes); null if it isn't in the
  // aligned editable set (a framework section deco injected).
  var findSection = function(el, out) {
    var node = el;
    var found = null;
    while (node && node !== document.body) {
      if (node.tagName === "SECTION" && node.hasAttribute && node.hasAttribute("data-manifest-key")) {
        found = node;
      }
      node = node.parentElement;
    }
    if (!found) return null;
    var sections = getAllSections();
    if (out) out.sections = sections;
    return sections.indexOf(found) >= 0 ? found : null;
  };

  // A Lazy wrapper's key is just the loader — show the inner section's instead.
  var LAZY_KEYS = [
    "website/sections/Rendering/Lazy.tsx",
    "website/sections/Rendering/SingleDeferred.tsx"
  ];
  var isLazyKey = function(key) {
    return LAZY_KEYS.some(function(s) { return key.endsWith(s); });
  };
  var displayKey = function(section) {
    var key = section.getAttribute("data-manifest-key") || "section";
    if (isLazyKey(key)) {
      var inner = section.querySelector("section[data-manifest-key]");
      if (inner) return inner.getAttribute("data-manifest-key") || key;
    }
    return key;
  };

  // Per-section metadata sent by the editor, aligned by index with
  // getAllSections(). labels: names the DOM can't carry (a global section or a
  // global inside async rendering); kinds: section type that drives the color.
  var sectionLabels = [];
  var sectionKinds = [];
  var labelFor = function(section, sections) {
    var idx = (sections || getAllSections()).indexOf(section);
    if (idx >= 0 && sectionLabels[idx]) return sectionLabels[idx];
    return displayKey(section);
  };
  var kindFor = function(section, sections) {
    var idx = (sections || getAllSections()).indexOf(section);
    return (idx >= 0 && sectionKinds[idx]) || "normal";
  };

  // Highlight palette by section kind: global = light purple, variant = green,
  // normal = blue.
  var COLORS = {
    normal: { solid: "#06b6d4", bg: "rgba(6,182,212,0.06)", active: "rgba(6,182,212,0.18)" },
    global: { solid: "#c084fc", bg: "rgba(192,132,252,0.10)", active: "rgba(192,132,252,0.22)" },
    variant: { solid: "#22c55e", bg: "rgba(34,197,94,0.08)", active: "rgba(34,197,94,0.20)" }
  };
  var applyColor = function(kind) {
    var c = COLORS[kind] || COLORS.normal;
    highlight.style.outline = "2px solid " + c.solid;
    highlight.style.background = c.bg;
    badge.style.background = c.solid;
  };

  var lastSection = null;
  var lastLabel = "";
  var lastKind = "normal";
  var rafPending = false;
  // True while an in-place render fetch/swap is in flight; suppresses hover so it can't re-show the overlay right before the swap snapshots it.
  var renderPending = false;

  // Document-relative coordinates (rect + scroll) on absolutely-positioned
  // nodes, so the browser scrolls the highlight together with the page
  // natively — no per-frame JS repositioning, no scroll lag.
  var positionHighlight = function(section) {
    var r = section.getBoundingClientRect();
    // A CSS zoom on <body> scales the overlay's lengths again; the rect is already zoomed.
    var z = document.body.currentCSSZoom || 1;
    var top = (r.top + window.scrollY) / z;
    var left = (r.left + window.scrollX) / z;
    highlight.style.display = "block";
    highlight.style.top = top + "px";
    highlight.style.left = left + "px";
    highlight.style.width = r.width / z + "px";
    highlight.style.height = r.height / z + "px";
    badge.textContent = lastLabel || displayKey(section);
    badge.style.display = "block";
    badge.style.top = Math.max(0, top - 20) + "px";
    badge.style.left = left + "px";
  };

  var moveHandler = function(e) {
    if (renderPending || rafPending) return;
    rafPending = true;
    var target = e.target;
    requestAnimationFrame(function() {
      rafPending = false;
      if (renderPending) return;
      if (!target || target === highlight || target === badge) return;
      var out = {};
      var section = findSection(target, out);
      if (section === lastSection) return;
      lastSection = section;
      if (!section) {
        highlight.style.display = "none";
        badge.style.display = "none";
        return;
      }
      lastLabel = labelFor(section, out.sections);
      lastKind = kindFor(section, out.sections);
      applyColor(lastKind);
      positionHighlight(section);
    });
  };
  document.addEventListener("mousemove", moveHandler, true);

  // Window scroll is handled natively by the absolute positioning above; this
  // only re-syncs on resize and on scrolls inside nested scroll containers
  // (capture=true catches those), where document coordinates do shift.
  var reposition = function() {
    if (!lastSection || highlight.style.display === "none") return;
    if (rafPending) return;
    rafPending = true;
    requestAnimationFrame(function() {
      rafPending = false;
      if (lastSection && highlight.style.display !== "none") positionHighlight(lastSection);
    });
  };
  window.addEventListener("scroll", reposition, { capture: true, passive: true });
  window.addEventListener("resize", reposition, { passive: true });

  var outHandler = function(e) {
    if (!e.relatedTarget || e.relatedTarget === document.documentElement) {
      highlight.style.display = "none";
      badge.style.display = "none";
      lastSection = null;
    }
  };
  document.addEventListener("mouseout", outHandler, true);

  var clickSeq = 0;

  // Blocks observes clicks to select sections in the side panel; it must not
  // cancel the iframe page's own handlers or native control behavior.
  var clickHandler = function(e) {
    var target = e.target;
    if (!target || target === highlight || target === badge) return;
    var out = {};
    var section = findSection(target, out);
    if (!section) return;

    var sectionIndex = out.sections.indexOf(section);
    var manifestKey = section.getAttribute("data-manifest-key") || "";

    var c = COLORS[lastKind] || COLORS.normal;
    highlight.style.outline = "2px solid " + c.solid;
    highlight.style.background = c.active;
    setTimeout(function() {
      highlight.style.background = c.bg;
    }, 400);

    clickSeq++;
    window.parent.postMessage({
      type: "cms-editor::section-clicked",
      payload: { sectionIndex: sectionIndex, manifestKey: manifestKey, clickSeq: clickSeq }
    }, "*");
  };
  document.addEventListener("click", clickHandler, true);

  /**
   * Navigation is disabled while editing: leaving the page would leave the
   * panel editing the previous page's sections. Only the default action of a
   * real navigation is cancelled, never propagation — in-page controls must
   * keep working (#5567).
   */
  var isNavigatingAnchor = function(a) {
    if (!a) return false;
    var href = a.getAttribute("href");
    if (!href) return false;
    var trimmed = href.trim();
    if (!trimmed || trimmed.charAt(0) === "#") return false;
    if (/^javascript:/i.test(trimmed)) return false;
    // Same document + fragment only scrolls.
    try {
      var url = new URL(a.href, location.href);
      if (url.href.split("#")[0] === location.href.split("#")[0]) return false;
    } catch (_) {}
    return true;
  };
  var navBlocker = function(e) {
    var el = e.target;
    var a = el && el.closest ? el.closest("a") : null;
    if (!isNavigatingAnchor(a)) return;
    e.preventDefault();
  };
  document.addEventListener("click", navBlocker, true);

  var submitBlocker = function(e) { e.preventDefault(); };
  document.addEventListener("submit", submitBlocker, true);

  // Fast Preview in-place render: POST merged decofile to /live/previews, swap the HTML in (document/window listeners survive; overlay nodes get re-attached).
  var renderCtrl = null;
  var renderQueue = Promise.resolve();
  var TRANSITION_TAG =
    "<style id=\\"deco-disable-transitions\\">* { transition: none !important; }</style></head>";

  // A skipped view transition rejects its promises with "AbortError:
  // Transition was skipped"; nobody else waits on them, so they are settled
  // here rather than left as uncaught errors in the page's console.
  var settleTransition = function(vt) {
    if (!vt) return;
    var ignore = function() {};
    if (vt.ready) vt.ready.catch(ignore);
    if (vt.updateCallbackDone) vt.updateCallbackDone.catch(ignore);
    if (vt.finished) vt.finished.catch(ignore);
  };

  // A site that opts into cross-document view transitions
  // (@view-transition { navigation: auto }) gets one on every reload a save
  // makes. When the next save navigates the frame before that transition
  // starts, the browser skips it and rejects the outgoing page's ready
  // promise, which only a pageswap listener can reach. Kept after deactivate:
  // settling changes nothing else, and the frame may still navigate.
  if (!window.__cmsEditorPageSwap) {
    window.__cmsEditorPageSwap = true;
    window.addEventListener("pageswap", function(e) {
      settleTransition(e.viewTransition);
    });
  }

  // A quick second save skips the running transition. Only finished says
  // when the swap is over, so the chain waits on it; the rest is settled.
  var runSwapTransition = function(swap) {
    if (typeof document.startViewTransition !== "function") {
      swap();
      return Promise.resolve();
    }
    var vt = document.startViewTransition(swap);
    settleTransition(vt);
    return vt.finished;
  };
  var renderInPlace = function(src, body) {
    if (renderCtrl) renderCtrl.abort();
    var ctrl = new AbortController();
    renderCtrl = ctrl;
    renderPending = true;
    highlight.style.display = "none";
    badge.style.display = "none";
    window.parent.postMessage({ type: "cms-editor::render-start" }, "*");
    renderQueue = renderQueue.then(function() {
      return fetch(src, {
        method: "POST",
        body: body,
        signal: ctrl.signal,
        headers: { accept: "text/html", "content-type": "application/json" }
      }).then(function(res) {
        if (!res.ok) throw new Error("render " + res.status);
        return res.text();
      }).then(function(html) {
        var swap = function() {
          document.documentElement.innerHTML = html.replace("</head>", TRANSITION_TAG);
          document.body.appendChild(highlight);
          document.body.appendChild(badge);
          // Old section is gone; hide the overlay until the next hover repositions it.
          highlight.style.display = "none";
          badge.style.display = "none";
          lastSection = null;
        };
        var headHtml = html.slice(html.indexOf("<head>"), html.indexOf("</head>") + 7);
        var doc = new DOMParser().parseFromString(headHtml, "text/html");
        var sheets = Array.prototype.map.call(
          doc.head.querySelectorAll("link[rel=\\"stylesheet\\"]"),
          function(el) { return el.href ? fetch(el.href).catch(function() {}) : null; }
        );
        return Promise.all(sheets).then(function() {
          return runSwapTransition(swap);
        });
      }).then(function() {
        var t = document.getElementById("deco-disable-transitions");
        if (t) t.remove();
        if (ctrl === renderCtrl) renderPending = false;
        window.parent.postMessage({ type: "cms-editor::render-end" }, "*");
      }).catch(function(err) {
        if (ctrl === renderCtrl) renderPending = false;
        if (err && err.name === "AbortError") return;
        window.parent.postMessage({ type: "cms-editor::render-error" }, "*");
      });
    });
  };

  window.addEventListener("message", function(e) {
    // Only Studio's own postMessage (source === this frame's parent) may drive the bridge — forged senders can't trigger the render fetch/swap.
    if (e.source !== window.parent) return;
    if (e.data && e.data.type === "cms-editor::render" && typeof e.data.src === "string") {
      renderInPlace(e.data.src, e.data.body);
      return;
    }
    if (e.data && e.data.type === "cms-editor::set-labels" && Array.isArray(e.data.labels)) {
      sectionLabels = e.data.labels;
      if (Array.isArray(e.data.kinds)) sectionKinds = e.data.kinds;
      if (Array.isArray(e.data.keys)) sectionCandidates = e.data.keys;
      if (lastSection) {
        lastLabel = labelFor(lastSection);
        lastKind = kindFor(lastSection);
        applyColor(lastKind);
        if (highlight.style.display !== "none") positionHighlight(lastSection);
      }
      return;
    }
    // Parent-driven clear: the cross-origin iframe can't self-detect a frame exit.
    if (e.data && e.data.type === "cms-editor::clear-hover") {
      highlight.style.display = "none";
      badge.style.display = "none";
      lastSection = null;
      return;
    }
    if (e.data && e.data.type === "cms-editor::deactivate") {
      highlight.remove();
      badge.remove();
      document.removeEventListener("mousemove", moveHandler, true);
      document.removeEventListener("mouseout", outHandler, true);
      document.removeEventListener("click", clickHandler, true);
      // Or the page stays unnavigable after leaving Blocks mode.
      document.removeEventListener("click", navBlocker, true);
      document.removeEventListener("submit", submitBlocker, true);
      window.removeEventListener("scroll", reposition, { capture: true });
      window.removeEventListener("resize", reposition);
      window.__cmsEditorActive = false;
    }
  });
})();`,ls=Object.freeze({ready:"deco:ready",load:"deco:load",loaded:"deco:loaded",loadError:"deco:load-error"}),ac="v1",oc="/studio-modules",Us=["wireframe","html-swap"];function ic(t,e,s){const n=new URL(`${oc}/${ac}/${e}.js`,t);return s&&n.searchParams.set("build",s),n.href}const lc=2e3;class cc{constructor(e){this.options=e,this.urls=Object.fromEntries(Us.map(s=>[s,ic(e.studioOrigin,s,e.build)]))}options;origin=null;urls;loaded=new Set;swapId=0;pendingSwap=null;startTimer=null;has(e){return this.loaded.has(e)}handle(e){const s=this.options.frame();if(!s||e.source!==s)return!1;const n=e.data;if(!n||typeof n.type!="string")return!1;if(n.type===ls.ready)return dc(e.origin)?(this.ready(e.origin),!0):!1;if(e.origin!==this.origin)return!1;const o=n;switch(o.type){case ls.loaded:{const c=this.nameOf(o.url);return c&&(this.loaded.add(c),this.options.onModulesChange?.(),c==="wireframe"&&this.options.onWireframeReady?.()),!0}case ls.loadError:{const c=this.nameOf(o.url);return c&&this.loaded.delete(c)&&this.options.onModulesChange?.(),c==="html-swap"&&this.failSwap(),!0}case"wireframe:hover":case"wireframe:select":return this.options.onWireframe?.(o),!0;case"html-swap:start":return this.pendingSwap?.id===o.id&&(this.pendingSwap.started=!0,this.clearStartTimer()),!0;case"html-swap:end":return this.pendingSwap?.id!==o.id||(this.pendingSwap=null,this.clearStartTimer(),this.options.onSwapEnd?.()),!0;case"html-swap:error":return this.pendingSwap?.id===o.id&&this.failSwap(),!0;default:return!1}}wireframe(e){return this.post("wireframe",e)}refresh(e){if(e!==void 0&&!this.isFrameOrigin(e))return!1;const s=++this.swapId,n=e?{type:"html-swap:refresh",id:s,url:e}:{type:"html-swap:refresh",id:s};return this.post("html-swap",n)?(this.pendingSwap={id:s,started:!1},this.clearStartTimer(),this.startTimer=setTimeout(()=>{this.startTimer=null,this.pendingSwap?.id===s&&!this.pendingSwap.started&&this.failSwap()},lc),!0):!1}dispose(){this.clearStartTimer(),this.pendingSwap=null,this.loaded.clear(),this.origin=null}ready(e){this.origin=e,this.loaded.size&&(this.loaded.clear(),this.options.onModulesChange?.()),this.pendingSwap&&(this.pendingSwap=null,this.clearStartTimer(),this.options.onSwapEnd?.());const s=this.options.frame();for(const n of Us)s?.postMessage({type:ls.load,url:this.urls[n]},e)}post(e,s){const n=this.options.frame();return!n||!this.origin||!this.loaded.has(e)?!1:(n.postMessage(s,this.origin),!0)}isFrameOrigin(e){try{return new URL(e).origin===this.origin}catch{return!1}}nameOf(e){return Us.find(s=>this.urls[s]===e)??null}failSwap(){this.clearStartTimer(),this.pendingSwap&&(this.pendingSwap=null,this.options.onSwapFailed?.())}clearStartTimer(){this.startTimer&&clearTimeout(this.startTimer),this.startTimer=null}}function dc(t){if(typeof t!="string"||t==="null")return!1;try{const e=new URL(t).origin;return e!=="null"&&e===t}catch{return!1}}function Qs(t,e,s=!1){let n=t,o=typeof n?.__resolveType=="string"?n.__resolveType:"";for(let c=0;o&&c<5;c++){const d=e[o];if(d&&typeof d=="object"&&"__resolveType"in d){const i=d.__resolveType;if(typeof i=="string"&&i&&i!==o){n=d,o=i;continue}}break}if(!o)return[];if(o.includes("flags/multivariate")||s&&So(o,s)){const c=Array.isArray(n.variants)?n.variants:[];if(c.length===0||c.every(a=>{const l=a?.rule;return Po(l?.__resolveType,s)}))return null;const i=[];for(const a of c){const l=jo(a,s);if(l&&typeof l=="object")for(const g of Qs(l,e,s)??[])i.includes(g)||i.push(g)}return i}if(Eo(o)){const c=n.section&&typeof n.section=="object"?Qs(n.section,e,s):[];return c===null?null:c.length?[o,...c]:[o]}return[o]}function ht(t){return t.replace(/[`*_]/g,"\\$&")}function uc(t,e){const s=[`The user selected an element on the live preview and asked: **"${ht(e.trim())}"**`,"","For text content changes, locate the correct source file and apply the change.","For code and CSS changes, understand which component the user is referring to and apply changes to the correct component.",""];t.manifestKey&&s.push(`**Section resolveType:** \`${ht(t.manifestKey)}\``,"","This is a Deco resolveType, not a literal file path. The leading segment is the app name, not a directory — the actual source file lives under a sections directory whose root varies by site (commonly `sections/`, `src/sections/`, or `site/sections/`). Locate the file by searching for the trailing path (e.g. the component filename), don't assume the resolveType is a valid path on disk.","");const n=`<${t.tag}${t.classes?` class="${ht(t.classes)}"`:""}>`;s.push(`**Clicked element:** \`${n}\``),t.parents&&s.push(`**DOM breadcrumb:** ${ht(t.parents)} > ${t.tag}`),t.text&&s.push(`**Text content:** "${ht(t.text)}"`),t.componentName&&s.push(`**Component name:** ${ht(t.componentName)}`);const o=t.html.replace(/```/g,"`` `");return s.push("","**HTML snippet:**","```html",o,"```"),s.push("","Please read the source file, locate the element, and apply the requested change."),s.join(`
`)}function fc(t,e,s=320,n=44,o=12){const{x:c,y:d}=t,{width:i,height:a}=e,l=Math.max(o,Math.min(c-s/2,i-s-o)),f=d/a>.68?Math.max(o,d-n-18):Math.min(d+18,a-n-o);return{leftPct:l/i*100,topPct:f/a*100}}function pc(t){const e=le.c(45),{element:s,onDismiss:n}=t,[o,c]=R.useState(""),d=R.useRef(null),{sendMessage:i}=$o(),{openSidePanel:a}=el(),l=Se();let g;e[0]!==s||e[1]!==o||e[2]!==n||e[3]!==a||e[4]!==i?(g=()=>{if(!o.trim())return;const I=uc(s,o);a(),i({parts:[{type:"text",text:I}]}),n()},e[0]=s,e[1]=o,e[2]=n,e[3]=a,e[4]=i,e[5]=g):g=e[5];const f=g;let p;e[6]!==s.position||e[7]!==s.viewport?(p=fc(s.position,s.viewport),e[6]=s.position,e[7]=s.viewport,e[8]=p):p=e[8];const m=p,v=`${m.leftPct}%`,y=`${m.topPct}%`;let h;e[9]!==v||e[10]!==y?(h={left:v,top:y,width:"320px"},e[9]=v,e[10]=y,e[11]=h):h=e[11];let x;e[12]!==f?(x=I=>{I.preventDefault(),f()},e[12]=f,e[13]=x):x=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=I=>c(I.target.value),e[14]=C):C=e[14];let b;e[15]!==n?(b=I=>{I.key==="Escape"&&n()},e[15]=n,e[16]=b):b=e[16];let w;e[17]!==l?(w=l("sandbox.visualEditorPrompt.inputPlaceholder"),e[17]=l,e[18]=w):w=e[18];let N;e[19]!==o||e[20]!==b||e[21]!==w?(N=r.jsx("input",{ref:d,autoFocus:!0,type:"text",value:o,onChange:C,onKeyDown:b,placeholder:w,className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"}),e[19]=o,e[20]=b,e[21]=w,e[22]=N):N=e[22];let k;e[23]!==o?(k=o.trim(),e[23]=o,e[24]=k):k=e[24];const S=!k;let E;e[25]!==l?(E=l("sandbox.visualEditorPrompt.sendButton"),e[25]=l,e[26]=E):E=e[26];let T;e[27]!==l?(T=l("sandbox.visualEditorPrompt.sendButton"),e[27]=l,e[28]=T):T=e[28];let B;e[29]!==T?(B=r.jsx("title",{children:T}),e[29]=T,e[30]=B):B=e[30];let A;e[31]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx("path",{d:"M5 9V1M1 5l4-4 4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e[31]=A):A=e[31];let L;e[32]!==B?(L=r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":"true",children:[B,A]}),e[32]=B,e[33]=L):L=e[33];let $;e[34]!==S||e[35]!==E||e[36]!==L?($=r.jsx("button",{type:"submit",disabled:S,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-lg bg-foreground text-background transition-opacity disabled:opacity-30",title:E,children:L}),e[34]=S,e[35]=E,e[36]=L,e[37]=$):$=e[37];let _;e[38]!==N||e[39]!==$||e[40]!==x?(_=r.jsxs("form",{className:"pointer-events-auto flex w-full items-center gap-1.5 rounded-xl glass px-3 py-1.5",onSubmit:x,children:[N,$]}),e[38]=N,e[39]=$,e[40]=x,e[41]=_):_=e[41];let F;return e[42]!==_||e[43]!==h?(F=r.jsx("div",{className:"absolute z-30 pointer-events-none",style:h,children:_}),e[42]=_,e[43]=h,e[44]=F):F=e[44],F}const zr="site-links",mc=/details?page|\bpdp\b/i,hc=/listingpage|\bplp\b/i;function gc(t,e,s){const n=new Set;for(const i of s)mc.test(i)&&n.add("product"),hc.test(i)&&n.add("category");const o=xt(pn(t)),c=o[o.length-1],d=o[o.length-2];return c?.type==="text"&&c.text==="/p"&&d?.type==="param"&&d.name===e&&n.add("product"),e==="*"&&o.some(i=>i.type==="param"&&i.name==="*")&&n.add("category"),n}const vc=["rosa","preto","pink","black"];function cs(t,e){const s=e.trim();return s?t(s):vc.flatMap(n=>t(n))}function xc(t,e){const s=e.trim(),n=[];/^\d+$/.test(s)&&n.push({resolveType:t,props:{ids:[s]}});const c=s.includes("-")&&!/\s/.test(s)?s.replace(/-+/g," "):s;return n.push({resolveType:t,props:{query:c,count:10}}),n}const Ca=new Set(["vtex","shopify","shopify-mcp","magento","wake","linx","linx-impulse","nuvemshop","vnda","wap","salesforce"]);function gn(t){return t.split("/")[0]??""}function bc(t){const e=new Set;for(const s of t){const n=gn(s);Ca.has(n)&&e.add(n)}return e}function yc(t,e){const s=gn(t);return!Ca.has(s)||e.size===0?!0:e.has(s)}const wc=[{kind:"product",test:t=>t==="vtex/loaders/intelligentSearch/productList.ts",clientFilter:!1,buildRequests:(t,e)=>cs(s=>xc(t,s),e),optionsFromPayload:ds},{kind:"product",test:t=>/magento\/.*products?\/list(\.tsx?)?$/i.test(t),clientFilter:!1,buildRequests:(t,e)=>cs(s=>[{resolveType:t,props:{props:{search:s,pageSize:10,currentPage:1}}}],e),optionsFromPayload:ds},{kind:"product",test:t=>/algolia\/.*products?\/(list|suggestions)(\.tsx?)?$/i.test(t),clientFilter:!1,buildRequests:(t,e)=>cs(s=>[{resolveType:t,props:{term:s,hitsPerPage:10}}],e),optionsFromPayload:ds},{kind:"product",test:t=>/products?\/list(\.tsx?)?$/i.test(t),clientFilter:!1,buildRequests:(t,e)=>cs(s=>[{resolveType:t,props:{query:s,term:s,count:10,hitsPerPage:10}}],e),optionsFromPayload:ds},{kind:"category",test:t=>t==="vtex/loaders/categories/tree.ts"||/categor(y|ies).*tree/i.test(t),clientFilter:!0,buildRequests:t=>[{resolveType:t,props:{}}],optionsFromPayload:Cc}];function kc(t,e,s=new Set){const n=[...e],o=i=>{const a=[];for(const l of wc){if(l.kind!==i)continue;const g=n.find(f=>l.test(f)&&yc(f,s));g&&a.push({cand:l,resolveType:g})}return a.find(l=>s.has(gn(l.resolveType)))??a[0]},c=(i,a,l)=>({kind:i.kind,id:`${i.kind}:${a}`,resolveType:a,clientFilter:i.clientFilter,isFallback:l,buildRequests:g=>i.buildRequests(a,g),optionsFromPayload:i.optionsFromPayload}),d=[];for(const i of["product","category"]){if(!t.has(i))continue;const a=o(i);a&&d.push(c(a.cand,a.resolveType,!1))}return t.size>0&&d.push(Sc(t.has("category")?"category":"product")),d}function Sc(t){return{kind:t,id:zr,resolveType:zr,clientFilter:!0,isFallback:!0,homepageLinks:!0,optionsFromPayload:(e,s)=>Oc(e,s)}}function ot(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Pc(t,e,s){const n=new Set,o=new Set,c=d=>{if(Array.isArray(d)){for(const l of d)c(l);return}const i=ot(d);if(!i)return;const a=i.__resolveType;if(typeof a=="string"){if(s(a))n.add(a);else if(a in e&&!o.has(a)){o.add(a);const l=ot(e[a])?.__resolveType;typeof l=="string"&&s(l)&&n.add(a),c(e[a])}}for(const l of Object.values(i))c(l)};return c(t),n}function Ta(t){const e=new Set,s=[];for(const n of t)for(const o of n)e.has(o.value)||(e.add(o.value),s.push(o));return s}function Ra(t){try{return decodeURIComponent(t)}catch{return t}}function jc(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ec(t){const e=[];let s="^";for(const n of t)n.type==="text"?s+=jc(n.text):(e.push(n.name),s+=n.name==="*"?"(.+)":"([^/]+)");return{pattern:new RegExp(`${s}$`),order:e}}function vn(t,e,s){if(typeof t!="string"||!t)return null;let n;try{n=new URL(t,"https://placeholder.invalid").pathname}catch{return null}n=n.replace(/\/+$/,"");const o=xt(pn(e)),{pattern:c,order:d}=Ec(o),i=d.indexOf(s);if(i===-1)return null;const a=n.match(c);if(!a)return null;const l=a[i+1]?.replace(/^\/+|\/+$/g,"");return l?Ra(l):null}function ds(t,e){const s=ot(t),n=Array.isArray(t)?t:Array.isArray(s?.products)?s.products:Array.isArray(s?.list)?s.list:[],o=[],c=new Set;for(const d of n){const i=ot(d);if(!i)continue;const a=vn(i.url,e.template,e.paramName);if(!a||c.has(a))continue;c.add(a);const l=ot(i.isVariantOf),g=typeof l?.name=="string"&&l.name||typeof i.name=="string"&&i.name||a,f=Array.isArray(i.image)?ot(i.image[0]):null,p=typeof f?.url=="string"?f.url:void 0;o.push({value:a,label:g,image:p})}return o}function Nc(t){if(typeof t!="string"||!t)return null;let e;try{e=new URL(t,"https://placeholder.invalid").pathname}catch{return null}const s=e.replace(/^\/+|\/+$/g,"");return s?Ra(s):null}function Cc(t){const e=[],s=new Set,n=(o,c)=>{const d=ot(o);if(!d)return;const i=typeof d.name=="string"&&d.name?d.name:"",a=i?[...c,i]:c,l=Nc(d.url);if(l&&!s.has(l)&&(s.add(l),e.push({value:l,label:a.join(" › ")||l})),Array.isArray(d.children))for(const g of d.children)n(g,a)};if(Array.isArray(t))for(const o of t)n(o,[]);return e}const Tc=new Set(["login","logout","signin","sign-in","signup","sign-up","register","account","myaccount","my-account","minha-conta","conta","cart","carrinho","checkout","wishlist","favoritos","favorites","orders","pedidos","help","hc","sac","atendimento","contato","contact","institucional","newsletter","customer","sales","catalogsearch","search","busca","privacy-policy-cookie-restriction-mode"]);function Rc(t){return(t.split("/").filter(Boolean).pop()??t).replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,s=>s.toUpperCase())}function Lc(t){if(typeof t!="string"||!t)return[];const e=[],s=/<a\b[^>]*?\bhref="([^"]+)"[^>]*>([\s\S]*?)<\/a>/gi;let n,o=0;for(;(n=s.exec(t))!==null&&o++<5e3;){const c=n[1]??"",d=(n[2]??"").replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim();e.push({href:c,text:d})}return e}function Ac(t){if(typeof t!="string"||!t)return[];const e=[],s=new Set,n=/"@type":"Product"[\s\S]{0,600}?(?:"url"|\burl):"([^"]+)"[\s\S]{0,300}?(?:"name"|\bname):"([^"]+)"/g,o=/(?:"image"|\bimage):\s*\[\s*\{[\s\S]{0,400}?(?:"url"|\burl):"([^"]+)"/;let c,d=0;for(;(c=n.exec(t))!==null&&d++<3e3;){const i=(c[1]??"").replace(/\\\//g,"/");if(!i||s.has(i))continue;s.add(i);const a=t.slice(c.index,c.index+900).match(o)?.[1]?.replace(/\\\//g,"/");e.push({url:i,name:c[2]??"",image:a||void 0})}return e}function Oc(t,e){const s=[],n=new Set,o=(c,d,i,a)=>{if(s.length>=200)return;const l=vn(c,e.template,e.paramName);!l||n.has(l)||e.paramName==="*"&&/(^|\/)p$/.test(l)||i==="category"&&Tc.has(l.split("/")[0]??"")||(n.add(l),s.push({value:l,label:d&&d.length<=80?d:Rc(l),kind:i,image:a}))};for(const{url:c,name:d,image:i}of Ac(t))o(c,d,"product",i);for(const{href:c,text:d}of Lc(t))c.startsWith("/")&&!c.startsWith("//")&&o(c,d,"category");return s}function zt(t,e,s=50){const n=e.trim().toLowerCase();return(n?t.filter(c=>c.label.toLowerCase().includes(n)||c.value.toLowerCase().includes(n)):t).slice(0,s)}const La=1e4;function _c(t){return{product:{noun:t("sandbox.pathParamPickerChip.kindProductNoun"),heading:t("sandbox.pathParamPickerChip.kindProductHeading")},category:{noun:t("sandbox.pathParamPickerChip.kindCategoryNoun"),heading:t("sandbox.pathParamPickerChip.kindCategoryHeading")}}}async function $c(t,{resolveType:e,props:s}){const n=await fetch(li(t),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({__resolveType:e,...s}),signal:AbortSignal.timeout(La)});if(!n.ok)throw new Error(`Failed to fetch options: ${n.status}`);return n.json()}async function Ir(t,e){const s=await fetch(ci(t,e),{signal:AbortSignal.timeout(La)});if(!s.ok)throw new Error(`Failed to fetch page: ${s.status}`);return s.text()}async function Fc(t,e,s){const n=e.optionsFromPayload(await Ir(t,"/"),s),o=n.find(d=>d.kind==="category");if(!o)return n;const c=Be(s.template,{[s.paramName]:o.value});if(c==="/")return n;try{const d=e.optionsFromPayload(await Ir(t,c),s).filter(i=>i.kind==="product");return Ta([n,d])}catch{return n}}function Dc(t,e,s){return sn.sandboxInvoke(`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`,`path-param-${e.id}:${e.clientFilter?"":s}`)}async function Bc(t,e,s,n){if(e.homepageLinks)return Fc(t,e,n);const o=e.buildRequests?.(s)??[];if(o.length===0)return[];const c=await Promise.allSettled(o.map(i=>$c(t,i))),d=c.filter(i=>i.status==="fulfilled").map(i=>i.value);if(d.length===0){const i=c.find(a=>a.status==="rejected");throw i?i.reason:new Error("Failed to fetch options")}return Ta(d.map(i=>e.optionsFromPayload(i,n)))}function Xs(t,e,s,n,o){return{queryKey:Dc(t,e,s),queryFn:()=>Bc(t,e,s,n),enabled:o,staleTime:6e4,retry:1}}function It(t){const e=le.c(16),{heading:s,iconKind:n,options:o,template:c,paramName:d,keyPrefix:i,onSelect:a}=t;if(o.length===0)return null;let l;if(e[0]!==n||e[1]!==i||e[2]!==a||e[3]!==o||e[4]!==d||e[5]!==c){let f;e[7]!==n||e[8]!==i||e[9]!==a||e[10]!==d||e[11]!==c?(f=p=>r.jsxs(qe,{value:`${i}:${p.value}`,className:"gap-3 py-2",onSelect:()=>a(p.value),children:[n==="product"&&r.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-muted",children:p.image?r.jsx("img",{src:p.image,alt:"",referrerPolicy:"no-referrer",className:"h-full w-full object-cover"}):r.jsx(on,{size:14,className:"text-muted-foreground"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block truncate text-sm",children:p.label}),r.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:Be(c,{[d]:p.value})})]})]},`${i}:${p.value}`),e[7]=n,e[8]=i,e[9]=a,e[10]=d,e[11]=c,e[12]=f):f=e[12],l=o.map(f),e[0]=n,e[1]=i,e[2]=a,e[3]=o,e[4]=d,e[5]=c,e[6]=l}else l=e[6];let g;return e[13]!==s||e[14]!==l?(g=r.jsx(We,{heading:s,children:l}),e[13]=s,e[14]=l,e[15]=g):g=e[15],g}function Kr(t){const e=le.c(2),{text:s}=t;let n;return e[0]!==s?(n=r.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:s}),e[0]=s,e[1]=n):n=e[1],n}function Mc(t){const e=le.c(52),{sources:s,template:n,paramName:o,value:c,sandboxRef:d,onCommit:i}=t,a=Se(),[l,g]=R.useState(!1),[f,p]=R.useState(""),[m,v]=R.useState(""),y=R.useRef(null),h=o==="*"?a("sandbox.preview.catchAllParamLabel"):`:${o}`,x=_c(a),b=[...new Set(s.map(re=>x[re.kind].noun))].join(" or ");let w;e[0]!==a||e[1]!==b?(w=a("sandbox.pathParamPickerChip.searchPlaceholder",{options:b}),e[0]=a,e[1]=b,e[2]=w):w=e[2];const N=w,k={template:n,paramName:o};let S;e[3]!==f?(S=(re,ue)=>({source:re,query:ue,options:re.clientFilter?zt(ue.data??[],f):ue.data??[]}),e[3]=f,e[4]=S):S=e[4];const E=S,T=s.filter(qc),B=s.filter(Wc),A=Js({queries:T.map(re=>Xs(d,re,m,k,l))});let L;e[5]!==A||e[6]!==E?(L=(re,ue)=>E(re,A[ue]),e[5]=A,e[6]=E,e[7]=L):L=e[7];const $=T.map(L),_=$.length===0||$.every(Vc),F=Js({queries:B.map(re=>Xs(d,re,m,k,l&&_))});let I;e[8]!==F||e[9]!==E?(I=(re,ue)=>E(re,F[ue]),e[8]=F,e[9]=E,e[10]=I):I=e[10];const J=B.map(I),W=_?J:$,Y=W.length===1&&W[0]?.source.homepageLinks?W[0]:null,Q=Y&&!Y.query.isLoading&&!Y.query.isError?Y?.query.data??[]:[],V=zt(Q.filter(Hc),f),ee=zt(Q.filter(Uc),f),q=V.length>0&&ee.length>0,K=re=>{g(re),y.current&&clearTimeout(y.current),p(re?c:""),v(re?c:"")};let z;e[11]===Symbol.for("react.memo_cache_sentinel")?(z=re=>{p(re),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{v(re)},300)},e[11]=z):z=e[11];const j=z,O=re=>{i(re),K(!1)},D=mn(f),H=Be(n,{[o]:D}),Z=tn,te=en,M="flex h-[85svh] flex-col gap-0 overflow-hidden p-0 sm:h-[520px] sm:max-w-[560px]",X=Kc;let se;e[12]!==h||e[13]!==a?(se=a("sandbox.pathParamPickerChip.pickValueTitle",{paramLabel:h}),e[12]=h,e[13]=a,e[14]=se):se=e[14];let ae;e[15]!==se?(ae=r.jsx(nn,{className:"sr-only",children:r.jsx(rn,{children:se})}),e[15]=se,e[16]=ae):ae=e[16];let me;e[17]===Symbol.for("react.memo_cache_sentinel")?(me=r.jsx(on,{size:16,className:"shrink-0 text-foreground"}),e[17]=me):me=e[17];let pe;e[18]!==a?(pe=a("sandbox.pathParamPickerChip.pickValueHeading"),e[18]=a,e[19]=pe):pe=e[19];let be;e[20]!==h?(be=r.jsx("span",{className:"rounded-sm bg-special/15 px-1 py-0.5 font-mono text-xs text-special",children:h}),e[20]=h,e[21]=be):be=e[21];let ge;e[22]!==pe||e[23]!==be?(ge=r.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-border px-4",children:[me,r.jsxs("span",{className:"text-sm font-medium text-foreground",children:[pe," ",be]})]}),e[22]=pe,e[23]=be,e[24]=ge):ge=e[24];const ve=cn,Pe=!1,fe="min-h-0 flex-1";let de;e[25]!==N||e[26]!==f?(de=r.jsx(dn,{autoFocus:!0,placeholder:N,value:f,onValueChange:j}),e[25]=N,e[26]=f,e[27]=de):de=e[27];const Le=ln,Ie="flex max-h-none min-h-0 flex-1 flex-col overflow-hidden";let Ke;e[28]!==a?(Ke=a("sandbox.pathParamPickerChip.noResults"),e[28]=a,e[29]=Ke):Ke=e[29];let Me;e[30]!==Ke?(Me=r.jsx(un,{children:Ke}),e[30]=Ke,e[31]=Me):Me=e[31];const yt=D&&r.jsx(We,{className:"shrink-0",children:r.jsxs(qe,{value:`__raw__:${D}`,className:"gap-3 py-2",onSelect:()=>O(D),children:[r.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-dashed border-border bg-muted",children:r.jsx(ga,{size:14,className:"text-muted-foreground"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block truncate text-sm",children:a("sandbox.pathParamPickerChip.useRawValue",{rawTerm:D,paramLabel:h})}),r.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:H})]})]})}),he=q?r.jsxs("div",{className:"flex min-h-0 flex-1",children:[r.jsx("div",{className:"min-w-0 flex-1 overflow-y-auto border-r border-border",children:r.jsx(It,{heading:x.category.heading,iconKind:"category",options:V,template:n,paramName:o,keyPrefix:`${Y?.source.id}:cat`,onSelect:O})}),r.jsx("div",{className:"min-w-0 flex-1 overflow-y-auto",children:r.jsx(It,{heading:x.product.heading,iconKind:"product",options:ee,template:n,paramName:o,keyPrefix:`${Y?.source.id}:prod`,onSelect:O})})]}):r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:W.map(re=>{const{source:ue,query:Ge,options:wt}=re,{noun:Je}=x[ue.kind];if(Ge.isLoading)return r.jsx(Kr,{text:a("sandbox.pathParamPickerChip.loading",{noun:Je})},ue.id);if(Ge.isError)return r.jsx(Kr,{text:a("sandbox.pathParamPickerChip.couldNotLoad")},ue.id);if(ue.homepageLinks){const Ht=Ge.data??[];return r.jsxs(R.Fragment,{children:[r.jsx(It,{heading:x.category.heading,iconKind:"category",options:zt(Ht.filter(Ic),f),template:n,paramName:o,keyPrefix:`${ue.id}:cat`,onSelect:O}),r.jsx(It,{heading:x.product.heading,iconKind:"product",options:zt(Ht.filter(zc),f),template:n,paramName:o,keyPrefix:`${ue.id}:prod`,onSelect:O})]},ue.id)}return r.jsx(It,{heading:W.length>1?x[ue.kind].heading:void 0,iconKind:ue.kind,options:wt,template:n,paramName:o,keyPrefix:ue.id,onSelect:O},ue.id)})});let $e;e[32]!==Le||e[33]!==Me||e[34]!==yt||e[35]!==he?($e=r.jsxs(Le,{className:Ie,children:[Me,yt,he]}),e[32]=Le,e[33]=Me,e[34]=yt,e[35]=he,e[36]=$e):$e=e[36];let xe;e[37]!==ve||e[38]!==de||e[39]!==$e?(xe=r.jsxs(ve,{shouldFilter:Pe,className:fe,children:[de,$e]}),e[37]=ve,e[38]=de,e[39]=$e,e[40]=xe):xe=e[40];let Ue;e[41]!==te||e[42]!==ae||e[43]!==ge||e[44]!==xe||e[45]!==X?(Ue=r.jsxs(te,{className:M,onClick:X,children:[ae,ge,xe]}),e[41]=te,e[42]=ae,e[43]=ge,e[44]=xe,e[45]=X,e[46]=Ue):Ue=e[46];let Ae;return e[47]!==Z||e[48]!==K||e[49]!==l||e[50]!==Ue?(Ae=r.jsx(Z,{open:l,onOpenChange:K,children:Ue}),e[47]=Z,e[48]=K,e[49]=l,e[50]=Ue,e[51]=Ae):Ae=e[51],r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",title:a("sandbox.pathParamPickerChip.buttonTitle",{paramLabel:h}),className:"max-w-64 shrink-0 cursor-pointer truncate rounded-lg bg-special/15 px-1 py-0.5 text-xs text-special hover:bg-special/25",onClick:re=>{re.stopPropagation(),K(!0)},children:c||h}),Ae]})}function zc(t){return t.kind==="product"}function Ic(t){return t.kind!=="product"}function Kc(t){return t.stopPropagation()}function Uc(t){return t.kind==="product"}function Hc(t){return t.kind!=="product"}function Vc(t){return!t.query.isLoading&&(t.query.isError||t.options.length===0)}function Wc(t){return t.isFallback}function qc(t){return!t.isFallback}function Gc(t){const e=le.c(8),{sources:s,template:n,paramName:o,sandboxRef:c,onFill:d}=t;let i,a;if(e[0]!==o||e[1]!==c||e[2]!==s||e[3]!==n){const m={template:n,paramName:o},v=s.filter(Jc);a=Js,i=v.map(y=>Xs(c,y,"",m,!0)),e[0]=o,e[1]=c,e[2]=s,e[3]=n,e[4]=i,e[5]=a}else i=e[4],a=e[5];let l;e[6]!==i?(l={queries:i},e[6]=i,e[7]=l):l=e[7];const g=a(l),[f,p]=R.useState(!1);if(!f)for(const m of g){if(m.isLoading)break;const v=m.data?.[0];if(v){p(!0),queueMicrotask(()=>d(v.value));break}}return null}function Jc(t){return!t.isFallback}function Yc(t){const e=le.c(31),{name:s,value:n,onCommit:o}=t,c=Se(),[d,i]=R.useState(n),[a,l]=R.useState(!1),g=R.useRef(!1);let f;e[0]!==s||e[1]!==c?(f=s==="*"?c("sandbox.preview.catchAllParamLabel"):`:${s}`,e[0]=s,e[1]=c,e[2]=f):f=e[2];const p=f,m=d||p;let v;e[3]!==m?(v=r.jsx("span",{"aria-hidden":!0,className:"invisible whitespace-pre px-1 py-0.5 text-xs",children:m}),e[3]=m,e[4]=v):v=e[4];let y;e[5]!==p||e[6]!==c?(y=c("sandbox.preview.valueForParam",{label:p}),e[5]=p,e[6]=c,e[7]=y):y=e[7];let h,x;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=E=>i(E.target.value),x=()=>l(!0),e[8]=h,e[9]=x):(h=e[8],x=e[9]);let C;e[10]!==n?(C=E=>{E.key==="Enter"&&E.currentTarget.blur(),E.key==="Escape"&&(g.current=!0,i(n),E.currentTarget.blur())},e[10]=n,e[11]=C):C=e[11];let b;e[12]!==d||e[13]!==o||e[14]!==n?(b=()=>{if(l(!1),g.current){g.current=!1;return}const E=mn(d);i(E),E!==n&&o(E)},e[12]=d,e[13]=o,e[14]=n,e[15]=b):b=e[15];let w;e[16]!==d||e[17]!==p||e[18]!==y||e[19]!==C||e[20]!==b?(w=r.jsx("input",{type:"text",value:d,placeholder:p,title:y,spellCheck:!1,className:"absolute inset-0 rounded-sm bg-special/15 px-1 text-xs text-special outline-none placeholder:text-special/60 focus:bg-special/25",onClick:Qc,onChange:h,onFocus:x,onKeyDown:C,onBlur:b}),e[16]=d,e[17]=p,e[18]=y,e[19]=C,e[20]=b,e[21]=w):w=e[21];let N;e[22]!==v||e[23]!==w?(N=r.jsxs("span",{className:"relative inline-flex max-w-64 shrink-0 items-center overflow-hidden",children:[v,w]}),e[22]=v,e[23]=w,e[24]=N):N=e[24];let k;e[25]!==a||e[26]!==c?(k=a&&r.jsxs("span",{className:"pointer-events-none ml-1.5 flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-border bg-muted px-1 py-0.5 text-2xs text-muted-foreground",children:[r.jsx(Ko,{size:10}),c("sandbox.preview.enterToGo")]}),e[25]=a,e[26]=c,e[27]=k):k=e[27];let S;return e[28]!==k||e[29]!==N?(S=r.jsxs(r.Fragment,{children:[N,k]}),e[28]=k,e[29]=N,e[30]=S):S=e[30],S}function Qc(t){return t.stopPropagation()}const Xc=/^(?:autor|author|authorSlug)$/;function Ur(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}const us=t=>typeof t=="string"?t:"";function Zc(t,e,s,n=new Date().toISOString().slice(0,10)){const o=Ti(e),[c]=xt(e);if(o.length===0||o.includes("*")||c?.type!=="text"||c.text==="/")return[];const d=sl(t),i=m=>d[m].map(v=>({label:v.label,data:Ur(Ur(t[v.key])[rl[m]])})),a=[],l=i("posts").filter(({data:m})=>nl(m)==="published"&&us(m.date).slice(0,10)<=n).sort((m,v)=>us(v.data.date).localeCompare(us(m.data.date)));for(const{label:m,data:v}of l)a.push({label:m,path:ol(t,v,s)});for(const{label:m,data:v}of i("categories"))a.push({label:m,path:il(t,v,s)});const g=o.find(m=>Xc.test(m));if(g)for(const{label:m,data:v}of i("authors")){const y=us(v.slug);a.push({label:m,path:y?Be(e,{[g]:y}):null})}const f=[],p=new Set;for(const{label:m,path:v}of a){if(!v)continue;const y={};for(const x of o){const C=vn(v,e,x);if(!C)break;y[x]=C}if(Object.keys(y).length!==o.length)continue;const h=Be(e,y);p.has(h)||(p.add(h),f.push({label:m,values:y}))}return f}function ed(t){const e=le.c(96),{paramName:s,template:n,value:o,options:c,onPick:d,onCommit:i}=t,a=Se(),[l,g]=R.useState(!1),[f,p]=R.useState(""),m=`:${s}`;let v;if(e[0]!==c||e[1]!==f){const K=f.trim().toLowerCase();v=K?c.filter(z=>z.label.toLowerCase().includes(K)||Object.values(z.values).some(j=>j.toLowerCase().includes(K))):c,e[0]=c,e[1]=f,e[2]=v}else v=e[2];const y=v;let h,x,C,b,w,N,k,S,E,T,B,A,L,$,_,F,I,J;if(e[3]!==i||e[4]!==l||e[5]!==m||e[6]!==f||e[7]!==a||e[8]!==o){const K=mn(f);let z;e[27]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{g(!1),p("")},e[27]=z):z=e[27],w=z;let j;e[28]!==m||e[29]!==a?(j=a("sandbox.pathParamPickerChip.buttonTitle",{paramLabel:m}),e[28]=m,e[29]=a,e[30]=j):j=e[30];let O;e[31]===Symbol.for("react.memo_cache_sentinel")?(O=ae=>{ae.stopPropagation(),g(!0)},e[31]=O):O=e[31];const D=o||m;e[32]!==j||e[33]!==D?(T=r.jsx("button",{type:"button",title:j,className:"max-w-64 shrink-0 cursor-pointer truncate rounded-lg bg-special/15 px-1 py-0.5 text-xs text-special hover:bg-special/25",onClick:O,children:D}),e[32]=j,e[33]=D,e[34]=T):T=e[34],b=tn,S=l,e[35]===Symbol.for("react.memo_cache_sentinel")?(E=ae=>ae?g(!0):w(),e[35]=E):E=e[35],C=en,I="flex h-[85svh] flex-col gap-0 overflow-hidden p-0 sm:h-[520px] sm:max-w-[560px]",J=td;let H;e[36]!==m||e[37]!==a?(H=a("sandbox.pathParamPickerChip.pickValueTitle",{paramLabel:m}),e[36]=m,e[37]=a,e[38]=H):H=e[38],e[39]!==H?(N=r.jsx(nn,{className:"sr-only",children:r.jsx(rn,{children:H})}),e[39]=H,e[40]=N):N=e[40];let Z;e[41]===Symbol.for("react.memo_cache_sentinel")?(Z=r.jsx(on,{size:16,className:"shrink-0 text-foreground"}),e[41]=Z):Z=e[41];let te;e[42]!==a?(te=a("sandbox.pathParamPickerChip.pickValueHeading"),e[42]=a,e[43]=te):te=e[43];let M;e[44]!==m?(M=r.jsx("span",{className:"rounded-sm bg-special/15 px-1 py-0.5 font-mono text-xs text-special",children:m}),e[44]=m,e[45]=M):M=e[45],e[46]!==te||e[47]!==M?(k=r.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-border px-4",children:[Z,r.jsxs("span",{className:"text-sm font-medium text-foreground",children:[te," ",M]})]}),e[46]=te,e[47]=M,e[48]=k):k=e[48],x=cn,$=!1,_="min-h-0 flex-1";let X;e[49]!==a?(X=a("sandbox.pathParamPickerChip.searchBlogPlaceholder"),e[49]=a,e[50]=X):X=e[50],e[51]!==f||e[52]!==X?(F=r.jsx(dn,{autoFocus:!0,placeholder:X,value:f,onValueChange:p}),e[51]=f,e[52]=X,e[53]=F):F=e[53],h=ln,B="max-h-none min-h-0 flex-1 overflow-y-auto";let se;e[54]!==a?(se=a("sandbox.pathParamPickerChip.noResults"),e[54]=a,e[55]=se):se=e[55],e[56]!==se?(A=r.jsx(un,{children:se}),e[56]=se,e[57]=A):A=e[57],L=K&&r.jsx(We,{children:r.jsxs(qe,{value:`__raw__:${K}`,className:"gap-3 py-2",onSelect:()=>{i(K),w()},children:[r.jsx(ga,{size:14,className:"shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:a("sandbox.pathParamPickerChip.useRawValue",{rawTerm:K,paramLabel:m})})]})}),e[3]=i,e[4]=l,e[5]=m,e[6]=f,e[7]=a,e[8]=o,e[9]=h,e[10]=x,e[11]=C,e[12]=b,e[13]=w,e[14]=N,e[15]=k,e[16]=S,e[17]=E,e[18]=T,e[19]=B,e[20]=A,e[21]=L,e[22]=$,e[23]=_,e[24]=F,e[25]=I,e[26]=J}else h=e[9],x=e[10],C=e[11],b=e[12],w=e[13],N=e[14],k=e[15],S=e[16],E=e[17],T=e[18],B=e[19],A=e[20],L=e[21],$=e[22],_=e[23],F=e[24],I=e[25],J=e[26];let W;if(e[58]!==w||e[59]!==d||e[60]!==n||e[61]!==y){let K;e[63]!==w||e[64]!==d||e[65]!==n?(K=z=>{const j=Be(n,z.values);return r.jsx(qe,{value:j,className:"py-2",onSelect:()=>{d(z.values),w()},children:r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block truncate text-sm",children:z.label}),r.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:j})]})},j)},e[63]=w,e[64]=d,e[65]=n,e[66]=K):K=e[66],W=y.map(K),e[58]=w,e[59]=d,e[60]=n,e[61]=y,e[62]=W}else W=e[62];let Y;e[67]!==W?(Y=r.jsx(We,{children:W}),e[67]=W,e[68]=Y):Y=e[68];let G;e[69]!==h||e[70]!==Y||e[71]!==B||e[72]!==A||e[73]!==L?(G=r.jsxs(h,{className:B,children:[A,L,Y]}),e[69]=h,e[70]=Y,e[71]=B,e[72]=A,e[73]=L,e[74]=G):G=e[74];let Q;e[75]!==x||e[76]!==G||e[77]!==$||e[78]!==_||e[79]!==F?(Q=r.jsxs(x,{shouldFilter:$,className:_,children:[F,G]}),e[75]=x,e[76]=G,e[77]=$,e[78]=_,e[79]=F,e[80]=Q):Q=e[80];let V;e[81]!==C||e[82]!==N||e[83]!==k||e[84]!==Q||e[85]!==I||e[86]!==J?(V=r.jsxs(C,{className:I,onClick:J,children:[N,k,Q]}),e[81]=C,e[82]=N,e[83]=k,e[84]=Q,e[85]=I,e[86]=J,e[87]=V):V=e[87];let ee;e[88]!==b||e[89]!==S||e[90]!==E||e[91]!==V?(ee=r.jsx(b,{open:S,onOpenChange:E,children:V}),e[88]=b,e[89]=S,e[90]=E,e[91]=V,e[92]=ee):ee=e[92];let q;return e[93]!==T||e[94]!==ee?(q=r.jsxs(r.Fragment,{children:[T,ee]}),e[93]=T,e[94]=ee,e[95]=q):q=e[95],q}function td(t){return t.stopPropagation()}function sd(t){if(t.activeGlobalSectionName)return t.activeGlobalSectionName;const e=t.iframeBase;if(!e)return t.noServerLabel;try{const s=new URL(e),n=t.resolvedPath==="/"?"":t.resolvedPath;return`${s.host}${n}`}catch{return e}}function nd(t){return t.previewSurfaceActive&&(t.daemonReady||t.production||!!t.servePreviewUrl)}function rd(t){return t.showPreviewToolbar&&(t.contentEditingEnabled||t.hasFrameworkRoutes)}function ad(t){return t.v8?null:t.production||t.localPreview?{type:"editor::inject",args:{script:t.script}}:{type:"visual-editor::activate",script:t.script}}function od(t){return t.v8?null:{type:"visual-editor::activate",script:t.script}}class Aa extends Error{constructor(){super("The site's schema isn't loaded yet"),this.name="PageSchemaNotReadyError"}}async function id(t,e){if(t)return t;const s=await e?.().catch(()=>null);if(!s)throw new Aa;return s}async function ld(t,e,s){return s?Tr(t,e,await id(s.meta,s.loadMeta)):Tr(t,e)}function cd(t){const e=le.c(5);let s;e[0]!==t?(s=t??{orgSlug:"",virtualMcpId:"",branch:""},e[0]=t,e[1]=s):s=e[1];const n=ll(s);let o;return e[2]!==t||e[3]!==n?(o={mutationFn:async c=>{const{name:d,path:i,template:a,schema:l}=c;if(!t?.virtualMcpId||!t.branch)throw new Error("Sandbox not ready");const g=Vi(d),f=a?{...a,name:d,path:i}:await ld(d,i,l);return await n.mutateAsync({blockKey:g,data:f}),{key:g,name:d,path:i}}},e[2]=t,e[3]=n,e[4]=o):o=e[4],No(o)}function dd(t){const e=le.c(89),{open:s,onOpenChange:n,isPending:o,error:c,templates:d,onSubmit:i}=t,a=o===void 0?!1:o,l=Se();let g;e[0]!==l?(g=l("sectionsEditor.createPageModal.defaultPageName"),e[0]=l,e[1]=g):g=e[1];const[f,p]=R.useState(g);let m;e[2]!==l?(m=l("sectionsEditor.createPageModal.defaultPagePath"),e[2]=l,e[3]=m):m=e[3];const[v,y]=R.useState(m),[h,x]=R.useState(Ds),[C,b]=R.useState(null),[w,N]=R.useState(s);s!==w&&(N(s),s&&(p(l("sectionsEditor.createPageModal.defaultPageName")),y(l("sectionsEditor.createPageModal.defaultPagePath")),x(Ds),b(null)));const k=!!d?.length;let S;e[4]!==a||e[5]!==n?(S=pe=>{!pe&&!a&&(b(null),n(!1))},e[4]=a,e[5]=n,e[6]=S):S=e[6];const E=S;let T;e[7]!==a||e[8]!==f||e[9]!==i||e[10]!==v||e[11]!==k||e[12]!==h?(T=async pe=>{pe.preventDefault();const be=f.trim(),ge=v.trim();if(!be||!ge||a)return;const ve=ma(ge);if(ve){b(ve);return}b(null),await i({name:be,path:ge,templateKey:k&&h!==Ds?h:null})},e[7]=a,e[8]=f,e[9]=i,e[10]=v,e[11]=k,e[12]=h,e[13]=T):T=e[13];const B=T,A=C??c;let L;e[14]!==l?(L=l("sectionsEditor.createPageModal.title"),e[14]=l,e[15]=L):L=e[15];let $;e[16]!==L?($=r.jsx(nn,{children:r.jsx(rn,{children:L})}),e[16]=L,e[17]=$):$=e[17];let _;e[18]!==l?(_=l("sectionsEditor.createPageModal.nameLabel"),e[18]=l,e[19]=_):_=e[19];let F;e[20]!==_?(F=r.jsx("label",{htmlFor:"new-page-name",className:"text-xs font-medium text-muted-foreground",children:_}),e[20]=_,e[21]=F):F=e[21];let I;e[22]===Symbol.for("react.memo_cache_sentinel")?(I=pe=>p(pe.target.value),e[22]=I):I=e[22];let J;e[23]!==l?(J=l("sectionsEditor.createPageModal.namePlaceholder"),e[23]=l,e[24]=J):J=e[24];let W;e[25]!==a||e[26]!==f||e[27]!==J?(W=r.jsx(Vs,{id:"new-page-name",value:f,onChange:I,placeholder:J,autoFocus:!0,disabled:a}),e[25]=a,e[26]=f,e[27]=J,e[28]=W):W=e[28];let Y;e[29]!==W||e[30]!==F?(Y=r.jsxs("div",{className:"space-y-1.5",children:[F,W]}),e[29]=W,e[30]=F,e[31]=Y):Y=e[31];let G;e[32]!==l?(G=l("sectionsEditor.createPageModal.pathLabel"),e[32]=l,e[33]=G):G=e[33];let Q;e[34]!==G?(Q=r.jsx("label",{htmlFor:"new-page-path",className:"text-xs font-medium text-muted-foreground",children:G}),e[34]=G,e[35]=Q):Q=e[35];let V;e[36]===Symbol.for("react.memo_cache_sentinel")?(V=pe=>y(pe.target.value),e[36]=V):V=e[36];let ee;e[37]!==l?(ee=l("sectionsEditor.createPageModal.pathPlaceholder"),e[37]=l,e[38]=ee):ee=e[38];let q;e[39]!==a||e[40]!==v||e[41]!==ee?(q=r.jsx(Vs,{id:"new-page-path",value:v,onChange:V,placeholder:ee,disabled:a}),e[39]=a,e[40]=v,e[41]=ee,e[42]=q):q=e[42];let K;e[43]!==Q||e[44]!==q?(K=r.jsxs("div",{className:"space-y-1.5",children:[Q,q]}),e[43]=Q,e[44]=q,e[45]=K):K=e[45];let z;e[46]!==a||e[47]!==k||e[48]!==l||e[49]!==h||e[50]!==d?(z=k&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("label",{htmlFor:"new-page-template",className:"text-xs font-medium text-muted-foreground",children:l("sectionsEditor.createPageModal.templateLabel")}),r.jsx(Wi,{id:"new-page-template",value:h,onChange:x,templates:d??[],disabled:a})]}),e[46]=a,e[47]=k,e[48]=l,e[49]=h,e[50]=d,e[51]=z):z=e[51];let j;e[52]!==A?(j=A&&r.jsx("p",{className:"text-xs text-destructive",children:A}),e[52]=A,e[53]=j):j=e[53];let O;e[54]!==Y||e[55]!==K||e[56]!==z||e[57]!==j?(O=r.jsxs("div",{className:"space-y-4 py-4",children:[Y,K,z,j]}),e[54]=Y,e[55]=K,e[56]=z,e[57]=j,e[58]=O):O=e[58];let D;e[59]!==n?(D=()=>n(!1),e[59]=n,e[60]=D):D=e[60];let H;e[61]!==l?(H=l("sectionsEditor.createPageModal.cancelButton"),e[61]=l,e[62]=H):H=e[62];let Z;e[63]!==a||e[64]!==D||e[65]!==H?(Z=r.jsx(_e,{type:"button",variant:"outline",onClick:D,disabled:a,children:H}),e[63]=a,e[64]=D,e[65]=H,e[66]=Z):Z=e[66];let te;e[67]!==a||e[68]!==f||e[69]!==v?(te=!f.trim()||!v.trim()||a,e[67]=a,e[68]=f,e[69]=v,e[70]=te):te=e[70];let M;e[71]!==a||e[72]!==l?(M=a?r.jsxs(r.Fragment,{children:[r.jsx(it,{className:"size-3.5"}),l("sectionsEditor.createPageModal.creatingButton")]}):l("sectionsEditor.createPageModal.createButton"),e[71]=a,e[72]=l,e[73]=M):M=e[73];let X;e[74]!==te||e[75]!==M?(X=r.jsx(_e,{type:"submit",disabled:te,children:M}),e[74]=te,e[75]=M,e[76]=X):X=e[76];let se;e[77]!==Z||e[78]!==X?(se=r.jsxs(Co,{children:[Z,X]}),e[77]=Z,e[78]=X,e[79]=se):se=e[79];let ae;e[80]!==B||e[81]!==O||e[82]!==se||e[83]!==$?(ae=r.jsx(en,{className:"sm:max-w-md",children:r.jsxs("form",{onSubmit:B,children:[$,O,se]})}),e[80]=B,e[81]=O,e[82]=se,e[83]=$,e[84]=ae):ae=e[84];let me;return e[85]!==E||e[86]!==s||e[87]!==ae?(me=r.jsx(tn,{open:s,onOpenChange:E,children:ae}),e[85]=E,e[86]=s,e[87]=ae,e[88]=me):me=e[88],me}function ud(t){const e=le.c(35),{orgSlug:s,virtualMcpId:n,branch:o,previewUrl:c,meta:d,decofile:i,blockKey:a}=t,l=Se();let g;e[0]!==o||e[1]!==s||e[2]!==n?(g={orgSlug:s,virtualMcpId:n,branch:o},e[0]=o,e[1]=s,e[2]=n,e[3]=g):g=e[3];const f=cl(g,i);let p;e[4]!==a||e[5]!==i?(p=qi(i,a),e[4]=a,e[5]=i,e[6]=p):p=e[6];const{resolveType:m,props:v,title:y}=p;if(!m){let N;e[7]!==l?(N=l("sandbox.preview.loaderNoLongerExists"),e[7]=l,e[8]=N):N=e[8];let k;return e[9]!==N?(k=r.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground",children:N}),e[9]=N,e[10]=k):k=e[10],k}const h=`loader:${a}`,x=`loader:${a}`;let C;e[11]!==a||e[12]!==m||e[13]!==y?(C={mode:"saved",blockKey:a,resolveType:m,title:y},e[11]=a,e[12]=m,e[13]=y,e[14]=C):C=e[14];let b;e[15]!==o||e[16]!==i||e[17]!==d||e[18]!==s||e[19]!==c||e[20]!==v||e[21]!==f.isPending||e[22]!==f.save||e[23]!==x||e[24]!==C||e[25]!==n?(b=r.jsx(Gi,{orgSlug:s,virtualMcpId:n,branch:o,previewUrl:c,meta:d,decofile:i,kind:"loaders",target:C,initialValue:v,isCreating:f.isPending,onCreate:fd,onSaveReferencedBlock:f.save,showRun:!1},x),e[15]=o,e[16]=i,e[17]=d,e[18]=s,e[19]=c,e[20]=v,e[21]=f.isPending,e[22]=f.save,e[23]=x,e[24]=C,e[25]=n,e[26]=b):b=e[26];let w;return e[27]!==a||e[28]!==o||e[29]!==i||e[30]!==s||e[31]!==h||e[32]!==b||e[33]!==n?(w=r.jsx(dl,{listing:i,orgSlug:s,virtualMcpId:n,branch:o,blockKey:a,present:void 0,children:b},h),e[27]=a,e[28]=o,e[29]=i,e[30]=s,e[31]=h,e[32]=b,e[33]=n,e[34]=w):w=e[34],w}async function fd(){}function pd(t){if(t instanceof Error&&"status"in t&&typeof t.status=="number")return t.status}function Hr(t){return{status:t.status,hasData:t.data!==void 0,errorStatus:pd(t.error)}}function md(t){switch(t){case"clone-failed":case"install-failed":case"start-failed":return"terminal-error";case"idle":case"cloning":return"booting";case"checking-out":case"installing":case"starting":case"running":case"crashed":return"snapshot-readable"}}function hd(t){if(t.fastPreviewActive)return t.decofile.status==="error"&&!t.decofile.hasData||t.meta.status==="error"&&!t.meta.hasData?{kind:"error",source:"data"}:!t.decofile.hasData||!t.meta.hasData?{kind:"loading"}:t.hasEditableContent?{kind:"content"}:{kind:"empty",reason:"no-content"};const e=md(t.lifecyclePhase);if(e==="terminal-error")return{kind:"error",source:"sandbox"};if(e==="booting")return{kind:"loading"};const s=t.decofile.status==="error"&&!t.decofile.hasData||t.meta.status==="error"&&!t.meta.hasData;return s&&t.lifecyclePhase==="checking-out"?{kind:"loading"}:[t.decofile,t.meta].some(o=>o.status==="error"&&!o.hasData&&o.errorStatus===404)?{kind:"empty",reason:"framework-missing"}:s?t.lifecyclePhase==="running"||t.lifecyclePhase==="crashed"?{kind:"error",source:"data"}:{kind:"loading"}:!t.decofile.hasData||!t.meta.hasData?{kind:"loading"}:t.hasEditableContent?{kind:"content"}:{kind:"empty",reason:"no-content"}}const gd=R.lazy(()=>To(()=>import("./sections-editor-DFekY7v1.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163])).then(t=>({default:t.SectionsEditor})));function Vr(t){const e=le.c(62),{virtualMcpId:s,externalSelection:n,onSectionPicked:o,onViewJsonFile:c}=t,d=n===void 0?null:n,{org:i}=gs(),{currentBranch:a,taskId:l}=lt(),g=hn(),f=bt(),p=xa(),m=g.lifecycle.phase==="running",v=f.previewUrl;let y;e[0]!==a||e[1]!==i||e[2]!==v||e[3]!==l||e[4]!==s?(y=a?{orgSlug:i.slug,virtualMcpId:s,branch:a,threadId:l??null,previewUrl:v}:null,e[0]=a,e[1]=i,e[2]=v,e[3]=l,e[4]=s,e[5]=y):y=e[5];const h=y,x=Ut(s,a);let C;e[6]!==m?(C={fetchEnabled:m},e[6]=m,e[7]=C):C=e[7];const b=vs(h,C),w=ia(h);let N;e[8]!==m?(N={fetchEnabled:m},e[8]=m,e[9]=N):N=e[9];const k=ha(h,N),S=hd({lifecyclePhase:g.lifecycle.phase,decofile:Hr(b),meta:Hr(k),hasEditableContent:Ri(b.data,k.data),fastPreviewActive:oa(s).runtime==="cms"||tt(x)}),E=an()===void 0,T=vd;if(Li(x)){let j;return e[10]===Symbol.for("react.memo_cache_sentinel")?(j=T(r.jsx(Oi,{})),e[10]=j):j=e[10],j}if(x.kind==="pending"&&x.retrying){let j;return e[11]!==x?(j=T(r.jsx(_i,{backend:x})),e[11]=x,e[12]=j):j=e[12],j}if(S.kind==="loading"||E){let j;return e[13]===Symbol.for("react.memo_cache_sentinel")?(j=T(r.jsx(Ro,{})),e[13]=j):j=e[13],j}if(b.data&&di(k.data)){const j=p.state.target,O=j?.kind==="page"||j?.kind==="section"?j.key:null,D=x.kind==="legacy"?O??"":`${w}:${O??""}`,H=a??"";let Z;return e[14]!==b.data||e[15]!==O||e[16]!==i.slug||e[17]!==D||e[18]!==H||e[19]!==s?(Z=T(r.jsx(Ji,{orgSlug:i.slug,virtualMcpId:s,branch:H,decofile:b.data,initialKey:O,compact:!0},D)),e[14]=b.data,e[15]=O,e[16]=i.slug,e[17]=D,e[18]=H,e[19]=s,e[20]=Z):Z=e[20],Z}if(S.kind==="empty"){let j;return e[21]===Symbol.for("react.memo_cache_sentinel")?(j=T(r.jsx($i,{})),e[21]=j):j=e[21],j}if(S.kind==="error"){let j;e[22]!==b||e[23]!==f||e[24]!==k||e[25]!==S.source?(j=()=>{if(S.source==="sandbox"){f.retry();return}Promise.all([b.refetch(),k.refetch()])},e[22]=b,e[23]=f,e[24]=k,e[25]=S.source,e[26]=j):j=e[26];const O=j;let D;return e[27]!==O||e[28]!==S.source?(D=T(r.jsx(Ai,{source:S.source,onRetry:O})),e[27]=O,e[28]=S.source,e[29]=D):D=e[29],D}let B;e[30]===Symbol.for("react.memo_cache_sentinel")?(B=j=>T(r.jsx("div",{className:"h-full min-h-0",children:j})),e[30]=B):B=e[30];const A=B,L=p.state.target;if(L?.kind==="loader"&&b.data&&k.data){const j=x.kind==="legacy"?void 0:w,O=a??"",D=v??null;let H;return e[31]!==b.data||e[32]!==k.data||e[33]!==i.slug||e[34]!==j||e[35]!==O||e[36]!==D||e[37]!==L.key||e[38]!==s?(H=A(r.jsx(ud,{orgSlug:i.slug,virtualMcpId:s,branch:O,previewUrl:D,meta:k.data,decofile:b.data,blockKey:L.key},j)),e[31]=b.data,e[32]=k.data,e[33]=i.slug,e[34]=j,e[35]=O,e[36]=D,e[37]=L.key,e[38]=s,e[39]=H):H=e[39],H}let $;e[40]!==a||e[41]!==i.slug||e[42]!==L||e[43]!==s?($=L||!a?null:Xr(Zr(i.slug,s,a)),e[40]=a,e[41]=i.slug,e[42]=L,e[43]=s,e[44]=$):$=e[44];const _=$;let F="/",I=null,J=null;L?.kind==="page"?(F=L.path,I=L.key):L?.kind==="section"?J=L.key:_&&(F=_.path,I=_.pageKey);const W=I?`page:${I}`:J?`section:${J}`:`path:${F}`;let Y;e[45]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsx(it,{className:"size-5 text-muted-foreground"})}),e[45]=Y):Y=e[45];const G=x.kind==="legacy"?W:`${w}:${W}`,Q=a??"",V=v??void 0,ee=J?null:d,q=J?void 0:o,K=!!I&&p.state.editSeoPageKey===I;let z;return e[46]!==J||e[47]!==I||e[48]!==F||e[49]!==c||e[50]!==i.slug||e[51]!==V||e[52]!==ee||e[53]!==q||e[54]!==K||e[55]!==G||e[56]!==Q||e[57]!==s||e[58]!==p.consumeEditSeo||e[59]!==p.setFocusedBlock||e[60]!==p.setVariantOverride?(z=A(r.jsx(R.Suspense,{fallback:Y,children:r.jsx(gd,{orgSlug:i.slug,virtualMcpId:s,branch:Q,previewReady:!0,previewUrl:V,currentPath:F,activePageBlockKey:I,activeGlobalBlockKey:J,externalSelection:ee,onSectionPicked:q,initialEditSeo:K,onExitSeo:p.consumeEditSeo,onVariantPreviewOverride:p.setVariantOverride,onFocusedBlockChange:p.setFocusedBlock,onViewJsonFile:c},G)})),e[46]=J,e[47]=I,e[48]=F,e[49]=c,e[50]=i.slug,e[51]=V,e[52]=ee,e[53]=q,e[54]=K,e[55]=G,e[56]=Q,e[57]=s,e[58]=p.consumeEditSeo,e[59]=p.setFocusedBlock,e[60]=p.setVariantOverride,e[61]=z):z=e[61],z}function vd(t){return r.jsx("div",{"data-testid":"blocks-panel",className:"h-full min-h-0 overflow-hidden",children:t})}function xd(t){const e=le.c(51),{virtualMcpId:s,pageKey:n,onClose:o,ref:c}=t,d=Se(),i=an(),a=i===!0,l=fn(s);let g;e[0]!==l||e[1]!==n?(g=la(l,ka(n)),e[0]=l,e[1]=n,e[2]=g):g=e[2];const f=g,{org:p}=gs(),{currentBranch:m,taskId:v}=lt(),h=bt().previewUrl;let x;e[3]!==m||e[4]!==p.slug||e[5]!==h||e[6]!==v||e[7]!==s?(x=m?{orgSlug:p.slug,virtualMcpId:s,branch:m,threadId:v??null,previewUrl:h}:null,e[3]=m,e[4]=p.slug,e[5]=h,e[6]=v,e[7]=s,e[8]=x):x=e[8];const b=vs(x),w=m??"";let N;e[9]!==p.slug||e[10]!==w||e[11]!==s?(N={orgSlug:p.slug,virtualMcpId:s,branch:w},e[9]=p.slug,e[10]=w,e[11]=s,e[12]=N):N=e[12];let k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k={holdsCopy:!0},e[13]=k):k=e[13];const{save:S,flush:E,hold:T}=va(N,k),B=m??"";let A;e[14]!==p.slug||e[15]!==B||e[16]!==s?(A=ya({orgSlug:p.slug,virtualMcpId:s,branch:B}),e[14]=p.slug,e[15]=B,e[16]=s,e[17]=A):A=e[17];const L=wa(A);let $;e[18]!==n||e[19]!==L?($=L(n),e[18]=n,e[19]=L,e[20]=$):$=e[20];const _=$;let F;e[21]!==_||e[22]!==n?(F={pageKey:n,copyEpoch:_},e[21]=_,e[22]=n,e[23]=F):F=e[23];const[I,J]=R.useState(F);(I.pageKey!==n||I.copyEpoch!==_)&&(J({pageKey:n,copyEpoch:_}),T(n));const W=b.data?.[n],Y=b.data===void 0&&b.isLoading||i===void 0,G=b.data!==void 0&&W===void 0,Q=!m||G||Y;let V;e[24]!==W?(V=W===void 0?"":JSON.stringify(W,null,2),e[24]=W,e[25]=V):V=e[25];const ee=V;let q;e[26]!==n||e[27]!==Q||e[28]!==S?(q=H=>{if(Q)return;let Z;try{Z=JSON.parse(H)}catch{return}Z===null||typeof Z!="object"||Array.isArray(Z)||S(n,Z)},e[26]=n,e[27]=Q,e[28]=S,e[29]=q):q=e[29];const K=q;let z;e[30]!==E?(z=()=>({flush:E}),e[30]=E,e[31]=z):z=e[31],R.useImperativeHandle(c,z);let j;e[32]!==f||e[33]!==a||e[34]!==o||e[35]!==d?(j=a?r.jsx("div",{className:"flex shrink-0 items-center border-b px-3 py-2.5",children:r.jsx("span",{title:f,className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:f})}):r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-3 py-2.5",children:[r.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:d("sectionsEditor.pageJsonDialog.titleShort")}),r.jsx(_e,{variant:"ghost",size:"icon-sm",onClick:o,"aria-label":d("sectionsEditor.pageJsonDialog.close"),className:"shrink-0",children:r.jsx(Jr,{size:14})})]}),e[32]=f,e[33]=a,e[34]=o,e[35]=d,e[36]=j):j=e[36];let O;e[37]!==_||e[38]!==b.data||e[39]!==E||e[40]!==ee||e[41]!==Y||e[42]!==G||e[43]!==n||e[44]!==Q||e[45]!==K||e[46]!==d?(O=Y?r.jsx("div",{className:"flex flex-1 items-center justify-center",children:r.jsx(it,{className:"size-5 text-muted-foreground"})}):G?r.jsxs("div",{className:"p-4 text-xs font-mono text-foreground/60",children:["// ",d("sectionsEditor.pageJsonDialog.pageNotFound")]}):r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(ba,{code:ee,language:"json",readOnly:Q,height:"100%",onChange:H=>K(H??""),onSave:H=>{K(H),E()}},`${n}:${b.data===void 0?"loading":"ready"}:${_}`)}),e[37]=_,e[38]=b.data,e[39]=E,e[40]=ee,e[41]=Y,e[42]=G,e[43]=n,e[44]=Q,e[45]=K,e[46]=d,e[47]=O):O=e[47];let D;return e[48]!==j||e[49]!==O?(D=r.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden bg-background",children:[j,O]}),e[48]=j,e[49]=O,e[50]=D):D=e[50],D}function Wr(t){const e=le.c(3),{currentBranch:s}=lt(),n=Ut(t.virtualMcpId,s);let o;return e[0]!==n.kind||e[1]!==t?(o=n.kind==="legacy"?r.jsx(xd,{...t}):r.jsx(bd,{...t}),e[0]=n.kind,e[1]=t,e[2]=o):o=e[2],o}function bd(t){const e=le.c(61),{virtualMcpId:s,pageKey:n,onClose:o,ref:c}=t,d=Se(),i=an(),a=i===!0,l=fn(s);let g;e[0]!==l||e[1]!==n?(g=la(l,ka(n)),e[0]=l,e[1]=n,e[2]=g):g=e[2];const f=g,{org:p}=gs(),{currentBranch:m,taskId:v}=lt(),h=bt().previewUrl;let x;e[3]!==m||e[4]!==p.slug||e[5]!==h||e[6]!==v||e[7]!==s?(x=m?{orgSlug:p.slug,virtualMcpId:s,branch:m,threadId:v??null,previewUrl:h}:null,e[3]=m,e[4]=p.slug,e[5]=h,e[6]=v,e[7]=s,e[8]=x):x=e[8];const C=x,b=vs(C);let w;e[9]!==n?(w=[n],e[9]=n,e[10]=w):w=e[10];let N;e[11]!==b.data?(N={listing:b.data},e[11]=b.data,e[12]=N):N=e[12];const k=ca(C,w,N),S=m??"";let E;e[13]!==p.slug||e[14]!==S||e[15]!==s?(E={orgSlug:p.slug,virtualMcpId:s,branch:S},e[13]=p.slug,e[14]=S,e[15]=s,e[16]=E):E=e[16];let T;e[17]===Symbol.for("react.memo_cache_sentinel")?(T={holdsCopy:!0},e[17]=T):T=e[17];const{save:B,flush:A,hold:L}=va(E,T),$=m??"";let _;e[18]!==p.slug||e[19]!==$||e[20]!==s?(_=ya({orgSlug:p.slug,virtualMcpId:s,branch:$}),e[18]=p.slug,e[19]=$,e[20]=s,e[21]=_):_=e[21];const F=wa(_);let I;e[22]!==n||e[23]!==F?(I=F(n),e[22]=n,e[23]=F,e[24]=I):I=e[24];const J=I,W=b.data?.[n];let Y;e[25]!==k.ready||e[26]!==b.data||e[27]!==W?(Y=k.ready&&b.data!==void 0&&(W===void 0||vr(W)),e[25]=k.ready,e[26]=b.data,e[27]=W,e[28]=Y):Y=e[28];const G=Y;let Q;e[29]!==J||e[30]!==n?(Q={pageKey:n,copyEpoch:J,opened:!1,code:""},e[29]=J,e[30]=n,e[31]=Q):Q=e[31];const[V,ee]=R.useState(Q);if(G&&(V.pageKey!==n||V.copyEpoch!==J||!V.opened)){let X;e[32]!==W?(X=W===void 0?"":JSON.stringify(W,null,2),e[32]=W,e[33]=X):X=e[33],ee({pageKey:n,copyEpoch:J,opened:!0,code:X}),vr(W)&&L(n)}const q=V.pageKey===n&&V.opened,K=i===void 0||!q&&!G,z=G&&W===void 0,j=!m||z||K;let O;e[34]!==n||e[35]!==j||e[36]!==B?(O=X=>{if(j)return;ee(ae=>({...ae,code:X}));let se;try{se=JSON.parse(X)}catch{return}se===null||typeof se!="object"||Array.isArray(se)||B(n,se)},e[34]=n,e[35]=j,e[36]=B,e[37]=O):O=e[37];const D=O;let H;e[38]!==A?(H=()=>({flush:A}),e[38]=A,e[39]=H):H=e[39],R.useImperativeHandle(c,H);let Z;e[40]!==f||e[41]!==a||e[42]!==o||e[43]!==d?(Z=a?r.jsx("div",{className:"flex shrink-0 items-center border-b px-3 py-2.5",children:r.jsx("span",{title:f,className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:f})}):r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-3 py-2.5",children:[r.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:d("sectionsEditor.pageJsonDialog.titleShort")}),r.jsx(_e,{variant:"ghost",size:"icon-sm",onClick:o,"aria-label":d("sectionsEditor.pageJsonDialog.close"),className:"shrink-0",children:r.jsx(Jr,{size:14})})]}),e[40]=f,e[41]=a,e[42]=o,e[43]=d,e[44]=Z):Z=e[44];let te;e[45]!==k.failed||e[46]!==k.retry||e[47]!==A||e[48]!==V.code||e[49]!==V.copyEpoch||e[50]!==V.pageKey||e[51]!==K||e[52]!==z||e[53]!==j||e[54]!==D||e[55]!==q||e[56]!==d?(te=!q&&k.failed?r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-4",children:[r.jsx("p",{className:"text-sm",children:d("sectionsEditor.hosted.blockLoadFailed")}),r.jsx(_e,{variant:"outline",size:"sm",onClick:k.retry,children:d("sectionsEditor.namedRules.tryAgain")})]}):K?r.jsx("div",{className:"flex flex-1 items-center justify-center",children:r.jsx(it,{className:"size-5 text-muted-foreground"})}):z?r.jsxs("div",{className:"p-4 text-xs font-mono text-foreground/60",children:["// ",d("sectionsEditor.pageJsonDialog.pageNotFound")]}):r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(ba,{code:V.code,language:"json",readOnly:j,height:"100%",onChange:X=>D(X??""),onSave:X=>{D(X),A()}},`${V.pageKey}:${V.copyEpoch}`)}),e[45]=k.failed,e[46]=k.retry,e[47]=A,e[48]=V.code,e[49]=V.copyEpoch,e[50]=V.pageKey,e[51]=K,e[52]=z,e[53]=j,e[54]=D,e[55]=q,e[56]=d,e[57]=te):te=e[57];let M;return e[58]!==Z||e[59]!==te?(M=r.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden bg-background",children:[Z,te]}),e[58]=Z,e[59]=te,e[60]=M):M=e[60],M}function Oa(t){return t.contentEditingEnabled&&!t.isMobile}function yd(t,e){return t!=="visual"?"visual":e?"blocks":"preview"}function wd(t,e){return t==="blocks"?"preview":e?"blocks":t}function kd(t){return Oa({contentEditingEnabled:Sa(t.cmsMode),isMobile:t.isMobile})?"blocks":"preview"}function Sd(t){return t.editingMode==="blocks"&&!t.blocksEditingEnabled||t.editingMode==="visual"&&!t.sandboxDisplay?"preview":t.editingMode}function Pd(t){const e=ui(t),{display:s}=t;let n=null;if(s.mode==="production"&&s.iframeBase)try{n=new URL(t.path,s.iframeBase).href}catch{n=null}const o=fi(n,e);return{value:e,frame:o?Ys(o,t.device):null,newTab:o}}function jd(t){const e=le.c(94),{tests:s,load:n,onOpen:o,options:c,onChange:d,available:i}=t,a=Se();let l;e[0]!==c?(l=da(c),e[0]=c,e[1]=l):l=e[1];const g=l;let f;e[2]!==c.tests?(f=c.tests??{},e[2]=c.tests,e[3]=f):f=e[3];const p=f;let m;e[4]!==d||e[5]!==c?(m=M=>{const X=M?xl(M):null,{at:se,...ae}=c;d(X?{...ae,at:X}:ae)},e[4]=d,e[5]=c,e[6]=m):m=e[6];const v=m;let y;e[7]!==p||e[8]!==d||e[9]!==c?(y=(M,X)=>{const se={...p};X==="on"?se[M]=!0:X==="off"?se[M]=!1:delete se[M];const{tests:ae,...me}=c;d(Object.keys(se).length>0?{...me,tests:se}:me)},e[7]=p,e[8]=d,e[9]=c,e[10]=y):y=e[10];const h=y;let x;e[11]!==o?(x=M=>{M&&o?.()},e[11]=o,e[12]=x):x=e[12];let C;e[13]!==a?(C=a("sandbox.previewAs.label"),e[13]=a,e[14]=C):C=e[14];let b;e[15]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(ml,{size:16}),e[15]=b):b=e[15];let w;e[16]!==g||e[17]!==C?(w=r.jsx(nt,{asChild:!0,children:r.jsx(na,{asChild:!0,children:r.jsx(st,{"aria-label":C,active:g,"data-testid":"preview-as-trigger",children:b})})}),e[16]=g,e[17]=C,e[18]=w):w=e[18];let N;e[19]!==a?(N=a("sandbox.previewAs.label"),e[19]=a,e[20]=N):N=e[20];let k;e[21]!==N?(k=r.jsx(rt,{children:N}),e[21]=N,e[22]=k):k=e[22];let S;e[23]!==k||e[24]!==w?(S=r.jsxs(at,{children:[w,k]}),e[23]=k,e[24]=w,e[25]=S):S=e[25];let E;e[26]!==a?(E=a("sandbox.previewAs.label"),e[26]=a,e[27]=E):E=e[27];let T;e[28]!==E?(T=r.jsx("h3",{className:"text-sm font-medium",children:E}),e[28]=E,e[29]=T):T=e[29];let B;e[30]!==i||e[31]!==a?(B=a(i?"sandbox.previewAs.intro":"sandbox.previewAs.unavailable"),e[30]=i,e[31]=a,e[32]=B):B=e[32];let A;e[33]!==B?(A=r.jsx("p",{className:"text-xs text-muted-foreground",children:B}),e[33]=B,e[34]=A):A=e[34];let L;e[35]!==T||e[36]!==A?(L=r.jsxs("div",{className:"flex flex-col gap-1",children:[T,A]}),e[35]=T,e[36]=A,e[37]=L):L=e[37];let $;e[38]!==a?($=a("sandbox.previewAs.momentLabel"),e[38]=a,e[39]=$):$=e[39];let _;e[40]!==$?(_=r.jsx(hl,{htmlFor:"preview-as-moment",children:$}),e[40]=$,e[41]=_):_=e[41];let F;e[42]!==c.at?(F=vl(c.at),e[42]=c.at,e[43]=F):F=e[43];let I;e[44]!==v?(I=M=>v(M.target.value),e[44]=v,e[45]=I):I=e[45];let J;e[46]!==F||e[47]!==I?(J=r.jsx(Vs,{id:"preview-as-moment",type:"datetime-local",className:bl,value:F,onChange:I}),e[46]=F,e[47]=I,e[48]=J):J=e[48];const W=c.at===void 0;let Y;e[49]!==v?(Y=()=>v(""),e[49]=v,e[50]=Y):Y=e[50];let G;e[51]!==a?(G=a("sandbox.previewAs.now"),e[51]=a,e[52]=G):G=e[52];let Q;e[53]!==W||e[54]!==Y||e[55]!==G?(Q=r.jsx(_e,{type:"button",variant:"ghost",size:"sm",disabled:W,onClick:Y,children:G}),e[53]=W,e[54]=Y,e[55]=G,e[56]=Q):Q=e[56];let V;e[57]!==J||e[58]!==Q?(V=r.jsxs("div",{className:"flex items-center gap-2",children:[J,Q]}),e[57]=J,e[58]=Q,e[59]=V):V=e[59];let ee;e[60]!==a?(ee=a("sandbox.previewAs.momentHint"),e[60]=a,e[61]=ee):ee=e[61];let q;e[62]!==ee?(q=r.jsx("p",{className:"text-xs text-muted-foreground",children:ee}),e[62]=ee,e[63]=q):q=e[63];let K;e[64]!==_||e[65]!==V||e[66]!==q?(K=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[_,V,q]}),e[64]=_,e[65]=V,e[66]=q,e[67]=K):K=e[67];let z;e[68]!==a?(z=a("sandbox.previewAs.testsLabel"),e[68]=a,e[69]=z):z=e[69];let j;e[70]!==z?(j=r.jsx("span",{className:"text-sm font-medium",children:z}),e[70]=z,e[71]=j):j=e[71];let O;e[72]!==p||e[73]!==n||e[74]!==h||e[75]!==a||e[76]!==s?(O=n&&!n.ready?n.failed?r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsx("p",{className:"text-xs text-muted-foreground",children:a("sandbox.previewAs.testsLoadFailed")}),r.jsx(_e,{type:"button",variant:"outline",size:"sm",onClick:n.retry,children:a("sandbox.previewAs.tryAgain")})]}):r.jsx("div",{className:"flex justify-center py-2","data-testid":"preview-as-tests-loading",children:r.jsx(it,{className:"size-4 text-muted-foreground"})}):s.length===0?r.jsx("p",{className:"text-xs text-muted-foreground",children:a("sandbox.previewAs.noTests")}):r.jsxs(r.Fragment,{children:[r.jsx("ul",{className:"flex flex-col gap-1.5",children:s.map(M=>r.jsxs("li",{className:"flex items-center justify-between gap-2","data-testid":"preview-as-test",children:[r.jsx("span",{className:"min-w-0 truncate text-sm",children:M}),r.jsxs(gl,{type:"single",variant:"outline",size:"sm",value:p[M]===void 0?"":p[M]?"on":"off",onValueChange:X=>h(M,X),"aria-label":M,children:[r.jsx(Or,{value:"off",children:a("sandbox.previewAs.off")}),r.jsx(Or,{value:"on",children:a("sandbox.previewAs.on")})]})]},M))}),r.jsx("p",{className:"text-xs text-muted-foreground",children:a("sandbox.previewAs.testsHint")})]}),e[72]=p,e[73]=n,e[74]=h,e[75]=a,e[76]=s,e[77]=O):O=e[77];let D;e[78]!==j||e[79]!==O?(D=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[j,O]}),e[78]=j,e[79]=O,e[80]=D):D=e[80];let H;e[81]!==g||e[82]!==d||e[83]!==a?(H=g&&r.jsx(_e,{type:"button",variant:"outline",size:"sm",onClick:()=>d({}),children:a("sandbox.previewAs.reset")}),e[81]=g,e[82]=d,e[83]=a,e[84]=H):H=e[84];let Z;e[85]!==L||e[86]!==K||e[87]!==D||e[88]!==H?(Z=r.jsxs(ra,{className:"flex w-80 flex-col gap-4 p-4",align:"center",sideOffset:8,"data-testid":"preview-as",children:[L,K,D,H]}),e[85]=L,e[86]=K,e[87]=D,e[88]=H,e[89]=Z):Z=e[89];let te;return e[90]!==S||e[91]!==Z||e[92]!==x?(te=r.jsxs(aa,{onOpenChange:x,children:[S,Z]}),e[90]=S,e[91]=Z,e[92]=x,e[93]=te):te=e[93],te}const Ed=["next"],Nd=["@tanstack/react-router","@tanstack/react-start","@tanstack/solid-router","@tanstack/solid-start"],_a=new Set(["tsx","ts","jsx","js","mdx"]),Cd=new Set(["tsx","jsx"]),Td=new Set(["404","500"]);function Rd(t){const e=new Set;if(!t||typeof t!="object")return e;const s=t;for(const n of["dependencies","devDependencies"]){const o=s[n];if(o&&typeof o=="object"&&!Array.isArray(o))for(const c of Object.keys(o))e.add(c)}return e}function Ld(t){const e=Rd(t);return Ed.some(s=>e.has(s))?"next":Nd.some(s=>e.has(s))?"tanstack":null}function $a(t,e){const s=(t??"").trim().replace(/^[/\\]+|[/\\]+$/g,"");return s?`${s}/${e}`:e}function Ad(t,e){const s=n=>$a(e,n);switch(t){case"next":return[{router:"next-pages",dir:s("pages"),pattern:"**/*"},{router:"next-pages",dir:s("src/pages"),pattern:"**/*"},{router:"next-app",dir:s("app"),pattern:"**/page.*"},{router:"next-app",dir:s("src/app"),pattern:"**/page.*"}];case"tanstack":return[{router:"tanstack",dir:s("src/routes"),pattern:"**/*"}];default:{const n=t;throw new Error(`Unknown framework: ${String(n)}`)}}}function xn(t){const e=t.lastIndexOf(".");return e<=0?null:[t.slice(0,e),t.slice(e+1)]}function Od(t){const e=xn(t.at(-1)??"");if(!e||!_a.has(e[1]))return null;const[s]=e;if(s.includes("."))return null;const n=[...t.slice(0,-1),s];return n[0]==="api"||n.length===1&&Td.has(s)||n.some(o=>o.startsWith("_")||o.includes("["))?null:(n.at(-1)==="index"&&n.pop(),`/${n.join("/")}`)}function _d(t){const e=xn(t.at(-1)??"");if(!e||e[0]!=="page"||!_a.has(e[1]))return null;const s=[];for(const n of t.slice(0,-1)){if(n.startsWith("_")||n.startsWith("@")||/^\(\.{1,3}\)/.test(n)||n.includes("["))return null;n.startsWith("(")&&n.endsWith(")")||s.push(n)}return`/${s.join("/")}`}function $d(t){const e=[];let s="",n=!1;for(const o of t)o==="["?n=!0:o==="]"&&(n=!1),o==="."&&!n?(e.push(s),s=""):s+=o;return e.push(s),e}function Fd(t){const e=xn(t.at(-1)??"");if(!e||!Cd.has(e[1]))return null;const s=[...t.slice(0,-1),...$d(e[0])].filter(Boolean);s.at(-1)==="lazy"&&s.pop();const n=s.at(-1);if(!n||n==="__root"||s.some(c=>c.startsWith("-"))||n.startsWith("_"))return null;(n==="index"||n==="route")&&s.pop();const o=[];for(const c of s){if(c.includes("$"))return null;if(c.startsWith("_")||c.startsWith("(")&&c.endsWith(")"))continue;const d=c.replace(/_$/,"").replace(/[[\]]/g,"");d&&o.push(d)}return`/${o.join("/")}`}function Dd(t,e){const s=e.split("/").filter(Boolean);if(s.length===0)return null;switch(t){case"next-pages":return Od(s);case"next-app":return _d(s);case"tanstack":return Fd(s);default:{const n=t;throw new Error(`Unknown router: ${String(n)}`)}}}function Bd(t){const e=new Set;for(const{root:s,files:n}of t){const o=`${s.dir}/`;for(const c of n){if(!c.startsWith(o))continue;const d=Dd(s.router,c.slice(o.length));d&&e.add(d)}}return[...e].sort((s,n)=>s==="/"?-1:n==="/"?1:s.localeCompare(n))}const Md=5e3,zd=6e4;async function Id(t,e){const s=await fetch(yl(t,"glob"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({pattern:e.pattern,path:e.dir,limit:Md})});if(!s.ok)throw new Error(`Failed to list ${e.dir}: ${s.status}`);const n=await s.json();return Array.isArray(n.files)?n.files.filter(o=>typeof o=="string"):[]}async function Kd(t,e){const s=await pi(t,$a(e,"package.json"));if(s.kind==="unavailable")throw new Error("package.json unavailable: sandbox not ready");const n=s.kind==="data"?Ld(s.data):null;if(!n)return[];const o=Ad(n,e),c=await Promise.all(o.map(async d=>({root:d,files:await Id(t,d)})));return Bd(c)}function Ud(t,e,s){const n=le.c(12);let o;n[0]!==e||n[1]!==t?(o=t?sn.frameworkRoutes(t.orgSlug,t.virtualMcpId,t.branch,t.threadId,e):["framework-routes","none"],n[0]=e,n[1]=t,n[2]=o):o=n[2];let c;n[3]!==e||n[4]!==t?(c=()=>t?Kd(t,e):[],n[3]=e,n[4]=t,n[5]=c):c=n[5];const d=s&&!!t;let i;n[6]!==o||n[7]!==c||n[8]!==d?(i={queryKey:o,queryFn:c,enabled:d,staleTime:zd},n[6]=o,n[7]=c,n[8]=d,n[9]=i):i=n[9];const a=Yr(i);let l;return n[10]!==a.data?(l=a.data??[],n[10]=a.data,n[11]=l):l=n[11],l}const Hd=500,Vd={mobile:{width:412,height:823},tablet:{width:1024,height:1366},desktop:{width:1280,height:800}},qr=1,fs=["desktop","mobile","tablet"],Wd=["preview","visual","blocks"],qd={mobile:"sandbox.preview.deviceMobile",tablet:"sandbox.preview.deviceTablet",desktop:"sandbox.preview.deviceDesktop"};function Gd(t){if(!t)return null;try{const e=new URL(t,window.location.href);return e.searchParams.set("__decoFBT","0"),e.searchParams.set("__deco_ssr","1"),e.href}catch{return t}}function Kt(t){if(!t)return null;try{return new URL(t,window.location.href).origin}catch{return null}}function Hs(t,e){try{return new URL(t,e).href}catch{return null}}function Jd(t,e){if(!e.inPlaceRenderActive)return{pin:e.draftPreviewUrl?{path:e.resolvedPath,url:e.draftPreviewUrl}:null,effective:e.draftPreviewUrl};if(e.draftPreviewUrl!==null&&t?.path!==e.resolvedPath){const s={path:e.resolvedPath,url:e.draftPreviewUrl};return{pin:s,effective:s.url}}return{pin:t,effective:t?.url??null}}function Yd(t,e){return!t||t.nav!==e.nav?!1:t.content!==e.content}function Qd(t,e,s){const n=t.toLowerCase(),o=e.toLowerCase(),c=o.split("/").filter(Boolean),d=a=>{if(a===s)return 100;const l=a.indexOf(s);if(l===-1)return 0;let g=40;return l===0?g+=30:/[\s/-]/.test(a[l-1]??"")&&(g+=20),g+=Math.round(s.length/a.length*20),g};let i=Math.max(d(n),d(o));return c.at(-1)===s?i=Math.max(i,95):c.includes(s)&&(i=Math.max(i,90)),i}function Xd(t,e){try{t.contentWindow?.location.reload()}catch{e&&(t.src=e)}}function Zd({virtualMcpId:t}){const e=Se(),s=pa(),{currentBranch:n,taskId:o,virtualMcpId:c}=lt(),d=!!Fo(),i=xa(),a=Jo(c===t?t:null),l=oa(t),g=wl(a?.metadata?.ui?.layout??null),f=Sa(g),p=Oa({contentEditingEnabled:f,isMobile:s}),[m]=R.useState(()=>kd({cmsMode:g,isMobile:s})),[v,y]=Ws(qs.previewEditingMode(t),u=>u&&Wd.includes(u)?u:null),h=v??m,[x,C]=Ws(qs.previewDeviceSize(t),u=>u&&fs.includes(u)?u:"desktop"),[b,w]=R.useState(null),[N,k]=R.useState(null),S=R.useRef(null),E=R.useRef(null),[T,B]=R.useState(!1),A=R.useRef(null),L=()=>{A.current?.flush(),B(!1)},$=()=>B(u=>(u&&A.current?.flush(),!u)),[_,F]=R.useState({width:0,height:0}),[I,J]=R.useState(!1),[W,Y]=R.useState({}),[G,Q]=R.useState(""),V=R.useRef(null),[ee,q]=R.useState(!1),[K,z]=R.useState(),[j,O]=R.useState(null),[D,H]=R.useState(null),[Z,te]=R.useState(null),[M,X]=R.useState(()=>i.state.target?.kind==="page"?i.state.target.path:"/"),[se,ae]=R.useState(()=>i.state.target?.kind==="page"?i.state.target.key:null),[me,pe]=R.useState({}),[be,ge]=R.useState(!1),ve=R.useRef(null),Pe=()=>{ge(!0),S.current&&$s(S.current),ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>ge(!1),15e3)},fe=()=>{ve.current&&(clearTimeout(ve.current),ve.current=null),ge(!1)},{org:de}=gs(),Le=hn(),Ie=bt(),Ke=Ie.vmEntry,Me=Le.lifecycle.phase,{url:yt}=ua(t),he=Ut(t,n),{connection:$e}=fa(t),xe=ul(t),Ue=mi({hasServeConnection:!!$e,runtime:l.runtime}),Ae=!tt(he)&&he.kind!=="pending",re=Ve(he)??yt,ue=re??Ie.previewUrl,Ge=!!re||Me==="running",wt=a?.id===t?ni(a.metadata):null,Je=!re&&a?.id===t&&l.runtime==="cms",Ht=l.projectDefault==="cms",kt=Ae?hi({sandboxUrl:ue,previewServerUrl:wt,fastPreviewActive:Je}):null,bn=t&&n?{orgSlug:de.slug,virtualMcpId:t,branch:n,threadId:o??null,previewUrl:ue}:null,yn=vs(bn,{fetchEnabled:Ge}),xs=ha(bn,{fetchEnabled:Ge}),ce=yn.data,we=xs.data,Ye=ce?Fi(ce,we).sort((u,P)=>u.name.localeCompare(P.name)):[],Vt=t&&n?{orgSlug:de.slug,virtualMcpId:t,branch:n}:null,wn=cd(Vt),Fa=gi(Vt),bs=ce&&we?Di(ce,we):[],kn=Ae&&ce&&we?Yi(we,ce,"loaders"):[],Da=G?(()=>{const u=G.toLowerCase();return Ye.map(P=>({page:P,score:Qd(P.name,P.path,u)})).filter(({score:P})=>P>0).sort((P,U)=>U.score-P.score||P.page.path.length-U.page.path.length).map(({page:P})=>P)})():Ye,Ba=bs.filter(u=>{if(!G)return!0;const P=G.toLowerCase();return u.name.toLowerCase().includes(P)||u.key.toLowerCase().includes(P)||u.resolveType.toLowerCase().includes(P)}),Sn=p?kn:[],Pn=Sn.filter(u=>{if(!G)return!0;const P=G.toLowerCase();return u.title.toLowerCase().includes(P)||u.key.toLowerCase().includes(P)||u.resolveType.toLowerCase().includes(P)}),Wt=D?kn.find(u=>u.key===D)??null:null,Ne=pn,ys=j||D?null:Bi(Ye,M,se),ie=ys?.key??null,ct=i.state.target?.kind==="section"?i.state.target.key:i.state.focusedBlockKey??ie,qt=ys?.path??null,ws={};if(Ae&&Ge&&ue&&we&&ce){const u=Qi(we,"loaders"),P=ie?ce[ie]:void 0,U=Pc(P,ce,Ee=>u.has(Ee)),oe=bc(U);for(const Ee of xt(M)){if(Ee.type!=="param")continue;const Ce=gc(M,Ee.name,U),mt=kc(Ce,u,oe);mt.length>0&&(ws[Ee.name]=mt)}}const jn=u=>ce?Zc(ce,u,we):[],ks=ie?jn(M):[],Qe=(ie?me[ie]:void 0)??ks[0]?.values??{},Te=Be(M,Qe),St=t&&n?{orgSlug:de.slug,virtualMcpId:t,branch:n,threadId:o??null}:null,En=ce&&ie?Zi(ce,ie,0):[],Nn=tt(he),Cn=ce?Xi(En,ce,Nn):[],Pt=Cn.map(u=>u.isSavedBlock?u.label:""),jt=Cn.map(u=>u.isSavedBlock?"global":u.isMultivariate?"variant":"normal"),Et=En.map(u=>Qs(u,ce??{},Nn)),dt=R.useRef(null),Fe=R.useRef(null),Ma=Le.status.state==="paused",Ss=Le.phase,Tn=al({claimPhase:Ss,lifecycle:Le.lifecycle}),Xe=Ie.previewState,za=Ie.userStopped,Ia=vi(de.slug,t??""),{url:He}=Hi(Je&&t&&n?{orgSlug:de.slug,virtualMcpId:t,branch:n,previewServerUrl:wt??null,path:Te}:null),Ka=Ht&&l.runtime==="sandbox",Oe=xi(he,Ue,xe),Rn=bi(Oe&&Je&&he.kind==="protocol"&&t&&n?{orgSlug:de.slug,virtualMcpId:t,branch:n}:null),Ln=Oe?Rn.pointer:null,ne=Yl({previewState:Xe,progressStatus:Tn.status,previewServerUrl:wt,fastPreviewActive:Je,fastPreviewReady:!!He,codingSession:Ka,localPreviewUrl:re,hostedDraft:Oe,hostedPointerPending:Oe&&(he.kind==="pending"||Rn.pending)}),An=ne.showWakingPill||Oe&&ne.mode==="production"&&!Ln,Nt=ne.mode!=="none",Ua=ne.mode==="production"&&ne.iframeBase?Kt(ne.iframeBase):null,ut=ne.mode==="production"?Ua:Kt(ue),Ha=a?.id===t&&a.metadata?.fastPreviewInPlace===!0,Ct=Ae?re?ne.mode==="sandbox"&&p&&h==="blocks":ne.mode==="production"&&Je&&Ha&&p&&h==="blocks":!1,On=R.useRef(null),{pin:Va,effective:Wa}=Jd(On.current,{inPlaceRenderActive:Ct,draftPreviewUrl:He,resolvedPath:Te});On.current=Va;const _n=i.state.variantOverride??[],Gt=Ae?_n:[],Tt=Ae?[]:_n,Jt=tt(he)&&Mi.some(u=>zi(we,u)==="available"),ft=Jt?W:{},$n=da(ft),qa=Jt&&ce?Object.keys(Ii(ce).experiments):[],[Fn,Ga]=R.useState(!1),Dn=ca(Vt,Jt&&Fn?Ki:[]),Ja={...Dn,ready:!(he.kind==="protocol"&&he.hosted)||Fn&&Dn.ready},Ze=t?yr(de.slug,t):null,Ya=yi(Ze),Yt=Oe?Pd({display:ne,path:Te,pointer:Ln,heldRevision:Ya,device:x,forcedVariants:Tt,previewOptions:ft}):null,Bn=JSON.stringify([Tt,ft]);R.useEffect(()=>{if(!Oe||!Ze)return;const[u,P]=JSON.parse(Bn);wr(Ze,{forcedVariants:u,previewOptions:P})},[Oe,Ze,Bn]),R.useEffect(()=>{if(!(!Oe||!Ze))return()=>wr(Ze,null)},[Oe,Ze]);const Ps=$e&&Ve(he)?wi($e.endpoint,Tt,$n):null,Qa=$e&&Ve(he)?Ps?ki(Ps,ft):kr:null,et=Gd(ne.mode==="sandbox"?os(Ys(Sr(Z??Hs(Te,ne.iframeBase)??ne.iframeBase,Qa),x),Gt):ne.mode==="production"&&Yt?.frame?Yt.frame:ne.mode==="production"?os(Ys(Pr(jr(Sr(Z??Wa??Hs(Te,ne.iframeBase)??ne.iframeBase,An?kr:null),Tt),ft),x),Gt):null),Mn=He??(ne.iframeBase?Hs(Te,ne.iframeBase):null),zn=ne.mode==="production"&&Yt?Yt.newTab:ne.mode==="production"?Mn?os(Pr(jr(Mn,Tt),ft),Gt):null:et??ne.iframeBase,Xa=()=>{const u=zn;u&&window.open(u,"_blank","noopener")},Rt=t&&n?Zr(de.slug,t,n):null,Lt=u=>{Rt&&Bo(Rt,u)},ke=i.state.target;R.useEffect(()=>{if(!(!ke||!kt||!we))if(ke.kind==="page"){const u=me[ke.key]??{};Fe.current=Be(ke.path,u),O(null),H(null),te(null),ae(ke.key),X(ke.path),Lt({path:ke.path,pageKey:ke.key,params:u})}else if(ke.kind==="loader")Fe.current=null,O(null),H(ke.key),te(null);else{const u=bs.find(P=>P.key===ke.key);if(u){Fe.current=null;const P=Cr(we);H(null),O(u),te(Er(kt,P,u.key))}}},[ke,kt,we,me]),R.useEffect(()=>{!ie||qt===null||ke?.kind==="page"&&ke.key===ie&&ke.path===qt||i.selectTarget({kind:"page",key:ie,path:qt})},[ie,qt,ke]);const[In,Za]=R.useState(null);if(Xe.kind==="iframe"&&In!==Xe.previewUrl){const u=In!==null;Za(Xe.previewUrl);const P=Rt?Xr(Rt):null;if(P){if(Fe.current=Be(P.path,P.params),X(P.path),ae(P.pageKey),te(null),O(null),H(null),P.pageKey&&Object.keys(P.params).length>0){const U=P.pageKey;pe(oe=>({...oe,[U]:P.params}))}}else u&&(Fe.current=null,X("/"),te(null),ae(null),O(null),H(null))}dt.current=et;const eo=ne.mode==="production"&&!!He&&!re,[Qt,js]=R.useState({src:et??void 0,loading:!1}),[to,Es]=R.useState(!1),[so,no]=R.useState(),[Kn,Un]=R.useState(null),je=Xo(Kn,{base:ne.iframeBase??"",frameSrc:Qt.src,loadedSrc:so,wanted:et??void 0,canSwap:xe&&to&&!Qt.loading});je!==Kn&&Un(je);const Xt=Zo(Qt,je?je.src:et??void 0,eo);Xt!==Qt&&js(Xt);const pt=Xt.src,Hn=Xt.loading,Vn=ei({iframeRef:S,src:ne.mode==="sandbox"?et:null,active:ne.mode==="sandbox"}),Wn=R.useRef(null);R.useEffect(()=>{const u=Hn?setTimeout(()=>js(br),ti):null,P=()=>{u&&clearTimeout(u)};if(!He||!pt||Wn.current===He)return P;Wn.current=He;const U=S.current;return U&&U.getAttribute("src")!==pt&&(Pe(),U.src=pt),P},[He,pt,Hn]);const qn=()=>{const u=S.current?.contentWindow,P=ut;if(!u||!P||!ce||!ie)return;const U=ce[ie];if(!U||typeof U!="object")return;const oe=Ei({previewBaseUrl:P,pageBlock:U,decofile:ce,path:Te,pathTemplate:M});if(!oe)return;const Ee=os(oe.src,Ci(Gt,ie));u.postMessage({type:"cms-editor::render",src:Ee,body:oe.body},P)},Ns=R.useRef(null);R.useEffect(()=>{if(!Ct||j||D||!ie||!ce){Ns.current=null;return}const u={nav:JSON.stringify({page:ie,path:Te,pathTemplate:M}),content:JSON.stringify(ce)},P=Yd(Ns.current,u);Ns.current=u,P&&qn()},[ce,Ct,j,D,ie,Te,M]);const Cs=R.useRef(null);R.useEffect(()=>{if(!Ct||j||D||!ie||!ce){Cs.current=null;return}const u=JSON.stringify(i.state.variantOverride??null),P=Cs.current;Cs.current={page:ie,sig:u},!(!P||P.page!==ie||P.sig===u)&&qn()},[i.state.variantOverride,Ct,j,D,ie]);const Gn=!!t&&!!n&&!Le.notFound&&!za&&!Ma&&(Ss?.kind==="ready"||Me!=="idle"),Jn=!tt(he),ro=fn(t??void 0),ao=Ud(St,ro,Jn&&Gn),oo=new Set(f?Ye.map(u=>Ne(u.path)):[]),At=Jn?ao.filter(u=>!oo.has(Ne(u))):[],Yn=G?At.filter(u=>u.toLowerCase().includes(G.toLowerCase())):At,ye=Sd({editingMode:h,sandboxDisplay:ne.mode==="sandbox",blocksEditingEnabled:p});R.useEffect(()=>{const u=ut;if(!u)return;const P=U=>{if(U.origin===u)if(U.data?.type==="visual-editor::element-clicked"){const oe=ec.safeParse(U.data.payload);oe.success&&w(oe.data)}else if(U.data?.type==="cms-editor::section-clicked"){const oe=nc.safeParse(U.data.payload);oe.success&&k({index:oe.data.sectionIndex,seq:oe.data.clickSeq})}else U.data?.type==="cms-editor::render-start"?Pe():U.data?.type==="cms-editor::render-end"?(fe(),S.current?.contentWindow?.postMessage({type:"cms-editor::set-labels",labels:Pt,kinds:jt,keys:Et},u)):U.data?.type==="cms-editor::render-error"&&fe()};return window.addEventListener("message",P),()=>window.removeEventListener("message",P)},[ut,Pt,jt,Et]);const Qn=()=>{const u=S.current?.contentWindow,P=Kt(ue),U=od({v8:xe,script:tc});!u||!P||!U||u.postMessage(U,P)},io=()=>{if(xe)return;const u=S.current?.contentWindow,P=Kt(ue);!u||!P||u.postMessage({type:"visual-editor::deactivate"},P)},Xn=()=>{const u=ze.current;u?.has("wireframe")&&(u.wireframe({type:"wireframe:sections",labels:Pt,kinds:jt,keys:Et}),u.wireframe({type:ye==="blocks"?"wireframe:activate":"wireframe:deactivate"}))},Ts=()=>{if(xe){Xn();return}const u=S.current?.contentWindow,P=ut,U=ad({v8:xe,production:ne.mode==="production",localPreview:!!re,script:rc});!u||!P||!U||(u.postMessage(U,P),u.postMessage({type:"cms-editor::set-labels",labels:Pt,kinds:jt,keys:Et},P))},lo=()=>{if(xe){ze.current?.wireframe({type:"wireframe:deactivate"});return}const u=S.current?.contentWindow,P=ut;!u||!P||u.postMessage({type:"cms-editor::deactivate"},P)},Zn=u=>{ze.current?.wireframe({type:"wireframe:scroll-to",sectionIndex:u})},co=()=>{if(ze.current?.wireframe({type:"wireframe:clear-hover"}),xe)return;const u=S.current?.contentWindow,P=ut;!u||!P||(u.postMessage({type:"cms-editor::clear-hover"},P),u.postMessage({type:"visual-editor::clear-hover"},P))},Zt=u=>{if(u==="blocks"&&!p)return;const P=h;!s&&u!==P&&(u==="blocks"?E.current?.resize("30%"):E.current?.collapse()),y(u),w(null),k(null),u!=="blocks"&&H(null),P==="visual"&&io(),u==="visual"&&Qn(),P==="blocks"&&u!=="blocks"&&lo(),u==="blocks"&&Ts()},uo=()=>{Zt(yd(h,p))},fo=()=>{Zt(wd(h,p))},es=()=>{const u=S.current;if(!u)return;Pe();const P=document.activeElement,U=u.tabIndex;u.tabIndex=-1,u.style.pointerEvents="none",u.blur(),Xd(u,dt.current);let oe;const Ee=()=>{clearTimeout(oe),u.tabIndex=U,u.style.pointerEvents="";const Ce=document.activeElement;(!Ce||Ce===document.body||Ce===u)&&P?.focus(),u.removeEventListener("load",Ee)};u.addEventListener("load",Ee),oe=setTimeout(Ee,3e3)};tl(es);const ze=R.useRef(null),er=R.useEffectEvent(Xn),po=R.useEffectEvent((u,P)=>{k({index:u,seq:P})}),mo=R.useEffectEvent(()=>{fe(),S.current&&$s(S.current),je&&(Rs.current=je.shown),_t&&Fs(Ot)}),tr=R.useEffectEvent(()=>{if(Es(!1),je&&Un(null),je&&je.src!==dt.current){Pe();return}es()});R.useEffect(()=>{if(!xe)return;const u=new cc({studioOrigin:window.location.origin,build:"4.619.4",frame:()=>S.current?.contentWindow??null,onWireframeReady:()=>er(),onWireframe:U=>{U.type==="wireframe:select"&&po(U.sectionIndex,U.clickSeq)},onModulesChange:()=>Es(u.has("html-swap")),onSwapEnd:()=>mo(),onSwapFailed:()=>tr()});ze.current=u;const P=U=>{u.handle(U)};return window.addEventListener("message",P),()=>{window.removeEventListener("message",P),u.dispose(),Es(!1),ze.current===u&&(ze.current=null)}},[xe,ne.iframeBase]);const sr=xe?JSON.stringify([Pt,jt,Et,ye]):"";R.useEffect(()=>{sr&&er()},[sr]);const nr=R.useRef(null);R.useEffect(()=>{const u=nr.current;if(nr.current=je,je&&je!==u){ze.current?.refresh(je.shown)?Pe():tr();return}!je&&u&&u.shown!==u.src&&u.src===dt.current&&es()},[je]);const rr=()=>{ze.current?.refresh()||es()},Ot=yr(de.slug,t??""),_t=Oe&&Nt&&!!t,Rs=R.useRef(null);R.useEffect(()=>{if(_t)return Si(Ot)},[_t,Ot]);const{reload:$t}=Pi(de.slug,t??""),ar=R.useRef($t.seq);R.useEffect(()=>{if(ar.current!==$t.seq&&(ar.current=$t.seq,!!_t&&Rs.current===dt.current)){if($t.navigates){Fs(Ot);return}rr()}},[$t.seq]);const Ls=ia(Vt),Ft=ji(Ve(he)?Ls:""),or=R.useRef(Ft);R.useEffect(()=>{const u=or.current;if(or.current=Ft,!u||!Ft||u===Ft)return;const P=S.current;if(P)return Zl({iframe:P,reload:rr})},[Ft]);const ir=()=>{const u=fs.indexOf(x);C(fs[(u+1)%fs.length])},ts=(u,P)=>lr({...Qe,[u]:P}),lr=u=>{if(!ie)return;const P=ie;Fe.current=Be(M,u),pe(U=>({...U,[P]:u})),Lt({path:M,pageKey:P,params:u})},ho=sd({iframeBase:ne.iframeBase,resolvedPath:Te,activeGlobalSectionName:j?.name??null,noServerLabel:e("sandbox.preview.noServerRunning")}),As=u=>{const P=me[u.key]??{},U=Be(u.path,me[u.key]??jn(u.path)[0]?.values??{});(j||Ne(U)!==Ne(Te))&&Pe(),Fe.current=U,O(null),H(null),te(null),k(null),ae(u.key),X(u.path),Lt({path:u.path,pageKey:u.key,params:P}),i.selectTarget({kind:"page",key:u.key,path:u.path})},cr=u=>{(j||Ne(u)!==Ne(Te))&&Pe(),Fe.current=u,O(null),H(null),te(null),k(null),ae(null),X(u),Lt({path:u,pageKey:null,params:{}})};Do(Rt,cr);const go=u=>{if(tt(he)){const oe=ce?Ui(ce,u.key,we):null;oe?As(oe):ms.info(e("sandbox.preview.blockOnNoPage"));return}if(!kt||!we){ms.error(e("sandbox.preview.previewMetadataNotReady"));return}Pe(),Fe.current=null;const P=Cr(we),U=Er(kt,P,u.key);O(u),H(null),te(U),k(null),i.selectTarget({kind:"section",key:u.key})},vo=u=>{p&&(O(null),H(u.key),te(null),Zt("blocks"),i.selectTarget({kind:"loader",key:u.key}))},xo=async({name:u,path:P,templateKey:U})=>{if(!t||!n)return;const oe=ma(P);if(oe){z(oe);return}const Ee=P.trim().startsWith("/")?P.trim():`/${P.trim()}`;if(Ye.some(Ce=>Ne(Ce.path)===Ne(Ee))){z(e("sandbox.preview.pageAlreadyExists",{path:Ee}));return}z(void 0);try{const Ce=U?await Fa(ce,U):void 0;if(U&&!Ce){z(e("sandbox.preview.templateNoLongerExists"));return}const mt=await wn.mutateAsync({name:u,path:Ee,template:Ce,schema:tt(he)?{meta:we,loadMeta:async()=>(await xs.refetch()).data}:void 0});q(!1),ms.success(e("sandbox.preview.pageCreated",{name:u})),await Sl(Hd),As({key:mt.key,name:mt.name,path:mt.path}),Zt("blocks")}catch(Ce){z(Ce instanceof Aa?e("sandbox.preview.pageSchemaNotReady"):Ce instanceof Error?Ce.message:e("sandbox.preview.failedToCreatePage"))}},Dt=nd({previewSurfaceActive:Nt,daemonReady:Gn,production:ne.mode==="production",servePreviewUrl:Ve(he)}),dr=rd({showPreviewToolbar:Dt,contentEditingEnabled:f,hasFrameworkRoutes:At.length>0}),ur=f?Da:[],fr=f?Ba:[],Bt=()=>{J(!1),Q("")},Os=f?j?.name??Wt?.title??ys?.name:void 0,_s=f&&(yn.isPending||xs.isPending),ss=_s?Kt(ne.iframeBase):Os,Mt=j?`section:${j.key}`:D?`loader:${D}`:f&&ie?`page:${ie}`:At.includes(Ne(M))?`route:${Ne(M)}`:void 0,ns=e(qd[x]),pr=x==="mobile"?r.jsx(ea,{size:16}):x==="tablet"?r.jsx(Vo,{size:16}):r.jsx(ta,{size:16}),bo=Dt?dr?r.jsxs("div",{className:"flex h-7 min-w-36 flex-1 items-stretch overflow-hidden rounded-[var(--studio-button-radius,calc(var(--radius)*1.333))] border border-border/60 bg-background transition-colors hover:border-border",children:[r.jsxs(at,{children:[r.jsx(nt,{asChild:!0,children:r.jsx("button",{type:"button",onClick:ir,"aria-label":ns,className:Re("flex w-7 shrink-0 items-center justify-center border-r border-border/60 text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",Nr),children:pr})}),r.jsx(rt,{children:ns})]}),r.jsxs(aa,{open:I,onOpenChange:u=>{J(u),u||Q("")},children:[r.jsx(na,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":e("sandbox.preview.choosePage"),"data-testid":"preview-page-picker",title:_s?ss??void 0:j||Wt?Os:[Os,M].filter(Boolean).join(" · "),className:Re("group/page-picker flex min-w-0 flex-1 items-stretch whitespace-nowrap text-left text-xs text-muted-foreground",Nr),children:r.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-2 transition-colors group-hover/page-picker:bg-accent/50 group-data-[state=open]/page-picker:bg-accent/50",children:[j&&r.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-2xs font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[r.jsx(Uo,{size:11}),e("sandbox.preview.globalBadge")]}),Wt&&r.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-2xs font-medium text-muted-foreground",children:[r.jsx(Wo,{size:11}),e("sandbox.preview.loaderBadge")]}),ss&&r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:ss}),!_s&&!j&&!Wt&&r.jsx("span",{"data-testid":"preview-page-path",className:Re("min-w-0 truncate font-mono [direction:rtl]",ss?"ml-auto shrink-[2] text-right text-muted-foreground md:@max-[40rem]/panel-toolbar:hidden":"flex-1 text-left text-foreground"),children:r.jsx("bdi",{dir:"ltr",children:M})}),r.jsx(Mo,{size:12,className:Re("shrink-0 transition-transform",I&&"rotate-180")})]})})}),r.jsxs(ra,{className:"w-112 max-w-[calc(100vw-2rem)] p-0",align:"center",sideOffset:8,children:[r.jsxs(cn,{shouldFilter:!1,defaultValue:Mt,children:[r.jsx(dn,{value:G,onValueChange:u=>{Q(u),V.current?.scrollTo({top:0})},placeholder:e("sandbox.preview.searchPagesAndComponents")}),r.jsxs(ln,{ref:V,className:"max-h-80",children:[r.jsx(un,{children:(!f||Ye.length===0)&&At.length===0&&(!f||bs.length===0)&&Sn.length===0?e("sandbox.preview.noPagesFound"):e("sandbox.preview.noSearchResults")}),ur.length>0&&r.jsx(We,{children:ur.map(u=>r.jsxs(qe,{value:`page:${u.key}`,"aria-current":Mt===`page:${u.key}`||void 0,title:`${u.name} · ${u.path}`,onSelect:()=>{Bt(),As(u)},className:"gap-3 px-3 py-2.5 aria-[current=true]:bg-accent aria-[current=true]:text-accent-foreground",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:u.name}),r.jsx("span",{className:"min-w-0 max-w-1/2 truncate text-right font-mono text-xs text-muted-foreground",children:u.path})]},u.key))}),Yn.length>0&&r.jsx(We,{heading:e("sandbox.preview.siteRoutes"),children:Yn.map(u=>r.jsx(qe,{value:`route:${u}`,"aria-current":Mt===`route:${u}`||void 0,title:u,onSelect:()=>{Bt(),cr(u)},className:"px-3 py-2.5 aria-[current=true]:bg-accent aria-[current=true]:text-accent-foreground",children:r.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:u})},u))}),fr.length>0&&r.jsx(We,{heading:e("sandbox.preview.globalComponents"),children:fr.map(u=>r.jsx(qe,{value:`section:${u.key}`,"aria-current":Mt===`section:${u.key}`||void 0,className:"aria-[current=true]:bg-accent aria-[current=true]:text-accent-foreground",onSelect:()=>{Bt(),go(u)},children:r.jsx("span",{className:"truncate",children:u.name})},u.key))}),Pn.length>0&&r.jsx(We,{heading:e("sandbox.preview.globalLoaders"),children:Pn.map(u=>r.jsx(qe,{value:`loader:${u.key}`,"aria-current":Mt===`loader:${u.key}`||void 0,className:"aria-[current=true]:bg-accent aria-[current=true]:text-accent-foreground",onSelect:()=>{Bt(),vo(u)},children:r.jsx("span",{className:"truncate",children:u.title})},u.key))})]})]}),f&&!j&&!D&&xt(M).some(u=>u.type!=="text")&&r.jsx("div",{className:"flex flex-wrap items-center gap-1 border-t px-3 py-3 text-xs text-muted-foreground",children:xt(M).map((u,P)=>{if(u.type==="text")return r.jsx("span",{children:u.text},`text-${P}`);const U=ws[u.name];return!U&&ks.length>0?r.jsx(ed,{paramName:u.name,template:M,value:Qe[u.name]??"",options:ks,onPick:lr,onCommit:oe=>ts(u.name,oe)},`${ie}:${u.name}`):U&&St?r.jsx(Mc,{sources:U,template:M,paramName:u.name,value:Qe[u.name]??"",sandboxRef:St,onCommit:oe=>ts(u.name,oe)},`${ie}:${u.name}`):r.jsx(Yc,{name:u.name,value:Qe[u.name]??"",onCommit:oe=>ts(u.name,oe)},`${ie}:${u.name}`)})}),f&&r.jsx("div",{className:"border-t p-1.5",children:r.jsxs(_e,{variant:"ghost",className:"w-full justify-start",onClick:()=>{Bt(),z(void 0),q(!0)},children:[r.jsx(sa,{size:16}),e("sandbox.preview.createNewPage")]})})]})]})]}):r.jsx("span",{className:"min-w-0 truncate text-xs text-muted-foreground",children:ho}):null,mr=Dt||f?r.jsxs("div",{className:"flex min-w-0 max-w-[24rem] flex-1 items-center justify-center gap-1",children:[!(Dt&&dr)&&r.jsxs(at,{children:[r.jsx(nt,{asChild:!0,children:r.jsx(st,{onClick:ir,"aria-label":ns,children:pr})}),r.jsx(rt,{children:ns})]}),bo,r.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Jt&&r.jsx(jd,{tests:qa,load:Ja,onOpen:()=>Ga(!0),options:W,onChange:u=>{Y(u),i.previewAsChanged()},available:!!Ps||!An||!$n}),r.jsx(st,{onClick:Xa,disabled:Oe&&!zn,"aria-label":e("sandbox.preview.openInNewTab"),children:r.jsx(Qr,{size:16})})]})]}):null,yo=(Ae||d)&&ne.mode==="sandbox",rs=Vd[x],as=x==="desktop"&&(_.width===0||_.width>=rs.width+2*qr),hr=as?1:Math.min(_.width>0?_.width/(rs.width+2*qr):1,1),wo=as?{width:"100%",height:"100%"}:{width:`${rs.width}px`,height:_.height>0?`${_.height/hr}px`:`${rs.height}px`,transform:`scale(${hr})`,transformOrigin:"top center"},gr=r.jsxs(r.Fragment,{children:[yo&&(Dt||f)&&r.jsx(st,{onClick:uo,"aria-pressed":ye==="visual","aria-label":e("sandbox.preview.visualEditor"),active:ye==="visual",children:r.jsx(xr,{size:16})}),p&&r.jsxs(at,{children:[r.jsx(nt,{asChild:!0,children:r.jsx(st,{onClick:fo,"aria-pressed":ye==="blocks","aria-label":e("sandbox.preview.blocksEditor"),active:ye==="blocks",children:r.jsx(qo,{size:16})})}),r.jsx(rt,{children:e("sandbox.preview.blocksEditor")})]}),ct&&r.jsxs(at,{children:[r.jsx(nt,{asChild:!0,children:r.jsx(st,{onClick:$,"aria-pressed":T,"aria-label":e("sectionsEditor.sectionsEditor.viewJson"),active:T,children:r.jsx(Ho,{size:16})})}),r.jsx(rt,{children:e("sectionsEditor.sectionsEditor.viewJson")})]})]}),ko=!!D&&ye==="blocks";return r.jsxs("div",{className:"flex flex-col w-full h-full",children:[St&&Object.entries(ws).map(([u,P])=>(Qe[u]??"")===""?r.jsx(Gc,{sources:P,template:M,paramName:u,sandboxRef:St,onFill:U=>ts(u,U)},`${ie}:${u}`):null),r.jsxs(r.Fragment,{children:[r.jsx(Gs.Toolbar.Center.Portal,{fallback:r.jsx("div",{className:"flex min-w-0 items-center justify-center border-b p-2",children:mr}),children:mr}),r.jsx(Gs.Toolbar.Right.Portal,{fallback:gr,children:gr})]}),r.jsx("div",{className:"flex-1 overflow-hidden relative",children:ko?r.jsxs("div",{className:"relative h-full min-h-0 overflow-hidden",children:[r.jsx(Vr,{virtualMcpId:t,externalSelection:N,onSectionPicked:Zn,onViewJsonFile:$}),T&&ct&&r.jsx("div",{className:"absolute inset-0 z-10",children:r.jsx(Wr,{ref:A,virtualMcpId:t,pageKey:ct,onClose:L},he.kind==="legacy"?void 0:JSON.stringify([Ls,xe]))})]}):r.jsxs(Rr,{orientation:"horizontal",disabled:ye!=="blocks",className:"relative isolate",children:[r.jsx(is,{ref:E,id:"preview-blocks-editor",defaultSize:ye==="blocks"?"30%":"0%",minSize:"20%",collapsible:!0,collapsedSize:"0%",className:"min-w-0 overflow-hidden",children:ye==="blocks"&&r.jsx(Vr,{virtualMcpId:t,externalSelection:N,onSectionPicked:Zn,onViewJsonFile:$})}),ye==="blocks"&&r.jsx(Lr,{withHandle:!0}),r.jsx(is,{id:"preview-canvas",defaultSize:ye==="blocks"?"70%":"100%",minSize:"35%",className:"min-w-0 overflow-hidden relative z-0",children:r.jsxs(Rr,{orientation:"horizontal",disabled:!(T&&ct),children:[r.jsx(is,{id:"preview-canvas-inner",minSize:"30%",className:"min-w-0 overflow-hidden",children:r.jsxs("div",{ref:u=>{if(!u)return;const P=()=>F(oe=>oe.width===u.clientWidth&&oe.height===u.clientHeight?oe:{width:u.clientWidth,height:u.clientHeight});P();const U=new ResizeObserver(P);return U.observe(u),()=>U.disconnect()},className:Re("h-full relative overflow-clip flex justify-center",Nt&&!as&&"bg-muted/30"),children:[(be||Ia)&&Nt&&r.jsx(si,{}),ne.showDecidingLoader&&r.jsx("div",{"data-testid":"preview-deciding",className:"absolute inset-0 z-30 flex items-center justify-center",children:r.jsx(it,{className:"size-5 text-muted-foreground"})}),ne.showBlockingOverlay&&r.jsx("div",{className:"absolute inset-0 z-30",children:r.jsx(Bs,{kind:"starting",progress:Tn,claimPhase:Ss})}),!re&&Xe.kind==="suspended"&&r.jsx("div",{className:"absolute inset-0 z-30",children:r.jsx(Bs,{kind:"suspended",onResume:Ie.resume})}),!re&&Xe.kind==="errored"&&r.jsx("div",{className:"absolute inset-0 z-30",children:r.jsx(Bs,{kind:"errored",error:Xe.error,onRetry:Ie.retry,connectionsHref:`/${de.slug}/settings/connections`})}),ne.showWakingPill&&r.jsxs("div",{className:"absolute top-4 left-1/2 z-20 flex max-w-md -translate-x-1/2 items-start gap-3 rounded-xl bg-muted px-4 py-3 shadow-soft pointer-events-none select-none",children:[r.jsx(it,{className:"size-4.5 mt-0.5 shrink-0 text-muted-foreground"}),r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("span",{className:"text-sm font-medium text-foreground",children:e("sandbox.preview.startingPreview")}),r.jsx("span",{className:"text-xs text-muted-foreground",children:e("sandbox.preview.startingPreviewHint")})]})]}),ye==="visual"&&!b&&r.jsxs("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20 flex items-center gap-1.5 rounded-full border border-special/40 bg-special/90 px-3 py-1 text-xs font-medium text-special-foreground shadow-soft backdrop-blur-sm pointer-events-none select-none",children:[r.jsx(xr,{size:12}),e("sandbox.preview.clickElementToAsk")]}),ye==="visual"&&b&&r.jsx(pc,{element:b,onDismiss:()=>w(null)}),Nt&&et&&r.jsx("div",{className:Re("shrink-0",!as&&"bg-background shadow-edge"),style:wo,onMouseLeave:co,children:r.jsx("iframe",{ref:S,src:pt,className:"w-full h-full border-0",title:e("sandbox.preview.devServerPreviewTitle"),onError:Vn.handleError,onLoad:u=>{if($s(u.currentTarget),js(br),no(pt),Vn.handleLoad(),fe(),Rs.current=dt.current,_t&&Fs(Ot),ne.mode!=="sandbox"||re){(ne.mode==="production"&&!ne.showWakingPill||re)&&ye==="blocks"&&Ts();return}if(Lo("vm_preview_loaded",{view_mode:ye,vm_id:Ke?.sandboxHandle??null}),!j)try{const P=S.current?.contentWindow?.location?.pathname;if(!P)return;const U=Fe.current;if(U!==null&&(Fe.current=null,Ne(P)!==Ne(U))||Ne(P)===Ne(Te))return;X(P),Lt({path:P,pageKey:se,params:Qe})}catch{}ye==="visual"&&Qn(),ye==="blocks"&&Ts()}},ne.iframeBase)})]})}),T&&ct&&r.jsxs(r.Fragment,{children:[r.jsx(Lr,{withHandle:!0}),r.jsx(is,{id:"preview-json-editor",defaultSize:"43%",minSize:"20%",className:"min-w-0 overflow-hidden",children:r.jsx(Wr,{ref:A,virtualMcpId:t,pageKey:ct,onClose:L},he.kind==="legacy"?void 0:JSON.stringify([Ls,xe]))})]})]})})]})}),r.jsx(dd,{open:ee,onOpenChange:q,isPending:wn.isPending,error:K,templates:Ye,onSubmit:xo})]})}const Zs={app:null,split:!1};function eu(t){const e=le.c(24),{project:s,maxApps:n,children:o}=t,c=Se();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={silent:!0},e[0]=d):d=e[0];const i=Yo(d),a=bt();let l;e[1]!==s.metadata.runtime?(l=s.metadata.runtime??{},e[1]=s.metadata.runtime,e[2]=l):l=e[2];const g=l;let f;e[3]!==g.apps?(f=g.apps??[],e[3]=g.apps,e[4]=f):f=e[4];const p=f;let m;e[5]!==i.update||e[6]!==a||e[7]!==s.id||e[8]!==s.metadata||e[9]!==g||e[10]!==c?(m=b=>i.update.mutate({id:s.id,data:{metadata:{...Pl(s.metadata),runtime:{...g,apps:b.length?b:null}}}},{onSuccess:()=>a.start(),onError:()=>ms.error(c("sandbox.appTabs.saveError"))}),e[5]=i.update,e[6]=a,e[7]=s.id,e[8]=s.metadata,e[9]=g,e[10]=c,e[11]=m):m=e[11];const v=m,y=g.path??null;let h,x;e[12]!==p||e[13]!==v?(h=b=>v([...p,{path:b}]),x=b=>v(p.filter(w=>w.path!==b)),e[12]=p,e[13]=v,e[14]=h,e[15]=x):(h=e[14],x=e[15]);let C;return e[16]!==p||e[17]!==o||e[18]!==n||e[19]!==s.id||e[20]!==y||e[21]!==h||e[22]!==x?(C=r.jsx(tu,{virtualMcpId:s.id,mainPath:y,apps:p,maxApps:n,onAddApp:h,onRemoveApp:x,children:o}),e[16]=p,e[17]=o,e[18]=n,e[19]=s.id,e[20]=y,e[21]=h,e[22]=x,e[23]=C):C=e[23],C}function tu(t){const e=le.c(102),{virtualMcpId:s,mainPath:n,apps:o,maxApps:c,onAddApp:d,onRemoveApp:i,children:a}=t,l=Se(),g=pa(),{currentBranch:f}=lt(),p=bt(),m=hn().lifecycle.phase,v=Ut(s,f),{url:y}=ua(s);let h;e[0]!==v||e[1]!==y?(h=Ve(v)??y,e[0]=v,e[1]=y,e[2]=h):h=e[2];const x=h,C=x??p.previewUrl,b=!!x||m==="running",w=!b&&p.status==="errored";let N;e[3]!==p.vmEntry?.startedWith?.apps?(N=p.vmEntry?.startedWith?.apps??[],e[3]=p.vmEntry?.startedWith?.apps,e[4]=N):N=e[4];const k=N;let S;e[5]!==s?(S=qs.previewAppLayout(s),e[5]=s,e[6]=S):S=e[6];const[E,T]=Ws(S,su);let B;e[7]!==o||e[8]!==E?(B=o.some(fe=>fe.path===E.app)?E.app:null,e[7]=o,e[8]=E,e[9]=B):B=e[9];const A=B,L=A!==null&&E.split&&!g,$=A===null||L,_=A??o[0]?.path??null,[F,I]=R.useState(null),[J,W]=R.useState(!1);let Y;e[10]===Symbol.for("react.memo_cache_sentinel")?(Y=()=>{I(null),W(!1)},e[10]=Y):Y=e[10];const G=Y;let Q;e[11]!==o||e[12]!==F||e[13]!==g||e[14]!==n||e[15]!==d||e[16]!==T?(Q=()=>{if(F===null)return;const fe=_r(F);if(!fe){G();return}if(fe===_r(n??"")||o.some(de=>de.path===fe)){W(!0);return}d(fe),T({app:fe,split:!g}),G()},e[11]=o,e[12]=F,e[13]=g,e[14]=n,e[15]=d,e[16]=T,e[17]=Q):Q=e[17];const V=Q;let ee;e[18]!==n||e[19]!==l?(ee=n?Ms(n):l("sandbox.appTabs.root"),e[18]=n,e[19]=l,e[20]=ee):ee=e[20];const q=ee;let K;e[21]!==L||e[22]!==l?(K=l(L?"sandbox.appTabs.single":"sandbox.appTabs.split"),e[21]=L,e[22]=l,e[23]=K):K=e[23];const z=K;let j;e[24]!==l?(j=l("sandbox.appTabs.label"),e[24]=l,e[25]=j):j=e[25];let O;e[26]!==l?(O=l("sandbox.appTabs.main"),e[26]=l,e[27]=O):O=e[27];let D;e[28]!==l?(D=l("sandbox.appTabs.mainHint"),e[28]=l,e[29]=D):D=e[29];let H;e[30]!==T?(H=()=>T(Zs),e[30]=T,e[31]=H):H=e[31];let Z;e[32]!==w||e[33]!==q||e[34]!==b||e[35]!==$||e[36]!==O||e[37]!==D||e[38]!==H?(Z=r.jsx(Gr,{label:q,badge:O,hint:D,ready:b,failed:w,onScreen:$,onSelect:H}),e[32]=w,e[33]=q,e[34]=b,e[35]=$,e[36]=O,e[37]=D,e[38]=H,e[39]=Z):Z=e[39];let te;if(e[40]!==o||e[41]!==A||e[42]!==w||e[43]!==q||e[44]!==i||e[45]!==b||e[46]!==T||e[47]!==L||e[48]!==l){let fe;e[50]!==A||e[51]!==w||e[52]!==q||e[53]!==i||e[54]!==b||e[55]!==T||e[56]!==L||e[57]!==l?(fe=de=>{const Le=Ms(de.path);return r.jsx(Gr,{label:Le,hint:l("sandbox.appTabs.extraHint",{app:q}),ready:b,failed:w,onScreen:de.path===A,onSelect:()=>T({app:de.path,split:L}),onRemove:()=>i(de.path),removeLabel:l("sandbox.appTabs.remove",{app:Le})},de.path)},e[50]=A,e[51]=w,e[52]=q,e[53]=i,e[54]=b,e[55]=T,e[56]=L,e[57]=l,e[58]=fe):fe=e[58],te=o.map(fe),e[40]=o,e[41]=A,e[42]=w,e[43]=q,e[44]=i,e[45]=b,e[46]=T,e[47]=L,e[48]=l,e[49]=te}else te=e[49];let M;e[59]!==Z||e[60]!==te||e[61]!==j?(M=r.jsxs("div",{role:"tablist","aria-label":j,className:"flex min-w-0 items-center gap-1 overflow-x-auto",children:[Z,te]}),e[59]=Z,e[60]=te,e[61]=j,e[62]=M):M=e[62];let X;e[63]!==o.length||e[64]!==V||e[65]!==F||e[66]!==J||e[67]!==c||e[68]!==l?(X=F!==null?r.jsx("form",{className:"w-40 shrink-0",onSubmit:fe=>{fe.preventDefault(),V()},children:r.jsx("input",{autoFocus:!0,value:F,placeholder:"apps/checkout","aria-label":l("sandbox.appTabs.pathLabel"),"aria-invalid":J,onChange:fe=>{I(fe.target.value),W(!1)},onBlur:G,onKeyDown:fe=>{fe.key==="Escape"&&G()},className:Re("h-7 w-full rounded-md border bg-background px-2 font-mono text-xs outline-none",J?"border-destructive":"border-border")})}):o.length<c&&r.jsx(vt,{label:l("sandbox.appTabs.add"),onClick:()=>I(""),children:r.jsx(sa,{})}),e[63]=o.length,e[64]=V,e[65]=F,e[66]=J,e[67]=c,e[68]=l,e[69]=X):X=e[69];let se;e[70]!==g||e[71]!==T||e[72]!==L||e[73]!==z||e[74]!==_?(se=!g&&_&&r.jsx(vt,{label:z,active:L,onClick:()=>T(L?Zs:{app:_,split:!0}),children:r.jsx(Go,{})}),e[70]=g,e[71]=T,e[72]=L,e[73]=z,e[74]=_,e[75]=se):se=e[75];let ae;e[76]!==M||e[77]!==X||e[78]!==se?(ae=r.jsxs(r.Fragment,{children:[M,X,se]}),e[76]=M,e[77]=X,e[78]=se,e[79]=ae):ae=e[79];const me=ae;let pe;e[80]!==me?(pe=r.jsx(Gs.Topbar.Left.Portal,{fallback:r.jsx("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b border-border px-2",children:me}),children:r.jsx("div",{className:"ml-1 flex min-w-0 items-center gap-1 border-l border-border/60 pl-2",children:me})}),e[80]=me,e[81]=pe):pe=e[81];let be;e[82]!==a||e[83]!==$?(be=$&&r.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:a}),e[82]=a,e[83]=$,e[84]=be):be=e[84];let ge;e[85]!==A||e[86]!==w||e[87]!==p.start||e[88]!==x||e[89]!==q||e[90]!==C||e[91]!==b||e[92]!==T||e[93]!==L||e[94]!==k?(ge=A!==null&&r.jsx(nu,{name:Ms(A),mainName:q,appUrl:C?jl(C,A):null,ready:b,failed:w,notStarted:!x&&!k.includes(A),onStart:p.start,className:Re(L&&"border-l border-border"),onClose:L?()=>T({app:A,split:!1}):void 0},A),e[85]=A,e[86]=w,e[87]=p.start,e[88]=x,e[89]=q,e[90]=C,e[91]=b,e[92]=T,e[93]=L,e[94]=k,e[95]=ge):ge=e[95];let ve;e[96]!==be||e[97]!==ge?(ve=r.jsxs("div",{className:"flex min-h-0 flex-1",children:[be,ge]}),e[96]=be,e[97]=ge,e[98]=ve):ve=e[98];let Pe;return e[99]!==pe||e[100]!==ve?(Pe=r.jsxs("div",{className:"flex h-full w-full min-h-0 flex-col",children:[pe,ve]}),e[99]=pe,e[100]=ve,e[101]=Pe):Pe=e[101],Pe}function su(t){return t??Zs}function Gr(t){const e=le.c(28),{label:s,badge:n,hint:o,ready:c,failed:d,onScreen:i,onSelect:a,onRemove:l,removeLabel:g}=t,f=i?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/60 hover:text-foreground";let p;e[0]!==f?(p=Re("group/app-tab flex h-7 shrink-0 items-center rounded-md text-xs transition-colors",f),e[0]=f,e[1]=p):p=e[1];const m=c?"bg-success":d?"bg-destructive":"animate-pulse bg-warning";let v;e[2]!==m?(v=Re("size-1.5 rounded-full",m),e[2]=m,e[3]=v):v=e[3];let y;e[4]!==v?(y=r.jsx("span",{"aria-hidden":!0,className:v}),e[4]=v,e[5]=y):y=e[5];let h;e[6]!==s?(h=r.jsx("span",{className:"max-w-40 truncate",children:s}),e[6]=s,e[7]=h):h=e[7];let x;e[8]!==n?(x=n&&r.jsx("span",{className:"text-[10px] text-muted-foreground",children:n}),e[8]=n,e[9]=x):x=e[9];let C;e[10]!==i||e[11]!==a||e[12]!==y||e[13]!==h||e[14]!==x?(C=r.jsx(nt,{asChild:!0,children:r.jsxs("button",{type:"button",role:"tab","aria-selected":i,onClick:a,className:"flex h-full items-center gap-1.5 rounded-md px-2.5 focus-ring",children:[y,h,x]})}),e[10]=i,e[11]=a,e[12]=y,e[13]=h,e[14]=x,e[15]=C):C=e[15];let b;e[16]!==o?(b=r.jsx(rt,{className:"max-w-64",children:o}),e[16]=o,e[17]=b):b=e[17];let w;e[18]!==C||e[19]!==b?(w=r.jsxs(at,{children:[C,b]}),e[18]=C,e[19]=b,e[20]=w):w=e[20];let N;e[21]!==l||e[22]!==g?(N=l&&r.jsx("button",{type:"button","aria-label":g,onClick:l,className:"-ml-1 mr-1 flex size-5 items-center justify-center rounded opacity-0 hover:bg-sidebar-accent focus-ring focus-visible:opacity-100 group-hover/app-tab:opacity-100",children:r.jsx(ja,{className:"size-3"})}),e[21]=l,e[22]=g,e[23]=N):N=e[23];let k;return e[24]!==w||e[25]!==N||e[26]!==p?(k=r.jsxs("div",{className:p,children:[w,N]}),e[24]=w,e[25]=N,e[26]=p,e[27]=k):k=e[27],k}function nu(t){const e=le.c(71),{name:s,mainName:n,appUrl:o,ready:c,failed:d,notStarted:i,onStart:a,className:l,onClose:g}=t,f=Se(),[p,m]=R.useState("/"),[v,y]=R.useState("desktop"),[h,x]=R.useState(0),C=R.useRef(null);let b;e[0]!==o||e[1]!==p?(b=o?El(o,p):null,e[0]=o,e[1]=p,e[2]=b):b=e[2];const w=b;let N;e[3]!==l?(N=Re("flex min-h-0 min-w-0 flex-1 flex-col",l),e[3]=l,e[4]=N):N=e[4];let k;e[5]===Symbol.for("react.memo_cache_sentinel")?(k=D=>{D.preventDefault(),m(C.current?.value||"/")},e[5]=k):k=e[5];let S;e[6]!==s||e[7]!==f?(S=f("sandbox.appPane.path",{app:s}),e[6]=s,e[7]=f,e[8]=S):S=e[8];let E;e[9]!==p||e[10]!==S?(E=r.jsx("form",{className:"min-w-0 flex-1",onSubmit:k,children:r.jsx("input",{ref:C,defaultValue:p,"aria-label":S,className:"h-7 w-full rounded-md border border-border/60 bg-background px-2 font-mono text-xs text-muted-foreground outline-none hover:border-border focus:border-border focus:text-foreground"})}),e[9]=p,e[10]=S,e[11]=E):E=e[11];let T;e[12]!==v||e[13]!==f?(T=f(v==="desktop"?"sandbox.preview.deviceMobile":"sandbox.preview.deviceDesktop"),e[12]=v,e[13]=f,e[14]=T):T=e[14];let B;e[15]===Symbol.for("react.memo_cache_sentinel")?(B=()=>y(au),e[15]=B):B=e[15];let A;e[16]!==v?(A=v==="desktop"?r.jsx(ta,{}):r.jsx(ea,{}),e[16]=v,e[17]=A):A=e[17];let L;e[18]!==T||e[19]!==A?(L=r.jsx(vt,{label:T,onClick:B,children:A}),e[18]=T,e[19]=A,e[20]=L):L=e[20];let $;e[21]!==s||e[22]!==f?($=f("sandbox.appPane.reload",{app:s}),e[21]=s,e[22]=f,e[23]=$):$=e[23];const _=!w||!c;let F,I;e[24]===Symbol.for("react.memo_cache_sentinel")?(F=()=>x(ru),I=r.jsx(Ao,{}),e[24]=F,e[25]=I):(F=e[24],I=e[25]);let J;e[26]!==$||e[27]!==_?(J=r.jsx(vt,{label:$,disabled:_,onClick:F,children:I}),e[26]=$,e[27]=_,e[28]=J):J=e[28];let W;e[29]!==s||e[30]!==f?(W=f("sandbox.appPane.openInNewTab",{app:s}),e[29]=s,e[30]=f,e[31]=W):W=e[31];const Y=!w||!c;let G;e[32]!==w?(G=()=>w&&window.open(w,"_blank","noopener"),e[32]=w,e[33]=G):G=e[33];let Q;e[34]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(Qr,{}),e[34]=Q):Q=e[34];let V;e[35]!==W||e[36]!==Y||e[37]!==G?(V=r.jsx(vt,{label:W,disabled:Y,onClick:G,children:Q}),e[35]=W,e[36]=Y,e[37]=G,e[38]=V):V=e[38];let ee;e[39]!==s||e[40]!==g||e[41]!==f?(ee=g&&r.jsx(vt,{label:f("sandbox.appPane.close",{app:s}),onClick:g,children:r.jsx(ja,{})}),e[39]=s,e[40]=g,e[41]=f,e[42]=ee):ee=e[42];let q;e[43]!==J||e[44]!==V||e[45]!==ee||e[46]!==E||e[47]!==L?(q=r.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b border-border px-2",children:[E,L,J,V,ee]}),e[43]=J,e[44]=V,e[45]=ee,e[46]=E,e[47]=L,e[48]=q):q=e[48];let K;e[49]!==n||e[50]!==f?(K=f("sandbox.appPane.previewOnly",{app:n}),e[49]=n,e[50]=f,e[51]=K):K=e[51];let z;e[52]!==K?(z=r.jsx("p",{className:"shrink-0 truncate border-b border-border bg-muted/40 px-3 py-1.5 text-xs text-muted-foreground",children:K}),e[52]=K,e[53]=z):z=e[53];let j;e[54]!==v||e[55]!==d||e[56]!==n||e[57]!==s||e[58]!==i||e[59]!==a||e[60]!==c||e[61]!==h||e[62]!==w||e[63]!==f?(j=r.jsx("div",{className:"flex min-h-0 flex-1 justify-center overflow-auto bg-muted/40",children:c&&i?r.jsxs("div",{className:"flex flex-col items-center gap-3 self-center px-6 text-center",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:f("sandbox.appPane.notStarted",{app:s})}),r.jsx(_e,{size:"sm",variant:"outline",onClick:a,children:f("sandbox.appPane.start",{app:s})})]}):!c||!w?r.jsx("p",{className:"self-center px-6 text-center text-sm text-muted-foreground",children:c?f("sandbox.appPane.noUrl"):d?f("sandbox.appPane.failed",{app:n}):f("sandbox.appPane.waiting")}):r.jsx("iframe",{src:w,title:s,className:Re("h-full bg-background",v==="mobile"?"w-[412px] max-w-full border-x border-border":"w-full")},`${w}#${h}`)}),e[54]=v,e[55]=d,e[56]=n,e[57]=s,e[58]=i,e[59]=a,e[60]=c,e[61]=h,e[62]=w,e[63]=f,e[64]=j):j=e[64];let O;return e[65]!==s||e[66]!==N||e[67]!==q||e[68]!==z||e[69]!==j?(O=r.jsxs("section",{"aria-label":s,className:N,children:[q,z,j]}),e[65]=s,e[66]=N,e[67]=q,e[68]=z,e[69]=j,e[70]=O):O=e[70],O}function ru(t){return t+1}function au(t){return t==="desktop"?"mobile":"desktop"}function vt(t){const e=le.c(11),{label:s,children:n,active:o,disabled:c,onClick:d}=t;let i;e[0]!==o||e[1]!==n||e[2]!==c||e[3]!==s||e[4]!==d?(i=r.jsx(nt,{asChild:!0,children:r.jsx(st,{"aria-label":s,"aria-pressed":o,active:o,disabled:c,onClick:d,children:n})}),e[0]=o,e[1]=n,e[2]=c,e[3]=s,e[4]=d,e[5]=i):i=e[5];let a;e[6]!==s?(a=r.jsx(rt,{children:s}),e[6]=s,e[7]=a):a=e[7];let l;return e[8]!==i||e[9]!==a?(l=r.jsxs(at,{children:[i,a]}),e[8]=i,e[9]=a,e[10]=l):l=e[10],l}const ou=async(t,e)=>{try{return await fetch(t,{method:"HEAD",mode:"no-cors",cache:"no-store",credentials:"omit",signal:e}),!0}catch{return!1}},iu=1e4,lu=1e4,cu=5e3,du=2;function uu(t,e){return t&&e===0?lu:Math.min(1e3*2**Math.max(0,e-1),cu)}function fu(t,e,s){return e?!0:t===!0&&s<du}function pu(t,e){const s=le.c(11),n=ou,o=Oo();let c;s[0]!==t?(c=sn.localAppReachable(t??""),s[0]=t,s[1]=c):c=s[1];const d=c;let i;s[2]!==n||s[3]!==o||s[4]!==d||s[5]!==t?(i=async f=>{const{signal:p}=f,m=new AbortController,v=()=>m.abort();p.addEventListener("abort",v);const y=setTimeout(v,iu),h=await n(t,m.signal).catch(hu);clearTimeout(y),p.removeEventListener("abort",v);const x=o.getQueryData(d),C=h?0:(x?.failures??0)+1;return{up:fu(x?.up??null,h,C),failures:C}},s[2]=n,s[3]=o,s[4]=d,s[5]=t,s[6]=i):i=s[6];const a=!!t;let l;s[7]!==d||s[8]!==i||s[9]!==a?(l={queryKey:d,queryFn:i,enabled:a,retry:!1,staleTime:0,gcTime:0,refetchInterval:mu},s[7]=d,s[8]=i,s[9]=a,s[10]=l):l=s[10];const{data:g}=Yr(l);return t?g?.up??null:null}function mu(t){return t.state.data?uu(t.state.data.up,t.state.data.failures):!1}function hu(){return!1}function gu(t){const{backend:e}=t;if(e.kind==="protocol"&&e.source==="local")return{kind:"connected"};if(e.kind==="unavailable"&&e.source==="local"){const s=e.problem;return!s||s.reason==="not-answering"?t.access==="denied"?{kind:"needs-permission"}:{kind:"not-running"}:{kind:"problem",problem:s}}return{kind:"connecting"}}function jf(t){const e=le.c(53),{virtualMcpId:s}=t,n=Se(),o=Qo(s),{connection:c}=fa(s),{activeTask:d,taskId:i,currentBranch:a}=lt(),l=_l(i),[g,f]=R.useState(!1),p=Ut(s,a);let m;e[0]!==p||e[1]!==c?(m=c?Ve(p):null,e[0]=p,e[1]=c,e[2]=m):m=e[2];const v=m,y=pu(v),h=Na(),x=Nl("multi_app_preview");if(Rl({threadId:i,sandboxBranch:d?.branch??a,agentHasRepo:zs(o?.metadata),threadHasRepo:zs(l)||zs(d?.metadata)})==="none"&&!c){let k;e[3]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("div",{className:"flex size-14 items-center justify-center rounded-full bg-muted",children:r.jsx($r,{className:"size-7 text-foreground"})}),e[3]=k):k=e[3];let S;e[4]!==n?(S=n("mainPanelTabs.previewTab.noSourceToPreview"),e[4]=n,e[5]=S):S=e[5];let E;e[6]!==n?(E=n("mainPanelTabs.previewTab.connectGithubDescription"),e[6]=n,e[7]=E):E=e[7];let T,B;e[8]===Symbol.for("react.memo_cache_sentinel")?(T=()=>f(!0),B=r.jsx($r,{className:"size-4"}),e[8]=T,e[9]=B):(T=e[8],B=e[9]);let A;e[10]!==n?(A=n("mainPanelTabs.previewTab.connectGithub"),e[10]=n,e[11]=A):A=e[11];let L;e[12]!==A?(L=r.jsxs(_e,{onClick:T,children:[B,A]}),e[12]=A,e[13]=L):L=e[13];let $;e[14]!==S||e[15]!==E||e[16]!==L?($=r.jsx(Cl,{className:"h-full",image:k,title:S,description:E,actions:L}),e[14]=S,e[15]=E,e[16]=L,e[17]=$):$=e[17];let _;e[18]!==g?(_=r.jsx(Tl,{open:g,onOpenChange:f,mode:"agent"}),e[18]=g,e[19]=_):_=e[19];let F;return e[20]!==_||e[21]!==$?(F=r.jsxs(r.Fragment,{children:[$,_]}),e[20]=_,e[21]=$,e[22]=F):F=e[22],F}if(c&&o&&!Ve(p)){let k;e[23]!==h||e[24]!==p?(k=gu({backend:p,access:h}),e[23]=h,e[24]=p,e[25]=k):k=e[25];let S;e[26]!==c.endpoint?(S=Ni(c.endpoint),e[26]=c.endpoint,e[27]=S):S=e[27];let E;return e[28]!==k||e[29]!==S?(E=r.jsx(xu,{status:k,host:S}),e[28]=k,e[29]=S,e[30]=E):E=e[30],E}if(v&&y!==!0){let k;e[31]!==n?(k=n("mainPanelTabs.previewTab.localAppWaiting.title"),e[31]=n,e[32]=k):k=e[32];let S;e[33]!==v||e[34]!==n?(S=n("mainPanelTabs.previewTab.localAppWaiting.body",{host:vu(v)}),e[33]=v,e[34]=n,e[35]=S):S=e[35];let E;e[36]!==S?(E=r.jsx(Pa,{text:S}),e[36]=S,e[37]=E):E=e[37];let T;e[38]!==n?(T=n("mainPanelTabs.previewTab.localAppWaiting.hint"),e[38]=n,e[39]=T):T=e[39];let B;e[40]!==T?(B=r.jsx("p",{role:"status",className:"text-center text-sm text-muted-foreground",children:T}),e[40]=T,e[41]=B):B=e[41];let A;return e[42]!==k||e[43]!==E||e[44]!==B?(A=r.jsx(hs,{headingLevel:2,waiting:!0,title:k,lead:E,footer:B}),e[42]=k,e[43]=E,e[44]=B,e[45]=A):A=e[45],A}let b;e[46]!==s?(b=r.jsx(Zd,{virtualMcpId:s}),e[46]=s,e[47]=b):b=e[47];const w=b;let N;return e[48]!==o||e[49]!==x||e[50]!==w||e[51]!==c?(N=r.jsx(_o,{children:x&&o&&!c?r.jsx(eu,{project:o,maxApps:kl,children:w}):w}),e[48]=o,e[49]=x,e[50]=w,e[51]=c,e[52]=N):N=e[52],N}function vu(t){try{return new URL(t).host}catch{return t}}function xu(t){const e=le.c(13),{status:s,host:n}=t,o=Se();if(s.kind==="connected"){let i;e[0]!==o?(i=o("mainPanelTabs.previewTab.localhostNoPreview.title"),e[0]=o,e[1]=i):i=e[1];let a;e[2]!==o?(a=o("mainPanelTabs.previewTab.localhostNoPreview.body"),e[2]=o,e[3]=a):a=e[3];let l;return e[4]!==i||e[5]!==a?(l=r.jsx(hs,{headingLevel:2,waiting:!1,title:i,lead:a}),e[4]=i,e[5]=a,e[6]=l):l=e[6],l}let c;e[7]!==n||e[8]!==s?(c=Ml(s,n),e[7]=n,e[8]=s,e[9]=c):c=e[9];let d;return e[10]!==n||e[11]!==c?(d=r.jsx(Bl,{wait:c,hosts:n}),e[10]=n,e[11]=c,e[12]=d):d=e[12],d}export{Bl as L,jf as P,hs as S,Pf as u};