@jxsuite/studio 8.0.1 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/dist/chunks/{2020-5wtzce5g.js → 2020-dg097k3e.js} +3 -3
  2. package/dist/chunks/adapter-tck81zft.js +4 -0
  3. package/dist/chunks/{add-new-flow-psym14sn.js → add-new-flow-a1w0bnm6.js} +3 -3
  4. package/dist/chunks/{cf-account-picker-haqazq5r.js → cf-account-picker-ce3kp3x1.js} +3 -3
  5. package/dist/chunks/cf-settings-7ye6x7g2.js +4 -0
  6. package/dist/chunks/color-4gj49xq6.js +4 -0
  7. package/dist/chunks/{color-area-6rbra5dy.js → color-area-vh9cew51.js} +2 -2
  8. package/dist/chunks/{color-field-gy56c94g.js → color-field-e78f16bs.js} +3 -3
  9. package/dist/chunks/{color-slider-sqqdyf6c.js → color-slider-fg4yhvk6.js} +2 -2
  10. package/dist/chunks/{combobox-72h32ejk.js → combobox-6hs00996.js} +2 -2
  11. package/dist/chunks/components-qce0v93f.js +4 -0
  12. package/dist/chunks/content-source-jjx8kgzr.js +4 -0
  13. package/dist/chunks/{convert-to-repeater-he70fc2b.js → convert-to-repeater-grnmea6c.js} +3 -3
  14. package/dist/chunks/editor-bkja5dbv.js +4 -0
  15. package/dist/chunks/entry-commands-1wh0btvg.js +4 -0
  16. package/dist/chunks/{extension-sections-0egb88dm.js → extension-sections-rp7fkega.js} +3 -3
  17. package/dist/chunks/file-ops-6pe4z7an.js +4 -0
  18. package/dist/chunks/files-ybpp3j38.js +4 -0
  19. package/dist/chunks/format-host-3mtbhxk1.js +4 -0
  20. package/dist/chunks/fs-events-xfanfxds.js +4 -0
  21. package/dist/chunks/grid-open-dg5qmnaj.js +4 -0
  22. package/dist/chunks/{grid-view-qg1b5eqx.js → grid-view-x26rfpz1.js} +16 -15
  23. package/dist/chunks/{icons-63bjtbs7.js → icons-853n6qt3.js} +2 -2
  24. package/dist/chunks/{iframe-entry-2zggzajv.js → iframe-entry-02wzcyvy.js} +4 -4
  25. package/dist/chunks/{iframe-entry-99nr5zfb.js → iframe-entry-42hpmwz5.js} +4 -4
  26. package/dist/chunks/{iframe-entry-76j8vwwx.js → iframe-entry-b5qgggyp.js} +2 -2
  27. package/dist/chunks/iframe-host-j2bk2xkc.js +4 -0
  28. package/dist/chunks/{index-32eqzv1k.js → index-203h71wy.js} +3 -3
  29. package/dist/chunks/index-fkrm7pdk.js +4 -0
  30. package/dist/chunks/{javascript-pjp734q4.js → javascript-ww5pv5ae.js} +2 -2
  31. package/dist/chunks/{jsonMode-njkvsa02.js → jsonMode-vwbdwwq3.js} +6 -6
  32. package/dist/chunks/jx-validate-w7v32f6a.js +4 -0
  33. package/dist/chunks/layers-g7j732cm.js +4 -0
  34. package/dist/chunks/layers-panel-gjrsxcck.js +4 -0
  35. package/dist/chunks/{listbox-c421cf8c.js → listbox-7gka1h86.js} +2 -2
  36. package/dist/chunks/lit-html-jdfz9rhc.js +4 -0
  37. package/dist/chunks/media-library-9j0v4wmk.js +4 -0
  38. package/dist/chunks/media-picker-cpyyt2m0.js +4 -0
  39. package/dist/chunks/{menu-bdpzbfvs.js → menu-d2jxpgma.js} +2 -2
  40. package/dist/chunks/{monaco-binding-vq1hgnn0.js → monaco-binding-63tqze27.js} +3 -3
  41. package/dist/chunks/monaco-buffer-9wcme176.js +4 -0
  42. package/dist/chunks/{monaco-setup-xrd2cbkp.js → monaco-setup-zyyynnj8.js} +3 -3
  43. package/dist/chunks/notify-rahnnnv4.js +4 -0
  44. package/dist/chunks/platform-b2aqv7v5.js +4 -0
  45. package/dist/chunks/{popover-b89sfej7.js → popover-9tf4cjrk.js} +2 -2
  46. package/dist/chunks/publish-panel-4yk2461b.js +4 -0
  47. package/dist/chunks/{publish-quick-qx2455cj.js → publish-quick-ajzdhhs6.js} +3 -3
  48. package/dist/chunks/publish-workspace-mxestzcf.js +4 -0
  49. package/dist/chunks/quick-search-9g6z65b0.js +4 -0
  50. package/dist/chunks/references-c26enpxs.js +4 -0
  51. package/dist/chunks/right-panel-9d0e0yg7.js +4 -0
  52. package/dist/chunks/source-control-xyn3a8ds.js +4 -0
  53. package/dist/chunks/{split-c9zfdgxf.js → split-m5rwn31z.js} +2 -2
  54. package/dist/chunks/{studio-x9hsze61.js → studio-02phtmqn.js} +4 -4
  55. package/dist/chunks/{studio-4hp8pkyt.js → studio-0khd0xdw.js} +4 -4
  56. package/dist/chunks/studio-1fvzq9vs.js +5 -0
  57. package/dist/chunks/studio-1gdfsr49.js +12 -0
  58. package/dist/chunks/{studio-3q40e3rj.js → studio-1meqbxns.js} +4 -4
  59. package/dist/chunks/{studio-q0tccd43.js → studio-1yhz0s8p.js} +4 -4
  60. package/dist/chunks/studio-25a5by3h.js +5 -0
  61. package/dist/chunks/{studio-k3xxbagr.js → studio-2b8443ms.js} +3 -3
  62. package/dist/chunks/{studio-3qqjeep5.js → studio-2c2mjyzj.js} +5 -5
  63. package/dist/chunks/studio-2dtc90zs.js +10 -0
  64. package/dist/chunks/{studio-9tmebf0s.js → studio-332hesdk.js} +4 -4
  65. package/dist/chunks/{studio-03ct6yfv.js → studio-3pndhat0.js} +8 -8
  66. package/dist/chunks/{studio-s32578pn.js → studio-3q6n9qvq.js} +4 -4
  67. package/dist/chunks/studio-4dsdnan2.js +9 -0
  68. package/dist/chunks/{studio-ed1hp6zf.js → studio-4fjqdzrb.js} +5 -5
  69. package/dist/chunks/{studio-jcnsdaep.js → studio-533py3yy.js} +4 -4
  70. package/dist/chunks/studio-5abge3wy.js +5 -0
  71. package/dist/chunks/{studio-8tr6cfrc.js → studio-6vrxzkba.js} +4 -4
  72. package/dist/chunks/{studio-jaaz8ce9.js → studio-73wz63nn.js} +4 -4
  73. package/dist/chunks/{studio-bavb31r0.js → studio-74nzv280.js} +4 -4
  74. package/dist/chunks/{studio-q7rtx6zq.js → studio-7cg75gtj.js} +7 -7
  75. package/dist/chunks/studio-89cwmnae.js +5 -0
  76. package/dist/chunks/studio-8m1t83kn.js +7 -0
  77. package/dist/chunks/{studio-q0mvbaq6.js → studio-8nyw10dp.js} +4 -4
  78. package/dist/chunks/{studio-83mk4bgg.js → studio-94ppxeqy.js} +8 -8
  79. package/dist/chunks/{studio-qmn1xc24.js → studio-957jg8g3.js} +4 -4
  80. package/dist/chunks/{studio-r5qy30vx.js → studio-9wyqyfqy.js} +4 -4
  81. package/dist/chunks/studio-a3evp7f6.js +6 -0
  82. package/dist/chunks/{studio-n0c5h6mf.js → studio-a6x058ew.js} +4 -4
  83. package/dist/chunks/studio-ana67wax.js +5 -0
  84. package/dist/chunks/studio-b4xhpcwy.js +4 -0
  85. package/dist/chunks/studio-bf0rgyf7.js +5 -0
  86. package/dist/chunks/{studio-x1x167jh.js → studio-bqgs90r8.js} +4 -4
  87. package/dist/chunks/{studio-qwdqwkj0.js → studio-c4rcaftm.js} +4 -4
  88. package/dist/chunks/{studio-mn0476ag.js → studio-c5dj3dzk.js} +4 -4
  89. package/dist/chunks/studio-cgjt1zce.js +5 -0
  90. package/dist/chunks/{studio-bbe4c90a.js → studio-cpdzrdgp.js} +4 -4
  91. package/dist/chunks/studio-cq87hree.js +5 -0
  92. package/dist/chunks/studio-d140sy8e.js +5 -0
  93. package/dist/chunks/{studio-jsgf2q5k.js → studio-dmn7gpba.js} +5 -5
  94. package/dist/chunks/studio-e8pzjjhf.js +5 -0
  95. package/dist/chunks/{studio-dgk4dqtx.js → studio-f8kz3krj.js} +5 -5
  96. package/dist/chunks/{studio-qgh13jtz.js → studio-fqs1a22a.js} +4 -4
  97. package/dist/chunks/{studio-syreb644.js → studio-fw3jp9m7.js} +4 -4
  98. package/dist/chunks/{studio-ed3xx40h.js → studio-g6ysm05p.js} +6 -6
  99. package/dist/chunks/studio-gmhd0j3f.js +5 -0
  100. package/dist/chunks/{studio-p4nrkvqr.js → studio-gqpty626.js} +4 -4
  101. package/dist/chunks/{studio-kt3pjkwd.js → studio-grp684wx.js} +4 -4
  102. package/dist/chunks/{studio-df0baea9.js → studio-h98520qr.js} +4 -4
  103. package/dist/chunks/{studio-8m0y2qe7.js → studio-hnx1h1pr.js} +4 -4
  104. package/dist/chunks/studio-hvxt8z79.js +5 -0
  105. package/dist/chunks/{studio-43sd2mam.js → studio-hw60n5dh.js} +3 -3
  106. package/dist/chunks/{studio-wbcjbhy1.js → studio-hxq1ebp0.js} +6 -6
  107. package/dist/chunks/{studio-wys23mxz.js → studio-j4e627w1.js} +4 -4
  108. package/dist/chunks/{studio-ccv2svc6.js → studio-j5jqvyn3.js} +4 -4
  109. package/dist/chunks/{studio-881z1xrx.js → studio-jqrg9xxg.js} +4 -4
  110. package/dist/chunks/{studio-b7y5mr30.js → studio-kdseew9m.js} +4 -4
  111. package/dist/chunks/studio-kt2j51sa.js +5 -0
  112. package/dist/chunks/{studio-d5grtb9e.js → studio-m4w6sygj.js} +9 -9
  113. package/dist/chunks/{studio-zz9qe3rw.js → studio-mmqr9awv.js} +37 -37
  114. package/dist/chunks/{studio-5g0rprdt.js → studio-nm9qev4p.js} +5 -5
  115. package/dist/chunks/{studio-tft6r105.js → studio-nsv7g1qn.js} +4 -4
  116. package/dist/chunks/{studio-3e54qh39.js → studio-p89w12s2.js} +5 -5
  117. package/dist/chunks/{studio-y3ahhdpx.js → studio-pbagym4j.js} +4 -4
  118. package/dist/chunks/{studio-w4rz9hdk.js → studio-pr23qhrw.js} +4 -4
  119. package/dist/chunks/{studio-6m380wp7.js → studio-r4ya3sb2.js} +4 -4
  120. package/dist/chunks/studio-rdnezzkd.js +6 -0
  121. package/dist/chunks/{studio-f14e1zdj.js → studio-rm9m3z60.js} +4 -4
  122. package/dist/chunks/studio-tpmnbgmt.js +5 -0
  123. package/dist/chunks/studio-ttxhq5yt.js +5 -0
  124. package/dist/chunks/{studio-nh6d342n.js → studio-txkx6586.js} +6 -6
  125. package/dist/chunks/{studio-a2bvaptz.js → studio-v0gsjav0.js} +4 -4
  126. package/dist/chunks/{studio-fbhxxc5f.js → studio-v2ek69cb.js} +4 -4
  127. package/dist/chunks/{studio-y0n7yxea.js → studio-wcakp5bt.js} +7 -7
  128. package/dist/chunks/{studio-k7evxqh4.js → studio-x3ge4rts.js} +4 -4
  129. package/dist/chunks/{studio-pbxa5fpc.js → studio-xddgbwhe.js} +3 -3
  130. package/dist/chunks/{studio-c05wdnt3.js → studio-y1x65h5r.js} +4 -4
  131. package/dist/chunks/{studio-rthyg42z.js → studio-z42kysg7.js} +169 -169
  132. package/dist/chunks/studio-zf188hnd.js +5 -0
  133. package/dist/chunks/{studio-tfkznv39.js → studio-zht0x0v3.js} +4 -4
  134. package/dist/chunks/{studio-svb7yyve.js → studio-zm7dnr9g.js} +4 -4
  135. package/dist/chunks/{tooltip-yypz28gq.js → tooltip-dj1pvgz7.js} +2 -2
  136. package/dist/chunks/{tree-9xa4hm7n.js → tree-j0ebwr5s.js} +2 -2
  137. package/dist/chunks/{tsMode-epyfz1hv.js → tsMode-vra2hh7y.js} +5 -5
  138. package/dist/chunks/workspace-3nt93k48.js +4 -0
  139. package/dist/chunks/workspace-home-zbgyqqws.js +4 -0
  140. package/dist/chunks/{ws-client-bv552sfx.js → ws-client-72x5n99j.js} +3 -3
  141. package/dist/iframe-entry.js +14 -14
  142. package/dist/manifest.json +75 -75
  143. package/dist/studio.js +80 -80
  144. package/package.json +11 -11
  145. package/src/browse/component-examples.ts +15 -224
  146. package/src/browse/library-preview.ts +6 -13
  147. package/src/browse/preview-root.ts +7 -4
  148. package/src/canvas/canvas-utils.ts +18 -4
  149. package/src/canvas/iframe-editable-root.ts +13 -4
  150. package/src/canvas/iframe-entry.ts +3 -1
  151. package/src/canvas/iframe-interaction.ts +11 -2
  152. package/src/canvas/iframe-render.ts +25 -3
  153. package/src/canvas/preview-placeholder.ts +120 -0
  154. package/src/editor/shortcuts.ts +3 -0
  155. package/src/panels/component-preview.ts +5 -0
  156. package/src/panels/pane-context.ts +43 -18
  157. package/src/panels/site-model.ts +7 -19
  158. package/src/panels/site-panel.ts +2 -25
  159. package/src/panels/stylebook-doc.ts +2 -53
  160. package/src/services/references.ts +0 -0
  161. package/src/style/stylebook-specimens.ts +11 -15
  162. package/src/surfaces/pane-context.json +286 -265
  163. package/src/surfaces/pane-context.ts +17 -8
  164. package/src/tabs/tab.ts +5 -6
  165. package/src/utils/geometry.ts +49 -2
  166. package/dist/chunks/adapter-5tphg7xe.js +0 -4
  167. package/dist/chunks/cf-settings-h2wrh6hq.js +0 -4
  168. package/dist/chunks/color-m7r1vk54.js +0 -4
  169. package/dist/chunks/components-r22xca09.js +0 -4
  170. package/dist/chunks/content-source-mmppmcyg.js +0 -4
  171. package/dist/chunks/editor-ccd9jwsa.js +0 -4
  172. package/dist/chunks/entry-commands-6qxz9e8p.js +0 -4
  173. package/dist/chunks/file-ops-qnab36ek.js +0 -4
  174. package/dist/chunks/files-rcn56qvm.js +0 -4
  175. package/dist/chunks/format-host-yxz0kjjs.js +0 -4
  176. package/dist/chunks/fs-events-d1qxq4z4.js +0 -4
  177. package/dist/chunks/grid-open-4z1g062t.js +0 -4
  178. package/dist/chunks/iframe-host-ssv7kyj0.js +0 -4
  179. package/dist/chunks/index-f0jn7nnp.js +0 -4
  180. package/dist/chunks/jx-validate-ttasrbh7.js +0 -4
  181. package/dist/chunks/layers-bgyr11tr.js +0 -4
  182. package/dist/chunks/layers-panel-7ez66zeq.js +0 -4
  183. package/dist/chunks/lit-html-v9gh687x.js +0 -4
  184. package/dist/chunks/media-library-sq468wts.js +0 -4
  185. package/dist/chunks/media-picker-shfe59pt.js +0 -4
  186. package/dist/chunks/monaco-buffer-3afgwvbp.js +0 -4
  187. package/dist/chunks/notify-kzrjr3fv.js +0 -4
  188. package/dist/chunks/platform-7v4rtd7m.js +0 -4
  189. package/dist/chunks/publish-panel-2z9gw8ee.js +0 -4
  190. package/dist/chunks/publish-workspace-wrc1dgwx.js +0 -4
  191. package/dist/chunks/quick-search-n0t0eqxb.js +0 -4
  192. package/dist/chunks/references-9547rg5s.js +0 -4
  193. package/dist/chunks/right-panel-wsgnr9pn.js +0 -4
  194. package/dist/chunks/source-control-kwktr9y6.js +0 -4
  195. package/dist/chunks/studio-07rcfje3.js +0 -5
  196. package/dist/chunks/studio-3exxhz5g.js +0 -5
  197. package/dist/chunks/studio-3qeh9t0h.js +0 -6
  198. package/dist/chunks/studio-58xg6j2q.js +0 -9
  199. package/dist/chunks/studio-80jyh1xh.js +0 -4
  200. package/dist/chunks/studio-8vcvfs7r.js +0 -6
  201. package/dist/chunks/studio-fyh0jc96.js +0 -5
  202. package/dist/chunks/studio-gcxk20n7.js +0 -5
  203. package/dist/chunks/studio-m8g16bgz.js +0 -5
  204. package/dist/chunks/studio-mx1smyq0.js +0 -5
  205. package/dist/chunks/studio-pgmvdv7z.js +0 -7
  206. package/dist/chunks/studio-ph84avkf.js +0 -5
  207. package/dist/chunks/studio-rj9eamf8.js +0 -5
  208. package/dist/chunks/studio-rptgsk96.js +0 -5
  209. package/dist/chunks/studio-s19tp1xr.js +0 -5
  210. package/dist/chunks/studio-tf9jryb1.js +0 -10
  211. package/dist/chunks/studio-txf2kysx.js +0 -5
  212. package/dist/chunks/studio-v8867ddv.js +0 -12
  213. package/dist/chunks/studio-vxq7fcvv.js +0 -5
  214. package/dist/chunks/studio-wc649wss.js +0 -5
  215. package/dist/chunks/studio-z97c48fk.js +0 -5
  216. package/dist/chunks/studio-zat62m0c.js +0 -5
  217. package/dist/chunks/studio-zcd2e7yz.js +0 -5
  218. package/dist/chunks/workspace-dz7nxfhv.js +0 -4
  219. package/dist/chunks/workspace-home-xsd7hkjw.js +0 -4
