@jxsuite/studio 5.5.0 → 5.7.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.
Files changed (244) hide show
  1. package/LICENSE +1 -1
  2. package/dist/chunks/{2020-g8mwpbkq.js → 2020-cs2sb9t1.js} +3 -3
  3. package/dist/chunks/adapter-y5gdq19c.js +4 -0
  4. package/dist/chunks/cf-account-picker-882a7ecm.js +4 -0
  5. package/dist/chunks/cf-settings-20dznc3j.js +4 -0
  6. package/dist/chunks/components-q037dya7.js +4 -0
  7. package/dist/chunks/content-source-37x3vsap.js +4 -0
  8. package/dist/chunks/convert-to-repeater-grfep2w8.js +4 -0
  9. package/dist/chunks/editor-j5sq149q.js +4 -0
  10. package/dist/chunks/entry-commands-c5h3nqck.js +4 -0
  11. package/dist/chunks/extension-sections-dp8endhx.js +4 -0
  12. package/dist/chunks/file-ops-937cvqk6.js +4 -0
  13. package/dist/chunks/files-tznwe1p1.js +4 -0
  14. package/dist/chunks/format-host-e2pjvd25.js +4 -0
  15. package/dist/chunks/fs-events-fv64ak3s.js +4 -0
  16. package/dist/chunks/git-panel-gb713ttc.js +4 -0
  17. package/dist/chunks/grid-view-5amhg604.js +51 -0
  18. package/dist/chunks/grid-view-5mqv1cbd.css +1 -0
  19. package/dist/chunks/iframe-host-t819mcg5.js +4 -0
  20. package/dist/chunks/{index-arg188jq.js → index-9ydfe04y.js} +3 -3
  21. package/dist/chunks/index-m0x5ztax.js +4 -0
  22. package/dist/chunks/{javascript-zcdmye2k.js → javascript-d9pqgc2p.js} +2 -2
  23. package/dist/chunks/{jsonMode-6x5e1nbf.js → jsonMode-800yvbem.js} +5 -5
  24. package/dist/chunks/jx-validate-zc9zp77s.js +4 -0
  25. package/dist/chunks/layers-4bsr82wz.js +4 -0
  26. package/dist/chunks/layers-panel-b6shnaax.js +4 -0
  27. package/dist/chunks/lit-html-cfn61dn7.js +4 -0
  28. package/dist/chunks/media-picker-ej0kdh1j.js +4 -0
  29. package/dist/chunks/menu-rtxf9chb.js +4 -0
  30. package/dist/chunks/{monaco-binding-4az2kh5p.js → monaco-binding-62dtmgbf.js} +3 -3
  31. package/dist/chunks/monaco-buffer-nn4dtx27.js +4 -0
  32. package/dist/chunks/{monaco-setup-d7mwkcx3.js → monaco-setup-tj13ndtm.js} +3 -3
  33. package/dist/chunks/notify-ahs57a2z.js +4 -0
  34. package/dist/chunks/platform-v9xyfkbx.js +4 -0
  35. package/dist/chunks/publish-panel-bq36xcmj.js +4 -0
  36. package/dist/chunks/quick-search-zm00h9dh.js +4 -0
  37. package/dist/chunks/references-99ws0b0m.js +4 -0
  38. package/dist/chunks/right-panel-pq2f71q3.js +4 -0
  39. package/dist/chunks/section-registry-b2yzp9sw.js +4 -0
  40. package/dist/chunks/studio-01kbbqg3.js +928 -0
  41. package/dist/chunks/{studio-hf4qdjc8.js → studio-01qza1n3.js} +4 -4
  42. package/dist/chunks/{studio-pkkw32j0.js → studio-03wwfvyt.js} +4 -4
  43. package/dist/chunks/{studio-7gqyhjns.js → studio-0bbxhhce.js} +4 -4
  44. package/dist/chunks/studio-0k9mvpgj.js +14 -0
  45. package/dist/chunks/studio-0scebvb9.js +6 -0
  46. package/dist/chunks/studio-1a99w39s.js +5 -0
  47. package/dist/chunks/studio-1wvfxkyy.js +5 -0
  48. package/dist/chunks/studio-1x8x26k3.js +5 -0
  49. package/dist/chunks/studio-222rqyyc.js +5 -0
  50. package/dist/chunks/studio-4xppwncr.js +4 -0
  51. package/dist/chunks/{studio-xcng8nx7.js → studio-54g077x3.js} +5 -5
  52. package/dist/chunks/studio-56z7evx4.js +10 -0
  53. package/dist/chunks/studio-5e9zsamh.js +9 -0
  54. package/dist/chunks/studio-65fhspdd.js +5 -0
  55. package/dist/chunks/studio-693nhyky.js +5 -0
  56. package/dist/chunks/{studio-7jazdy6y.js → studio-7pgy3xaf.js} +4 -4
  57. package/dist/chunks/studio-888knnkc.js +5 -0
  58. package/dist/chunks/studio-9mqfamps.js +5 -0
  59. package/dist/chunks/studio-a7xqhc3n.js +5 -0
  60. package/dist/chunks/studio-aje966s9.js +5 -0
  61. package/dist/chunks/studio-aqmph6k4.js +5 -0
  62. package/dist/chunks/studio-c6w3tq7t.js +5 -0
  63. package/dist/chunks/{studio-6j2jn55a.js → studio-c6zdm25z.js} +8 -8
  64. package/dist/chunks/{studio-f8jyp45j.js → studio-c9d3pxf7.js} +4 -4
  65. package/dist/chunks/studio-ceb34dxj.js +5 -0
  66. package/dist/chunks/studio-cvbkkfqb.js +5 -0
  67. package/dist/chunks/studio-cxt150pj.js +7 -0
  68. package/dist/chunks/studio-dkn3x3hz.js +5 -0
  69. package/dist/chunks/studio-e6re3rk1.js +5 -0
  70. package/dist/chunks/{studio-5n1km79v.js → studio-edbtvcd1.js} +4 -4
  71. package/dist/chunks/{studio-xc8ebsts.js → studio-eh0rac07.js} +4 -4
  72. package/dist/chunks/{studio-625ezz59.js → studio-evwgp1ym.js} +4 -4
  73. package/dist/chunks/{studio-he2fhrgp.js → studio-f195h2hq.js} +4 -4
  74. package/dist/chunks/studio-fqq890ap.js +4 -0
  75. package/dist/chunks/studio-frb0qbf7.js +6 -0
  76. package/dist/chunks/studio-gfn1kpxj.js +6 -0
  77. package/dist/chunks/studio-gh97gngt.js +5 -0
  78. package/dist/chunks/{studio-awqghqxv.js → studio-gp02nqnw.js} +4 -4
  79. package/dist/chunks/{studio-x9sagq2d.js → studio-hjbg8d5y.js} +7 -7
  80. package/dist/chunks/studio-j6gnhvaa.js +5 -0
  81. package/dist/chunks/studio-mwxgyn9h.js +7 -0
  82. package/dist/chunks/{studio-x5esgzct.js → studio-n78gjfy8.js} +4 -4
  83. package/dist/chunks/studio-nbxqcgvf.js +5 -0
  84. package/dist/chunks/{studio-p1eggxcf.js → studio-nt06yybj.js} +4 -4
  85. package/dist/chunks/{studio-hc9q4j24.js → studio-p7c1agz0.js} +5 -5
  86. package/dist/chunks/{studio-8r4y2x0z.js → studio-pwqfmt4p.js} +4 -4
  87. package/dist/chunks/{studio-5wfrgee9.js → studio-r3kaka4d.js} +4 -4
  88. package/dist/chunks/studio-semd1s8s.js +5 -0
  89. package/dist/chunks/studio-skzanb0k.js +5 -0
  90. package/dist/chunks/studio-spf2skgc.js +5 -0
  91. package/dist/chunks/{studio-b4epb26c.js → studio-st75kn99.js} +7 -7
  92. package/dist/chunks/{studio-eq27rrr0.js → studio-sxc0zvpt.js} +3 -3
  93. package/dist/chunks/studio-t1eedsyx.js +4 -0
  94. package/dist/chunks/{studio-73czgk6a.js → studio-tp642n5g.js} +4 -4
  95. package/dist/chunks/studio-tw7rre6s.js +5 -0
  96. package/dist/chunks/{studio-7by9a93k.js → studio-tzegmy4w.js} +4 -4
  97. package/dist/chunks/studio-vavmwshr.js +5 -0
  98. package/dist/chunks/studio-wma2c6g8.js +5 -0
  99. package/dist/chunks/studio-x92tgnee.js +64 -0
  100. package/dist/chunks/studio-xk0z6msk.js +5 -0
  101. package/dist/chunks/{studio-c4pnt1c6.js → studio-xry7tk3z.js} +5 -5
  102. package/dist/chunks/studio-xta2vxp6.js +9 -0
  103. package/dist/chunks/{studio-21enxdr8.js → studio-xy3tv3az.js} +4 -4
  104. package/dist/chunks/studio-y7jehjrp.js +5 -0
  105. package/dist/chunks/{studio-k1eaqyzm.js → studio-yr04mv2j.js} +4 -4
  106. package/dist/chunks/{studio-mhhc9btt.js → studio-zd4kayn2.js} +4 -4
  107. package/dist/chunks/studio-zpnk016a.js +16 -0
  108. package/dist/chunks/{tsMode-rtwt7w1a.js → tsMode-k9s9fcag.js} +5 -5
  109. package/dist/chunks/workspace-b69mgm0e.js +4 -0
  110. package/dist/chunks/ws-client-0ja08haa.js +4 -0
  111. package/dist/iframe-entry.js +14 -14
  112. package/dist/manifest.json +62 -59
  113. package/dist/studio.css +1 -1
  114. package/dist/studio.js +121 -123
  115. package/package.json +5 -5
  116. package/src/account/action-flow.ts +294 -0
  117. package/src/account/action-required.ts +68 -0
  118. package/src/account-status.ts +29 -1
  119. package/src/browse/library-model.ts +3 -1
  120. package/src/browse/library-preview.ts +6 -2
  121. package/src/canvas/asset-refs.ts +3 -1
  122. package/src/canvas/asset-resolve.ts +79 -1
  123. package/src/canvas/iframe-entry.ts +38 -1
  124. package/src/canvas/iframe-host.ts +85 -0
  125. package/src/canvas/iframe-protocol.ts +13 -0
  126. package/src/canvas/stage-scrollbar.ts +7 -7
  127. package/src/files/asset-versions.ts +294 -0
  128. package/src/files/file-ops.ts +5 -8
  129. package/src/files/files.ts +61 -9
  130. package/src/files/fs-events.ts +279 -28
  131. package/src/files/media-meta.ts +2 -1
  132. package/src/files/media-paths.ts +5 -2
  133. package/src/files/media-upload.ts +5 -1
  134. package/src/new-project/add-repo-modal.ts +12 -1
  135. package/src/new-project/new-project-modal.ts +12 -1
  136. package/src/panels/git-panel.ts +25 -2
  137. package/src/panels/jump-bar.ts +132 -158
  138. package/src/panels/pane-context.ts +8 -8
  139. package/src/panels/pane-grid.ts +18 -26
  140. package/src/panels/style-panel.ts +2 -2
  141. package/src/platform-errors.ts +61 -1
  142. package/src/platforms/cloud.ts +389 -50
  143. package/src/platforms/devserver.ts +17 -1
  144. package/src/publish/pages-service.ts +17 -7
  145. package/src/services/ai-models.ts +30 -6
  146. package/src/services/ai-system-prompt.ts +81 -51
  147. package/src/services/context-manager.ts +41 -70
  148. package/src/services/document-assistant.ts +12 -3
  149. package/src/services/harness/chat-reducer.ts +115 -0
  150. package/src/services/harness/turn-hooks.ts +50 -0
  151. package/src/services/tool-executor.ts +69 -288
  152. package/src/services/tool-outcomes.ts +12 -10
  153. package/src/settings/preferences-accounts.ts +42 -3
  154. package/src/settings/preferences-dialog.ts +8 -1
  155. package/src/studio.ts +20 -6
  156. package/src/surfaces/block-action-bar.json +6 -1
  157. package/src/surfaces/dialog.ts +5 -0
  158. package/src/surfaces/jump-bar.json +9 -12
  159. package/src/surfaces/jump-bar.ts +15 -16
  160. package/src/surfaces/pane-context.json +2 -2
  161. package/src/surfaces/pane-grid.json +8 -25
  162. package/src/surfaces/pane-grid.ts +7 -8
  163. package/src/surfaces/statusbar.json +71 -3
  164. package/src/surfaces/statusbar.ts +66 -139
  165. package/src/surfaces/style-panel.json +3 -3
  166. package/src/surfaces/style-panel.ts +11 -1
  167. package/src/surfaces/welcome.json +86 -1
  168. package/src/surfaces/welcome.ts +61 -2
  169. package/src/types.ts +84 -2
  170. package/src/ui/ai-managed-connect.ts +41 -4
  171. package/src/ui/media-picker.ts +2 -1
  172. package/dist/chunks/adapter-bsbs78x9.js +0 -4
  173. package/dist/chunks/cf-account-picker-gnm7xeqb.js +0 -4
  174. package/dist/chunks/cf-settings-9y6jyscp.js +0 -4
  175. package/dist/chunks/components-s51h3b7c.js +0 -4
  176. package/dist/chunks/content-source-ty3be0qg.js +0 -4
  177. package/dist/chunks/convert-to-repeater-c3e7q61z.js +0 -4
  178. package/dist/chunks/editor-t002b41m.js +0 -4
  179. package/dist/chunks/entry-commands-sb72e9gy.js +0 -4
  180. package/dist/chunks/extension-sections-ktn2ntnj.js +0 -4
  181. package/dist/chunks/file-ops-78zeytkm.js +0 -4
  182. package/dist/chunks/files-gatzrz8v.js +0 -4
  183. package/dist/chunks/format-host-r59b1651.js +0 -4
  184. package/dist/chunks/fs-events-f8h91ndt.js +0 -4
  185. package/dist/chunks/git-panel-y12zf7nj.js +0 -4
  186. package/dist/chunks/grid-view-rfd8b2pg.js +0 -51
  187. package/dist/chunks/grid-view-tafenfm2.css +0 -1
  188. package/dist/chunks/iframe-host-vsrsj20g.js +0 -4
  189. package/dist/chunks/index-5aghyrfh.js +0 -4
  190. package/dist/chunks/jx-validate-653krkrf.js +0 -4
  191. package/dist/chunks/layers-32p8gtae.js +0 -4
  192. package/dist/chunks/layers-panel-rs58m105.js +0 -4
  193. package/dist/chunks/lit-html-54bmkwz3.js +0 -4
  194. package/dist/chunks/media-picker-5bb04wct.js +0 -4
  195. package/dist/chunks/menu-cbha7w2e.js +0 -4
  196. package/dist/chunks/monaco-buffer-9vbbyfr1.js +0 -4
  197. package/dist/chunks/notify-dc1nz5ar.js +0 -4
  198. package/dist/chunks/platform-2m49s1zf.js +0 -4
  199. package/dist/chunks/publish-panel-nx3ycmma.js +0 -4
  200. package/dist/chunks/quick-search-yzrzh9x3.js +0 -4
  201. package/dist/chunks/references-vx7mbj9f.js +0 -4
  202. package/dist/chunks/right-panel-7jzpbxja.js +0 -4
  203. package/dist/chunks/section-registry-gjryse41.js +0 -4
  204. package/dist/chunks/studio-3znfhcxg.js +0 -5
  205. package/dist/chunks/studio-58qam27v.js +0 -4
  206. package/dist/chunks/studio-6j59fwaw.js +0 -5
  207. package/dist/chunks/studio-7z69g1gx.js +0 -5
  208. package/dist/chunks/studio-93j3v6zx.js +0 -5
  209. package/dist/chunks/studio-9gf6v8zy.js +0 -5
  210. package/dist/chunks/studio-9rhmettf.js +0 -4
  211. package/dist/chunks/studio-ac5aq677.js +0 -10
  212. package/dist/chunks/studio-as65vbns.js +0 -5
  213. package/dist/chunks/studio-bkv0sga4.js +0 -6
  214. package/dist/chunks/studio-bttmqef4.js +0 -5
  215. package/dist/chunks/studio-c3y9d41k.js +0 -5
  216. package/dist/chunks/studio-ccegp7gz.js +0 -9
  217. package/dist/chunks/studio-chxabn98.js +0 -6
  218. package/dist/chunks/studio-cktcdsxz.js +0 -16
  219. package/dist/chunks/studio-cnspfke5.js +0 -5
  220. package/dist/chunks/studio-de3p1ktm.js +0 -5
  221. package/dist/chunks/studio-fsbcn530.js +0 -928
  222. package/dist/chunks/studio-gftga7a3.js +0 -64
  223. package/dist/chunks/studio-hf1rpcq0.js +0 -4
  224. package/dist/chunks/studio-hz02hq70.js +0 -5
  225. package/dist/chunks/studio-jnb285we.js +0 -5
  226. package/dist/chunks/studio-jsv3s3s1.js +0 -5
  227. package/dist/chunks/studio-ks7cksh0.js +0 -5
  228. package/dist/chunks/studio-nptx0dbs.js +0 -5
  229. package/dist/chunks/studio-pg0z7k98.js +0 -5
  230. package/dist/chunks/studio-pve0b2f2.js +0 -5
  231. package/dist/chunks/studio-q7zmjv3b.js +0 -6
  232. package/dist/chunks/studio-rpmvw7kj.js +0 -5
  233. package/dist/chunks/studio-rwhss52s.js +0 -5
  234. package/dist/chunks/studio-sbg3g3h0.js +0 -5
  235. package/dist/chunks/studio-sq1bn60g.js +0 -14
  236. package/dist/chunks/studio-vwz7rma2.js +0 -5
  237. package/dist/chunks/studio-wa55e8gf.js +0 -5
  238. package/dist/chunks/studio-x0mzdha2.js +0 -5
  239. package/dist/chunks/studio-xrgpakvc.js +0 -9
  240. package/dist/chunks/studio-xt3djk1w.js +0 -7
  241. package/dist/chunks/studio-yh3nggx1.js +0 -7
  242. package/dist/chunks/studio-zmecp6hq.js +0 -5
  243. package/dist/chunks/workspace-g6dvaete.js +0 -4
  244. package/dist/chunks/ws-client-shf41j5p.js +0 -4
