@jxsuite/studio 8.0.0 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{2020-5wtzce5g.js → 2020-dg097k3e.js} +3 -3
- package/dist/chunks/adapter-tck81zft.js +4 -0
- package/dist/chunks/{add-new-flow-psym14sn.js → add-new-flow-a1w0bnm6.js} +3 -3
- package/dist/chunks/{cf-account-picker-haqazq5r.js → cf-account-picker-ce3kp3x1.js} +3 -3
- package/dist/chunks/cf-settings-7ye6x7g2.js +4 -0
- package/dist/chunks/color-4gj49xq6.js +4 -0
- package/dist/chunks/{color-area-6rbra5dy.js → color-area-vh9cew51.js} +2 -2
- package/dist/chunks/{color-field-gy56c94g.js → color-field-e78f16bs.js} +3 -3
- package/dist/chunks/{color-slider-sqqdyf6c.js → color-slider-fg4yhvk6.js} +2 -2
- package/dist/chunks/{combobox-72h32ejk.js → combobox-6hs00996.js} +2 -2
- package/dist/chunks/components-qce0v93f.js +4 -0
- package/dist/chunks/content-source-jjx8kgzr.js +4 -0
- package/dist/chunks/{convert-to-repeater-he70fc2b.js → convert-to-repeater-grnmea6c.js} +3 -3
- package/dist/chunks/editor-bkja5dbv.js +4 -0
- package/dist/chunks/entry-commands-1wh0btvg.js +4 -0
- package/dist/chunks/{extension-sections-0egb88dm.js → extension-sections-rp7fkega.js} +3 -3
- package/dist/chunks/file-ops-6pe4z7an.js +4 -0
- package/dist/chunks/files-ybpp3j38.js +4 -0
- package/dist/chunks/format-host-3mtbhxk1.js +4 -0
- package/dist/chunks/fs-events-xfanfxds.js +4 -0
- package/dist/chunks/grid-open-dg5qmnaj.js +4 -0
- package/dist/chunks/{grid-view-qg1b5eqx.js → grid-view-x26rfpz1.js} +16 -15
- package/dist/chunks/{icons-63bjtbs7.js → icons-853n6qt3.js} +2 -2
- package/dist/chunks/{iframe-entry-2zggzajv.js → iframe-entry-02wzcyvy.js} +4 -4
- package/dist/chunks/{iframe-entry-99nr5zfb.js → iframe-entry-42hpmwz5.js} +4 -4
- package/dist/chunks/{iframe-entry-76j8vwwx.js → iframe-entry-b5qgggyp.js} +2 -2
- package/dist/chunks/iframe-host-j2bk2xkc.js +4 -0
- package/dist/chunks/{index-32eqzv1k.js → index-203h71wy.js} +3 -3
- package/dist/chunks/index-fkrm7pdk.js +4 -0
- package/dist/chunks/{javascript-pjp734q4.js → javascript-ww5pv5ae.js} +2 -2
- package/dist/chunks/{jsonMode-njkvsa02.js → jsonMode-vwbdwwq3.js} +6 -6
- package/dist/chunks/jx-validate-w7v32f6a.js +4 -0
- package/dist/chunks/layers-g7j732cm.js +4 -0
- package/dist/chunks/layers-panel-gjrsxcck.js +4 -0
- package/dist/chunks/{listbox-c421cf8c.js → listbox-7gka1h86.js} +2 -2
- package/dist/chunks/lit-html-jdfz9rhc.js +4 -0
- package/dist/chunks/media-library-9j0v4wmk.js +4 -0
- package/dist/chunks/media-picker-cpyyt2m0.js +4 -0
- package/dist/chunks/{menu-bdpzbfvs.js → menu-d2jxpgma.js} +2 -2
- package/dist/chunks/{monaco-binding-vq1hgnn0.js → monaco-binding-63tqze27.js} +3 -3
- package/dist/chunks/monaco-buffer-9wcme176.js +4 -0
- package/dist/chunks/{monaco-setup-xrd2cbkp.js → monaco-setup-zyyynnj8.js} +3 -3
- package/dist/chunks/notify-rahnnnv4.js +4 -0
- package/dist/chunks/platform-b2aqv7v5.js +4 -0
- package/dist/chunks/{popover-b89sfej7.js → popover-9tf4cjrk.js} +2 -2
- package/dist/chunks/publish-panel-4yk2461b.js +4 -0
- package/dist/chunks/{publish-quick-qx2455cj.js → publish-quick-ajzdhhs6.js} +3 -3
- package/dist/chunks/publish-workspace-mxestzcf.js +4 -0
- package/dist/chunks/quick-search-9g6z65b0.js +4 -0
- package/dist/chunks/references-c26enpxs.js +4 -0
- package/dist/chunks/right-panel-9d0e0yg7.js +4 -0
- package/dist/chunks/source-control-xyn3a8ds.js +4 -0
- package/dist/chunks/{split-c9zfdgxf.js → split-m5rwn31z.js} +2 -2
- package/dist/chunks/{studio-x9hsze61.js → studio-02phtmqn.js} +4 -4
- package/dist/chunks/{studio-4hp8pkyt.js → studio-0khd0xdw.js} +4 -4
- package/dist/chunks/studio-1fvzq9vs.js +5 -0
- package/dist/chunks/studio-1gdfsr49.js +12 -0
- package/dist/chunks/{studio-3q40e3rj.js → studio-1meqbxns.js} +4 -4
- package/dist/chunks/{studio-q0tccd43.js → studio-1yhz0s8p.js} +4 -4
- package/dist/chunks/studio-25a5by3h.js +5 -0
- package/dist/chunks/{studio-k3xxbagr.js → studio-2b8443ms.js} +3 -3
- package/dist/chunks/{studio-3qqjeep5.js → studio-2c2mjyzj.js} +5 -5
- package/dist/chunks/studio-2dtc90zs.js +10 -0
- package/dist/chunks/{studio-9tmebf0s.js → studio-332hesdk.js} +4 -4
- package/dist/chunks/{studio-03ct6yfv.js → studio-3pndhat0.js} +8 -8
- package/dist/chunks/{studio-s32578pn.js → studio-3q6n9qvq.js} +4 -4
- package/dist/chunks/studio-4dsdnan2.js +9 -0
- package/dist/chunks/{studio-ed1hp6zf.js → studio-4fjqdzrb.js} +5 -5
- package/dist/chunks/{studio-jcnsdaep.js → studio-533py3yy.js} +4 -4
- package/dist/chunks/studio-5abge3wy.js +5 -0
- package/dist/chunks/{studio-8tr6cfrc.js → studio-6vrxzkba.js} +4 -4
- package/dist/chunks/{studio-jaaz8ce9.js → studio-73wz63nn.js} +4 -4
- package/dist/chunks/{studio-bavb31r0.js → studio-74nzv280.js} +4 -4
- package/dist/chunks/{studio-q7rtx6zq.js → studio-7cg75gtj.js} +7 -7
- package/dist/chunks/studio-89cwmnae.js +5 -0
- package/dist/chunks/studio-8m1t83kn.js +7 -0
- package/dist/chunks/{studio-q0mvbaq6.js → studio-8nyw10dp.js} +4 -4
- package/dist/chunks/{studio-83mk4bgg.js → studio-94ppxeqy.js} +8 -8
- package/dist/chunks/{studio-qmn1xc24.js → studio-957jg8g3.js} +4 -4
- package/dist/chunks/{studio-r5qy30vx.js → studio-9wyqyfqy.js} +4 -4
- package/dist/chunks/studio-a3evp7f6.js +6 -0
- package/dist/chunks/{studio-n0c5h6mf.js → studio-a6x058ew.js} +4 -4
- package/dist/chunks/studio-ana67wax.js +5 -0
- package/dist/chunks/studio-b4xhpcwy.js +4 -0
- package/dist/chunks/studio-bf0rgyf7.js +5 -0
- package/dist/chunks/{studio-x1x167jh.js → studio-bqgs90r8.js} +4 -4
- package/dist/chunks/{studio-qwdqwkj0.js → studio-c4rcaftm.js} +4 -4
- package/dist/chunks/{studio-mn0476ag.js → studio-c5dj3dzk.js} +4 -4
- package/dist/chunks/studio-cgjt1zce.js +5 -0
- package/dist/chunks/{studio-bbe4c90a.js → studio-cpdzrdgp.js} +4 -4
- package/dist/chunks/studio-cq87hree.js +5 -0
- package/dist/chunks/studio-d140sy8e.js +5 -0
- package/dist/chunks/{studio-jsgf2q5k.js → studio-dmn7gpba.js} +5 -5
- package/dist/chunks/studio-e8pzjjhf.js +5 -0
- package/dist/chunks/{studio-dgk4dqtx.js → studio-f8kz3krj.js} +5 -5
- package/dist/chunks/{studio-qgh13jtz.js → studio-fqs1a22a.js} +4 -4
- package/dist/chunks/{studio-syreb644.js → studio-fw3jp9m7.js} +4 -4
- package/dist/chunks/{studio-ed3xx40h.js → studio-g6ysm05p.js} +6 -6
- package/dist/chunks/studio-gmhd0j3f.js +5 -0
- package/dist/chunks/{studio-p4nrkvqr.js → studio-gqpty626.js} +4 -4
- package/dist/chunks/{studio-kt3pjkwd.js → studio-grp684wx.js} +4 -4
- package/dist/chunks/{studio-df0baea9.js → studio-h98520qr.js} +4 -4
- package/dist/chunks/{studio-8m0y2qe7.js → studio-hnx1h1pr.js} +4 -4
- package/dist/chunks/studio-hvxt8z79.js +5 -0
- package/dist/chunks/{studio-43sd2mam.js → studio-hw60n5dh.js} +3 -3
- package/dist/chunks/{studio-wbcjbhy1.js → studio-hxq1ebp0.js} +6 -6
- package/dist/chunks/{studio-wys23mxz.js → studio-j4e627w1.js} +4 -4
- package/dist/chunks/{studio-ccv2svc6.js → studio-j5jqvyn3.js} +4 -4
- package/dist/chunks/{studio-881z1xrx.js → studio-jqrg9xxg.js} +4 -4
- package/dist/chunks/{studio-b7y5mr30.js → studio-kdseew9m.js} +4 -4
- package/dist/chunks/studio-kt2j51sa.js +5 -0
- package/dist/chunks/{studio-d5grtb9e.js → studio-m4w6sygj.js} +9 -9
- package/dist/chunks/{studio-zz9qe3rw.js → studio-mmqr9awv.js} +37 -37
- package/dist/chunks/{studio-5g0rprdt.js → studio-nm9qev4p.js} +5 -5
- package/dist/chunks/{studio-tft6r105.js → studio-nsv7g1qn.js} +4 -4
- package/dist/chunks/{studio-3e54qh39.js → studio-p89w12s2.js} +5 -5
- package/dist/chunks/{studio-y3ahhdpx.js → studio-pbagym4j.js} +4 -4
- package/dist/chunks/{studio-w4rz9hdk.js → studio-pr23qhrw.js} +4 -4
- package/dist/chunks/{studio-6m380wp7.js → studio-r4ya3sb2.js} +4 -4
- package/dist/chunks/studio-rdnezzkd.js +6 -0
- package/dist/chunks/{studio-f14e1zdj.js → studio-rm9m3z60.js} +4 -4
- package/dist/chunks/studio-tpmnbgmt.js +5 -0
- package/dist/chunks/studio-ttxhq5yt.js +5 -0
- package/dist/chunks/{studio-nh6d342n.js → studio-txkx6586.js} +6 -6
- package/dist/chunks/{studio-a2bvaptz.js → studio-v0gsjav0.js} +4 -4
- package/dist/chunks/{studio-fbhxxc5f.js → studio-v2ek69cb.js} +4 -4
- package/dist/chunks/{studio-y0n7yxea.js → studio-wcakp5bt.js} +7 -7
- package/dist/chunks/{studio-k7evxqh4.js → studio-x3ge4rts.js} +4 -4
- package/dist/chunks/{studio-pbxa5fpc.js → studio-xddgbwhe.js} +3 -3
- package/dist/chunks/{studio-c05wdnt3.js → studio-y1x65h5r.js} +4 -4
- package/dist/chunks/{studio-rthyg42z.js → studio-z42kysg7.js} +169 -169
- package/dist/chunks/studio-zf188hnd.js +5 -0
- package/dist/chunks/{studio-tfkznv39.js → studio-zht0x0v3.js} +4 -4
- package/dist/chunks/{studio-svb7yyve.js → studio-zm7dnr9g.js} +4 -4
- package/dist/chunks/{tooltip-yypz28gq.js → tooltip-dj1pvgz7.js} +2 -2
- package/dist/chunks/{tree-9xa4hm7n.js → tree-j0ebwr5s.js} +2 -2
- package/dist/chunks/{tsMode-epyfz1hv.js → tsMode-vra2hh7y.js} +5 -5
- package/dist/chunks/workspace-3nt93k48.js +4 -0
- package/dist/chunks/workspace-home-zbgyqqws.js +4 -0
- package/dist/chunks/{ws-client-bv552sfx.js → ws-client-72x5n99j.js} +3 -3
- package/dist/iframe-entry.js +14 -14
- package/dist/manifest.json +75 -75
- package/dist/studio.js +80 -80
- package/package.json +11 -11
- package/src/browse/component-examples.ts +15 -224
- package/src/browse/library-preview.ts +6 -13
- package/src/browse/preview-root.ts +7 -4
- package/src/canvas/canvas-utils.ts +18 -4
- package/src/canvas/iframe-editable-root.ts +13 -4
- package/src/canvas/iframe-entry.ts +3 -1
- package/src/canvas/iframe-interaction.ts +11 -2
- package/src/canvas/iframe-render.ts +25 -3
- package/src/canvas/preview-placeholder.ts +120 -0
- package/src/editor/shortcuts.ts +3 -0
- package/src/panels/component-preview.ts +5 -0
- package/src/panels/pane-context.ts +43 -18
- package/src/panels/site-model.ts +7 -19
- package/src/panels/site-panel.ts +2 -25
- package/src/panels/stylebook-doc.ts +2 -53
- package/src/services/references.ts +0 -0
- package/src/style/stylebook-specimens.ts +11 -15
- package/src/surfaces/pane-context.json +286 -265
- package/src/surfaces/pane-context.ts +17 -8
- package/src/tabs/tab.ts +5 -6
- package/src/utils/geometry.ts +49 -2
- package/dist/chunks/adapter-5tphg7xe.js +0 -4
- package/dist/chunks/cf-settings-h2wrh6hq.js +0 -4
- package/dist/chunks/color-m7r1vk54.js +0 -4
- package/dist/chunks/components-r22xca09.js +0 -4
- package/dist/chunks/content-source-mmppmcyg.js +0 -4
- package/dist/chunks/editor-ccd9jwsa.js +0 -4
- package/dist/chunks/entry-commands-6qxz9e8p.js +0 -4
- package/dist/chunks/file-ops-qnab36ek.js +0 -4
- package/dist/chunks/files-rcn56qvm.js +0 -4
- package/dist/chunks/format-host-yxz0kjjs.js +0 -4
- package/dist/chunks/fs-events-d1qxq4z4.js +0 -4
- package/dist/chunks/grid-open-4z1g062t.js +0 -4
- package/dist/chunks/iframe-host-ssv7kyj0.js +0 -4
- package/dist/chunks/index-f0jn7nnp.js +0 -4
- package/dist/chunks/jx-validate-ttasrbh7.js +0 -4
- package/dist/chunks/layers-bgyr11tr.js +0 -4
- package/dist/chunks/layers-panel-7ez66zeq.js +0 -4
- package/dist/chunks/lit-html-v9gh687x.js +0 -4
- package/dist/chunks/media-library-sq468wts.js +0 -4
- package/dist/chunks/media-picker-shfe59pt.js +0 -4
- package/dist/chunks/monaco-buffer-3afgwvbp.js +0 -4
- package/dist/chunks/notify-kzrjr3fv.js +0 -4
- package/dist/chunks/platform-7v4rtd7m.js +0 -4
- package/dist/chunks/publish-panel-2z9gw8ee.js +0 -4
- package/dist/chunks/publish-workspace-wrc1dgwx.js +0 -4
- package/dist/chunks/quick-search-n0t0eqxb.js +0 -4
- package/dist/chunks/references-9547rg5s.js +0 -4
- package/dist/chunks/right-panel-wsgnr9pn.js +0 -4
- package/dist/chunks/source-control-kwktr9y6.js +0 -4
- package/dist/chunks/studio-07rcfje3.js +0 -5
- package/dist/chunks/studio-3exxhz5g.js +0 -5
- package/dist/chunks/studio-3qeh9t0h.js +0 -6
- package/dist/chunks/studio-58xg6j2q.js +0 -9
- package/dist/chunks/studio-80jyh1xh.js +0 -4
- package/dist/chunks/studio-8vcvfs7r.js +0 -6
- package/dist/chunks/studio-fyh0jc96.js +0 -5
- package/dist/chunks/studio-gcxk20n7.js +0 -5
- package/dist/chunks/studio-m8g16bgz.js +0 -5
- package/dist/chunks/studio-mx1smyq0.js +0 -5
- package/dist/chunks/studio-pgmvdv7z.js +0 -7
- package/dist/chunks/studio-ph84avkf.js +0 -5
- package/dist/chunks/studio-rj9eamf8.js +0 -5
- package/dist/chunks/studio-rptgsk96.js +0 -5
- package/dist/chunks/studio-s19tp1xr.js +0 -5
- package/dist/chunks/studio-tf9jryb1.js +0 -10
- package/dist/chunks/studio-txf2kysx.js +0 -5
- package/dist/chunks/studio-v8867ddv.js +0 -12
- package/dist/chunks/studio-vxq7fcvv.js +0 -5
- package/dist/chunks/studio-wc649wss.js +0 -5
- package/dist/chunks/studio-z97c48fk.js +0 -5
- package/dist/chunks/studio-zat62m0c.js +0 -5
- package/dist/chunks/studio-zcd2e7yz.js +0 -5
- package/dist/chunks/workspace-dz7nxfhv.js +0 -4
- package/dist/chunks/workspace-home-xsd7hkjw.js +0 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var n;function
|
|
2
|
-
export{
|
|
1
|
+
var n;function QO(e){n=new URL("./",e).href}function Kx(e){if(n===void 0)throw Error(`bundleUrl(${JSON.stringify(e)}) before setBundleBase(). An entry module (src/studio.ts or src/canvas/iframe-entry.ts) must call setBundleBase(import.meta.url) first; a test needs tests/with-dom.ts, which sets one.`);return new URL(e,n).href}
|
|
2
|
+
export{QO,Kx};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=D894F40351157D6264756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-533py3yy.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{p,_e}from"./studio-pr23qhrw.js";import{Pn,Yb,Vt,ln,go,gx,ZA,Me,Qs,kx,Y,Lo,bh,Yc,Ve,Up,Tn,St,Nx,Bi,Wn,Se,di,A$,$o,We,Vn,ui,m,u,pn,Er,qp}from"./studio-y1x65h5r.js";import{ge,ne,he,C}from"./studio-hw60n5dh.js";import{st,vo,Gp,Qc}from"./studio-grp684wx.js";import{td,zi}from"./studio-tpmnbgmt.js";import{GS,Ne,jc,Hc}from"./studio-v2ek69cb.js";import{E$,fh}from"./studio-hnx1h1pr.js";import{He,rx,Js,nn,sh,Fd,Pb,ah}from"./studio-gmhd0j3f.js";import{jp,Bd,Ub,Kc,Ts,To,Ls,Ta,Bp,Jl,qb,WA,Sr,io,hh,Gb,ae}from"./studio-7cg75gtj.js";import{rl,Wr,qs,Gs,Vr}from"./studio-txkx6586.js";import{eo,KN,FL,Kw,Jw,Es,Rp,ol,Yw,jL,h,KL}from"./studio-m4w6sygj.js";import{sr,At,hi,Tr,ec,S,Sh,Xp,Ch,xn}from"./studio-ana67wax.js";import{oe}from"./studio-gqpty626.js";import{Kx}from"./studio-533py3yy.js";import{n,Z,te,_,v,Oe,Yo,qn,it,id}from"./studio-kt2j51sa.js";import{le}from"./studio-fqs1a22a.js";var at="jx:canvas";function Qt(e){let{target:t,source:o,targetOrigin:r,acceptOrigin:i,token:a}=e,l=new Set,s=(c)=>{if(i!=="*"&&c.origin!==i)return;let d=c.data;if(!_(d)||!(at in d)||d[at]!==a)return;let f="payload"in d?d.payload:void 0;for(let g of l)g(f)};return o.addEventListener("message",s),{dispose(){l.clear(),o.removeEventListener("message",s)},onMessage(c){return l.add(c),()=>l.delete(c)},post(c){t.postMessage({[at]:a,payload:c},r)}}}var lt=null;function en(){return lt}function xb(e){if(lt){lt(e);return}window.open(e,"_blank","noopener,noreferrer")}function yr(){return vo(m.activePaneId)}function vt(e){let t=pn(e),o=t?.derived,r=o?.kind==="lens"?pn(o.sourcePaneId)?.activeTabId:t?.activeTabId;return r?m.tabs.get(r)??null:null}function Br(e){return pn(e)?.derived??null}function _S(e){if(!e)return[];let t=[];for(let o of m.panes)if(vt(o.id)?.id===e.id)t.push(vo(o.id));return t}function W(e){for(let t of Gp()){let o=t.panels.find((r)=>r.canvas===e);if(o)return{panel:o,surface:t}}return null}function tn(e){let t=e.canvas,o=t?W(t):null;return o?vt(o.surface.paneId):null}function Ac(e){let t=e?.session.ui,o=t?.canvasMode??"design";return t?.preview&&(o==="edit"||o==="design")?"preview":o}function Uo(e){let t=Br(e);if(t?.kind==="lens"){let o=t.mode;return vt(e)?.session.ui?.preview&&(o==="edit"||o==="design")?"preview":o}return Ac(vt(e))}function nl(e){let t=Br(e);if(t?.kind==="lens"&&t.preset==="breakpoint")return t.media;return vt(e)?.session.ui.activeMedia??null}function ct(e){return Qc(e)?.paneId??ui}function ce(e){return vt(ct(e))}function Pe(e,t,o,r=null,i=null,a=[]){if(!e.state)e.state={};let l={};if(i!==null)l.defaultLocale=i.defaultLocale,l.locales=i.locales;e.state.$site={name:t.name??"Jx Site",url:t.url??"",...l,...t.state};let s=(n(e.$lang)?e.$lang:void 0)??ZA(o.urlPattern,i)??t.defaults?.lang,c=a.map((f)=>({code:f.locale,current:f.urlPattern===o.urlPattern,dir:Yb(f.locale),label:Vt(f.locale),url:f.urlPattern})),d={params:o._pathParams??{},title:e.title??e._pageTitle??t.name??"",url:o.urlPattern};if(c.length>0)d.alternates=c;if(s!==void 0)d.dir=Yb(s),d.locale=s;if(e.state.$page=d,t.state){for(let[f,g]of Object.entries(t.state))if(f!=="$site"&&f!=="$page"&&!(f in e.state))e.state[f]=g}if(t.$media)e.$media={...t.$media,...e.$media};if(t.imports&&Object.keys(t.imports).length>0){if(!e.imports)e.imports={};for(let[f,g]of Object.entries(t.imports))if(!(f in e.imports))e.imports[f]=r&&(g.startsWith("./")||g.startsWith("../"))?r(g,o):g}if(t.$elements?.length)if(!e.$elements?.length)e.$elements=[...t.$elements];else{let f=new Set,g=[];for(let y of[...t.$elements,...e.$elements]){let b=n(y)?y:_(y)?y.$ref:void 0;if(b&&!f.has(b))f.add(b),g.push(y)}e.$elements=g}return e}var Ir=/\[\.\.\.(\w+)\]|\[(\w+)\]/g;function on(e){return e.split("\\").join("/").replace(/^\.\//,"").replace(/^\//,"").replace(/^pages\//,"")}function wr(e){let t=on(e),o=t.slice(t.lastIndexOf("/")+1),r=o.lastIndexOf(".");if(r>0)t=t.slice(0,t.length-(o.length-r));if(t.endsWith("/index"))t=t.slice(0,-6)||"/";else if(t==="index")t="/";if(!t.startsWith("/"))t=`/${t}`;let i=[],a=!1,l=!1,s=t.replaceAll(Ir,(c,d,f)=>{if(a=!0,d)return l=!0,i.push(d),"*";return i.push(f),`:${f}`});return{isCatchAll:l,isDynamic:a,params:i,urlPattern:s}}function Yu(e){if(!e)return"/";return wr(e).urlPattern}function Oc(e){if(!e)return[];return wr(e).params}function Zu(e,t){let o=on(e).split("/");if(!o.every((l)=>l!==""&&l[0]!=="_"))return!1;if(t===void 0)return!0;let r=o.at(-1)??"",i=r.lastIndexOf("."),a=i>0?r.slice(i).toLowerCase():"";return a!==""&&new Set(t).has(a)}function SS(e,t){if(e.isDynamic!==t.isDynamic)return e.isDynamic?1:-1;if(e.isCatchAll!==t.isCatchAll)return e.isCatchAll?1:-1;return e.urlPattern.localeCompare(t.urlPattern)}var Dr=new Set(["img","video","source","iframe","audio"]),rn="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",ut="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='32'%20height='32'%3E%3Crect%20width='32'%20height='32'%20fill='%23d0d0d0'/%3E%3C/svg%3E";function mN(e,t){e.addEventListener("error",(o)=>{let{target:r}=o;if(r instanceof HTMLImageElement&&r.getAttribute("src")!==ut)r.setAttribute("src",ut),r.removeAttribute("srcset"),r.dataset.placeholder=""},{capture:!0,signal:t})}var kr=/(src|poster|image|bg|background|icon|logo|photo|avatar|thumbnail|cover|banner)$/i;function an(e){return kr.test(e)}var Jr=/(?<![\w$.])(?:item|index|\$map)\b/u;function B(e){if(n(e))return e.includes("${")&&Jr.test(e);return qn(e)&&n(e.$ref)&&/^(?:#\/)?\$map\//u.test(e.$ref)}function we(e,t){if(e==="href"||e==="action")return"";if(an(e))return ut;if(n(t))return dt(t);return qn(t)&&n(t.$ref)?fn(t.$ref):""}var Hr=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","li","dt","dd","th","td","span","strong","em","small","mark","code","abbr","q","sub","sup","time","a","button","label","legend","caption","summary","pre","option"]),Lr=new Set(["div","section","article","aside","header","footer","main","nav","figure","figcaption","details","fieldset","form","ul","ol","dl","table"]);var _r=["width","height","inlineSize","blockSize"];function jr(e){let{style:t}=e;if(!_(t))return!1;return _r.some((o)=>{let r=t[o],i=Z(r)?String(r):n(r)?r.trim():"";return i!==""&&i!=="auto"})}function Fr(e){if(!e.tagName||e.textContent||e.innerHTML)return null;if(e.$__layout)return null;if(Array.isArray(e.children)&&e.children.length>0)return null;if(jr(e))return null;if(Hr.has(it(e.tagName)))return"empty-text-placeholder";if(Lr.has(it(e.tagName)))return"empty-container-placeholder";return null}function dt(e){return e.replaceAll(/\$\{([^}]+)\}/g,"❪ $1 ❫")}function qr(e,t){let o=e.map;return{children:_(o)?[F(o,Kr(e.items,t))]:[],className:"repeater-perimeter",tagName:"div"}}function sn(e){return JSON.stringify(e)}function cn(e){let t=e.startsWith("#/")?e.slice(2):e,[o,...r]=t.split("/"),i=o==="state"||o==="$map"?o:null;if(i===null)return null;let a=r.map((l)=>l.replaceAll("~1","/").replaceAll("~0","~"));return i+a.map((l)=>`?.[${sn(l)}]`).join("")}function pt(e,t){if(t===null)return`(${e})`;return`((r) => ((item, index, $map) => (${e}))(r, 0, { index: 0, item: r }))(${t})`}function Kr(e,t){if(Array.isArray(e))return`${sn(e)}[0]`;if(Oe(e)){let r=cn(e.$ref);return r===null?null:`${pt(r,t)}?.[0]`}let o=n(e)?un(e):[];if(n(e)&&o.length===1&&Ur(e,o[0]))return`${pt(o[0].expr,t)}?.[0]`;return null}function Ur(e,t){return t.start===0&&t.end===e.length-1}function un(e){let t=[],o=e.indexOf("${");while(o!==-1){let r=0,i=-1;for(let a=o+1;a<e.length;a+=1)if(e[a]==="{")r+=1;else if(e[a]==="}"){if(r-=1,r===0){i=a;break}}if(i===-1)break;t.push({end:i,expr:e.slice(o+2,i),start:o}),o=e.indexOf("${",i+1)}return t}function dn(e,t=null){let o=un(e);if(o.length===0)return e;let r="",i=0;for(let{start:a,end:l,expr:s}of o)r+=e.slice(i,a),r+=`\${(() => { try { return ${pt(s,t)}; } catch { return ""; } })()}`,i=l+1;return r+e.slice(i)}function Gr(e,t){let o=e.startsWith("#/")?e.slice(2):e;if(o!=="$map"&&!o.startsWith("$map/"))return{$ref:e};let r=cn(e);return t===null||r===null?void 0:dn(`\${${r}}`,t)}function fn(e){return`{${e.startsWith("#/state/")?e.slice(8):e}}`}function ft(e,t=null){return F(e,t)}function F(e,t){if(Array.isArray(e))return e.map((s)=>F(s,t));if(!qn(e))return e;if(e.$prototype==="Array")return qr(e,t);let o=e,r={},i=!1,a=n(o.tagName)&&Dr.has(o.tagName);if(a){let{attributes:s,src:c}=o,d=s?.src,f=o.poster,g=s?.poster;if(!(c&&c!==""||d&&d!=="")&&!(f&&f!==""||g&&g!==""))i=!0}for(let[s,c]of Object.entries(o))if(s==="state"||s==="$media"||s==="$elements")r[s]=c;else if(s==="$props"&&Sh(c)){let d={};for(let[f,g]of Object.entries(c))if(!B(g))d[f]=g;else if(n(g))d[f]=an(f)||f==="href"||f==="action"?we(f,g):dn(g,t);else if(Oe(g)){let y=Gr(g.$ref,t);if(y!==void 0)d[f]=y}else d[f]=g;r[s]=d}else if(s==="children")if(Array.isArray(c))r.children=c.map((d)=>F(d,t));else if(qn(c)&&c.$prototype==="Array")r.children=[F(c,t)];else r.children=F(c,t);else if(s==="cases"&&o.$switch&&Sh(c)){let[d]=Object.entries(c);if(d){let[,f]=d;r.children=Sh(f)&&!(qn(f)&&f.$ref)?[F(f,t)]:[{style:{background:"color-mix(in srgb, var(--danger) 8%, transparent)",border:"1px dashed color-mix(in srgb, var(--danger) 40%, transparent)",borderRadius:"4px",color:"var(--danger)",fontFamily:"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace",fontSize:"11px",fontStyle:"italic",padding:"6px 10px"},tagName:"div",textContent:`[$switch: ${Object.keys(c).join(" | ")}]`}]}}else if(s==="attributes"&&a&&Sh(c)){let d={};for(let[f,g]of Object.entries(c))if((f==="src"||f==="poster")&&(g===""||g==null||B(g)))i=!0,d[f]=rn;else d[f]=B(g)?we(f,g):g;r.attributes=d}else if(s==="attributes"&&Sh(c)){let d={};for(let[f,g]of Object.entries(c))d[f]=B(g)?we(f,g):g;r.attributes=d}else if(s==="style")if(Sh(c)){let d={};for(let[f,g]of Object.entries(c))if(!B(g))d[f]=g;r.style=d}else r.style=c;else if(s==="$switch"&&n(c)&&c.includes("${"))r[s]=dt(c);else if(s==="textContent"&&n(c)&&c.includes("${"))r[s]=dt(c);else if(s==="textContent"&&qn(c)&&c.$ref)r[s]=fn(c.$ref);else if(a&&(s==="src"||s==="poster"))if(c===""||c==null||B(c))i=!0,r[s]=rn;else r[s]=c;else if(B(c))r[s]=we(s,c);else if(n(c)||qn(c)&&c.$ref)r[s]=c;else r[s]=F(c,t);let l=Fr(r);if(l)r.className=r.className?`${r.className} ${l}`:l;if(i){let s=n(r.className)?r.className:"";if(!s.includes("empty-media-placeholder"))r.className=s?`${s} empty-media-placeholder`:"empty-media-placeholder"}return r}function CS(e){let t=e.document?.$paths,o=e.frontmatter?.$paths;return t??o??null}var Te=new Map;function gN(){Te.clear()}function bN(e,t){if(!t)return Promise.resolve({});let o=`${e??""}::${JSON.stringify(t)}`,r=Te.get(o);if(!r)r=Zr(t).catch((i)=>(Te.delete(o),console.warn("page-params: failed to enumerate $paths values:",i),{})),Te.set(o,r);return r}async function Zr(e){if(Array.isArray(e)){let t={};for(let o of e)for(let[r,i]of Object.entries(o))Ee(t,r,i);return t}if("contentType"in e&&n(e.contentType)&&e.contentType){let t=e.param??"slug",o=e.field??"id",r=await Xr(e.contentType),i={[t]:[]};if(!Array.isArray(r))return i;let a=r;for(let l of a)Ee(i,t,o==="id"?l.id:l.data?.[o]??l.id);return i}if("values"in e&&Array.isArray(e.values)){let t=e.param??"value",o={[t]:[]};for(let r of e.values)Ee(o,t,r);return o}if("$ref"in e&&n(e.$ref)&&e.$ref){let t=e.param??"id",o=e.field??"id",r=await p().readFile(e.$ref.replace(/^\.\//,"")),i=JSON.parse(r),a={[t]:[]};if(!Array.isArray(i))return a;for(let l of i)Ee(a,t,v(l)?l[o]??l.id??l:l);return a}return{}}async function Yr(){let e=await td();for(let t of e){let o=t.classes?.find((r)=>r.name==="ContentCollection");if(o)return o.path}return"@jxsuite/parser/ContentCollection.class.json"}async function Xr(e){let t={$prototype:"ContentCollection",$src:await Yr(),contentType:e},o=p();if(o.resolveClass)return o.resolveClass(t);return fetch("/__jx_resolve__",{body:JSON.stringify(t),headers:{"content-type":"application/json"},method:"POST"}).then((r)=>{if(!r.ok)throw Error(`Class resolution failed: ${r.status}`);return r.json()})}function Ee(e,t,o){if(o===null||o===void 0||o==="")return;let r=String(o);e[t]??=[];let i=e[t];if(!i.includes(r))i.push(r)}function mn(e,t,o){if(Object.keys(t).length===0)return e;let r=yn(e,t);return r.state??={},r.state.$page={params:{...t},title:n(r.title)?r.title:"",url:Yu(o)},r}function gn(e){if(!e)return[];return Object.keys(e).filter((t)=>{let o=e[t];return v(o)&&n(o.$prototype)&&n(o.$src)&&JSON.stringify(o).includes('"#/$params/')})}async function hn(e,t,o){if(t.length===0)return;let r=p(),{resolveClass:i}=r;if(!i)return;let{state:a}=e;if(!a)return;await Promise.all(t.map(async(l)=>{let s=a[l];if(!v(s))return;let c={...s};if(o)c.$base=o;try{a[l]=await i.call(r,c)}catch(d){console.warn(`page-params: failed to resolve state.${l} for preview:`,d)}}))}function vn(e,t){let o=Qr(e,t);if(o!==null)return o;if(Array.isArray(e))return e.map((r)=>vn(r,t));return v(e)?yn(e,t):e}function yn(e,t){let o={};for(let[r,i]of Object.entries(e))o[r]=vn(i,t);return o}function Qr(e,t){if(!Oe(e)||!e.$ref.startsWith("#/$params/"))return null;return t[e.$ref.slice(10)]??null}function kS(e){let t=e?.tagName;return n(t)&&t.includes("-")}function ei(e){return _(e)&&!Array.isArray(e)}function bn(e){if(e===void 0)return null;if(ei(e)){if(e.$expression||e.$compute||e.$prototype||e.$handler)return null;return"default"in e||"type"in e?"signal":"literal"}return n(e)&&e.includes("${")?null:"literal"}function vN(e){let t=e?.state??{},o=[];for(let[r,i]of Object.entries(t)){if(id(r))continue;let a=bn(i);if(!a)continue;let l=a==="signal"?i.default:i;o.push({name:r,value:l})}return o}function Cn(e,t){let o={...e.state},r=!1;for(let[i,a]of Object.entries(t)){let l=o[i],s=bn(l);if(!s)continue;o[i]=s==="signal"?{...l,default:a}:a,r=!0}if(!r)return e;return{...e,state:o}}var ti=new Set(["data","media","metadata","news","series","species"]),ni=new Set(["archive","catalog","catalogue","collection","directory","faq","gallery","inventory","library","menu","portfolio","showcase"]);function ES(e){return e.replaceAll(/[_-]+/g," ").replaceAll(/([a-z\d])([A-Z])/g,"$1 $2").trim().replaceAll(/\s+/g," ").toLowerCase()}function Xu(e){let t=/[_-]|[a-z\d][A-Z]/.test(e)?ES(e):e,o=t.lastIndexOf(" "),r=t.slice(o+1);if(ni.has(r.toLowerCase()))return`${t} item`;return`${t.slice(0,o+1)}${oi(r)}`}function oi(e){if(ti.has(e.toLowerCase()))return e;if(/[^aeiou]ies$/.test(e))return`${e.slice(0,-3)}y`;if(/(?:ss|x|ch|sh|z)es$/.test(e))return e.slice(0,-2);if(/(?:us|is|ss)$/.test(e))return e;if(e.endsWith("s"))return e.slice(0,-1);return e}function _b(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Sb(e){return(e.replaceAll("\\","/").split("/").pop()??e).replace(/\.[^.]+$/,"").replaceAll(/[-_]+/g," ").replaceAll(/\b\w/g,(o)=>o.toUpperCase())}var ci="pages";function mt(){return S?.projectConfig?.content??{}}function Sn(e){return e!==void 0&&/\.[\da-z]+$/i.test(e.replace(/\/+$/,""))}var ri={fileBacked:!1,item:"page",key:ci,kind:"pages",title:"Pages"};function gm(){let e=Object.entries(mt()).map(([t,o])=>({fileBacked:Sn(o.source),item:Xu(t),key:t,kind:"collection",title:_b(ES(t))}));return[ri,...e]}function KT(){return gm().map((e)=>e.key)}function Aw(e){let t=mt()[e]?.source;return t!==void 0&&Sn(t)?t.replace(/^\.\//,""):null}function yN(e){return mt()[e]?.schema??null}function Wl(e){return gm().find((t)=>t.key===e)??null}function Vl(e){if(!e)return null;let t=e.replaceAll("\\","/").replace(/^\.\//,"");if(Js.has(nn(t)))return null;if(t.startsWith("pages/"))return Zu(t)?ci:null;return Vn(t)?.name??null}function Qu(e){if(!e)return!1;let t=Vn(e);if(!t||t.fileBacked)return!1;let o=nn(e);return o!==".json"&&o!==".csv"}function wN(e,t){if(e===void 0||t)return{entries:!0,pages:!0,scan:!0};let o=e.map((r)=>r.replaceAll("\\","/").replace(/^\.\//,""));return{entries:o.some((r)=>{let i=Vl(r);return i!==null&&i!==ci}),pages:o.some((r)=>r.startsWith("pages/")),scan:!1}}function ii(e,t,o){let r=e?.state??t?.state,i=`#/$params/${o}`;for(let a of Object.values(v(r)?r:{})){if(!v(a)||a.$prototype!=="ContentEntry")continue;let{contentType:l,id:s}=a;if(v(s)&&s.$ref===i&&n(l)&&l!=="")return l}return null}function TS(e,t){let o=CS({document:e,frontmatter:t}),r=null,i=null,a=null,l=null;if(o&&!Array.isArray(o)&&"contentType"in o){let d=o.contentType;r=n(d)&&d!==""?d:null;let f="param"in o?o.param:void 0;i=n(f)&&f!==""?f:null;let g="field"in o?o.field:void 0;a=n(g)&&g!==""&&g!=="id"?g:null}else if(o&&!Array.isArray(o)&&"values"in o){let d="param"in o?o.param:void 0,f=n(d)&&d!==""?d:null;r=f===null?null:ii(e,t,f),i=r===null?null:f;let g=o.values;l=r!==null&&Array.isArray(g)?g.flatMap((y)=>{let b=ht(y);return b===null?[]:[b]}):null}let s=e?.$layout??t?.$layout,c=n(s)||s===!1?s:void 0;return{contentType:r,field:a,layout:c,param:i,...l!==null&&{values:l}}}async function JT(e){let t={contentType:null,field:null,layout:void 0,param:null};try{let o=await p().readFile(e);if(e.endsWith(".json"))return TS(JSON.parse(o),null);let{parseSourceForPath:r}=await (le("6pe4z7an"),import("./file-ops-6pe4z7an.js")),i=await r(e,o);return TS(i.document,i.frontmatter)}catch{return t}}var V=null,ue=null,gt=0,Re=new Set;async function wn(e,t){let o;try{o=await p().listDirectory(e)}catch{return}await Promise.all(o.map(async(r)=>{if(r.type==="directory")await wn(r.path,t);else t.push(r.path)}))}async function ai(){let e=[];await wn("pages",e);let t=e.filter((a)=>a.includes("[")&&Zu(a)).toSorted(),o=await Promise.all(t.map(async(a)=>[a,await JT(a)])),{i18n:r}=ln(S?.projectConfig??{}),i=new Map;for(let[a,l]of o)if(l.contentType){let s={field:l.field,layout:l.layout,locale:gx(a,r),param:l.param,path:a,pattern:wr(a).urlPattern,...l.values&&{values:l.values}};i.set(l.contentType,[...i.get(l.contentType)??[],s])}return i}function yt(){if(V)return Promise.resolve(V);if(!_e()||!S)return Promise.resolve(new Map);if(!ue){let e=gt;ue=ai().then((t)=>{if(e===gt){V=t,ue=null;for(let o of Re)o()}return t})}return ue}function En(e,t){if(!e||e.length===0)return null;let o=Pn(t),r=ln(S?.projectConfig??{}).i18n?.defaultLocale??null;return(o===null?void 0:e.find((i)=>i.locale===o))??(r===null?void 0:e.find((i)=>i.locale===r))??e.find((i)=>i.locale===null)??e[0]}function Mc(e){if(!e)return null;return go(e,ln(S?.projectConfig??{}).i18n)}function eh(e,t){if(!V){yt();return}return En(V.get(e),t)}function xN(e){if(!V){yt();return}return V.get(e)??[]}async function Ae(e,t){let o=await yt();return En(o.get(e),t)}function Cb(){gt+=1,V=null,ue=null}function kp(e){return Re.add(e),()=>{Re.delete(e)}}function ht(e){if(n(e)&&e!=="")return e;return Z(e)&&Number.isFinite(e)?String(e):null}function LS(e,t,o){if(!e)return null;let r=t.split("/").pop()??t,i=r.lastIndexOf("."),a=i>0?r.slice(0,i):r,l=e.field===null?null:ht(o?.[e.field]),s=t.endsWith(".json")?ht(o?.id):null,c=l??s??a;if(e.values&&!e.values.includes(c))return null;if(e.param)return e.pattern.replace(`:${e.param}`,c);return e.pattern.replace(/:[A-Za-z_]\w*/,c)}function $S(e,t){if(e===!1)return null;if(n(e)&&e!=="")return e;if(t?.layout===!1)return null;if(n(t?.layout)&&t.layout!=="")return t.layout;return S?.projectConfig?.defaults?.layout??null}function _N(){Cb(),Re.clear()}function si(e,t){let o=t.split("/"),r={};for(let[i,a]of e.split("/").entries()){let l=o[i];if(a.startsWith(":")&&l!==void 0)r[a.slice(1)]=l}return r}async function li(e){let{documentPath:t,fields:o,isEntry:r,params:i}=e;if(!r)return{_pathParams:{...i},sourcePath:t,urlPattern:Yu(t)};let a=Vn(t),l=a?await Ae(a.name,Mc(t)):null,s=LS(l,t,o);if(!l||s===null)return{_pathParams:{},sourcePath:t,urlPattern:l?.pattern??"/"};return{_pathParams:si(l.pattern,s),sourcePath:l.path,urlPattern:s}}async function Mn(e,t){if(!t)return null;let o=await li(e),r=e.fields?.title,i=n(e.title)?e.title:n(r)?r:null,a={state:{}};if(i!==null)a.title=i;if(n(e.lang))a.$lang=e.lang;let l=Pe(a,t,o,null,ln(t).i18n),{$page:s,$site:c}=l.state??{};return s===void 0||c===void 0?null:{$page:s,$site:c}}var $e=new Map;function IS(){$e=new Map}function pi(e){if(!e.startsWith("#/state/"))return null;let[t]=e.slice(8).split("/");return t?t.replaceAll("~1","/").replaceAll("~0","~"):null}function xt(e){if(n(e))return e.includes("${");if(Array.isArray(e))return e.some((t)=>xt(t));return v(e)&&Object.values(e).some((t)=>xt(t))}function Nn(e,t){if(n(e.$src))return e.$src;return n(e.$prototype)&&Object.hasOwn(t,e.$prototype)?t[e.$prototype]??null:null}function bt(e,t={}){return v(e)&&n(e.$prototype)&&Nn(e,t)!==null&&!xt(e)}function On(e,t){return Object.entries(e.state??{}).filter(([,o])=>v(o)&&!n(o.$src)&&bt(o,t)).map(([o])=>o)}function Rn(e){let t=new Set,o=(i)=>{if(Array.isArray(i)){for(let a of i)o(a);return}if(!qn(i))return;if(i.$prototype==="Array"&&Oe(i.items)){let a=pi(i.items.$ref);if(a)t.add(a)}o(i.map),o(i.children);for(let a of Object.values(i.cases??{}))o(a)};o(e.children);let r=e.state??{};return[...t].filter((i)=>bt(r[i]))}function fi(e,t){return console.warn(`canvas: could not resolve state.${e} before the render:`,t),null}async function An(e,t,o,r={}){let i=p(),{resolveClass:a}=i,l=e.state;if(t.length===0||!a||!l)return e;let s={...l};return await Promise.all(t.map(async(c)=>{let d=s[c];if(!bt(d,r))return;let f={...d,$src:Nn(d,r)};if(o)f.$base=o;let g=JSON.stringify(f),y=$e.get(g);if(!y)y=a.call(i,f).then((T)=>T??null,(T)=>($e.delete(g),fi(c,T))),$e.set(g,y);let b=await y;if(b!==null)s[c]=b})),{...e,state:s}}function $n(e,t=[]){if(!_(e))return null;if(Array.isArray(e.children)){let o=e.children.findIndex((r)=>_(r)&&!r.$__layout);if(o!==-1)return{offset:o,prefix:[...t,"children"]};for(let r=0;r<e.children.length;r++){let i=e.children[r];if(_(i)&&i.$__layout){let a=$n(i,[...t,"children",r]);if(a)return a}}}return null}function Ct(e,t,o=[]){if(!_(e))return;if(e.$__layout={file:t,path:o},Array.isArray(e.children))for(let[r,i]of e.children.entries()){if(n(i))continue;Ct(i,t,[...o,"children",r])}if(Array.isArray(e.$elements)){for(let[r,i]of e.$elements.entries())if(!n(i))Ct(i,t,[...o,"$elements",r])}}async function In(e,t=new Set){let o=e.replace(/^\.\//,"");if(t.has(o))return null;t.add(o);let r=await Yw(e);if(!r)return null;Ct(r,o);let i=r.$layout;if(!n(i)||!i)return r;let a=await In(i,t);if(!a)return r;let l=jL(a,r);return delete l.$layout,l}function mi(e,t){for(let o of e??[]){if(!_(o)||!n(o.$ref)||!/^\.\.?\//.test(o.$ref))continue;let r=o.$__layout;if(!v(r)||!n(r.file))continue;let i=new URL(o.$ref,`jx-project:/${r.file}`).pathname.replace(/^\//,"");o.$ref=Hc(t,i)}}function Dn(e,t){if(e.$layout!==void 0)return e.$layout;let o=t?.doc.content.frontmatter.$layout;return n(o)||o===!1?o:void 0}async function gi(e,t,o){let r=Dn(e,t),i=o?Vn(o):null,a=i?await Ae(i.name,Mc(o)):null;return $S(r,a)}async function kn(e,t,o=null){let r={documentPath:t?.documentPath,mode:t?.doc.mode},i=o??Ac(t),a=i==="preview"?structuredClone(he(e)):ft(Xp(e)),l=!1,s=r.documentPath&&S?.isSiteProject&&(r.documentPath.startsWith("pages/")||r.documentPath.startsWith("./pages/")),c=!s&&Boolean(S?.isSiteProject)&&Qu(r.documentPath),d=null,f=0;if((s||c)&&t?.session.ui.showLayout!==!1){let w=c?await gi(e,t,r.documentPath):ol(Dn(e,t));if(w){let M=await In(w);if(M){let D=i==="preview"?structuredClone(he(e)):a,P=jL(M,D);if(a=i==="preview"?P:ft(Xp(P)),l=!0,r.documentPath)mi(a.$elements,r.documentPath);let O=$n(P);d=O?.prefix??null,f=O?.offset??0}}}let g=S?.projectConfig;if(s&&g){if(a={...a,state:{...a.state}},a.imports)a.imports={...a.imports};Pe(a,g,{urlPattern:Yu(r.documentPath)})}let y=Fd(S?.projectRoot),b=r.documentPath?new URL(r.documentPath,y).href:void 0,T=Pb(r.documentPath,ah());if(s&&t){let{previewParams:w}=t.session.ui;if(Object.keys(w).length>0){let M=gn(e.state??null);a=mn(a,w,r.documentPath),await hn(a,M,b)}}if((s||c)&&r.documentPath){let w=await Mn({documentPath:r.documentPath,fields:c?t?.doc.content.frontmatter??null:null,isEntry:c,lang:e.$lang,params:t?.session.ui.previewParams??{},title:e.title},S?.projectConfig);if(w)a={...a,state:{...a.state,...w}}}let k=await td(),I=FL(k),J=On(a,I);if(i!=="preview")J.push(...Rn(e));if(a=await An(a,[...new Set(J)],b,I),!s&&t&&kS(a)){let{previewProps:w}=t.session.ui;if(w&&Object.keys(w).length>0)a=Cn(a,w)}let ee=new Set;if(i!=="preview")(function w(M,D){if(!_(M))return;if(M.$prototype==="Array"){ee.add(D.join("/"));let P=M.map;if(_(P))w(P,[...D,"map"]);return}if(Array.isArray(M.children))for(let[P,O]of M.children.entries()){if(n(O))continue;w(O,[...D,"children",P])}else if(Yo(M.children))w(M.children,[...D,"children"]);if(M.$switch&&M.cases)for(let[P,O]of Object.entries(M.cases))w(O,[...D,"cases",P])})(e,[]);let ot=r.documentPath!=null&&(r.documentPath.startsWith("layouts/")||r.documentPath.startsWith("./layouts/")),Ce=Kw(a.$elements);if((r.mode==="content"||l||ot)&&Ne.length>0){let w=new Set(Ce.map((P)=>_(P)?P.$ref:P)),M=new Map(Ne.map((P)=>[P.tagName,P])),D=GS(a);if(a.tagName)D.add(it(a.tagName));for(let P of D)for(let O of M.get(P)?.uses??[])D.add(O);for(let P of D){let O=M.get(P);if(O&&O.source!=="npm"&&O.path){let rt=Hc(r.documentPath??null,O.path);if(!w.has(rt))Ce.push({$ref:rt}),w.add(rt)}}}if(Ce.length>0)a.$elements=Ce;return a.imports=KN(a.imports,k),a.$media=eo(a.$media),a.$head=Jw(a.$head),{assets:T,docBase:b,mapperCtx:{arrayPaths:[...ee],canvasMode:i,layoutWrapped:l,pageContentOffset:f,pageContentPrefix:d},renderDoc:a,siteStyle:S?.projectConfig?.style??null}}var vi=128,YT="fullRender",SN="mountCanvas",CN="patchBatch",Ln="prepareRender",qo={derivedResolves:0,derivedRetargets:0,escalations:0,fullRenders:0,hostRenderPosts:0,lastEscalationReason:"",lastFullRenderMs:0,p95FullRenderMs:0,panelRenders:0,patchedOps:0,renderPreparations:0,skippedFullRenders:0,timings:{}};globalThis.__jxCanvasPerf=qo;var Jn=new Map;function _n(){try{return typeof localStorage<"u"&&Boolean(localStorage.getItem("jx-canvas-debug"))}catch{return!1}}function Hn(){return typeof performance<"u"&&te(performance.now)?performance.now():0}function jn(e,t){if(_n())console.debug(`[jx-canvas] ${e}`,t??"")}function Ow(e){qo.escalations+=1,qo.lastEscalationReason=e,jn("escalation",e)}function yi(e){if(e.length===0)return 0;let t=e.toSorted((r,i)=>r-i),o=Math.min(t.length-1,Math.ceil(t.length*0.95)-1);return t[Math.max(0,o)]??0}function xi(e,t){let o=Number.isFinite(t)&&t>0?t:0,r=Jn.get(e);if(!r)r=[],Jn.set(e,r);if(r.push(o),r.length>vi)r.shift();let i=qo.timings[e],a={count:(i?.count??0)+1,lastMs:o,maxMs:Math.max(i?.maxMs??0,o),p95Ms:yi(r),totalMs:(i?.totalMs??0)+o};if(qo.timings[e]=a,e===YT)qo.lastFullRenderMs=a.lastMs,qo.p95FullRenderMs=a.p95Ms;jn(`span:${e}`,`${o.toFixed(2)}ms`)}function Fn(e){let t=Hn(),o=_n(),r=`jx-${e}-start`;if(o)try{performance.mark(r)}catch{}let i=!1;return()=>{if(i)return qo.timings[e]?.lastMs??0;i=!0;let a=Hn()-t;if(o)try{performance.measure(`jx-${e}`,r),performance.clearMarks(r)}catch{}return xi(e,a),a}}function RS(e,t){let o=Fn(e);try{return t()}finally{o()}}async function DS(e,t){let o=Fn(e);try{return await t()}finally{o()}}function ji(e){if(e==="--")return"Base";return e.replace(/^--/,"").replaceAll("-"," ").replaceAll(/\b\w/g,(t)=>t.toUpperCase())||e}var Bn=new Set(["script","style","link","iframe","object","embed"]);function th(e){let t={tagName:e};if(/^h[1-6]$/.test(e))t.textContent="Heading";else if(e==="p")t.textContent="Paragraph text";else if(e==="span"||e==="strong"||e==="em"||e==="small"||e==="mark"||e==="code"||e==="abbr"||e==="q"||e==="sub"||e==="sup"||e==="time")t.textContent="Text";else if(e==="a")t.textContent="Link",t.attributes={href:"#"};else if(e==="button")t.textContent="Button";else if(e==="label")t.textContent="Label";else if(e==="legend")t.textContent="Legend";else if(e==="caption")t.textContent="Caption";else if(e==="summary")t.textContent="Summary";else if(e==="li"||e==="dt"||e==="dd"||e==="th"||e==="td"||e==="option")t.textContent="Item";else if(e==="blockquote")t.textContent="Quote";else if(e==="pre")t.textContent="Preformatted text";else if(e==="input")t.attributes={placeholder:"Enter text...",type:"text"};else if(e==="img")t.attributes={alt:"Image"};else if(e==="iframe")t.attributes={src:""};else if(e==="slot")t.children=[{tagName:"p",textContent:"Slot content"}];else if(e==="select")t.children=[{tagName:"option",textContent:"Option 1"}];else if(e==="ul"||e==="ol")t.children=[{tagName:"li",textContent:"Item"}];else if(e==="dl")t.children=[{tagName:"dt",textContent:"Term"},{tagName:"dd",textContent:"Definition"}];else if(e==="table")t.children=[{children:[{children:[{tagName:"th",textContent:"Header"}],tagName:"tr"}],tagName:"thead"},{children:[{children:[{tagName:"td",textContent:"Cell"}],tagName:"tr"}],tagName:"tbody"}];else if(e==="details")t.children=[{tagName:"summary",textContent:"Summary"},{tagName:"p",textContent:"Detail content"}];return t}function Pt(e){return _(e)&&n(e.$ref)?e.$ref:null}function Ie(e){if(e.source!=="npm"||!e.package)return null;return e.modulePath?`${e.package}/${e.modulePath}`:e.package}function bi(e,t){let o=Ie(e);if(o)return o;return e.path?{$ref:Hc(t,e.path)}:null}function ZT(e,t,o){let r=Ie(t);if(r)return e.some((a)=>n(a)&&(a===r||a===t.package));if(!t.path)return!1;let i=re(Hc(o,t.path));return e.some((a)=>{let l=Pt(a);return l!==null&&re(l)===i})}function re(e){return e.replace(/^(?:\.\/)+/,"")}function kb(e,t,o){let r=bi(t,o);if(!r)return[...e];let a=Ie(t)&&t.modulePath?e.filter((l)=>l!==t.package):[...e];return ZT(a,t,o)?a:[...a,r]}function XT(e,t,o){let r=Ie(t);if(r)return e.filter((a)=>!(n(a)&&(a===r||a===t.package)));if(!t.path)return[...e];let i=re(Hc(o,t.path));return e.filter((a)=>{let l=Pt(a);return l===null||re(l)!==i})}function kN(e,t){return e.filter((o)=>!n(o)||!(o===t||o.startsWith(`${t}/`)))}function EN(e,t){let o=re(t);return e.filter((r)=>{let i=Pt(r);return i===null||re(i)!==o})}var Ci="Components";function Ep(e,t){let o=Pi(e,t);if(o)Ve(e,[],"$elements",o)}function Pi(e,t){if(!n(t)||!t.includes("-"))return null;let o=Ne.find((a)=>a.tagName===t);if(!o)return null;let r=e.doc.document.$elements??[],i=kb(r,o,e.documentPath??null);return i.length===r.length?null:i}function NS(e){let t=Ne.find((o)=>o.tagName===e);return t?jc(t):null}function TN(){return Ne.map((e)=>({component:!0,description:(e.source==="npm"?e.package:e.path)??"",group:Ci,label:`<${e.tagName}>`,tag:e.tagName}))}function z(e){if(!e)return[];if(Array.isArray(e.children))return e.children;return n(e.textContent)&&e.textContent.length>0?[e.textContent]:[]}function de(e){let t=0;for(let o of e)t+=n(o)?o.length:de(z(o));return t}function wt(e,t,o){let r=[],i=0;for(let a of e){if(i>=o)break;if(n(a)){let d=i+a.length;if(d>t){let f=a.slice(Math.max(0,t-i),Math.max(0,Math.min(o,d)-i));if(f)r.push(f)}i=d;continue}let l=z(a),s=de(l),c=i+s;if(s===0){if(i>=t&&i<o)r.push({...a})}else if(c>t){let d=wt(l,Math.max(0,t-i),Math.min(o,c)-i);if(d.length>0)r.push(Si(a,d))}i=c}return r}function Si(e,t){let{children:o,textContent:r,...i}=e;if(t.length===0)return{...i,textContent:""};if(t.length===1&&n(t[0]))return{...i,textContent:t[0]};return{...i,children:t}}function zn(e){let t=[];for(let o of e){if(n(o)){if(o.length===0)continue;let r=t.at(-1);if(n(r)){t[t.length-1]=r+o;continue}}t.push(o)}return t}function Kn(e,t,o,r,i=""){return zn([...wt(e,0,t),...i?[i]:[],...wt(o,r,de(o))])}function Et(e){let t=zn(e);if(t.length===0)return{textContent:""};if(t.length===1&&n(t[0]))return{textContent:t[0]};return{children:t}}function Un(e){if(!e)return!0;if(e.textContent!=null&&e.textContent.trim()==="")return!0;let t=e.children;if(!t)return!1;if(t.length===0)return!0;let[o]=t;if(t.length===1&&n(o)&&o.trim()==="")return!0;return t.length===1&&_(o)&&o.tagName==="br"}function Tt(e){return{index:hi(e),parentPath:At(e)}}function Gn(e,t,o,r,i={}){if(!e)return;let a=oe(e.doc.document,t);if(o){if(a&&JSON.stringify(a.children)===JSON.stringify(o))return;Y(e,(l)=>{if(a?.textContent!=null)Ve(l,t,"textContent");Ve(l,t,"children",o)},{coalesceKey:i.coalesceKey??null})}else if(r!=null){if(a&&a.textContent===r&&!a.children)return;Y(e,(l)=>{if(a?.children)Ve(l,t,"children");Ve(l,t,"textContent",r)},{coalesceKey:i.coalesceKey??null})}}function Zn(e,t,o,r){if(!e)return!1;let i=oe(e.doc.document,t);if(!i)return!1;if(`${i.$props?.[o]??""}`===r)return!1;return Y(e,(l)=>{Up(l,t,o,r)}),!0}function Yn(e,t,o){if(!e)return null;let r=oe(e.doc.document,t),i=oe(e.doc.document,o);if(!r||!i)return null;if(ec(t,o)||ec(o,t))return null;let a=z(i),l=z(r),s=de(a),c=Et([...a,...l]);return Y(e,(d)=>{if(c.children){if(i.textContent!=null)Ve(d,o,"textContent");Ve(d,o,"children",c.children)}else{if(i.children)Ve(d,o,"children");Ve(d,o,"textContent",c.textContent??"")}if(bh(d,t),Xn(d,At(t)),qp(e))d.session.selection=[o]}),{offset:s,path:o}}function Xn(e,t){let o=t;while(o.length>0){let r=oe(e.doc.document,o),i=r?.children;if(!r||!Array.isArray(i)||i.length>0)return;let a=At(o);if(bh(e,o),!a)return;o=a}}function Qn(e,t,o,r){let{parentPath:i,index:a}=Tt(t),l=[...i,"children",a+1];if(!e)return l;let s={tagName:"p"};if(r.textContent!=null)s.textContent=r.textContent;else if(r.children)s.children=r.children;else s.textContent="";return Y(e,(c)=>{if(o.textContent!=null)Ve(c,t,"children"),Ve(c,t,"textContent",o.textContent);else if(o.children)Ve(c,t,"textContent"),Ve(c,t,"children",o.children);if(Lo(c,i,a+1,s),qp(e))c.session.selection=[l]}),l}function wi(e,t,o,r){let{parentPath:i,index:a}=Tt(t),l=Un(r),s=l?a:a+1,c=[...i,"children",s];if(!e)return c;return Y(e,(d)=>{if(l)bh(d,t);else if(r?.children)Ve(d,t,"textContent"),Ve(d,t,"children",r.children);else if(r?.textContent!=null)Ve(d,t,"children"),Ve(d,t,"textContent",r.textContent);if(Lo(d,i,s,o),Ep(d,o.tagName),qp(e))d.session.selection=[c]}),c}function to(e,t,o,r){let i=o.component===!0?NS(o.tag):null;if(i)return wi(e,t,i,r);if(Un(r)){if(!e)return t;return Y(e,(d)=>{Ve(d,t,"tagName",o.tag),Ve(d,t,"children");let f=th(o.tag);if(f.textContent&&f.textContent!=="Paragraph text")Ve(d,t,"textContent",f.textContent);else Ve(d,t,"textContent");if(qp(e))d.session.selection=[t]}),t}let{parentPath:a,index:l}=Tt(t),s=[...a,"children",l+1];if(!e)return s;let c=th(o.tag);return Y(e,(d)=>{if(r?.children)Ve(d,t,"textContent"),Ve(d,t,"children",r.children);else if(r?.textContent!=null)Ve(d,t,"children"),Ve(d,t,"textContent",r.textContent);if(Lo(d,a,l+1,structuredClone(c)),qp(e))d.session.selection=[s]}),s}function no(e,t,o,r,i){if(!e)return null;let a=oe(e.doc.document,t.path),l=oe(e.doc.document,o.path);if(!a||!l)return null;if(ec(t.path,o.path)||ec(o.path,t.path))return null;let s=Et(Kn(z(a),t.offset,z(l),o.offset,i)),c=[...r,o.path].toSorted(Ei);return Y(e,(d)=>{if(s.children){if(a.textContent!=null)Ve(d,t.path,"textContent");Ve(d,t.path,"children",s.children)}else{if(a.children)Ve(d,t.path,"children");Ve(d,t.path,"textContent",s.textContent??"")}for(let f of c)if(oe(d.doc.document,f))bh(d,f),Xn(d,At(f));if(qp(e))d.session.selection=[t.path]}),{offset:t.offset+i.length,path:t.path}}function Ei(e,t){let o=Math.min(e.length,t.length);for(let r=0;r<o;r++){let i=e[r],a=t[r];if(i===a)continue;if(Z(i)&&Z(a))return a-i;return String(a).localeCompare(String(i))}return t.length-e.length}function R(e,t=1){return{height:e.height*t,left:e.x*t,top:e.y*t,width:e.width*t}}function LN(e,t,o=1){return{x:(e.x-t.left)/o,y:(e.y-t.top)/o}}function De(e,t){if(!t){e.style.display="none";return}e.style.display="block",e.style.left=`${t.left}px`,e.style.top=`${t.top}px`,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`}function oo(e=document){let t=e.createElement("div");t.className="jx-canvas-iframe-overlay",t.style.cssText="position:absolute;inset:0;pointer-events:none;overflow:hidden;z-index:2";let o=e.createElement("div");o.className="overlay-box overlay-selection",o.style.display="none";let r=e.createElement("div");r.className="overlay-label",r.style.display="none",o.append(r);let i=e.createElement("div");i.className="overlay-box overlay-hover",i.style.display="none";let a=e.createElement("div");a.className="canvas-drop-indicator",a.style.display="none";let l=e.createElement("button");l.className="insertion-helper",l.textContent="+",l.style.pointerEvents="auto",l.style.display="none";let s=e.createElement("div");s.className="canvas-replace-target",s.style.display="none";let c=e.createElement("div");c.className="overlay-presence-group";let d=e.createElement("div");return d.className="overlay-coselection-group",t.append(i,o,d,a,s,l,c),{dispose:()=>t.remove(),insertButton:l,root:t,setDropIndicator:(f,g="inside")=>Mi(a,f,g),setHover:(f)=>De(i,f),setInsertZone:(f,g="center")=>Ti(l,f,g),setReplaceTarget:(f)=>De(s,f),setSuppressed:(f)=>{t.style.display=f?"none":""},setCoSelection:(f)=>{d.replaceChildren();for(let g of f){let y=e.createElement("div");y.className="overlay-box overlay-selection overlay-coselection",De(y,g),d.append(y)}},setPresence:(f)=>{c.replaceChildren();for(let g of f){let y=e.createElement("div");y.className="overlay-box overlay-presence",y.style.cssText=`position:absolute;display:block;pointer-events:none;outline:1.5px solid ${g.color};outline-offset:1px;left:${g.placement.left}px;top:${g.placement.top}px;width:${g.placement.width}px;height:${g.placement.height}px`;let b=e.createElement("div");b.className="overlay-presence-tag",b.textContent=g.label,b.style.cssText=`position:absolute;top:-18px;left:-2px;padding:1px 5px;border-radius:3px;font:10px/1.4 sans-serif;color:#fff;white-space:nowrap;background:${g.color}`,y.append(b),c.append(y)}},setSelection:(f,g=null)=>{if(De(o,f),f&&g)r.textContent=g,r.style.display="block";else r.style.display="none"}}}function Ti(e,t,o){if(!t){e.style.display="none",e.classList.remove("visible");return}e.dataset.edge=o,e.classList.add("visible"),e.style.display="grid",e.style.left=`${t.left+t.width/2}px`,e.style.top=`${t.top+t.height/2}px`,e.style.translate="-50% -50%"}function Mi(e,t,o){if(!t){e.style.display="none";return}if(e.style.display="block",e.style.left=`${t.left}px`,e.style.width=`${t.width}px`,o==="inside"){e.className="canvas-drop-indicator inside",e.style.top=`${t.top}px`,e.style.height=`${t.height}px`;return}e.className="canvas-drop-indicator line",e.style.height="",e.style.top=`${o==="top"?t.top:t.top+t.height}px`}function Pc(e){return JSON.stringify(e)}var AS={$id:"elements-meta",title:"HTML Element Metadata",description:"Inline scoping and inline toolbar action metadata for HTML elements.",$convertGroups:{text:["p","h1","h2","h3","h4","h5","h6","blockquote"],container:["div","section","article","aside","main","header","footer","nav","search"],list:["ul","ol"]},$defs:{p:{$convertTo:"text",$convertToWhenEmpty:["text","container"],$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:[{tag:"strong",label:"Bold",command:"bold"},{tag:"em",label:"Italic",command:"italic"},{tag:"u",label:"Underline",command:"underline"},{tag:"del",label:"Strikethrough",command:"strikethrough"},{tag:"sup",label:"Superscript",command:"superscript"},{tag:"sub",label:"Subscript",command:"subscript"},{tag:"code",label:"Code",command:"code"},{tag:"a",label:"Link",command:"link"}]},h1:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:[{tag:"strong",label:"Bold",command:"bold"},{tag:"em",label:"Italic",command:"italic"},{tag:"code",label:"Code",command:"code"},{tag:"a",label:"Link",command:"link"}]},h2:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h3:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h4:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h5:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h6:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},li:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},td:{$inlineChildren:["em","strong","del","code","a","span","br","b","i","u","sub","sup","s"],$inlineActions:"p"},th:{$inlineChildren:["em","strong","del","code","a","span","br","b","i","u","sub","sup","s"],$inlineActions:"p"},blockquote:{$convertTo:"text",$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},figcaption:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},caption:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},summary:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},dt:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},dd:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},label:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},a:{$inlineChildren:["em","strong","code","span","br","b","i","u","sub","sup"],$inlineActions:[{tag:"strong",label:"Bold",command:"bold"},{tag:"em",label:"Italic",command:"italic"},{tag:"code",label:"Code",command:"code"}]},span:{$inlineChildren:["em","strong","del","code","a","br","b","i","u","sub","sup","s"],$inlineActions:"p"},div:{$convertTo:"container",$convertToWhenEmpty:["container","text"],$inlineChildren:[]},section:{$convertTo:"container",$inlineChildren:[]},article:{$convertTo:"container",$inlineChildren:[]},nav:{$convertTo:"container",$inlineChildren:[]},main:{$convertTo:"container",$inlineChildren:[]},header:{$convertTo:"container",$inlineChildren:[]},footer:{$convertTo:"container",$inlineChildren:[]},aside:{$convertTo:"container",$inlineChildren:[]},ul:{$convertTo:"list",$inlineChildren:[]},ol:{$convertTo:"list",$inlineChildren:[]},pre:{$inlineChildren:["code"]},table:{$inlineChildren:[]},thead:{$inlineChildren:[]},tbody:{$inlineChildren:[]},tr:{$inlineChildren:[]}}};var bm=AS.$defs,Ri=new Set(["pre"]),pc=new Set(Object.entries(bm).filter(([e,t])=>!Ri.has(e)&&(t.$inlineChildren?.length??0)>0).map(([e])=>e));var ro=new Set(["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"]);function Mt(e,t){if(!t)return ro.has(e);let o=bm[t];if(!o||!o.$inlineChildren)return!1;return o.$inlineChildren.includes(e)}function $N(e){let t=bm[e];if(!t)return null;let o=t.$inlineActions;if(n(o))o=bm[o]?.$inlineActions??void 0;if(!Array.isArray(o))return null;return o}var Ai=null;function Mw(e,t){if(!_(e))return!1;let o=(it(e.tagName)||"div").toLowerCase();if(t){let r=(it(t.tagName)||"div").toLowerCase();return Mt(o,r)}return ro.has(o)}function IN(){return Ai!==null}function ke(e){return!e||e==="base"?null:e}function Pw(e){let t=e.panels;if(t.length===0)return null;if(t.length===1)return t[0];let o=nl(e.paneId);for(let r of t){if(o===null&&r.mediaName==="base")return r;if(r.mediaName===o)return r}return t[0]}function ao(){return Pw(yr())}function RN(e,t){if(!e)return t;let o=t;for(let r=At(o);r;r=At(o)){let i=oe(e,o),a=oe(e,r);if(!i||!a)break;let l=(it(i.tagName)||"div").toLowerCase(),s=(it(a.tagName)||"div").toLowerCase();if(!Mt(l,s))break;o=r}return o}function Fw(e){return jp(e)!==null}function Tp(e){return jp(e)}function zr(e){if(!e)return{baseWidth:320,featureQueries:[],sizeBreakpoints:[]};let t=[],o=[],r=320;for(let[i,a]of Object.entries(e)){if(i==="--"){let c=String(a).match(/^(\d+)\s*px$/);r=c?Number(c[1]):320;continue}let l=a.match(/min-width:\s*([\d.]+)px/),s=a.match(/max-width:\s*([\d.]+)px/);if(l)o.push({name:i,query:a,type:"min",width:Number(l[1])});else if(s)o.push({name:i,query:a,type:"max",width:Number(s[1])});else t.push({name:i,query:a})}return o.sort((i,a)=>i.type==="min"?i.width-a.width:a.width-i.width),{baseWidth:r,featureQueries:t,sizeBreakpoints:o}}function $i(e,t){let o=new Set;for(let r of e)if(r.type==="min"&&t>=r.width)o.add(r.name);else if(r.type==="max"&&t<=r.width)o.add(r.name);return o}function so(e,t){let o=$i(e,t),r=null;for(let i of e){if(!o.has(i.name))continue;let a=Math.abs(i.width-t);if(r===null){r=i;continue}let l=Math.abs(r.width-t);if(a<l||a===l&&i.width<r.width)r=i}return r?.name??null}function DN(e,t,o=8){let r=null;for(let i of t){let a=Math.abs(i-e);if(a>o)continue;if(r===null||a<Math.abs(r-e))r=i}return r??e}var vm=240,NN=8,AN=16,Je=new Map;function Nt(e){return zr(eo(e.doc.document.$media))}function OS(e){let{baseWidth:t,sizeBreakpoints:o}=Nt(e),r=e.session.ui.activeMedia;return o.find((i)=>i.name===r)?.width??t}function Ii(e,t){let o=Je.get(e);if(!o)return null;if(!t||o.tabId!==t.id||o.media!==t.session.ui.activeMedia)return Je.delete(e),null;return o.width}function ON(e,t){let o=t?OS(t):0;return Ii(e.paneId,t)??o}function MS(e){Je.delete(e)}function MN(e){let{baseWidth:t,sizeBreakpoints:o}=Nt(e);return[t,...o.map((r)=>r.width)]}function PS(e,t,o){let{sizeBreakpoints:r}=Nt(t),i=so(r,o);return t.session.ui.activeMedia=i,Je.set(e,{media:i,tabId:t.id,width:o}),i}var Ot={invokerTags:Gb,popoverTags:hh};function QT(e,t){if(!e||!t)return null;for(let o=t.length;o>=0;o-=1){let r=t.slice(0,o),i=oe(e,r);if(_(i)&&Ta(i,Ot))return r}return null}function lo(e,t){let o=e.doc.document;if(!o)return null;if(t){let r=oe(o,t);return _(r)&&Ta(r,Ot)?t:null}return QT(o,Me(e.session.selection))}function co(){let e=u.value?.doc.document;return e?WA(e,Ot):!1}var po=["toggle-popover","show-popover","hide-popover","show-modal","close","request-close"],Rt=new Set(["show-modal","close","request-close"]),$t=new Set(["toggle-popover","show-popover","hide-popover"]),Di=["any","closerequest","none"],ki=new Set(po),Ji=new Set(Di),Hi=new Set(["button"]);function H(e){return To(e)==="dialog"}function uo(e){return e.startsWith("--")}function Li(e){let t=[];for(let{node:o}of Jl(e)){let r=Bp(o);if(H(o)&&r!==null&&!t.includes(r))t.push(r)}return t}function fo(e){for(let{node:t}of Jl(e))if(H(t))return!0;return!1}function _i(e){let t=e.oncommand;return t!==void 0&&t!==null}function Fi(e,t){for(let{node:o}of Jl(e)){if(o===e)continue;let r=To(o);if(r==="button"){let i=Ts(o,"command"),a=Ts(o,"commandfor");if(i!==null&&(i==="close"||i==="request-close")&&(a===null||a===t))return!0}if(r==="form"&&Ts(o,"method")?.toLowerCase()==="dialog")return!0}return!1}function fN(e,t){let o=[...Jl(e,[],null,t)],r=Li(e),i=qb(e,t),a=r.length>0||i.length>0,l=new Map,s=new Map;for(let{node:d}of o){let f=Bp(d);if(f!==null&&!l.has(f))l.set(f,d);if(To(d)==="button"){let g=Ts(d,"commandfor"),y=Ts(d,"command");if(g!==null){let b=s.get(g)??new Set;b.add(y??""),s.set(g,b)}}}let c=[];for(let{node:d,path:f}of o)if(c.push(...Vi(d,f,l,r,i,a,t)),H(d))c.push(...qi(d,f,s));return c}function Vi(e,t,o,r,i,a,l){let s=[],c=To(e),d=l?.invokerTags?.has(c)??!1,f=Ts(e,"command"),g=Ts(e,"commandfor");if(!(f!==null||g!==null||("command"in Kc(e))||("commandfor"in Kc(e))))return s;let b=Ls(e,"the element");if(!Hi.has(c)&&!d)return s.push({detail:"`command` and `commandfor` are attributes of `HTMLButtonElement` and of no other "+"interface — not even `<input>`, which `popovertarget` does allow. Elsewhere they parse "+`and do nothing. Make it a <button>, or remove both attributes. ${io}`,fix:"invoker",message:`<${c||"element"}> carries command/commandfor, which only <button> supports.`,path:t,rule:"invoker-not-button",severity:"error"}),s;if(f!==null&&!ki.has(f)&&!uo(f))return s.push({detail:`\`command\` is an enumerated attribute taking ${po.map((T)=>`\`${T}\``).join(", ")}, or a custom command starting with \`--\`. Anything else is the invalid-value state, and a button in that state does nothing when clicked. ${io}`,message:`${b} declares command="${f}", which is not a built-in or --custom command.`,path:t,rule:"command-invalid",severity:"error"}),s;if(g!==null){let T=o.get(g),k=r.includes(g),I=i.includes(g);if(!T&&a){let J=[...r,...i].map((ee)=>`"${ee}"`).join(", ");return s.push({detail:`No element in this document has the id "${g}". The dialogs and popovers here are: ${J}. A commandfor that names nothing does nothing, silently. ${io}`,message:`commandfor="${g}" names nothing in this document.`,path:t,rule:"command-target-missing",severity:"error"}),s}if(f!==null&&T){if(Rt.has(f)&&!H(T))s.push({detail:`\`${f}\` acts on a <dialog>, and "${g}" is ${I?"a popover":`a <${To(T)||"element"}>`}. The click is ignored. ${I?"Use `toggle-popover`, `show-popover` or `hide-popover` for a popover.":"Point it at a dialog, or make the target one."} ${io}`,message:`${b} sends ${f} to "${g}", which is not a dialog.`,path:t,rule:"command-target-mismatch",severity:"error"});else if($t.has(f)&&!Ta(T,l))s.push({detail:`\`${f}\` acts on a popover, and "${g}" is ${k?"a dialog":`a <${To(T)||"element"}>`} that declares no \`popover\`. The click is ignored. ${k?"Use `show-modal`, `close` or `request-close` for a dialog.":"Give the target a `popover` attribute, or point the button elsewhere."} ${io}`,message:`${b} sends ${f} to "${g}", which is not a popover.`,path:t,rule:"command-target-mismatch",severity:"error"});else if(uo(f)&&!_i(T))s.push({detail:`A custom command is a \`CommandEvent\` dispatched at its target, and "${g}" has no `+"`oncommand` handler to answer it — so the click does nothing. Add one that switches on "+`\`event#/command\`, or use a built-in command. ${io}`,message:`${b} sends ${f} to "${g}", which handles no command.`,path:t,rule:"custom-command-unhandled",severity:"warn"})}}return s}function qi(e,t,o){let r=[],i=Ls(e,"the dialog"),a=Bp(e),{style:l}=e,s=Ts(e,"closedby");if(s!==null&&!Ji.has(s))r.push({detail:`\`closedby\` is an enumerated attribute taking \`any\` (light dismiss and Escape), \`closerequest\` (Escape only, the default for a modal) or \`none\`. Anything else is the invalid-value default, \`auto\`, which is the same as leaving it out. ${io}`,message:`${i} declares closedby="${s}", which is not any, closerequest or none.`,path:t,rule:"dialog-closedby-invalid",severity:"error"});if(Sr(l,"display")!==null)r.push({detail:`A closed dialog is hidden by the browser's own \`dialog:not([open]) { display: none }\`. That rule is UA-origin, so any author \`display\` beats it, and the dialog is laid out on every page whether or not anyone opened it. \`display\` belongs in the \`&[open]\` rule and nowhere else. ${io}`,fix:"display",message:`${i} sets display in its base rule.`,path:t,rule:"dialog-display",severity:"error"});let c=a===null?void 0:o.get(a),d=Ts(e,"open")!==null||Kc(e).open===!0||e.open===!0;if(a!==null&&!c?.has("show-modal")&&!d)r.push({detail:`No <button> in this document opens it with \`command="show-modal"\`. If it is opened from another file or from a function that calls \`showModal()\`, this is fine; otherwise there is no way for a reader to open it. ${io}`,message:`${i} has no invoker in this document.`,path:t,rule:"dialog-no-invoker",severity:"warn"});if(c?.has("show-modal")&&s==="none"&&!Fi(e,a))r.push({detail:`A modal dialog makes everything outside it inert, so the only ways out are the ones it offers: \`closedby="none"\` turns off Escape and light dismiss, and nothing inside it closes it. A reader who opens it cannot leave. Add a <button command="close"> inside, or drop \`closedby="none"\`. ${io}`,message:`${i} opens modally, closes on nothing, and has no close button.`,path:t,rule:"modal-without-close",severity:"error"});return r}function eL(e,t){if(!e||!t)return null;for(let o=t.length;o>=0;o-=1){let r=t.slice(0,o),i=oe(e,r);if(_(i)&&H(i))return r}return null}function FS(e,t){let o=e.doc.document;if(!o)return null;if(t){let r=oe(o,t);return _(r)&&H(r)?t:null}return eL(o,Me(e.session.selection))}function mo(){let e=u.value?.doc.document;return e?fo(e):!1}function G(e){return vt(e.paneId)}function pe(e){let t=Br(e.paneId);if(t?.kind==="lens")return t.zoom;return G(e)?.session.ui.zoom??1}function ym(e=yr()){return pe(e)}function Le(e,t){let o=Br(e.paneId);if(o?.kind==="lens"){o.zoom=t;return}let r=G(e);if(r)r.session.ui.zoom=t}function Wi(e){return Boolean(e.canvas&&e.viewport)}function Lp(e,t,o,r=null){let a={_width:r||null,canvas:null,element:null,mediaName:e||"",ready:!1,renderScope:null,scrollContainer:null,viewport:null},l=[];if(r&&!o)l.push(`--panel-viewport-w:${r}px`);if(r)l.push(`--panel-canvas-w:${r}px`);return{item:{fullWidth:o,header:t?"shown":"hidden",key:e??"",label:t??"",mediaAttr:e,widthVars:l.join(";")},panel:a}}function PN(e,t){for(let{item:o,panel:r}of e){let i=(a)=>t.panelNode(o.key,a);r.element=i("panel"),r.viewport=i("panel-viewport"),r.canvas=i("panel-canvas")}}function FN(e,t){let o=e.find((i)=>i.item.key===t);if(!o)return;let r=tn(o.panel);if(r)r.session.ui.activeMedia=ke(o.item.mediaAttr)}function Jt(e){if(!e.panzoomWrap)return;let t=e.wrap.clientWidth,o=e.panzoomWrap.scrollWidth,r=pe(e),i=t-o*r;e.panX=i>=0?i/2:16,e.panY=0}function jw(e){if(e.centerObserver)e.centerObserver.disconnect(),e.centerObserver=null;if(!e.panzoomWrap)return;e.needsCenter=!0,e.centerObserver=new ResizeObserver(()=>{if(!e.needsCenter){e.centerObserver?.disconnect(),e.centerObserver=null;return}Jt(e),Us(e)}),e.centerObserver.observe(e.panzoomWrap),Jt(e)}function Us(e){if(!e.panzoomWrap)return;let t=pe(e);e.panzoomWrap.style.transform=`translate(${e.panX}px, ${e.panY}px) scale(${t})`,xn("overlays")}var Ht=0.25,Lt=3;function xo(e){return Math.min(Lt,Math.max(Ht,e))}function Ki(e,t,o){let r=e.wrap.querySelector('[part="edit-canvas"]'),i=e.panels[0]?.canvas;if(!r||!i)return null;let a=e.wrap.querySelector('[part="edit-column"]'),l=a?He(a).width:0,s=t&&l>0?l/t:1,c=o;if(c===null){let d=He(r);c=d.top+d.height/2}return{layoutY:Math.max(0,(c-He(i).top)/s),scroller:r,zoom:s}}function nh(e=yr(),t=null){if(Uo(e.paneId)!=="edit")return;let[o]=e.panels;if(!o||!Wi(o))return;let r=o.canvas,i=r.querySelector("iframe"),a=G(e)?.session.ui.editZoom??1,l=Ki(e,o._width??null,t);if(a===1){if(o._width=null,r.style.width="",r.style.transform="",r.style.transformOrigin="",i)i.style.width="100%";o.viewport.style.height=""}else{let s=e.wrap.querySelector('[part="edit-column"]');if(!s)return;let c=He(s).width;if(c<=0)return;let d=c/a;if(o._width=d,r.style.width=`${d}px`,r.style.transform=`scale(${a})`,r.style.transformOrigin="top left",i)i.style.width=`${d}px`,o.viewport.style.height=`${i.offsetHeight*a}px`}if(l)l.scroller.scrollTop+=l.layoutY*(a-l.zoom);xn("overlays")}function $p(e,t=yr()){let o=G(t);if(!o)return;o.session.ui.editZoom=xo(e),nh(t)}var It=new Map,Dt=new Map;function jN(e,t=yr(),o=null){let r=G(t);if(!r)return;if(r.session.ui.editZoom=xo(e),Dt.set(t.paneId,o),It.has(t.paneId))return;It.set(t.paneId,requestAnimationFrame(()=>{It.delete(t.paneId);let i=Dt.get(t.paneId)??null;Dt.delete(t.paneId),nh(t,i)}))}function Ui(e){let t=getComputedStyle(e).getPropertyValue("--boards-inset").trim(),o=Number(t.replace(/px$/,""));return Number.isFinite(o)?o:0}function bo(e,t,o){if(!e.panzoomWrap)return;let r=e.wrap.clientWidth,i=e.wrap.clientHeight-Ui(e.panzoomWrap),a=24,l=32,s=0,{panels:c}=e;for(let ot of c)s+=ot._width||800;s+=a*Math.max(0,c.length-1)+l;let d=pe(e),y=He(e.panzoomWrap).height/d+l,b=r/s,T=i/y,k=t==="width"?b:Math.min(b,T),I=Math.min(o,Math.max(K,k));Le(e,I);let J=s*I,ee=y*I;e.panX=Math.max(0,(r-J)/2),e.panY=Math.max(0,(i-ee)/2),Us(e)}function HN({maxZoom:e=U,surface:t=yr()}={}){je("page",t),bo(t,"page",e)}var K=0.05,U=5;function Co(e){return Math.min(U,Math.max(K,e))}var Gi="page",_t=["width","page","none"];function Zi(e,t,o){let r=t[o];if(Yi(r))return r;if(Z(r)&&r>=K&&r<=U)return r;throw RangeError(`command "${e}" argument "${o}": expected ${_t.map((i)=>`"${i}"`).join(" | ")} or a number in [${K}, ${U}], got ${JSON.stringify(r)}`)}function Yi(e){return n(e)&&_t.includes(e)}var Po=new Map;function So(e){let t=G(e);if(!t)return null;let o=Br(e.paneId)?.kind==="lens"?`::${e.paneId}`:"";return`${t.id}::${t.documentPath??""}${o}`}function je(e,t){let o=So(t);if(o)Po.set(o,e)}function jS(e=yr()){let t=So(e);return(t===null?void 0:Po.get(t))??Gi}function wo(e,t=yr()){let o=e??jS(t);if(o==="none"){Us(t);return}if(Z(o)){Le(t,Co(o)),Us(t);return}bo(t,o,1)}function tL(e,t=yr()){je(e,t),wo(e,t)}function wm(e,t=yr(),o=null){if(!G(t))return;let i=Co(e),a=i/pe(t);if(je(i,t),t.panzoomWrap&&a!==1){let l=He(t.panzoomWrap),s=He(t.wrap),c=o?.clientX??s.left+s.width/2,d=o?.clientY??s.top+s.height/2;t.panX+=(c-l.left)*(1-a),t.panY+=(d-l.top)*(1-a),t.needsCenter=!1}Le(t,i),Us(t)}function HS(e){if(e.wrap.clientWidth<=0){Us(e);return}wo(jS(e),e)}function BN(e=yr()){if(je(1,e),!e.panzoomWrap)return;Le(e,1),Jt(e),Us(e)}function Eo(e,t){let o=He(Mo(e)??e.wrap),r=t.top+t.height/2-o.top;return o.height/2-r}function Mo(e){return Pw(e)?.scrollContainer??null}function Xi(e,t,o){let r=Mo(e);if(!r){Oo(e,t);return}let i=r.scrollTop-t;if(o){r.scrollTo({behavior:"smooth",top:i});return}r.scrollTop=i}function BS(e,t=yr()){Xi(t,Eo(t,e),!1)}function No(e,t=yr()){let o=He(t.wrap);if(e.top>=o.top&&e.top+e.height<=o.top+o.height)return;let r=Eo(t,e),i=Math.max(t.panY,0)-t.panY,a=Math.min(r,i);if(a!==0)t.needsCenter=!1,Oo(t,a)}function Oo(e,t){let o=e.panY,r=o+t,i=performance.now(),a=250,l=(s)=>{let c=Math.min((s-i)/250,1),d=c*(2-c);if(e.panY=o+(r-o)*d,Us(e),c<1)requestAnimationFrame(l)};requestAnimationFrame(l)}var Qi=["edit","design","preview","source","stylebook","tokens","grid","git-diff"],kt=Qi.filter((e)=>e!=="git-diff"),Fe=new Set(["edit","design"]);function ea(e){return Fe.has(e)}var nL=["edit","design","preview"];function ta(e){return nL.filter((t)=>e.capabilities.modes.includes(t))}function zN(e){return ta(e).filter((t)=>t!=="preview")}function iL(e){let t=e.session.ui.canvasMode;return ea(t)?t:null}function oL(e){return{available:e.capabilities.modes.includes("preview")&&Fe.has(e.session.ui.canvasMode),on:e.session.ui.preview===!0}}function rL(e,t,o){if(t==="preview"){if(Fe.has(e.session.ui.canvasMode))e.session.ui.preview=!0;return}if(e.session.ui.preview=!1,e.session.ui.canvasMode!==t)o(e,t)}var ho=new Set(["design","stylebook","git-diff"]),A=(e)=>e.document.open,yo=["auto","light","dark"];function na(e){function t(l){let s=u.value;if(!s)throw RangeError(`command "${l}" needs an open document; no tab is active`);return s}function o(l,s){let{pane:c}=s;if(c===void 0)return t(l);let d=St(l,s,"pane"),f=vt(d);if(!f)throw RangeError(`command "${l}" argument "pane": "${d}" has no open document`);return f}let r={pane:We("Which pane to render this way. Defaults to the focused one.")};function i(l){e.renderPane(a(l))}function a(l){let{pane:s}=l;return n(s)?s:m.activePaneId}return[{args:Se({mode:di(kt,"The canvas mode to switch the active pane to.")}),category:"View",id:"canvas.setMode",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:A,aiTool:{description:"Switch the active document's editor mode. edit and design put its element tree on the canvas, where the document tools work; preview renders it as a visitor sees it; source shows the JSON; stylebook, tokens and grid open other editors. Use it to return a document to edit or design when the tree tools are refused.",name:"set_canvas_mode",report:({after:l,args:s})=>{let c=Wn("canvas.setMode",s,"mode",kt),d=l.editor.kind==="canvas"?"the document tools address its element tree":"the tree-editing tools are unavailable until it returns to edit or design";return`The active document is in ${c} mode; ${d}.`}},run:(l,s)=>{let c=Wn("canvas.setMode",s,"mode",kt),d=t("canvas.setMode"),{modes:f}=d.capabilities;if(!f.includes(c))throw RangeError(`command "canvas.setMode" argument "mode": "${c}" is not a mode this document `+`supports — it declares: ${f.join(", ")}`);if(c==="preview"){let g=d.session.ui.canvasMode;if(!Fe.has(g))throw RangeError(`command "canvas.setMode" argument "mode": "preview" composes with the edit and design base modes; this pane is in "${g}"`);d.session.ui.preview=!0;return}d.session.ui.preview=!1,e.setCanvasMode(d,c)},title:"Set Canvas Mode"},{args:Se({zoom:A$("Pan-zoom scale, 1 = 100%.",{maximum:U,minimum:K})}),category:"View",id:"canvas.setZoom",level:"document",menus:["palette"],group:"3_canvas",requires:"a document on the pan-zoom surface",when:A,enablement:()=>ho.has(e.getCanvasMode()),run:(l,s)=>{t("canvas.setZoom"),wm(Nx("canvas.setZoom",s,"zoom",K,U))},title:"Set Zoom"},{args:Se({fit:{description:'How the document is framed: "width" | "page" | "none", or a numeric pan-zoom scale.',oneOf:[{enum:[..._t],type:"string"},{maximum:U,minimum:K,type:"number"}]}}),category:"View",id:"canvas.setFit",level:"document",menus:["palette"],group:"3_canvas",requires:"a document on the pan-zoom surface",when:A,enablement:()=>ho.has(e.getCanvasMode()),run:(l,s)=>{t("canvas.setFit"),tL(Zi("canvas.setFit",s,"fit"))},title:"Set Fit"},{args:Se({zoom:A$("Edit-mode content zoom, 1 = 100%.",{maximum:Lt,minimum:Ht})}),category:"View",id:"canvas.setEditZoom",level:"document",menus:["palette"],group:"3_canvas",requires:"a document in edit mode",when:A,enablement:()=>e.getCanvasMode()==="edit",run:(l,s)=>{t("canvas.setEditZoom"),$p(Nx("canvas.setEditZoom",s,"zoom",Ht,Lt))},title:"Set Edit Zoom"},{args:{additionalProperties:!1,properties:{...r,width:{description:"How wide the Edit column should render, in CSS pixels, or null to go back to the chosen breakpoint's own width.",type:["number","null"]}},required:["width"],type:"object"},category:"View",id:"canvas.setEditWidth",level:"document",menus:["palette"],group:"3_canvas",requires:"a document in edit mode",when:A,enablement:()=>e.getCanvasMode()==="edit",run:(l,s)=>{let c=o("canvas.setEditWidth",s),{width:d}=s;if(d===null){MS(a(s)),i(s);return}PS(a(s),c,Nx("canvas.setEditWidth",s,"width",vm,1e4)),i(s)},title:"Set Edit Width"},{args:{additionalProperties:!1,properties:{...r,media:{description:"A breakpoint key the document renders under, or null for the base rendering.",type:["string","null"]}},required:["media"],type:"object"},category:"View",id:"canvas.setBreakpoint",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:A,run:(l,s)=>{let c=o("canvas.setBreakpoint",s),{media:d}=s;if(d!==null&&!n(d))throw RangeError('command "canvas.setBreakpoint" argument "media": expected a breakpoint key or null');let f=Object.keys(eo(c.doc.document.$media));if(d!==null&&!f.includes(d))throw RangeError(`command "canvas.setBreakpoint" argument "media": "${d}" is not a breakpoint this `+`document defines — it defines: ${f.length>0?f.join(", "):"nothing"}`);c.session.ui.activeMedia=d,i(s)},title:"Set Breakpoint"},{args:Se({...r,scheme:di(yo,"Which color scheme the canvas renders in.")},["scheme"]),category:"View",id:"canvas.setColorScheme",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:A,run:(l,s)=>{let c=o("canvas.setColorScheme",s);c.session.ui.previewColorScheme=Wn("canvas.setColorScheme",s,"scheme",yo),i(s)},title:"Set Color Scheme"},{args:Se({...r,locale:We("BCP 47 tag this pane renders as.")},["locale"]),category:"View",id:"i18n.switchLocale",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document in a project that declares more than one locale",when:(l)=>l.document.open&&l.project.isMultilingual,run:(l,s)=>{let c=o("i18n.switchLocale",s),d=St("i18n.switchLocale",s,"locale"),f=Es();if(f===null||!f.locales.includes(d))throw RangeError(`command "i18n.switchLocale" argument "locale": "${d}" is not a locale this `+`project declares — it declares: ${f===null?"nothing":f.locales.join(", ")}`);c.session.ui.previewLocale=d,i(s)},title:"Set Rendering Language"},{args:Se({...r,visible:$o("True to draw the page's layout elements, false to hide them.")},["visible"]),category:"View",id:"canvas.setLayoutVisible",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:A,run:(l,s)=>{let c=o("canvas.setLayoutVisible",s);c.session.ui.showLayout=Bi("canvas.setLayoutVisible",s,"visible"),i(s)},title:"Show Layout Elements"},{args:Se({...r,open:$o("True to draw the popover open, false to close it."),path:{description:"Document path of the popover. Defaults to the popover the selection is in or at.",items:{type:["string","number"]},type:"array"}},[]),category:"View",enablement:()=>co(),group:"3_canvas",id:"canvas.setPopoverOpen",level:"document",menus:["palette"],requires:"a popover in the open document",run:(l,s)=>{let c=o("canvas.setPopoverOpen",s),d=s.path,f=s.open===void 0?!0:Bi("canvas.setPopoverOpen",s,"open");if(!f&&d===void 0){e.setOpenPopover(c,null);return}let g=lo(c,d);if(g===null)throw RangeError('command "canvas.setPopoverOpen" argument "path": names no popover in this document — '+"a popover is an element with a `popover` attribute, and <dialog> is not one");e.setOpenPopover(c,f?g:null)},title:"Show Popover",when:A},{args:Se({...r,open:$o("True to draw the dialog open, false to close it."),path:{description:"Document path of the dialog. Defaults to the dialog the selection is in or at.",items:{type:["string","number"]},type:"array"}},[]),category:"View",enablement:()=>mo(),group:"3_canvas",id:"canvas.setDialogOpen",level:"document",menus:["palette"],requires:"a dialog in the open document",run:(l,s)=>{let c=o("canvas.setDialogOpen",s),d=s.path,f=s.open===void 0?!0:Bi("canvas.setDialogOpen",s,"open");if(!f&&d===void 0){e.setOpenDialog(c,null);return}let g=FS(c,d);if(g===null)throw RangeError('command "canvas.setDialogOpen" argument "path": names no dialog in this document — '+"a dialog is a <dialog> element, and a popover is not one");e.setOpenDialog(c,f?g:null)},title:"Show Dialog",when:A},{args:{additionalProperties:!1,properties:{...r,open:{default:!0,description:"True to open the resolving-with popover, false to close it.",type:"boolean"}},required:[],type:"object"},category:"View",id:"canvas.setResolvingOpen",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:A,run:(l,s)=>{o("canvas.setResolvingOpen",s);let{open:c,pane:d}=s;e.setResolvingOpen(n(d)?d:m.activePaneId,c===void 0||Bi("canvas.setResolvingOpen",s,"open"))},title:"Show Resolving Values"},{args:{additionalProperties:!1,properties:{...r,name:We("The prop's name, as the component's state declares it."),value:{description:"The test value — any JSON. Null clears it and the prop returns to its default.",type:["string","number","boolean","array","object","null"]}},required:["name"],type:"object"},category:"View",id:"canvas.setTestProp",level:"document",menus:["palette"],group:"3_canvas",requires:"an open component document",when:A,run:(l,s)=>{let c=o("canvas.setTestProp",s),d=St("canvas.setTestProp",s,"name"),f=Object.keys(c.doc.document.state??{});if(!f.includes(d))throw RangeError(`command "canvas.setTestProp" argument "name": "${d}" is not a prop this component `+`declares — it declares: ${f.length>0?f.join(", "):"nothing"}`);let{value:g}=s,y={...c.session.ui.previewProps};if(g===null||g===void 0)delete y[d];else y[d]=g;c.session.ui.previewProps=Object.keys(y).length>0?y:null,i(s)},title:"Set Test Value"},{args:{additionalProperties:!1,properties:{...r,name:We("The route parameter's name, without brackets."),value:We("The value to preview the route with. Empty clears it.")},required:["name","value"],type:"object"},category:"View",id:"canvas.setRouteParam",level:"document",menus:["palette"],group:"3_canvas",requires:"an open page with a dynamic route",when:A,run:(l,s)=>{let c=o("canvas.setRouteParam",s),d=St("canvas.setRouteParam",s,"name"),f=Oc(c.documentPath);if(!f.includes(d))throw RangeError(`command "canvas.setRouteParam" argument "name": "${d}" is not a parameter of this `+`route — it has: ${f.length>0?f.join(", "):"none"}`);c.session.ui.previewParams={...c.session.ui.previewParams,[d]:St("canvas.setRouteParam",s,"value")},i(s)},title:"Set Route Parameter"}]}function WN(e,t){e.registerAll(na(t))}function Hw(e=yr()){let t=nl(e.paneId),o=e.panels;for(let r of o){let i=r.element?.querySelector('[part="panel-header"]');if(i){let a=t===null&&r.mediaName==="base"||t===r.mediaName;i.toggleAttribute("data-active",a)}}}var L=null;function oa(e){if(L?.isConnected)return L;let t=e.createElement("div");return t.className="jx-drag-ghost",t.style.cssText="position:fixed;left:0;top:0;z-index:9999;pointer-events:none;display:none;padding:2px 8px;border-radius:4px;font-size:12px;line-height:1.4;white-space:nowrap;background:var(--accent,#3b82f6);color:var(--accent-fg,#fff);box-shadow:0 2px 8px rgba(0,0,0,0.25);transform:translate(8px,8px)",e.body.append(t),L=t,t}function sL(e,t,o,r=document){let i=oa(r);i.textContent=e,i.style.left=`${t}px`,i.style.top=`${o}px`,i.style.display="block"}function zS(e,t){if(!L||L.style.display==="none")return;L.style.left=`${e}px`,L.style.top=`${t}px`}function ih(){if(L)L.style.display="none"}var Ro=function(){if(typeof window>"u")return null;var e=new Image;return e.src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",e}();function il(e){var t=e.nativeSetDragImage;if(t&&Ro)t(Ro,0,0)}function Ao(e,t){if(e==null)return{};var o={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;o[r]=e[r]}return o}function Io(e,t){if(e==null)return{};var o,r,i=Ao(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)o=a[r],t.indexOf(o)===-1&&{}.propertyIsEnumerable.call(e,o)&&(i[o]=e[o])}return i}function qe(e,t){var o=Object.keys(e),r=Object.keys(t);if(o.length!==r.length)return!1;return o.every(function(i){return Object.is(e[i],t[i])})}function Do(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:qe,t=null;return function(o){if(t&&e(t.value,o))return t.value;return t={value:o},t.value}}var ra=["block"];function ko(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),o.push.apply(o,r)}return o}function Jo(e){for(var t=1;t<arguments.length;t++){var o=arguments[t]!=null?arguments[t]:{};t%2?ko(Object(o),!0).forEach(function(r){rl(e,r,o[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):ko(Object(o)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(o,r))})}return e}function ia(e){return{x:(e.right+e.left)/2,y:(e.bottom+e.top)/2}}function jt(e){var{client:t,borderBox:o}=e,r=o.height/4;if(t.y<=o.top+r)return"reorder-above";if(t.y>=o.bottom-r)return"reorder-below";return"make-child"}function aa(e){var{element:t,input:o,currentLevel:r,indentPerLevel:i,mode:a}=e,l={x:o.clientX,y:o.clientY},s=t.getBoundingClientRect();if(a==="standard"){var c=jt({borderBox:s,client:l});return{type:c,indentPerLevel:i,currentLevel:r}}var d=ia(s);if(a==="expanded"){var f=jt({borderBox:s,client:l});return{type:f==="reorder-above"?f:"make-child",indentPerLevel:i,currentLevel:r}}var g=i*r;if(l.x<s.left+g){if(l.y<d.y)return{type:"reorder-above",indentPerLevel:i,currentLevel:r};var y=(l.x-s.left)/i,b=Math.max(Math.floor(y),0);return{type:"reparent",desiredLevel:b,indentPerLevel:i,currentLevel:r}}return{type:jt({borderBox:s,client:l}),indentPerLevel:i,currentLevel:r}}function Ho(e,t){if(e.type!==t.type)return!1;if(e.type==="instruction-blocked"&&t.type==="instruction-blocked")return Ho(e.desired,t.desired);return qe(e,t)}var sa=Do(Ho);function la(e){var{desired:t,block:o}=e;if(o!==null&&o!==void 0&&o.includes(t.type)&&t.type!=="instruction-blocked"){var r={type:"instruction-blocked",desired:t};return r}return t}function Bw(e,t){var o=t.block,r=Io(t,ra),i=aa(r),a=la({desired:i,block:o}),l=sa(a);return Jo(Jo({},e),{},rl({},Be,l))}function Ip(e){var t;return(t=e[Be])!==null&&t!==void 0?t:null}var Be=Symbol("tree-item-instruction");var _o=`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="320" height="180" viewBox="0 0 320 180"><rect width="320" height="180" fill="#808080" fill-opacity="0.16"/><g fill="#808080" fill-opacity="0.38"><circle cx="118" cy="64" r="14"/><path d="M60 140l52-50 34 30 38-46 76 66z"/></g></svg>')}`;function ca(e){let t=e.getAttribute("src")?.trim()??"",o=e.getAttribute("srcset")?.trim()??"";if(t!==""||o!=="")return!1;return!(e.parentElement?.localName==="picture"?e.parentElement:null)?.querySelector("source[srcset]:not([srcset=''])")}function Ft(e){if(ca(e))e.setAttribute("data-jx-image-placeholder",""),e.setAttribute("src",_o);else if(e.hasAttribute("data-jx-image-placeholder")&&e.getAttribute("src")!==_o)e.removeAttribute("data-jx-image-placeholder")}function Fo(e){return e.localName==="img"}function jo(e){if(e.nodeType!==e.ELEMENT_NODE||!("querySelectorAll"in e))return[];let t=e,o=[...t.querySelectorAll("img")];return Fo(t)?[t,...o]:o}function Vo(e){for(let r of jo(e))Ft(r);let o=new(e.ownerDocument.defaultView?.MutationObserver??MutationObserver)((r)=>{for(let i of r){if(i.type==="attributes"){let{target:a}=i;if(a.nodeType===a.ELEMENT_NODE&&"localName"in a){let l=a;if(Fo(l))Ft(l)}continue}for(let a of i.addedNodes)for(let l of jo(a))Ft(l)}});return o.observe(e,{attributeFilter:["src","srcset"],attributes:!0,childList:!0,subtree:!0}),()=>o.disconnect()}async function zw(e,t=new Map){Bd(!0);try{if(!await ua(e))return Wo(e.tagName);let o=document.createElement(e.tagName);for(let i of e.props||[])if(i.default!==void 0&&i.default!=="false"&&i.default!=="''"){let a=String(i.default).replaceAll(/^'|'$/g,"");o.setAttribute(i.name,a)}let r=o;for(let[i,a]of t)r[i]=a;return Vo(o),o}catch(o){return console.warn("Component preview failed:",e.tagName,o),Wo(e.tagName)}}async function ua(e){if(e.source==="npm")return Boolean(customElements.get(e.tagName));if(e.path&&!e.path.endsWith(".json"))return!1;let t=S?.projectRoot;return await Ub(`${location.origin}/${t?`${t}/`:""}${e.path}`),!0}function Wo(e){let t=document.createElement("div");return t.style.cssText="padding:12px;border:1px dashed var(--border);border-radius:var(--radius);color:var(--fg-dim)",t.textContent=`<${e}>`,t}var da='[part="outline"]',qt='[part="row"]',pa='[part="verbs"]',ze=null;function VN(){if(ze!==null)cancelAnimationFrame(ze);for(let e of st.dndCleanups)e();st.dndCleanups=[],ze=requestAnimationFrame(()=>{ze=null;let e=Ch?.querySelector(da);if(!e)return;for(let o of e.querySelectorAll("[data-dnd-row]")){let r=o.dataset.value.split("/").map((c)=>/^\d+$/.test(c)?Math.trunc(Number(c)):c),i=Math.trunc(Number(o.dataset.dndDepth))||0,a=Object.hasOwn(o.dataset,"dndVoid"),l=Object.hasOwn(o.dataset,"dndExpanded"),s=Wr(Vr({canDrag({element:c,input:d}){if(rx(d.clientX,d.clientY)?.closest(pa))return!1;return!0},element:o,getInitialData(){return{path:r,type:"tree-node"}},onGenerateDragPreview({nativeSetDragImage:c}){il({nativeSetDragImage:c})},onDragStart(){if(o.dataset.dragging="",st.layerDragSourceHeight=o.offsetHeight,l)fa(o,e)},onDrop(){if(delete o.dataset.dragging,l)xn("leftPanel")}}),qs({element:o,canDrop({source:c}){let d=c.data.path;if(Array.isArray(d)&&ec(d,r))return!1;return!0},getData({input:c,element:d}){return Bw({path:r},{block:a?["make-child"]:[],currentLevel:i,element:d,indentPerLevel:16,input:c,mode:l?"expanded":"standard"})},onDragEnter({self:c}){Bo(o,c.data,e)},onDrag({self:c}){Bo(o,c.data,e)},onDrop(){fe(e)}}));st.dndCleanups.push(s)}let t=Gs({onDrop({source:o,location:r}){fe(e);let[i]=r.current.dropTargets;if(!i)return;let a=Ip(i.data);if(!a||a.type==="instruction-blocked")return;let l=o.data,s=i.data.path;if(!Array.isArray(s))return;let c=l.type==="tree-node"&&o.element,d=c&&Object.hasOwn(c.dataset,"dndExpanded");if(Eb(u.value,a,l,s),d){let f=u.value,g=Me(f?.session.selection);if(g)st._layersCollapsed||=new Set,st._layersCollapsed.add(g.join("/"))}},onDropTargetChange({location:o}){let[r]=o.current.dropTargets;if(r&&!Ip(r.data))fe(e)}});st.dndCleanups.push(t)})}function UN(){requestAnimationFrame(()=>{let e=Ch?.querySelector(".components-section");if(!e)return;for(let t of e.querySelectorAll("[data-component-tag]")){let o=t.dataset.componentTag;if(!o)continue;let r=Ne.find((s)=>s.tagName===o);if(!r)continue;let i=t.querySelector(".element-card-preview");if(i&&!i.querySelector(o))zw(r).then((s)=>{i.textContent="",i.append(s)});let a=jc(r),l=Vr({element:t,getInitialData(){return{fragment:structuredClone(a),type:"block"}},onGenerateDragPreview({nativeSetDragImage:s}){il({nativeSetDragImage:s})}});st.dndCleanups.push(l)}})}function qN(){requestAnimationFrame(()=>{let e=Ch?.querySelector('[part="content"]');if(!e)return;for(let t of e.querySelectorAll("[data-block-tag]")){let o=t.dataset.blockTag,r=t.querySelector(".element-card-preview");if(r&&!r.firstChild){let l=document.createElement(Bn.has(o)?"span":o);l.textContent=o,r.append(l)}let i=th(o),a=Vr({element:t,getInitialData(){return{fragment:structuredClone(i),type:"block"}},onGenerateDragPreview({nativeSetDragImage:l}){il({nativeSetDragImage:l})}});st.dndCleanups.push(a)}})}function fa(e,t){let o=`${e.dataset.value}/`,r=t.querySelectorAll(qt);for(let i of r)if(i.dataset.value?.startsWith(o))i.style.display="none"}function Bo(e,t,o){let r=Ip(t);if(st._currentDropTargetRow&&st._currentDropTargetRow!==e)delete st._currentDropTargetRow.dataset.drop;if(!r||r.type==="instruction-blocked"){fe(o);return}if(r.type==="make-child"){fe(o),e.dataset.drop="",st._currentDropTargetRow=e;return}delete e.dataset.drop,st._currentDropTargetRow=e;let i=[...o.querySelectorAll(qt)],a=i.indexOf(e),l=st.layerDragSourceHeight;for(let[s,c]of i.entries()){if(c.dataset.dragging!==void 0)continue;if(r.type==="reorder-above")c.style.transform=s>=a?`translateY(${l}px)`:"";else c.style.transform=s>a?`translateY(${l}px)`:""}}function fe(e){if(st._currentDropTargetRow)delete st._currentDropTargetRow.dataset.drop,st._currentDropTargetRow=null;let t=e.querySelectorAll(qt);for(let o of t)o.style.transform="",o.style.display=""}function zo(e,t,o){if(t==="make-child")return{index:sr(oe(e,o)).length,parent:o};let r=At(o),i=hi(o);if(!r||!Z(i))return;if(t==="reorder-above")return{index:i,parent:r};if(t==="reorder-below")return{index:i+1,parent:r};return null}function Eb(e,t,o,r){if(!e)return;if(o.type==="tree-node"){let i=o.path,a=zo(e.doc.document,t.type,r);if(a)Y(e,(l)=>Yc(l,i,a.parent,a.index))}else if(o.type==="block"){let i=zo(e.doc.document,t.type,r);if(i===void 0)return;let a=o.fragment;if(i)Y(e,(l)=>{Lo(l,i.parent,i.index,structuredClone(a)),Ep(l,a.tagName),l.session.selection=[[...i.parent,"children",i.index]]})}}function Ko(e){let t={};for(let[o,r]of Object.entries(e?.nesting??{}))if(o!=="_root")t[o]=r?.inline===!0;for(let o of e?.inline??[])t[o]=!1;return t}function j(e){return JSON.parse(JSON.stringify(e))}var Qe=new WeakMap,x=new Set,Q=0,ve=new Map,lr=-1,cr=0,ma=600;function aL(e){return lr===e&&Date.now()-cr<=ma}var Go=0,ur=new Set;function ga(e,t){let o;try{o=new URL(e,t.iframe.src||sh())}catch{return}if(!["http:","https:","mailto:","tel:"].includes(o.protocol))return;let r=o.href,i=en();if(i){i(r);return}window.open(r,"_blank","noopener,noreferrer")}function lL(e){ur.add(e)}function ha(e){return ur.delete(e)}var q=new Map,ie=new Map,ye=new Map,va=300;function cL(e,t,o,r=va){let i=null;for(let s of x){if(!s.iframe.isConnected){x.delete(s);continue}if(s.ready&&!s.stylebook&&e!==null&&s.tabId===e){i=s;break}}if(!i)return Promise.resolve(null);Go+=1;let a=Go,l=j(t);return i.channel.post({contextPath:o?[...o]:null,exprs:l,gen:i.lastRenderedGen,kind:"evalExpr",reqId:a}),new Promise((s)=>{let c=setTimeout(()=>{q.delete(a),ie.delete(a),s(null)},r);ie.set(a,i),q.set(a,(d)=>{clearTimeout(c),ie.delete(a),s(d)})})}var Zo=0,se=new Map,ya=250;function dL(e,t=ya){let o=[];for(let r of x){if(!r.iframe.isConnected){x.delete(r);continue}if(r.ready&&!r.stylebook&&e!==null&&r.tabId===e)o.push(r)}if(o.length===0)return Promise.resolve();return new Promise((r)=>{let i=o.length,a=setTimeout(()=>{for(let c of s)se.delete(c),ye.delete(c);r()},t),l=()=>{if(i-=1,i===0)clearTimeout(a),r()},s=[];for(let c of o){Zo+=1;let d=Zo;s.push(d),se.set(d,l),ye.set(d,c),c.channel.post({kind:"flushEdits",reqId:d})}})}function WS(e){return Qe.get(e)??null}function Tb(e){for(let t of x){if(!t.iframe.isConnected)continue;let o=He(t.iframe);if(e.x>=o.left&&e.x<=o.right&&e.y>=o.top&&e.y<=o.bottom)return t}return null}function Lb(e,t,o){Q+=1,ve.set(Q,o);let r=t.type==="tree-node"?{path:[...t.path],type:"tree-node"}:{type:t.type};return e.channel.post({dragSeq:Q,gen:e.lastRenderedGen,kind:"dragStart",src:r}),Q}function VS(){return Q}function Ul(e){let t=He(e.iframe),o=e.iframe.clientWidth>0?t.width/e.iframe.clientWidth:1;return{rect:t,scale:o}}function dr(e){if(e.stylebook)return"stylebook";return e.tabId??"unbound"}function uL(){let e=[];for(let t of x){if(!t.iframe.isConnected){x.delete(t);continue}let o=`canvas[${dr(t)}]`;if(!t.ready){e.push(`${o}: frame has not handshaked`);continue}let r=[...t.pendingTabIds.keys()];if(r.length>0)e.push(`${o}: gen ${r.join(", ")} unacked`);if(t.pendingPatches>0)e.push(`${o}: ${t.pendingPatches} unacked patch(es)`);if(t.pendingMeasures.size>0)e.push(`${o}: ${t.pendingMeasures.size} measure(s) in flight`);let{idle:i}=t;if(!i){e.push(`${o}: no quiescence report yet`);continue}if(i.gen!==t.lastRenderedGen)e.push(`${o}: quiescence is for gen ${i.gen}, DOM is gen ${t.lastRenderedGen}`);if(!i.fonts)e.push(`${o}: fonts still loading`);if(i.animations>0)e.push(`${o}: ${i.animations} running animation(s)`);if(i.images>0)e.push(`${o}: ${i.images} pending image retry(ies)`)}if(q.size>0)e.push(`canvas: ${q.size} expression eval(s) in flight`);return e}var xa=500,ba=2,Ca=40;function pr(){let e=u.value?.id??null,t=null;for(let o of x){if(!o.iframe.isConnected){x.delete(o);continue}if(!o.ready||o.stylebook)continue;if(o.tabId===e)return o;t??=o}return t}function fr(e,t){let{rect:o,scale:r}=Ul(e),i=o.left+t.x*r,a=o.top+t.y*r,l=t.width*r,s=t.height*r;return{height:s,left:i,top:a,width:l,x:i+l/2,y:a+s/2}}function xe(e,t){return new Promise((o)=>{e.measureSeq+=1;let r=e.measureSeq,i=setTimeout(()=>{e.pendingMeasures.delete(r),o(null)},xa);e.pendingMeasures.set(r,(a)=>{clearTimeout(i);let[l]=a;o(l?fr(e,l.rect):null)}),e.channel.post({kind:"measure",paths:[[...t]],reqId:r})})}function hL(e){let t=WS(e),o=t?.lastHover;if(!t||!o)return null;return{settle:async()=>(await xe(t,o.path))?.top??null,top:fr(t,o.rect).top}}function pL(e){let t=pr();return t?xe(t,e):Promise.resolve(null)}function Pa(e){return new Promise((t)=>{let o=Number.NaN,r=0,i=0,a=()=>{let{top:l}=He(e.iframe);if(r=l===o?r+1:0,o=l,i+=1,r>=ba||i>=Ca){t();return}requestAnimationFrame(a)};requestAnimationFrame(a)})}async function $b(e){let t=pr();return t?D2(t,e):null}async function D2(e,t){let o=await xe(e,t);if(!o)return null;let r=W(e.canvasEl)?.surface;return BS({height:o.height,top:o.top},r),await Pa(e),xe(e,t)}function Q2(e,t){let o=WS(e);return o?xe(o,t):Promise.resolve(null)}function Sa(e){let t=e.canvasEl.parentElement;if(!t)return;let o=/scale\(([\d.]+)\)/.exec(e.canvasEl.style.transform),r=o?Number(o[1]):1;t.style.height=r===1?"":`${e.iframe.offsetHeight*r}px`}function mr(e){if(e.preview){e.iframe.style.height="100%",e.iframe.style.minHeight="0px";return}if(e.contentHeight===null)return;e.iframe.style.height=`${e.contentHeight}px`,e.iframe.style.minHeight=e.contentFragment?"0px":"480px",Sa(e)}function Ut(e,t){if(e.preview=t,e.overlay.setSuppressed(t),t)e.pendingEnterEdit=null;mr(e)}function fL(e,t){Ut(Zt(e),t)}function Fc(e,t){if(!e.iframe.isConnected)return;e.channel.post(t)}function Ww(e){ve.delete(e)}function Vw(e){e.overlay.setDropIndicator(null)}var gr=null;function mL(e){gr=e}var wa=300,hr=null;function gL(e){hr=e}var Gt=null;function bL(e){Gt=e}function Ea(e,t,o){if((t?Ma(t.tagName):!1)&&t){e.overlay.setDropIndicator(null),e.overlay.setReplaceTarget(R(t.rect));return}e.overlay.setReplaceTarget(null),e.overlay.setDropIndicator(o?R(o.referenceRect):null,o?.edge)}function Xo(e){e.overlay.setReplaceTarget(null),e.overlay.setDropIndicator(null)}function Ma(e){return e==="img"||e==="video"||e==="source"}function Na(e,t){if(e.dataset.jxGutterDrop==="1")return;e.dataset.jxGutterDrop="1",e.addEventListener("dragover",(o)=>{if(![...o.dataTransfer?.types??[]].includes("Files"))return;if(o.preventDefault(),o.dataTransfer)o.dataTransfer.dropEffect="copy"}),e.addEventListener("drop",(o)=>{let r=o.dataTransfer?.files,i=t();if(!r?.length||!i||i.stylebook)return;o.preventDefault(),Gt?.(E(i),[...r],null,null)})}var Ge=null;function vL(e){Ge=e}var Ze=null;function yL(e){Ze=e}var vr=null;function wL(e){vr=e}function Qo(e,t){let o=[...t];for(;;){let r=e.get(Pc(o));if(r)return r;if(o.length<2)return null;o=o.slice(0,-2)}}var N=null;function xL(){let e=N;return Boolean(e?.editing&&e.iframe.isConnected)}var Ye=null;function _L(e){Ye=e}var Kt=null;function SL(e){Kt=e}var er=null,xr=null;function CL(e){xr=e}function kL(e,t){for(let o of x){if(!o.iframe.isConnected){x.delete(o);continue}if(o.ready&&o.tabId===e.id&&!o.preview)o.popoverOpen=t,o.channel.post({kind:"setPopoverOpen",path:t})}}function EL(e,t){for(let o of x){if(!o.iframe.isConnected){x.delete(o);continue}if(o.ready&&o.tabId===e.id&&!o.preview)o.dialogOpen=t,o.channel.post({kind:"setDialogOpen",path:t})}}function US(e,t){let o=0;for(let r of x){if(!r.iframe.isConnected){x.delete(r);continue}if(r.ready&&r.tabId===t){let i=W(r.canvasEl)?.surface;if(!i){Ow("host-stage-unresolved");continue}let a=i.renderGeneration,l=et?.host===r?et.paths:void 0;tt(r),r.channel.post(l?{echoPaths:l,forwardOps:e,gen:a,kind:"patch"}:{forwardOps:e,gen:a,kind:"patch"}),r.pendingPatches+=1,o+=1}}return o}var et=null,Oa=0;function tr(e,t,o){et={host:e,paths:t};try{o()}finally{et=null}}var Wt=null,Bt=null;function Ra(e,t,o){return!e&&t===o}function Aa(e,t){let o=E(e);if(!o)return;let r=oe(o.doc.document,t);if(!r)return;US([{key:"$props",op:"set-key",path:t,value:r.$props}],o.id)}function E(e){return e.tabId?m.tabs.get(e.tabId)??null:null}function TL(e){return E(e)}function Ke(e){let t=W(e.canvasEl)?.surface.paneId;if(t)Er(t)}var $a=Object.freeze([]);function Ia(){let e=new Map;for(let t of m.panes){let o=t.activeTabId?m.tabs.get(t.activeTabId):null;if(!o)continue;let r=o.session.selection;r.map((i)=>i.join("/")).join("|"),e.set(o.id,r)}return e}function Da(){if(er)return;let e=ge(!0);e.run(()=>{ne(()=>{let t=Ia();h.stylebook.selection;for(let o of x)nt(o,(o.tabId?t.get(o.tabId):null)??$a)})}),er={stop:()=>e.stop()}}function tt(e){if(!e.ready)return;let t=fh();if(t===e.postedVersions)return;if(e.postedVersions===null&&Object.keys(t).length===0){e.postedVersions=t;return}e.postedVersions=t,e.channel.post({kind:"assetVersions",versions:t})}var nr=!1,zt=!1;function ka(){if(nr)return;nr=!0,ge(!0).run(()=>{ne(()=>{if(E$.value,zt)return;zt=!0,queueMicrotask(()=>{zt=!1,Ja()})})})}function Ja(){for(let e of x){if(!e.iframe.isConnected){x.delete(e);continue}tt(e)}}var or=!1,Ue=null;function Ha(){if(or)return;or=!0,ge(!0).run(()=>{ne(()=>{for(let t of m.panes){let o=t.activeTabId?m.tabs.get(t.activeTabId):null;if(!o)continue;let{peers:r}=Tn(o);r.map((i)=>JSON.stringify(i.state.structuralSelection??null)).join("|")}if(Ue)clearTimeout(Ue);Ue=setTimeout(()=>{Ue=null;for(let t of x)br(t)},100)})})}function br(e){if(e.stylebook||!e.ready||!e.iframe.isConnected)return;let t=E(e),o=t?Tn(t).peers:[];e.presenceMeta.clear();let r=[];for(let i of o){let{structuralSelection:a}=i.state;if(!a||i.state.focusedPath!==t?.documentPath)continue;for(let l of a){let s=[...l];r.push(s),e.presenceMeta.set(JSON.stringify(s),{color:i.state.user.color,label:i.state.user.name??i.state.user.login})}}if(r.length===0){e.presenceReqId=-1,e.overlay.setPresence([]);return}e.measureSeq+=1,e.presenceReqId=e.measureSeq,e.channel.post({kind:"measure",paths:r,reqId:e.presenceReqId})}function nt(e,t){if(e.stylebook){La(e);return}let o=Me(t);if(e.selectionPath=o,e.selectionPaths=t,!e.iframe.isConnected){x.delete(e);return}if(!o){e.selReqId=-1,e.coSelectionKeys.clear(),e.overlay.setSelection(null),e.overlay.setCoSelection([]);return}if(!e.ready)return;let r=Qs(t.slice(0,-1));e.coSelectionKeys=new Set(r.map((i)=>JSON.stringify(i))),e.measureSeq+=1,e.selReqId=e.measureSeq,e.channel.post({kind:"measure",paths:[[...o],...r],reqId:e.selReqId})}function La(e){if(!e.iframe.isConnected){x.delete(e);return}let t=h.stylebook.selection,o=t?e.stylebook?.tagToCardPath.get(t):void 0;if(!t||!o){e.selReqId=-1,e.overlay.setSelection(null);return}if(!e.ready)return;e.measureSeq+=1,e.selReqId=e.measureSeq,e.channel.post({kind:"measure",paths:[[...o]],reqId:e.selReqId})}function rr(){return Kx("../canvas.html")}function Cr(e){e.channel.dispose();for(let[t,o]of q)if(ie.get(t)===e)q.delete(t),ie.delete(t),o(null);for(let[t,o]of se)if(ye.get(t)===e)se.delete(t),ye.delete(t),o();for(let[,t]of e.pendingMeasures)t([]);if(e.pendingMeasures.clear(),e.pendingTabIds.clear(),be(e),N===e)N=null;e.overlay.root.remove(),e.iframe.remove(),Qe.delete(e.canvasEl),x.delete(e)}function _a(){if(!_e())return rr();return p().canvasUrl||rr()}function Ib(e){let t=0;for(let o of new Set(x))if(e.contains(o.canvasEl))Cr(o),t+=1;return t}function Zt(e){let t=_a(),o=Qe.get(e);if(o){if(o.canvasUrl===t)return o;Cr(o)}let r=location.origin,i=crypto.randomUUID(),a=new URL(t,location.href).origin,l=document.createElement("iframe");l.className="jx-canvas-iframe",l.title="Canvas — live page render",l.style.cssText="width:100%;min-height:480px;height:100%;border:0;display:block;background:#fff";let s=new URL(t,location.href);if(s.searchParams.set("token",i),location.protocol==="http:"||location.protocol==="https:")s.searchParams.set("parentOrigin",r);if(l.src=a===r?`${s.pathname}${s.search}`:s.href,!e.style.position)e.style.position="relative";let c=oo(document);e.replaceChildren(l,c.root),Na(e,()=>WS(e));let d=Qt({acceptOrigin:a,source:window,target:{postMessage:(g,y)=>l.contentWindow?.postMessage(g,y)},targetOrigin:a,token:i}),f={canvasEl:e,canvasUrl:t,channel:d,contentFragment:!1,contentHeight:null,hiddenPaths:new Set,popoverOpen:null,dialogOpen:null,editing:!1,editingProp:null,iframe:l,insertHideTimer:null,insertHover:!1,coSelectionKeys:new Set,insertZone:null,lastRenderedGen:-1,lastHover:null,lastSelectionRect:null,lastSnapshotSeq:0,measureSeq:0,overlay:c,panReqId:-1,pending:null,postedVersions:null,idle:null,pendingEnterEdit:null,pendingMeasures:new Map,pendingPatches:0,pendingTabIds:new Map,presenceMeta:new Map,presenceReqId:-1,preview:!1,ready:!1,selectionPath:null,selectionPaths:[],selReqId:-1,snapshot:null,stylebook:null,tabId:null};return c.insertButton.addEventListener("click",(g)=>Va(f,g)),c.insertButton.addEventListener("mouseenter",()=>{f.insertHover=!0,be(f)}),c.insertButton.addEventListener("mouseleave",()=>{f.insertHover=!1,Mr(f)}),d.onMessage((g)=>Wa(f,g)),Qe.set(e,f),x.add(f),Da(),Ha(),ka(),f}function ja(e,t){be(e),e.insertZone=t,e.overlay.setInsertZone(R(t.rect),t.edge)}function Pr(e){be(e),e.insertZone=null,e.insertHover=!1,e.overlay.setInsertZone(null)}function Fa(e){let t=e.overlay.insertButton;return e.insertHover||t.matches(":hover")}function Mr(e){be(e),e.insertHideTimer=setTimeout(()=>{if(e.insertHideTimer=null,Fa(e))return;Pr(e)},wa)}function be(e){if(e.insertHideTimer!==null)clearTimeout(e.insertHideTimer),e.insertHideTimer=null}function Va(e,t){t.stopPropagation(),t.preventDefault();let o=e.insertZone;if(!o)return;hr?.(e.overlay.insertButton,o)}var qa=new Set(["contextMenu","dragOver","dropResult","editCommit","editCommitProp","editInput","editInsert","editMerge","editRangeReplace","editSplit","editStart","fileDragOver","fileDrop","hit","hover","insertZones","layoutHit","nativeDragEnter"]);function Wa(e,t){if(e.preview&&qa.has(t.kind))return;switch(t.kind){case"ready":{e.ready=!0;let o=Yt?.();if(o)e.channel.post({chords:o.chords,kind:"keymap",mac:o.mac});if(e.postedVersions=null,tt(e),e.pending)e.channel.post(e.pending),e.pending=null;nt(e,e.selectionPaths);return}case"paneFocus":{Ke(e),Kt?.();return}case"popoverTargetClick":{let o=E(e);if(!o||e.preview)return;let r=JSON.stringify(o.session.ui.openPopover)===JSON.stringify(t.targetPath),i=t.action==="show"||t.action==="toggle"&&!r;if(i||r)ae()?.run("canvas.setPopoverOpen",{open:i,path:t.targetPath});return}case"commandTargetClick":{let o=E(e);if(!o||e.preview)return;let r=(a)=>JSON.stringify(a)===JSON.stringify(t.targetPath),i=oe(o.doc.document,t.targetPath);if(!qn(i))return;if($t.has(t.command)){if(!Ta(i))return;let a=t.command==="show-popover"||t.command==="toggle-popover"&&!r(o.session.ui.openPopover);if(a||r(o.session.ui.openPopover))ae()?.run("canvas.setPopoverOpen",{open:a,path:t.targetPath})}else if(Rt.has(t.command)){if(!H(i))return;let a=t.command==="show-modal";if(a||r(o.session.ui.openDialog))ae()?.run("canvas.setDialogOpen",{open:a,path:t.targetPath})}return}case"hit":{Ke(e),Kt?.(),KL(null);let o=null,r=W(e.canvasEl)?.panel;if(r?.mediaName&&!r.mediaName.startsWith("git-diff")){o=ke(r.mediaName);let a=E(e);if(a)a.session.ui.activeMedia=o}if(Ze?.dismiss(),e.stylebook){let a=Qo(e.stylebook.pathToTag,t.hit.path);if(vr?.(a,o),a){let l=R(t.hit.rect);e.overlay.setSelection(l,`<${a}>`),e.lastSelectionRect=l}else e.overlay.setSelection(null);return}e.selectionPath=t.hit.path,e.selectionPaths=[t.hit.path];let i=E(e);if(i)i.session.selection=t.additive?kx(i.session.selection,t.hit.path):[t.hit.path];{let a=R(t.hit.rect);e.overlay.setSelection(a),e.lastSelectionRect=a}return}case"layoutHit":{if(e.stylebook)return;Ke(e),Ze?.dismiss(),KL(t.hit),e.selectionPath=null,e.selectionPaths=[];let o=E(e);if(o)o.session.selection=[];let r=R(t.hit.rect);e.overlay.setSelection(r,`LAYOUT · ${t.hit.layoutFile}`),e.lastSelectionRect=r,xn("rightPanel");return}case"hover":{if(e.stylebook){let o=t.hit?Qo(e.stylebook.pathToTag,t.hit.path):null,r=h.stylebook.selection;if(t.hit&&o&&o!==r)e.overlay.setHover(R(t.hit.rect));else e.overlay.setHover(null);return}e.lastHover=t.hit,Ua(e,t.hit);return}case"insertZones":{if(e.stylebook)return;let o=t.zones?.[0]??null;if(o)ja(e,o);else Mr(e);return}case"geometry":{let o=e.pendingMeasures.get(t.reqId);if(o){e.pendingMeasures.delete(t.reqId),o(t.hits);return}if(t.reqId===e.presenceReqId){e.presenceReqId=-1;let r=[];for(let i of t.hits){let a=e.presenceMeta.get(JSON.stringify(i.path));if(a)r.push({...a,placement:R(i.rect)})}e.overlay.setPresence(r);return}if(t.reqId===e.panReqId){e.panReqId=-1;let[r]=t.hits;if(r){let{rect:i,scale:a}=Ul(e);No({height:r.rect.height*a,top:r.rect.y*a+i.top})}return}if(t.reqId===e.selReqId){let r=JSON.stringify(e.selectionPath),i=[],a=null;if(e.stylebook){let[s]=t.hits;a=s?R(s.rect):null}else for(let s of t.hits){let c=JSON.stringify(s.path);if(c===r)a=R(s.rect);else if(e.coSelectionKeys.has(c))i.push(R(s.rect))}let l=e.stylebook?h.stylebook.selection:null;e.overlay.setSelection(a,l?`<${l}>`:null),e.overlay.setCoSelection(i),e.lastSelectionRect=a,e.hiddenPaths=new Set((t.hidden??[]).map((s)=>JSON.stringify(s)))}return}case"evalResult":{let o=q.get(t.reqId);if(!o)return;q.delete(t.reqId),ie.delete(t.reqId),o(t.gen===e.lastRenderedGen?t.results:null);return}case"renderComplete":{if(e.pendingTabIds.has(t.gen))e.tabId=e.pendingTabIds.get(t.gen)??null;for(let o of e.pendingTabIds.keys())if(o<=t.gen)e.pendingTabIds.delete(o);ir(e,t.gen);return}case"patchComplete":{e.pendingPatches=Math.max(0,e.pendingPatches-1),ir(e,t.gen);return}case"idle":{e.idle={animations:t.animations,fonts:t.fonts,gen:t.gen,images:t.images};return}case"renderError":{e.pendingTabIds.delete(t.gen);let o=E(e);if(o)o.session.canvas.refreshing=!1,xn("leftPanel");C.error("The page could not be rendered.",{detail:t.message,key:`canvas.render:${dr(e)}`,source:"Canvas"});return}case"dataScope":{if(t.gen!==e.lastRenderedGen)return;let o=E(e);if(o)o.session.canvas.scope=t.scope,o.session.canvas.refreshing=!1;xn("leftPanel");return}case"contentHeight":{e.contentHeight=t.height,e.contentFragment=t.fragment,mr(e);return}case"dragOver":{if(t.dragSeq!==Q)return;if(t.cursor)lr=t.dragSeq,cr=Date.now();if(t.gen!==e.lastRenderedGen)return;if(t.preview)e.overlay.setDropIndicator(R(t.preview.referenceRect),t.preview.edge);else e.overlay.setDropIndicator(null);if(t.cursor){let o=Ul(e);zS(t.cursor.x*o.scale+o.rect.left,t.cursor.y*o.scale+o.rect.top)}return}case"nativeDragEnter":{if(e.stylebook)return;gr?.(e);return}case"dragEnd":{e.overlay.setDropIndicator(null),ih(),ve.delete(t.dragSeq);return}case"dropResult":{if(t.dragSeq!==Q||t.gen!==e.lastRenderedGen)return;if(t.instruction&&t.targetPath){let o=ve.get(t.dragSeq);if(o)Eb(E(e),{type:t.instruction},o,t.targetPath)}ve.delete(t.dragSeq),e.overlay.setDropIndicator(null),ih();return}case"fileDragOver":{if(e.stylebook)return;Ea(e,t.hit,t.preview);return}case"fileDragLeave":{Xo(e);return}case"fileDrop":{if(Xo(e),e.stylebook)return;Gt?.(E(e),t.files,t.hit,t.preview);return}case"patchError":{e.pendingPatches=Math.max(0,e.pendingPatches-1);let o=W(e.canvasEl)?.surface;if(o)xr?.(o.paneId);return}case"forwardKey":{Ka(t.event);return}case"forwardWheel":{za(e,t);return}case"editStart":{if(N&&N!==e)N.editing=!1,N.editingProp=null,N.snapshot=null;if(N=e,t.prop!==void 0&&Bt===Pc(t.path))me(e,t.path,void 0,t.prop);Bt=null,Oa+=1,e.editing=!0,e.editingProp=t.prop??null,e.snapshot=null,e.lastSnapshotSeq=0,Ye?.();return}case"selectionChanged":{if(t.seq<=e.lastSnapshotSeq)return;if(e.lastSnapshotSeq=t.seq,e.snapshot=t,!e.editing)e.editing=!0,N=e;Ye?.();return}case"flushComplete":{let o=se.get(t.reqId);if(o)se.delete(t.reqId),ye.delete(t.reqId),o();return}case"editInput":{let o=E(e);if(o)o.doc.dirty=!0;return}case"editCommit":{let o=()=>Gn(E(e),t.path,t.children,t.textContent);if(t.inPlace)tr(e,[t.path],o);else o();return}case"editCommitProp":{let o=()=>Zn(E(e),t.path,t.prop,t.value);if(t.inPlace){tr(e,[t.path],o),Wt=Pc(t.path);return}let r=o();if(Ra(r,Wt,Pc(t.path)))Aa(e,t.path);Wt=null,Bt=r?Pc(t.path):null;return}case"editMerge":{let o=Yn(E(e),t.fromPath,t.intoPath);if(o)me(e,o.path,o.offset);return}case"editRangeReplace":{let o=no(E(e),t.from,t.to,t.between,t.text);if(o)me(e,o.path,o.offset);return}case"editSplit":{me(e,Qn(E(e),t.path,t.before,t.after));return}case"editInsert":{me(e,to(E(e),t.path,t.cmd,t.commitData));return}case"slashShow":{let{rect:o,scale:r}=Ul(e),i=t.rect.x*r+o.left,a=t.rect.y*r+o.top,l={filter:t.filter,onDismiss:()=>e.channel.post({kind:"slashDismissed"}),onSelect:(s)=>e.channel.post({cmd:{...s},kind:"slashSelect"}),rect:{bottom:a+t.rect.height*r,height:t.rect.height*r,left:i,top:a,width:t.rect.width*r}};if(t.showFilter===!0)l.showFilter=!0;Ge?.show(l);return}case"slashNav":{Ge?.nav(t.key);return}case"slashDismiss":{Ge?.dismiss();return}case"previewNavigate":{ga(t.href,e);return}case"contextMenu":{if(e.stylebook)return;Ke(e);let{rect:o,scale:r}=Ul(e);Ze?.show({clientX:t.x*r+o.left,clientY:t.y*r+o.top,path:t.path?[...t.path]:null});return}case"editEnd":{if(!e.editing)return;if(e.editing=!1,e.editingProp=null,e.snapshot=null,N===e)N=null;Ye?.();break}default:break}}function ir(e,t){if(e.lastRenderedGen=t,nt(e,e.selectionPaths),br(e),Pr(e),Xa(e),e.pendingEnterEdit&&t>=e.pendingEnterEdit.minGen){let{offset:o,path:r,prop:i}=e.pendingEnterEdit;if(e.pendingEnterEdit=null,e.tabId!==null&&e.tabId===ce(e.canvasEl)?.id)Ba(e,r,o,i)}}function me(e,t,o,r){let i={minGen:e.lastRenderedGen,path:[...t]};if(o!==void 0)i.offset=o;if(r!==void 0)i.prop=r;e.pendingEnterEdit=i}function Ba(e,t,o,r){let i={kind:"enterEdit",path:[...t]};if(o!==void 0)i.offset=o;if(r!==void 0)i.prop=r;e.channel.post(i)}function za(e,t){let{rect:o,scale:r}=Ul(e),i=Qc(e.canvasEl)?.wrap;if(!i)return;i.dispatchEvent(new WheelEvent("wheel",{bubbles:!0,cancelable:!0,clientX:o.left+t.x*r,clientY:o.top+t.y*r,ctrlKey:t.ctrlKey,deltaX:t.deltaX,deltaY:t.deltaY,metaKey:t.metaKey,shiftKey:t.shiftKey}))}function Ka(e){document.dispatchEvent(new KeyboardEvent("keydown",{altKey:e.altKey,bubbles:!0,cancelable:!0,code:e.code,ctrlKey:e.ctrlKey,key:e.key,metaKey:e.metaKey,shiftKey:e.shiftKey}))}function Ua(e,t){if(!t||Tr(t.path,e.selectionPath)){e.overlay.setHover(null);return}e.overlay.setHover(R(t.rect))}var Ga=4,X=new Map;function Za(e){let t=X.get(e);if(t)return X.delete(e),X.set(e,t),t;let o=new Map;X.set(e,o);for(let r of X.keys()){if(X.size<=Ga)break;X.delete(r)}return o}function Ya(e,t,o,r,i,a=null){let l=Za(e),s=r?.id??null,c=l.get(t);if(c&&c.tabId===o&&c.viewTabId===s&&c.mode===a)return c.payload;let d=ha(i),f=DS(Ln,async()=>{qo.renderPreparations+=1;let g=await kn(t,r,a),y=j(g.renderDoc),b=j(t),T=o?m.tabs.get(o)??null:null,k=zi(T?.doc.sourceFormat)?.studio?.elements,I=k?Ko(k):void 0,J={assets:g.assets,doc:y,docBase:g.docBase??`${sh()}/`,mapperCtx:g.mapperCtx,mode:g.mapperCtx.canvasMode,shadowDoc:b,siteStyle:g.siteStyle};if(I)J.editableTags=I;if(d)J.allowAutoRequests=!0;return J});return l.set(t,{mode:a,payload:f,tabId:o,viewTabId:s}),f}async function LL(e,t,o,r,i=null,a=ce(o),l=null,s=null){let c=Zt(o);c.pendingTabIds.set(e,i),c.stylebook=null,c.iframe.style.width=r?`${r}px`:"100%";let f={...await Ya(e,t,i,a,ct(o),l),colorScheme:Or(a),gen:e,kind:"render",locale:Ar(a),popoverOpen:a?.session.ui.openPopover??null,dialogOpen:a?.session.ui.openDialog??null};if(s)f.diffMarks=s;c.popoverOpen=f.popoverOpen??null,c.dialogOpen=f.dialogOpen??null,Ut(c,f.mode==="preview"),Nr(c,f)}function Nr(e,t){if(qo.hostRenderPosts+=1,e.ready){tt(e),e.channel.post(t);return}let o=e.pending;if(o?.kind==="render"&&o.gen>t.gen){e.pendingTabIds.delete(t.gen);return}e.pending=t}function $L(e,t,o,r){let i=Zt(o);i.pendingTabIds.set(e,null),i.stylebook={pathToTag:t.pathToTag,tagToCardPath:t.tagToCardPath},Ut(i,!1),i.pendingEnterEdit=null,i.iframe.style.width=r?`${r}px`:"100%";let a=j(t.doc),l=j(t.doc),s={assets:null,colorScheme:Or(ce(o)),locale:Ar(ce(o)),doc:a,docBase:`${sh()}/`,gen:e,kind:"render",mapperCtx:{arrayPaths:[],canvasMode:"stylebook",layoutWrapped:!1,pageContentOffset:null,pageContentPrefix:null},mode:"stylebook",shadowDoc:l,siteStyle:null};Nr(i,s)}function Or(e){let t=e?.session.ui.previewColorScheme;return t==="light"||t==="dark"?t:null}function IL(e,t){for(let o of x){if(!o.iframe.isConnected){x.delete(o);continue}if(t&&!t.contains(o.iframe))continue;if(o.ready)o.channel.post({kind:"setColorScheme",scheme:e})}}function Rr(e){return e===null?null:{dir:Yb(e),locale:e}}function Ar(e){return Rr(e?Rp(e.session.ui.previewLocale,e.documentPath):null)}function RL(e,t){let o=Yb(e);for(let r of x){if(!r.iframe.isConnected){x.delete(r);continue}if(t&&!t.contains(r.iframe))continue;if(r.ready)r.channel.post({dir:o,kind:"setLocale",locale:e});else if(r.pending?.kind==="render")r.pending={...r.pending,locale:Rr(e)}}}function DL(e,t){let o=j(e),r=0;for(let i of x){if(!i.iframe.isConnected){x.delete(i);continue}if(i.ready)i.channel.post({base:t,doc:o,kind:"redefineElement"}),r+=1}return r}function NL(){let e=S?.projectConfig;if(!e)return;let t=j(e.style??null),o=j(e.$media??{});for(let r of x){if(!r.iframe.isConnected){x.delete(r);continue}if(r.ready&&!r.stylebook)r.channel.post({kind:"siteStyleUpdate",media:o,siteStyle:t})}}function Uw(e){let t=0,o=j(e);for(let r of x){if(!r.iframe.isConnected){x.delete(r);continue}if(r.ready&&r.stylebook)r.channel.post({gen:r.lastRenderedGen,kind:"styleUpdate",style:o}),t+=1,nt(r,r.selectionPaths)}return t}var Xe=null;function $r(e,t){if(!e?.stylebook||!e.ready)return!1;let o=e.stylebook.tagToCardPath.get(t);if(!o)return!1;return e.measureSeq+=1,e.panReqId=e.measureSeq,e.channel.post({kind:"measure",paths:[[...o]],reqId:e.panReqId}),!0}function AL(e){Xe=$r(Xt(),e)?null:e}function Xa(e){let t=Xe;if(t===null||!e.stylebook)return;if(h.stylebook.selection!==t){Xe=null;return}if(e===Xt()&&$r(e,t))Xe=null}function ql(){let e=N;if(!e||!e.iframe.isConnected)return{editing:!1,editingProp:null,snapshot:null};return{editing:e.editing,editingProp:e.editingProp,snapshot:e.snapshot}}var Yt=null;function OL(e,t){Yt=e,t?.(()=>ar()),ar()}function ar(){let e=Yt?.();if(!e)return;for(let t of x){if(!t.iframe.isConnected){x.delete(t);continue}if(t.ready)t.channel.post({chords:e.chords,kind:"keymap",mac:e.mac})}}function oh(e){let t=N;if(!t||!t.ready)return;t.channel.post({intent:e,kind:"applyFormat"})}function ML(){let e=N;if(!e||!e.ready)return;e.channel.post({kind:"openSlash"})}function qw(){let e=N;if(e?.editing&&e.ready&&e.iframe.isConnected)e.channel.post({kind:"endEdit"})}function Xt(){let e=ao();return e?WS(e.canvas):null}function qS(){let e=N,t=e??Xt();if(!t)return null;let{rect:o,scale:r}=Ul(t);if(t.lastSelectionRect)return{height:t.lastSelectionRect.height*r,left:t.lastSelectionRect.left*r+o.left,top:t.lastSelectionRect.top*r+o.top,width:t.lastSelectionRect.width*r};let i=t===e?t.snapshot?.rect:null;if(i)return{height:i.height*r,left:i.x*r+o.left,top:i.y*r+o.top,width:i.width*r};return null}
|
|
2
|
+
export{fN,xb,yr,vt,Br,_S,Ac,Uo,nl,wr,Yu,Oc,Zu,SS,mN,CS,gN,bN,kS,vN,ES,Xu,_b,Sb,ci,gm,KT,Aw,yN,Wl,Vl,Qu,wN,TS,JT,Mc,eh,xN,Cb,kp,LS,$S,_N,IS,YT,SN,CN,qo,Ow,RS,DS,ji,th,ZT,kb,XT,kN,EN,Ep,NS,TN,LN,Pc,AS,bm,$N,Mw,IN,Pw,RN,Fw,Tp,zr,DN,vm,NN,AN,OS,ON,MS,MN,PS,QT,eL,FS,ym,Lp,PN,FN,jw,Us,nh,$p,jN,HN,jS,tL,wm,HS,BN,BS,nL,zN,iL,oL,rL,WN,Hw,sL,zS,ih,il,Bw,Ip,zw,VN,UN,qN,Eb,aL,lL,cL,dL,WS,Tb,Lb,VS,Ul,uL,hL,pL,$b,D2,Q2,fL,Fc,Ww,Vw,mL,gL,bL,vL,yL,wL,xL,_L,SL,CL,kL,EL,US,TL,Ib,LL,$L,IL,RL,DL,NL,Uw,AL,ql,OL,oh,ML,qw,qS};
|
|
3
|
+
|
|
4
|
+
//# debugId=AF2527FA80C7D62D64756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-5abge3wy.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
export{
|
|
1
|
+
var X$="content",OC=/^[\w.~-]+$/,Io="{locale}";function u(t){let n=t.replaceAll("\\","/");return n.length>1&&n.endsWith("/")?n.slice(0,-1):n}function p(t){let n=u(t);return n.startsWith("/")?n:`/${n}`}function f(t,n){return[...t].toSorted((e,s)=>s[n].length-e[n].length)}function g(t,n){return t===n||t.startsWith(`${n}/`)}function VO(t,n){let e=u(n);for(let s of f(t,"dir")){let r=u(s.dir);if(!g(e,r)||e===r)continue;let o=e.slice(r.length+1),{filter:i}=s;if(i&&!i(o))return null;let l=o.split("/").map((c)=>encodeURIComponent(c)).join("/");return`${p(s.urlPrefix)}/${l}`}return null}function h(t,n){let e=n.split("#")[0].split("?")[0];if(!e.startsWith("/"))return null;let s;try{s=decodeURIComponent(e)}catch{return null}if(/%2e|%2f/i.test(s))return null;for(let r of f(t,"urlPrefix")){let o=p(r.urlPrefix);if(!s.startsWith(`${o}/`))continue;let l=s.slice(o.length+1).split("/");if(l.some((a)=>a===""||a==="."||a===".."))return null;let{filter:c}=r;if(c&&!c(l.join("/")))return null;return`${u(r.dir)}/${l.join("/")}`}return null}var m=String.raw`"'\s<>()\\`;var MC="public";var UO=["mounts","public"];function zx(t){let n=t.search(/[#?]/);return n===-1?{path:t,suffix:""}:{path:t.slice(0,n),suffix:t.slice(n)}}function Q$(t){return t===""||t.startsWith("/")||t.startsWith("#")||t.includes("${")||/^[a-z][\w+.-]*:/i.test(t)}function Si(t){return t.replaceAll("\\","/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}function qO(t){let n=Si(t),e=n.lastIndexOf("/");return e===-1?"":n.slice(0,e)}function eI(t,n){let s=(t===""||t==="."?[]:Si(t).split("/")).filter((r)=>r!==""&&r!==".");for(let r of n.replaceAll("\\","/").split("/")){if(r===""||r===".")continue;if(r===".."){if(s.length===0)return null;s.pop();continue}s.push(r)}return s.join("/")}function d(t,n,e){let{path:s}=zx(t);if(!s.startsWith("/"))return[];let r;try{r=decodeURIComponent(s)}catch{return[]}if(/%2e|%2f/i.test(r))return[];let o=r.replace(/^\/+/,"");if(o===""||o.split("/").some((l)=>l==="."||l===".."))return[];let i=[];for(let l of e){if(l==="mounts"){let c=h(n,s);if(c!==null&&!c.startsWith("/")&&!/^[A-Za-z]:/.test(c))i.push(Si(c));continue}i.push(l==="root"?o:`${MC}/${o}`)}return[...new Set(i)]}function GO(t,n,e,s){let{path:r}=zx(t);if(r==="")return null;if(Q$(t))return r.startsWith("/")?d(r,e,s)[0]??null:null;if(r.endsWith("/"))return null;let o;try{o=decodeURIComponent(r)}catch{return null}let i=eI(n,o);if(i===null||i===""||i===Si(n))return null;return i}function bv(t){return t.split("/").map((n)=>encodeURIComponent(n)).join("/")}function KO(t){let n=[],e=0;while(e<t.length){while(e<t.length&&(/\s/.test(t[e])||t[e]===","))e+=1;if(e>=t.length)break;let s=e;while(e<t.length&&!/\s/.test(t[e]))e+=1;let r=t.slice(s,e);if(r.endsWith(",")){n.push({descriptor:"",url:r.replace(/,+$/,"")});continue}while(e<t.length&&/\s/.test(t[e]))e+=1;let o=e;while(e<t.length&&t[e]!==",")e+=1;let i=t.slice(o,e).trim();if(e+=1,r=r.replace(/,+$/,""),r!=="")n.push({descriptor:i,url:r})}return n}function JO(t){return t.map(({url:n,descriptor:e})=>e?`${n} ${e}`:n).join(", ")}
|
|
2
|
+
export{X$,OC,Io,VO,MC,UO,zx,Q$,Si,qO,eI,GO,bv,KO,JO};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=A526792CF3DAADE064756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-6vrxzkba.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{
|
|
1
|
+
import{qx,Gx}from"./studio-jqrg9xxg.js";import{n,v}from"./studio-kt2j51sa.js";import{op,le}from"./studio-fqs1a22a.js";var a={document:qx,project:Gx},i={...a},s={document:null,project:null},d=!1;function u(e){return s[e]??=(async()=>{try{let{default:t}=await (le("dg097k3e"),import("./2020-dg097k3e.js").then((m)=>op(m.default,1))),{default:r}=await (le("203h71wy"),import("./index-203h71wy.js").then((m)=>op(m.default,1))),o=new t({allErrors:!0,strict:!1,allowUnionTypes:!0});return r(o),o.compile(i[e])}catch(t){if(!d)d=!0,console.error(`[jx] ${e} schema validation is unavailable — the AI assistant's schema gate is a `+"no-op for this session:",t);return null}})(),s[e]}function p(e){return v(e)&&Object.keys(e).length>0}function U2(e){let t=e?.document,r=e?.project,o=p(t)?t:a.document,c=p(r)?r:a.project,m=o!==a.document||c!==a.project;if(o===i.document&&c===i.project)return m;return i.document=o,i.project=c,s.document=null,s.project=null,m}var j=["unevaluatedProperty","additionalProperty","missingProperty"];function l(e){return(e.errors||[]).map((t)=>{let r=j.find((c)=>n(t.params[c])),o=r?` (${String(t.params[r])})`:"";return`${t.instancePath||"(root)"}: ${t.message}${o}`})}async function cm(e){let t=await u("document");if(!t||t(e))return[];return l(t)}async function q2(e){let t=await u("document");if(!t)return null;return t(e)?[]:l(t)}async function zu(e){let t=await u("project");if(!t||t(e))return[];return l(t)}
|
|
2
|
+
export{U2,cm,q2,zu};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=9EA3201F4DC45CE064756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-73wz63nn.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{St,Xn,Se,We,yh,m,_i,Bt}from"./studio-c05wdnt3.js";import{g}from"./studio-43sd2mam.js";import{p}from"./studio-w4rz9hdk.js";import{Ot,cn}from"./studio-z97c48fk.js";import{T,R,Zs,tt}from"./studio-x9hsze61.js";import{$a,Vd}from"./studio-r5qy30vx.js";import{Md,HT,vS,zT,WT}from"./studio-tf9jryb1.js";import{bb,cs,zl,Iw,Rw,xp,nr,_p}from"./studio-q0tccd43.js";import{x}from"./studio-gcxk20n7.js";import{n,Z,te,of}from"./studio-vxq7fcvv.js";var j={$schema:"https://jxsuite.com/schema/v1",$id:"StudioGridOpen",$description:"Every grid-able source a project has, grouped by where it comes from: the project's own pages and content collections first, then each connection's tables. It is the ISLAND of a confirm dialog rather than a dialog of its own — `ui/layers.ts`'s dialog owns the headline, the cancel button, modality and focus, and this document is only the list — because a second answer to \"what is a dialog\" is a defect (studio-ui-guidelines.md §12.5). Group headings are why it is not the kit menu: a menu row can carry a divider above it and cannot carry a name for the run it opens.",tagName:"div",attributes:{part:"sources"},style:{display:"flex",flexDirection:"column",gap:"var(--jx-space-3)",minWidth:"280px",fontFamily:"var(--jx-font-sans)",fontSize:"var(--jx-text-md)",color:"var(--fg)",'& [part="group-title"]':{margin:"0",fontSize:"var(--jx-text-xs)",fontWeight:"600",textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--fg-dim)"},'& [part="rows"]':{display:"flex",flexDirection:"column",gap:"1px",marginTop:"var(--jx-space-1)"},'& [part="source"]':{textAlign:"left",background:"none",border:"none",color:"var(--fg)",font:"inherit",padding:"var(--jx-space-2) var(--jx-space-2)",borderRadius:"var(--jx-radius-sm)",cursor:"pointer"},'& [part="source"]:hover':{background:"var(--bg-hover)"},'& [part="source"]:focus-visible':{outline:"var(--jx-focus-ring)",outlineOffset:"-2px"},'& [part="group-empty"]':{margin:"0",padding:"var(--jx-space-2)",color:"var(--fg-dim)",fontSize:"var(--jx-text-sm)"}},children:[{$prototype:"Array",items:{$ref:"#/state/groups"},key:{$ref:"$map/item/key"},map:{$description:"One origin of grid-able sources. A connection with no tables says why it has none instead of drawing an empty box — an author who has not pushed a schema yet is exactly the reader who needs the sentence.",tagName:"section",attributes:{part:"group","data-group":"${$map.item.key}"},children:[{tagName:"h3",attributes:{part:"group-title"},textContent:"${$map.item.title}"},{tagName:"div",attributes:{part:"rows"},$switch:{$ref:"$map/item/state"},cases:{listed:{tagName:"div",attributes:{part:"rows-list",role:"none"},style:{display:"contents"},children:[{$prototype:"Array",items:{$ref:"$map/item/rows"},key:{$ref:"$map/item/id"},map:{tagName:"button",attributes:{part:"source",type:"button","data-source":"${$map.item.id}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/open"},value:[{$ref:"$map/item/id"}]}]},textContent:"${$map.item.label}"}}]},empty:{tagName:"p",attributes:{part:"group-empty"},textContent:"${$map.item.emptyMessage}"}}}]}}]};T("grid-open",j);function I(e,r,t){let o=g({groups:r,open:t}),i=null,s=!1,c=R("grid-open",o,e).then((y)=>{let a=y.root;if(s)return y.dispose(),a;return i=y,a});return{dispose(){s=!0,i?.dispose(),i=null},ready:c}}function G(){try{return p()}catch{return null}}function nS(){return te(G()?.dataRows)}async function K(){let e=G();if(!te(e?.dataConnections))return null;return e.dataConnections()}async function zD(e){let r=G();if(!te(r?.dataConnectionTest))return{error:"Connection tests are not supported by this backend",ok:!1};try{return await r.dataConnectionTest(e)}catch(t){return{error:t instanceof Error?t.message:String(t),ok:!1}}}async function eT(e){let r=G();if(!te(r?.dataPush))return{applied:!1,errors:["Schema push is not supported by this backend"],plan:[]};try{return await r.dataPush(e)}catch(t){return{applied:!1,errors:[t instanceof Error?t.message:String(t)],plan:[]}}}function k(e){let t=G()?.[e];if(t===void 0)throw Error(`The ${String(e)} surface is not supported by this backend`);return t}function v(e){return k("dataRows")(e)}function M(e){return k("dataInsertRow")(e)}function E(e){return k("dataUpdateRow")(e)}function O(e){return k("dataDeleteRow")(e)}function WD(e,r,t){let o=(c)=>c.replaceAll(/([a-z0-9])([A-Z])/g,"$1_$2").replaceAll(/[^A-Za-z0-9]+/g,"_").replaceAll(/^_+|_+$/g,"").toUpperCase(),s=[r??e,t.replace(/Env$/,"")].flatMap((c)=>{let y=o(c);return y?[y]:[]}).join("_")||"SECRET";return/^\d/.test(s)?`JX_${s}`:s}var H=["id","sku","slug","Slug"];function L(e){let r=new Set;return e.map((t,o)=>{let i=t.trim()===""?`column${o+1}`:t;if(r.has(i))i=`${i}__${o+1}`;return r.add(i),i})}function Q(e,r){for(let t of H){let o=e.indexOf(t);if(o===-1)continue;let i=r.rows.map((s)=>s[o]??"");if(i.every((s)=>s!=="")&&new Set(i).size===i.length)return t}return null}function A(e,r){let t=Md(e),o=L(t.headers),i=Q(o,t),s=i?o.indexOf(i):-1,c=t.rows.map((d,u)=>s===-1?String(u):d[s]),y=new Map(c.map((d,u)=>[d,u])),a=yh(r,x?.projectConfig),l=a?.schema.properties??{},b=t.rows.slice(0,50).map((d)=>{let u={};for(let[S,C]of o.entries())u[C]=d[S]??"";return u}),f=new Map(Rw(b).map((d)=>[d.field,d])),w=new Map(Iw(a?.schema,{idField:i??void 0}).map((d)=>[d.field,d]));return{columns:o.map((d,u)=>{let C=(d in l?w.get(d):void 0)??f.get(d)??{editable:!0,field:d,kind:"string",title:t.headers[u]||d};return{...C,pk:d===i,title:t.headers[u]?.trim()||C.title}}),doc:t,fields:o,keys:c,keyToIndex:y,loadText:e}}function J(e,r){let t={},o=e.doc.rows[r]??[];for(let[i,s]of e.fields.entries()){let c=e.columns[i],y=o[i]??"";t[s]=c.kind==="string"||c.kind==="text"||c.kind==="readonly"?y:xp(y,c)}return t}function F(e,r){let t=e.doc.rows.map((s)=>[...s]),o=(s)=>e.fields.indexOf(s);for(let s of r.cells){let c=e.keyToIndex.get(s.rowKey),y=o(s.field);if(c===void 0||y===-1)continue;t[c][y]=nr(s.value)}for(let s of r.inserts){let c=e.fields.map((y)=>nr(s.cells[y]??null));t.push(c)}let i=r.deletes.map((s)=>e.keyToIndex.get(s.rowKey)).filter((s)=>s!==void 0).toSorted((s,c)=>c-s);for(let s of i)t.splice(s,1);return{...e.doc,rows:t}}function _(e,r){return{cells:e.cells.map((t)=>({field:t.field,rowKey:t.rowKey,...r})),deletes:e.deletes.map((t)=>({rowKey:t.rowKey,...r})),inserts:e.inserts.map((t)=>({error:r.error,ok:r.ok,tempKey:t.tempKey}))}}function iS(e){let r=null,t=(o=!1)=>{if(!o&&r)return r;return r=p().readFile(e).then((i)=>A(i,e)),r};return{backingPaths:()=>new Map([[e,"*"]]),capabilities:{delete:!0,insert:!0,remotePaging:!1,remoteSort:!1},async columns(){return(await t()).columns},async commit(o){let i=await t(),s=p(),c=null;try{c=await s.readFile(e)}catch{c=null}if(c!==i.loadText&&!Vd(e))return _(o,{error:"File changed on disk — refresh to reload",ok:!1,stale:!0});let y=F(i,o),a=HT(y);return $a(e),await s.writeFile(e,a),r=Promise.resolve(A(a,e)),_(o,{ok:!0})},id:e,label:e.split("/").pop()??e,async refresh(){await t(!0)},async rows(){let o=await t(),i=o.doc.rows.map((s,c)=>({cells:J(o,c),key:o.keys[c]}));return{rows:i,total:i.length}},async serializeForSource(o){let i=await t();return HT(F(i,o))}}}var z=50;function U(e){let r=e.toLowerCase();if(/(int|real|floa|doub|num|dec)/.test(r))return"number";if(r.includes("bool"))return"boolean";if(/(timestamp|datetime|date)/.test(r))return"date";return"string"}function q(e){return!e.pk&&e.name!=="created_at"&&e.name!=="updated_at"}function W(e){if(e===void 0)return null;if(of(e))return e;return JSON.stringify(e)}function N(e,r){let t=[],o="id",i=new Map,s=(a)=>{if(a.length>0)t=a,o=a.find((l)=>l.pk)?.name??"id"},c=(a)=>{let l={table:r};if(e)l.connection=e;if(l.limit=a?.limit??z,l.offset=a?.offset??0,a?.orderBy)l.dir=a.dir??"asc",l.orderBy=a.orderBy;return l},y=(a,l)=>{let b=a[o];if(n(b)||Z(b))return i.set(String(b),b),String(b);return`row-${l}`};return{capabilities:{delete:!0,insert:!0,remotePaging:!0,remoteSort:!0},async columns(){if(t.length===0){let a=await v(c({limit:1,offset:0}));s(a.columns)}return t.map((a)=>{let l=q(a)?U(a.type):"readonly";return{editable:l!=="readonly",field:a.name,kind:l,pk:a.pk===!0,title:a.name,widthHint:a.pk?80:void 0}})},async commit(a){let l={cells:[],deletes:[],inserts:[]},b=new Map;for(let f of a.cells){let w=b.get(f.rowKey)??[];w.push({field:f.field,value:f.value}),b.set(f.rowKey,w)}for(let[f,w]of b){let h=i.get(f),d=(u,S)=>{for(let C of w)l.cells.push({error:S,field:C.field,ok:u,rowKey:f})};if(h===void 0){d(!1,"Row has no primary key — refresh the grid");continue}try{let u={};for(let C of w)u[C.field]=C.value;let S={pk:h,set:u,table:r};if(e)S.connection=e;await E(S),d(!0)}catch(u){d(!1,u instanceof Error?u.message:String(u))}}for(let f of a.inserts)try{let w={};for(let[C,P]of Object.entries(f.cells))if(P!==null)w[C]=P;let h={table:r,values:w};if(e)h.connection=e;let{row:d}=await M(h),u=d[o],S;if(n(u)||Z(u))S=String(u),i.set(S,u);l.inserts.push({newKey:S,ok:!0,tempKey:f.tempKey})}catch(w){l.inserts.push({error:w instanceof Error?w.message:String(w),ok:!1,tempKey:f.tempKey})}for(let f of a.deletes){let w=i.get(f.rowKey);if(w===void 0){l.deletes.push({error:"Row has no primary key — refresh the grid",ok:!1,rowKey:f.rowKey});continue}try{let h={pk:w,table:r};if(e)h.connection=e;await O(h),l.deletes.push({ok:!0,rowKey:f.rowKey})}catch(h){l.deletes.push({error:h instanceof Error?h.message:String(h),ok:!1,rowKey:f.rowKey})}}return l},id:cs({connection:e??"default",kind:"data",table:r}),label:r,async refresh(){t=[],i.clear()},async rows(a){let l=await v(c(a));return s(l.columns),{rows:l.rows.map((f,w)=>{let h=y(f,w),d={};for(let u of t)d[u.name]=W(f[u.name]);return{cells:d,key:h}}),total:l.total}}}}async function tT(e,r={}){let t=m.tabs.get(e);if(t)return Bt(e,{focus:r.focus!==!1}),t;try{await Ot()}catch{}let o=iS(e),i=_i({capabilities:{modes:["grid","source"]},document:structuredClone(bb),documentPath:e,id:e,sourceFormat:cn(e)?.name??null,...r.paneId!==void 0&&{paneId:r.paneId},...r.preview===!0&&{preview:!0},...r.focus===!1&&{focus:!1}});return _p(i,o).load(),i}function D(e){let r=_i({capabilities:{modes:["grid"]},document:structuredClone(bb),documentPath:null,id:e.id});return _p(r,e).load(),r}function VD(e){let r=cs({kind:"collection",name:e}),t=m.tabs.get(r);if(t)return Bt(r),t;return D(zT(e))}function oS(){let e=cs({kind:"pages"}),r=m.tabs.get(e);if(r)return Bt(e),r;return D(WT())}function V(e,r){let t=cs({connection:e??"default",kind:"data",table:r}),o=m.tabs.get(t);if(o)return Bt(t),o;return D(N(e,r))}function X(e){let r=zl(e);if(r?.kind==="pages")oS();else if(r?.kind==="collection")VD(r.name);else if(r?.kind==="data")V(r.connection,r.table)}function Y(e,r){return[{emptyMessage:"",key:"project",rows:[{id:cs({kind:"pages"}),label:"Pages"},...e.map(({name:t})=>({id:cs({kind:"collection",name:t}),label:`Collection: ${t}`}))],state:"listed",title:"Project"},...r.map((t)=>({emptyMessage:"No tables — push a schema first.",key:`data:${t.name}`,rows:t.tables.map((o)=>({id:cs({connection:t.name,kind:"data",table:o}),label:o})),state:t.tables.length===0?"empty":"listed",title:`Data · ${t.name}`}))]}async function nT(){let e=vS(),r=[];if(nS())r=(await K().catch(()=>null))?.connections??[];let t=null,o=Zs({cancelLabel:"Cancel",confirmLabel:"",headline:"Open Grid",island:(i)=>{t=I(i,Y(e,r),(s)=>{o.close(),X(s)})},layer:tt("dialog"),onCancel:()=>o.close(),onClosed:()=>{t?.dispose(),t=null},onConfirm:()=>{},region:"grid/open"});o.ready}function ee(){return[{args:Se({name:We("The content collection's name, as project.json declares it.")}),category:"Project",id:"collection.editInGrid",level:"project",menus:["context/file","palette"],group:"5_data",requires:"a project that declares content collections",when:(e)=>e.project.open,run:(e,r)=>{let t=St("collection.editInGrid",r,"name"),o=vS().map((i)=>i.name);if(!o.includes(t))throw RangeError(`command "collection.editInGrid" argument "name": "${t}" is not a content `+"collection this project declares — it declares: "+`${o.length>0?o.join(", "):"none"}`);VD(t)},title:"Edit Collection in Grid"},{args:{additionalProperties:!1,properties:{connection:We('The connection name from project.json. Defaults to "default".'),table:We("The table to open.")},required:["table"],type:"object"},category:"Project",id:"data.openGrid",level:"project",menus:["palette"],group:"5_data",requires:"a platform that serves the data routes",when:(e)=>e.project.open,enablement:(e)=>e.capability.dataRows,run:(e,r)=>{let t=St("data.openGrid",r,"table");V(Xn("data.openGrid",r,"connection"),t)},title:"Open Data Grid"}]}function iT(e){e.registerAll(ee())}
|
|
2
|
-
export{
|
|
1
|
+
import{St,Xn,Se,We,yh,m,_i,Ht}from"./studio-y1x65h5r.js";import{g}from"./studio-hw60n5dh.js";import{p}from"./studio-pr23qhrw.js";import{Bt,fn}from"./studio-tpmnbgmt.js";import{T,R,Ys,tt}from"./studio-02phtmqn.js";import{La,zd}from"./studio-9wyqyfqy.js";import{Ad,AT,mS,MT,PT}from"./studio-2dtc90zs.js";import{gb,ls,Bl,Ew,Tw,xp,nr,_p}from"./studio-1yhz0s8p.js";import{S}from"./studio-ana67wax.js";import{n,Z,te,rf}from"./studio-kt2j51sa.js";var j={$schema:"https://jxsuite.com/schema/v1",$id:"StudioGridOpen",$description:"Every grid-able source a project has, grouped by where it comes from: the project's own pages and content collections first, then each connection's tables. It is the ISLAND of a confirm dialog rather than a dialog of its own — `ui/layers.ts`'s dialog owns the headline, the cancel button, modality and focus, and this document is only the list — because a second answer to \"what is a dialog\" is a defect (studio-ui-guidelines.md §12.5). Group headings are why it is not the kit menu: a menu row can carry a divider above it and cannot carry a name for the run it opens.",tagName:"div",attributes:{part:"sources"},style:{display:"flex",flexDirection:"column",gap:"var(--jx-space-3)",minWidth:"280px",fontFamily:"var(--jx-font-sans)",fontSize:"var(--jx-text-md)",color:"var(--fg)",'& [part="group-title"]':{margin:"0",fontSize:"var(--jx-text-xs)",fontWeight:"600",textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--fg-dim)"},'& [part="rows"]':{display:"flex",flexDirection:"column",gap:"1px",marginTop:"var(--jx-space-1)"},'& [part="source"]':{textAlign:"left",background:"none",border:"none",color:"var(--fg)",font:"inherit",padding:"var(--jx-space-2) var(--jx-space-2)",borderRadius:"var(--jx-radius-sm)",cursor:"pointer"},'& [part="source"]:hover':{background:"var(--bg-hover)"},'& [part="source"]:focus-visible':{outline:"var(--jx-focus-ring)",outlineOffset:"-2px"},'& [part="group-empty"]':{margin:"0",padding:"var(--jx-space-2)",color:"var(--fg-dim)",fontSize:"var(--jx-text-sm)"}},children:[{$prototype:"Array",items:{$ref:"#/state/groups"},key:{$ref:"$map/item/key"},map:{$description:"One origin of grid-able sources. A connection with no tables says why it has none instead of drawing an empty box — an author who has not pushed a schema yet is exactly the reader who needs the sentence.",tagName:"section",attributes:{part:"group","data-group":"${$map.item.key}"},children:[{tagName:"h3",attributes:{part:"group-title"},textContent:"${$map.item.title}"},{tagName:"div",attributes:{part:"rows"},$switch:{$ref:"$map/item/state"},cases:{listed:{tagName:"div",attributes:{part:"rows-list",role:"none"},style:{display:"contents"},children:[{$prototype:"Array",items:{$ref:"$map/item/rows"},key:{$ref:"$map/item/id"},map:{tagName:"button",attributes:{part:"source",type:"button","data-source":"${$map.item.id}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/open"},value:[{$ref:"$map/item/id"}]}]},textContent:"${$map.item.label}"}}]},empty:{tagName:"p",attributes:{part:"group-empty"},textContent:"${$map.item.emptyMessage}"}}}]}}]};T("grid-open",j);function I(e,r,t){let o=g({groups:r,open:t}),i=null,s=!1,c=R("grid-open",o,e).then((y)=>{let a=y.root;if(s)return y.dispose(),a;return i=y,a});return{dispose(){s=!0,i?.dispose(),i=null},ready:c}}function x(){try{return p()}catch{return null}}function Q_(){return te(x()?.dataRows)}async function K(){let e=x();if(!te(e?.dataConnections))return null;return e.dataConnections()}async function PD(e){let r=x();if(!te(r?.dataConnectionTest))return{error:"Connection tests are not supported by this backend",ok:!1};try{return await r.dataConnectionTest(e)}catch(t){return{error:t instanceof Error?t.message:String(t),ok:!1}}}async function KE(e){let r=x();if(!te(r?.dataPush))return{applied:!1,errors:["Schema push is not supported by this backend"],plan:[]};try{return await r.dataPush(e)}catch(t){return{applied:!1,errors:[t instanceof Error?t.message:String(t)],plan:[]}}}function k(e){let t=x()?.[e];if(t===void 0)throw Error(`The ${String(e)} surface is not supported by this backend`);return t}function v(e){return k("dataRows")(e)}function M(e){return k("dataInsertRow")(e)}function E(e){return k("dataUpdateRow")(e)}function O(e){return k("dataDeleteRow")(e)}function FD(e,r,t){let o=(c)=>c.replaceAll(/([a-z0-9])([A-Z])/g,"$1_$2").replaceAll(/[^A-Za-z0-9]+/g,"_").replaceAll(/^_+|_+$/g,"").toUpperCase(),s=[r??e,t.replace(/Env$/,"")].flatMap((c)=>{let y=o(c);return y?[y]:[]}).join("_")||"SECRET";return/^\d/.test(s)?`JX_${s}`:s}var H=["id","sku","slug","Slug"];function L(e){let r=new Set;return e.map((t,o)=>{let i=t.trim()===""?`column${o+1}`:t;if(r.has(i))i=`${i}__${o+1}`;return r.add(i),i})}function Q(e,r){for(let t of H){let o=e.indexOf(t);if(o===-1)continue;let i=r.rows.map((s)=>s[o]??"");if(i.every((s)=>s!=="")&&new Set(i).size===i.length)return t}return null}function A(e,r){let t=Ad(e),o=L(t.headers),i=Q(o,t),s=i?o.indexOf(i):-1,c=t.rows.map((d,u)=>s===-1?String(u):d[s]),y=new Map(c.map((d,u)=>[d,u])),a=yh(r,S?.projectConfig),l=a?.schema.properties??{},b=t.rows.slice(0,50).map((d)=>{let u={};for(let[C,G]of o.entries())u[G]=d[C]??"";return u}),f=new Map(Tw(b).map((d)=>[d.field,d])),w=new Map(Ew(a?.schema,{idField:i??void 0}).map((d)=>[d.field,d]));return{columns:o.map((d,u)=>{let G=(d in l?w.get(d):void 0)??f.get(d)??{editable:!0,field:d,kind:"string",title:t.headers[u]||d};return{...G,pk:d===i,title:t.headers[u]?.trim()||G.title}}),doc:t,fields:o,keys:c,keyToIndex:y,loadText:e}}function J(e,r){let t={},o=e.doc.rows[r]??[];for(let[i,s]of e.fields.entries()){let c=e.columns[i],y=o[i]??"";t[s]=c.kind==="string"||c.kind==="text"||c.kind==="readonly"?y:xp(y,c)}return t}function F(e,r){let t=e.doc.rows.map((s)=>[...s]),o=(s)=>e.fields.indexOf(s);for(let s of r.cells){let c=e.keyToIndex.get(s.rowKey),y=o(s.field);if(c===void 0||y===-1)continue;t[c][y]=nr(s.value)}for(let s of r.inserts){let c=e.fields.map((y)=>nr(s.cells[y]??null));t.push(c)}let i=r.deletes.map((s)=>e.keyToIndex.get(s.rowKey)).filter((s)=>s!==void 0).toSorted((s,c)=>c-s);for(let s of i)t.splice(s,1);return{...e.doc,rows:t}}function _(e,r){return{cells:e.cells.map((t)=>({field:t.field,rowKey:t.rowKey,...r})),deletes:e.deletes.map((t)=>({rowKey:t.rowKey,...r})),inserts:e.inserts.map((t)=>({error:r.error,ok:r.ok,tempKey:t.tempKey}))}}function eS(e){let r=null,t=(o=!1)=>{if(!o&&r)return r;return r=p().readFile(e).then((i)=>A(i,e)),r};return{backingPaths:()=>new Map([[e,"*"]]),capabilities:{delete:!0,insert:!0,remotePaging:!1,remoteSort:!1},async columns(){return(await t()).columns},async commit(o){let i=await t(),s=p(),c=null;try{c=await s.readFile(e)}catch{c=null}if(c!==i.loadText&&!zd(e))return _(o,{error:"File changed on disk — refresh to reload",ok:!1,stale:!0});let y=F(i,o),a=AT(y);return La(e),await s.writeFile(e,a),r=Promise.resolve(A(a,e)),_(o,{ok:!0})},id:e,label:e.split("/").pop()??e,async refresh(){await t(!0)},async rows(){let o=await t(),i=o.doc.rows.map((s,c)=>({cells:J(o,c),key:o.keys[c]}));return{rows:i,total:i.length}},async serializeForSource(o){let i=await t();return AT(F(i,o))}}}var z=50;function U(e){let r=e.toLowerCase();if(/(int|real|floa|doub|num|dec)/.test(r))return"number";if(r.includes("bool"))return"boolean";if(/(timestamp|datetime|date)/.test(r))return"date";return"string"}function q(e){return!e.pk&&e.name!=="created_at"&&e.name!=="updated_at"}function W(e){if(e===void 0)return null;if(rf(e))return e;return JSON.stringify(e)}function N(e,r){let t=[],o="id",i=new Map,s=(a)=>{if(a.length>0)t=a,o=a.find((l)=>l.pk)?.name??"id"},c=(a)=>{let l={table:r};if(e)l.connection=e;if(l.limit=a?.limit??z,l.offset=a?.offset??0,a?.orderBy)l.dir=a.dir??"asc",l.orderBy=a.orderBy;return l},y=(a,l)=>{let b=a[o];if(n(b)||Z(b))return i.set(String(b),b),String(b);return`row-${l}`};return{capabilities:{delete:!0,insert:!0,remotePaging:!0,remoteSort:!0},async columns(){if(t.length===0){let a=await v(c({limit:1,offset:0}));s(a.columns)}return t.map((a)=>{let l=q(a)?U(a.type):"readonly";return{editable:l!=="readonly",field:a.name,kind:l,pk:a.pk===!0,title:a.name,widthHint:a.pk?80:void 0}})},async commit(a){let l={cells:[],deletes:[],inserts:[]},b=new Map;for(let f of a.cells){let w=b.get(f.rowKey)??[];w.push({field:f.field,value:f.value}),b.set(f.rowKey,w)}for(let[f,w]of b){let h=i.get(f),d=(u,C)=>{for(let G of w)l.cells.push({error:C,field:G.field,ok:u,rowKey:f})};if(h===void 0){d(!1,"Row has no primary key — refresh the grid");continue}try{let u={};for(let G of w)u[G.field]=G.value;let C={pk:h,set:u,table:r};if(e)C.connection=e;await E(C),d(!0)}catch(u){d(!1,u instanceof Error?u.message:String(u))}}for(let f of a.inserts)try{let w={};for(let[G,P]of Object.entries(f.cells))if(P!==null)w[G]=P;let h={table:r,values:w};if(e)h.connection=e;let{row:d}=await M(h),u=d[o],C;if(n(u)||Z(u))C=String(u),i.set(C,u);l.inserts.push({newKey:C,ok:!0,tempKey:f.tempKey})}catch(w){l.inserts.push({error:w instanceof Error?w.message:String(w),ok:!1,tempKey:f.tempKey})}for(let f of a.deletes){let w=i.get(f.rowKey);if(w===void 0){l.deletes.push({error:"Row has no primary key — refresh the grid",ok:!1,rowKey:f.rowKey});continue}try{let h={pk:w,table:r};if(e)h.connection=e;await O(h),l.deletes.push({ok:!0,rowKey:f.rowKey})}catch(h){l.deletes.push({error:h instanceof Error?h.message:String(h),ok:!1,rowKey:f.rowKey})}}return l},id:ls({connection:e??"default",kind:"data",table:r}),label:r,async refresh(){t=[],i.clear()},async rows(a){let l=await v(c(a));return s(l.columns),{rows:l.rows.map((f,w)=>{let h=y(f,w),d={};for(let u of t)d[u.name]=W(f[u.name]);return{cells:d,key:h}}),total:l.total}}}}async function JE(e,r={}){let t=m.tabs.get(e);if(t)return Ht(e,{focus:r.focus!==!1}),t;try{await Bt()}catch{}let o=eS(e),i=_i({capabilities:{modes:["grid","source"]},document:structuredClone(gb),documentPath:e,id:e,sourceFormat:fn(e)?.name??null,...r.paneId!==void 0&&{paneId:r.paneId},...r.preview===!0&&{preview:!0},...r.focus===!1&&{focus:!1}});return _p(i,o).load(),i}function D(e){let r=_i({capabilities:{modes:["grid"]},document:structuredClone(gb),documentPath:null,id:e.id});return _p(r,e).load(),r}function jD(e){let r=ls({kind:"collection",name:e}),t=m.tabs.get(r);if(t)return Ht(r),t;return D(MT(e))}function tS(){let e=ls({kind:"pages"}),r=m.tabs.get(e);if(r)return Ht(e),r;return D(PT())}function V(e,r){let t=ls({connection:e??"default",kind:"data",table:r}),o=m.tabs.get(t);if(o)return Ht(t),o;return D(N(e,r))}function X(e){let r=Bl(e);if(r?.kind==="pages")tS();else if(r?.kind==="collection")jD(r.name);else if(r?.kind==="data")V(r.connection,r.table)}function Y(e,r){return[{emptyMessage:"",key:"project",rows:[{id:ls({kind:"pages"}),label:"Pages"},...e.map(({name:t})=>({id:ls({kind:"collection",name:t}),label:`Collection: ${t}`}))],state:"listed",title:"Project"},...r.map((t)=>({emptyMessage:"No tables — push a schema first.",key:`data:${t.name}`,rows:t.tables.map((o)=>({id:ls({connection:t.name,kind:"data",table:o}),label:o})),state:t.tables.length===0?"empty":"listed",title:`Data · ${t.name}`}))]}async function YE(){let e=mS(),r=[];if(Q_())r=(await K().catch(()=>null))?.connections??[];let t=null,o=Ys({cancelLabel:"Cancel",confirmLabel:"",headline:"Open Grid",island:(i)=>{t=I(i,Y(e,r),(s)=>{o.close(),X(s)})},layer:tt("dialog"),onCancel:()=>o.close(),onClosed:()=>{t?.dispose(),t=null},onConfirm:()=>{},region:"grid/open"});o.ready}function ee(){return[{args:Se({name:We("The content collection's name, as project.json declares it.")}),category:"Project",id:"collection.editInGrid",level:"project",menus:["context/file","palette"],group:"5_data",requires:"a project that declares content collections",when:(e)=>e.project.open,run:(e,r)=>{let t=St("collection.editInGrid",r,"name"),o=mS().map((i)=>i.name);if(!o.includes(t))throw RangeError(`command "collection.editInGrid" argument "name": "${t}" is not a content `+"collection this project declares — it declares: "+`${o.length>0?o.join(", "):"none"}`);jD(t)},title:"Edit Collection in Grid"},{args:{additionalProperties:!1,properties:{connection:We('The connection name from project.json. Defaults to "default".'),table:We("The table to open.")},required:["table"],type:"object"},category:"Project",id:"data.openGrid",level:"project",menus:["palette"],group:"5_data",requires:"a platform that serves the data routes",when:(e)=>e.project.open,enablement:(e)=>e.capability.dataRows,run:(e,r)=>{let t=St("data.openGrid",r,"table");V(Xn("data.openGrid",r,"connection"),t)},title:"Open Data Grid"}]}function ZE(e){e.registerAll(ee())}
|
|
2
|
+
export{Q_,PD,KE,FD,eS,JE,jD,tS,YE,ZE};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=18B6AF02441C8DEC64756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-74nzv280.js.map
|