@@ -1,5 +1,5 @@
1
- import{Q}from"./studio-nqxqf8p2.js";import{p}from"./studio-w4rz9hdk.js";import{g,C}from"./studio-43sd2mam.js";import{ph,Er,Yb}from"./studio-fyh0jc96.js";import{Pt,Nt}from"./studio-q7rtx6zq.js";import{qe,wi,ft,T,R,Jt,tt}from"./studio-x9hsze61.js";import{m,u,Zd}from"./studio-c05wdnt3.js";import{Ud}from"./studio-8m0y2qe7.js";import{ze}from"./studio-ph84avkf.js";import{qc,Sa,n$,hA,i$,Ca,fA,mA,Pb,rr}from"./studio-3exxhz5g.js";import{Ow,Ju}from"./studio-y0n7yxea.js";import{NT,Uu}from"./studio-n0c5h6mf.js";import{OT,MT,PT,FT,fb}from"./studio-x1x167jh.js";import{bp}from"./studio-8vcvfs7r.js";import{Ad,Od,qu,yp,Lw}from"./studio-9tmebf0s.js";import{n,S}from"./studio-vxq7fcvv.js";import{le}from"./studio-qgh13jtz.js";var E=[{key:"all",label:"All media"},{key:"image",label:"Images"},{key:"video",label:"Video"},{key:"audio",label:"Audio"},{key:"document",label:"Documents"},{key:"font",label:"Fonts"},{key:"unused",label:"Unused"}],uS=E.map((e)=>e.key);function ae(e){return uS.some((t)=>t===e)}function L(e){return E.find((t)=>t.key===e)?.label??"All media"}var z=[{key:"newest",label:"Newest"},{key:"name",label:"Name"},{key:"size",label:"Size"}],Ne=z.map((e)=>e.key);function re(e){return Ne.some((t)=>t===e)}function _(e,t,i){switch(t){case"all":return!0;case"unused":return i!==null&&i.has(e.file);default:return e.kind===t}}function U(e,t){let i=t.trim().toLowerCase();return i===""||e.name.toLowerCase().includes(i)}function W(e,t){return e.filter((a)=>_(a,t.filter,t.unused)&&U(a,t.query)).toSorted((a,r)=>je(t.sort,a,r)||a.file.localeCompare(r.file))}function je(e,t,i){switch(e){case"name":return t.name.localeCompare(i.name,void 0,{numeric:!0,sensitivity:"base"});case"size":return(i.bytes??-1)-(t.bytes??-1);default:return(i.modified??"").localeCompare(t.modified??"")}}function ne(e,t){let i={all:e.length,audio:0,document:0,font:0,image:0,unused:t===null?null:e.filter((a)=>t.has(a.file)).length,video:0};for(let a of e)i[a.kind]=(i[a.kind]??0)+1;return i}var He=132,ie=12;function oe(e){return Math.max(1,Math.floor((e+ie)/(He+ie)))}function se(e,t,i,a,r=!1){if(a===0)return null;let o=Math.min(Math.max(e,0),a-1),l=o-o%i,c;switch(t){case"ArrowRight":{c=o+1;break}case"ArrowLeft":{c=o-1;break}case"ArrowDown":{c=o+i;break}case"ArrowUp":{c=o-i;break}case"Home":{c=r?0:l;break}case"End":{c=r?a-1:Math.min(l+i-1,a-1);break}default:return null}return c<0||c>=a?o:c}var de={$schema:"https://jxsuite.com/schema/v1",$id:"StudioMediaLibrary",$description:"The Media workspace's library (`specs/studio.md` §22.6): the project's media as filters, a grid and the selected file's detail. ONE document in two modes. In `manage` it is the Media home tab, with Replace, Open in viewer and Delete under the detail; in `pick` it is the full-size picker inside a `jx-dialog` (`media-pick-dialog.json`), and the dialog's own footer answers Cancel or Use <file>. `media/media-library.ts` keeps every decision (which files a filter keeps, the sort, what a count may claim, where an arrow lands, what Replace writes) and hands this document strings and discriminants. **Unused is drawn with no number until the usage sweep has settled**, and Missing alt text and tags are not drawn at all: each needs a store that does not exist, and a filter that cannot be answered is not shipped as one that always answers nothing.",tagName:"div",attributes:{part:"media-library","data-jx-region":"${state.region}","data-mode":"${state.mode}","data-drop":"${state.dropActive}"},style:{$description:"Three columns over the whole stage: the filters, the grid with its toolbar, and the selected file's detail. Fills the pane's stage by its own geometry, as the workspace home does: the stage is `position: relative` (`pane-grid.json`). In pick mode the same columns fill the dialog's body instead, so the root's box is the only thing that differs between the two modes.",position:"absolute",inset:"0",display:"grid",gridTemplateColumns:"200px minmax(0, 1fr) 300px",boxSizing:"border-box",fontFamily:"var(--jx-font-sans)",fontSize:"var(--jx-text-md)",color:"var(--fg)",background:"var(--bg)",'&[data-mode="pick"]':{$description:"Inside a dialog there is no stage to fill: the box is the dialog body's, at a height the dialog can scroll within.",position:"relative",inset:"auto",height:"min(70vh, 620px)",gridTemplateColumns:"150px minmax(0, 1fr) 210px"},'&[data-drop="true"]':{$description:"The drop affordance is a STATE the flow holds, not a class a handler adds and forgets to take off.",outline:"2px dashed var(--accent)",outlineOffset:"-4px"},'& [part="filters"]':{display:"flex",flexDirection:"column",gap:"2px",padding:"var(--jx-space-3) var(--jx-space-2)",borderRight:"1px solid var(--border)",background:"var(--bg-panel)",overflowY:"auto"},'& [part="filters-heading"]':{margin:"0",padding:"var(--jx-space-2) var(--jx-space-2) var(--jx-space-1)",fontSize:"var(--jx-text-xs)",fontWeight:"600",letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--fg-dim)"},'& [part="filter"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-2)",height:"30px",padding:"0 var(--jx-space-2)",border:"none",borderRadius:"var(--radius)",background:"none",color:"var(--fg)",font:"inherit",textAlign:"left",cursor:"pointer"},'& [part="filter"]:hover':{background:"var(--hover-bg)"},'& [part="filter"][aria-pressed="true"]':{background:"color-mix(in srgb, var(--accent) 16%, transparent)",color:"var(--fg)",fontWeight:"600"},'& [part="filter"]:focus-visible':{outline:"var(--jx-focus-ring)",outlineOffset:"-2px"},'& [part="filter-count"]':{marginLeft:"auto",fontSize:"var(--jx-text-xs)",color:"var(--fg-dim)",fontWeight:"400"},'& [part="main"]':{display:"flex",flexDirection:"column",minWidth:"0",minHeight:"0"},'& [part="toolbar"]':{display:"flex",alignItems:"center",flexWrap:"wrap",gap:"var(--jx-space-3)",padding:"var(--jx-space-3) var(--jx-space-4)",borderBottom:"1px solid var(--border)"},'& [part="title"]':{margin:"0 auto 0 0",fontSize:"var(--jx-text-lg)",fontWeight:"600"},'& [part="search"]':{width:"220px"},'& [part="sort"]':{width:"130px"},'& [part="upload"], & [part="empty-upload"]':{$description:"A LABEL around the file picker, not a button that clicks a hidden one: the picker is the control, so it takes focus, Enter opens it and a screen reader announces a file upload. A plain element because a label forwards a click to the input it contains and a custom element between the two would break that.",position:"relative",display:"inline-flex",alignItems:"center",gap:"6px",height:"28px",padding:"0 var(--jx-space-3)",border:"1px solid var(--border)",borderRadius:"var(--radius)",background:"var(--bg-panel)",color:"var(--fg)",font:"inherit",cursor:"pointer",":hover":{background:"var(--hover-bg)"},":has(:focus-visible)":{outline:"var(--jx-focus-ring)",outlineOffset:"2px"}},'& [part="upload-input"], & [part="replace-input"]':{$description:"Out of the way but still FOCUSABLE: `display: none` would take the control out of the tab order, and the label around it draws the focus ring for it.",position:"absolute",width:"1px",height:"1px",opacity:"0",pointerEvents:"none"},'& [part="upload-glyph"]':{"--jx-icon-size":"16px"},'& [part="body"]':{flex:"1",minHeight:"0",overflowY:"auto",padding:"var(--jx-space-4)"},'& [part="grid"]':{$description:"auto-fill over a minimum tile width; `media/media-library-model.ts` `gridColumns` does the same arithmetic, so ArrowDown lands on the tile drawn under the current one. Keep the two numbers in step.",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(132px, 1fr))",gap:"12px",alignContent:"start"},'& [part="tile"]':{display:"flex",flexDirection:"column",gap:"4px",padding:"4px",borderRadius:"var(--jx-radius-md, 6px)",border:"2px solid transparent",cursor:"pointer",minWidth:"0",outline:"none"},'& [part="tile"]:hover':{background:"var(--hover-bg)"},'& [part="tile"][aria-selected="true"]':{borderColor:"var(--accent)"},'& [part="tile"]:focus-visible':{outline:"var(--jx-focus-ring)",outlineOffset:"2px"},'& [part="thumb"]':{display:"flex",alignItems:"center",justifyContent:"center",aspectRatio:"4 / 3",borderRadius:"var(--radius)",background:"var(--bg-input)",overflow:"hidden",color:"var(--fg-dim)","--jx-icon-size":"28px"},'& [part="thumb-img"]':{width:"100%",height:"100%",objectFit:"cover"},'& [part="tile-name"]':{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"var(--jx-text-sm)"},'& [part="tile-caption"]':{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"var(--jx-text-xs)",color:"var(--fg-dim)",minHeight:"1em"},'& [part="empty"]':{display:"flex",flexDirection:"column",alignItems:"center",gap:"var(--jx-space-3)",padding:"48px var(--jx-space-6)",textAlign:"center",color:"var(--fg-dim)","--jx-icon-size":"40px"},'& [part="empty-title"]':{margin:"0",fontSize:"var(--jx-text-lg)",fontWeight:"600",color:"var(--fg)"},'& [part="empty-detail"]':{margin:"0",maxWidth:"42ch",lineHeight:"1.5"},'& [part="detail"]':{display:"flex",flexDirection:"column",gap:"var(--jx-space-3)",padding:"var(--jx-space-4)",borderLeft:"1px solid var(--border)",background:"var(--bg-panel)",overflowY:"auto",minWidth:"0"},'& [part="detail-hint"]':{margin:"auto 0",textAlign:"center",color:"var(--fg-dim)"},'& [part="detail-preview"]':{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"140px",maxHeight:"220px",borderRadius:"var(--radius)",background:"var(--bg-input)",overflow:"hidden",color:"var(--fg-dim)","--jx-icon-size":"40px"},'& [part="preview-img"], & [part="preview-video"]':{maxWidth:"100%",maxHeight:"220px",objectFit:"contain"},'& [part="preview-audio"]':{width:"100%"},'& [part="preview-specimen"]':{$description:"The viewer's specimen at a side pane's size. The face arrives as the `@font-face` the flow writes under a family name generated from the path (`media/media-pane.ts` `specimenOf`); the element carries only that name, as a custom property, and the fallback stack is a rule, here.",display:"flex",flexDirection:"column",gap:"var(--jx-space-2)",padding:"var(--jx-space-4)",maxWidth:"100%",color:"var(--fg)",fontFamily:"var(--jx-specimen-family, system-ui), system-ui, sans-serif"},'& [part="specimen-line"]':{margin:"0",lineHeight:"1.3",overflowWrap:"anywhere"},'& [part="specimen-line"][data-size="32"]':{fontSize:"32px"},'& [part="specimen-line"][data-size="14"]':{fontSize:"var(--jx-text-md)"},'& [part="detail-name"]':{margin:"0",fontSize:"var(--jx-text-md)",fontWeight:"600",overflowWrap:"anywhere"},'& [part="facts"]':{margin:"0",color:"var(--fg-dim)",fontSize:"var(--jx-text-sm)"},'& [part="group-title"]':{margin:"0",fontSize:"var(--jx-text-xs)",fontWeight:"600",color:"var(--fg-dim)"},'& [part="url"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-2)",minWidth:"0"},'& [part="url-value"]':{flex:"1",minWidth:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"var(--jx-font-mono)",fontSize:"var(--jx-text-sm)"},'& [part="usage"]':{display:"flex",flexDirection:"column",gap:"var(--jx-space-1)"},'& [part="usage-headline"]':{margin:"0",fontSize:"var(--jx-text-sm)"},'& [part="usage-list"]':{margin:"0",padding:"0",listStyle:"none",display:"flex",flexDirection:"column",gap:"2px"},'& [part="usage-row"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-2)"},'& [part="usage-link"]':{flex:"1",minWidth:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",border:"none",background:"none",padding:"0",color:"var(--accent)",font:"inherit",fontSize:"var(--jx-text-sm)",textAlign:"left",cursor:"pointer",":hover":{textDecoration:"underline"},":focus-visible":{outline:"var(--jx-focus-ring)"}},'& [part="usage-count"]':{fontSize:"var(--jx-text-xs)",color:"var(--fg-dim)"},'& [part="actions"]':{display:"flex",flexWrap:"wrap",gap:"var(--jx-space-2)",marginTop:"var(--jx-space-2)"},'& [part="replace"]':{position:"relative",display:"inline-flex",alignItems:"center",height:"28px",padding:"0 var(--jx-space-3)",border:"1px solid var(--border)",borderRadius:"var(--radius)",background:"var(--bg)",color:"var(--fg)",font:"inherit",cursor:"pointer",":hover":{background:"var(--hover-bg)"},":has(:focus-visible)":{outline:"var(--jx-focus-ring)",outlineOffset:"2px"}}},ondragover:{$prototype:"Function",body:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/dragOver"},value:[]}],description:"A file dropped ANYWHERE on the library uploads, to the destination the Upload label names before the drop: public/media/."},ondragleave:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/dragOut"},value:[]}]},ondrop:{$prototype:"Function",body:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/drop"},value:[{$ref:"event#/dataTransfer/files"}]}]},children:[{tagName:"nav",attributes:{part:"filters","aria-label":"Media filters"},children:[{tagName:"h2",attributes:{part:"filters-heading"},textContent:"Library"},{$prototype:"Array",items:{$ref:"#/state/filters"},key:{$ref:"$map/item/key"},map:{tagName:"button",attributes:{part:"filter",type:"button","aria-pressed":"${$map.item.pressed}","data-filter":"${$map.item.key}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setFilter"},value:[{$ref:"$map/item/key"}]}]},children:[{tagName:"span",attributes:{part:"filter-label"},textContent:"${$map.item.label}"},{tagName:"span",attributes:{part:"filter-count"},textContent:"${$map.item.count}"}]}}]},{tagName:"section",attributes:{part:"main","aria-labelledby":"${state.titleId}"},children:[{tagName:"header",attributes:{part:"toolbar"},children:[{tagName:"h2",attributes:{part:"title",id:"${state.titleId}"},textContent:"${state.title}"},{tagName:"jx-textfield",attributes:{part:"search"},$props:{type:"search",size:"sm",label:"Search media",placeholder:"Search by name…",autocomplete:"off",value:{$ref:"#/state/query"}},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setQuery"},value:[{$ref:"event#/target/value"}]}]}},{tagName:"jx-select",attributes:{part:"sort"},$props:{label:"Sort",size:"sm",options:{$ref:"#/state/sortOptions"},value:{$ref:"#/state/sort"}},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setSort"},value:[{$ref:"event#/target/value"}]}]}},{tagName:"label",attributes:{part:"upload",title:"${state.uploadHint}"},children:[{tagName:"input",attributes:{part:"upload-input",type:"file",multiple:!0,accept:"${state.uploadAccept}"},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/upload"},value:[{$ref:"event#/target"}]}],description:"The picker itself, so the destination in the label's tooltip is visible BEFORE the files are chosen. The flow takes the element rather than the file list because a file input that is not cleared refuses the same file twice."}},{tagName:"jx-icon",attributes:{part:"upload-glyph","aria-hidden":"true"},$props:{name:"upload-simple"}},{tagName:"span",textContent:"Upload"}]}]},{tagName:"div",attributes:{part:"body"},children:[{tagName:"div",attributes:{part:"grid-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/gridState"},cases:{loading:{tagName:"p",attributes:{part:"empty",role:"status"},textContent:"Reading the project's media…"},counting:{tagName:"p",attributes:{part:"empty",role:"status"},textContent:"${state.countingLabel}"},empty:{tagName:"div",attributes:{part:"empty"},children:[{tagName:"jx-icon",attributes:{part:"empty-glyph","aria-hidden":"true"},$props:{name:"image"}},{tagName:"p",attributes:{part:"empty-title"},textContent:"${state.emptyTitle}"},{tagName:"p",attributes:{part:"empty-detail"},textContent:"${state.emptyDetail}"},{tagName:"label",attributes:{part:"empty-upload",title:"${state.uploadHint}"},children:[{tagName:"input",attributes:{part:"upload-input",type:"file",multiple:!0,accept:"${state.uploadAccept}"},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/upload"},value:[{$ref:"event#/target"}]}],description:"The picker itself, so the destination in the label's tooltip is visible BEFORE the files are chosen. The flow takes the element rather than the file list because a file input that is not cleared refuses the same file twice."}},{tagName:"jx-icon",attributes:{part:"upload-glyph","aria-hidden":"true"},$props:{name:"upload-simple"}},{tagName:"span",textContent:"Upload"}]}]},nomatch:{tagName:"div",attributes:{part:"empty"},children:[{tagName:"jx-icon",attributes:{part:"empty-glyph","aria-hidden":"true"},$props:{name:"image"}},{tagName:"p",attributes:{part:"empty-title"},textContent:"${state.emptyTitle}"},{tagName:"p",attributes:{part:"empty-detail"},textContent:"${state.emptyDetail}"},{tagName:"jx-button",attributes:{part:"reset"},$props:{size:"sm",variant:"secondary"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/reset"},value:[]}]},children:[{tagName:"span",textContent:"Show all media"}]}]},listed:{tagName:"div",attributes:{part:"grid",role:"listbox","aria-labelledby":"${state.titleId}"},onkeydown:{$prototype:"Function",body:[{$switch:{$ref:"event#/key"},cases:{ArrowRight:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/key"},value:[{$ref:"event#/key"},{$ref:"event#/ctrlKey"}]}],ArrowLeft:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/key"},value:[{$ref:"event#/key"},{$ref:"event#/ctrlKey"}]}],ArrowDown:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/key"},value:[{$ref:"event#/key"},{$ref:"event#/ctrlKey"}]}],ArrowUp:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/key"},value:[{$ref:"event#/key"},{$ref:"event#/ctrlKey"}]}],Home:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/key"},value:[{$ref:"event#/key"},{$ref:"event#/ctrlKey"}]}],End:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/key"},value:[{$ref:"event#/key"},{$ref:"event#/ctrlKey"}]}],Enter:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/activateSelected"},value:[]}]}}],description:"The grid pattern: arrows move one tile, Home and End to the ends of the row, Ctrl+Home and Ctrl+End to the ends of the grid, and Enter opens the selected file (in pick mode, uses it). The flow computes where the move lands; the tile that receives it takes focus, so the roving tabindex follows the selection."},children:[{$prototype:"Array",items:{$ref:"#/state/tiles"},key:{$ref:"$map/item/key"},map:{tagName:"div",attributes:{part:"tile",role:"option","aria-selected":"${$map.item.selected}",tabindex:"${$map.item.tabindex}","data-file":"${$map.item.file}",title:"${$map.item.name}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/select"},value:[{$ref:"$map/item/file"}]}]},onfocus:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/focusTile"},value:[{$ref:"$map/item/file"}]}],description:"Selection follows focus, the listbox pattern: a Tab onto the grid lands on the roving stop and selects it, so the first Enter opens (in pick mode, uses) the tile the focus ring is on rather than nothing."},ondblclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/activate"},value:[{$ref:"$map/item/file"}]}]},children:[{tagName:"div",attributes:{part:"thumb"},children:[{tagName:"div",attributes:{part:"thumb-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/thumbState"},cases:{image:{tagName:"img",attributes:{part:"thumb-img",src:"${$map.item.thumbSrc}",alt:"",draggable:"false"},onload:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/measure"},value:[{$ref:"$map/item/file"},{$ref:"event#/target/naturalWidth"},{$ref:"event#/target/naturalHeight"}]}]}},pending:{tagName:"span",attributes:{part:"thumb-pending","aria-hidden":"true"}},glyph:{tagName:"jx-icon",attributes:{part:"thumb-glyph","aria-hidden":"true"},$props:{name:{$ref:"$map/item/glyph"}}}},$description:"The thumbnail is asked for when the tile scrolls into view, not when the grid is built: `pending` until the flow's observer reports the tile, then the picture. A file the browser draws no picture of shows its kind's glyph."}]},{tagName:"span",attributes:{part:"tile-name"},textContent:"${$map.item.name}"},{tagName:"span",attributes:{part:"tile-caption"},textContent:"${$map.item.caption}"}]}}]}}}]}]},{tagName:"aside",attributes:{part:"detail","aria-label":"Details"},children:[{tagName:"div",attributes:{part:"detail-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/detailState"},cases:{none:{tagName:"p",attributes:{part:"detail-hint"},textContent:"${state.detailHint}"},shown:{tagName:"div",attributes:{part:"detail-body",role:"none"},style:{display:"contents"},children:[{tagName:"div",attributes:{part:"detail-preview"},children:[{tagName:"div",attributes:{part:"preview-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/previewKind"},cases:{image:{tagName:"img",attributes:{part:"preview-img",src:"${state.previewSrc}",alt:""},onload:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/measure"},value:[{$ref:"#/state/selectedFile"},{$ref:"event#/target/naturalWidth"},{$ref:"event#/target/naturalHeight"}]}]}},video:{tagName:"video",attributes:{part:"preview-video",src:"${state.previewSrc}",controls:!0}},audio:{tagName:"audio",attributes:{part:"preview-audio",src:"${state.previewSrc}",controls:!0}},font:{tagName:"div",attributes:{part:"preview-specimen",style:"${state.previewSpecimenFamily}"},children:[{tagName:"style",textContent:"${state.previewFontFace}"},{tagName:"p",attributes:{part:"specimen-line","data-size":"32"},textContent:"Aa"},{tagName:"p",attributes:{part:"specimen-line","data-size":"14"},textContent:"${state.previewSpecimen}"}]},glyph:{tagName:"jx-icon",attributes:{part:"preview-glyph","aria-hidden":"true"},$props:{name:{$ref:"#/state/previewGlyph"}}}}}]},{tagName:"h3",attributes:{part:"detail-name"},textContent:"${state.detailName}"},{tagName:"p",attributes:{part:"facts"},textContent:"${state.detailFacts}"},{tagName:"div",attributes:{part:"url-group"},children:[{tagName:"h4",attributes:{part:"group-title"},textContent:"Site URL"},{tagName:"div",attributes:{part:"url"},children:[{tagName:"code",attributes:{part:"url-value"},textContent:"${state.detailRef}"},{tagName:"jx-action-button",attributes:{part:"copy"},$props:{size:"sm",quiet:!0,hint:"Copy the site URL"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/copyRef"},value:[]}]},children:[{tagName:"span",textContent:"Copy"}]}]}]},{tagName:"div",attributes:{part:"usage-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/usageState"},cases:{shown:{tagName:"div",attributes:{part:"usage"},children:[{tagName:"h4",attributes:{part:"group-title"},textContent:"Used on"},{tagName:"p",attributes:{part:"usage-headline"},textContent:"${state.usageHeadline}"},{tagName:"div",attributes:{part:"usage-list-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/hasUsageFiles"},cases:{true:{tagName:"ul",attributes:{part:"usage-list"},children:[{$prototype:"Array",items:{$ref:"#/state/usageFiles"},key:{$ref:"$map/item/path"},map:{tagName:"li",attributes:{part:"usage-row","data-usage":"${$map.item.path}"},children:[{tagName:"button",attributes:{part:"usage-link",type:"button",title:"Open ${$map.item.path}"},textContent:"${$map.item.path}",onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/openDocument"},value:[{$ref:"$map/item/path"}]}]}},{tagName:"span",attributes:{part:"usage-count"},textContent:"${$map.item.count}"}]}}]}}}]}},$description:'Hidden on a host with no reference index, which is a different fact from "nothing uses it": a confident zero is the one answer this pane must never invent.'},{tagName:"div",attributes:{part:"actions-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/mode"},cases:{manage:{tagName:"div",attributes:{part:"actions"},children:[{tagName:"label",attributes:{part:"replace",title:"Replace ${state.detailName} everywhere it is used"},children:[{tagName:"input",attributes:{part:"replace-input",type:"file",accept:"${state.replaceAccept}"},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/replace"},value:[{$ref:"event#/target"}]}],description:"Replace writes the chosen file over this one's path, so every reference keeps resolving and now shows the new bytes (studio.md §9.3). The element rather than the list, so the input can be cleared."}},{tagName:"span",textContent:"Replace"}]},{tagName:"jx-button",attributes:{part:"open-viewer"},$props:{size:"sm",variant:"secondary"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/openViewer"},value:[]}]},children:[{tagName:"span",textContent:"Open in viewer"}]},{tagName:"jx-button",attributes:{part:"delete"},$props:{size:"sm",variant:"negative"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/remove"},value:[]}]},children:[{tagName:"span",textContent:"Delete"}]}]}},$description:"Manage mode's actions. Pick mode has none here: its answer is the dialog's own footer, Cancel and Use <file>."}]}}}]}]};T("media-library",de);function De(){return{countingLabel:"",detailFacts:"",detailHint:"",detailName:"",detailRef:"",detailState:"none",dropActive:"false",emptyDetail:"",emptyTitle:"",filters:[],gridState:"loading",mode:"manage",previewFontFace:"",previewGlyph:"",previewKind:"glyph",previewSpecimen:"",previewSpecimenFamily:"",previewSrc:"",query:"",region:"",replaceAccept:"",selectedFile:"",sort:"",sortOptions:[],tiles:[],title:"",titleId:"",uploadAccept:"",uploadHint:"",usageFiles:[],usageHeadline:"",usageState:"hidden"}}function pe(e,t){Object.assign(e,t),e.hasUsageFiles=t.usageFiles.length>0}function Ee(e){let t=n(e)?void 0:e.attributes?.part;return n(t)?t:""}function Ae(e){let t=e?.$map,i=S(t)&&"item"in t?t.item:void 0;return S(i)&&"file"in i&&n(i.file)?i.file:null}function q(e,t,i,a){if(a.clear)e.replaceChildren();let{tileHost:r,gridHost:o,inputHost:l,...c}=i,s=g({...De(),...c,hasUsageFiles:!1});pe(s,t);let h=null,w=!1,K=R("media-library",s,e,{onNodeCreated:(f,d,k,Te)=>{if(w||!(f instanceof HTMLElement))return;let D=Ee(k);if(D==="tile"){let te=Ae(Te);if(te!==null)r(f,te)}else if(D==="grid")o(f);else if(f instanceof HTMLInputElement&&D==="upload-input")l(f,"upload");else if(f instanceof HTMLInputElement&&D==="replace-input")l(f,"replace")}}).then((f)=>{if(w)f.dispose();else h=f;return f.root});return{attached:()=>{if(w)return!1;let f=h?.root;return f===void 0?!0:f instanceof HTMLElement&&e.contains(f)},dispose(){w=!0,h?.dispose(),h=null},ready:K,update:(f)=>pe(s,f)}}var ce={$schema:"https://jxsuite.com/schema/v1",$id:"StudioMediaPickDialog",$description:"The full-size media picker (`specs/studio.md` §9.3): a `jx-dialog` whose body is the Media workspace's own library surface in pick mode, so the picker and the workspace are one surface at two sizes. The dialog owns modality, Escape, the backdrop and focus restoration, and its footer is the answer: Cancel, or Use <file>, disabled until a file is chosen. The body is an ISLAND: this document draws the slot and nothing in it, and `surfaces/media-pick-dialog.ts` mounts `media-library.json` there through `onNodeCreated`.",tagName:"jx-dialog",$props:{headline:{$ref:"#/state/headline"},confirmLabel:{$ref:"#/state/confirmLabel"},confirmDisabled:{$ref:"#/state/blocked"},cancelLabel:"Cancel",dismissible:!0,size:"xl"},attributes:{part:"media-pick"},onconfirm:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/confirm"},value:[]}]},oncancel:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/closed"},value:[]}]},onclose:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/closed"},value:[]}]},children:[{tagName:"div",attributes:{part:"library-slot"},style:{$description:"The library's box in pick mode is its own (`media-library.json`, `data-mode=\"pick\"`); the slot only gives it the dialog body's width.",minWidth:"0"}}]};T("media-pick-dialog",ce);var V="media-picker";function Re(e){let t=n(e)?void 0:e.attributes?.part;return n(t)?t:""}function ue(e){let t=document.createElement("div");t.style.pointerEvents="auto",t.setAttribute(qe,ft("dialog",V)),e.layer.append(t);let i=!1,a=()=>{if(i)return;i=!0,e.closed()},r=()=>i,o=g({...e.view,closed:a,confirm:e.confirm}),l=null,c=R("media-pick-dialog",o,t,{onNodeCreated:(s,h,w)=>{if(!r()&&s instanceof HTMLElement&&Re(w)==="library-slot")e.body(s)}}).then(async(s)=>{l=s;let h=s.root;if(r())return s.dispose(),h;if(await Jt(h),!r())Pt(h);return h});return{close(){let s=l?.root;if(s instanceof HTMLElement)Nt(s);l?.dispose(),l=null,t.remove(),a()},host:t,ready:c,update(s){Object.assign(o,s)}}}var Q2="media-home",ve={audio:"play",document:"file-text",font:"text-aa",image:"image",video:"play"},Oe={audio:"Audio",document:"Document",font:"Font",image:"Image",video:"Video"},y={filter:"all",query:"",sort:"newest",selected:null},H=null,x=null,I=0,O=0,A=!1,G=0;function Y(){x=null,A=!1,I=0,O=0,G+=1}function Pe(){return[...F].some((e)=>!e.disposed&&e.choice.filter==="unused")}async function Ke(e){if(A||x!==null||!ph())return;let t=G;A=!0,I=0,O=e.length;let i=new Set;for(let a of e){let r=await Ju(a.file);if(t!==G)return;if(!Pe()){Y();return}if(r.status==="ready"&&r.result.files.length===0)i.add(a.file);I+=1,b()}x=i,A=!1,b()}var F=new Set,M=new Map,J=new Set,N=null;function be(){if(N!==null)return;let e=()=>{Y(),b()},t=NT(e),i=Yb(e);N=()=>{t(),i()}}function _e(){if(F.size===0&&N)N(),N=null}function v(e){if(!e.disposed){if(e.handle?.update(Z(e)),e.onSelect?.(),Ue(e),e.focusOwed)queueMicrotask(()=>Le(e));we(e)}}function Ue(e){let t=e.reveal,i=t===null?void 0:e.tiles.get(t);if(i?.isConnected)e.reveal=null,i.scrollIntoView({block:"nearest"})}function we(e){if(e.sweepTimer!==null||e.disposed)return;e.sweepTimer=setTimeout(()=>{e.sweepTimer=null,e.observer.releaseDetached();for(let[t,i]of e.tiles)if(!i.isConnected)e.tiles.delete(t);for(let t of[e.inputs.upload,e.inputs.replace])for(let i of t)if(!i.isConnected)t.delete(i)},0)}function xe(e){return[...e].find((t)=>t.isConnected)??null}function b(){for(let e of F)v(e)}function X(e){if(e.disposed=!0,e.sweepTimer!==null)clearTimeout(e.sweepTimer),e.sweepTimer=null;e.inputs.upload.clear(),e.inputs.replace.clear(),e.observer.destroy(),e.handle?.dispose(),e.handle=null,e.tiles.clear(),F.delete(e),_e()}function $e(e){let t=Uu(),i=t===null?null:e.images?t.filter((r)=>r.isImage):t;return{files:(i??[]).map((r)=>{let o=Od(r.file);return{bytes:o?.bytes??null,file:r.file,kind:r.kind,modified:o?.modified??null,name:r.name}}),listed:i}}function We(e){return E.filter((t)=>(t.key!=="unused"||ph())&&(!e.images||t.key==="image"||t.key==="unused"))}function ww(e){let{filter:t,query:i,selected:a}=e.choice;if(a===null)return null;let r=Uu()?.find((l)=>l.file===a)??null;if(r===null||e.images&&!r.isImage)return null;let o={bytes:null,file:r.file,kind:r.kind,modified:null,name:r.name};return _(o,t,x)&&U(o,i)?r:null}function Ve(e,t){if(t===0)return{emptyDetail:`Upload files or drop them anywhere here. They are saved under ${e.uploadDir}/, and anything already under public/ or a collection's images/ folder is listed here too.`,emptyTitle:e.images?"No images yet":"No media yet"};let{filter:i,query:a}=e.choice;if(a.trim()!=="")return{emptyDetail:`Nothing in ${L(i)} matches it.`,emptyTitle:`No matches for “${a.trim()}”`};if(i==="unused")return{emptyDetail:"Every file is referenced by at least one document.",emptyTitle:"No unused media"};return{emptyDetail:`${t} ${t===1?"file":"files"} in the project, none of them ${L(i).toLowerCase()}.`,emptyTitle:`No ${L(i).toLowerCase()}`}}function Z(e){let{choice:t}=e,{files:i,listed:a}=$e(e),r=ne(i,x),o=We(e);if(!o.some((d)=>d.key===t.filter))t.filter=o[0]?.key??"all";let l=W(i,{filter:t.filter,query:t.query,sort:t.sort,unused:x}),c=Uu();if(t.filter==="unused"&&c!==null)Ke(c);let s="listed";if(a===null)s="loading";else if(t.filter==="unused"&&x===null)s="counting";else if(i.length===0||l.length===0)s=i.length===0?"empty":"nomatch";let h=ww(e),w=l.some((d)=>d.file===t.selected)?t.selected:l[0]?.file??null,K=l.map((d)=>{let k=d.kind==="image";return{caption:Lw(Od(d.file))||Oe[d.kind],file:d.file,glyph:ve[d.kind],key:d.file,name:d.name,selected:d.file===t.selected?"true":"false",tabindex:d.file===w?"0":"-1",thumbSrc:k&&e.visible.has(d.file)?rr(d.file):"",thumbState:k?e.visible.has(d.file)?"image":"pending":"glyph"}}),f=e.images&&t.filter==="image"?"Images":L(t.filter);return{countingLabel:O>0?`Counting references… ${I} of ${O}`:"Counting references…",dropActive:e.dropActive?"true":"false",filters:o.map((d)=>{let k=r[d.key];return{count:k===null?"":String(k),key:d.key,label:e.images&&d.key==="image"?"All images":d.label,pressed:d.key===t.filter?"true":"false"}}),gridState:s,mode:e.mode,query:t.query,region:e.region,sort:t.sort,sortOptions:z.map((d)=>({label:d.label,value:d.key})),tiles:K,title:f,titleId:`media-library-title-${e.region.replaceAll(/[^\w-]/g,"-")}`,uploadAccept:e.images?"image/*":qc(),uploadHint:`Upload into ${e.uploadDir}/`,...Ve(e,i.length),...Be(e,h)}}function Be(e,t){if(t===null)return{detailFacts:"",detailHint:e.mode==="pick"?"Choose a file to use it.":"Select a file to see its details.",detailName:"",detailRef:"",detailState:"none",previewFontFace:"",previewGlyph:"",previewKind:"glyph",previewSpecimen:"",previewSpecimenFamily:"",previewSrc:"",replaceAccept:"",selectedFile:"",usageFiles:[],usageHeadline:"",usageState:"hidden"};let i=Od(t.file),a=Ow(t.file);if(!Ad(t.file))qu(t.file).then(b);if(a===null||a.status==="pending")Ju(t.file).then(b);let r=OT(t.file),o=r==="image"||r==="video"||r==="audio"||r==="font"?r:"glyph",l=o==="font"?PT(t.file):{fontFace:"",specimen:"",specimenFamily:""};return{detailFacts:MT(t.file,i),detailHint:"",detailName:t.name,detailRef:t.ref,detailState:"shown",previewFontFace:l.fontFace,previewGlyph:ve[t.kind],previewKind:o,previewSpecimen:l.specimen,previewSpecimenFamily:l.specimenFamily,previewSrc:o==="glyph"?"":rr(t.file),replaceAccept:fA(t.file),selectedFile:t.file,...FT(a)}}var fe=null,me=null;function Ge(){return fe??=(le("rcn56qvm"),import("./files-rcn56qvm.js")),fe}function Ye(){return me??=(le("qnab36ek"),import("./file-ops-qnab36ek.js")),me}function ee(e){try{e.showPicker()}catch{e.focus()}}function j(e,t){e.choice.selected=t,v(e)}async function ge(e,t){let i=await Ca([...t],{dir:e.uploadDir,only:e.images?"image":"media"}),[a]=i;if(!a)return;if(e.choice.filter!=="all"&&e.choice.filter!==a.kind)e.choice.filter=e.images?"image":"all";e.choice.query="",e.reveal=a.path,j(e,a.path)}async function N2(e){let t=e.split("/").pop()??e,{confirmFileDelete:i}=await Ye();if(!await i({name:t,path:e}))return!1;let{markLocalMutation:a}=await (le("d1qxq4z4"),import("./fs-events-d1qxq4z4.js"));try{a(e),await p().deleteFile(e)}catch(l){return C.error(`Could not delete ${t}.`,{detail:Q(l),path:e,source:"Media"}),!1}if(Ud([e]),Er(),m.tabs.has(e))Zd(e);for(let l of F)if(l.choice.selected===e)l.choice.selected=null;if(y.selected===e)y.selected=null;let r=Pb(e),o=await Je(r,a);return await i$(o?Pb(r):r),C.success(`Deleted ${t}`),!0}async function Je(e,t){if(!hA(e))return!1;let i=p();try{if((await i.listDirectory(e)).length>0)return!1;return t(e),await i.deleteFile(e),!0}catch{return!1}}function Me(e){return{activate:(t)=>{j(e,t),he(e,t)},activateSelected:()=>{let{selected:t}=e.choice;if(t!==null)he(e,t)},copyRef:()=>{let t=ww(e);if(t&&"clipboard"in navigator)navigator.clipboard.writeText(t.ref)},dragOut:()=>{if(e.dropActive)e.dropActive=!1,v(e)},dragOver:()=>{if(!e.dropActive)e.dropActive=!0,v(e)},drop:(t)=>{if(e.dropActive=!1,v(e),t?.length)ge(e,t)},focusTile:(t)=>{if(e.choice.selected!==t)j(e,t)},gridHost:(t)=>{e.grid=t},inputHost:(t,i)=>{e.inputs[i].add(t),we(e);let a=H;if(e.mode==="manage"&&a?.role===i&&(i==="upload"||a.file===e.choice.selected))H=null,ee(t)},key:(t,i)=>Qe(e,t,i),measure:(t,i,a)=>{if(yp(t,i,a))b();else if(!Ad(t))qu(t).then(b)},openDocument:(t)=>{Ge().then(({openFileInTab:i})=>i(t))},openViewer:()=>{let{selected:t}=e.choice;if(t!==null)fb(t)},remove:()=>{let{selected:t}=e.choice;if(t!==null)N2(t)},replace:(t)=>{let[i]=t.files??[];t.value="";let{selected:a}=e.choice;if(i&&a!==null)mA(a,i).then(b)},reset:()=>{e.choice.filter=e.images?"image":"all",e.choice.query="",v(e)},select:(t)=>j(e,t),setFilter:(t)=>{if(ae(t))e.choice.filter=t,v(e)},setQuery:(t)=>{e.choice.query=t,v(e)},setSort:(t)=>{if(re(t))e.choice.sort=t,v(e)},tileHost:(t,i)=>{e.tiles.set(i,t),ke.set(t,i),e.observer.observe(t)},upload:(t)=>{let i=[...t.files??[]];if(t.value="",i.length>0)ge(e,i)}}}function he(e,t){if(e.mode==="pick"){let i=ww(e);if(i)e.onPick?.(i);return}fb(t)}function Qe(e,t,i){let{files:a}=$e(e),r=W(a,{filter:e.choice.filter,query:e.choice.query,sort:e.choice.sort,unused:x}),o=r.findIndex((h)=>h.file===e.choice.selected),l=e.grid?oe(ze(e.grid).width):1,c=o===-1?r.length>0?0:null:se(o,t,l,r.length,i),s=c===null?void 0:r[c];if(!s)return;j(e,s.file),e.tiles.get(s.file)?.focus()}var ke=new WeakMap;function Se(e,t,i,a,r,o){let l={choice:t,disposed:!1,dropActive:!1,grid:null,handle:null,images:r,inputs:{replace:new Set,upload:new Set},mode:e,observer:bp((c)=>{let s=ke.get(c);if(s!==void 0&&!l.visible.has(s))l.visible.add(s),Xe(l)}),onPick:null,onSelect:null,paneId:a,reveal:null,focusOwed:!1,region:i,sweepTimer:null,tiles:new Map,uploadDir:o,visible:new Set};return l}var B=new Set;function Xe(e){if(B.has(e))return;B.add(e),queueMicrotask(()=>{B.delete(e),v(e)})}function hS(e,t){let i=M.get(e);return i!==void 0&&i.tabId===t.id&&i.wrap.isConnected&&i.mount.handle!==null&&i.mount.handle.attached()}function xw(e){let t=M.get(e);if(!t)return;X(t.mount),M.delete(e)}function LT(e,t){let{paneId:i,wrap:a}=e;if(hS(i,t))return;xw(i);let r=Se("manage",y,wi(i,"media-library"),i,!1,Sa);if(F.add(r),be(),r.handle=q(a,Z(r),Me(r),{clear:!0}),M.set(i,{mount:r,tabId:t.id,wrap:a}),J.delete(i))Fe(r)}async function Fe(e){await e.handle?.ready,Le(e,!0)}function Le(e,t=e.focusOwed){if(!t||e.disposed)return;let{selected:i}=e.choice,a=(i===null?void 0:e.tiles.get(i))??[...e.tiles.values()].find((r)=>r.getAttribute("tabindex")==="0");if(a?.isConnected){e.focusOwed=!1,a.focus();return}e.focusOwed=!0}function $T(e){let t=M.get(e);if(t?.wrap.isConnected&&t.mount.handle?.attached()===!0){Fe(t.mount);return}J.add(e)}function A2(e){if(e.filter!==void 0)y.filter=e.filter;if(e.query!==void 0)y.query=e.query;if(e.select!==void 0){if(y.selected=e.select,y.filter!=="all")y.filter="all";y.query=""}b()}function eP(){let e=[...M.values()].map((t)=>xe(t.mount.inputs.upload)).find((t)=>t!==null)??null;if(e){ee(e);return}H={file:null,role:"upload"}}function tP(e){A2({select:e});let t=null;for(let i of M.values())if(i.mount.choice.selected===e)t??=xe(i.mount.inputs.replace);if(t){ee(t);return}H={file:e,role:"replace"}}var P=null;function ye(e){let t=ww(e);return{blocked:t===null,confirmLabel:t?`Use ${t.name}`:e.images?"Use image":"Use file",headline:e.images?"Choose an image":"Choose media"}}function pS(){let e=P;if(P=null,e)X(e.mount),e.dialog.close()}function nP(e){pS();let t={filter:e.images?"image":"all",query:"",selected:null,sort:"newest"},i=Se("pick",t,`${ft("dialog",V)}/library`,null,e.images,n$(u.value?.documentPath??null)),a=(o)=>{pS(),e.onPick(o.ref)};i.onPick=a,F.add(i),be();let r=ue({body:(o)=>{i.handle=q(o,Z(i),Me(i),{clear:!1})},closed:()=>{if(P?.mount===i)pS();else X(i)},confirm:()=>{let o=ww(i);if(o)a(o)},layer:tt("dialog"),view:ye(i)});i.onSelect=()=>r.update(ye(i)),P={dialog:r,mount:i}}function IT(){pS();for(let e of M.keys())xw(e);y.filter="all",y.query="",y.selected=null,y.sort="newest",H=null,J.clear(),Y()}
2
- export{uS,Q2,ww,N2,hS,xw,LT,$T,A2,eP,tP,pS,nP,IT};
1
+ import{Q}from"./studio-nqxqf8p2.js";import{p}from"./studio-pr23qhrw.js";import{g,C}from"./studio-hw60n5dh.js";import{ph,Cr,C$}from"./studio-cq87hree.js";import{Mt,Nt}from"./studio-7cg75gtj.js";import{qe,wi,ft,T,R,Jt,tt}from"./studio-02phtmqn.js";import{m,u,Yd}from"./studio-y1x65h5r.js";import{Vd}from"./studio-hnx1h1pr.js";import{He}from"./studio-gmhd0j3f.js";import{Wc,_a,YL,aA,ZL,Sa,cA,dA,Ab,or}from"./studio-hvxt8z79.js";import{Rw,Ku}from"./studio-wcakp5bt.js";import{TT,Vu}from"./studio-a6x058ew.js";import{$T,IT,RT,DT,pb}from"./studio-bqgs90r8.js";import{bp}from"./studio-a3evp7f6.js";import{Dd,Nd,Uu,yp,Cw}from"./studio-332hesdk.js";import{n,_}from"./studio-kt2j51sa.js";import{le}from"./studio-fqs1a22a.js";var D=[{key:"all",label:"All media"},{key:"image",label:"Images"},{key:"video",label:"Video"},{key:"audio",label:"Audio"},{key:"document",label:"Documents"},{key:"font",label:"Fonts"},{key:"unused",label:"Unused"}],lS=D.map((e)=>e.key);function ae(e){return lS.some((t)=>t===e)}function F(e){return D.find((t)=>t.key===e)?.label??"All media"}var K=[{key:"newest",label:"Newest"},{key:"name",label:"Name"},{key:"size",label:"Size"}],Ne=K.map((e)=>e.key);function re(e){return Ne.some((t)=>t===e)}function z(e,t,i){switch(t){case"all":return!0;case"unused":return i!==null&&i.has(e.file);default:return e.kind===t}}function U(e,t){let i=t.trim().toLowerCase();return i===""||e.name.toLowerCase().includes(i)}function W(e,t){return e.filter((a)=>z(a,t.filter,t.unused)&&U(a,t.query)).toSorted((a,r)=>je(t.sort,a,r)||a.file.localeCompare(r.file))}function je(e,t,i){switch(e){case"name":return t.name.localeCompare(i.name,void 0,{numeric:!0,sensitivity:"base"});case"size":return(i.bytes??-1)-(t.bytes??-1);default:return(i.modified??"").localeCompare(t.modified??"")}}function ne(e,t){let i={all:e.length,audio:0,document:0,font:0,image:0,unused:t===null?null:e.filter((a)=>t.has(a.file)).length,video:0};for(let a of e)i[a.kind]=(i[a.kind]??0)+1;return i}var Ce=132,ie=12;function oe(e){return Math.max(1,Math.floor((e+ie)/(Ce+ie)))}function se(e,t,i,a,r=!1){if(a===0)return null;let o=Math.min(Math.max(e,0),a-1),l=o-o%i,c;switch(t){case"ArrowRight":{c=o+1;break}case"ArrowLeft":{c=o-1;break}case"ArrowDown":{c=o+i;break}case"ArrowUp":{c=o-i;break}case"Home":{c=r?0:l;break}case"End":{c=r?a-1:Math.min(l+i-1,a-1);break}default:return null}return c<0||c>=a?o:c}var de={$schema:"https://jxsuite.com/schema/v1",$id:"StudioMediaLibrary",$description:"The Media workspace's library (`specs/studio.md` §22.6): the project's media as filters, a grid and the selected file's detail. ONE document in two modes. In `manage` it is the Media home tab, with Replace, Open in viewer and Delete under the detail; in `pick` it is the full-size picker inside a `jx-dialog` (`media-pick-dialog.json`), and the dialog's own footer answers Cancel or Use <file>. `media/media-library.ts` keeps every decision (which files a filter keeps, the sort, what a count may claim, where an arrow lands, what Replace writes) and hands this document strings and discriminants. **Unused is drawn with no number until the usage sweep has settled**, and Missing alt text and tags are not drawn at all: each needs a store that does not exist, and a filter that cannot be answered is not shipped as one that always answers nothing.",tagName:"div",attributes:{part:"media-library","data-jx-region":"${state.region}","data-mode":"${state.mode}","data-drop":"${state.dropActive}"},style:{$description:"Three columns over the whole stage: the filters, the grid with its toolbar, and the selected file's detail. Fills the pane's stage by its own geometry, as the workspace home does: the stage is `position: relative` (`pane-grid.json`). In pick mode the same columns fill the dialog's body instead, so the root's box is the only thing that differs between the two modes.",position:"absolute",inset:"0",display:"grid",gridTemplateColumns:"200px minmax(0, 1fr) 300px",boxSizing:"border-box",fontFamily:"var(--jx-font-sans)",fontSize:"var(--jx-text-md)",color:"var(--fg)",background:"var(--bg)",'&[data-mode="pick"]':{$description:"Inside a dialog there is no stage to fill: the box is the dialog body's, at a height the dialog can scroll within.",position:"relative",inset:"auto",height:"min(70vh, 620px)",gridTemplateColumns:"150px minmax(0, 1fr) 210px"},'&[data-drop="true"]':{$description:"The drop affordance is a STATE the flow holds, not a class a handler adds and forgets to take off.",outline:"2px dashed var(--accent)",outlineOffset:"-4px"},'& [part="filters"]':{display:"flex",flexDirection:"column",gap:"2px",padding:"var(--jx-space-3) var(--jx-space-2)",borderRight:"1px solid var(--border)",background:"var(--bg-panel)",overflowY:"auto"},'& [part="filters-heading"]':{margin:"0",padding:"var(--jx-space-2) var(--jx-space-2) var(--jx-space-1)",fontSize:"var(--jx-text-xs)",fontWeight:"600",letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--fg-dim)"},'& [part="filter"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-2)",height:"30px",padding:"0 var(--jx-space-2)",border:"none",borderRadius:"var(--radius)",background:"none",color:"var(--fg)",font:"inherit",textAlign:"left",cursor:"pointer"},'& [part="filter"]:hover':{background:"var(--hover-bg)"},'& [part="filter"][aria-pressed="true"]':{background:"color-mix(in srgb, var(--accent) 16%, transparent)",color:"var(--fg)",fontWeight:"600"},'& [part="filter"]:focus-visible':{outline:"var(--jx-focus-ring)",outlineOffset:"-2px"},'& [part="filter-count"]':{marginLeft:"auto",fontSize:"var(--jx-text-xs)",color:"var(--fg-dim)",fontWeight:"400"},'& [part="main"]':{display:"flex",flexDirection:"column",minWidth:"0",minHeight:"0"},'& [part="toolbar"]':{display:"flex",alignItems:"center",flexWrap:"wrap",gap:"var(--jx-space-3)",padding:"var(--jx-space-3) var(--jx-space-4)",borderBottom:"1px solid var(--border)"},'& [part="title"]':{margin:"0 auto 0 0",fontSize:"var(--jx-text-lg)",fontWeight:"600"},'& [part="search"]':{width:"220px"},'& [part="sort"]':{width:"130px"},'& [part="upload"], & [part="empty-upload"]':{$description:"A LABEL around the file picker, not a button that clicks a hidden one: the picker is the control, so it takes focus, Enter opens it and a screen reader announces a file upload. A plain element because a label forwards a click to the input it contains and a custom element between the two would break that.",position:"relative",display:"inline-flex",alignItems:"center",gap:"6px",height:"28px",padding:"0 var(--jx-space-3)",border:"1px solid var(--border)",borderRadius:"var(--radius)",background:"var(--bg-panel)",color:"var(--fg)",font:"inherit",cursor:"pointer",":hover":{background:"var(--hover-bg)"},":has(:focus-visible)":{outline:"var(--jx-focus-ring)",outlineOffset:"2px"}},'& [part="upload-input"], & [part="replace-input"]':{$description:"Out of the way but still FOCUSABLE: `display: none` would take the control out of the tab order, and the label around it draws the focus ring for it.",position:"absolute",width:"1px",height:"1px",opacity:"0",pointerEvents:"none"},'& [part="upload-glyph"]':{"--jx-icon-size":"16px"},'& [part="body"]':{flex:"1",minHeight:"0",overflowY:"auto",padding:"var(--jx-space-4)"},'& [part="grid"]':{$description:"auto-fill over a minimum tile width; `media/media-library-model.ts` `gridColumns` does the same arithmetic, so ArrowDown lands on the tile drawn under the current one. Keep the two numbers in step.",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(132px, 1fr))",gap:"12px",alignContent:"start"},'& [part="tile"]':{display:"flex",flexDirection:"column",gap:"4px",padding:"4px",borderRadius:"var(--jx-radius-md, 6px)",border:"2px solid transparent",cursor:"pointer",minWidth:"0",outline:"none"},'& [part="tile"]:hover':{background:"var(--hover-bg)"},'& [part="tile"][aria-selected="true"]':{borderColor:"var(--accent)"},'& [part="tile"]:focus-visible':{outline:"var(--jx-focus-ring)",outlineOffset:"2px"},'& [part="thumb"]':{display:"flex",alignItems:"center",justifyContent:"center",aspectRatio:"4 / 3",borderRadius:"var(--radius)",background:"var(--bg-input)",overflow:"hidden",color:"var(--fg-dim)","--jx-icon-size":"28px"},'& [part="thumb-img"]':{width:"100%",height:"100%",objectFit:"cover"},'& [part="tile-name"]':{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"var(--jx-text-sm)"},'& [part="tile-caption"]':{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"var(--jx-text-xs)",color:"var(--fg-dim)",minHeight:"1em"},'& [part="empty"]':{display:"flex",flexDirection:"column",alignItems:"center",gap:"var(--jx-space-3)",padding:"48px var(--jx-space-6)",textAlign:"center",color:"var(--fg-dim)","--jx-icon-size":"40px"},'& [part="empty-title"]':{margin:"0",fontSize:"var(--jx-text-lg)",fontWeight:"600",color:"var(--fg)"},'& [part="empty-detail"]':{margin:"0",maxWidth:"42ch",lineHeight:"1.5"},'& [part="detail"]':{display:"flex",flexDirection:"column",gap:"var(--jx-space-3)",padding:"var(--jx-space-4)",borderLeft:"1px solid var(--border)",background:"var(--bg-panel)",overflowY:"auto",minWidth:"0"},'& [part="detail-hint"]':{margin:"auto 0",textAlign:"center",color:"var(--fg-dim)"},'& [part="detail-preview"]':{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"140px",maxHeight:"220px",borderRadius:"var(--radius)",background:"var(--bg-input)",overflow:"hidden",color:"var(--fg-dim)","--jx-icon-size":"40px"},'& [part="preview-img"], & [part="preview-video"]':{maxWidth:"100%",maxHeight:"220px",objectFit:"contain"},'& [part="preview-audio"]':{width:"100%"},'& [part="preview-specimen"]':{$description:"The viewer's specimen at a side pane's size. The face arrives as the `@font-face` the flow writes under a family name generated from the path (`media/media-pane.ts` `specimenOf`); the element carries only that name, as a custom property, and the fallback stack is a rule, here.",display:"flex",flexDirection:"column",gap:"var(--jx-space-2)",padding:"var(--jx-space-4)",maxWidth:"100%",color:"var(--fg)",fontFamily:"var(--jx-specimen-family, system-ui), system-ui, sans-serif"},'& [part="specimen-line"]':{margin:"0",lineHeight:"1.3",overflowWrap:"anywhere"},'& [part="specimen-line"][data-size="32"]':{fontSize:"32px"},'& [part="specimen-line"][data-size="14"]':{fontSize:"var(--jx-text-md)"},'& [part="detail-name"]':{margin:"0",fontSize:"var(--jx-text-md)",fontWeight:"600",overflowWrap:"anywhere"},'& [part="facts"]':{margin:"0",color:"var(--fg-dim)",fontSize:"var(--jx-text-sm)"},'& [part="group-title"]':{margin:"0",fontSize:"var(--jx-text-xs)",fontWeight:"600",color:"var(--fg-dim)"},'& [part="url"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-2)",minWidth:"0"},'& [part="url-value"]':{flex:"1",minWidth:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"var(--jx-font-mono)",fontSize:"var(--jx-text-sm)"},'& [part="usage"]':{display:"flex",flexDirection:"column",gap:"var(--jx-space-1)"},'& [part="usage-headline"]':{margin:"0",fontSize:"var(--jx-text-sm)"},'& [part="usage-list"]':{margin:"0",padding:"0",listStyle:"none",display:"flex",flexDirection:"column",gap:"2px"},'& [part="usage-row"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-2)"},'& [part="usage-link"]':{flex:"1",minWidth:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",border:"none",background:"none",padding:"0",color:"var(--accent)",font:"inherit",fontSize:"var(--jx-text-sm)",textAlign:"left",cursor:"pointer",":hover":{textDecoration:"underline"},":focus-visible":{outline:"var(--jx-focus-ring)"}},'& [part="usage-count"]':{fontSize:"var(--jx-text-xs)",color:"var(--fg-dim)"},'& [part="actions"]':{display:"flex",flexWrap:"wrap",gap:"var(--jx-space-2)",marginTop:"var(--jx-space-2)"},'& [part="replace"]':{position:"relative",display:"inline-flex",alignItems:"center",height:"28px",padding:"0 var(--jx-space-3)",border:"1px solid var(--border)",borderRadius:"var(--radius)",background:"var(--bg)",color:"var(--fg)",font:"inherit",cursor:"pointer",":hover":{background:"var(--hover-bg)"},":has(:focus-visible)":{outline:"var(--jx-focus-ring)",outlineOffset:"2px"}}},ondragover:{$prototype:"Function",body:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/dragOver"},value:[]}],description:"A file dropped ANYWHERE on the library uploads, to the destination the Upload label names before the drop: public/media/."},ondragleave:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/dragOut"},value:[]}]},ondrop:{$prototype:"Function",body:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/drop"},value:[{$ref:"event#/dataTransfer/files"}]}]},children:[{tagName:"nav",attributes:{part:"filters","aria-label":"Media filters"},children:[{tagName:"h2",attributes:{part:"filters-heading"},textContent:"Library"},{$prototype:"Array",items:{$ref:"#/state/filters"},key:{$ref:"$map/item/key"},map:{tagName:"button",attributes:{part:"filter",type:"button","aria-pressed":"${$map.item.pressed}","data-filter":"${$map.item.key}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setFilter"},value:[{$ref:"$map/item/key"}]}]},children:[{tagName:"span",attributes:{part:"filter-label"},textContent:"${$map.item.label}"},{tagName:"span",attributes:{part:"filter-count"},textContent:"${$map.item.count}"}]}}]},{tagName:"section",attributes:{part:"main","aria-labelledby":"${state.titleId}"},children:[{tagName:"header",attributes:{part:"toolbar"},children:[{tagName:"h2",attributes:{part:"title",id:"${state.titleId}"},textContent:"${state.title}"},{tagName:"jx-textfield",attributes:{part:"search"},$props:{type:"search",size:"sm",label:"Search media",placeholder:"Search by name…",autocomplete:"off",value:{$ref:"#/state/query"}},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setQuery"},value:[{$ref:"event#/target/value"}]}]}},{tagName:"jx-select",attributes:{part:"sort"},$props:{label:"Sort",size:"sm",options:{$ref:"#/state/sortOptions"},value:{$ref:"#/state/sort"}},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setSort"},value:[{$ref:"event#/target/value"}]}]}},{tagName:"label",attributes:{part:"upload",title:"${state.uploadHint}"},children:[{tagName:"input",attributes:{part:"upload-input",type:"file",multiple:!0,accept:"${state.uploadAccept}"},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/upload"},value:[{$ref:"event#/target"}]}],description:"The picker itself, so the destination in the label's tooltip is visible BEFORE the files are chosen. The flow takes the element rather than the file list because a file input that is not cleared refuses the same file twice."}},{tagName:"jx-icon",attributes:{part:"upload-glyph","aria-hidden":"true"},$props:{name:"upload-simple"}},{tagName:"span",textContent:"Upload"}]}]},{tagName:"div",attributes:{part:"body"},children:[{tagName:"div",attributes:{part:"grid-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/gridState"},cases:{loading:{tagName:"p",attributes:{part:"empty",role:"status"},textContent:"Reading the project's media…"},counting:{tagName:"p",attributes:{part:"empty",role:"status"},textContent:"${state.countingLabel}"},empty:{tagName:"div",attributes:{part:"empty"},children:[{tagName:"jx-icon",attributes:{part:"empty-glyph","aria-hidden":"true"},$props:{name:"image"}},{tagName:"p",attributes:{part:"empty-title"},textContent:"${state.emptyTitle}"},{tagName:"p",attributes:{part:"empty-detail"},textContent:"${state.emptyDetail}"},{tagName:"label",attributes:{part:"empty-upload",title:"${state.uploadHint}"},children:[{tagName:"input",attributes:{part:"upload-input",type:"file",multiple:!0,accept:"${state.uploadAccept}"},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/upload"},value:[{$ref:"event#/target"}]}],description:"The picker itself, so the destination in the label's tooltip is visible BEFORE the files are chosen. The flow takes the element rather than the file list because a file input that is not cleared refuses the same file twice."}},{tagName:"jx-icon",attributes:{part:"upload-glyph","aria-hidden":"true"},$props:{name:"upload-simple"}},{tagName:"span",textContent:"Upload"}]}]},nomatch:{tagName:"div",attributes:{part:"empty"},children:[{tagName:"jx-icon",attributes:{part:"empty-glyph","aria-hidden":"true"},$props:{name:"image"}},{tagName:"p",attributes:{part:"empty-title"},textContent:"${state.emptyTitle}"},{tagName:"p",attributes:{part:"empty-detail"},textContent:"${state.emptyDetail}"},{tagName:"jx-button",attributes:{part:"reset"},$props:{size:"sm",variant:"secondary"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/reset"},value:[]}]},children:[{tagName:"span",textContent:"Show all media"}]}]},listed:{tagName:"div",attributes:{part:"grid",role:"listbox","aria-labelledby":"${state.titleId}"},onkeydown:{$prototype:"Function",body:[{$switch:{$ref:"event#/key"},cases:{ArrowRight:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/key"},value:[{$ref:"event#/key"},{$ref:"event#/ctrlKey"}]}],ArrowLeft:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/key"},value:[{$ref:"event#/key"},{$ref:"event#/ctrlKey"}]}],ArrowDown:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/key"},value:[{$ref:"event#/key"},{$ref:"event#/ctrlKey"}]}],ArrowUp:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/key"},value:[{$ref:"event#/key"},{$ref:"event#/ctrlKey"}]}],Home:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/key"},value:[{$ref:"event#/key"},{$ref:"event#/ctrlKey"}]}],End:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/key"},value:[{$ref:"event#/key"},{$ref:"event#/ctrlKey"}]}],Enter:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/activateSelected"},value:[]}]}}],description:"The grid pattern: arrows move one tile, Home and End to the ends of the row, Ctrl+Home and Ctrl+End to the ends of the grid, and Enter opens the selected file (in pick mode, uses it). The flow computes where the move lands; the tile that receives it takes focus, so the roving tabindex follows the selection."},children:[{$prototype:"Array",items:{$ref:"#/state/tiles"},key:{$ref:"$map/item/key"},map:{tagName:"div",attributes:{part:"tile",role:"option","aria-selected":"${$map.item.selected}",tabindex:"${$map.item.tabindex}","data-file":"${$map.item.file}",title:"${$map.item.name}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/select"},value:[{$ref:"$map/item/file"}]}]},onfocus:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/focusTile"},value:[{$ref:"$map/item/file"}]}],description:"Selection follows focus, the listbox pattern: a Tab onto the grid lands on the roving stop and selects it, so the first Enter opens (in pick mode, uses) the tile the focus ring is on rather than nothing."},ondblclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/activate"},value:[{$ref:"$map/item/file"}]}]},children:[{tagName:"div",attributes:{part:"thumb"},children:[{tagName:"div",attributes:{part:"thumb-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/thumbState"},cases:{image:{tagName:"img",attributes:{part:"thumb-img",src:"${$map.item.thumbSrc}",alt:"",draggable:"false"},onload:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/measure"},value:[{$ref:"$map/item/file"},{$ref:"event#/target/naturalWidth"},{$ref:"event#/target/naturalHeight"}]}]}},pending:{tagName:"span",attributes:{part:"thumb-pending","aria-hidden":"true"}},glyph:{tagName:"jx-icon",attributes:{part:"thumb-glyph","aria-hidden":"true"},$props:{name:{$ref:"$map/item/glyph"}}}},$description:"The thumbnail is asked for when the tile scrolls into view, not when the grid is built: `pending` until the flow's observer reports the tile, then the picture. A file the browser draws no picture of shows its kind's glyph."}]},{tagName:"span",attributes:{part:"tile-name"},textContent:"${$map.item.name}"},{tagName:"span",attributes:{part:"tile-caption"},textContent:"${$map.item.caption}"}]}}]}}}]}]},{tagName:"aside",attributes:{part:"detail","aria-label":"Details"},children:[{tagName:"div",attributes:{part:"detail-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/detailState"},cases:{none:{tagName:"p",attributes:{part:"detail-hint"},textContent:"${state.detailHint}"},shown:{tagName:"div",attributes:{part:"detail-body",role:"none"},style:{display:"contents"},children:[{tagName:"div",attributes:{part:"detail-preview"},children:[{tagName:"div",attributes:{part:"preview-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/previewKind"},cases:{image:{tagName:"img",attributes:{part:"preview-img",src:"${state.previewSrc}",alt:""},onload:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/measure"},value:[{$ref:"#/state/selectedFile"},{$ref:"event#/target/naturalWidth"},{$ref:"event#/target/naturalHeight"}]}]}},video:{tagName:"video",attributes:{part:"preview-video",src:"${state.previewSrc}",controls:!0}},audio:{tagName:"audio",attributes:{part:"preview-audio",src:"${state.previewSrc}",controls:!0}},font:{tagName:"div",attributes:{part:"preview-specimen",style:"${state.previewSpecimenFamily}"},children:[{tagName:"style",textContent:"${state.previewFontFace}"},{tagName:"p",attributes:{part:"specimen-line","data-size":"32"},textContent:"Aa"},{tagName:"p",attributes:{part:"specimen-line","data-size":"14"},textContent:"${state.previewSpecimen}"}]},glyph:{tagName:"jx-icon",attributes:{part:"preview-glyph","aria-hidden":"true"},$props:{name:{$ref:"#/state/previewGlyph"}}}}}]},{tagName:"h3",attributes:{part:"detail-name"},textContent:"${state.detailName}"},{tagName:"p",attributes:{part:"facts"},textContent:"${state.detailFacts}"},{tagName:"div",attributes:{part:"url-group"},children:[{tagName:"h4",attributes:{part:"group-title"},textContent:"Site URL"},{tagName:"div",attributes:{part:"url"},children:[{tagName:"code",attributes:{part:"url-value"},textContent:"${state.detailRef}"},{tagName:"jx-action-button",attributes:{part:"copy"},$props:{size:"sm",quiet:!0,hint:"Copy the site URL"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/copyRef"},value:[]}]},children:[{tagName:"span",textContent:"Copy"}]}]}]},{tagName:"div",attributes:{part:"usage-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/usageState"},cases:{shown:{tagName:"div",attributes:{part:"usage"},children:[{tagName:"h4",attributes:{part:"group-title"},textContent:"Used on"},{tagName:"p",attributes:{part:"usage-headline"},textContent:"${state.usageHeadline}"},{tagName:"div",attributes:{part:"usage-list-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/hasUsageFiles"},cases:{true:{tagName:"ul",attributes:{part:"usage-list"},children:[{$prototype:"Array",items:{$ref:"#/state/usageFiles"},key:{$ref:"$map/item/path"},map:{tagName:"li",attributes:{part:"usage-row","data-usage":"${$map.item.path}"},children:[{tagName:"button",attributes:{part:"usage-link",type:"button",title:"Open ${$map.item.path}"},textContent:"${$map.item.path}",onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/openDocument"},value:[{$ref:"$map/item/path"}]}]}},{tagName:"span",attributes:{part:"usage-count"},textContent:"${$map.item.count}"}]}}]}}}]}},$description:'Hidden on a host with no reference index, which is a different fact from "nothing uses it": a confident zero is the one answer this pane must never invent.'},{tagName:"div",attributes:{part:"actions-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/mode"},cases:{manage:{tagName:"div",attributes:{part:"actions"},children:[{tagName:"label",attributes:{part:"replace",title:"Replace ${state.detailName} everywhere it is used"},children:[{tagName:"input",attributes:{part:"replace-input",type:"file",accept:"${state.replaceAccept}"},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/replace"},value:[{$ref:"event#/target"}]}],description:"Replace writes the chosen file over this one's path, so every reference keeps resolving and now shows the new bytes (studio.md §9.3). The element rather than the list, so the input can be cleared."}},{tagName:"span",textContent:"Replace"}]},{tagName:"jx-button",attributes:{part:"open-viewer"},$props:{size:"sm",variant:"secondary"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/openViewer"},value:[]}]},children:[{tagName:"span",textContent:"Open in viewer"}]},{tagName:"jx-button",attributes:{part:"delete"},$props:{size:"sm",variant:"negative"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/remove"},value:[]}]},children:[{tagName:"span",textContent:"Delete"}]}]}},$description:"Manage mode's actions. Pick mode has none here: its answer is the dialog's own footer, Cancel and Use <file>."}]}}}]}]};T("media-library",de);function Ee(){return{countingLabel:"",detailFacts:"",detailHint:"",detailName:"",detailRef:"",detailState:"none",dropActive:"false",emptyDetail:"",emptyTitle:"",filters:[],gridState:"loading",mode:"manage",previewFontFace:"",previewGlyph:"",previewKind:"glyph",previewSpecimen:"",previewSpecimenFamily:"",previewSrc:"",query:"",region:"",replaceAccept:"",selectedFile:"",sort:"",sortOptions:[],tiles:[],title:"",titleId:"",uploadAccept:"",uploadHint:"",usageFiles:[],usageHeadline:"",usageState:"hidden"}}function pe(e,t){Object.assign(e,t),e.hasUsageFiles=t.usageFiles.length>0}function Ae(e){let t=n(e)?void 0:e.attributes?.part;return n(t)?t:""}function Ie(e){let t=e?.$map,i=_(t)&&"item"in t?t.item:void 0;return _(i)&&"file"in i&&n(i.file)?i.file:null}function q(e,t,i,a){if(a.clear)e.replaceChildren();let{tileHost:r,gridHost:o,inputHost:l,...c}=i,s=g({...Ee(),...c,hasUsageFiles:!1});pe(s,t);let h=null,w=!1,P=R("media-library",s,e,{onNodeCreated:(f,d,k,Te)=>{if(w||!(f instanceof HTMLElement))return;let H=Ae(k);if(H==="tile"){let te=Ie(Te);if(te!==null)r(f,te)}else if(H==="grid")o(f);else if(f instanceof HTMLInputElement&&H==="upload-input")l(f,"upload");else if(f instanceof HTMLInputElement&&H==="replace-input")l(f,"replace")}}).then((f)=>{if(w)f.dispose();else h=f;return f.root});return{attached:()=>{if(w)return!1;let f=h?.root;return f===void 0?!0:f instanceof HTMLElement&&e.contains(f)},dispose(){w=!0,h?.dispose(),h=null},ready:P,update:(f)=>pe(s,f)}}var ce={$schema:"https://jxsuite.com/schema/v1",$id:"StudioMediaPickDialog",$description:"The full-size media picker (`specs/studio.md` §9.3): a `jx-dialog` whose body is the Media workspace's own library surface in pick mode, so the picker and the workspace are one surface at two sizes. The dialog owns modality, Escape, the backdrop and focus restoration, and its footer is the answer: Cancel, or Use <file>, disabled until a file is chosen. The body is an ISLAND: this document draws the slot and nothing in it, and `surfaces/media-pick-dialog.ts` mounts `media-library.json` there through `onNodeCreated`.",tagName:"jx-dialog",$props:{headline:{$ref:"#/state/headline"},confirmLabel:{$ref:"#/state/confirmLabel"},confirmDisabled:{$ref:"#/state/blocked"},cancelLabel:"Cancel",dismissible:!0,size:"xl"},attributes:{part:"media-pick"},onconfirm:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/confirm"},value:[]}]},oncancel:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/closed"},value:[]}]},onclose:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/closed"},value:[]}]},children:[{tagName:"div",attributes:{part:"library-slot"},style:{$description:"The library's box in pick mode is its own (`media-library.json`, `data-mode=\"pick\"`); the slot only gives it the dialog body's width.",minWidth:"0"}}]};T("media-pick-dialog",ce);var V="media-picker";function Oe(e){let t=n(e)?void 0:e.attributes?.part;return n(t)?t:""}function ue(e){let t=document.createElement("div");t.style.pointerEvents="auto",t.setAttribute(qe,ft("dialog",V)),e.layer.append(t);let i=!1,a=()=>{if(i)return;i=!0,e.closed()},r=()=>i,o=g({...e.view,closed:a,confirm:e.confirm}),l=null,c=R("media-pick-dialog",o,t,{onNodeCreated:(s,h,w)=>{if(!r()&&s instanceof HTMLElement&&Oe(w)==="library-slot")e.body(s)}}).then(async(s)=>{l=s;let h=s.root;if(r())return s.dispose(),h;if(await Jt(h),!r())Mt(h);return h});return{close(){let s=l?.root;if(s instanceof HTMLElement)Nt(s);l?.dispose(),l=null,t.remove(),a()},host:t,ready:c,update(s){Object.assign(o,s)}}}var K2="media-home",ve={audio:"play",document:"file-text",font:"text-aa",image:"image",video:"play"},Pe={audio:"Audio",document:"Document",font:"Font",image:"Image",video:"Video"},y={filter:"all",query:"",sort:"newest",selected:null},j=null,x=null,A=0,I=0,E=!1,G=0;function Y(){x=null,E=!1,A=0,I=0,G+=1}function Ke(){return[...S].some((e)=>!e.disposed&&e.choice.filter==="unused")}async function ze(e){if(E||x!==null||!ph())return;let t=G;E=!0,A=0,I=e.length;let i=new Set;for(let a of e){let r=await Ku(a.file);if(t!==G)return;if(!Ke()){Y();return}if(r.status==="ready"&&r.result.files.length===0)i.add(a.file);A+=1,b()}x=i,E=!1,b()}var S=new Set,M=new Map,J=new Set,L=null;function be(){if(L!==null)return;let e=()=>{Y(),b()},t=TT(e),i=C$(e);L=()=>{t(),i()}}function _e(){if(S.size===0&&L)L(),L=null}function v(e){if(!e.disposed){if(e.handle?.update(Z(e)),e.onSelect?.(),Ue(e),e.focusOwed)queueMicrotask(()=>Le(e));we(e)}}function Ue(e){let t=e.reveal,i=t===null?void 0:e.tiles.get(t);if(i?.isConnected)e.reveal=null,i.scrollIntoView({block:"nearest"})}function we(e){if(e.sweepTimer!==null||e.disposed)return;e.sweepTimer=setTimeout(()=>{e.sweepTimer=null,e.observer.releaseDetached();for(let[t,i]of e.tiles)if(!i.isConnected)e.tiles.delete(t);for(let t of[e.inputs.upload,e.inputs.replace])for(let i of t)if(!i.isConnected)t.delete(i)},0)}function xe(e){return[...e].find((t)=>t.isConnected)??null}function b(){for(let e of S)v(e)}function X(e){if(e.disposed=!0,e.sweepTimer!==null)clearTimeout(e.sweepTimer),e.sweepTimer=null;e.inputs.upload.clear(),e.inputs.replace.clear(),e.observer.destroy(),e.handle?.dispose(),e.handle=null,e.tiles.clear(),S.delete(e),_e()}function $e(e){let t=Vu(),i=t===null?null:e.images?t.filter((r)=>r.isImage):t;return{files:(i??[]).map((r)=>{let o=Nd(r.file);return{bytes:o?.bytes??null,file:r.file,kind:r.kind,modified:o?.modified??null,name:r.name}}),listed:i}}function We(e){return D.filter((t)=>(t.key!=="unused"||ph())&&(!e.images||t.key==="image"||t.key==="unused"))}function bw(e){let{filter:t,query:i,selected:a}=e.choice;if(a===null)return null;let r=Vu()?.find((l)=>l.file===a)??null;if(r===null||e.images&&!r.isImage)return null;let o={bytes:null,file:r.file,kind:r.kind,modified:null,name:r.name};return z(o,t,x)&&U(o,i)?r:null}function Ve(e,t){if(t===0)return{emptyDetail:`Upload files or drop them anywhere here. They are saved under ${e.uploadDir}/, and anything already under public/ or a collection's images/ folder is listed here too.`,emptyTitle:e.images?"No images yet":"No media yet"};let{filter:i,query:a}=e.choice;if(a.trim()!=="")return{emptyDetail:`Nothing in ${F(i)} matches it.`,emptyTitle:`No matches for “${a.trim()}”`};if(i==="unused")return{emptyDetail:"Every file is referenced by at least one document.",emptyTitle:"No unused media"};return{emptyDetail:`${t} ${t===1?"file":"files"} in the project, none of them ${F(i).toLowerCase()}.`,emptyTitle:`No ${F(i).toLowerCase()}`}}function Z(e){let{choice:t}=e,{files:i,listed:a}=$e(e),r=ne(i,x),o=We(e);if(!o.some((d)=>d.key===t.filter))t.filter=o[0]?.key??"all";let l=W(i,{filter:t.filter,query:t.query,sort:t.sort,unused:x}),c=Vu();if(t.filter==="unused"&&c!==null)ze(c);let s="listed";if(a===null)s="loading";else if(t.filter==="unused"&&x===null)s="counting";else if(i.length===0||l.length===0)s=i.length===0?"empty":"nomatch";let h=bw(e),w=l.some((d)=>d.file===t.selected)?t.selected:l[0]?.file??null,P=l.map((d)=>{let k=d.kind==="image";return{caption:Cw(Nd(d.file))||Pe[d.kind],file:d.file,glyph:ve[d.kind],key:d.file,name:d.name,selected:d.file===t.selected?"true":"false",tabindex:d.file===w?"0":"-1",thumbSrc:k&&e.visible.has(d.file)?or(d.file):"",thumbState:k?e.visible.has(d.file)?"image":"pending":"glyph"}}),f=e.images&&t.filter==="image"?"Images":F(t.filter);return{countingLabel:I>0?`Counting references… ${A} of ${I}`:"Counting references…",dropActive:e.dropActive?"true":"false",filters:o.map((d)=>{let k=r[d.key];return{count:k===null?"":String(k),key:d.key,label:e.images&&d.key==="image"?"All images":d.label,pressed:d.key===t.filter?"true":"false"}}),gridState:s,mode:e.mode,query:t.query,region:e.region,sort:t.sort,sortOptions:K.map((d)=>({label:d.label,value:d.key})),tiles:P,title:f,titleId:`media-library-title-${e.region.replaceAll(/[^\w-]/g,"-")}`,uploadAccept:e.images?"image/*":Wc(),uploadHint:`Upload into ${e.uploadDir}/`,...Ve(e,i.length),...Be(e,h)}}function Be(e,t){if(t===null)return{detailFacts:"",detailHint:e.mode==="pick"?"Choose a file to use it.":"Select a file to see its details.",detailName:"",detailRef:"",detailState:"none",previewFontFace:"",previewGlyph:"",previewKind:"glyph",previewSpecimen:"",previewSpecimenFamily:"",previewSrc:"",replaceAccept:"",selectedFile:"",usageFiles:[],usageHeadline:"",usageState:"hidden"};let i=Nd(t.file),a=Rw(t.file);if(!Dd(t.file))Uu(t.file).then(b);if(a===null||a.status==="pending")Ku(t.file).then(b);let r=$T(t.file),o=r==="image"||r==="video"||r==="audio"||r==="font"?r:"glyph",l=o==="font"?RT(t.file):{fontFace:"",specimen:"",specimenFamily:""};return{detailFacts:IT(t.file,i),detailHint:"",detailName:t.name,detailRef:t.ref,detailState:"shown",previewFontFace:l.fontFace,previewGlyph:ve[t.kind],previewKind:o,previewSpecimen:l.specimen,previewSpecimenFamily:l.specimenFamily,previewSrc:o==="glyph"?"":or(t.file),replaceAccept:cA(t.file),selectedFile:t.file,...DT(a)}}var fe=null,me=null;function Ge(){return fe??=(le("ybpp3j38"),import("./files-ybpp3j38.js")),fe}function Ye(){return me??=(le("6pe4z7an"),import("./file-ops-6pe4z7an.js")),me}function ee(e){try{e.showPicker()}catch{e.focus()}}function N(e,t){e.choice.selected=t,v(e)}async function ge(e,t){let i=await Sa([...t],{dir:e.uploadDir,only:e.images?"image":"media"}),[a]=i;if(!a)return;if(e.choice.filter!=="all"&&e.choice.filter!==a.kind)e.choice.filter=e.images?"image":"all";e.choice.query="",e.reveal=a.path,N(e,a.path)}async function L2(e){let t=e.split("/").pop()??e,{confirmFileDelete:i}=await Ye();if(!await i({name:t,path:e}))return!1;let{markLocalMutation:a}=await (le("xfanfxds"),import("./fs-events-xfanfxds.js"));try{a(e),await p().deleteFile(e)}catch(l){return C.error(`Could not delete ${t}.`,{detail:Q(l),path:e,source:"Media"}),!1}if(Vd([e]),Cr(),m.tabs.has(e))Yd(e);for(let l of S)if(l.choice.selected===e)l.choice.selected=null;if(y.selected===e)y.selected=null;let r=Ab(e),o=await Je(r,a);return await ZL(o?Ab(r):r),C.success(`Deleted ${t}`),!0}async function Je(e,t){if(!aA(e))return!1;let i=p();try{if((await i.listDirectory(e)).length>0)return!1;return t(e),await i.deleteFile(e),!0}catch{return!1}}function Me(e){return{activate:(t)=>{N(e,t),he(e,t)},activateSelected:()=>{let{selected:t}=e.choice;if(t!==null)he(e,t)},copyRef:()=>{let t=bw(e);if(t&&"clipboard"in navigator)navigator.clipboard.writeText(t.ref)},dragOut:()=>{if(e.dropActive)e.dropActive=!1,v(e)},dragOver:()=>{if(!e.dropActive)e.dropActive=!0,v(e)},drop:(t)=>{if(e.dropActive=!1,v(e),t?.length)ge(e,t)},focusTile:(t)=>{if(e.choice.selected!==t)N(e,t)},gridHost:(t)=>{e.grid=t},inputHost:(t,i)=>{e.inputs[i].add(t),we(e);let a=j;if(e.mode==="manage"&&a?.role===i&&(i==="upload"||a.file===e.choice.selected))j=null,ee(t)},key:(t,i)=>Qe(e,t,i),measure:(t,i,a)=>{if(yp(t,i,a))b();else if(!Dd(t))Uu(t).then(b)},openDocument:(t)=>{Ge().then(({openFileInTab:i})=>i(t))},openViewer:()=>{let{selected:t}=e.choice;if(t!==null)pb(t)},remove:()=>{let{selected:t}=e.choice;if(t!==null)L2(t)},replace:(t)=>{let[i]=t.files??[];t.value="";let{selected:a}=e.choice;if(i&&a!==null)dA(a,i).then(b)},reset:()=>{e.choice.filter=e.images?"image":"all",e.choice.query="",v(e)},select:(t)=>N(e,t),setFilter:(t)=>{if(ae(t))e.choice.filter=t,v(e)},setQuery:(t)=>{e.choice.query=t,v(e)},setSort:(t)=>{if(re(t))e.choice.sort=t,v(e)},tileHost:(t,i)=>{e.tiles.set(i,t),ke.set(t,i),e.observer.observe(t)},upload:(t)=>{let i=[...t.files??[]];if(t.value="",i.length>0)ge(e,i)}}}function he(e,t){if(e.mode==="pick"){let i=bw(e);if(i)e.onPick?.(i);return}pb(t)}function Qe(e,t,i){let{files:a}=$e(e),r=W(a,{filter:e.choice.filter,query:e.choice.query,sort:e.choice.sort,unused:x}),o=r.findIndex((h)=>h.file===e.choice.selected),l=e.grid?oe(He(e.grid).width):1,c=o===-1?r.length>0?0:null:se(o,t,l,r.length,i),s=c===null?void 0:r[c];if(!s)return;N(e,s.file),e.tiles.get(s.file)?.focus()}var ke=new WeakMap;function Se(e,t,i,a,r,o){let l={choice:t,disposed:!1,dropActive:!1,grid:null,handle:null,images:r,inputs:{replace:new Set,upload:new Set},mode:e,observer:bp((c)=>{let s=ke.get(c);if(s!==void 0&&!l.visible.has(s))l.visible.add(s),Xe(l)}),onPick:null,onSelect:null,paneId:a,reveal:null,focusOwed:!1,region:i,sweepTimer:null,tiles:new Map,uploadDir:o,visible:new Set};return l}var B=new Set;function Xe(e){if(B.has(e))return;B.add(e),queueMicrotask(()=>{B.delete(e),v(e)})}function cS(e,t){let i=M.get(e);return i!==void 0&&i.tabId===t.id&&i.wrap.isConnected&&i.mount.handle!==null&&i.mount.handle.attached()}function vw(e){let t=M.get(e);if(!t)return;X(t.mount),M.delete(e)}function _T(e,t){let{paneId:i,wrap:a}=e;if(cS(i,t))return;vw(i);let r=Se("manage",y,wi(i,"media-library"),i,!1,_a);if(S.add(r),be(),r.handle=q(a,Z(r),Me(r),{clear:!0}),M.set(i,{mount:r,tabId:t.id,wrap:a}),J.delete(i))Fe(r)}async function Fe(e){await e.handle?.ready,Le(e,!0)}function Le(e,t=e.focusOwed){if(!t||e.disposed)return;let{selected:i}=e.choice,a=(i===null?void 0:e.tiles.get(i))??[...e.tiles.values()].find((r)=>r.getAttribute("tabindex")==="0");if(a?.isConnected){e.focusOwed=!1,a.focus();return}e.focusOwed=!0}function ST(e){let t=M.get(e);if(t?.wrap.isConnected&&t.mount.handle?.attached()===!0){Fe(t.mount);return}J.add(e)}function $2(e){if(e.filter!==void 0)y.filter=e.filter;if(e.query!==void 0)y.query=e.query;if(e.select!==void 0){if(y.selected=e.select,y.filter!=="all")y.filter="all";y.query=""}b()}function J2(){let e=[...M.values()].map((t)=>xe(t.mount.inputs.upload)).find((t)=>t!==null)??null;if(e){ee(e);return}j={file:null,role:"upload"}}function Y2(e){$2({select:e});let t=null;for(let i of M.values())if(i.mount.choice.selected===e)t??=xe(i.mount.inputs.replace);if(t){ee(t);return}j={file:e,role:"replace"}}var O=null;function ye(e){let t=bw(e);return{blocked:t===null,confirmLabel:t?`Use ${t.name}`:e.images?"Use image":"Use file",headline:e.images?"Choose an image":"Choose media"}}function dS(){let e=O;if(O=null,e)X(e.mount),e.dialog.close()}function Z2(e){dS();let t={filter:e.images?"image":"all",query:"",selected:null,sort:"newest"},i=Se("pick",t,`${ft("dialog",V)}/library`,null,e.images,YL(u.value?.documentPath??null)),a=(o)=>{dS(),e.onPick(o.ref)};i.onPick=a,S.add(i),be();let r=ue({body:(o)=>{i.handle=q(o,Z(i),Me(i),{clear:!1})},closed:()=>{if(O?.mount===i)dS();else X(i)},confirm:()=>{let o=bw(i);if(o)a(o)},layer:tt("dialog"),view:ye(i)});i.onSelect=()=>r.update(ye(i)),O={dialog:r,mount:i}}function CT(){dS();for(let e of M.keys())vw(e);y.filter="all",y.query="",y.selected=null,y.sort="newest",j=null,J.clear(),Y()}
2
+ export{lS,K2,bw,L2,cS,vw,_T,ST,$2,J2,Y2,dS,Z2,CT};
3
3
 
4
- //# debugId=09B5C90CB8913C5864756E2164756E21
5
- //# sourceMappingURL=studio-qwdqwkj0.js.map
4
+ //# debugId=B7BE530774E796E364756E2164756E21
5
+ //# sourceMappingURL=studio-c4rcaftm.js.map
@@ -1,5 +1,5 @@
1
- import{Ae}from"./studio-fbhxxc5f.js";import{vt,Pc,qo,Wr}from"./studio-rj9eamf8.js";import{Vt,Xc,Xn,Vn,Se,di,We,m,Kr,fn,NC,Wm,wh,td}from"./studio-c05wdnt3.js";import{ne}from"./studio-43sd2mam.js";import{to,Ts,ol,h}from"./studio-d5grtb9e.js";import{At}from"./studio-gcxk20n7.js";import{oe}from"./studio-p4nrkvqr.js";var M_=["code","layout","component","diff","breakpoint","locale"],T={breakpoint:"design",code:"source",component:"design"},x={design:"Design",source:"Code"},k="Could not read this file's comparison against HEAD.";var Pu={breakpoint:"Same page at",code:"Code",component:"Component definition",diff:"Diff vs HEAD",layout:"Layout",locale:"Same page in"};function R(e){let t=fn(e)?.derived;if(!t)return null;let o=vt(t.sourcePaneId);if(!o)return{diffPath:null,kind:t.kind,media:null,mode:null,path:null,probePath:null,reason:"The pane this one follows has no document open.",select:null,status:"unavailable"};if(t.kind==="lens")return w(e,t,o);return S(e,t,o)}function w(e,t,o){let n={diffPath:null,kind:"lens",media:t.media,mode:t.mode,path:null,probePath:null,select:null};if(t.preset==="diff"){let i=o.documentPath;if(!p(i))return{...n,reason:"Nothing to compare — this file matches HEAD.",status:"unavailable"};if(t.diff?.filePath===i&&(t.diffRev===void 0||t.diffRev===h.git.rev))return{...n,reason:"",status:"ready"};if(u.get(e)?.failed&&u.get(e)?.path===i)return{...n,reason:k,status:"unavailable"};return{...n,diffPath:i,reason:"",status:"loading"}}if(t.preset==="code"&&Pc(o)==="source")return{...n,reason:"The pane this one follows is showing Code — one document has one editor.",status:"unavailable"};if(t.preset==="breakpoint"&&!P_(o).includes(t.media))return{...n,reason:`This document does not declare a "${t.media??"base"}" breakpoint.`,status:"unavailable"};return{...n,reason:"",status:"ready"}}function p(e){return h.git.status?.files.find((t)=>t.path===e&&(t.status==="M"||t.status==="A"||t.status==="U"))??null}function S(e,t,o){let n={diffPath:null,kind:"companion",media:null,mode:null};if(t.preset==="layout"){let a=h.layoutSelection,r=a?.layoutFile??ol(o.doc.document.$layout);return r===null?{...n,path:null,probePath:null,reason:"This page has no layout.",select:null,status:"unavailable"}:{...n,path:r,probePath:null,reason:"",select:a?a.layoutPath:null,status:"ready"}}if(t.preset==="locale"){let a=Ts(),r=o.documentPath===null||t.locale===null?null:Xc(o.documentPath,t.locale,a);if(r===null)return{...n,path:null,probePath:null,reason:"This document has no path in that locale.",select:null,status:"unavailable"};let l=c.get(e);if(l?.path!==r||l.exists===null)return{...n,path:null,probePath:r,reason:"",select:null,status:"loading"};if(!l.exists)return{...n,path:null,probePath:null,reason:`No ${Vt(t.locale)} copy of this document yet — `+"the Languages panel can create one.",select:null,status:"unavailable"};return{...n,path:r,probePath:null,reason:"",select:null,status:"ready"}}let i=_(o);if(i===null)return t.resolved===null?{...n,path:null,probePath:null,reason:"Select an element inside a component to see its definition.",select:null,status:"unavailable"}:{...n,path:null,probePath:null,reason:"",select:null,status:"ready"};return{...n,path:i,probePath:null,reason:"",select:null,status:"ready"}}function P_(e){let{sizeBreakpoints:t}=Wr(to(e.doc.document.$media));return[null,...t.map((o)=>o.name)]}function _(e){let[t]=e?.session.selection??[];if(!e||!t)return null;let o=e.doc.document,n=[...t];while(n){let i=oe(o,n),a=i?Ae.find((r)=>r.tagName===i.tagName):null;if(a?.path)return a.path;n=At(n)}return null}function F(e,t){if(t.sourcePaneId===e||!fn(t.sourcePaneId))throw RangeError(`pane "${e}" cannot derive from "${t.sourcePaneId}" — a derivation names `+"another pane that is in the grid");b(e,t)}function b(e,t){let o=fn(e);if(o)u.delete(e),c.delete(e),o.derived=t}function fE(e){b(e,null)}function d(e,t){let o=fn(e),n=o?.derived,i=R(e);if(!o||!n||!i)return;if(qo.derivedResolves+=1,n.status=i.status,n.reason=i.reason,n.kind==="lens"){let r=fn(n.sourcePaneId);if(o.tabOrder.length>0||o.activeTabId!==null){let l=[...o.tabOrder];for(let s of l)if(Wm(s),r)wh(r,s);o.activeTabId=null}if(n.preset==="diff"&&i.status!=="ready")n.diff=null;A(e,i,t);return}if(C(e,i,t),n.resolved!==null&&vt(e)===null)n.resolved=null;if(i.path===null||i.path===n.resolved){v(e,i);return}n.resolved=i.path,qo.derivedRetargets+=1;let a=t.openFileInPane(e,i.path);if(i.select===null)return;Promise.resolve(a).then(()=>{v(e,i)})}function v(e,t){let o=t.select,n=vt(e);if(!o||!n||t.path!==null&&n.documentPath!==t.path)return;let[i]=n.session.selection;if(i?.length===o.length&&i.every((a,r)=>a===o[r]))return;n.session.selection=[[...o]]}var u=new Map;function A(e,t,o){let n=t.diffPath,i=p(n),{rev:a}=h.git,r=u.get(e);if(n===null||!i||r?.path===n&&r.rev===a)return;u.set(e,{failed:!1,path:n,rev:a}),o.loadDiff(n,i.status).then((l)=>{let s=fn(e)?.derived;if(s?.kind!=="lens"||s.preset!=="diff"||u.get(e)?.path!==n)return;if(l)s.diff=l,s.diffRev=a;else u.set(e,{failed:!0,path:n,rev:a});d(e,o)}).catch((l)=>{console.error("loadDiff error:",l)})}var c=new Map;function C(e,t,o){let n=t.probePath;if(n===null||c.get(e)?.path===n)return;c.set(e,{exists:null,path:n}),o.fileExists(n).then((i)=>{let a=fn(e)?.derived;if(a?.kind!=="companion"||a.preset!=="locale"||c.get(e)?.path!==n)return;c.set(e,{exists:i,path:n}),d(e,o)}).catch((i)=>{console.error("fileExists error:",i)})}var f=new Map;function M(e,t){if(f.has(e))return;f.set(e,requestAnimationFrame(()=>{f.delete(e);try{d(e,t)}catch(o){console.error("applyDerivation error:",o)}}))}function cD(e,t){ne(()=>{let o=fn(e),n=o?.derived;if(!n)return;o.activeTabId;let i=vt(n.sourcePaneId);if(n.kind==="lens"&&n.preset==="code")i?.session.ui.canvasMode;if(n.kind==="companion"&&n.preset==="component")i?.session.selection;if(n.kind==="companion"&&n.preset==="layout")h.layoutSelection,i?.doc.document?.$layout;M(e,t)})}function Qy(e,t,o,n=null){let i=vt(t);if(!i)return"an open document";let a=T[e];if(a&&!i.capabilities.modes.includes(a))return`a document with a ${x[a]} view — this one declares none`;if(e==="code")return Pc(i)==="source"?"a source pane that is not already showing Code":null;if(e==="diff")return p(i.documentPath)===null?"a file with changes against HEAD":null;if(e==="breakpoint")return P_(i).includes(o)?null:"a breakpoint this document declares — see Project Settings › Contexts";if(e==="layout")return ol(i.doc.document.$layout)===null?"a page with a layout — this one declares none":null;if(e==="locale"){let r=Ts();if(r===null||r.locales.length<2)return"a project that declares more than one locale — see Project Settings › Locales";if(i.documentPath===null)return"a document that has been saved";return n!==null&&r.locales.includes(n)?null:"a locale this project declares"}return null}function Zg(e){let t=fn(e);return t&&t.activeTabId!==null&&t.derived===null?null:D}var D="an open document in a pane that is not itself derived";function O(e,t,o,n=null){if(e==="locale")return{kind:"companion",locale:n,preset:e,reason:"",resolved:null,sourcePaneId:t,status:"loading"};if(e==="layout"||e==="component")return{kind:"companion",preset:e,reason:"",resolved:null,sourcePaneId:t,status:"loading"};return{diff:null,kind:"lens",media:e==="breakpoint"?o:null,mode:e==="code"?"source":e==="diff"?"git-diff":"design",preset:e,reason:"",sourcePaneId:t,status:"loading",zoom:1}}function P(){return m.panes.find((e)=>mE(e.id)===null)??null}function mE(e){let t=fn(e);return t?.derived?.kind==="companion"&&t.activeTabId?null:y}var y="a derived pane showing a document of its own — Code, Diff and breakpoint views project "+"the document already open beside them";function dD(e){return[{args:Se({locale:We('BCP 47 tag for preset "locale". Ignored by every other preset.'),media:We('Breakpoint name for preset "breakpoint" — omit or leave empty for the base size. '+"Ignored by every other preset."),preset:di(M_,"Which projection of this pane's document to show beside it.")},["preset"]),id:"pane.derive",title:"Show Beside This…",category:"View",level:"document",menus:["context/pane"],group:"5_pane",when:(t)=>t.document.open,enablement:()=>Zg(Kr().id)===null,requires:D,undo:"none",run:(t,o)=>{let n=Vn("pane.derive",o,"preset",M_),i=Xn("pane.derive",o,"media")??null,a=Xn("pane.derive",o,"locale")??null,r=Kr(),l=Qy(n,r.id,i,a);if(l)throw RangeError(`command "pane.derive" argument "preset": "${n}" requires ${l}`);let s=NC(r.id);F(s.id,O(n,r.id,i,a));let E=[...s.tabOrder];for(let g of E)Wm(g),wh(r,g);d(s.id,e)}},{id:"pane.pin",title:"Keep This Document",category:"View",level:"document",menus:["context/pane","palette"],group:"5_pane",enablement:()=>P()!==null,requires:y,undo:"none",run:()=>{let t=P();if(!t?.activeTabId)return;td(t.activeTabId),fE(t.id)}}]}
2
- export{M_,Pu,P_,fE,cD,Qy,Zg,mE,dD};
1
+ import{Ne}from"./studio-v2ek69cb.js";import{vt,Ac,qo,zr}from"./studio-5abge3wy.js";import{Vt,Jc,Xn,Wn,Se,di,We,m,Gr,pn,TC,zm,wh,Xc}from"./studio-y1x65h5r.js";import{ne}from"./studio-hw60n5dh.js";import{eo,Es,ol,h}from"./studio-m4w6sygj.js";import{At}from"./studio-ana67wax.js";import{oe}from"./studio-gqpty626.js";var N_=["code","layout","component","diff","breakpoint","locale"],T={breakpoint:"design",code:"source",component:"design"},x={design:"Design",source:"Code"},k="Could not read this file's comparison against HEAD.";var Mu={breakpoint:"Same page at",code:"Code",component:"Component definition",diff:"Diff vs HEAD",layout:"Layout",locale:"Same page in"};function R(e){let t=pn(e)?.derived;if(!t)return null;let o=vt(t.sourcePaneId);if(!o)return{diffPath:null,kind:t.kind,media:null,mode:null,path:null,probePath:null,reason:"The pane this one follows has no document open.",select:null,status:"unavailable"};if(t.kind==="lens")return w(e,t,o);return S(e,t,o)}function w(e,t,o){let n={diffPath:null,kind:"lens",media:t.media,mode:t.mode,path:null,probePath:null,select:null};if(t.preset==="diff"){let i=o.documentPath;if(!p(i))return{...n,reason:"Nothing to compare — this file matches HEAD.",status:"unavailable"};if(t.diff?.filePath===i&&(t.diffRev===void 0||t.diffRev===h.git.rev))return{...n,reason:"",status:"ready"};if(u.get(e)?.failed&&u.get(e)?.path===i)return{...n,reason:k,status:"unavailable"};return{...n,diffPath:i,reason:"",status:"loading"}}if(t.preset==="code"&&Ac(o)==="source")return{...n,reason:"The pane this one follows is showing Code — one document has one editor.",status:"unavailable"};if(t.preset==="breakpoint"&&!A_(o).includes(t.media))return{...n,reason:`This document does not declare a "${t.media??"base"}" breakpoint.`,status:"unavailable"};return{...n,reason:"",status:"ready"}}function p(e){return h.git.status?.files.find((t)=>t.path===e&&(t.status==="M"||t.status==="A"||t.status==="U"))??null}function S(e,t,o){let n={diffPath:null,kind:"companion",media:null,mode:null};if(t.preset==="layout"){let a=h.layoutSelection,r=a?.layoutFile??ol(o.doc.document.$layout);return r===null?{...n,path:null,probePath:null,reason:"This page has no layout.",select:null,status:"unavailable"}:{...n,path:r,probePath:null,reason:"",select:a?a.layoutPath:null,status:"ready"}}if(t.preset==="locale"){let a=Es(),r=o.documentPath===null||t.locale===null?null:Jc(o.documentPath,t.locale,a);if(r===null)return{...n,path:null,probePath:null,reason:"This document has no path in that locale.",select:null,status:"unavailable"};let l=c.get(e);if(l?.path!==r||l.exists===null)return{...n,path:null,probePath:r,reason:"",select:null,status:"loading"};if(!l.exists)return{...n,path:null,probePath:null,reason:`No ${Vt(t.locale)} copy of this document yet — `+"the Languages panel can create one.",select:null,status:"unavailable"};return{...n,path:r,probePath:null,reason:"",select:null,status:"ready"}}let i=_(o);if(i===null)return t.resolved===null?{...n,path:null,probePath:null,reason:"Select an element inside a component to see its definition.",select:null,status:"unavailable"}:{...n,path:null,probePath:null,reason:"",select:null,status:"ready"};return{...n,path:i,probePath:null,reason:"",select:null,status:"ready"}}function A_(e){let{sizeBreakpoints:t}=zr(eo(e.doc.document.$media));return[null,...t.map((o)=>o.name)]}function _(e){let[t]=e?.session.selection??[];if(!e||!t)return null;let o=e.doc.document,n=[...t];while(n){let i=oe(o,n),a=i?Ne.find((r)=>r.tagName===i.tagName):null;if(a?.path)return a.path;n=At(n)}return null}function F(e,t){if(t.sourcePaneId===e||!pn(t.sourcePaneId))throw RangeError(`pane "${e}" cannot derive from "${t.sourcePaneId}" — a derivation names `+"another pane that is in the grid");b(e,t)}function b(e,t){let o=pn(e);if(o)u.delete(e),c.delete(e),o.derived=t}function lE(e){b(e,null)}function d(e,t){let o=pn(e),n=o?.derived,i=R(e);if(!o||!n||!i)return;if(qo.derivedResolves+=1,n.status=i.status,n.reason=i.reason,n.kind==="lens"){let r=pn(n.sourcePaneId);if(o.tabOrder.length>0||o.activeTabId!==null){let l=[...o.tabOrder];for(let s of l)if(zm(s),r)wh(r,s);o.activeTabId=null}if(n.preset==="diff"&&i.status!=="ready")n.diff=null;A(e,i,t);return}if(C(e,i,t),n.resolved!==null&&vt(e)===null)n.resolved=null;if(i.path===null||i.path===n.resolved){v(e,i);return}n.resolved=i.path,qo.derivedRetargets+=1;let a=t.openFileInPane(e,i.path);if(i.select===null)return;Promise.resolve(a).then(()=>{v(e,i)})}function v(e,t){let o=t.select,n=vt(e);if(!o||!n||t.path!==null&&n.documentPath!==t.path)return;let[i]=n.session.selection;if(i?.length===o.length&&i.every((a,r)=>a===o[r]))return;n.session.selection=[[...o]]}var u=new Map;function A(e,t,o){let n=t.diffPath,i=p(n),{rev:a}=h.git,r=u.get(e);if(n===null||!i||r?.path===n&&r.rev===a)return;u.set(e,{failed:!1,path:n,rev:a}),o.loadDiff(n,i.status).then((l)=>{let s=pn(e)?.derived;if(s?.kind!=="lens"||s.preset!=="diff"||u.get(e)?.path!==n)return;if(l)s.diff=l,s.diffRev=a;else u.set(e,{failed:!0,path:n,rev:a});d(e,o)}).catch((l)=>{console.error("loadDiff error:",l)})}var c=new Map;function C(e,t,o){let n=t.probePath;if(n===null||c.get(e)?.path===n)return;c.set(e,{exists:null,path:n}),o.fileExists(n).then((i)=>{let a=pn(e)?.derived;if(a?.kind!=="companion"||a.preset!=="locale"||c.get(e)?.path!==n)return;c.set(e,{exists:i,path:n}),d(e,o)}).catch((i)=>{console.error("fileExists error:",i)})}var f=new Map;function M(e,t){if(f.has(e))return;f.set(e,requestAnimationFrame(()=>{f.delete(e);try{d(e,t)}catch(o){console.error("applyDerivation error:",o)}}))}function oD(e,t){ne(()=>{let o=pn(e),n=o?.derived;if(!n)return;o.activeTabId;let i=vt(n.sourcePaneId);if(n.kind==="lens"&&n.preset==="code")i?.session.ui.canvasMode;if(n.kind==="companion"&&n.preset==="component")i?.session.selection;if(n.kind==="companion"&&n.preset==="layout")h.layoutSelection,i?.doc.document?.$layout;M(e,t)})}function Yy(e,t,o,n=null){let i=vt(t);if(!i)return"an open document";let a=T[e];if(a&&!i.capabilities.modes.includes(a))return`a document with a ${x[a]} view — this one declares none`;if(e==="code")return Ac(i)==="source"?"a source pane that is not already showing Code":null;if(e==="diff")return p(i.documentPath)===null?"a file with changes against HEAD":null;if(e==="breakpoint")return A_(i).includes(o)?null:"a breakpoint this document declares — see Project Settings › Contexts";if(e==="layout")return ol(i.doc.document.$layout)===null?"a page with a layout — this one declares none":null;if(e==="locale"){let r=Es();if(r===null||r.locales.length<2)return"a project that declares more than one locale — see Project Settings › Locales";if(i.documentPath===null)return"a document that has been saved";return n!==null&&r.locales.includes(n)?null:"a locale this project declares"}return null}function Yg(e){let t=pn(e);return t&&t.activeTabId!==null&&t.derived===null?null:D}var D="an open document in a pane that is not itself derived";function O(e,t,o,n=null){if(e==="locale")return{kind:"companion",locale:n,preset:e,reason:"",resolved:null,sourcePaneId:t,status:"loading"};if(e==="layout"||e==="component")return{kind:"companion",preset:e,reason:"",resolved:null,sourcePaneId:t,status:"loading"};return{diff:null,kind:"lens",media:e==="breakpoint"?o:null,mode:e==="code"?"source":e==="diff"?"git-diff":"design",preset:e,reason:"",sourcePaneId:t,status:"loading",zoom:1}}function P(){return m.panes.find((e)=>cE(e.id)===null)??null}function cE(e){let t=pn(e);return t?.derived?.kind==="companion"&&t.activeTabId?null:y}var y="a derived pane showing a document of its own — Code, Diff and breakpoint views project "+"the document already open beside them";function rD(e){return[{args:Se({locale:We('BCP 47 tag for preset "locale". Ignored by every other preset.'),media:We('Breakpoint name for preset "breakpoint" — omit or leave empty for the base size. '+"Ignored by every other preset."),preset:di(N_,"Which projection of this pane's document to show beside it.")},["preset"]),id:"pane.derive",title:"Show Beside This…",category:"View",level:"document",menus:["context/pane"],group:"5_pane",when:(t)=>t.document.open,enablement:()=>Yg(Gr().id)===null,requires:D,undo:"none",run:(t,o)=>{let n=Wn("pane.derive",o,"preset",N_),i=Xn("pane.derive",o,"media")??null,a=Xn("pane.derive",o,"locale")??null,r=Gr(),l=Yy(n,r.id,i,a);if(l)throw RangeError(`command "pane.derive" argument "preset": "${n}" requires ${l}`);let s=TC(r.id);F(s.id,O(n,r.id,i,a));let E=[...s.tabOrder];for(let g of E)zm(g),wh(r,g);d(s.id,e)}},{id:"pane.pin",title:"Keep This Document",category:"View",level:"document",menus:["context/pane","palette"],group:"5_pane",enablement:()=>P()!==null,requires:y,undo:"none",run:()=>{let t=P();if(!t?.activeTabId)return;Xc(t.activeTabId),lE(t.id)}}]}
2
+ export{N_,Mu,A_,lE,oD,Yy,Yg,cE,rD};
3
3
 
4
- //# debugId=A6470CE045DD17F264756E2164756E21
5
- //# sourceMappingURL=studio-mn0476ag.js.map
4
+ //# debugId=2E10ADFB9E239D9864756E2164756E21
5
+ //# sourceMappingURL=studio-c5dj3dzk.js.map
@@ -0,0 +1,5 @@
1
+ import{pt,Go,_r,Op}from"./studio-3q6n9qvq.js";function rb(){return Go(pt.cfToken)}function IE(t){_r(pt.cfToken,t||"")}function RE(){return Go(pt.cfAccountId)}function V2(t){_r(pt.cfAccountId,t||"")}function DE(){Op([pt.cfToken,pt.cfAccountId])}
2
+ export{rb,IE,RE,V2,DE};
3
+
4
+ //# debugId=EA0B6478FB85346B64756E2164756E21
5
+ //# sourceMappingURL=studio-cgjt1zce.js.map
@@ -1,5 +1,5 @@
1
- var s=new Set(["project.schema.json","document.schema.json"]);function dI(e){return s.has(e)?`file:///.jx/generated/${e}`:`file:///${e}`}function nM(e,r){return{head:`file:///.jx/diff/${e}/head/${r}`,work:`file:///.jx/diff/${e}/work/${r}`}}function iM(e){switch(e.slice(e.lastIndexOf(".")+1).toLowerCase()){case"cjs":case"js":case"mjs":return"javascript";case"css":return"css";case"htm":case"html":return"html";case"json":return"json";case"md":return"markdown";case"cts":case"mts":case"ts":return"typescript";case"yaml":case"yml":return"yaml";default:return"plaintext"}}
2
- export{dI,nM,iM};
1
+ var s=new Set(["project.schema.json","document.schema.json"]);function rI(e){return s.has(e)?`file:///.jx/generated/${e}`:`file:///${e}`}function ZO(e,r){return{head:`file:///.jx/diff/${e}/head/${r}`,work:`file:///.jx/diff/${e}/work/${r}`}}function XO(e){switch(e.slice(e.lastIndexOf(".")+1).toLowerCase()){case"cjs":case"js":case"mjs":return"javascript";case"css":return"css";case"htm":case"html":return"html";case"json":return"json";case"md":return"markdown";case"cts":case"mts":case"ts":return"typescript";case"yaml":case"yml":return"yaml";default:return"plaintext"}}
2
+ export{rI,ZO,XO};
3
3
 
4
- //# debugId=52A037696E21BDD764756E2164756E21
5
- //# sourceMappingURL=studio-bbe4c90a.js.map
4
+ //# debugId=2281401913969A9F64756E2164756E21
5
+ //# sourceMappingURL=studio-cpdzrdgp.js.map
@@ -0,0 +1,5 @@
1
+ import{p,_e}from"./studio-pr23qhrw.js";import{Q}from"./studio-nqxqf8p2.js";import{te}from"./studio-kt2j51sa.js";function ph(){return _e()&&te(p().findReferences)}function u(e){return`${e.path??""}\x00${e.tagName??""}`}var i=new Map,o=new Map;function Wd(e){if(!ph())return{status:"unsupported"};return i.get(u(e))??(o.has(u(e))?{status:"pending"}:null)}async function $a(e){if(!ph())return{status:"unsupported"};if(!e.path&&!e.tagName)return{status:"failed",message:"no target to look for"};let t=u(e),s=i.get(t);if(s)return s;let r=o.get(t);if(r)return r;let n={};if(e.path!==void 0)n.path=e.path;if(e.tagName!==void 0)n.tagName=e.tagName;let a=(async()=>{try{return{result:await p().findReferences(n),status:"ready"}}catch(c){return{message:Q(c),status:"failed"}}})();o.set(t,a);let d=f,l=await a;if(o.get(t)===a)o.delete(t);if(d!==f)return l;return i.set(t,l),l}function S$(e){return i.delete(u(e)),$a(e)}var f=0,g=new Set;function Cr(){f+=1,i.clear(),o.clear();for(let e of g)e()}function C$(e){return g.add(e),()=>{g.delete(e)}}function h(e){let t=0;for(let s of e.files)if(s.path.startsWith("pages/"))t+=1;return{others:e.files.length-t,pages:t}}function Kb(e){let{others:t,pages:s}=h(e);if(s===0&&t===0)return"Not used yet";let r=t===1?"file":"files";if(s===0)return`Used in ${t} ${r}`;let n=`Used on ${s} page${s===1?"":"s"}`;return t===0?n:`${n} and ${t} other ${r}`}function k$(e,t){if(e.status==="unsupported")return null;if(e.status==="pending")return"Counting references…";if(e.status==="failed")return`References could not be counted (${e.message}) — this may break more than it appears to.`;let{files:s,refsTotal:r}=e.result;if(s.length===0)return t==="delete"?"Nothing else in this project refers to it.":"Nothing else in this project refers to it, so nothing needs updating.";let n=`${r} reference${r===1?"":"s"} in ${s.length} file${s.length===1?"":"s"}`,a=e.result.errors.length>0?" (at least — some documents could not be read)":"";if(t==="delete")return`${n}${a} will break. Those files stay on disk; the references in them stop resolving.`;if(t==="convert")return`${n}${a} will be updated automatically to point at the new file.`;return`${n}${a} will be updated automatically. Nothing else changes.`}function Jb(e){return e.files.toSorted((t,s)=>s.count-t.count||t.path.localeCompare(s.path))}
2
+ export{ph,Wd,$a,S$,Cr,C$,Kb,k$,Jb};
3
+
4
+ //# debugId=08B1DB222A3D909764756E2164756E21
5
+ //# sourceMappingURL=studio-cq87hree.js.map
@@ -0,0 +1,5 @@
1
+ import{yh}from"./studio-y1x65h5r.js";import{fb}from"./studio-2dtc90zs.js";import{S}from"./studio-ana67wax.js";import{n,_}from"./studio-kt2j51sa.js";function VE(){return Object.keys(S?.projectConfig?.content??{})}function ya(e){let t=fb(e);if(!t)return null;if(/\.[a-z\d]+$/i.test(t.dir))return null;return{def:t.def,dir:t.dir,ext:t.ext,name:t.name,schema:t.def.schema??null}}function pw(){return VE().map((e)=>ya(e)).filter((e)=>e!==null)}function Rc(e){let t=yh(e??null,S?.projectConfig);return t?ya(t.name):null}function OD(e){let t=yh(e??null,S?.projectConfig),r=t?fb(t.name):null;if(!t||!r)return null;return{def:r.def,dir:r.dir,ext:r.ext,name:r.name,schema:t.schema}}function c(e){if(e===null||!_(e))return e;return JSON.parse(JSON.stringify(e))}function u(e){if(n(e.$ref))return"";switch(e.type){case"boolean":return!1;case"integer":case"number":return 0;case"array":return[];case"object":return UE(e);default:return""}}function UE(e){let t=e?.properties;if(!t)return{};let r=new Set(Array.isArray(e.required)?e.required:[]),o={};for(let[i,l]of Object.entries(t))if(l.default!==void 0)o[i]=c(l.default);else if(r.has(i))o[i]=u(l);return o}function MD(e,t){return(Array.isArray(e?.required)?e.required:[]).filter((o)=>t[o]===void 0)}
2
+ export{VE,ya,pw,Rc,OD,UE,MD};
3
+
4
+ //# debugId=1BB137D4B38DC27164756E2164756E21
5
+ //# sourceMappingURL=studio-d140sy8e.js.map