@jxsuite/studio 5.7.0 → 6.1.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/{2020-cs2sb9t1.js → 2020-nkxms0ay.js} +3 -3
- package/dist/chunks/adapter-m948ab5f.js +4 -0
- package/dist/chunks/{cf-account-picker-882a7ecm.js → cf-account-picker-n8hr38v7.js} +3 -3
- package/dist/chunks/cf-settings-356xdtne.js +4 -0
- package/dist/chunks/components-yk3t844e.js +4 -0
- package/dist/chunks/content-source-bawmyc09.js +4 -0
- package/dist/chunks/{convert-to-repeater-grfep2w8.js → convert-to-repeater-7wns8kf1.js} +3 -3
- package/dist/chunks/editor-6sc8nacq.js +4 -0
- package/dist/chunks/entry-commands-8ay9fh81.js +4 -0
- package/dist/chunks/{extension-sections-dp8endhx.js → extension-sections-na7rj3nr.js} +3 -3
- package/dist/chunks/file-ops-gye0qw56.js +4 -0
- package/dist/chunks/files-dmc2xvcq.js +4 -0
- package/dist/chunks/format-host-t76b53f8.js +4 -0
- package/dist/chunks/fs-events-cg4tpz06.js +4 -0
- package/dist/chunks/git-panel-yef7bshy.js +4 -0
- package/dist/chunks/{grid-view-5amhg604.js → grid-view-7tt4bxw1.js} +6 -6
- package/dist/chunks/iframe-host-tmz30gfp.js +4 -0
- package/dist/chunks/{index-9ydfe04y.js → index-gybvv7a6.js} +3 -3
- package/dist/chunks/index-nag78a9h.js +4 -0
- package/dist/chunks/{javascript-d9pqgc2p.js → javascript-rnvdp3k4.js} +2 -2
- package/dist/chunks/{jsonMode-800yvbem.js → jsonMode-zhwsprqk.js} +5 -5
- package/dist/chunks/jx-validate-3gbp5nkn.js +4 -0
- package/dist/chunks/layers-fvz99859.js +4 -0
- package/dist/chunks/layers-panel-gchmbf9p.js +4 -0
- package/dist/chunks/lit-html-9agdspkt.js +4 -0
- package/dist/chunks/media-picker-rhjvyy00.js +4 -0
- package/dist/chunks/menu-2e4y9j7b.js +4 -0
- package/dist/chunks/{monaco-binding-62dtmgbf.js → monaco-binding-2jnhjjvr.js} +3 -3
- package/dist/chunks/monaco-buffer-rp21359g.js +4 -0
- package/dist/chunks/{monaco-setup-tj13ndtm.js → monaco-setup-vhh7gayr.js} +3 -3
- package/dist/chunks/notify-h3www560.js +4 -0
- package/dist/chunks/platform-hz34wcd7.js +4 -0
- package/dist/chunks/publish-panel-exsmjzyj.js +4 -0
- package/dist/chunks/quick-search-pgaqeh0m.js +4 -0
- package/dist/chunks/references-2cgdxnb8.js +4 -0
- package/dist/chunks/right-panel-jf856w5w.js +4 -0
- package/dist/chunks/section-registry-jnf8r5gy.js +4 -0
- package/dist/chunks/studio-0f55h9ye.js +5 -0
- package/dist/chunks/{studio-hjbg8d5y.js → studio-0sqdhnew.js} +7 -7
- package/dist/chunks/{studio-1wvfxkyy.js → studio-0x3jyb8r.js} +4 -4
- package/dist/chunks/{studio-yr04mv2j.js → studio-19x1c75w.js} +4 -4
- package/dist/chunks/{studio-evwgp1ym.js → studio-2sqcndak.js} +4 -4
- package/dist/chunks/{studio-cvbkkfqb.js → studio-3aey7dd3.js} +4 -4
- package/dist/chunks/{studio-888knnkc.js → studio-3bpdkq2s.js} +4 -4
- package/dist/chunks/{studio-ceb34dxj.js → studio-47y6fbpf.js} +4 -4
- package/dist/chunks/{studio-c6w3tq7t.js → studio-4m3826v2.js} +4 -4
- package/dist/chunks/studio-4nx2dj1g.js +4 -0
- package/dist/chunks/{studio-p7c1agz0.js → studio-4xv5s47r.js} +5 -5
- package/dist/chunks/{studio-sxc0zvpt.js → studio-5g0ag7c0.js} +3 -3
- package/dist/chunks/{studio-semd1s8s.js → studio-5g4t8v6w.js} +4 -4
- package/dist/chunks/studio-5py436sf.js +5 -0
- package/dist/chunks/{studio-aje966s9.js → studio-77kt594t.js} +4 -4
- package/dist/chunks/{studio-56z7evx4.js → studio-8f87n763.js} +6 -6
- package/dist/chunks/studio-8mb00b84.js +5 -0
- package/dist/chunks/studio-8p51gq2h.js +6 -0
- package/dist/chunks/studio-954ds834.js +5 -0
- package/dist/chunks/{studio-xta2vxp6.js → studio-9ft45c83.js} +6 -6
- package/dist/chunks/studio-a2138x5k.js +7 -0
- package/dist/chunks/studio-a9yzstqj.js +5 -0
- package/dist/chunks/{studio-gp02nqnw.js → studio-acdksxx6.js} +4 -4
- package/dist/chunks/{studio-edbtvcd1.js → studio-anyrgzvb.js} +4 -4
- package/dist/chunks/{studio-dkn3x3hz.js → studio-ar8jcf2y.js} +4 -4
- package/dist/chunks/{studio-xry7tk3z.js → studio-bmn4mn9j.js} +5 -5
- package/dist/chunks/{studio-03wwfvyt.js → studio-cpxkgjrj.js} +4 -4
- package/dist/chunks/{studio-spf2skgc.js → studio-e7xxa0sj.js} +4 -4
- package/dist/chunks/{studio-01qza1n3.js → studio-ecaz25vk.js} +4 -4
- package/dist/chunks/{studio-5e9zsamh.js → studio-fzdywr6p.js} +6 -6
- package/dist/chunks/{studio-65fhspdd.js → studio-g5fmf0c1.js} +4 -4
- package/dist/chunks/studio-g7nse7zb.js +5 -0
- package/dist/chunks/studio-geq1ea6k.js +14 -0
- package/dist/chunks/{studio-n78gjfy8.js → studio-ghkb32r8.js} +4 -4
- package/dist/chunks/{studio-222rqyyc.js → studio-ghrhy2y7.js} +4 -4
- package/dist/chunks/{studio-a7xqhc3n.js → studio-grawhey1.js} +4 -4
- package/dist/chunks/{studio-eh0rac07.js → studio-h0xgswew.js} +4 -4
- package/dist/chunks/{studio-wma2c6g8.js → studio-h9c4p2tx.js} +4 -4
- package/dist/chunks/studio-jyzj5cxs.js +5 -0
- package/dist/chunks/{studio-x92tgnee.js → studio-mgx8yhnz.js} +31 -31
- package/dist/chunks/{studio-0scebvb9.js → studio-mpb04y1d.js} +5 -5
- package/dist/chunks/{studio-xy3tv3az.js → studio-n17mty64.js} +4 -4
- package/dist/chunks/{studio-gfn1kpxj.js → studio-nwh2eqsk.js} +5 -5
- package/dist/chunks/{studio-nt06yybj.js → studio-pxg4ap1e.js} +3 -3
- package/dist/chunks/{studio-zpnk016a.js → studio-q1h883bt.js} +5 -5
- package/dist/chunks/{studio-c6zdm25z.js → studio-q4tv82h7.js} +6 -6
- package/dist/chunks/{studio-st75kn99.js → studio-qbj760tx.js} +5 -5
- package/dist/chunks/{studio-y7jehjrp.js → studio-qpqa7vk3.js} +4 -4
- package/dist/chunks/{studio-j6gnhvaa.js → studio-qqz8e5gk.js} +4 -4
- package/dist/chunks/{studio-skzanb0k.js → studio-qvasen3f.js} +4 -4
- package/dist/chunks/studio-rggdb3hm.js +5 -0
- package/dist/chunks/{studio-4xppwncr.js → studio-sghy936h.js} +3 -3
- package/dist/chunks/{studio-9mqfamps.js → studio-skprc6ef.js} +4 -4
- package/dist/chunks/{studio-1x8x26k3.js → studio-tt2nactf.js} +4 -4
- package/dist/chunks/{studio-54g077x3.js → studio-txjjzrsm.js} +5 -5
- package/dist/chunks/{studio-f195h2hq.js → studio-tyasmc39.js} +4 -4
- package/dist/chunks/{studio-0bbxhhce.js → studio-v2bvmbjj.js} +4 -4
- package/dist/chunks/{studio-pwqfmt4p.js → studio-vk9ezads.js} +4 -4
- package/dist/chunks/{studio-fqq890ap.js → studio-vzacdfsc.js} +3 -3
- package/dist/chunks/{studio-zd4kayn2.js → studio-w4c0xmrw.js} +4 -4
- package/dist/chunks/{studio-tw7rre6s.js → studio-wfjqhhbk.js} +4 -4
- package/dist/chunks/{studio-tp642n5g.js → studio-wgh5kxpj.js} +4 -4
- package/dist/chunks/studio-xasj0796.js +5 -0
- package/dist/chunks/{studio-tzegmy4w.js → studio-y78s8r2n.js} +4 -4
- package/dist/chunks/{studio-7pgy3xaf.js → studio-z8w183sh.js} +4 -4
- package/dist/chunks/{studio-01kbbqg3.js → studio-zscd9ty4.js} +124 -124
- package/dist/chunks/{studio-mwxgyn9h.js → studio-zxp13sss.js} +6 -6
- package/dist/chunks/{studio-r3kaka4d.js → studio-zygnmm01.js} +4 -4
- package/dist/chunks/{tsMode-k9s9fcag.js → tsMode-gr0m4dzr.js} +5 -5
- package/dist/chunks/workspace-m15qtcqp.js +4 -0
- package/dist/chunks/{ws-client-0ja08haa.js → ws-client-nf61frr1.js} +3 -3
- package/dist/iframe-entry.js +3 -3
- package/dist/manifest.json +62 -62
- package/dist/studio.js +83 -83
- package/package.json +11 -11
- package/src/new-project/add-repo-modal.ts +459 -59
- package/src/platforms/cloud.ts +95 -18
- package/src/publish/pages-service.ts +7 -0
- package/src/publish/publish-panel.ts +16 -2
- package/src/surfaces/add-repo.json +721 -224
- package/src/surfaces/add-repo.ts +196 -31
- package/src/types.ts +42 -3
- package/src/ui/schema-form.ts +6 -2
- package/src/utils/project-dir.ts +24 -0
- package/dist/chunks/adapter-y5gdq19c.js +0 -4
- package/dist/chunks/cf-settings-20dznc3j.js +0 -4
- package/dist/chunks/components-q037dya7.js +0 -4
- package/dist/chunks/content-source-37x3vsap.js +0 -4
- package/dist/chunks/editor-j5sq149q.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/format-host-e2pjvd25.js +0 -4
- package/dist/chunks/fs-events-fv64ak3s.js +0 -4
- package/dist/chunks/git-panel-gb713ttc.js +0 -4
- package/dist/chunks/iframe-host-t819mcg5.js +0 -4
- package/dist/chunks/index-m0x5ztax.js +0 -4
- package/dist/chunks/jx-validate-zc9zp77s.js +0 -4
- package/dist/chunks/layers-4bsr82wz.js +0 -4
- package/dist/chunks/layers-panel-b6shnaax.js +0 -4
- package/dist/chunks/lit-html-cfn61dn7.js +0 -4
- package/dist/chunks/media-picker-ej0kdh1j.js +0 -4
- package/dist/chunks/menu-rtxf9chb.js +0 -4
- package/dist/chunks/monaco-buffer-nn4dtx27.js +0 -4
- package/dist/chunks/notify-ahs57a2z.js +0 -4
- package/dist/chunks/platform-v9xyfkbx.js +0 -4
- package/dist/chunks/publish-panel-bq36xcmj.js +0 -4
- package/dist/chunks/quick-search-zm00h9dh.js +0 -4
- package/dist/chunks/references-99ws0b0m.js +0 -4
- package/dist/chunks/right-panel-pq2f71q3.js +0 -4
- package/dist/chunks/section-registry-b2yzp9sw.js +0 -4
- package/dist/chunks/studio-0k9mvpgj.js +0 -14
- package/dist/chunks/studio-1a99w39s.js +0 -5
- package/dist/chunks/studio-693nhyky.js +0 -5
- package/dist/chunks/studio-aqmph6k4.js +0 -5
- package/dist/chunks/studio-c9d3pxf7.js +0 -5
- package/dist/chunks/studio-cxt150pj.js +0 -7
- package/dist/chunks/studio-e6re3rk1.js +0 -5
- package/dist/chunks/studio-frb0qbf7.js +0 -6
- package/dist/chunks/studio-gh97gngt.js +0 -5
- package/dist/chunks/studio-nbxqcgvf.js +0 -5
- package/dist/chunks/studio-t1eedsyx.js +0 -4
- package/dist/chunks/studio-vavmwshr.js +0 -5
- package/dist/chunks/studio-xk0z6msk.js +0 -5
- package/dist/chunks/workspace-b69mgm0e.js +0 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function v(s,n={}){let t=n.baseMs??1000,o=n.maxMs??30000,i=n.random??Math.random,e=Math.min(o,t*2**Math.max(0,s));return e/2+i()*e/2}function
|
|
2
|
-
export{
|
|
1
|
+
function v(s,n={}){let t=n.baseMs??1000,o=n.maxMs??30000,i=n.random??Math.random,e=Math.min(o,t*2**Math.max(0,s));return e/2+i()*e/2}function Wg(s,n={}){let t=n.win??(typeof window>"u"?void 0:window),o=n.doc??(typeof document>"u"?void 0:document),i=0,e=null,r=!1,a=()=>{if(e=null,!r)s()},c=()=>{if(r||e===null)return;clearTimeout(e),i=0,a()},u=(d)=>{if(d.persisted)c()},l=()=>{if(o?.visibilityState==="visible")c()};return t?.addEventListener("online",c),t?.addEventListener("pageshow",u),o?.addEventListener("visibilitychange",l),{dispose(){if(r)return;if(r=!0,e!==null)clearTimeout(e),e=null;t?.removeEventListener("online",c),t?.removeEventListener("pageshow",u),o?.removeEventListener("visibilitychange",l)},opened(){i=0},scheduleRetry(){if(r||e!==null)return;let d=v(i,n);i+=1,e=setTimeout(a,d)},wake:c}}
|
|
2
|
+
export{Wg};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=ECA3F42FDAF9505864756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-0x3jyb8r.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{p,We}from"./studio-
|
|
2
|
-
export{
|
|
1
|
+
import{p,We}from"./studio-qpqa7vk3.js";import{te}from"./studio-ery42sqr.js";function $b(){return We()&&typeof p().findReferences==="function"}function u(e){return`${e.path??""}\x00${e.tagName??""}`}var o=new Map,i=new Map;function wc(e){if(!$b())return{status:"unsupported"};return o.get(u(e))??(i.has(u(e))?{status:"pending"}:null)}async function js(e){if(!$b())return{status:"unsupported"};if(!e.path&&!e.tagName)return{status:"failed",message:"no target to look for"};let t=u(e),s=o.get(t);if(s)return s;let n=i.get(t);if(n)return n;let r=(async()=>{try{return{result:await p().findReferences({...e.path===void 0?{}:{path:e.path},...e.tagName===void 0?{}:{tagName:e.tagName}}),status:"ready"}}catch(l){return{message:te(l),status:"failed"}}finally{i.delete(t)}})();i.set(t,r);let a=await r;return o.set(t,a),a}function G1(e){return o.delete(u(e)),js(e)}function ua(){o.clear()}function f(e){let t=0;for(let s of e.files)if(s.path.startsWith("pages/"))t+=1;return{others:e.files.length-t,pages:t}}function nm(e){let{others:t,pages:s}=f(e);if(s===0&&t===0)return"Not used yet";let n=[];if(s>0)n.push(`${s} page${s===1?"":"s"}`);if(t>0)n.push(`${t} other file${t===1?"":"s"}`);return`Used on ${n.join(" and ")}`}function K1(e,t){if(e.status==="unsupported")return null;if(e.status==="pending")return"Counting references…";if(e.status==="failed")return`References could not be counted (${e.message}) — this may break more than it appears to.`;let{files:s,refsTotal:n}=e.result;if(s.length===0)return t==="delete"?"Nothing else in this project refers to it.":"Nothing else in this project refers to it, so nothing needs updating.";let r=`${n} reference${n===1?"":"s"} in ${s.length} file${s.length===1?"":"s"}`,a=e.result.errors.length>0?" (at least — some documents could not be read)":"";if(t==="delete")return`${r}${a} will break. Those files stay on disk; the references in them stop resolving.`;if(t==="convert")return`${r}${a} will be updated automatically to point at the new file.`;return`${r}${a} will be updated automatically. Nothing else changes.`}function im(e){return e.files.toSorted((t,s)=>s.count-t.count||t.path.localeCompare(s.path))}
|
|
2
|
+
export{$b,wc,js,G1,ua,nm,K1,im};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=14330E68FDF18DD664756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-19x1c75w.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function p(t){return JSON.parse(JSON.stringify(t))}function Ae(t){return t===void 0||t===null?t:p(t)}function
|
|
2
|
-
export{Ae,
|
|
1
|
+
function p(t){return JSON.parse(JSON.stringify(t))}function Ae(t){return t===void 0||t===null?t:p(t)}function Md(t,e){let n=t;for(let r of e){if(n==null)return;n=n[r]}return n}function Rc(t){if(Array.isArray(t))throw TypeError("Cannot insert into a children array; parentPath must point at a node");if(!t.children)t.children=[];if(!Array.isArray(t.children))throw TypeError("Cannot insert into mapped-array children; edit the map template instead");return t.children}function Rm(t,e){switch(e.op){case"set-key":{let n=Md(t,e.path);if(!n)throw Error(`doc-op-node-not-found:${e.path.join("/")}`);let r=n;if(e.value===void 0)delete r[e.key];else r[e.key]=Ae(e.value);return}case"insert-child":{let n=Md(t,e.parentPath);Rc(n).splice(e.index,0,Ae(e.node));return}case"remove-child":{let n=Md(t,e.parentPath);Rc(n).splice(e.index,1);return}case"set-child":{let n=Md(t,e.parentPath);Rc(n).splice(e.index,1,Ae(e.node));return}case"move-child":{x(e);let n=Md(t,e.fromParentPath),r=Md(t,e.toParentPath),o=Rc(n),a=Rc(r),[s]=o.splice(e.fromIndex,1);a.splice(e.toIndex,0,s);return}default:break}throw Error(`unknown-doc-op:${e.op}`)}function d(t,e,n,r,o){let a=t.length;if(!(a<e.length&&t.every((m,J)=>m===e[J]))||e[a]!=="children"||typeof e[a+1]!=="number")return e;let i=e[a+1];if(o?i<n:i<=n)return e;let c=[...e];return c[a+1]=i+r,c}function x(t){let e=[...t.fromParentPath,"children",t.fromIndex],n=t.toParentPath;if(n.length>=e.length&&e.every((r,o)=>r===n[o]))throw Error(`doc-op-move-into-self:${n.join("/")}`)}function h(t,e){return t<0?Math.max(e+t,0):Math.min(t,e)}function dk(t,e){switch(e.op){case"set-key":{let n=Md(t,e.path);if(!n)throw Error(`doc-op-node-not-found:${e.path.join("/")}`);let r=Ae(n[e.key]);return r===void 0?{key:e.key,op:"set-key",path:e.path}:{key:e.key,op:"set-key",path:e.path,value:r}}case"insert-child":{let{length:n}=l(t,e.parentPath);return{index:h(e.index,n),op:"remove-child",parentPath:e.parentPath}}case"remove-child":{let n=u(t,e.parentPath,e.index);return{index:e.index,node:n,op:"insert-child",parentPath:e.parentPath}}case"set-child":{let n=u(t,e.parentPath,e.index);return{index:e.index,node:n,op:"set-child",parentPath:e.parentPath}}case"move-child":{x(e);let n=f(t,e.fromParentPath);P(n,e.fromParentPath,e.fromIndex);let r=l(t,e.toParentPath),o=h(e.toIndex,r.length-(r===n?1:0));return{fromIndex:o,fromParentPath:d(e.fromParentPath,e.toParentPath,e.fromIndex,-1,!1),op:"move-child",toIndex:e.fromIndex,toParentPath:d(e.toParentPath,e.fromParentPath,o,1,!0)}}default:break}throw Error(`unknown-doc-op:${e.op}`)}function f(t,e){let n=Md(t,e);return n&&Array.isArray(n.children)?n.children:null}function P(t,e,n){if(!t||n<0||n>=t.length)throw Error(`doc-op-node-not-found:${[...e,"children",n].join("/")}`)}function u(t,e,n){let r=f(t,e);return P(r,e,n),Ae(r[n])}function l(t,e){let n=Md(t,e);if(!n||typeof n!=="object"||Array.isArray(n))throw Error(`doc-op-node-not-found:${e.join("/")}`);if(n.children===void 0)return[];if(!Array.isArray(n.children))throw TypeError(`doc-op-mapped-children:${e.join("/")}`);return n.children}
|
|
2
|
+
export{Ae,Md,Rc,Rm,dk};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=EE44201EF4CB98F864756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-2sqcndak.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{ge,Xa,Q,v,re,zd,k}from"./studio-fqq890ap.js";import{kp}from"./studio-7pgy3xaf.js";import{p}from"./studio-y7jehjrp.js";import{wi,Zt,Dr}from"./studio-1x8x26k3.js";import{K,Lm,ht,_n,Yo,qa,D}from"./studio-tp642n5g.js";import{Ae,Ic,Im,lk}from"./studio-evwgp1ym.js";import{va,oh,rh}from"./studio-nbxqcgvf.js";import{me}from"./studio-0bbxhhce.js";function vm(e,t){return{success:!0,data:e,summary:t}}function zi(e){return{success:!1,error:e}}function Ki({name:e,description:t,parameters:n,strict:o=!0,llmStrict:r=!1,interactive:i,execute:s}){return{name:e,description:t,parameters:n,strict:o,llmStrict:r,...i===void 0?{}:{interactive:i},execute:s}}function av(e){let t=[];return{record(n){t.push(n),e?.(n)},writes:t}}function Dd(e=null,t={}){let n=new Map(Object.entries(t));return{sessionId:e,get:(o)=>n.get(o),set:(o,r)=>{n.set(o,r)},toJSON:()=>Object.fromEntries(n)}}var Ot=new AbortController().signal;function lv(e={}){let t=e.session??Dd();return{actor:e.actor??{id:`assistant:${t.sessionId??"local"}:`,kind:"assistant",sessionId:t.sessionId,turnId:""},callId:e.callId??"",ledger:e.ledger??av(),progress:e.progress??(()=>{}),session:t,signal:e.signal??Ot}}function wL(e){let t=new AbortController;if(e.aborted)return t.abort(e.reason),{release:()=>{},signal:t.signal};let n=()=>{t.abort(e.reason)};return e.addEventListener("abort",n,{once:!0}),{release:()=>{e.removeEventListener("abort",n)},signal:t.signal}}function zC(){let e=new Map;return{register(t){if(e.has(t.name))console.warn(`Tool "${t.name}" is being re-registered.`);e.set(t.name,t)},list(){return[...e.values()]},listForLLM(){return[...e.values()].map((t)=>({type:"function",function:{name:t.name,description:t.description,parameters:t.parameters,...t.llmStrict===!0?{strict:!0}:{}}}))},getDefinition(t){return e.get(t)},validate(t,n){let o=e.get(t);if(!o)return{valid:!1,errors:[`Unknown tool: "${t}"`]};if(!o.strict)return{valid:!0};let r=o.parameters;if(!r||!r.properties)return{valid:!0};let i=[],s=r.properties,a=r.required||[],l=n;for(let c of a)if(!(c in n)||l[c]===void 0||l[c]===null)i.push(`Missing required argument: "${c}"`);for(let[c,d]of Object.entries(l)){let g=s[c];if(!g)continue;let y=g.type;if(!y)continue;let b=Array.isArray(d)?"array":typeof d;if(y==="number"||y==="integer"){if(b==="number")continue;if(b==="string"){if(!Number.isNaN(Number(d)))continue;i.push(`Argument "${c}" should be a number, got non-numeric string "${d}"`);continue}i.push(`Argument "${c}" should be a number, got ${b}`);continue}if(y==="string"&&b!=="string")i.push(`Argument "${c}" should be a string, got ${b}`);else if(y==="boolean"&&b!=="boolean")i.push(`Argument "${c}" should be a boolean, got ${b}`);else if(y==="array"&&b!=="array")i.push(`Argument "${c}" should be an array, got ${b}`);else if(y==="object"&&b!=="object")i.push(`Argument "${c}" should be an object, got ${b}`)}return i.length>0?{valid:!1,errors:i}:{valid:!0}},async execute(t,n,o=lv()){let r=e.get(t);if(!r)return zi(`Unknown tool: "${t}"`);let i=this.validate(t,n);if(!i.valid)return zi(`Validation failed: ${(i.errors||[]).join("; ")}`);try{return await r.execute(n,o)}catch(s){return zi(`Tool "${t}" execution error: ${s.message}`)}}}}function wt(e){return JSON.parse(JSON.stringify(e))}function St(e){if(!e)return{};let t=JSON.parse(e);if(t===null||typeof t!=="object"||Array.isArray(t)){let n=t===null?"null":Array.isArray(t)?"array":typeof t;throw TypeError(`arguments must be a JSON object, got ${n}`)}return t}async function xL(e,t,n){let o=!1,r;try{let i=St(t.argumentsText);o=!0,r=await e.execute(t.name,i,n)}catch(i){r=zi(`Failed to parse arguments: ${i.message}`)}try{return{status:"done",result:wt(r),executed:o}}catch(i){let s=i.message;return{status:"done",result:zi(`Tool "${t.name}" returned a result that cannot be serialized: ${s}`),executed:o}}}var F=[],Ct=50;function _L(e){return Object.assign(av(),{turnId:e})}function CL(e,t){if(t.length===0)return[];let n={id:e,writes:[...t]};F.push(n);while(F.length>Ct)F.shift();return n.writes}function Tx(e){return F.find((t)=>t.id===e)?.writes??[]}function kL(e){let t=e.filter((a)=>a.ok),n=new Set(t.map((a)=>a.path)),o=e.length-t.length;if(n.size===0)return o>0?`${o} change${o===1?"":"s"} failed`:"";let r=`Changed ${n.size} file${n.size===1?"":"s"}`,i=new Set(t.filter((a)=>a.disk).map((a)=>a.path)),s=[r];if(i.size>0)s.push(`${i.size} written to disk — undo cannot reach ${i.size===1?"it":"them"}`);if(o>0)s.push(`${o} failed`);return s.join(" · ")}function Lx(){F.splice(0)}function SL(e,t){let n=null;for(let o=e.length-1;o>=0;o--){let r=e[o];if(r.id===t)return n;let i=r.role==="assistant"&&(r.content||(r.toolCalls?.length??0)>0);if(n===null&&i)n=r.id}return t===void 0?n:null}var Rt=new Set(["Adlm","Arab","Aran","Armi","Avst","Cprt","Egyd","Egyh","Elym","Gara","Hatr","Hebr","Hluw","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogd","Sogo","Syrc","Thaa","Todr","Yezi"]),Sx="^[A-Za-z]{2,8}(-[A-Za-z0-9]{1,8})*$";function Go(e){if(typeof e!=="string"||e.trim()==="")return null;try{return new Intl.Locale(e.trim()).toString()}catch{return null}}function iv(e){return Go(e)!==null}function gL(e){let t=Go(e);if(t===null)return"ltr";let n=new Intl.Locale(t),o=n.script??n.maximize().script;return o!==void 0&&Rt.has(o)?"rtl":"ltr"}function dn(e){let t=Go(e);if(t===null)return typeof e==="string"?e:"";return new Intl.DisplayNames([t],{type:"language"}).of(t)??t}var At="prefix-except-default";function $o(e){let t=e.i18n,n=[];if(!t||typeof t!=="object")return{errors:n,i18n:null};let o=Array.isArray(t.locales)?t.locales:[],r=[];for(let a of o){let l=Go(a);if(l===null){n.push(`i18n.locales: "${String(a)}" is not a well-formed BCP 47 language tag.`);continue}if(!r.includes(l))r.push(l)}let i=Go(t.defaultLocale)??r[0]??null;if(t.defaultLocale!==void 0&&Go(t.defaultLocale)===null)n.push(`i18n.defaultLocale: "${String(t.defaultLocale)}" is not a well-formed BCP 47 language tag.`);if(i===null)return n.push("i18n is declared with no usable locale — set `defaultLocale` or `locales`."),{errors:n,i18n:null};if(!r.includes(i))r.unshift(i);let s=t.routing==="prefix-always"||t.routing==="prefix-except-default"?t.routing:At;return{errors:n,i18n:{defaultLocale:i,locales:r,routing:s}}}function zu(e,t){let n=se(W(e),t);if(n===-1||t===null)return null;return Go(W(e)[n])}function bL(e,t){let n=zu(e,t);if(n!==null||t===null||t.routing!=="prefix-except-default")return n;return W(e)[0]==="pages"?t.defaultLocale:null}function BC(e,t){let n=W(e),o=se(n,t);return o===-1?n.join("/"):n.filter((r,i)=>i!==o).join("/")}function Wu(e,t,n){if(n===null)return null;let o=Go(t);if(o===null||!n.locales.includes(o))return null;let r=W(e),i=se(r,n),s=i===-1?kt(r):i;if(s===-1)return null;let a=i===-1?r:r.filter((l,c)=>c!==i);if(o===n.defaultLocale&&n.routing==="prefix-except-default")return a.join("/");return a.toSpliced(s,0,o.toLowerCase()).join("/")}function W(e){return e.replace(/^\.\//,"").split("/").filter(Boolean)}function se(e,t){if(t===null)return-1;return e.findIndex((n)=>{let o=Go(n);return o!==null&&t.locales.includes(o)})}function kt(e){if(e[0]==="pages"&&e.length>1)return 1;if(e[0]==="content"&&e.length>2)return 2;return-1}var Dx="{locale}";function Re(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}function B(e){return e.replaceAll("\\","/").replace(/^\.\//,"").replace(/\/+$/,"")}function ke(e){return e??D?.projectConfig??null}function Je(e){return e?.content??{}}function Jt(e){let t=$o(e??{}).i18n?.locales??[];return t.length>0?[...t]:null}function je(e){if(e.endsWith("/"))return!1;let t=e.slice(e.lastIndexOf("/")+1);return/\.[a-z\d]+$/i.test(t)}function Ie(e){if(e.format==="json")return{ext:".json",unresolvedFormat:null};if(e.format===void 0||e.format==="")return{ext:Dr()?.extensions[0]??".json",unresolvedFormat:null};let t=wi(e.format);return t?.extensions[0]===void 0?{ext:null,unresolvedFormat:e.format}:{ext:t.extensions[0],unresolvedFormat:null}}function jt(e,t){let n=t===null?"[^/]+":`(?:${t.map((r)=>Re(r)).join("|")})`,o=B(e).split(Dx).map((r)=>Re(r)).join(n);return new RegExp(`^${o}(?:/|$)`,"i")}function It(e,t,n){let o=jt(e,n).exec(t);if(!o)return null;return o[0].replace(/\/$/,"")}function Dt(e){return B(e).replaceAll(Dx,"").length}function bp(e,t){if(e===null||e===void 0||e==="")return null;let n=ke(t),o=Jt(n),r=B(e),i=null,s=-1;for(let[a,l]of Object.entries(Je(n))){let{source:c}=l;if(c===void 0||c===""||je(c))continue;let d=Dt(c);if(d<=s)continue;let g=It(c,r,o);if(g===null)continue;i={def:l,dir:r,fileBacked:!1,isSourceRoot:r.length===g.length,name:a,...Ie(l)},s=d}return i}function Ax(e,t){if(e===null||e===void 0||e==="")return null;let n=ke(t),o=B(e),r=o.toLowerCase();for(let[i,s]of Object.entries(Je(n))){let{source:a}=s;if(a===void 0||a===""||!je(a))continue;let l=B(a).toLowerCase();if(r===l||r.endsWith(`/${l}`))return{def:s,dir:o.includes("/")?o.slice(0,o.lastIndexOf("/")):".",fileBacked:!0,isSourceRoot:!1,name:i,...Ie(s)}}return bp(o.includes("/")?o.slice(0,o.lastIndexOf("/")):".",n)}function Ml(e){return e.replaceAll(/([A-Z])/g," $1").replace(/^./,(t)=>t.toUpperCase())}function xv(e){return e.replaceAll(/[^a-zA-Z0-9]+(.)?/g,(t,n)=>n?n.toUpperCase():"").replace(/^[A-Z]/,(t)=>t.toLowerCase())}function _v(e){return e.replaceAll(/(^|-)(\w)/g,(t,n,o)=>(n?" ":"")+o.toUpperCase())}function Nx(e,t){return e?.$label||Ml(t)}function KL(e,t){if(e?.$label)return e.$label;if(t.includes("-"))return t.replaceAll(/(^|-)(\w)/g,(n,o,r)=>(o?" ":"")+r.toUpperCase());return Ml(t)}function ma(e){return e==="image"||e==="uri-reference"}function Ad(e){if(e.$shorthand===!0)return"shorthand";if(e.$input==="button-group")return"button-group";if(e.$input==="media")return"media";if(e.format==="color")return"color";if(ma(e.format))return"media";if(e.$units!==void 0)return"number-unit";if(e.type==="number")return"number";if(Array.isArray(e.enum))return"select";if(Array.isArray(e.examples)||Array.isArray(e.presets))return"combobox";return"text"}function qu(e,t){if(!e||!t?.content)return null;let n=Ax(e,t);if(!n||!n.def.schema)return null;if(!n.fileBacked){let o=n.ext??Dr()?.extensions[0]??".json";if(!e.toLowerCase().endsWith(o.toLowerCase()))return null}return{name:n.name,schema:n.def.schema}}function xm(e,t){let n=e.trim().toLowerCase().replaceAll(/[^a-z0-9\s-]/g,"").replaceAll(/\s+/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,"");if(!n)return"";return`${t}${n}`}function Cv(e,t){return e.replace(new RegExp(`^${t.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}`),"").replace(/^--/,"").replaceAll("-"," ").replaceAll(/\b\w/g,(n)=>n.toUpperCase())||e}function JL(e){if(!e)return{kind:"text"};let t=e.trim().replaceAll(/\s*\|\s*undefined\b/g,"").trim();if(t==="boolean")return{kind:"boolean"};if(t==="number")return{kind:"number"};if(t.match(/^'[^']*'(\s*\|\s*'[^']*')+$/))return{kind:"combobox",options:[...t.matchAll(/'([^']*)'/g)].map((r)=>r[1])};return{kind:"text"}}function Ao(e){return JSON.parse(JSON.stringify(e))}function Le(e){return e&&e.length>0?e.at(-1):null}function LL(e){return e&&e.length>0?e[0]:null}function dv(e,t){if(!t||!e)return!1;return e.some((n)=>Yo(n,t))}function ms(e){return E(e)}function E(e){let t=[];for(let n of e)t.push([...n]);return t}function uv(e,t){if(dv(e,t))return E(e.filter((n)=>!Yo(n,t)));return[...E(e),[...t]]}function IL(e,t,n){let o=e.findIndex((s)=>Yo(s,n)),r=t?e.findIndex((s)=>Yo(s,t)):-1;if(o===-1||r===-1)return[[...n]];let i=r<=o?e.slice(r,o+1):e.slice(o,r+1).toReversed();return E(i)}function De(e,t){return E(e.filter((n)=>!qa(t,n)))}function Et(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 r-i;return String(r)<String(i)?-1:1}return e.length-t.length}function Lt(e){return E(e.filter((t)=>!e.some((n)=>!Yo(n,t)&&qa(n,t))))}function Nl(e){return e.at(-2)==="children"&&typeof e.at(-1)==="number"}function hv(e){return Lt(e).filter((t)=>Nl(t)).toSorted((t,n)=>Et(n,t))}function RL(e){let t=[];for(let n of e)if(!t.some((o)=>Yo(o,n)))t.push([...n]);return t}function mp(e){if(e.length===0)return{mixed:!1,value:void 0};let t=e[0],n=JSON.stringify(t??null);for(let o=1;o<e.length;o++)if(JSON.stringify(e[o]??null)!==n)return{mixed:!0,value:void 0};return{mixed:!1,value:t}}var Ee=null;function $L(e){Ee=e}function Me(){return Ee}var V=null,U=null,G=null,ae=!0;function $e(){V=[],U=[],G=[],ae=!0}function f(e){if(V)V.push(e)}function vi(e){if(U)U.push(e)}function Ne(e){if(G)G.push(e)}function _e(){let e={docOps:U??[],fmOps:G??[],invertible:ae,ops:V??[]};return V=null,U=null,G=null,ae=!0,e}var Fe=100,Mt=20;function H(){try{return typeof localStorage>"u"||!localStorage.getItem("jx-legacy-history")}catch{return!0}}function P(e,t,n,o){return{forward:{key:t,op:"set-key",path:e,value:o},inverse:{key:t,op:"set-key",path:e,value:n}}}function $t(e,t,n,o,r){let i=e.length;if(!(i<t.length&&e.every((c,d)=>c===t[d]))||t[i]!=="children"||typeof t[i+1]!=="number")return t;let a=t[i+1];if(r?a<n:a<=n)return t;let l=[...t];return l[i+1]=a+o,l}var We=null;function Be(e){We=e}var Ve=null;function Ke(e){Ve=e}function Nt(e,t,n,o){for(let r=t.docOps.length-1;r>=0;r--)Im(e.doc.document,re(t.docOps[r].inverse));for(let r=t.fmOps.length-1;r>=0;r--){let i=t.fmOps[r];de(e,i.field,i.before)}e.doc.document={...re(e.doc.document)},e.session.selection=n,e.doc.dirty=o}function q(e,t,{skipHistory:n=!1,origin:o="user",coalesceKey:r=null}={}){if(!e)return!1;if(o!=="remote"&&Ve?.(e,o))return!1;let i=ms(e.session.selection),s=e.doc.dirty;$e();let a,l=null;try{t(e)}catch(b){l={error:b}}finally{a=_e()}if(l)throw Nt(e,a,i,s),l.error;let c=re(e.doc.document),d={...c},g=Me(),y=g===null?{patchable:!1,reason:"no-patch-consumer"}:a.ops.length===0?{patchable:!1,reason:"unrecorded-mutation"}:g.classify(e,a.ops);if(y.patchable)g.markConsumed(d,e);if(e.doc.document=d,y.patchable)try{g.apply(e,a.ops,a)}catch(b){g.escalate(`patch-apply-failed: ${b instanceof Error?b.message:String(b)}`,e)}if(!n&&!L)_t(e,c,a,i,r);return e.doc.dirty=!0,We?.(e,a,o),!0}function _t(e,t,n,o,r=null){let i=e.history.snapshots.slice(0,e.history.index+1),s=H()&&n.invertible&&(n.docOps.length>0||n.fmOps.length>0),a=i.at(-1);if(r&&s&&a&&a.coalesceKey===r&&a.inverseOps){if(a.forwardOps=[...a.forwardOps??[],...n.docOps.map((c)=>c.forward)],a.inverseOps=[...a.inverseOps,...n.docOps.map((c)=>c.inverse)],a.selection=ms(e.session.selection),a.document)a.document=Ao(t);e.history.snapshots=i,e.history.index=i.length-1;return}let l=!s||i.length%Mt===0;if(i.push({document:l?Ao(t):null,fmOps:s&&n.fmOps.length>0?n.fmOps:null,forwardOps:s?n.docOps.map((c)=>c.forward):null,inverseOps:s?n.docOps.map((c)=>c.inverse):null,coalesceKey:r,selection:ms(e.session.selection),selectionBefore:o}),i.length>Fe){if(!i[1].document)i[1].document=le(i,1);i.shift()}e.history.snapshots=i,e.history.index=i.length-1}function le(e,t){let n=t;while(n>=0&&!e[n].document)n-=1;if(n<0)throw Error("history-missing-checkpoint");let o=Ao(e[n].document);for(let r=n+1;r<=t;r++)for(let i of e[r].forwardOps??[])Im(o,i);return o}function Hs(e,t,n){return q(e,(o)=>t(o.doc.document),n)}function ce(e,t){q(e,(n)=>{for(let o of t)ue(n,o)},{origin:"remote",skipHistory:!0})}var Ft=new Set(["state","$media","$head","$elements","imports","$layout"]);function ue(e,t){let n=t.op==="set-key"?K(e.doc.document,t.path)?.[t.key]:null;switch(Im(e.doc.document,t),vi({forward:t,inverse:t}),t.op){case"set-key":{if(Ft.has(t.key))f({key:t.key,op:"doc-meta"});else if(t.key==="style")f({op:"set-style",path:t.path});else if(t.key==="textContent")f({op:"set-text",path:t.path});else if(t.key==="attributes"||t.key==="cases"||t.key==="$props")f({op:"replace",path:t.path});else{let o=t.key.startsWith("on")&&(rh(t.value)||rh(n));f({isEvent:o,key:t.key,op:"set-prop",path:t.path})}return}case"insert-child":{f({index:t.index,op:"insert",parentPath:t.parentPath});return}case"remove-child":{f({op:"remove",path:[...t.parentPath,"children",t.index]});return}case"set-child":{f({op:"replace",path:[...t.parentPath,"children",t.index]});return}case"move-child":{f({fromPath:[...t.fromParentPath,"children",t.fromIndex],op:"move",toIndex:t.toIndex,toParentPath:t.toParentPath});break}default:break}}var L=null,Ge=null;function qe(e){Ge=e}function pv(e){L=e}function fv(){let e=L;if(e&&!j.has(e)){let t=re(e.doc.document),n={document:Ao(t),selection:ms(e.session.selection)},o=e.history.snapshots.slice(0,e.history.index+1);if(o.push(n),o.length>Fe)o.shift();e.history.snapshots=o,e.history.index=o.length-1}if(L=null,e)Ge?.(e)}function Ix(){return L!==null}function DL(){return L}var j=new WeakMap;function ym(e,t){if(t)j.set(e,t);else j.delete(e)}function AL(e){let t=j.get(e);return t?t.canUndo(e):e.history.index>0}function NL(e){let t=j.get(e);return t?t.canRedo(e):e.history.index<e.history.snapshots.length-1}function ze(e,t){let{snapshots:n}=e.history;e.doc.document=le(n,t);let o=n[t];e.session.selection=ms(re(o.selection))}function Ye(e,t){try{if(typeof localStorage>"u"||!localStorage.getItem("jx-canvas-debug"))return}catch{return}let n=JSON.stringify(le(e.history.snapshots,t)),o=JSON.stringify(Ao(re(e.doc.document)));if(n!==o)console.error("jx history: ops-based undo/redo diverged from checkpoint replay",{index:t})}function Rx(e){let t=j.get(e);if(t){t.undo(e);return}if(e.history.index<=0)return;let n=e.history.snapshots[e.history.index],o=H()?n.inverseOps:null,r=H()?n.fmOps:null;if(o&&o.length>0||r&&r.length>0){if(!q(e,(s)=>{if(o)for(let a=o.length-1;a>=0;a--)ue(s,re(o[a]));if(r)for(let a=r.length-1;a>=0;a--){let l=re(r[a]);de(s,l.field,l.before)}},{origin:"history",skipHistory:!0}))return;e.session.selection=ms(re(n.selectionBefore??[])),e.history.index-=1,Ye(e,e.history.index)}else e.history.index-=1,ze(e,e.history.index);e.doc.dirty=!0}function OL(e){let t=j.get(e);if(t){t.redo(e);return}if(e.history.index>=e.history.snapshots.length-1)return;let n=e.history.snapshots[e.history.index+1],o=H()?n.forwardOps:null,r=H()?n.fmOps:null;if(o&&o.length>0||r&&r.length>0){if(!q(e,(s)=>{if(o)for(let a of o)ue(s,re(a));if(r)for(let a of r){let l=re(a);de(s,l.field,l.after)}},{origin:"history",skipHistory:!0}))return;e.session.selection=ms(re(n.selection)),e.history.index+=1,Ye(e,e.history.index)}else e.history.index+=1,ze(e,e.history.index);e.doc.dirty=!0}function Ji(e,t,n,o){let r=K(e.doc.document,t);if(!r)return;Ic(r).splice(n,0,structuredClone(o)),f({index:n,op:"insert",parentPath:t}),vi({forward:{index:n,node:Ae(o),op:"insert-child",parentPath:t},inverse:{index:n,op:"remove-child",parentPath:t}})}function Vu(e,t){if(!t||!Nl(t))return;let n=ht(t),o=_n(t),[r]=K(e.doc.document,n).children.splice(o,1);f({op:"remove",path:t}),vi({forward:{index:o,op:"remove-child",parentPath:n},inverse:{index:o,node:Ae(r),op:"insert-child",parentPath:n}}),e.session.selection=De(e.session.selection,t)}function VC(e,t){if(!t||!Nl(t))return;let n=K(e.doc.document,t);if(!n)return;let o=ht(t),r=_n(t),i=structuredClone(re(n));K(e.doc.document,o).children.splice(r+1,0,i),f({index:r+1,op:"insert",parentPath:o}),vi({forward:{index:r+1,node:Ae(i),op:"insert-child",parentPath:o},inverse:{index:r+1,op:"remove-child",parentPath:o}}),e.session.selection=[[...o,"children",r+1]]}function gp(e,t){for(let n of hv(t))Vu(e,n)}function mv(e,t){let n=[];for(let o of hv(t)){let r=e.session.selection;VC(e,o);let i=Le(e.session.selection);if(!i||e.session.selection===r)continue;let s=ht(i),a=_n(i);n=n.map((l)=>$t(s,l,a,1,!0)),n.unshift(i)}if(n.length>0)e.session.selection=n}function ML(e,t,n="div"){if(!t||!Nl(t))return;let o=K(e.doc.document,t);if(!o)return;let r=ht(t),i=_n(t),s={children:[structuredClone(re(o))],tagName:n},a=Ae(o);K(e.doc.document,r).children.splice(i,1,s),f({op:"replace",path:t}),vi({forward:{index:i,node:Ae(s),op:"set-child",parentPath:r},inverse:{index:i,node:a,op:"set-child",parentPath:r}}),e.session.selection=[[...r,"children",i]]}function pa(e,t,n,o){let r=e.doc.document,i=ht(t),s=_n(t);if(!i||typeof s!=="number")return;let a=K(r,i),l=K(r,n);if(!a||!Array.isArray(a.children)||!l)return;if(a.children[s]===void 0)return;let c=o;if(a===l&&s<o)c-=1;let d={fromIndex:s,fromParentPath:i,op:"move-child",toIndex:c,toParentPath:n},g=lk(r,d),[y]=a.children.splice(s,1);if(Ic(l).splice(c,0,y),f({fromPath:t,op:"move",toIndex:c,toParentPath:n}),vi({forward:d,inverse:g}),Yo(Le(e.session.selection),t)){let b=o;if(i.length===n.length&&i.every((_,I)=>_===n[I])&&s<o)b=o-1;e.session.selection=[[...n,"children",b]]}}function Ue(e,t,n,o){let r=K(e.doc.document,t);if(!r)return;let i=r[n],s=Ae(i);if(o===void 0||o===null||o==="")delete r[n];else r[n]=o;if(vi(P(t,n,s,Ae(r[n]))),n==="textContent")f({op:"set-text",path:t});else if(n==="style")f({op:"set-style",path:t});else{let a=o===void 0||o===null||o===""?i:o,l=n.startsWith("on")&&rh(a);f({isEvent:l,key:n,op:"set-prop",path:t})}}function kc(e,t,n,o){let r=K(e.doc.document,t),i=Ae(r.style);if(!r.style)r.style={};if(o===void 0||o==="")delete r.style[n];else r.style[n]=o;if(Object.keys(r.style).length===0)delete r.style;vi(P(t,"style",i,Ae(r.style))),f({op:"set-style",path:t})}function Ko(e,t,n,o){let r=K(e.doc.document,t),i=Ae(r.attributes);if(!r.attributes)r.attributes={};if(o===void 0||o==="")delete r.attributes[n];else r.attributes[n]=o;if(Object.keys(r.attributes).length===0)delete r.attributes;vi(P(t,"attributes",i,Ae(r.attributes))),f({attr:n,op:"set-attr",path:t})}function PL(e,t,n,o,r){if(!n)return kc(e,t,o,r);let i=K(e.doc.document,t),s=Ae(i.style);if(!i.style)i.style={};let a=`@${n}`,l=oh(i.style,a);if(r===void 0||r===""){if(delete l[o],Object.keys(l).length===0)delete i.style[a]}else l[o]=r;if(Object.keys(i.style).length===0)delete i.style;vi(P(t,"style",s,Ae(i.style))),f({op:"set-style",path:t})}function gv(e,t,n,o,r){let i=K(e.doc.document,t),s=Ae(i.style);if(!i.style)i.style={};let a=oh(i.style,n);if(r===void 0||r===""){if(delete a[o],Object.keys(a).length===0)delete i.style[n]}else a[o]=r;if(Object.keys(i.style).length===0)delete i.style;vi(P(t,"style",s,Ae(i.style))),f({op:"set-style",path:t})}function FL(e,t,n,o,r,i){let s=K(e.doc.document,t),a=Ae(s.style);if(!s.style)s.style={};let l=`@${n}`,c=oh(s.style,l),d=oh(c,o);if(i===void 0||i===""){if(delete d[r],Object.keys(d).length===0)delete c[o];if(Object.keys(c).length===0)delete s.style[l]}else d[r]=i;if(Object.keys(s.style).length===0)delete s.style;vi(P(t,"style",a,Ae(s.style))),f({op:"set-style",path:t})}function Ze(e,t){let n=[e];for(let o of t){let r=va(n.at(-1),o);if(!r)break;n.push(r)}for(let o=n.length-2;o>=0;o--){let r=n[o],i=t[o],s=va(r,i);if(s&&Object.keys(s).length===0)delete r[i]}}function bv(e,t,n,o,r){let i=K(e.doc.document,t),s=Ae(i.style);if(!i.style)i.style={};let a=i.style;for(let l of n)a=oh(a,l);if(r===void 0||r==="")delete a[o],Ze(i.style,n);else a[o]=r;if(Object.keys(i.style).length===0)delete i.style;vi(P(t,"style",s,Ae(i.style))),f({op:"set-style",path:t})}function jL(e,t,n,o,r,i){let s=K(e.doc.document,t),a=Ae(s.style);if(!s.style)s.style={};let l=`@${n}`,c=oh(s.style,l),d=c;for(let g of o)d=oh(d,g);if(i===void 0||i===""){if(delete d[r],Ze(c,o),Object.keys(c).length===0)delete s.style[l]}else d[r]=i;if(Object.keys(s.style).length===0)delete s.style;vi(P(t,"style",a,Ae(s.style))),f({op:"set-style",path:t})}function HL(e,t,n){let o=K(e.doc.document,t),r=Ae(o.style);if(n&&Object.keys(n).length>0)o.style=n;else delete o.style;vi(P(t,"style",r,Ae(o.style))),f({op:"set-style",path:t})}function Bs(e,t,n){let o=e.doc.document,r=Ae(o.state);if(!o.state)o.state={};o.state[t]=n,vi(P([],"state",r,Ae(o.state))),f({key:"state",op:"doc-meta"})}function vv(e,t){let n=e.doc.document;if(n.state){let o=Ae(n.state);if(delete n.state[t],Object.keys(n.state).length===0)delete n.state;vi(P([],"state",o,Ae(n.state))),f({key:"state",op:"doc-meta"})}}function mr(e,t,n){let o=e.doc.document,r=Ae(o.state);if(!o.state)o.state={};let i=o.state[t],s=i==null?{}:typeof i!=="object"||Array.isArray(i)?{default:i}:i;o.state[t]=s,Object.assign(s,n);for(let a of Object.keys(s))if(s[a]===void 0||s[a]===null)delete s[a];vi(P([],"state",r,Ae(o.state))),f({key:"state",op:"doc-meta"})}function BL(e,t,n){let o=e.doc.document;if(!o.state||!o.state[t])return;let r=Ae(o.state);o.state[n]=o.state[t],delete o.state[t],vi(P([],"state",r,Ae(o.state))),f({key:"state",op:"doc-meta"})}function Uu(e,t,n,o){let r=K(e.doc.document,t),i=Ae(r.$props);if(!r.$props)r.$props={};if(o===void 0||o===null||o==="")delete r.$props[n];else r.$props[n]=o;if(Object.keys(r.$props).length===0)delete r.$props;vi(P(t,"$props",i,Ae(r.$props))),f({op:"replace",path:t})}function zL(e,t,n,o){let r=K(e.doc.document,t),i=Ae(r.cases);if(!r.cases)r.cases={};r.cases[n]=o||{tagName:"div",textContent:n},vi(P(t,"cases",i,Ae(r.cases))),f({op:"replace",path:t})}function WL(e,t,n){let o=K(e.doc.document,t);if(o.cases){let r=Ae(o.cases);delete o.cases[n],vi(P(t,"cases",r,Ae(o.cases))),f({op:"replace",path:t})}}function VL(e,t,n,o){let r=K(e.doc.document,t);if(!r.cases||!r.cases[n])return;let i=Ae(r.cases);r.cases[o]=r.cases[n],delete r.cases[n],vi(P(t,"cases",i,Ae(r.cases))),f({op:"replace",path:t})}function Ol(e,t,n){let o=e.doc.content.frontmatter,r=Object.hasOwn(o,t)?Ae(o[t]):void 0,i=n===void 0||n===null||n==="";if(i)delete o[t];else o[t]=n;let s=i?void 0:Ae(n);Ne({after:s,before:r,field:t}),e.doc.dirty=!0}function de(e,t,n){if(n===void 0)delete e.doc.content.frontmatter[t];else e.doc.content.frontmatter[t]=n}var Wt={design:"canvas",edit:"canvas",entry:"entry","git-diff":"diff",grid:"grid",manage:"library",media:"media",preview:"canvas",settings:"config",source:"code",stylebook:"config"},ov={canvas:"Canvas",code:"Code",config:"Project Styles",diff:"Diff",entry:"Entry",grid:"Grid",media:"Media",library:"Library",none:"None"};function ha(e){return Wt[e]??"canvas"}var Bt={design:"design",edit:"edit",preview:"preview"};function vL(e){return Bt[e]??"design"}var rv=(e)=>e.editor.kind==="canvas",$d=(e)=>rv(e)&&e.selection.count>0,sv=(e)=>$d(e)&&!e.selection.isRoot;function bm(){return{project:{open:!1,isSite:!1,isRepo:!1,isMultilingual:!1},git:{ahead:0,behind:0,dirtyCount:0},document:{open:!1,dirty:!1,mode:"",canUndo:!1,canRedo:!1},editor:{kind:"none"},canvas:{view:"design"},pane:{count:1,derived:!1},selection:{count:0,paths:[],kind:"",isRoot:!1,isComponentInstance:!1,isLayoutNode:!1,isRepeater:!1},caret:{active:!1,inCanvas:!1},focus:{region:"pane"},modal:{open:!1},collab:{attached:!1,readOnly:!1,sourceCanonical:!1},ai:{configured:!1,streaming:!1,waiting:!1},capability:{gitClone:!1,importSite:!1,openProjectInNewWindow:!1,dataRows:!1,windowControls:!1,findReferences:!1,readFileBytes:!1}}}function Ex(e={}){let t=bm();for(let n of Object.keys(e)){let o=e[n];if(o)Object.assign(t[n],o)}return t}var Vt=["palette"],Kt=["caret","global"],Ut=["dock","global"],Gt=["canvas","global"],Ht=["grid","global"],qt=["code","global"],Xe=["global"];function yL(e){if(e.modal.open)return Vt;if(e.caret.active)return Kt;if(e.focus.region!=="pane")return Ut;switch(e.editor.kind){case"grid":return Ht;case"code":return qt;case"canvas":return e.canvas.view==="preview"?Xe:Gt;default:return Xe}}var ai="project.json";function zt(e,t=!1){return{activeMedia:null,activeSelector:null,openPopover:null,openDialog:null,canvasMode:e,editZoom:1,editingFormula:null,editingFunction:null,featureToggles:{},inspectorSections:{},pendingInlineEdit:null,preview:t,previewColorScheme:"auto",previewLocale:null,previewParams:{},previewProps:null,rightTab:"properties",showLayout:!0,styleFilter:"",styleSections:{},dataRows:{},dataLimits:{},styleShorthands:{},zoom:1}}var Yt=["edit","design","preview","source","stylebook","git-diff"];function cv({id:e,documentPath:t=null,fileHandle:n=null,document:o,frontmatter:r,sourceFormat:i=null,capabilities:s,openedFrom:a=null,preview:l=!1,layout:c=null}){let d=ge();Lm(o);let g=s?.modes??Xt(t,i),y=g.find((I)=>I!=="preview")??"edit",b=g[0]==="preview";return d.run(()=>({capabilities:{modes:g},doc:v({content:{frontmatter:r||{}},dirty:!1,document:o,handlersSource:null,layout:c,mode:Qt(t,i),sourceFormat:i}),documentPath:t,fileHandle:n,history:v({index:0,snapshots:[{document:structuredClone(o),selection:[]}]}),id:e,pinned:!1,preview:l,scope:d,session:v({canvas:{refreshing:!1,error:null,livePreviews:null,pendingInlineEdit:null,scope:null,status:"idle"},clipboard:null,hover:null,openedFrom:a,selection:[],ui:zt(y,b)})}))}function Xt(e,t){if(e===ai)return["stylebook","source"];let n=wi(t)??Zt(e);if(n)return n.studio?.modes??["edit","design","preview","source"];return Yt}function Qt(e,t){let n=wi(t)??Zt(e);if(n)return n.studio?.documentMode?.default??"content";return"component"}function WC(e){return ha(e.session.ui.canvasMode)}function EL(e){let t=[];for(let n of e.capabilities.modes){if(n==="preview")continue;let o=ha(n);if(!t.includes(o))t.push(o)}return t}function TL(e,t){return e.capabilities.modes.find((n)=>n!=="preview"&&ha(n)===t)}function fp(e){e.scope.stop()}var Qe=new WeakMap,M=new Map;function xn(e){let t=re(e),n=Qe.get(t);if(!n)n=v({active:!1,attachError:"",peers:[],readOnly:!1,sourceCanonical:!1,status:"unavailable"}),Qe.set(t,n);return n}function et(e){M.set(e,(M.get(e)??0)+1)}function tt(e){let t=M.get(e)??0;if(t<=1)M.delete(e);else M.set(e,t-1)}function wm(e){return M.has(e.replaceAll("\\","/"))}var en=8000,tn=800,nn=2500,nt=null;function on(){return nt??=(me("m0x5ztax"),import("./index-m0x5ztax.js")),nt}function it(){try{return p()}catch{return null}}var N=null;function YL(e){N=e}var pe=null;function ZL(e){pe=e}var st=()=>{};function XL(e){st=e??(()=>{})}var be=new WeakMap;function at(e){return re(e)}function C(e){return be.get(at(e))}function xe(e){let t=at(e),n=be.get(t);if(!n)n={attaching:null,generation:0,optedOut:v({value:!1}),session:null,watcherInstalled:!1},be.set(t,n);return n}var rt=!1;function rn(){if(rt)return;rt=!0,Be(sn),qe(an),Ke((e)=>{if(C(e)?.session?.synced&&xn(e).sourceCanonical)return st("Source editing in progress — structural edits are paused"),"source-canonical";return null})}function sn(e,t,n){let o=C(e)?.session;if(!o||!o.synced)return;if(o.lastSeenRef=re(e.doc.document),n==="remote"){ee(o);return}if(o.canWrite)ln(o,t),ee(o)}function an(e){let t=C(e)?.session;if(!t?.synced||t.batchOps===null)return;let{batchOps:n,batchNeedsDiff:o}=t;if(t.batchOps=null,t.batchNeedsDiff=!1,!t.canWrite)return;if(t.undoManager?.stopCapturing(),o)z(t);else if(n.length>0)try{t.collab.applyDocOpsToY(t.handle.doc,n,t.collab.LOCAL_ORIGIN)}catch{z(t)}t.undoManager?.stopCapturing()}function ln(e,t){let n=t.docOps.map((o)=>o.forward);if(Ix()){if(e.batchOps??=[],n.length===0)e.batchNeedsDiff=!0;else e.batchOps.push(...n);return}if(n.length===0){z(e);return}try{e.collab.applyDocOpsToY(e.handle.doc,n,e.collab.LOCAL_ORIGIN)}catch{z(e)}}function z(e){let{collab:t,handle:n,tab:o}=e,r=t.yDocToJson(n.doc),i=Ao(re(o.doc.document)),s=t.diffDocs(r,i);if(s===null)t.replaceYStructure(n.doc,i,t.LOCAL_ORIGIN);else if(s.length>0)try{t.applyDocOpsToY(n.doc,s,t.LOCAL_ORIGIN)}catch{t.replaceYStructure(n.doc,i,t.LOCAL_ORIGIN)}}function fe(e){let t=e.collab.yDocToJson(e.handle.doc);q(e.tab,(n)=>{let o=n.doc.document;for(let r of Object.keys(o))if(!(r in t))delete o[r];Object.assign(o,t)},{origin:"remote",skipHistory:!0})}function cn(e){if(!e.canWrite)return!1;let{awareness:t}=e.handle,n=t.clientID;for(let[o,r]of t.getStates())if(r.canWrite!==!1&&o<n)n=o;return n===e.handle.awareness.clientID}function ee(e){if(!N||!cn(e))return;if(e.collab.canonicalOf(e.handle.doc)==="source")return;let t=Date.now();if(e.lastMirrorAt??=t,t-e.lastMirrorAt>=nn){if(e.mirrorTimer)clearTimeout(e.mirrorTimer),e.mirrorTimer=null;e.lastMirrorAt=t,ye(e);return}if(e.mirrorTimer)clearTimeout(e.mirrorTimer);e.mirrorTimer=setTimeout(()=>{e.mirrorTimer=null,e.lastMirrorAt=Date.now(),ye(e)},tn)}async function ye(e){if(!N||!e.synced)return;try{let t=await N(e.tab);e.collab.updateSourceText(e.handle.doc,t,e.collab.MIRROR_ORIGIN)}catch{}}async function lt(e){if(!pe||!e.synced||!e.canWrite)return;let{collab:t,handle:n,tab:o}=e,r=t.canonicalRevOf(n.doc),i=t.sourceText(n.doc).toString(),s;try{s=await pe(o,i)}catch{return}if(!e.synced||t.canonicalRevOf(n.doc)!==r)return;let a=t.diffDocs(t.yDocToJson(n.doc),s.document);if(a===null)t.replaceYStructure(n.doc,s.document,t.MIRROR_ORIGIN);else if(a.length>0)try{t.applyDocOpsToY(n.doc,a,t.MIRROR_ORIGIN)}catch{t.replaceYStructure(n.doc,s.document,t.MIRROR_ORIGIN)}let l=t.frontmatterMap(n.doc),c=s.frontmatter??{};n.doc.transact(()=>{let d=[...l.keys()];for(let g of d)if(!(g in c))l.delete(g);for(let[g,y]of Object.entries(c))if(!t.deepEqual(l.get(g),y))l.set(g,y)},t.MIRROR_ORIGIN)}function QL(e){let t=C(e)?.session;if(!t?.synced)return null;let{collab:n,handle:o}=t,r=null,i=()=>r!==null&&t.sourceLockOwner===r;return{awareness:o.awareness,enter:async()=>{r={},t.sourceLockOwner=r;let s=o.awareness.getLocalState();if(s)o.awareness.setLocalState({...s,mode:"source"});if(!t.canWrite)return;let a=null;if(N)try{a=await N(e)}catch{a=null}if(!i())return;n.acquireSourceCanonical(o.doc,a??n.sourceText(o.doc).toString(),n.LOCAL_ORIGIN)},leave:()=>{if(!i()){r=null;return}r=null,t.sourceLockOwner=null;let s=o.awareness.getLocalState();if(s)o.awareness.setLocalState({...s,mode:"structure"});if(!t.canWrite)return;if(n.otherSourceEditors(o.awareness,t.path,o.awareness.clientID).filter((l)=>o.awareness.getStates().get(l)?.canWrite!==!1).length===0)lt(t).then(()=>{n.releaseSourceCanonical(o.doc,n.LOCAL_ORIGIN)})},localOrigin:n.LOCAL_ORIGIN,readOnly:!t.canWrite,text:n.sourceText(o.doc)}}function _m(e){let t=xn(e);return t.active&&t.readOnly}async function GC(e){let t=C(e)?.session;if(!t?.synced||!t.canWrite)return!1;if(t.mirrorTimer)clearTimeout(t.mirrorTimer),t.mirrorTimer=null;return await ye(t),await t.handle.flush(),!0}async function KC(){for(let e of he)if(C(e)?.session?.synced)await GC(e)}var he=new Set;function Y(e){if(!it()?.collab||!e.documentPath||e.documentPath===ai)return;let n=xe(e);if(n.watcherInstalled)return;n.watcherInstalled=!0,rn(),he.add(e),e.scope.run(()=>{Q(()=>{if(n.optedOut.value)te(e);else ve(e)}),Xa(()=>{he.delete(e),te(e)})})}function JC(e,t){let n=xe(e);if(n.optedOut.value===!t)return;if(n.optedOut.value=!t,!n.watcherInstalled&&t)Y(e)}function YC(e){return C(e)?.optedOut.value!==!0}function ct(e){if(!C(e)?.watcherInstalled){Y(e);return}te(e),ve(e)}async function ve(e){let t=xe(e);if(t.session||t.attaching)return;let{documentPath:n}=e,o=it();if(!n||!o?.collab){xn(e).status="unavailable";return}let{generation:r}=t,i=xn(e);i.status="connecting",i.attachError="";let s=(async()=>{try{let[a,l]=await Promise.all([on(),o.collab(n)]);if(!l){i.status="detached";return}if(t.generation!==r){l.destroy();return}let c=null,d=new Promise((g,y)=>{c=setTimeout(()=>y(Error("collab-sync-timeout")),en)});try{await Promise.race([l.whenSynced,d])}finally{if(c)clearTimeout(c)}if(t.generation!==r){l.destroy();return}t.session=un(e,n,a,l),i.active=!0,i.status="synced",i.readOnly=!t.session.canWrite,i.attachError="",et(n)}catch(a){i.status="failed",i.active=!1,i.attachError=a instanceof Error?a.message:String(a),k.warn(`Live collaboration is not available for "${n}" — ${i.attachError}`,{key:`collab:${n}`,path:n,source:"Collaboration"})}finally{t.attaching=null}})();t.attaching=s,await s}function te(e){let t=C(e);if(!t)return;t.generation+=1;let{session:n}=t;t.session=null;let o=xn(e);if(o.active=!1,o.status="detached",o.attachError="",o.peers=[],!n)return;if(tt(n.path),n.mirrorTimer)clearTimeout(n.mirrorTimer);if(n.sourceParseTimer)clearTimeout(n.sourceParseTimer);for(let r of n.disposers)try{r()}catch{}ym(e,null),e.history.snapshots=[{document:Ao(re(e.doc.document)),selection:ms(e.session.selection)}],e.history.index=0,n.undoManager?.destroy(),n.handle.destroy()}function un(e,t,n,o){let r=o.identity(),i={applyingRemoteFrontmatter:!1,batchNeedsDiff:!1,batchOps:null,canWrite:r?r.permission!=="read":!0,collab:n,disposers:[],handle:o,lastSeenRef:re(e.doc.document),mirrorTimer:null,path:t,sourceLockOwner:null,sourceParseTimer:null,synced:!1,tab:e,undoManager:null};if(n.metaMap(o.doc).get("structureSeeded")===!0){let h=n.yDocToJson(o.doc),x=Ao(re(e.doc.document));if(!n.deepEqual(h,x)){let w=n.diffDocs(x,h);if(w===null)i.synced=!0,fe(i),i.synced=!1;else if(w.length>0)ce(e,w)}i.applyingRemoteFrontmatter=!0;let T=n.frontmatterMap(o.doc);for(let[w,J]of T.entries())e.doc.content.frontmatter[w]=J;i.applyingRemoteFrontmatter=!1}else if(i.canWrite)n.seedStructure(o.doc,Ao(re(e.doc.document)),{frontmatter:Ao(re(e.doc.content.frontmatter)),origin:n.SEED_ORIGIN,sourceFormat:e.doc.sourceFormat});i.lastSeenRef=re(e.doc.document),i.disposers.push(o.onDirty((h)=>{e.doc.dirty=h})),o.awareness.setLocalState({canWrite:i.canWrite,focusedPath:t,structuralSelection:null,user:r?{avatarUrl:r.avatarUrl,color:r.color,login:r.login,name:r.name}:{color:n.colorForKey(String(o.awareness.clientID)),login:`guest-${o.awareness.clientID%1000}`}});let a=new n.UndoManager([n.structureMap(o.doc),n.frontmatterMap(o.doc)],{trackedOrigins:new Set([n.LOCAL_ORIGIN])});i.undoManager=a;let l=({stackItem:h})=>{h.meta.set("selection",ms(e.session.selection))},c=({stackItem:h})=>{let x=h.meta.get("selection");e.session.selection=ms(x??[])};a.on("stack-item-added",l),a.on("stack-item-popped",c),i.disposers.push(()=>{a.off("stack-item-added",l),a.off("stack-item-popped",c)}),ym(e,{canRedo:()=>a.canRedo(),canUndo:()=>a.canUndo(),redo:()=>{a.redo()},undo:()=>{a.undo()}});let d=n.structureMap(o.doc),g=(h,x)=>{if(x.origin===n.LOCAL_ORIGIN||!i.synced)return;let T=n.yEventsToDocOps(h);if(T===null){fe(i);return}if(T.length===0)return;try{ce(e,T)}catch{fe(i)}};d.observeDeep(g),i.disposers.push(()=>d.unobserveDeep(g));let y=xn(e);y.sourceCanonical=n.canonicalOf(o.doc)==="source";let b=n.metaMap(o.doc),_=()=>{y.sourceCanonical=n.canonicalOf(o.doc)==="source"};b.observe(_),i.disposers.push(()=>b.unobserve(_));let I=n.sourceText(o.doc),Oe=(h,x)=>{if(x.origin===n.MIRROR_ORIGIN||!i.synced)return;if(n.canonicalOf(o.doc)!=="source")return;if(!n.isSourceReconciler(o.awareness,i.path))return;if(i.sourceParseTimer)clearTimeout(i.sourceParseTimer);i.sourceParseTimer=setTimeout(()=>{i.sourceParseTimer=null,lt(i)},600)};I.observe(Oe),i.disposers.push(()=>I.unobserve(Oe));let A=n.frontmatterMap(o.doc),we=(h,x)=>{if(x.origin===n.LOCAL_ORIGIN||!i.synced)return;i.applyingRemoteFrontmatter=!0;try{for(let[T,w]of h.changes.keys)if(w.action==="delete")delete e.doc.content.frontmatter[T];else e.doc.content.frontmatter[T]=A.get(T)}finally{i.applyingRemoteFrontmatter=!1}};A.observe(we),i.disposers.push(()=>A.unobserve(we)),e.scope.run(()=>{let h=JSON.stringify(e.doc.content.frontmatter);Q(()=>{let x=JSON.stringify(e.doc.content.frontmatter);if(x===h)return;if(h=x,i.applyingRemoteFrontmatter||!i.synced||!i.canWrite)return;let T=JSON.parse(x);o.doc.transact(()=>{let w=[...A.keys()];for(let J of w)if(!(J in T))A.delete(J);for(let[J,Ce]of Object.entries(T))if(!n.deepEqual(A.get(J),Ce))A.set(J,Ce)},n.LOCAL_ORIGIN),ee(i)}),Q(()=>{let x=e.session.selection.length>0?ms(e.session.selection):null,T=o.awareness.getLocalState();if(T)o.awareness.setLocalState({...T,structuralSelection:x})}),Q(()=>{let x=re(e.doc.document);queueMicrotask(()=>{if(C(e)?.session!==i||!i.synced||!i.canWrite)return;let w=re(e.doc.document);if(w!==x||w===i.lastSeenRef)return;i.lastSeenRef=w,z(i),ee(i)})})});let oe=xn(e),ie=()=>{let h=[];for(let[x,T]of o.awareness.getStates())if(x!==o.awareness.clientID&&T.user)h.push({clientId:x,state:T});oe.peers=h};return ie(),o.awareness.on("change",ie),i.disposers.push(()=>o.awareness.off("change",ie),o.onStatus((h)=>{if(h==="offline"||h==="connecting")oe.status="offline";else if(i.synced)oe.status="synced"}),o.onReset(()=>{te(e),ve(e)})),i.synced=!0,i}function S(e,t,n){return RangeError(`command "${e}" argument "${t}": ${n}`)}function O(e){if(e===void 0)return"missing";return typeof e==="string"?`"${e}"`:`${typeof e} ${JSON.stringify(e)}`}function ot(e,t,n){let o=t[n];if(typeof o!=="string"||o==="")throw S(e,n,`expected a non-empty string, got ${O(o)}`);return o}function Jo(e,t,n){if(t[n]===void 0)return;return ot(e,t,n)}function dt(e,t,n){let o=t[n];if(typeof o!=="number"||!Number.isFinite(o))throw S(e,n,`expected a finite number, got ${O(o)}`);return o}function ut(e,t,n){let o=t[n];if(typeof o!=="number"||!Number.isInteger(o))throw S(e,n,`expected an integer, got ${O(o)}`);return o}function yv(e,t,n,o,r){let i=dt(e,t,n);if(i<o||i>r)throw S(e,n,`${i} is outside the supported range ${o}–${r}`);return i}function yi(e,t,n){let o=t[n];if(typeof o!=="boolean")throw S(e,n,`expected a boolean, got ${O(o)}`);return o}function li(e,t,n,o){let r=t[n];if(typeof r!=="string"||!o.includes(r))throw S(e,n,`${O(r)} is not declared — declared: ${o.join(", ")||"none"}`);return r}function $x(e,t,n){let o=t[n];if(!Array.isArray(o)||!o.every((r)=>typeof r==="string"||typeof r==="number"))throw S(e,n,`expected an array of path segments (strings or numbers), got ${O(o)}`);return o}function UL(e,t,n){if(t[n]===null)return null;return $x(e,t,n)}function UC(e,t,n){let o=t[n];if(!Array.isArray(o))throw S(e,n,`expected an array of document paths, got ${O(o)}`);return o.map((r,i)=>{if(!Array.isArray(r)||!r.every((s)=>typeof s==="string"||typeof s==="number"))throw S(e,n,`entry ${i} is not a document path — expected an array of segments, got ${O(r)}`);return r})}function Se(e,t=Object.keys(e)){return{additionalProperties:!1,properties:e,required:[...t],type:"object"}}function Do(e,t){return{description:t,enum:[...e],type:"string"}}function fa(e,t){return{description:t,get enum(){return[...e()]},type:"string"}}function qC(e,t={}){return{description:e,type:"number",...t}}function oo(e){return{description:e,type:"boolean"}}function wv(e,t=!1){let n={items:{type:["string","number"]},type:"array"};return t?{description:e,oneOf:[n,{type:"null"}]}:{description:e,...n}}function qL(e){return{description:e,items:{items:{type:["string","number"]},type:"array"},type:"array"}}function He(e){return{description:e,type:"string"}}function fn(e){return e.length===2&&e.includes("string")&&e.includes("number")}function Te(e){return Array.isArray(e)?e:[e]}function ft(e){let t=e;if("enum"in t)return"enum";if("const"in t)return"const";if(Array.isArray(t.oneOf))return"one-of";if(Array.isArray(t.type))return"typed";switch(t.type){case"boolean":return"boolean";case"number":case"integer":{if(t.minimum!==void 0&&t.maximum!==void 0)return"bounded-number";return t.type==="integer"?"integer":"number"}case"string":return"string";case"array":{let n=t.items?.type;if(Array.isArray(n))return fn(n)?"path":"pass-through";return n==="array"?"path-list":"pass-through"}case"null":case"object":return"typed";default:break}return"pass-through"}function pt(e,t){switch(e){case"null":return t===null;case"boolean":return typeof t==="boolean";case"string":return typeof t==="string";case"number":return typeof t==="number"&&Number.isFinite(t);case"integer":return typeof t==="number"&&Number.isInteger(t);case"array":return Array.isArray(t);case"object":return typeof t==="object"&&t!==null&&!Array.isArray(t);default:break}return!1}function mt(e){if(e.length<=1)return e.join("");return`${e.slice(0,-1).join(", ")} or ${e.at(-1)}`}function pn(e,t,n,o){let r=t[n];if(!o.some((i)=>pt(i,r)))throw S(e,n,`expected ${mt(o)}, got ${O(r)}`);return r}function gt(e){switch(ft(e)){case"enum":return`one of ${(e.enum??[]).map((t)=>O(t)).join(" | ")}`;case"const":return`the constant ${O(e.const)}`;case"one-of":return(e.oneOf??[]).map((t)=>gt(t)).join(" or ");case"typed":return mt(Te(e.type??[]));case"boolean":return"a boolean";case"bounded-number":return`a number from ${e.minimum} to ${e.maximum}`;case"number":return"a finite number";case"integer":return"an integer";case"string":return"a non-empty string";case"path":return"a document path";case"path-list":return"a list of document paths";default:return"anything"}}function mn(e,t,n,o){let r=t[n],i=[];for(let s of o){if(s.type!==void 0&&!Te(s.type).some((a)=>pt(a,r)))continue;try{return bt(e,t,n,s)}catch(a){i.push(a)}}if(i.length===1)throw i[0];throw S(e,n,`expected ${o.map((s)=>gt(s)).join(" or ")}, got ${O(r)}`)}function bt(e,t,n,o){switch(ft(o)){case"enum":return li(e,t,n,o.enum??[]);case"const":{let r=t[n];if(r!==o.const)throw S(e,n,`expected the constant ${O(o.const)}, got ${O(r)}`);return r}case"one-of":return mn(e,t,n,o.oneOf??[]);case"typed":return pn(e,t,n,Te(o.type??[]));case"boolean":return yi(e,t,n);case"bounded-number":{if(o.type==="integer")ut(e,t,n);return yv(e,t,n,o.minimum,o.maximum)}case"number":return dt(e,t,n);case"integer":return ut(e,t,n);case"string":return ot(e,t,n);case"path":return $x(e,t,n);case"path-list":return UC(e,t,n);default:return t[n]}}function GL(e,t,n){let o=t,r=o.properties??{},i=Object.keys(r),s=o.required??[],a={};for(let[l,c]of Object.entries(n)){if(c===void 0||Object.hasOwn(r,l))continue;if(o.additionalProperties===!1)throw S(e,l,`not declared — declared: ${i.join(", ")||"none"}`);a[l]=c}for(let l of i){if(n[l]===void 0&&!s.includes(l))continue;a[l]=bt(e,n,l,r[l])}return a}var gn=20,Qn="primary",vp="secondary",ZC=2,m=v({activePaneId:Qn,clipboard:null,closedTabs:[],componentRegistry:[],mruOrder:[],fileTree:{dirs:new Map,expanded:new Set,searchQuery:"",selectedPath:null},panes:[{activeTabId:null,derived:null,id:Qn,tabOrder:[]}],projectConfig:null,projectRoot:null,styleClipboard:null,tabs:new Map,ui:{activityBar:"files"},get activeTabId(){let e=Rr();return e.derived?.kind==="lens"?Hn(e.derived.sourcePaneId)?.activeTabId??null:e.activeTabId},get tabOrder(){return Rr().tabOrder}}),u=zd(()=>m.activeTabId?m.tabs.get(m.activeTabId)??null:null);function Rr(){let{panes:e}=m;return e.find((t)=>t.id===m.activePaneId)??e[0]}function Hn(e){return m.panes.find((t)=>t.id===e)}function Gu(e){return m.panes.find((t)=>t.tabOrder.includes(e))}function $r(e){let t=Hn(e);if(!t||t.id===m.activePaneId)return;m.activePaneId=t.id,R();let{activeTabId:n}=t;if(n){Pe(n);let o=m.tabs.get(n);if(o)vt(o)}}function yp(e){return m.activePaneId===e}function Ox(e){let t=e??Rr().activeTabId,n=t?m.tabs.get(t):null;if(!t||!n)return null;let o=Gu(t);if(!o)return null;let r=Pl(o.id);return _p(t),Ku(r,t),r.activeTabId=t,m.activePaneId=r.id,R(),Pe(t),r}function Mx(e){return m.panes.find((t)=>t.id!==e)??bn(vp)}function Pl(e){let t=Mx(e);if(t.derived)t.derived=null;return t}function bn(e){let t=Hn(e);if(t)return t;return m.panes=[...m.panes,{activeTabId:null,derived:null,id:e,tabOrder:[]}],Hn(e)}function wp(e){if(m.panes.length<2)return;let t=e===Qn?m.panes.find((r)=>r.id!==Qn)?.id:e,n=t===void 0?void 0:Hn(t),o=m.panes.find((r)=>r.id!==t);if(!n||!o)return;for(let r of n.tabOrder)Ku(o,r);if(o.activeTabId=m.activePaneId===n.id?n.activeTabId??o.activeTabId:o.activeTabId??n.activeTabId,m.activePaneId=o.id,o.derived?.sourcePaneId===n.id)o.derived=null;m.panes=m.panes.filter((r)=>r.id!==n.id),R()}function xp(e){return e.tabOrder.length===0&&e.derived===null}function _p(e){let t=[];for(let n of m.panes){if(!n.tabOrder.includes(e))continue;if(n.tabOrder=n.tabOrder.filter((o)=>o!==e),n.activeTabId===e)n.activeTabId=n.tabOrder.at(-1)??null;if(n.id!==Qn&&xp(n))t.push(n.id)}for(let n of t)wp(n)}function Ku(e,t,n){if(e.tabOrder.includes(t))return;let o=n??hn(e,t);e.tabOrder=[...e.tabOrder.slice(0,o),t,...e.tabOrder.slice(o)]}function yn(e){let t=0;for(let n of e.tabOrder){if(m.tabs.get(n)?.pinned!==!0)break;t+=1}return t}function hn(e,t){return m.tabs.get(t)?.pinned===!0?yn(e):e.tabOrder.length}function Ua(e,t=null){if(m.projectRoot&&e!==m.projectRoot)Lx();m.projectRoot=e,m.projectConfig=t}function Cp(e){let t=u.value;return e!==null&&t!==null&&re(t)===re(e)}function Sc(e){if(!e)return!1;let t=m.tabs.get(e.id);return t!==void 0&&re(t)===re(e)}function Pe(e){m.mruOrder=[e,...m.mruOrder.filter((t)=>t!==e)]}var ne=null,Z=0;function R(){ne=null,Z=0}function vt(e){if(D&&e.documentPath)D.selectedPath=e.documentPath}function X(e,t={}){let n=m.tabs.get(e),o=Gu(e);if(!n||!o)return;if(o.activeTabId=e,t.focus===!1)return;if(m.activePaneId=o.id,!t.cycling)R(),Pe(e);vt(n)}function No(e){let t=m.tabs.get(e.id),n=e.preview===!0&&t?.pinned!==!0,o=cv({...e,preview:n}),r=(e.paneId===void 0?void 0:Hn(e.paneId))??Rr(),i;if(t)o.pinned=t.pinned,fp(t);else{if(n){let a=yt(r),l=a?m.tabs.get(a):null;if(l)kp(l);Px()}let s=n?yt(r):null;if(s)i=r.tabOrder.indexOf(s),Fx(s);Ku(r,o.id,i)}return m.tabs.set(o.id,o),X(o.id,{focus:e.focus!==!1}),Y(o),o}function yt(e){return e.tabOrder.find((t)=>m.tabs.get(t)?.preview===!0)??null}function Fl(e){let t=m.tabs.get(e);if(t?.preview===!0)t.preview=!1}function Px(){for(let[e,t]of m.tabs)if(t.preview&&t.doc.dirty)Fl(e)}function kv(e,t){let n=m.tabs.get(e),o=Gu(e);if(!n||!o)return;if(n.pinned=t,t)n.preview=!1;let r=o.tabOrder.filter((s)=>s!==e),i=r.filter((s)=>m.tabs.get(s)?.pinned===!0).length;o.tabOrder=[...r.slice(0,i),e,...r.slice(i)]}function XC(e,t){let n=m.tabs.get(e),o=Gu(e);if(!n||!o)return;o.tabOrder=Tt(o,e,t)}function Tt(e,t,n){let o=m.tabs.get(t);if(!o)return e.tabOrder;let r=e.tabOrder.filter((c)=>c!==t),i=r.filter((c)=>m.tabs.get(c)?.pinned===!0).length,s=o.pinned?0:i,a=o.pinned?i:r.length,l=Math.min(Math.max(n,s),a);return[...r.slice(0,l),t,...r.slice(l)]}function Fx(e){let t=m.tabs.get(e);if(!t)return;let n=Gu(e),o=n?.activeTabId===e;if(vn(t),fp(t),m.tabs.delete(e),_p(e),m.mruOrder=m.mruOrder.filter((s)=>s!==e),R(),n&&xp(n))wp(n.id);if(!o)return;let r=Rr(),i=m.mruOrder.find((s)=>r.tabOrder.includes(s))??r.tabOrder.at(-1)??null;if(i)X(i)}function QC(){let e=[...m.tabs.values()];m.tabs.clear(),Pt(),m.mruOrder=[],R();for(let t of e)fp(t)}function Pt(){m.panes=[{activeTabId:null,derived:null,id:Qn,tabOrder:[]}],m.activePaneId=Qn}function vn(e){if(!e.documentPath)return;let t=e.documentPath;m.closedTabs=[{documentPath:t},...m.closedTabs.filter((n)=>n.documentPath!==t)].slice(0,gn)}function Tn(){let[e]=m.closedTabs;if(!e)return;return m.closedTabs=m.closedTabs.slice(1),e.documentPath}function xt(e){if(!ne)ne=m.mruOrder.filter((o)=>m.tabs.has(o)),Z=0;let t=ne;if(t.length<2)return;Z=((Z+e)%t.length+t.length)%t.length;let n=t[Z];return X(n,{cycling:!0}),n}function ek(e){let t=[...m.tabs.keys()],n=[...m.tabs.values()],o=cv(e);m.tabs.set(o.id,o),Pt(),m.panes[0].tabOrder=[o.id],m.mruOrder=[],R(),X(o.id),Y(o);for(let r of t){if(r===o.id)continue;m.tabs.delete(r)}for(let r of n)fp(r);return o}function ci(e,t={}){X(e,t)}function Cm(e,t,n){let o=Hn(t);if(!o||!m.tabs.has(e))return null;if(o.tabOrder.includes(e)){if(n!==void 0)o.tabOrder=Tt(o,e,n);return o}return _p(e),Ku(o,e,n),o}function Sv(e,t,n){let o=m.tabs.get(e);if(!o)return;o.id=t,o.documentPath=n,m.tabs.delete(e),m.tabs.set(t,o);for(let r of m.panes)if(r.tabOrder=r.tabOrder.map((i)=>i===e?t:i),r.activeTabId===e)r.activeTabId=t;m.mruOrder=m.mruOrder.map((r)=>r===e?t:r),R(),ct(o)}function tk(e,t){e.registerAll([...Pn(t),...On(t)])}function Pn(e){let t=()=>m.tabs.size>1;return[{id:"document.nextTab",title:"Next Tab",category:"Document",level:"document",keybinding:["ctrl+tab","mod+tab"],menus:["palette"],group:"2_navigate",when:(n)=>n.document.open,enablement:t,requires:"a second open document",run:()=>{xt(1)}},{id:"document.previousTab",title:"Previous Tab",category:"Document",level:"document",keybinding:["ctrl+shift+tab","mod+shift+tab"],menus:["palette"],group:"2_navigate",when:(n)=>n.document.open,enablement:t,requires:"a second open document",run:()=>{xt(-1)}},{args:Se({path:He('Project-relative path of the file to open, e.g. "pages/about.json" or "components/nav-bar.json". It must exist.')}),id:"document.open",title:"Open Document",category:"Document",level:"project",menus:["palette"],group:"1_file",when:(n)=>n.project.open,requires:"an open project",aiTool:{description:"Open a project file as the active document; the document tools then operate on it. Use it when the user should SEE the page, or for iterative visual refinement after creating a page or component.",name:"open_document",report:({after:n,args:o})=>{let r=ot("document.open",o,"path"),i=u.value?.documentPath??null;if(i!==r)return`Opened "${r}", but the active document is ${i===null?"none":`"${i}"`}.`;let s=n.editor.kind==="canvas"?"on the canvas; the document tools now operate on it":`in the ${ov[n.editor.kind]} editor, which is not an element tree the document tools can edit`;return`"${r}" is the active document, ${s}.`}},run:async(n,o)=>{let r=ot("document.open",o,"path");if(await e.openFile(r),![...m.tabs.values()].some((i)=>i.documentPath===r))throw RangeError(`command "document.open" argument "path": "${r}" could not be opened — it does `+"not exist, or no editor claims its format. Problems has the reason.")}},{args:Se({file:He('Project-relative path of the file to open in the other pane, e.g. "pages/about.json". It must exist.')}),id:"document.openToSide",title:"Open to the Side",category:"Document",level:"project",menus:["context/file","palette"],group:"1_file",when:(n)=>n.project.open,requires:"an open project",undo:"none",run:async(n,o)=>{let r=ot("document.openToSide",o,"file"),i=Pl(Rr().id);if(await e.openFile(r,{paneId:i.id}),![...m.tabs.values()].some((s)=>s.documentPath===r)){if(xp(i)&&i.id!==Qn)wp(i.id);throw RangeError(`command "document.openToSide" argument "file": "${r}" could not be opened — it `+"does not exist, or no editor claims its format. Problems has the reason.")}}},{id:"document.reopenClosed",title:"Reopen Closed Document",category:"Document",level:"document",keybinding:"mod+shift+t",menus:["context/tab","palette"],group:"1_file",enablement:()=>m.closedTabs.length>0,requires:"a document closed in this session",run:async()=>{let n=Tn();if(n)await e.openFile(n)}},{id:"document.togglePinned",title:"Pin / Unpin Document",category:"Document",level:"document",menus:["context/tab","palette"],group:"1_file",when:(n)=>n.document.open,requires:"an open document",run:()=>{let n=m.activeTabId,o=n?m.tabs.get(n):null;if(n&&o)kv(n,!o.pinned)}},{args:Se({pinned:oo("True to pin the active document's tab, false to unpin it.")}),id:"document.setPinned",title:"Set Document Pinned",category:"Document",level:"document",menus:["palette"],group:"1_file",when:(n)=>n.document.open,requires:"an open document",run:(n,o)=>{let r=m.activeTabId;if(r&&m.tabs.get(r))kv(r,yi("document.setPinned",o,"pinned"))}},{id:"document.keepOpen",title:"Keep Document Open",category:"Document",level:"document",menus:["context/tab","palette"],group:"1_file",when:(n)=>n.document.open,enablement:()=>{let n=m.activeTabId;return n!==null&&m.tabs.get(n)?.preview===!0},requires:"a preview document — one opened by a single click",run:()=>{let n=m.activeTabId;if(n)Fl(n)}}]}function On(e){let t=()=>m.panes.length>1;return[{id:"pane.splitRight",title:"Split Right",category:"View",level:"document",keybinding:"mod+\\",menus:["context/pane","context/tab","palette"],group:"5_pane",when:(n)=>n.document.open,enablement:()=>m.activeTabId!==null,requires:"an open document",undo:"none",run:()=>{Ox()}},{args:Se({path:He("Project-relative path of the document to open beside this one.")}),id:"pane.compareWith",title:"Compare With…",category:"View",level:"document",menus:["context/pane","context/tab","palette"],group:"5_pane",when:(n)=>n.document.open,enablement:()=>m.activeTabId!==null,requires:"an open document",undo:"none",run:async(n,o)=>{let r=ot("pane.compareWith",o,"path"),i=Rr();if((i.activeTabId?m.tabs.get(i.activeTabId):null)?.documentPath===r)throw RangeError(`command "pane.compareWith" argument "path": "${r}" is the document this pane is `+"already showing — name a different one");await e.openFileInPane(Pl(i.id).id,r)}},{id:"pane.focusPrimary",title:"Focus Primary Pane",category:"View",level:"document",keybinding:"mod+0",menus:["palette"],group:"5_pane",enablement:t,requires:"a split pane grid",undo:"none",run:()=>{$r(Qn)}},{id:"pane.focusSecondary",title:"Focus Side Pane",category:"View",level:"document",keybinding:"mod+alt+0",menus:["palette"],group:"5_pane",enablement:t,requires:"a split pane grid",undo:"none",run:()=>{$r(vp)}},{id:"pane.unsplit",title:"Close Side Pane",category:"View",level:"document",menus:["context/pane","palette"],group:"5_pane",enablement:t,requires:"a second pane",undo:"none",run:wn}]}function wn(){let e=m.panes.find((t)=>t.derived!==null);if(e?.id===Qn){if(e.derived=null,!xp(e))return}wp(e?.id??vp)}
|
|
2
|
-
export{
|
|
1
|
+
import{ge,Qa,Q,v,re,Wd,k}from"./studio-vzacdfsc.js";import{Sp}from"./studio-z8w183sh.js";import{p}from"./studio-qpqa7vk3.js";import{wi,Zt,Dr}from"./studio-tt2nactf.js";import{K,Im,ht,_n,Yo,Ga,D}from"./studio-wgh5kxpj.js";import{Ae,Rc,Rm,dk}from"./studio-2sqcndak.js";import{va,rh,sh}from"./studio-8mb00b84.js";import{me}from"./studio-v2bvmbjj.js";function ym(e,t){return{success:!0,data:e,summary:t}}function zi(e){return{success:!1,error:e}}function Ki({name:e,description:t,parameters:n,strict:o=!0,llmStrict:r=!1,interactive:i,execute:s}){return{name:e,description:t,parameters:n,strict:o,llmStrict:r,...i===void 0?{}:{interactive:i},execute:s}}function lv(e){let t=[];return{record(n){t.push(n),e?.(n)},writes:t}}function Ad(e=null,t={}){let n=new Map(Object.entries(t));return{sessionId:e,get:(o)=>n.get(o),set:(o,r)=>{n.set(o,r)},toJSON:()=>Object.fromEntries(n)}}var Ot=new AbortController().signal;function cv(e={}){let t=e.session??Ad();return{actor:e.actor??{id:`assistant:${t.sessionId??"local"}:`,kind:"assistant",sessionId:t.sessionId,turnId:""},callId:e.callId??"",ledger:e.ledger??lv(),progress:e.progress??(()=>{}),session:t,signal:e.signal??Ot}}function _L(e){let t=new AbortController;if(e.aborted)return t.abort(e.reason),{release:()=>{},signal:t.signal};let n=()=>{t.abort(e.reason)};return e.addEventListener("abort",n,{once:!0}),{release:()=>{e.removeEventListener("abort",n)},signal:t.signal}}function VC(){let e=new Map;return{register(t){if(e.has(t.name))console.warn(`Tool "${t.name}" is being re-registered.`);e.set(t.name,t)},list(){return[...e.values()]},listForLLM(){return[...e.values()].map((t)=>({type:"function",function:{name:t.name,description:t.description,parameters:t.parameters,...t.llmStrict===!0?{strict:!0}:{}}}))},getDefinition(t){return e.get(t)},validate(t,n){let o=e.get(t);if(!o)return{valid:!1,errors:[`Unknown tool: "${t}"`]};if(!o.strict)return{valid:!0};let r=o.parameters;if(!r||!r.properties)return{valid:!0};let i=[],s=r.properties,a=r.required||[],l=n;for(let c of a)if(!(c in n)||l[c]===void 0||l[c]===null)i.push(`Missing required argument: "${c}"`);for(let[c,d]of Object.entries(l)){let g=s[c];if(!g)continue;let y=g.type;if(!y)continue;let b=Array.isArray(d)?"array":typeof d;if(y==="number"||y==="integer"){if(b==="number")continue;if(b==="string"){if(!Number.isNaN(Number(d)))continue;i.push(`Argument "${c}" should be a number, got non-numeric string "${d}"`);continue}i.push(`Argument "${c}" should be a number, got ${b}`);continue}if(y==="string"&&b!=="string")i.push(`Argument "${c}" should be a string, got ${b}`);else if(y==="boolean"&&b!=="boolean")i.push(`Argument "${c}" should be a boolean, got ${b}`);else if(y==="array"&&b!=="array")i.push(`Argument "${c}" should be an array, got ${b}`);else if(y==="object"&&b!=="object")i.push(`Argument "${c}" should be an object, got ${b}`)}return i.length>0?{valid:!1,errors:i}:{valid:!0}},async execute(t,n,o=cv()){let r=e.get(t);if(!r)return zi(`Unknown tool: "${t}"`);let i=this.validate(t,n);if(!i.valid)return zi(`Validation failed: ${(i.errors||[]).join("; ")}`);try{return await r.execute(n,o)}catch(s){return zi(`Tool "${t}" execution error: ${s.message}`)}}}}function wt(e){return JSON.parse(JSON.stringify(e))}function St(e){if(!e)return{};let t=JSON.parse(e);if(t===null||typeof t!=="object"||Array.isArray(t)){let n=t===null?"null":Array.isArray(t)?"array":typeof t;throw TypeError(`arguments must be a JSON object, got ${n}`)}return t}async function CL(e,t,n){let o=!1,r;try{let i=St(t.argumentsText);o=!0,r=await e.execute(t.name,i,n)}catch(i){r=zi(`Failed to parse arguments: ${i.message}`)}try{return{status:"done",result:wt(r),executed:o}}catch(i){let s=i.message;return{status:"done",result:zi(`Tool "${t.name}" returned a result that cannot be serialized: ${s}`),executed:o}}}var F=[],Ct=50;function kL(e){return Object.assign(lv(),{turnId:e})}function SL(e,t){if(t.length===0)return[];let n={id:e,writes:[...t]};F.push(n);while(F.length>Ct)F.shift();return n.writes}function Lx(e){return F.find((t)=>t.id===e)?.writes??[]}function EL(e){let t=e.filter((a)=>a.ok),n=new Set(t.map((a)=>a.path)),o=e.length-t.length;if(n.size===0)return o>0?`${o} change${o===1?"":"s"} failed`:"";let r=`Changed ${n.size} file${n.size===1?"":"s"}`,i=new Set(t.filter((a)=>a.disk).map((a)=>a.path)),s=[r];if(i.size>0)s.push(`${i.size} written to disk — undo cannot reach ${i.size===1?"it":"them"}`);if(o>0)s.push(`${o} failed`);return s.join(" · ")}function Ix(){F.splice(0)}function TL(e,t){let n=null;for(let o=e.length-1;o>=0;o--){let r=e[o];if(r.id===t)return n;let i=r.role==="assistant"&&(r.content||(r.toolCalls?.length??0)>0);if(n===null&&i)n=r.id}return t===void 0?n:null}var Rt=new Set(["Adlm","Arab","Aran","Armi","Avst","Cprt","Egyd","Egyh","Elym","Gara","Hatr","Hebr","Hluw","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogd","Sogo","Syrc","Thaa","Todr","Yezi"]),Ex="^[A-Za-z]{2,8}(-[A-Za-z0-9]{1,8})*$";function Go(e){if(typeof e!=="string"||e.trim()==="")return null;try{return new Intl.Locale(e.trim()).toString()}catch{return null}}function ov(e){return Go(e)!==null}function vL(e){let t=Go(e);if(t===null)return"ltr";let n=new Intl.Locale(t),o=n.script??n.maximize().script;return o!==void 0&&Rt.has(o)?"rtl":"ltr"}function dn(e){let t=Go(e);if(t===null)return typeof e==="string"?e:"";return new Intl.DisplayNames([t],{type:"language"}).of(t)??t}var At="prefix-except-default";function $o(e){let t=e.i18n,n=[];if(!t||typeof t!=="object")return{errors:n,i18n:null};let o=Array.isArray(t.locales)?t.locales:[],r=[];for(let a of o){let l=Go(a);if(l===null){n.push(`i18n.locales: "${String(a)}" is not a well-formed BCP 47 language tag.`);continue}if(!r.includes(l))r.push(l)}let i=Go(t.defaultLocale)??r[0]??null;if(t.defaultLocale!==void 0&&Go(t.defaultLocale)===null)n.push(`i18n.defaultLocale: "${String(t.defaultLocale)}" is not a well-formed BCP 47 language tag.`);if(i===null)return n.push("i18n is declared with no usable locale — set `defaultLocale` or `locales`."),{errors:n,i18n:null};if(!r.includes(i))r.unshift(i);let s=t.routing==="prefix-always"||t.routing==="prefix-except-default"?t.routing:At;return{errors:n,i18n:{defaultLocale:i,locales:r,routing:s}}}function Wu(e,t){let n=se(W(e),t);if(n===-1||t===null)return null;return Go(W(e)[n])}function yL(e,t){let n=Wu(e,t);if(n!==null||t===null||t.routing!=="prefix-except-default")return n;return W(e)[0]==="pages"?t.defaultLocale:null}function WC(e,t){let n=W(e),o=se(n,t);return o===-1?n.join("/"):n.filter((r,i)=>i!==o).join("/")}function Vu(e,t,n){if(n===null)return null;let o=Go(t);if(o===null||!n.locales.includes(o))return null;let r=W(e),i=se(r,n),s=i===-1?kt(r):i;if(s===-1)return null;let a=i===-1?r:r.filter((l,c)=>c!==i);if(o===n.defaultLocale&&n.routing==="prefix-except-default")return a.join("/");return a.toSpliced(s,0,o.toLowerCase()).join("/")}function W(e){return e.replace(/^\.\//,"").split("/").filter(Boolean)}function se(e,t){if(t===null)return-1;return e.findIndex((n)=>{let o=Go(n);return o!==null&&t.locales.includes(o)})}function kt(e){if(e[0]==="pages"&&e.length>1)return 1;if(e[0]==="content"&&e.length>2)return 2;return-1}var Ax="{locale}";function Re(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}function B(e){return e.replaceAll("\\","/").replace(/^\.\//,"").replace(/\/+$/,"")}function ke(e){return e??D?.projectConfig??null}function Je(e){return e?.content??{}}function Jt(e){let t=$o(e??{}).i18n?.locales??[];return t.length>0?[...t]:null}function je(e){if(e.endsWith("/"))return!1;let t=e.slice(e.lastIndexOf("/")+1);return/\.[a-z\d]+$/i.test(t)}function Ie(e){if(e.format==="json")return{ext:".json",unresolvedFormat:null};if(e.format===void 0||e.format==="")return{ext:Dr()?.extensions[0]??".json",unresolvedFormat:null};let t=wi(e.format);return t?.extensions[0]===void 0?{ext:null,unresolvedFormat:e.format}:{ext:t.extensions[0],unresolvedFormat:null}}function jt(e,t){let n=t===null?"[^/]+":`(?:${t.map((r)=>Re(r)).join("|")})`,o=B(e).split(Ax).map((r)=>Re(r)).join(n);return new RegExp(`^${o}(?:/|$)`,"i")}function It(e,t,n){let o=jt(e,n).exec(t);if(!o)return null;return o[0].replace(/\/$/,"")}function Dt(e){return B(e).replaceAll(Ax,"").length}function vp(e,t){if(e===null||e===void 0||e==="")return null;let n=ke(t),o=Jt(n),r=B(e),i=null,s=-1;for(let[a,l]of Object.entries(Je(n))){let{source:c}=l;if(c===void 0||c===""||je(c))continue;let d=Dt(c);if(d<=s)continue;let g=It(c,r,o);if(g===null)continue;i={def:l,dir:r,fileBacked:!1,isSourceRoot:r.length===g.length,name:a,...Ie(l)},s=d}return i}function Nx(e,t){if(e===null||e===void 0||e==="")return null;let n=ke(t),o=B(e),r=o.toLowerCase();for(let[i,s]of Object.entries(Je(n))){let{source:a}=s;if(a===void 0||a===""||!je(a))continue;let l=B(a).toLowerCase();if(r===l||r.endsWith(`/${l}`))return{def:s,dir:o.includes("/")?o.slice(0,o.lastIndexOf("/")):".",fileBacked:!0,isSourceRoot:!1,name:i,...Ie(s)}}return vp(o.includes("/")?o.slice(0,o.lastIndexOf("/")):".",n)}function Pl(e){return e.replaceAll(/([A-Z])/g," $1").replace(/^./,(t)=>t.toUpperCase())}function _v(e){return e.replaceAll(/[^a-zA-Z0-9]+(.)?/g,(t,n)=>n?n.toUpperCase():"").replace(/^[A-Z]/,(t)=>t.toLowerCase())}function Cv(e){return e.replaceAll(/(^|-)(\w)/g,(t,n,o)=>(n?" ":"")+o.toUpperCase())}function Ox(e,t){return e?.$label||Pl(t)}function YL(e,t){if(e?.$label)return e.$label;if(t.includes("-"))return t.replaceAll(/(^|-)(\w)/g,(n,o,r)=>(o?" ":"")+r.toUpperCase());return Pl(t)}function ma(e){return e==="image"||e==="uri-reference"}function Nd(e){if(e.$shorthand===!0)return"shorthand";if(e.$input==="button-group")return"button-group";if(e.$input==="media")return"media";if(e.format==="color")return"color";if(ma(e.format))return"media";if(e.$units!==void 0)return"number-unit";if(e.type==="number")return"number";if(Array.isArray(e.enum))return"select";if(Array.isArray(e.examples)||Array.isArray(e.presets))return"combobox";return"text"}function Gu(e,t){if(!e||!t?.content)return null;let n=Nx(e,t);if(!n||!n.def.schema)return null;if(!n.fileBacked){let o=n.ext??Dr()?.extensions[0]??".json";if(!e.toLowerCase().endsWith(o.toLowerCase()))return null}return{name:n.name,schema:n.def.schema}}function _m(e,t){let n=e.trim().toLowerCase().replaceAll(/[^a-z0-9\s-]/g,"").replaceAll(/\s+/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,"");if(!n)return"";return`${t}${n}`}function kv(e,t){return e.replace(new RegExp(`^${t.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}`),"").replace(/^--/,"").replaceAll("-"," ").replaceAll(/\b\w/g,(n)=>n.toUpperCase())||e}function ZL(e){if(!e)return{kind:"text"};let t=e.trim().replaceAll(/\s*\|\s*undefined\b/g,"").trim();if(t==="boolean")return{kind:"boolean"};if(t==="number")return{kind:"number"};if(t.match(/^'[^']*'(\s*\|\s*'[^']*')+$/))return{kind:"combobox",options:[...t.matchAll(/'([^']*)'/g)].map((r)=>r[1])};return{kind:"text"}}function Ao(e){return JSON.parse(JSON.stringify(e))}function Le(e){return e&&e.length>0?e.at(-1):null}function RL(e){return e&&e.length>0?e[0]:null}function uv(e,t){if(!t||!e)return!1;return e.some((n)=>Yo(n,t))}function ms(e){return E(e)}function E(e){let t=[];for(let n of e)t.push([...n]);return t}function hv(e,t){if(uv(e,t))return E(e.filter((n)=>!Yo(n,t)));return[...E(e),[...t]]}function $L(e,t,n){let o=e.findIndex((s)=>Yo(s,n)),r=t?e.findIndex((s)=>Yo(s,t)):-1;if(o===-1||r===-1)return[[...n]];let i=r<=o?e.slice(r,o+1):e.slice(o,r+1).toReversed();return E(i)}function De(e,t){return E(e.filter((n)=>!Ga(t,n)))}function Et(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 r-i;return String(r)<String(i)?-1:1}return e.length-t.length}function Lt(e){return E(e.filter((t)=>!e.some((n)=>!Yo(n,t)&&Ga(n,t))))}function Ol(e){return e.at(-2)==="children"&&typeof e.at(-1)==="number"}function pv(e){return Lt(e).filter((t)=>Ol(t)).toSorted((t,n)=>Et(n,t))}function DL(e){let t=[];for(let n of e)if(!t.some((o)=>Yo(o,n)))t.push([...n]);return t}function gp(e){if(e.length===0)return{mixed:!1,value:void 0};let t=e[0],n=JSON.stringify(t??null);for(let o=1;o<e.length;o++)if(JSON.stringify(e[o]??null)!==n)return{mixed:!0,value:void 0};return{mixed:!1,value:t}}var Ee=null;function AL(e){Ee=e}function Me(){return Ee}var V=null,U=null,G=null,ae=!0;function $e(){V=[],U=[],G=[],ae=!0}function f(e){if(V)V.push(e)}function vi(e){if(U)U.push(e)}function Ne(e){if(G)G.push(e)}function _e(){let e={docOps:U??[],fmOps:G??[],invertible:ae,ops:V??[]};return V=null,U=null,G=null,ae=!0,e}var Fe=100,Mt=20;function H(){try{return typeof localStorage>"u"||!localStorage.getItem("jx-legacy-history")}catch{return!0}}function P(e,t,n,o){return{forward:{key:t,op:"set-key",path:e,value:o},inverse:{key:t,op:"set-key",path:e,value:n}}}function $t(e,t,n,o,r){let i=e.length;if(!(i<t.length&&e.every((c,d)=>c===t[d]))||t[i]!=="children"||typeof t[i+1]!=="number")return t;let a=t[i+1];if(r?a<n:a<=n)return t;let l=[...t];return l[i+1]=a+o,l}var We=null;function Be(e){We=e}var Ve=null;function Ke(e){Ve=e}function Nt(e,t,n,o){for(let r=t.docOps.length-1;r>=0;r--)Rm(e.doc.document,re(t.docOps[r].inverse));for(let r=t.fmOps.length-1;r>=0;r--){let i=t.fmOps[r];de(e,i.field,i.before)}e.doc.document={...re(e.doc.document)},e.session.selection=n,e.doc.dirty=o}function q(e,t,{skipHistory:n=!1,origin:o="user",coalesceKey:r=null}={}){if(!e)return!1;if(o!=="remote"&&Ve?.(e,o))return!1;let i=ms(e.session.selection),s=e.doc.dirty;$e();let a,l=null;try{t(e)}catch(b){l={error:b}}finally{a=_e()}if(l)throw Nt(e,a,i,s),l.error;let c=re(e.doc.document),d={...c},g=Me(),y=g===null?{patchable:!1,reason:"no-patch-consumer"}:a.ops.length===0?{patchable:!1,reason:"unrecorded-mutation"}:g.classify(e,a.ops);if(y.patchable)g.markConsumed(d,e);if(e.doc.document=d,y.patchable)try{g.apply(e,a.ops,a)}catch(b){g.escalate(`patch-apply-failed: ${b instanceof Error?b.message:String(b)}`,e)}if(!n&&!L)_t(e,c,a,i,r);return e.doc.dirty=!0,We?.(e,a,o),!0}function _t(e,t,n,o,r=null){let i=e.history.snapshots.slice(0,e.history.index+1),s=H()&&n.invertible&&(n.docOps.length>0||n.fmOps.length>0),a=i.at(-1);if(r&&s&&a&&a.coalesceKey===r&&a.inverseOps){if(a.forwardOps=[...a.forwardOps??[],...n.docOps.map((c)=>c.forward)],a.inverseOps=[...a.inverseOps,...n.docOps.map((c)=>c.inverse)],a.selection=ms(e.session.selection),a.document)a.document=Ao(t);e.history.snapshots=i,e.history.index=i.length-1;return}let l=!s||i.length%Mt===0;if(i.push({document:l?Ao(t):null,fmOps:s&&n.fmOps.length>0?n.fmOps:null,forwardOps:s?n.docOps.map((c)=>c.forward):null,inverseOps:s?n.docOps.map((c)=>c.inverse):null,coalesceKey:r,selection:ms(e.session.selection),selectionBefore:o}),i.length>Fe){if(!i[1].document)i[1].document=le(i,1);i.shift()}e.history.snapshots=i,e.history.index=i.length-1}function le(e,t){let n=t;while(n>=0&&!e[n].document)n-=1;if(n<0)throw Error("history-missing-checkpoint");let o=Ao(e[n].document);for(let r=n+1;r<=t;r++)for(let i of e[r].forwardOps??[])Rm(o,i);return o}function Hs(e,t,n){return q(e,(o)=>t(o.doc.document),n)}function ce(e,t){q(e,(n)=>{for(let o of t)ue(n,o)},{origin:"remote",skipHistory:!0})}var Ft=new Set(["state","$media","$head","$elements","imports","$layout"]);function ue(e,t){let n=t.op==="set-key"?K(e.doc.document,t.path)?.[t.key]:null;switch(Rm(e.doc.document,t),vi({forward:t,inverse:t}),t.op){case"set-key":{if(Ft.has(t.key))f({key:t.key,op:"doc-meta"});else if(t.key==="style")f({op:"set-style",path:t.path});else if(t.key==="textContent")f({op:"set-text",path:t.path});else if(t.key==="attributes"||t.key==="cases"||t.key==="$props")f({op:"replace",path:t.path});else{let o=t.key.startsWith("on")&&(sh(t.value)||sh(n));f({isEvent:o,key:t.key,op:"set-prop",path:t.path})}return}case"insert-child":{f({index:t.index,op:"insert",parentPath:t.parentPath});return}case"remove-child":{f({op:"remove",path:[...t.parentPath,"children",t.index]});return}case"set-child":{f({op:"replace",path:[...t.parentPath,"children",t.index]});return}case"move-child":{f({fromPath:[...t.fromParentPath,"children",t.fromIndex],op:"move",toIndex:t.toIndex,toParentPath:t.toParentPath});break}default:break}}var L=null,Ge=null;function qe(e){Ge=e}function fv(e){L=e}function mv(){let e=L;if(e&&!j.has(e)){let t=re(e.doc.document),n={document:Ao(t),selection:ms(e.session.selection)},o=e.history.snapshots.slice(0,e.history.index+1);if(o.push(n),o.length>Fe)o.shift();e.history.snapshots=o,e.history.index=o.length-1}if(L=null,e)Ge?.(e)}function Rx(){return L!==null}function NL(){return L}var j=new WeakMap;function wm(e,t){if(t)j.set(e,t);else j.delete(e)}function OL(e){let t=j.get(e);return t?t.canUndo(e):e.history.index>0}function ML(e){let t=j.get(e);return t?t.canRedo(e):e.history.index<e.history.snapshots.length-1}function ze(e,t){let{snapshots:n}=e.history;e.doc.document=le(n,t);let o=n[t];e.session.selection=ms(re(o.selection))}function Ye(e,t){try{if(typeof localStorage>"u"||!localStorage.getItem("jx-canvas-debug"))return}catch{return}let n=JSON.stringify(le(e.history.snapshots,t)),o=JSON.stringify(Ao(re(e.doc.document)));if(n!==o)console.error("jx history: ops-based undo/redo diverged from checkpoint replay",{index:t})}function $x(e){let t=j.get(e);if(t){t.undo(e);return}if(e.history.index<=0)return;let n=e.history.snapshots[e.history.index],o=H()?n.inverseOps:null,r=H()?n.fmOps:null;if(o&&o.length>0||r&&r.length>0){if(!q(e,(s)=>{if(o)for(let a=o.length-1;a>=0;a--)ue(s,re(o[a]));if(r)for(let a=r.length-1;a>=0;a--){let l=re(r[a]);de(s,l.field,l.before)}},{origin:"history",skipHistory:!0}))return;e.session.selection=ms(re(n.selectionBefore??[])),e.history.index-=1,Ye(e,e.history.index)}else e.history.index-=1,ze(e,e.history.index);e.doc.dirty=!0}function PL(e){let t=j.get(e);if(t){t.redo(e);return}if(e.history.index>=e.history.snapshots.length-1)return;let n=e.history.snapshots[e.history.index+1],o=H()?n.forwardOps:null,r=H()?n.fmOps:null;if(o&&o.length>0||r&&r.length>0){if(!q(e,(s)=>{if(o)for(let a of o)ue(s,re(a));if(r)for(let a of r){let l=re(a);de(s,l.field,l.after)}},{origin:"history",skipHistory:!0}))return;e.session.selection=ms(re(n.selection)),e.history.index+=1,Ye(e,e.history.index)}else e.history.index+=1,ze(e,e.history.index);e.doc.dirty=!0}function Ji(e,t,n,o){let r=K(e.doc.document,t);if(!r)return;Rc(r).splice(n,0,structuredClone(o)),f({index:n,op:"insert",parentPath:t}),vi({forward:{index:n,node:Ae(o),op:"insert-child",parentPath:t},inverse:{index:n,op:"remove-child",parentPath:t}})}function Uu(e,t){if(!t||!Ol(t))return;let n=ht(t),o=_n(t),[r]=K(e.doc.document,n).children.splice(o,1);f({op:"remove",path:t}),vi({forward:{index:o,op:"remove-child",parentPath:n},inverse:{index:o,node:Ae(r),op:"insert-child",parentPath:n}}),e.session.selection=De(e.session.selection,t)}function qC(e,t){if(!t||!Ol(t))return;let n=K(e.doc.document,t);if(!n)return;let o=ht(t),r=_n(t),i=structuredClone(re(n));K(e.doc.document,o).children.splice(r+1,0,i),f({index:r+1,op:"insert",parentPath:o}),vi({forward:{index:r+1,node:Ae(i),op:"insert-child",parentPath:o},inverse:{index:r+1,op:"remove-child",parentPath:o}}),e.session.selection=[[...o,"children",r+1]]}function bp(e,t){for(let n of pv(t))Uu(e,n)}function gv(e,t){let n=[];for(let o of pv(t)){let r=e.session.selection;qC(e,o);let i=Le(e.session.selection);if(!i||e.session.selection===r)continue;let s=ht(i),a=_n(i);n=n.map((l)=>$t(s,l,a,1,!0)),n.unshift(i)}if(n.length>0)e.session.selection=n}function FL(e,t,n="div"){if(!t||!Ol(t))return;let o=K(e.doc.document,t);if(!o)return;let r=ht(t),i=_n(t),s={children:[structuredClone(re(o))],tagName:n},a=Ae(o);K(e.doc.document,r).children.splice(i,1,s),f({op:"replace",path:t}),vi({forward:{index:i,node:Ae(s),op:"set-child",parentPath:r},inverse:{index:i,node:a,op:"set-child",parentPath:r}}),e.session.selection=[[...r,"children",i]]}function pa(e,t,n,o){let r=e.doc.document,i=ht(t),s=_n(t);if(!i||typeof s!=="number")return;let a=K(r,i),l=K(r,n);if(!a||!Array.isArray(a.children)||!l)return;if(a.children[s]===void 0)return;let c=o;if(a===l&&s<o)c-=1;let d={fromIndex:s,fromParentPath:i,op:"move-child",toIndex:c,toParentPath:n},g=dk(r,d),[y]=a.children.splice(s,1);if(Rc(l).splice(c,0,y),f({fromPath:t,op:"move",toIndex:c,toParentPath:n}),vi({forward:d,inverse:g}),Yo(Le(e.session.selection),t)){let b=o;if(i.length===n.length&&i.every((_,I)=>_===n[I])&&s<o)b=o-1;e.session.selection=[[...n,"children",b]]}}function Ue(e,t,n,o){let r=K(e.doc.document,t);if(!r)return;let i=r[n],s=Ae(i);if(o===void 0||o===null||o==="")delete r[n];else r[n]=o;if(vi(P(t,n,s,Ae(r[n]))),n==="textContent")f({op:"set-text",path:t});else if(n==="style")f({op:"set-style",path:t});else{let a=o===void 0||o===null||o===""?i:o,l=n.startsWith("on")&&sh(a);f({isEvent:l,key:n,op:"set-prop",path:t})}}function Sc(e,t,n,o){let r=K(e.doc.document,t),i=Ae(r.style);if(!r.style)r.style={};if(o===void 0||o==="")delete r.style[n];else r.style[n]=o;if(Object.keys(r.style).length===0)delete r.style;vi(P(t,"style",i,Ae(r.style))),f({op:"set-style",path:t})}function Ko(e,t,n,o){let r=K(e.doc.document,t),i=Ae(r.attributes);if(!r.attributes)r.attributes={};if(o===void 0||o==="")delete r.attributes[n];else r.attributes[n]=o;if(Object.keys(r.attributes).length===0)delete r.attributes;vi(P(t,"attributes",i,Ae(r.attributes))),f({attr:n,op:"set-attr",path:t})}function jL(e,t,n,o,r){if(!n)return Sc(e,t,o,r);let i=K(e.doc.document,t),s=Ae(i.style);if(!i.style)i.style={};let a=`@${n}`,l=rh(i.style,a);if(r===void 0||r===""){if(delete l[o],Object.keys(l).length===0)delete i.style[a]}else l[o]=r;if(Object.keys(i.style).length===0)delete i.style;vi(P(t,"style",s,Ae(i.style))),f({op:"set-style",path:t})}function bv(e,t,n,o,r){let i=K(e.doc.document,t),s=Ae(i.style);if(!i.style)i.style={};let a=rh(i.style,n);if(r===void 0||r===""){if(delete a[o],Object.keys(a).length===0)delete i.style[n]}else a[o]=r;if(Object.keys(i.style).length===0)delete i.style;vi(P(t,"style",s,Ae(i.style))),f({op:"set-style",path:t})}function HL(e,t,n,o,r,i){let s=K(e.doc.document,t),a=Ae(s.style);if(!s.style)s.style={};let l=`@${n}`,c=rh(s.style,l),d=rh(c,o);if(i===void 0||i===""){if(delete d[r],Object.keys(d).length===0)delete c[o];if(Object.keys(c).length===0)delete s.style[l]}else d[r]=i;if(Object.keys(s.style).length===0)delete s.style;vi(P(t,"style",a,Ae(s.style))),f({op:"set-style",path:t})}function Ze(e,t){let n=[e];for(let o of t){let r=va(n.at(-1),o);if(!r)break;n.push(r)}for(let o=n.length-2;o>=0;o--){let r=n[o],i=t[o],s=va(r,i);if(s&&Object.keys(s).length===0)delete r[i]}}function vv(e,t,n,o,r){let i=K(e.doc.document,t),s=Ae(i.style);if(!i.style)i.style={};let a=i.style;for(let l of n)a=rh(a,l);if(r===void 0||r==="")delete a[o],Ze(i.style,n);else a[o]=r;if(Object.keys(i.style).length===0)delete i.style;vi(P(t,"style",s,Ae(i.style))),f({op:"set-style",path:t})}function BL(e,t,n,o,r,i){let s=K(e.doc.document,t),a=Ae(s.style);if(!s.style)s.style={};let l=`@${n}`,c=rh(s.style,l),d=c;for(let g of o)d=rh(d,g);if(i===void 0||i===""){if(delete d[r],Ze(c,o),Object.keys(c).length===0)delete s.style[l]}else d[r]=i;if(Object.keys(s.style).length===0)delete s.style;vi(P(t,"style",a,Ae(s.style))),f({op:"set-style",path:t})}function zL(e,t,n){let o=K(e.doc.document,t),r=Ae(o.style);if(n&&Object.keys(n).length>0)o.style=n;else delete o.style;vi(P(t,"style",r,Ae(o.style))),f({op:"set-style",path:t})}function Bs(e,t,n){let o=e.doc.document,r=Ae(o.state);if(!o.state)o.state={};o.state[t]=n,vi(P([],"state",r,Ae(o.state))),f({key:"state",op:"doc-meta"})}function yv(e,t){let n=e.doc.document;if(n.state){let o=Ae(n.state);if(delete n.state[t],Object.keys(n.state).length===0)delete n.state;vi(P([],"state",o,Ae(n.state))),f({key:"state",op:"doc-meta"})}}function mr(e,t,n){let o=e.doc.document,r=Ae(o.state);if(!o.state)o.state={};let i=o.state[t],s=i==null?{}:typeof i!=="object"||Array.isArray(i)?{default:i}:i;o.state[t]=s,Object.assign(s,n);for(let a of Object.keys(s))if(s[a]===void 0||s[a]===null)delete s[a];vi(P([],"state",r,Ae(o.state))),f({key:"state",op:"doc-meta"})}function WL(e,t,n){let o=e.doc.document;if(!o.state||!o.state[t])return;let r=Ae(o.state);o.state[n]=o.state[t],delete o.state[t],vi(P([],"state",r,Ae(o.state))),f({key:"state",op:"doc-meta"})}function qu(e,t,n,o){let r=K(e.doc.document,t),i=Ae(r.$props);if(!r.$props)r.$props={};if(o===void 0||o===null||o==="")delete r.$props[n];else r.$props[n]=o;if(Object.keys(r.$props).length===0)delete r.$props;vi(P(t,"$props",i,Ae(r.$props))),f({op:"replace",path:t})}function VL(e,t,n,o){let r=K(e.doc.document,t),i=Ae(r.cases);if(!r.cases)r.cases={};r.cases[n]=o||{tagName:"div",textContent:n},vi(P(t,"cases",i,Ae(r.cases))),f({op:"replace",path:t})}function UL(e,t,n){let o=K(e.doc.document,t);if(o.cases){let r=Ae(o.cases);delete o.cases[n],vi(P(t,"cases",r,Ae(o.cases))),f({op:"replace",path:t})}}function qL(e,t,n,o){let r=K(e.doc.document,t);if(!r.cases||!r.cases[n])return;let i=Ae(r.cases);r.cases[o]=r.cases[n],delete r.cases[n],vi(P(t,"cases",i,Ae(r.cases))),f({op:"replace",path:t})}function Ml(e,t,n){let o=e.doc.content.frontmatter,r=Object.hasOwn(o,t)?Ae(o[t]):void 0,i=n===void 0||n===null||n==="";if(i)delete o[t];else o[t]=n;let s=i?void 0:Ae(n);Ne({after:s,before:r,field:t}),e.doc.dirty=!0}function de(e,t,n){if(n===void 0)delete e.doc.content.frontmatter[t];else e.doc.content.frontmatter[t]=n}var Wt={design:"canvas",edit:"canvas",entry:"entry","git-diff":"diff",grid:"grid",manage:"library",media:"media",preview:"canvas",settings:"config",source:"code",stylebook:"config"},rv={canvas:"Canvas",code:"Code",config:"Project Styles",diff:"Diff",entry:"Entry",grid:"Grid",media:"Media",library:"Library",none:"None"};function ha(e){return Wt[e]??"canvas"}var Bt={design:"design",edit:"edit",preview:"preview"};function wL(e){return Bt[e]??"design"}var sv=(e)=>e.editor.kind==="canvas",Dd=(e)=>sv(e)&&e.selection.count>0,av=(e)=>Dd(e)&&!e.selection.isRoot;function vm(){return{project:{open:!1,isSite:!1,isRepo:!1,isMultilingual:!1},git:{ahead:0,behind:0,dirtyCount:0},document:{open:!1,dirty:!1,mode:"",canUndo:!1,canRedo:!1},editor:{kind:"none"},canvas:{view:"design"},pane:{count:1,derived:!1},selection:{count:0,paths:[],kind:"",isRoot:!1,isComponentInstance:!1,isLayoutNode:!1,isRepeater:!1},caret:{active:!1,inCanvas:!1},focus:{region:"pane"},modal:{open:!1},collab:{attached:!1,readOnly:!1,sourceCanonical:!1},ai:{configured:!1,streaming:!1,waiting:!1},capability:{gitClone:!1,importSite:!1,openProjectInNewWindow:!1,dataRows:!1,windowControls:!1,findReferences:!1,readFileBytes:!1}}}function Tx(e={}){let t=vm();for(let n of Object.keys(e)){let o=e[n];if(o)Object.assign(t[n],o)}return t}var Vt=["palette"],Kt=["caret","global"],Ut=["dock","global"],Gt=["canvas","global"],Ht=["grid","global"],qt=["code","global"],Xe=["global"];function xL(e){if(e.modal.open)return Vt;if(e.caret.active)return Kt;if(e.focus.region!=="pane")return Ut;switch(e.editor.kind){case"grid":return Ht;case"code":return qt;case"canvas":return e.canvas.view==="preview"?Xe:Gt;default:return Xe}}var ai="project.json";function zt(e,t=!1){return{activeMedia:null,activeSelector:null,openPopover:null,openDialog:null,canvasMode:e,editZoom:1,editingFormula:null,editingFunction:null,featureToggles:{},inspectorSections:{},pendingInlineEdit:null,preview:t,previewColorScheme:"auto",previewLocale:null,previewParams:{},previewProps:null,rightTab:"properties",showLayout:!0,styleFilter:"",styleSections:{},dataRows:{},dataLimits:{},styleShorthands:{},zoom:1}}var Yt=["edit","design","preview","source","stylebook","git-diff"];function dv({id:e,documentPath:t=null,fileHandle:n=null,document:o,frontmatter:r,sourceFormat:i=null,capabilities:s,openedFrom:a=null,preview:l=!1,layout:c=null}){let d=ge();Im(o);let g=s?.modes??Xt(t,i),y=g.find((I)=>I!=="preview")??"edit",b=g[0]==="preview";return d.run(()=>({capabilities:{modes:g},doc:v({content:{frontmatter:r||{}},dirty:!1,document:o,handlersSource:null,layout:c,mode:Qt(t,i),sourceFormat:i}),documentPath:t,fileHandle:n,history:v({index:0,snapshots:[{document:structuredClone(o),selection:[]}]}),id:e,pinned:!1,preview:l,scope:d,session:v({canvas:{refreshing:!1,error:null,livePreviews:null,pendingInlineEdit:null,scope:null,status:"idle"},clipboard:null,hover:null,openedFrom:a,selection:[],ui:zt(y,b)})}))}function Xt(e,t){if(e===ai)return["stylebook","source"];let n=wi(t)??Zt(e);if(n)return n.studio?.modes??["edit","design","preview","source"];return Yt}function Qt(e,t){let n=wi(t)??Zt(e);if(n)return n.studio?.documentMode?.default??"content";return"component"}function UC(e){return ha(e.session.ui.canvasMode)}function LL(e){let t=[];for(let n of e.capabilities.modes){if(n==="preview")continue;let o=ha(n);if(!t.includes(o))t.push(o)}return t}function IL(e,t){return e.capabilities.modes.find((n)=>n!=="preview"&&ha(n)===t)}function mp(e){e.scope.stop()}var Qe=new WeakMap,M=new Map;function xn(e){let t=re(e),n=Qe.get(t);if(!n)n=v({active:!1,attachError:"",peers:[],readOnly:!1,sourceCanonical:!1,status:"unavailable"}),Qe.set(t,n);return n}function et(e){M.set(e,(M.get(e)??0)+1)}function tt(e){let t=M.get(e)??0;if(t<=1)M.delete(e);else M.set(e,t-1)}function xm(e){return M.has(e.replaceAll("\\","/"))}var en=8000,tn=800,nn=2500,nt=null;function on(){return nt??=(me("nag78a9h"),import("./index-nag78a9h.js")),nt}function it(){try{return p()}catch{return null}}var N=null;function XL(e){N=e}var pe=null;function QL(e){pe=e}var st=()=>{};function eI(e){st=e??(()=>{})}var be=new WeakMap;function at(e){return re(e)}function C(e){return be.get(at(e))}function xe(e){let t=at(e),n=be.get(t);if(!n)n={attaching:null,generation:0,optedOut:v({value:!1}),session:null,watcherInstalled:!1},be.set(t,n);return n}var rt=!1;function rn(){if(rt)return;rt=!0,Be(sn),qe(an),Ke((e)=>{if(C(e)?.session?.synced&&xn(e).sourceCanonical)return st("Source editing in progress — structural edits are paused"),"source-canonical";return null})}function sn(e,t,n){let o=C(e)?.session;if(!o||!o.synced)return;if(o.lastSeenRef=re(e.doc.document),n==="remote"){ee(o);return}if(o.canWrite)ln(o,t),ee(o)}function an(e){let t=C(e)?.session;if(!t?.synced||t.batchOps===null)return;let{batchOps:n,batchNeedsDiff:o}=t;if(t.batchOps=null,t.batchNeedsDiff=!1,!t.canWrite)return;if(t.undoManager?.stopCapturing(),o)z(t);else if(n.length>0)try{t.collab.applyDocOpsToY(t.handle.doc,n,t.collab.LOCAL_ORIGIN)}catch{z(t)}t.undoManager?.stopCapturing()}function ln(e,t){let n=t.docOps.map((o)=>o.forward);if(Rx()){if(e.batchOps??=[],n.length===0)e.batchNeedsDiff=!0;else e.batchOps.push(...n);return}if(n.length===0){z(e);return}try{e.collab.applyDocOpsToY(e.handle.doc,n,e.collab.LOCAL_ORIGIN)}catch{z(e)}}function z(e){let{collab:t,handle:n,tab:o}=e,r=t.yDocToJson(n.doc),i=Ao(re(o.doc.document)),s=t.diffDocs(r,i);if(s===null)t.replaceYStructure(n.doc,i,t.LOCAL_ORIGIN);else if(s.length>0)try{t.applyDocOpsToY(n.doc,s,t.LOCAL_ORIGIN)}catch{t.replaceYStructure(n.doc,i,t.LOCAL_ORIGIN)}}function fe(e){let t=e.collab.yDocToJson(e.handle.doc);q(e.tab,(n)=>{let o=n.doc.document;for(let r of Object.keys(o))if(!(r in t))delete o[r];Object.assign(o,t)},{origin:"remote",skipHistory:!0})}function cn(e){if(!e.canWrite)return!1;let{awareness:t}=e.handle,n=t.clientID;for(let[o,r]of t.getStates())if(r.canWrite!==!1&&o<n)n=o;return n===e.handle.awareness.clientID}function ee(e){if(!N||!cn(e))return;if(e.collab.canonicalOf(e.handle.doc)==="source")return;let t=Date.now();if(e.lastMirrorAt??=t,t-e.lastMirrorAt>=nn){if(e.mirrorTimer)clearTimeout(e.mirrorTimer),e.mirrorTimer=null;e.lastMirrorAt=t,ye(e);return}if(e.mirrorTimer)clearTimeout(e.mirrorTimer);e.mirrorTimer=setTimeout(()=>{e.mirrorTimer=null,e.lastMirrorAt=Date.now(),ye(e)},tn)}async function ye(e){if(!N||!e.synced)return;try{let t=await N(e.tab);e.collab.updateSourceText(e.handle.doc,t,e.collab.MIRROR_ORIGIN)}catch{}}async function lt(e){if(!pe||!e.synced||!e.canWrite)return;let{collab:t,handle:n,tab:o}=e,r=t.canonicalRevOf(n.doc),i=t.sourceText(n.doc).toString(),s;try{s=await pe(o,i)}catch{return}if(!e.synced||t.canonicalRevOf(n.doc)!==r)return;let a=t.diffDocs(t.yDocToJson(n.doc),s.document);if(a===null)t.replaceYStructure(n.doc,s.document,t.MIRROR_ORIGIN);else if(a.length>0)try{t.applyDocOpsToY(n.doc,a,t.MIRROR_ORIGIN)}catch{t.replaceYStructure(n.doc,s.document,t.MIRROR_ORIGIN)}let l=t.frontmatterMap(n.doc),c=s.frontmatter??{};n.doc.transact(()=>{let d=[...l.keys()];for(let g of d)if(!(g in c))l.delete(g);for(let[g,y]of Object.entries(c))if(!t.deepEqual(l.get(g),y))l.set(g,y)},t.MIRROR_ORIGIN)}function tI(e){let t=C(e)?.session;if(!t?.synced)return null;let{collab:n,handle:o}=t,r=null,i=()=>r!==null&&t.sourceLockOwner===r;return{awareness:o.awareness,enter:async()=>{r={},t.sourceLockOwner=r;let s=o.awareness.getLocalState();if(s)o.awareness.setLocalState({...s,mode:"source"});if(!t.canWrite)return;let a=null;if(N)try{a=await N(e)}catch{a=null}if(!i())return;n.acquireSourceCanonical(o.doc,a??n.sourceText(o.doc).toString(),n.LOCAL_ORIGIN)},leave:()=>{if(!i()){r=null;return}r=null,t.sourceLockOwner=null;let s=o.awareness.getLocalState();if(s)o.awareness.setLocalState({...s,mode:"structure"});if(!t.canWrite)return;if(n.otherSourceEditors(o.awareness,t.path,o.awareness.clientID).filter((l)=>o.awareness.getStates().get(l)?.canWrite!==!1).length===0)lt(t).then(()=>{n.releaseSourceCanonical(o.doc,n.LOCAL_ORIGIN)})},localOrigin:n.LOCAL_ORIGIN,readOnly:!t.canWrite,text:n.sourceText(o.doc)}}function Cm(e){let t=xn(e);return t.active&&t.readOnly}async function JC(e){let t=C(e)?.session;if(!t?.synced||!t.canWrite)return!1;if(t.mirrorTimer)clearTimeout(t.mirrorTimer),t.mirrorTimer=null;return await ye(t),await t.handle.flush(),!0}async function YC(){for(let e of he)if(C(e)?.session?.synced)await JC(e)}var he=new Set;function Y(e){if(!it()?.collab||!e.documentPath||e.documentPath===ai)return;let n=xe(e);if(n.watcherInstalled)return;n.watcherInstalled=!0,rn(),he.add(e),e.scope.run(()=>{Q(()=>{if(n.optedOut.value)te(e);else ve(e)}),Qa(()=>{he.delete(e),te(e)})})}function ZC(e,t){let n=xe(e);if(n.optedOut.value===!t)return;if(n.optedOut.value=!t,!n.watcherInstalled&&t)Y(e)}function XC(e){return C(e)?.optedOut.value!==!0}function ct(e){if(!C(e)?.watcherInstalled){Y(e);return}te(e),ve(e)}async function ve(e){let t=xe(e);if(t.session||t.attaching)return;let{documentPath:n}=e,o=it();if(!n||!o?.collab){xn(e).status="unavailable";return}let{generation:r}=t,i=xn(e);i.status="connecting",i.attachError="";let s=(async()=>{try{let[a,l]=await Promise.all([on(),o.collab(n)]);if(!l){i.status="detached";return}if(t.generation!==r){l.destroy();return}let c=null,d=new Promise((g,y)=>{c=setTimeout(()=>y(Error("collab-sync-timeout")),en)});try{await Promise.race([l.whenSynced,d])}finally{if(c)clearTimeout(c)}if(t.generation!==r){l.destroy();return}t.session=un(e,n,a,l),i.active=!0,i.status="synced",i.readOnly=!t.session.canWrite,i.attachError="",et(n)}catch(a){i.status="failed",i.active=!1,i.attachError=a instanceof Error?a.message:String(a),k.warn(`Live collaboration is not available for "${n}" — ${i.attachError}`,{key:`collab:${n}`,path:n,source:"Collaboration"})}finally{t.attaching=null}})();t.attaching=s,await s}function te(e){let t=C(e);if(!t)return;t.generation+=1;let{session:n}=t;t.session=null;let o=xn(e);if(o.active=!1,o.status="detached",o.attachError="",o.peers=[],!n)return;if(tt(n.path),n.mirrorTimer)clearTimeout(n.mirrorTimer);if(n.sourceParseTimer)clearTimeout(n.sourceParseTimer);for(let r of n.disposers)try{r()}catch{}wm(e,null),e.history.snapshots=[{document:Ao(re(e.doc.document)),selection:ms(e.session.selection)}],e.history.index=0,n.undoManager?.destroy(),n.handle.destroy()}function un(e,t,n,o){let r=o.identity(),i={applyingRemoteFrontmatter:!1,batchNeedsDiff:!1,batchOps:null,canWrite:r?r.permission!=="read":!0,collab:n,disposers:[],handle:o,lastSeenRef:re(e.doc.document),mirrorTimer:null,path:t,sourceLockOwner:null,sourceParseTimer:null,synced:!1,tab:e,undoManager:null};if(n.metaMap(o.doc).get("structureSeeded")===!0){let h=n.yDocToJson(o.doc),x=Ao(re(e.doc.document));if(!n.deepEqual(h,x)){let w=n.diffDocs(x,h);if(w===null)i.synced=!0,fe(i),i.synced=!1;else if(w.length>0)ce(e,w)}i.applyingRemoteFrontmatter=!0;let T=n.frontmatterMap(o.doc);for(let[w,J]of T.entries())e.doc.content.frontmatter[w]=J;i.applyingRemoteFrontmatter=!1}else if(i.canWrite)n.seedStructure(o.doc,Ao(re(e.doc.document)),{frontmatter:Ao(re(e.doc.content.frontmatter)),origin:n.SEED_ORIGIN,sourceFormat:e.doc.sourceFormat});i.lastSeenRef=re(e.doc.document),i.disposers.push(o.onDirty((h)=>{e.doc.dirty=h})),o.awareness.setLocalState({canWrite:i.canWrite,focusedPath:t,structuralSelection:null,user:r?{avatarUrl:r.avatarUrl,color:r.color,login:r.login,name:r.name}:{color:n.colorForKey(String(o.awareness.clientID)),login:`guest-${o.awareness.clientID%1000}`}});let a=new n.UndoManager([n.structureMap(o.doc),n.frontmatterMap(o.doc)],{trackedOrigins:new Set([n.LOCAL_ORIGIN])});i.undoManager=a;let l=({stackItem:h})=>{h.meta.set("selection",ms(e.session.selection))},c=({stackItem:h})=>{let x=h.meta.get("selection");e.session.selection=ms(x??[])};a.on("stack-item-added",l),a.on("stack-item-popped",c),i.disposers.push(()=>{a.off("stack-item-added",l),a.off("stack-item-popped",c)}),wm(e,{canRedo:()=>a.canRedo(),canUndo:()=>a.canUndo(),redo:()=>{a.redo()},undo:()=>{a.undo()}});let d=n.structureMap(o.doc),g=(h,x)=>{if(x.origin===n.LOCAL_ORIGIN||!i.synced)return;let T=n.yEventsToDocOps(h);if(T===null){fe(i);return}if(T.length===0)return;try{ce(e,T)}catch{fe(i)}};d.observeDeep(g),i.disposers.push(()=>d.unobserveDeep(g));let y=xn(e);y.sourceCanonical=n.canonicalOf(o.doc)==="source";let b=n.metaMap(o.doc),_=()=>{y.sourceCanonical=n.canonicalOf(o.doc)==="source"};b.observe(_),i.disposers.push(()=>b.unobserve(_));let I=n.sourceText(o.doc),Oe=(h,x)=>{if(x.origin===n.MIRROR_ORIGIN||!i.synced)return;if(n.canonicalOf(o.doc)!=="source")return;if(!n.isSourceReconciler(o.awareness,i.path))return;if(i.sourceParseTimer)clearTimeout(i.sourceParseTimer);i.sourceParseTimer=setTimeout(()=>{i.sourceParseTimer=null,lt(i)},600)};I.observe(Oe),i.disposers.push(()=>I.unobserve(Oe));let A=n.frontmatterMap(o.doc),we=(h,x)=>{if(x.origin===n.LOCAL_ORIGIN||!i.synced)return;i.applyingRemoteFrontmatter=!0;try{for(let[T,w]of h.changes.keys)if(w.action==="delete")delete e.doc.content.frontmatter[T];else e.doc.content.frontmatter[T]=A.get(T)}finally{i.applyingRemoteFrontmatter=!1}};A.observe(we),i.disposers.push(()=>A.unobserve(we)),e.scope.run(()=>{let h=JSON.stringify(e.doc.content.frontmatter);Q(()=>{let x=JSON.stringify(e.doc.content.frontmatter);if(x===h)return;if(h=x,i.applyingRemoteFrontmatter||!i.synced||!i.canWrite)return;let T=JSON.parse(x);o.doc.transact(()=>{let w=[...A.keys()];for(let J of w)if(!(J in T))A.delete(J);for(let[J,Ce]of Object.entries(T))if(!n.deepEqual(A.get(J),Ce))A.set(J,Ce)},n.LOCAL_ORIGIN),ee(i)}),Q(()=>{let x=e.session.selection.length>0?ms(e.session.selection):null,T=o.awareness.getLocalState();if(T)o.awareness.setLocalState({...T,structuralSelection:x})}),Q(()=>{let x=re(e.doc.document);queueMicrotask(()=>{if(C(e)?.session!==i||!i.synced||!i.canWrite)return;let w=re(e.doc.document);if(w!==x||w===i.lastSeenRef)return;i.lastSeenRef=w,z(i),ee(i)})})});let oe=xn(e),ie=()=>{let h=[];for(let[x,T]of o.awareness.getStates())if(x!==o.awareness.clientID&&T.user)h.push({clientId:x,state:T});oe.peers=h};return ie(),o.awareness.on("change",ie),i.disposers.push(()=>o.awareness.off("change",ie),o.onStatus((h)=>{if(h==="offline"||h==="connecting")oe.status="offline";else if(i.synced)oe.status="synced"}),o.onReset(()=>{te(e),ve(e)})),i.synced=!0,i}function S(e,t,n){return RangeError(`command "${e}" argument "${t}": ${n}`)}function O(e){if(e===void 0)return"missing";return typeof e==="string"?`"${e}"`:`${typeof e} ${JSON.stringify(e)}`}function ot(e,t,n){let o=t[n];if(typeof o!=="string"||o==="")throw S(e,n,`expected a non-empty string, got ${O(o)}`);return o}function Jo(e,t,n){if(t[n]===void 0)return;return ot(e,t,n)}function dt(e,t,n){let o=t[n];if(typeof o!=="number"||!Number.isFinite(o))throw S(e,n,`expected a finite number, got ${O(o)}`);return o}function ut(e,t,n){let o=t[n];if(typeof o!=="number"||!Number.isInteger(o))throw S(e,n,`expected an integer, got ${O(o)}`);return o}function wv(e,t,n,o,r){let i=dt(e,t,n);if(i<o||i>r)throw S(e,n,`${i} is outside the supported range ${o}–${r}`);return i}function yi(e,t,n){let o=t[n];if(typeof o!=="boolean")throw S(e,n,`expected a boolean, got ${O(o)}`);return o}function li(e,t,n,o){let r=t[n];if(typeof r!=="string"||!o.includes(r))throw S(e,n,`${O(r)} is not declared — declared: ${o.join(", ")||"none"}`);return r}function Dx(e,t,n){let o=t[n];if(!Array.isArray(o)||!o.every((r)=>typeof r==="string"||typeof r==="number"))throw S(e,n,`expected an array of path segments (strings or numbers), got ${O(o)}`);return o}function GL(e,t,n){if(t[n]===null)return null;return Dx(e,t,n)}function GC(e,t,n){let o=t[n];if(!Array.isArray(o))throw S(e,n,`expected an array of document paths, got ${O(o)}`);return o.map((r,i)=>{if(!Array.isArray(r)||!r.every((s)=>typeof s==="string"||typeof s==="number"))throw S(e,n,`entry ${i} is not a document path — expected an array of segments, got ${O(r)}`);return r})}function Se(e,t=Object.keys(e)){return{additionalProperties:!1,properties:e,required:[...t],type:"object"}}function Do(e,t){return{description:t,enum:[...e],type:"string"}}function fa(e,t){return{description:t,get enum(){return[...e()]},type:"string"}}function KC(e,t={}){return{description:e,type:"number",...t}}function oo(e){return{description:e,type:"boolean"}}function xv(e,t=!1){let n={items:{type:["string","number"]},type:"array"};return t?{description:e,oneOf:[n,{type:"null"}]}:{description:e,...n}}function KL(e){return{description:e,items:{items:{type:["string","number"]},type:"array"},type:"array"}}function He(e){return{description:e,type:"string"}}function fn(e){return e.length===2&&e.includes("string")&&e.includes("number")}function Te(e){return Array.isArray(e)?e:[e]}function ft(e){let t=e;if("enum"in t)return"enum";if("const"in t)return"const";if(Array.isArray(t.oneOf))return"one-of";if(Array.isArray(t.type))return"typed";switch(t.type){case"boolean":return"boolean";case"number":case"integer":{if(t.minimum!==void 0&&t.maximum!==void 0)return"bounded-number";return t.type==="integer"?"integer":"number"}case"string":return"string";case"array":{let n=t.items?.type;if(Array.isArray(n))return fn(n)?"path":"pass-through";return n==="array"?"path-list":"pass-through"}case"null":case"object":return"typed";default:break}return"pass-through"}function pt(e,t){switch(e){case"null":return t===null;case"boolean":return typeof t==="boolean";case"string":return typeof t==="string";case"number":return typeof t==="number"&&Number.isFinite(t);case"integer":return typeof t==="number"&&Number.isInteger(t);case"array":return Array.isArray(t);case"object":return typeof t==="object"&&t!==null&&!Array.isArray(t);default:break}return!1}function mt(e){if(e.length<=1)return e.join("");return`${e.slice(0,-1).join(", ")} or ${e.at(-1)}`}function pn(e,t,n,o){let r=t[n];if(!o.some((i)=>pt(i,r)))throw S(e,n,`expected ${mt(o)}, got ${O(r)}`);return r}function gt(e){switch(ft(e)){case"enum":return`one of ${(e.enum??[]).map((t)=>O(t)).join(" | ")}`;case"const":return`the constant ${O(e.const)}`;case"one-of":return(e.oneOf??[]).map((t)=>gt(t)).join(" or ");case"typed":return mt(Te(e.type??[]));case"boolean":return"a boolean";case"bounded-number":return`a number from ${e.minimum} to ${e.maximum}`;case"number":return"a finite number";case"integer":return"an integer";case"string":return"a non-empty string";case"path":return"a document path";case"path-list":return"a list of document paths";default:return"anything"}}function mn(e,t,n,o){let r=t[n],i=[];for(let s of o){if(s.type!==void 0&&!Te(s.type).some((a)=>pt(a,r)))continue;try{return bt(e,t,n,s)}catch(a){i.push(a)}}if(i.length===1)throw i[0];throw S(e,n,`expected ${o.map((s)=>gt(s)).join(" or ")}, got ${O(r)}`)}function bt(e,t,n,o){switch(ft(o)){case"enum":return li(e,t,n,o.enum??[]);case"const":{let r=t[n];if(r!==o.const)throw S(e,n,`expected the constant ${O(o.const)}, got ${O(r)}`);return r}case"one-of":return mn(e,t,n,o.oneOf??[]);case"typed":return pn(e,t,n,Te(o.type??[]));case"boolean":return yi(e,t,n);case"bounded-number":{if(o.type==="integer")ut(e,t,n);return wv(e,t,n,o.minimum,o.maximum)}case"number":return dt(e,t,n);case"integer":return ut(e,t,n);case"string":return ot(e,t,n);case"path":return Dx(e,t,n);case"path-list":return GC(e,t,n);default:return t[n]}}function JL(e,t,n){let o=t,r=o.properties??{},i=Object.keys(r),s=o.required??[],a={};for(let[l,c]of Object.entries(n)){if(c===void 0||Object.hasOwn(r,l))continue;if(o.additionalProperties===!1)throw S(e,l,`not declared — declared: ${i.join(", ")||"none"}`);a[l]=c}for(let l of i){if(n[l]===void 0&&!s.includes(l))continue;a[l]=bt(e,n,l,r[l])}return a}var gn=20,Qn="primary",yp="secondary",QC=2,m=v({activePaneId:Qn,clipboard:null,closedTabs:[],componentRegistry:[],mruOrder:[],fileTree:{dirs:new Map,expanded:new Set,searchQuery:"",selectedPath:null},panes:[{activeTabId:null,derived:null,id:Qn,tabOrder:[]}],projectConfig:null,projectRoot:null,styleClipboard:null,tabs:new Map,ui:{activityBar:"files"},get activeTabId(){let e=Rr();return e.derived?.kind==="lens"?Hn(e.derived.sourcePaneId)?.activeTabId??null:e.activeTabId},get tabOrder(){return Rr().tabOrder}}),u=Wd(()=>m.activeTabId?m.tabs.get(m.activeTabId)??null:null);function Rr(){let{panes:e}=m;return e.find((t)=>t.id===m.activePaneId)??e[0]}function Hn(e){return m.panes.find((t)=>t.id===e)}function Ku(e){return m.panes.find((t)=>t.tabOrder.includes(e))}function $r(e){let t=Hn(e);if(!t||t.id===m.activePaneId)return;m.activePaneId=t.id,R();let{activeTabId:n}=t;if(n){Pe(n);let o=m.tabs.get(n);if(o)vt(o)}}function wp(e){return m.activePaneId===e}function Mx(e){let t=e??Rr().activeTabId,n=t?m.tabs.get(t):null;if(!t||!n)return null;let o=Ku(t);if(!o)return null;let r=Fl(o.id);return Cp(t),Ju(r,t),r.activeTabId=t,m.activePaneId=r.id,R(),Pe(t),r}function Px(e){return m.panes.find((t)=>t.id!==e)??bn(yp)}function Fl(e){let t=Px(e);if(t.derived)t.derived=null;return t}function bn(e){let t=Hn(e);if(t)return t;return m.panes=[...m.panes,{activeTabId:null,derived:null,id:e,tabOrder:[]}],Hn(e)}function xp(e){if(m.panes.length<2)return;let t=e===Qn?m.panes.find((r)=>r.id!==Qn)?.id:e,n=t===void 0?void 0:Hn(t),o=m.panes.find((r)=>r.id!==t);if(!n||!o)return;for(let r of n.tabOrder)Ju(o,r);if(o.activeTabId=m.activePaneId===n.id?n.activeTabId??o.activeTabId:o.activeTabId??n.activeTabId,m.activePaneId=o.id,o.derived?.sourcePaneId===n.id)o.derived=null;m.panes=m.panes.filter((r)=>r.id!==n.id),R()}function _p(e){return e.tabOrder.length===0&&e.derived===null}function Cp(e){let t=[];for(let n of m.panes){if(!n.tabOrder.includes(e))continue;if(n.tabOrder=n.tabOrder.filter((o)=>o!==e),n.activeTabId===e)n.activeTabId=n.tabOrder.at(-1)??null;if(n.id!==Qn&&_p(n))t.push(n.id)}for(let n of t)xp(n)}function Ju(e,t,n){if(e.tabOrder.includes(t))return;let o=n??hn(e,t);e.tabOrder=[...e.tabOrder.slice(0,o),t,...e.tabOrder.slice(o)]}function yn(e){let t=0;for(let n of e.tabOrder){if(m.tabs.get(n)?.pinned!==!0)break;t+=1}return t}function hn(e,t){return m.tabs.get(t)?.pinned===!0?yn(e):e.tabOrder.length}function qa(e,t=null){if(m.projectRoot&&e!==m.projectRoot)Ix();m.projectRoot=e,m.projectConfig=t}function kp(e){let t=u.value;return e!==null&&t!==null&&re(t)===re(e)}function Ec(e){if(!e)return!1;let t=m.tabs.get(e.id);return t!==void 0&&re(t)===re(e)}function Pe(e){m.mruOrder=[e,...m.mruOrder.filter((t)=>t!==e)]}var ne=null,Z=0;function R(){ne=null,Z=0}function vt(e){if(D&&e.documentPath)D.selectedPath=e.documentPath}function X(e,t={}){let n=m.tabs.get(e),o=Ku(e);if(!n||!o)return;if(o.activeTabId=e,t.focus===!1)return;if(m.activePaneId=o.id,!t.cycling)R(),Pe(e);vt(n)}function No(e){let t=m.tabs.get(e.id),n=e.preview===!0&&t?.pinned!==!0,o=dv({...e,preview:n}),r=(e.paneId===void 0?void 0:Hn(e.paneId))??Rr(),i;if(t)o.pinned=t.pinned,mp(t);else{if(n){let a=yt(r),l=a?m.tabs.get(a):null;if(l)Sp(l);Fx()}let s=n?yt(r):null;if(s)i=r.tabOrder.indexOf(s),jx(s);Ju(r,o.id,i)}return m.tabs.set(o.id,o),X(o.id,{focus:e.focus!==!1}),Y(o),o}function yt(e){return e.tabOrder.find((t)=>m.tabs.get(t)?.preview===!0)??null}function jl(e){let t=m.tabs.get(e);if(t?.preview===!0)t.preview=!1}function Fx(){for(let[e,t]of m.tabs)if(t.preview&&t.doc.dirty)jl(e)}function Sv(e,t){let n=m.tabs.get(e),o=Ku(e);if(!n||!o)return;if(n.pinned=t,t)n.preview=!1;let r=o.tabOrder.filter((s)=>s!==e),i=r.filter((s)=>m.tabs.get(s)?.pinned===!0).length;o.tabOrder=[...r.slice(0,i),e,...r.slice(i)]}function ek(e,t){let n=m.tabs.get(e),o=Ku(e);if(!n||!o)return;o.tabOrder=Tt(o,e,t)}function Tt(e,t,n){let o=m.tabs.get(t);if(!o)return e.tabOrder;let r=e.tabOrder.filter((c)=>c!==t),i=r.filter((c)=>m.tabs.get(c)?.pinned===!0).length,s=o.pinned?0:i,a=o.pinned?i:r.length,l=Math.min(Math.max(n,s),a);return[...r.slice(0,l),t,...r.slice(l)]}function jx(e){let t=m.tabs.get(e);if(!t)return;let n=Ku(e),o=n?.activeTabId===e;if(vn(t),mp(t),m.tabs.delete(e),Cp(e),m.mruOrder=m.mruOrder.filter((s)=>s!==e),R(),n&&_p(n))xp(n.id);if(!o)return;let r=Rr(),i=m.mruOrder.find((s)=>r.tabOrder.includes(s))??r.tabOrder.at(-1)??null;if(i)X(i)}function tk(){let e=[...m.tabs.values()];m.tabs.clear(),Pt(),m.mruOrder=[],R();for(let t of e)mp(t)}function Pt(){m.panes=[{activeTabId:null,derived:null,id:Qn,tabOrder:[]}],m.activePaneId=Qn}function vn(e){if(!e.documentPath)return;let t=e.documentPath;m.closedTabs=[{documentPath:t},...m.closedTabs.filter((n)=>n.documentPath!==t)].slice(0,gn)}function Tn(){let[e]=m.closedTabs;if(!e)return;return m.closedTabs=m.closedTabs.slice(1),e.documentPath}function xt(e){if(!ne)ne=m.mruOrder.filter((o)=>m.tabs.has(o)),Z=0;let t=ne;if(t.length<2)return;Z=((Z+e)%t.length+t.length)%t.length;let n=t[Z];return X(n,{cycling:!0}),n}function nk(e){let t=[...m.tabs.keys()],n=[...m.tabs.values()],o=dv(e);m.tabs.set(o.id,o),Pt(),m.panes[0].tabOrder=[o.id],m.mruOrder=[],R(),X(o.id),Y(o);for(let r of t){if(r===o.id)continue;m.tabs.delete(r)}for(let r of n)mp(r);return o}function ci(e,t={}){X(e,t)}function km(e,t,n){let o=Hn(t);if(!o||!m.tabs.has(e))return null;if(o.tabOrder.includes(e)){if(n!==void 0)o.tabOrder=Tt(o,e,n);return o}return Cp(e),Ju(o,e,n),o}function Ev(e,t,n){let o=m.tabs.get(e);if(!o)return;o.id=t,o.documentPath=n,m.tabs.delete(e),m.tabs.set(t,o);for(let r of m.panes)if(r.tabOrder=r.tabOrder.map((i)=>i===e?t:i),r.activeTabId===e)r.activeTabId=t;m.mruOrder=m.mruOrder.map((r)=>r===e?t:r),R(),ct(o)}function ik(e,t){e.registerAll([...Pn(t),...On(t)])}function Pn(e){let t=()=>m.tabs.size>1;return[{id:"document.nextTab",title:"Next Tab",category:"Document",level:"document",keybinding:["ctrl+tab","mod+tab"],menus:["palette"],group:"2_navigate",when:(n)=>n.document.open,enablement:t,requires:"a second open document",run:()=>{xt(1)}},{id:"document.previousTab",title:"Previous Tab",category:"Document",level:"document",keybinding:["ctrl+shift+tab","mod+shift+tab"],menus:["palette"],group:"2_navigate",when:(n)=>n.document.open,enablement:t,requires:"a second open document",run:()=>{xt(-1)}},{args:Se({path:He('Project-relative path of the file to open, e.g. "pages/about.json" or "components/nav-bar.json". It must exist.')}),id:"document.open",title:"Open Document",category:"Document",level:"project",menus:["palette"],group:"1_file",when:(n)=>n.project.open,requires:"an open project",aiTool:{description:"Open a project file as the active document; the document tools then operate on it. Use it when the user should SEE the page, or for iterative visual refinement after creating a page or component.",name:"open_document",report:({after:n,args:o})=>{let r=ot("document.open",o,"path"),i=u.value?.documentPath??null;if(i!==r)return`Opened "${r}", but the active document is ${i===null?"none":`"${i}"`}.`;let s=n.editor.kind==="canvas"?"on the canvas; the document tools now operate on it":`in the ${rv[n.editor.kind]} editor, which is not an element tree the document tools can edit`;return`"${r}" is the active document, ${s}.`}},run:async(n,o)=>{let r=ot("document.open",o,"path");if(await e.openFile(r),![...m.tabs.values()].some((i)=>i.documentPath===r))throw RangeError(`command "document.open" argument "path": "${r}" could not be opened — it does `+"not exist, or no editor claims its format. Problems has the reason.")}},{args:Se({file:He('Project-relative path of the file to open in the other pane, e.g. "pages/about.json". It must exist.')}),id:"document.openToSide",title:"Open to the Side",category:"Document",level:"project",menus:["context/file","palette"],group:"1_file",when:(n)=>n.project.open,requires:"an open project",undo:"none",run:async(n,o)=>{let r=ot("document.openToSide",o,"file"),i=Fl(Rr().id);if(await e.openFile(r,{paneId:i.id}),![...m.tabs.values()].some((s)=>s.documentPath===r)){if(_p(i)&&i.id!==Qn)xp(i.id);throw RangeError(`command "document.openToSide" argument "file": "${r}" could not be opened — it `+"does not exist, or no editor claims its format. Problems has the reason.")}}},{id:"document.reopenClosed",title:"Reopen Closed Document",category:"Document",level:"document",keybinding:"mod+shift+t",menus:["context/tab","palette"],group:"1_file",enablement:()=>m.closedTabs.length>0,requires:"a document closed in this session",run:async()=>{let n=Tn();if(n)await e.openFile(n)}},{id:"document.togglePinned",title:"Pin / Unpin Document",category:"Document",level:"document",menus:["context/tab","palette"],group:"1_file",when:(n)=>n.document.open,requires:"an open document",run:()=>{let n=m.activeTabId,o=n?m.tabs.get(n):null;if(n&&o)Sv(n,!o.pinned)}},{args:Se({pinned:oo("True to pin the active document's tab, false to unpin it.")}),id:"document.setPinned",title:"Set Document Pinned",category:"Document",level:"document",menus:["palette"],group:"1_file",when:(n)=>n.document.open,requires:"an open document",run:(n,o)=>{let r=m.activeTabId;if(r&&m.tabs.get(r))Sv(r,yi("document.setPinned",o,"pinned"))}},{id:"document.keepOpen",title:"Keep Document Open",category:"Document",level:"document",menus:["context/tab","palette"],group:"1_file",when:(n)=>n.document.open,enablement:()=>{let n=m.activeTabId;return n!==null&&m.tabs.get(n)?.preview===!0},requires:"a preview document — one opened by a single click",run:()=>{let n=m.activeTabId;if(n)jl(n)}}]}function On(e){let t=()=>m.panes.length>1;return[{id:"pane.splitRight",title:"Split Right",category:"View",level:"document",keybinding:"mod+\\",menus:["context/pane","context/tab","palette"],group:"5_pane",when:(n)=>n.document.open,enablement:()=>m.activeTabId!==null,requires:"an open document",undo:"none",run:()=>{Mx()}},{args:Se({path:He("Project-relative path of the document to open beside this one.")}),id:"pane.compareWith",title:"Compare With…",category:"View",level:"document",menus:["context/pane","context/tab","palette"],group:"5_pane",when:(n)=>n.document.open,enablement:()=>m.activeTabId!==null,requires:"an open document",undo:"none",run:async(n,o)=>{let r=ot("pane.compareWith",o,"path"),i=Rr();if((i.activeTabId?m.tabs.get(i.activeTabId):null)?.documentPath===r)throw RangeError(`command "pane.compareWith" argument "path": "${r}" is the document this pane is `+"already showing — name a different one");await e.openFileInPane(Fl(i.id).id,r)}},{id:"pane.focusPrimary",title:"Focus Primary Pane",category:"View",level:"document",keybinding:"mod+0",menus:["palette"],group:"5_pane",enablement:t,requires:"a split pane grid",undo:"none",run:()=>{$r(Qn)}},{id:"pane.focusSecondary",title:"Focus Side Pane",category:"View",level:"document",keybinding:"mod+alt+0",menus:["palette"],group:"5_pane",enablement:t,requires:"a split pane grid",undo:"none",run:()=>{$r(yp)}},{id:"pane.unsplit",title:"Close Side Pane",category:"View",level:"document",menus:["context/pane","palette"],group:"5_pane",enablement:t,requires:"a second pane",undo:"none",run:wn}]}function wn(){let e=m.panes.find((t)=>t.derived!==null);if(e?.id===Qn){if(e.derived=null,!_p(e))return}xp(e?.id??yp)}
|
|
2
|
+
export{Ex,Go,ov,vL,dn,$o,Wu,yL,WC,Vu,rv,ha,wL,sv,Dd,av,vm,Tx,xL,ym,zi,Ki,lv,Ad,cv,_L,VC,CL,kL,SL,Lx,EL,Ix,TL,ai,dv,UC,LL,IL,mp,Le,RL,uv,ms,hv,$L,Ol,pv,DL,gp,AL,vi,q,Hs,fv,mv,Rx,NL,wm,OL,ML,$x,PL,Ji,Uu,qC,bp,gv,FL,pa,Ue,Sc,Ko,jL,bv,HL,vv,BL,zL,Bs,yv,mr,WL,qu,VL,UL,qL,Ml,xn,xm,ot,Jo,wv,yi,li,Dx,GL,GC,Se,Do,fa,KC,oo,xv,KL,He,JL,Ax,vp,Nx,Pl,_v,Cv,Ox,YL,ma,Nd,Gu,_m,kv,ZL,Ao,XL,QL,eI,tI,Cm,JC,YC,ZC,XC,Qn,yp,QC,m,u,Rr,Hn,Ku,$r,wp,Mx,Px,Fl,xp,_p,Cp,Ju,qa,kp,Ec,No,jl,Fx,Sv,ek,jx,tk,nk,ci,km,Ev,ik};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=248AC212FDF931D664756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-3aey7dd3.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{di}from"./studio-
|
|
2
|
-
export{
|
|
1
|
+
import{di}from"./studio-g7nse7zb.js";import{tl}from"./studio-vzacdfsc.js";var v=new Set([".apng",".avif",".bmp",".gif",".ico",".jpeg",".jpg",".png",".svg",".webp",".eot",".otf",".ttf",".woff",".woff2",".m4v",".mov",".mp4",".ogv",".webm",".aac",".flac",".m4a",".mp3",".oga",".ogg",".opus",".wav"]);function l(e){let o=e.lastIndexOf("/"),t=e.lastIndexOf(".");return t>o+1&&v.has(e.slice(t).toLowerCase())}var i=new Map,a=0,p=0,u=new Map,d=new Map,c=null,m=Object.freeze({}),BC=tl(0);function g(){c=null,BC.value+=1}function h(){return a}function y(e,o){let t=u.get(e);if(t!==void 0&&t>o)return!0;for(let[r,n]of d)if(n>o&&e.startsWith(r))return!0;return!1}function x(e,o){if(o<p)return;let t=!1;for(let r of e){if(r.type!=="file")continue;let n=di(r.path);if(n===""||y(n,o))continue;let s=typeof r.version==="string"&&r.version!==""?r.version:null,f=i.get(n);if(s===null){if(f===void 0)continue;i.delete(n)}else if(f===s)continue;else i.set(n,s);if(l(n))t=!0}if(t)g()}async function Ir(e){let o=h(),t=await e();return x(t,o),t}function bm(e,o=[]){a+=1;let t=!1;for(let r of e){let n=di(r);if(n==="")continue;if(u.set(n,a),i.delete(n)&&l(n))t=!0}for(let r of o){let n=di(r);if(n==="")continue;let s=`${n}/`;d.set(s,a);for(let f of i.keys())if(f.startsWith(s)){if(i.delete(f),l(f))t=!0}}if(t)g()}function bL(e){return i.get(di(e))}function $d(){if(c)return c;let e={},o=!1;for(let[t,r]of i)if(l(t))e[t]=r,o=!0;return c=o?Object.freeze(e):m,c}function zC(){let e=$d()!==m;if(i.clear(),u.clear(),d.clear(),a+=1,p=a,e)g()}function fp(){zC()}
|
|
2
|
+
export{BC,Ir,bm,bL,$d,zC,fp};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=D95B3A77F85A1A4464756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-3bpdkq2s.js.map
|