@jxsuite/studio 8.1.0 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{2020-dg097k3e.js → 2020-j56903f1.js} +3 -3
- package/dist/chunks/adapter-wc5zvg9a.js +4 -0
- package/dist/chunks/add-new-flow-snx1s4b0.js +4 -0
- package/dist/chunks/cf-account-picker-xyqw0jex.js +4 -0
- package/dist/chunks/cf-settings-hp1pjm0n.js +4 -0
- package/dist/chunks/color-04361ttk.js +4 -0
- package/dist/chunks/{color-area-vh9cew51.js → color-area-h8dbasp1.js} +2 -2
- package/dist/chunks/{color-field-e78f16bs.js → color-field-qv5r2b16.js} +3 -3
- package/dist/chunks/{color-slider-fg4yhvk6.js → color-slider-nz2mrzky.js} +2 -2
- package/dist/chunks/components-nkwphrx3.js +4 -0
- package/dist/chunks/content-source-6a253wmk.js +4 -0
- package/dist/chunks/{convert-to-repeater-grnmea6c.js → convert-to-repeater-fhdwyg14.js} +3 -3
- package/dist/chunks/editor-wqrc68ca.js +4 -0
- package/dist/chunks/entry-commands-nef0wrmp.js +4 -0
- package/dist/chunks/{extension-sections-rp7fkega.js → extension-sections-8ez2rrk8.js} +3 -3
- package/dist/chunks/file-ops-y3w71k1n.js +4 -0
- package/dist/chunks/files-de90apn9.js +4 -0
- package/dist/chunks/format-host-zfjz4rzm.js +4 -0
- package/dist/chunks/fs-events-77c0mr0x.js +4 -0
- package/dist/chunks/grid-open-4n4fjfpf.js +4 -0
- package/dist/chunks/{grid-view-x26rfpz1.js → grid-view-ka55z38f.js} +10 -10
- package/dist/chunks/{iframe-entry-pkgmcgp0.js → iframe-entry-2x9bn5ng.js} +4 -4
- package/dist/chunks/{iframe-entry-02wzcyvy.js → iframe-entry-btck0e9s.js} +4 -4
- package/dist/chunks/iframe-host-na2mywz4.js +4 -0
- package/dist/chunks/index-ewmgdb7c.js +4 -0
- package/dist/chunks/{index-203h71wy.js → index-qb98xhse.js} +3 -3
- package/dist/chunks/{javascript-ww5pv5ae.js → javascript-ces13wny.js} +2 -2
- package/dist/chunks/{jsonMode-vwbdwwq3.js → jsonMode-6md16d4v.js} +6 -6
- package/dist/chunks/jx-validate-b309c020.js +4 -0
- package/dist/chunks/layers-8rn8y6qv.js +4 -0
- package/dist/chunks/layers-panel-eyah7h9z.js +4 -0
- package/dist/chunks/lit-html-wyqw04y2.js +4 -0
- package/dist/chunks/media-library-gs3np47y.js +4 -0
- package/dist/chunks/media-picker-tt7dk4tb.js +4 -0
- package/dist/chunks/{monaco-binding-63tqze27.js → monaco-binding-p8j80s4w.js} +3 -3
- package/dist/chunks/monaco-buffer-wsf6cmnq.js +4 -0
- package/dist/chunks/{monaco-setup-zyyynnj8.js → monaco-setup-wasktzfg.js} +3 -3
- package/dist/chunks/notify-qwst108r.js +4 -0
- package/dist/chunks/parse-n8dfxnqf.js +4 -0
- package/dist/chunks/platform-c16mqvmp.js +4 -0
- package/dist/chunks/publish-panel-d34bhvwj.js +4 -0
- package/dist/chunks/{publish-quick-ajzdhhs6.js → publish-quick-vr695j26.js} +3 -3
- package/dist/chunks/publish-workspace-2yr60mt4.js +4 -0
- package/dist/chunks/quick-search-e6xsdv0d.js +4 -0
- package/dist/chunks/references-gsj6trdv.js +4 -0
- package/dist/chunks/right-panel-33jv1knc.js +4 -0
- package/dist/chunks/source-control-bj9bejjv.js +4 -0
- package/dist/chunks/studio-03mqh8ax.js +5 -0
- package/dist/chunks/{studio-957jg8g3.js → studio-06j4en5h.js} +4 -4
- package/dist/chunks/studio-0ydxv2mr.js +7 -0
- package/dist/chunks/{studio-v2ek69cb.js → studio-1e8dw2w2.js} +4 -4
- package/dist/chunks/studio-2hsqbq7b.js +7 -0
- package/dist/chunks/studio-2j86y34y.js +6 -0
- package/dist/chunks/studio-2ks6ka4g.js +5 -0
- package/dist/chunks/studio-34jrz12k.js +5 -0
- package/dist/chunks/{studio-1meqbxns.js → studio-35vrtpdq.js} +4 -4
- package/dist/chunks/studio-38g0jdz7.js +5 -0
- package/dist/chunks/{studio-25a5by3h.js → studio-396srjbk.js} +4 -4
- package/dist/chunks/{studio-zm7dnr9g.js → studio-3c8pp7pb.js} +4 -4
- package/dist/chunks/{studio-x3ge4rts.js → studio-3v5cagy9.js} +4 -4
- package/dist/chunks/studio-3w35qvay.js +5 -0
- package/dist/chunks/studio-3zge48z4.js +7 -0
- package/dist/chunks/studio-45gyxpcq.js +5 -0
- package/dist/chunks/{studio-hw60n5dh.js → studio-4kzbrr5t.js} +3 -3
- package/dist/chunks/{studio-533py3yy.js → studio-5tzgq6fx.js} +4 -4
- package/dist/chunks/studio-5wzdy1jc.js +16 -0
- package/dist/chunks/studio-732mw0g8.js +5 -0
- package/dist/chunks/{studio-3q6n9qvq.js → studio-771k2n12.js} +4 -4
- package/dist/chunks/{studio-z42kysg7.js → studio-7dzyz9n8.js} +137 -137
- package/dist/chunks/{studio-fqs1a22a.js → studio-7xag4na8.js} +4 -4
- package/dist/chunks/{studio-jqrg9xxg.js → studio-881z1xrx.js} +4 -4
- package/dist/chunks/studio-88bmt9rh.js +5 -0
- package/dist/chunks/{studio-8nyw10dp.js → studio-9b7177jq.js} +4 -4
- package/dist/chunks/{studio-nm9qev4p.js → studio-9cxmp61c.js} +5 -5
- package/dist/chunks/{studio-4dsdnan2.js → studio-9dz76yqc.js} +5 -5
- package/dist/chunks/{studio-a6x058ew.js → studio-agyvzfm4.js} +4 -4
- package/dist/chunks/{studio-2b8443ms.js → studio-ajw4k8hp.js} +3 -3
- package/dist/chunks/studio-c1pxszat.js +5 -0
- package/dist/chunks/studio-cpkamjdn.js +14 -0
- package/dist/chunks/studio-d038kqbs.js +5 -0
- package/dist/chunks/studio-d83m0wyq.js +5 -0
- package/dist/chunks/studio-dbxv7w4s.js +5 -0
- package/dist/chunks/studio-de1s2x9v.js +5 -0
- package/dist/chunks/{studio-94ppxeqy.js → studio-dx73md4n.js} +8 -8
- package/dist/chunks/studio-ekgtrndg.js +5 -0
- package/dist/chunks/studio-epenqmvk.js +7 -0
- package/dist/chunks/studio-et2q4s8n.js +5 -0
- package/dist/chunks/{studio-txkx6586.js → studio-ewarnzm4.js} +7 -7
- package/dist/chunks/{studio-bf0rgyf7.js → studio-fy7jzj9j.js} +4 -4
- package/dist/chunks/{studio-332hesdk.js → studio-gr36vnte.js} +4 -4
- package/dist/chunks/{studio-rdnezzkd.js → studio-gwrhcrss.js} +5 -5
- package/dist/chunks/{studio-9wyqyfqy.js → studio-h310mbqm.js} +4 -4
- package/dist/chunks/{studio-zht0x0v3.js → studio-h5tpz5ke.js} +4 -4
- package/dist/chunks/studio-h7weqf2q.js +5 -0
- package/dist/chunks/{studio-1gdfsr49.js → studio-hcsba201.js} +7 -7
- package/dist/chunks/studio-hwejq03c.js +5 -0
- package/dist/chunks/{studio-wcakp5bt.js → studio-hy4ye0dx.js} +7 -7
- package/dist/chunks/{studio-02phtmqn.js → studio-jttyqrmh.js} +4 -4
- package/dist/chunks/{studio-j5jqvyn3.js → studio-jw0q5j6k.js} +4 -4
- package/dist/chunks/studio-k3a8rp3d.js +5 -0
- package/dist/chunks/{studio-hnx1h1pr.js → studio-k3bcy02e.js} +4 -4
- package/dist/chunks/studio-m48v13s3.js +4 -0
- package/dist/chunks/{studio-bqgs90r8.js → studio-ndskgqef.js} +4 -4
- package/dist/chunks/studio-p1n2xjda.js +5 -0
- package/dist/chunks/studio-pgm83a2f.js +6 -0
- package/dist/chunks/studio-pqqq6v85.js +5 -0
- package/dist/chunks/studio-psh8mwnw.js +4 -0
- package/dist/chunks/{studio-cpdzrdgp.js → studio-r17asgs0.js} +4 -4
- package/dist/chunks/{studio-6vrxzkba.js → studio-ry81j4q1.js} +4 -4
- package/dist/chunks/studio-rzg8hnkf.js +5 -0
- package/dist/chunks/{studio-nsv7g1qn.js → studio-s0fg2wav.js} +4 -4
- package/dist/chunks/{studio-v0gsjav0.js → studio-tj2s0tks.js} +4 -4
- package/dist/chunks/studio-tyw7tk0x.js +5 -0
- package/dist/chunks/studio-v9ywz2se.js +6 -0
- package/dist/chunks/{studio-dmn7gpba.js → studio-vswcpzk7.js} +5 -5
- package/dist/chunks/studio-vzgmyt0v.js +5 -0
- package/dist/chunks/{studio-2dtc90zs.js → studio-wxdcd42g.js} +6 -6
- package/dist/chunks/{studio-c5dj3dzk.js → studio-wxhy1yh7.js} +4 -4
- package/dist/chunks/studio-x08a3m0a.js +5 -0
- package/dist/chunks/studio-x3mjr5cc.js +5 -0
- package/dist/chunks/{studio-xddgbwhe.js → studio-x97ay0v4.js} +4 -4
- package/dist/chunks/{studio-mmqr9awv.js → studio-xdpz9rpe.js} +33 -33
- package/dist/chunks/studio-xh683qzy.js +5 -0
- package/dist/chunks/{studio-hxq1ebp0.js → studio-xkxetm65.js} +6 -6
- package/dist/chunks/{studio-73wz63nn.js → studio-y26hx9re.js} +4 -4
- package/dist/chunks/{studio-kdseew9m.js → studio-yg3djpnm.js} +4 -4
- package/dist/chunks/studio-yx8hzqja.js +5 -0
- package/dist/chunks/studio-zg16eeq1.js +5 -0
- package/dist/chunks/studio-zgx7svjd.js +9 -0
- package/dist/chunks/studio-zkq3r91p.js +5 -0
- package/dist/chunks/{toast-host-1yg5ar8d.js → toast-host-g3r2s0kn.js} +2 -2
- package/dist/chunks/toast-w11qpkyz.js +4 -0
- package/dist/chunks/{tsMode-vra2hh7y.js → tsMode-h6tkz0ea.js} +5 -5
- package/dist/chunks/workspace-home-zkkrxq3r.js +4 -0
- package/dist/chunks/workspace-tdqqjqaa.js +4 -0
- package/dist/chunks/{ws-client-72x5n99j.js → ws-client-e951my95.js} +3 -3
- package/dist/iframe-entry.js +13 -13
- package/dist/manifest.json +77 -77
- package/dist/studio.js +91 -92
- package/package.json +11 -12
- package/src/canvas/iframe-editable-root.ts +32 -2
- package/src/collab/collab-session.ts +6 -2
- package/src/commands/context.ts +4 -0
- package/src/commands/defaults.ts +2 -0
- package/src/commands/live-context.ts +2 -0
- package/src/files/files.ts +6 -3
- package/src/format/format-host.ts +1 -1
- package/src/github/github-auth-status.ts +2 -2
- package/src/media/media-library.ts +73 -3
- package/src/new-project/new-project-modal.ts +1 -4
- package/src/packages/ensure-deps.ts +5 -5
- package/src/packages/pull-package-sync.ts +4 -4
- package/src/panels/activity-panel.ts +1 -1
- package/src/panels/ai-panel.ts +27 -34
- package/src/platform.ts +20 -0
- package/src/platforms/cloud.ts +48 -34
- package/src/platforms/devserver.ts +2 -120
- package/src/services/ai-ask.ts +29 -171
- package/src/services/ai-command-tools.ts +40 -50
- package/src/services/ai-import-tools.ts +4 -5
- package/src/services/ai-project-tools.ts +13 -3
- package/src/services/ai-tools.ts +26 -564
- package/src/services/ai-writes.ts +84 -2
- package/src/services/document-assistant.ts +29 -58
- package/src/services/harness/assistant-tools.ts +68 -0
- package/src/services/harness/interaction-store.ts +118 -0
- package/src/services/harness/studio-documents.ts +105 -0
- package/src/services/harness/turn-hooks.ts +1 -6
- package/src/services/project-adoption.ts +8 -16
- package/src/services/tool-executor.ts +25 -22
- package/src/settings/extension-commands.ts +1 -1
- package/src/settings/extension-rows.ts +1 -6
- package/src/settings/extensions-section.ts +3 -6
- package/src/state.ts +3 -13
- package/src/surfaces/block-action-bar.json +1 -3
- package/src/surfaces/files-panel.json +12 -0
- package/src/surfaces/files-panel.ts +5 -2
- package/src/surfaces/media-library.json +35 -0
- package/src/surfaces/media-library.ts +2 -0
- package/src/surfaces/menu.ts +62 -1
- package/src/surfaces/settings-packages.ts +1 -1
- package/src/surfaces/welcome.ts +4 -1
- package/src/tabs/selection.ts +14 -109
- package/src/tabs/tab.ts +10 -1
- package/src/tabs/transact.ts +316 -124
- package/src/types.ts +23 -16
- package/src/ui/layers.ts +1 -1
- package/src/ui/progress-modal.ts +3 -3
- package/dist/chunks/adapter-tck81zft.js +0 -4
- package/dist/chunks/add-new-flow-a1w0bnm6.js +0 -4
- package/dist/chunks/cf-account-picker-ce3kp3x1.js +0 -4
- package/dist/chunks/cf-settings-7ye6x7g2.js +0 -4
- package/dist/chunks/color-4gj49xq6.js +0 -4
- package/dist/chunks/components-qce0v93f.js +0 -4
- package/dist/chunks/content-source-jjx8kgzr.js +0 -4
- package/dist/chunks/editor-bkja5dbv.js +0 -4
- package/dist/chunks/entry-commands-1wh0btvg.js +0 -4
- package/dist/chunks/file-ops-6pe4z7an.js +0 -4
- package/dist/chunks/files-ybpp3j38.js +0 -4
- package/dist/chunks/format-host-3mtbhxk1.js +0 -4
- package/dist/chunks/fs-events-xfanfxds.js +0 -4
- package/dist/chunks/grid-open-dg5qmnaj.js +0 -4
- package/dist/chunks/iframe-host-j2bk2xkc.js +0 -4
- package/dist/chunks/index-fkrm7pdk.js +0 -4
- package/dist/chunks/jx-validate-w7v32f6a.js +0 -4
- package/dist/chunks/layers-g7j732cm.js +0 -4
- package/dist/chunks/layers-panel-gjrsxcck.js +0 -4
- package/dist/chunks/lit-html-jdfz9rhc.js +0 -4
- package/dist/chunks/media-library-9j0v4wmk.js +0 -4
- package/dist/chunks/media-picker-cpyyt2m0.js +0 -4
- package/dist/chunks/monaco-buffer-9wcme176.js +0 -4
- package/dist/chunks/notify-rahnnnv4.js +0 -4
- package/dist/chunks/parse-v77xtwv7.js +0 -4
- package/dist/chunks/platform-b2aqv7v5.js +0 -4
- package/dist/chunks/publish-panel-4yk2461b.js +0 -4
- package/dist/chunks/publish-workspace-mxestzcf.js +0 -4
- package/dist/chunks/quick-search-9g6z65b0.js +0 -4
- package/dist/chunks/references-c26enpxs.js +0 -4
- package/dist/chunks/right-panel-9d0e0yg7.js +0 -4
- package/dist/chunks/source-control-xyn3a8ds.js +0 -4
- package/dist/chunks/studio-0khd0xdw.js +0 -5
- package/dist/chunks/studio-1fvzq9vs.js +0 -5
- package/dist/chunks/studio-1yhz0s8p.js +0 -5
- package/dist/chunks/studio-2c2mjyzj.js +0 -6
- package/dist/chunks/studio-3pndhat0.js +0 -9
- package/dist/chunks/studio-4fjqdzrb.js +0 -6
- package/dist/chunks/studio-5abge3wy.js +0 -5
- package/dist/chunks/studio-74nzv280.js +0 -5
- package/dist/chunks/studio-7cg75gtj.js +0 -14
- package/dist/chunks/studio-89cwmnae.js +0 -5
- package/dist/chunks/studio-8m1t83kn.js +0 -7
- package/dist/chunks/studio-a3evp7f6.js +0 -6
- package/dist/chunks/studio-ana67wax.js +0 -5
- package/dist/chunks/studio-b4xhpcwy.js +0 -4
- package/dist/chunks/studio-c4rcaftm.js +0 -5
- package/dist/chunks/studio-cgjt1zce.js +0 -5
- package/dist/chunks/studio-cq87hree.js +0 -5
- package/dist/chunks/studio-d140sy8e.js +0 -5
- package/dist/chunks/studio-e1g64q43.js +0 -5
- package/dist/chunks/studio-e8pzjjhf.js +0 -5
- package/dist/chunks/studio-f8kz3krj.js +0 -7
- package/dist/chunks/studio-fw3jp9m7.js +0 -5
- package/dist/chunks/studio-g6ysm05p.js +0 -7
- package/dist/chunks/studio-gmhd0j3f.js +0 -5
- package/dist/chunks/studio-gqpty626.js +0 -5
- package/dist/chunks/studio-grp684wx.js +0 -5
- package/dist/chunks/studio-h98520qr.js +0 -5
- package/dist/chunks/studio-hvxt8z79.js +0 -5
- package/dist/chunks/studio-j4e627w1.js +0 -5
- package/dist/chunks/studio-kt2j51sa.js +0 -5
- package/dist/chunks/studio-m4w6sygj.js +0 -16
- package/dist/chunks/studio-nqxqf8p2.js +0 -4
- package/dist/chunks/studio-p89w12s2.js +0 -7
- package/dist/chunks/studio-pbagym4j.js +0 -5
- package/dist/chunks/studio-pr23qhrw.js +0 -5
- package/dist/chunks/studio-r4ya3sb2.js +0 -5
- package/dist/chunks/studio-rm9m3z60.js +0 -5
- package/dist/chunks/studio-tpmnbgmt.js +0 -5
- package/dist/chunks/studio-ttxhq5yt.js +0 -5
- package/dist/chunks/studio-y1x65h5r.js +0 -5
- package/dist/chunks/studio-zf188hnd.js +0 -5
- package/dist/chunks/toast-1gv0h53h.js +0 -4
- package/dist/chunks/workspace-3nt93k48.js +0 -4
- package/dist/chunks/workspace-home-zbgyqqws.js +0 -4
- package/src/services/directory-picker.ts +0 -187
- package/src/services/gated-registry.ts +0 -77
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{ge,Qs,ne,g,de,Eh,C}from"./studio-4kzbrr5t.js";import{Yd}from"./studio-x08a3m0a.js";import{p}from"./studio-03mqh8ax.js";import{Wi,fn,lr}from"./studio-3w35qvay.js";import{tI,OC,Lo,XO,Wx,nI,iI,tM,wv}from"./studio-ry81j4q1.js";import{yv,J$,Er,S}from"./studio-45gyxpcq.js";import{Se,oe,Lv,$v,FC,sf,jC,ta,af,Ym,Gx}from"./studio-ekgtrndg.js";import{n,Z,Ze,_,v,Go,Di,ed,cf}from"./studio-zkq3r91p.js";import{le}from"./studio-7xag4na8.js";var we=g(new Set);function Mm(e){we.add(e)}function kx(e){we.delete(e)}function wC(e){return we.has(e)}var R$=()=>({kind:"proceed"});function av(e,t){return{success:!0,data:e,summary:t}}function Fn(e){return{success:!1,error:e}}function Ur({name:e,description:t,parameters:o,strict:r=!0,llmStrict:i=!1,interactive:s,title:a,annotations:l,interaction:c,settle:d,execute:b}){let f={name:e,description:t,parameters:o,strict:r,llmStrict:i,execute:b};if(s!==void 0)f.interactive=s;if(a!==void 0)f.title=a;if(l!==void 0)f.annotations=l;if(c!==void 0)f.interaction=c;if(d!==void 0)f.settle=d;return f}function Ex(e){let t=[];return{record(o){t.push(o),e?.(o)},writes:t}}function mh(e=null,t={}){let o=new Map(Object.entries(t));return{sessionId:e,get:(r)=>o.get(r),set:(r,i)=>{o.set(r,i)},toJSON:()=>Object.fromEntries(o)}}var zt=new AbortController().signal;function Tx(e={}){let t=e.session??mh();return{actor:e.actor??{id:`assistant:${t.sessionId??"local"}:`,kind:"assistant",sessionId:t.sessionId,turnId:""},callId:e.callId??"",ledger:e.ledger??Ex(),progress:e.progress??(()=>{}),session:t,signal:e.signal??zt}}function oO(e){let t=new AbortController;if(e.aborted)return t.abort(e.reason),{release:()=>{},signal:t.signal};let o=()=>{t.abort(e.reason)};return e.addEventListener("abort",o,{once:!0}),{release:()=>{e.removeEventListener("abort",o)},signal:t.signal}}function Lx(){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)=>{let o={name:t.name,description:t.description,parameters:t.parameters};if(t.llmStrict===!0)o.strict=!0;return{type:"function",function:o}})},getDefinition(t){return e.get(t)},validate(t,o){let r=e.get(t);if(!r)return{valid:!1,errors:[`Unknown tool: "${t}"`]};if(!r.strict)return{valid:!0};let i=r.parameters;if(!i.properties)return{valid:!0};let s=[],a=i.properties,l=i.required||[];for(let c of l)if(!(c in o)||o[c]===void 0||o[c]===null)s.push(`Missing required argument: "${c}"`);for(let[c,d]of Object.entries(o)){let b=a[c];if(!b)continue;let f=b.type;if(!f)continue;let x=Ge(d);if(f==="number"||f==="integer"){if(Re(d,"number"))continue;if(Re(d,"string")){if(!Number.isNaN(Number(d)))continue;s.push(`Argument "${c}" should be a number, got non-numeric string "${d}"`);continue}s.push(`Argument "${c}" should be a number, got ${x}`);continue}if(f==="string"&&x!=="string")s.push(`Argument "${c}" should be a string, got ${x}`);else if(f==="boolean"&&x!=="boolean")s.push(`Argument "${c}" should be a boolean, got ${x}`);else if(f==="array"&&x!=="array")s.push(`Argument "${c}" should be an array, got ${x}`);else if(f==="object"&&x!=="object")s.push(`Argument "${c}" should be an object, got ${x}`)}return s.length>0?{valid:!1,errors:s}:{valid:!0}},async execute(t,o,r=Tx()){let i=e.get(t);if(!i)return Fn(`Unknown tool: "${t}"`);let s=this.validate(t,o);if(!s.valid)return Fn(`Validation failed: ${(s.errors||[]).join("; ")}`);try{return await i.execute(o,r)}catch(a){return Fn(`Tool "${t}" execution error: ${me(a)}`)}}}}var Yt="The author declined this call.";function Zt(e){return JSON.parse(JSON.stringify(e))}function me(e){return e.message}var Xt=["string","number","boolean","undefined"];function Re(e,t){return typeof e===t}function Qt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Ge(e){if(Array.isArray(e))return"array";return Xt.find((t)=>Re(e,t))??"object"}function en(e){if(!e)return{};let t=JSON.parse(e);if(!Qt(t)){let o=t===null?"null":Ge(t);throw TypeError(`arguments must be a JSON object, got ${o}`)}return t}async function D$(e,t,o,{approval:r=R$,response:i}={}){let s=!1,a;try{let l=en(t.argumentsText),c=e.getDefinition(t.name),d=c?tn(e,c,l,r,i):null;if(d?.status==="needs_input")return d;if(d)({result:a}=d);else s=!0,a=await e.execute(t.name,l,o)}catch(l){a=Fn(`Failed to parse arguments: ${me(l)}`)}try{return{status:"done",result:Zt(a),executed:s}}catch(l){let c=me(l);return{status:"done",result:Fn(`Tool "${t.name}" returned a result that cannot be serialized: ${c}`),executed:s}}}function tn(e,t,o,r,i){let{interaction:s,settle:a}=t;if(s&&a){let c=e.validate(t.name,o);if(!c.valid)return pe(`Validation failed: ${(c.errors||[]).join("; ")}`);if(i)return{status:"done",result:nn(t.name,a,o,i),executed:!1};let d=s(o);return"refusal"in d?pe(d.refusal):{status:"needs_input",request:d}}let l=r(t,o);if(l.kind==="deny")return pe(l.message);if(l.kind==="confirm"){if(!i)return{status:"needs_input",request:{kind:"approval",reason:l.reason,summary:l.summary,title:t.title??t.name,tool:t.name}};if(i.kind!=="approval"||!i.approved)return pe(Yt)}return null}function pe(e){return{status:"done",result:Fn(e),executed:!1}}function nn(e,t,o,r){try{return t(o,r)}catch(i){return Fn(`Tool "${e}" execution error: ${me(i)}`)}}var on=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"]),bC="^[A-Za-z]{2,8}(-[A-Za-z0-9]{1,8})*$";function Pn(e){if(!n(e)||e.trim()==="")return null;try{return new Intl.Locale(e.trim()).toString()}catch{return null}}function yx(e){return Pn(e)!==null}function tv(e){let t=Pn(e);if(t===null)return"ltr";let o=new Intl.Locale(t),r=o.script??o.maximize().script;return r!==void 0&&on.has(r)?"rtl":"ltr"}function Vt(e){let t=Pn(e);if(t===null)return n(e)?e:"";return new Intl.DisplayNames([t],{type:"language"}).of(t)??t}var rn="prefix-except-default";function ln(e){let t=e.i18n,o=[];if(!_(t))return{errors:o,i18n:null};let r=Array.isArray(t.locales)?t.locales:[],i=[];for(let l of r){let c=Pn(l);if(c===null){o.push(`i18n.locales: "${String(l)}" is not a well-formed BCP 47 language tag.`);continue}if(!i.includes(c))i.push(c)}let s=Pn(t.defaultLocale)??i[0]??null;if(t.defaultLocale!==void 0&&Pn(t.defaultLocale)===null)o.push(`i18n.defaultLocale: "${String(t.defaultLocale)}" is not a well-formed BCP 47 language tag.`);if(s===null)return o.push("i18n is declared with no usable locale — set `defaultLocale` or `locales`."),{errors:o,i18n:null};if(!i.includes(s))i.unshift(s);let a=t.routing==="prefix-always"||t.routing==="prefix-except-default"?t.routing:rn;return{errors:o,i18n:{defaultLocale:s,locales:i,routing:a}}}function go(e,t){let o=Ae(q(e),t);if(o===-1||t===null)return null;return Pn(q(e)[o])}function wx(e,t){let o=go(e,t);if(o!==null||t===null||t.routing!=="prefix-except-default")return o;return q(e)[0]==="pages"?t.defaultLocale:null}function nv(e,t){let o=q(e),r=Ae(o,t);return r===-1?o.join("/"):o.filter((i,s)=>s!==r).join("/")}function Kc(e,t,o){if(o===null)return null;let r=Pn(t);if(r===null||!o.locales.includes(r))return null;let i=q(e),s=Ae(i,o),a=s===-1?sn(i):s;if(a===-1)return null;let l=s===-1?i:i.filter((c,d)=>d!==s);if(r===o.defaultLocale&&o.routing==="prefix-except-default")return l.join("/");return l.toSpliced(a,0,r.toLowerCase()).join("/")}function q(e){return e.replace(/^\.\//,"").split("/").filter(Boolean)}function Ae(e,t){if(t===null)return-1;return e.findIndex((o)=>{let r=Pn(o);return r!==null&&t.locales.includes(r)})}function sn(e){if(e[0]==="pages"&&e.length>1)return 1;if(e[0]==="content"&&e.length>2)return 2;return-1}function tO(e,t){if(t===null)return null;let o=e.split("/").find(Boolean);if(o===void 0)return t.defaultLocale;let r=Pn(o);return r!==null&&t.locales.includes(r)?r:t.defaultLocale}function A$(e,t){if(!n(t)||t==="")return e;let o=e.indexOf("#"),r=o===-1?"":e.slice(o),i=o===-1?e:e.slice(0,o),s=i.indexOf("?"),a=s===-1?i:i.slice(0,s),c=(s===-1?[]:i.slice(s+1).split("&")).filter((d)=>d!==""&&!cn(d));return c.push(`v=${encodeURIComponent(t)}`),`${a}?${c.join("&")}${r}`}function cn(e){let t=e.indexOf("="),o=t===-1?e:e.slice(0,t);if(o==="v")return!0;if(!o.includes("%"))return!1;try{return decodeURIComponent(o)==="v"}catch{return!1}}function un(e,t){if(!e||!Object.hasOwn(e,t))return;let o=e[t];return n(o)?o:void 0}function dv(e,t,o=[]){if(!e||!t)return null;let r=e.replaceAll("\\","/").replace(/^\.\//,""),i=null,s=(a,l)=>{if(r.startsWith(`${a}/`)&&(!i||a.length>i.dir.length))i={dir:a,urlPrefix:l}};for(let[a,l]of Object.entries(t)){if(!l?.source||!OC.test(a))continue;let c=mn(l.source);if(c===""||c.startsWith(".."))continue;if(c.includes(Lo)){let d=dn(r,c,a,o);if(d)s(d.dir,d.urlPrefix);continue}if(/\.[a-z0-9]+$/i.test(c))continue;s(c,`/${tI}/${a}`)}return i}function dn(e,t,o,r){let i=t.indexOf(Lo),s=t.slice(0,i),a=t.slice(i+Lo.length);if(!e.startsWith(s))return null;let l=e.slice(s.length).split("/")[0]??"";if(l===""||!OC.test(l))return null;let c=r.find((b)=>b.toLowerCase()===l.toLowerCase());if(c===void 0||!OC.test(c))return null;return{dir:`${s}${l}${a}`.replace(/\/+$/,""),urlPrefix:`/${tI}/${o}/${c}`}}function mn(e){return e.replaceAll("\\","/").replace(/^\.\//,"").replace(/\/+$/,"")}function uv(e,t){if(!t||e==="")return null;if(t.space==="repo"){if(!t.fileBaseUrl)return null;let r=tM(e,t.documentDir,t.mounts,t.lanes);if(r===null)return null;let{suffix:i}=Wx(e);return A$(`${t.fileBaseUrl}${wv(r)}${i}`,un(t.versions,r))}let[o]=t.mounts;return o?gn(e,t.documentDir,o):null}function gn(e,t,o){if(nI(e))return null;let{path:r,suffix:i}=Wx(e),s;try{s=decodeURIComponent(r)}catch{return null}let a=iI(t,s);if(a===null)return null;let l=XO([o],a);if(!l)return null;return`${l}${i}`}function ze(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}function G(e){return e.replaceAll("\\","/").replace(/^\.\//,"").replace(/\/+$/,"")}function Ye(e){return e??S?.projectConfig??null}function Xe(e){return e?.content??{}}function yn(e){let t=ln(e??{}).i18n?.locales??[];return t.length>0?[...t]:null}function et(e){if(e.endsWith("/"))return!1;let t=e.slice(e.lastIndexOf("/")+1);return/\.[a-z\d]+$/i.test(t)}function tt(e){if(e.format==="json")return{ext:".json",unresolvedFormat:null};if(e.format===void 0||e.format==="")return{ext:lr()?.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 bn(e,t){let o=t===null?"[^/]+":`(?:${t.map((i)=>ze(i)).join("|")})`,r=G(e).split(Lo).map((i)=>ze(i)).join(o);return new RegExp(`^${r}(?:/|$)`,"i")}function hn(e,t,o){let r=bn(e,o).exec(t);if(!r)return null;return r[0].replace(/\/$/,"")}function xn(e){return G(e).replaceAll(Lo,"").length}function Wd(e,t){if(e===null||e===void 0||e==="")return null;let o=Ye(t),r=yn(o),i=G(e),s=null,a=-1;for(let[l,c]of Object.entries(Xe(o))){let{source:d}=c;if(d===void 0||d===""||et(d))continue;let b=xn(d);if(b<=a)continue;let f=hn(d,i,r);if(f===null)continue;s={def:c,dir:i,fileBacked:!1,isSourceRoot:i.length===f.length,name:l,...tt(c)},a=b}return s}function Un(e,t){if(e===null||e===void 0||e==="")return null;let o=Ye(t),r=G(e),i=r.toLowerCase();for(let[s,a]of Object.entries(Xe(o))){let{source:l}=a;if(l===void 0||l===""||!et(l))continue;let c=G(l).toLowerCase();if(i===c||i.endsWith(`/${c}`))return{def:a,dir:r.includes("/")?r.slice(0,r.lastIndexOf("/")):".",fileBacked:!0,isSourceRoot:!1,name:s,...tt(a)}}return Wd(r.includes("/")?r.slice(0,r.lastIndexOf("/")):".",o)}function Jc(e){return e.replaceAll(/([A-Z])/g," $1").replace(/^./,(t)=>t.toUpperCase())}function Nx(e){return e.replaceAll(/[^a-zA-Z0-9]+(.)?/g,(t,o)=>o?o.toUpperCase():"").replace(/^[A-Z]/,(t)=>t.toLowerCase())}function Ax(e){return e.replaceAll(/(^|-)(\w)/g,(t,o,r)=>(o?" ":"")+r.toUpperCase())}function SC(e,t){return e?.$label||Jc(t)}function yO(e,t){if(e?.$label)return e.$label;if(t.includes("-"))return t.replaceAll(/(^|-)(\w)/g,(o,r,i)=>(r?" ":"")+i.toUpperCase());return Jc(t)}function Ia(e){return e==="image"||e==="uri-reference"}function gh(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(Ia(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 bh(e,t){if(!e||!t?.content)return null;let o=Un(e,t);if(!o||!o.def.schema)return null;if(!o.fileBacked){let r=o.ext??lr()?.extensions[0]??".json";if(!e.toLowerCase().endsWith(r.toLowerCase()))return null}return{name:o.name,schema:o.def.schema}}function pv(e,t){let o=e.trim().toLowerCase().replaceAll(/[^a-z0-9\s-]/g,"").replaceAll(/\s+/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,"");if(!o)return"";return`${t}${o}`}function Ox(e,t){return e.replace(new RegExp(`^${t.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}`),"").replace(/^--/,"").replaceAll("-"," ").replaceAll(/\b\w/g,(o)=>o.toUpperCase())||e}function wO(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((i)=>i[1])};return{kind:"text"}}function ir(e){return JSON.parse(JSON.stringify(e))}function Oe(e){return e?.at(-1)??null}function aO(e){return e?.[0]??null}function $x(e,t){if(!t||!e)return!1;return e.some((o)=>Er(o,t))}function $a(e){return z(e)}function z(e){let t=[];for(let o of e)t.push([...o]);return t}function Ix(e,t){if($x(e,t))return z(e.filter((o)=>!Er(o,t)));return[...z(e),[...t]]}function lO(e,t,o){let r=e.findIndex((a)=>Er(a,o)),i=t?e.findIndex((a)=>Er(a,t)):-1;if(r===-1||i===-1)return[[...o]];let s=i<=r?e.slice(i,r+1):e.slice(r,i+1).toReversed();return z(s)}function ye(e,t){return z(e.filter((o)=>!ta(t,o)))}function cO(e){let t=[];for(let o of e)if(!t.some((r)=>Er(r,o)))t.push([...o]);return t}function jm(e){if(e.length===0)return{mixed:!1,value:void 0};let[t]=e,o=JSON.stringify(t??null);for(let r=1;r<e.length;r++)if(JSON.stringify(e[r]??null)!==o)return{mixed:!0,value:void 0};return{mixed:!1,value:t}}var nt=null;function vO(e){nt=e}function ot(){return nt}var X=null,Q=null,ee=null,Je=!0;function rt(){X=[],Q=[],ee=[],Je=!0}function y(e){if(X)X.push(e)}function Bi(e){if(Q)Q.push(e)}function it(e){if(ee)ee.push(e)}function st(){let e={docOps:Q??[],fmOps:ee??[],invertible:Je,ops:X??[]};return X=null,Q=null,ee=null,Je=!0,e}var vn=100,On=20;function te(){try{return typeof localStorage>"u"||!localStorage.getItem("jx-legacy-history")}catch{return!0}}function w(e,t){let o=oe(e,t);if(!o)throw TypeError(`No node at path [${t.join(", ")}]`);return o}function P(e,t,o,r){return{forward:{key:t,op:"set-key",path:e,value:r},inverse:{key:t,op:"set-key",path:e,value:o}}}var at=null;function lt(e){at=e}var ct=null;function ut(e){ct=e}function Sn(e,t,o,r){for(let i=t.docOps.length-1;i>=0;i--)$v(e.doc.document,de(t.docOps[i].inverse));for(let i=t.fmOps.length-1;i>=0;i--){let s=t.fmOps[i];je(e,s.field,s.before)}e.doc.document={...de(e.doc.document)},e.session.selection=o,e.doc.dirty=r}function Y(e,t,{skipHistory:o=!1,origin:r="user",coalesceKey:i=null,actor:s=null}={}){if(!e)return!1;if(r!=="remote"&&ct?.(e,r))return!1;let a=s??be;if(r!=="remote")De(e,a);let l=$a(e.session.selection),c=e.doc.dirty;rt();let d,b=null;try{t(e)}catch(A){b={error:A}}finally{d=st()}if(b)throw Sn(e,d,l,c),b.error;let f=de(e.doc.document),x={...f},k=ot(),j=k===null?{patchable:!1,reason:"no-patch-consumer"}:d.ops.length===0?{patchable:!1,reason:"unrecorded-mutation"}:k.classify(e,d.ops);if(j.patchable)k.markConsumed(x,e);if(e.doc.document=x,j.patchable)try{k.apply(e,d.ops,d)}catch(A){k.escalate(`patch-apply-failed: ${A instanceof Error?A.message:String(A)}`,e)}if(!o){let A=a?Rn(a):null;if(A)An(A,e,d,l);else dt(e,f,d,l,i)}return e.doc.dirty=!0,at?.(e,d,r),!0}function dt(e,t,o,r,i=null){let s=e.history.snapshots.slice(0,e.history.index+1),a=te()&&o.invertible&&(o.docOps.length>0||o.fmOps.length>0),l=s.at(-1);if(i&&a&&l&&l.coalesceKey===i&&l.inverseOps){if(l.forwardOps=[...l.forwardOps??[],...o.docOps.map((d)=>d.forward)],l.inverseOps=[...l.inverseOps,...o.docOps.map((d)=>d.inverse)],l.selection=$a(e.session.selection),l.document)l.document=ir(t);e.history.snapshots=s,e.history.index=s.length-1;return}let c=!a||s.length%On===0;if(s.push({document:c?ir(t):null,fmOps:a&&o.fmOps.length>0?o.fmOps:null,forwardOps:a?o.docOps.map((d)=>d.forward):null,inverseOps:a?o.docOps.map((d)=>d.inverse):null,coalesceKey:i,selection:$a(e.session.selection),selectionBefore:r}),s.length>vn){if(!s[1].document)s[1].document=Ie(s,1);s.shift()}e.history.snapshots=s,e.history.index=s.length-1}function Ie(e,t){let o=t;while(o>=0&&!e[o].document)o-=1;let r=o<0?null:e[o].document;if(!r)throw Error("history-missing-checkpoint");let i=ir(r);for(let s=o+1;s<=t;s++)for(let a of e[s].forwardOps??[])$v(i,a);return i}function Vd(e,t,o){return Y(e,(r)=>t(r.doc.document),o)}function ke(e,t){Y(e,(o)=>{for(let r of t)xe(o,r)},{origin:"remote",skipHistory:!0})}function xO(e,t,{actor:o=null,selection:r={kind:"keep"}}={}){if(t.length===0)return"unchanged";return Y(e,(s)=>{for(let a of t)xe(s,a,jC(de(s.doc.document),a));Cn(s,r)},{actor:o})?"applied":"refused"}function Cn(e,t){if(t.kind==="prune")for(let o of t.under)e.session.selection=ye(e.session.selection,o);else if(t.kind==="follow"&&Er(Oe(e.session.selection),t.from))e.session.selection=[[...t.to]]}var wn=new Set(["state","$media","$head","$elements","imports","$layout"]);function xe(e,t,o=t){let r=null;if(t.op==="set-key")r=oe(e.doc.document,t.path)?.[t.key];switch($v(e.doc.document,t),Bi({forward:t,inverse:o}),t.op){case"set-key":{if(wn.has(t.key))y({key:t.key,op:"doc-meta"});else if(t.key==="style")y({op:"set-style",path:t.path});else if(t.key==="textContent")y({op:"set-text",path:t.path});else if(t.key==="attributes"||t.key==="cases"||t.key==="$props")y({op:"replace",path:t.path});else{let i=t.key.startsWith("on")&&(cf(t.value)||cf(r));y({isEvent:i,key:t.key,op:"set-prop",path:t.path})}return}case"insert-child":{y({index:t.index,op:"insert",parentPath:t.parentPath});return}case"remove-child":{y({op:"remove",path:[...t.parentPath,"children",t.index]});return}case"set-child":{y({op:"replace",path:[...t.parentPath,"children",t.index]});return}case"move-child":{y({fromPath:[...t.fromParentPath,"children",t.fromIndex],op:"move",toIndex:t.toIndex,toParentPath:t.toParentPath});break}default:break}}var V=new Map,M=new Map,be=null,ft=null;function pt(e){ft=e}function _O(e){let t=V.get(e.id);if(t)he(t);let o={owner:e,receipts:[]};return V.set(e.id,o),{owner:e,flush:()=>he(o),close:()=>{if(he(o),V.get(e.id)===o)V.delete(e.id);return[...o.receipts]}}}function H$(e,t){let o=be;be=e;try{return t()}finally{be=o}}function mt(e,t){let o=M.get(e);return o!==void 0&&(!t||o.lane.owner.id===t.id)}function SO(){for(let e of V.values())he(e)}function Rn(e){return V.get(e.id)??null}function he(e){for(let[t,o]of M)if(o.lane===e)gt(t,o)}function An(e,t,o,r){let i=M.get(t);if(!i)i={docOps:[],fmOps:[],invertible:!0,lane:e,selectionBefore:r},M.set(t,i);if(i.docOps.push(...o.docOps),i.fmOps.push(...o.fmOps),!o.invertible||o.docOps.length===0&&o.fmOps.length===0)i.invertible=!1}function De(e,t){let o=M.get(e);if(o&&o.lane.owner.id!==t?.id)gt(e,o)}function gt(e,t){M.delete(e);let{owner:o}=t.lane,r=o.turnId??"";if(F.has(e))t.lane.receipts.push({entry:null,tab:e,turnId:r});else{let i={docOps:t.docOps,fmOps:t.fmOps,invertible:t.invertible,ops:[]};dt(e,de(e.doc.document),i,t.selectionBefore);let s=e.history.snapshots[e.history.index];if(s.actor=o.id,o.turnId!==void 0)s.turnId=o.turnId;t.lane.receipts.push({entry:s,tab:e,turnId:r})}ft?.(e)}var F=new WeakMap;function fv(e,t){if(t)F.set(e,t);else F.delete(e)}function CO(e){let t=F.get(e);return t?t.canUndo(e):e.history.index>0||M.has(e)}function kO(e){let t=F.get(e);return t?t.canRedo(e):!M.has(e)&&e.history.index<e.history.snapshots.length-1}function yt(e,t){let{snapshots:o}=e.history;e.doc.document=Ie(o,t);let r=o[t];e.session.selection=$a(de(r.selection))}function bt(e,t){try{if(typeof localStorage>"u"||!localStorage.getItem("jx-canvas-debug"))return}catch{return}let o=JSON.stringify(Ie(e.history.snapshots,t)),r=JSON.stringify(ir(de(e.doc.document)));if(o!==r)console.error("jx history: ops-based undo/redo diverged from checkpoint replay",{index:t})}function CC(e){De(e,null);let t=F.get(e);if(t){t.undo(e);return}if(e.history.index<=0)return;let o=e.history.snapshots[e.history.index],r=te()?o.inverseOps:null,i=te()?o.fmOps:null;if(r&&r.length>0||i&&i.length>0){if(!Y(e,(a)=>{if(r)for(let l=r.length-1;l>=0;l--)xe(a,de(r[l]));if(i)for(let l=i.length-1;l>=0;l--){let c=de(i[l]);je(a,c.field,c.before)}},{origin:"history",skipHistory:!0}))return;e.session.selection=$a(de(o.selectionBefore??[])),e.history.index-=1,bt(e,e.history.index)}else e.history.index-=1,yt(e,e.history.index);e.doc.dirty=!0}function EO(e){De(e,null);let t=F.get(e);if(t){t.redo(e);return}if(e.history.index>=e.history.snapshots.length-1)return;let o=e.history.snapshots[e.history.index+1],r=te()?o.forwardOps:null,i=te()?o.fmOps:null;if(r&&r.length>0||i&&i.length>0){if(!Y(e,(a)=>{if(r)for(let l of r)xe(a,de(l));if(i)for(let l of i){let c=de(l);je(a,c.field,c.after)}},{origin:"history",skipHistory:!0}))return;e.session.selection=$a(de(o.selection)),e.history.index+=1,bt(e,e.history.index)}else e.history.index+=1,yt(e,e.history.index);e.doc.dirty=!0}function or(e,t,o,r){let i=oe(e.doc.document,t);if(!i)return;let s=Lv(i),a=sf(o,s.length);s.splice(a,0,structuredClone(r)),y({index:a,op:"insert",parentPath:t}),Bi({forward:{index:a,node:Se(r),op:"insert-child",parentPath:t},inverse:{index:a,op:"remove-child",parentPath:t}})}function vh(e,t){let o=af(t);if(!o)return;let{index:r,parentPath:i}=o,[s]=w(e.doc.document,i).children.splice(r,1);y({op:"remove",path:t}),Bi({forward:{index:r,op:"remove-child",parentPath:i},inverse:{index:r,node:Se(s),op:"insert-child",parentPath:i}}),e.session.selection=ye(e.session.selection,t)}function B$(e,t){let o=af(t);if(!o)return;let r=oe(e.doc.document,t);if(!r)return;let{index:i,parentPath:s}=o,a=structuredClone(de(r));w(e.doc.document,s).children.splice(i+1,0,a),y({index:i+1,op:"insert",parentPath:s}),Bi({forward:{index:i+1,node:Se(a),op:"insert-child",parentPath:s},inverse:{index:i+1,op:"remove-child",parentPath:s}}),e.session.selection=[[...s,"children",i+1]]}function Hm(e,t){for(let o of Ym(t))vh(e,o)}function Mx(e,t){let o=[];for(let r of Ym(t)){let i=e.session.selection;B$(e,r);let s=Oe(e.session.selection),a=af(s);if(!s||!a||e.session.selection===i)continue;o=o.map((l)=>FC(a.parentPath,l,a.index,1,!0)),o.unshift(s)}if(o.length>0)e.session.selection=o}function TO(e,t,o="div"){let r=af(t);if(!r)return;let i=oe(e.doc.document,t);if(!i)return;let{index:s,parentPath:a}=r,l={children:[structuredClone(de(i))],tagName:o},c=Se(i);w(e.doc.document,a).children.splice(s,1,l),y({op:"replace",path:t}),Bi({forward:{index:s,node:Se(l),op:"set-child",parentPath:a},inverse:{index:s,node:c,op:"set-child",parentPath:a}}),e.session.selection=[[...a,"children",s]]}function Vp(e,t,o,r){let i=e.doc.document,s=Gx(i,t,o,r);if(!s)return;let{forward:a,inverse:l}=s,c=oe(i,a.fromParentPath),d=oe(i,o),[b]=c.children.splice(a.fromIndex,1);if(Lv(d).splice(a.toIndex,0,b),y({fromPath:t,op:"move",toIndex:a.toIndex,toParentPath:o}),Bi({forward:a,inverse:l}),Er(Oe(e.session.selection),t))e.session.selection=[[...l.fromParentPath,"children",l.fromIndex]]}function Qe(e,t,o,r){let i=oe(e.doc.document,t);if(!i)return;let s=i[o],a=Se(s);if(r===void 0||r===null||r==="")delete i[o];else i[o]=r;if(Bi(P(t,o,a,Se(i[o]))),o==="children")e.session.selection=ye(e.session.selection,[...t,"children"]);if(o==="textContent")y({op:"set-text",path:t});else if(o==="style")y({op:"set-style",path:t});else{let l=r===void 0||r===null||r===""?s:r,c=o.startsWith("on")&&cf(l);y({isEvent:c,key:o,op:"set-prop",path:t})}}function Bm(e,t,o,r){let i=w(e.doc.document,t),s=Se(i.style);if(!i.style)i.style={};if(r===void 0||r==="")delete i.style[o];else i.style[o]=r;if(Object.keys(i.style).length===0)delete i.style;Bi(P(t,"style",s,Se(i.style))),y({op:"set-style",path:t})}function Cr(e,t,o,r){let i=w(e.doc.document,t),s=Se(i.attributes);if(!i.attributes)i.attributes={};if(r===void 0||r==="")delete i.attributes[o];else i.attributes[o]=r;if(Object.keys(i.attributes).length===0)delete i.attributes;Bi(P(t,"attributes",s,Se(i.attributes))),y({attr:o,op:"set-attr",path:t})}function LO(e,t,o,r,i){if(!o)return Bm(e,t,r,i);let s=w(e.doc.document,t),a=Se(s.style);if(!s.style)s.style={};let l=`@${o}`,c=ed(s.style,l);if(i===void 0||i===""){if(delete c[r],Object.keys(c).length===0)delete s.style[l]}else c[r]=i;if(Object.keys(s.style).length===0)delete s.style;Bi(P(t,"style",a,Se(s.style))),y({op:"set-style",path:t})}function Px(e,t,o,r,i){let s=w(e.doc.document,t),a=Se(s.style);if(!s.style)s.style={};let l=ed(s.style,o);if(i===void 0||i===""){if(delete l[r],Object.keys(l).length===0)delete s.style[o]}else l[r]=i;if(Object.keys(s.style).length===0)delete s.style;Bi(P(t,"style",a,Se(s.style))),y({op:"set-style",path:t})}function $O(e,t,o,r,i,s){let a=w(e.doc.document,t),l=Se(a.style);if(!a.style)a.style={};let c=`@${o}`,d=ed(a.style,c),b=ed(d,r);if(s===void 0||s===""){if(delete b[i],Object.keys(b).length===0)delete d[r];if(Object.keys(d).length===0)delete a.style[c]}else b[i]=s;if(Object.keys(a.style).length===0)delete a.style;Bi(P(t,"style",l,Se(a.style))),y({op:"set-style",path:t})}function ht(e,t){let o=[e];for(let r of t){let i=Di(o.at(-1),r);if(!i)break;o.push(i)}for(let r=o.length-2;r>=0;r--){let i=o[r],s=t[r],a=Di(i,s);if(a&&Object.keys(a).length===0)delete i[s]}}function Fx(e,t,o,r,i){let s=w(e.doc.document,t),a=Se(s.style);if(!s.style)s.style={};let l=s.style;for(let c of o)l=ed(l,c);if(i===void 0||i==="")delete l[r],ht(s.style,o);else l[r]=i;if(Object.keys(s.style).length===0)delete s.style;Bi(P(t,"style",a,Se(s.style))),y({op:"set-style",path:t})}function IO(e,t,o,r,i,s){let a=w(e.doc.document,t),l=Se(a.style);if(!a.style)a.style={};let c=`@${o}`,d=ed(a.style,c),b=d;for(let f of r)b=ed(b,f);if(s===void 0||s===""){if(delete b[i],ht(d,r),Object.keys(d).length===0)delete a.style[c]}else b[i]=s;if(Object.keys(a.style).length===0)delete a.style;Bi(P(t,"style",l,Se(a.style))),y({op:"set-style",path:t})}function RO(e,t,o){let r=w(e.doc.document,t),i=Se(r.style);if(o&&Object.keys(o).length>0)r.style=o;else delete r.style;Bi(P(t,"style",i,Se(r.style))),y({op:"set-style",path:t})}function Ud(e,t,o){let r=e.doc.document,i=Se(r.state);if(!r.state)r.state={};r.state[t]=o,Bi(P([],"state",i,Se(r.state))),y({key:"state",op:"doc-meta"})}function DO(e,t){let o=e.doc.document;if(o.state){let r=Se(o.state);if(delete o.state[t],Object.keys(o.state).length===0)delete o.state;Bi(P([],"state",r,Se(o.state))),y({key:"state",op:"doc-meta"})}}function qr(e,t,o){let r=e.doc.document,i=Se(r.state);if(!r.state)r.state={};let s=r.state[t],a=s==null?{}:!_(s)||Array.isArray(s)?{default:s}:s;r.state[t]=a,Object.assign(a,o);for(let l of Object.keys(a))if(a[l]===void 0||a[l]===null)delete a[l];Bi(P([],"state",i,Se(r.state))),y({key:"state",op:"doc-meta"})}function NO(e,t,o){let r=e.doc.document;if(!r.state||!r.state[t])return;let i=Se(r.state);r.state[o]=r.state[t],delete r.state[t],Bi(P([],"state",i,Se(r.state))),y({key:"state",op:"doc-meta"})}function Up(e,t,o,r){let i=w(e.doc.document,t),s=Se(i.$props);if(!i.$props)i.$props={};if(r===void 0||r===null||r==="")delete i.$props[o];else i.$props[o]=r;if(Object.keys(i.$props).length===0)delete i.$props;Bi(P(t,"$props",s,Se(i.$props))),y({op:"replace",path:t})}function AO(e,t,o,r){let i=w(e.doc.document,t),s=Se(i.cases);if(!i.cases)i.cases={};i.cases[o]=r||{tagName:"div",textContent:o},Bi(P(t,"cases",s,Se(i.cases))),y({op:"replace",path:t})}function OO(e,t,o){let r=w(e.doc.document,t);if(r.cases){let i=Se(r.cases);delete r.cases[o],Bi(P(t,"cases",i,Se(r.cases))),y({op:"replace",path:t})}}function MO(e,t,o,r){let i=w(e.doc.document,t);if(!i.cases||!i.cases[o])return;let s=Se(i.cases);i.cases[r]=i.cases[o],delete i.cases[o],Bi(P(t,"cases",s,Se(i.cases))),y({op:"replace",path:t})}function qd(e,t,o){let r=e.doc.content.frontmatter,i=Object.hasOwn(r,t)?Se(r[t]):void 0,s=o===void 0||o===null||o==="";if(s)delete r[t];else r[t]=o;let a=s?void 0:Se(o);it({after:a,before:i,field:t}),e.doc.dirty=!0}function je(e,t,o){if(o===void 0)delete e.doc.content.frontmatter[t];else e.doc.content.frontmatter[t]=o}var W=[],Jn=50;function PO(e){return Object.assign(Ex(),{turnId:e})}function FO(e,t,o=[]){if(t.length===0)return[];let r={batches:[...o],id:e,writes:[...t]};W.push(r);while(W.length>Jn)W.shift();return r.writes}function jO(e){return W.find((t)=>t.id===e)?.writes??[]}function HO(e){let t=W.find((s)=>s.id===e),o="There is no longer a record of what that turn changed.";if(!t)return"There is no longer a record of what that turn changed.";let r=t.writes.filter((s)=>s.disk).map((s)=>s.path);if(r.length>0)return`Cannot restore: ${r.join(", ")} ${r.length===1?"was":"were"} written straight to disk, which undo cannot reach.`;if(t.batches.length===0)return"There is no longer a record of what that turn changed.";let i=new Map;for(let s of t.batches)i.set(s.tab,[...i.get(s.tab)??[],s]);for(let[s,a]of i){let l=In(s,a);if(l)return l}for(let[s,a]of i)for(let l of a)CC(s);return[...i.keys()]}function In(e,t){let o=e.documentPath??"(untitled)";if(e.scope.active===!1)return`Cannot restore: ${o} was closed after that turn.`;if(t.some((l)=>l.entry===null))return`Cannot restore: ${o} is shared live, and Restore cannot check its undo history. Undo it in the document instead.`;let{index:r,snapshots:i}=e.history,s=i.slice(r-t.length+1,r+1);if(r-t.length>=0&&t.every((l,c)=>s[c]===l.entry))return null;return i.indexOf(t.at(-1).entry)>r?`Cannot restore: that turn's change to ${o} was already undone.`:`Cannot restore: ${o} has edits made since that turn began, which Restore would undo too.`}function BO(e){let t=e.filter((l)=>l.ok),o=new Set(t.map((l)=>l.path)),r=e.length-t.length;if(o.size===0)return r>0?`${r} change${r===1?"":"s"} failed`:"";let i=`Changed ${o.size} file${o.size===1?"":"s"}`,s=new Set(t.flatMap((l)=>l.disk?[l.path]:[])),a=[i];if(s.size>0)a.push(`${s.size} written to disk — undo cannot reach ${s.size===1?"it":"them"}`);if(r>0)a.push(`${r} failed`);return a.join(" · ")}function kC(){W.splice(0)}function zO(e,t){let o=null;for(let r=e.length-1;r>=0;r--){let i=e[r];if(i.id===t)return o;let s=i.role==="assistant"&&(i.content||(i.toolCalls?.length??0)>0);if(o===null&&s)o=i.id}return t===void 0?o:null}function Pm(e){let t=new Set,o=new Set;return yv(e,(r,i)=>{t.add(r),o.add(JSON.stringify(i))}),t.size===0?null:{fingerprints:o,pointers:t}}function rO(e,t){if(!t)return e;return Ee(e,"",t)}function Ee(e,t,o){if(Array.isArray(e)){let i=null;for(let[s,a]of e.entries()){let l=Ee(a,`${t}/${s}`,o);if(l!==a)i??=[...e],i[s]=l}return i??e}if(!v(e))return e;let r=null;for(let[i,s]of Object.entries(e)){let a=Ee(s,`${t}/${J$(i)}`,o);if(i==="children"&&Array.isArray(a)&&a.length===1){let[l]=a;if(Go(l)&&(o.pointers.has(t)||o.fingerprints.has(JSON.stringify(l))))a=l}if(a!==s)r??={...e},r[i]=a}return r??e}var vC=["design","content","media","styles","publish"],xx="design",iv=[{icon:"frame-corners",id:"design",title:"Design"},{icon:"file-text",id:"content",title:"Content"},{icon:"image",id:"media",title:"Media"},{icon:"paint-brush",id:"styles",title:"Styles"},{icon:"paper-plane-tilt",id:"publish",title:"Publish"}];function I$(e){return typeof e==="string"&&vC.some((t)=>t===e)}function ov(e){return iv.find((t)=>t.id===e)}var Me="workspace://",_x={content:"content-home",media:"media-home",publish:"publish-home"};function zp(e){return Object.hasOwn(_x,e)}function Yl(e){return`${Me}${e}`}function al(e){if(!e.startsWith(Me))return null;let t=e.slice(Me.length);return I$(t)&&zp(t)?t:null}function rv(e){let t=al(e);return t?ov(t).title:null}var kn=new Map([["design","canvas"],["edit","canvas"],["entry","entry"],["git-diff","diff"],["grid","grid"],["content-home","home"],["media-home","home"],["publish-home","home"],["media","media"],["preview","canvas"],["source","code"],["stylebook","config"],["tokens","tokens"]]),Wp={canvas:"Canvas",code:"Code",config:"Elements",diff:"Diff",entry:"Entry",grid:"Grid",home:"Home",media:"Media",none:"None",tokens:"Variables"};function Xs(e){return kn.get(e)??"canvas"}var Dn=new Map([["design","design"],["edit","edit"],["preview","preview"]]);function nO(e){return Dn.get(e)??"design"}var Sx=(e)=>e.editor.kind==="canvas",fh=(e)=>Sx(e)&&e.selection.count>0,Cx=(e)=>fh(e)&&!e.selection.isRoot;function sv(){return{project:{open:!1,isSite:!1,isRepo:!1,isMultilingual:!1},git:{ahead:0,behind:0,dirtyCount:0},workspace:{id:xx},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,openProject:!1,dataRows:!1,windowControls:!1,findReferences:!1,readFileBytes:!1,publish:!1}}}function yC(e={}){let t=sv();for(let o of Object.keys(e)){let r=e[o];if(r)Object.assign(t[o],r)}return t}var jn=["palette"],En=["caret","global"],Mn=["dock","global"],$n=["canvas","global"],Ln=["grid","global"],Nn=["code","global"],xt=["global"];function iO(e){if(e.modal.open)return jn;if(e.caret.active)return En;if(e.focus.region!=="pane")return Mn;switch(e.editor.kind){case"grid":return Ln;case"code":return Nn;case"canvas":return e.canvas.view==="preview"?xt:$n;default:return xt}}var an="project.json";function _n(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:"page",elementTab:"properties",showLayout:!0,styleFilter:"",styleSections:{},dataRows:{},dataLimits:{},styleShorthands:{},zoom:1}}var Wn=["edit","design","preview","source","stylebook","git-diff"];function lv({id:e,documentPath:t=null,fileHandle:o=null,document:r,frontmatter:i,sourceFormat:s=null,capabilities:a,openedFrom:l=null,preview:c=!1,layout:d=null,source:b=null,canvasMode:f}){let x=ge(),k=Pm(r),j=a?.modes??Bn(t,s),A=f??j.find((h)=>h!=="preview")??"edit",ce=j[0]==="preview",E={bareRepeaters:k,content:{frontmatter:i||{}},dirty:!1,document:r,handlersSource:null,layout:d,mode:Hn(t,s),source:b,sourceFormat:s},ue={index:0,snapshots:[{document:structuredClone(r),selection:[]}]},K={canvas:{refreshing:!1,error:null,livePreviews:null,pendingInlineEdit:null,scope:null,status:"idle"},clipboard:null,hover:null,openedFrom:l,selection:[],ui:_n(A,ce)};return x.run(()=>({capabilities:{modes:j},doc:g(E),documentPath:t,fileHandle:o,history:g(ue),id:e,pinned:!1,preview:c,scope:x,session:g(K)}))}function Bn(e,t){if(e===an)return["stylebook","tokens","source"];let o=Wi(t)??fn(e);if(o)return o.studio?.modes??["edit","design","preview","source"];return Wn}function Hn(e,t){let o=Wi(t)??fn(e);if(o)return o.studio?.documentMode?.default??"content";return"component"}function xC(e){return Xs(e.session.ui.canvasMode)}function N$(e){let t=[];for(let o of e.capabilities.modes){if(o==="preview")continue;let r=Xs(o);if(!t.includes(r))t.push(r)}return t}function sO(e,t){return e.capabilities.modes.find((o)=>o!=="preview"&&Xs(o)===t)}function Fm(e){e.scope.stop()}var Tt=new WeakMap,B=new Map;function Tn(e){let t=de(e),o=Tt.get(t);if(!o)o=g({active:!1,attachError:"",peers:[],readOnly:!1,sourceCanonical:!1,status:"unavailable"}),Tt.set(t,o);return o}function vt(e){B.set(e,(B.get(e)??0)+1)}function Ot(e){let t=B.get(e)??0;if(t<=1)B.delete(e);else B.set(e,t-1)}function cv(e){return B.has(e.replaceAll("\\","/"))}var Kn=8000,qn=800,Gn=2500,Pt=null;function zn(){return Pt??=(le("ewmgdb7c"),import("./index-ewmgdb7c.js")),Pt}function wt(){try{return p()}catch{return null}}var H=null;function dO(e){H=e}var Le=null;function uO(e){Le=e}var Rt=()=>{};function hO(e){Rt=e??(()=>{})}var Ne=new WeakMap;function At(e){return de(e)}function _e(e,t){return e.frontmatterMap(t)}function Yn(e){return e.synced}function D(e){return Ne.get(At(e))}function Be(e){let t=At(e),o=Ne.get(t);if(!o)o={attaching:null,generation:0,optedOut:g({value:!1}),session:null,watcherInstalled:!1},Ne.set(t,o);return o}var Ct=!1;function Zn(){if(Ct)return;Ct=!0,lt(Xn),pt(eo),ut((e)=>{if(D(e)?.session?.synced&&Tn(e).sourceCanonical)return Rt("Source editing in progress — structural edits are paused"),"source-canonical";return null})}function Xn(e,t,o){let r=D(e)?.session;if(!r||!r.synced)return;if(r.lastSeenRef=de(e.doc.document),o==="remote"){Te(r);return}if(r.canWrite)to(r,t),Te(r)}function eo(e){let t=D(e)?.session;if(!t?.synced||t.batchOps===null)return;let{batchOps:o,batchNeedsDiff:r}=t;if(t.batchOps=null,t.batchNeedsDiff=!1,!t.canWrite)return;if(t.undoManager?.stopCapturing(),r)re(t);else if(o.length>0)try{t.collab.applyDocOpsToY(t.handle.doc,o,t.collab.LOCAL_ORIGIN)}catch{re(t)}t.undoManager?.stopCapturing()}function to(e,t){let o=t.docOps.map((r)=>r.forward);if(mt(e.tab)){if(e.batchOps??=[],o.length===0)e.batchNeedsDiff=!0;else e.batchOps.push(...o);return}if(o.length===0){re(e);return}try{e.collab.applyDocOpsToY(e.handle.doc,o,e.collab.LOCAL_ORIGIN)}catch{re(e)}}function re(e){let{collab:t,handle:o,tab:r}=e,i=t.yDocToJson(o.doc),s=ir(de(r.doc.document)),a=t.diffDocs(i,s);if(a===null)t.replaceYStructure(o.doc,s,t.LOCAL_ORIGIN);else if(a.length>0)try{t.applyDocOpsToY(o.doc,a,t.LOCAL_ORIGIN)}catch{t.replaceYStructure(o.doc,s,t.LOCAL_ORIGIN)}}function $e(e){let t=e.collab.yDocToJson(e.handle.doc);Y(e.tab,(o)=>{let r=o.doc.document;for(let i of Object.keys(r))if(!(i in t))delete r[i];Object.assign(r,t)},{origin:"remote",skipHistory:!0})}function no(e){if(!e.canWrite)return!1;let{awareness:t}=e.handle,o=t.clientID;for(let[r,i]of t.getStates())if(i.canWrite!==!1&&r<o)o=r;return o===e.handle.awareness.clientID}function Te(e){if(!H||!no(e))return;if(e.collab.canonicalOf(e.handle.doc)==="source")return;let t=Date.now();if(e.lastMirrorAt??=t,t-e.lastMirrorAt>=Gn){if(e.mirrorTimer)clearTimeout(e.mirrorTimer),e.mirrorTimer=null;e.lastMirrorAt=t,Fe(e);return}if(e.mirrorTimer)clearTimeout(e.mirrorTimer);e.mirrorTimer=setTimeout(()=>{e.mirrorTimer=null,e.lastMirrorAt=Date.now(),Fe(e)},qn)}async function Fe(e){if(!H||!e.synced)return;try{let t=await H(e.tab);e.collab.updateSourceText(e.handle.doc,t,e.collab.MIRROR_ORIGIN)}catch{}}async function Jt(e){if(!Le||!e.synced||!e.canWrite)return;let{collab:t,handle:o,tab:r}=e,i=t.canonicalRevOf(o.doc),s=t.sourceText(o.doc).toString(),a;try{a=await Le(r,s)}catch{return}if(!Yn(e)||t.canonicalRevOf(o.doc)!==i)return;let l=t.diffDocs(t.yDocToJson(o.doc),a.document);if(l===null)t.replaceYStructure(o.doc,a.document,t.MIRROR_ORIGIN);else if(l.length>0)try{t.applyDocOpsToY(o.doc,l,t.MIRROR_ORIGIN)}catch{t.replaceYStructure(o.doc,a.document,t.MIRROR_ORIGIN)}let c=_e(t,o.doc),d=a.frontmatter??{};o.doc.transact(()=>{let b=[...c.keys()];for(let f of b)if(!(f in d))c.delete(f);for(let[f,x]of Object.entries(d))if(!t.deepEqual(c.get(f),x))c.set(f,x)},t.MIRROR_ORIGIN)}function pO(e){let t=D(e)?.session;if(!t?.synced)return null;let{collab:o,handle:r}=t,i=null,s=()=>i!==null&&t.sourceLockOwner===i;return{awareness:r.awareness,enter:async()=>{i={},t.sourceLockOwner=i;let a=r.awareness.getLocalState();if(a)r.awareness.setLocalState({...a,mode:"source"});if(!t.canWrite)return;let l=null;if(H)try{l=await H(e)}catch{l=null}if(!s())return;o.acquireSourceCanonical(r.doc,l??o.sourceText(r.doc).toString(),o.LOCAL_ORIGIN)},leave:()=>{if(!s()){i=null;return}i=null,t.sourceLockOwner=null;let a=r.awareness.getLocalState();if(a)r.awareness.setLocalState({...a,mode:"structure"});if(!t.canWrite)return;if(o.otherSourceEditors(r.awareness,t.path,r.awareness.clientID).filter((c)=>r.awareness.getStates().get(c)?.canWrite!==!1).length===0)Jt(t).then(()=>{o.releaseSourceCanonical(r.doc,o.LOCAL_ORIGIN)})},localOrigin:o.LOCAL_ORIGIN,readOnly:!t.canWrite,text:o.sourceText(r.doc)}}function hv(e){let t=Tn(e);return t.active&&t.readOnly}async function O$(e){let t=D(e)?.session;if(!t?.synced||!t.canWrite)return!1;if(t.mirrorTimer)clearTimeout(t.mirrorTimer),t.mirrorTimer=null;return await Fe(t),await t.handle.flush(),!0}async function fO(){for(let e of Ve)if(D(e)?.session?.synced)await O$(e)}var Ve=new Set;function ie(e){if(!wt()?.collab||!e.documentPath||e.documentPath===an)return;let o=Be(e);if(o.watcherInstalled)return;o.watcherInstalled=!0,Zn(),Ve.add(e),e.scope.run(()=>{ne(()=>{if(o.optedOut.value)ve(e);else He(e)}),Qs(()=>{Ve.delete(e),ve(e)})})}function M$(e,t){let o=Be(e);if(o.optedOut.value===!t)return;if(o.optedOut.value=!t,!o.watcherInstalled&&t)ie(e)}function P$(e){return D(e)?.optedOut.value!==!0}function It(e){if(!D(e)?.watcherInstalled){ie(e);return}ve(e),He(e)}async function He(e){let t=Be(e);if(t.session||t.attaching)return;let{documentPath:o}=e,r=wt();if(!o||!r?.collab){Tn(e).status="unavailable";return}let{generation:i}=t,s=Tn(e);s.status="connecting",s.attachError="";let a=(async()=>{try{let[l,c]=await Promise.all([zn(),r.collab(o)]);if(!c){s.status="detached";return}if(t.generation!==i){c.destroy();return}let d,b=new Promise((f,x)=>{d=setTimeout(()=>x(Error("collab-sync-timeout")),Kn)});try{await Promise.race([c.whenSynced,b])}finally{clearTimeout(d)}if(t.generation!==i){c.destroy();return}t.session=oo(e,o,l,c),s.active=!0,s.status="synced",s.readOnly=!t.session.canWrite,s.attachError="",vt(o)}catch(l){s.status="failed",s.active=!1,s.attachError=l instanceof Error?l.message:String(l),C.warn(`Live collaboration is not available for "${o}" — ${s.attachError}`,{key:`collab:${o}`,path:o,source:"Collaboration"})}finally{t.attaching=null}})();t.attaching=a,await a}function ve(e){let t=D(e);if(!t)return;t.generation+=1;let{session:o}=t;t.session=null;let r=Tn(e);if(r.active=!1,r.status="detached",r.attachError="",r.peers=[],!o)return;if(Ot(o.path),o.mirrorTimer)clearTimeout(o.mirrorTimer);if(o.sourceParseTimer)clearTimeout(o.sourceParseTimer);for(let i of o.disposers)try{i()}catch{}fv(e,null),e.history.snapshots=[{document:ir(de(e.doc.document)),selection:$a(e.session.selection)}],e.history.index=0,o.undoManager?.destroy(),o.handle.destroy()}function oo(e,t,o,r){let i=r.identity(),s={applyingRemoteFrontmatter:!1,batchNeedsDiff:!1,batchOps:null,canWrite:i?i.permission!=="read":!0,collab:o,disposers:[],handle:r,lastSeenRef:de(e.doc.document),mirrorTimer:null,path:t,sourceLockOwner:null,sourceParseTimer:null,synced:!1,tab:e,undoManager:null};if(o.metaMap(r.doc).get("structureSeeded")===!0){let h=o.yDocToJson(r.doc),T=ir(de(e.doc.document));if(!o.deepEqual(h,T)){let J=o.diffDocs(T,h);if(J===null)s.synced=!0,$e(s),s.synced=!1;else if(J.length>0)ke(e,J)}s.applyingRemoteFrontmatter=!0;let O=_e(o,r.doc);for(let[J,N]of O.entries())e.doc.content.frontmatter[J]=N;s.applyingRemoteFrontmatter=!1}else if(s.canWrite)o.seedStructure(r.doc,ir(de(e.doc.document)),{frontmatter:ir(de(e.doc.content.frontmatter)),origin:o.SEED_ORIGIN,sourceFormat:e.doc.sourceFormat});s.lastSeenRef=de(e.doc.document),s.disposers.push(r.onDirty((h)=>{e.doc.dirty=h})),r.awareness.setLocalState({canWrite:s.canWrite,focusedPath:t,structuralSelection:null,user:i?{avatarUrl:i.avatarUrl,color:i.color,login:i.login,name:i.name}:{color:o.colorForKey(String(r.awareness.clientID)),login:`guest-${r.awareness.clientID%1000}`}});let l=new o.UndoManager([o.structureMap(r.doc),o.frontmatterMap(r.doc)],{trackedOrigins:new Set([o.LOCAL_ORIGIN])});s.undoManager=l;let c=({stackItem:h})=>{h.meta.set("selection",$a(e.session.selection))},d=({stackItem:h})=>{let T=h.meta.get("selection");e.session.selection=$a(T??[])};l.on("stack-item-added",c),l.on("stack-item-popped",d),s.disposers.push(()=>{l.off("stack-item-added",c),l.off("stack-item-popped",d)}),fv(e,{canRedo:()=>l.canRedo(),canUndo:()=>l.canUndo(),redo:()=>{l.redo()},undo:()=>{l.undo()}});let b=o.structureMap(r.doc),f=(h,T)=>{if(T.origin===o.LOCAL_ORIGIN||!s.synced)return;let O=o.yEventsToDocOps(h);if(O===null){$e(s);return}if(O.length===0)return;try{ke(e,O)}catch{$e(s)}};b.observeDeep(f),s.disposers.push(()=>b.unobserveDeep(f));let x=Tn(e);x.sourceCanonical=o.canonicalOf(r.doc)==="source";let k=o.metaMap(r.doc),j=()=>{x.sourceCanonical=o.canonicalOf(r.doc)==="source"};k.observe(j),s.disposers.push(()=>k.unobserve(j));let A=o.sourceText(r.doc),ce=(h,T)=>{if(T.origin===o.MIRROR_ORIGIN||!s.synced)return;if(o.canonicalOf(r.doc)!=="source")return;if(!o.isSourceReconciler(r.awareness,s.path))return;if(s.sourceParseTimer)clearTimeout(s.sourceParseTimer);s.sourceParseTimer=setTimeout(()=>{s.sourceParseTimer=null,Jt(s)},600)};A.observe(ce),s.disposers.push(()=>A.unobserve(ce));let E=_e(o,r.doc),ue=(h,T)=>{if(T.origin===o.LOCAL_ORIGIN||!s.synced)return;s.applyingRemoteFrontmatter=!0;try{for(let[O,J]of h.changes.keys)if(J.action==="delete")delete e.doc.content.frontmatter[O];else e.doc.content.frontmatter[O]=E.get(O)}finally{s.applyingRemoteFrontmatter=!1}};E.observe(ue),s.disposers.push(()=>E.unobserve(ue)),e.scope.run(()=>{let h=JSON.stringify(e.doc.content.frontmatter);ne(()=>{let T=JSON.stringify(e.doc.content.frontmatter);if(T===h)return;if(h=T,s.applyingRemoteFrontmatter||!s.synced||!s.canWrite)return;let O=JSON.parse(T);r.doc.transact(()=>{let J=[...E.keys()];for(let N of J)if(!(N in O))E.delete(N);for(let[N,qe]of Object.entries(O))if(!o.deepEqual(E.get(N),qe))E.set(N,qe)},o.LOCAL_ORIGIN),Te(s)}),ne(()=>{let T=e.session.selection.length>0?$a(e.session.selection):null,O=r.awareness.getLocalState();if(O)r.awareness.setLocalState({...O,structuralSelection:T})}),ne(()=>{let T=de(e.doc.document);queueMicrotask(()=>{if(D(e)?.session!==s||!s.synced||!s.canWrite)return;let J=de(e.doc.document);if(J!==T||J===s.lastSeenRef)return;s.lastSeenRef=J,re(s),Te(s)})})});let K=Tn(e),fe=()=>{let h=[];for(let[T,O]of r.awareness.getStates())if(T!==r.awareness.clientID&&O.user)h.push({clientId:T,state:O});K.peers=h};return fe(),r.awareness.on("change",fe),s.disposers.push(()=>r.awareness.off("change",fe),r.onStatus((h)=>{if(h==="offline"||h==="connecting")K.status="offline";else if(s.synced)K.status="synced"}),r.onReset(()=>{ve(e),He(e)})),s.synced=!0,s}function I(e,t,o){return RangeError(`command "${e}" argument "${t}": ${o}`)}function ro(e){if(Z(e))return"number";if(Ze(e))return"boolean";return n(e)?"string":"object"}function R(e){if(e===void 0)return"missing";return n(e)?`"${e}"`:`${ro(e)} ${JSON.stringify(e)}`}function Dt(e){return Array.isArray(e)&&e.every((t)=>n(t)||Z(t))}function St(e,t,o){let r=t[o];if(!n(r)||r==="")throw I(e,o,`expected a non-empty string, got ${R(r)}`);return r}function Qn(e,t,o){if(t[o]===void 0)return;return St(e,t,o)}function Et(e,t,o){let r=t[o];if(!Z(r)||!Number.isFinite(r))throw I(e,o,`expected a finite number, got ${R(r)}`);return r}function kt(e,t,o){let r=t[o];if(!Z(r)||!Number.isInteger(r))throw I(e,o,`expected an integer, got ${R(r)}`);return r}function Rx(e,t,o,r,i){let s=Et(e,t,o);if(s<r||s>i)throw I(e,o,`${s} is outside the supported range ${r}–${i}`);return s}function Hi(e,t,o){let r=t[o];if(!Ze(r))throw I(e,o,`expected a boolean, got ${R(r)}`);return r}function Vn(e,t,o,r){let i=t[o],s=n(i)?r.find((a)=>a===i):void 0;if(s===void 0)throw I(e,o,`${R(i)} is not declared — declared: ${r.join(", ")||"none"}`);return s}function _C(e,t,o){let r=t[o];if(!Dt(r))throw I(e,o,`expected an array of path segments (strings or numbers), got ${R(r)}`);return r}function mO(e,t,o){if(t[o]===null)return null;return _C(e,t,o)}function F$(e,t,o){let r=t[o];if(!Array.isArray(r))throw I(e,o,`expected an array of document paths, got ${R(r)}`);return r.map((i,s)=>{if(!Dt(i))throw I(e,o,`entry ${s} is not a document path — expected an array of segments, got ${R(i)}`);return i})}function Ce(e,t=Object.keys(e)){return{additionalProperties:!1,properties:e,required:[...t],type:"object"}}function ui(e,t){return{description:t,enum:[...e],type:"string"}}function ll(e,t){return{description:t,get enum(){return[...e()]},type:"string"}}function j$(e,t={}){return{description:e,type:"number",...t}}function To(e){return{description:e,type:"boolean"}}function Dx(e,t=!1){let o={items:{type:["string","number"]},type:"array"};return t?{description:e,oneOf:[o,{type:"null"}]}:{description:e,...o}}function gO(e){return{description:e,items:{items:{type:["string","number"]},type:"array"},type:"array"}}function We(e){return{description:e,type:"string"}}function io(e){return e.length===2&&e.includes("string")&&e.includes("number")}function Ue(e){return n(e)?[e]:e}function Mt(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 o=t.items?.type;if(Array.isArray(o))return io(o)?"path":"pass-through";return o==="array"?"path-list":"pass-through"}case"null":case"object":return"typed";default:break}return"pass-through"}function $t(e,t){switch(e){case"null":return t===null;case"boolean":return Ze(t);case"string":return n(t);case"number":return Z(t)&&Number.isFinite(t);case"integer":return Z(t)&&Number.isInteger(t);case"array":return Array.isArray(t);case"object":return _(t)&&!Array.isArray(t);default:break}return!1}function Lt(e){if(e.length<=1)return e.join("");return`${e.slice(0,-1).join(", ")} or ${e.at(-1)}`}function so(e,t,o,r){let i=t[o];if(i===void 0||!r.some((s)=>$t(s,i)))throw I(e,o,`expected ${Lt(r)}, got ${R(i)}`);return i}function Nt(e){switch(Mt(e)){case"enum":return`one of ${(e.enum??[]).map((t)=>R(t)).join(" | ")}`;case"const":return`the constant ${R(e.const)}`;case"one-of":return(e.oneOf??[]).map((t)=>Nt(t)).join(" or ");case"typed":return Lt(Ue(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 ao(e,t,o,r){let i=t[o],s=[];for(let a of r){if(a.type!==void 0&&!Ue(a.type).some((l)=>$t(l,i)))continue;try{return _t(e,t,o,a)}catch(l){s.push(l)}}if(s.length===1)throw s[0];throw I(e,o,`expected ${r.map((a)=>Nt(a)).join(" or ")}, got ${R(i)}`)}function _t(e,t,o,r){switch(Mt(r)){case"enum":return Vn(e,t,o,r.enum??[]);case"const":{let i=t[o];if(i!==r.const)throw I(e,o,`expected the constant ${R(r.const)}, got ${R(i)}`);return i}case"one-of":return ao(e,t,o,r.oneOf??[]);case"typed":return so(e,t,o,Ue(r.type??[]));case"boolean":return Hi(e,t,o);case"bounded-number":{if(r.type==="integer")kt(e,t,o);return Rx(e,t,o,r.minimum,r.maximum)}case"number":return Et(e,t,o);case"integer":return kt(e,t,o);case"string":return St(e,t,o);case"path":return _C(e,t,o);case"path-list":return F$(e,t,o);default:return t[o]}}function bO(e,t,o){let r=t,i=r.properties??{},s=Object.keys(i),a=r.required??[],l={};for(let[c,d]of Object.entries(o)){if(d===void 0||Object.hasOwn(i,c))continue;if(r.additionalProperties===!1)throw I(e,c,`not declared — declared: ${s.join(", ")||"none"}`);l[c]=d}for(let c of s){if(o[c]===void 0&&!a.includes(c))continue;l[c]=_t(e,o,c,i[c])}return l}var lo=20,hi="primary",zm="secondary",z$=2,m=g({activePaneId:hi,clipboard:null,closedTabs:[],componentRegistry:[],mruOrder:[],fileTree:{dirs:new Map,expanded:new Set,searchQuery:"",selectedPath:null},panes:[{activeTabId:null,derived:null,id:hi,tabOrder:[]}],projectConfig:null,projectRoot:null,styleClipboard:null,tabs:new Map,ui:{activityBar:"files"},get activeTabId(){let e=Gr();return e.derived?.kind==="lens"?pn(e.derived.sourcePaneId)?.activeTabId??null:e.activeTabId},get tabOrder(){return Gr().tabOrder}}),u=Eh(()=>m.activeTabId?m.tabs.get(m.activeTabId)??null:null);function Gr(){let{panes:e}=m;return e.find((t)=>t.id===m.activePaneId)??e[0]}function pn(e){return m.panes.find((t)=>t.id===e)}function Zl(e){return m.panes.find((t)=>t.tabOrder.includes(e))}function kr(e){let t=pn(e);if(!t||t.id===m.activePaneId)return;m.activePaneId=t.id,L();let{activeTabId:o}=t;if(o){Ke(o);let r=m.tabs.get(o);if(r)Kt(r)}}function Wm(e){return m.activePaneId===e}function EC(e){let t=e??Gr().activeTabId,o=t?m.tabs.get(t):null;if(!t||!o)return null;let r=Zl(t);if(!r)return null;let i=Xl(r.id);return qm(t),yh(i,t),i.activeTabId=t,m.activePaneId=i.id,L(),Ke(t),i}function TC(e){return m.panes.find((t)=>t.id!==e)??co(zm)}function Xl(e){let t=TC(e);if(t.derived)t.derived=null;return t}function co(e){let t=pn(e);if(t)return t;return m.panes=[...m.panes,{activeTabId:null,derived:null,id:e,tabOrder:[]}],pn(e)}function Vm(e){if(m.panes.length<2)return;let t=e===hi?m.panes.find((s)=>s.id!==hi)?.id:e,o=t===void 0?void 0:pn(t),r=m.panes.find((s)=>s.id!==t);if(!o||!r)return;for(let s of o.tabOrder)yh(r,s);let i=o.activeTabId!==null&&U(o.activeTabId)?o.activeTabId:null;if(r.activeTabId=m.activePaneId===o.id?i??r.activeTabId??o.activeTabId:r.activeTabId??o.activeTabId,m.activePaneId=r.id,r.derived?.sourcePaneId===o.id)r.derived=null;m.panes=m.panes.filter((s)=>s.id!==o.id),L()}function Um(e){return e.tabOrder.length===0&&e.derived===null}var U=()=>!0;function LC(e){U=e??(()=>!0)}var Bt=null;function $C(e){Bt=e}var Ht=null;function IC(e){Ht=e}function uo(){let e=0;for(let t of m.tabs.keys())if(U(t))e+=1;return e}function Ut(e){return e.tabOrder.findLast((t)=>U(t))??null}function qm(e){let t=[];for(let o of m.panes){if(!o.tabOrder.includes(e))continue;if(o.tabOrder=o.tabOrder.filter((r)=>r!==e),o.activeTabId===e)o.activeTabId=Ut(o);if(o.id!==hi&&Um(o))t.push(o.id)}for(let o of t)Vm(o)}function yh(e,t,o){if(e.tabOrder.includes(t))return;let r=o??po(e,t);e.tabOrder=[...e.tabOrder.slice(0,r),t,...e.tabOrder.slice(r)]}function fo(e){let t=0;for(let o of e.tabOrder){if(m.tabs.get(o)?.pinned!==!0)break;t+=1}return t}function po(e,t){return m.tabs.get(t)?.pinned===!0?fo(e):e.tabOrder.length}function Ql(e,t=null){if(m.projectRoot&&e!==m.projectRoot)kC();m.projectRoot=e,m.projectConfig=t}function qp(e){let t=u.value;return e!==null&&t!==null&&de(t)===de(e)}function Gd(e){if(!e)return!1;let t=m.tabs.get(e.id);return t!==void 0&&de(t)===de(e)}function Ke(e){m.mruOrder=[e,...m.mruOrder.filter((t)=>t!==e)]}var Pe=null,se=0;function L(){Pe=null,se=0}function Kt(e){if(S&&e.documentPath)S.selectedPath=e.documentPath}function RC(e){let t=pn(e);if(t)t.activeTabId=null}function ae(e,t={}){let o=m.tabs.get(e),r=Zl(e);if(!o||!r)return;if(r.activeTabId=e,t.focus===!1)return;if(m.activePaneId=r.id,!t.cycling)L(),Ke(e);Kt(o)}function _i(e){if(e.background===!0){let a=m.tabs.get(e.id);if(a)return a;let l=lv({...e,preview:!1}),c=(e.paneId===void 0?void 0:pn(e.paneId))??Gr();return yh(c,l.id),m.tabs.set(l.id,l),l}let t=m.tabs.get(e.id),o=e.preview===!0&&t?.pinned!==!0,r=lv({...e,preview:o}),i=(e.paneId===void 0?void 0:pn(e.paneId))??Gr(),s;if(t)r.pinned=t.pinned,Fm(t);else{if(o){let l=Ft(i),c=l?m.tabs.get(l):null;if(c)Yd(c);DC()}let a=o?Ft(i):null;if(a)s=i.tabOrder.indexOf(a),Kd(a);yh(i,r.id,s)}return m.tabs.set(r.id,r),ae(r.id,{focus:e.focus!==!1}),ie(r),r}function Ft(e){return e.tabOrder.find((t)=>m.tabs.get(t)?.preview===!0)??null}function Yc(e){let t=m.tabs.get(e);if(t?.preview===!0)t.preview=!1}function DC(){for(let[e,t]of m.tabs)if(t.preview&&t.doc.dirty)Yc(e)}function jx(e,t){let o=m.tabs.get(e),r=Zl(e);if(!o||!r)return;if(o.pinned=t,t)o.preview=!1;let i=r.tabOrder.filter((a)=>a!==e),s=i.filter((a)=>m.tabs.get(a)?.pinned===!0).length;r.tabOrder=[...i.slice(0,s),e,...i.slice(s)]}function W$(e,t){let o=m.tabs.get(e),r=Zl(e);if(!o||!r)return;r.tabOrder=qt(r,e,t)}function qt(e,t,o){let r=m.tabs.get(t);if(!r)return e.tabOrder;let i=e.tabOrder.filter((d)=>d!==t),s=i.filter((d)=>m.tabs.get(d)?.pinned===!0).length,a=r.pinned?0:s,l=r.pinned?s:i.length,c=Math.min(Math.max(o,a),l);return[...i.slice(0,c),t,...i.slice(c)]}function Kd(e){let t=m.tabs.get(e);if(!t)return;let o=Zl(e),r=o?.activeTabId===e;if(mo(t),Fm(t),m.tabs.delete(e),kx(e),qm(e),m.mruOrder=m.mruOrder.filter((l)=>l!==e),L(),o&&Um(o))Vm(o.id);if(!r)return;let i=Gr(),s=Ht?.(i.id)??null,a=(s!==null&&i.tabOrder.includes(s)?s:null)??m.mruOrder.find((l)=>i.tabOrder.includes(l)&&U(l))??Ut(i);if(a)ae(a);else Bt?.(i.id)}function V$(){let e=[...m.tabs.values()];m.tabs.clear(),Gt(),m.mruOrder=[],L();for(let t of e)Fm(t)}function Gt(){m.panes=[{activeTabId:null,derived:null,id:hi,tabOrder:[]}],m.activePaneId=hi}function mo(e){if(!e.documentPath)return;let t=e.documentPath;m.closedTabs=[{documentPath:t},...m.closedTabs.filter((o)=>o.documentPath!==t)].slice(0,lo)}function yo(){let[e]=m.closedTabs;if(!e)return;return m.closedTabs=m.closedTabs.slice(1),e.documentPath}function Wt(e){if(!Pe)Pe=m.mruOrder.filter((r)=>m.tabs.has(r)&&U(r)),se=0;let t=Pe;if(t.length<2)return;se=((se+e)%t.length+t.length)%t.length;let o=t[se];return ae(o,{cycling:!0}),o}function U$(e){let t=[...m.tabs.keys()],o=[...m.tabs.values()],r=lv(e);m.tabs.set(r.id,r),Gt(),m.panes[0].tabOrder=[r.id],m.mruOrder=[],L(),ae(r.id),ie(r);for(let i of t){if(i===r.id)continue;m.tabs.delete(i)}for(let i of o)Fm(i);return r}function jt(e,t={}){ae(e,t)}function mv(e,t,o){let r=pn(t);if(!r||!m.tabs.has(e))return null;if(r.tabOrder.includes(e)){if(o!==void 0)r.tabOrder=qt(r,e,o);return r}return qm(e),yh(r,e,o),r}function Hx(e,t,o){let r=m.tabs.get(e);if(!r)return;if(r.id=t,r.documentPath=o,wC(e))kx(e),Mm(t);m.tabs.delete(e),m.tabs.set(t,r);for(let i of m.panes)if(i.tabOrder=i.tabOrder.map((s)=>s===e?t:s),i.activeTabId===e)i.activeTabId=t;m.mruOrder=m.mruOrder.map((i)=>i===e?t:i),L(),It(r)}function q$(e,t){e.registerAll([...bo(t),...ho(t)])}function bo(e){let t=()=>uo()>1;return[{id:"document.nextTab",title:"Next Tab",category:"Document",level:"document",keybinding:["ctrl+tab","mod+tab"],menus:["palette"],group:"2_navigate",when:(o)=>o.document.open,enablement:t,requires:"a second open document in this workspace",run:()=>{Wt(1)}},{id:"document.previousTab",title:"Previous Tab",category:"Document",level:"document",keybinding:["ctrl+shift+tab","mod+shift+tab"],menus:["palette"],group:"2_navigate",when:(o)=>o.document.open,enablement:t,requires:"a second open document in this workspace",run:()=>{Wt(-1)}},{args:Ce({path:We('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:(o)=>o.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:o,args:r})=>{let i=St("document.open",r,"path"),s=u.value?.documentPath??null;if(s!==i)return`Opened "${i}", but the active document is ${s===null?"none":`"${s}"`}.`;let a=o.editor.kind==="canvas"?"on the canvas; the document tools now operate on it":`in the ${Wp[o.editor.kind]} editor, which is not an element tree the document tools can edit`;return`"${i}" is the active document, ${a}.`}},run:async(o,r)=>{let i=St("document.open",r,"path");if(await e.openFile(i),![...m.tabs.values()].some((s)=>s.documentPath===i))throw RangeError(`command "document.open" argument "path": "${i}" could not be opened — it does `+"not exist, or no editor claims its format. Problems has the reason.")}},{args:Ce({file:We('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:(o)=>o.project.open,requires:"an open project",undo:"none",run:async(o,r)=>{let i=St("document.openToSide",r,"file"),s=Xl(Gr().id);if(await e.openFile(i,{paneId:s.id}),![...m.tabs.values()].some((a)=>a.documentPath===i)){if(Um(s)&&s.id!==hi)Vm(s.id);throw RangeError(`command "document.openToSide" argument "file": "${i}" 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 o=yo();if(o)await e.openFile(o)}},{id:"document.togglePinned",title:"Pin / Unpin Document",category:"Document",level:"document",menus:["context/tab","palette"],group:"1_file",when:(o)=>o.document.open,requires:"an open document",run:()=>{let o=m.activeTabId,r=o?m.tabs.get(o):null;if(o&&r)jx(o,!r.pinned)}},{args:Ce({pinned:To("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:(o)=>o.document.open,requires:"an open document",run:(o,r)=>{let i=m.activeTabId;if(i&&m.tabs.get(i))jx(i,Hi("document.setPinned",r,"pinned"))}},{id:"document.keepOpen",title:"Keep Document Open",category:"Document",level:"document",menus:["context/tab","palette"],group:"1_file",when:(o)=>o.document.open,enablement:()=>{let o=m.activeTabId;return o!==null&&m.tabs.get(o)?.preview===!0},requires:"a preview document — one opened by a single click",run:()=>{let o=m.activeTabId;if(o)Yc(o)}}]}function ho(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:(o)=>o.document.open,enablement:()=>m.activeTabId!==null,requires:"an open document",undo:"none",run:()=>{EC()}},{args:Ce({path:We("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:(o)=>o.document.open,enablement:()=>m.activeTabId!==null,requires:"an open document",undo:"none",run:async(o,r)=>{let i=St("pane.compareWith",r,"path"),s=Gr();if((s.activeTabId?m.tabs.get(s.activeTabId):null)?.documentPath===i)throw RangeError(`command "pane.compareWith" argument "path": "${i}" is the document this pane is `+"already showing — name a different one");await e.openFileInPane(Xl(s.id).id,i)}},{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:()=>{kr(hi)}},{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:()=>{kr(zm)}},{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:xo}]}function xo(){let e=m.panes.find((t)=>t.derived!==null);if(e?.id===hi){if(e.derived=null,!Um(e))return}Vm(e?.id??zm)}
|
|
2
|
+
export{bC,Pn,yx,tv,Vt,ln,go,wx,nv,Kc,tO,vC,xx,iv,I$,ov,_x,zp,Yl,al,rv,Wp,Xs,nO,Sx,fh,Cx,sv,yC,iO,Mm,kx,wC,R$,av,Fn,Ur,Ex,mh,Tx,oO,Lx,D$,Pm,rO,an,lv,xC,N$,sO,Fm,Tn,cv,A$,dv,uv,Oe,aO,$x,$a,Ix,lO,cO,jm,dO,uO,hO,pO,hv,O$,fO,M$,P$,St,Qn,Rx,Hi,Vn,_C,mO,F$,Ce,ui,ll,j$,To,Dx,gO,We,bO,vO,Bi,Wd,Un,Jc,Nx,Ax,SC,yO,Ia,gh,bh,pv,Ox,wO,ir,Y,Vd,xO,_O,H$,SO,fv,CO,kO,CC,EO,or,vh,B$,Hm,Mx,TO,Vp,Qe,Bm,Cr,LO,Px,$O,Fx,IO,RO,Ud,DO,qr,NO,Up,AO,OO,MO,qd,PO,FO,jO,HO,BO,kC,zO,hi,zm,z$,m,u,Gr,pn,Zl,kr,Wm,EC,TC,Xl,Vm,Um,LC,$C,IC,qm,yh,Ql,qp,Gd,RC,_i,Yc,DC,jx,W$,Kd,V$,U$,jt,mv,Hx,q$};
|
|
3
|
+
|
|
4
|
+
//# debugId=0945DE4AC8CC527564756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-vzgmyt0v.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{p}from"./studio-
|
|
1
|
+
import{p}from"./studio-03mqh8ax.js";import{Wd,m}from"./studio-vzgmyt0v.js";import{g}from"./studio-4kzbrr5t.js";import{Ht,Wi,fn,ul,lr,Aa}from"./studio-3w35qvay.js";import{Lo}from"./studio-ry81j4q1.js";import{Ta,Hd}from"./studio-h310mbqm.js";import{Fw}from"./studio-pqqq6v85.js";import{ls,Tw,Lw,er,jr}from"./studio-c1pxszat.js";import{S}from"./studio-45gyxpcq.js";import{n,Z,_,lf}from"./studio-zkq3r91p.js";import{le}from"./studio-7xag4na8.js";var Cs="draft",gp="Marked a draft. Studio filters drafts out of its own lists; the build does not exclude them yet.";function jl(e){return e?.[Cs]===!0}function M(e){return e?.properties?.[Cs]?.type==="boolean"}function Rc(e,t){return M(e)||jl(t)}var k=g({includeDrafts:!1});function I(){return k.includeDrafts}function WD(e){k.includeDrafts=e}function T(e,t,r){return r?e:e.filter((o)=>!jl(t(o)))}function W(e){let t=[],r=[],o="",s=!1,l=!1,u=()=>{r.push(o),o="",l=!1},x=()=>{if(u(),r.length===1&&r[0]===""){r=[];return}t.push(r),r=[]};for(let C=0;C<e.length;C++){let F=e[C];if(s){if(F==='"')if(e[C+1]==='"')o+='"',C+=1;else s=!1;else o+=F;continue}if(F==='"'&&!l)s=!0,l=!0;else if(F==='"')o+=F;else if(F===",")u();else if(F===`
|
|
2
2
|
`)x();else if(F==="\r"){if(e[C+1]===`
|
|
3
|
-
`)C+=1;x()}else o+=F,l=!0}if(o!==""||r.length>0)x();return t}function
|
|
3
|
+
`)C+=1;x()}else o+=F,l=!0}if(o!==""||r.length>0)x();return t}function Id(e){let t=(e.match(/\r\n/g)??[]).length,r=(e.match(/(?<!\r)\n/g)??[]).length,o=t>r?`\r
|
|
4
4
|
`:`
|
|
5
5
|
`,s=e.endsWith(`
|
|
6
|
-
`),l=W(e),u=l[0]??[],x=l.slice(1),C=Math.max(u.length,...x.map((F)=>F.length),0);while(u.length<C)u.push("");for(let F of x)while(F.length<C)F.push("");return{eol:o,headers:u,rows:x,trailingNewline:s}}function z(e){if(/[",\n\r]/.test(e))return`"${e.replaceAll('"','""')}"`;return e}function
|
|
7
|
-
export{
|
|
6
|
+
`),l=W(e),u=l[0]??[],x=l.slice(1),C=Math.max(u.length,...x.map((F)=>F.length),0);while(u.length<C)u.push("");for(let F of x)while(F.length<C)F.push("");return{eol:o,headers:u,rows:x,trailingNewline:s}}function z(e){if(/[",\n\r]/.test(e))return`"${e.replaceAll('"','""')}"`;return e}function eT(e){return[e.headers,...e.rows].map((r)=>r.map((o)=>z(o)).join(",")).join(e.eol)+(e.trailingNewline?e.eol:"")}function q(e,t){let{headers:r,rows:o}=Id(e),s=[t,"id","sku","slug","Slug"].flatMap((l)=>{let u=l===void 0?-1:r.indexOf(l);return u===-1?[]:[u]});return o.filter((l)=>l.some((u)=>u.trim()!=="")).map((l,u)=>{let x=s.find((C)=>(l[C]??"")!=="");return x===void 0?String(u):l[x]})}function B(e,t){let r;try{r=JSON.parse(e)}catch{return[]}let o=(s,l)=>{let u=_(s)&&!Array.isArray(s)?s.id:void 0;return n(u)||Z(u)?String(u):l};if(!Array.isArray(r))return[o(r,t)];return r.map((s,l)=>o(s,`${t}-${l}`))}function K(e,t,r){let o=e.toLowerCase();if(o.endsWith(".csv"))return q(t,r);if(o.endsWith(".json")){let s=(e.split("/").pop()??e).replace(/\.json$/i,"");return B(t,s)}return[]}var R="__path";function N(){return S?.projectConfig?.content??{}}function mb(e){let t=N()[e];if(!t?.source)return null;let r=t.source.replace(/^\.\//,"").replace(/\/$/,""),o=t.format==="json"?".json":Wi(t.format)?.extensions[0]??lr()?.extensions[0]??".json";return{def:t,dir:r,ext:o,name:e}}function rS(){return Object.entries(N()).filter(([,e])=>{let t=e.source?.replace(/^\.\//,"")??"";return t!==""&&!/\.[a-z0-9]+$/i.test(t)}).map(([e,t])=>({dir:t.source.replace(/^\.\//,"").replace(/\/$/,""),name:e}))}async function O(e,t){let r=p(),o=[],s=async(l)=>{let u;try{u=await r.listDirectory(l)}catch{return}for(let x of u)if(x.type==="directory")await s(x.path);else if(t.some((C)=>x.path.endsWith(C)))o.push(x.path)};return await s(e),o.toSorted()}async function sS(e){let t=e.dir.indexOf(Lo);if(t===-1)return[e.dir];let r=e.dir.slice(0,t).replace(/\/$/,""),o=e.dir.slice(t+Lo.length),s;try{s=await p().listDirectory(r)}catch{return[]}return s.filter((l)=>l.type==="directory").map((l)=>`${l.path}${o}`.replace(/\/$/,"")).filter((l)=>Wd(l)?.name===e.name).toSorted()}async function V(e){let t=await sS(e);return(await Promise.all(t.map((o)=>O(o,[e.ext])))).flat().toSorted()}async function H(e){let t=Fw(e.name);if(t===null)return null;let r;try{r=await p().readFile(t)}catch{return[]}return K(t,r,e.def.idField)}async function gb(e){await Ht().catch(()=>{});let t=mb(e);if(!t)return[];let r=await H(t);if(r!==null)return r;return(await V(t)).map((s)=>{let l=s.split("/").pop()??s;return l.slice(0,l.length-t.ext.length)})}async function Q(e,t,r){let o=Array.from({length:e.length}),s=0,l=Array.from({length:Math.min(t,e.length)},async()=>{while(s<e.length){let u=s;s+=1,o[u]=await r(e[u])}});return await Promise.all(l),o}function j(e){if(e===void 0)return null;if(lf(e))return e;if(Array.isArray(e)&&e.every((t)=>!_(t)))return e.map(String);return JSON.stringify(e)}function A(e){for(let t of m.tabs.values())if(t.documentPath===e)return t;return null}function U(e,t){return e.every((r)=>{let o=r[t];return!n(o)||!o.startsWith("{")&&!o.startsWith("[")})}var L=new WeakSet;async function tT(){let e=[];for(let t of m.tabs.values()){let r=er(t);if(r&&L.has(r.source))e.push(r.load())}await Promise.all(e)}function J(e){let t=X(e);if(e.drafts)L.add(t);return t}function X(e){let t=new Map,r=null,o=null,s=(d=!1)=>{if(!d&&r)return r;return r=(async()=>{await Ht().catch(()=>{});let h=p(),f=await e.list();t.clear(),o=null;let y=await Q(f,32,async(i)=>{try{let a=await h.readFile(i),c=await jr(i,a);return{document:c.document,formatName:c.format.name,frontmatter:c.frontmatter,rawText:a}}catch{return null}});for(let[i,a]of f.entries()){let c=y[i];if(c)t.set(a,c)}})(),r},l=()=>{if(o)return o;let d={editable:!1,field:R,insertOnly:!0,kind:"string",pk:!0,required:!0,title:"Path",widthHint:220},h=Tw(e.schema()),f=new Set([R,...h.map((a)=>a.field)]),y=[...t.values()].map((a)=>{let c={};for(let[w,b]of Object.entries(a.frontmatter))if(!f.has(w)&&!w.startsWith("$"))c[w]=j(b);return c}),i=Lw(y);for(let a of i)a.editable=a.kind!=="text"||U(y,a.field);if(e.priorityFields?.length){let a=(c)=>{let w=e.priorityFields.indexOf(c.field);return w===-1?e.priorityFields.length:w};i.sort((c,w)=>a(c)-a(w))}return o=x([d,...h,...i]),o},u=()=>{if(!e.drafts)return!1;let d=e.schema();return Rc(d)||[...t.values()].some((h)=>Rc(d,h.frontmatter))},x=(d)=>{let h=d.findIndex((y)=>y.field===Cs);if(h<1||!u())return d;let f=d.filter((y)=>y.field!==Cs);return[f[0],d[h],...f.slice(1)]},C=(d,h)=>{let f={[R]:d};for(let y of l()){if(y.field===R)continue;f[y.field]=j(h.frontmatter[y.field])}return{cells:f,fingerprint:h.rawText,key:d}},F=async(d,h,f)=>{let y=p(),i={...h.frontmatter};for(let b of f)if(b.value===null)delete i[b.field];else i[b.field]=b.value;let a=h.document,c={...i,...a,children:a.children??[]},w=await Aa(h.formatName,c,{mode:"roundtrip",source:h.rawText});Ta(d),await y.writeFile(d,w),t.set(d,{...h,frontmatter:i,rawText:w})};return{backingPaths:()=>new Map([...t.keys()].map((d)=>[d,d])),capabilities:{delete:!0,insert:!0,remotePaging:!1,remoteSort:!1},async columns(){return await s(),l()},async commit(d){await s();let h=p(),f={cells:[],deletes:[],inserts:[]},y=new Map;for(let i of d.cells){let a=y.get(i.rowKey)??[];a.push({field:i.field,value:i.value}),y.set(i.rowKey,a)}for(let[i,a]of y){let c=(P,D,v)=>{for(let G of a)f.cells.push({error:D,field:G.field,ok:P,rowKey:i,stale:v})},w=t.get(i);if(!w){c(!1,"Entry no longer loaded — refresh the grid");continue}let b=A(i);if(b?.doc.dirty){c(!1,"Open in a tab with unsaved changes — save or close it first");continue}let E=null;try{E=await h.readFile(i)}catch{E=null}if(E!==w.rawText&&!Hd(i)){c(!1,"File changed on disk — refresh to reload",!0);continue}try{if(await F(i,w,a),c(!0),b){let{reloadFileInTab:P}=await (le("de90apn9"),import("./files-de90apn9.js"));P(i)}}catch(P){c(!1,P instanceof Error?P.message:String(P))}}for(let i of d.inserts){let a=i.cells[R];if(!n(a)||a.trim()===""){f.inserts.push({error:"Path is required",ok:!1,tempKey:i.tempKey});continue}let c=e.resolveInsertPath(a),w=t.has(c);if(!w)try{await h.readFile(c),w=!0}catch{w=!1}if(w){f.inserts.push({error:`${c} already exists`,ok:!1,tempKey:i.tempKey});continue}let b=e.insertFormatName(c);if(!b){f.inserts.push({error:`No format can serialize ${c}`,ok:!1,tempKey:i.tempKey});continue}try{let E={};for(let[v,G]of Object.entries(i.cells))if(v!==R&&G!==null)E[v]=G;let P=await Aa(b,{...E,children:[]},{frontmatter:Object.keys(E).length>0,mode:"roundtrip"});Ta(c),await h.writeFile(c,P);let D=await jr(c,P);t.set(c,{document:D.document,formatName:D.format.name,frontmatter:D.frontmatter,rawText:P}),f.inserts.push({newKey:c,ok:!0,tempKey:i.tempKey})}catch(E){f.inserts.push({error:E instanceof Error?E.message:String(E),ok:!1,tempKey:i.tempKey})}}for(let i of d.deletes){if(A(i.rowKey)){f.deletes.push({error:"Open in a tab — close it first",ok:!1,rowKey:i.rowKey});continue}try{Ta(i.rowKey),await h.deleteFile(i.rowKey),t.delete(i.rowKey),f.deletes.push({ok:!0,rowKey:i.rowKey})}catch(a){f.deletes.push({error:a instanceof Error?a.message:String(a),ok:!1,rowKey:i.rowKey})}}return f},id:e.id,label:e.label,async refresh(){await s(!0)},async rows(){await s();let h=(e.drafts?T([...t.entries()],([,f])=>f.frontmatter,I()):[...t.entries()]).map(([f,y])=>C(f,y));return{rows:h,total:h.length}}}}function nT(e){let t=()=>{let r=mb(e);if(!r)throw Error(`No content collection named "${e}" in project.json`);return r};return J({drafts:!0,id:ls({kind:"collection",name:e}),insertFormatName:(r)=>{let o=t();return(o.def.format?Wi(o.def.format)?.name:void 0)??fn(r)?.name??lr()?.name??null},label:e,list:()=>V(t()),resolveInsertPath:(r)=>{let o=t(),s=r.trim().replace(/^\.\//,"").replace(/^\//,"");if(!s.includes("/"))s=`${o.dir}/${s}`;if(!s.endsWith(o.ext))s=`${s}${o.ext}`;return s},schema:()=>t().def.schema})}function iT(){let e=()=>{let t=ul("page").filter((r)=>r!==".json");return t.length>0?t:[".md"]};return J({id:ls({kind:"pages"}),insertFormatName:(t)=>fn(t)?.name??null,label:"Pages",list:()=>O("pages",e()),priorityFields:["title","description"],resolveInsertPath:(t)=>{let r=t.trim().replace(/^\.\//,"").replace(/^\//,"");if(!r.startsWith("pages/"))r=`pages/${r}`;if(!e().some((o)=>r.endsWith(o)))r=`${r}${e()[0]}`;return r},schema:()=>null})}
|
|
7
|
+
export{Id,eT,Cs,gp,jl,Rc,WD,mb,rS,sS,gb,tT,nT,iT};
|
|
8
8
|
|
|
9
|
-
//# debugId=
|
|
10
|
-
//# sourceMappingURL=studio-
|
|
9
|
+
//# debugId=D898D9DB8E5711D564756E2164756E21
|
|
10
|
+
//# sourceMappingURL=studio-wxdcd42g.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{Ne}from"./studio-
|
|
2
|
-
export{
|
|
1
|
+
import{Ne}from"./studio-1e8dw2w2.js";import{vt,Nc,Vo,Br}from"./studio-pqqq6v85.js";import{Vt,Kc,Qn,Vn,Ce,ui,We,m,Gr,pn,TC,qm,yh,Yc}from"./studio-vzgmyt0v.js";import{ne}from"./studio-4kzbrr5t.js";import{to,Es,il,h}from"./studio-5wzdy1jc.js";import{Ut}from"./studio-45gyxpcq.js";import{oe}from"./studio-ekgtrndg.js";var O_=["code","layout","component","diff","breakpoint","locale"],T={breakpoint:"design",code:"source",component:"design"},x={design:"Design",source:"Code"},k="Could not read this file's comparison against HEAD.";var Ou={breakpoint:"Same page at",code:"Code",component:"Component definition",diff:"Diff vs HEAD",layout:"Layout",locale:"Same page in"};function R(e){let t=pn(e)?.derived;if(!t)return null;let o=vt(t.sourcePaneId);if(!o)return{diffPath:null,kind:t.kind,media:null,mode:null,path:null,probePath:null,reason:"The pane this one follows has no document open.",select:null,status:"unavailable"};if(t.kind==="lens")return w(e,t,o);return S(e,t,o)}function w(e,t,o){let n={diffPath:null,kind:"lens",media:t.media,mode:t.mode,path:null,probePath:null,select:null};if(t.preset==="diff"){let i=o.documentPath;if(!p(i))return{...n,reason:"Nothing to compare — this file matches HEAD.",status:"unavailable"};if(t.diff?.filePath===i&&(t.diffRev===void 0||t.diffRev===h.git.rev))return{...n,reason:"",status:"ready"};if(u.get(e)?.failed&&u.get(e)?.path===i)return{...n,reason:k,status:"unavailable"};return{...n,diffPath:i,reason:"",status:"loading"}}if(t.preset==="code"&&Nc(o)==="source")return{...n,reason:"The pane this one follows is showing Code — one document has one editor.",status:"unavailable"};if(t.preset==="breakpoint"&&!M_(o).includes(t.media))return{...n,reason:`This document does not declare a "${t.media??"base"}" breakpoint.`,status:"unavailable"};return{...n,reason:"",status:"ready"}}function p(e){return h.git.status?.files.find((t)=>t.path===e&&(t.status==="M"||t.status==="A"||t.status==="U"))??null}function S(e,t,o){let n={diffPath:null,kind:"companion",media:null,mode:null};if(t.preset==="layout"){let a=h.layoutSelection,r=a?.layoutFile??il(o.doc.document.$layout);return r===null?{...n,path:null,probePath:null,reason:"This page has no layout.",select:null,status:"unavailable"}:{...n,path:r,probePath:null,reason:"",select:a?a.layoutPath:null,status:"ready"}}if(t.preset==="locale"){let a=Es(),r=o.documentPath===null||t.locale===null?null:Kc(o.documentPath,t.locale,a);if(r===null)return{...n,path:null,probePath:null,reason:"This document has no path in that locale.",select:null,status:"unavailable"};let l=c.get(e);if(l?.path!==r||l.exists===null)return{...n,path:null,probePath:r,reason:"",select:null,status:"loading"};if(!l.exists)return{...n,path:null,probePath:null,reason:`No ${Vt(t.locale)} copy of this document yet — `+"the Languages panel can create one.",select:null,status:"unavailable"};return{...n,path:r,probePath:null,reason:"",select:null,status:"ready"}}let i=_(o);if(i===null)return t.resolved===null?{...n,path:null,probePath:null,reason:"Select an element inside a component to see its definition.",select:null,status:"unavailable"}:{...n,path:null,probePath:null,reason:"",select:null,status:"ready"};return{...n,path:i,probePath:null,reason:"",select:null,status:"ready"}}function M_(e){let{sizeBreakpoints:t}=Br(to(e.doc.document.$media));return[null,...t.map((o)=>o.name)]}function _(e){let[t]=e?.session.selection??[];if(!e||!t)return null;let o=e.doc.document,n=[...t];while(n){let i=oe(o,n),a=i?Ne.find((r)=>r.tagName===i.tagName):null;if(a?.path)return a.path;n=Ut(n)}return null}function F(e,t){if(t.sourcePaneId===e||!pn(t.sourcePaneId))throw RangeError(`pane "${e}" cannot derive from "${t.sourcePaneId}" — a derivation names `+"another pane that is in the grid");b(e,t)}function b(e,t){let o=pn(e);if(o)u.delete(e),c.delete(e),o.derived=t}function dE(e){b(e,null)}function d(e,t){let o=pn(e),n=o?.derived,i=R(e);if(!o||!n||!i)return;if(Vo.derivedResolves+=1,n.status=i.status,n.reason=i.reason,n.kind==="lens"){let r=pn(n.sourcePaneId);if(o.tabOrder.length>0||o.activeTabId!==null){let l=[...o.tabOrder];for(let s of l)if(qm(s),r)yh(r,s);o.activeTabId=null}if(n.preset==="diff"&&i.status!=="ready")n.diff=null;A(e,i,t);return}if(C(e,i,t),n.resolved!==null&&vt(e)===null)n.resolved=null;if(i.path===null||i.path===n.resolved){v(e,i);return}n.resolved=i.path,Vo.derivedRetargets+=1;let a=t.openFileInPane(e,i.path);if(i.select===null)return;Promise.resolve(a).then(()=>{v(e,i)})}function v(e,t){let o=t.select,n=vt(e);if(!o||!n||t.path!==null&&n.documentPath!==t.path)return;let[i]=n.session.selection;if(i?.length===o.length&&i.every((a,r)=>a===o[r]))return;n.session.selection=[[...o]]}var u=new Map;function A(e,t,o){let n=t.diffPath,i=p(n),{rev:a}=h.git,r=u.get(e);if(n===null||!i||r?.path===n&&r.rev===a)return;u.set(e,{failed:!1,path:n,rev:a}),o.loadDiff(n,i.status).then((l)=>{let s=pn(e)?.derived;if(s?.kind!=="lens"||s.preset!=="diff"||u.get(e)?.path!==n)return;if(l)s.diff=l,s.diffRev=a;else u.set(e,{failed:!0,path:n,rev:a});d(e,o)}).catch((l)=>{console.error("loadDiff error:",l)})}var c=new Map;function C(e,t,o){let n=t.probePath;if(n===null||c.get(e)?.path===n)return;c.set(e,{exists:null,path:n}),o.fileExists(n).then((i)=>{let a=pn(e)?.derived;if(a?.kind!=="companion"||a.preset!=="locale"||c.get(e)?.path!==n)return;c.set(e,{exists:i,path:n}),d(e,o)}).catch((i)=>{console.error("fileExists error:",i)})}var f=new Map;function M(e,t){if(f.has(e))return;f.set(e,requestAnimationFrame(()=>{f.delete(e);try{d(e,t)}catch(o){console.error("applyDerivation error:",o)}}))}function aD(e,t){ne(()=>{let o=pn(e),n=o?.derived;if(!n)return;o.activeTabId;let i=vt(n.sourcePaneId);if(n.kind==="lens"&&n.preset==="code")i?.session.ui.canvasMode;if(n.kind==="companion"&&n.preset==="component")i?.session.selection;if(n.kind==="companion"&&n.preset==="layout")h.layoutSelection,i?.doc.document?.$layout;M(e,t)})}function tw(e,t,o,n=null){let i=vt(t);if(!i)return"an open document";let a=T[e];if(a&&!i.capabilities.modes.includes(a))return`a document with a ${x[a]} view — this one declares none`;if(e==="code")return Nc(i)==="source"?"a source pane that is not already showing Code":null;if(e==="diff")return p(i.documentPath)===null?"a file with changes against HEAD":null;if(e==="breakpoint")return M_(i).includes(o)?null:"a breakpoint this document declares — see Project Settings › Contexts";if(e==="layout")return il(i.doc.document.$layout)===null?"a page with a layout — this one declares none":null;if(e==="locale"){let r=Es();if(r===null||r.locales.length<2)return"a project that declares more than one locale — see Project Settings › Locales";if(i.documentPath===null)return"a document that has been saved";return n!==null&&r.locales.includes(n)?null:"a locale this project declares"}return null}function tb(e){let t=pn(e);return t&&t.activeTabId!==null&&t.derived===null?null:D}var D="an open document in a pane that is not itself derived";function O(e,t,o,n=null){if(e==="locale")return{kind:"companion",locale:n,preset:e,reason:"",resolved:null,sourcePaneId:t,status:"loading"};if(e==="layout"||e==="component")return{kind:"companion",preset:e,reason:"",resolved:null,sourcePaneId:t,status:"loading"};return{diff:null,kind:"lens",media:e==="breakpoint"?o:null,mode:e==="code"?"source":e==="diff"?"git-diff":"design",preset:e,reason:"",sourcePaneId:t,status:"loading",zoom:1}}function P(){return m.panes.find((e)=>uE(e.id)===null)??null}function uE(e){let t=pn(e);return t?.derived?.kind==="companion"&&t.activeTabId?null:y}var y="a derived pane showing a document of its own — Code, Diff and breakpoint views project "+"the document already open beside them";function lD(e){return[{args:Ce({locale:We('BCP 47 tag for preset "locale". Ignored by every other preset.'),media:We('Breakpoint name for preset "breakpoint" — omit or leave empty for the base size. '+"Ignored by every other preset."),preset:ui(O_,"Which projection of this pane's document to show beside it.")},["preset"]),id:"pane.derive",title:"Show Beside This…",category:"View",level:"document",menus:["context/pane"],group:"5_pane",when:(t)=>t.document.open,enablement:()=>tb(Gr().id)===null,requires:D,undo:"none",run:(t,o)=>{let n=Vn("pane.derive",o,"preset",O_),i=Qn("pane.derive",o,"media")??null,a=Qn("pane.derive",o,"locale")??null,r=Gr(),l=tw(n,r.id,i,a);if(l)throw RangeError(`command "pane.derive" argument "preset": "${n}" requires ${l}`);let s=TC(r.id);F(s.id,O(n,r.id,i,a));let E=[...s.tabOrder];for(let g of E)qm(g),yh(r,g);d(s.id,e)}},{id:"pane.pin",title:"Keep This Document",category:"View",level:"document",menus:["context/pane","palette"],group:"5_pane",enablement:()=>P()!==null,requires:y,undo:"none",run:()=>{let t=P();if(!t?.activeTabId)return;Yc(t.activeTabId),dE(t.id)}}]}
|
|
2
|
+
export{O_,Ou,M_,dE,aD,tw,tb,uE,lD};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=55B7584E5B6E46B664756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-wxhy1yh7.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{de,C}from"./studio-4kzbrr5t.js";import{Q,_}from"./studio-zkq3r91p.js";var st={functionEditor:null,blockActionBarEl:null,selDragCleanup:null,dndCleanups:[],elementsCollapsed:new Set,elementsFilter:"",_currentDropTargetRow:null,layerDragSourceHeight:0,_completionRegistered:!1,_layersCollapsed:null};var m=0;function WO(){return m+=1,m}var l=new Map;function bo(e){let r=l.get(e);if(!r)r=v(e),l.set(e,r);return r}function v(e){return{centerObserver:null,monacoDiffEditor:null,monacoEditor:null,needsCenter:!0,panX:0,panY:0,panels:[],paneId:e,panzoomWrap:null,stage:null,prevCanvasMode:null,prevStylebookCustomizedOnly:null,prevStylebookFilter:null,renderGeneration:0,sourceCollabCleanup:null,stageScrollbar:null,wrap:null}}function wh(e){return e.wrap}function Gp(){return[...l.values()]}function Zc(e){if(!e)return null;for(let r of l.values())if(wh(r)?.contains(e))return r;return null}function g(e){for(let r of e.panels)r.renderScope?.stop(),r.renderScope=null;e.panels.length=0,e.prevCanvasMode=null}function VO(e,r){let t=bo(e);return t.wrap=r,g(t),t}function UO(e){if(l.get(e))G$(e);let t=v(e);return l.set(e,t),t}var S=null;function qO(e){S=e}function G$(e){let r=l.get(e);if(!r)return;S?.(r),g(r),y(e)}function y(e){l.delete(e)}var Kp="commit";function b(e){return _(e)&&Q(e.then)}function gv(e){let r=new Map,t=new Map,o=new Map,a=!1,u=!1,c=!1;function f(n,i){if(!b(i))return i;let s=i.finally(()=>{if(o.get(n)===s)o.delete(n)});return o.set(n,s),s}let d={arm(n,i,s){clearTimeout(r.get(n)),t.set(n,s),r.set(n,setTimeout(()=>{r.delete(n),t.delete(n),f(n,s())},i))},cancel(){for(let n of r.values())clearTimeout(n);r.clear(),t.clear()},flush(n){let i=t.get(n);if(!i)return o.get(n);return clearTimeout(r.get(n)),r.delete(n),t.delete(n),f(n,i())},ahead:()=>a,markAhead(){a=!0},typed:()=>u,markTyped(){a=!0,u=!0},markSettled(){a=!1,u=!1},shared:()=>c,markShared(){c=!0}};return e._writes=d,d}var T={logic:{holds:"The handler you were typing",reached:"written into",source:"Logic"},source:{holds:"The source you were typing",reached:"parsed into",source:"Editor"}};function p(e,r,t){if(e._writes?.typed()!==!0)return!0;let a=e._editingTab??null,u=a?.documentPath??"Untitled",{holds:c,reached:f,source:d}=T[r],n=t?{detail:h(t.error)}:{};if(n.key=`buffer-discarded:${r}:${a?.id??"none"}`,n.source=d,a?.documentPath)n.path=a.documentPath;return C.warn(`${c} was discarded — it was never ${f} "${u}".`,n),!1}function h(e){return e instanceof Error?e.stack??e.message:String(e)}function bv(e,r){let t=e?._writes;if(!e||!t)return!0;let o;try{o=t.flush(Kp)}catch(a){return t.cancel(),p(e,r,{error:a})}if(t.cancel(),b(o))return o.then(()=>p(e,r,null),(a)=>p(e,r,{error:a})),!0;return p(e,r,null)}function K$(e){e?._writes?.cancel()}function Jd(e){return Boolean(e?.getModel())}function Jp(e,r){if(!Jd(e)||e.hasTextFocus()||e._writes?.ahead()||e._writes?.shared())return!0;return r!==void 0&&e.getValue()!==r}function w(e){let r=de(e);return[...Gp().map((o)=>o.monacoEditor),st.functionEditor].filter((o)=>o!=null&&o._editingTab!=null&&de(o._editingTab)===r&&Jd(o))}async function Yd(e){for(let r of w(e)){if(!Jd(r))continue;try{await r._writes?.flush(Kp)}catch(t){let o={detail:h(t),key:`buffer-commit:${e.id}`,source:"Editor"};if(e.documentPath)o.path=e.documentPath;C.error(`Could not save the editor's contents into "${e.documentPath??"Untitled"}".`,o)}}}function Yp(e){return w(e).some((r)=>r._writes?.typed()===!0)}
|
|
2
|
+
export{st,WO,bo,wh,Gp,Zc,VO,UO,qO,G$,Kp,gv,bv,K$,Jd,Jp,Yd,Yp};
|
|
3
|
+
|
|
4
|
+
//# debugId=C315607FB148807564756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-x08a3m0a.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{p,_e}from"./studio-03mqh8ax.js";import{QO,eM}from"./studio-ry81j4q1.js";import{ph}from"./studio-k3bcy02e.js";import{ln,dv,uv,u}from"./studio-vzgmyt0v.js";import{S}from"./studio-45gyxpcq.js";function i(t){return t.ownerDocument.defaultView?.getComputedStyle(t).display==="contents"}function He(t){let e=t.getBoundingClientRect();if(e.width>0||e.height>0||!t.hasChildNodes()||!i(t))return e;let n=null;for(let r of t.childNodes){let o=null;if(r instanceof Element)o=He(r);else if(r.nodeType===Node.TEXT_NODE){let s=t.ownerDocument.createRange();s.selectNodeContents(r),o=s.getBoundingClientRect()}if(!o||o.width===0&&o.height===0)continue;n=n?{bottom:Math.max(n.bottom,o.bottom),left:Math.min(n.left,o.left),right:Math.max(n.right,o.right),top:Math.min(n.top,o.top)}:{bottom:o.bottom,left:o.left,right:o.right,top:o.top}}return n?new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top):e}function cx(t,e,n=document){return n.elementFromPoint(t,e)}var Ks=new Set([".jpg",".jpeg",".png",".gif",".svg",".webp",".avif",".ico"]),e$=new Set([".mp4",".webm",".mov",".m4v"]),t$=new Set([".mp3",".wav",".ogg",".m4a",".flac"]),Js=new Set([...Ks,...e$,...t$,".pdf",".woff",".woff2",".ttf",".otf"]);function nn(t){let e=t.lastIndexOf(".");return e>0?t.slice(e).toLowerCase():""}function Rp(t){return Ks.has(t.startsWith(".")?t.toLowerCase():`.${t.toLowerCase()}`)}function rh(){let t=_e()?p().canvasUrl:void 0;if(t)return new URL(t,location.href).origin;return location.origin}function Bb(){let t=_e()?p().canvasUrl:void 0;if(!t)return null;let e=new URL(t,location.href);return e.origin===location.origin?e.searchParams.get("rpcToken"):null}function Md(t){let e=rh(),n=_e()?p().documentBaseUrl:void 0;if(n){let o=n.endsWith("/")?n:`${n}/`;return new URL(o,`${e}/`).href}let r=t||"";return`${e}/${r?`${r}/`:""}`}function rC(t){if(t.startsWith("data:")||t.startsWith("blob:")||t.startsWith("http")||t.startsWith("views://"))return t;let e=rh();if((e.startsWith("http:")||e.startsWith("https:"))&&e!==location.origin)return`${e}/${t.replace(/^\.?\//,"")}`;return t}function n$(){return ln(S?.projectConfig??{}).i18n?.locales??[]}function zb(t,e){let n=e?.space??"site",r=dv(t,S?.projectConfig?.content,n$());if(n==="site"&&!r)return null;let o={documentDir:eM(t??""),lanes:QO,mounts:r?[r]:[],space:n};if(e?.fileBaseUrl!==void 0)o.fileBaseUrl=e.fileBaseUrl;return o}function Vc(t){return Wb(t,u.value?.documentPath)}function Wb(t,e){if(!t)return t;let n=zb(e,sh()),r=n&&{...n,versions:ph()};return rC(uv(t,r)??t)}function sh(){let t={fileBaseUrl:Md(S?.projectRoot)};if(_e())t.space=p().assetSpace;return t}
|
|
2
|
+
export{He,cx,Ks,e$,t$,Js,nn,Rp,rh,Bb,Md,rC,n$,zb,Vc,Wb,sh};
|
|
3
|
+
|
|
4
|
+
//# debugId=94485CFEAD0E85C064756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-x3mjr5cc.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{
|
|
1
|
+
import{x$}from"./studio-cpkamjdn.js";import{T,R,Zs,Gb}from"./studio-jttyqrmh.js";import{g}from"./studio-4kzbrr5t.js";import{He}from"./studio-x3mjr5cc.js";var x={$schema:"https://jxsuite.com/schema/v1",$id:"StudioMenu",$description:"A Studio menu: one jx-menu whose rows are a projection of command records the adapter hands in as `rows`. Nothing here decides what a row says; a row prints its record's title, chord, disabled reason and destructive flag, a divider falls where the adapter marked a group boundary, and a row with children owns a one-level submenu of the same shape. The chord and the reason are rendered only when present, so a row's text is its title.",tagName:"jx-menu",$props:{label:{$ref:"#/state/label"},x:{$ref:"#/state/x"},y:{$ref:"#/state/y"},floor:{$ref:"#/state/floor"},placement:{$ref:"#/state/placement"}},onselect:{$ref:"#/state/select"},children:[{$prototype:"Array",items:{$ref:"#/state/rows"},key:{$ref:"$map/item/id"},map:{tagName:"div",attributes:{role:"none"},children:[{tagName:"div",attributes:{role:"none"},$switch:{$ref:"$map/item/dividerAbove"},cases:{true:{tagName:"hr"}}},{tagName:"jx-menu-item",$props:{value:{$ref:"$map/item/id"},disabled:{$ref:"$map/item/disabled"},destructive:{$ref:"$map/item/destructive"},requires:{$ref:"$map/item/requires"},checked:{$ref:"$map/item/checked"},haspopup:{$ref:"$map/item/haspopup"}},attributes:{"data-command-id":"${$map.item.id}"},children:[{tagName:"span",textContent:"${$map.item.title}"},{tagName:"span",attributes:{slot:"value"},$switch:{$ref:"$map/item/noChord"},cases:{false:{tagName:"kbd",textContent:"${$map.item.chord}"}}},{tagName:"span",attributes:{slot:"description"},$switch:{$ref:"$map/item/enabled"},cases:{false:{tagName:"span",textContent:"Needs ${$map.item.requires}"}}},{tagName:"span",attributes:{slot:"submenu"},$switch:{$ref:"$map/item/haspopup"},cases:{true:{tagName:"jx-menu",$props:{label:{$ref:"$map/item/submenuLabel"}},children:[{$prototype:"Array",items:{$ref:"$map/item/children"},key:{$ref:"$map/item/id"},map:{tagName:"div",attributes:{role:"none"},children:[{tagName:"div",attributes:{role:"none"},$switch:{$ref:"$map/item/dividerAbove"},cases:{true:{tagName:"hr"}}},{tagName:"jx-menu-item",$props:{value:{$ref:"$map/item/id"},disabled:{$ref:"$map/item/disabled"},destructive:{$ref:"$map/item/destructive"},requires:{$ref:"$map/item/requires"},checked:{$ref:"$map/item/checked"}},attributes:{"data-command-id":"${$map.item.id}"},children:[{tagName:"span",textContent:"${$map.item.title}"},{tagName:"span",attributes:{slot:"value"},$switch:{$ref:"$map/item/noChord"},cases:{false:{tagName:"kbd",textContent:"${$map.item.chord}"}}},{tagName:"span",attributes:{slot:"description"},$switch:{$ref:"$map/item/enabled"},cases:{false:{tagName:"span",textContent:"Needs ${$map.item.requires}"}}}]}]}}]}}}]}]}}]};T("menu",x);var L="block-end span-inline-end";function j(e){if(e.placement!==void 0)return e.placement;return e.opener&&!e.origin&&!e.place&&!e.floor?L:""}function P(e){if(!e)return{x:0,y:0};let n=He(e);return{x:Math.round(n.left),y:Math.round(n.bottom)}}function b(e,n=0){let r=n===0?(e.children??[]).map((t)=>b(t,1)):[];return{...e,checked:e.checked??"",children:r,chord:e.chord??"",enabled:!e.disabled,haspopup:r.length>0,noChord:!e.chord,noDivider:!e.dividerAbove,requires:e.requires??"",submenuLabel:e.submenuLabel??e.title}}function N(e,n){for(let r of e){if(r.id===n)return r;let t=r.children.find((a)=>a.id===n);if(t)return t}return}function Wt(e){let n=Zs("popover",e.region),r=new AbortController,t=null,a=null,s=!1,h=()=>{if(s)return;s=!0,r.abort(),a?.(),a=null,Gb("popover",e.region),k(e.opener??null),e.onClosed?.(f)},v=e.place?e.place(new DOMRect):e.origin??P(e.opener),c=g({floor:e.floor?.()??0,label:e.label,placement:j(e),rows:e.rows.map((o)=>b(o)),select:(o,u)=>{let i=String(u.detail),d=N(c.rows,i);if(!d)return;if(C(t,e.opener??null),d.run)d.run();else e.run?.(i);f.close()},x:v.x,y:v.y}),w=()=>{if(s||!t||!e.place)return;let o=e.place(He(t));c.x=o.x,c.y=o.y},p=()=>r.signal.aborted,E=(async()=>{let o=await R("menu",c,n,{signal:r.signal});if(p())return;if({dispose:a}=o,t=o.root,t.addEventListener("toggle",(i)=>{if(i.newState==="closed")h()}),!t.hasAttribute("popover"))await new Promise((i)=>{t.addEventListener("jx-ready",()=>i(),{once:!0})});if(p())return;if(await S(r.signal),p())return;let u=e.opener instanceof HTMLElement&&e.opener!==document.body?e.opener:void 0;t.showPopover(u?{source:u}:void 0),w(),requestAnimationFrame(w)})(),f={close:()=>{if(s)return;if(t?.open)t.hidePopover();h()},host:n,ready:E,setRows:(o)=>{if(s)return;let i=document.activeElement?.closest("jx-menu"),d=i&&i!==t?i.parentElement?.closest("jx-menu-item")?.dataset.commandId:void 0;c.rows=o.map((m)=>b(m)),setTimeout(()=>{if(s||!t||t.contains(document.activeElement))return;let m=d?t.querySelector(`jx-menu-item[data-command-id="${d}"]`):null,y=m?.querySelector("jx-menu")??null;if(m&&!(y?.open&&y.querySelector("jx-menu-item")))m.focus();else x$(t)},0)}};return f}var l=new Set;if(typeof window<"u")window.addEventListener("pointerdown",(e)=>l.add(e.pointerId),!0),window.addEventListener("pointerup",(e)=>l.delete(e.pointerId),!0),window.addEventListener("pointercancel",(e)=>l.delete(e.pointerId),!0),window.addEventListener("blur",()=>l.clear());function S(e){if(l.size===0||e.aborted)return Promise.resolve();return new Promise((n)=>{let r=new AbortController,t=()=>{if(l.size===0||e.aborted)r.abort(),n()},a={capture:!0,signal:r.signal};window.addEventListener("pointerup",t,a),window.addEventListener("pointercancel",t,a),window.addEventListener("blur",t,{signal:r.signal}),e.addEventListener("abort",t,{signal:r.signal})})}function C(e,n){if(e?.contains(document.activeElement)&&n?.isConnected&&n!==document.body)n.focus({preventScroll:!0})}function k(e){let n=document.activeElement;if(e?.isConnected&&(!n||n===document.body))e.focus()}
|
|
2
|
+
export{Wt};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=2EBFD18065569C2364756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-x97ay0v4.js.map
|