@@ -0,0 +1,5 @@
1
+ import{p,We}from"./studio-y7jehjrp.js";import{ge,Q,re,k}from"./studio-fqq890ap.js";import{Je,Yi,Ju,jl}from"./studio-7pgy3xaf.js";import{gL,Le,ms,uv,q,Hs,Ji,Vu,pa,Ue,Uu,xn,ot,yv,yi,li,Se,Do,qC,oo,He,Qn,m,u,Hn,$r,Cp}from"./studio-cvbkkfqb.js";import{Pd,wi}from"./studio-1x8x26k3.js";import{st,um,xc}from"./studio-pwqfmt4p.js";import{jC,Rd}from"./studio-888knnkc.js";import{Dv,$p,Mm,Wl,Kr,ro,Jr,Gs,nh,Ya,Fm,wI,Qo,jd,jm,ne}from"./studio-0k9mvpgj.js";import{ga,gr,zs,Ws,gs}from"./studio-st75kn99.js";import{Di,JT,Vb,YT,ps,$l,Ub,ZT,y,OC}from"./studio-zpnk016a.js";import{pm,hp,fm}from"./studio-a7xqhc3n.js";import{K,_o,ht,_n,Yo,qa,D,Xu,Qu,Ai}from"./studio-tp642n5g.js";import{Oe,Rv}from"./studio-vavmwshr.js";import{qe,Mp}from"./studio-nbxqcgvf.js";import{zv}from"./studio-edbtvcd1.js";function xt(e){let{target:t,source:n,targetOrigin:o,acceptOrigin:r,token:i}=e,s=new Set,a=(l)=>{if(r!=="*"&&l.origin!==r)return;let c=l.data;if(!c||typeof c!=="object"||c["jx:canvas"]!==i)return;for(let d of s)d(c.payload)};return n.addEventListener("message",a),{dispose(){s.clear(),n.removeEventListener("message",a)},onMessage(l){return s.add(l),()=>s.delete(l)},post(l){t.postMessage({["jx:canvas"]:i,payload:l},o)}}}var Yn=null;function Qw(){return Yn}function Uo(){return Yi(m.activePaneId)}function lt(e){let t=Hn(e),n=t?.derived,o=n?.kind==="lens"?Hn(n.sourcePaneId)?.activeTabId:t?.activeTabId;return o?m.tabs.get(o)??null:null}function ur(e){return Hn(e)?.derived??null}function Xw(e){if(!e)return[];let t=[];for(let n of m.panes)if(lt(n.id)?.id===e.id)t.push(Yi(n.id));return t}function _(e){for(let t of Ju()){let n=t.panels.find((o)=>o.canvas===e);if(n)return{panel:n,surface:t}}return null}function wt(e){let t=e.canvas,n=t?_(t):null;return n?lt(n.surface.paneId):null}function Tl(e){let t=e?.session.ui,n=t?.canvasMode??"design";return t?.preview&&(n==="edit"||n==="design")?"preview":n}function wo(e){let t=ur(e);if(t?.kind==="lens"){let n=t.mode;return lt(e)?.session.ui?.preview&&(n==="edit"||n==="design")?"preview":n}return Tl(lt(e))}function Nu(e){let t=ur(e);if(t?.kind==="lens"&&t.preset==="breakpoint")return t.media;return lt(e)?.session.ui.activeMedia??null}function $b(e){return jl(e)?.paneId??Qn}function im(e){return lt($b(e))}var ce=new Set(["img","video","source","iframe","audio"]),ue="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",eo="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='32'%20height='32'%3E%3Crect%20width='32'%20height='32'%20fill='%23d0d0d0'/%3E%3C/svg%3E",to=/(src|poster|image|bg|background|icon|logo|photo|avatar|thumbnail|cover|banner)$/i;function no(e){return to.test(e)}var io=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","li","dt","dd","th","td","span","strong","em","small","mark","code","abbr","q","sub","sup","time","a","button","label","legend","caption","summary","pre","option"]),ao=new Set(["div","section","article","aside","header","footer","main","nav","figure","figcaption","details","fieldset","form","ul","ol","dl","table"]);function so(e){if(!e.tagName||e.textContent||e.innerHTML)return null;if(e.$__layout)return null;if(Array.isArray(e.children)&&e.children.length>0)return null;if(io.has(qe(e.tagName)))return"empty-text-placeholder";if(ao.has(qe(e.tagName)))return"empty-container-placeholder";return null}function De(e){return e.replaceAll(/\$\{([^}]+)\}/g,"❪ $1 ❫")}function lo(e){let t=e.map;return{children:t&&typeof t==="object"?[A(t)]:[],className:"repeater-perimeter",tagName:"div"}}function A(e){if(!e||typeof e!=="object")return e;if(Array.isArray(e))return e.map((s)=>A(s));if(e.$prototype==="Array")return lo(e);let t=e,n={},o=!1,r=ce.has(t.tagName||"");if(r){let{attributes:s,src:a}=t,l=s?.src,c=t.poster,d=s?.poster;if(!(a&&a!==""||l&&l!=="")&&!(c&&c!==""||d&&d!==""))o=!0}for(let[s,a]of Object.entries(t))if(s==="state"||s==="$media"||s==="$elements")n[s]=a;else if(s==="$props"&&a&&typeof a==="object"){let l={};for(let[c,d]of Object.entries(a))if(typeof d==="string"&&d.includes("${"))if(no(c))l[c]=eo;else if(c==="href"||c==="action")l[c]="";else l[c]=De(d);else if(d&&typeof d==="object"&&d.$ref){let f=d.$ref,h=f.startsWith("#/state/")?f.slice(8):f;l[c]=`{${h}}`}else l[c]=d;n[s]=l}else if(s==="children")if(Array.isArray(a))n.children=a.map((l)=>A(l));else if(a&&typeof a==="object"&&a.$prototype==="Array")n.children=[A(a)];else n.children=A(a);else if(s==="cases"&&t.$switch&&a&&typeof a==="object"){let l=Object.keys(a);if(l.length>0){let c=a[l[0]];n.children=c&&typeof c==="object"&&!c.$ref?[A(c)]:[{style:{background:"color-mix(in srgb, var(--danger) 8%, transparent)",border:"1px dashed color-mix(in srgb, var(--danger) 40%, transparent)",borderRadius:"4px",color:"var(--danger)",fontFamily:"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace",fontSize:"11px",fontStyle:"italic",padding:"6px 10px"},tagName:"div",textContent:`[$switch: ${l.join(" | ")}]`}]}}else if(s==="attributes"&&r&&a&&typeof a==="object"){let l=a,c={};for(let[d,f]of Object.entries(l))if(d==="src"||d==="poster")if(typeof f==="string"&&f!==""&&!f.includes("${"))c[d]=f;else o=!0,c[d]=ue;else if(typeof f==="string"&&f.includes("${")){let h=d==="href"||d==="action";c[d]=h?"":De(f)}else if(f&&typeof f==="object"&&f.$ref){let h=f.$ref,b=h.startsWith("#/state/")?h.slice(8):h;c[d]=`{${b}}`}else c[d]=f;n.attributes=c}else if(s==="style")if(a&&typeof a==="object"){let l={};for(let[c,d]of Object.entries(a))if(typeof d!=="string"||!d.includes("${"))l[c]=d;n.style=l}else n.style=a;else if(typeof a==="string"&&a.includes("${"))if((s==="src"||s==="poster")&&ce.has(t.tagName||""))o=!0,n[s]=ue;else{let c=s==="src"||s==="href"||s==="poster"||s==="action";n[s]=c?"":De(a)}else if(a&&typeof a==="object"&&a.$ref){let l=a.$ref,c=l.startsWith("#/state/")?l.slice(8):l;if((s==="src"||s==="poster")&&ce.has(t.tagName||""))o=!0,n[s]=ue;else n[s]=`{${c}}`}else if((s==="src"||s==="poster")&&a===""&&ce.has(t.tagName||""))o=!0,n[s]=ue;else n[s]=A(a);let i=so(n);if(i)n.className=n.className?`${n.className} ${i}`:i;if(o){let s=n.className||"";if(!s.includes("empty-media-placeholder"))n.className=s?`${s} empty-media-placeholder`:"empty-media-placeholder"}return n}var co=/\[\.\.\.(\w+)\]|\[(\w+)\]/g;function uo(e){return e.split("\\").join("/").replace(/^\.\//,"").replace(/^\//,"").replace(/^pages\//,"")}function Ct(e){let t=uo(e),n=t.slice(t.lastIndexOf("/")+1),o=n.lastIndexOf(".");if(o>0)t=t.slice(0,t.length-(n.length-o));if(t.endsWith("/index"))t=t.slice(0,-6)||"/";else if(t==="index")t="/";if(!t.startsWith("/"))t=`/${t}`;let r=[],i=!1,s=!1,a=t.replaceAll(co,(l,c,d)=>{if(i=!0,c)return s=!0,r.push(c),"*";return r.push(d),`:${d}`});return{isCatchAll:s,isDynamic:i,params:r,urlPattern:a}}function Db(e){if(!e)return"/";return Ct(e).urlPattern}function Ll(e){if(!e)return[];return Ct(e).params}function yT(e){let t=e.document?.$paths,n=e.frontmatter?.$paths;return t??n??null}var pe=new Map;function wT(){pe.clear()}function xT(e,t){if(!t)return Promise.resolve({});let n=`${e??""}::${JSON.stringify(t)}`,o=pe.get(n);if(!o)o=po(t).catch((r)=>(pe.delete(n),console.warn("page-params: failed to enumerate $paths values:",r),{})),pe.set(n,o);return o}async function po(e){if(Array.isArray(e)){let t={};for(let n of e)for(let[o,r]of Object.entries(n))de(t,o,r);return t}if("contentType"in e&&typeof e.contentType==="string"&&e.contentType){let t=e.param??"slug",n=e.field??"id",o=await mo(e.contentType),r={[t]:[]};if(!Array.isArray(o))return r;for(let i of o)de(r,t,n==="id"?i.id:i.data?.[n]??i.id);return r}if("values"in e&&Array.isArray(e.values)){let t=e.param??"value",n={[t]:[]};for(let o of e.values)de(n,t,o);return n}if("$ref"in e&&typeof e.$ref==="string"&&e.$ref){let t=e.param??"id",n=e.field??"id",o=await p().readFile(e.$ref.replace(/^\.\//,"")),r=JSON.parse(o),i={[t]:[]};if(!Array.isArray(r))return i;for(let s of r)de(i,t,s?.[n]??s?.id??s);return i}return{}}async function fo(){let e=await Pd();for(let t of e){let n=t.classes?.find((o)=>o.name==="ContentCollection");if(n)return n.path}return"@jxsuite/parser/ContentCollection.class.json"}async function mo(e){let t={$prototype:"ContentCollection",$src:await fo(),contentType:e},n=p();if(n.resolveClass)return n.resolveClass(t);return fetch("/__jx_resolve__",{body:JSON.stringify(t),headers:{"content-type":"application/json"},method:"POST"}).then((o)=>{if(!o.ok)throw Error(`Class resolution failed: ${o.status}`);return o.json()})}function de(e,t,n){if(n===null||n===void 0||n==="")return;let o=String(n);e[t]??=[];let r=e[t];if(!r.includes(o))r.push(o)}function Pt(e,t,n){if(Object.keys(t).length===0)return e;let o=_e(e,t);return o.state??={},o.state.$page={params:{...t},title:typeof o.title==="string"?o.title:"",url:Db(n)},o}function St(e){if(!e)return[];return Object.keys(e).filter((t)=>{let n=e[t];return n&&typeof n==="object"&&typeof n.$prototype==="string"&&typeof n.$src==="string"&&JSON.stringify(n).includes('"#/$params/')})}async function Et(e,t,n){if(t.length===0)return;let o=p();if(!o.resolveClass)return;let{state:r}=e;if(!r)return;await Promise.all(t.map(async(i)=>{let s=r[i];if(!s||typeof s!=="object")return;try{r[i]=await o.resolveClass({...s,...n?{$base:n}:{}})}catch(a){console.warn(`page-params: failed to resolve state.${i} for preview:`,a)}}))}function _e(e,t){let n=ho(e,t);if(n!==null)return n;if(!e||typeof e!=="object")return e;if(Array.isArray(e))return e.map((r)=>_e(r,t));let o={};for(let[r,i]of Object.entries(e))o[r]=_e(i,t);return o}function ho(e,t){if(!e||typeof e!=="object"||Array.isArray(e))return null;let n=e.$ref;if(typeof n!=="string"||!n.startsWith("#/$params/"))return null;return t[n.slice(10)]??null}function ex(e){return typeof e?.tagName==="string"&&e.tagName.includes("-")}function Tt(e){if(e===null||typeof e==="number"||typeof e==="boolean")return"literal";if(typeof e==="string")return e.includes("${")?null:"literal";if(Array.isArray(e))return"literal";if(typeof e==="object"){let t=e;if(t.$expression||t.$compute||t.$prototype||t.$handler)return null;return"default"in t||"type"in t?"signal":"literal"}return null}function _T(e){let t=e?.state??{},n=[];for(let[o,r]of Object.entries(t)){if(Mp(o))continue;let i=Tt(r);if(!i)continue;let s=i==="signal"?r.default:r;n.push({name:o,value:s})}return n}function Mt(e,t){let n={...e.state??{}},o=!1;for(let[r,i]of Object.entries(t)){let s=Tt(n[r]);if(!s)continue;n[r]=s==="signal"?{...n[r],default:i}:i,o=!0}if(!o)return e;return{...e,state:n}}function Nt(e,t=[]){if(!e||typeof e!=="object")return null;if(Array.isArray(e.children)){let n=e.children.findIndex((o)=>o&&typeof o==="object"&&!o.$__layout);if(n!==-1)return{offset:n,prefix:[...t,"children"]};for(let o=0;o<e.children.length;o++){let r=e.children[o];if(r&&typeof r==="object"&&r.$__layout){let i=Nt(r,[...t,"children",o]);if(i)return i}}}return null}function je(e,t,n=[]){if(!e||typeof e!=="object")return;if(e.$__layout={file:t,path:n},Array.isArray(e.children))for(let[o,r]of e.children.entries()){if(typeof r==="string")continue;je(r,t,[...n,"children",o])}if(Array.isArray(e.$elements)){for(let[o,r]of e.$elements.entries())if(typeof r!=="string")je(r,t,[...n,"$elements",o])}}async function kt(e,t,n=null){let o={documentPath:t?.documentPath,mode:t?.doc.mode},r=n??Tl(t),i=r==="preview"?structuredClone(re(e)):A(Xu(e)),s=!1,a=o.documentPath&&D?.isSiteProject&&(o.documentPath.startsWith("pages/")||o.documentPath.startsWith("./pages/")),l=null,c=0;if(a&&t?.session.ui.showLayout!==!1){let w=$l(e.$layout);if(w){let v=await Ub(w);if(v){je(v,w.replace(/^\.\//,""));let C=r==="preview"?structuredClone(re(e)):i,x=ZT(v,C);i=r==="preview"?x:A(Xu(x)),s=!0;let E=Nt(x);l=E?.prefix??null,c=E?.offset??0}}}let d=hp(D?.projectRoot),f=o.documentPath?new URL(o.documentPath,d).href:void 0,h=fm(o.documentPath,{fileBaseUrl:d,...We()?{space:p().assetSpace}:{}});if(a&&t){let{previewParams:w}=t.session.ui;if(w&&Object.keys(w).length>0){let v=St(e.state??null);i=Pt(i,w,o.documentPath),await Et(i,v,f)}}if(!a&&t&&ex(i)){let{previewProps:w}=t.session.ui;if(w&&Object.keys(w).length>0)i=Mt(i,w)}let b=new Set;if(r!=="preview")(function w(v,C){if(!v||typeof v!=="object")return;if(v.$prototype==="Array"){b.add(C.join("/"));let x=v.map;if(x&&typeof x==="object")w(x,[...C,"map"]);return}if(Array.isArray(v.children))for(let x=0;x<v.children.length;x++){let E=v.children[x];if(typeof E==="string")continue;w(E,[...C,"children",x])}else if(v.children&&typeof v.children==="object"&&v.children.$prototype==="Array")w(v.children,[...C,"children"]);if(v.$switch&&v.cases)for(let[x,E]of Object.entries(v.cases))w(E,[...C,"cases",x])})(e,[]);let T=o.documentPath!=null&&(o.documentPath.startsWith("layouts/")||o.documentPath.startsWith("./layouts/")),R=Vb(i.$elements);if((o.mode==="content"||s||T)&&st.length>0){let w=new Set(R.map((C)=>typeof C==="string"?C:C?.$ref)),v=(C)=>{let x=new Set;if(!C||typeof C!=="object")return x;if(C.tagName)x.add(qe(C.tagName));if(Array.isArray(C.children)){for(let E of C.children)if(typeof E!=="string")for(let Xn of v(E))x.add(Xn)}return x};for(let C of v(i)){let x=st.find((E)=>E.tagName===C);if(x&&x.source!=="npm"&&x.path){let E=xc(o.documentPath??null,x.path);if(!w.has(E))R.push({$ref:E}),w.add(E)}}}if(R.length>0)i.$elements=R;i.imports=JT(i.imports);let O=Di(i.$media);if(O===void 0)delete i.$media;else i.$media=O;let U=YT(i.$head);if(U===void 0)delete i.$head;else i.$head=U;return{assets:h,docBase:f,mapperCtx:{arrayPaths:[...b],canvasMode:r,layoutWrapped:s,pageContentOffset:c,pageContentPrefix:l},renderDoc:i,siteStyle:D?.projectConfig?.style??null}}var CT="fullRender",kT="mountCanvas",ST="patchBatch",At="prepareRender",xo={derivedResolves:0,derivedRetargets:0,escalations:0,fullRenders:0,hostRenderPosts:0,lastEscalationReason:"",lastFullRenderMs:0,p95FullRenderMs:0,panelRenders:0,patchedOps:0,renderPreparations:0,skippedFullRenders:0,timings:{}};globalThis.__jxCanvasPerf=xo;var Rt=new Map;function $t(){try{return typeof localStorage<"u"&&Boolean(localStorage.getItem("jx-canvas-debug"))}catch{return!1}}function Ot(){return typeof performance<"u"&&typeof performance.now==="function"?performance.now():0}function It(e,t){if($t())console.debug(`[jx-canvas] ${e}`,t??"")}function Ab(e){xo.escalations+=1,xo.lastEscalationReason=e,It("escalation",e)}function go(e){if(e.length===0)return 0;let t=e.toSorted((o,r)=>o-r),n=Math.min(t.length-1,Math.ceil(t.length*0.95)-1);return t[Math.max(0,n)]??0}function vo(e,t){let n=Number.isFinite(t)&&t>0?t:0,o=Rt.get(e);if(!o)o=[],Rt.set(e,o);if(o.push(n),o.length>128)o.shift();let r=xo.timings[e],i={count:(r?.count??0)+1,lastMs:n,maxMs:Math.max(r?.maxMs??0,n),p95Ms:go(o),totalMs:(r?.totalMs??0)+n};if(xo.timings[e]=i,e==="fullRender")xo.lastFullRenderMs=i.lastMs,xo.p95FullRenderMs=i.p95Ms;It(`span:${e}`,`${n.toFixed(2)}ms`)}function Dt(e){let t=Ot(),n=$t(),o=`jx-${e}-start`;if(n)try{performance.mark(o)}catch{}let r=!1;return()=>{if(r)return xo.timings[e]?.lastMs??0;r=!0;let i=Ot()-t;if(n)try{performance.measure(`jx-${e}`,o),performance.clearMarks(o)}catch{}return vo(e,i),i}}function tx(e,t){let n=Dt(e);try{return t()}finally{n()}}async function nx(e,t){let n=Dt(e);try{return await t()}finally{n()}}function bi(e){if(e==="--")return"Base";return e.replace(/^--/,"").replaceAll("-"," ").replaceAll(/\b\w/g,(t)=>t.toUpperCase())||e}var Ht=new Set(["script","style","link","iframe","object","embed"]);function yd(e){let t={tagName:e};if(/^h[1-6]$/.test(e))t.textContent="Heading";else if(e==="p")t.textContent="Paragraph text";else if(e==="span"||e==="strong"||e==="em"||e==="small"||e==="mark"||e==="code"||e==="abbr"||e==="q"||e==="sub"||e==="sup"||e==="time")t.textContent="Text";else if(e==="a")t.textContent="Link",t.attributes={href:"#"};else if(e==="button")t.textContent="Button";else if(e==="label")t.textContent="Label";else if(e==="legend")t.textContent="Legend";else if(e==="caption")t.textContent="Caption";else if(e==="summary")t.textContent="Summary";else if(e==="li"||e==="dt"||e==="dd"||e==="th"||e==="td"||e==="option")t.textContent="Item";else if(e==="blockquote")t.textContent="Quote";else if(e==="pre")t.textContent="Preformatted text";else if(e==="input")t.attributes={placeholder:"Enter text...",type:"text"};else if(e==="img")t.attributes={alt:"Image"};else if(e==="iframe")t.attributes={src:""};else if(e==="slot")t.children=[{tagName:"p",textContent:"Slot content"}];else if(e==="select")t.children=[{tagName:"option",textContent:"Option 1"}];else if(e==="ul"||e==="ol")t.children=[{tagName:"li",textContent:"Item"}];else if(e==="dl")t.children=[{tagName:"dt",textContent:"Term"},{tagName:"dd",textContent:"Definition"}];else if(e==="table")t.children=[{children:[{children:[{tagName:"th",textContent:"Header"}],tagName:"tr"}],tagName:"thead"},{children:[{children:[{tagName:"td",textContent:"Cell"}],tagName:"tr"}],tagName:"tbody"}];else if(e==="details")t.children=[{tagName:"summary",textContent:"Summary"},{tagName:"p",textContent:"Detail content"}];return t}function j(e){if(!e)return[];if(Array.isArray(e.children))return e.children;return typeof e.textContent==="string"&&e.textContent.length>0?[e.textContent]:[]}function Y(e){let t=0;for(let n of e)t+=typeof n==="string"?n.length:Y(j(n));return t}function Fe(e,t,n){let o=[],r=0;for(let i of e){if(r>=n)break;if(typeof i==="string"){let c=r+i.length;if(c>t){let d=i.slice(Math.max(0,t-r),Math.max(0,Math.min(n,c)-r));if(d)o.push(d)}r=c;continue}let s=j(i),a=Y(s),l=r+a;if(a===0){if(r>=t&&r<n)o.push({...i})}else if(l>t){let c=Fe(s,Math.max(0,t-r),Math.min(n,l)-r);if(c.length>0)o.push(yo(i,c))}r=l}return o}function yo(e,t){let{children:n,textContent:o,...r}=e;if(t.length===0)return{...r,textContent:""};if(t.length===1&&typeof t[0]==="string")return{...r,textContent:t[0]};return{...r,children:t}}function Jt(e){let t=[];for(let n of e){if(typeof n==="string"){if(n.length===0)continue;let o=t.at(-1);if(typeof o==="string"){t[t.length-1]=o+n;continue}}t.push(n)}return t}function Lt(e,t,n,o,r=""){return Jt([...Fe(e,0,t),...r?[r]:[],...Fe(n,o,Y(n))])}function Ve(e){let t=Jt(e);if(t.length===0)return{textContent:""};if(t.length===1&&typeof t[0]==="string")return{textContent:t[0]};return{children:t}}function bo(e){if(!e)return!0;if(e.textContent!=null&&e.textContent.trim()==="")return!0;let t=e.children;if(!t)return!1;if(t.length===0)return!0;if(t.length===1&&typeof t[0]==="string"&&t[0].trim()==="")return!0;return t.length===1&&typeof t[0]==="object"&&t[0]?.tagName==="br"}function _t(e,t,n,o,r={}){if(!e)return;let i=K(e.doc.document,t);if(n){if(i&&JSON.stringify(i.children)===JSON.stringify(n))return;q(e,(s)=>{if(i?.textContent!=null)Ue(s,t,"textContent");Ue(s,t,"children",n)},{coalesceKey:r.coalesceKey??null})}else if(o!=null){if(i&&i.textContent===o&&!i.children)return;q(e,(s)=>{if(i?.children)Ue(s,t,"children");Ue(s,t,"textContent",o)},{coalesceKey:r.coalesceKey??null})}}function jt(e,t,n,o){if(!e)return!1;let r=K(e.doc.document,t);if(!r)return!1;if(`${r.$props?.[n]??""}`===o)return!1;return q(e,(s)=>{Uu(s,t,n,o)}),!0}function qt(e,t,n){if(!e)return null;let o=K(e.doc.document,t),r=K(e.doc.document,n);if(!o||!r)return null;if(qa(t,n)||qa(n,t))return null;let i=j(r),s=j(o),a=Y(i),l=Ve([...i,...s]);return q(e,(c)=>{if(l.children){if(r.textContent!=null)Ue(c,n,"textContent");Ue(c,n,"children",l.children)}else{if(r.children)Ue(c,n,"children");Ue(c,n,"textContent",l.textContent??"")}if(Vu(c,t),Ft(c,ht(t)),Cp(e))c.session.selection=[n]}),{offset:a,path:n}}function Ft(e,t){let n=t;while(n.length>0){let o=K(e.doc.document,n),r=o?.children;if(!o||!Array.isArray(r)||r.length>0)return;let i=ht(n);if(Vu(e,n),!i)return;n=i}}function Wt(e,t,n,o){let r=ht(t),i=_n(t),s=[...r,"children",i+1];if(!e)return s;let a={tagName:"p"};if(o.textContent!=null)a.textContent=o.textContent;else if(o.children)a.children=o.children;else a.textContent="";return q(e,(l)=>{if(n.textContent!=null)Ue(l,t,"children"),Ue(l,t,"textContent",n.textContent);else if(n.children)Ue(l,t,"textContent"),Ue(l,t,"children",n.children);if(Ji(l,r,i+1,a),Cp(e))l.session.selection=[s]}),s}function Vt(e,t,n,o){if(bo(o)){if(!e)return t;return q(e,(l)=>{Ue(l,t,"tagName",n.tag),Ue(l,t,"children");let c=yd(n.tag);if(c.textContent&&c.textContent!=="Paragraph text")Ue(l,t,"textContent",c.textContent);else Ue(l,t,"textContent");if(Cp(e))l.session.selection=[t]}),t}let r=ht(t),i=_n(t),s=[...r,"children",i+1];if(!e)return s;let a=yd(n.tag);return q(e,(l)=>{if(o?.children)Ue(l,t,"textContent"),Ue(l,t,"children",o.children);else if(o?.textContent!=null)Ue(l,t,"children"),Ue(l,t,"textContent",o.textContent);if(Ji(l,r,i+1,structuredClone(a)),Cp(e))l.session.selection=[s]}),s}function Bt(e,t,n,o,r){if(!e)return null;let i=K(e.doc.document,t.path),s=K(e.doc.document,n.path);if(!i||!s)return null;if(qa(t.path,n.path)||qa(n.path,t.path))return null;let a=Ve(Lt(j(i),t.offset,j(s),n.offset,r)),l=[...o,n.path].toSorted(Co);return q(e,(c)=>{if(a.children){if(i.textContent!=null)Ue(c,t.path,"textContent");Ue(c,t.path,"children",a.children)}else{if(i.children)Ue(c,t.path,"children");Ue(c,t.path,"textContent",a.textContent??"")}for(let d of l)if(K(c.doc.document,d))Vu(c,d),Ft(c,ht(d));if(Cp(e))c.session.selection=[t.path]}),{offset:t.offset+r.length,path:t.path}}function Co(e,t){let n=Math.min(e.length,t.length);for(let o=0;o<n;o++){let r=e[o],i=t[o];if(r===i)continue;if(typeof r==="number"&&typeof i==="number")return i-r;return String(i).localeCompare(String(r))}return t.length-e.length}function M(e,t=1){return{height:e.height*t,left:e.x*t,top:e.y*t,width:e.width*t}}function ET(e,t,n=1){return{x:(e.x-t.left)/n,y:(e.y-t.top)/n}}function fe(e,t){if(!t){e.style.display="none";return}e.style.display="block",e.style.left=`${t.left}px`,e.style.top=`${t.top}px`,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`}function zt(e=document){let t=e.createElement("div");t.className="jx-canvas-iframe-overlay",t.style.cssText="position:absolute;inset:0;pointer-events:none;overflow:hidden;z-index:2";let n=e.createElement("div");n.className="overlay-box overlay-selection",n.style.display="none";let o=e.createElement("div");o.className="overlay-label",o.style.display="none",n.append(o);let r=e.createElement("div");r.className="overlay-box overlay-hover",r.style.display="none";let i=e.createElement("div");i.className="canvas-drop-indicator",i.style.display="none";let s=e.createElement("button");s.className="insertion-helper",s.textContent="+",s.style.pointerEvents="auto",s.style.display="none";let a=e.createElement("div");a.className="canvas-replace-target",a.style.display="none";let l=e.createElement("div");l.className="overlay-presence-group";let c=e.createElement("div");return c.className="overlay-coselection-group",t.append(r,n,c,i,a,s,l),{dispose:()=>t.remove(),insertButton:s,root:t,setDropIndicator:(d,f="inside")=>So(i,d,f),setHover:(d)=>fe(r,d),setInsertZone:(d,f="center")=>Po(s,d,f),setReplaceTarget:(d)=>fe(a,d),setSuppressed:(d)=>{t.style.display=d?"none":""},setCoSelection:(d)=>{c.replaceChildren();for(let f of d){let h=e.createElement("div");h.className="overlay-box overlay-selection overlay-coselection",fe(h,f),c.append(h)}},setPresence:(d)=>{l.replaceChildren();for(let f of d){let h=e.createElement("div");h.className="overlay-box overlay-presence",h.style.cssText=`position:absolute;display:block;pointer-events:none;outline:1.5px solid ${f.color};outline-offset:1px;left:${f.placement.left}px;top:${f.placement.top}px;width:${f.placement.width}px;height:${f.placement.height}px`;let b=e.createElement("div");b.className="overlay-presence-tag",b.textContent=f.label,b.style.cssText=`position:absolute;top:-18px;left:-2px;padding:1px 5px;border-radius:3px;font:10px/1.4 sans-serif;color:#fff;white-space:nowrap;background:${f.color}`,h.append(b),l.append(h)}},setSelection:(d,f=null)=>{if(fe(n,d),d&&f)o.textContent=f,o.style.display="block";else o.style.display="none"}}}function Po(e,t,n){if(!t){e.style.display="none",e.classList.remove("visible");return}e.dataset.edge=n,e.classList.add("visible"),e.style.display="grid",e.style.left=`${t.left+t.width/2}px`,e.style.top=`${t.top+t.height/2}px`,e.style.translate="-50% -50%"}function So(e,t,n){if(!t){e.style.display="none";return}if(e.style.display="block",e.style.left=`${t.left}px`,e.style.width=`${t.width}px`,n==="inside"){e.className="canvas-drop-indicator inside",e.style.top=`${t.top}px`,e.style.height=`${t.height}px`;return}e.className="canvas-drop-indicator line",e.style.height="",e.style.top=`${n==="top"?t.top:t.top+t.height}px`}function Il(e){return JSON.stringify(e)}var wd={$id:"elements-meta",title:"HTML Element Metadata",description:"Inline scoping and inline toolbar action metadata for HTML elements.",$convertGroups:{text:["p","h1","h2","h3","h4","h5","h6","blockquote"],container:["div","section","article","aside","main","header","footer","nav","search"],list:["ul","ol"]},$defs:{p:{$convertTo:"text",$convertToWhenEmpty:["text","container"],$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:[{tag:"strong",label:"Bold",command:"bold"},{tag:"em",label:"Italic",command:"italic"},{tag:"u",label:"Underline",command:"underline"},{tag:"del",label:"Strikethrough",command:"strikethrough"},{tag:"sup",label:"Superscript",command:"superscript"},{tag:"sub",label:"Subscript",command:"subscript"},{tag:"code",label:"Code",command:"code"},{tag:"a",label:"Link",command:"link"}]},h1:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:[{tag:"strong",label:"Bold",command:"bold"},{tag:"em",label:"Italic",command:"italic"},{tag:"code",label:"Code",command:"code"},{tag:"a",label:"Link",command:"link"}]},h2:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h3:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h4:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h5:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h6:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},li:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},td:{$inlineChildren:["em","strong","del","code","a","span","br","b","i","u","sub","sup","s"],$inlineActions:"p"},th:{$inlineChildren:["em","strong","del","code","a","span","br","b","i","u","sub","sup","s"],$inlineActions:"p"},blockquote:{$convertTo:"text",$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},figcaption:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},caption:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},summary:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},dt:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},dd:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},label:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},a:{$inlineChildren:["em","strong","code","span","br","b","i","u","sub","sup"],$inlineActions:[{tag:"strong",label:"Bold",command:"bold"},{tag:"em",label:"Italic",command:"italic"},{tag:"code",label:"Code",command:"code"}]},span:{$inlineChildren:["em","strong","del","code","a","br","b","i","u","sub","sup","s"],$inlineActions:"p"},div:{$convertTo:"container",$convertToWhenEmpty:["container","text"],$inlineChildren:[]},section:{$convertTo:"container",$inlineChildren:[]},article:{$convertTo:"container",$inlineChildren:[]},nav:{$convertTo:"container",$inlineChildren:[]},main:{$convertTo:"container",$inlineChildren:[]},header:{$convertTo:"container",$inlineChildren:[]},footer:{$convertTo:"container",$inlineChildren:[]},aside:{$convertTo:"container",$inlineChildren:[]},ul:{$convertTo:"list",$inlineChildren:[]},ol:{$convertTo:"list",$inlineChildren:[]},pre:{$inlineChildren:["code"]},table:{$inlineChildren:[]},thead:{$inlineChildren:[]},tbody:{$inlineChildren:[]},tr:{$inlineChildren:[]}}};var To=new Set(["pre"]),na=new Set(Object.entries(wd.$defs).filter(([e,t])=>!To.has(e)&&(t.$inlineChildren?.length??0)>0).map(([e])=>e));var Kt=new Set(["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"]);function Be(e,t){if(!t)return Kt.has(e);let n=wd.$defs[t];if(!n||!n.$inlineChildren)return!1;return n.$inlineChildren.includes(e)}function TT(e){let t=wd.$defs[e];if(!t)return null;let n=t.$inlineActions;if(typeof n==="string")n=wd.$defs[n]?.$inlineActions??void 0;if(!Array.isArray(n))return null;return n}var Mo=null;function ix(e,t){if(!e||typeof e!=="object")return!1;let n=(qe(e.tagName)||"div").toLowerCase();if(t){let o=(qe(t.tagName)||"div").toLowerCase();return Be(n,o)}return Kt.has(n)}function LT(){return Mo!==null}function me(e){return!e||e==="base"?null:e}function Nb(e){let t=e.panels;if(t.length===0)return null;if(t.length===1)return t[0];let n=Nu(e.paneId);for(let o of t){if(n===null&&(o.mediaName==="base"||o.mediaName===null))return o;if(o.mediaName===n)return o}return t[0]}function Ut(){return Nb(Uo())}function IT(e,t){if(!e)return t;let n=t;while(n.length>=2){let o=K(e,n),r=ht(n),i=r?K(e,r):null;if(!o||!i)break;let s=(qe(o.tagName)||"div").toLowerCase(),a=(qe(i.tagName)||"div").toLowerCase();if(!Be(s,a))break;n=r}return n}function Ob(e){return Dv(e)!==null}function Ou(e){return Dv(e)}function hr(e){if(!e)return{baseWidth:320,featureQueries:[],sizeBreakpoints:[]};let t=[],n=[],o=320;for(let[r,i]of Object.entries(e)){if(r==="--"){let l=String(i).match(/^(\d+)\s*px$/);o=l?Number(l[1]):320;continue}let s=i.match(/min-width:\s*([\d.]+)px/),a=i.match(/max-width:\s*([\d.]+)px/);if(s)n.push({name:r,query:i,type:"min",width:Number(s[1])});else if(a)n.push({name:r,query:i,type:"max",width:Number(a[1])});else t.push({name:r,query:i})}return n.sort((r,i)=>r.type==="min"?r.width-i.width:i.width-r.width),{baseWidth:o,featureQueries:t,sizeBreakpoints:n}}function No(e,t){let n=new Set;for(let o of e)if(o.type==="min"&&t>=o.width)n.add(o.name);else if(o.type==="max"&&t<=o.width)n.add(o.name);return n}function Gt(e,t){let n=No(e,t),o=null;for(let r of e){if(!n.has(r.name))continue;let i=Math.abs(r.width-t);if(o===null){o=r;continue}let s=Math.abs(o.width-t);if(i<s||i===s&&r.width<o.width)o=r}return o?.name??null}function RT(e,t,n=8){let o=null;for(let r of t){let i=Math.abs(r-e);if(i>n)continue;if(o===null||i<Math.abs(o-e))o=r}return o??e}var cp=240,$T=8,DT=16,he=new Map;function ze(e){return hr(Di(e.doc.document?.$media))}function ox(e){let{baseWidth:t,sizeBreakpoints:n}=ze(e),o=e.session.ui.activeMedia;return n.find((r)=>r.name===o)?.width??t}function ko(e,t){let n=he.get(e);if(!n)return null;if(!t||n.tabId!==t.id||n.media!==t.session.ui.activeMedia)return he.delete(e),null;return n.width}function AT(e,t){let n=t?ox(t):0;return ko(e.paneId,t)??n}function rx(e){he.delete(e)}function NT(e){let{baseWidth:t,sizeBreakpoints:n}=ze(e);return[t,...n.map((o)=>o.width)]}function sx(e,t,n){let{sizeBreakpoints:o}=ze(t),r=Gt(o,n);return t.session.ui.activeMedia=r,he.set(e,{media:r,tabId:t.id,width:n}),r}var Ke={invokerTags:jm,popoverTags:jd};function G1(e,t){if(!e||!t)return null;for(let n=t.length;n>=0;n-=1){let o=t.slice(0,n),r=K(e,o);if(r&&typeof r==="object"&&Gs(r,Ke))return o}return null}function Zt(e,t){let n=e.doc.document;if(!n)return null;if(t){let o=K(n,t);return o&&typeof o==="object"&&Gs(o,Ke)?t:null}return G1(n,Le(e.session.selection))}function Xt(){let e=u.value?.doc.document;return e?wI(e,Ke):!1}var Yt=["toggle-popover","show-popover","hide-popover","show-modal","close","request-close"],Ge=new Set(["show-modal","close","request-close"]),Ze=new Set(["toggle-popover","show-popover","hide-popover"]),Ro=["any","closerequest","none"],Oo=new Set(["button"]),I="See docs/framework/concepts/overlays.";function H(e){return ro(e)==="dialog"}function Qt(e){return e.startsWith("--")}function Ao(e){let t=[];for(let{node:n}of Ya(e)){let o=nh(n);if(H(n)&&o!==null&&!t.includes(o))t.push(o)}return t}function en(e){for(let{node:t}of Ya(e))if(H(t))return!0;return!1}function $o(e){let t=e.oncommand;return t!==void 0&&t!==null}function Io(e,t){for(let{node:n}of Ya(e)){if(n===e)continue;let o=ro(n);if(o==="button"){let r=Kr(n,"command"),i=Kr(n,"commandfor");if(r!==null&&(r==="close"||r==="request-close")&&(i===null||i===t))return!0}if(o==="form"&&Kr(n,"method")?.toLowerCase()==="dialog")return!0}return!1}function vT(e,t){let n=[...Ya(e,[],null,t)],o=Ao(e),r=Fm(e,t),i=o.length>0||r.length>0,s=new Map,a=new Map;for(let{node:c}of n){let d=nh(c);if(d!==null&&!s.has(d))s.set(d,c);if(ro(c)==="button"){let f=Kr(c,"commandfor"),h=Kr(c,"command");if(f!==null){let b=a.get(f)??new Set;b.add(h??""),a.set(f,b)}}}let l=[];for(let{node:c,path:d}of n)if(l.push(...Ho(c,d,s,o,r,i,t)),H(c))l.push(...Jo(c,d,a));return l}function Ho(e,t,n,o,r,i,s){let a=[],l=ro(e),c=s?.invokerTags?.has(l)??!1,d=Kr(e,"command"),f=Kr(e,"commandfor");if(!(d!==null||f!==null||("command"in Wl(e))||("commandfor"in Wl(e))))return a;let b=Jr(e,"the element");if(!Oo.has(l)&&!c)return a.push({detail:"`command` and `commandfor` are attributes of `HTMLButtonElement` and of no other "+"interface — not even `<input>`, which `popovertarget` does allow. Elsewhere they parse "+`and do nothing. Make it a <button>, or remove both attributes. ${I}`,fix:"invoker",message:`<${l||"element"}> carries command/commandfor, which only <button> supports.`,path:t,rule:"invoker-not-button",severity:"error"}),a;if(d!==null&&!Yt.includes(d)&&!Qt(d))return a.push({detail:`\`command\` is an enumerated attribute taking ${Yt.map((T)=>`\`${T}\``).join(", ")}, or a custom command starting with \`--\`. Anything else is the invalid-value state, and a button in that state does nothing when clicked. ${I}`,message:`${b} declares command="${d}", which is not a built-in or --custom command.`,path:t,rule:"command-invalid",severity:"error"}),a;if(f!==null){let T=n.get(f),R=o.includes(f),O=r.includes(f);if(!T&&i){let U=[...o,...r].map((w)=>`"${w}"`).join(", ");return a.push({detail:`No element in this document has the id "${f}". The dialogs and popovers here are: ${U}. A commandfor that names nothing does nothing, silently. ${I}`,message:`commandfor="${f}" names nothing in this document.`,path:t,rule:"command-target-missing",severity:"error"}),a}if(d!==null&&T){if(Ge.has(d)&&!H(T))a.push({detail:`\`${d}\` acts on a <dialog>, and "${f}" is ${O?"a popover":`a <${ro(T)||"element"}>`}. The click is ignored. ${O?"Use `toggle-popover`, `show-popover` or `hide-popover` for a popover.":"Point it at a dialog, or make the target one."} ${I}`,message:`${b} sends ${d} to "${f}", which is not a dialog.`,path:t,rule:"command-target-mismatch",severity:"error"});else if(Ze.has(d)&&!Gs(T,s))a.push({detail:`\`${d}\` acts on a popover, and "${f}" is ${R?"a dialog":`a <${ro(T)||"element"}>`} that declares no \`popover\`. The click is ignored. ${R?"Use `show-modal`, `close` or `request-close` for a dialog.":"Give the target a `popover` attribute, or point the button elsewhere."} ${I}`,message:`${b} sends ${d} to "${f}", which is not a popover.`,path:t,rule:"command-target-mismatch",severity:"error"});else if(Qt(d)&&!$o(T))a.push({detail:`A custom command is a \`CommandEvent\` dispatched at its target, and "${f}" has no `+"`oncommand` handler to answer it — so the click does nothing. Add one that switches on "+`\`event#/command\`, or use a built-in command. ${I}`,message:`${b} sends ${d} to "${f}", which handles no command.`,path:t,rule:"custom-command-unhandled",severity:"warn"})}}return a}function Jo(e,t,n){let o=[],r=Jr(e,"the dialog"),i=nh(e),{style:s}=e,a=Kr(e,"closedby");if(a!==null&&!Ro.includes(a))o.push({detail:`\`closedby\` is an enumerated attribute taking \`any\` (light dismiss and Escape), \`closerequest\` (Escape only, the default for a modal) or \`none\`. Anything else is the invalid-value default, \`auto\`, which is the same as leaving it out. ${I}`,message:`${r} declares closedby="${a}", which is not any, closerequest or none.`,path:t,rule:"dialog-closedby-invalid",severity:"error"});if(Qo(s,"display")!==null)o.push({detail:`A closed dialog is hidden by the browser's own \`dialog:not([open]) { display: none }\`. That rule is UA-origin, so any author \`display\` beats it, and the dialog is laid out on every page whether or not anyone opened it. \`display\` belongs in the \`&[open]\` rule and nowhere else. ${I}`,fix:"display",message:`${r} sets display in its base rule.`,path:t,rule:"dialog-display",severity:"error"});let l=i===null?void 0:n.get(i),c=Kr(e,"open")!==null||Wl(e).open===!0||e.open===!0;if(i!==null&&!l?.has("show-modal")&&!c)o.push({detail:`No <button> in this document opens it with \`command="show-modal"\`. If it is opened from another file or from a function that calls \`showModal()\`, this is fine; otherwise there is no way for a reader to open it. ${I}`,message:`${r} has no invoker in this document.`,path:t,rule:"dialog-no-invoker",severity:"warn"});if(l?.has("show-modal")&&a==="none"&&!Io(e,i))o.push({detail:`A modal dialog makes everything outside it inert, so the only ways out are the ones it offers: \`closedby="none"\` turns off Escape and light dismiss, and nothing inside it closes it. A reader who opens it cannot leave. Add a <button command="close"> inside, or drop \`closedby="none"\`. ${I}`,message:`${r} opens modally, closes on nothing, and has no close button.`,path:t,rule:"modal-without-close",severity:"error"});return o}function K1(e,t){if(!e||!t)return null;for(let n=t.length;n>=0;n-=1){let o=t.slice(0,n),r=K(e,o);if(r&&typeof r==="object"&&H(r))return o}return null}function ax(e,t){let n=e.doc.document;if(!n)return null;if(t){let o=K(n,t);return o&&typeof o==="object"&&H(o)?t:null}return K1(n,Le(e.session.selection))}function tn(){let e=u.value?.doc.document;return e?en(e):!1}function V(e){return lt(e.paneId)}function ee(e){let t=ur(e.paneId);if(t?.kind==="lens")return t.zoom;return V(e)?.session.ui.zoom??1}function lx(e=Uo()){return ee(e)}function ve(e,t){let n=ur(e.paneId);if(n?.kind==="lens"){n.zoom=t;return}let o=V(e);if(o)o.session.ui.zoom=t}function Mu(e,t,n,o=null){let r={_width:o||null,canvas:null,element:null,mediaName:e||"",ready:!1,renderScope:null,scrollContainer:null,viewport:null},i=[];if(o&&!n)i.push(`--panel-viewport-w:${o}px`);if(o)i.push(`--panel-canvas-w:${o}px`);return{item:{fullWidth:n,header:t?"shown":"hidden",key:e??"",label:t??"",mediaAttr:e,widthVars:i.join(";")},panel:r}}function OT(e,t){for(let{item:n,panel:o}of e)o.element=t.panelNode(n.key,"panel"),o.viewport=t.panelNode(n.key,"panel-viewport"),o.canvas=t.panelNode(n.key,"panel-canvas")}function MT(e,t){let n=e.find((r)=>r.item.key===t);if(!n)return;let o=wt(n.panel);if(o)o.session.ui.activeMedia=me(n.item.mediaAttr)}function Qe(e){if(!e.panzoomWrap)return;let t=e.wrap.clientWidth,n=e.panzoomWrap.scrollWidth,o=ee(e),r=n*o;e.panX=Math.max(16,(t-r)/2),e.panY=0}function Mb(e){if(e.centerObserver)e.centerObserver.disconnect(),e.centerObserver=null;if(!e.panzoomWrap)return;e.needsCenter=!0,e.centerObserver=new ResizeObserver(()=>{if(!e.needsCenter){e.centerObserver?.disconnect(),e.centerObserver=null;return}Qe(e),us(e)}),e.centerObserver.observe(e.panzoomWrap),Qe(e)}function us(e){if(!e.panzoomWrap)return;let t=ee(e);e.panzoomWrap.style.transform=`translate(${e.panX}px, ${e.panY}px) scale(${t})`,Ai("overlays")}var et=0.25,tt=3;function rn(e){return Math.min(tt,Math.max(et,e))}function xd(e=Uo()){if(wo(e.paneId)!=="edit")return;let[t]=e.panels;if(!t?.canvas||!t.viewport)return;let n=t.canvas,o=n.querySelector("iframe"),r=V(e)?.session.ui.editZoom??1;if(r===1){if(t._width=null,n.style.width="",n.style.transform="",n.style.transformOrigin="",o)o.style.width="100%";t.viewport.style.height=""}else{let i=e.wrap.querySelector('[part="edit-column"]');if(!i)return;let s=Oe(i).width;if(s<=0)return;let a=s/r;if(t._width=a,n.style.width=`${a}px`,n.style.transform=`scale(${r})`,n.style.transformOrigin="top left",o)o.style.width=`${a}px`,t.viewport.style.height=`${o.offsetHeight*r}px`}Ai("overlays")}function Pu(e,t=Uo()){let n=V(t);if(!n)return;n.session.ui.editZoom=rn(e),xd(t)}var Xe=new Map;function PT(e,t=Uo()){let n=V(t);if(!n)return;if(n.session.ui.editZoom=rn(e),Xe.has(t.paneId))return;Xe.set(t.paneId,requestAnimationFrame(()=>{Xe.delete(t.paneId),xd(t)}))}function an(e,t,n){if(!e.panzoomWrap)return;let o=e.wrap.clientWidth,r=e.wrap.clientHeight,i=24,s=32,a=0,{panels:l}=e;for(let v of l)a+=v._width||800;a+=i*Math.max(0,l.length-1)+s;let c=ee(e),h=Oe(e.panzoomWrap).height/c+s,b=o/a,T=r/h,R=t==="width"?b:Math.min(b,T),O=Math.min(n,Math.max(F,R));ve(e,O);let U=a*O,w=h*O;e.panX=Math.max(0,(o-U)/2),e.panY=Math.max(0,(r-w)/2),us(e)}function FT({maxZoom:e=W,surface:t=Uo()}={}){te("page",t),an(t,"page",e)}var F=0.05,W=5;function rt(e){return Math.min(W,Math.max(F,e))}var Lo="page",nt=["width","page","none"];function jo(e,t,n){let o=t[n];if(typeof o==="string"&&nt.includes(o))return o;if(typeof o==="number"&&o>=F&&o<=W)return o;throw RangeError(`command "${e}" argument "${n}": expected ${nt.map((r)=>`"${r}"`).join(" | ")} or a number in [${F}, ${W}], got ${JSON.stringify(o)}`)}var sn=new Map;function ln(e){let t=V(e);if(!t)return null;let n=ur(e.paneId)?.kind==="lens"?`::${e.paneId}`:"";return`${t.id}::${t.documentPath??""}${n}`}function te(e,t){let n=ln(t);if(n)sn.set(n,e)}function cx(e=Uo()){let t=ln(e);return(t===null?void 0:sn.get(t))??Lo}function cn(e,t=Uo()){let n=e??cx(t);if(n==="none"){us(t);return}if(typeof n==="number"){ve(t,rt(n)),us(t);return}an(t,n,1)}function J1(e,t=Uo()){te(e,t),cn(e,t)}function jT(e=Uo()){te(rt(ee(e)),e)}function dx(e,t=Uo()){if(!V(t))return;let o=rt(e);te(o,t),ve(t,o),us(t)}function ux(e){if(e.wrap.clientWidth<=0){us(e);return}cn(cx(e),e)}function HT(e=Uo()){if(te(1,e),!e.panzoomWrap)return;ve(e,1),Qe(e),us(e)}function qo(e,t){let n=Oe(un(e)??e.wrap),o=t.top+t.height/2-n.top;return n.height/2-o}function un(e){return Nb(e)?.scrollContainer??null}function Fo(e,t,n){let o=un(e);if(!o){Wo(e,t);return}let r=o.scrollTop-t;if(n){o.scrollTo({behavior:"smooth",top:r});return}o.scrollTop=r}function Pb(e,t=Uo()){Fo(t,qo(t,e),!1)}function Wo(e,t){let n=e.panY,o=n+t,r=performance.now(),i=250,s=(a)=>{let l=Math.min((a-r)/250,1),c=l*(2-l);if(e.panY=n+(o-n)*c,us(e),l<1)requestAnimationFrame(s)};requestAnimationFrame(s)}var Ye=["edit","design","preview","source","stylebook","grid","git-diff"],ye=new Set(["edit","design"]),Vo=["edit","design","preview"];function Bo(e){return Vo.filter((t)=>e.capabilities.modes.includes(t))}function BT(e){return Bo(e).filter((t)=>t!=="preview")}function Y1(e){let t=e.session.ui.canvasMode;return ye.has(t)?t:null}function Z1(e){return{available:e.capabilities.modes.includes("preview")&&ye.has(e.session.ui.canvasMode),on:e.session.ui.preview===!0}}function X1(e,t,n){if(t==="preview"){if(ye.has(e.session.ui.canvasMode))e.session.ui.preview=!0;return}if(e.session.ui.preview=!1,e.session.ui.canvasMode!==t)n(e,t)}var nn=new Set(["design","stylebook","git-diff"]),N=(e)=>e.document.open,on=["auto","light","dark"];function zo(e){function t(s){let a=u.value;if(!a)throw RangeError(`command "${s}" needs an open document; no tab is active`);return a}function n(s,a){let{pane:l}=a;if(l===void 0)return t(s);let c=ot(s,a,"pane"),d=lt(c);if(!d)throw RangeError(`command "${s}" argument "pane": "${c}" has no open document`);return d}let o={pane:He("Which pane to render this way. Defaults to the focused one.")};function r(s){e.renderPane(i(s))}function i(s){let{pane:a}=s;return typeof a==="string"?a:m.activePaneId}return[{args:Se({mode:Do(Ye,"The canvas mode to switch the active pane to.")}),category:"View",id:"canvas.setMode",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:N,aiTool:{description:"Switch the active document's editor mode. edit and design put its element tree on the canvas, where the document tools work; preview renders it as a visitor sees it; source shows the JSON; stylebook, grid and git-diff open other editors. Use it to return a document to edit or design when the tree tools are refused.",name:"set_canvas_mode",report:({after:s,args:a})=>{let l=li("canvas.setMode",a,"mode",Ye),c=s.editor.kind==="canvas"?"the document tools address its element tree":"the tree-editing tools are unavailable until it returns to edit or design";return`The active document is in ${l} mode; ${c}.`}},run:(s,a)=>{let l=li("canvas.setMode",a,"mode",Ye),c=t("canvas.setMode"),{modes:d}=c.capabilities;if(!d.includes(l))throw RangeError(`command "canvas.setMode" argument "mode": "${l}" is not a mode this document `+`supports — it declares: ${d.join(", ")}`);if(l==="preview"){let f=c.session.ui.canvasMode;if(!ye.has(f))throw RangeError(`command "canvas.setMode" argument "mode": "preview" composes with the edit and design base modes; this pane is in "${f}"`);c.session.ui.preview=!0;return}c.session.ui.preview=!1,e.setCanvasMode(c,l)},title:"Set Canvas Mode"},{args:Se({zoom:qC("Pan-zoom scale, 1 = 100%.",{maximum:W,minimum:F})}),category:"View",id:"canvas.setZoom",level:"document",menus:["palette"],group:"3_canvas",requires:"a document on the pan-zoom surface",when:N,enablement:()=>nn.has(e.getCanvasMode()),run:(s,a)=>{t("canvas.setZoom"),dx(yv("canvas.setZoom",a,"zoom",F,W))},title:"Set Zoom"},{args:Se({fit:{description:'How the document is framed: "width" | "page" | "none", or a numeric pan-zoom scale.',oneOf:[{enum:[...nt],type:"string"},{maximum:W,minimum:F,type:"number"}]}}),category:"View",id:"canvas.setFit",level:"document",menus:["palette"],group:"3_canvas",requires:"a document on the pan-zoom surface",when:N,enablement:()=>nn.has(e.getCanvasMode()),run:(s,a)=>{t("canvas.setFit"),J1(jo("canvas.setFit",a,"fit"))},title:"Set Fit"},{args:Se({zoom:qC("Edit-mode content zoom, 1 = 100%.",{maximum:tt,minimum:et})}),category:"View",id:"canvas.setEditZoom",level:"document",menus:["palette"],group:"3_canvas",requires:"a document in edit mode",when:N,enablement:()=>e.getCanvasMode()==="edit",run:(s,a)=>{t("canvas.setEditZoom"),Pu(yv("canvas.setEditZoom",a,"zoom",et,tt))},title:"Set Edit Zoom"},{args:{additionalProperties:!1,properties:{...o,width:{description:"How wide the Edit column should render, in CSS pixels, or null to go back to the chosen breakpoint's own width.",type:["number","null"]}},required:["width"],type:"object"},category:"View",id:"canvas.setEditWidth",level:"document",menus:["palette"],group:"3_canvas",requires:"a document in edit mode",when:N,enablement:()=>e.getCanvasMode()==="edit",run:(s,a)=>{let l=n("canvas.setEditWidth",a),{width:c}=a;if(c===null){rx(i(a)),r(a);return}sx(i(a),l,yv("canvas.setEditWidth",a,"width",cp,1e4)),r(a)},title:"Set Edit Width"},{args:{additionalProperties:!1,properties:{...o,media:{description:"A breakpoint key the document renders under, or null for the base rendering.",type:["string","null"]}},required:["media"],type:"object"},category:"View",id:"canvas.setBreakpoint",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:N,run:(s,a)=>{let l=n("canvas.setBreakpoint",a),{media:c}=a;if(c!==null&&typeof c!=="string")throw RangeError('command "canvas.setBreakpoint" argument "media": expected a breakpoint key or null');let d=Object.keys(Di(l.doc.document?.$media));if(c!==null&&!d.includes(c))throw RangeError(`command "canvas.setBreakpoint" argument "media": "${c}" is not a breakpoint this `+`document defines — it defines: ${d.length>0?d.join(", "):"nothing"}`);l.session.ui.activeMedia=c,r(a)},title:"Set Breakpoint"},{args:Se({...o,scheme:Do(on,"Which color scheme the canvas renders in.")},["scheme"]),category:"View",id:"canvas.setColorScheme",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:N,run:(s,a)=>{let l=n("canvas.setColorScheme",a);l.session.ui.previewColorScheme=li("canvas.setColorScheme",a,"scheme",on),r(a)},title:"Set Color Scheme"},{args:Se({...o,locale:He("BCP 47 tag this pane renders as.")},["locale"]),category:"View",id:"i18n.switchLocale",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document in a project that declares more than one locale",when:(s)=>s.document.open&&s.project.isMultilingual,run:(s,a)=>{let l=n("i18n.switchLocale",a),c=ot("i18n.switchLocale",a,"locale"),d=ps();if(d===null||!d.locales.includes(c))throw RangeError(`command "i18n.switchLocale" argument "locale": "${c}" is not a locale this `+`project declares — it declares: ${d===null?"nothing":d.locales.join(", ")}`);l.session.ui.previewLocale=c,r(a)},title:"Set Rendering Language"},{args:Se({...o,visible:oo("True to draw the page's layout elements, false to hide them.")},["visible"]),category:"View",id:"canvas.setLayoutVisible",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:N,run:(s,a)=>{let l=n("canvas.setLayoutVisible",a);l.session.ui.showLayout=yi("canvas.setLayoutVisible",a,"visible"),r(a)},title:"Show Layout Elements"},{args:Se({...o,open:oo("True to draw the popover open, false to close it."),path:{description:"Document path of the popover. Defaults to the popover the selection is in or at.",items:{type:["string","number"]},type:"array"}},[]),category:"View",enablement:()=>Xt(),group:"3_canvas",id:"canvas.setPopoverOpen",level:"document",menus:["palette"],requires:"a popover in the open document",run:(s,a)=>{let l=n("canvas.setPopoverOpen",a),c=a??{},d=c.open===void 0?!0:yi("canvas.setPopoverOpen",a,"open");if(!d&&c.path===void 0){e.setOpenPopover(l,null);return}let f=Zt(l,c.path);if(f===null)throw RangeError('command "canvas.setPopoverOpen" argument "path": names no popover in this document — '+"a popover is an element with a `popover` attribute, and <dialog> is not one");e.setOpenPopover(l,d?f:null)},title:"Show Popover",when:N},{args:Se({...o,open:oo("True to draw the dialog open, false to close it."),path:{description:"Document path of the dialog. Defaults to the dialog the selection is in or at.",items:{type:["string","number"]},type:"array"}},[]),category:"View",enablement:()=>tn(),group:"3_canvas",id:"canvas.setDialogOpen",level:"document",menus:["palette"],requires:"a dialog in the open document",run:(s,a)=>{let l=n("canvas.setDialogOpen",a),c=a??{},d=c.open===void 0?!0:yi("canvas.setDialogOpen",a,"open");if(!d&&c.path===void 0){e.setOpenDialog(l,null);return}let f=ax(l,c.path);if(f===null)throw RangeError('command "canvas.setDialogOpen" argument "path": names no dialog in this document — '+"a dialog is a <dialog> element, and a popover is not one");e.setOpenDialog(l,d?f:null)},title:"Show Dialog",when:N},{args:{additionalProperties:!1,properties:{...o,open:{default:!0,description:"True to open the resolving-with popover, false to close it.",type:"boolean"}},required:[],type:"object"},category:"View",id:"canvas.setResolvingOpen",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:N,run:(s,a)=>{n("canvas.setResolvingOpen",a);let{open:l,pane:c}=a;e.setResolvingOpen(typeof c==="string"?c:m.activePaneId,l===void 0||yi("canvas.setResolvingOpen",a,"open"))},title:"Show Resolving Values"},{args:{additionalProperties:!1,properties:{...o,name:He("The prop's name, as the component's state declares it."),value:{description:"The test value — any JSON. Null clears it and the prop returns to its default.",type:["string","number","boolean","array","object","null"]}},required:["name"],type:"object"},category:"View",id:"canvas.setTestProp",level:"document",menus:["palette"],group:"3_canvas",requires:"an open component document",when:N,run:(s,a)=>{let l=n("canvas.setTestProp",a),c=ot("canvas.setTestProp",a,"name"),d=Object.keys(l.doc.document?.state??{});if(!d.includes(c))throw RangeError(`command "canvas.setTestProp" argument "name": "${c}" is not a prop this component `+`declares — it declares: ${d.length>0?d.join(", "):"nothing"}`);let{value:f}=a,h={...l.session.ui.previewProps};if(f===null||f===void 0)delete h[c];else h[c]=f;l.session.ui.previewProps=Object.keys(h).length>0?h:null,r(a)},title:"Set Test Value"},{args:{additionalProperties:!1,properties:{...o,name:He("The route parameter's name, without brackets."),value:He("The value to preview the route with. Empty clears it.")},required:["name","value"],type:"object"},category:"View",id:"canvas.setRouteParam",level:"document",menus:["palette"],group:"3_canvas",requires:"an open page with a dynamic route",when:N,run:(s,a)=>{let l=n("canvas.setRouteParam",a),c=ot("canvas.setRouteParam",a,"name"),d=Ll(l.documentPath);if(!d.includes(c))throw RangeError(`command "canvas.setRouteParam" argument "name": "${c}" is not a parameter of this `+`route — it has: ${d.length>0?d.join(", "):"none"}`);l.session.ui.previewParams={...l.session.ui.previewParams,[c]:ot("canvas.setRouteParam",a,"value")},r(a)},title:"Set Route Parameter"}]}function zT(e,t){e.registerAll(zo(t))}function Fb(e=Uo()){let t=Nu(e.paneId);for(let n of e.panels){let o=n.element?.querySelector('[part="panel-header"]');if(o){let r=t===null&&n.mediaName==="base"||t===null&&n.mediaName===null||t===n.mediaName;o.toggleAttribute("data-active",r)}}}var J=null;function Ko(e){if(J?.isConnected)return J;let t=e.createElement("div");return t.className="jx-drag-ghost",t.style.cssText="position:fixed;left:0;top:0;z-index:9999;pointer-events:none;display:none;padding:2px 8px;border-radius:4px;font-size:12px;line-height:1.4;white-space:nowrap;background:var(--accent,#3b82f6);color:var(--accent-fg,#fff);box-shadow:0 2px 8px rgba(0,0,0,0.25);transform:translate(8px,8px)",e.body.append(t),J=t,t}function Q1(e,t,n,o=document){let r=Ko(o);r.textContent=e,r.style.left=`${t}px`,r.style.top=`${n}px`,r.style.display="block"}function hx(e,t){if(!J||J.style.display==="none")return;J.style.left=`${e}px`,J.style.top=`${t}px`}function _d(){if(J)J.style.display="none"}var dn=function(){if(typeof window>"u")return null;var e=new Image;return e.src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",e}();function wc(e){var t=e.nativeSetDragImage;if(t&&dn)t(dn,0,0)}function pn(e,t){if(e==null)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(t.indexOf(o)!==-1)continue;n[o]=e[o]}return n}function fn(e,t){if(e==null)return{};var n,o,r=pn(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function be(e,t){var n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;return n.every(function(r){return Object.is(e[r],t[r])})}function mn(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:be,t=null;return function(n){if(t&&e(t.value,n))return t.value;return t={value:n},t.value}}var Go=["block"];function hn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,o)}return n}function gn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?hn(Object(n),!0).forEach(function(o){ga(e,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hn(Object(n)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(n,o))})}return e}function Zo(e){return{x:(e.right+e.left)/2,y:(e.bottom+e.top)/2}}function it(e){var{client:t,borderBox:n}=e,o=n.height/4;if(t.y<=n.top+o)return"reorder-above";if(t.y>=n.bottom-o)return"reorder-below";return"make-child"}function Xo(e){var{element:t,input:n,currentLevel:o,indentPerLevel:r,mode:i}=e,s={x:n.clientX,y:n.clientY},a=t.getBoundingClientRect();if(i==="standard"){var l=it({borderBox:a,client:s});return{type:l,indentPerLevel:r,currentLevel:o}}var c=Zo(a);if(i==="expanded"){var d=it({borderBox:a,client:s});return{type:d==="reorder-above"?d:"make-child",indentPerLevel:r,currentLevel:o}}var f=r*o;if(s.x<a.left+f){if(s.y<c.y)return{type:"reorder-above",indentPerLevel:r,currentLevel:o};var h=(s.x-a.left)/r,b=Math.max(Math.floor(h),0);return{type:"reparent",desiredLevel:b,indentPerLevel:r,currentLevel:o}}return{type:it({borderBox:a,client:s}),indentPerLevel:r,currentLevel:o}}function vn(e,t){if(e.type!==t.type)return!1;if(e.type==="instruction-blocked"&&t.type==="instruction-blocked")return vn(e.desired,t.desired);return be(e,t)}var er=mn(vn);function tr(e){var{desired:t,block:n}=e;if(n!==null&&n!==void 0&&n.includes(t.type)&&t.type!=="instruction-blocked"){var o={type:"instruction-blocked",desired:t};return o}return t}function jb(e,t){var n=t.block,o=fn(t,Go),r=Xo(o),i=tr({desired:r,block:n}),s=er(i);return gn(gn({},e),{},ga({},xe,s))}function Fu(e){var t;return(t=e[xe])!==null&&t!==void 0?t:null}var xe=Symbol("tree-item-instruction");function at(e){return typeof e==="object"&&e!==null&&typeof e.$ref==="string"?e.$ref:null}function we(e){if(e.source!=="npm"||!e.package)return null;return e.modulePath?`${e.package}/${e.modulePath}`:e.package}function nr(e,t){let n=we(e);if(n)return n;return e.path?{$ref:xc(t,e.path)}:null}function eC(e,t,n){let o=we(t);if(o)return e.some((i)=>typeof i==="string"&&(i===o||i===t.package));if(!t.path)return!1;let r=G(xc(n,t.path));return e.some((i)=>{let s=at(i);return s!==null&&G(s)===r})}function G(e){return e.replace(/^(?:\.\/)+/,"")}function om(e,t,n){let o=nr(t,n);if(!o)return[...e];let i=we(t)&&t.modulePath?e.filter((s)=>s!==t.package):[...e];return eC(i,t,n)?i:[...i,o]}function tC(e,t,n){let o=we(t);if(o)return e.filter((i)=>!(typeof i==="string"&&(i===o||i===t.package)));if(!t.path)return[...e];let r=G(xc(n,t.path));return e.filter((i)=>{let s=at(i);return s===null||G(s)!==r})}function WT(e,t){return e.filter((n)=>typeof n!=="string"||!(n===t||n.startsWith(`${t}/`)))}function VT(e,t){let n=G(t);return e.filter((o)=>{let r=at(o);return r===null||G(r)!==n})}async function px(e){$p(!0);try{if(e.source==="npm"){if(!customElements.get(e.tagName))return ct(e.tagName)}else{if(e.path&&!e.path.endsWith(".json"))return ct(e.tagName);let n=D?.projectRoot,o=`${location.origin}/${n?`${n}/`:""}${e.path}`;await Mm(o)}let t=document.createElement(e.tagName);for(let n of e.props||[])if(n.default!==void 0&&n.default!=="false"&&n.default!=="''"){let o=String(n.default).replaceAll(/^'|'$/g,"");t.setAttribute(n.name,o)}return t}catch(t){return console.warn("Component preview failed:",e.tagName,t),ct(e.tagName)}}function ct(e){let t=document.createElement("div");return t.style.cssText="padding:12px;border:1px dashed var(--border);border-radius:var(--radius);color:var(--fg-dim)",t.textContent=`<${e}>`,t}var or='[part="outline"]',ut='[part="row"]',rr='[part="verbs"]',Ce=null;function UT(){if(Ce!==null)cancelAnimationFrame(Ce);for(let e of Je.dndCleanups)e();Je.dndCleanups=[],Ce=requestAnimationFrame(()=>{Ce=null;let e=Qu?.querySelector(or);if(!e)return;for(let n of e.querySelectorAll("[data-dnd-row]")){let o=n.dataset.value.split("/").map((l)=>/^\d+$/.test(l)?Math.trunc(Number(l)):l),r=Math.trunc(Number(n.dataset.dndDepth))||0,i=Object.hasOwn(n.dataset,"dndVoid"),s=Object.hasOwn(n.dataset,"dndExpanded"),a=gr(gs({canDrag({element:l,input:c}){if(Rv(c.clientX,c.clientY)?.closest(rr))return!1;return!0},element:n,getInitialData(){return{path:o,type:"tree-node"}},onGenerateDragPreview({nativeSetDragImage:l}){wc({nativeSetDragImage:l})},onDragStart(){if(n.dataset.dragging="",Je.layerDragSourceHeight=n.offsetHeight,s)ir(n,e)},onDrop(){if(delete n.dataset.dragging,s)Ai("leftPanel")}}),zs({element:n,canDrop({source:l}){let c=l.data.path;if(c&&qa(c,o))return!1;return!0},getData({input:l,element:c}){return jb({path:o},{block:i?["make-child"]:[],currentLevel:r,element:c,indentPerLevel:16,input:l,mode:s?"expanded":"standard"})},onDragEnter({self:l}){yn(n,l.data,e)},onDrag({self:l}){yn(n,l.data,e)},onDrop(){oe(e)}}));Je.dndCleanups.push(a)}let t=Ws({onDrop({source:n,location:o}){oe(e);let[r]=o.current.dropTargets;if(!r)return;let i=Fu(r.data);if(!i||i.type==="instruction-blocked")return;let s=n.data,a=r.data.path,l=s.type==="tree-node"&&n.element,c=l&&Object.hasOwn(l.dataset,"dndExpanded");if(rm(u.value,i,s,a),c){let d=u.value,f=Le(d?.session.selection);if(f)Je._layersCollapsed||=new Set,Je._layersCollapsed.add(f.join("/"))}},onDropTargetChange({location:n}){let[o]=n.current.dropTargets;if(o&&!Fu(o.data))oe(e)}});Je.dndCleanups.push(t)})}function qT(){requestAnimationFrame(()=>{let e=Qu?.querySelector(".components-section");if(!e)return;for(let t of e.querySelectorAll("[data-component-tag]")){let n=t.dataset.componentTag;if(!n)continue;let o=st.find((a)=>a.tagName===n);if(!o)continue;let r=t.querySelector(".element-card-preview");if(r&&!r.querySelector(n))px(o).then((a)=>{r.textContent="",r.append(a)});let i=um(o),s=gs({element:t,getInitialData(){return{fragment:structuredClone(i),type:"block"}},onGenerateDragPreview({nativeSetDragImage:a}){wc({nativeSetDragImage:a})}});Je.dndCleanups.push(s)}})}function GT(){requestAnimationFrame(()=>{let e=Qu?.querySelector('[part="content"]');if(!e)return;for(let t of e.querySelectorAll("[data-block-tag]")){let n=t.dataset.blockTag,o=t.querySelector(".element-card-preview");if(o&&!o.firstChild){let s=document.createElement(Ht.has(n)?"span":n);s.textContent=n,o.append(s)}let r=yd(n),i=gs({element:t,getInitialData(){return{fragment:structuredClone(r),type:"block"}},onGenerateDragPreview({nativeSetDragImage:s}){wc({nativeSetDragImage:s})}});Je.dndCleanups.push(i)}})}function ir(e,t){let n=`${e.dataset.value}/`,o=t.querySelectorAll(ut);for(let r of o)if(r.dataset.value?.startsWith(n))r.style.display="none"}function yn(e,t,n){let o=Fu(t);if(Je._currentDropTargetRow&&Je._currentDropTargetRow!==e)delete Je._currentDropTargetRow.dataset.drop;if(!o||o.type==="instruction-blocked"){oe(n);return}if(o.type==="make-child"){oe(n),e.dataset.drop="",Je._currentDropTargetRow=e;return}delete e.dataset.drop,Je._currentDropTargetRow=e;let r=[...n.querySelectorAll(ut)],i=r.indexOf(e),s=Je.layerDragSourceHeight;for(let a=0;a<r.length;a++){if(r[a].dataset.dragging!==void 0)continue;if(o.type==="reorder-above")r[a].style.transform=a>=i?`translateY(${s}px)`:"";else r[a].style.transform=a>i?`translateY(${s}px)`:""}}function oe(e){if(Je._currentDropTargetRow)delete Je._currentDropTargetRow.dataset.drop,Je._currentDropTargetRow=null;let t=e.querySelectorAll(ut);for(let n of t)n.style.transform="",n.style.display=""}function rm(e,t,n,o){if(!e)return;let r=e.doc.document;if(n.type==="tree-node"){let i=n.path,s=ht(o),a=_n(o);if(t.type!=="make-child"&&(!s||typeof a!=="number"))return;switch(t.type){case"reorder-above":{q(e,(l)=>pa(l,i,s,a));break}case"reorder-below":{q(e,(l)=>pa(l,i,s,a+1));break}case"make-child":{let l=K(r,o),c=_o(l).length;q(e,(d)=>pa(d,i,o,c));break}default:break}}else if(n.type==="block"){let i=ht(o),s=_n(o);if(t.type!=="make-child"&&(!i||typeof s!=="number"))return;switch(t.type){case"reorder-above":{q(e,(c)=>Ji(c,i,s,structuredClone(n.fragment)));break}case"reorder-below":{q(e,(c)=>Ji(c,i,s+1,structuredClone(n.fragment)));break}case"make-child":{let c=K(r,o),d=_o(c).length;q(e,(f)=>Ji(f,o,d,structuredClone(n.fragment)));break}default:break}let l=n.fragment?.tagName;if(qe(l).includes("-")){let c=st.find((h)=>h.tagName===l),d=e.doc.document?.$elements??[],f=c?om(d,c,e.documentPath??null):d;if(f.length!==d.length)Hs(e,(h)=>{h.$elements=f})}}}function bn(e){let t={};for(let[n,o]of Object.entries(e?.nesting??{}))if(n!=="_root")t[n]=o?.inline===!0;for(let n of e?.inline??[])t[n]=!1;return t}var ke=new WeakMap,g=new Set,z=0,ae=new Map,An=-1,$n=0,ar=600;function nC(e){return An===e&&Date.now()-$n<=ar}var wn=0,In=new Set;function sr(e,t){let n;try{n=new URL(e,t.iframe.src||pm())}catch{return}if(!["http:","https:","mailto:","tel:"].includes(n.protocol))return;let o=n.href,r=Qw();if(r){r(o);return}window.open(o,"_blank","noopener,noreferrer")}function iC(e){In.add(e)}function lr(e){return In.delete(e)}var L=new Map,Z=new Map,se=new Map,cr=300;function oC(e,t,n,o=cr){let r=null;for(let a of g){if(!a.iframe.isConnected){g.delete(a);continue}if(a.ready&&!a.stylebook&&e!==null&&a.tabId===e){r=a;break}}if(!r)return Promise.resolve(null);wn+=1;let i=wn,s=JSON.parse(JSON.stringify(t));return r.channel.post({contextPath:n?[...n]:null,exprs:s,gen:r.lastRenderedGen,kind:"evalExpr",reqId:i}),new Promise((a)=>{let l=setTimeout(()=>{L.delete(i),Z.delete(i),a(null)},o);Z.set(i,r),L.set(i,(c)=>{clearTimeout(l),Z.delete(i),a(c)})})}var Cn=0,X=new Map,dr=250;function rC(e,t=dr){let n=[];for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(o.ready&&!o.stylebook&&e!==null&&o.tabId===e)n.push(o)}if(n.length===0)return Promise.resolve();return new Promise((o)=>{let r=n.length,i=setTimeout(()=>{for(let l of a)X.delete(l),se.delete(l);o()},t),s=()=>{if(r-=1,r===0)clearTimeout(i),o()},a=[];for(let l of n){Cn+=1;let c=Cn;a.push(c),X.set(c,s),se.set(c,l),l.channel.post({kind:"flushEdits",reqId:c})}})}function sC(e){return ke.get(e)??null}function sm(e){for(let t of g){if(!t.iframe.isConnected)continue;let n=Oe(t.iframe);if(e.x>=n.left&&e.x<=n.right&&e.y>=n.top&&e.y<=n.bottom)return t}return null}function am(e,t,n){z+=1,ae.set(z,n);let o=t.type==="tree-node"?{path:[...t.path],type:"tree-node"}:{type:t.type};return e.channel.post({dragSeq:z,gen:e.lastRenderedGen,kind:"dragStart",src:o}),z}function fx(){return z}function za(e){let t=Oe(e.iframe),n=e.iframe.clientWidth>0?t.width/e.iframe.clientWidth:1;return{rect:t,scale:n}}function Dn(e){if(e.stylebook)return"stylebook";return e.tabId??"unbound"}function aC(){let e=[];for(let t of g){if(!t.iframe.isConnected){g.delete(t);continue}let n=`canvas[${Dn(t)}]`;if(!t.ready){e.push(`${n}: frame has not handshaked`);continue}let o=[...t.pendingTabIds.keys()];if(o.length>0)e.push(`${n}: gen ${o.join(", ")} unacked`);if(t.pendingPatches>0)e.push(`${n}: ${t.pendingPatches} unacked patch(es)`);if(t.pendingMeasures.size>0)e.push(`${n}: ${t.pendingMeasures.size} measure(s) in flight`);let{idle:r}=t;if(!r){e.push(`${n}: no quiescence report yet`);continue}if(r.gen!==t.lastRenderedGen)e.push(`${n}: quiescence is for gen ${r.gen}, DOM is gen ${t.lastRenderedGen}`);if(!r.fonts)e.push(`${n}: fonts still loading`);if(r.animations>0)e.push(`${n}: ${r.animations} running animation(s)`);if(r.images>0)e.push(`${n}: ${r.images} pending image retry(ies)`)}if(L.size>0)e.push(`canvas: ${L.size} expression eval(s) in flight`);return e}var pr=500,fr=2,mr=40;function Jn(){let e=u.value?.id??null,t=null;for(let n of g){if(!n.iframe.isConnected){g.delete(n);continue}if(!n.ready||n.stylebook)continue;if(n.tabId===e)return n;t??=n}return t}function vr(e,t){let{rect:n,scale:o}=za(e),r=n.left+t.x*o,i=n.top+t.y*o,s=t.width*o,a=t.height*o;return{height:a,left:r,top:i,width:s,x:r+s/2,y:i+a/2}}function Re(e,t){return new Promise((n)=>{e.selReqId+=1;let o=e.selReqId,r=setTimeout(()=>{e.pendingMeasures.delete(o),n(null)},pr);e.pendingMeasures.set(o,(i)=>{clearTimeout(r);let[s]=i;n(s?vr(e,s.rect):null)}),e.channel.post({kind:"measure",paths:[[...t]],reqId:o})})}function lC(e){let t=Jn();return t?Re(t,e):Promise.resolve(null)}function yr(e){return new Promise((t)=>{let n=Number.NaN,o=0,r=0,i=()=>{let{top:s}=Oe(e.iframe);if(o=s===n?o+1:0,n=s,r+=1,o>=fr||r>=mr){t();return}requestAnimationFrame(i)};requestAnimationFrame(i)})}async function lm(e){let t=Jn();return t?n$(t,e):null}async function n$(e,t){let n=await Re(e,t);if(!n)return null;let o=_(e.canvasEl)?.surface;return Pb({height:n.height,top:n.top},o),await yr(e),Re(e,t)}function b$(e,t){let n=sC(e);return n?Re(n,t):Promise.resolve(null)}function br(e){let t=e.canvasEl.parentElement;if(!t)return;let n=/scale\(([\d.]+)\)/.exec(e.canvasEl.style.transform),o=n?Number(n[1]):1;t.style.height=o===1?"":`${e.iframe.offsetHeight*o}px`}function Ln(e){if(e.preview){e.iframe.style.height="100%",e.iframe.style.minHeight="0px";return}if(e.contentHeight===null)return;e.iframe.style.height=`${e.contentHeight}px`,e.iframe.style.minHeight=e.contentFragment?"0px":"480px",br(e)}function gt(e,t){if(e.preview=t,e.overlay.setSuppressed(t),t)e.pendingEnterEdit=null;Ln(e)}function cC(e,t){gt(yt(e),t)}function Rl(e,t){if(!e.iframe.isConnected)return;e.channel.post(t)}function Hb(e){ae.delete(e)}function Bb(e){e.overlay.setDropIndicator(null)}var jn=null;function dC(e){jn=e}var xr=300,qn=null;function uC(e){qn=e}var vt=null;function hC(e){vt=e}function wr(e,t,n){if((t?Cr(t.tagName):!1)&&t){e.overlay.setDropIndicator(null),e.overlay.setReplaceTarget(M(t.rect));return}e.overlay.setReplaceTarget(null),e.overlay.setDropIndicator(n?M(n.referenceRect):null,n?.edge)}function Pn(e){e.overlay.setReplaceTarget(null),e.overlay.setDropIndicator(null)}function Cr(e){return e==="img"||e==="video"||e==="source"}function Pr(e,t){if(e.dataset.jxGutterDrop==="1")return;e.dataset.jxGutterDrop="1",e.addEventListener("dragover",(n)=>{if(![...n.dataTransfer?.types??[]].includes("Files"))return;if(n.preventDefault(),n.dataTransfer)n.dataTransfer.dropEffect="copy"}),e.addEventListener("drop",(n)=>{let o=n.dataTransfer?.files,r=t();if(!o?.length||!r||r.stylebook)return;n.preventDefault(),vt?.(P(r),[...o],null,null)})}var Te=null;function pC(e){Te=e}var Me=null;function fC(e){Me=e}var Fn=null;function mC(e){Fn=e}function Sn(e,t){let n=[...t];for(;;){let o=e.get(Il(n));if(o)return o;if(n.length<2)return null;n=n.slice(0,-2)}}var S=null;function gC(){let e=S;return Boolean(e?.editing&&e.iframe.isConnected)}var Ne=null;function bC(e){Ne=e}var mt=null;function vC(e){mt=e}var En=null,Wn=null;function yC(e){Wn=e}function wC(e,t){for(let n of g){if(!n.iframe.isConnected){g.delete(n);continue}if(n.ready&&n.tabId===e.id&&!n.preview)n.popoverOpen=t,n.channel.post({kind:"setPopoverOpen",path:t})}}function xC(e,t){for(let n of g){if(!n.iframe.isConnected){g.delete(n);continue}if(n.ready&&n.tabId===e.id&&!n.preview)n.dialogOpen=t,n.channel.post({kind:"setDialogOpen",path:t})}}function mx(e,t){let n=0;for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(o.ready&&o.tabId===t){let r=_(o.canvasEl)?.surface;if(!r){Ab("host-stage-unresolved");continue}let i=r.renderGeneration,s=Ae?.host===o?Ae.paths:void 0;$e(o),o.channel.post(s?{echoPaths:s,forwardOps:e,gen:i,kind:"patch"}:{forwardOps:e,gen:i,kind:"patch"}),o.pendingPatches+=1,n+=1}}return n}var Ae=null,Sr=0;function Tn(e,t,n){Ae={host:e,paths:t};try{n()}finally{Ae=null}}var dt=null,pt=null;function Er(e,t,n){return!e&&t===n}function Tr(e,t){let n=P(e);if(!n)return;let o=K(n.doc.document,t);if(!o)return;mx([{key:"$props",op:"set-key",path:t,value:o.$props}],n.id)}function P(e){return e.tabId?m.tabs.get(e.tabId)??null:null}function _C(e){return P(e)}function Pe(e){let t=_(e.canvasEl)?.surface.paneId;if(t)$r(t)}var Mr=Object.freeze([]);function Nr(){let e=new Map;for(let t of m.panes){let n=t.activeTabId?m.tabs.get(t.activeTabId):null;if(!n)continue;let o=n.session.selection??[];o.map((r)=>r.join("/")).join("|"),e.set(n.id,o)}return e}function kr(){if(En)return;let e=ge(!0);e.run(()=>{Q(()=>{let t=Nr();y.stylebook.selection;for(let n of g)Ie(n,(n.tabId?t.get(n.tabId):null)??Mr)})}),En={stop:()=>e.stop()}}function $e(e){if(!e.ready)return;let t=Rd();if(t===e.postedVersions)return;if(e.postedVersions===null&&Object.keys(t).length===0){e.postedVersions=t;return}e.postedVersions=t,e.channel.post({kind:"assetVersions",versions:t})}var Mn=!1,ft=!1;function Rr(){if(Mn)return;Mn=!0,ge(!0).run(()=>{Q(()=>{if(jC.value,ft)return;ft=!0,queueMicrotask(()=>{ft=!1,Or()})})})}function Or(){for(let e of g){if(!e.iframe.isConnected){g.delete(e);continue}$e(e)}}var Nn=!1,Ee=null;function Ar(){if(Nn)return;Nn=!0,ge(!0).run(()=>{Q(()=>{for(let t of m.panes){let n=t.activeTabId?m.tabs.get(t.activeTabId):null;if(!n)continue;let{peers:o}=xn(n);o.map((r)=>JSON.stringify(r.state.structuralSelection??null)).join("|")}if(Ee)clearTimeout(Ee);Ee=setTimeout(()=>{Ee=null;for(let t of g)Vn(t)},100)})})}function Vn(e){if(e.stylebook||!e.ready||!e.iframe.isConnected)return;let t=P(e),n=t?xn(t).peers:[];e.presenceMeta.clear();let o=[];for(let r of n){let{structuralSelection:i}=r.state;if(!i||r.state.focusedPath!==t?.documentPath)continue;for(let s of i){let a=[...s];o.push(a),e.presenceMeta.set(JSON.stringify(a),{color:r.state.user.color,label:r.state.user.name??r.state.user.login})}}if(o.length===0){e.presenceReqId=-1,e.overlay.setPresence([]);return}e.selReqId+=1,e.presenceReqId=e.selReqId,e.channel.post({kind:"measure",paths:o,reqId:e.presenceReqId})}function Ie(e,t){if(e.stylebook){Ir(e);return}let n=Le(t);if(e.selectionPath=n,e.selectionPaths=t,!e.iframe.isConnected){g.delete(e);return}if(!n){e.coSelectionKeys.clear(),e.overlay.setSelection(null),e.overlay.setCoSelection([]);return}if(!e.ready)return;let o=ms(t.slice(0,-1));e.coSelectionKeys=new Set(o.map((r)=>JSON.stringify(r))),e.selReqId+=1,e.channel.post({kind:"measure",paths:[[...n],...o],reqId:e.selReqId})}function Ir(e){if(!e.iframe.isConnected){g.delete(e);return}let t=y.stylebook.selection,n=t?e.stylebook?.tagToCardPath.get(t):void 0;if(!t||!n){e.overlay.setSelection(null);return}if(!e.ready)return;e.selReqId+=1,e.channel.post({kind:"measure",paths:[[...n]],reqId:e.selReqId})}function kn(){return zv("../canvas.html")}var Dr="about:blank";function Bn(e){e.channel.dispose();for(let[t,n]of L)if(Z.get(t)===e)L.delete(t),Z.delete(t),n(null);for(let[t,n]of X)if(se.get(t)===e)X.delete(t),se.delete(t),n();for(let[,t]of e.pendingMeasures)t([]);if(e.pendingMeasures.clear(),e.pendingTabIds.clear(),le(e),S===e)S=null;e.overlay.root.remove(),e.iframe.remove(),ke.delete(e.canvasEl),g.delete(e)}function Hr(){if(!We())return kn();let e=p();if(e.canvasUrl)return e.canvasUrl;return e.canvasUrlDeferred?Dr:kn()}function cm(e){let t=0;for(let n of new Set(g))if(e.contains(n.canvasEl))Bn(n),t+=1;return t}function yt(e){let t=Hr(),n=ke.get(e);if(n){if(n.canvasUrl===t)return n;Bn(n)}let o=location.origin,r=crypto.randomUUID(),i=new URL(t,location.href).origin,s=document.createElement("iframe");s.className="jx-canvas-iframe",s.title="Canvas — live page render",s.style.cssText="width:100%;min-height:480px;height:100%;border:0;display:block;background:#fff";let a=new URL(t,location.href);if(a.searchParams.set("token",r),location.protocol==="http:"||location.protocol==="https:")a.searchParams.set("parentOrigin",o);if(s.src=i===o?`${a.pathname}${a.search}`:a.href,!e.style.position)e.style.position="relative";let l=zt(document);e.replaceChildren(s,l.root),Pr(e,()=>sC(e));let c=xt({acceptOrigin:i,source:window,target:{postMessage:(f,h)=>s.contentWindow?.postMessage(f,h)},targetOrigin:i,token:r}),d={canvasEl:e,canvasUrl:t,channel:c,contentFragment:!1,contentHeight:null,hiddenPaths:new Set,popoverOpen:null,dialogOpen:null,editing:!1,editingProp:null,iframe:s,insertHideTimer:null,insertHover:!1,coSelectionKeys:new Set,insertZone:null,lastRenderedGen:-1,lastSelectionRect:null,lastSnapshotSeq:0,overlay:l,panReqId:-1,pending:null,postedVersions:null,idle:null,pendingEnterEdit:null,pendingMeasures:new Map,pendingPatches:0,pendingTabIds:new Map,presenceMeta:new Map,presenceReqId:-1,preview:!1,ready:!1,selectionPath:null,selectionPaths:[],selReqId:0,snapshot:null,stylebook:null,tabId:null};return l.insertButton.addEventListener("click",(f)=>jr(d,f)),l.insertButton.addEventListener("mouseenter",()=>{d.insertHover=!0,le(d)}),l.insertButton.addEventListener("mouseleave",()=>{d.insertHover=!1,Kn(d)}),c.onMessage((f)=>Fr(d,f)),ke.set(e,d),g.add(d),kr(),Ar(),Rr(),d}function Lr(e,t){le(e),e.insertZone=t,e.overlay.setInsertZone(M(t.rect),t.edge)}function zn(e){le(e),e.insertZone=null,e.insertHover=!1,e.overlay.setInsertZone(null)}function _r(e){let t=e.overlay.insertButton;return e.insertHover||typeof t.matches==="function"&&t.matches(":hover")}function Kn(e){le(e),e.insertHideTimer=setTimeout(()=>{if(e.insertHideTimer=null,_r(e))return;zn(e)},xr)}function le(e){if(e.insertHideTimer!==null)clearTimeout(e.insertHideTimer),e.insertHideTimer=null}function jr(e,t){t.stopPropagation(),t.preventDefault();let n=e.insertZone;if(!n)return;qn?.(e.overlay.insertButton,n)}var qr=new Set(["contextMenu","dragOver","dropResult","editCommit","editCommitProp","editInsert","editMerge","editRangeReplace","editSplit","editStart","fileDragOver","fileDrop","hit","hover","insertZones","layoutHit","nativeDragEnter"]);function Fr(e,t){if(e.preview&&qr.has(t.kind))return;switch(t.kind){case"ready":{e.ready=!0;let n=bt?.();if(n)e.channel.post({chords:n.chords,kind:"keymap",mac:n.mac});if(e.postedVersions=null,$e(e),e.pending)e.channel.post(e.pending),e.pending=null;Ie(e,e.selectionPaths);return}case"paneFocus":{Pe(e),mt?.();return}case"popoverTargetClick":{let n=P(e);if(!n||e.preview)return;let o=JSON.stringify(n.session.ui.openPopover)===JSON.stringify(t.targetPath),r=t.action==="show"||t.action==="toggle"&&!o;if(r||o)ne()?.run("canvas.setPopoverOpen",{open:r,path:t.targetPath});return}case"commandTargetClick":{let n=P(e);if(!n||e.preview)return;let o=(i)=>JSON.stringify(i)===JSON.stringify(t.targetPath),r=K(n.doc.document,t.targetPath);if(!r||typeof r!=="object")return;if(Ze.has(t.command)){if(!Gs(r))return;let i=t.command==="show-popover"||t.command==="toggle-popover"&&!o(n.session.ui.openPopover);if(i||o(n.session.ui.openPopover))ne()?.run("canvas.setPopoverOpen",{open:i,path:t.targetPath})}else if(Ge.has(t.command)){if(!H(r))return;let i=t.command==="show-modal";if(i||o(n.session.ui.openDialog))ne()?.run("canvas.setDialogOpen",{open:i,path:t.targetPath})}return}case"hit":{Pe(e),mt?.(),OC(null);let n=null,o=_(e.canvasEl)?.panel;if(o?.mediaName&&!o.mediaName.startsWith("git-diff")){n=me(o.mediaName);let i=P(e);if(i)i.session.ui.activeMedia=n}if(Me?.dismiss(),e.stylebook){let i=Sn(e.stylebook.pathToTag,t.hit.path);if(Fn?.(i,n),i){let s=M(t.hit.rect);e.overlay.setSelection(s,`<${i}>`),e.lastSelectionRect=s}else e.overlay.setSelection(null);return}e.selectionPath=t.hit.path,e.selectionPaths=[t.hit.path];let r=P(e);if(r)r.session.selection=t.additive?uv(r.session.selection,t.hit.path):[t.hit.path];{let i=M(t.hit.rect);e.overlay.setSelection(i),e.lastSelectionRect=i}return}case"layoutHit":{if(e.stylebook)return;Pe(e),Me?.dismiss(),OC(t.hit),e.selectionPath=null,e.selectionPaths=[];let n=P(e);if(n)n.session.selection=[];let o=M(t.hit.rect);e.overlay.setSelection(o,`LAYOUT · ${t.hit.layoutFile}`),e.lastSelectionRect=o,Ai("rightPanel");return}case"hover":{if(e.stylebook){let n=t.hit?Sn(e.stylebook.pathToTag,t.hit.path):null,o=y.stylebook.selection;if(t.hit&&n&&n!==o)e.overlay.setHover(M(t.hit.rect));else e.overlay.setHover(null);return}zr(e,t.hit);return}case"insertZones":{if(e.stylebook)return;let n=t.zones?.[0]??null;if(n)Lr(e,n);else Kn(e);return}case"geometry":{let n=e.pendingMeasures.get(t.reqId);if(n){e.pendingMeasures.delete(t.reqId),n(t.hits);return}if(t.reqId===e.presenceReqId){e.presenceReqId=-1;let o=[];for(let r of t.hits){let i=e.presenceMeta.get(JSON.stringify(r.path));if(i)o.push({...i,placement:M(r.rect)})}e.overlay.setPresence(o);return}if(t.reqId===e.panReqId){e.panReqId=-1;let[o]=t.hits;if(o){let{rect:r,scale:i}=za(e);Pb({height:o.rect.height*i,top:o.rect.y*i+r.top})}return}if(t.reqId===e.selReqId){let o=JSON.stringify(e.selectionPath),r=[],i=null;if(e.stylebook){let[a]=t.hits;i=a?M(a.rect):null}else for(let a of t.hits){let l=JSON.stringify(a.path);if(l===o)i=M(a.rect);else if(e.coSelectionKeys.has(l))r.push(M(a.rect))}let s=e.stylebook?y.stylebook.selection:null;e.overlay.setSelection(i,s?`<${s}>`:null),e.overlay.setCoSelection(r),e.lastSelectionRect=i,e.hiddenPaths=new Set((t.hidden??[]).map((a)=>JSON.stringify(a)))}return}case"evalResult":{let n=L.get(t.reqId);if(!n)return;L.delete(t.reqId),Z.delete(t.reqId),n(t.gen===e.lastRenderedGen?t.results:null);return}case"renderComplete":{if(e.pendingTabIds.has(t.gen))e.tabId=e.pendingTabIds.get(t.gen)??null;for(let n of e.pendingTabIds.keys())if(n<=t.gen)e.pendingTabIds.delete(n);Rn(e,t.gen);return}case"patchComplete":{e.pendingPatches=Math.max(0,e.pendingPatches-1),Rn(e,t.gen);return}case"idle":{e.idle={animations:t.animations,fonts:t.fonts,gen:t.gen,images:t.images};return}case"renderError":{e.pendingTabIds.delete(t.gen);let n=P(e);if(n)n.session.canvas.refreshing=!1,Ai("leftPanel");k.error("The page could not be rendered.",{detail:t.message,key:`canvas.render:${Dn(e)}`,source:"Canvas"});return}case"dataScope":{if(t.gen!==e.lastRenderedGen)return;let n=P(e);if(n)n.session.canvas.scope=t.scope,n.session.canvas.refreshing=!1;Ai("leftPanel");return}case"contentHeight":{e.contentHeight=t.height,e.contentFragment=t.fragment,Ln(e);return}case"dragOver":{if(t.dragSeq!==z)return;if(t.cursor)An=t.dragSeq,$n=Date.now();if(t.gen!==e.lastRenderedGen)return;if(t.preview)e.overlay.setDropIndicator(M(t.preview.referenceRect),t.preview.edge);else e.overlay.setDropIndicator(null);if(t.cursor){let n=za(e);hx(t.cursor.x*n.scale+n.rect.left,t.cursor.y*n.scale+n.rect.top)}return}case"nativeDragEnter":{if(e.stylebook)return;jn?.(e);return}case"dragEnd":{e.overlay.setDropIndicator(null),_d(),ae.delete(t.dragSeq);return}case"dropResult":{if(t.dragSeq!==z||t.gen!==e.lastRenderedGen)return;if(t.instruction&&t.targetPath){let n=ae.get(t.dragSeq);if(n)rm(P(e),{type:t.instruction},n,t.targetPath)}ae.delete(t.dragSeq),e.overlay.setDropIndicator(null),_d();return}case"fileDragOver":{if(e.stylebook)return;wr(e,t.hit,t.preview);return}case"fileDragLeave":{Pn(e);return}case"fileDrop":{if(Pn(e),e.stylebook)return;vt?.(P(e),t.files,t.hit,t.preview);return}case"patchError":{e.pendingPatches=Math.max(0,e.pendingPatches-1);let n=_(e.canvasEl)?.surface;if(n)Wn?.(n.paneId);return}case"forwardKey":{Br(t.event);return}case"forwardWheel":{Vr(e,t);return}case"editStart":{if(S&&S!==e)S.editing=!1,S.editingProp=null,S.snapshot=null;if(S=e,t.prop!==void 0&&pt===Il(t.path))ie(e,t.path,void 0,t.prop);pt=null,Sr+=1,e.editing=!0,e.editingProp=t.prop??null,e.snapshot=null,e.lastSnapshotSeq=0,Ne?.();return}case"selectionChanged":{if(t.seq<=e.lastSnapshotSeq)return;if(e.lastSnapshotSeq=t.seq,e.snapshot=t,!e.editing)e.editing=!0,S=e;Ne?.();return}case"flushComplete":{let n=X.get(t.reqId);if(n)X.delete(t.reqId),se.delete(t.reqId),n();return}case"editCommit":{let n=()=>_t(P(e),t.path,t.children,t.textContent);if(t.inPlace)Tn(e,[t.path],n);else n();return}case"editCommitProp":{let n=()=>jt(P(e),t.path,t.prop,t.value);if(t.inPlace){Tn(e,[t.path],n),dt=Il(t.path);return}let o=n();if(Er(o,dt,Il(t.path)))Tr(e,t.path);dt=null,pt=o?Il(t.path):null;return}case"editMerge":{let n=qt(P(e),t.fromPath,t.intoPath);if(n)ie(e,n.path,n.offset);return}case"editRangeReplace":{let n=Bt(P(e),t.from,t.to,t.between,t.text);if(n)ie(e,n.path,n.offset);return}case"editSplit":{ie(e,Wt(P(e),t.path,t.before,t.after));return}case"editInsert":{ie(e,Vt(P(e),t.path,t.cmd,t.commitData));return}case"slashShow":{let{rect:n,scale:o}=za(e),r=t.rect.x*o+n.left,i=t.rect.y*o+n.top;Te?.show({filter:t.filter,...t.showFilter===!0?{showFilter:!0}:{},onDismiss:()=>e.channel.post({kind:"slashDismissed"}),onSelect:(s)=>e.channel.post({cmd:{...s},kind:"slashSelect"}),rect:{bottom:i+t.rect.height*o,height:t.rect.height*o,left:r,top:i,width:t.rect.width*o}});return}case"slashNav":{Te?.nav(t.key);return}case"slashDismiss":{Te?.dismiss();return}case"previewNavigate":{sr(t.href,e);return}case"contextMenu":{if(e.stylebook)return;Pe(e);let{rect:n,scale:o}=za(e);Me?.show({clientX:t.x*o+n.left,clientY:t.y*o+n.top,path:t.path?[...t.path]:null});return}case"editEnd":{if(!e.editing)return;if(e.editing=!1,e.editingProp=null,e.snapshot=null,S===e)S=null;Ne?.();break}default:break}}function Rn(e,t){if(e.lastRenderedGen=t,Ie(e,e.selectionPaths),Vn(e),zn(e),e.pendingEnterEdit&&t>=e.pendingEnterEdit.minGen){let{offset:n,path:o,prop:r}=e.pendingEnterEdit;if(e.pendingEnterEdit=null,e.tabId!==null&&e.tabId===im(e.canvasEl)?.id)Wr(e,o,n,r)}}function ie(e,t,n,o){e.pendingEnterEdit={minGen:e.lastRenderedGen,path:[...t],...n===void 0?{}:{offset:n},...o===void 0?{}:{prop:o}}}function Wr(e,t,n,o){e.channel.post({kind:"enterEdit",path:[...t],...n===void 0?{}:{offset:n},...o===void 0?{}:{prop:o}})}function Vr(e,t){let{rect:n,scale:o}=za(e),r=jl(e.canvasEl)?.wrap;if(!r)return;r.dispatchEvent(new WheelEvent("wheel",{bubbles:!0,cancelable:!0,clientX:n.left+t.x*o,clientY:n.top+t.y*o,ctrlKey:t.ctrlKey,deltaX:t.deltaX,deltaY:t.deltaY,metaKey:t.metaKey,shiftKey:t.shiftKey}))}function Br(e){document.dispatchEvent(new KeyboardEvent("keydown",{altKey:e.altKey,bubbles:!0,cancelable:!0,code:e.code,ctrlKey:e.ctrlKey,key:e.key,metaKey:e.metaKey,shiftKey:e.shiftKey}))}function zr(e,t){if(!t||Yo(t.path,e.selectionPath)){e.overlay.setHover(null);return}e.overlay.setHover(M(t.rect))}var Ur=4,B=new Map;function Gr(e){let t=B.get(e);if(t)return B.delete(e),B.set(e,t),t;let n=new Map;B.set(e,n);for(let o of B.keys()){if(B.size<=Ur)break;B.delete(o)}return n}function Zr(e,t,n,o,r,i=null){let s=Gr(e),a=o?.id??null,l=s.get(t);if(l&&l.tabId===n&&l.viewTabId===a&&l.mode===i)return l.payload;let c=lr(r),d=nx(At,async()=>{xo.renderPreparations+=1;let f=await kt(t,o,i),h=JSON.parse(JSON.stringify(f.renderDoc)),b=JSON.parse(JSON.stringify(t)),T=n?m.tabs.get(n)??null:null,R=wi(T?.doc.sourceFormat)?.studio?.elements,O=R?bn(R):void 0;return{assets:f.assets,doc:h,docBase:f.docBase??`${pm()}/`,mapperCtx:f.mapperCtx,mode:f.mapperCtx.canvasMode,shadowDoc:b,siteStyle:f.siteStyle,...O?{editableTags:O}:{},...c?{allowAutoRequests:!0}:{}}});return s.set(t,{mode:i,payload:d,tabId:n,viewTabId:a}),d}async function CC(e,t,n,o,r=null,i=im(n),s=null,a=null){let l=yt(n);l.pendingTabIds.set(e,r),l.stylebook=null,l.iframe.style.width=o?`${o}px`:"100%";let d={...await Zr(e,t,r,i,$b(n),s),colorScheme:Gn(i),...a?{diffMarks:a}:{},gen:e,kind:"render",popoverOpen:i?.session.ui.openPopover??null,dialogOpen:i?.session.ui.openDialog??null};l.popoverOpen=d.popoverOpen??null,l.dialogOpen=d.dialogOpen??null,gt(l,d.mode==="preview"),Un(l,d)}function Un(e,t){if(xo.hostRenderPosts+=1,e.ready)$e(e),e.channel.post(t);else e.pending=t}function kC(e,t,n,o){let r=yt(n);r.pendingTabIds.set(e,null),r.stylebook={pathToTag:t.pathToTag,tagToCardPath:t.tagToCardPath},gt(r,!1),r.pendingEnterEdit=null,r.iframe.style.width=o?`${o}px`:"100%";let i=JSON.parse(JSON.stringify(t.doc)),s=JSON.parse(JSON.stringify(t.doc)),a={assets:null,colorScheme:Gn(im(n)),doc:i,docBase:`${pm()}/`,gen:e,kind:"render",mapperCtx:{arrayPaths:[],canvasMode:"stylebook",layoutWrapped:!1,pageContentOffset:null,pageContentPrefix:null},mode:"stylebook",shadowDoc:s,siteStyle:null};Un(r,a)}function Gn(e){let t=e?.session.ui.previewColorScheme;return t==="light"||t==="dark"?t:null}function SC(e,t){for(let n of g){if(!n.iframe.isConnected){g.delete(n);continue}if(t&&!t.contains(n.iframe))continue;if(n.ready)n.channel.post({kind:"setColorScheme",scheme:e})}}function EC(e,t){let n=gL(e);for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(t&&!t.contains(o.iframe))continue;if(o.ready)o.channel.post({dir:n,kind:"setLocale",locale:e})}}function TC(e,t){let n=JSON.parse(JSON.stringify(e)),o=0;for(let r of g){if(!r.iframe.isConnected){g.delete(r);continue}if(r.ready)r.channel.post({base:t,doc:n,kind:"redefineElement"}),o+=1}return o}function LC(){let e=D?.projectConfig;if(!e)return;let t=JSON.parse(JSON.stringify(e.style??null)),n=JSON.parse(JSON.stringify(e.$media??{}));for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(o.ready&&!o.stylebook)o.channel.post({kind:"siteStyleUpdate",media:n,siteStyle:t})}}function zb(e){let t=0,n=JSON.parse(JSON.stringify(e));for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(o.ready&&o.stylebook)o.channel.post({gen:o.lastRenderedGen,kind:"styleUpdate",style:n}),t+=1,Ie(o,o.selectionPaths)}return t}function IC(e){let t=Zn();if(!t?.stylebook||!t.ready)return;let n=t.stylebook.tagToCardPath.get(e);if(!n)return;t.selReqId+=1,t.panReqId=t.selReqId,t.channel.post({kind:"measure",paths:[[...n]],reqId:t.selReqId})}function Wa(){let e=S;if(!e||!e.iframe.isConnected)return{editing:!1,editingProp:null,snapshot:null};return{editing:e.editing,editingProp:e.editingProp,snapshot:e.snapshot}}var bt=null;function RC(e,t){bt=e,t?.(()=>On()),On()}function On(){let e=bt?.();if(!e)return;for(let t of g){if(!t.iframe.isConnected){g.delete(t);continue}if(t.ready)t.channel.post({chords:e.chords,kind:"keymap",mac:e.mac})}}function Cd(e){let t=S;if(!t||!t.ready)return;t.channel.post({intent:e,kind:"applyFormat"})}function $C(){let e=S;if(!e||!e.ready)return;e.channel.post({kind:"openSlash"})}function Wb(){let e=S;if(e?.editing&&e.ready&&e.iframe.isConnected)e.channel.post({kind:"endEdit"})}function Zn(){let e=Ut();return e?sC(e.canvas):null}function gx(){let e=S,t=e??Zn();if(!t)return null;let{rect:n,scale:o}=za(t),r=t===e?t.snapshot?.rect:null;if(r)return{height:r.height*o,left:r.x*o+n.left,top:r.y*o+n.top,width:r.width*o};if(t.lastSelectionRect)return{height:t.lastSelectionRect.height*o,left:t.lastSelectionRect.left*o+n.left,top:t.lastSelectionRect.top*o+n.top,width:t.lastSelectionRect.width*o};return null}
2
+ export{Uo,lt,ur,Xw,Tl,wo,Nu,$b,im,vT,Qw,Db,Ll,yT,wT,xT,ex,_T,CT,kT,ST,xo,Ab,tx,nx,bi,yd,ET,Il,wd,TT,ix,LT,Nb,IT,Ob,Ou,hr,RT,cp,$T,DT,ox,AT,rx,NT,sx,G1,K1,ax,lx,Mu,OT,MT,Mb,us,xd,Pu,PT,FT,cx,J1,jT,dx,ux,HT,Pb,BT,Y1,Z1,X1,zT,Fb,Q1,hx,_d,wc,jb,Fu,eC,om,tC,WT,VT,px,UT,qT,GT,rm,nC,iC,oC,rC,sC,sm,am,fx,za,aC,lC,lm,n$,b$,cC,Rl,Hb,Bb,dC,uC,hC,pC,fC,mC,gC,bC,vC,yC,wC,xC,mx,_C,cm,CC,kC,SC,EC,TC,LC,zb,IC,Wa,RC,Cd,$C,Wb,gx};
3
+
4
+ //# debugId=8587CC83433C749E64756E2164756E21
5
+ //# sourceMappingURL=studio-ceb34dxj.js.map
@@ -0,0 +1,5 @@
1
+ import{ge,Xa,Q,v,re,zd,k}from"./studio-fqq890ap.js";import{kp}from"./studio-7pgy3xaf.js";import{p}from"./studio-y7jehjrp.js";import{wi,Zt,Dr}from"./studio-1x8x26k3.js";import{K,Lm,ht,_n,Yo,qa,D}from"./studio-tp642n5g.js";import{Ae,Ic,Im,lk}from"./studio-evwgp1ym.js";import{va,oh,rh}from"./studio-nbxqcgvf.js";import{me}from"./studio-0bbxhhce.js";function vm(e,t){return{success:!0,data:e,summary:t}}function zi(e){return{success:!1,error:e}}function Ki({name:e,description:t,parameters:n,strict:o=!0,llmStrict:r=!1,interactive:i,execute:s}){return{name:e,description:t,parameters:n,strict:o,llmStrict:r,...i===void 0?{}:{interactive:i},execute:s}}function av(e){let t=[];return{record(n){t.push(n),e?.(n)},writes:t}}function Dd(e=null,t={}){let n=new Map(Object.entries(t));return{sessionId:e,get:(o)=>n.get(o),set:(o,r)=>{n.set(o,r)},toJSON:()=>Object.fromEntries(n)}}var Ot=new AbortController().signal;function lv(e={}){let t=e.session??Dd();return{actor:e.actor??{id:`assistant:${t.sessionId??"local"}:`,kind:"assistant",sessionId:t.sessionId,turnId:""},callId:e.callId??"",ledger:e.ledger??av(),progress:e.progress??(()=>{}),session:t,signal:e.signal??Ot}}function wL(e){let t=new AbortController;if(e.aborted)return t.abort(e.reason),{release:()=>{},signal:t.signal};let n=()=>{t.abort(e.reason)};return e.addEventListener("abort",n,{once:!0}),{release:()=>{e.removeEventListener("abort",n)},signal:t.signal}}function zC(){let e=new Map;return{register(t){if(e.has(t.name))console.warn(`Tool "${t.name}" is being re-registered.`);e.set(t.name,t)},list(){return[...e.values()]},listForLLM(){return[...e.values()].map((t)=>({type:"function",function:{name:t.name,description:t.description,parameters:t.parameters,...t.llmStrict===!0?{strict:!0}:{}}}))},getDefinition(t){return e.get(t)},validate(t,n){let o=e.get(t);if(!o)return{valid:!1,errors:[`Unknown tool: "${t}"`]};if(!o.strict)return{valid:!0};let r=o.parameters;if(!r||!r.properties)return{valid:!0};let i=[],s=r.properties,a=r.required||[],l=n;for(let c of a)if(!(c in n)||l[c]===void 0||l[c]===null)i.push(`Missing required argument: "${c}"`);for(let[c,d]of Object.entries(l)){let g=s[c];if(!g)continue;let y=g.type;if(!y)continue;let b=Array.isArray(d)?"array":typeof d;if(y==="number"||y==="integer"){if(b==="number")continue;if(b==="string"){if(!Number.isNaN(Number(d)))continue;i.push(`Argument "${c}" should be a number, got non-numeric string "${d}"`);continue}i.push(`Argument "${c}" should be a number, got ${b}`);continue}if(y==="string"&&b!=="string")i.push(`Argument "${c}" should be a string, got ${b}`);else if(y==="boolean"&&b!=="boolean")i.push(`Argument "${c}" should be a boolean, got ${b}`);else if(y==="array"&&b!=="array")i.push(`Argument "${c}" should be an array, got ${b}`);else if(y==="object"&&b!=="object")i.push(`Argument "${c}" should be an object, got ${b}`)}return i.length>0?{valid:!1,errors:i}:{valid:!0}},async execute(t,n,o=lv()){let r=e.get(t);if(!r)return zi(`Unknown tool: "${t}"`);let i=this.validate(t,n);if(!i.valid)return zi(`Validation failed: ${(i.errors||[]).join("; ")}`);try{return await r.execute(n,o)}catch(s){return zi(`Tool "${t}" execution error: ${s.message}`)}}}}function wt(e){return JSON.parse(JSON.stringify(e))}function St(e){if(!e)return{};let t=JSON.parse(e);if(t===null||typeof t!=="object"||Array.isArray(t)){let n=t===null?"null":Array.isArray(t)?"array":typeof t;throw TypeError(`arguments must be a JSON object, got ${n}`)}return t}async function xL(e,t,n){let o=!1,r;try{let i=St(t.argumentsText);o=!0,r=await e.execute(t.name,i,n)}catch(i){r=zi(`Failed to parse arguments: ${i.message}`)}try{return{status:"done",result:wt(r),executed:o}}catch(i){let s=i.message;return{status:"done",result:zi(`Tool "${t.name}" returned a result that cannot be serialized: ${s}`),executed:o}}}var F=[],Ct=50;function _L(e){return Object.assign(av(),{turnId:e})}function CL(e,t){if(t.length===0)return[];let n={id:e,writes:[...t]};F.push(n);while(F.length>Ct)F.shift();return n.writes}function Tx(e){return F.find((t)=>t.id===e)?.writes??[]}function kL(e){let t=e.filter((a)=>a.ok),n=new Set(t.map((a)=>a.path)),o=e.length-t.length;if(n.size===0)return o>0?`${o} change${o===1?"":"s"} failed`:"";let r=`Changed ${n.size} file${n.size===1?"":"s"}`,i=new Set(t.filter((a)=>a.disk).map((a)=>a.path)),s=[r];if(i.size>0)s.push(`${i.size} written to disk — undo cannot reach ${i.size===1?"it":"them"}`);if(o>0)s.push(`${o} failed`);return s.join(" · ")}function Lx(){F.splice(0)}function SL(e,t){let n=null;for(let o=e.length-1;o>=0;o--){let r=e[o];if(r.id===t)return n;let i=r.role==="assistant"&&(r.content||(r.toolCalls?.length??0)>0);if(n===null&&i)n=r.id}return t===void 0?n:null}var Rt=new Set(["Adlm","Arab","Aran","Armi","Avst","Cprt","Egyd","Egyh","Elym","Gara","Hatr","Hebr","Hluw","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogd","Sogo","Syrc","Thaa","Todr","Yezi"]),Sx="^[A-Za-z]{2,8}(-[A-Za-z0-9]{1,8})*$";function Go(e){if(typeof e!=="string"||e.trim()==="")return null;try{return new Intl.Locale(e.trim()).toString()}catch{return null}}function iv(e){return Go(e)!==null}function gL(e){let t=Go(e);if(t===null)return"ltr";let n=new Intl.Locale(t),o=n.script??n.maximize().script;return o!==void 0&&Rt.has(o)?"rtl":"ltr"}function dn(e){let t=Go(e);if(t===null)return typeof e==="string"?e:"";return new Intl.DisplayNames([t],{type:"language"}).of(t)??t}var At="prefix-except-default";function $o(e){let t=e.i18n,n=[];if(!t||typeof t!=="object")return{errors:n,i18n:null};let o=Array.isArray(t.locales)?t.locales:[],r=[];for(let a of o){let l=Go(a);if(l===null){n.push(`i18n.locales: "${String(a)}" is not a well-formed BCP 47 language tag.`);continue}if(!r.includes(l))r.push(l)}let i=Go(t.defaultLocale)??r[0]??null;if(t.defaultLocale!==void 0&&Go(t.defaultLocale)===null)n.push(`i18n.defaultLocale: "${String(t.defaultLocale)}" is not a well-formed BCP 47 language tag.`);if(i===null)return n.push("i18n is declared with no usable locale — set `defaultLocale` or `locales`."),{errors:n,i18n:null};if(!r.includes(i))r.unshift(i);let s=t.routing==="prefix-always"||t.routing==="prefix-except-default"?t.routing:At;return{errors:n,i18n:{defaultLocale:i,locales:r,routing:s}}}function zu(e,t){let n=se(W(e),t);if(n===-1||t===null)return null;return Go(W(e)[n])}function bL(e,t){let n=zu(e,t);if(n!==null||t===null||t.routing!=="prefix-except-default")return n;return W(e)[0]==="pages"?t.defaultLocale:null}function BC(e,t){let n=W(e),o=se(n,t);return o===-1?n.join("/"):n.filter((r,i)=>i!==o).join("/")}function Wu(e,t,n){if(n===null)return null;let o=Go(t);if(o===null||!n.locales.includes(o))return null;let r=W(e),i=se(r,n),s=i===-1?kt(r):i;if(s===-1)return null;let a=i===-1?r:r.filter((l,c)=>c!==i);if(o===n.defaultLocale&&n.routing==="prefix-except-default")return a.join("/");return a.toSpliced(s,0,o.toLowerCase()).join("/")}function W(e){return e.replace(/^\.\//,"").split("/").filter(Boolean)}function se(e,t){if(t===null)return-1;return e.findIndex((n)=>{let o=Go(n);return o!==null&&t.locales.includes(o)})}function kt(e){if(e[0]==="pages"&&e.length>1)return 1;if(e[0]==="content"&&e.length>2)return 2;return-1}var Dx="{locale}";function Re(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}function B(e){return e.replaceAll("\\","/").replace(/^\.\//,"").replace(/\/+$/,"")}function ke(e){return e??D?.projectConfig??null}function Je(e){return e?.content??{}}function Jt(e){let t=$o(e??{}).i18n?.locales??[];return t.length>0?[...t]:null}function je(e){if(e.endsWith("/"))return!1;let t=e.slice(e.lastIndexOf("/")+1);return/\.[a-z\d]+$/i.test(t)}function Ie(e){if(e.format==="json")return{ext:".json",unresolvedFormat:null};if(e.format===void 0||e.format==="")return{ext:Dr()?.extensions[0]??".json",unresolvedFormat:null};let t=wi(e.format);return t?.extensions[0]===void 0?{ext:null,unresolvedFormat:e.format}:{ext:t.extensions[0],unresolvedFormat:null}}function jt(e,t){let n=t===null?"[^/]+":`(?:${t.map((r)=>Re(r)).join("|")})`,o=B(e).split(Dx).map((r)=>Re(r)).join(n);return new RegExp(`^${o}(?:/|$)`,"i")}function It(e,t,n){let o=jt(e,n).exec(t);if(!o)return null;return o[0].replace(/\/$/,"")}function Dt(e){return B(e).replaceAll(Dx,"").length}function bp(e,t){if(e===null||e===void 0||e==="")return null;let n=ke(t),o=Jt(n),r=B(e),i=null,s=-1;for(let[a,l]of Object.entries(Je(n))){let{source:c}=l;if(c===void 0||c===""||je(c))continue;let d=Dt(c);if(d<=s)continue;let g=It(c,r,o);if(g===null)continue;i={def:l,dir:r,fileBacked:!1,isSourceRoot:r.length===g.length,name:a,...Ie(l)},s=d}return i}function Ax(e,t){if(e===null||e===void 0||e==="")return null;let n=ke(t),o=B(e),r=o.toLowerCase();for(let[i,s]of Object.entries(Je(n))){let{source:a}=s;if(a===void 0||a===""||!je(a))continue;let l=B(a).toLowerCase();if(r===l||r.endsWith(`/${l}`))return{def:s,dir:o.includes("/")?o.slice(0,o.lastIndexOf("/")):".",fileBacked:!0,isSourceRoot:!1,name:i,...Ie(s)}}return bp(o.includes("/")?o.slice(0,o.lastIndexOf("/")):".",n)}function Ml(e){return e.replaceAll(/([A-Z])/g," $1").replace(/^./,(t)=>t.toUpperCase())}function xv(e){return e.replaceAll(/[^a-zA-Z0-9]+(.)?/g,(t,n)=>n?n.toUpperCase():"").replace(/^[A-Z]/,(t)=>t.toLowerCase())}function _v(e){return e.replaceAll(/(^|-)(\w)/g,(t,n,o)=>(n?" ":"")+o.toUpperCase())}function Nx(e,t){return e?.$label||Ml(t)}function KL(e,t){if(e?.$label)return e.$label;if(t.includes("-"))return t.replaceAll(/(^|-)(\w)/g,(n,o,r)=>(o?" ":"")+r.toUpperCase());return Ml(t)}function ma(e){return e==="image"||e==="uri-reference"}function Ad(e){if(e.$shorthand===!0)return"shorthand";if(e.$input==="button-group")return"button-group";if(e.$input==="media")return"media";if(e.format==="color")return"color";if(ma(e.format))return"media";if(e.$units!==void 0)return"number-unit";if(e.type==="number")return"number";if(Array.isArray(e.enum))return"select";if(Array.isArray(e.examples)||Array.isArray(e.presets))return"combobox";return"text"}function qu(e,t){if(!e||!t?.content)return null;let n=Ax(e,t);if(!n||!n.def.schema)return null;if(!n.fileBacked){let o=n.ext??Dr()?.extensions[0]??".json";if(!e.toLowerCase().endsWith(o.toLowerCase()))return null}return{name:n.name,schema:n.def.schema}}function xm(e,t){let n=e.trim().toLowerCase().replaceAll(/[^a-z0-9\s-]/g,"").replaceAll(/\s+/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,"");if(!n)return"";return`${t}${n}`}function Cv(e,t){return e.replace(new RegExp(`^${t.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}`),"").replace(/^--/,"").replaceAll("-"," ").replaceAll(/\b\w/g,(n)=>n.toUpperCase())||e}function JL(e){if(!e)return{kind:"text"};let t=e.trim().replaceAll(/\s*\|\s*undefined\b/g,"").trim();if(t==="boolean")return{kind:"boolean"};if(t==="number")return{kind:"number"};if(t.match(/^'[^']*'(\s*\|\s*'[^']*')+$/))return{kind:"combobox",options:[...t.matchAll(/'([^']*)'/g)].map((r)=>r[1])};return{kind:"text"}}function Ao(e){return JSON.parse(JSON.stringify(e))}function Le(e){return e&&e.length>0?e.at(-1):null}function LL(e){return e&&e.length>0?e[0]:null}function dv(e,t){if(!t||!e)return!1;return e.some((n)=>Yo(n,t))}function ms(e){return E(e)}function E(e){let t=[];for(let n of e)t.push([...n]);return t}function uv(e,t){if(dv(e,t))return E(e.filter((n)=>!Yo(n,t)));return[...E(e),[...t]]}function IL(e,t,n){let o=e.findIndex((s)=>Yo(s,n)),r=t?e.findIndex((s)=>Yo(s,t)):-1;if(o===-1||r===-1)return[[...n]];let i=r<=o?e.slice(r,o+1):e.slice(o,r+1).toReversed();return E(i)}function De(e,t){return E(e.filter((n)=>!qa(t,n)))}function Et(e,t){let n=Math.min(e.length,t.length);for(let o=0;o<n;o++){let r=e[o],i=t[o];if(r===i)continue;if(typeof r==="number"&&typeof i==="number")return r-i;return String(r)<String(i)?-1:1}return e.length-t.length}function Lt(e){return E(e.filter((t)=>!e.some((n)=>!Yo(n,t)&&qa(n,t))))}function Nl(e){return e.at(-2)==="children"&&typeof e.at(-1)==="number"}function hv(e){return Lt(e).filter((t)=>Nl(t)).toSorted((t,n)=>Et(n,t))}function RL(e){let t=[];for(let n of e)if(!t.some((o)=>Yo(o,n)))t.push([...n]);return t}function mp(e){if(e.length===0)return{mixed:!1,value:void 0};let t=e[0],n=JSON.stringify(t??null);for(let o=1;o<e.length;o++)if(JSON.stringify(e[o]??null)!==n)return{mixed:!0,value:void 0};return{mixed:!1,value:t}}var Ee=null;function $L(e){Ee=e}function Me(){return Ee}var V=null,U=null,G=null,ae=!0;function $e(){V=[],U=[],G=[],ae=!0}function f(e){if(V)V.push(e)}function vi(e){if(U)U.push(e)}function Ne(e){if(G)G.push(e)}function _e(){let e={docOps:U??[],fmOps:G??[],invertible:ae,ops:V??[]};return V=null,U=null,G=null,ae=!0,e}var Fe=100,Mt=20;function H(){try{return typeof localStorage>"u"||!localStorage.getItem("jx-legacy-history")}catch{return!0}}function P(e,t,n,o){return{forward:{key:t,op:"set-key",path:e,value:o},inverse:{key:t,op:"set-key",path:e,value:n}}}function $t(e,t,n,o,r){let i=e.length;if(!(i<t.length&&e.every((c,d)=>c===t[d]))||t[i]!=="children"||typeof t[i+1]!=="number")return t;let a=t[i+1];if(r?a<n:a<=n)return t;let l=[...t];return l[i+1]=a+o,l}var We=null;function Be(e){We=e}var Ve=null;function Ke(e){Ve=e}function Nt(e,t,n,o){for(let r=t.docOps.length-1;r>=0;r--)Im(e.doc.document,re(t.docOps[r].inverse));for(let r=t.fmOps.length-1;r>=0;r--){let i=t.fmOps[r];de(e,i.field,i.before)}e.doc.document={...re(e.doc.document)},e.session.selection=n,e.doc.dirty=o}function q(e,t,{skipHistory:n=!1,origin:o="user",coalesceKey:r=null}={}){if(!e)return!1;if(o!=="remote"&&Ve?.(e,o))return!1;let i=ms(e.session.selection),s=e.doc.dirty;$e();let a,l=null;try{t(e)}catch(b){l={error:b}}finally{a=_e()}if(l)throw Nt(e,a,i,s),l.error;let c=re(e.doc.document),d={...c},g=Me(),y=g===null?{patchable:!1,reason:"no-patch-consumer"}:a.ops.length===0?{patchable:!1,reason:"unrecorded-mutation"}:g.classify(e,a.ops);if(y.patchable)g.markConsumed(d,e);if(e.doc.document=d,y.patchable)try{g.apply(e,a.ops,a)}catch(b){g.escalate(`patch-apply-failed: ${b instanceof Error?b.message:String(b)}`,e)}if(!n&&!L)_t(e,c,a,i,r);return e.doc.dirty=!0,We?.(e,a,o),!0}function _t(e,t,n,o,r=null){let i=e.history.snapshots.slice(0,e.history.index+1),s=H()&&n.invertible&&(n.docOps.length>0||n.fmOps.length>0),a=i.at(-1);if(r&&s&&a&&a.coalesceKey===r&&a.inverseOps){if(a.forwardOps=[...a.forwardOps??[],...n.docOps.map((c)=>c.forward)],a.inverseOps=[...a.inverseOps,...n.docOps.map((c)=>c.inverse)],a.selection=ms(e.session.selection),a.document)a.document=Ao(t);e.history.snapshots=i,e.history.index=i.length-1;return}let l=!s||i.length%Mt===0;if(i.push({document:l?Ao(t):null,fmOps:s&&n.fmOps.length>0?n.fmOps:null,forwardOps:s?n.docOps.map((c)=>c.forward):null,inverseOps:s?n.docOps.map((c)=>c.inverse):null,coalesceKey:r,selection:ms(e.session.selection),selectionBefore:o}),i.length>Fe){if(!i[1].document)i[1].document=le(i,1);i.shift()}e.history.snapshots=i,e.history.index=i.length-1}function le(e,t){let n=t;while(n>=0&&!e[n].document)n-=1;if(n<0)throw Error("history-missing-checkpoint");let o=Ao(e[n].document);for(let r=n+1;r<=t;r++)for(let i of e[r].forwardOps??[])Im(o,i);return o}function Hs(e,t,n){return q(e,(o)=>t(o.doc.document),n)}function ce(e,t){q(e,(n)=>{for(let o of t)ue(n,o)},{origin:"remote",skipHistory:!0})}var Ft=new Set(["state","$media","$head","$elements","imports","$layout"]);function ue(e,t){let n=t.op==="set-key"?K(e.doc.document,t.path)?.[t.key]:null;switch(Im(e.doc.document,t),vi({forward:t,inverse:t}),t.op){case"set-key":{if(Ft.has(t.key))f({key:t.key,op:"doc-meta"});else if(t.key==="style")f({op:"set-style",path:t.path});else if(t.key==="textContent")f({op:"set-text",path:t.path});else if(t.key==="attributes"||t.key==="cases"||t.key==="$props")f({op:"replace",path:t.path});else{let o=t.key.startsWith("on")&&(rh(t.value)||rh(n));f({isEvent:o,key:t.key,op:"set-prop",path:t.path})}return}case"insert-child":{f({index:t.index,op:"insert",parentPath:t.parentPath});return}case"remove-child":{f({op:"remove",path:[...t.parentPath,"children",t.index]});return}case"set-child":{f({op:"replace",path:[...t.parentPath,"children",t.index]});return}case"move-child":{f({fromPath:[...t.fromParentPath,"children",t.fromIndex],op:"move",toIndex:t.toIndex,toParentPath:t.toParentPath});break}default:break}}var L=null,Ge=null;function qe(e){Ge=e}function pv(e){L=e}function fv(){let e=L;if(e&&!j.has(e)){let t=re(e.doc.document),n={document:Ao(t),selection:ms(e.session.selection)},o=e.history.snapshots.slice(0,e.history.index+1);if(o.push(n),o.length>Fe)o.shift();e.history.snapshots=o,e.history.index=o.length-1}if(L=null,e)Ge?.(e)}function Ix(){return L!==null}function DL(){return L}var j=new WeakMap;function ym(e,t){if(t)j.set(e,t);else j.delete(e)}function AL(e){let t=j.get(e);return t?t.canUndo(e):e.history.index>0}function NL(e){let t=j.get(e);return t?t.canRedo(e):e.history.index<e.history.snapshots.length-1}function ze(e,t){let{snapshots:n}=e.history;e.doc.document=le(n,t);let o=n[t];e.session.selection=ms(re(o.selection))}function Ye(e,t){try{if(typeof localStorage>"u"||!localStorage.getItem("jx-canvas-debug"))return}catch{return}let n=JSON.stringify(le(e.history.snapshots,t)),o=JSON.stringify(Ao(re(e.doc.document)));if(n!==o)console.error("jx history: ops-based undo/redo diverged from checkpoint replay",{index:t})}function Rx(e){let t=j.get(e);if(t){t.undo(e);return}if(e.history.index<=0)return;let n=e.history.snapshots[e.history.index],o=H()?n.inverseOps:null,r=H()?n.fmOps:null;if(o&&o.length>0||r&&r.length>0){if(!q(e,(s)=>{if(o)for(let a=o.length-1;a>=0;a--)ue(s,re(o[a]));if(r)for(let a=r.length-1;a>=0;a--){let l=re(r[a]);de(s,l.field,l.before)}},{origin:"history",skipHistory:!0}))return;e.session.selection=ms(re(n.selectionBefore??[])),e.history.index-=1,Ye(e,e.history.index)}else e.history.index-=1,ze(e,e.history.index);e.doc.dirty=!0}function OL(e){let t=j.get(e);if(t){t.redo(e);return}if(e.history.index>=e.history.snapshots.length-1)return;let n=e.history.snapshots[e.history.index+1],o=H()?n.forwardOps:null,r=H()?n.fmOps:null;if(o&&o.length>0||r&&r.length>0){if(!q(e,(s)=>{if(o)for(let a of o)ue(s,re(a));if(r)for(let a of r){let l=re(a);de(s,l.field,l.after)}},{origin:"history",skipHistory:!0}))return;e.session.selection=ms(re(n.selection)),e.history.index+=1,Ye(e,e.history.index)}else e.history.index+=1,ze(e,e.history.index);e.doc.dirty=!0}function Ji(e,t,n,o){let r=K(e.doc.document,t);if(!r)return;Ic(r).splice(n,0,structuredClone(o)),f({index:n,op:"insert",parentPath:t}),vi({forward:{index:n,node:Ae(o),op:"insert-child",parentPath:t},inverse:{index:n,op:"remove-child",parentPath:t}})}function Vu(e,t){if(!t||!Nl(t))return;let n=ht(t),o=_n(t),[r]=K(e.doc.document,n).children.splice(o,1);f({op:"remove",path:t}),vi({forward:{index:o,op:"remove-child",parentPath:n},inverse:{index:o,node:Ae(r),op:"insert-child",parentPath:n}}),e.session.selection=De(e.session.selection,t)}function VC(e,t){if(!t||!Nl(t))return;let n=K(e.doc.document,t);if(!n)return;let o=ht(t),r=_n(t),i=structuredClone(re(n));K(e.doc.document,o).children.splice(r+1,0,i),f({index:r+1,op:"insert",parentPath:o}),vi({forward:{index:r+1,node:Ae(i),op:"insert-child",parentPath:o},inverse:{index:r+1,op:"remove-child",parentPath:o}}),e.session.selection=[[...o,"children",r+1]]}function gp(e,t){for(let n of hv(t))Vu(e,n)}function mv(e,t){let n=[];for(let o of hv(t)){let r=e.session.selection;VC(e,o);let i=Le(e.session.selection);if(!i||e.session.selection===r)continue;let s=ht(i),a=_n(i);n=n.map((l)=>$t(s,l,a,1,!0)),n.unshift(i)}if(n.length>0)e.session.selection=n}function ML(e,t,n="div"){if(!t||!Nl(t))return;let o=K(e.doc.document,t);if(!o)return;let r=ht(t),i=_n(t),s={children:[structuredClone(re(o))],tagName:n},a=Ae(o);K(e.doc.document,r).children.splice(i,1,s),f({op:"replace",path:t}),vi({forward:{index:i,node:Ae(s),op:"set-child",parentPath:r},inverse:{index:i,node:a,op:"set-child",parentPath:r}}),e.session.selection=[[...r,"children",i]]}function pa(e,t,n,o){let r=e.doc.document,i=ht(t),s=_n(t);if(!i||typeof s!=="number")return;let a=K(r,i),l=K(r,n);if(!a||!Array.isArray(a.children)||!l)return;if(a.children[s]===void 0)return;let c=o;if(a===l&&s<o)c-=1;let d={fromIndex:s,fromParentPath:i,op:"move-child",toIndex:c,toParentPath:n},g=lk(r,d),[y]=a.children.splice(s,1);if(Ic(l).splice(c,0,y),f({fromPath:t,op:"move",toIndex:c,toParentPath:n}),vi({forward:d,inverse:g}),Yo(Le(e.session.selection),t)){let b=o;if(i.length===n.length&&i.every((_,I)=>_===n[I])&&s<o)b=o-1;e.session.selection=[[...n,"children",b]]}}function Ue(e,t,n,o){let r=K(e.doc.document,t);if(!r)return;let i=r[n],s=Ae(i);if(o===void 0||o===null||o==="")delete r[n];else r[n]=o;if(vi(P(t,n,s,Ae(r[n]))),n==="textContent")f({op:"set-text",path:t});else if(n==="style")f({op:"set-style",path:t});else{let a=o===void 0||o===null||o===""?i:o,l=n.startsWith("on")&&rh(a);f({isEvent:l,key:n,op:"set-prop",path:t})}}function kc(e,t,n,o){let r=K(e.doc.document,t),i=Ae(r.style);if(!r.style)r.style={};if(o===void 0||o==="")delete r.style[n];else r.style[n]=o;if(Object.keys(r.style).length===0)delete r.style;vi(P(t,"style",i,Ae(r.style))),f({op:"set-style",path:t})}function Ko(e,t,n,o){let r=K(e.doc.document,t),i=Ae(r.attributes);if(!r.attributes)r.attributes={};if(o===void 0||o==="")delete r.attributes[n];else r.attributes[n]=o;if(Object.keys(r.attributes).length===0)delete r.attributes;vi(P(t,"attributes",i,Ae(r.attributes))),f({attr:n,op:"set-attr",path:t})}function PL(e,t,n,o,r){if(!n)return kc(e,t,o,r);let i=K(e.doc.document,t),s=Ae(i.style);if(!i.style)i.style={};let a=`@${n}`,l=oh(i.style,a);if(r===void 0||r===""){if(delete l[o],Object.keys(l).length===0)delete i.style[a]}else l[o]=r;if(Object.keys(i.style).length===0)delete i.style;vi(P(t,"style",s,Ae(i.style))),f({op:"set-style",path:t})}function gv(e,t,n,o,r){let i=K(e.doc.document,t),s=Ae(i.style);if(!i.style)i.style={};let a=oh(i.style,n);if(r===void 0||r===""){if(delete a[o],Object.keys(a).length===0)delete i.style[n]}else a[o]=r;if(Object.keys(i.style).length===0)delete i.style;vi(P(t,"style",s,Ae(i.style))),f({op:"set-style",path:t})}function FL(e,t,n,o,r,i){let s=K(e.doc.document,t),a=Ae(s.style);if(!s.style)s.style={};let l=`@${n}`,c=oh(s.style,l),d=oh(c,o);if(i===void 0||i===""){if(delete d[r],Object.keys(d).length===0)delete c[o];if(Object.keys(c).length===0)delete s.style[l]}else d[r]=i;if(Object.keys(s.style).length===0)delete s.style;vi(P(t,"style",a,Ae(s.style))),f({op:"set-style",path:t})}function Ze(e,t){let n=[e];for(let o of t){let r=va(n.at(-1),o);if(!r)break;n.push(r)}for(let o=n.length-2;o>=0;o--){let r=n[o],i=t[o],s=va(r,i);if(s&&Object.keys(s).length===0)delete r[i]}}function bv(e,t,n,o,r){let i=K(e.doc.document,t),s=Ae(i.style);if(!i.style)i.style={};let a=i.style;for(let l of n)a=oh(a,l);if(r===void 0||r==="")delete a[o],Ze(i.style,n);else a[o]=r;if(Object.keys(i.style).length===0)delete i.style;vi(P(t,"style",s,Ae(i.style))),f({op:"set-style",path:t})}function jL(e,t,n,o,r,i){let s=K(e.doc.document,t),a=Ae(s.style);if(!s.style)s.style={};let l=`@${n}`,c=oh(s.style,l),d=c;for(let g of o)d=oh(d,g);if(i===void 0||i===""){if(delete d[r],Ze(c,o),Object.keys(c).length===0)delete s.style[l]}else d[r]=i;if(Object.keys(s.style).length===0)delete s.style;vi(P(t,"style",a,Ae(s.style))),f({op:"set-style",path:t})}function HL(e,t,n){let o=K(e.doc.document,t),r=Ae(o.style);if(n&&Object.keys(n).length>0)o.style=n;else delete o.style;vi(P(t,"style",r,Ae(o.style))),f({op:"set-style",path:t})}function Bs(e,t,n){let o=e.doc.document,r=Ae(o.state);if(!o.state)o.state={};o.state[t]=n,vi(P([],"state",r,Ae(o.state))),f({key:"state",op:"doc-meta"})}function vv(e,t){let n=e.doc.document;if(n.state){let o=Ae(n.state);if(delete n.state[t],Object.keys(n.state).length===0)delete n.state;vi(P([],"state",o,Ae(n.state))),f({key:"state",op:"doc-meta"})}}function mr(e,t,n){let o=e.doc.document,r=Ae(o.state);if(!o.state)o.state={};let i=o.state[t],s=i==null?{}:typeof i!=="object"||Array.isArray(i)?{default:i}:i;o.state[t]=s,Object.assign(s,n);for(let a of Object.keys(s))if(s[a]===void 0||s[a]===null)delete s[a];vi(P([],"state",r,Ae(o.state))),f({key:"state",op:"doc-meta"})}function BL(e,t,n){let o=e.doc.document;if(!o.state||!o.state[t])return;let r=Ae(o.state);o.state[n]=o.state[t],delete o.state[t],vi(P([],"state",r,Ae(o.state))),f({key:"state",op:"doc-meta"})}function Uu(e,t,n,o){let r=K(e.doc.document,t),i=Ae(r.$props);if(!r.$props)r.$props={};if(o===void 0||o===null||o==="")delete r.$props[n];else r.$props[n]=o;if(Object.keys(r.$props).length===0)delete r.$props;vi(P(t,"$props",i,Ae(r.$props))),f({op:"replace",path:t})}function zL(e,t,n,o){let r=K(e.doc.document,t),i=Ae(r.cases);if(!r.cases)r.cases={};r.cases[n]=o||{tagName:"div",textContent:n},vi(P(t,"cases",i,Ae(r.cases))),f({op:"replace",path:t})}function WL(e,t,n){let o=K(e.doc.document,t);if(o.cases){let r=Ae(o.cases);delete o.cases[n],vi(P(t,"cases",r,Ae(o.cases))),f({op:"replace",path:t})}}function VL(e,t,n,o){let r=K(e.doc.document,t);if(!r.cases||!r.cases[n])return;let i=Ae(r.cases);r.cases[o]=r.cases[n],delete r.cases[n],vi(P(t,"cases",i,Ae(r.cases))),f({op:"replace",path:t})}function Ol(e,t,n){let o=e.doc.content.frontmatter,r=Object.hasOwn(o,t)?Ae(o[t]):void 0,i=n===void 0||n===null||n==="";if(i)delete o[t];else o[t]=n;let s=i?void 0:Ae(n);Ne({after:s,before:r,field:t}),e.doc.dirty=!0}function de(e,t,n){if(n===void 0)delete e.doc.content.frontmatter[t];else e.doc.content.frontmatter[t]=n}var Wt={design:"canvas",edit:"canvas",entry:"entry","git-diff":"diff",grid:"grid",manage:"library",media:"media",preview:"canvas",settings:"config",source:"code",stylebook:"config"},ov={canvas:"Canvas",code:"Code",config:"Project Styles",diff:"Diff",entry:"Entry",grid:"Grid",media:"Media",library:"Library",none:"None"};function ha(e){return Wt[e]??"canvas"}var Bt={design:"design",edit:"edit",preview:"preview"};function vL(e){return Bt[e]??"design"}var rv=(e)=>e.editor.kind==="canvas",$d=(e)=>rv(e)&&e.selection.count>0,sv=(e)=>$d(e)&&!e.selection.isRoot;function bm(){return{project:{open:!1,isSite:!1,isRepo:!1,isMultilingual:!1},git:{ahead:0,behind:0,dirtyCount:0},document:{open:!1,dirty:!1,mode:"",canUndo:!1,canRedo:!1},editor:{kind:"none"},canvas:{view:"design"},pane:{count:1,derived:!1},selection:{count:0,paths:[],kind:"",isRoot:!1,isComponentInstance:!1,isLayoutNode:!1,isRepeater:!1},caret:{active:!1,inCanvas:!1},focus:{region:"pane"},modal:{open:!1},collab:{attached:!1,readOnly:!1,sourceCanonical:!1},ai:{configured:!1,streaming:!1,waiting:!1},capability:{gitClone:!1,importSite:!1,openProjectInNewWindow:!1,dataRows:!1,windowControls:!1,findReferences:!1,readFileBytes:!1}}}function Ex(e={}){let t=bm();for(let n of Object.keys(e)){let o=e[n];if(o)Object.assign(t[n],o)}return t}var Vt=["palette"],Kt=["caret","global"],Ut=["dock","global"],Gt=["canvas","global"],Ht=["grid","global"],qt=["code","global"],Xe=["global"];function yL(e){if(e.modal.open)return Vt;if(e.caret.active)return Kt;if(e.focus.region!=="pane")return Ut;switch(e.editor.kind){case"grid":return Ht;case"code":return qt;case"canvas":return e.canvas.view==="preview"?Xe:Gt;default:return Xe}}var ai="project.json";function zt(e,t=!1){return{activeMedia:null,activeSelector:null,openPopover:null,openDialog:null,canvasMode:e,editZoom:1,editingFormula:null,editingFunction:null,featureToggles:{},inspectorSections:{},pendingInlineEdit:null,preview:t,previewColorScheme:"auto",previewLocale:null,previewParams:{},previewProps:null,rightTab:"properties",showLayout:!0,styleFilter:"",styleSections:{},dataRows:{},dataLimits:{},styleShorthands:{},zoom:1}}var Yt=["edit","design","preview","source","stylebook","git-diff"];function cv({id:e,documentPath:t=null,fileHandle:n=null,document:o,frontmatter:r,sourceFormat:i=null,capabilities:s,openedFrom:a=null,preview:l=!1,layout:c=null}){let d=ge();Lm(o);let g=s?.modes??Xt(t,i),y=g.find((I)=>I!=="preview")??"edit",b=g[0]==="preview";return d.run(()=>({capabilities:{modes:g},doc:v({content:{frontmatter:r||{}},dirty:!1,document:o,handlersSource:null,layout:c,mode:Qt(t,i),sourceFormat:i}),documentPath:t,fileHandle:n,history:v({index:0,snapshots:[{document:structuredClone(o),selection:[]}]}),id:e,pinned:!1,preview:l,scope:d,session:v({canvas:{refreshing:!1,error:null,livePreviews:null,pendingInlineEdit:null,scope:null,status:"idle"},clipboard:null,hover:null,openedFrom:a,selection:[],ui:zt(y,b)})}))}function Xt(e,t){if(e===ai)return["stylebook","source"];let n=wi(t)??Zt(e);if(n)return n.studio?.modes??["edit","design","preview","source"];return Yt}function Qt(e,t){let n=wi(t)??Zt(e);if(n)return n.studio?.documentMode?.default??"content";return"component"}function WC(e){return ha(e.session.ui.canvasMode)}function EL(e){let t=[];for(let n of e.capabilities.modes){if(n==="preview")continue;let o=ha(n);if(!t.includes(o))t.push(o)}return t}function TL(e,t){return e.capabilities.modes.find((n)=>n!=="preview"&&ha(n)===t)}function fp(e){e.scope.stop()}var Qe=new WeakMap,M=new Map;function xn(e){let t=re(e),n=Qe.get(t);if(!n)n=v({active:!1,attachError:"",peers:[],readOnly:!1,sourceCanonical:!1,status:"unavailable"}),Qe.set(t,n);return n}function et(e){M.set(e,(M.get(e)??0)+1)}function tt(e){let t=M.get(e)??0;if(t<=1)M.delete(e);else M.set(e,t-1)}function wm(e){return M.has(e.replaceAll("\\","/"))}var en=8000,tn=800,nn=2500,nt=null;function on(){return nt??=(me("m0x5ztax"),import("./index-m0x5ztax.js")),nt}function it(){try{return p()}catch{return null}}var N=null;function YL(e){N=e}var pe=null;function ZL(e){pe=e}var st=()=>{};function XL(e){st=e??(()=>{})}var be=new WeakMap;function at(e){return re(e)}function C(e){return be.get(at(e))}function xe(e){let t=at(e),n=be.get(t);if(!n)n={attaching:null,generation:0,optedOut:v({value:!1}),session:null,watcherInstalled:!1},be.set(t,n);return n}var rt=!1;function rn(){if(rt)return;rt=!0,Be(sn),qe(an),Ke((e)=>{if(C(e)?.session?.synced&&xn(e).sourceCanonical)return st("Source editing in progress — structural edits are paused"),"source-canonical";return null})}function sn(e,t,n){let o=C(e)?.session;if(!o||!o.synced)return;if(o.lastSeenRef=re(e.doc.document),n==="remote"){ee(o);return}if(o.canWrite)ln(o,t),ee(o)}function an(e){let t=C(e)?.session;if(!t?.synced||t.batchOps===null)return;let{batchOps:n,batchNeedsDiff:o}=t;if(t.batchOps=null,t.batchNeedsDiff=!1,!t.canWrite)return;if(t.undoManager?.stopCapturing(),o)z(t);else if(n.length>0)try{t.collab.applyDocOpsToY(t.handle.doc,n,t.collab.LOCAL_ORIGIN)}catch{z(t)}t.undoManager?.stopCapturing()}function ln(e,t){let n=t.docOps.map((o)=>o.forward);if(Ix()){if(e.batchOps??=[],n.length===0)e.batchNeedsDiff=!0;else e.batchOps.push(...n);return}if(n.length===0){z(e);return}try{e.collab.applyDocOpsToY(e.handle.doc,n,e.collab.LOCAL_ORIGIN)}catch{z(e)}}function z(e){let{collab:t,handle:n,tab:o}=e,r=t.yDocToJson(n.doc),i=Ao(re(o.doc.document)),s=t.diffDocs(r,i);if(s===null)t.replaceYStructure(n.doc,i,t.LOCAL_ORIGIN);else if(s.length>0)try{t.applyDocOpsToY(n.doc,s,t.LOCAL_ORIGIN)}catch{t.replaceYStructure(n.doc,i,t.LOCAL_ORIGIN)}}function fe(e){let t=e.collab.yDocToJson(e.handle.doc);q(e.tab,(n)=>{let o=n.doc.document;for(let r of Object.keys(o))if(!(r in t))delete o[r];Object.assign(o,t)},{origin:"remote",skipHistory:!0})}function cn(e){if(!e.canWrite)return!1;let{awareness:t}=e.handle,n=t.clientID;for(let[o,r]of t.getStates())if(r.canWrite!==!1&&o<n)n=o;return n===e.handle.awareness.clientID}function ee(e){if(!N||!cn(e))return;if(e.collab.canonicalOf(e.handle.doc)==="source")return;let t=Date.now();if(e.lastMirrorAt??=t,t-e.lastMirrorAt>=nn){if(e.mirrorTimer)clearTimeout(e.mirrorTimer),e.mirrorTimer=null;e.lastMirrorAt=t,ye(e);return}if(e.mirrorTimer)clearTimeout(e.mirrorTimer);e.mirrorTimer=setTimeout(()=>{e.mirrorTimer=null,e.lastMirrorAt=Date.now(),ye(e)},tn)}async function ye(e){if(!N||!e.synced)return;try{let t=await N(e.tab);e.collab.updateSourceText(e.handle.doc,t,e.collab.MIRROR_ORIGIN)}catch{}}async function lt(e){if(!pe||!e.synced||!e.canWrite)return;let{collab:t,handle:n,tab:o}=e,r=t.canonicalRevOf(n.doc),i=t.sourceText(n.doc).toString(),s;try{s=await pe(o,i)}catch{return}if(!e.synced||t.canonicalRevOf(n.doc)!==r)return;let a=t.diffDocs(t.yDocToJson(n.doc),s.document);if(a===null)t.replaceYStructure(n.doc,s.document,t.MIRROR_ORIGIN);else if(a.length>0)try{t.applyDocOpsToY(n.doc,a,t.MIRROR_ORIGIN)}catch{t.replaceYStructure(n.doc,s.document,t.MIRROR_ORIGIN)}let l=t.frontmatterMap(n.doc),c=s.frontmatter??{};n.doc.transact(()=>{let d=[...l.keys()];for(let g of d)if(!(g in c))l.delete(g);for(let[g,y]of Object.entries(c))if(!t.deepEqual(l.get(g),y))l.set(g,y)},t.MIRROR_ORIGIN)}function QL(e){let t=C(e)?.session;if(!t?.synced)return null;let{collab:n,handle:o}=t,r=null,i=()=>r!==null&&t.sourceLockOwner===r;return{awareness:o.awareness,enter:async()=>{r={},t.sourceLockOwner=r;let s=o.awareness.getLocalState();if(s)o.awareness.setLocalState({...s,mode:"source"});if(!t.canWrite)return;let a=null;if(N)try{a=await N(e)}catch{a=null}if(!i())return;n.acquireSourceCanonical(o.doc,a??n.sourceText(o.doc).toString(),n.LOCAL_ORIGIN)},leave:()=>{if(!i()){r=null;return}r=null,t.sourceLockOwner=null;let s=o.awareness.getLocalState();if(s)o.awareness.setLocalState({...s,mode:"structure"});if(!t.canWrite)return;if(n.otherSourceEditors(o.awareness,t.path,o.awareness.clientID).filter((l)=>o.awareness.getStates().get(l)?.canWrite!==!1).length===0)lt(t).then(()=>{n.releaseSourceCanonical(o.doc,n.LOCAL_ORIGIN)})},localOrigin:n.LOCAL_ORIGIN,readOnly:!t.canWrite,text:n.sourceText(o.doc)}}function _m(e){let t=xn(e);return t.active&&t.readOnly}async function GC(e){let t=C(e)?.session;if(!t?.synced||!t.canWrite)return!1;if(t.mirrorTimer)clearTimeout(t.mirrorTimer),t.mirrorTimer=null;return await ye(t),await t.handle.flush(),!0}async function KC(){for(let e of he)if(C(e)?.session?.synced)await GC(e)}var he=new Set;function Y(e){if(!it()?.collab||!e.documentPath||e.documentPath===ai)return;let n=xe(e);if(n.watcherInstalled)return;n.watcherInstalled=!0,rn(),he.add(e),e.scope.run(()=>{Q(()=>{if(n.optedOut.value)te(e);else ve(e)}),Xa(()=>{he.delete(e),te(e)})})}function JC(e,t){let n=xe(e);if(n.optedOut.value===!t)return;if(n.optedOut.value=!t,!n.watcherInstalled&&t)Y(e)}function YC(e){return C(e)?.optedOut.value!==!0}function ct(e){if(!C(e)?.watcherInstalled){Y(e);return}te(e),ve(e)}async function ve(e){let t=xe(e);if(t.session||t.attaching)return;let{documentPath:n}=e,o=it();if(!n||!o?.collab){xn(e).status="unavailable";return}let{generation:r}=t,i=xn(e);i.status="connecting",i.attachError="";let s=(async()=>{try{let[a,l]=await Promise.all([on(),o.collab(n)]);if(!l){i.status="detached";return}if(t.generation!==r){l.destroy();return}let c=null,d=new Promise((g,y)=>{c=setTimeout(()=>y(Error("collab-sync-timeout")),en)});try{await Promise.race([l.whenSynced,d])}finally{if(c)clearTimeout(c)}if(t.generation!==r){l.destroy();return}t.session=un(e,n,a,l),i.active=!0,i.status="synced",i.readOnly=!t.session.canWrite,i.attachError="",et(n)}catch(a){i.status="failed",i.active=!1,i.attachError=a instanceof Error?a.message:String(a),k.warn(`Live collaboration is not available for "${n}" — ${i.attachError}`,{key:`collab:${n}`,path:n,source:"Collaboration"})}finally{t.attaching=null}})();t.attaching=s,await s}function te(e){let t=C(e);if(!t)return;t.generation+=1;let{session:n}=t;t.session=null;let o=xn(e);if(o.active=!1,o.status="detached",o.attachError="",o.peers=[],!n)return;if(tt(n.path),n.mirrorTimer)clearTimeout(n.mirrorTimer);if(n.sourceParseTimer)clearTimeout(n.sourceParseTimer);for(let r of n.disposers)try{r()}catch{}ym(e,null),e.history.snapshots=[{document:Ao(re(e.doc.document)),selection:ms(e.session.selection)}],e.history.index=0,n.undoManager?.destroy(),n.handle.destroy()}function un(e,t,n,o){let r=o.identity(),i={applyingRemoteFrontmatter:!1,batchNeedsDiff:!1,batchOps:null,canWrite:r?r.permission!=="read":!0,collab:n,disposers:[],handle:o,lastSeenRef:re(e.doc.document),mirrorTimer:null,path:t,sourceLockOwner:null,sourceParseTimer:null,synced:!1,tab:e,undoManager:null};if(n.metaMap(o.doc).get("structureSeeded")===!0){let h=n.yDocToJson(o.doc),x=Ao(re(e.doc.document));if(!n.deepEqual(h,x)){let w=n.diffDocs(x,h);if(w===null)i.synced=!0,fe(i),i.synced=!1;else if(w.length>0)ce(e,w)}i.applyingRemoteFrontmatter=!0;let T=n.frontmatterMap(o.doc);for(let[w,J]of T.entries())e.doc.content.frontmatter[w]=J;i.applyingRemoteFrontmatter=!1}else if(i.canWrite)n.seedStructure(o.doc,Ao(re(e.doc.document)),{frontmatter:Ao(re(e.doc.content.frontmatter)),origin:n.SEED_ORIGIN,sourceFormat:e.doc.sourceFormat});i.lastSeenRef=re(e.doc.document),i.disposers.push(o.onDirty((h)=>{e.doc.dirty=h})),o.awareness.setLocalState({canWrite:i.canWrite,focusedPath:t,structuralSelection:null,user:r?{avatarUrl:r.avatarUrl,color:r.color,login:r.login,name:r.name}:{color:n.colorForKey(String(o.awareness.clientID)),login:`guest-${o.awareness.clientID%1000}`}});let a=new n.UndoManager([n.structureMap(o.doc),n.frontmatterMap(o.doc)],{trackedOrigins:new Set([n.LOCAL_ORIGIN])});i.undoManager=a;let l=({stackItem:h})=>{h.meta.set("selection",ms(e.session.selection))},c=({stackItem:h})=>{let x=h.meta.get("selection");e.session.selection=ms(x??[])};a.on("stack-item-added",l),a.on("stack-item-popped",c),i.disposers.push(()=>{a.off("stack-item-added",l),a.off("stack-item-popped",c)}),ym(e,{canRedo:()=>a.canRedo(),canUndo:()=>a.canUndo(),redo:()=>{a.redo()},undo:()=>{a.undo()}});let d=n.structureMap(o.doc),g=(h,x)=>{if(x.origin===n.LOCAL_ORIGIN||!i.synced)return;let T=n.yEventsToDocOps(h);if(T===null){fe(i);return}if(T.length===0)return;try{ce(e,T)}catch{fe(i)}};d.observeDeep(g),i.disposers.push(()=>d.unobserveDeep(g));let y=xn(e);y.sourceCanonical=n.canonicalOf(o.doc)==="source";let b=n.metaMap(o.doc),_=()=>{y.sourceCanonical=n.canonicalOf(o.doc)==="source"};b.observe(_),i.disposers.push(()=>b.unobserve(_));let I=n.sourceText(o.doc),Oe=(h,x)=>{if(x.origin===n.MIRROR_ORIGIN||!i.synced)return;if(n.canonicalOf(o.doc)!=="source")return;if(!n.isSourceReconciler(o.awareness,i.path))return;if(i.sourceParseTimer)clearTimeout(i.sourceParseTimer);i.sourceParseTimer=setTimeout(()=>{i.sourceParseTimer=null,lt(i)},600)};I.observe(Oe),i.disposers.push(()=>I.unobserve(Oe));let A=n.frontmatterMap(o.doc),we=(h,x)=>{if(x.origin===n.LOCAL_ORIGIN||!i.synced)return;i.applyingRemoteFrontmatter=!0;try{for(let[T,w]of h.changes.keys)if(w.action==="delete")delete e.doc.content.frontmatter[T];else e.doc.content.frontmatter[T]=A.get(T)}finally{i.applyingRemoteFrontmatter=!1}};A.observe(we),i.disposers.push(()=>A.unobserve(we)),e.scope.run(()=>{let h=JSON.stringify(e.doc.content.frontmatter);Q(()=>{let x=JSON.stringify(e.doc.content.frontmatter);if(x===h)return;if(h=x,i.applyingRemoteFrontmatter||!i.synced||!i.canWrite)return;let T=JSON.parse(x);o.doc.transact(()=>{let w=[...A.keys()];for(let J of w)if(!(J in T))A.delete(J);for(let[J,Ce]of Object.entries(T))if(!n.deepEqual(A.get(J),Ce))A.set(J,Ce)},n.LOCAL_ORIGIN),ee(i)}),Q(()=>{let x=e.session.selection.length>0?ms(e.session.selection):null,T=o.awareness.getLocalState();if(T)o.awareness.setLocalState({...T,structuralSelection:x})}),Q(()=>{let x=re(e.doc.document);queueMicrotask(()=>{if(C(e)?.session!==i||!i.synced||!i.canWrite)return;let w=re(e.doc.document);if(w!==x||w===i.lastSeenRef)return;i.lastSeenRef=w,z(i),ee(i)})})});let oe=xn(e),ie=()=>{let h=[];for(let[x,T]of o.awareness.getStates())if(x!==o.awareness.clientID&&T.user)h.push({clientId:x,state:T});oe.peers=h};return ie(),o.awareness.on("change",ie),i.disposers.push(()=>o.awareness.off("change",ie),o.onStatus((h)=>{if(h==="offline"||h==="connecting")oe.status="offline";else if(i.synced)oe.status="synced"}),o.onReset(()=>{te(e),ve(e)})),i.synced=!0,i}function S(e,t,n){return RangeError(`command "${e}" argument "${t}": ${n}`)}function O(e){if(e===void 0)return"missing";return typeof e==="string"?`"${e}"`:`${typeof e} ${JSON.stringify(e)}`}function ot(e,t,n){let o=t[n];if(typeof o!=="string"||o==="")throw S(e,n,`expected a non-empty string, got ${O(o)}`);return o}function Jo(e,t,n){if(t[n]===void 0)return;return ot(e,t,n)}function dt(e,t,n){let o=t[n];if(typeof o!=="number"||!Number.isFinite(o))throw S(e,n,`expected a finite number, got ${O(o)}`);return o}function ut(e,t,n){let o=t[n];if(typeof o!=="number"||!Number.isInteger(o))throw S(e,n,`expected an integer, got ${O(o)}`);return o}function yv(e,t,n,o,r){let i=dt(e,t,n);if(i<o||i>r)throw S(e,n,`${i} is outside the supported range ${o}–${r}`);return i}function yi(e,t,n){let o=t[n];if(typeof o!=="boolean")throw S(e,n,`expected a boolean, got ${O(o)}`);return o}function li(e,t,n,o){let r=t[n];if(typeof r!=="string"||!o.includes(r))throw S(e,n,`${O(r)} is not declared — declared: ${o.join(", ")||"none"}`);return r}function $x(e,t,n){let o=t[n];if(!Array.isArray(o)||!o.every((r)=>typeof r==="string"||typeof r==="number"))throw S(e,n,`expected an array of path segments (strings or numbers), got ${O(o)}`);return o}function UL(e,t,n){if(t[n]===null)return null;return $x(e,t,n)}function UC(e,t,n){let o=t[n];if(!Array.isArray(o))throw S(e,n,`expected an array of document paths, got ${O(o)}`);return o.map((r,i)=>{if(!Array.isArray(r)||!r.every((s)=>typeof s==="string"||typeof s==="number"))throw S(e,n,`entry ${i} is not a document path — expected an array of segments, got ${O(r)}`);return r})}function Se(e,t=Object.keys(e)){return{additionalProperties:!1,properties:e,required:[...t],type:"object"}}function Do(e,t){return{description:t,enum:[...e],type:"string"}}function fa(e,t){return{description:t,get enum(){return[...e()]},type:"string"}}function qC(e,t={}){return{description:e,type:"number",...t}}function oo(e){return{description:e,type:"boolean"}}function wv(e,t=!1){let n={items:{type:["string","number"]},type:"array"};return t?{description:e,oneOf:[n,{type:"null"}]}:{description:e,...n}}function qL(e){return{description:e,items:{items:{type:["string","number"]},type:"array"},type:"array"}}function He(e){return{description:e,type:"string"}}function fn(e){return e.length===2&&e.includes("string")&&e.includes("number")}function Te(e){return Array.isArray(e)?e:[e]}function ft(e){let t=e;if("enum"in t)return"enum";if("const"in t)return"const";if(Array.isArray(t.oneOf))return"one-of";if(Array.isArray(t.type))return"typed";switch(t.type){case"boolean":return"boolean";case"number":case"integer":{if(t.minimum!==void 0&&t.maximum!==void 0)return"bounded-number";return t.type==="integer"?"integer":"number"}case"string":return"string";case"array":{let n=t.items?.type;if(Array.isArray(n))return fn(n)?"path":"pass-through";return n==="array"?"path-list":"pass-through"}case"null":case"object":return"typed";default:break}return"pass-through"}function pt(e,t){switch(e){case"null":return t===null;case"boolean":return typeof t==="boolean";case"string":return typeof t==="string";case"number":return typeof t==="number"&&Number.isFinite(t);case"integer":return typeof t==="number"&&Number.isInteger(t);case"array":return Array.isArray(t);case"object":return typeof t==="object"&&t!==null&&!Array.isArray(t);default:break}return!1}function mt(e){if(e.length<=1)return e.join("");return`${e.slice(0,-1).join(", ")} or ${e.at(-1)}`}function pn(e,t,n,o){let r=t[n];if(!o.some((i)=>pt(i,r)))throw S(e,n,`expected ${mt(o)}, got ${O(r)}`);return r}function gt(e){switch(ft(e)){case"enum":return`one of ${(e.enum??[]).map((t)=>O(t)).join(" | ")}`;case"const":return`the constant ${O(e.const)}`;case"one-of":return(e.oneOf??[]).map((t)=>gt(t)).join(" or ");case"typed":return mt(Te(e.type??[]));case"boolean":return"a boolean";case"bounded-number":return`a number from ${e.minimum} to ${e.maximum}`;case"number":return"a finite number";case"integer":return"an integer";case"string":return"a non-empty string";case"path":return"a document path";case"path-list":return"a list of document paths";default:return"anything"}}function mn(e,t,n,o){let r=t[n],i=[];for(let s of o){if(s.type!==void 0&&!Te(s.type).some((a)=>pt(a,r)))continue;try{return bt(e,t,n,s)}catch(a){i.push(a)}}if(i.length===1)throw i[0];throw S(e,n,`expected ${o.map((s)=>gt(s)).join(" or ")}, got ${O(r)}`)}function bt(e,t,n,o){switch(ft(o)){case"enum":return li(e,t,n,o.enum??[]);case"const":{let r=t[n];if(r!==o.const)throw S(e,n,`expected the constant ${O(o.const)}, got ${O(r)}`);return r}case"one-of":return mn(e,t,n,o.oneOf??[]);case"typed":return pn(e,t,n,Te(o.type??[]));case"boolean":return yi(e,t,n);case"bounded-number":{if(o.type==="integer")ut(e,t,n);return yv(e,t,n,o.minimum,o.maximum)}case"number":return dt(e,t,n);case"integer":return ut(e,t,n);case"string":return ot(e,t,n);case"path":return $x(e,t,n);case"path-list":return UC(e,t,n);default:return t[n]}}function GL(e,t,n){let o=t,r=o.properties??{},i=Object.keys(r),s=o.required??[],a={};for(let[l,c]of Object.entries(n)){if(c===void 0||Object.hasOwn(r,l))continue;if(o.additionalProperties===!1)throw S(e,l,`not declared — declared: ${i.join(", ")||"none"}`);a[l]=c}for(let l of i){if(n[l]===void 0&&!s.includes(l))continue;a[l]=bt(e,n,l,r[l])}return a}var gn=20,Qn="primary",vp="secondary",ZC=2,m=v({activePaneId:Qn,clipboard:null,closedTabs:[],componentRegistry:[],mruOrder:[],fileTree:{dirs:new Map,expanded:new Set,searchQuery:"",selectedPath:null},panes:[{activeTabId:null,derived:null,id:Qn,tabOrder:[]}],projectConfig:null,projectRoot:null,styleClipboard:null,tabs:new Map,ui:{activityBar:"files"},get activeTabId(){let e=Rr();return e.derived?.kind==="lens"?Hn(e.derived.sourcePaneId)?.activeTabId??null:e.activeTabId},get tabOrder(){return Rr().tabOrder}}),u=zd(()=>m.activeTabId?m.tabs.get(m.activeTabId)??null:null);function Rr(){let{panes:e}=m;return e.find((t)=>t.id===m.activePaneId)??e[0]}function Hn(e){return m.panes.find((t)=>t.id===e)}function Gu(e){return m.panes.find((t)=>t.tabOrder.includes(e))}function $r(e){let t=Hn(e);if(!t||t.id===m.activePaneId)return;m.activePaneId=t.id,R();let{activeTabId:n}=t;if(n){Pe(n);let o=m.tabs.get(n);if(o)vt(o)}}function yp(e){return m.activePaneId===e}function Ox(e){let t=e??Rr().activeTabId,n=t?m.tabs.get(t):null;if(!t||!n)return null;let o=Gu(t);if(!o)return null;let r=Pl(o.id);return _p(t),Ku(r,t),r.activeTabId=t,m.activePaneId=r.id,R(),Pe(t),r}function Mx(e){return m.panes.find((t)=>t.id!==e)??bn(vp)}function Pl(e){let t=Mx(e);if(t.derived)t.derived=null;return t}function bn(e){let t=Hn(e);if(t)return t;return m.panes=[...m.panes,{activeTabId:null,derived:null,id:e,tabOrder:[]}],Hn(e)}function wp(e){if(m.panes.length<2)return;let t=e===Qn?m.panes.find((r)=>r.id!==Qn)?.id:e,n=t===void 0?void 0:Hn(t),o=m.panes.find((r)=>r.id!==t);if(!n||!o)return;for(let r of n.tabOrder)Ku(o,r);if(o.activeTabId=m.activePaneId===n.id?n.activeTabId??o.activeTabId:o.activeTabId??n.activeTabId,m.activePaneId=o.id,o.derived?.sourcePaneId===n.id)o.derived=null;m.panes=m.panes.filter((r)=>r.id!==n.id),R()}function xp(e){return e.tabOrder.length===0&&e.derived===null}function _p(e){let t=[];for(let n of m.panes){if(!n.tabOrder.includes(e))continue;if(n.tabOrder=n.tabOrder.filter((o)=>o!==e),n.activeTabId===e)n.activeTabId=n.tabOrder.at(-1)??null;if(n.id!==Qn&&xp(n))t.push(n.id)}for(let n of t)wp(n)}function Ku(e,t,n){if(e.tabOrder.includes(t))return;let o=n??hn(e,t);e.tabOrder=[...e.tabOrder.slice(0,o),t,...e.tabOrder.slice(o)]}function yn(e){let t=0;for(let n of e.tabOrder){if(m.tabs.get(n)?.pinned!==!0)break;t+=1}return t}function hn(e,t){return m.tabs.get(t)?.pinned===!0?yn(e):e.tabOrder.length}function Ua(e,t=null){if(m.projectRoot&&e!==m.projectRoot)Lx();m.projectRoot=e,m.projectConfig=t}function Cp(e){let t=u.value;return e!==null&&t!==null&&re(t)===re(e)}function Sc(e){if(!e)return!1;let t=m.tabs.get(e.id);return t!==void 0&&re(t)===re(e)}function Pe(e){m.mruOrder=[e,...m.mruOrder.filter((t)=>t!==e)]}var ne=null,Z=0;function R(){ne=null,Z=0}function vt(e){if(D&&e.documentPath)D.selectedPath=e.documentPath}function X(e,t={}){let n=m.tabs.get(e),o=Gu(e);if(!n||!o)return;if(o.activeTabId=e,t.focus===!1)return;if(m.activePaneId=o.id,!t.cycling)R(),Pe(e);vt(n)}function No(e){let t=m.tabs.get(e.id),n=e.preview===!0&&t?.pinned!==!0,o=cv({...e,preview:n}),r=(e.paneId===void 0?void 0:Hn(e.paneId))??Rr(),i;if(t)o.pinned=t.pinned,fp(t);else{if(n){let a=yt(r),l=a?m.tabs.get(a):null;if(l)kp(l);Px()}let s=n?yt(r):null;if(s)i=r.tabOrder.indexOf(s),Fx(s);Ku(r,o.id,i)}return m.tabs.set(o.id,o),X(o.id,{focus:e.focus!==!1}),Y(o),o}function yt(e){return e.tabOrder.find((t)=>m.tabs.get(t)?.preview===!0)??null}function Fl(e){let t=m.tabs.get(e);if(t?.preview===!0)t.preview=!1}function Px(){for(let[e,t]of m.tabs)if(t.preview&&t.doc.dirty)Fl(e)}function kv(e,t){let n=m.tabs.get(e),o=Gu(e);if(!n||!o)return;if(n.pinned=t,t)n.preview=!1;let r=o.tabOrder.filter((s)=>s!==e),i=r.filter((s)=>m.tabs.get(s)?.pinned===!0).length;o.tabOrder=[...r.slice(0,i),e,...r.slice(i)]}function XC(e,t){let n=m.tabs.get(e),o=Gu(e);if(!n||!o)return;o.tabOrder=Tt(o,e,t)}function Tt(e,t,n){let o=m.tabs.get(t);if(!o)return e.tabOrder;let r=e.tabOrder.filter((c)=>c!==t),i=r.filter((c)=>m.tabs.get(c)?.pinned===!0).length,s=o.pinned?0:i,a=o.pinned?i:r.length,l=Math.min(Math.max(n,s),a);return[...r.slice(0,l),t,...r.slice(l)]}function Fx(e){let t=m.tabs.get(e);if(!t)return;let n=Gu(e),o=n?.activeTabId===e;if(vn(t),fp(t),m.tabs.delete(e),_p(e),m.mruOrder=m.mruOrder.filter((s)=>s!==e),R(),n&&xp(n))wp(n.id);if(!o)return;let r=Rr(),i=m.mruOrder.find((s)=>r.tabOrder.includes(s))??r.tabOrder.at(-1)??null;if(i)X(i)}function QC(){let e=[...m.tabs.values()];m.tabs.clear(),Pt(),m.mruOrder=[],R();for(let t of e)fp(t)}function Pt(){m.panes=[{activeTabId:null,derived:null,id:Qn,tabOrder:[]}],m.activePaneId=Qn}function vn(e){if(!e.documentPath)return;let t=e.documentPath;m.closedTabs=[{documentPath:t},...m.closedTabs.filter((n)=>n.documentPath!==t)].slice(0,gn)}function Tn(){let[e]=m.closedTabs;if(!e)return;return m.closedTabs=m.closedTabs.slice(1),e.documentPath}function xt(e){if(!ne)ne=m.mruOrder.filter((o)=>m.tabs.has(o)),Z=0;let t=ne;if(t.length<2)return;Z=((Z+e)%t.length+t.length)%t.length;let n=t[Z];return X(n,{cycling:!0}),n}function ek(e){let t=[...m.tabs.keys()],n=[...m.tabs.values()],o=cv(e);m.tabs.set(o.id,o),Pt(),m.panes[0].tabOrder=[o.id],m.mruOrder=[],R(),X(o.id),Y(o);for(let r of t){if(r===o.id)continue;m.tabs.delete(r)}for(let r of n)fp(r);return o}function ci(e,t={}){X(e,t)}function Cm(e,t,n){let o=Hn(t);if(!o||!m.tabs.has(e))return null;if(o.tabOrder.includes(e)){if(n!==void 0)o.tabOrder=Tt(o,e,n);return o}return _p(e),Ku(o,e,n),o}function Sv(e,t,n){let o=m.tabs.get(e);if(!o)return;o.id=t,o.documentPath=n,m.tabs.delete(e),m.tabs.set(t,o);for(let r of m.panes)if(r.tabOrder=r.tabOrder.map((i)=>i===e?t:i),r.activeTabId===e)r.activeTabId=t;m.mruOrder=m.mruOrder.map((r)=>r===e?t:r),R(),ct(o)}function tk(e,t){e.registerAll([...Pn(t),...On(t)])}function Pn(e){let t=()=>m.tabs.size>1;return[{id:"document.nextTab",title:"Next Tab",category:"Document",level:"document",keybinding:["ctrl+tab","mod+tab"],menus:["palette"],group:"2_navigate",when:(n)=>n.document.open,enablement:t,requires:"a second open document",run:()=>{xt(1)}},{id:"document.previousTab",title:"Previous Tab",category:"Document",level:"document",keybinding:["ctrl+shift+tab","mod+shift+tab"],menus:["palette"],group:"2_navigate",when:(n)=>n.document.open,enablement:t,requires:"a second open document",run:()=>{xt(-1)}},{args:Se({path:He('Project-relative path of the file to open, e.g. "pages/about.json" or "components/nav-bar.json". It must exist.')}),id:"document.open",title:"Open Document",category:"Document",level:"project",menus:["palette"],group:"1_file",when:(n)=>n.project.open,requires:"an open project",aiTool:{description:"Open a project file as the active document; the document tools then operate on it. Use it when the user should SEE the page, or for iterative visual refinement after creating a page or component.",name:"open_document",report:({after:n,args:o})=>{let r=ot("document.open",o,"path"),i=u.value?.documentPath??null;if(i!==r)return`Opened "${r}", but the active document is ${i===null?"none":`"${i}"`}.`;let s=n.editor.kind==="canvas"?"on the canvas; the document tools now operate on it":`in the ${ov[n.editor.kind]} editor, which is not an element tree the document tools can edit`;return`"${r}" is the active document, ${s}.`}},run:async(n,o)=>{let r=ot("document.open",o,"path");if(await e.openFile(r),![...m.tabs.values()].some((i)=>i.documentPath===r))throw RangeError(`command "document.open" argument "path": "${r}" could not be opened — it does `+"not exist, or no editor claims its format. Problems has the reason.")}},{args:Se({file:He('Project-relative path of the file to open in the other pane, e.g. "pages/about.json". It must exist.')}),id:"document.openToSide",title:"Open to the Side",category:"Document",level:"project",menus:["context/file","palette"],group:"1_file",when:(n)=>n.project.open,requires:"an open project",undo:"none",run:async(n,o)=>{let r=ot("document.openToSide",o,"file"),i=Pl(Rr().id);if(await e.openFile(r,{paneId:i.id}),![...m.tabs.values()].some((s)=>s.documentPath===r)){if(xp(i)&&i.id!==Qn)wp(i.id);throw RangeError(`command "document.openToSide" argument "file": "${r}" could not be opened — it `+"does not exist, or no editor claims its format. Problems has the reason.")}}},{id:"document.reopenClosed",title:"Reopen Closed Document",category:"Document",level:"document",keybinding:"mod+shift+t",menus:["context/tab","palette"],group:"1_file",enablement:()=>m.closedTabs.length>0,requires:"a document closed in this session",run:async()=>{let n=Tn();if(n)await e.openFile(n)}},{id:"document.togglePinned",title:"Pin / Unpin Document",category:"Document",level:"document",menus:["context/tab","palette"],group:"1_file",when:(n)=>n.document.open,requires:"an open document",run:()=>{let n=m.activeTabId,o=n?m.tabs.get(n):null;if(n&&o)kv(n,!o.pinned)}},{args:Se({pinned:oo("True to pin the active document's tab, false to unpin it.")}),id:"document.setPinned",title:"Set Document Pinned",category:"Document",level:"document",menus:["palette"],group:"1_file",when:(n)=>n.document.open,requires:"an open document",run:(n,o)=>{let r=m.activeTabId;if(r&&m.tabs.get(r))kv(r,yi("document.setPinned",o,"pinned"))}},{id:"document.keepOpen",title:"Keep Document Open",category:"Document",level:"document",menus:["context/tab","palette"],group:"1_file",when:(n)=>n.document.open,enablement:()=>{let n=m.activeTabId;return n!==null&&m.tabs.get(n)?.preview===!0},requires:"a preview document — one opened by a single click",run:()=>{let n=m.activeTabId;if(n)Fl(n)}}]}function On(e){let t=()=>m.panes.length>1;return[{id:"pane.splitRight",title:"Split Right",category:"View",level:"document",keybinding:"mod+\\",menus:["context/pane","context/tab","palette"],group:"5_pane",when:(n)=>n.document.open,enablement:()=>m.activeTabId!==null,requires:"an open document",undo:"none",run:()=>{Ox()}},{args:Se({path:He("Project-relative path of the document to open beside this one.")}),id:"pane.compareWith",title:"Compare With…",category:"View",level:"document",menus:["context/pane","context/tab","palette"],group:"5_pane",when:(n)=>n.document.open,enablement:()=>m.activeTabId!==null,requires:"an open document",undo:"none",run:async(n,o)=>{let r=ot("pane.compareWith",o,"path"),i=Rr();if((i.activeTabId?m.tabs.get(i.activeTabId):null)?.documentPath===r)throw RangeError(`command "pane.compareWith" argument "path": "${r}" is the document this pane is `+"already showing — name a different one");await e.openFileInPane(Pl(i.id).id,r)}},{id:"pane.focusPrimary",title:"Focus Primary Pane",category:"View",level:"document",keybinding:"mod+0",menus:["palette"],group:"5_pane",enablement:t,requires:"a split pane grid",undo:"none",run:()=>{$r(Qn)}},{id:"pane.focusSecondary",title:"Focus Side Pane",category:"View",level:"document",keybinding:"mod+alt+0",menus:["palette"],group:"5_pane",enablement:t,requires:"a split pane grid",undo:"none",run:()=>{$r(vp)}},{id:"pane.unsplit",title:"Close Side Pane",category:"View",level:"document",menus:["context/pane","palette"],group:"5_pane",enablement:t,requires:"a second pane",undo:"none",run:wn}]}function wn(){let e=m.panes.find((t)=>t.derived!==null);if(e?.id===Qn){if(e.derived=null,!xp(e))return}wp(e?.id??vp)}
2
+ export{Sx,Go,iv,gL,dn,$o,zu,bL,BC,Wu,ov,ha,vL,rv,$d,sv,bm,Ex,yL,vm,zi,Ki,av,Dd,lv,wL,zC,xL,_L,CL,Tx,kL,Lx,SL,ai,cv,WC,EL,TL,fp,Le,LL,dv,ms,uv,IL,Nl,hv,RL,mp,$L,vi,q,Hs,pv,fv,Ix,DL,ym,AL,NL,Rx,OL,Ji,Vu,VC,gp,mv,ML,pa,Ue,kc,Ko,PL,gv,FL,bv,jL,HL,Bs,vv,mr,BL,Uu,zL,WL,VL,Ol,xn,wm,ot,Jo,yv,yi,li,$x,UL,UC,Se,Do,fa,qC,oo,wv,qL,He,GL,Dx,bp,Ax,Ml,xv,_v,Nx,KL,ma,Ad,qu,xm,Cv,JL,Ao,YL,ZL,XL,QL,_m,GC,KC,JC,YC,Qn,vp,ZC,m,u,Rr,Hn,Gu,$r,yp,Ox,Mx,Pl,wp,xp,_p,Ku,Ua,Cp,Sc,No,Fl,Px,kv,XC,Fx,QC,ek,ci,Cm,Sv,tk};
3
+
4
+ //# debugId=D2F6E6849DBDB77464756E2164756E21
5
+ //# sourceMappingURL=studio-cvbkkfqb.js.map
@@ -0,0 +1,7 @@
1
+ import{p}from"./studio-y7jehjrp.js";import{lp}from"./studio-222rqyyc.js";import{ge,Q,v,Hm}from"./studio-fqq890ap.js";import{ne}from"./studio-0k9mvpgj.js";import{T,R}from"./studio-spf2skgc.js";import{Bi,y}from"./studio-zpnk016a.js";import{D}from"./studio-tp642n5g.js";function k({slug:e,adapter:t}){let o=new Date().toISOString().slice(0,10);return`${JSON.stringify(t==="cloudflare-workers"?{assets:{binding:"ASSETS",directory:"./dist"},compatibility_date:o,compatibility_flags:["nodejs_compat"],main:"./dist/worker.js",name:e}:{compatibility_date:o,compatibility_flags:["nodejs_compat"],name:e,pages_build_output_dir:"./dist"},null,"\t")}
2
+ `}function m(e,{slug:t,adapter:o}){if(!e)return{content:k({adapter:o,slug:t}),patched:!0};let n;try{n=JSON.parse(e)}catch{return{content:e,patched:!1}}if(n.name=t,o==="cloudflare-workers")delete n.pages_build_output_dir,n.main="./dist/worker.js",n.assets={binding:"ASSETS",directory:"./dist"};else delete n.main,delete n.assets,n.pages_build_output_dir="./dist";return{content:`${JSON.stringify(n,null,"\t")}
3
+ `,patched:!0}}function gd(){try{return typeof p().cfApi==="function"}catch{return!1}}async function l(e,t){let o=p().cfApi;if(!o)throw Error("This platform cannot reach the Cloudflare API");try{return await o(e,t)}catch(n){throw lp(n),n}}async function YE(){return l("/accounts")}async function j(e,t){try{return await l(`/accounts/${e}/pages/projects/${t}`)}catch{return null}}async function C(e){return l(`/accounts/${e.accountId}/pages/projects`,{method:"POST",body:{name:e.projectName,production_branch:e.productionBranch,build_config:{build_command:"bunx jx build",destination_dir:"dist"},source:{type:"github",config:{owner:e.owner,repo_name:e.repo,production_branch:e.productionBranch,deployments_enabled:!0}}}})}async function Zf(e){let t=await l(`/accounts/${e.accountId}/pages/projects/${e.projectName}/deployments`),[o]=t;if(!o)return null;return{id:o.id,url:o.url,environment:o.environment,stage:o.latest_stage?.name??"unknown",status:o.latest_stage?.status??"unknown",createdOn:o.created_on}}async function P1(e,t){let o={...e.build};if(t===null)delete o.deploy;else o.deploy=t;if(await Bi({build:o}),t!==null){let n=p(),i=null;try{i=await n.readFile("wrangler.jsonc")}catch{i=null}let w=o.adapter==="cloudflare-workers"?"cloudflare-workers":"cloudflare-pages",{content:x,patched:S}=m(i,{adapter:w,slug:t.projectName});if(S)await n.writeFile("wrangler.jsonc",x)}}async function ZE(e,t){let n=await j(t.accountId,t.projectName)??await C(t),i={provider:"cloudflare-pages",accountId:t.accountId,projectName:t.projectName,...n.subdomain?{productionUrl:`https://${n.subdomain}`}:{}};return await P1(e,i),i}var h={$schema:"https://jxsuite.com/schema/v1",$id:"StudioPanelDeployChecklist",$description:"The deploy checklist, drawn above the Activity feed in the Bottom dock's Activity tab: what is MISSING before this project can ship, as one row with the chain of prerequisites under it. `publish/deploy-checklist.ts` owns the chain — which link is forged, which is merely unasked, and which command forges the next one — and hands this document a row, four steps and at most one action. Nothing here reads source control, the project config or the command registry. It draws in the Activity tab's own vocabulary because a deploy is an ordered list of stages that finish, which is exactly what a row of that feed already is; a fifth visual idiom for it would be a second design of a thing the tab has.",tagName:"div",attributes:{part:"checklist"},style:{$description:"What `.activity-list`, `.activity-row`, `.activity-row--running`, `.activity-row--done`, `.activity-icon`, `.activity-body`, `.activity-head`, `.activity-title`, `.activity-source`, `.activity-status`, `.activity-steps`, `.activity-step`, `.activity-step--done` and `.activity-step-icon` said in `styles/panels.css`, keyed on `part`. This is the LAST reader of those rules — `surfaces/panel-activity.json` carried its own copy when the feed converted, and left the stylesheet standing because this file still drew from it — so the whole `.problem-*, .activity-*` block is dead once this lands. Three token names could not travel: `--spectrum-font-size-50`, `--spectrum-font-size-75` and `--spectrum-corner-radius-75` resolve only inside `<sp-theme>`, and a document mounted into the dock body is outside it, so each would silently have taken its hard-coded px fallback. They are the kit's own scale here. One thing changed meaning on purpose: the step's `data-state` is the checklist's own three-valued state rather than the two CSS classes it used to collapse into, so `unknown` — \"nobody has asked\" — is a state the styling can tell apart from `todo` the day it should.",display:"block",minWidth:"0",fontFamily:"var(--jx-font-sans)",color:"var(--fg)",'& [part="list"]':{display:"flex",flexDirection:"column",gap:"var(--jx-space-1)",margin:"0",padding:"0",listStyle:"none"},'& [part="row"]':{$description:"The left border is the state, at 3px, which is the one thing that must be legible without reading the row. Its default is the dim foreground so a state nobody has a colour for still draws a border rather than a gap.",display:"flex",alignItems:"flex-start",gap:"var(--jx-space-2)",padding:"6px var(--jx-space-2)",border:"1px solid var(--border)",borderLeft:"3px solid var(--fg-dim)",borderRadius:"var(--radius)",background:"var(--bg-panel)",color:"var(--fg)",fontSize:"var(--jx-text-md)"},'& [part="row"][data-state="running"]':{borderLeftColor:"var(--accent)"},'& [part="row"][data-state="done"]':{borderLeftColor:"var(--success)"},'& [part="state-icon"]':{$description:'Named `state-icon` rather than `icon`: `jx-button` puts `part="icon"` on the glyph slot of every button it draws, and the action button below is inside this same light-DOM tree — a rule on the bare name would reach into the kit\'s own drawing and a devtools query could not tell the two apart.',flex:"none",width:"14px",textAlign:"center",fontWeight:"700",lineHeight:"1.5"},'& [part="row"][data-state="running"] > [part="state-icon"]':{color:"var(--accent)"},'& [part="row"][data-state="done"] > [part="state-icon"]':{color:"var(--success)"},'& [part="row-body"]':{flex:"1",minWidth:"0",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"2px"},'& [part="head"]':{display:"flex",alignItems:"baseline",gap:"var(--jx-space-2)",alignSelf:"stretch",minWidth:"0"},'& [part="row-title"]':{fontWeight:"700",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},'& [part="source"]':{$description:"Pushed to the far edge, so the tab reads as a column of who raised what.",flex:"none",marginLeft:"auto",color:"var(--fg-dim)",fontSize:"var(--jx-text-sm)"},'& [part="summary"]':{color:"var(--fg-dim)",overflowWrap:"anywhere"},'& [part="steps"]':{$description:'The chain, declared up front, so "which link is missing" is answered by looking rather than by reading the summary and remembering what came before it.',display:"flex",flexDirection:"column",gap:"1px",margin:"2px 0 0",padding:"0",listStyle:"none",fontSize:"var(--jx-text-sm)"},'& [part="step"]':{display:"flex",gap:"6px",color:"var(--fg-dim)"},'& [part="step"][data-state="done"] > [part="step-icon"]':{color:"var(--success)"},'& [part="step-icon"]':{flex:"none",width:"10px",textAlign:"center"},'& [part="action"]':{marginTop:"var(--jx-space-1)"}},children:[{tagName:"div",attributes:{part:"body-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/hasProject"},cases:{true:{tagName:"ul",attributes:{part:"list"},children:[{tagName:"li",attributes:{part:"row","data-state":"${state.rowState}"},children:[{tagName:"span",attributes:{part:"state-icon","aria-hidden":"true"},textContent:"${state.rowIcon}"},{tagName:"div",attributes:{part:"row-body"},children:[{tagName:"div",attributes:{part:"head"},children:[{tagName:"span",attributes:{part:"row-title"},textContent:"Deploy checklist"},{tagName:"span",attributes:{part:"source"},textContent:"Publish"}]},{tagName:"div",attributes:{part:"summary"},textContent:"${state.summary}"},{tagName:"ol",attributes:{part:"steps"},children:[{$prototype:"Array",items:{$ref:"#/state/steps"},key:{$ref:"$map/item/id"},map:{tagName:"li",attributes:{part:"step","data-step":"${$map.item.id}","data-state":"${$map.item.state}"},children:[{tagName:"span",attributes:{part:"step-icon","aria-hidden":"true"},textContent:"${$map.item.icon}"},{tagName:"span",attributes:{part:"step-text"},textContent:"${$map.item.text}"}]}}]},{tagName:"span",attributes:{part:"action-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/hasAction"},cases:{true:{tagName:"jx-button",$description:"The recovery button wears the command's own title, so it reads as a verb rather than as a decoration, and a refused command is dimmed with the reason it names in its tooltip. A command the registry does not have, or whose `when` is false, draws NOTHING rather than a dead label — a surface may choose whether to show a command, never whether it exists (§13).",$props:{size:"sm",disabled:{$ref:"#/state/actionDisabled"}},attributes:{part:"action",title:"${state.actionTitle}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/runAction"},value:[]}]},children:[{tagName:"span",textContent:"${state.actionLabel}"}]}}}]}]}]}}}]};T("panel-deploy-checklist",h);var d=null,c=null,a=null,r=null;function A(e,t){e.hasProject=t.hasProject,e.rowState=t.rowState,e.rowIcon=t.rowIcon,e.summary=t.summary,e.steps=t.steps,e.hasAction=t.hasAction,e.actionLabel=t.actionLabel,e.actionTitle=t.actionTitle,e.actionDisabled=t.actionDisabled}function N(e){if(d!==e)return!1;return r===null?a!==null:r.root.parentNode===e}function f(e,t){if(N(e))return;u(),d=e;let o=v({actionDisabled:!1,actionLabel:"",actionTitle:"",hasAction:!1,hasProject:!1,rowIcon:"",rowState:"running",runAction:t.runAction,steps:[],summary:""});c=ge(),c.run(()=>{Q(()=>{A(o,t.project())})});let n=R("panel-deploy-checklist",o,e);a=n,n.then((i)=>{if(a===n)r=i;else i.dispose()})}function u(){c?.stop(),c=null;let e=a;if(a=null,r)r.dispose(),r=null;else if(e)e.then((t)=>t.dispose());d=null}function I(){return D?.projectConfig??null}function ca(){return I()?.build?.deploy}var s=Hm({asked:!1,observed:null});function rp(e){s.observed=e,s.asked=!0}function _(){let{status:e}=y.git;if(e===null)return{command:"git.init",detail:"Source control has not reported on this project yet.",id:"repo",label:"Track this project with git",state:"unknown"};return e.isRepo?{command:"git.init",detail:`Tracked${e.branch?` — on branch ${e.branch}`:""}.`,id:"repo",label:"Track this project with git",state:"done"}:{command:"git.init",detail:"A deploy ships what the repository holds, so the repository comes first.",id:"repo",label:"Track this project with git",state:"todo"}}function L(){let{status:e}=y.git;if(e===null||!e.isRepo)return{command:"git.createGithubRepository",detail:"A remote is where the provider builds from.",id:"remote",label:"Push to a remote",state:e===null?"unknown":"todo"};if((e.remotes??[]).length===0)return{command:"git.createGithubRepository",detail:"This repository is local only — nothing outside this machine can build it.",id:"remote",label:"Push to a remote",state:"todo"};return e.ahead>0?{command:"git.push",detail:`${e.ahead} commit(s) are not on ${e.remotes[0]} yet, so a build would ship the older tree.`,id:"remote",label:"Push to a remote",state:"todo"}:{command:"git.push",detail:`Up to date with ${e.remotes[0]}.`,id:"remote",label:"Push to a remote",state:"done"}}function O(){let e=ca();if(e)return{command:"publish.setUp",detail:`Cloudflare Pages project ${e.projectName}.`,id:"provider",label:"Connect a deploy provider",state:"done"};return gd()?{command:"publish.setUp",detail:"Connecting one makes every commit build and publish on its own.",id:"provider",label:"Connect a deploy provider",state:"todo"}:{command:"publish.setUp",detail:"This platform cannot reach the Cloudflare API. Commit and push instead — your host "+"runs bunx jx build and serves dist/.",id:"provider",label:"Connect a deploy provider",state:"unknown"}}function E(){if(!ca())return{command:"publish.deploy",detail:"Nothing has been deployed, because no provider is connected.",id:"deployed",label:"Deploy",state:"todo"};if(!s.asked)return{command:"publish.deploy",detail:"Cloudflare has not been asked yet, so this is not a claim that nothing shipped.",id:"deployed",label:"Deploy",state:"unknown"};if(s.observed===null)return{command:"publish.deploy",detail:"Cloudflare reports no deployments for this project.",id:"deployed",label:"Deploy",state:"todo"};let{observed:e}=s;return e.status==="success"?{command:"publish.deploy",detail:`${e.environment} — ${e.url}`,id:"deployed",label:"Deploy",state:"done"}:{command:"publish.deploy",detail:`Last deployment ${e.stage}: ${e.status}.`,id:"deployed",label:"Deploy",state:"todo"}}function g(){return[_(),L(),O(),E()]}function b(){return g().find((e)=>e.state!=="done")??null}function XE(){if(!D)return null;let e=b();if(e)return{command:e.command,label:e.label,title:e.detail};return{command:"publish.openDashboard",label:"Deployed",title:ca()?.productionUrl??"Everything this project needs to ship is in place."}}var W={done:"✓",todo:"·",unknown:"?"};function V(e){return{icon:W[e.state],id:e.id,state:e.state,text:e.state==="done"?e.label:`${e.label} — ${e.detail}`}}function H(e){let t={actionDisabled:!1,actionLabel:"",actionTitle:"",hasAction:!1};if(!e)return t;let o=ne(),n=o?.get(e.command);if(!o||!n||!o.isVisible(e.command))return t;let i=o.disabledReason(e.command);return{actionDisabled:i!==void 0,actionLabel:n.title,actionTitle:i?`${n.title} — requires ${i}`:n.title,hasAction:!0}}function J(){if(!D)return{actionDisabled:!1,actionLabel:"",actionTitle:"",hasAction:!1,hasProject:!1,rowIcon:"",rowState:"running",steps:[],summary:""};let e=g(),t=e.find((o)=>o.state!=="done")??null;return{...H(t),hasProject:!0,rowIcon:t?"⋯":"✓",rowState:t?"running":"done",steps:e.map((o)=>V(o)),summary:t?t.detail:"Everything this project needs to ship is in place."}}function B(){let e=b();if(!e)return;ne()?.run(e.command)}var F={project:J,runAction:B};function QE(e){let t=e.querySelector("[data-deploy-checklist]");if(!t){u();return}f(t,F)}
4
+ export{gd,YE,Zf,P1,ZE,ca,rp,XE,QE};
5
+
6
+ //# debugId=32A006FBA9B78D4764756E2164756E21
7
+ //# sourceMappingURL=studio-cxt150pj.js.map
@@ -0,0 +1,5 @@
1
+ import{p}from"./studio-y7jehjrp.js";import{rt,zt,T,R,Ct}from"./studio-spf2skgc.js";import{v}from"./studio-fqq890ap.js";import{Ir}from"./studio-888knnkc.js";import{Al,Ld,_c,Gi,Va,Id,Bu}from"./studio-c6w3tq7t.js";import{sb,bE,ab,yE,wE}from"./studio-xk0z6msk.js";import{Cc}from"./studio-a7xqhc3n.js";import{Tv,Ai}from"./studio-tp642n5g.js";import{Oe}from"./studio-vavmwshr.js";var E={$schema:"https://jxsuite.com/schema/v1",$id:"StudioMediaField",$description:"The media field: a thumbnail of what the value names, the value itself, and the two doors to a different one. It is a LEAF a caller interpolates — the Inspector's Content tab, the Signals panel and the grid's image-cell panel each draw an empty host and `ui/media-picker.ts` mounts this into it — so it has no chrome of its own and takes its width from whatever row it lands in. **Browse is addressed through its `part`, not through a class.** `ui/regions.ts` derives `inspector/field:<prop>/browse` by finding the Browse control inside the Inspector's own `[data-prop]` row; the handle used to be `.media-picker-browse`, and a document emits no class, so `[part=\"browse\"]` is the handle now. The four `.media-picker*` rules from `styles/overlays.css` are TRANSCRIBED here rather than shared, for the reason `doc-header.json` gives: a class a document does not emit cannot style it. `--radius` becomes `--jx-radius-sm` on the way, because a document mounted in a pane's stage is outside `<sp-theme>` and would otherwise take a fallback rather than follow the theme.",tagName:"div",attributes:{part:"media-field"},style:{$description:"The row's own layout and the four transcribed `.media-picker*` rules. Upload and Browse never shrink, so the FIELD is what yields width when the row is narrow — the buttons would otherwise collapse into unreadable stubs before the text did.",display:"flex",alignItems:"center",gap:"var(--jx-space-1)",flex:"1",minWidth:"0",fontFamily:"var(--jx-font-sans)",fontSize:"var(--jx-text-md)",color:"var(--fg)",'& [part="value"]':{flex:"1",minWidth:"0"},'& [part="upload"]':{flexShrink:"0"},'& [part="browse"]':{flexShrink:"0"},'& [part="thumb"]':{width:"24px",height:"24px",objectFit:"cover",borderRadius:"var(--jx-radius-sm)",border:"1px solid var(--border)",flexShrink:"0"}},children:[{tagName:"span",attributes:{part:"thumb-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/thumbState"},cases:{shown:{$description:"Decorative on purpose: the field beside it already states the path in text, so a caption here would be the same fact twice to a screen reader and nothing to anyone else.",tagName:"img",attributes:{part:"thumb",src:"${state.thumbSrc}",alt:""}}}},{tagName:"jx-textfield",attributes:{part:"value"},$props:{size:"sm",label:"${state.label}",placeholder:"/image.jpg",value:{$ref:"#/state/value"}},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/edit"},value:[{$ref:"event#/target/value"}]}],description:"Every keystroke, because the host debounces it: the canvas follows the typing without a document write per character."},onfocus:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/warm"},value:[]}],description:"Entering the field is the earliest honest signal that a pick is coming, so the project's media are listed then rather than when Browse is pressed."}},{tagName:"jx-action-button",attributes:{part:"upload"},$props:{size:"sm",quiet:!0,icon:"upload-simple",label:"Upload media",hint:"Upload media"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/upload"},value:[]}]}},{tagName:"jx-action-button",attributes:{part:"browse"},$props:{size:"sm",quiet:!0,icon:"image",label:"Browse media",hint:"Browse media"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/browse"},value:[{$ref:"event#/currentTarget"}]}],description:"The button hands over ITSELF: the browser is a popover and the platform wants its invoker, both so a second press on this control toggles rather than reopens and so focus comes back here when it closes."}}]};T("media-field",E);function O(t,e){t.label=e.label,t.value=e.value,t.thumbState=e.thumbState,t.thumbSrc=e.thumbSrc}function j(t,e,r){let i=v({browse:r.browse,edit:r.edit,label:e.label,thumbSrc:e.thumbSrc,thumbState:e.thumbState,upload:r.upload,value:e.value,warm:r.warm}),a=null,o=!1;return R("media-field",i,t).then((n)=>{if(o){n.dispose();return}a=n}),{dispose(){o=!0,a?.dispose(),a=null},update:(n)=>O(i,n)}}function ld(t){let{anchor:e,name:r,scope:i,slot:a}=t,o=document.createElement("div");o.style.pointerEvents="auto",o.setAttribute(rt,zt("popover",a)),Ct("popover").append(o);let n=new AbortController,s=null,w=null,c=!1,F=(m)=>{if(c)return;if(c=!0,n.abort(),w?.dispose(),w=null,o.remove(),m)t.onDismissed?.()},A=(async()=>{let m=await R(r,i,o,{signal:n.signal,...t.onNodeCreated?{onNodeCreated:t.onNodeCreated}:{}});if(n.signal.aborted)return;if(w=m,s=m.root,s.setAttribute(rt,zt("popover",a)),s.addEventListener("toggle",(b)=>{if(b.newState==="closed")F(!0)}),!s.hasAttribute("popover"))await new Promise((b)=>{s?.addEventListener("jx-ready",()=>b(),{once:!0})});if(n.signal.aborted)return;s.showPopover(e?{source:e}:void 0)})();return{close:()=>{if(c)return;if(s?.open)s.hidePopover();F(!1)},host:o,isOpen:()=>!c,ready:A}}var L={$schema:"https://jxsuite.com/schema/v1",$id:"StudioMediaBrowser",$description:'The project\'s media, offered under whatever control asked for them. **Not the kit menu, and the difference is the thumbnails.** `surfaces/menu.json` is the settled answer to "a list of actions" and a `MenuRowProjection` carries a title, a chord and a gate — there is nowhere in it for a picture, nowhere for the size caption beside it, and a `jx-menu` is itself `popover=auto`, so a filter field cannot stand above one inside a panel. This is a browser: you pick an image by looking at it. **It is a `jx-popover`, so the PLATFORM owns dismissal** — light dismiss, Escape, the top layer and focus back to the invoker are the popover\'s contract, which is why nothing here binds a document listener and why the panel can paint over a modal `<dialog>` that the layer-div popover it replaces could not. The rows are plain buttons in a group, exactly as `grid-views.json`\'s saved views are: a list of buttons is reachable by Tab, and a `role="listbox"` would be a keyboard contract nothing here implements.',tagName:"jx-popover",attributes:{part:"media-browser"},$props:{label:"Project media",x:{$ref:"#/state/x"},y:{$ref:"#/state/y"}},children:[{tagName:"div",attributes:{part:"body"},style:{$description:"A search box that stays put and a list that scrolls under it. The panel itself never scrolls — `jx-popover` says why — so the box is here rather than on the host.",display:"flex",flexDirection:"column",gap:"var(--jx-space-2)",padding:"var(--jx-space-2)",minWidth:"260px",maxHeight:"360px",fontFamily:"var(--jx-font-sans)",fontSize:"var(--jx-text-md)",color:"var(--fg)",'& [part="rows"]':{display:"flex",flexDirection:"column",gap:"2px",overflowY:"auto",minHeight:"0"},'& [part="row"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-2)",textAlign:"left",background:"none",border:"none",color:"var(--fg)",font:"inherit",padding:"var(--jx-space-1) var(--jx-space-2)",borderRadius:"var(--jx-radius-sm)",cursor:"pointer",minWidth:"0"},'& [part="row"]:hover':{background:"var(--bg-hover)"},'& [part="row"]:focus-visible':{outline:"var(--jx-focus-ring)",outlineOffset:"-2px"},'& [part="row-thumb"]':{width:"24px",height:"24px",objectFit:"cover",borderRadius:"var(--jx-radius-sm)",flexShrink:"0"},'& [part="row-text"]':{display:"flex",flexDirection:"column",minWidth:"0"},'& [part="row-name"]':{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},'& [part="row-caption"]':{color:"var(--fg-dim)",fontSize:"var(--jx-text-xs)"},'& [part="empty"]':{margin:"0",color:"var(--fg-dim)",fontSize:"var(--jx-text-xs)"},'& [part="more"]':{margin:"0",color:"var(--fg-dim)",fontSize:"var(--jx-text-xs)"}},children:[{tagName:"jx-textfield",attributes:{part:"filter"},$props:{type:"search",size:"sm",label:"Search media",placeholder:"Search media…",autocomplete:"off",value:{$ref:"#/state/filter"}},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setFilter"},value:[{$ref:"event#/target/value"}]}]}},{tagName:"div",attributes:{part:"rows-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/rowsState"},cases:{empty:{tagName:"p",attributes:{part:"empty"},textContent:"${state.emptyLabel}"},listed:{tagName:"div",attributes:{part:"rows"},children:[{$prototype:"Array",items:{$ref:"#/state/rows"},key:{$ref:"$map/item/key"},map:{$description:"One file. The row hands back the value a pick writes — the site URL — rather than an index, so the list may be filtered under it without changing what any row means.",tagName:"button",attributes:{part:"row",type:"button","data-path":"${$map.item.path}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/pick"},value:[{$ref:"$map/item/path"}]}]},children:[{tagName:"span",attributes:{part:"row-thumb-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/thumbState"},cases:{shown:{$description:"Decorative: the row's own text names the file. The load handler is the whole of the dimensions caption — measuring an image is a decode the `<img>` has finished by the time `load` fires, so the numbers are a read of work already done rather than a second fetch per row.",tagName:"img",attributes:{part:"row-thumb",src:"${$map.item.thumbSrc}",alt:""},onload:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/measure"},value:[{$ref:"$map/item/file"},{$ref:"event#/target/naturalWidth"},{$ref:"event#/target/naturalHeight"}]}]}}}},{tagName:"span",attributes:{part:"row-text"},children:[{tagName:"span",attributes:{part:"row-name"},textContent:"${$map.item.name}"},{tagName:"span",attributes:{part:"row-caption-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/captionState"},cases:{shown:{tagName:"span",attributes:{part:"row-caption"},textContent:"${$map.item.caption}"}}}]}]}}]}}},{tagName:"div",attributes:{part:"more-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/moreState"},cases:{shown:{$description:'A truncated list says so. Fifty rows is the cap the list has always had; the sentence is what keeps the cap from reading as "that is all there is".',tagName:"p",attributes:{part:"more"},textContent:"${state.moreLabel}"}}}]}]};T("media-browser",L);var D="media-picker";function V(t,e){t.x=e.x,t.y=e.y,t.filter=e.filter,t.rowsState=e.rowsState,t.rows=e.rows,t.emptyLabel=e.emptyLabel,t.moreState=e.moreState,t.moreLabel=e.moreLabel}function N(t,e,r){let i=v({emptyLabel:t.emptyLabel,filter:t.filter,measure:e.measure,moreLabel:t.moreLabel,moreState:t.moreState,pick:e.pick,rows:t.rows,rowsState:t.rowsState,setFilter:e.setFilter,x:t.x,y:t.y}),a=ld({anchor:r,name:"media-browser",scope:i,slot:D,...e.dismissed?{onDismissed:e.dismissed}:{}});return a.ready.then(()=>{if(a.isOpen())a.host.querySelector('[part="filter"] [part="input"]')?.focus()}),{close:a.close,host:a.host,isOpen:a.isOpen,ready:a.ready,update:(o)=>V(i,o)}}var h=[],S=!1;async function P(t,e){let r=[];try{let i=await Ir(()=>e.listDirectory(t));bE(i);for(let a of i)if(a.type==="directory"){let o=await P(a.path,e);r.push(...o)}else{let o=Gi(a.name);if(Ld.has(o))r.push({file:a.path,isImage:Al.has(o),name:a.name,path:Id(a.path)})}}catch{}return r}async function g(){if(S)return;let t=p();h=await P("public",t),S=!0,Ai("leftPanel","rightPanel","frontmatterPanel")}function Y_(){h=[],S=!1,yE()}var y=50,d=null,u=null,l="",M={x:0,y:0};function k(){let t=l.toLowerCase(),e=t?h.filter((a)=>a.path.toLowerCase().includes(t)||a.name.toLowerCase().includes(t)):h,i=e.slice(0,y).map((a)=>{let o=wE(sb(a.file));return{caption:o,captionState:o?"shown":"hidden",file:a.file,key:a.file,name:a.name,path:a.path,thumbSrc:a.isImage?Bu(a.file):"",thumbState:a.isImage?"shown":"hidden"}});return{emptyLabel:"No matches",filter:l,moreLabel:`…${e.length-y} more`,moreState:e.length>y?"shown":"hidden",rows:i,rowsState:i.length>0?"listed":"empty",x:M.x,y:M.y}}function B(){let t=d;d=null,u=null,l="",t?.close()}var x=0;function z(t,e,r){if(!ab(t,e,r)||x!==0)return;x=requestAnimationFrame(()=>{x=0,d?.update(k())})}function XR(t,e){B(),u=e;let r=Oe(t);M={x:r.left,y:r.bottom+4},d=N(k(),{dismissed:()=>{d=null,u=null,l=""},measure:z,pick:(i)=>{let a=u;B(),a?.(i)},setFilter:(i)=>{l=i,d?.update(k())}},t)}async function QR(t,e){let r=await Va([...t]),[i]=r;if(i)e(i.ref)}function e$(t){let e=document.createElement("input");e.type="file",e.multiple=!0,e.accept=_c(),e.addEventListener("change",()=>{if(e.files?.length)QR(e.files,t)}),e.click()}var _=400,f=new WeakMap;function H(t,e){let r=Al.has(Gi(e));return{label:t,thumbSrc:r&&e?Cc(e):"",thumbState:r&&e?"shown":"hidden",value:e}}function cd(t,e,r,i){g();let a=f.get(t);if(a){a.prop=e,a.commit=i,a.handle.update(H(e,r));return}let o={commit:i,handle:null,prop:e};o.handle=j(t,H(e,r),{browse:(n)=>{g(),XR(n,(s)=>o.commit(s))},edit:(n)=>Tv(`media:${o.prop}`,_,(s)=>o.commit(s))(n),upload:()=>e$((n)=>o.commit(n)),warm:()=>{g()}}),f.set(t,o)}function uw(t){let e=f.get(t);if(e)f.delete(t),e.handle.dispose()}
2
+ export{ld,Y_,XR,QR,e$,cd,uw};
3
+
4
+ //# debugId=E3994757D515F61664756E2164756E21
5
+ //# sourceMappingURL=studio-dkn3x3hz.js.map
@@ -0,0 +1,5 @@
1
+ import{qu}from"./studio-cvbkkfqb.js";import{gb}from"./studio-65fhspdd.js";import{D}from"./studio-tp642n5g.js";function c(){return Object.keys(D?.projectConfig?.content??{})}function Tw(e){let n=gb(e);if(!n)return null;if(/\.[a-z\d]+$/i.test(n.dir))return null;return{def:n.def,dir:n.dir,ext:n.ext,name:n.name,schema:n.def.schema??null}}function cb(){return c().map((e)=>Tw(e)).filter((e)=>e!==null)}function sa(e){let n=qu(e??null,D?.projectConfig);return n?Tw(n.name):null}function u(e){if(e===null||typeof e!=="object")return e;return JSON.parse(JSON.stringify(e))}function l(e){if(typeof e.$ref==="string")return"";switch(e.type){case"boolean":return!1;case"integer":case"number":return 0;case"array":return[];case"object":return y1(e);default:return""}}function y1(e){let n=e?.properties;if(!n)return{};let i=new Set(Array.isArray(e?.required)?e.required:[]),t={};for(let[r,o]of Object.entries(n))if(o.default!==void 0)t[r]=u(o.default);else if(i.has(r))t[r]=l(o);return t}function CE(e,n){return(Array.isArray(e?.required)?e.required:[]).filter((t)=>n[t]===void 0)}
2
+ export{Tw,cb,sa,y1,CE};
3
+
4
+ //# debugId=33EF567F57BD535C64756E2164756E21
5
+ //# sourceMappingURL=studio-e6re3rk1.js.map
@@ -1,5 +1,5 @@
1
- var n;function oI(e){n=new URL("./",e).href}function Lv(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{oI,Lv};
1
+ var n;function NI(e){n=new URL("./",e).href}function zv(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{NI,zv};
3
3
 
4
- //# debugId=3588BA3400E85CC964756E2164756E21
5
- //# sourceMappingURL=studio-5n1km79v.js.map
4
+ //# debugId=498A34F958330ADF64756E2164756E21
5
+ //# sourceMappingURL=studio-edbtvcd1.js.map