@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
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{p}from"./studio-pr23qhrw.js";import{n}from"./studio-kt2j51sa.js";import{le}from"./studio-fqs1a22a.js";var a=null,P=null,F=null,g=!1;function S(t){return F=t,g=!0,a?E():Promise.resolve()}async function E(){if(!g)return;g=!1;try{let{applyProjectSchemas:t}=await (le("zyyynnj8"),import("./monaco-setup-zyyynnj8.js"));t(F)}catch{}}function Um(){if(a)return Promise.resolve(a);return P??=(async()=>{let[t]=await Promise.all([(le("bkja5dbv"),import("./editor-bkja5dbv.js")),(le("zyyynnj8"),import("./monaco-setup-zyyynnj8.js"))]);return a=t,await E(),a})(),P}function nf(){return a}function xv(t,o,e){if(!t?.isConnected||o)return!1;return e()}var i=[],d=null;function Bt(){if(!d)d=(async()=>{try{i=await p().listFormats?.()??[]}catch{i=[]}return i})();return d}function $h(){d=null,i=[],f=null,c=[],x=null,l=[]}var c=[],f=null;function td(){if(!f)f=(async()=>{try{c=await p().listExtensions?.()??[]}catch{c=[]}return c})();return f}function _v(){return c}var l=[],x=null;function w(){if(!x)x=(async()=>{try{l=await p().listExtensionCatalog?.()??[]}catch{l=[]}return l})();return x}function Vx(){return l}async function j(t){let o=null;try{o=await t.fetchProjectSchemas?.()??null}catch{}S(o),await (le("w7v32f6a"),import("./jx-validate-w7v32f6a.js")).then(({applyProjectSchemas:e})=>e(o)).catch(()=>!1)}function tc(t){j(t),w(),(le("rp7fkega"),import("./extension-sections-rp7fkega.js")).then(({syncExtensionSettingsSections:o})=>o()).catch(()=>{})}function eu(){return i}function Aa(t,o){let e=t.startsWith(".")?t.toLowerCase():`.${t.toLowerCase()}`;return i.find((r)=>r.extensions.includes(e)&&(!o||r.capabilities[o]))}function zi(t){if(!t)return;return i.find((o)=>o.name===t)}function of(t){return Error(`No format class imported for "${t}" — add one to project.json imports `+`(e.g. "Markdown": "@jxsuite/parser/Markdown.class.json") and make sure the project's dependencies are installed`)}function fn(t){if(!t)return;let o=t.lastIndexOf(".");if(o===-1)return;return Aa(t.slice(o))}function ul(t){let o=new Set;for(let e of i){if(t&&!e.documentKinds.includes(t))continue;for(let r of e.extensions)o.add(r)}return o.delete(".json"),[...o]}async function Sv(){return await Bt(),[".json",...ul("page")]}function cr(){return i.find((t)=>t.capabilities.serialize&&t.documentKinds.includes("content"))}async function M(t){let o=p();if(!o.formatAction)throw Error("Platform does not support format actions");return o.formatAction(t)}async function tI(t,o,e){return await M({action:"parse",format:t,options:e,source:o})}async function Oa(t,o,e){return await M({action:"serialize",doc:o,format:t,options:e})}function nI(t,o){let e=t?.studio?.documentMode,r=e?.componentWhen;if(r?.frontmatterKey){let s=o[r.frontmatterKey],u=r.matches?new RegExp(r.matches):/./;if(n(s)&&u.test(s))return{document:o,frontmatter:{},mode:"component"}}if(e?.default==="component")return{document:o,frontmatter:{},mode:"component"};let m=o.children??[];if(Array.isArray(m)&&m.length===0)m.push({children:[],tagName:"p"});let b=new Set(["state","imports"]),h={children:m},y={};for(let[s,u]of Object.entries(o)){if(s==="children")continue;if(b.has(s))h[s]=u;else y[s]=u}return{document:h,frontmatter:y,mode:"content"}}
|
|
2
|
-
export{Um,nf,xv,Bt,$h,td,_v,Vx,tc,eu,Aa,zi,of,fn,ul,Sv,cr,tI,Oa,nI};
|
|
3
|
-
|
|
4
|
-
//# debugId=DD5AB5EFBC498D7D64756E2164756E21
|
|
5
|
-
//# sourceMappingURL=studio-tpmnbgmt.js.map
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{Q}from"./studio-nqxqf8p2.js";import{Me,Ud,Jo,u}from"./studio-y1x65h5r.js";import{C}from"./studio-hw60n5dh.js";import{p}from"./studio-pr23qhrw.js";import{Ne,xa,Hc}from"./studio-v2ek69cb.js";import{xi}from"./studio-02phtmqn.js";import{iw,ib}from"./studio-j5jqvyn3.js";import{vS}from"./studio-1yhz0s8p.js";import{ko}from"./studio-m4w6sygj.js";import{At,hi}from"./studio-ana67wax.js";import{oe}from"./studio-gqpty626.js";import{_,it}from"./studio-kt2j51sa.js";function Jy(){let t=u.value,e=Me(t?.session.selection);if(!t||!e||e.length<2)return null;let o=oe(t.doc.document,e);if(!o||!o.tagName)return null;return{node:o,path:e}}async function nm(){let t=Jy();if(!t)return;let e=await b(g(t.node));if(!e)return;await aE(e.toLowerCase())}async function aE(t){let e=u.value,o=Jy();if(!e||!o)return null;let{node:m,path:d}=o,l=v(m);l.tagName=t;let r=`components/${t}.json`,c=Hc(e.documentPath,r),f=d;if(!Ud(e,(n)=>{let s=At(f)??[],h=hi(f),a=n;for(let i of s)a=a[i];if(!Array.isArray(a.children))a.children=[];if(a.children[h]={tagName:t},!n.$elements)n.$elements=[];if(!n.$elements.some((i)=>_(i)&&("$ref"in i)&&i.$ref===c))n.$elements.push({$ref:c})}))return null;try{await p().writeFile(r,ko(l,null)),await xa();let s=vS(l);if(C.success(`Converted to <${t}>`),s)C.warn(`<${t}> has a slot problem: ${s}`,{path:r,source:"Components",tier:"problem"});return r}catch(n){return C.error(`Could not save the <${t}> component.`,{detail:Q(n),path:r,source:"Components"}),null}}function g(t){if(t.$id){let o=ib(t.$id);if(o!=="")return o}let e=(it(t.tagName)||"div").toLowerCase();return e.includes("-")?e:ib(e)}function v(t){let e=Jo(t);return delete e.$id,delete e.$layout,delete e.$paths,e}function N(t){let e=t.trim().toLowerCase(),o=iw(e);if(o!=="")return o;return Ne.some((m)=>m.tagName===e)?`Component <${e}> already exists`:""}function b(t){return xi("Convert to Component",{confirmLabel:"Convert",message:"Enter a hyphenated tag name for the new component.",placeholder:"my-component",validate:N,value:t})}
|
|
2
|
-
export{Jy,nm,aE};
|
|
3
|
-
|
|
4
|
-
//# debugId=367C32B89321377D64756E2164756E21
|
|
5
|
-
//# sourceMappingURL=studio-ttxhq5yt.js.map
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{ge,ea,ne,g,he,Th,C}from"./studio-hw60n5dh.js";import{Xd}from"./studio-grp684wx.js";import{p}from"./studio-pr23qhrw.js";import{zi,fn,cr}from"./studio-tpmnbgmt.js";import{X$,OC,Io,VO,zx,Q$,eI,GO,bv}from"./studio-6vrxzkba.js";import{fv,U$,At,hi,Tr,ec,S}from"./studio-ana67wax.js";import{$e,oe,mv,gv,Z$}from"./studio-gqpty626.js";import{n,Z,Xe,_,v,Yo,Di,nd,sf}from"./studio-kt2j51sa.js";import{le}from"./studio-fqs1a22a.js";var be=g(new Set);function Dm(e){be.add(e)}function xx(e){be.delete(e)}function vC(e){return be.has(e)}function nv(e,t){return{success:!0,data:e,summary:t}}function uo(e){return{success:!1,error:e}}function bo({name:e,description:t,parameters:o,strict:r=!0,llmStrict:i=!1,interactive:s,execute:a}){let l={name:e,description:t,parameters:o,strict:r,llmStrict:i,execute:a};if(s!==void 0)l.interactive=s;return l}function _x(e){let t=[];return{record(o){t.push(o),e?.(o)},writes:t}}function gh(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 Bt=new AbortController().signal;function Sx(e={}){let t=e.session??gh();return{actor:e.actor??{id:`assistant:${t.sessionId??"local"}:`,kind:"assistant",sessionId:t.sessionId,turnId:""},callId:e.callId??"",ledger:e.ledger??_x(),progress:e.progress??(()=>{}),session:t,signal:e.signal??Bt}}function eO(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 $$(){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 y=b.type;if(!y)continue;let h=Ke(d);if(y==="number"||y==="integer"){if(xe(d,"number"))continue;if(xe(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 ${h}`);continue}if(y==="string"&&h!=="string")s.push(`Argument "${c}" should be a string, got ${h}`);else if(y==="boolean"&&h!=="boolean")s.push(`Argument "${c}" should be a boolean, got ${h}`);else if(y==="array"&&h!=="array")s.push(`Argument "${c}" should be an array, got ${h}`);else if(y==="object"&&h!=="object")s.push(`Argument "${c}" should be an object, got ${h}`)}return s.length>0?{valid:!1,errors:s}:{valid:!0}},async execute(t,o,r=Sx()){let i=e.get(t);if(!i)return uo(`Unknown tool: "${t}"`);let s=this.validate(t,o);if(!s.valid)return uo(`Validation failed: ${(s.errors||[]).join("; ")}`);try{return await i.execute(o,r)}catch(a){return uo(`Tool "${t}" execution error: ${ye(a)}`)}}}}function Kt(e){return JSON.parse(JSON.stringify(e))}function ye(e){return e.message}var Ut=["string","number","boolean","undefined"];function xe(e,t){return typeof e===t}function Gt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Ke(e){if(Array.isArray(e))return"array";return Ut.find((t)=>xe(e,t))??"object"}function zt(e){if(!e)return{};let t=JSON.parse(e);if(!Gt(t)){let o=t===null?"null":Ke(t);throw TypeError(`arguments must be a JSON object, got ${o}`)}return t}async function tO(e,t,o){let r=!1,i;try{let s=zt(t.argumentsText);r=!0,i=await e.execute(t.name,s,o)}catch(s){i=uo(`Failed to parse arguments: ${ye(s)}`)}try{return{status:"done",result:Kt(i),executed:r}}catch(s){let a=ye(s);return{status:"done",result:uo(`Tool "${t.name}" returned a result that cannot be serialized: ${a}`),executed:r}}}var G=[],Yt=50;function nO(e){return Object.assign(_x(),{turnId:e})}function iO(e,t){if(t.length===0)return[];let o={id:e,writes:[...t]};G.push(o);while(G.length>Yt)G.shift();return o.writes}function yC(e){return G.find((t)=>t.id===e)?.writes??[]}function oO(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 wC(){G.splice(0)}function rO(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}var qt=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"]),mC="^[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 mx(e){return Pn(e)!==null}function Yb(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&&qt.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 Zt="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:Zt;return{errors:o,i18n:{defaultLocale:s,locales:i,routing:a}}}function go(e,t){let o=Te(z(e),t);if(o===-1||t===null)return null;return Pn(z(e)[o])}function gx(e,t){let o=go(e,t);if(o!==null||t===null||t.routing!=="prefix-except-default")return o;return z(e)[0]==="pages"?t.defaultLocale:null}function Zb(e,t){let o=z(e),r=Te(o,t);return r===-1?o.join("/"):o.filter((i,s)=>s!==r).join("/")}function Jc(e,t,o){if(o===null)return null;let r=Pn(t);if(r===null||!o.locales.includes(r))return null;let i=z(e),s=Te(i,o),a=s===-1?Xt(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 z(e){return e.replace(/^\.\//,"").split("/").filter(Boolean)}function Te(e,t){if(t===null)return-1;return e.findIndex((o)=>{let r=Pn(o);return r!==null&&t.locales.includes(r)})}function Xt(e){if(e[0]==="pages"&&e.length>1)return 1;if(e[0]==="content"&&e.length>2)return 2;return-1}function ZA(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 D$(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!==""&&!Qt(d));return c.push(`v=${encodeURIComponent(t)}`),`${a}?${c.join("&")}${r}`}function Qt(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 en(e,t){if(!e||!Object.hasOwn(e,t))return;let o=e[t];return n(o)?o:void 0}function sv(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=nn(l.source);if(c===""||c.startsWith(".."))continue;if(c.includes(Io)){let d=tn(r,c,a,o);if(d)s(d.dir,d.urlPrefix);continue}if(/\.[a-z0-9]+$/i.test(c))continue;s(c,`/${X$}/${a}`)}return i}function tn(e,t,o,r){let i=t.indexOf(Io),s=t.slice(0,i),a=t.slice(i+Io.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:`/${X$}/${o}/${c}`}}function nn(e){return e.replaceAll("\\","/").replace(/^\.\//,"").replace(/\/+$/,"")}function av(e,t){if(!t||e==="")return null;if(t.space==="repo"){if(!t.fileBaseUrl)return null;let r=GO(e,t.documentDir,t.mounts,t.lanes);if(r===null)return null;let{suffix:i}=zx(e);return D$(`${t.fileBaseUrl}${bv(r)}${i}`,en(t.versions,r))}let[o]=t.mounts;return o?on(e,t.documentDir,o):null}function on(e,t,o){if(Q$(e))return null;let{path:r,suffix:i}=zx(e),s;try{s=decodeURIComponent(r)}catch{return null}let a=eI(t,s);if(a===null)return null;let l=VO([o],a);if(!l)return null;return`${l}${i}`}function Ue(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}function q(e){return e.replaceAll("\\","/").replace(/^\.\//,"").replace(/\/+$/,"")}function He(e){return e??S?.projectConfig??null}function Ge(e){return e?.content??{}}function rn(e){let t=ln(e??{}).i18n?.locales??[];return t.length>0?[...t]:null}function ze(e){if(e.endsWith("/"))return!1;let t=e.slice(e.lastIndexOf("/")+1);return/\.[a-z\d]+$/i.test(t)}function Ye(e){if(e.format==="json")return{ext:".json",unresolvedFormat:null};if(e.format===void 0||e.format==="")return{ext:cr()?.extensions[0]??".json",unresolvedFormat:null};let t=zi(e.format);return t?.extensions[0]===void 0?{ext:null,unresolvedFormat:e.format}:{ext:t.extensions[0],unresolvedFormat:null}}function sn(e,t){let o=t===null?"[^/]+":`(?:${t.map((i)=>Ue(i)).join("|")})`,r=q(e).split(Io).map((i)=>Ue(i)).join(o);return new RegExp(`^${r}(?:/|$)`,"i")}function cn(e,t,o){let r=sn(e,o).exec(t);if(!r)return null;return r[0].replace(/\/$/,"")}function un(e){return q(e).replaceAll(Io,"").length}function Kd(e,t){if(e===null||e===void 0||e==="")return null;let o=He(t),r=rn(o),i=q(e),s=null,a=-1;for(let[l,c]of Object.entries(Ge(o))){let{source:d}=c;if(d===void 0||d===""||ze(d))continue;let b=un(d);if(b<=a)continue;let y=cn(d,i,r);if(y===null)continue;s={def:c,dir:i,fileBacked:!1,isSourceRoot:i.length===y.length,name:l,...Ye(c)},a=b}return s}function Vn(e,t){if(e===null||e===void 0||e==="")return null;let o=He(t),r=q(e),i=r.toLowerCase();for(let[s,a]of Object.entries(Ge(o))){let{source:l}=a;if(l===void 0||l===""||!ze(l))continue;let c=q(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,...Ye(a)}}return Kd(r.includes("/")?r.slice(0,r.lastIndexOf("/")):".",o)}function Zc(e){return e.replaceAll(/([A-Z])/g," $1").replace(/^./,(t)=>t.toUpperCase())}function Ox(e){return e.replaceAll(/[^a-zA-Z0-9]+(.)?/g,(t,o)=>o?o.toUpperCase():"").replace(/^[A-Z]/,(t)=>t.toLowerCase())}function Mx(e){return e.replaceAll(/(^|-)(\w)/g,(t,o,r)=>(o?" ":"")+r.toUpperCase())}function kC(e,t){return e?.$label||Zc(t)}function LO(e,t){if(e?.$label)return e.$label;if(t.includes("-"))return t.replaceAll(/(^|-)(\w)/g,(o,r,i)=>(r?" ":"")+i.toUpperCase());return Zc(t)}function Ra(e){return e==="image"||e==="uri-reference"}function vh(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(Ra(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 yh(e,t){if(!e||!t?.content)return null;let o=Vn(e,t);if(!o||!o.def.schema)return null;if(!o.fileBacked){let r=o.ext??cr()?.extensions[0]??".json";if(!e.toLowerCase().endsWith(r.toLowerCase()))return null}return{name:o.name,schema:o.def.schema}}function lv(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 Px(e,t){return e.replace(new RegExp(`^${t.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}`),"").replace(/^--/,"").replaceAll("-"," ").replaceAll(/\b\w/g,(o)=>o.toUpperCase())||e}function $O(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 Jo(e){return JSON.parse(JSON.stringify(e))}function Me(e){return e?.at(-1)??null}function lO(e){return e?.[0]??null}function Cx(e,t){if(!t||!e)return!1;return e.some((o)=>Tr(o,t))}function Qs(e){return F(e)}function F(e){let t=[];for(let o of e)t.push([...o]);return t}function kx(e,t){if(Cx(e,t))return F(e.filter((o)=>!Tr(o,t)));return[...F(e),[...t]]}function cO(e,t,o){let r=e.findIndex((a)=>Tr(a,o)),i=t?e.findIndex((a)=>Tr(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 F(s)}function qe(e,t){return F(e.filter((o)=>!ec(t,o)))}function dn(e,t){let o=Math.min(e.length,t.length);for(let r=0;r<o;r++){let i=e[r],s=t[r];if(i===s)continue;if(Z(i)&&Z(s))return i-s;return String(i)<String(s)?-1:1}return e.length-t.length}function mn(e){return F(e.filter((t)=>!e.some((o)=>!Tr(o,t)&&ec(o,t))))}function Om(e){return V(e)!==null}function V(e){let t=e?.at(-1);return e&&e.at(-2)==="children"&&Z(t)?{index:t,parentPath:e.slice(0,-2)}:null}function Ex(e){return mn(e).filter((t)=>Om(t)).toSorted((t,o)=>dn(o,t))}function dO(e){let t=[];for(let o of e)if(!t.some((r)=>Tr(r,o)))t.push([...o]);return t}function Mm(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 Ze=null;function uO(e){Ze=e}function Qe(){return Ze}var X=null,Q=null,ee=null,ve=!0;function et(){X=[],Q=[],ee=[],ve=!0}function f(e){if(X)X.push(e)}function Hi(e){if(Q)Q.push(e)}function tt(e){if(ee)ee.push(e)}function nt(){let e={docOps:Q??[],fmOps:ee??[],invertible:ve,ops:X??[]};return X=null,Q=null,ee=null,ve=!0,e}var ot=100,gn=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}}}function bn(e,t,o,r,i){let s=e.length,a=s<t.length&&e.every((d,b)=>d===t[b]),l=t[s+1];if(!a||t[s]!=="children"||!Z(l))return t;if(i?l<o:l<=o)return t;let c=[...t];return c[s+1]=l+r,c}var rt=null;function it(e){rt=e}var st=null;function at(e){st=e}function yn(e,t,o,r){for(let i=t.docOps.length-1;i>=0;i--)gv(e.doc.document,he(t.docOps[i].inverse));for(let i=t.fmOps.length-1;i>=0;i--){let s=t.fmOps[i];we(e,s.field,s.before)}e.doc.document={...he(e.doc.document)},e.session.selection=o,e.doc.dirty=r}function Y(e,t,{skipHistory:o=!1,origin:r="user",coalesceKey:i=null}={}){if(!e)return!1;if(r!=="remote"&&st?.(e,r))return!1;let s=Qs(e.session.selection),a=e.doc.dirty;et();let l,c=null;try{t(e)}catch(A){c={error:A}}finally{l=nt()}if(c)throw yn(e,l,s,a),c.error;let d=he(e.doc.document),b={...d},y=Qe(),h=y===null?{patchable:!1,reason:"no-patch-consumer"}:l.ops.length===0?{patchable:!1,reason:"unrecorded-mutation"}:y.classify(e,l.ops);if(h.patchable)y.markConsumed(b,e);if(e.doc.document=b,h.patchable)try{y.apply(e,l.ops,l)}catch(A){y.escalate(`patch-apply-failed: ${A instanceof Error?A.message:String(A)}`,e)}if(!o&&!W)hn(e,d,l,s,i);return e.doc.dirty=!0,rt?.(e,l,r),!0}function hn(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=Qs(e.session.selection),l.document)l.document=Jo(t);e.history.snapshots=s,e.history.index=s.length-1;return}let c=!a||s.length%gn===0;if(s.push({document:c?Jo(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:Qs(e.session.selection),selectionBefore:r}),s.length>ot){if(!s[1].document)s[1].document=Oe(s,1);s.shift()}e.history.snapshots=s,e.history.index=s.length-1}function Oe(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=Jo(r);for(let s=o+1;s<=t;s++)for(let a of e[s].forwardOps??[])gv(i,a);return i}function Ud(e,t,o){return Y(e,(r)=>t(r.doc.document),o)}function Pe(e,t){Y(e,(o)=>{for(let r of t)Ce(o,r)},{origin:"remote",skipHistory:!0})}var xn=new Set(["state","$media","$head","$elements","imports","$layout"]);function Ce(e,t){let o=null;if(t.op==="set-key")o=oe(e.doc.document,t.path)?.[t.key];switch(gv(e.doc.document,t),Hi({forward:t,inverse:t}),t.op){case"set-key":{if(xn.has(t.key))f({key:t.key,op:"doc-meta"});else if(t.key==="style")f({op:"set-style",path:t.path});else if(t.key==="textContent")f({op:"set-text",path:t.path});else if(t.key==="attributes"||t.key==="cases"||t.key==="$props")f({op:"replace",path:t.path});else{let r=t.key.startsWith("on")&&(sf(t.value)||sf(o));f({isEvent:r,key:t.key,op:"set-prop",path:t.path})}return}case"insert-child":{f({index:t.index,op:"insert",parentPath:t.parentPath});return}case"remove-child":{f({op:"remove",path:[...t.parentPath,"children",t.index]});return}case"set-child":{f({op:"replace",path:[...t.parentPath,"children",t.index]});return}case"move-child":{f({fromPath:[...t.fromParentPath,"children",t.fromIndex],op:"move",toIndex:t.toIndex,toParentPath:t.toParentPath});break}default:break}}var W=null,lt=null;function ct(e){lt=e}function Tx(e){W=e}function Lx(){let e=W;if(e&&!N.has(e)){let t=he(e.doc.document),o={document:Jo(t),selection:Qs(e.session.selection)},r=e.history.snapshots.slice(0,e.history.index+1);if(r.push(o),r.length>ot)r.shift();e.history.snapshots=r,e.history.index=r.length-1}if(W=null,e)lt?.(e)}function _C(){return W!==null}function hO(){return W}var N=new WeakMap;function ov(e,t){if(t)N.set(e,t);else N.delete(e)}function pO(e){let t=N.get(e);return t?t.canUndo(e):e.history.index>0}function fO(e){let t=N.get(e);return t?t.canRedo(e):e.history.index<e.history.snapshots.length-1}function ut(e,t){let{snapshots:o}=e.history;e.doc.document=Oe(o,t);let r=o[t];e.session.selection=Qs(he(r.selection))}function dt(e,t){try{if(typeof localStorage>"u"||!localStorage.getItem("jx-canvas-debug"))return}catch{return}let o=JSON.stringify(Oe(e.history.snapshots,t)),r=JSON.stringify(Jo(he(e.doc.document)));if(o!==r)console.error("jx history: ops-based undo/redo diverged from checkpoint replay",{index:t})}function SC(e){let t=N.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--)Ce(a,he(r[l]));if(i)for(let l=i.length-1;l>=0;l--){let c=he(i[l]);we(a,c.field,c.before)}},{origin:"history",skipHistory:!0}))return;e.session.selection=Qs(he(o.selectionBefore??[])),e.history.index-=1,dt(e,e.history.index)}else e.history.index-=1,ut(e,e.history.index);e.doc.dirty=!0}function mO(e){let t=N.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)Ce(a,he(l));if(i)for(let l of i){let c=he(l);we(a,c.field,c.after)}},{origin:"history",skipHistory:!0}))return;e.session.selection=Qs(he(o.selection)),e.history.index+=1,dt(e,e.history.index)}else e.history.index+=1,ut(e,e.history.index);e.doc.dirty=!0}function Lo(e,t,o,r){let i=oe(e.doc.document,t);if(!i)return;mv(i).splice(o,0,structuredClone(r)),f({index:o,op:"insert",parentPath:t}),Hi({forward:{index:o,node:$e(r),op:"insert-child",parentPath:t},inverse:{index:o,op:"remove-child",parentPath:t}})}function bh(e,t){let o=V(t);if(!o)return;let{index:r,parentPath:i}=o,[s]=w(e.doc.document,i).children.splice(r,1);f({op:"remove",path:t}),Hi({forward:{index:r,op:"remove-child",parentPath:i},inverse:{index:r,node:$e(s),op:"insert-child",parentPath:i}}),e.session.selection=qe(e.session.selection,t)}function R$(e,t){let o=V(t);if(!o)return;let r=oe(e.doc.document,t);if(!r)return;let{index:i,parentPath:s}=o,a=structuredClone(he(r));w(e.doc.document,s).children.splice(i+1,0,a),f({index:i+1,op:"insert",parentPath:s}),Hi({forward:{index:i+1,node:$e(a),op:"insert-child",parentPath:s},inverse:{index:i+1,op:"remove-child",parentPath:s}}),e.session.selection=[[...s,"children",i+1]]}function Pm(e,t){for(let o of Ex(t))bh(e,o)}function $x(e,t){let o=[];for(let r of Ex(t)){let i=e.session.selection;R$(e,r);let s=Me(e.session.selection),a=V(s);if(!s||!a||e.session.selection===i)continue;o=o.map((l)=>bn(a.parentPath,l,a.index,1,!0)),o.unshift(s)}if(o.length>0)e.session.selection=o}function gO(e,t,o="div"){let r=V(t);if(!r)return;let i=oe(e.doc.document,t);if(!i)return;let{index:s,parentPath:a}=r,l={children:[structuredClone(he(i))],tagName:o},c=$e(i);w(e.doc.document,a).children.splice(s,1,l),f({op:"replace",path:t}),Hi({forward:{index:s,node:$e(l),op:"set-child",parentPath:a},inverse:{index:s,node:c,op:"set-child",parentPath:a}}),e.session.selection=[[...a,"children",s]]}function Yc(e,t,o,r){let i=e.doc.document,s=At(t),a=hi(t);if(!s||!Z(a))return;let l=oe(i,s),c=oe(i,o);if(!l||!Array.isArray(l.children)||!c)return;if(l.children[a]===void 0)return;let d=r;if(l===c&&a<r)d-=1;let b={fromIndex:a,fromParentPath:s,op:"move-child",toIndex:d,toParentPath:o},y=Z$(i,b),[h]=l.children.splice(a,1);if(mv(c).splice(d,0,h),f({fromPath:t,op:"move",toIndex:d,toParentPath:o}),Hi({forward:b,inverse:y}),Tr(Me(e.session.selection),t)){let A=r;if(s.length===o.length&&s.every((j,L)=>j===o[L])&&a<r)A=r-1;e.session.selection=[[...o,"children",A]]}}function Ve(e,t,o,r){let i=oe(e.doc.document,t);if(!i)return;let s=i[o],a=$e(s);if(r===void 0||r===null||r==="")delete i[o];else i[o]=r;if(Hi(P(t,o,a,$e(i[o]))),o==="textContent")f({op:"set-text",path:t});else if(o==="style")f({op:"set-style",path:t});else{let l=r===void 0||r===null||r===""?s:r,c=o.startsWith("on")&&sf(l);f({isEvent:c,key:o,op:"set-prop",path:t})}}function qd(e,t,o,r){let i=w(e.doc.document,t),s=$e(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;Hi(P(t,"style",s,$e(i.style))),f({op:"set-style",path:t})}function kr(e,t,o,r){let i=w(e.doc.document,t),s=$e(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;Hi(P(t,"attributes",s,$e(i.attributes))),f({attr:o,op:"set-attr",path:t})}function bO(e,t,o,r,i){if(!o)return qd(e,t,r,i);let s=w(e.doc.document,t),a=$e(s.style);if(!s.style)s.style={};let l=`@${o}`,c=nd(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;Hi(P(t,"style",a,$e(s.style))),f({op:"set-style",path:t})}function Ix(e,t,o,r,i){let s=w(e.doc.document,t),a=$e(s.style);if(!s.style)s.style={};let l=nd(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;Hi(P(t,"style",a,$e(s.style))),f({op:"set-style",path:t})}function vO(e,t,o,r,i,s){let a=w(e.doc.document,t),l=$e(a.style);if(!a.style)a.style={};let c=`@${o}`,d=nd(a.style,c),b=nd(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;Hi(P(t,"style",l,$e(a.style))),f({op:"set-style",path:t})}function ft(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 Rx(e,t,o,r,i){let s=w(e.doc.document,t),a=$e(s.style);if(!s.style)s.style={};let l=s.style;for(let c of o)l=nd(l,c);if(i===void 0||i==="")delete l[r],ft(s.style,o);else l[r]=i;if(Object.keys(s.style).length===0)delete s.style;Hi(P(t,"style",a,$e(s.style))),f({op:"set-style",path:t})}function yO(e,t,o,r,i,s){let a=w(e.doc.document,t),l=$e(a.style);if(!a.style)a.style={};let c=`@${o}`,d=nd(a.style,c),b=d;for(let y of r)b=nd(b,y);if(s===void 0||s===""){if(delete b[i],ft(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;Hi(P(t,"style",l,$e(a.style))),f({op:"set-style",path:t})}function wO(e,t,o){let r=w(e.doc.document,t),i=$e(r.style);if(o&&Object.keys(o).length>0)r.style=o;else delete r.style;Hi(P(t,"style",i,$e(r.style))),f({op:"set-style",path:t})}function Ia(e,t,o){let r=e.doc.document,i=$e(r.state);if(!r.state)r.state={};r.state[t]=o,Hi(P([],"state",i,$e(r.state))),f({key:"state",op:"doc-meta"})}function Dx(e,t){let o=e.doc.document;if(o.state){let r=$e(o.state);if(delete o.state[t],Object.keys(o.state).length===0)delete o.state;Hi(P([],"state",r,$e(o.state))),f({key:"state",op:"doc-meta"})}}function qr(e,t,o){let r=e.doc.document,i=$e(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];Hi(P([],"state",i,$e(r.state))),f({key:"state",op:"doc-meta"})}function xO(e,t,o){let r=e.doc.document;if(!r.state||!r.state[t])return;let i=$e(r.state);r.state[o]=r.state[t],delete r.state[t],Hi(P([],"state",i,$e(r.state))),f({key:"state",op:"doc-meta"})}function Up(e,t,o,r){let i=w(e.doc.document,t),s=$e(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;Hi(P(t,"$props",s,$e(i.$props))),f({op:"replace",path:t})}function _O(e,t,o,r){let i=w(e.doc.document,t),s=$e(i.cases);if(!i.cases)i.cases={};i.cases[o]=r||{tagName:"div",textContent:o},Hi(P(t,"cases",s,$e(i.cases))),f({op:"replace",path:t})}function SO(e,t,o){let r=w(e.doc.document,t);if(r.cases){let i=$e(r.cases);delete r.cases[o],Hi(P(t,"cases",i,$e(r.cases))),f({op:"replace",path:t})}}function CO(e,t,o,r){let i=w(e.doc.document,t);if(!i.cases||!i.cases[o])return;let s=$e(i.cases);i.cases[r]=i.cases[o],delete i.cases[o],Hi(P(t,"cases",s,$e(i.cases))),f({op:"replace",path:t})}function Gd(e,t,o){let r=e.doc.content.frontmatter,i=Object.hasOwn(r,t)?$e(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:$e(o);tt({after:a,before:i,field:t}),e.doc.dirty=!0}function we(e,t,o){if(o===void 0)delete e.doc.content.frontmatter[t];else e.doc.content.frontmatter[t]=o}function Nm(e){let t=new Set,o=new Set;return fv(e,(r,i)=>{t.add(r),o.add(JSON.stringify(i))}),t.size===0?null:{fingerprints:o,pointers:t}}function sO(e,t){if(!t)return e;return Re(e,"",t)}function Re(e,t,o){if(Array.isArray(e)){let i=null;for(let[s,a]of e.entries()){let l=Re(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=Re(s,`${t}/${U$(i)}`,o);if(i==="children"&&Array.isArray(a)&&a.length===1){let[l]=a;if(Yo(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 gC=["design","content","media","styles","publish"],bx="design",Xb=[{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 L$(e){return typeof e==="string"&&gC.some((t)=>t===e)}function Qb(e){return Xb.find((t)=>t.id===e)}var Ae="workspace://",vx={content:"content-home",media:"media-home",publish:"publish-home"};function Wp(e){return Object.hasOwn(vx,e)}function Yl(e){return`${Ae}${e}`}function al(e){if(!e.startsWith(Ae))return null;let t=e.slice(Ae.length);return L$(t)&&Wp(t)?t:null}function ev(e){let t=al(e);return t?Qb(t).title:null}var vn=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"]]),Vp={canvas:"Canvas",code:"Code",config:"Elements",diff:"Diff",entry:"Entry",grid:"Grid",home:"Home",media:"Media",none:"None",tokens:"Variables"};function Xs(e){return vn.get(e)??"canvas"}var On=new Map([["design","design"],["edit","edit"],["preview","preview"]]);function XA(e){return On.get(e)??"design"}var yx=(e)=>e.editor.kind==="canvas",mh=(e)=>yx(e)&&e.selection.count>0,wx=(e)=>mh(e)&&!e.selection.isRoot;function tv(){return{project:{open:!1,isSite:!1,isRepo:!1,isMultilingual:!1},git:{ahead:0,behind:0,dirtyCount:0},workspace:{id:bx},document:{open:!1,dirty:!1,mode:"",canUndo:!1,canRedo:!1},editor:{kind:"none"},canvas:{view:"design"},pane:{count:1,derived:!1},selection:{count:0,paths:[],kind:"",isRoot:!1,isComponentInstance:!1,isLayoutNode:!1,isRepeater:!1},caret:{active:!1,inCanvas:!1},focus:{region:"pane"},modal:{open:!1},collab:{attached:!1,readOnly:!1,sourceCanonical:!1},ai:{configured:!1,streaming:!1,waiting:!1},capability:{gitClone:!1,importSite:!1,openProjectInNewWindow:!1,dataRows:!1,windowControls:!1,findReferences:!1,readFileBytes:!1,publish:!1}}}function bC(e={}){let t=tv();for(let o of Object.keys(e)){let r=e[o];if(r)Object.assign(t[o],r)}return t}var Sn=["palette"],Cn=["caret","global"],wn=["dock","global"],Rn=["canvas","global"],An=["grid","global"],Jn=["code","global"],pt=["global"];function QA(e){if(e.modal.open)return Sn;if(e.caret.active)return Cn;if(e.focus.region!=="pane")return wn;switch(e.editor.kind){case"grid":return An;case"code":return Jn;case"canvas":return e.canvas.view==="preview"?pt:Rn;default:return pt}}var an="project.json";function In(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 kn=["edit","design","preview","source","stylebook","git-diff"];function iv({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:y}){let h=ge(),A=Nm(r),j=a?.modes??Dn(t,s),L=y??j.find((x)=>x!=="preview")??"edit",ce=j[0]==="preview",D={bareRepeaters:A,content:{frontmatter:i||{}},dirty:!1,document:r,handlersSource:null,layout:d,mode:jn(t,s),source:b,sourceFormat:s},ue={index:0,snapshots:[{document:structuredClone(r),selection:[]}]},H={canvas:{refreshing:!1,error:null,livePreviews:null,pendingInlineEdit:null,scope:null,status:"idle"},clipboard:null,hover:null,openedFrom:l,selection:[],ui:In(L,ce)};return h.run(()=>({capabilities:{modes:j},doc:g(D),documentPath:t,fileHandle:o,history:g(ue),id:e,pinned:!1,preview:c,scope:h,session:g(H)}))}function Dn(e,t){if(e===an)return["stylebook","tokens","source"];let o=zi(t)??fn(e);if(o)return o.studio?.modes??["edit","design","preview","source"];return kn}function jn(e,t){let o=zi(t)??fn(e);if(o)return o.studio?.documentMode?.default??"content";return"component"}function xC(e){return Xs(e.session.ui.canvasMode)}function I$(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 aO(e,t){return e.capabilities.modes.find((o)=>o!=="preview"&&Xs(o)===t)}function Am(e){e.scope.stop()}var mt=new WeakMap,B=new Map;function Tn(e){let t=he(e),o=mt.get(t);if(!o)o=g({active:!1,attachError:"",peers:[],readOnly:!1,sourceCanonical:!1,status:"unavailable"}),mt.set(t,o);return o}function gt(e){B.set(e,(B.get(e)??0)+1)}function bt(e){let t=B.get(e)??0;if(t<=1)B.delete(e);else B.set(e,t-1)}function rv(e){return B.has(e.replaceAll("\\","/"))}var En=8000,Mn=800,Nn=2500,yt=null;function $n(){return yt??=(le("fkrm7pdk"),import("./index-fkrm7pdk.js")),yt}function xt(){try{return p()}catch{return null}}var K=null;function IO(e){K=e}var Ie=null;function RO(e){Ie=e}var Tt=()=>{};function DO(e){Tt=e??(()=>{})}var ke=new WeakMap;function vt(e){return he(e)}function De(e,t){return e.frontmatterMap(t)}function Ln(e){return e.synced}function k(e){return ke.get(vt(e))}function Ne(e){let t=vt(e),o=ke.get(t);if(!o)o={attaching:null,generation:0,optedOut:g({value:!1}),session:null,watcherInstalled:!1},ke.set(t,o);return o}var ht=!1;function Fn(){if(ht)return;ht=!0,it(_n),ct(Bn),at((e)=>{if(k(e)?.session?.synced&&Tn(e).sourceCanonical)return Tt("Source editing in progress — structural edits are paused"),"source-canonical";return null})}function _n(e,t,o){let r=k(e)?.session;if(!r||!r.synced)return;if(r.lastSeenRef=he(e.doc.document),o==="remote"){fe(r);return}if(r.canWrite)Kn(r,t),fe(r)}function Bn(e){let t=k(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 Kn(e,t){let o=t.docOps.map((r)=>r.forward);if(_C()){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=Jo(he(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 Je(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 Un(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 fe(e){if(!K||!Un(e))return;if(e.collab.canonicalOf(e.handle.doc)==="source")return;let t=Date.now();if(e.lastMirrorAt??=t,t-e.lastMirrorAt>=Nn){if(e.mirrorTimer)clearTimeout(e.mirrorTimer),e.mirrorTimer=null;e.lastMirrorAt=t,je(e);return}if(e.mirrorTimer)clearTimeout(e.mirrorTimer);e.mirrorTimer=setTimeout(()=>{e.mirrorTimer=null,e.lastMirrorAt=Date.now(),je(e)},Mn)}async function je(e){if(!K||!e.synced)return;try{let t=await K(e.tab);e.collab.updateSourceText(e.handle.doc,t,e.collab.MIRROR_ORIGIN)}catch{}}async function Ot(e){if(!Ie||!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 Ie(r,s)}catch{return}if(!Ln(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=De(t,o.doc),d=a.frontmatter??{};o.doc.transact(()=>{let b=[...c.keys()];for(let y of b)if(!(y in d))c.delete(y);for(let[y,h]of Object.entries(d))if(!t.deepEqual(c.get(y),h))c.set(y,h)},t.MIRROR_ORIGIN)}function NO(e){let t=k(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(K)try{l=await K(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)Ot(t).then(()=>{o.releaseSourceCanonical(r.doc,o.LOCAL_ORIGIN)})},localOrigin:o.LOCAL_ORIGIN,readOnly:!t.canWrite,text:o.sourceText(r.doc)}}function cv(e){let t=Tn(e);return t.active&&t.readOnly}async function O$(e){let t=k(e)?.session;if(!t?.synced||!t.canWrite)return!1;if(t.mirrorTimer)clearTimeout(t.mirrorTimer),t.mirrorTimer=null;return await je(t),await t.handle.flush(),!0}async function AO(){for(let e of Ee)if(k(e)?.session?.synced)await O$(e)}var Ee=new Set;function ie(e){if(!xt()?.collab||!e.documentPath||e.documentPath===an)return;let o=Ne(e);if(o.watcherInstalled)return;o.watcherInstalled=!0,Fn(),Ee.add(e),e.scope.run(()=>{ne(()=>{if(o.optedOut.value)pe(e);else Le(e)}),ea(()=>{Ee.delete(e),pe(e)})})}function M$(e,t){let o=Ne(e);if(o.optedOut.value===!t)return;if(o.optedOut.value=!t,!o.watcherInstalled&&t)ie(e)}function P$(e){return k(e)?.optedOut.value!==!0}function Pt(e){if(!k(e)?.watcherInstalled){ie(e);return}pe(e),Le(e)}async function Le(e){let t=Ne(e);if(t.session||t.attaching)return;let{documentPath:o}=e,r=xt();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([$n(),r.collab(o)]);if(!c){s.status="detached";return}if(t.generation!==i){c.destroy();return}let d,b=new Promise((y,h)=>{d=setTimeout(()=>h(Error("collab-sync-timeout")),En)});try{await Promise.race([c.whenSynced,b])}finally{clearTimeout(d)}if(t.generation!==i){c.destroy();return}t.session=Hn(e,o,l,c),s.active=!0,s.status="synced",s.readOnly=!t.session.canWrite,s.attachError="",gt(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 pe(e){let t=k(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(bt(o.path),o.mirrorTimer)clearTimeout(o.mirrorTimer);if(o.sourceParseTimer)clearTimeout(o.sourceParseTimer);for(let i of o.disposers)try{i()}catch{}ov(e,null),e.history.snapshots=[{document:Jo(he(e.doc.document)),selection:Qs(e.session.selection)}],e.history.index=0,o.undoManager?.destroy(),o.handle.destroy()}function Hn(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:he(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 x=o.yDocToJson(r.doc),T=Jo(he(e.doc.document));if(!o.deepEqual(x,T)){let J=o.diffDocs(T,x);if(J===null)s.synced=!0,Je(s),s.synced=!1;else if(J.length>0)Pe(e,J)}s.applyingRemoteFrontmatter=!0;let O=De(o,r.doc);for(let[J,M]of O.entries())e.doc.content.frontmatter[J]=M;s.applyingRemoteFrontmatter=!1}else if(s.canWrite)o.seedStructure(r.doc,Jo(he(e.doc.document)),{frontmatter:Jo(he(e.doc.content.frontmatter)),origin:o.SEED_ORIGIN,sourceFormat:e.doc.sourceFormat});s.lastSeenRef=he(e.doc.document),s.disposers.push(r.onDirty((x)=>{e.doc.dirty=x})),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:x})=>{x.meta.set("selection",Qs(e.session.selection))},d=({stackItem:x})=>{let T=x.meta.get("selection");e.session.selection=Qs(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)}),ov(e,{canRedo:()=>l.canRedo(),canUndo:()=>l.canUndo(),redo:()=>{l.redo()},undo:()=>{l.undo()}});let b=o.structureMap(r.doc),y=(x,T)=>{if(T.origin===o.LOCAL_ORIGIN||!s.synced)return;let O=o.yEventsToDocOps(x);if(O===null){Je(s);return}if(O.length===0)return;try{Pe(e,O)}catch{Je(s)}};b.observeDeep(y),s.disposers.push(()=>b.unobserveDeep(y));let h=Tn(e);h.sourceCanonical=o.canonicalOf(r.doc)==="source";let A=o.metaMap(r.doc),j=()=>{h.sourceCanonical=o.canonicalOf(r.doc)==="source"};A.observe(j),s.disposers.push(()=>A.unobserve(j));let L=o.sourceText(r.doc),ce=(x,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,Ot(s)},600)};L.observe(ce),s.disposers.push(()=>L.unobserve(ce));let D=De(o,r.doc),ue=(x,T)=>{if(T.origin===o.LOCAL_ORIGIN||!s.synced)return;s.applyingRemoteFrontmatter=!0;try{for(let[O,J]of x.changes.keys)if(J.action==="delete")delete e.doc.content.frontmatter[O];else e.doc.content.frontmatter[O]=D.get(O)}finally{s.applyingRemoteFrontmatter=!1}};D.observe(ue),s.disposers.push(()=>D.unobserve(ue)),e.scope.run(()=>{let x=JSON.stringify(e.doc.content.frontmatter);ne(()=>{let T=JSON.stringify(e.doc.content.frontmatter);if(T===x)return;if(x=T,s.applyingRemoteFrontmatter||!s.synced||!s.canWrite)return;let O=JSON.parse(T);r.doc.transact(()=>{let J=[...D.keys()];for(let M of J)if(!(M in O))D.delete(M);for(let[M,Be]of Object.entries(O))if(!o.deepEqual(D.get(M),Be))D.set(M,Be)},o.LOCAL_ORIGIN),fe(s)}),ne(()=>{let T=e.session.selection.length>0?Qs(e.session.selection):null,O=r.awareness.getLocalState();if(O)r.awareness.setLocalState({...O,structuralSelection:T})}),ne(()=>{let T=he(e.doc.document);queueMicrotask(()=>{if(k(e)?.session!==s||!s.synced||!s.canWrite)return;let J=he(e.doc.document);if(J!==T||J===s.lastSeenRef)return;s.lastSeenRef=J,re(s),fe(s)})})});let H=Tn(e),de=()=>{let x=[];for(let[T,O]of r.awareness.getStates())if(T!==r.awareness.clientID&&O.user)x.push({clientId:T,state:O});H.peers=x};return de(),r.awareness.on("change",de),s.disposers.push(()=>r.awareness.off("change",de),r.onStatus((x)=>{if(x==="offline"||x==="connecting")H.status="offline";else if(s.synced)H.status="synced"}),r.onReset(()=>{pe(e),Le(e)})),s.synced=!0,s}function I(e,t,o){return RangeError(`command "${e}" argument "${t}": ${o}`)}function Gn(e){if(Z(e))return"number";if(Xe(e))return"boolean";return n(e)?"string":"object"}function R(e){if(e===void 0)return"missing";return n(e)?`"${e}"`:`${Gn(e)} ${JSON.stringify(e)}`}function wt(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 Xn(e,t,o){if(t[o]===void 0)return;return St(e,t,o)}function Rt(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 Ct(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 Nx(e,t,o,r,i){let s=Rt(e,t,o);if(s<r||s>i)throw I(e,o,`${s} is outside the supported range ${r}–${i}`);return s}function Bi(e,t,o){let r=t[o];if(!Xe(r))throw I(e,o,`expected a boolean, got ${R(r)}`);return r}function Wn(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 CC(e,t,o){let r=t[o];if(!wt(r))throw I(e,o,`expected an array of path segments (strings or numbers), got ${R(r)}`);return r}function kO(e,t,o){if(t[o]===null)return null;return CC(e,t,o)}function N$(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(!wt(i))throw I(e,o,`entry ${s} is not a document path — expected an array of segments, got ${R(i)}`);return i})}function Se(e,t=Object.keys(e)){return{additionalProperties:!1,properties:e,required:[...t],type:"object"}}function di(e,t){return{description:t,enum:[...e],type:"string"}}function ll(e,t){return{description:t,get enum(){return[...e()]},type:"string"}}function A$(e,t={}){return{description:e,type:"number",...t}}function $o(e){return{description:e,type:"boolean"}}function Ax(e,t=!1){let o={items:{type:["string","number"]},type:"array"};return t?{description:e,oneOf:[o,{type:"null"}]}:{description:e,...o}}function EO(e){return{description:e,items:{items:{type:["string","number"]},type:"array"},type:"array"}}function We(e){return{description:e,type:"string"}}function zn(e){return e.length===2&&e.includes("string")&&e.includes("number")}function Fe(e){return n(e)?[e]:e}function Jt(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 zn(o)?"path":"pass-through";return o==="array"?"path-list":"pass-through"}case"null":case"object":return"typed";default:break}return"pass-through"}function It(e,t){switch(e){case"null":return t===null;case"boolean":return Xe(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 kt(e){if(e.length<=1)return e.join("");return`${e.slice(0,-1).join(", ")} or ${e.at(-1)}`}function Yn(e,t,o,r){let i=t[o];if(i===void 0||!r.some((s)=>It(s,i)))throw I(e,o,`expected ${kt(r)}, got ${R(i)}`);return i}function Dt(e){switch(Jt(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)=>Dt(t)).join(" or ");case"typed":return kt(Fe(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 qn(e,t,o,r){let i=t[o],s=[];for(let a of r){if(a.type!==void 0&&!Fe(a.type).some((l)=>It(l,i)))continue;try{return jt(e,t,o,a)}catch(l){s.push(l)}}if(s.length===1)throw s[0];throw I(e,o,`expected ${r.map((a)=>Dt(a)).join(" or ")}, got ${R(i)}`)}function jt(e,t,o,r){switch(Jt(r)){case"enum":return Wn(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 qn(e,t,o,r.oneOf??[]);case"typed":return Yn(e,t,o,Fe(r.type??[]));case"boolean":return Bi(e,t,o);case"bounded-number":{if(r.type==="integer")Ct(e,t,o);return Nx(e,t,o,r.minimum,r.maximum)}case"number":return Rt(e,t,o);case"integer":return Ct(e,t,o);case"string":return St(e,t,o);case"path":return CC(e,t,o);case"path-list":return N$(e,t,o);default:return t[o]}}function TO(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]=jt(e,o,c,i[c])}return l}var Zn=20,ui="primary",Fm="secondary",F$=2,m=g({activePaneId:ui,clipboard:null,closedTabs:[],componentRegistry:[],mruOrder:[],fileTree:{dirs:new Map,expanded:new Set,searchQuery:"",selectedPath:null},panes:[{activeTabId:null,derived:null,id:ui,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=Th(()=>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 Er(e){let t=pn(e);if(!t||t.id===m.activePaneId)return;m.activePaneId=t.id,E();let{activeTabId:o}=t;if(o){_e(o);let r=m.tabs.get(o);if(r)Ft(r)}}function jm(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 zm(t),wh(i,t),i.activeTabId=t,m.activePaneId=i.id,E(),_e(t),i}function TC(e){return m.panes.find((t)=>t.id!==e)??Qn(Fm)}function Xl(e){let t=TC(e);if(t.derived)t.derived=null;return t}function Qn(e){let t=pn(e);if(t)return t;return m.panes=[...m.panes,{activeTabId:null,derived:null,id:e,tabOrder:[]}],pn(e)}function Hm(e){if(m.panes.length<2)return;let t=e===ui?m.panes.find((s)=>s.id!==ui)?.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)wh(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),E()}function Bm(e){return e.tabOrder.length===0&&e.derived===null}var U=()=>!0;function LC(e){U=e??(()=>!0)}var Nt=null;function $C(e){Nt=e}var $t=null;function IC(e){$t=e}function eo(){let e=0;for(let t of m.tabs.keys())if(U(t))e+=1;return e}function Lt(e){return e.tabOrder.findLast((t)=>U(t))??null}function zm(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=Lt(o);if(o.id!==ui&&Bm(o))t.push(o.id)}for(let o of t)Hm(o)}function wh(e,t,o){if(e.tabOrder.includes(t))return;let r=o??no(e,t);e.tabOrder=[...e.tabOrder.slice(0,r),t,...e.tabOrder.slice(r)]}function to(e){let t=0;for(let o of e.tabOrder){if(m.tabs.get(o)?.pinned!==!0)break;t+=1}return t}function no(e,t){return m.tabs.get(t)?.pinned===!0?to(e):e.tabOrder.length}function Ql(e,t=null){if(m.projectRoot&&e!==m.projectRoot)wC();m.projectRoot=e,m.projectConfig=t}function qp(e){let t=u.value;return e!==null&&t!==null&&he(t)===he(e)}function Jd(e){if(!e)return!1;let t=m.tabs.get(e.id);return t!==void 0&&he(t)===he(e)}function _e(e){m.mruOrder=[e,...m.mruOrder.filter((t)=>t!==e)]}var me=null,se=0;function E(){me=null,se=0}function Ft(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)E(),_e(e);Ft(o)}function _i(e){if(e.background===!0){let a=m.tabs.get(e.id);if(a)return a;let l=iv({...e,preview:!1}),c=(e.paneId===void 0?void 0:pn(e.paneId))??Gr();return wh(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=iv({...e,preview:o}),i=(e.paneId===void 0?void 0:pn(e.paneId))??Gr(),s;if(t)r.pinned=t.pinned,Am(t);else{if(o){let l=Et(i),c=l?m.tabs.get(l):null;if(c)Xd(c);DC()}let a=o?Et(i):null;if(a)s=i.tabOrder.indexOf(a),Yd(a);wh(i,r.id,s)}return m.tabs.set(r.id,r),ae(r.id,{focus:e.focus!==!1}),ie(r),r}function Et(e){return e.tabOrder.find((t)=>m.tabs.get(t)?.preview===!0)??null}function Xc(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)Xc(e)}function Fx(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 j$(e,t){let o=m.tabs.get(e),r=Zl(e);if(!o||!r)return;r.tabOrder=_t(r,e,t)}function _t(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 Yd(e){let t=m.tabs.get(e);if(!t)return;let o=Zl(e),r=o?.activeTabId===e;if(oo(t),Am(t),m.tabs.delete(e),xx(e),zm(e),m.mruOrder=m.mruOrder.filter((l)=>l!==e),E(),o&&Bm(o))Hm(o.id);if(!r)return;let i=Gr(),s=$t?.(i.id)??null,a=(s!==null&&i.tabOrder.includes(s)?s:null)??m.mruOrder.find((l)=>i.tabOrder.includes(l)&&U(l))??Lt(i);if(a)ae(a);else Nt?.(i.id)}function H$(){let e=[...m.tabs.values()];m.tabs.clear(),Wt(),m.mruOrder=[],E();for(let t of e)Am(t)}function Wt(){m.panes=[{activeTabId:null,derived:null,id:ui,tabOrder:[]}],m.activePaneId=ui}function oo(e){if(!e.documentPath)return;let t=e.documentPath;m.closedTabs=[{documentPath:t},...m.closedTabs.filter((o)=>o.documentPath!==t)].slice(0,Zn)}function ro(){let[e]=m.closedTabs;if(!e)return;return m.closedTabs=m.closedTabs.slice(1),e.documentPath}function Mt(e){if(!me)me=m.mruOrder.filter((r)=>m.tabs.has(r)&&U(r)),se=0;let t=me;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 B$(e){let t=[...m.tabs.keys()],o=[...m.tabs.values()],r=iv(e);m.tabs.set(r.id,r),Wt(),m.panes[0].tabOrder=[r.id],m.mruOrder=[],E(),ae(r.id),ie(r);for(let i of t){if(i===r.id)continue;m.tabs.delete(i)}for(let i of o)Am(i);return r}function Ht(e,t={}){ae(e,t)}function dv(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=_t(r,e,o);return r}return zm(e),wh(r,e,o),r}function jx(e,t,o){let r=m.tabs.get(e);if(!r)return;if(r.id=t,r.documentPath=o,vC(e))xx(e),Dm(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),E(),Pt(r)}function z$(e,t){e.registerAll([...io(t),...so(t)])}function io(e){let t=()=>eo()>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:()=>{Mt(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:()=>{Mt(-1)}},{args:Se({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 ${Vp[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:Se({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(Bm(s)&&s.id!==ui)Hm(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=ro();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)Fx(o,!r.pinned)}},{args:Se({pinned:$o("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))Fx(i,Bi("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)Xc(o)}}]}function so(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:Se({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:()=>{Er(ui)}},{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:()=>{Er(Fm)}},{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:ao}]}function ao(){let e=m.panes.find((t)=>t.derived!==null);if(e?.id===ui){if(e.derived=null,!Bm(e))return}Hm(e?.id??Fm)}
|
|
2
|
-
export{mC,Pn,mx,Yb,Vt,ln,go,gx,Zb,Jc,ZA,gC,bx,Xb,L$,Qb,vx,Wp,Yl,al,ev,Vp,Xs,XA,yx,mh,wx,tv,bC,QA,Dm,xx,vC,nv,uo,bo,_x,gh,Sx,eO,$$,tO,nO,iO,yC,oO,wC,rO,Nm,sO,an,iv,xC,I$,aO,Am,Me,lO,Cx,Qs,kx,cO,Om,Ex,dO,Mm,uO,Hi,Y,Ud,Tx,Lx,_C,hO,ov,pO,fO,SC,mO,Lo,bh,R$,Pm,$x,gO,Yc,Ve,qd,kr,bO,Ix,vO,Rx,yO,wO,Ia,Dx,qr,xO,Up,_O,SO,CO,Gd,Tn,rv,D$,sv,av,St,Xn,Nx,Bi,Wn,CC,kO,N$,Se,di,ll,A$,$o,Ax,EO,We,TO,Kd,Vn,Zc,Ox,Mx,kC,LO,Ra,vh,yh,lv,Px,$O,Jo,IO,RO,DO,NO,cv,O$,AO,M$,P$,ui,Fm,F$,m,u,Gr,pn,Zl,Er,jm,EC,TC,Xl,Hm,Bm,LC,$C,IC,zm,wh,Ql,qp,Jd,RC,_i,Xc,DC,Fx,j$,Yd,H$,B$,Ht,dv,jx,z$};
|
|
3
|
-
|
|
4
|
-
//# debugId=324F44DC8B3C1D5D64756E2164756E21
|
|
5
|
-
//# sourceMappingURL=studio-y1x65h5r.js.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{L,C,A,H,q,z,G,Y,X,Q}from"./iframe-entry-pkgmcgp0.js";export{L as TOAST_PAUSE,C as TOAST_RESUME,H as closeToast,Q as onToastAction,X as onToastDismiss,G as onToastHold,q as onToastMount,Y as onToastRelease,z as onToastUnmount,A as staysInside};
|
|
2
|
-
|
|
3
|
-
//# debugId=A581186084C4425F64756E2164756E21
|
|
4
|
-
//# sourceMappingURL=toast-1gv0h53h.js.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{ui,Fm,F$,m,u,Gr,pn,Zl,Er,jm,EC,TC,Xl,Hm,Bm,LC,$C,IC,zm,wh,Ql,qp,Jd,RC,_i,Xc,DC,Fx,j$,Yd,H$,B$,Ht,dv,jx,z$}from"./studio-y1x65h5r.js";import"./studio-grp684wx.js";import"./studio-6vrxzkba.js";import"./studio-hw60n5dh.js";import"./studio-tpmnbgmt.js";import"./studio-pr23qhrw.js";export{F$ as MAX_PANES,ui as PRIMARY_PANE,Fm as SECONDARY_PANE,Ht as activateTab,Gr as activePane,u as activeTab,RC as clearPaneActiveTab,H$ as closeAllTabs,Hm as closePane,Yd as closeTab,zm as detachTab,Er as focusPane,wh as insertIntoPane,jm as isPaneFocused,qp as isTabActive,j$ as moveTab,dv as moveTabToPane,_i as openTab,TC as paneBeside,pn as paneById,Bm as paneIsEmpty,Zl as paneOfTab,DC as promoteDirtyPreviewTabs,Xc as promoteTab,Xl as receivingPane,z$ as registerTabCommands,jx as renameTab,B$ as replaceAllTabs,IC as setCloseLanding,$C as setEmptyPaneFallback,Fx as setTabPinned,LC as setTabScope,Ql as setWorkspaceProject,EC as splitRight,Jd as tabIsLive,m as workspace};
|
|
2
|
-
|
|
3
|
-
//# debugId=45ACB254DB7F46E164756E2164756E21
|
|
4
|
-
//# sourceMappingURL=workspace-3nt93k48.js.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{b2,Q0,mk,gk,e_,Ag,bk}from"./studio-1fvzq9vs.js";import"./studio-v0gsjav0.js";import"./studio-pbagym4j.js";import"./studio-8m1t83kn.js";import"./studio-89cwmnae.js";import"./studio-3pndhat0.js";import"./studio-bf0rgyf7.js";import"./studio-g6ysm05p.js";import"./studio-j4e627w1.js";import"./studio-d140sy8e.js";import"./studio-74nzv280.js";import"./studio-xddgbwhe.js";import"./studio-fw3jp9m7.js";import"./studio-f8kz3krj.js";import"./studio-c4rcaftm.js";import"./studio-a3evp7f6.js";import"./studio-a6x058ew.js";import"./studio-bqgs90r8.js";import"./studio-332hesdk.js";import"./studio-2dtc90zs.js";import"./studio-1yhz0s8p.js";import"./studio-rdnezzkd.js";import"./studio-wcakp5bt.js";import"./studio-p89w12s2.js";import"./studio-nm9qev4p.js";import"./studio-5abge3wy.js";import"./studio-v2ek69cb.js";import"./studio-m4w6sygj.js";import"./studio-txkx6586.js";import"./studio-hvxt8z79.js";import"./studio-gmhd0j3f.js";import"./studio-0khd0xdw.js";import"./studio-3q6n9qvq.js";import"./studio-02phtmqn.js";import"./studio-2b8443ms.js";import"./studio-7cg75gtj.js";import"./studio-9wyqyfqy.js";import"./studio-cq87hree.js";import"./studio-hnx1h1pr.js";import"./studio-y1x65h5r.js";import"./studio-grp684wx.js";import"./studio-6vrxzkba.js";import"./studio-hw60n5dh.js";import"./studio-nqxqf8p2.js";import"./studio-tpmnbgmt.js";import"./studio-pr23qhrw.js";import"./studio-k1wvtp03.js";export{b2 as WORKSPACE_HOME_MODE_SET,Ag as detachWorkspaceHome,Q0 as isWorkspaceHomeMode,mk as openWorkspaceHome,gk as placeWorkspaceHome,bk as renderWorkspaceHome,e_ as workspaceHomeMounted};
|
|
2
|
-
|
|
3
|
-
//# debugId=9DAC49D9E47DF08064756E2164756E21
|
|
4
|
-
//# sourceMappingURL=workspace-home-zbgyqqws.js.map
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/// <reference lib="dom" />
|
|
2
|
-
/**
|
|
3
|
-
* Browser-side folder picking for the New Project modal's **Browse…** button.
|
|
4
|
-
*
|
|
5
|
-
* `showDirectoryPicker()` is the only native folder chooser a web page gets, but it hands back a
|
|
6
|
-
* `FileSystemDirectoryHandle` that exposes `.name` and nothing else — never a filesystem path
|
|
7
|
-
* (specs/desktop.md §8.2). Opening a project works around that by searching for the `project.json`
|
|
8
|
-
* the user pointed at, which is no help when choosing a _destination_: that folder is empty by
|
|
9
|
-
* definition, and often does not exist as a project at all.
|
|
10
|
-
*
|
|
11
|
-
* So the handle is made to identify itself. Using the readwrite grant the picker just issued, we
|
|
12
|
-
* drop a hidden {@link LOCATION_ID_FILE} holding a freshly generated id and ask the backend which
|
|
13
|
-
* directory holds that exact id. A fixed filename with the identity in its _contents_ is what makes
|
|
14
|
-
* the match unambiguous: two folders may share a basename, and a stale file from a crashed session
|
|
15
|
-
* may still be lying around, but only one file anywhere holds this id. The file lives in the chosen
|
|
16
|
-
* **Location** (the parent the project will be created in), never in the new project folder. The
|
|
17
|
-
* backend deletes it as soon as it matches, and this module removes it on every path the page
|
|
18
|
-
* survives, including a write that failed after the empty file was created. Only a tab closed
|
|
19
|
-
* mid-lookup can leave one behind, and a stale id can never match a later pick.
|
|
20
|
-
*
|
|
21
|
-
* **`null` means the user dismissed the chooser, and nothing else does.** Every other failure
|
|
22
|
-
* rejects with a sentence fit to show under the Location field: the chooser could not open, the
|
|
23
|
-
* folder cannot be written, the backend could not be reached, or it found no folder holding the id.
|
|
24
|
-
* This used to resolve `null` for all of them, which made a broken lookup indistinguishable from a
|
|
25
|
-
* cancel, and Browse… a button that silently did nothing.
|
|
26
|
-
*
|
|
27
|
-
* Only the plain dev-server browser session needs this. Every packaged build has a real native
|
|
28
|
-
* dialog that returns a path directly and keeps it — the Electron app's native folder dialog, and
|
|
29
|
-
* the NixOS chromium build's XDG desktop portal.
|
|
30
|
-
*
|
|
31
|
-
* @docs studio/projects/create
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
import { LOCATION_ID_FILE } from "@jxsuite/protocol/routes";
|
|
35
|
-
import { isNonNullObject, isString } from "@jxsuite/schema/guards";
|
|
36
|
-
import { errorMessage } from "@jxsuite/schema/parse";
|
|
37
|
-
|
|
38
|
-
/** Re-exported so a caller wiring up `locate` need not also reach into the protocol package. */
|
|
39
|
-
export { LOCATION_ID_FILE } from "@jxsuite/protocol/routes";
|
|
40
|
-
|
|
41
|
-
/** The subset of the File System Access API this module uses. */
|
|
42
|
-
interface WritableHandle {
|
|
43
|
-
createWritable: () => Promise<{
|
|
44
|
-
write: (data: string) => Promise<void>;
|
|
45
|
-
close: () => Promise<void>;
|
|
46
|
-
}>;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
interface DirectoryHandle {
|
|
50
|
-
name: string;
|
|
51
|
-
getFileHandle: (name: string, opts?: { create?: boolean }) => Promise<WritableHandle>;
|
|
52
|
-
removeEntry: (name: string, opts?: { recursive?: boolean }) => Promise<void>;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
type ShowDirectoryPicker = (opts?: {
|
|
56
|
-
id?: string;
|
|
57
|
-
mode?: "read" | "readwrite";
|
|
58
|
-
startIn?: string;
|
|
59
|
-
}) => Promise<DirectoryHandle>;
|
|
60
|
-
|
|
61
|
-
/** A realm that exposes the File System Access API's folder chooser. */
|
|
62
|
-
type DirectoryPickerRealm = typeof globalThis & { showDirectoryPicker: ShowDirectoryPicker };
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Whether a realm carries `showDirectoryPicker`. The DOM lib this package compiles against does not
|
|
66
|
-
* declare it (the API is Chromium-only), so the global is probed rather than read.
|
|
67
|
-
*/
|
|
68
|
-
function hasDirectoryPicker(realm: typeof globalThis): realm is DirectoryPickerRealm {
|
|
69
|
-
return "showDirectoryPicker" in realm && typeof realm.showDirectoryPicker === "function";
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** Whether this browser can open a native folder chooser at all. */
|
|
73
|
-
export function canPickDirectory(): boolean {
|
|
74
|
-
return hasDirectoryPicker(globalThis);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** A location id: URL-safe, unguessable enough that a concurrent pick cannot collide. */
|
|
78
|
-
function newLocationId(): string {
|
|
79
|
-
const bytes = new Uint8Array(16);
|
|
80
|
-
globalThis.crypto.getRandomValues(bytes);
|
|
81
|
-
return [...bytes].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* A thrown value's `name`, read structurally. A DOMException from another realm (an iframe's
|
|
86
|
-
* `showDirectoryPicker`, a test double) is not `instanceof Error` here, but it still says what it
|
|
87
|
-
* is.
|
|
88
|
-
*/
|
|
89
|
-
function nameOf(cause: unknown): string {
|
|
90
|
-
return isNonNullObject(cause) && "name" in cause && isString(cause.name) ? cause.name : "";
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Open the browser's native folder chooser and resolve the chosen folder's absolute path.
|
|
95
|
-
*
|
|
96
|
-
* Resolves `null` only when the user dismisses the chooser (an `AbortError`, which is also what a
|
|
97
|
-
* declined readwrite grant reaches the page as: a user choice either way). Everything else rejects
|
|
98
|
-
* with an Error whose message is a plain sentence the caller can show as is:
|
|
99
|
-
*
|
|
100
|
-
* - No `showDirectoryPicker` at all (the dev-server adapter never offers Browse… then, so only an
|
|
101
|
-
* embedder wiring this helper by hand reaches it);
|
|
102
|
-
* - The chooser refused to open (a `SecurityError` included: this runs synchronously from the click,
|
|
103
|
-
* so a lost gesture means the environment is wrong, and silence would be a dead button);
|
|
104
|
-
* - The folder cannot be written, so it cannot be tagged, and a project could not be created there
|
|
105
|
-
* either;
|
|
106
|
-
* - `locate` threw (backend unreachable, non-ok), or answered `null` (no folder holds the id).
|
|
107
|
-
*
|
|
108
|
-
* MUST be called synchronously from a user gesture; `showDirectoryPicker()` is invoked before this
|
|
109
|
-
* function awaits anything so a click handler that calls it directly keeps the gesture.
|
|
110
|
-
*
|
|
111
|
-
* @param locate Ask the backend which directory holds `id`, given the handle's `name`. Resolve the
|
|
112
|
-
* path, resolve `null` for "no directory holds this id", and throw on a transport or backend
|
|
113
|
-
* failure. The not-found sentence assumes a backend that searches the home folder, as the dev
|
|
114
|
-
* server does.
|
|
115
|
-
*/
|
|
116
|
-
export async function pickDirectoryPath(
|
|
117
|
-
locate: (query: { name: string; id: string }) => Promise<string | null>,
|
|
118
|
-
): Promise<string | null> {
|
|
119
|
-
const realm = globalThis;
|
|
120
|
-
if (!hasDirectoryPicker(realm)) {
|
|
121
|
-
throw new TypeError(
|
|
122
|
-
"This browser has no folder chooser. Type the folder's path into Location instead.",
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
const show = realm.showDirectoryPicker;
|
|
126
|
-
|
|
127
|
-
let handle: DirectoryHandle;
|
|
128
|
-
try {
|
|
129
|
-
// `id` makes Chrome reopen at the last folder chosen for this purpose across sessions.
|
|
130
|
-
handle = await show({ id: "jx-new-project-location", mode: "readwrite", startIn: "documents" });
|
|
131
|
-
} catch (error) {
|
|
132
|
-
if (nameOf(error) === "AbortError") {
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
throw new Error(
|
|
136
|
-
`The folder chooser could not open (${errorMessage(error)}). Type the folder's path into Location instead.`,
|
|
137
|
-
{ cause: error },
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const { name } = handle;
|
|
142
|
-
const id = newLocationId();
|
|
143
|
-
/* The `getFileHandle({ create: true })` call puts an empty file on disk before anything is
|
|
144
|
-
written, so a write that fails after it still leaves a tag to clean up. Only remove what this
|
|
145
|
-
call created. */
|
|
146
|
-
let tagged = false;
|
|
147
|
-
try {
|
|
148
|
-
try {
|
|
149
|
-
const file = await handle.getFileHandle(LOCATION_ID_FILE, { create: true });
|
|
150
|
-
tagged = true;
|
|
151
|
-
const writable = await file.createWritable();
|
|
152
|
-
await writable.write(id);
|
|
153
|
-
await writable.close();
|
|
154
|
-
} catch (error) {
|
|
155
|
-
/* The readwrite grant was just issued, so this is the filesystem refusing: a read-only
|
|
156
|
-
mount, OS permissions, a full disk. Creating the project there would fail the same way. */
|
|
157
|
-
throw new Error(
|
|
158
|
-
`Jx Studio can't write to "${name}" (${errorMessage(error)}), so it can't create a project there. Choose a folder you can write to.`,
|
|
159
|
-
{ cause: error },
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
let path: string | null;
|
|
164
|
-
try {
|
|
165
|
-
path = await locate({ id, name });
|
|
166
|
-
} catch (error) {
|
|
167
|
-
throw new Error(
|
|
168
|
-
`Jx Studio could not look up where "${name}" is: ${errorMessage(error)}. Type the folder's path into Location instead.`,
|
|
169
|
-
{ cause: error },
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
if (!path) {
|
|
173
|
-
throw new Error(
|
|
174
|
-
`Jx Studio could not find where "${name}" is. From a browser it can only find folders inside your home folder. Type its full path into Location instead.`,
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
return path;
|
|
178
|
-
} finally {
|
|
179
|
-
// The backend removes the file the moment it matches; this covers every path where it did not
|
|
180
|
-
// (no match, a network failure, a backend that never ran the lookup, a half-finished write).
|
|
181
|
-
if (tagged) {
|
|
182
|
-
await handle.removeEntry(LOCATION_ID_FILE).catch(() => {
|
|
183
|
-
/* Already gone — the backend beat us to it. */
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gated-registry.ts — state-aware tool advertisement for the AI assistant.
|
|
3
|
-
*
|
|
4
|
-
* Wraps a `@jxsuite/ai` ToolRegistry so each tool is only advertised to the LLM while its
|
|
5
|
-
* availability predicate holds (no project open → bootstrap tools only; project open → file tools;
|
|
6
|
-
* document open → document tools). `runAgentLoop` calls `listForLLM()` every round, so availability
|
|
7
|
-
* flips mid-loop: after `create_project` succeeds, the very next round advertises the file and
|
|
8
|
-
* document tools without any extra plumbing.
|
|
9
|
-
*
|
|
10
|
-
* Executing a tool whose predicate currently fails returns a tool error naming the missing state
|
|
11
|
-
* instead of throwing, so the agent loop can self-correct.
|
|
12
|
-
*
|
|
13
|
-
* @license MIT
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import type { ToolArguments, ToolContext, ToolDefinition, ToolRegistry } from "@jxsuite/ai/tools";
|
|
17
|
-
|
|
18
|
-
export interface ToolAvailability {
|
|
19
|
-
/** Whether the tool is currently advertised/executable. */
|
|
20
|
-
when: () => boolean;
|
|
21
|
-
/** Human-readable requirement, surfaced when execution is refused (e.g. "a project is open"). */
|
|
22
|
-
requires: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Wrap `inner` so tools listed in `availability` are only advertised/executable while their
|
|
27
|
-
* predicate holds. Tools without an entry are always available.
|
|
28
|
-
*
|
|
29
|
-
* @param {ToolRegistry} inner
|
|
30
|
-
* @param {Map<string, ToolAvailability>} availability
|
|
31
|
-
* @returns {ToolRegistry}
|
|
32
|
-
*/
|
|
33
|
-
export function createGatedToolRegistry(
|
|
34
|
-
inner: ToolRegistry,
|
|
35
|
-
availability: Map<string, ToolAvailability>,
|
|
36
|
-
): ToolRegistry {
|
|
37
|
-
function isAvailable(name: string): boolean {
|
|
38
|
-
const gate = availability.get(name);
|
|
39
|
-
return gate ? gate.when() : true;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
register(tool: ToolDefinition) {
|
|
44
|
-
inner.register(tool);
|
|
45
|
-
},
|
|
46
|
-
list() {
|
|
47
|
-
return inner.list().filter((t) => isAvailable(t.name));
|
|
48
|
-
},
|
|
49
|
-
listForLLM() {
|
|
50
|
-
const available = new Set(this.list().map((t) => t.name));
|
|
51
|
-
return inner.listForLLM().filter((t) => {
|
|
52
|
-
/* SAFETY: a @jxsuite/ai registry lists each tool in OpenAI function-calling form,
|
|
53
|
-
`{ type: "function", function: { name, … } }`; the registry interface types the entries
|
|
54
|
-
as bare objects, and the optional chain still answers "" for any other shape. */
|
|
55
|
-
const tool = t as { function?: { name?: string } };
|
|
56
|
-
return available.has(tool.function?.name ?? "");
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
getDefinition(toolName: string) {
|
|
60
|
-
return inner.getDefinition(toolName);
|
|
61
|
-
},
|
|
62
|
-
validate(toolName: string, args: ToolArguments) {
|
|
63
|
-
return inner.validate(toolName, args);
|
|
64
|
-
},
|
|
65
|
-
async execute(toolName: string, args: ToolArguments, ctx?: ToolContext) {
|
|
66
|
-
if (inner.getDefinition(toolName) && !isAvailable(toolName)) {
|
|
67
|
-
const gate = availability.get(toolName);
|
|
68
|
-
return {
|
|
69
|
-
success: false,
|
|
70
|
-
error: `Tool "${toolName}" is not available right now — it requires ${gate?.requires ?? "a different studio state"}.`,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
// The call's context reaches the tool unchanged: its signal, id, ledger and session.
|
|
74
|
-
return inner.execute(toolName, args, ctx);
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
}
|