@jxsuite/studio 5.7.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{cf-account-picker-882a7ecm.js → cf-account-picker-bb2yq946.js} +2 -2
- package/dist/chunks/content-source-t0q184js.js +4 -0
- package/dist/chunks/{convert-to-repeater-grfep2w8.js → convert-to-repeater-vqkt7s3s.js} +2 -2
- package/dist/chunks/entry-commands-fxzgcc4k.js +4 -0
- package/dist/chunks/{extension-sections-dp8endhx.js → extension-sections-8beq9ac3.js} +2 -2
- package/dist/chunks/file-ops-2n77759h.js +4 -0
- package/dist/chunks/files-fjy7zpxt.js +4 -0
- package/dist/chunks/{format-host-e2pjvd25.js → format-host-wj3mf3n8.js} +2 -2
- package/dist/chunks/fs-events-7kcgn4e9.js +4 -0
- package/dist/chunks/git-panel-7z2mpt2d.js +4 -0
- package/dist/chunks/{grid-view-5amhg604.js → grid-view-ca10def6.js} +2 -2
- package/dist/chunks/{iframe-host-t819mcg5.js → iframe-host-a0zjd6xp.js} +2 -2
- package/dist/chunks/{layers-4bsr82wz.js → layers-p677nrh5.js} +2 -2
- package/dist/chunks/layers-panel-y4w1dq90.js +4 -0
- package/dist/chunks/media-picker-xg7yjpz9.js +4 -0
- package/dist/chunks/menu-fpekzj6w.js +4 -0
- package/dist/chunks/publish-panel-xtbfgg2r.js +4 -0
- package/dist/chunks/quick-search-d3a6m7j3.js +4 -0
- package/dist/chunks/right-panel-31vbk5xp.js +4 -0
- package/dist/chunks/studio-1q6amtph.js +5 -0
- package/dist/chunks/{studio-56z7evx4.js → studio-3ck2a5c4.js} +2 -2
- package/dist/chunks/{studio-gh97gngt.js → studio-4fde4a0x.js} +2 -2
- package/dist/chunks/{studio-gfn1kpxj.js → studio-4jj9gme2.js} +3 -3
- package/dist/chunks/{studio-zpnk016a.js → studio-4m50vh74.js} +3 -3
- package/dist/chunks/{studio-dkn3x3hz.js → studio-4r0sjtx8.js} +2 -2
- package/dist/chunks/{studio-a7xqhc3n.js → studio-5d7wfmnp.js} +2 -2
- package/dist/chunks/{studio-ceb34dxj.js → studio-5gs9th4b.js} +2 -2
- package/dist/chunks/{studio-j6gnhvaa.js → studio-5vy2wfm5.js} +2 -2
- package/dist/chunks/{studio-spf2skgc.js → studio-7qvs7v0m.js} +2 -2
- package/dist/chunks/{studio-e6re3rk1.js → studio-84rtc120.js} +2 -2
- package/dist/chunks/{studio-nt06yybj.js → studio-8xcwewjq.js} +2 -2
- package/dist/chunks/{studio-cxt150pj.js → studio-aekhcdzw.js} +2 -2
- package/dist/chunks/{studio-222rqyyc.js → studio-bftp4n4b.js} +2 -2
- package/dist/chunks/{studio-xta2vxp6.js → studio-capk0583.js} +2 -2
- package/dist/chunks/{studio-wma2c6g8.js → studio-cbr9czkn.js} +2 -2
- package/dist/chunks/{studio-c9d3pxf7.js → studio-chdmwwzw.js} +2 -2
- package/dist/chunks/{studio-0k9mvpgj.js → studio-cp1gbff9.js} +2 -2
- package/dist/chunks/{studio-1x8x26k3.js → studio-cqmtbg2p.js} +2 -2
- package/dist/chunks/{studio-c6w3tq7t.js → studio-e47215hh.js} +2 -2
- package/dist/chunks/{studio-frb0qbf7.js → studio-fbx6twps.js} +2 -2
- package/dist/chunks/{studio-xk0z6msk.js → studio-fthwn4kf.js} +2 -2
- package/dist/chunks/{studio-0scebvb9.js → studio-g8dsj3d2.js} +2 -2
- package/dist/chunks/{studio-54g077x3.js → studio-ge5fqjth.js} +2 -2
- package/dist/chunks/{studio-p7c1agz0.js → studio-gjknvzam.js} +3 -3
- package/dist/chunks/{studio-mwxgyn9h.js → studio-hnvnfbdv.js} +3 -3
- package/dist/chunks/{studio-9mqfamps.js → studio-mk00zd5d.js} +2 -2
- package/dist/chunks/{studio-skzanb0k.js → studio-qa73881a.js} +2 -2
- package/dist/chunks/{studio-xry7tk3z.js → studio-rmn2dz59.js} +2 -2
- package/dist/chunks/{studio-eh0rac07.js → studio-rr4xkv81.js} +2 -2
- package/dist/chunks/{studio-f195h2hq.js → studio-tmeq6mjb.js} +2 -2
- package/dist/chunks/{studio-cvbkkfqb.js → studio-x5g1xk77.js} +2 -2
- package/dist/chunks/{studio-65fhspdd.js → studio-xg1942as.js} +2 -2
- package/dist/chunks/{studio-888knnkc.js → studio-xkfs0dp2.js} +2 -2
- package/dist/chunks/{studio-xy3tv3az.js → studio-zev8ssp1.js} +3 -3
- package/dist/chunks/{studio-tw7rre6s.js → studio-ztvcxm3w.js} +2 -2
- package/dist/chunks/{workspace-b69mgm0e.js → workspace-5vmgsagj.js} +2 -2
- package/dist/iframe-entry.js +3 -3
- package/dist/manifest.json +36 -36
- package/dist/studio.js +10 -10
- package/package.json +11 -11
- package/src/ui/schema-form.ts +6 -2
- package/dist/chunks/content-source-37x3vsap.js +0 -4
- package/dist/chunks/entry-commands-c5h3nqck.js +0 -4
- package/dist/chunks/file-ops-937cvqk6.js +0 -4
- package/dist/chunks/files-tznwe1p1.js +0 -4
- package/dist/chunks/fs-events-fv64ak3s.js +0 -4
- package/dist/chunks/git-panel-gb713ttc.js +0 -4
- package/dist/chunks/layers-panel-b6shnaax.js +0 -4
- package/dist/chunks/media-picker-ej0kdh1j.js +0 -4
- package/dist/chunks/menu-rtxf9chb.js +0 -4
- package/dist/chunks/publish-panel-bq36xcmj.js +0 -4
- package/dist/chunks/quick-search-zm00h9dh.js +0 -4
- package/dist/chunks/right-panel-pq2f71q3.js +0 -4
- package/dist/chunks/studio-693nhyky.js +0 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{p,We}from"./studio-y7jehjrp.js";import{ge,Q,re,k}from"./studio-fqq890ap.js";import{Je,Yi,Ju,jl}from"./studio-7pgy3xaf.js";import{gL,Le,ms,uv,q,Hs,Ji,Vu,pa,Ue,Uu,xn,ot,yv,yi,li,Se,Do,qC,oo,He,Qn,m,u,Hn,$r,Cp}from"./studio-cvbkkfqb.js";import{Pd,wi}from"./studio-1x8x26k3.js";import{st,um,xc}from"./studio-pwqfmt4p.js";import{jC,Rd}from"./studio-888knnkc.js";import{Dv,$p,Mm,Wl,Kr,ro,Jr,Gs,nh,Ya,Fm,wI,Qo,jd,jm,ne}from"./studio-0k9mvpgj.js";import{ga,gr,zs,Ws,gs}from"./studio-st75kn99.js";import{Di,JT,Vb,YT,ps,$l,Ub,ZT,y,OC}from"./studio-zpnk016a.js";import{pm,hp,fm}from"./studio-a7xqhc3n.js";import{K,_o,ht,_n,Yo,qa,D,Xu,Qu,Ai}from"./studio-tp642n5g.js";import{Oe,Rv}from"./studio-vavmwshr.js";import{qe,Mp}from"./studio-nbxqcgvf.js";import{zv}from"./studio-edbtvcd1.js";function xt(e){let{target:t,source:n,targetOrigin:o,acceptOrigin:r,token:i}=e,s=new Set,a=(l)=>{if(r!=="*"&&l.origin!==r)return;let c=l.data;if(!c||typeof c!=="object"||c["jx:canvas"]!==i)return;for(let d of s)d(c.payload)};return n.addEventListener("message",a),{dispose(){s.clear(),n.removeEventListener("message",a)},onMessage(l){return s.add(l),()=>s.delete(l)},post(l){t.postMessage({["jx:canvas"]:i,payload:l},o)}}}var Yn=null;function Qw(){return Yn}function Uo(){return Yi(m.activePaneId)}function lt(e){let t=Hn(e),n=t?.derived,o=n?.kind==="lens"?Hn(n.sourcePaneId)?.activeTabId:t?.activeTabId;return o?m.tabs.get(o)??null:null}function ur(e){return Hn(e)?.derived??null}function Xw(e){if(!e)return[];let t=[];for(let n of m.panes)if(lt(n.id)?.id===e.id)t.push(Yi(n.id));return t}function _(e){for(let t of Ju()){let n=t.panels.find((o)=>o.canvas===e);if(n)return{panel:n,surface:t}}return null}function wt(e){let t=e.canvas,n=t?_(t):null;return n?lt(n.surface.paneId):null}function Tl(e){let t=e?.session.ui,n=t?.canvasMode??"design";return t?.preview&&(n==="edit"||n==="design")?"preview":n}function wo(e){let t=ur(e);if(t?.kind==="lens"){let n=t.mode;return lt(e)?.session.ui?.preview&&(n==="edit"||n==="design")?"preview":n}return Tl(lt(e))}function Nu(e){let t=ur(e);if(t?.kind==="lens"&&t.preset==="breakpoint")return t.media;return lt(e)?.session.ui.activeMedia??null}function $b(e){return jl(e)?.paneId??Qn}function im(e){return lt($b(e))}var ce=new Set(["img","video","source","iframe","audio"]),ue="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",eo="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='32'%20height='32'%3E%3Crect%20width='32'%20height='32'%20fill='%23d0d0d0'/%3E%3C/svg%3E",to=/(src|poster|image|bg|background|icon|logo|photo|avatar|thumbnail|cover|banner)$/i;function no(e){return to.test(e)}var io=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","li","dt","dd","th","td","span","strong","em","small","mark","code","abbr","q","sub","sup","time","a","button","label","legend","caption","summary","pre","option"]),ao=new Set(["div","section","article","aside","header","footer","main","nav","figure","figcaption","details","fieldset","form","ul","ol","dl","table"]);function so(e){if(!e.tagName||e.textContent||e.innerHTML)return null;if(e.$__layout)return null;if(Array.isArray(e.children)&&e.children.length>0)return null;if(io.has(qe(e.tagName)))return"empty-text-placeholder";if(ao.has(qe(e.tagName)))return"empty-container-placeholder";return null}function De(e){return e.replaceAll(/\$\{([^}]+)\}/g,"❪ $1 ❫")}function lo(e){let t=e.map;return{children:t&&typeof t==="object"?[A(t)]:[],className:"repeater-perimeter",tagName:"div"}}function A(e){if(!e||typeof e!=="object")return e;if(Array.isArray(e))return e.map((s)=>A(s));if(e.$prototype==="Array")return lo(e);let t=e,n={},o=!1,r=ce.has(t.tagName||"");if(r){let{attributes:s,src:a}=t,l=s?.src,c=t.poster,d=s?.poster;if(!(a&&a!==""||l&&l!=="")&&!(c&&c!==""||d&&d!==""))o=!0}for(let[s,a]of Object.entries(t))if(s==="state"||s==="$media"||s==="$elements")n[s]=a;else if(s==="$props"&&a&&typeof a==="object"){let l={};for(let[c,d]of Object.entries(a))if(typeof d==="string"&&d.includes("${"))if(no(c))l[c]=eo;else if(c==="href"||c==="action")l[c]="";else l[c]=De(d);else if(d&&typeof d==="object"&&d.$ref){let f=d.$ref,h=f.startsWith("#/state/")?f.slice(8):f;l[c]=`{${h}}`}else l[c]=d;n[s]=l}else if(s==="children")if(Array.isArray(a))n.children=a.map((l)=>A(l));else if(a&&typeof a==="object"&&a.$prototype==="Array")n.children=[A(a)];else n.children=A(a);else if(s==="cases"&&t.$switch&&a&&typeof a==="object"){let l=Object.keys(a);if(l.length>0){let c=a[l[0]];n.children=c&&typeof c==="object"&&!c.$ref?[A(c)]:[{style:{background:"color-mix(in srgb, var(--danger) 8%, transparent)",border:"1px dashed color-mix(in srgb, var(--danger) 40%, transparent)",borderRadius:"4px",color:"var(--danger)",fontFamily:"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace",fontSize:"11px",fontStyle:"italic",padding:"6px 10px"},tagName:"div",textContent:`[$switch: ${l.join(" | ")}]`}]}}else if(s==="attributes"&&r&&a&&typeof a==="object"){let l=a,c={};for(let[d,f]of Object.entries(l))if(d==="src"||d==="poster")if(typeof f==="string"&&f!==""&&!f.includes("${"))c[d]=f;else o=!0,c[d]=ue;else if(typeof f==="string"&&f.includes("${")){let h=d==="href"||d==="action";c[d]=h?"":De(f)}else if(f&&typeof f==="object"&&f.$ref){let h=f.$ref,b=h.startsWith("#/state/")?h.slice(8):h;c[d]=`{${b}}`}else c[d]=f;n.attributes=c}else if(s==="style")if(a&&typeof a==="object"){let l={};for(let[c,d]of Object.entries(a))if(typeof d!=="string"||!d.includes("${"))l[c]=d;n.style=l}else n.style=a;else if(typeof a==="string"&&a.includes("${"))if((s==="src"||s==="poster")&&ce.has(t.tagName||""))o=!0,n[s]=ue;else{let c=s==="src"||s==="href"||s==="poster"||s==="action";n[s]=c?"":De(a)}else if(a&&typeof a==="object"&&a.$ref){let l=a.$ref,c=l.startsWith("#/state/")?l.slice(8):l;if((s==="src"||s==="poster")&&ce.has(t.tagName||""))o=!0,n[s]=ue;else n[s]=`{${c}}`}else if((s==="src"||s==="poster")&&a===""&&ce.has(t.tagName||""))o=!0,n[s]=ue;else n[s]=A(a);let i=so(n);if(i)n.className=n.className?`${n.className} ${i}`:i;if(o){let s=n.className||"";if(!s.includes("empty-media-placeholder"))n.className=s?`${s} empty-media-placeholder`:"empty-media-placeholder"}return n}var co=/\[\.\.\.(\w+)\]|\[(\w+)\]/g;function uo(e){return e.split("\\").join("/").replace(/^\.\//,"").replace(/^\//,"").replace(/^pages\//,"")}function Ct(e){let t=uo(e),n=t.slice(t.lastIndexOf("/")+1),o=n.lastIndexOf(".");if(o>0)t=t.slice(0,t.length-(n.length-o));if(t.endsWith("/index"))t=t.slice(0,-6)||"/";else if(t==="index")t="/";if(!t.startsWith("/"))t=`/${t}`;let r=[],i=!1,s=!1,a=t.replaceAll(co,(l,c,d)=>{if(i=!0,c)return s=!0,r.push(c),"*";return r.push(d),`:${d}`});return{isCatchAll:s,isDynamic:i,params:r,urlPattern:a}}function Db(e){if(!e)return"/";return Ct(e).urlPattern}function Ll(e){if(!e)return[];return Ct(e).params}function yT(e){let t=e.document?.$paths,n=e.frontmatter?.$paths;return t??n??null}var pe=new Map;function wT(){pe.clear()}function xT(e,t){if(!t)return Promise.resolve({});let n=`${e??""}::${JSON.stringify(t)}`,o=pe.get(n);if(!o)o=po(t).catch((r)=>(pe.delete(n),console.warn("page-params: failed to enumerate $paths values:",r),{})),pe.set(n,o);return o}async function po(e){if(Array.isArray(e)){let t={};for(let n of e)for(let[o,r]of Object.entries(n))de(t,o,r);return t}if("contentType"in e&&typeof e.contentType==="string"&&e.contentType){let t=e.param??"slug",n=e.field??"id",o=await mo(e.contentType),r={[t]:[]};if(!Array.isArray(o))return r;for(let i of o)de(r,t,n==="id"?i.id:i.data?.[n]??i.id);return r}if("values"in e&&Array.isArray(e.values)){let t=e.param??"value",n={[t]:[]};for(let o of e.values)de(n,t,o);return n}if("$ref"in e&&typeof e.$ref==="string"&&e.$ref){let t=e.param??"id",n=e.field??"id",o=await p().readFile(e.$ref.replace(/^\.\//,"")),r=JSON.parse(o),i={[t]:[]};if(!Array.isArray(r))return i;for(let s of r)de(i,t,s?.[n]??s?.id??s);return i}return{}}async function fo(){let e=await Pd();for(let t of e){let n=t.classes?.find((o)=>o.name==="ContentCollection");if(n)return n.path}return"@jxsuite/parser/ContentCollection.class.json"}async function mo(e){let t={$prototype:"ContentCollection",$src:await fo(),contentType:e},n=p();if(n.resolveClass)return n.resolveClass(t);return fetch("/__jx_resolve__",{body:JSON.stringify(t),headers:{"content-type":"application/json"},method:"POST"}).then((o)=>{if(!o.ok)throw Error(`Class resolution failed: ${o.status}`);return o.json()})}function de(e,t,n){if(n===null||n===void 0||n==="")return;let o=String(n);e[t]??=[];let r=e[t];if(!r.includes(o))r.push(o)}function Pt(e,t,n){if(Object.keys(t).length===0)return e;let o=_e(e,t);return o.state??={},o.state.$page={params:{...t},title:typeof o.title==="string"?o.title:"",url:Db(n)},o}function St(e){if(!e)return[];return Object.keys(e).filter((t)=>{let n=e[t];return n&&typeof n==="object"&&typeof n.$prototype==="string"&&typeof n.$src==="string"&&JSON.stringify(n).includes('"#/$params/')})}async function Et(e,t,n){if(t.length===0)return;let o=p();if(!o.resolveClass)return;let{state:r}=e;if(!r)return;await Promise.all(t.map(async(i)=>{let s=r[i];if(!s||typeof s!=="object")return;try{r[i]=await o.resolveClass({...s,...n?{$base:n}:{}})}catch(a){console.warn(`page-params: failed to resolve state.${i} for preview:`,a)}}))}function _e(e,t){let n=ho(e,t);if(n!==null)return n;if(!e||typeof e!=="object")return e;if(Array.isArray(e))return e.map((r)=>_e(r,t));let o={};for(let[r,i]of Object.entries(e))o[r]=_e(i,t);return o}function ho(e,t){if(!e||typeof e!=="object"||Array.isArray(e))return null;let n=e.$ref;if(typeof n!=="string"||!n.startsWith("#/$params/"))return null;return t[n.slice(10)]??null}function ex(e){return typeof e?.tagName==="string"&&e.tagName.includes("-")}function Tt(e){if(e===null||typeof e==="number"||typeof e==="boolean")return"literal";if(typeof e==="string")return e.includes("${")?null:"literal";if(Array.isArray(e))return"literal";if(typeof e==="object"){let t=e;if(t.$expression||t.$compute||t.$prototype||t.$handler)return null;return"default"in t||"type"in t?"signal":"literal"}return null}function _T(e){let t=e?.state??{},n=[];for(let[o,r]of Object.entries(t)){if(Mp(o))continue;let i=Tt(r);if(!i)continue;let s=i==="signal"?r.default:r;n.push({name:o,value:s})}return n}function Mt(e,t){let n={...e.state??{}},o=!1;for(let[r,i]of Object.entries(t)){let s=Tt(n[r]);if(!s)continue;n[r]=s==="signal"?{...n[r],default:i}:i,o=!0}if(!o)return e;return{...e,state:n}}function Nt(e,t=[]){if(!e||typeof e!=="object")return null;if(Array.isArray(e.children)){let n=e.children.findIndex((o)=>o&&typeof o==="object"&&!o.$__layout);if(n!==-1)return{offset:n,prefix:[...t,"children"]};for(let o=0;o<e.children.length;o++){let r=e.children[o];if(r&&typeof r==="object"&&r.$__layout){let i=Nt(r,[...t,"children",o]);if(i)return i}}}return null}function je(e,t,n=[]){if(!e||typeof e!=="object")return;if(e.$__layout={file:t,path:n},Array.isArray(e.children))for(let[o,r]of e.children.entries()){if(typeof r==="string")continue;je(r,t,[...n,"children",o])}if(Array.isArray(e.$elements)){for(let[o,r]of e.$elements.entries())if(typeof r!=="string")je(r,t,[...n,"$elements",o])}}async function kt(e,t,n=null){let o={documentPath:t?.documentPath,mode:t?.doc.mode},r=n??Tl(t),i=r==="preview"?structuredClone(re(e)):A(Xu(e)),s=!1,a=o.documentPath&&D?.isSiteProject&&(o.documentPath.startsWith("pages/")||o.documentPath.startsWith("./pages/")),l=null,c=0;if(a&&t?.session.ui.showLayout!==!1){let w=$l(e.$layout);if(w){let v=await Ub(w);if(v){je(v,w.replace(/^\.\//,""));let C=r==="preview"?structuredClone(re(e)):i,x=ZT(v,C);i=r==="preview"?x:A(Xu(x)),s=!0;let E=Nt(x);l=E?.prefix??null,c=E?.offset??0}}}let d=hp(D?.projectRoot),f=o.documentPath?new URL(o.documentPath,d).href:void 0,h=fm(o.documentPath,{fileBaseUrl:d,...We()?{space:p().assetSpace}:{}});if(a&&t){let{previewParams:w}=t.session.ui;if(w&&Object.keys(w).length>0){let v=St(e.state??null);i=Pt(i,w,o.documentPath),await Et(i,v,f)}}if(!a&&t&&ex(i)){let{previewProps:w}=t.session.ui;if(w&&Object.keys(w).length>0)i=Mt(i,w)}let b=new Set;if(r!=="preview")(function w(v,C){if(!v||typeof v!=="object")return;if(v.$prototype==="Array"){b.add(C.join("/"));let x=v.map;if(x&&typeof x==="object")w(x,[...C,"map"]);return}if(Array.isArray(v.children))for(let x=0;x<v.children.length;x++){let E=v.children[x];if(typeof E==="string")continue;w(E,[...C,"children",x])}else if(v.children&&typeof v.children==="object"&&v.children.$prototype==="Array")w(v.children,[...C,"children"]);if(v.$switch&&v.cases)for(let[x,E]of Object.entries(v.cases))w(E,[...C,"cases",x])})(e,[]);let T=o.documentPath!=null&&(o.documentPath.startsWith("layouts/")||o.documentPath.startsWith("./layouts/")),R=Vb(i.$elements);if((o.mode==="content"||s||T)&&st.length>0){let w=new Set(R.map((C)=>typeof C==="string"?C:C?.$ref)),v=(C)=>{let x=new Set;if(!C||typeof C!=="object")return x;if(C.tagName)x.add(qe(C.tagName));if(Array.isArray(C.children)){for(let E of C.children)if(typeof E!=="string")for(let Xn of v(E))x.add(Xn)}return x};for(let C of v(i)){let x=st.find((E)=>E.tagName===C);if(x&&x.source!=="npm"&&x.path){let E=xc(o.documentPath??null,x.path);if(!w.has(E))R.push({$ref:E}),w.add(E)}}}if(R.length>0)i.$elements=R;i.imports=JT(i.imports);let O=Di(i.$media);if(O===void 0)delete i.$media;else i.$media=O;let U=YT(i.$head);if(U===void 0)delete i.$head;else i.$head=U;return{assets:h,docBase:f,mapperCtx:{arrayPaths:[...b],canvasMode:r,layoutWrapped:s,pageContentOffset:c,pageContentPrefix:l},renderDoc:i,siteStyle:D?.projectConfig?.style??null}}var CT="fullRender",kT="mountCanvas",ST="patchBatch",At="prepareRender",xo={derivedResolves:0,derivedRetargets:0,escalations:0,fullRenders:0,hostRenderPosts:0,lastEscalationReason:"",lastFullRenderMs:0,p95FullRenderMs:0,panelRenders:0,patchedOps:0,renderPreparations:0,skippedFullRenders:0,timings:{}};globalThis.__jxCanvasPerf=xo;var Rt=new Map;function $t(){try{return typeof localStorage<"u"&&Boolean(localStorage.getItem("jx-canvas-debug"))}catch{return!1}}function Ot(){return typeof performance<"u"&&typeof performance.now==="function"?performance.now():0}function It(e,t){if($t())console.debug(`[jx-canvas] ${e}`,t??"")}function Ab(e){xo.escalations+=1,xo.lastEscalationReason=e,It("escalation",e)}function go(e){if(e.length===0)return 0;let t=e.toSorted((o,r)=>o-r),n=Math.min(t.length-1,Math.ceil(t.length*0.95)-1);return t[Math.max(0,n)]??0}function vo(e,t){let n=Number.isFinite(t)&&t>0?t:0,o=Rt.get(e);if(!o)o=[],Rt.set(e,o);if(o.push(n),o.length>128)o.shift();let r=xo.timings[e],i={count:(r?.count??0)+1,lastMs:n,maxMs:Math.max(r?.maxMs??0,n),p95Ms:go(o),totalMs:(r?.totalMs??0)+n};if(xo.timings[e]=i,e==="fullRender")xo.lastFullRenderMs=i.lastMs,xo.p95FullRenderMs=i.p95Ms;It(`span:${e}`,`${n.toFixed(2)}ms`)}function Dt(e){let t=Ot(),n=$t(),o=`jx-${e}-start`;if(n)try{performance.mark(o)}catch{}let r=!1;return()=>{if(r)return xo.timings[e]?.lastMs??0;r=!0;let i=Ot()-t;if(n)try{performance.measure(`jx-${e}`,o),performance.clearMarks(o)}catch{}return vo(e,i),i}}function tx(e,t){let n=Dt(e);try{return t()}finally{n()}}async function nx(e,t){let n=Dt(e);try{return await t()}finally{n()}}function bi(e){if(e==="--")return"Base";return e.replace(/^--/,"").replaceAll("-"," ").replaceAll(/\b\w/g,(t)=>t.toUpperCase())||e}var Ht=new Set(["script","style","link","iframe","object","embed"]);function yd(e){let t={tagName:e};if(/^h[1-6]$/.test(e))t.textContent="Heading";else if(e==="p")t.textContent="Paragraph text";else if(e==="span"||e==="strong"||e==="em"||e==="small"||e==="mark"||e==="code"||e==="abbr"||e==="q"||e==="sub"||e==="sup"||e==="time")t.textContent="Text";else if(e==="a")t.textContent="Link",t.attributes={href:"#"};else if(e==="button")t.textContent="Button";else if(e==="label")t.textContent="Label";else if(e==="legend")t.textContent="Legend";else if(e==="caption")t.textContent="Caption";else if(e==="summary")t.textContent="Summary";else if(e==="li"||e==="dt"||e==="dd"||e==="th"||e==="td"||e==="option")t.textContent="Item";else if(e==="blockquote")t.textContent="Quote";else if(e==="pre")t.textContent="Preformatted text";else if(e==="input")t.attributes={placeholder:"Enter text...",type:"text"};else if(e==="img")t.attributes={alt:"Image"};else if(e==="iframe")t.attributes={src:""};else if(e==="slot")t.children=[{tagName:"p",textContent:"Slot content"}];else if(e==="select")t.children=[{tagName:"option",textContent:"Option 1"}];else if(e==="ul"||e==="ol")t.children=[{tagName:"li",textContent:"Item"}];else if(e==="dl")t.children=[{tagName:"dt",textContent:"Term"},{tagName:"dd",textContent:"Definition"}];else if(e==="table")t.children=[{children:[{children:[{tagName:"th",textContent:"Header"}],tagName:"tr"}],tagName:"thead"},{children:[{children:[{tagName:"td",textContent:"Cell"}],tagName:"tr"}],tagName:"tbody"}];else if(e==="details")t.children=[{tagName:"summary",textContent:"Summary"},{tagName:"p",textContent:"Detail content"}];return t}function j(e){if(!e)return[];if(Array.isArray(e.children))return e.children;return typeof e.textContent==="string"&&e.textContent.length>0?[e.textContent]:[]}function Y(e){let t=0;for(let n of e)t+=typeof n==="string"?n.length:Y(j(n));return t}function Fe(e,t,n){let o=[],r=0;for(let i of e){if(r>=n)break;if(typeof i==="string"){let c=r+i.length;if(c>t){let d=i.slice(Math.max(0,t-r),Math.max(0,Math.min(n,c)-r));if(d)o.push(d)}r=c;continue}let s=j(i),a=Y(s),l=r+a;if(a===0){if(r>=t&&r<n)o.push({...i})}else if(l>t){let c=Fe(s,Math.max(0,t-r),Math.min(n,l)-r);if(c.length>0)o.push(yo(i,c))}r=l}return o}function yo(e,t){let{children:n,textContent:o,...r}=e;if(t.length===0)return{...r,textContent:""};if(t.length===1&&typeof t[0]==="string")return{...r,textContent:t[0]};return{...r,children:t}}function Jt(e){let t=[];for(let n of e){if(typeof n==="string"){if(n.length===0)continue;let o=t.at(-1);if(typeof o==="string"){t[t.length-1]=o+n;continue}}t.push(n)}return t}function Lt(e,t,n,o,r=""){return Jt([...Fe(e,0,t),...r?[r]:[],...Fe(n,o,Y(n))])}function Ve(e){let t=Jt(e);if(t.length===0)return{textContent:""};if(t.length===1&&typeof t[0]==="string")return{textContent:t[0]};return{children:t}}function bo(e){if(!e)return!0;if(e.textContent!=null&&e.textContent.trim()==="")return!0;let t=e.children;if(!t)return!1;if(t.length===0)return!0;if(t.length===1&&typeof t[0]==="string"&&t[0].trim()==="")return!0;return t.length===1&&typeof t[0]==="object"&&t[0]?.tagName==="br"}function _t(e,t,n,o,r={}){if(!e)return;let i=K(e.doc.document,t);if(n){if(i&&JSON.stringify(i.children)===JSON.stringify(n))return;q(e,(s)=>{if(i?.textContent!=null)Ue(s,t,"textContent");Ue(s,t,"children",n)},{coalesceKey:r.coalesceKey??null})}else if(o!=null){if(i&&i.textContent===o&&!i.children)return;q(e,(s)=>{if(i?.children)Ue(s,t,"children");Ue(s,t,"textContent",o)},{coalesceKey:r.coalesceKey??null})}}function jt(e,t,n,o){if(!e)return!1;let r=K(e.doc.document,t);if(!r)return!1;if(`${r.$props?.[n]??""}`===o)return!1;return q(e,(s)=>{Uu(s,t,n,o)}),!0}function qt(e,t,n){if(!e)return null;let o=K(e.doc.document,t),r=K(e.doc.document,n);if(!o||!r)return null;if(qa(t,n)||qa(n,t))return null;let i=j(r),s=j(o),a=Y(i),l=Ve([...i,...s]);return q(e,(c)=>{if(l.children){if(r.textContent!=null)Ue(c,n,"textContent");Ue(c,n,"children",l.children)}else{if(r.children)Ue(c,n,"children");Ue(c,n,"textContent",l.textContent??"")}if(Vu(c,t),Ft(c,ht(t)),Cp(e))c.session.selection=[n]}),{offset:a,path:n}}function Ft(e,t){let n=t;while(n.length>0){let o=K(e.doc.document,n),r=o?.children;if(!o||!Array.isArray(r)||r.length>0)return;let i=ht(n);if(Vu(e,n),!i)return;n=i}}function Wt(e,t,n,o){let r=ht(t),i=_n(t),s=[...r,"children",i+1];if(!e)return s;let a={tagName:"p"};if(o.textContent!=null)a.textContent=o.textContent;else if(o.children)a.children=o.children;else a.textContent="";return q(e,(l)=>{if(n.textContent!=null)Ue(l,t,"children"),Ue(l,t,"textContent",n.textContent);else if(n.children)Ue(l,t,"textContent"),Ue(l,t,"children",n.children);if(Ji(l,r,i+1,a),Cp(e))l.session.selection=[s]}),s}function Vt(e,t,n,o){if(bo(o)){if(!e)return t;return q(e,(l)=>{Ue(l,t,"tagName",n.tag),Ue(l,t,"children");let c=yd(n.tag);if(c.textContent&&c.textContent!=="Paragraph text")Ue(l,t,"textContent",c.textContent);else Ue(l,t,"textContent");if(Cp(e))l.session.selection=[t]}),t}let r=ht(t),i=_n(t),s=[...r,"children",i+1];if(!e)return s;let a=yd(n.tag);return q(e,(l)=>{if(o?.children)Ue(l,t,"textContent"),Ue(l,t,"children",o.children);else if(o?.textContent!=null)Ue(l,t,"children"),Ue(l,t,"textContent",o.textContent);if(Ji(l,r,i+1,structuredClone(a)),Cp(e))l.session.selection=[s]}),s}function Bt(e,t,n,o,r){if(!e)return null;let i=K(e.doc.document,t.path),s=K(e.doc.document,n.path);if(!i||!s)return null;if(qa(t.path,n.path)||qa(n.path,t.path))return null;let a=Ve(Lt(j(i),t.offset,j(s),n.offset,r)),l=[...o,n.path].toSorted(Co);return q(e,(c)=>{if(a.children){if(i.textContent!=null)Ue(c,t.path,"textContent");Ue(c,t.path,"children",a.children)}else{if(i.children)Ue(c,t.path,"children");Ue(c,t.path,"textContent",a.textContent??"")}for(let d of l)if(K(c.doc.document,d))Vu(c,d),Ft(c,ht(d));if(Cp(e))c.session.selection=[t.path]}),{offset:t.offset+r.length,path:t.path}}function Co(e,t){let n=Math.min(e.length,t.length);for(let o=0;o<n;o++){let r=e[o],i=t[o];if(r===i)continue;if(typeof r==="number"&&typeof i==="number")return i-r;return String(i).localeCompare(String(r))}return t.length-e.length}function M(e,t=1){return{height:e.height*t,left:e.x*t,top:e.y*t,width:e.width*t}}function ET(e,t,n=1){return{x:(e.x-t.left)/n,y:(e.y-t.top)/n}}function fe(e,t){if(!t){e.style.display="none";return}e.style.display="block",e.style.left=`${t.left}px`,e.style.top=`${t.top}px`,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`}function zt(e=document){let t=e.createElement("div");t.className="jx-canvas-iframe-overlay",t.style.cssText="position:absolute;inset:0;pointer-events:none;overflow:hidden;z-index:2";let n=e.createElement("div");n.className="overlay-box overlay-selection",n.style.display="none";let o=e.createElement("div");o.className="overlay-label",o.style.display="none",n.append(o);let r=e.createElement("div");r.className="overlay-box overlay-hover",r.style.display="none";let i=e.createElement("div");i.className="canvas-drop-indicator",i.style.display="none";let s=e.createElement("button");s.className="insertion-helper",s.textContent="+",s.style.pointerEvents="auto",s.style.display="none";let a=e.createElement("div");a.className="canvas-replace-target",a.style.display="none";let l=e.createElement("div");l.className="overlay-presence-group";let c=e.createElement("div");return c.className="overlay-coselection-group",t.append(r,n,c,i,a,s,l),{dispose:()=>t.remove(),insertButton:s,root:t,setDropIndicator:(d,f="inside")=>So(i,d,f),setHover:(d)=>fe(r,d),setInsertZone:(d,f="center")=>Po(s,d,f),setReplaceTarget:(d)=>fe(a,d),setSuppressed:(d)=>{t.style.display=d?"none":""},setCoSelection:(d)=>{c.replaceChildren();for(let f of d){let h=e.createElement("div");h.className="overlay-box overlay-selection overlay-coselection",fe(h,f),c.append(h)}},setPresence:(d)=>{l.replaceChildren();for(let f of d){let h=e.createElement("div");h.className="overlay-box overlay-presence",h.style.cssText=`position:absolute;display:block;pointer-events:none;outline:1.5px solid ${f.color};outline-offset:1px;left:${f.placement.left}px;top:${f.placement.top}px;width:${f.placement.width}px;height:${f.placement.height}px`;let b=e.createElement("div");b.className="overlay-presence-tag",b.textContent=f.label,b.style.cssText=`position:absolute;top:-18px;left:-2px;padding:1px 5px;border-radius:3px;font:10px/1.4 sans-serif;color:#fff;white-space:nowrap;background:${f.color}`,h.append(b),l.append(h)}},setSelection:(d,f=null)=>{if(fe(n,d),d&&f)o.textContent=f,o.style.display="block";else o.style.display="none"}}}function Po(e,t,n){if(!t){e.style.display="none",e.classList.remove("visible");return}e.dataset.edge=n,e.classList.add("visible"),e.style.display="grid",e.style.left=`${t.left+t.width/2}px`,e.style.top=`${t.top+t.height/2}px`,e.style.translate="-50% -50%"}function So(e,t,n){if(!t){e.style.display="none";return}if(e.style.display="block",e.style.left=`${t.left}px`,e.style.width=`${t.width}px`,n==="inside"){e.className="canvas-drop-indicator inside",e.style.top=`${t.top}px`,e.style.height=`${t.height}px`;return}e.className="canvas-drop-indicator line",e.style.height="",e.style.top=`${n==="top"?t.top:t.top+t.height}px`}function Il(e){return JSON.stringify(e)}var wd={$id:"elements-meta",title:"HTML Element Metadata",description:"Inline scoping and inline toolbar action metadata for HTML elements.",$convertGroups:{text:["p","h1","h2","h3","h4","h5","h6","blockquote"],container:["div","section","article","aside","main","header","footer","nav","search"],list:["ul","ol"]},$defs:{p:{$convertTo:"text",$convertToWhenEmpty:["text","container"],$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:[{tag:"strong",label:"Bold",command:"bold"},{tag:"em",label:"Italic",command:"italic"},{tag:"u",label:"Underline",command:"underline"},{tag:"del",label:"Strikethrough",command:"strikethrough"},{tag:"sup",label:"Superscript",command:"superscript"},{tag:"sub",label:"Subscript",command:"subscript"},{tag:"code",label:"Code",command:"code"},{tag:"a",label:"Link",command:"link"}]},h1:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:[{tag:"strong",label:"Bold",command:"bold"},{tag:"em",label:"Italic",command:"italic"},{tag:"code",label:"Code",command:"code"},{tag:"a",label:"Link",command:"link"}]},h2:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h3:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h4:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h5:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h6:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},li:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},td:{$inlineChildren:["em","strong","del","code","a","span","br","b","i","u","sub","sup","s"],$inlineActions:"p"},th:{$inlineChildren:["em","strong","del","code","a","span","br","b","i","u","sub","sup","s"],$inlineActions:"p"},blockquote:{$convertTo:"text",$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},figcaption:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},caption:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},summary:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},dt:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},dd:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},label:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},a:{$inlineChildren:["em","strong","code","span","br","b","i","u","sub","sup"],$inlineActions:[{tag:"strong",label:"Bold",command:"bold"},{tag:"em",label:"Italic",command:"italic"},{tag:"code",label:"Code",command:"code"}]},span:{$inlineChildren:["em","strong","del","code","a","br","b","i","u","sub","sup","s"],$inlineActions:"p"},div:{$convertTo:"container",$convertToWhenEmpty:["container","text"],$inlineChildren:[]},section:{$convertTo:"container",$inlineChildren:[]},article:{$convertTo:"container",$inlineChildren:[]},nav:{$convertTo:"container",$inlineChildren:[]},main:{$convertTo:"container",$inlineChildren:[]},header:{$convertTo:"container",$inlineChildren:[]},footer:{$convertTo:"container",$inlineChildren:[]},aside:{$convertTo:"container",$inlineChildren:[]},ul:{$convertTo:"list",$inlineChildren:[]},ol:{$convertTo:"list",$inlineChildren:[]},pre:{$inlineChildren:["code"]},table:{$inlineChildren:[]},thead:{$inlineChildren:[]},tbody:{$inlineChildren:[]},tr:{$inlineChildren:[]}}};var To=new Set(["pre"]),na=new Set(Object.entries(wd.$defs).filter(([e,t])=>!To.has(e)&&(t.$inlineChildren?.length??0)>0).map(([e])=>e));var Kt=new Set(["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"]);function Be(e,t){if(!t)return Kt.has(e);let n=wd.$defs[t];if(!n||!n.$inlineChildren)return!1;return n.$inlineChildren.includes(e)}function TT(e){let t=wd.$defs[e];if(!t)return null;let n=t.$inlineActions;if(typeof n==="string")n=wd.$defs[n]?.$inlineActions??void 0;if(!Array.isArray(n))return null;return n}var Mo=null;function ix(e,t){if(!e||typeof e!=="object")return!1;let n=(qe(e.tagName)||"div").toLowerCase();if(t){let o=(qe(t.tagName)||"div").toLowerCase();return Be(n,o)}return Kt.has(n)}function LT(){return Mo!==null}function me(e){return!e||e==="base"?null:e}function Nb(e){let t=e.panels;if(t.length===0)return null;if(t.length===1)return t[0];let n=Nu(e.paneId);for(let o of t){if(n===null&&(o.mediaName==="base"||o.mediaName===null))return o;if(o.mediaName===n)return o}return t[0]}function Ut(){return Nb(Uo())}function IT(e,t){if(!e)return t;let n=t;while(n.length>=2){let o=K(e,n),r=ht(n),i=r?K(e,r):null;if(!o||!i)break;let s=(qe(o.tagName)||"div").toLowerCase(),a=(qe(i.tagName)||"div").toLowerCase();if(!Be(s,a))break;n=r}return n}function Ob(e){return Dv(e)!==null}function Ou(e){return Dv(e)}function hr(e){if(!e)return{baseWidth:320,featureQueries:[],sizeBreakpoints:[]};let t=[],n=[],o=320;for(let[r,i]of Object.entries(e)){if(r==="--"){let l=String(i).match(/^(\d+)\s*px$/);o=l?Number(l[1]):320;continue}let s=i.match(/min-width:\s*([\d.]+)px/),a=i.match(/max-width:\s*([\d.]+)px/);if(s)n.push({name:r,query:i,type:"min",width:Number(s[1])});else if(a)n.push({name:r,query:i,type:"max",width:Number(a[1])});else t.push({name:r,query:i})}return n.sort((r,i)=>r.type==="min"?r.width-i.width:i.width-r.width),{baseWidth:o,featureQueries:t,sizeBreakpoints:n}}function No(e,t){let n=new Set;for(let o of e)if(o.type==="min"&&t>=o.width)n.add(o.name);else if(o.type==="max"&&t<=o.width)n.add(o.name);return n}function Gt(e,t){let n=No(e,t),o=null;for(let r of e){if(!n.has(r.name))continue;let i=Math.abs(r.width-t);if(o===null){o=r;continue}let s=Math.abs(o.width-t);if(i<s||i===s&&r.width<o.width)o=r}return o?.name??null}function RT(e,t,n=8){let o=null;for(let r of t){let i=Math.abs(r-e);if(i>n)continue;if(o===null||i<Math.abs(o-e))o=r}return o??e}var cp=240,$T=8,DT=16,he=new Map;function ze(e){return hr(Di(e.doc.document?.$media))}function ox(e){let{baseWidth:t,sizeBreakpoints:n}=ze(e),o=e.session.ui.activeMedia;return n.find((r)=>r.name===o)?.width??t}function ko(e,t){let n=he.get(e);if(!n)return null;if(!t||n.tabId!==t.id||n.media!==t.session.ui.activeMedia)return he.delete(e),null;return n.width}function AT(e,t){let n=t?ox(t):0;return ko(e.paneId,t)??n}function rx(e){he.delete(e)}function NT(e){let{baseWidth:t,sizeBreakpoints:n}=ze(e);return[t,...n.map((o)=>o.width)]}function sx(e,t,n){let{sizeBreakpoints:o}=ze(t),r=Gt(o,n);return t.session.ui.activeMedia=r,he.set(e,{media:r,tabId:t.id,width:n}),r}var Ke={invokerTags:jm,popoverTags:jd};function G1(e,t){if(!e||!t)return null;for(let n=t.length;n>=0;n-=1){let o=t.slice(0,n),r=K(e,o);if(r&&typeof r==="object"&&Gs(r,Ke))return o}return null}function Zt(e,t){let n=e.doc.document;if(!n)return null;if(t){let o=K(n,t);return o&&typeof o==="object"&&Gs(o,Ke)?t:null}return G1(n,Le(e.session.selection))}function Xt(){let e=u.value?.doc.document;return e?wI(e,Ke):!1}var Yt=["toggle-popover","show-popover","hide-popover","show-modal","close","request-close"],Ge=new Set(["show-modal","close","request-close"]),Ze=new Set(["toggle-popover","show-popover","hide-popover"]),Ro=["any","closerequest","none"],Oo=new Set(["button"]),I="See docs/framework/concepts/overlays.";function H(e){return ro(e)==="dialog"}function Qt(e){return e.startsWith("--")}function Ao(e){let t=[];for(let{node:n}of Ya(e)){let o=nh(n);if(H(n)&&o!==null&&!t.includes(o))t.push(o)}return t}function en(e){for(let{node:t}of Ya(e))if(H(t))return!0;return!1}function $o(e){let t=e.oncommand;return t!==void 0&&t!==null}function Io(e,t){for(let{node:n}of Ya(e)){if(n===e)continue;let o=ro(n);if(o==="button"){let r=Kr(n,"command"),i=Kr(n,"commandfor");if(r!==null&&(r==="close"||r==="request-close")&&(i===null||i===t))return!0}if(o==="form"&&Kr(n,"method")?.toLowerCase()==="dialog")return!0}return!1}function vT(e,t){let n=[...Ya(e,[],null,t)],o=Ao(e),r=Fm(e,t),i=o.length>0||r.length>0,s=new Map,a=new Map;for(let{node:c}of n){let d=nh(c);if(d!==null&&!s.has(d))s.set(d,c);if(ro(c)==="button"){let f=Kr(c,"commandfor"),h=Kr(c,"command");if(f!==null){let b=a.get(f)??new Set;b.add(h??""),a.set(f,b)}}}let l=[];for(let{node:c,path:d}of n)if(l.push(...Ho(c,d,s,o,r,i,t)),H(c))l.push(...Jo(c,d,a));return l}function Ho(e,t,n,o,r,i,s){let a=[],l=ro(e),c=s?.invokerTags?.has(l)??!1,d=Kr(e,"command"),f=Kr(e,"commandfor");if(!(d!==null||f!==null||("command"in Wl(e))||("commandfor"in Wl(e))))return a;let b=Jr(e,"the element");if(!Oo.has(l)&&!c)return a.push({detail:"`command` and `commandfor` are attributes of `HTMLButtonElement` and of no other "+"interface — not even `<input>`, which `popovertarget` does allow. Elsewhere they parse "+`and do nothing. Make it a <button>, or remove both attributes. ${I}`,fix:"invoker",message:`<${l||"element"}> carries command/commandfor, which only <button> supports.`,path:t,rule:"invoker-not-button",severity:"error"}),a;if(d!==null&&!Yt.includes(d)&&!Qt(d))return a.push({detail:`\`command\` is an enumerated attribute taking ${Yt.map((T)=>`\`${T}\``).join(", ")}, or a custom command starting with \`--\`. Anything else is the invalid-value state, and a button in that state does nothing when clicked. ${I}`,message:`${b} declares command="${d}", which is not a built-in or --custom command.`,path:t,rule:"command-invalid",severity:"error"}),a;if(f!==null){let T=n.get(f),R=o.includes(f),O=r.includes(f);if(!T&&i){let U=[...o,...r].map((w)=>`"${w}"`).join(", ");return a.push({detail:`No element in this document has the id "${f}". The dialogs and popovers here are: ${U}. A commandfor that names nothing does nothing, silently. ${I}`,message:`commandfor="${f}" names nothing in this document.`,path:t,rule:"command-target-missing",severity:"error"}),a}if(d!==null&&T){if(Ge.has(d)&&!H(T))a.push({detail:`\`${d}\` acts on a <dialog>, and "${f}" is ${O?"a popover":`a <${ro(T)||"element"}>`}. The click is ignored. ${O?"Use `toggle-popover`, `show-popover` or `hide-popover` for a popover.":"Point it at a dialog, or make the target one."} ${I}`,message:`${b} sends ${d} to "${f}", which is not a dialog.`,path:t,rule:"command-target-mismatch",severity:"error"});else if(Ze.has(d)&&!Gs(T,s))a.push({detail:`\`${d}\` acts on a popover, and "${f}" is ${R?"a dialog":`a <${ro(T)||"element"}>`} that declares no \`popover\`. The click is ignored. ${R?"Use `show-modal`, `close` or `request-close` for a dialog.":"Give the target a `popover` attribute, or point the button elsewhere."} ${I}`,message:`${b} sends ${d} to "${f}", which is not a popover.`,path:t,rule:"command-target-mismatch",severity:"error"});else if(Qt(d)&&!$o(T))a.push({detail:`A custom command is a \`CommandEvent\` dispatched at its target, and "${f}" has no `+"`oncommand` handler to answer it — so the click does nothing. Add one that switches on "+`\`event#/command\`, or use a built-in command. ${I}`,message:`${b} sends ${d} to "${f}", which handles no command.`,path:t,rule:"custom-command-unhandled",severity:"warn"})}}return a}function Jo(e,t,n){let o=[],r=Jr(e,"the dialog"),i=nh(e),{style:s}=e,a=Kr(e,"closedby");if(a!==null&&!Ro.includes(a))o.push({detail:`\`closedby\` is an enumerated attribute taking \`any\` (light dismiss and Escape), \`closerequest\` (Escape only, the default for a modal) or \`none\`. Anything else is the invalid-value default, \`auto\`, which is the same as leaving it out. ${I}`,message:`${r} declares closedby="${a}", which is not any, closerequest or none.`,path:t,rule:"dialog-closedby-invalid",severity:"error"});if(Qo(s,"display")!==null)o.push({detail:`A closed dialog is hidden by the browser's own \`dialog:not([open]) { display: none }\`. That rule is UA-origin, so any author \`display\` beats it, and the dialog is laid out on every page whether or not anyone opened it. \`display\` belongs in the \`&[open]\` rule and nowhere else. ${I}`,fix:"display",message:`${r} sets display in its base rule.`,path:t,rule:"dialog-display",severity:"error"});let l=i===null?void 0:n.get(i),c=Kr(e,"open")!==null||Wl(e).open===!0||e.open===!0;if(i!==null&&!l?.has("show-modal")&&!c)o.push({detail:`No <button> in this document opens it with \`command="show-modal"\`. If it is opened from another file or from a function that calls \`showModal()\`, this is fine; otherwise there is no way for a reader to open it. ${I}`,message:`${r} has no invoker in this document.`,path:t,rule:"dialog-no-invoker",severity:"warn"});if(l?.has("show-modal")&&a==="none"&&!Io(e,i))o.push({detail:`A modal dialog makes everything outside it inert, so the only ways out are the ones it offers: \`closedby="none"\` turns off Escape and light dismiss, and nothing inside it closes it. A reader who opens it cannot leave. Add a <button command="close"> inside, or drop \`closedby="none"\`. ${I}`,message:`${r} opens modally, closes on nothing, and has no close button.`,path:t,rule:"modal-without-close",severity:"error"});return o}function K1(e,t){if(!e||!t)return null;for(let n=t.length;n>=0;n-=1){let o=t.slice(0,n),r=K(e,o);if(r&&typeof r==="object"&&H(r))return o}return null}function ax(e,t){let n=e.doc.document;if(!n)return null;if(t){let o=K(n,t);return o&&typeof o==="object"&&H(o)?t:null}return K1(n,Le(e.session.selection))}function tn(){let e=u.value?.doc.document;return e?en(e):!1}function V(e){return lt(e.paneId)}function ee(e){let t=ur(e.paneId);if(t?.kind==="lens")return t.zoom;return V(e)?.session.ui.zoom??1}function lx(e=Uo()){return ee(e)}function ve(e,t){let n=ur(e.paneId);if(n?.kind==="lens"){n.zoom=t;return}let o=V(e);if(o)o.session.ui.zoom=t}function Mu(e,t,n,o=null){let r={_width:o||null,canvas:null,element:null,mediaName:e||"",ready:!1,renderScope:null,scrollContainer:null,viewport:null},i=[];if(o&&!n)i.push(`--panel-viewport-w:${o}px`);if(o)i.push(`--panel-canvas-w:${o}px`);return{item:{fullWidth:n,header:t?"shown":"hidden",key:e??"",label:t??"",mediaAttr:e,widthVars:i.join(";")},panel:r}}function OT(e,t){for(let{item:n,panel:o}of e)o.element=t.panelNode(n.key,"panel"),o.viewport=t.panelNode(n.key,"panel-viewport"),o.canvas=t.panelNode(n.key,"panel-canvas")}function MT(e,t){let n=e.find((r)=>r.item.key===t);if(!n)return;let o=wt(n.panel);if(o)o.session.ui.activeMedia=me(n.item.mediaAttr)}function Qe(e){if(!e.panzoomWrap)return;let t=e.wrap.clientWidth,n=e.panzoomWrap.scrollWidth,o=ee(e),r=n*o;e.panX=Math.max(16,(t-r)/2),e.panY=0}function Mb(e){if(e.centerObserver)e.centerObserver.disconnect(),e.centerObserver=null;if(!e.panzoomWrap)return;e.needsCenter=!0,e.centerObserver=new ResizeObserver(()=>{if(!e.needsCenter){e.centerObserver?.disconnect(),e.centerObserver=null;return}Qe(e),us(e)}),e.centerObserver.observe(e.panzoomWrap),Qe(e)}function us(e){if(!e.panzoomWrap)return;let t=ee(e);e.panzoomWrap.style.transform=`translate(${e.panX}px, ${e.panY}px) scale(${t})`,Ai("overlays")}var et=0.25,tt=3;function rn(e){return Math.min(tt,Math.max(et,e))}function xd(e=Uo()){if(wo(e.paneId)!=="edit")return;let[t]=e.panels;if(!t?.canvas||!t.viewport)return;let n=t.canvas,o=n.querySelector("iframe"),r=V(e)?.session.ui.editZoom??1;if(r===1){if(t._width=null,n.style.width="",n.style.transform="",n.style.transformOrigin="",o)o.style.width="100%";t.viewport.style.height=""}else{let i=e.wrap.querySelector('[part="edit-column"]');if(!i)return;let s=Oe(i).width;if(s<=0)return;let a=s/r;if(t._width=a,n.style.width=`${a}px`,n.style.transform=`scale(${r})`,n.style.transformOrigin="top left",o)o.style.width=`${a}px`,t.viewport.style.height=`${o.offsetHeight*r}px`}Ai("overlays")}function Pu(e,t=Uo()){let n=V(t);if(!n)return;n.session.ui.editZoom=rn(e),xd(t)}var Xe=new Map;function PT(e,t=Uo()){let n=V(t);if(!n)return;if(n.session.ui.editZoom=rn(e),Xe.has(t.paneId))return;Xe.set(t.paneId,requestAnimationFrame(()=>{Xe.delete(t.paneId),xd(t)}))}function an(e,t,n){if(!e.panzoomWrap)return;let o=e.wrap.clientWidth,r=e.wrap.clientHeight,i=24,s=32,a=0,{panels:l}=e;for(let v of l)a+=v._width||800;a+=i*Math.max(0,l.length-1)+s;let c=ee(e),h=Oe(e.panzoomWrap).height/c+s,b=o/a,T=r/h,R=t==="width"?b:Math.min(b,T),O=Math.min(n,Math.max(F,R));ve(e,O);let U=a*O,w=h*O;e.panX=Math.max(0,(o-U)/2),e.panY=Math.max(0,(r-w)/2),us(e)}function FT({maxZoom:e=W,surface:t=Uo()}={}){te("page",t),an(t,"page",e)}var F=0.05,W=5;function rt(e){return Math.min(W,Math.max(F,e))}var Lo="page",nt=["width","page","none"];function jo(e,t,n){let o=t[n];if(typeof o==="string"&&nt.includes(o))return o;if(typeof o==="number"&&o>=F&&o<=W)return o;throw RangeError(`command "${e}" argument "${n}": expected ${nt.map((r)=>`"${r}"`).join(" | ")} or a number in [${F}, ${W}], got ${JSON.stringify(o)}`)}var sn=new Map;function ln(e){let t=V(e);if(!t)return null;let n=ur(e.paneId)?.kind==="lens"?`::${e.paneId}`:"";return`${t.id}::${t.documentPath??""}${n}`}function te(e,t){let n=ln(t);if(n)sn.set(n,e)}function cx(e=Uo()){let t=ln(e);return(t===null?void 0:sn.get(t))??Lo}function cn(e,t=Uo()){let n=e??cx(t);if(n==="none"){us(t);return}if(typeof n==="number"){ve(t,rt(n)),us(t);return}an(t,n,1)}function J1(e,t=Uo()){te(e,t),cn(e,t)}function jT(e=Uo()){te(rt(ee(e)),e)}function dx(e,t=Uo()){if(!V(t))return;let o=rt(e);te(o,t),ve(t,o),us(t)}function ux(e){if(e.wrap.clientWidth<=0){us(e);return}cn(cx(e),e)}function HT(e=Uo()){if(te(1,e),!e.panzoomWrap)return;ve(e,1),Qe(e),us(e)}function qo(e,t){let n=Oe(un(e)??e.wrap),o=t.top+t.height/2-n.top;return n.height/2-o}function un(e){return Nb(e)?.scrollContainer??null}function Fo(e,t,n){let o=un(e);if(!o){Wo(e,t);return}let r=o.scrollTop-t;if(n){o.scrollTo({behavior:"smooth",top:r});return}o.scrollTop=r}function Pb(e,t=Uo()){Fo(t,qo(t,e),!1)}function Wo(e,t){let n=e.panY,o=n+t,r=performance.now(),i=250,s=(a)=>{let l=Math.min((a-r)/250,1),c=l*(2-l);if(e.panY=n+(o-n)*c,us(e),l<1)requestAnimationFrame(s)};requestAnimationFrame(s)}var Ye=["edit","design","preview","source","stylebook","grid","git-diff"],ye=new Set(["edit","design"]),Vo=["edit","design","preview"];function Bo(e){return Vo.filter((t)=>e.capabilities.modes.includes(t))}function BT(e){return Bo(e).filter((t)=>t!=="preview")}function Y1(e){let t=e.session.ui.canvasMode;return ye.has(t)?t:null}function Z1(e){return{available:e.capabilities.modes.includes("preview")&&ye.has(e.session.ui.canvasMode),on:e.session.ui.preview===!0}}function X1(e,t,n){if(t==="preview"){if(ye.has(e.session.ui.canvasMode))e.session.ui.preview=!0;return}if(e.session.ui.preview=!1,e.session.ui.canvasMode!==t)n(e,t)}var nn=new Set(["design","stylebook","git-diff"]),N=(e)=>e.document.open,on=["auto","light","dark"];function zo(e){function t(s){let a=u.value;if(!a)throw RangeError(`command "${s}" needs an open document; no tab is active`);return a}function n(s,a){let{pane:l}=a;if(l===void 0)return t(s);let c=ot(s,a,"pane"),d=lt(c);if(!d)throw RangeError(`command "${s}" argument "pane": "${c}" has no open document`);return d}let o={pane:He("Which pane to render this way. Defaults to the focused one.")};function r(s){e.renderPane(i(s))}function i(s){let{pane:a}=s;return typeof a==="string"?a:m.activePaneId}return[{args:Se({mode:Do(Ye,"The canvas mode to switch the active pane to.")}),category:"View",id:"canvas.setMode",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:N,aiTool:{description:"Switch the active document's editor mode. edit and design put its element tree on the canvas, where the document tools work; preview renders it as a visitor sees it; source shows the JSON; stylebook, grid and git-diff open other editors. Use it to return a document to edit or design when the tree tools are refused.",name:"set_canvas_mode",report:({after:s,args:a})=>{let l=li("canvas.setMode",a,"mode",Ye),c=s.editor.kind==="canvas"?"the document tools address its element tree":"the tree-editing tools are unavailable until it returns to edit or design";return`The active document is in ${l} mode; ${c}.`}},run:(s,a)=>{let l=li("canvas.setMode",a,"mode",Ye),c=t("canvas.setMode"),{modes:d}=c.capabilities;if(!d.includes(l))throw RangeError(`command "canvas.setMode" argument "mode": "${l}" is not a mode this document `+`supports — it declares: ${d.join(", ")}`);if(l==="preview"){let f=c.session.ui.canvasMode;if(!ye.has(f))throw RangeError(`command "canvas.setMode" argument "mode": "preview" composes with the edit and design base modes; this pane is in "${f}"`);c.session.ui.preview=!0;return}c.session.ui.preview=!1,e.setCanvasMode(c,l)},title:"Set Canvas Mode"},{args:Se({zoom:qC("Pan-zoom scale, 1 = 100%.",{maximum:W,minimum:F})}),category:"View",id:"canvas.setZoom",level:"document",menus:["palette"],group:"3_canvas",requires:"a document on the pan-zoom surface",when:N,enablement:()=>nn.has(e.getCanvasMode()),run:(s,a)=>{t("canvas.setZoom"),dx(yv("canvas.setZoom",a,"zoom",F,W))},title:"Set Zoom"},{args:Se({fit:{description:'How the document is framed: "width" | "page" | "none", or a numeric pan-zoom scale.',oneOf:[{enum:[...nt],type:"string"},{maximum:W,minimum:F,type:"number"}]}}),category:"View",id:"canvas.setFit",level:"document",menus:["palette"],group:"3_canvas",requires:"a document on the pan-zoom surface",when:N,enablement:()=>nn.has(e.getCanvasMode()),run:(s,a)=>{t("canvas.setFit"),J1(jo("canvas.setFit",a,"fit"))},title:"Set Fit"},{args:Se({zoom:qC("Edit-mode content zoom, 1 = 100%.",{maximum:tt,minimum:et})}),category:"View",id:"canvas.setEditZoom",level:"document",menus:["palette"],group:"3_canvas",requires:"a document in edit mode",when:N,enablement:()=>e.getCanvasMode()==="edit",run:(s,a)=>{t("canvas.setEditZoom"),Pu(yv("canvas.setEditZoom",a,"zoom",et,tt))},title:"Set Edit Zoom"},{args:{additionalProperties:!1,properties:{...o,width:{description:"How wide the Edit column should render, in CSS pixels, or null to go back to the chosen breakpoint's own width.",type:["number","null"]}},required:["width"],type:"object"},category:"View",id:"canvas.setEditWidth",level:"document",menus:["palette"],group:"3_canvas",requires:"a document in edit mode",when:N,enablement:()=>e.getCanvasMode()==="edit",run:(s,a)=>{let l=n("canvas.setEditWidth",a),{width:c}=a;if(c===null){rx(i(a)),r(a);return}sx(i(a),l,yv("canvas.setEditWidth",a,"width",cp,1e4)),r(a)},title:"Set Edit Width"},{args:{additionalProperties:!1,properties:{...o,media:{description:"A breakpoint key the document renders under, or null for the base rendering.",type:["string","null"]}},required:["media"],type:"object"},category:"View",id:"canvas.setBreakpoint",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:N,run:(s,a)=>{let l=n("canvas.setBreakpoint",a),{media:c}=a;if(c!==null&&typeof c!=="string")throw RangeError('command "canvas.setBreakpoint" argument "media": expected a breakpoint key or null');let d=Object.keys(Di(l.doc.document?.$media));if(c!==null&&!d.includes(c))throw RangeError(`command "canvas.setBreakpoint" argument "media": "${c}" is not a breakpoint this `+`document defines — it defines: ${d.length>0?d.join(", "):"nothing"}`);l.session.ui.activeMedia=c,r(a)},title:"Set Breakpoint"},{args:Se({...o,scheme:Do(on,"Which color scheme the canvas renders in.")},["scheme"]),category:"View",id:"canvas.setColorScheme",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:N,run:(s,a)=>{let l=n("canvas.setColorScheme",a);l.session.ui.previewColorScheme=li("canvas.setColorScheme",a,"scheme",on),r(a)},title:"Set Color Scheme"},{args:Se({...o,locale:He("BCP 47 tag this pane renders as.")},["locale"]),category:"View",id:"i18n.switchLocale",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document in a project that declares more than one locale",when:(s)=>s.document.open&&s.project.isMultilingual,run:(s,a)=>{let l=n("i18n.switchLocale",a),c=ot("i18n.switchLocale",a,"locale"),d=ps();if(d===null||!d.locales.includes(c))throw RangeError(`command "i18n.switchLocale" argument "locale": "${c}" is not a locale this `+`project declares — it declares: ${d===null?"nothing":d.locales.join(", ")}`);l.session.ui.previewLocale=c,r(a)},title:"Set Rendering Language"},{args:Se({...o,visible:oo("True to draw the page's layout elements, false to hide them.")},["visible"]),category:"View",id:"canvas.setLayoutVisible",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:N,run:(s,a)=>{let l=n("canvas.setLayoutVisible",a);l.session.ui.showLayout=yi("canvas.setLayoutVisible",a,"visible"),r(a)},title:"Show Layout Elements"},{args:Se({...o,open:oo("True to draw the popover open, false to close it."),path:{description:"Document path of the popover. Defaults to the popover the selection is in or at.",items:{type:["string","number"]},type:"array"}},[]),category:"View",enablement:()=>Xt(),group:"3_canvas",id:"canvas.setPopoverOpen",level:"document",menus:["palette"],requires:"a popover in the open document",run:(s,a)=>{let l=n("canvas.setPopoverOpen",a),c=a??{},d=c.open===void 0?!0:yi("canvas.setPopoverOpen",a,"open");if(!d&&c.path===void 0){e.setOpenPopover(l,null);return}let f=Zt(l,c.path);if(f===null)throw RangeError('command "canvas.setPopoverOpen" argument "path": names no popover in this document — '+"a popover is an element with a `popover` attribute, and <dialog> is not one");e.setOpenPopover(l,d?f:null)},title:"Show Popover",when:N},{args:Se({...o,open:oo("True to draw the dialog open, false to close it."),path:{description:"Document path of the dialog. Defaults to the dialog the selection is in or at.",items:{type:["string","number"]},type:"array"}},[]),category:"View",enablement:()=>tn(),group:"3_canvas",id:"canvas.setDialogOpen",level:"document",menus:["palette"],requires:"a dialog in the open document",run:(s,a)=>{let l=n("canvas.setDialogOpen",a),c=a??{},d=c.open===void 0?!0:yi("canvas.setDialogOpen",a,"open");if(!d&&c.path===void 0){e.setOpenDialog(l,null);return}let f=ax(l,c.path);if(f===null)throw RangeError('command "canvas.setDialogOpen" argument "path": names no dialog in this document — '+"a dialog is a <dialog> element, and a popover is not one");e.setOpenDialog(l,d?f:null)},title:"Show Dialog",when:N},{args:{additionalProperties:!1,properties:{...o,open:{default:!0,description:"True to open the resolving-with popover, false to close it.",type:"boolean"}},required:[],type:"object"},category:"View",id:"canvas.setResolvingOpen",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:N,run:(s,a)=>{n("canvas.setResolvingOpen",a);let{open:l,pane:c}=a;e.setResolvingOpen(typeof c==="string"?c:m.activePaneId,l===void 0||yi("canvas.setResolvingOpen",a,"open"))},title:"Show Resolving Values"},{args:{additionalProperties:!1,properties:{...o,name:He("The prop's name, as the component's state declares it."),value:{description:"The test value — any JSON. Null clears it and the prop returns to its default.",type:["string","number","boolean","array","object","null"]}},required:["name"],type:"object"},category:"View",id:"canvas.setTestProp",level:"document",menus:["palette"],group:"3_canvas",requires:"an open component document",when:N,run:(s,a)=>{let l=n("canvas.setTestProp",a),c=ot("canvas.setTestProp",a,"name"),d=Object.keys(l.doc.document?.state??{});if(!d.includes(c))throw RangeError(`command "canvas.setTestProp" argument "name": "${c}" is not a prop this component `+`declares — it declares: ${d.length>0?d.join(", "):"nothing"}`);let{value:f}=a,h={...l.session.ui.previewProps};if(f===null||f===void 0)delete h[c];else h[c]=f;l.session.ui.previewProps=Object.keys(h).length>0?h:null,r(a)},title:"Set Test Value"},{args:{additionalProperties:!1,properties:{...o,name:He("The route parameter's name, without brackets."),value:He("The value to preview the route with. Empty clears it.")},required:["name","value"],type:"object"},category:"View",id:"canvas.setRouteParam",level:"document",menus:["palette"],group:"3_canvas",requires:"an open page with a dynamic route",when:N,run:(s,a)=>{let l=n("canvas.setRouteParam",a),c=ot("canvas.setRouteParam",a,"name"),d=Ll(l.documentPath);if(!d.includes(c))throw RangeError(`command "canvas.setRouteParam" argument "name": "${c}" is not a parameter of this `+`route — it has: ${d.length>0?d.join(", "):"none"}`);l.session.ui.previewParams={...l.session.ui.previewParams,[c]:ot("canvas.setRouteParam",a,"value")},r(a)},title:"Set Route Parameter"}]}function zT(e,t){e.registerAll(zo(t))}function Fb(e=Uo()){let t=Nu(e.paneId);for(let n of e.panels){let o=n.element?.querySelector('[part="panel-header"]');if(o){let r=t===null&&n.mediaName==="base"||t===null&&n.mediaName===null||t===n.mediaName;o.toggleAttribute("data-active",r)}}}var J=null;function Ko(e){if(J?.isConnected)return J;let t=e.createElement("div");return t.className="jx-drag-ghost",t.style.cssText="position:fixed;left:0;top:0;z-index:9999;pointer-events:none;display:none;padding:2px 8px;border-radius:4px;font-size:12px;line-height:1.4;white-space:nowrap;background:var(--accent,#3b82f6);color:var(--accent-fg,#fff);box-shadow:0 2px 8px rgba(0,0,0,0.25);transform:translate(8px,8px)",e.body.append(t),J=t,t}function Q1(e,t,n,o=document){let r=Ko(o);r.textContent=e,r.style.left=`${t}px`,r.style.top=`${n}px`,r.style.display="block"}function hx(e,t){if(!J||J.style.display==="none")return;J.style.left=`${e}px`,J.style.top=`${t}px`}function _d(){if(J)J.style.display="none"}var dn=function(){if(typeof window>"u")return null;var e=new Image;return e.src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",e}();function wc(e){var t=e.nativeSetDragImage;if(t&&dn)t(dn,0,0)}function pn(e,t){if(e==null)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(t.indexOf(o)!==-1)continue;n[o]=e[o]}return n}function fn(e,t){if(e==null)return{};var n,o,r=pn(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function be(e,t){var n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;return n.every(function(r){return Object.is(e[r],t[r])})}function mn(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:be,t=null;return function(n){if(t&&e(t.value,n))return t.value;return t={value:n},t.value}}var Go=["block"];function hn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,o)}return n}function gn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?hn(Object(n),!0).forEach(function(o){ga(e,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hn(Object(n)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(n,o))})}return e}function Zo(e){return{x:(e.right+e.left)/2,y:(e.bottom+e.top)/2}}function it(e){var{client:t,borderBox:n}=e,o=n.height/4;if(t.y<=n.top+o)return"reorder-above";if(t.y>=n.bottom-o)return"reorder-below";return"make-child"}function Xo(e){var{element:t,input:n,currentLevel:o,indentPerLevel:r,mode:i}=e,s={x:n.clientX,y:n.clientY},a=t.getBoundingClientRect();if(i==="standard"){var l=it({borderBox:a,client:s});return{type:l,indentPerLevel:r,currentLevel:o}}var c=Zo(a);if(i==="expanded"){var d=it({borderBox:a,client:s});return{type:d==="reorder-above"?d:"make-child",indentPerLevel:r,currentLevel:o}}var f=r*o;if(s.x<a.left+f){if(s.y<c.y)return{type:"reorder-above",indentPerLevel:r,currentLevel:o};var h=(s.x-a.left)/r,b=Math.max(Math.floor(h),0);return{type:"reparent",desiredLevel:b,indentPerLevel:r,currentLevel:o}}return{type:it({borderBox:a,client:s}),indentPerLevel:r,currentLevel:o}}function vn(e,t){if(e.type!==t.type)return!1;if(e.type==="instruction-blocked"&&t.type==="instruction-blocked")return vn(e.desired,t.desired);return be(e,t)}var er=mn(vn);function tr(e){var{desired:t,block:n}=e;if(n!==null&&n!==void 0&&n.includes(t.type)&&t.type!=="instruction-blocked"){var o={type:"instruction-blocked",desired:t};return o}return t}function jb(e,t){var n=t.block,o=fn(t,Go),r=Xo(o),i=tr({desired:r,block:n}),s=er(i);return gn(gn({},e),{},ga({},xe,s))}function Fu(e){var t;return(t=e[xe])!==null&&t!==void 0?t:null}var xe=Symbol("tree-item-instruction");function at(e){return typeof e==="object"&&e!==null&&typeof e.$ref==="string"?e.$ref:null}function we(e){if(e.source!=="npm"||!e.package)return null;return e.modulePath?`${e.package}/${e.modulePath}`:e.package}function nr(e,t){let n=we(e);if(n)return n;return e.path?{$ref:xc(t,e.path)}:null}function eC(e,t,n){let o=we(t);if(o)return e.some((i)=>typeof i==="string"&&(i===o||i===t.package));if(!t.path)return!1;let r=G(xc(n,t.path));return e.some((i)=>{let s=at(i);return s!==null&&G(s)===r})}function G(e){return e.replace(/^(?:\.\/)+/,"")}function om(e,t,n){let o=nr(t,n);if(!o)return[...e];let i=we(t)&&t.modulePath?e.filter((s)=>s!==t.package):[...e];return eC(i,t,n)?i:[...i,o]}function tC(e,t,n){let o=we(t);if(o)return e.filter((i)=>!(typeof i==="string"&&(i===o||i===t.package)));if(!t.path)return[...e];let r=G(xc(n,t.path));return e.filter((i)=>{let s=at(i);return s===null||G(s)!==r})}function WT(e,t){return e.filter((n)=>typeof n!=="string"||!(n===t||n.startsWith(`${t}/`)))}function VT(e,t){let n=G(t);return e.filter((o)=>{let r=at(o);return r===null||G(r)!==n})}async function px(e){$p(!0);try{if(e.source==="npm"){if(!customElements.get(e.tagName))return ct(e.tagName)}else{if(e.path&&!e.path.endsWith(".json"))return ct(e.tagName);let n=D?.projectRoot,o=`${location.origin}/${n?`${n}/`:""}${e.path}`;await Mm(o)}let t=document.createElement(e.tagName);for(let n of e.props||[])if(n.default!==void 0&&n.default!=="false"&&n.default!=="''"){let o=String(n.default).replaceAll(/^'|'$/g,"");t.setAttribute(n.name,o)}return t}catch(t){return console.warn("Component preview failed:",e.tagName,t),ct(e.tagName)}}function ct(e){let t=document.createElement("div");return t.style.cssText="padding:12px;border:1px dashed var(--border);border-radius:var(--radius);color:var(--fg-dim)",t.textContent=`<${e}>`,t}var or='[part="outline"]',ut='[part="row"]',rr='[part="verbs"]',Ce=null;function UT(){if(Ce!==null)cancelAnimationFrame(Ce);for(let e of Je.dndCleanups)e();Je.dndCleanups=[],Ce=requestAnimationFrame(()=>{Ce=null;let e=Qu?.querySelector(or);if(!e)return;for(let n of e.querySelectorAll("[data-dnd-row]")){let o=n.dataset.value.split("/").map((l)=>/^\d+$/.test(l)?Math.trunc(Number(l)):l),r=Math.trunc(Number(n.dataset.dndDepth))||0,i=Object.hasOwn(n.dataset,"dndVoid"),s=Object.hasOwn(n.dataset,"dndExpanded"),a=gr(gs({canDrag({element:l,input:c}){if(Rv(c.clientX,c.clientY)?.closest(rr))return!1;return!0},element:n,getInitialData(){return{path:o,type:"tree-node"}},onGenerateDragPreview({nativeSetDragImage:l}){wc({nativeSetDragImage:l})},onDragStart(){if(n.dataset.dragging="",Je.layerDragSourceHeight=n.offsetHeight,s)ir(n,e)},onDrop(){if(delete n.dataset.dragging,s)Ai("leftPanel")}}),zs({element:n,canDrop({source:l}){let c=l.data.path;if(c&&qa(c,o))return!1;return!0},getData({input:l,element:c}){return jb({path:o},{block:i?["make-child"]:[],currentLevel:r,element:c,indentPerLevel:16,input:l,mode:s?"expanded":"standard"})},onDragEnter({self:l}){yn(n,l.data,e)},onDrag({self:l}){yn(n,l.data,e)},onDrop(){oe(e)}}));Je.dndCleanups.push(a)}let t=Ws({onDrop({source:n,location:o}){oe(e);let[r]=o.current.dropTargets;if(!r)return;let i=Fu(r.data);if(!i||i.type==="instruction-blocked")return;let s=n.data,a=r.data.path,l=s.type==="tree-node"&&n.element,c=l&&Object.hasOwn(l.dataset,"dndExpanded");if(rm(u.value,i,s,a),c){let d=u.value,f=Le(d?.session.selection);if(f)Je._layersCollapsed||=new Set,Je._layersCollapsed.add(f.join("/"))}},onDropTargetChange({location:n}){let[o]=n.current.dropTargets;if(o&&!Fu(o.data))oe(e)}});Je.dndCleanups.push(t)})}function qT(){requestAnimationFrame(()=>{let e=Qu?.querySelector(".components-section");if(!e)return;for(let t of e.querySelectorAll("[data-component-tag]")){let n=t.dataset.componentTag;if(!n)continue;let o=st.find((a)=>a.tagName===n);if(!o)continue;let r=t.querySelector(".element-card-preview");if(r&&!r.querySelector(n))px(o).then((a)=>{r.textContent="",r.append(a)});let i=um(o),s=gs({element:t,getInitialData(){return{fragment:structuredClone(i),type:"block"}},onGenerateDragPreview({nativeSetDragImage:a}){wc({nativeSetDragImage:a})}});Je.dndCleanups.push(s)}})}function GT(){requestAnimationFrame(()=>{let e=Qu?.querySelector('[part="content"]');if(!e)return;for(let t of e.querySelectorAll("[data-block-tag]")){let n=t.dataset.blockTag,o=t.querySelector(".element-card-preview");if(o&&!o.firstChild){let s=document.createElement(Ht.has(n)?"span":n);s.textContent=n,o.append(s)}let r=yd(n),i=gs({element:t,getInitialData(){return{fragment:structuredClone(r),type:"block"}},onGenerateDragPreview({nativeSetDragImage:s}){wc({nativeSetDragImage:s})}});Je.dndCleanups.push(i)}})}function ir(e,t){let n=`${e.dataset.value}/`,o=t.querySelectorAll(ut);for(let r of o)if(r.dataset.value?.startsWith(n))r.style.display="none"}function yn(e,t,n){let o=Fu(t);if(Je._currentDropTargetRow&&Je._currentDropTargetRow!==e)delete Je._currentDropTargetRow.dataset.drop;if(!o||o.type==="instruction-blocked"){oe(n);return}if(o.type==="make-child"){oe(n),e.dataset.drop="",Je._currentDropTargetRow=e;return}delete e.dataset.drop,Je._currentDropTargetRow=e;let r=[...n.querySelectorAll(ut)],i=r.indexOf(e),s=Je.layerDragSourceHeight;for(let a=0;a<r.length;a++){if(r[a].dataset.dragging!==void 0)continue;if(o.type==="reorder-above")r[a].style.transform=a>=i?`translateY(${s}px)`:"";else r[a].style.transform=a>i?`translateY(${s}px)`:""}}function oe(e){if(Je._currentDropTargetRow)delete Je._currentDropTargetRow.dataset.drop,Je._currentDropTargetRow=null;let t=e.querySelectorAll(ut);for(let n of t)n.style.transform="",n.style.display=""}function rm(e,t,n,o){if(!e)return;let r=e.doc.document;if(n.type==="tree-node"){let i=n.path,s=ht(o),a=_n(o);if(t.type!=="make-child"&&(!s||typeof a!=="number"))return;switch(t.type){case"reorder-above":{q(e,(l)=>pa(l,i,s,a));break}case"reorder-below":{q(e,(l)=>pa(l,i,s,a+1));break}case"make-child":{let l=K(r,o),c=_o(l).length;q(e,(d)=>pa(d,i,o,c));break}default:break}}else if(n.type==="block"){let i=ht(o),s=_n(o);if(t.type!=="make-child"&&(!i||typeof s!=="number"))return;switch(t.type){case"reorder-above":{q(e,(c)=>Ji(c,i,s,structuredClone(n.fragment)));break}case"reorder-below":{q(e,(c)=>Ji(c,i,s+1,structuredClone(n.fragment)));break}case"make-child":{let c=K(r,o),d=_o(c).length;q(e,(f)=>Ji(f,o,d,structuredClone(n.fragment)));break}default:break}let l=n.fragment?.tagName;if(qe(l).includes("-")){let c=st.find((h)=>h.tagName===l),d=e.doc.document?.$elements??[],f=c?om(d,c,e.documentPath??null):d;if(f.length!==d.length)Hs(e,(h)=>{h.$elements=f})}}}function bn(e){let t={};for(let[n,o]of Object.entries(e?.nesting??{}))if(n!=="_root")t[n]=o?.inline===!0;for(let n of e?.inline??[])t[n]=!1;return t}var ke=new WeakMap,g=new Set,z=0,ae=new Map,An=-1,$n=0,ar=600;function nC(e){return An===e&&Date.now()-$n<=ar}var wn=0,In=new Set;function sr(e,t){let n;try{n=new URL(e,t.iframe.src||pm())}catch{return}if(!["http:","https:","mailto:","tel:"].includes(n.protocol))return;let o=n.href,r=Qw();if(r){r(o);return}window.open(o,"_blank","noopener,noreferrer")}function iC(e){In.add(e)}function lr(e){return In.delete(e)}var L=new Map,Z=new Map,se=new Map,cr=300;function oC(e,t,n,o=cr){let r=null;for(let a of g){if(!a.iframe.isConnected){g.delete(a);continue}if(a.ready&&!a.stylebook&&e!==null&&a.tabId===e){r=a;break}}if(!r)return Promise.resolve(null);wn+=1;let i=wn,s=JSON.parse(JSON.stringify(t));return r.channel.post({contextPath:n?[...n]:null,exprs:s,gen:r.lastRenderedGen,kind:"evalExpr",reqId:i}),new Promise((a)=>{let l=setTimeout(()=>{L.delete(i),Z.delete(i),a(null)},o);Z.set(i,r),L.set(i,(c)=>{clearTimeout(l),Z.delete(i),a(c)})})}var Cn=0,X=new Map,dr=250;function rC(e,t=dr){let n=[];for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(o.ready&&!o.stylebook&&e!==null&&o.tabId===e)n.push(o)}if(n.length===0)return Promise.resolve();return new Promise((o)=>{let r=n.length,i=setTimeout(()=>{for(let l of a)X.delete(l),se.delete(l);o()},t),s=()=>{if(r-=1,r===0)clearTimeout(i),o()},a=[];for(let l of n){Cn+=1;let c=Cn;a.push(c),X.set(c,s),se.set(c,l),l.channel.post({kind:"flushEdits",reqId:c})}})}function sC(e){return ke.get(e)??null}function sm(e){for(let t of g){if(!t.iframe.isConnected)continue;let n=Oe(t.iframe);if(e.x>=n.left&&e.x<=n.right&&e.y>=n.top&&e.y<=n.bottom)return t}return null}function am(e,t,n){z+=1,ae.set(z,n);let o=t.type==="tree-node"?{path:[...t.path],type:"tree-node"}:{type:t.type};return e.channel.post({dragSeq:z,gen:e.lastRenderedGen,kind:"dragStart",src:o}),z}function fx(){return z}function za(e){let t=Oe(e.iframe),n=e.iframe.clientWidth>0?t.width/e.iframe.clientWidth:1;return{rect:t,scale:n}}function Dn(e){if(e.stylebook)return"stylebook";return e.tabId??"unbound"}function aC(){let e=[];for(let t of g){if(!t.iframe.isConnected){g.delete(t);continue}let n=`canvas[${Dn(t)}]`;if(!t.ready){e.push(`${n}: frame has not handshaked`);continue}let o=[...t.pendingTabIds.keys()];if(o.length>0)e.push(`${n}: gen ${o.join(", ")} unacked`);if(t.pendingPatches>0)e.push(`${n}: ${t.pendingPatches} unacked patch(es)`);if(t.pendingMeasures.size>0)e.push(`${n}: ${t.pendingMeasures.size} measure(s) in flight`);let{idle:r}=t;if(!r){e.push(`${n}: no quiescence report yet`);continue}if(r.gen!==t.lastRenderedGen)e.push(`${n}: quiescence is for gen ${r.gen}, DOM is gen ${t.lastRenderedGen}`);if(!r.fonts)e.push(`${n}: fonts still loading`);if(r.animations>0)e.push(`${n}: ${r.animations} running animation(s)`);if(r.images>0)e.push(`${n}: ${r.images} pending image retry(ies)`)}if(L.size>0)e.push(`canvas: ${L.size} expression eval(s) in flight`);return e}var pr=500,fr=2,mr=40;function Jn(){let e=u.value?.id??null,t=null;for(let n of g){if(!n.iframe.isConnected){g.delete(n);continue}if(!n.ready||n.stylebook)continue;if(n.tabId===e)return n;t??=n}return t}function vr(e,t){let{rect:n,scale:o}=za(e),r=n.left+t.x*o,i=n.top+t.y*o,s=t.width*o,a=t.height*o;return{height:a,left:r,top:i,width:s,x:r+s/2,y:i+a/2}}function Re(e,t){return new Promise((n)=>{e.selReqId+=1;let o=e.selReqId,r=setTimeout(()=>{e.pendingMeasures.delete(o),n(null)},pr);e.pendingMeasures.set(o,(i)=>{clearTimeout(r);let[s]=i;n(s?vr(e,s.rect):null)}),e.channel.post({kind:"measure",paths:[[...t]],reqId:o})})}function lC(e){let t=Jn();return t?Re(t,e):Promise.resolve(null)}function yr(e){return new Promise((t)=>{let n=Number.NaN,o=0,r=0,i=()=>{let{top:s}=Oe(e.iframe);if(o=s===n?o+1:0,n=s,r+=1,o>=fr||r>=mr){t();return}requestAnimationFrame(i)};requestAnimationFrame(i)})}async function lm(e){let t=Jn();return t?n$(t,e):null}async function n$(e,t){let n=await Re(e,t);if(!n)return null;let o=_(e.canvasEl)?.surface;return Pb({height:n.height,top:n.top},o),await yr(e),Re(e,t)}function b$(e,t){let n=sC(e);return n?Re(n,t):Promise.resolve(null)}function br(e){let t=e.canvasEl.parentElement;if(!t)return;let n=/scale\(([\d.]+)\)/.exec(e.canvasEl.style.transform),o=n?Number(n[1]):1;t.style.height=o===1?"":`${e.iframe.offsetHeight*o}px`}function Ln(e){if(e.preview){e.iframe.style.height="100%",e.iframe.style.minHeight="0px";return}if(e.contentHeight===null)return;e.iframe.style.height=`${e.contentHeight}px`,e.iframe.style.minHeight=e.contentFragment?"0px":"480px",br(e)}function gt(e,t){if(e.preview=t,e.overlay.setSuppressed(t),t)e.pendingEnterEdit=null;Ln(e)}function cC(e,t){gt(yt(e),t)}function Rl(e,t){if(!e.iframe.isConnected)return;e.channel.post(t)}function Hb(e){ae.delete(e)}function Bb(e){e.overlay.setDropIndicator(null)}var jn=null;function dC(e){jn=e}var xr=300,qn=null;function uC(e){qn=e}var vt=null;function hC(e){vt=e}function wr(e,t,n){if((t?Cr(t.tagName):!1)&&t){e.overlay.setDropIndicator(null),e.overlay.setReplaceTarget(M(t.rect));return}e.overlay.setReplaceTarget(null),e.overlay.setDropIndicator(n?M(n.referenceRect):null,n?.edge)}function Pn(e){e.overlay.setReplaceTarget(null),e.overlay.setDropIndicator(null)}function Cr(e){return e==="img"||e==="video"||e==="source"}function Pr(e,t){if(e.dataset.jxGutterDrop==="1")return;e.dataset.jxGutterDrop="1",e.addEventListener("dragover",(n)=>{if(![...n.dataTransfer?.types??[]].includes("Files"))return;if(n.preventDefault(),n.dataTransfer)n.dataTransfer.dropEffect="copy"}),e.addEventListener("drop",(n)=>{let o=n.dataTransfer?.files,r=t();if(!o?.length||!r||r.stylebook)return;n.preventDefault(),vt?.(P(r),[...o],null,null)})}var Te=null;function pC(e){Te=e}var Me=null;function fC(e){Me=e}var Fn=null;function mC(e){Fn=e}function Sn(e,t){let n=[...t];for(;;){let o=e.get(Il(n));if(o)return o;if(n.length<2)return null;n=n.slice(0,-2)}}var S=null;function gC(){let e=S;return Boolean(e?.editing&&e.iframe.isConnected)}var Ne=null;function bC(e){Ne=e}var mt=null;function vC(e){mt=e}var En=null,Wn=null;function yC(e){Wn=e}function wC(e,t){for(let n of g){if(!n.iframe.isConnected){g.delete(n);continue}if(n.ready&&n.tabId===e.id&&!n.preview)n.popoverOpen=t,n.channel.post({kind:"setPopoverOpen",path:t})}}function xC(e,t){for(let n of g){if(!n.iframe.isConnected){g.delete(n);continue}if(n.ready&&n.tabId===e.id&&!n.preview)n.dialogOpen=t,n.channel.post({kind:"setDialogOpen",path:t})}}function mx(e,t){let n=0;for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(o.ready&&o.tabId===t){let r=_(o.canvasEl)?.surface;if(!r){Ab("host-stage-unresolved");continue}let i=r.renderGeneration,s=Ae?.host===o?Ae.paths:void 0;$e(o),o.channel.post(s?{echoPaths:s,forwardOps:e,gen:i,kind:"patch"}:{forwardOps:e,gen:i,kind:"patch"}),o.pendingPatches+=1,n+=1}}return n}var Ae=null,Sr=0;function Tn(e,t,n){Ae={host:e,paths:t};try{n()}finally{Ae=null}}var dt=null,pt=null;function Er(e,t,n){return!e&&t===n}function Tr(e,t){let n=P(e);if(!n)return;let o=K(n.doc.document,t);if(!o)return;mx([{key:"$props",op:"set-key",path:t,value:o.$props}],n.id)}function P(e){return e.tabId?m.tabs.get(e.tabId)??null:null}function _C(e){return P(e)}function Pe(e){let t=_(e.canvasEl)?.surface.paneId;if(t)$r(t)}var Mr=Object.freeze([]);function Nr(){let e=new Map;for(let t of m.panes){let n=t.activeTabId?m.tabs.get(t.activeTabId):null;if(!n)continue;let o=n.session.selection??[];o.map((r)=>r.join("/")).join("|"),e.set(n.id,o)}return e}function kr(){if(En)return;let e=ge(!0);e.run(()=>{Q(()=>{let t=Nr();y.stylebook.selection;for(let n of g)Ie(n,(n.tabId?t.get(n.tabId):null)??Mr)})}),En={stop:()=>e.stop()}}function $e(e){if(!e.ready)return;let t=Rd();if(t===e.postedVersions)return;if(e.postedVersions===null&&Object.keys(t).length===0){e.postedVersions=t;return}e.postedVersions=t,e.channel.post({kind:"assetVersions",versions:t})}var Mn=!1,ft=!1;function Rr(){if(Mn)return;Mn=!0,ge(!0).run(()=>{Q(()=>{if(jC.value,ft)return;ft=!0,queueMicrotask(()=>{ft=!1,Or()})})})}function Or(){for(let e of g){if(!e.iframe.isConnected){g.delete(e);continue}$e(e)}}var Nn=!1,Ee=null;function Ar(){if(Nn)return;Nn=!0,ge(!0).run(()=>{Q(()=>{for(let t of m.panes){let n=t.activeTabId?m.tabs.get(t.activeTabId):null;if(!n)continue;let{peers:o}=xn(n);o.map((r)=>JSON.stringify(r.state.structuralSelection??null)).join("|")}if(Ee)clearTimeout(Ee);Ee=setTimeout(()=>{Ee=null;for(let t of g)Vn(t)},100)})})}function Vn(e){if(e.stylebook||!e.ready||!e.iframe.isConnected)return;let t=P(e),n=t?xn(t).peers:[];e.presenceMeta.clear();let o=[];for(let r of n){let{structuralSelection:i}=r.state;if(!i||r.state.focusedPath!==t?.documentPath)continue;for(let s of i){let a=[...s];o.push(a),e.presenceMeta.set(JSON.stringify(a),{color:r.state.user.color,label:r.state.user.name??r.state.user.login})}}if(o.length===0){e.presenceReqId=-1,e.overlay.setPresence([]);return}e.selReqId+=1,e.presenceReqId=e.selReqId,e.channel.post({kind:"measure",paths:o,reqId:e.presenceReqId})}function Ie(e,t){if(e.stylebook){Ir(e);return}let n=Le(t);if(e.selectionPath=n,e.selectionPaths=t,!e.iframe.isConnected){g.delete(e);return}if(!n){e.coSelectionKeys.clear(),e.overlay.setSelection(null),e.overlay.setCoSelection([]);return}if(!e.ready)return;let o=ms(t.slice(0,-1));e.coSelectionKeys=new Set(o.map((r)=>JSON.stringify(r))),e.selReqId+=1,e.channel.post({kind:"measure",paths:[[...n],...o],reqId:e.selReqId})}function Ir(e){if(!e.iframe.isConnected){g.delete(e);return}let t=y.stylebook.selection,n=t?e.stylebook?.tagToCardPath.get(t):void 0;if(!t||!n){e.overlay.setSelection(null);return}if(!e.ready)return;e.selReqId+=1,e.channel.post({kind:"measure",paths:[[...n]],reqId:e.selReqId})}function kn(){return zv("../canvas.html")}var Dr="about:blank";function Bn(e){e.channel.dispose();for(let[t,n]of L)if(Z.get(t)===e)L.delete(t),Z.delete(t),n(null);for(let[t,n]of X)if(se.get(t)===e)X.delete(t),se.delete(t),n();for(let[,t]of e.pendingMeasures)t([]);if(e.pendingMeasures.clear(),e.pendingTabIds.clear(),le(e),S===e)S=null;e.overlay.root.remove(),e.iframe.remove(),ke.delete(e.canvasEl),g.delete(e)}function Hr(){if(!We())return kn();let e=p();if(e.canvasUrl)return e.canvasUrl;return e.canvasUrlDeferred?Dr:kn()}function cm(e){let t=0;for(let n of new Set(g))if(e.contains(n.canvasEl))Bn(n),t+=1;return t}function yt(e){let t=Hr(),n=ke.get(e);if(n){if(n.canvasUrl===t)return n;Bn(n)}let o=location.origin,r=crypto.randomUUID(),i=new URL(t,location.href).origin,s=document.createElement("iframe");s.className="jx-canvas-iframe",s.title="Canvas — live page render",s.style.cssText="width:100%;min-height:480px;height:100%;border:0;display:block;background:#fff";let a=new URL(t,location.href);if(a.searchParams.set("token",r),location.protocol==="http:"||location.protocol==="https:")a.searchParams.set("parentOrigin",o);if(s.src=i===o?`${a.pathname}${a.search}`:a.href,!e.style.position)e.style.position="relative";let l=zt(document);e.replaceChildren(s,l.root),Pr(e,()=>sC(e));let c=xt({acceptOrigin:i,source:window,target:{postMessage:(f,h)=>s.contentWindow?.postMessage(f,h)},targetOrigin:i,token:r}),d={canvasEl:e,canvasUrl:t,channel:c,contentFragment:!1,contentHeight:null,hiddenPaths:new Set,popoverOpen:null,dialogOpen:null,editing:!1,editingProp:null,iframe:s,insertHideTimer:null,insertHover:!1,coSelectionKeys:new Set,insertZone:null,lastRenderedGen:-1,lastSelectionRect:null,lastSnapshotSeq:0,overlay:l,panReqId:-1,pending:null,postedVersions:null,idle:null,pendingEnterEdit:null,pendingMeasures:new Map,pendingPatches:0,pendingTabIds:new Map,presenceMeta:new Map,presenceReqId:-1,preview:!1,ready:!1,selectionPath:null,selectionPaths:[],selReqId:0,snapshot:null,stylebook:null,tabId:null};return l.insertButton.addEventListener("click",(f)=>jr(d,f)),l.insertButton.addEventListener("mouseenter",()=>{d.insertHover=!0,le(d)}),l.insertButton.addEventListener("mouseleave",()=>{d.insertHover=!1,Kn(d)}),c.onMessage((f)=>Fr(d,f)),ke.set(e,d),g.add(d),kr(),Ar(),Rr(),d}function Lr(e,t){le(e),e.insertZone=t,e.overlay.setInsertZone(M(t.rect),t.edge)}function zn(e){le(e),e.insertZone=null,e.insertHover=!1,e.overlay.setInsertZone(null)}function _r(e){let t=e.overlay.insertButton;return e.insertHover||typeof t.matches==="function"&&t.matches(":hover")}function Kn(e){le(e),e.insertHideTimer=setTimeout(()=>{if(e.insertHideTimer=null,_r(e))return;zn(e)},xr)}function le(e){if(e.insertHideTimer!==null)clearTimeout(e.insertHideTimer),e.insertHideTimer=null}function jr(e,t){t.stopPropagation(),t.preventDefault();let n=e.insertZone;if(!n)return;qn?.(e.overlay.insertButton,n)}var qr=new Set(["contextMenu","dragOver","dropResult","editCommit","editCommitProp","editInsert","editMerge","editRangeReplace","editSplit","editStart","fileDragOver","fileDrop","hit","hover","insertZones","layoutHit","nativeDragEnter"]);function Fr(e,t){if(e.preview&&qr.has(t.kind))return;switch(t.kind){case"ready":{e.ready=!0;let n=bt?.();if(n)e.channel.post({chords:n.chords,kind:"keymap",mac:n.mac});if(e.postedVersions=null,$e(e),e.pending)e.channel.post(e.pending),e.pending=null;Ie(e,e.selectionPaths);return}case"paneFocus":{Pe(e),mt?.();return}case"popoverTargetClick":{let n=P(e);if(!n||e.preview)return;let o=JSON.stringify(n.session.ui.openPopover)===JSON.stringify(t.targetPath),r=t.action==="show"||t.action==="toggle"&&!o;if(r||o)ne()?.run("canvas.setPopoverOpen",{open:r,path:t.targetPath});return}case"commandTargetClick":{let n=P(e);if(!n||e.preview)return;let o=(i)=>JSON.stringify(i)===JSON.stringify(t.targetPath),r=K(n.doc.document,t.targetPath);if(!r||typeof r!=="object")return;if(Ze.has(t.command)){if(!Gs(r))return;let i=t.command==="show-popover"||t.command==="toggle-popover"&&!o(n.session.ui.openPopover);if(i||o(n.session.ui.openPopover))ne()?.run("canvas.setPopoverOpen",{open:i,path:t.targetPath})}else if(Ge.has(t.command)){if(!H(r))return;let i=t.command==="show-modal";if(i||o(n.session.ui.openDialog))ne()?.run("canvas.setDialogOpen",{open:i,path:t.targetPath})}return}case"hit":{Pe(e),mt?.(),OC(null);let n=null,o=_(e.canvasEl)?.panel;if(o?.mediaName&&!o.mediaName.startsWith("git-diff")){n=me(o.mediaName);let i=P(e);if(i)i.session.ui.activeMedia=n}if(Me?.dismiss(),e.stylebook){let i=Sn(e.stylebook.pathToTag,t.hit.path);if(Fn?.(i,n),i){let s=M(t.hit.rect);e.overlay.setSelection(s,`<${i}>`),e.lastSelectionRect=s}else e.overlay.setSelection(null);return}e.selectionPath=t.hit.path,e.selectionPaths=[t.hit.path];let r=P(e);if(r)r.session.selection=t.additive?uv(r.session.selection,t.hit.path):[t.hit.path];{let i=M(t.hit.rect);e.overlay.setSelection(i),e.lastSelectionRect=i}return}case"layoutHit":{if(e.stylebook)return;Pe(e),Me?.dismiss(),OC(t.hit),e.selectionPath=null,e.selectionPaths=[];let n=P(e);if(n)n.session.selection=[];let o=M(t.hit.rect);e.overlay.setSelection(o,`LAYOUT · ${t.hit.layoutFile}`),e.lastSelectionRect=o,Ai("rightPanel");return}case"hover":{if(e.stylebook){let n=t.hit?Sn(e.stylebook.pathToTag,t.hit.path):null,o=y.stylebook.selection;if(t.hit&&n&&n!==o)e.overlay.setHover(M(t.hit.rect));else e.overlay.setHover(null);return}zr(e,t.hit);return}case"insertZones":{if(e.stylebook)return;let n=t.zones?.[0]??null;if(n)Lr(e,n);else Kn(e);return}case"geometry":{let n=e.pendingMeasures.get(t.reqId);if(n){e.pendingMeasures.delete(t.reqId),n(t.hits);return}if(t.reqId===e.presenceReqId){e.presenceReqId=-1;let o=[];for(let r of t.hits){let i=e.presenceMeta.get(JSON.stringify(r.path));if(i)o.push({...i,placement:M(r.rect)})}e.overlay.setPresence(o);return}if(t.reqId===e.panReqId){e.panReqId=-1;let[o]=t.hits;if(o){let{rect:r,scale:i}=za(e);Pb({height:o.rect.height*i,top:o.rect.y*i+r.top})}return}if(t.reqId===e.selReqId){let o=JSON.stringify(e.selectionPath),r=[],i=null;if(e.stylebook){let[a]=t.hits;i=a?M(a.rect):null}else for(let a of t.hits){let l=JSON.stringify(a.path);if(l===o)i=M(a.rect);else if(e.coSelectionKeys.has(l))r.push(M(a.rect))}let s=e.stylebook?y.stylebook.selection:null;e.overlay.setSelection(i,s?`<${s}>`:null),e.overlay.setCoSelection(r),e.lastSelectionRect=i,e.hiddenPaths=new Set((t.hidden??[]).map((a)=>JSON.stringify(a)))}return}case"evalResult":{let n=L.get(t.reqId);if(!n)return;L.delete(t.reqId),Z.delete(t.reqId),n(t.gen===e.lastRenderedGen?t.results:null);return}case"renderComplete":{if(e.pendingTabIds.has(t.gen))e.tabId=e.pendingTabIds.get(t.gen)??null;for(let n of e.pendingTabIds.keys())if(n<=t.gen)e.pendingTabIds.delete(n);Rn(e,t.gen);return}case"patchComplete":{e.pendingPatches=Math.max(0,e.pendingPatches-1),Rn(e,t.gen);return}case"idle":{e.idle={animations:t.animations,fonts:t.fonts,gen:t.gen,images:t.images};return}case"renderError":{e.pendingTabIds.delete(t.gen);let n=P(e);if(n)n.session.canvas.refreshing=!1,Ai("leftPanel");k.error("The page could not be rendered.",{detail:t.message,key:`canvas.render:${Dn(e)}`,source:"Canvas"});return}case"dataScope":{if(t.gen!==e.lastRenderedGen)return;let n=P(e);if(n)n.session.canvas.scope=t.scope,n.session.canvas.refreshing=!1;Ai("leftPanel");return}case"contentHeight":{e.contentHeight=t.height,e.contentFragment=t.fragment,Ln(e);return}case"dragOver":{if(t.dragSeq!==z)return;if(t.cursor)An=t.dragSeq,$n=Date.now();if(t.gen!==e.lastRenderedGen)return;if(t.preview)e.overlay.setDropIndicator(M(t.preview.referenceRect),t.preview.edge);else e.overlay.setDropIndicator(null);if(t.cursor){let n=za(e);hx(t.cursor.x*n.scale+n.rect.left,t.cursor.y*n.scale+n.rect.top)}return}case"nativeDragEnter":{if(e.stylebook)return;jn?.(e);return}case"dragEnd":{e.overlay.setDropIndicator(null),_d(),ae.delete(t.dragSeq);return}case"dropResult":{if(t.dragSeq!==z||t.gen!==e.lastRenderedGen)return;if(t.instruction&&t.targetPath){let n=ae.get(t.dragSeq);if(n)rm(P(e),{type:t.instruction},n,t.targetPath)}ae.delete(t.dragSeq),e.overlay.setDropIndicator(null),_d();return}case"fileDragOver":{if(e.stylebook)return;wr(e,t.hit,t.preview);return}case"fileDragLeave":{Pn(e);return}case"fileDrop":{if(Pn(e),e.stylebook)return;vt?.(P(e),t.files,t.hit,t.preview);return}case"patchError":{e.pendingPatches=Math.max(0,e.pendingPatches-1);let n=_(e.canvasEl)?.surface;if(n)Wn?.(n.paneId);return}case"forwardKey":{Br(t.event);return}case"forwardWheel":{Vr(e,t);return}case"editStart":{if(S&&S!==e)S.editing=!1,S.editingProp=null,S.snapshot=null;if(S=e,t.prop!==void 0&&pt===Il(t.path))ie(e,t.path,void 0,t.prop);pt=null,Sr+=1,e.editing=!0,e.editingProp=t.prop??null,e.snapshot=null,e.lastSnapshotSeq=0,Ne?.();return}case"selectionChanged":{if(t.seq<=e.lastSnapshotSeq)return;if(e.lastSnapshotSeq=t.seq,e.snapshot=t,!e.editing)e.editing=!0,S=e;Ne?.();return}case"flushComplete":{let n=X.get(t.reqId);if(n)X.delete(t.reqId),se.delete(t.reqId),n();return}case"editCommit":{let n=()=>_t(P(e),t.path,t.children,t.textContent);if(t.inPlace)Tn(e,[t.path],n);else n();return}case"editCommitProp":{let n=()=>jt(P(e),t.path,t.prop,t.value);if(t.inPlace){Tn(e,[t.path],n),dt=Il(t.path);return}let o=n();if(Er(o,dt,Il(t.path)))Tr(e,t.path);dt=null,pt=o?Il(t.path):null;return}case"editMerge":{let n=qt(P(e),t.fromPath,t.intoPath);if(n)ie(e,n.path,n.offset);return}case"editRangeReplace":{let n=Bt(P(e),t.from,t.to,t.between,t.text);if(n)ie(e,n.path,n.offset);return}case"editSplit":{ie(e,Wt(P(e),t.path,t.before,t.after));return}case"editInsert":{ie(e,Vt(P(e),t.path,t.cmd,t.commitData));return}case"slashShow":{let{rect:n,scale:o}=za(e),r=t.rect.x*o+n.left,i=t.rect.y*o+n.top;Te?.show({filter:t.filter,...t.showFilter===!0?{showFilter:!0}:{},onDismiss:()=>e.channel.post({kind:"slashDismissed"}),onSelect:(s)=>e.channel.post({cmd:{...s},kind:"slashSelect"}),rect:{bottom:i+t.rect.height*o,height:t.rect.height*o,left:r,top:i,width:t.rect.width*o}});return}case"slashNav":{Te?.nav(t.key);return}case"slashDismiss":{Te?.dismiss();return}case"previewNavigate":{sr(t.href,e);return}case"contextMenu":{if(e.stylebook)return;Pe(e);let{rect:n,scale:o}=za(e);Me?.show({clientX:t.x*o+n.left,clientY:t.y*o+n.top,path:t.path?[...t.path]:null});return}case"editEnd":{if(!e.editing)return;if(e.editing=!1,e.editingProp=null,e.snapshot=null,S===e)S=null;Ne?.();break}default:break}}function Rn(e,t){if(e.lastRenderedGen=t,Ie(e,e.selectionPaths),Vn(e),zn(e),e.pendingEnterEdit&&t>=e.pendingEnterEdit.minGen){let{offset:n,path:o,prop:r}=e.pendingEnterEdit;if(e.pendingEnterEdit=null,e.tabId!==null&&e.tabId===im(e.canvasEl)?.id)Wr(e,o,n,r)}}function ie(e,t,n,o){e.pendingEnterEdit={minGen:e.lastRenderedGen,path:[...t],...n===void 0?{}:{offset:n},...o===void 0?{}:{prop:o}}}function Wr(e,t,n,o){e.channel.post({kind:"enterEdit",path:[...t],...n===void 0?{}:{offset:n},...o===void 0?{}:{prop:o}})}function Vr(e,t){let{rect:n,scale:o}=za(e),r=jl(e.canvasEl)?.wrap;if(!r)return;r.dispatchEvent(new WheelEvent("wheel",{bubbles:!0,cancelable:!0,clientX:n.left+t.x*o,clientY:n.top+t.y*o,ctrlKey:t.ctrlKey,deltaX:t.deltaX,deltaY:t.deltaY,metaKey:t.metaKey,shiftKey:t.shiftKey}))}function Br(e){document.dispatchEvent(new KeyboardEvent("keydown",{altKey:e.altKey,bubbles:!0,cancelable:!0,code:e.code,ctrlKey:e.ctrlKey,key:e.key,metaKey:e.metaKey,shiftKey:e.shiftKey}))}function zr(e,t){if(!t||Yo(t.path,e.selectionPath)){e.overlay.setHover(null);return}e.overlay.setHover(M(t.rect))}var Ur=4,B=new Map;function Gr(e){let t=B.get(e);if(t)return B.delete(e),B.set(e,t),t;let n=new Map;B.set(e,n);for(let o of B.keys()){if(B.size<=Ur)break;B.delete(o)}return n}function Zr(e,t,n,o,r,i=null){let s=Gr(e),a=o?.id??null,l=s.get(t);if(l&&l.tabId===n&&l.viewTabId===a&&l.mode===i)return l.payload;let c=lr(r),d=nx(At,async()=>{xo.renderPreparations+=1;let f=await kt(t,o,i),h=JSON.parse(JSON.stringify(f.renderDoc)),b=JSON.parse(JSON.stringify(t)),T=n?m.tabs.get(n)??null:null,R=wi(T?.doc.sourceFormat)?.studio?.elements,O=R?bn(R):void 0;return{assets:f.assets,doc:h,docBase:f.docBase??`${pm()}/`,mapperCtx:f.mapperCtx,mode:f.mapperCtx.canvasMode,shadowDoc:b,siteStyle:f.siteStyle,...O?{editableTags:O}:{},...c?{allowAutoRequests:!0}:{}}});return s.set(t,{mode:i,payload:d,tabId:n,viewTabId:a}),d}async function CC(e,t,n,o,r=null,i=im(n),s=null,a=null){let l=yt(n);l.pendingTabIds.set(e,r),l.stylebook=null,l.iframe.style.width=o?`${o}px`:"100%";let d={...await Zr(e,t,r,i,$b(n),s),colorScheme:Gn(i),...a?{diffMarks:a}:{},gen:e,kind:"render",popoverOpen:i?.session.ui.openPopover??null,dialogOpen:i?.session.ui.openDialog??null};l.popoverOpen=d.popoverOpen??null,l.dialogOpen=d.dialogOpen??null,gt(l,d.mode==="preview"),Un(l,d)}function Un(e,t){if(xo.hostRenderPosts+=1,e.ready)$e(e),e.channel.post(t);else e.pending=t}function kC(e,t,n,o){let r=yt(n);r.pendingTabIds.set(e,null),r.stylebook={pathToTag:t.pathToTag,tagToCardPath:t.tagToCardPath},gt(r,!1),r.pendingEnterEdit=null,r.iframe.style.width=o?`${o}px`:"100%";let i=JSON.parse(JSON.stringify(t.doc)),s=JSON.parse(JSON.stringify(t.doc)),a={assets:null,colorScheme:Gn(im(n)),doc:i,docBase:`${pm()}/`,gen:e,kind:"render",mapperCtx:{arrayPaths:[],canvasMode:"stylebook",layoutWrapped:!1,pageContentOffset:null,pageContentPrefix:null},mode:"stylebook",shadowDoc:s,siteStyle:null};Un(r,a)}function Gn(e){let t=e?.session.ui.previewColorScheme;return t==="light"||t==="dark"?t:null}function SC(e,t){for(let n of g){if(!n.iframe.isConnected){g.delete(n);continue}if(t&&!t.contains(n.iframe))continue;if(n.ready)n.channel.post({kind:"setColorScheme",scheme:e})}}function EC(e,t){let n=gL(e);for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(t&&!t.contains(o.iframe))continue;if(o.ready)o.channel.post({dir:n,kind:"setLocale",locale:e})}}function TC(e,t){let n=JSON.parse(JSON.stringify(e)),o=0;for(let r of g){if(!r.iframe.isConnected){g.delete(r);continue}if(r.ready)r.channel.post({base:t,doc:n,kind:"redefineElement"}),o+=1}return o}function LC(){let e=D?.projectConfig;if(!e)return;let t=JSON.parse(JSON.stringify(e.style??null)),n=JSON.parse(JSON.stringify(e.$media??{}));for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(o.ready&&!o.stylebook)o.channel.post({kind:"siteStyleUpdate",media:n,siteStyle:t})}}function zb(e){let t=0,n=JSON.parse(JSON.stringify(e));for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(o.ready&&o.stylebook)o.channel.post({gen:o.lastRenderedGen,kind:"styleUpdate",style:n}),t+=1,Ie(o,o.selectionPaths)}return t}function IC(e){let t=Zn();if(!t?.stylebook||!t.ready)return;let n=t.stylebook.tagToCardPath.get(e);if(!n)return;t.selReqId+=1,t.panReqId=t.selReqId,t.channel.post({kind:"measure",paths:[[...n]],reqId:t.selReqId})}function Wa(){let e=S;if(!e||!e.iframe.isConnected)return{editing:!1,editingProp:null,snapshot:null};return{editing:e.editing,editingProp:e.editingProp,snapshot:e.snapshot}}var bt=null;function RC(e,t){bt=e,t?.(()=>On()),On()}function On(){let e=bt?.();if(!e)return;for(let t of g){if(!t.iframe.isConnected){g.delete(t);continue}if(t.ready)t.channel.post({chords:e.chords,kind:"keymap",mac:e.mac})}}function Cd(e){let t=S;if(!t||!t.ready)return;t.channel.post({intent:e,kind:"applyFormat"})}function $C(){let e=S;if(!e||!e.ready)return;e.channel.post({kind:"openSlash"})}function Wb(){let e=S;if(e?.editing&&e.ready&&e.iframe.isConnected)e.channel.post({kind:"endEdit"})}function Zn(){let e=Ut();return e?sC(e.canvas):null}function gx(){let e=S,t=e??Zn();if(!t)return null;let{rect:n,scale:o}=za(t),r=t===e?t.snapshot?.rect:null;if(r)return{height:r.height*o,left:r.x*o+n.left,top:r.y*o+n.top,width:r.width*o};if(t.lastSelectionRect)return{height:t.lastSelectionRect.height*o,left:t.lastSelectionRect.left*o+n.left,top:t.lastSelectionRect.top*o+n.top,width:t.lastSelectionRect.width*o};return null}
|
|
1
|
+
import{p,We}from"./studio-y7jehjrp.js";import{ge,Q,re,k}from"./studio-fqq890ap.js";import{Je,Yi,Ju,jl}from"./studio-7pgy3xaf.js";import{gL,Le,ms,uv,q,Hs,Ji,Vu,pa,Ue,Uu,xn,ot,yv,yi,li,Se,Do,qC,oo,He,Qn,m,u,Hn,$r,Cp}from"./studio-x5g1xk77.js";import{Pd,wi}from"./studio-cqmtbg2p.js";import{st,um,xc}from"./studio-pwqfmt4p.js";import{jC,Rd}from"./studio-xkfs0dp2.js";import{Dv,$p,Mm,Wl,Kr,ro,Jr,Gs,nh,Ya,Fm,wI,Qo,jd,jm,ne}from"./studio-cp1gbff9.js";import{ga,gr,zs,Ws,gs}from"./studio-st75kn99.js";import{Di,JT,Vb,YT,ps,$l,Ub,ZT,y,OC}from"./studio-4m50vh74.js";import{pm,hp,fm}from"./studio-5d7wfmnp.js";import{K,_o,ht,_n,Yo,qa,D,Xu,Qu,Ai}from"./studio-tp642n5g.js";import{Oe,Rv}from"./studio-vavmwshr.js";import{qe,Mp}from"./studio-nbxqcgvf.js";import{zv}from"./studio-edbtvcd1.js";function xt(e){let{target:t,source:n,targetOrigin:o,acceptOrigin:r,token:i}=e,s=new Set,a=(l)=>{if(r!=="*"&&l.origin!==r)return;let c=l.data;if(!c||typeof c!=="object"||c["jx:canvas"]!==i)return;for(let d of s)d(c.payload)};return n.addEventListener("message",a),{dispose(){s.clear(),n.removeEventListener("message",a)},onMessage(l){return s.add(l),()=>s.delete(l)},post(l){t.postMessage({["jx:canvas"]:i,payload:l},o)}}}var Yn=null;function Qw(){return Yn}function Uo(){return Yi(m.activePaneId)}function lt(e){let t=Hn(e),n=t?.derived,o=n?.kind==="lens"?Hn(n.sourcePaneId)?.activeTabId:t?.activeTabId;return o?m.tabs.get(o)??null:null}function ur(e){return Hn(e)?.derived??null}function Xw(e){if(!e)return[];let t=[];for(let n of m.panes)if(lt(n.id)?.id===e.id)t.push(Yi(n.id));return t}function _(e){for(let t of Ju()){let n=t.panels.find((o)=>o.canvas===e);if(n)return{panel:n,surface:t}}return null}function wt(e){let t=e.canvas,n=t?_(t):null;return n?lt(n.surface.paneId):null}function Tl(e){let t=e?.session.ui,n=t?.canvasMode??"design";return t?.preview&&(n==="edit"||n==="design")?"preview":n}function wo(e){let t=ur(e);if(t?.kind==="lens"){let n=t.mode;return lt(e)?.session.ui?.preview&&(n==="edit"||n==="design")?"preview":n}return Tl(lt(e))}function Nu(e){let t=ur(e);if(t?.kind==="lens"&&t.preset==="breakpoint")return t.media;return lt(e)?.session.ui.activeMedia??null}function $b(e){return jl(e)?.paneId??Qn}function im(e){return lt($b(e))}var ce=new Set(["img","video","source","iframe","audio"]),ue="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",eo="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='32'%20height='32'%3E%3Crect%20width='32'%20height='32'%20fill='%23d0d0d0'/%3E%3C/svg%3E",to=/(src|poster|image|bg|background|icon|logo|photo|avatar|thumbnail|cover|banner)$/i;function no(e){return to.test(e)}var io=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","li","dt","dd","th","td","span","strong","em","small","mark","code","abbr","q","sub","sup","time","a","button","label","legend","caption","summary","pre","option"]),ao=new Set(["div","section","article","aside","header","footer","main","nav","figure","figcaption","details","fieldset","form","ul","ol","dl","table"]);function so(e){if(!e.tagName||e.textContent||e.innerHTML)return null;if(e.$__layout)return null;if(Array.isArray(e.children)&&e.children.length>0)return null;if(io.has(qe(e.tagName)))return"empty-text-placeholder";if(ao.has(qe(e.tagName)))return"empty-container-placeholder";return null}function De(e){return e.replaceAll(/\$\{([^}]+)\}/g,"❪ $1 ❫")}function lo(e){let t=e.map;return{children:t&&typeof t==="object"?[A(t)]:[],className:"repeater-perimeter",tagName:"div"}}function A(e){if(!e||typeof e!=="object")return e;if(Array.isArray(e))return e.map((s)=>A(s));if(e.$prototype==="Array")return lo(e);let t=e,n={},o=!1,r=ce.has(t.tagName||"");if(r){let{attributes:s,src:a}=t,l=s?.src,c=t.poster,d=s?.poster;if(!(a&&a!==""||l&&l!=="")&&!(c&&c!==""||d&&d!==""))o=!0}for(let[s,a]of Object.entries(t))if(s==="state"||s==="$media"||s==="$elements")n[s]=a;else if(s==="$props"&&a&&typeof a==="object"){let l={};for(let[c,d]of Object.entries(a))if(typeof d==="string"&&d.includes("${"))if(no(c))l[c]=eo;else if(c==="href"||c==="action")l[c]="";else l[c]=De(d);else if(d&&typeof d==="object"&&d.$ref){let f=d.$ref,h=f.startsWith("#/state/")?f.slice(8):f;l[c]=`{${h}}`}else l[c]=d;n[s]=l}else if(s==="children")if(Array.isArray(a))n.children=a.map((l)=>A(l));else if(a&&typeof a==="object"&&a.$prototype==="Array")n.children=[A(a)];else n.children=A(a);else if(s==="cases"&&t.$switch&&a&&typeof a==="object"){let l=Object.keys(a);if(l.length>0){let c=a[l[0]];n.children=c&&typeof c==="object"&&!c.$ref?[A(c)]:[{style:{background:"color-mix(in srgb, var(--danger) 8%, transparent)",border:"1px dashed color-mix(in srgb, var(--danger) 40%, transparent)",borderRadius:"4px",color:"var(--danger)",fontFamily:"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace",fontSize:"11px",fontStyle:"italic",padding:"6px 10px"},tagName:"div",textContent:`[$switch: ${l.join(" | ")}]`}]}}else if(s==="attributes"&&r&&a&&typeof a==="object"){let l=a,c={};for(let[d,f]of Object.entries(l))if(d==="src"||d==="poster")if(typeof f==="string"&&f!==""&&!f.includes("${"))c[d]=f;else o=!0,c[d]=ue;else if(typeof f==="string"&&f.includes("${")){let h=d==="href"||d==="action";c[d]=h?"":De(f)}else if(f&&typeof f==="object"&&f.$ref){let h=f.$ref,b=h.startsWith("#/state/")?h.slice(8):h;c[d]=`{${b}}`}else c[d]=f;n.attributes=c}else if(s==="style")if(a&&typeof a==="object"){let l={};for(let[c,d]of Object.entries(a))if(typeof d!=="string"||!d.includes("${"))l[c]=d;n.style=l}else n.style=a;else if(typeof a==="string"&&a.includes("${"))if((s==="src"||s==="poster")&&ce.has(t.tagName||""))o=!0,n[s]=ue;else{let c=s==="src"||s==="href"||s==="poster"||s==="action";n[s]=c?"":De(a)}else if(a&&typeof a==="object"&&a.$ref){let l=a.$ref,c=l.startsWith("#/state/")?l.slice(8):l;if((s==="src"||s==="poster")&&ce.has(t.tagName||""))o=!0,n[s]=ue;else n[s]=`{${c}}`}else if((s==="src"||s==="poster")&&a===""&&ce.has(t.tagName||""))o=!0,n[s]=ue;else n[s]=A(a);let i=so(n);if(i)n.className=n.className?`${n.className} ${i}`:i;if(o){let s=n.className||"";if(!s.includes("empty-media-placeholder"))n.className=s?`${s} empty-media-placeholder`:"empty-media-placeholder"}return n}var co=/\[\.\.\.(\w+)\]|\[(\w+)\]/g;function uo(e){return e.split("\\").join("/").replace(/^\.\//,"").replace(/^\//,"").replace(/^pages\//,"")}function Ct(e){let t=uo(e),n=t.slice(t.lastIndexOf("/")+1),o=n.lastIndexOf(".");if(o>0)t=t.slice(0,t.length-(n.length-o));if(t.endsWith("/index"))t=t.slice(0,-6)||"/";else if(t==="index")t="/";if(!t.startsWith("/"))t=`/${t}`;let r=[],i=!1,s=!1,a=t.replaceAll(co,(l,c,d)=>{if(i=!0,c)return s=!0,r.push(c),"*";return r.push(d),`:${d}`});return{isCatchAll:s,isDynamic:i,params:r,urlPattern:a}}function Db(e){if(!e)return"/";return Ct(e).urlPattern}function Ll(e){if(!e)return[];return Ct(e).params}function yT(e){let t=e.document?.$paths,n=e.frontmatter?.$paths;return t??n??null}var pe=new Map;function wT(){pe.clear()}function xT(e,t){if(!t)return Promise.resolve({});let n=`${e??""}::${JSON.stringify(t)}`,o=pe.get(n);if(!o)o=po(t).catch((r)=>(pe.delete(n),console.warn("page-params: failed to enumerate $paths values:",r),{})),pe.set(n,o);return o}async function po(e){if(Array.isArray(e)){let t={};for(let n of e)for(let[o,r]of Object.entries(n))de(t,o,r);return t}if("contentType"in e&&typeof e.contentType==="string"&&e.contentType){let t=e.param??"slug",n=e.field??"id",o=await mo(e.contentType),r={[t]:[]};if(!Array.isArray(o))return r;for(let i of o)de(r,t,n==="id"?i.id:i.data?.[n]??i.id);return r}if("values"in e&&Array.isArray(e.values)){let t=e.param??"value",n={[t]:[]};for(let o of e.values)de(n,t,o);return n}if("$ref"in e&&typeof e.$ref==="string"&&e.$ref){let t=e.param??"id",n=e.field??"id",o=await p().readFile(e.$ref.replace(/^\.\//,"")),r=JSON.parse(o),i={[t]:[]};if(!Array.isArray(r))return i;for(let s of r)de(i,t,s?.[n]??s?.id??s);return i}return{}}async function fo(){let e=await Pd();for(let t of e){let n=t.classes?.find((o)=>o.name==="ContentCollection");if(n)return n.path}return"@jxsuite/parser/ContentCollection.class.json"}async function mo(e){let t={$prototype:"ContentCollection",$src:await fo(),contentType:e},n=p();if(n.resolveClass)return n.resolveClass(t);return fetch("/__jx_resolve__",{body:JSON.stringify(t),headers:{"content-type":"application/json"},method:"POST"}).then((o)=>{if(!o.ok)throw Error(`Class resolution failed: ${o.status}`);return o.json()})}function de(e,t,n){if(n===null||n===void 0||n==="")return;let o=String(n);e[t]??=[];let r=e[t];if(!r.includes(o))r.push(o)}function Pt(e,t,n){if(Object.keys(t).length===0)return e;let o=_e(e,t);return o.state??={},o.state.$page={params:{...t},title:typeof o.title==="string"?o.title:"",url:Db(n)},o}function St(e){if(!e)return[];return Object.keys(e).filter((t)=>{let n=e[t];return n&&typeof n==="object"&&typeof n.$prototype==="string"&&typeof n.$src==="string"&&JSON.stringify(n).includes('"#/$params/')})}async function Et(e,t,n){if(t.length===0)return;let o=p();if(!o.resolveClass)return;let{state:r}=e;if(!r)return;await Promise.all(t.map(async(i)=>{let s=r[i];if(!s||typeof s!=="object")return;try{r[i]=await o.resolveClass({...s,...n?{$base:n}:{}})}catch(a){console.warn(`page-params: failed to resolve state.${i} for preview:`,a)}}))}function _e(e,t){let n=ho(e,t);if(n!==null)return n;if(!e||typeof e!=="object")return e;if(Array.isArray(e))return e.map((r)=>_e(r,t));let o={};for(let[r,i]of Object.entries(e))o[r]=_e(i,t);return o}function ho(e,t){if(!e||typeof e!=="object"||Array.isArray(e))return null;let n=e.$ref;if(typeof n!=="string"||!n.startsWith("#/$params/"))return null;return t[n.slice(10)]??null}function ex(e){return typeof e?.tagName==="string"&&e.tagName.includes("-")}function Tt(e){if(e===null||typeof e==="number"||typeof e==="boolean")return"literal";if(typeof e==="string")return e.includes("${")?null:"literal";if(Array.isArray(e))return"literal";if(typeof e==="object"){let t=e;if(t.$expression||t.$compute||t.$prototype||t.$handler)return null;return"default"in t||"type"in t?"signal":"literal"}return null}function _T(e){let t=e?.state??{},n=[];for(let[o,r]of Object.entries(t)){if(Mp(o))continue;let i=Tt(r);if(!i)continue;let s=i==="signal"?r.default:r;n.push({name:o,value:s})}return n}function Mt(e,t){let n={...e.state??{}},o=!1;for(let[r,i]of Object.entries(t)){let s=Tt(n[r]);if(!s)continue;n[r]=s==="signal"?{...n[r],default:i}:i,o=!0}if(!o)return e;return{...e,state:n}}function Nt(e,t=[]){if(!e||typeof e!=="object")return null;if(Array.isArray(e.children)){let n=e.children.findIndex((o)=>o&&typeof o==="object"&&!o.$__layout);if(n!==-1)return{offset:n,prefix:[...t,"children"]};for(let o=0;o<e.children.length;o++){let r=e.children[o];if(r&&typeof r==="object"&&r.$__layout){let i=Nt(r,[...t,"children",o]);if(i)return i}}}return null}function je(e,t,n=[]){if(!e||typeof e!=="object")return;if(e.$__layout={file:t,path:n},Array.isArray(e.children))for(let[o,r]of e.children.entries()){if(typeof r==="string")continue;je(r,t,[...n,"children",o])}if(Array.isArray(e.$elements)){for(let[o,r]of e.$elements.entries())if(typeof r!=="string")je(r,t,[...n,"$elements",o])}}async function kt(e,t,n=null){let o={documentPath:t?.documentPath,mode:t?.doc.mode},r=n??Tl(t),i=r==="preview"?structuredClone(re(e)):A(Xu(e)),s=!1,a=o.documentPath&&D?.isSiteProject&&(o.documentPath.startsWith("pages/")||o.documentPath.startsWith("./pages/")),l=null,c=0;if(a&&t?.session.ui.showLayout!==!1){let w=$l(e.$layout);if(w){let v=await Ub(w);if(v){je(v,w.replace(/^\.\//,""));let C=r==="preview"?structuredClone(re(e)):i,x=ZT(v,C);i=r==="preview"?x:A(Xu(x)),s=!0;let E=Nt(x);l=E?.prefix??null,c=E?.offset??0}}}let d=hp(D?.projectRoot),f=o.documentPath?new URL(o.documentPath,d).href:void 0,h=fm(o.documentPath,{fileBaseUrl:d,...We()?{space:p().assetSpace}:{}});if(a&&t){let{previewParams:w}=t.session.ui;if(w&&Object.keys(w).length>0){let v=St(e.state??null);i=Pt(i,w,o.documentPath),await Et(i,v,f)}}if(!a&&t&&ex(i)){let{previewProps:w}=t.session.ui;if(w&&Object.keys(w).length>0)i=Mt(i,w)}let b=new Set;if(r!=="preview")(function w(v,C){if(!v||typeof v!=="object")return;if(v.$prototype==="Array"){b.add(C.join("/"));let x=v.map;if(x&&typeof x==="object")w(x,[...C,"map"]);return}if(Array.isArray(v.children))for(let x=0;x<v.children.length;x++){let E=v.children[x];if(typeof E==="string")continue;w(E,[...C,"children",x])}else if(v.children&&typeof v.children==="object"&&v.children.$prototype==="Array")w(v.children,[...C,"children"]);if(v.$switch&&v.cases)for(let[x,E]of Object.entries(v.cases))w(E,[...C,"cases",x])})(e,[]);let T=o.documentPath!=null&&(o.documentPath.startsWith("layouts/")||o.documentPath.startsWith("./layouts/")),R=Vb(i.$elements);if((o.mode==="content"||s||T)&&st.length>0){let w=new Set(R.map((C)=>typeof C==="string"?C:C?.$ref)),v=(C)=>{let x=new Set;if(!C||typeof C!=="object")return x;if(C.tagName)x.add(qe(C.tagName));if(Array.isArray(C.children)){for(let E of C.children)if(typeof E!=="string")for(let Xn of v(E))x.add(Xn)}return x};for(let C of v(i)){let x=st.find((E)=>E.tagName===C);if(x&&x.source!=="npm"&&x.path){let E=xc(o.documentPath??null,x.path);if(!w.has(E))R.push({$ref:E}),w.add(E)}}}if(R.length>0)i.$elements=R;i.imports=JT(i.imports);let O=Di(i.$media);if(O===void 0)delete i.$media;else i.$media=O;let U=YT(i.$head);if(U===void 0)delete i.$head;else i.$head=U;return{assets:h,docBase:f,mapperCtx:{arrayPaths:[...b],canvasMode:r,layoutWrapped:s,pageContentOffset:c,pageContentPrefix:l},renderDoc:i,siteStyle:D?.projectConfig?.style??null}}var CT="fullRender",kT="mountCanvas",ST="patchBatch",At="prepareRender",xo={derivedResolves:0,derivedRetargets:0,escalations:0,fullRenders:0,hostRenderPosts:0,lastEscalationReason:"",lastFullRenderMs:0,p95FullRenderMs:0,panelRenders:0,patchedOps:0,renderPreparations:0,skippedFullRenders:0,timings:{}};globalThis.__jxCanvasPerf=xo;var Rt=new Map;function $t(){try{return typeof localStorage<"u"&&Boolean(localStorage.getItem("jx-canvas-debug"))}catch{return!1}}function Ot(){return typeof performance<"u"&&typeof performance.now==="function"?performance.now():0}function It(e,t){if($t())console.debug(`[jx-canvas] ${e}`,t??"")}function Ab(e){xo.escalations+=1,xo.lastEscalationReason=e,It("escalation",e)}function go(e){if(e.length===0)return 0;let t=e.toSorted((o,r)=>o-r),n=Math.min(t.length-1,Math.ceil(t.length*0.95)-1);return t[Math.max(0,n)]??0}function vo(e,t){let n=Number.isFinite(t)&&t>0?t:0,o=Rt.get(e);if(!o)o=[],Rt.set(e,o);if(o.push(n),o.length>128)o.shift();let r=xo.timings[e],i={count:(r?.count??0)+1,lastMs:n,maxMs:Math.max(r?.maxMs??0,n),p95Ms:go(o),totalMs:(r?.totalMs??0)+n};if(xo.timings[e]=i,e==="fullRender")xo.lastFullRenderMs=i.lastMs,xo.p95FullRenderMs=i.p95Ms;It(`span:${e}`,`${n.toFixed(2)}ms`)}function Dt(e){let t=Ot(),n=$t(),o=`jx-${e}-start`;if(n)try{performance.mark(o)}catch{}let r=!1;return()=>{if(r)return xo.timings[e]?.lastMs??0;r=!0;let i=Ot()-t;if(n)try{performance.measure(`jx-${e}`,o),performance.clearMarks(o)}catch{}return vo(e,i),i}}function tx(e,t){let n=Dt(e);try{return t()}finally{n()}}async function nx(e,t){let n=Dt(e);try{return await t()}finally{n()}}function bi(e){if(e==="--")return"Base";return e.replace(/^--/,"").replaceAll("-"," ").replaceAll(/\b\w/g,(t)=>t.toUpperCase())||e}var Ht=new Set(["script","style","link","iframe","object","embed"]);function yd(e){let t={tagName:e};if(/^h[1-6]$/.test(e))t.textContent="Heading";else if(e==="p")t.textContent="Paragraph text";else if(e==="span"||e==="strong"||e==="em"||e==="small"||e==="mark"||e==="code"||e==="abbr"||e==="q"||e==="sub"||e==="sup"||e==="time")t.textContent="Text";else if(e==="a")t.textContent="Link",t.attributes={href:"#"};else if(e==="button")t.textContent="Button";else if(e==="label")t.textContent="Label";else if(e==="legend")t.textContent="Legend";else if(e==="caption")t.textContent="Caption";else if(e==="summary")t.textContent="Summary";else if(e==="li"||e==="dt"||e==="dd"||e==="th"||e==="td"||e==="option")t.textContent="Item";else if(e==="blockquote")t.textContent="Quote";else if(e==="pre")t.textContent="Preformatted text";else if(e==="input")t.attributes={placeholder:"Enter text...",type:"text"};else if(e==="img")t.attributes={alt:"Image"};else if(e==="iframe")t.attributes={src:""};else if(e==="slot")t.children=[{tagName:"p",textContent:"Slot content"}];else if(e==="select")t.children=[{tagName:"option",textContent:"Option 1"}];else if(e==="ul"||e==="ol")t.children=[{tagName:"li",textContent:"Item"}];else if(e==="dl")t.children=[{tagName:"dt",textContent:"Term"},{tagName:"dd",textContent:"Definition"}];else if(e==="table")t.children=[{children:[{children:[{tagName:"th",textContent:"Header"}],tagName:"tr"}],tagName:"thead"},{children:[{children:[{tagName:"td",textContent:"Cell"}],tagName:"tr"}],tagName:"tbody"}];else if(e==="details")t.children=[{tagName:"summary",textContent:"Summary"},{tagName:"p",textContent:"Detail content"}];return t}function j(e){if(!e)return[];if(Array.isArray(e.children))return e.children;return typeof e.textContent==="string"&&e.textContent.length>0?[e.textContent]:[]}function Y(e){let t=0;for(let n of e)t+=typeof n==="string"?n.length:Y(j(n));return t}function Fe(e,t,n){let o=[],r=0;for(let i of e){if(r>=n)break;if(typeof i==="string"){let c=r+i.length;if(c>t){let d=i.slice(Math.max(0,t-r),Math.max(0,Math.min(n,c)-r));if(d)o.push(d)}r=c;continue}let s=j(i),a=Y(s),l=r+a;if(a===0){if(r>=t&&r<n)o.push({...i})}else if(l>t){let c=Fe(s,Math.max(0,t-r),Math.min(n,l)-r);if(c.length>0)o.push(yo(i,c))}r=l}return o}function yo(e,t){let{children:n,textContent:o,...r}=e;if(t.length===0)return{...r,textContent:""};if(t.length===1&&typeof t[0]==="string")return{...r,textContent:t[0]};return{...r,children:t}}function Jt(e){let t=[];for(let n of e){if(typeof n==="string"){if(n.length===0)continue;let o=t.at(-1);if(typeof o==="string"){t[t.length-1]=o+n;continue}}t.push(n)}return t}function Lt(e,t,n,o,r=""){return Jt([...Fe(e,0,t),...r?[r]:[],...Fe(n,o,Y(n))])}function Ve(e){let t=Jt(e);if(t.length===0)return{textContent:""};if(t.length===1&&typeof t[0]==="string")return{textContent:t[0]};return{children:t}}function bo(e){if(!e)return!0;if(e.textContent!=null&&e.textContent.trim()==="")return!0;let t=e.children;if(!t)return!1;if(t.length===0)return!0;if(t.length===1&&typeof t[0]==="string"&&t[0].trim()==="")return!0;return t.length===1&&typeof t[0]==="object"&&t[0]?.tagName==="br"}function _t(e,t,n,o,r={}){if(!e)return;let i=K(e.doc.document,t);if(n){if(i&&JSON.stringify(i.children)===JSON.stringify(n))return;q(e,(s)=>{if(i?.textContent!=null)Ue(s,t,"textContent");Ue(s,t,"children",n)},{coalesceKey:r.coalesceKey??null})}else if(o!=null){if(i&&i.textContent===o&&!i.children)return;q(e,(s)=>{if(i?.children)Ue(s,t,"children");Ue(s,t,"textContent",o)},{coalesceKey:r.coalesceKey??null})}}function jt(e,t,n,o){if(!e)return!1;let r=K(e.doc.document,t);if(!r)return!1;if(`${r.$props?.[n]??""}`===o)return!1;return q(e,(s)=>{Uu(s,t,n,o)}),!0}function qt(e,t,n){if(!e)return null;let o=K(e.doc.document,t),r=K(e.doc.document,n);if(!o||!r)return null;if(qa(t,n)||qa(n,t))return null;let i=j(r),s=j(o),a=Y(i),l=Ve([...i,...s]);return q(e,(c)=>{if(l.children){if(r.textContent!=null)Ue(c,n,"textContent");Ue(c,n,"children",l.children)}else{if(r.children)Ue(c,n,"children");Ue(c,n,"textContent",l.textContent??"")}if(Vu(c,t),Ft(c,ht(t)),Cp(e))c.session.selection=[n]}),{offset:a,path:n}}function Ft(e,t){let n=t;while(n.length>0){let o=K(e.doc.document,n),r=o?.children;if(!o||!Array.isArray(r)||r.length>0)return;let i=ht(n);if(Vu(e,n),!i)return;n=i}}function Wt(e,t,n,o){let r=ht(t),i=_n(t),s=[...r,"children",i+1];if(!e)return s;let a={tagName:"p"};if(o.textContent!=null)a.textContent=o.textContent;else if(o.children)a.children=o.children;else a.textContent="";return q(e,(l)=>{if(n.textContent!=null)Ue(l,t,"children"),Ue(l,t,"textContent",n.textContent);else if(n.children)Ue(l,t,"textContent"),Ue(l,t,"children",n.children);if(Ji(l,r,i+1,a),Cp(e))l.session.selection=[s]}),s}function Vt(e,t,n,o){if(bo(o)){if(!e)return t;return q(e,(l)=>{Ue(l,t,"tagName",n.tag),Ue(l,t,"children");let c=yd(n.tag);if(c.textContent&&c.textContent!=="Paragraph text")Ue(l,t,"textContent",c.textContent);else Ue(l,t,"textContent");if(Cp(e))l.session.selection=[t]}),t}let r=ht(t),i=_n(t),s=[...r,"children",i+1];if(!e)return s;let a=yd(n.tag);return q(e,(l)=>{if(o?.children)Ue(l,t,"textContent"),Ue(l,t,"children",o.children);else if(o?.textContent!=null)Ue(l,t,"children"),Ue(l,t,"textContent",o.textContent);if(Ji(l,r,i+1,structuredClone(a)),Cp(e))l.session.selection=[s]}),s}function Bt(e,t,n,o,r){if(!e)return null;let i=K(e.doc.document,t.path),s=K(e.doc.document,n.path);if(!i||!s)return null;if(qa(t.path,n.path)||qa(n.path,t.path))return null;let a=Ve(Lt(j(i),t.offset,j(s),n.offset,r)),l=[...o,n.path].toSorted(Co);return q(e,(c)=>{if(a.children){if(i.textContent!=null)Ue(c,t.path,"textContent");Ue(c,t.path,"children",a.children)}else{if(i.children)Ue(c,t.path,"children");Ue(c,t.path,"textContent",a.textContent??"")}for(let d of l)if(K(c.doc.document,d))Vu(c,d),Ft(c,ht(d));if(Cp(e))c.session.selection=[t.path]}),{offset:t.offset+r.length,path:t.path}}function Co(e,t){let n=Math.min(e.length,t.length);for(let o=0;o<n;o++){let r=e[o],i=t[o];if(r===i)continue;if(typeof r==="number"&&typeof i==="number")return i-r;return String(i).localeCompare(String(r))}return t.length-e.length}function M(e,t=1){return{height:e.height*t,left:e.x*t,top:e.y*t,width:e.width*t}}function ET(e,t,n=1){return{x:(e.x-t.left)/n,y:(e.y-t.top)/n}}function fe(e,t){if(!t){e.style.display="none";return}e.style.display="block",e.style.left=`${t.left}px`,e.style.top=`${t.top}px`,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`}function zt(e=document){let t=e.createElement("div");t.className="jx-canvas-iframe-overlay",t.style.cssText="position:absolute;inset:0;pointer-events:none;overflow:hidden;z-index:2";let n=e.createElement("div");n.className="overlay-box overlay-selection",n.style.display="none";let o=e.createElement("div");o.className="overlay-label",o.style.display="none",n.append(o);let r=e.createElement("div");r.className="overlay-box overlay-hover",r.style.display="none";let i=e.createElement("div");i.className="canvas-drop-indicator",i.style.display="none";let s=e.createElement("button");s.className="insertion-helper",s.textContent="+",s.style.pointerEvents="auto",s.style.display="none";let a=e.createElement("div");a.className="canvas-replace-target",a.style.display="none";let l=e.createElement("div");l.className="overlay-presence-group";let c=e.createElement("div");return c.className="overlay-coselection-group",t.append(r,n,c,i,a,s,l),{dispose:()=>t.remove(),insertButton:s,root:t,setDropIndicator:(d,f="inside")=>So(i,d,f),setHover:(d)=>fe(r,d),setInsertZone:(d,f="center")=>Po(s,d,f),setReplaceTarget:(d)=>fe(a,d),setSuppressed:(d)=>{t.style.display=d?"none":""},setCoSelection:(d)=>{c.replaceChildren();for(let f of d){let h=e.createElement("div");h.className="overlay-box overlay-selection overlay-coselection",fe(h,f),c.append(h)}},setPresence:(d)=>{l.replaceChildren();for(let f of d){let h=e.createElement("div");h.className="overlay-box overlay-presence",h.style.cssText=`position:absolute;display:block;pointer-events:none;outline:1.5px solid ${f.color};outline-offset:1px;left:${f.placement.left}px;top:${f.placement.top}px;width:${f.placement.width}px;height:${f.placement.height}px`;let b=e.createElement("div");b.className="overlay-presence-tag",b.textContent=f.label,b.style.cssText=`position:absolute;top:-18px;left:-2px;padding:1px 5px;border-radius:3px;font:10px/1.4 sans-serif;color:#fff;white-space:nowrap;background:${f.color}`,h.append(b),l.append(h)}},setSelection:(d,f=null)=>{if(fe(n,d),d&&f)o.textContent=f,o.style.display="block";else o.style.display="none"}}}function Po(e,t,n){if(!t){e.style.display="none",e.classList.remove("visible");return}e.dataset.edge=n,e.classList.add("visible"),e.style.display="grid",e.style.left=`${t.left+t.width/2}px`,e.style.top=`${t.top+t.height/2}px`,e.style.translate="-50% -50%"}function So(e,t,n){if(!t){e.style.display="none";return}if(e.style.display="block",e.style.left=`${t.left}px`,e.style.width=`${t.width}px`,n==="inside"){e.className="canvas-drop-indicator inside",e.style.top=`${t.top}px`,e.style.height=`${t.height}px`;return}e.className="canvas-drop-indicator line",e.style.height="",e.style.top=`${n==="top"?t.top:t.top+t.height}px`}function Il(e){return JSON.stringify(e)}var wd={$id:"elements-meta",title:"HTML Element Metadata",description:"Inline scoping and inline toolbar action metadata for HTML elements.",$convertGroups:{text:["p","h1","h2","h3","h4","h5","h6","blockquote"],container:["div","section","article","aside","main","header","footer","nav","search"],list:["ul","ol"]},$defs:{p:{$convertTo:"text",$convertToWhenEmpty:["text","container"],$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:[{tag:"strong",label:"Bold",command:"bold"},{tag:"em",label:"Italic",command:"italic"},{tag:"u",label:"Underline",command:"underline"},{tag:"del",label:"Strikethrough",command:"strikethrough"},{tag:"sup",label:"Superscript",command:"superscript"},{tag:"sub",label:"Subscript",command:"subscript"},{tag:"code",label:"Code",command:"code"},{tag:"a",label:"Link",command:"link"}]},h1:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:[{tag:"strong",label:"Bold",command:"bold"},{tag:"em",label:"Italic",command:"italic"},{tag:"code",label:"Code",command:"code"},{tag:"a",label:"Link",command:"link"}]},h2:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h3:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h4:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h5:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h6:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},li:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},td:{$inlineChildren:["em","strong","del","code","a","span","br","b","i","u","sub","sup","s"],$inlineActions:"p"},th:{$inlineChildren:["em","strong","del","code","a","span","br","b","i","u","sub","sup","s"],$inlineActions:"p"},blockquote:{$convertTo:"text",$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},figcaption:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},caption:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},summary:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},dt:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},dd:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},label:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},a:{$inlineChildren:["em","strong","code","span","br","b","i","u","sub","sup"],$inlineActions:[{tag:"strong",label:"Bold",command:"bold"},{tag:"em",label:"Italic",command:"italic"},{tag:"code",label:"Code",command:"code"}]},span:{$inlineChildren:["em","strong","del","code","a","br","b","i","u","sub","sup","s"],$inlineActions:"p"},div:{$convertTo:"container",$convertToWhenEmpty:["container","text"],$inlineChildren:[]},section:{$convertTo:"container",$inlineChildren:[]},article:{$convertTo:"container",$inlineChildren:[]},nav:{$convertTo:"container",$inlineChildren:[]},main:{$convertTo:"container",$inlineChildren:[]},header:{$convertTo:"container",$inlineChildren:[]},footer:{$convertTo:"container",$inlineChildren:[]},aside:{$convertTo:"container",$inlineChildren:[]},ul:{$convertTo:"list",$inlineChildren:[]},ol:{$convertTo:"list",$inlineChildren:[]},pre:{$inlineChildren:["code"]},table:{$inlineChildren:[]},thead:{$inlineChildren:[]},tbody:{$inlineChildren:[]},tr:{$inlineChildren:[]}}};var To=new Set(["pre"]),na=new Set(Object.entries(wd.$defs).filter(([e,t])=>!To.has(e)&&(t.$inlineChildren?.length??0)>0).map(([e])=>e));var Kt=new Set(["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"]);function Be(e,t){if(!t)return Kt.has(e);let n=wd.$defs[t];if(!n||!n.$inlineChildren)return!1;return n.$inlineChildren.includes(e)}function TT(e){let t=wd.$defs[e];if(!t)return null;let n=t.$inlineActions;if(typeof n==="string")n=wd.$defs[n]?.$inlineActions??void 0;if(!Array.isArray(n))return null;return n}var Mo=null;function ix(e,t){if(!e||typeof e!=="object")return!1;let n=(qe(e.tagName)||"div").toLowerCase();if(t){let o=(qe(t.tagName)||"div").toLowerCase();return Be(n,o)}return Kt.has(n)}function LT(){return Mo!==null}function me(e){return!e||e==="base"?null:e}function Nb(e){let t=e.panels;if(t.length===0)return null;if(t.length===1)return t[0];let n=Nu(e.paneId);for(let o of t){if(n===null&&(o.mediaName==="base"||o.mediaName===null))return o;if(o.mediaName===n)return o}return t[0]}function Ut(){return Nb(Uo())}function IT(e,t){if(!e)return t;let n=t;while(n.length>=2){let o=K(e,n),r=ht(n),i=r?K(e,r):null;if(!o||!i)break;let s=(qe(o.tagName)||"div").toLowerCase(),a=(qe(i.tagName)||"div").toLowerCase();if(!Be(s,a))break;n=r}return n}function Ob(e){return Dv(e)!==null}function Ou(e){return Dv(e)}function hr(e){if(!e)return{baseWidth:320,featureQueries:[],sizeBreakpoints:[]};let t=[],n=[],o=320;for(let[r,i]of Object.entries(e)){if(r==="--"){let l=String(i).match(/^(\d+)\s*px$/);o=l?Number(l[1]):320;continue}let s=i.match(/min-width:\s*([\d.]+)px/),a=i.match(/max-width:\s*([\d.]+)px/);if(s)n.push({name:r,query:i,type:"min",width:Number(s[1])});else if(a)n.push({name:r,query:i,type:"max",width:Number(a[1])});else t.push({name:r,query:i})}return n.sort((r,i)=>r.type==="min"?r.width-i.width:i.width-r.width),{baseWidth:o,featureQueries:t,sizeBreakpoints:n}}function No(e,t){let n=new Set;for(let o of e)if(o.type==="min"&&t>=o.width)n.add(o.name);else if(o.type==="max"&&t<=o.width)n.add(o.name);return n}function Gt(e,t){let n=No(e,t),o=null;for(let r of e){if(!n.has(r.name))continue;let i=Math.abs(r.width-t);if(o===null){o=r;continue}let s=Math.abs(o.width-t);if(i<s||i===s&&r.width<o.width)o=r}return o?.name??null}function RT(e,t,n=8){let o=null;for(let r of t){let i=Math.abs(r-e);if(i>n)continue;if(o===null||i<Math.abs(o-e))o=r}return o??e}var cp=240,$T=8,DT=16,he=new Map;function ze(e){return hr(Di(e.doc.document?.$media))}function ox(e){let{baseWidth:t,sizeBreakpoints:n}=ze(e),o=e.session.ui.activeMedia;return n.find((r)=>r.name===o)?.width??t}function ko(e,t){let n=he.get(e);if(!n)return null;if(!t||n.tabId!==t.id||n.media!==t.session.ui.activeMedia)return he.delete(e),null;return n.width}function AT(e,t){let n=t?ox(t):0;return ko(e.paneId,t)??n}function rx(e){he.delete(e)}function NT(e){let{baseWidth:t,sizeBreakpoints:n}=ze(e);return[t,...n.map((o)=>o.width)]}function sx(e,t,n){let{sizeBreakpoints:o}=ze(t),r=Gt(o,n);return t.session.ui.activeMedia=r,he.set(e,{media:r,tabId:t.id,width:n}),r}var Ke={invokerTags:jm,popoverTags:jd};function G1(e,t){if(!e||!t)return null;for(let n=t.length;n>=0;n-=1){let o=t.slice(0,n),r=K(e,o);if(r&&typeof r==="object"&&Gs(r,Ke))return o}return null}function Zt(e,t){let n=e.doc.document;if(!n)return null;if(t){let o=K(n,t);return o&&typeof o==="object"&&Gs(o,Ke)?t:null}return G1(n,Le(e.session.selection))}function Xt(){let e=u.value?.doc.document;return e?wI(e,Ke):!1}var Yt=["toggle-popover","show-popover","hide-popover","show-modal","close","request-close"],Ge=new Set(["show-modal","close","request-close"]),Ze=new Set(["toggle-popover","show-popover","hide-popover"]),Ro=["any","closerequest","none"],Oo=new Set(["button"]),I="See docs/framework/concepts/overlays.";function H(e){return ro(e)==="dialog"}function Qt(e){return e.startsWith("--")}function Ao(e){let t=[];for(let{node:n}of Ya(e)){let o=nh(n);if(H(n)&&o!==null&&!t.includes(o))t.push(o)}return t}function en(e){for(let{node:t}of Ya(e))if(H(t))return!0;return!1}function $o(e){let t=e.oncommand;return t!==void 0&&t!==null}function Io(e,t){for(let{node:n}of Ya(e)){if(n===e)continue;let o=ro(n);if(o==="button"){let r=Kr(n,"command"),i=Kr(n,"commandfor");if(r!==null&&(r==="close"||r==="request-close")&&(i===null||i===t))return!0}if(o==="form"&&Kr(n,"method")?.toLowerCase()==="dialog")return!0}return!1}function vT(e,t){let n=[...Ya(e,[],null,t)],o=Ao(e),r=Fm(e,t),i=o.length>0||r.length>0,s=new Map,a=new Map;for(let{node:c}of n){let d=nh(c);if(d!==null&&!s.has(d))s.set(d,c);if(ro(c)==="button"){let f=Kr(c,"commandfor"),h=Kr(c,"command");if(f!==null){let b=a.get(f)??new Set;b.add(h??""),a.set(f,b)}}}let l=[];for(let{node:c,path:d}of n)if(l.push(...Ho(c,d,s,o,r,i,t)),H(c))l.push(...Jo(c,d,a));return l}function Ho(e,t,n,o,r,i,s){let a=[],l=ro(e),c=s?.invokerTags?.has(l)??!1,d=Kr(e,"command"),f=Kr(e,"commandfor");if(!(d!==null||f!==null||("command"in Wl(e))||("commandfor"in Wl(e))))return a;let b=Jr(e,"the element");if(!Oo.has(l)&&!c)return a.push({detail:"`command` and `commandfor` are attributes of `HTMLButtonElement` and of no other "+"interface — not even `<input>`, which `popovertarget` does allow. Elsewhere they parse "+`and do nothing. Make it a <button>, or remove both attributes. ${I}`,fix:"invoker",message:`<${l||"element"}> carries command/commandfor, which only <button> supports.`,path:t,rule:"invoker-not-button",severity:"error"}),a;if(d!==null&&!Yt.includes(d)&&!Qt(d))return a.push({detail:`\`command\` is an enumerated attribute taking ${Yt.map((T)=>`\`${T}\``).join(", ")}, or a custom command starting with \`--\`. Anything else is the invalid-value state, and a button in that state does nothing when clicked. ${I}`,message:`${b} declares command="${d}", which is not a built-in or --custom command.`,path:t,rule:"command-invalid",severity:"error"}),a;if(f!==null){let T=n.get(f),R=o.includes(f),O=r.includes(f);if(!T&&i){let U=[...o,...r].map((w)=>`"${w}"`).join(", ");return a.push({detail:`No element in this document has the id "${f}". The dialogs and popovers here are: ${U}. A commandfor that names nothing does nothing, silently. ${I}`,message:`commandfor="${f}" names nothing in this document.`,path:t,rule:"command-target-missing",severity:"error"}),a}if(d!==null&&T){if(Ge.has(d)&&!H(T))a.push({detail:`\`${d}\` acts on a <dialog>, and "${f}" is ${O?"a popover":`a <${ro(T)||"element"}>`}. The click is ignored. ${O?"Use `toggle-popover`, `show-popover` or `hide-popover` for a popover.":"Point it at a dialog, or make the target one."} ${I}`,message:`${b} sends ${d} to "${f}", which is not a dialog.`,path:t,rule:"command-target-mismatch",severity:"error"});else if(Ze.has(d)&&!Gs(T,s))a.push({detail:`\`${d}\` acts on a popover, and "${f}" is ${R?"a dialog":`a <${ro(T)||"element"}>`} that declares no \`popover\`. The click is ignored. ${R?"Use `show-modal`, `close` or `request-close` for a dialog.":"Give the target a `popover` attribute, or point the button elsewhere."} ${I}`,message:`${b} sends ${d} to "${f}", which is not a popover.`,path:t,rule:"command-target-mismatch",severity:"error"});else if(Qt(d)&&!$o(T))a.push({detail:`A custom command is a \`CommandEvent\` dispatched at its target, and "${f}" has no `+"`oncommand` handler to answer it — so the click does nothing. Add one that switches on "+`\`event#/command\`, or use a built-in command. ${I}`,message:`${b} sends ${d} to "${f}", which handles no command.`,path:t,rule:"custom-command-unhandled",severity:"warn"})}}return a}function Jo(e,t,n){let o=[],r=Jr(e,"the dialog"),i=nh(e),{style:s}=e,a=Kr(e,"closedby");if(a!==null&&!Ro.includes(a))o.push({detail:`\`closedby\` is an enumerated attribute taking \`any\` (light dismiss and Escape), \`closerequest\` (Escape only, the default for a modal) or \`none\`. Anything else is the invalid-value default, \`auto\`, which is the same as leaving it out. ${I}`,message:`${r} declares closedby="${a}", which is not any, closerequest or none.`,path:t,rule:"dialog-closedby-invalid",severity:"error"});if(Qo(s,"display")!==null)o.push({detail:`A closed dialog is hidden by the browser's own \`dialog:not([open]) { display: none }\`. That rule is UA-origin, so any author \`display\` beats it, and the dialog is laid out on every page whether or not anyone opened it. \`display\` belongs in the \`&[open]\` rule and nowhere else. ${I}`,fix:"display",message:`${r} sets display in its base rule.`,path:t,rule:"dialog-display",severity:"error"});let l=i===null?void 0:n.get(i),c=Kr(e,"open")!==null||Wl(e).open===!0||e.open===!0;if(i!==null&&!l?.has("show-modal")&&!c)o.push({detail:`No <button> in this document opens it with \`command="show-modal"\`. If it is opened from another file or from a function that calls \`showModal()\`, this is fine; otherwise there is no way for a reader to open it. ${I}`,message:`${r} has no invoker in this document.`,path:t,rule:"dialog-no-invoker",severity:"warn"});if(l?.has("show-modal")&&a==="none"&&!Io(e,i))o.push({detail:`A modal dialog makes everything outside it inert, so the only ways out are the ones it offers: \`closedby="none"\` turns off Escape and light dismiss, and nothing inside it closes it. A reader who opens it cannot leave. Add a <button command="close"> inside, or drop \`closedby="none"\`. ${I}`,message:`${r} opens modally, closes on nothing, and has no close button.`,path:t,rule:"modal-without-close",severity:"error"});return o}function K1(e,t){if(!e||!t)return null;for(let n=t.length;n>=0;n-=1){let o=t.slice(0,n),r=K(e,o);if(r&&typeof r==="object"&&H(r))return o}return null}function ax(e,t){let n=e.doc.document;if(!n)return null;if(t){let o=K(n,t);return o&&typeof o==="object"&&H(o)?t:null}return K1(n,Le(e.session.selection))}function tn(){let e=u.value?.doc.document;return e?en(e):!1}function V(e){return lt(e.paneId)}function ee(e){let t=ur(e.paneId);if(t?.kind==="lens")return t.zoom;return V(e)?.session.ui.zoom??1}function lx(e=Uo()){return ee(e)}function ve(e,t){let n=ur(e.paneId);if(n?.kind==="lens"){n.zoom=t;return}let o=V(e);if(o)o.session.ui.zoom=t}function Mu(e,t,n,o=null){let r={_width:o||null,canvas:null,element:null,mediaName:e||"",ready:!1,renderScope:null,scrollContainer:null,viewport:null},i=[];if(o&&!n)i.push(`--panel-viewport-w:${o}px`);if(o)i.push(`--panel-canvas-w:${o}px`);return{item:{fullWidth:n,header:t?"shown":"hidden",key:e??"",label:t??"",mediaAttr:e,widthVars:i.join(";")},panel:r}}function OT(e,t){for(let{item:n,panel:o}of e)o.element=t.panelNode(n.key,"panel"),o.viewport=t.panelNode(n.key,"panel-viewport"),o.canvas=t.panelNode(n.key,"panel-canvas")}function MT(e,t){let n=e.find((r)=>r.item.key===t);if(!n)return;let o=wt(n.panel);if(o)o.session.ui.activeMedia=me(n.item.mediaAttr)}function Qe(e){if(!e.panzoomWrap)return;let t=e.wrap.clientWidth,n=e.panzoomWrap.scrollWidth,o=ee(e),r=n*o;e.panX=Math.max(16,(t-r)/2),e.panY=0}function Mb(e){if(e.centerObserver)e.centerObserver.disconnect(),e.centerObserver=null;if(!e.panzoomWrap)return;e.needsCenter=!0,e.centerObserver=new ResizeObserver(()=>{if(!e.needsCenter){e.centerObserver?.disconnect(),e.centerObserver=null;return}Qe(e),us(e)}),e.centerObserver.observe(e.panzoomWrap),Qe(e)}function us(e){if(!e.panzoomWrap)return;let t=ee(e);e.panzoomWrap.style.transform=`translate(${e.panX}px, ${e.panY}px) scale(${t})`,Ai("overlays")}var et=0.25,tt=3;function rn(e){return Math.min(tt,Math.max(et,e))}function xd(e=Uo()){if(wo(e.paneId)!=="edit")return;let[t]=e.panels;if(!t?.canvas||!t.viewport)return;let n=t.canvas,o=n.querySelector("iframe"),r=V(e)?.session.ui.editZoom??1;if(r===1){if(t._width=null,n.style.width="",n.style.transform="",n.style.transformOrigin="",o)o.style.width="100%";t.viewport.style.height=""}else{let i=e.wrap.querySelector('[part="edit-column"]');if(!i)return;let s=Oe(i).width;if(s<=0)return;let a=s/r;if(t._width=a,n.style.width=`${a}px`,n.style.transform=`scale(${r})`,n.style.transformOrigin="top left",o)o.style.width=`${a}px`,t.viewport.style.height=`${o.offsetHeight*r}px`}Ai("overlays")}function Pu(e,t=Uo()){let n=V(t);if(!n)return;n.session.ui.editZoom=rn(e),xd(t)}var Xe=new Map;function PT(e,t=Uo()){let n=V(t);if(!n)return;if(n.session.ui.editZoom=rn(e),Xe.has(t.paneId))return;Xe.set(t.paneId,requestAnimationFrame(()=>{Xe.delete(t.paneId),xd(t)}))}function an(e,t,n){if(!e.panzoomWrap)return;let o=e.wrap.clientWidth,r=e.wrap.clientHeight,i=24,s=32,a=0,{panels:l}=e;for(let v of l)a+=v._width||800;a+=i*Math.max(0,l.length-1)+s;let c=ee(e),h=Oe(e.panzoomWrap).height/c+s,b=o/a,T=r/h,R=t==="width"?b:Math.min(b,T),O=Math.min(n,Math.max(F,R));ve(e,O);let U=a*O,w=h*O;e.panX=Math.max(0,(o-U)/2),e.panY=Math.max(0,(r-w)/2),us(e)}function FT({maxZoom:e=W,surface:t=Uo()}={}){te("page",t),an(t,"page",e)}var F=0.05,W=5;function rt(e){return Math.min(W,Math.max(F,e))}var Lo="page",nt=["width","page","none"];function jo(e,t,n){let o=t[n];if(typeof o==="string"&&nt.includes(o))return o;if(typeof o==="number"&&o>=F&&o<=W)return o;throw RangeError(`command "${e}" argument "${n}": expected ${nt.map((r)=>`"${r}"`).join(" | ")} or a number in [${F}, ${W}], got ${JSON.stringify(o)}`)}var sn=new Map;function ln(e){let t=V(e);if(!t)return null;let n=ur(e.paneId)?.kind==="lens"?`::${e.paneId}`:"";return`${t.id}::${t.documentPath??""}${n}`}function te(e,t){let n=ln(t);if(n)sn.set(n,e)}function cx(e=Uo()){let t=ln(e);return(t===null?void 0:sn.get(t))??Lo}function cn(e,t=Uo()){let n=e??cx(t);if(n==="none"){us(t);return}if(typeof n==="number"){ve(t,rt(n)),us(t);return}an(t,n,1)}function J1(e,t=Uo()){te(e,t),cn(e,t)}function jT(e=Uo()){te(rt(ee(e)),e)}function dx(e,t=Uo()){if(!V(t))return;let o=rt(e);te(o,t),ve(t,o),us(t)}function ux(e){if(e.wrap.clientWidth<=0){us(e);return}cn(cx(e),e)}function HT(e=Uo()){if(te(1,e),!e.panzoomWrap)return;ve(e,1),Qe(e),us(e)}function qo(e,t){let n=Oe(un(e)??e.wrap),o=t.top+t.height/2-n.top;return n.height/2-o}function un(e){return Nb(e)?.scrollContainer??null}function Fo(e,t,n){let o=un(e);if(!o){Wo(e,t);return}let r=o.scrollTop-t;if(n){o.scrollTo({behavior:"smooth",top:r});return}o.scrollTop=r}function Pb(e,t=Uo()){Fo(t,qo(t,e),!1)}function Wo(e,t){let n=e.panY,o=n+t,r=performance.now(),i=250,s=(a)=>{let l=Math.min((a-r)/250,1),c=l*(2-l);if(e.panY=n+(o-n)*c,us(e),l<1)requestAnimationFrame(s)};requestAnimationFrame(s)}var Ye=["edit","design","preview","source","stylebook","grid","git-diff"],ye=new Set(["edit","design"]),Vo=["edit","design","preview"];function Bo(e){return Vo.filter((t)=>e.capabilities.modes.includes(t))}function BT(e){return Bo(e).filter((t)=>t!=="preview")}function Y1(e){let t=e.session.ui.canvasMode;return ye.has(t)?t:null}function Z1(e){return{available:e.capabilities.modes.includes("preview")&&ye.has(e.session.ui.canvasMode),on:e.session.ui.preview===!0}}function X1(e,t,n){if(t==="preview"){if(ye.has(e.session.ui.canvasMode))e.session.ui.preview=!0;return}if(e.session.ui.preview=!1,e.session.ui.canvasMode!==t)n(e,t)}var nn=new Set(["design","stylebook","git-diff"]),N=(e)=>e.document.open,on=["auto","light","dark"];function zo(e){function t(s){let a=u.value;if(!a)throw RangeError(`command "${s}" needs an open document; no tab is active`);return a}function n(s,a){let{pane:l}=a;if(l===void 0)return t(s);let c=ot(s,a,"pane"),d=lt(c);if(!d)throw RangeError(`command "${s}" argument "pane": "${c}" has no open document`);return d}let o={pane:He("Which pane to render this way. Defaults to the focused one.")};function r(s){e.renderPane(i(s))}function i(s){let{pane:a}=s;return typeof a==="string"?a:m.activePaneId}return[{args:Se({mode:Do(Ye,"The canvas mode to switch the active pane to.")}),category:"View",id:"canvas.setMode",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:N,aiTool:{description:"Switch the active document's editor mode. edit and design put its element tree on the canvas, where the document tools work; preview renders it as a visitor sees it; source shows the JSON; stylebook, grid and git-diff open other editors. Use it to return a document to edit or design when the tree tools are refused.",name:"set_canvas_mode",report:({after:s,args:a})=>{let l=li("canvas.setMode",a,"mode",Ye),c=s.editor.kind==="canvas"?"the document tools address its element tree":"the tree-editing tools are unavailable until it returns to edit or design";return`The active document is in ${l} mode; ${c}.`}},run:(s,a)=>{let l=li("canvas.setMode",a,"mode",Ye),c=t("canvas.setMode"),{modes:d}=c.capabilities;if(!d.includes(l))throw RangeError(`command "canvas.setMode" argument "mode": "${l}" is not a mode this document `+`supports — it declares: ${d.join(", ")}`);if(l==="preview"){let f=c.session.ui.canvasMode;if(!ye.has(f))throw RangeError(`command "canvas.setMode" argument "mode": "preview" composes with the edit and design base modes; this pane is in "${f}"`);c.session.ui.preview=!0;return}c.session.ui.preview=!1,e.setCanvasMode(c,l)},title:"Set Canvas Mode"},{args:Se({zoom:qC("Pan-zoom scale, 1 = 100%.",{maximum:W,minimum:F})}),category:"View",id:"canvas.setZoom",level:"document",menus:["palette"],group:"3_canvas",requires:"a document on the pan-zoom surface",when:N,enablement:()=>nn.has(e.getCanvasMode()),run:(s,a)=>{t("canvas.setZoom"),dx(yv("canvas.setZoom",a,"zoom",F,W))},title:"Set Zoom"},{args:Se({fit:{description:'How the document is framed: "width" | "page" | "none", or a numeric pan-zoom scale.',oneOf:[{enum:[...nt],type:"string"},{maximum:W,minimum:F,type:"number"}]}}),category:"View",id:"canvas.setFit",level:"document",menus:["palette"],group:"3_canvas",requires:"a document on the pan-zoom surface",when:N,enablement:()=>nn.has(e.getCanvasMode()),run:(s,a)=>{t("canvas.setFit"),J1(jo("canvas.setFit",a,"fit"))},title:"Set Fit"},{args:Se({zoom:qC("Edit-mode content zoom, 1 = 100%.",{maximum:tt,minimum:et})}),category:"View",id:"canvas.setEditZoom",level:"document",menus:["palette"],group:"3_canvas",requires:"a document in edit mode",when:N,enablement:()=>e.getCanvasMode()==="edit",run:(s,a)=>{t("canvas.setEditZoom"),Pu(yv("canvas.setEditZoom",a,"zoom",et,tt))},title:"Set Edit Zoom"},{args:{additionalProperties:!1,properties:{...o,width:{description:"How wide the Edit column should render, in CSS pixels, or null to go back to the chosen breakpoint's own width.",type:["number","null"]}},required:["width"],type:"object"},category:"View",id:"canvas.setEditWidth",level:"document",menus:["palette"],group:"3_canvas",requires:"a document in edit mode",when:N,enablement:()=>e.getCanvasMode()==="edit",run:(s,a)=>{let l=n("canvas.setEditWidth",a),{width:c}=a;if(c===null){rx(i(a)),r(a);return}sx(i(a),l,yv("canvas.setEditWidth",a,"width",cp,1e4)),r(a)},title:"Set Edit Width"},{args:{additionalProperties:!1,properties:{...o,media:{description:"A breakpoint key the document renders under, or null for the base rendering.",type:["string","null"]}},required:["media"],type:"object"},category:"View",id:"canvas.setBreakpoint",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:N,run:(s,a)=>{let l=n("canvas.setBreakpoint",a),{media:c}=a;if(c!==null&&typeof c!=="string")throw RangeError('command "canvas.setBreakpoint" argument "media": expected a breakpoint key or null');let d=Object.keys(Di(l.doc.document?.$media));if(c!==null&&!d.includes(c))throw RangeError(`command "canvas.setBreakpoint" argument "media": "${c}" is not a breakpoint this `+`document defines — it defines: ${d.length>0?d.join(", "):"nothing"}`);l.session.ui.activeMedia=c,r(a)},title:"Set Breakpoint"},{args:Se({...o,scheme:Do(on,"Which color scheme the canvas renders in.")},["scheme"]),category:"View",id:"canvas.setColorScheme",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:N,run:(s,a)=>{let l=n("canvas.setColorScheme",a);l.session.ui.previewColorScheme=li("canvas.setColorScheme",a,"scheme",on),r(a)},title:"Set Color Scheme"},{args:Se({...o,locale:He("BCP 47 tag this pane renders as.")},["locale"]),category:"View",id:"i18n.switchLocale",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document in a project that declares more than one locale",when:(s)=>s.document.open&&s.project.isMultilingual,run:(s,a)=>{let l=n("i18n.switchLocale",a),c=ot("i18n.switchLocale",a,"locale"),d=ps();if(d===null||!d.locales.includes(c))throw RangeError(`command "i18n.switchLocale" argument "locale": "${c}" is not a locale this `+`project declares — it declares: ${d===null?"nothing":d.locales.join(", ")}`);l.session.ui.previewLocale=c,r(a)},title:"Set Rendering Language"},{args:Se({...o,visible:oo("True to draw the page's layout elements, false to hide them.")},["visible"]),category:"View",id:"canvas.setLayoutVisible",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:N,run:(s,a)=>{let l=n("canvas.setLayoutVisible",a);l.session.ui.showLayout=yi("canvas.setLayoutVisible",a,"visible"),r(a)},title:"Show Layout Elements"},{args:Se({...o,open:oo("True to draw the popover open, false to close it."),path:{description:"Document path of the popover. Defaults to the popover the selection is in or at.",items:{type:["string","number"]},type:"array"}},[]),category:"View",enablement:()=>Xt(),group:"3_canvas",id:"canvas.setPopoverOpen",level:"document",menus:["palette"],requires:"a popover in the open document",run:(s,a)=>{let l=n("canvas.setPopoverOpen",a),c=a??{},d=c.open===void 0?!0:yi("canvas.setPopoverOpen",a,"open");if(!d&&c.path===void 0){e.setOpenPopover(l,null);return}let f=Zt(l,c.path);if(f===null)throw RangeError('command "canvas.setPopoverOpen" argument "path": names no popover in this document — '+"a popover is an element with a `popover` attribute, and <dialog> is not one");e.setOpenPopover(l,d?f:null)},title:"Show Popover",when:N},{args:Se({...o,open:oo("True to draw the dialog open, false to close it."),path:{description:"Document path of the dialog. Defaults to the dialog the selection is in or at.",items:{type:["string","number"]},type:"array"}},[]),category:"View",enablement:()=>tn(),group:"3_canvas",id:"canvas.setDialogOpen",level:"document",menus:["palette"],requires:"a dialog in the open document",run:(s,a)=>{let l=n("canvas.setDialogOpen",a),c=a??{},d=c.open===void 0?!0:yi("canvas.setDialogOpen",a,"open");if(!d&&c.path===void 0){e.setOpenDialog(l,null);return}let f=ax(l,c.path);if(f===null)throw RangeError('command "canvas.setDialogOpen" argument "path": names no dialog in this document — '+"a dialog is a <dialog> element, and a popover is not one");e.setOpenDialog(l,d?f:null)},title:"Show Dialog",when:N},{args:{additionalProperties:!1,properties:{...o,open:{default:!0,description:"True to open the resolving-with popover, false to close it.",type:"boolean"}},required:[],type:"object"},category:"View",id:"canvas.setResolvingOpen",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:N,run:(s,a)=>{n("canvas.setResolvingOpen",a);let{open:l,pane:c}=a;e.setResolvingOpen(typeof c==="string"?c:m.activePaneId,l===void 0||yi("canvas.setResolvingOpen",a,"open"))},title:"Show Resolving Values"},{args:{additionalProperties:!1,properties:{...o,name:He("The prop's name, as the component's state declares it."),value:{description:"The test value — any JSON. Null clears it and the prop returns to its default.",type:["string","number","boolean","array","object","null"]}},required:["name"],type:"object"},category:"View",id:"canvas.setTestProp",level:"document",menus:["palette"],group:"3_canvas",requires:"an open component document",when:N,run:(s,a)=>{let l=n("canvas.setTestProp",a),c=ot("canvas.setTestProp",a,"name"),d=Object.keys(l.doc.document?.state??{});if(!d.includes(c))throw RangeError(`command "canvas.setTestProp" argument "name": "${c}" is not a prop this component `+`declares — it declares: ${d.length>0?d.join(", "):"nothing"}`);let{value:f}=a,h={...l.session.ui.previewProps};if(f===null||f===void 0)delete h[c];else h[c]=f;l.session.ui.previewProps=Object.keys(h).length>0?h:null,r(a)},title:"Set Test Value"},{args:{additionalProperties:!1,properties:{...o,name:He("The route parameter's name, without brackets."),value:He("The value to preview the route with. Empty clears it.")},required:["name","value"],type:"object"},category:"View",id:"canvas.setRouteParam",level:"document",menus:["palette"],group:"3_canvas",requires:"an open page with a dynamic route",when:N,run:(s,a)=>{let l=n("canvas.setRouteParam",a),c=ot("canvas.setRouteParam",a,"name"),d=Ll(l.documentPath);if(!d.includes(c))throw RangeError(`command "canvas.setRouteParam" argument "name": "${c}" is not a parameter of this `+`route — it has: ${d.length>0?d.join(", "):"none"}`);l.session.ui.previewParams={...l.session.ui.previewParams,[c]:ot("canvas.setRouteParam",a,"value")},r(a)},title:"Set Route Parameter"}]}function zT(e,t){e.registerAll(zo(t))}function Fb(e=Uo()){let t=Nu(e.paneId);for(let n of e.panels){let o=n.element?.querySelector('[part="panel-header"]');if(o){let r=t===null&&n.mediaName==="base"||t===null&&n.mediaName===null||t===n.mediaName;o.toggleAttribute("data-active",r)}}}var J=null;function Ko(e){if(J?.isConnected)return J;let t=e.createElement("div");return t.className="jx-drag-ghost",t.style.cssText="position:fixed;left:0;top:0;z-index:9999;pointer-events:none;display:none;padding:2px 8px;border-radius:4px;font-size:12px;line-height:1.4;white-space:nowrap;background:var(--accent,#3b82f6);color:var(--accent-fg,#fff);box-shadow:0 2px 8px rgba(0,0,0,0.25);transform:translate(8px,8px)",e.body.append(t),J=t,t}function Q1(e,t,n,o=document){let r=Ko(o);r.textContent=e,r.style.left=`${t}px`,r.style.top=`${n}px`,r.style.display="block"}function hx(e,t){if(!J||J.style.display==="none")return;J.style.left=`${e}px`,J.style.top=`${t}px`}function _d(){if(J)J.style.display="none"}var dn=function(){if(typeof window>"u")return null;var e=new Image;return e.src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",e}();function wc(e){var t=e.nativeSetDragImage;if(t&&dn)t(dn,0,0)}function pn(e,t){if(e==null)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(t.indexOf(o)!==-1)continue;n[o]=e[o]}return n}function fn(e,t){if(e==null)return{};var n,o,r=pn(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function be(e,t){var n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;return n.every(function(r){return Object.is(e[r],t[r])})}function mn(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:be,t=null;return function(n){if(t&&e(t.value,n))return t.value;return t={value:n},t.value}}var Go=["block"];function hn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,o)}return n}function gn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?hn(Object(n),!0).forEach(function(o){ga(e,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hn(Object(n)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(n,o))})}return e}function Zo(e){return{x:(e.right+e.left)/2,y:(e.bottom+e.top)/2}}function it(e){var{client:t,borderBox:n}=e,o=n.height/4;if(t.y<=n.top+o)return"reorder-above";if(t.y>=n.bottom-o)return"reorder-below";return"make-child"}function Xo(e){var{element:t,input:n,currentLevel:o,indentPerLevel:r,mode:i}=e,s={x:n.clientX,y:n.clientY},a=t.getBoundingClientRect();if(i==="standard"){var l=it({borderBox:a,client:s});return{type:l,indentPerLevel:r,currentLevel:o}}var c=Zo(a);if(i==="expanded"){var d=it({borderBox:a,client:s});return{type:d==="reorder-above"?d:"make-child",indentPerLevel:r,currentLevel:o}}var f=r*o;if(s.x<a.left+f){if(s.y<c.y)return{type:"reorder-above",indentPerLevel:r,currentLevel:o};var h=(s.x-a.left)/r,b=Math.max(Math.floor(h),0);return{type:"reparent",desiredLevel:b,indentPerLevel:r,currentLevel:o}}return{type:it({borderBox:a,client:s}),indentPerLevel:r,currentLevel:o}}function vn(e,t){if(e.type!==t.type)return!1;if(e.type==="instruction-blocked"&&t.type==="instruction-blocked")return vn(e.desired,t.desired);return be(e,t)}var er=mn(vn);function tr(e){var{desired:t,block:n}=e;if(n!==null&&n!==void 0&&n.includes(t.type)&&t.type!=="instruction-blocked"){var o={type:"instruction-blocked",desired:t};return o}return t}function jb(e,t){var n=t.block,o=fn(t,Go),r=Xo(o),i=tr({desired:r,block:n}),s=er(i);return gn(gn({},e),{},ga({},xe,s))}function Fu(e){var t;return(t=e[xe])!==null&&t!==void 0?t:null}var xe=Symbol("tree-item-instruction");function at(e){return typeof e==="object"&&e!==null&&typeof e.$ref==="string"?e.$ref:null}function we(e){if(e.source!=="npm"||!e.package)return null;return e.modulePath?`${e.package}/${e.modulePath}`:e.package}function nr(e,t){let n=we(e);if(n)return n;return e.path?{$ref:xc(t,e.path)}:null}function eC(e,t,n){let o=we(t);if(o)return e.some((i)=>typeof i==="string"&&(i===o||i===t.package));if(!t.path)return!1;let r=G(xc(n,t.path));return e.some((i)=>{let s=at(i);return s!==null&&G(s)===r})}function G(e){return e.replace(/^(?:\.\/)+/,"")}function om(e,t,n){let o=nr(t,n);if(!o)return[...e];let i=we(t)&&t.modulePath?e.filter((s)=>s!==t.package):[...e];return eC(i,t,n)?i:[...i,o]}function tC(e,t,n){let o=we(t);if(o)return e.filter((i)=>!(typeof i==="string"&&(i===o||i===t.package)));if(!t.path)return[...e];let r=G(xc(n,t.path));return e.filter((i)=>{let s=at(i);return s===null||G(s)!==r})}function WT(e,t){return e.filter((n)=>typeof n!=="string"||!(n===t||n.startsWith(`${t}/`)))}function VT(e,t){let n=G(t);return e.filter((o)=>{let r=at(o);return r===null||G(r)!==n})}async function px(e){$p(!0);try{if(e.source==="npm"){if(!customElements.get(e.tagName))return ct(e.tagName)}else{if(e.path&&!e.path.endsWith(".json"))return ct(e.tagName);let n=D?.projectRoot,o=`${location.origin}/${n?`${n}/`:""}${e.path}`;await Mm(o)}let t=document.createElement(e.tagName);for(let n of e.props||[])if(n.default!==void 0&&n.default!=="false"&&n.default!=="''"){let o=String(n.default).replaceAll(/^'|'$/g,"");t.setAttribute(n.name,o)}return t}catch(t){return console.warn("Component preview failed:",e.tagName,t),ct(e.tagName)}}function ct(e){let t=document.createElement("div");return t.style.cssText="padding:12px;border:1px dashed var(--border);border-radius:var(--radius);color:var(--fg-dim)",t.textContent=`<${e}>`,t}var or='[part="outline"]',ut='[part="row"]',rr='[part="verbs"]',Ce=null;function UT(){if(Ce!==null)cancelAnimationFrame(Ce);for(let e of Je.dndCleanups)e();Je.dndCleanups=[],Ce=requestAnimationFrame(()=>{Ce=null;let e=Qu?.querySelector(or);if(!e)return;for(let n of e.querySelectorAll("[data-dnd-row]")){let o=n.dataset.value.split("/").map((l)=>/^\d+$/.test(l)?Math.trunc(Number(l)):l),r=Math.trunc(Number(n.dataset.dndDepth))||0,i=Object.hasOwn(n.dataset,"dndVoid"),s=Object.hasOwn(n.dataset,"dndExpanded"),a=gr(gs({canDrag({element:l,input:c}){if(Rv(c.clientX,c.clientY)?.closest(rr))return!1;return!0},element:n,getInitialData(){return{path:o,type:"tree-node"}},onGenerateDragPreview({nativeSetDragImage:l}){wc({nativeSetDragImage:l})},onDragStart(){if(n.dataset.dragging="",Je.layerDragSourceHeight=n.offsetHeight,s)ir(n,e)},onDrop(){if(delete n.dataset.dragging,s)Ai("leftPanel")}}),zs({element:n,canDrop({source:l}){let c=l.data.path;if(c&&qa(c,o))return!1;return!0},getData({input:l,element:c}){return jb({path:o},{block:i?["make-child"]:[],currentLevel:r,element:c,indentPerLevel:16,input:l,mode:s?"expanded":"standard"})},onDragEnter({self:l}){yn(n,l.data,e)},onDrag({self:l}){yn(n,l.data,e)},onDrop(){oe(e)}}));Je.dndCleanups.push(a)}let t=Ws({onDrop({source:n,location:o}){oe(e);let[r]=o.current.dropTargets;if(!r)return;let i=Fu(r.data);if(!i||i.type==="instruction-blocked")return;let s=n.data,a=r.data.path,l=s.type==="tree-node"&&n.element,c=l&&Object.hasOwn(l.dataset,"dndExpanded");if(rm(u.value,i,s,a),c){let d=u.value,f=Le(d?.session.selection);if(f)Je._layersCollapsed||=new Set,Je._layersCollapsed.add(f.join("/"))}},onDropTargetChange({location:n}){let[o]=n.current.dropTargets;if(o&&!Fu(o.data))oe(e)}});Je.dndCleanups.push(t)})}function qT(){requestAnimationFrame(()=>{let e=Qu?.querySelector(".components-section");if(!e)return;for(let t of e.querySelectorAll("[data-component-tag]")){let n=t.dataset.componentTag;if(!n)continue;let o=st.find((a)=>a.tagName===n);if(!o)continue;let r=t.querySelector(".element-card-preview");if(r&&!r.querySelector(n))px(o).then((a)=>{r.textContent="",r.append(a)});let i=um(o),s=gs({element:t,getInitialData(){return{fragment:structuredClone(i),type:"block"}},onGenerateDragPreview({nativeSetDragImage:a}){wc({nativeSetDragImage:a})}});Je.dndCleanups.push(s)}})}function GT(){requestAnimationFrame(()=>{let e=Qu?.querySelector('[part="content"]');if(!e)return;for(let t of e.querySelectorAll("[data-block-tag]")){let n=t.dataset.blockTag,o=t.querySelector(".element-card-preview");if(o&&!o.firstChild){let s=document.createElement(Ht.has(n)?"span":n);s.textContent=n,o.append(s)}let r=yd(n),i=gs({element:t,getInitialData(){return{fragment:structuredClone(r),type:"block"}},onGenerateDragPreview({nativeSetDragImage:s}){wc({nativeSetDragImage:s})}});Je.dndCleanups.push(i)}})}function ir(e,t){let n=`${e.dataset.value}/`,o=t.querySelectorAll(ut);for(let r of o)if(r.dataset.value?.startsWith(n))r.style.display="none"}function yn(e,t,n){let o=Fu(t);if(Je._currentDropTargetRow&&Je._currentDropTargetRow!==e)delete Je._currentDropTargetRow.dataset.drop;if(!o||o.type==="instruction-blocked"){oe(n);return}if(o.type==="make-child"){oe(n),e.dataset.drop="",Je._currentDropTargetRow=e;return}delete e.dataset.drop,Je._currentDropTargetRow=e;let r=[...n.querySelectorAll(ut)],i=r.indexOf(e),s=Je.layerDragSourceHeight;for(let a=0;a<r.length;a++){if(r[a].dataset.dragging!==void 0)continue;if(o.type==="reorder-above")r[a].style.transform=a>=i?`translateY(${s}px)`:"";else r[a].style.transform=a>i?`translateY(${s}px)`:""}}function oe(e){if(Je._currentDropTargetRow)delete Je._currentDropTargetRow.dataset.drop,Je._currentDropTargetRow=null;let t=e.querySelectorAll(ut);for(let n of t)n.style.transform="",n.style.display=""}function rm(e,t,n,o){if(!e)return;let r=e.doc.document;if(n.type==="tree-node"){let i=n.path,s=ht(o),a=_n(o);if(t.type!=="make-child"&&(!s||typeof a!=="number"))return;switch(t.type){case"reorder-above":{q(e,(l)=>pa(l,i,s,a));break}case"reorder-below":{q(e,(l)=>pa(l,i,s,a+1));break}case"make-child":{let l=K(r,o),c=_o(l).length;q(e,(d)=>pa(d,i,o,c));break}default:break}}else if(n.type==="block"){let i=ht(o),s=_n(o);if(t.type!=="make-child"&&(!i||typeof s!=="number"))return;switch(t.type){case"reorder-above":{q(e,(c)=>Ji(c,i,s,structuredClone(n.fragment)));break}case"reorder-below":{q(e,(c)=>Ji(c,i,s+1,structuredClone(n.fragment)));break}case"make-child":{let c=K(r,o),d=_o(c).length;q(e,(f)=>Ji(f,o,d,structuredClone(n.fragment)));break}default:break}let l=n.fragment?.tagName;if(qe(l).includes("-")){let c=st.find((h)=>h.tagName===l),d=e.doc.document?.$elements??[],f=c?om(d,c,e.documentPath??null):d;if(f.length!==d.length)Hs(e,(h)=>{h.$elements=f})}}}function bn(e){let t={};for(let[n,o]of Object.entries(e?.nesting??{}))if(n!=="_root")t[n]=o?.inline===!0;for(let n of e?.inline??[])t[n]=!1;return t}var ke=new WeakMap,g=new Set,z=0,ae=new Map,An=-1,$n=0,ar=600;function nC(e){return An===e&&Date.now()-$n<=ar}var wn=0,In=new Set;function sr(e,t){let n;try{n=new URL(e,t.iframe.src||pm())}catch{return}if(!["http:","https:","mailto:","tel:"].includes(n.protocol))return;let o=n.href,r=Qw();if(r){r(o);return}window.open(o,"_blank","noopener,noreferrer")}function iC(e){In.add(e)}function lr(e){return In.delete(e)}var L=new Map,Z=new Map,se=new Map,cr=300;function oC(e,t,n,o=cr){let r=null;for(let a of g){if(!a.iframe.isConnected){g.delete(a);continue}if(a.ready&&!a.stylebook&&e!==null&&a.tabId===e){r=a;break}}if(!r)return Promise.resolve(null);wn+=1;let i=wn,s=JSON.parse(JSON.stringify(t));return r.channel.post({contextPath:n?[...n]:null,exprs:s,gen:r.lastRenderedGen,kind:"evalExpr",reqId:i}),new Promise((a)=>{let l=setTimeout(()=>{L.delete(i),Z.delete(i),a(null)},o);Z.set(i,r),L.set(i,(c)=>{clearTimeout(l),Z.delete(i),a(c)})})}var Cn=0,X=new Map,dr=250;function rC(e,t=dr){let n=[];for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(o.ready&&!o.stylebook&&e!==null&&o.tabId===e)n.push(o)}if(n.length===0)return Promise.resolve();return new Promise((o)=>{let r=n.length,i=setTimeout(()=>{for(let l of a)X.delete(l),se.delete(l);o()},t),s=()=>{if(r-=1,r===0)clearTimeout(i),o()},a=[];for(let l of n){Cn+=1;let c=Cn;a.push(c),X.set(c,s),se.set(c,l),l.channel.post({kind:"flushEdits",reqId:c})}})}function sC(e){return ke.get(e)??null}function sm(e){for(let t of g){if(!t.iframe.isConnected)continue;let n=Oe(t.iframe);if(e.x>=n.left&&e.x<=n.right&&e.y>=n.top&&e.y<=n.bottom)return t}return null}function am(e,t,n){z+=1,ae.set(z,n);let o=t.type==="tree-node"?{path:[...t.path],type:"tree-node"}:{type:t.type};return e.channel.post({dragSeq:z,gen:e.lastRenderedGen,kind:"dragStart",src:o}),z}function fx(){return z}function za(e){let t=Oe(e.iframe),n=e.iframe.clientWidth>0?t.width/e.iframe.clientWidth:1;return{rect:t,scale:n}}function Dn(e){if(e.stylebook)return"stylebook";return e.tabId??"unbound"}function aC(){let e=[];for(let t of g){if(!t.iframe.isConnected){g.delete(t);continue}let n=`canvas[${Dn(t)}]`;if(!t.ready){e.push(`${n}: frame has not handshaked`);continue}let o=[...t.pendingTabIds.keys()];if(o.length>0)e.push(`${n}: gen ${o.join(", ")} unacked`);if(t.pendingPatches>0)e.push(`${n}: ${t.pendingPatches} unacked patch(es)`);if(t.pendingMeasures.size>0)e.push(`${n}: ${t.pendingMeasures.size} measure(s) in flight`);let{idle:r}=t;if(!r){e.push(`${n}: no quiescence report yet`);continue}if(r.gen!==t.lastRenderedGen)e.push(`${n}: quiescence is for gen ${r.gen}, DOM is gen ${t.lastRenderedGen}`);if(!r.fonts)e.push(`${n}: fonts still loading`);if(r.animations>0)e.push(`${n}: ${r.animations} running animation(s)`);if(r.images>0)e.push(`${n}: ${r.images} pending image retry(ies)`)}if(L.size>0)e.push(`canvas: ${L.size} expression eval(s) in flight`);return e}var pr=500,fr=2,mr=40;function Jn(){let e=u.value?.id??null,t=null;for(let n of g){if(!n.iframe.isConnected){g.delete(n);continue}if(!n.ready||n.stylebook)continue;if(n.tabId===e)return n;t??=n}return t}function vr(e,t){let{rect:n,scale:o}=za(e),r=n.left+t.x*o,i=n.top+t.y*o,s=t.width*o,a=t.height*o;return{height:a,left:r,top:i,width:s,x:r+s/2,y:i+a/2}}function Re(e,t){return new Promise((n)=>{e.selReqId+=1;let o=e.selReqId,r=setTimeout(()=>{e.pendingMeasures.delete(o),n(null)},pr);e.pendingMeasures.set(o,(i)=>{clearTimeout(r);let[s]=i;n(s?vr(e,s.rect):null)}),e.channel.post({kind:"measure",paths:[[...t]],reqId:o})})}function lC(e){let t=Jn();return t?Re(t,e):Promise.resolve(null)}function yr(e){return new Promise((t)=>{let n=Number.NaN,o=0,r=0,i=()=>{let{top:s}=Oe(e.iframe);if(o=s===n?o+1:0,n=s,r+=1,o>=fr||r>=mr){t();return}requestAnimationFrame(i)};requestAnimationFrame(i)})}async function lm(e){let t=Jn();return t?n$(t,e):null}async function n$(e,t){let n=await Re(e,t);if(!n)return null;let o=_(e.canvasEl)?.surface;return Pb({height:n.height,top:n.top},o),await yr(e),Re(e,t)}function b$(e,t){let n=sC(e);return n?Re(n,t):Promise.resolve(null)}function br(e){let t=e.canvasEl.parentElement;if(!t)return;let n=/scale\(([\d.]+)\)/.exec(e.canvasEl.style.transform),o=n?Number(n[1]):1;t.style.height=o===1?"":`${e.iframe.offsetHeight*o}px`}function Ln(e){if(e.preview){e.iframe.style.height="100%",e.iframe.style.minHeight="0px";return}if(e.contentHeight===null)return;e.iframe.style.height=`${e.contentHeight}px`,e.iframe.style.minHeight=e.contentFragment?"0px":"480px",br(e)}function gt(e,t){if(e.preview=t,e.overlay.setSuppressed(t),t)e.pendingEnterEdit=null;Ln(e)}function cC(e,t){gt(yt(e),t)}function Rl(e,t){if(!e.iframe.isConnected)return;e.channel.post(t)}function Hb(e){ae.delete(e)}function Bb(e){e.overlay.setDropIndicator(null)}var jn=null;function dC(e){jn=e}var xr=300,qn=null;function uC(e){qn=e}var vt=null;function hC(e){vt=e}function wr(e,t,n){if((t?Cr(t.tagName):!1)&&t){e.overlay.setDropIndicator(null),e.overlay.setReplaceTarget(M(t.rect));return}e.overlay.setReplaceTarget(null),e.overlay.setDropIndicator(n?M(n.referenceRect):null,n?.edge)}function Pn(e){e.overlay.setReplaceTarget(null),e.overlay.setDropIndicator(null)}function Cr(e){return e==="img"||e==="video"||e==="source"}function Pr(e,t){if(e.dataset.jxGutterDrop==="1")return;e.dataset.jxGutterDrop="1",e.addEventListener("dragover",(n)=>{if(![...n.dataTransfer?.types??[]].includes("Files"))return;if(n.preventDefault(),n.dataTransfer)n.dataTransfer.dropEffect="copy"}),e.addEventListener("drop",(n)=>{let o=n.dataTransfer?.files,r=t();if(!o?.length||!r||r.stylebook)return;n.preventDefault(),vt?.(P(r),[...o],null,null)})}var Te=null;function pC(e){Te=e}var Me=null;function fC(e){Me=e}var Fn=null;function mC(e){Fn=e}function Sn(e,t){let n=[...t];for(;;){let o=e.get(Il(n));if(o)return o;if(n.length<2)return null;n=n.slice(0,-2)}}var S=null;function gC(){let e=S;return Boolean(e?.editing&&e.iframe.isConnected)}var Ne=null;function bC(e){Ne=e}var mt=null;function vC(e){mt=e}var En=null,Wn=null;function yC(e){Wn=e}function wC(e,t){for(let n of g){if(!n.iframe.isConnected){g.delete(n);continue}if(n.ready&&n.tabId===e.id&&!n.preview)n.popoverOpen=t,n.channel.post({kind:"setPopoverOpen",path:t})}}function xC(e,t){for(let n of g){if(!n.iframe.isConnected){g.delete(n);continue}if(n.ready&&n.tabId===e.id&&!n.preview)n.dialogOpen=t,n.channel.post({kind:"setDialogOpen",path:t})}}function mx(e,t){let n=0;for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(o.ready&&o.tabId===t){let r=_(o.canvasEl)?.surface;if(!r){Ab("host-stage-unresolved");continue}let i=r.renderGeneration,s=Ae?.host===o?Ae.paths:void 0;$e(o),o.channel.post(s?{echoPaths:s,forwardOps:e,gen:i,kind:"patch"}:{forwardOps:e,gen:i,kind:"patch"}),o.pendingPatches+=1,n+=1}}return n}var Ae=null,Sr=0;function Tn(e,t,n){Ae={host:e,paths:t};try{n()}finally{Ae=null}}var dt=null,pt=null;function Er(e,t,n){return!e&&t===n}function Tr(e,t){let n=P(e);if(!n)return;let o=K(n.doc.document,t);if(!o)return;mx([{key:"$props",op:"set-key",path:t,value:o.$props}],n.id)}function P(e){return e.tabId?m.tabs.get(e.tabId)??null:null}function _C(e){return P(e)}function Pe(e){let t=_(e.canvasEl)?.surface.paneId;if(t)$r(t)}var Mr=Object.freeze([]);function Nr(){let e=new Map;for(let t of m.panes){let n=t.activeTabId?m.tabs.get(t.activeTabId):null;if(!n)continue;let o=n.session.selection??[];o.map((r)=>r.join("/")).join("|"),e.set(n.id,o)}return e}function kr(){if(En)return;let e=ge(!0);e.run(()=>{Q(()=>{let t=Nr();y.stylebook.selection;for(let n of g)Ie(n,(n.tabId?t.get(n.tabId):null)??Mr)})}),En={stop:()=>e.stop()}}function $e(e){if(!e.ready)return;let t=Rd();if(t===e.postedVersions)return;if(e.postedVersions===null&&Object.keys(t).length===0){e.postedVersions=t;return}e.postedVersions=t,e.channel.post({kind:"assetVersions",versions:t})}var Mn=!1,ft=!1;function Rr(){if(Mn)return;Mn=!0,ge(!0).run(()=>{Q(()=>{if(jC.value,ft)return;ft=!0,queueMicrotask(()=>{ft=!1,Or()})})})}function Or(){for(let e of g){if(!e.iframe.isConnected){g.delete(e);continue}$e(e)}}var Nn=!1,Ee=null;function Ar(){if(Nn)return;Nn=!0,ge(!0).run(()=>{Q(()=>{for(let t of m.panes){let n=t.activeTabId?m.tabs.get(t.activeTabId):null;if(!n)continue;let{peers:o}=xn(n);o.map((r)=>JSON.stringify(r.state.structuralSelection??null)).join("|")}if(Ee)clearTimeout(Ee);Ee=setTimeout(()=>{Ee=null;for(let t of g)Vn(t)},100)})})}function Vn(e){if(e.stylebook||!e.ready||!e.iframe.isConnected)return;let t=P(e),n=t?xn(t).peers:[];e.presenceMeta.clear();let o=[];for(let r of n){let{structuralSelection:i}=r.state;if(!i||r.state.focusedPath!==t?.documentPath)continue;for(let s of i){let a=[...s];o.push(a),e.presenceMeta.set(JSON.stringify(a),{color:r.state.user.color,label:r.state.user.name??r.state.user.login})}}if(o.length===0){e.presenceReqId=-1,e.overlay.setPresence([]);return}e.selReqId+=1,e.presenceReqId=e.selReqId,e.channel.post({kind:"measure",paths:o,reqId:e.presenceReqId})}function Ie(e,t){if(e.stylebook){Ir(e);return}let n=Le(t);if(e.selectionPath=n,e.selectionPaths=t,!e.iframe.isConnected){g.delete(e);return}if(!n){e.coSelectionKeys.clear(),e.overlay.setSelection(null),e.overlay.setCoSelection([]);return}if(!e.ready)return;let o=ms(t.slice(0,-1));e.coSelectionKeys=new Set(o.map((r)=>JSON.stringify(r))),e.selReqId+=1,e.channel.post({kind:"measure",paths:[[...n],...o],reqId:e.selReqId})}function Ir(e){if(!e.iframe.isConnected){g.delete(e);return}let t=y.stylebook.selection,n=t?e.stylebook?.tagToCardPath.get(t):void 0;if(!t||!n){e.overlay.setSelection(null);return}if(!e.ready)return;e.selReqId+=1,e.channel.post({kind:"measure",paths:[[...n]],reqId:e.selReqId})}function kn(){return zv("../canvas.html")}var Dr="about:blank";function Bn(e){e.channel.dispose();for(let[t,n]of L)if(Z.get(t)===e)L.delete(t),Z.delete(t),n(null);for(let[t,n]of X)if(se.get(t)===e)X.delete(t),se.delete(t),n();for(let[,t]of e.pendingMeasures)t([]);if(e.pendingMeasures.clear(),e.pendingTabIds.clear(),le(e),S===e)S=null;e.overlay.root.remove(),e.iframe.remove(),ke.delete(e.canvasEl),g.delete(e)}function Hr(){if(!We())return kn();let e=p();if(e.canvasUrl)return e.canvasUrl;return e.canvasUrlDeferred?Dr:kn()}function cm(e){let t=0;for(let n of new Set(g))if(e.contains(n.canvasEl))Bn(n),t+=1;return t}function yt(e){let t=Hr(),n=ke.get(e);if(n){if(n.canvasUrl===t)return n;Bn(n)}let o=location.origin,r=crypto.randomUUID(),i=new URL(t,location.href).origin,s=document.createElement("iframe");s.className="jx-canvas-iframe",s.title="Canvas — live page render",s.style.cssText="width:100%;min-height:480px;height:100%;border:0;display:block;background:#fff";let a=new URL(t,location.href);if(a.searchParams.set("token",r),location.protocol==="http:"||location.protocol==="https:")a.searchParams.set("parentOrigin",o);if(s.src=i===o?`${a.pathname}${a.search}`:a.href,!e.style.position)e.style.position="relative";let l=zt(document);e.replaceChildren(s,l.root),Pr(e,()=>sC(e));let c=xt({acceptOrigin:i,source:window,target:{postMessage:(f,h)=>s.contentWindow?.postMessage(f,h)},targetOrigin:i,token:r}),d={canvasEl:e,canvasUrl:t,channel:c,contentFragment:!1,contentHeight:null,hiddenPaths:new Set,popoverOpen:null,dialogOpen:null,editing:!1,editingProp:null,iframe:s,insertHideTimer:null,insertHover:!1,coSelectionKeys:new Set,insertZone:null,lastRenderedGen:-1,lastSelectionRect:null,lastSnapshotSeq:0,overlay:l,panReqId:-1,pending:null,postedVersions:null,idle:null,pendingEnterEdit:null,pendingMeasures:new Map,pendingPatches:0,pendingTabIds:new Map,presenceMeta:new Map,presenceReqId:-1,preview:!1,ready:!1,selectionPath:null,selectionPaths:[],selReqId:0,snapshot:null,stylebook:null,tabId:null};return l.insertButton.addEventListener("click",(f)=>jr(d,f)),l.insertButton.addEventListener("mouseenter",()=>{d.insertHover=!0,le(d)}),l.insertButton.addEventListener("mouseleave",()=>{d.insertHover=!1,Kn(d)}),c.onMessage((f)=>Fr(d,f)),ke.set(e,d),g.add(d),kr(),Ar(),Rr(),d}function Lr(e,t){le(e),e.insertZone=t,e.overlay.setInsertZone(M(t.rect),t.edge)}function zn(e){le(e),e.insertZone=null,e.insertHover=!1,e.overlay.setInsertZone(null)}function _r(e){let t=e.overlay.insertButton;return e.insertHover||typeof t.matches==="function"&&t.matches(":hover")}function Kn(e){le(e),e.insertHideTimer=setTimeout(()=>{if(e.insertHideTimer=null,_r(e))return;zn(e)},xr)}function le(e){if(e.insertHideTimer!==null)clearTimeout(e.insertHideTimer),e.insertHideTimer=null}function jr(e,t){t.stopPropagation(),t.preventDefault();let n=e.insertZone;if(!n)return;qn?.(e.overlay.insertButton,n)}var qr=new Set(["contextMenu","dragOver","dropResult","editCommit","editCommitProp","editInsert","editMerge","editRangeReplace","editSplit","editStart","fileDragOver","fileDrop","hit","hover","insertZones","layoutHit","nativeDragEnter"]);function Fr(e,t){if(e.preview&&qr.has(t.kind))return;switch(t.kind){case"ready":{e.ready=!0;let n=bt?.();if(n)e.channel.post({chords:n.chords,kind:"keymap",mac:n.mac});if(e.postedVersions=null,$e(e),e.pending)e.channel.post(e.pending),e.pending=null;Ie(e,e.selectionPaths);return}case"paneFocus":{Pe(e),mt?.();return}case"popoverTargetClick":{let n=P(e);if(!n||e.preview)return;let o=JSON.stringify(n.session.ui.openPopover)===JSON.stringify(t.targetPath),r=t.action==="show"||t.action==="toggle"&&!o;if(r||o)ne()?.run("canvas.setPopoverOpen",{open:r,path:t.targetPath});return}case"commandTargetClick":{let n=P(e);if(!n||e.preview)return;let o=(i)=>JSON.stringify(i)===JSON.stringify(t.targetPath),r=K(n.doc.document,t.targetPath);if(!r||typeof r!=="object")return;if(Ze.has(t.command)){if(!Gs(r))return;let i=t.command==="show-popover"||t.command==="toggle-popover"&&!o(n.session.ui.openPopover);if(i||o(n.session.ui.openPopover))ne()?.run("canvas.setPopoverOpen",{open:i,path:t.targetPath})}else if(Ge.has(t.command)){if(!H(r))return;let i=t.command==="show-modal";if(i||o(n.session.ui.openDialog))ne()?.run("canvas.setDialogOpen",{open:i,path:t.targetPath})}return}case"hit":{Pe(e),mt?.(),OC(null);let n=null,o=_(e.canvasEl)?.panel;if(o?.mediaName&&!o.mediaName.startsWith("git-diff")){n=me(o.mediaName);let i=P(e);if(i)i.session.ui.activeMedia=n}if(Me?.dismiss(),e.stylebook){let i=Sn(e.stylebook.pathToTag,t.hit.path);if(Fn?.(i,n),i){let s=M(t.hit.rect);e.overlay.setSelection(s,`<${i}>`),e.lastSelectionRect=s}else e.overlay.setSelection(null);return}e.selectionPath=t.hit.path,e.selectionPaths=[t.hit.path];let r=P(e);if(r)r.session.selection=t.additive?uv(r.session.selection,t.hit.path):[t.hit.path];{let i=M(t.hit.rect);e.overlay.setSelection(i),e.lastSelectionRect=i}return}case"layoutHit":{if(e.stylebook)return;Pe(e),Me?.dismiss(),OC(t.hit),e.selectionPath=null,e.selectionPaths=[];let n=P(e);if(n)n.session.selection=[];let o=M(t.hit.rect);e.overlay.setSelection(o,`LAYOUT · ${t.hit.layoutFile}`),e.lastSelectionRect=o,Ai("rightPanel");return}case"hover":{if(e.stylebook){let n=t.hit?Sn(e.stylebook.pathToTag,t.hit.path):null,o=y.stylebook.selection;if(t.hit&&n&&n!==o)e.overlay.setHover(M(t.hit.rect));else e.overlay.setHover(null);return}zr(e,t.hit);return}case"insertZones":{if(e.stylebook)return;let n=t.zones?.[0]??null;if(n)Lr(e,n);else Kn(e);return}case"geometry":{let n=e.pendingMeasures.get(t.reqId);if(n){e.pendingMeasures.delete(t.reqId),n(t.hits);return}if(t.reqId===e.presenceReqId){e.presenceReqId=-1;let o=[];for(let r of t.hits){let i=e.presenceMeta.get(JSON.stringify(r.path));if(i)o.push({...i,placement:M(r.rect)})}e.overlay.setPresence(o);return}if(t.reqId===e.panReqId){e.panReqId=-1;let[o]=t.hits;if(o){let{rect:r,scale:i}=za(e);Pb({height:o.rect.height*i,top:o.rect.y*i+r.top})}return}if(t.reqId===e.selReqId){let o=JSON.stringify(e.selectionPath),r=[],i=null;if(e.stylebook){let[a]=t.hits;i=a?M(a.rect):null}else for(let a of t.hits){let l=JSON.stringify(a.path);if(l===o)i=M(a.rect);else if(e.coSelectionKeys.has(l))r.push(M(a.rect))}let s=e.stylebook?y.stylebook.selection:null;e.overlay.setSelection(i,s?`<${s}>`:null),e.overlay.setCoSelection(r),e.lastSelectionRect=i,e.hiddenPaths=new Set((t.hidden??[]).map((a)=>JSON.stringify(a)))}return}case"evalResult":{let n=L.get(t.reqId);if(!n)return;L.delete(t.reqId),Z.delete(t.reqId),n(t.gen===e.lastRenderedGen?t.results:null);return}case"renderComplete":{if(e.pendingTabIds.has(t.gen))e.tabId=e.pendingTabIds.get(t.gen)??null;for(let n of e.pendingTabIds.keys())if(n<=t.gen)e.pendingTabIds.delete(n);Rn(e,t.gen);return}case"patchComplete":{e.pendingPatches=Math.max(0,e.pendingPatches-1),Rn(e,t.gen);return}case"idle":{e.idle={animations:t.animations,fonts:t.fonts,gen:t.gen,images:t.images};return}case"renderError":{e.pendingTabIds.delete(t.gen);let n=P(e);if(n)n.session.canvas.refreshing=!1,Ai("leftPanel");k.error("The page could not be rendered.",{detail:t.message,key:`canvas.render:${Dn(e)}`,source:"Canvas"});return}case"dataScope":{if(t.gen!==e.lastRenderedGen)return;let n=P(e);if(n)n.session.canvas.scope=t.scope,n.session.canvas.refreshing=!1;Ai("leftPanel");return}case"contentHeight":{e.contentHeight=t.height,e.contentFragment=t.fragment,Ln(e);return}case"dragOver":{if(t.dragSeq!==z)return;if(t.cursor)An=t.dragSeq,$n=Date.now();if(t.gen!==e.lastRenderedGen)return;if(t.preview)e.overlay.setDropIndicator(M(t.preview.referenceRect),t.preview.edge);else e.overlay.setDropIndicator(null);if(t.cursor){let n=za(e);hx(t.cursor.x*n.scale+n.rect.left,t.cursor.y*n.scale+n.rect.top)}return}case"nativeDragEnter":{if(e.stylebook)return;jn?.(e);return}case"dragEnd":{e.overlay.setDropIndicator(null),_d(),ae.delete(t.dragSeq);return}case"dropResult":{if(t.dragSeq!==z||t.gen!==e.lastRenderedGen)return;if(t.instruction&&t.targetPath){let n=ae.get(t.dragSeq);if(n)rm(P(e),{type:t.instruction},n,t.targetPath)}ae.delete(t.dragSeq),e.overlay.setDropIndicator(null),_d();return}case"fileDragOver":{if(e.stylebook)return;wr(e,t.hit,t.preview);return}case"fileDragLeave":{Pn(e);return}case"fileDrop":{if(Pn(e),e.stylebook)return;vt?.(P(e),t.files,t.hit,t.preview);return}case"patchError":{e.pendingPatches=Math.max(0,e.pendingPatches-1);let n=_(e.canvasEl)?.surface;if(n)Wn?.(n.paneId);return}case"forwardKey":{Br(t.event);return}case"forwardWheel":{Vr(e,t);return}case"editStart":{if(S&&S!==e)S.editing=!1,S.editingProp=null,S.snapshot=null;if(S=e,t.prop!==void 0&&pt===Il(t.path))ie(e,t.path,void 0,t.prop);pt=null,Sr+=1,e.editing=!0,e.editingProp=t.prop??null,e.snapshot=null,e.lastSnapshotSeq=0,Ne?.();return}case"selectionChanged":{if(t.seq<=e.lastSnapshotSeq)return;if(e.lastSnapshotSeq=t.seq,e.snapshot=t,!e.editing)e.editing=!0,S=e;Ne?.();return}case"flushComplete":{let n=X.get(t.reqId);if(n)X.delete(t.reqId),se.delete(t.reqId),n();return}case"editCommit":{let n=()=>_t(P(e),t.path,t.children,t.textContent);if(t.inPlace)Tn(e,[t.path],n);else n();return}case"editCommitProp":{let n=()=>jt(P(e),t.path,t.prop,t.value);if(t.inPlace){Tn(e,[t.path],n),dt=Il(t.path);return}let o=n();if(Er(o,dt,Il(t.path)))Tr(e,t.path);dt=null,pt=o?Il(t.path):null;return}case"editMerge":{let n=qt(P(e),t.fromPath,t.intoPath);if(n)ie(e,n.path,n.offset);return}case"editRangeReplace":{let n=Bt(P(e),t.from,t.to,t.between,t.text);if(n)ie(e,n.path,n.offset);return}case"editSplit":{ie(e,Wt(P(e),t.path,t.before,t.after));return}case"editInsert":{ie(e,Vt(P(e),t.path,t.cmd,t.commitData));return}case"slashShow":{let{rect:n,scale:o}=za(e),r=t.rect.x*o+n.left,i=t.rect.y*o+n.top;Te?.show({filter:t.filter,...t.showFilter===!0?{showFilter:!0}:{},onDismiss:()=>e.channel.post({kind:"slashDismissed"}),onSelect:(s)=>e.channel.post({cmd:{...s},kind:"slashSelect"}),rect:{bottom:i+t.rect.height*o,height:t.rect.height*o,left:r,top:i,width:t.rect.width*o}});return}case"slashNav":{Te?.nav(t.key);return}case"slashDismiss":{Te?.dismiss();return}case"previewNavigate":{sr(t.href,e);return}case"contextMenu":{if(e.stylebook)return;Pe(e);let{rect:n,scale:o}=za(e);Me?.show({clientX:t.x*o+n.left,clientY:t.y*o+n.top,path:t.path?[...t.path]:null});return}case"editEnd":{if(!e.editing)return;if(e.editing=!1,e.editingProp=null,e.snapshot=null,S===e)S=null;Ne?.();break}default:break}}function Rn(e,t){if(e.lastRenderedGen=t,Ie(e,e.selectionPaths),Vn(e),zn(e),e.pendingEnterEdit&&t>=e.pendingEnterEdit.minGen){let{offset:n,path:o,prop:r}=e.pendingEnterEdit;if(e.pendingEnterEdit=null,e.tabId!==null&&e.tabId===im(e.canvasEl)?.id)Wr(e,o,n,r)}}function ie(e,t,n,o){e.pendingEnterEdit={minGen:e.lastRenderedGen,path:[...t],...n===void 0?{}:{offset:n},...o===void 0?{}:{prop:o}}}function Wr(e,t,n,o){e.channel.post({kind:"enterEdit",path:[...t],...n===void 0?{}:{offset:n},...o===void 0?{}:{prop:o}})}function Vr(e,t){let{rect:n,scale:o}=za(e),r=jl(e.canvasEl)?.wrap;if(!r)return;r.dispatchEvent(new WheelEvent("wheel",{bubbles:!0,cancelable:!0,clientX:n.left+t.x*o,clientY:n.top+t.y*o,ctrlKey:t.ctrlKey,deltaX:t.deltaX,deltaY:t.deltaY,metaKey:t.metaKey,shiftKey:t.shiftKey}))}function Br(e){document.dispatchEvent(new KeyboardEvent("keydown",{altKey:e.altKey,bubbles:!0,cancelable:!0,code:e.code,ctrlKey:e.ctrlKey,key:e.key,metaKey:e.metaKey,shiftKey:e.shiftKey}))}function zr(e,t){if(!t||Yo(t.path,e.selectionPath)){e.overlay.setHover(null);return}e.overlay.setHover(M(t.rect))}var Ur=4,B=new Map;function Gr(e){let t=B.get(e);if(t)return B.delete(e),B.set(e,t),t;let n=new Map;B.set(e,n);for(let o of B.keys()){if(B.size<=Ur)break;B.delete(o)}return n}function Zr(e,t,n,o,r,i=null){let s=Gr(e),a=o?.id??null,l=s.get(t);if(l&&l.tabId===n&&l.viewTabId===a&&l.mode===i)return l.payload;let c=lr(r),d=nx(At,async()=>{xo.renderPreparations+=1;let f=await kt(t,o,i),h=JSON.parse(JSON.stringify(f.renderDoc)),b=JSON.parse(JSON.stringify(t)),T=n?m.tabs.get(n)??null:null,R=wi(T?.doc.sourceFormat)?.studio?.elements,O=R?bn(R):void 0;return{assets:f.assets,doc:h,docBase:f.docBase??`${pm()}/`,mapperCtx:f.mapperCtx,mode:f.mapperCtx.canvasMode,shadowDoc:b,siteStyle:f.siteStyle,...O?{editableTags:O}:{},...c?{allowAutoRequests:!0}:{}}});return s.set(t,{mode:i,payload:d,tabId:n,viewTabId:a}),d}async function CC(e,t,n,o,r=null,i=im(n),s=null,a=null){let l=yt(n);l.pendingTabIds.set(e,r),l.stylebook=null,l.iframe.style.width=o?`${o}px`:"100%";let d={...await Zr(e,t,r,i,$b(n),s),colorScheme:Gn(i),...a?{diffMarks:a}:{},gen:e,kind:"render",popoverOpen:i?.session.ui.openPopover??null,dialogOpen:i?.session.ui.openDialog??null};l.popoverOpen=d.popoverOpen??null,l.dialogOpen=d.dialogOpen??null,gt(l,d.mode==="preview"),Un(l,d)}function Un(e,t){if(xo.hostRenderPosts+=1,e.ready)$e(e),e.channel.post(t);else e.pending=t}function kC(e,t,n,o){let r=yt(n);r.pendingTabIds.set(e,null),r.stylebook={pathToTag:t.pathToTag,tagToCardPath:t.tagToCardPath},gt(r,!1),r.pendingEnterEdit=null,r.iframe.style.width=o?`${o}px`:"100%";let i=JSON.parse(JSON.stringify(t.doc)),s=JSON.parse(JSON.stringify(t.doc)),a={assets:null,colorScheme:Gn(im(n)),doc:i,docBase:`${pm()}/`,gen:e,kind:"render",mapperCtx:{arrayPaths:[],canvasMode:"stylebook",layoutWrapped:!1,pageContentOffset:null,pageContentPrefix:null},mode:"stylebook",shadowDoc:s,siteStyle:null};Un(r,a)}function Gn(e){let t=e?.session.ui.previewColorScheme;return t==="light"||t==="dark"?t:null}function SC(e,t){for(let n of g){if(!n.iframe.isConnected){g.delete(n);continue}if(t&&!t.contains(n.iframe))continue;if(n.ready)n.channel.post({kind:"setColorScheme",scheme:e})}}function EC(e,t){let n=gL(e);for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(t&&!t.contains(o.iframe))continue;if(o.ready)o.channel.post({dir:n,kind:"setLocale",locale:e})}}function TC(e,t){let n=JSON.parse(JSON.stringify(e)),o=0;for(let r of g){if(!r.iframe.isConnected){g.delete(r);continue}if(r.ready)r.channel.post({base:t,doc:n,kind:"redefineElement"}),o+=1}return o}function LC(){let e=D?.projectConfig;if(!e)return;let t=JSON.parse(JSON.stringify(e.style??null)),n=JSON.parse(JSON.stringify(e.$media??{}));for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(o.ready&&!o.stylebook)o.channel.post({kind:"siteStyleUpdate",media:n,siteStyle:t})}}function zb(e){let t=0,n=JSON.parse(JSON.stringify(e));for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(o.ready&&o.stylebook)o.channel.post({gen:o.lastRenderedGen,kind:"styleUpdate",style:n}),t+=1,Ie(o,o.selectionPaths)}return t}function IC(e){let t=Zn();if(!t?.stylebook||!t.ready)return;let n=t.stylebook.tagToCardPath.get(e);if(!n)return;t.selReqId+=1,t.panReqId=t.selReqId,t.channel.post({kind:"measure",paths:[[...n]],reqId:t.selReqId})}function Wa(){let e=S;if(!e||!e.iframe.isConnected)return{editing:!1,editingProp:null,snapshot:null};return{editing:e.editing,editingProp:e.editingProp,snapshot:e.snapshot}}var bt=null;function RC(e,t){bt=e,t?.(()=>On()),On()}function On(){let e=bt?.();if(!e)return;for(let t of g){if(!t.iframe.isConnected){g.delete(t);continue}if(t.ready)t.channel.post({chords:e.chords,kind:"keymap",mac:e.mac})}}function Cd(e){let t=S;if(!t||!t.ready)return;t.channel.post({intent:e,kind:"applyFormat"})}function $C(){let e=S;if(!e||!e.ready)return;e.channel.post({kind:"openSlash"})}function Wb(){let e=S;if(e?.editing&&e.ready&&e.iframe.isConnected)e.channel.post({kind:"endEdit"})}function Zn(){let e=Ut();return e?sC(e.canvas):null}function gx(){let e=S,t=e??Zn();if(!t)return null;let{rect:n,scale:o}=za(t),r=t===e?t.snapshot?.rect:null;if(r)return{height:r.height*o,left:r.x*o+n.left,top:r.y*o+n.top,width:r.width*o};if(t.lastSelectionRect)return{height:t.lastSelectionRect.height*o,left:t.lastSelectionRect.left*o+n.left,top:t.lastSelectionRect.top*o+n.top,width:t.lastSelectionRect.width*o};return null}
|
|
2
2
|
export{Uo,lt,ur,Xw,Tl,wo,Nu,$b,im,vT,Qw,Db,Ll,yT,wT,xT,ex,_T,CT,kT,ST,xo,Ab,tx,nx,bi,yd,ET,Il,wd,TT,ix,LT,Nb,IT,Ob,Ou,hr,RT,cp,$T,DT,ox,AT,rx,NT,sx,G1,K1,ax,lx,Mu,OT,MT,Mb,us,xd,Pu,PT,FT,cx,J1,jT,dx,ux,HT,Pb,BT,Y1,Z1,X1,zT,Fb,Q1,hx,_d,wc,jb,Fu,eC,om,tC,WT,VT,px,UT,qT,GT,rm,nC,iC,oC,rC,sC,sm,am,fx,za,aC,lC,lm,n$,b$,cC,Rl,Hb,Bb,dC,uC,hC,pC,fC,mC,gC,bC,vC,yC,wC,xC,mx,_C,cm,CC,kC,SC,EC,TC,LC,zb,IC,Wa,RC,Cd,$C,Wb,gx};
|
|
3
3
|
|
|
4
4
|
//# debugId=8587CC83433C749E64756E2164756E21
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
5
|
+
//# sourceMappingURL=studio-5gs9th4b.js.map
|