@jxsuite/studio 6.0.0 → 6.1.1

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 (208) hide show
  1. package/dist/chunks/2020-va2wwra4.js +4 -0
  2. package/dist/chunks/adapter-f93pafd7.js +4 -0
  3. package/dist/chunks/{cf-account-picker-bb2yq946.js → cf-account-picker-af1h381v.js} +3 -3
  4. package/dist/chunks/cf-settings-125tdm0w.js +4 -0
  5. package/dist/chunks/components-ax2f1fnn.js +4 -0
  6. package/dist/chunks/content-source-108aqtk1.js +4 -0
  7. package/dist/chunks/{convert-to-repeater-vqkt7s3s.js → convert-to-repeater-ry5rmppr.js} +3 -3
  8. package/dist/chunks/editor-pfgdmkb0.js +4 -0
  9. package/dist/chunks/entry-commands-t0k1q0kx.js +4 -0
  10. package/dist/chunks/{extension-sections-8beq9ac3.js → extension-sections-6mwh2hf8.js} +3 -3
  11. package/dist/chunks/file-ops-meej5mqf.js +4 -0
  12. package/dist/chunks/files-44vp8a2s.js +4 -0
  13. package/dist/chunks/format-host-7q1petb9.js +4 -0
  14. package/dist/chunks/fs-events-h2mwnxaz.js +4 -0
  15. package/dist/chunks/git-panel-zngbymvd.js +4 -0
  16. package/dist/chunks/{grid-view-ca10def6.js → grid-view-sx9vynsp.js} +15 -15
  17. package/dist/chunks/icons-p44xhjf0.js +4 -0
  18. package/dist/chunks/iframe-host-qk3ycq87.js +4 -0
  19. package/dist/chunks/{index-9ydfe04y.js → index-2veqmnhr.js} +3 -3
  20. package/dist/chunks/index-wkyfjeqz.js +4 -0
  21. package/dist/chunks/{javascript-d9pqgc2p.js → javascript-8nbvs12s.js} +3 -3
  22. package/dist/chunks/jsonMode-s8kt9dsj.js +13 -0
  23. package/dist/chunks/jx-validate-psgd7vsx.js +4 -0
  24. package/dist/chunks/layers-panel-1kq2jyfk.js +4 -0
  25. package/dist/chunks/layers-xd92fg8d.js +4 -0
  26. package/dist/chunks/lit-html-ac4cwwr4.js +4 -0
  27. package/dist/chunks/media-picker-0svzkdyb.js +4 -0
  28. package/dist/chunks/menu-5c55ea3d.js +4 -0
  29. package/dist/chunks/{monaco-binding-62dtmgbf.js → monaco-binding-z6r70pdt.js} +3 -3
  30. package/dist/chunks/monaco-buffer-fz6gq5y7.js +4 -0
  31. package/dist/chunks/monaco-setup-q4axkgj7.js +4 -0
  32. package/dist/chunks/notify-0xgtn8q1.js +4 -0
  33. package/dist/chunks/platform-v1qctbe6.js +4 -0
  34. package/dist/chunks/publish-panel-ym1fmgq5.js +4 -0
  35. package/dist/chunks/quick-search-a54e6t5n.js +4 -0
  36. package/dist/chunks/references-gmqp82fs.js +4 -0
  37. package/dist/chunks/right-panel-v7t9awbk.js +4 -0
  38. package/dist/chunks/section-registry-vhyf3zsr.js +4 -0
  39. package/dist/chunks/studio-0bhx5hz6.js +5 -0
  40. package/dist/chunks/studio-0k1ddnyy.js +6 -0
  41. package/dist/chunks/studio-1b04pd0j.js +64 -0
  42. package/dist/chunks/{studio-sxc0zvpt.js → studio-1q1sh2ax.js} +3 -3
  43. package/dist/chunks/studio-4dwbj6gb.js +5 -0
  44. package/dist/chunks/studio-4tanh828.js +5 -0
  45. package/dist/chunks/{studio-fqq890ap.js → studio-55h4mstj.js} +3 -3
  46. package/dist/chunks/studio-5tnvjkz4.js +5 -0
  47. package/dist/chunks/studio-60dqgb0c.js +5 -0
  48. package/dist/chunks/studio-61dp09qg.js +9 -0
  49. package/dist/chunks/studio-63epcrj2.js +5 -0
  50. package/dist/chunks/studio-74k29dy9.js +5 -0
  51. package/dist/chunks/{studio-qa73881a.js → studio-7vg6jcd3.js} +4 -4
  52. package/dist/chunks/studio-7zx31knw.js +9 -0
  53. package/dist/chunks/studio-8bxk97km.js +5 -0
  54. package/dist/chunks/{studio-edbtvcd1.js → studio-8grwxtqk.js} +4 -4
  55. package/dist/chunks/studio-933e30n4.js +5 -0
  56. package/dist/chunks/{studio-rr4xkv81.js → studio-98wnwhbg.js} +4 -4
  57. package/dist/chunks/studio-9mccjwjh.js +14 -0
  58. package/dist/chunks/studio-a2ke1e4t.js +5 -0
  59. package/dist/chunks/studio-e3a2a6v3.js +4 -0
  60. package/dist/chunks/{studio-pwqfmt4p.js → studio-e81q1vb9.js} +4 -4
  61. package/dist/chunks/{studio-7pgy3xaf.js → studio-epgrmqqm.js} +4 -4
  62. package/dist/chunks/studio-g1shz58g.js +5 -0
  63. package/dist/chunks/studio-gf0fz03c.js +5 -0
  64. package/dist/chunks/studio-gjtpe62q.js +6 -0
  65. package/dist/chunks/{studio-tzegmy4w.js → studio-gkskhg7m.js} +4 -4
  66. package/dist/chunks/studio-gx4dnjzd.js +5 -0
  67. package/dist/chunks/{studio-8xcwewjq.js → studio-h46vtzk8.js} +4 -4
  68. package/dist/chunks/studio-j03zga3y.js +9 -0
  69. package/dist/chunks/{studio-4r0sjtx8.js → studio-jhpxeckz.js} +4 -4
  70. package/dist/chunks/{studio-zd4kayn2.js → studio-k01r7ykp.js} +4 -4
  71. package/dist/chunks/{studio-03wwfvyt.js → studio-kggey1jt.js} +4 -4
  72. package/dist/chunks/{studio-hnvnfbdv.js → studio-kk7h30ne.js} +6 -6
  73. package/dist/chunks/{studio-01qza1n3.js → studio-kt1zqney.js} +4 -4
  74. package/dist/chunks/{studio-r3kaka4d.js → studio-m3cwhvye.js} +4 -4
  75. package/dist/chunks/{studio-evwgp1ym.js → studio-mcayt6hz.js} +4 -4
  76. package/dist/chunks/{studio-5vy2wfm5.js → studio-myjcghv3.js} +4 -4
  77. package/dist/chunks/studio-n8bxwc3y.js +4 -0
  78. package/dist/chunks/{studio-ztvcxm3w.js → studio-ngm8gvpb.js} +4 -4
  79. package/dist/chunks/{studio-01kbbqg3.js → studio-nj5a01jy.js} +196 -196
  80. package/dist/chunks/{studio-xkfs0dp2.js → studio-pcgz8heb.js} +4 -4
  81. package/dist/chunks/{studio-0bbxhhce.js → studio-pre0skq6.js} +4 -4
  82. package/dist/chunks/{studio-n78gjfy8.js → studio-qcsq0t15.js} +4 -4
  83. package/dist/chunks/studio-qkstvve9.js +5 -0
  84. package/dist/chunks/studio-qv1pwd3c.js +5 -0
  85. package/dist/chunks/{studio-rmn2dz59.js → studio-rc6dvxjb.js} +5 -5
  86. package/dist/chunks/{studio-st75kn99.js → studio-rv11kfwa.js} +7 -7
  87. package/dist/chunks/studio-s8dmmz66.js +5 -0
  88. package/dist/chunks/studio-sp5xzbj4.js +6 -0
  89. package/dist/chunks/{studio-tmeq6mjb.js → studio-szsjbj0g.js} +4 -4
  90. package/dist/chunks/studio-t1xzawhr.js +16 -0
  91. package/dist/chunks/{studio-mk00zd5d.js → studio-t6b6qe31.js} +4 -4
  92. package/dist/chunks/{studio-bftp4n4b.js → studio-tdcprbqb.js} +4 -4
  93. package/dist/chunks/{studio-ge5fqjth.js → studio-vrmcjf9g.js} +5 -5
  94. package/dist/chunks/studio-vyc0b4he.js +10 -0
  95. package/dist/chunks/{studio-semd1s8s.js → studio-w0cgf6jg.js} +4 -4
  96. package/dist/chunks/{studio-gp02nqnw.js → studio-w3hskzqk.js} +4 -4
  97. package/dist/chunks/{studio-1wvfxkyy.js → studio-wszjyh0j.js} +4 -4
  98. package/dist/chunks/studio-xgrgcdyh.js +9 -0
  99. package/dist/chunks/{studio-y7jehjrp.js → studio-xz2yxfcb.js} +4 -4
  100. package/dist/chunks/{studio-aje966s9.js → studio-y6n42tgs.js} +4 -4
  101. package/dist/chunks/{studio-yr04mv2j.js → studio-yb560vxr.js} +4 -4
  102. package/dist/chunks/{studio-tp642n5g.js → studio-yn9f8vtx.js} +4 -4
  103. package/dist/chunks/studio-yw05w8f0.js +7 -0
  104. package/dist/chunks/{studio-cbr9czkn.js → studio-z16sgavc.js} +4 -4
  105. package/dist/chunks/studio-zey7zsdw.js +12 -0
  106. package/dist/chunks/{studio-1q6amtph.js → studio-zyqn40w4.js} +4 -4
  107. package/dist/chunks/tsMode-2frah6h1.js +14 -0
  108. package/dist/chunks/workspace-zt81g1ms.js +4 -0
  109. package/dist/chunks/ws-client-n2bh4hkf.js +4 -0
  110. package/dist/iframe-entry.js +13 -13
  111. package/dist/manifest.json +62 -62
  112. package/dist/studio.js +87 -87
  113. package/dist/workers/ts.worker.js +3 -3
  114. package/package.json +10 -10
  115. package/src/canvas/canvas-render.ts +4 -1
  116. package/src/canvas/canvas-utils.ts +73 -15
  117. package/src/canvas/iframe-host.ts +67 -21
  118. package/src/canvas/iframe-inline-edit.ts +22 -4
  119. package/src/canvas/iframe-interaction.ts +7 -1
  120. package/src/canvas/iframe-protocol.ts +3 -0
  121. package/src/canvas/iframe-render.ts +5 -2
  122. package/src/commands/defaults.ts +4 -1
  123. package/src/commands/live-context.ts +3 -1
  124. package/src/editor/shortcuts.ts +55 -27
  125. package/src/files/media-paths.ts +3 -1
  126. package/src/new-project/add-repo-modal.ts +459 -59
  127. package/src/panels/editors.ts +3 -1
  128. package/src/panels/style-panel.ts +36 -11
  129. package/src/platforms/cloud.ts +95 -18
  130. package/src/platforms/devserver.ts +47 -12
  131. package/src/publish/pages-service.ts +7 -0
  132. package/src/publish/publish-panel.ts +16 -2
  133. package/src/studio.ts +14 -2
  134. package/src/surfaces/add-repo.json +721 -224
  135. package/src/surfaces/add-repo.ts +196 -31
  136. package/src/surfaces/library-pane.ts +6 -0
  137. package/src/surfaces/rail.json +126 -73
  138. package/src/surfaces/rail.ts +31 -5
  139. package/src/tabs/typing.ts +31 -0
  140. package/src/types.ts +42 -3
  141. package/src/utils/edit-display.ts +30 -1
  142. package/src/utils/project-dir.ts +24 -0
  143. package/src/workspace/workspace.ts +7 -0
  144. package/dist/chunks/2020-cs2sb9t1.js +0 -4
  145. package/dist/chunks/adapter-y5gdq19c.js +0 -4
  146. package/dist/chunks/cf-settings-20dznc3j.js +0 -4
  147. package/dist/chunks/components-q037dya7.js +0 -4
  148. package/dist/chunks/content-source-t0q184js.js +0 -4
  149. package/dist/chunks/editor-j5sq149q.js +0 -4
  150. package/dist/chunks/entry-commands-fxzgcc4k.js +0 -4
  151. package/dist/chunks/file-ops-2n77759h.js +0 -4
  152. package/dist/chunks/files-fjy7zpxt.js +0 -4
  153. package/dist/chunks/format-host-wj3mf3n8.js +0 -4
  154. package/dist/chunks/fs-events-7kcgn4e9.js +0 -4
  155. package/dist/chunks/git-panel-7z2mpt2d.js +0 -4
  156. package/dist/chunks/icons-qbh8akb1.js +0 -4
  157. package/dist/chunks/iframe-host-a0zjd6xp.js +0 -4
  158. package/dist/chunks/index-m0x5ztax.js +0 -4
  159. package/dist/chunks/jsonMode-800yvbem.js +0 -13
  160. package/dist/chunks/jx-validate-zc9zp77s.js +0 -4
  161. package/dist/chunks/layers-p677nrh5.js +0 -4
  162. package/dist/chunks/layers-panel-y4w1dq90.js +0 -4
  163. package/dist/chunks/lit-html-cfn61dn7.js +0 -4
  164. package/dist/chunks/media-picker-xg7yjpz9.js +0 -4
  165. package/dist/chunks/menu-fpekzj6w.js +0 -4
  166. package/dist/chunks/monaco-buffer-nn4dtx27.js +0 -4
  167. package/dist/chunks/monaco-setup-tj13ndtm.js +0 -4
  168. package/dist/chunks/notify-ahs57a2z.js +0 -4
  169. package/dist/chunks/platform-v9xyfkbx.js +0 -4
  170. package/dist/chunks/publish-panel-xtbfgg2r.js +0 -4
  171. package/dist/chunks/quick-search-d3a6m7j3.js +0 -4
  172. package/dist/chunks/references-99ws0b0m.js +0 -4
  173. package/dist/chunks/right-panel-31vbk5xp.js +0 -4
  174. package/dist/chunks/section-registry-b2yzp9sw.js +0 -4
  175. package/dist/chunks/studio-1a99w39s.js +0 -5
  176. package/dist/chunks/studio-3ck2a5c4.js +0 -10
  177. package/dist/chunks/studio-4fde4a0x.js +0 -5
  178. package/dist/chunks/studio-4jj9gme2.js +0 -6
  179. package/dist/chunks/studio-4m50vh74.js +0 -16
  180. package/dist/chunks/studio-4xppwncr.js +0 -4
  181. package/dist/chunks/studio-5d7wfmnp.js +0 -5
  182. package/dist/chunks/studio-5e9zsamh.js +0 -9
  183. package/dist/chunks/studio-5gs9th4b.js +0 -5
  184. package/dist/chunks/studio-7qvs7v0m.js +0 -5
  185. package/dist/chunks/studio-84rtc120.js +0 -5
  186. package/dist/chunks/studio-aekhcdzw.js +0 -7
  187. package/dist/chunks/studio-aqmph6k4.js +0 -5
  188. package/dist/chunks/studio-c6zdm25z.js +0 -9
  189. package/dist/chunks/studio-capk0583.js +0 -9
  190. package/dist/chunks/studio-chdmwwzw.js +0 -5
  191. package/dist/chunks/studio-cp1gbff9.js +0 -14
  192. package/dist/chunks/studio-cqmtbg2p.js +0 -5
  193. package/dist/chunks/studio-e47215hh.js +0 -5
  194. package/dist/chunks/studio-fbx6twps.js +0 -6
  195. package/dist/chunks/studio-fthwn4kf.js +0 -5
  196. package/dist/chunks/studio-g8dsj3d2.js +0 -6
  197. package/dist/chunks/studio-gjknvzam.js +0 -9
  198. package/dist/chunks/studio-hjbg8d5y.js +0 -12
  199. package/dist/chunks/studio-nbxqcgvf.js +0 -5
  200. package/dist/chunks/studio-t1eedsyx.js +0 -4
  201. package/dist/chunks/studio-vavmwshr.js +0 -5
  202. package/dist/chunks/studio-x5g1xk77.js +0 -5
  203. package/dist/chunks/studio-x92tgnee.js +0 -64
  204. package/dist/chunks/studio-xg1942as.js +0 -5
  205. package/dist/chunks/studio-zev8ssp1.js +0 -5
  206. package/dist/chunks/tsMode-k9s9fcag.js +0 -14
  207. package/dist/chunks/workspace-5vmgsagj.js +0 -4
  208. package/dist/chunks/ws-client-0ja08haa.js +0 -4
@@ -0,0 +1,5 @@
1
+ import{te}from"./studio-ery42sqr.js";import{p,Ve}from"./studio-xz2yxfcb.js";import{C}from"./studio-55h4mstj.js";import{u}from"./studio-a2ke1e4t.js";import{Zp,hi,eg}from"./studio-zyqn40w4.js";import{Ao,Im,DL}from"./studio-pcgz8heb.js";import{e1,by,jx,t1,$m}from"./studio-74k29dy9.js";import{D}from"./studio-yn9f8vtx.js";var Ul=new Set([".jpg",".jpeg",".png",".gif",".svg",".webp",".avif",".ico"]),Hd=new Set([...Ul,".mp4",".webm",".mp3",".wav",".ogg",".pdf",".woff",".woff2",".ttf",".otf"]);function m(e){let t=["B","KB","MB","GB"],n=e,r=0;while(n>=1024&&r<t.length-1)n/=1024,r+=1;return`${r===0?n:Number(n.toFixed(1))} ${t[r]}`}var h=["image/*","video/*","audio/*",".pdf",".svg",".woff",".woff2",".ttf",".otf"].join(",");function Oc(){return(Ve()?p().assetCapabilities?.accept:void 0)??h}function Ji(e){let t=e.lastIndexOf(".");return t>0?e.slice(t).toLowerCase():""}function gy(e){return Ul.has(e.startsWith(".")?e.toLowerCase():`.${e.toLowerCase()}`)}function Tm(e){return Hd.has(Ji(e))}var x=new Set([".mp4",".webm",".mov",".m4v"]),w=new Set([".mp3",".wav",".ogg",".m4a",".flac"]);function Tp(e){let t=e.type??"";if(t.startsWith("image/"))return"image";if(t.startsWith("video/"))return"video";if(t.startsWith("audio/"))return"audio";let n=Ji(e.name);if(Ul.has(n))return"image";if(x.has(n))return"video";if(w.has(n))return"audio";return"file"}var S=/^content\/([^/]+)\//;function v(e){let t=e?S.exec(e.replaceAll("\\","/")):null;return t?`content/${t[1]}/images`:"public"}function A(e){let t=e.replaceAll("\\","/");if(t.startsWith("public/"))return t.slice(6);let n=/^content\/[^/]+\/(.+)$/.exec(t);if(n)return`./${n[1]}`;return`./${t}`}function b(e,t){if(!t.has(e))return e;let n=Ji(e),r=n?e.slice(0,-n.length):e;for(let i=1;;i++){let s=`${r}-${i}${n}`;if(!t.has(s))return s}}function y(e,t){let n=e.replaceAll("\\","/").replace(/\/+$/,"");return n==="."||n===""?t:`${n}/${t}`}var g=null;function RL(e){g=e}async function tl(e,t={}){let n=[...e];if(n.length===0)return[];let r=p(),i=t.dir??v(u.value?.documentPath??null),s;try{let o=await Ao(()=>r.listDirectory(i));s=new Set(o.map((c)=>c.name))}catch{s=new Set}let f=Ve()?p().assetCapabilities?.maxUploadBytes:void 0,a=[];for(let o of n){if(f!==void 0&&o.size>f){C.error(`${o.name} is too large.`,{detail:`This backend accepts at most ${m(f)}; that file is ${m(o.size)}.`,source:"Media"});continue}let c=b(o.name,s);s.add(c);let d=y(i,c);try{let{path:l}=await r.uploadFile(d,o);Im([l]),a.push({kind:Tp(o),name:c,path:l,ref:A(l)})}catch(l){C.error(`Could not upload ${o.name}.`,{detail:te(l),path:d,source:"Media"})}}if(a.length>0)C.success(a.length===1?`Uploaded ${a[0].name} to ${i}/`:`Uploaded ${a.length} files to ${i}/`),await g?.(i);return a}function $L(e){let t=hi(e),n=t.lastIndexOf("/");return n===-1?t:t.slice(n+1)}function IL(e){let t=hi(e),n=t.lastIndexOf("/");return n===-1?".":t.slice(0,n)}function E(){return D?.projectConfig?.content??null}function I(e){return by(e,E(),t1())}function N(e,t){return`${hi(t.urlPrefix)}/${e.slice(t.dir.length+1)}`}function Bd(e){let t=hi(e);if(t.startsWith(`${Zp}/`))return`/${t.slice(Zp.length+1)}`;let n=I(t);return n?`/${N(t,n)}`:`/${t}`}function th(e){let t=hi(e);if(t==="")return e;let{space:n,fileBaseUrl:r}=$m();if(n==="repo")return e1(`${r}${eg(t)}`,DL(t));return jx(`/${eg(Bd(t).slice(1))}`)}
2
+ export{Ul,Hd,Oc,Ji,gy,Tm,Tp,RL,tl,$L,IL,Bd,th};
3
+
4
+ //# debugId=E77B97B20720E00564756E2164756E21
5
+ //# sourceMappingURL=studio-gx4dnjzd.js.map
@@ -1,5 +1,5 @@
1
- import{_k}from"./studio-cp1gbff9.js";import{T,R,vs,Nm}from"./studio-7qvs7v0m.js";import{v}from"./studio-fqq890ap.js";import{Oe}from"./studio-vavmwshr.js";var w={$schema:"https://jxsuite.com/schema/v1",$id:"StudioMenu",$description:"A Studio menu: one jx-menu whose rows are a projection of command records the adapter hands in as `rows`. Nothing here decides what a row says; a row prints its record's title, chord, disabled reason and destructive flag, a divider falls where the adapter marked a group boundary, and a row with children owns a one-level submenu of the same shape. The chord and the reason are rendered only when present, so a row's text is its title.",tagName:"jx-menu",$props:{label:{$ref:"#/state/label"},x:{$ref:"#/state/x"},y:{$ref:"#/state/y"},floor:{$ref:"#/state/floor"},placement:{$ref:"#/state/placement"}},onselect:{$ref:"#/state/select"},children:[{$prototype:"Array",items:{$ref:"#/state/rows"},key:{$ref:"$map/item/id"},map:{tagName:"div",attributes:{role:"none"},children:[{tagName:"div",attributes:{role:"none"},$switch:{$ref:"$map/item/dividerAbove"},cases:{true:{tagName:"hr"}}},{tagName:"jx-menu-item",$props:{value:{$ref:"$map/item/id"},disabled:{$ref:"$map/item/disabled"},destructive:{$ref:"$map/item/destructive"},requires:{$ref:"$map/item/requires"},checked:{$ref:"$map/item/checked"},haspopup:{$ref:"$map/item/haspopup"}},attributes:{"data-command-id":"${$map.item.id}"},children:[{tagName:"span",textContent:"${$map.item.title}"},{tagName:"span",attributes:{slot:"value"},$switch:{$ref:"$map/item/noChord"},cases:{false:{tagName:"kbd",textContent:"${$map.item.chord}"}}},{tagName:"span",attributes:{slot:"description"},$switch:{$ref:"$map/item/enabled"},cases:{false:{tagName:"span",textContent:"Needs ${$map.item.requires}"}}},{tagName:"span",attributes:{slot:"submenu"},$switch:{$ref:"$map/item/haspopup"},cases:{true:{tagName:"jx-menu",$props:{label:{$ref:"$map/item/submenuLabel"}},children:[{$prototype:"Array",items:{$ref:"$map/item/children"},key:{$ref:"$map/item/id"},map:{tagName:"div",attributes:{role:"none"},children:[{tagName:"div",attributes:{role:"none"},$switch:{$ref:"$map/item/dividerAbove"},cases:{true:{tagName:"hr"}}},{tagName:"jx-menu-item",$props:{value:{$ref:"$map/item/id"},disabled:{$ref:"$map/item/disabled"},destructive:{$ref:"$map/item/destructive"},requires:{$ref:"$map/item/requires"},checked:{$ref:"$map/item/checked"}},attributes:{"data-command-id":"${$map.item.id}"},children:[{tagName:"span",textContent:"${$map.item.title}"},{tagName:"span",attributes:{slot:"value"},$switch:{$ref:"$map/item/noChord"},cases:{false:{tagName:"kbd",textContent:"${$map.item.chord}"}}},{tagName:"span",attributes:{slot:"description"},$switch:{$ref:"$map/item/enabled"},cases:{false:{tagName:"span",textContent:"Needs ${$map.item.requires}"}}}]}]}}]}}}]}]}}]};T("menu",w);var M="block-end span-inline-end";function j(e){if(e.placement!==void 0)return e.placement;return e.opener&&!e.origin&&!e.place&&!e.floor?M:""}function E(e){if(!e)return{x:0,y:0};let n=Oe(e);return{x:Math.round(n.left),y:Math.round(n.bottom)}}function p(e,n=0){let r=n===0?(e.children??[]).map((t)=>p(t,1)):[];return{...e,checked:e.checked??"",children:r,chord:e.chord??"",enabled:!e.disabled,haspopup:r.length>0,noChord:!e.chord,noDivider:!e.dividerAbove,requires:e.requires??"",submenuLabel:e.submenuLabel??e.title}}function N(e,n){for(let r of e){if(r.id===n)return r;let t=r.children.find((d)=>d.id===n);if(t)return t}return}var L={bottom:0,height:0,left:0,right:0,top:0,width:0,x:0,y:0};function Nt(e){let n=vs("popover",e.region),r=new AbortController,t=null,d=null,i=!1,f=()=>{if(i)return;i=!0,r.abort(),d?.(),d=null,Nm("popover",e.region),P(e.opener??null),e.onClosed?.(u)},h=e.place?e.place(L):e.origin??E(e.opener),l=v({floor:e.floor?.()??0,label:e.label,placement:j(e),rows:e.rows.map((o)=>p(o)),select:(o,m)=>{let a=String(m.detail),s=N(l.rows,a);if(!s)return;if(s.run)s.run();else e.run?.(a);u.close()},x:h.x,y:h.y}),b=()=>{if(i||!t||!e.place)return;let o=e.place(Oe(t));l.x=o.x,l.y=o.y},y=(async()=>{let o=await R("menu",l,n,{signal:r.signal});if(r.signal.aborted)return;if({dispose:d}=o,t=o.root,t.addEventListener("toggle",(a)=>{if(a.newState==="closed")f()}),!t.hasAttribute("popover"))await new Promise((a)=>{t.addEventListener("jx-ready",()=>a(),{once:!0})});if(r.signal.aborted)return;let m=e.opener instanceof HTMLElement&&e.opener!==document.body?e.opener:void 0;t.showPopover(m?{source:m}:void 0),b(),requestAnimationFrame(b)})(),u={close:()=>{if(i)return;if(t?.open)t.hidePopover();f()},host:n,ready:y,setRows:(o)=>{if(i)return;let a=document.activeElement?.closest("jx-menu"),s=a&&a!==t?a.parentElement?.closest("jx-menu-item")?.dataset.commandId:void 0;l.rows=o.map((c)=>p(c)),setTimeout(()=>{if(i||!t||t.contains(document.activeElement))return;let c=s?t.querySelector(`jx-menu-item[data-command-id="${s}"]`):null,g=c?.querySelector("jx-menu")??null;if(c&&!(g?.open&&g.querySelector("jx-menu-item")))c.focus();else _k(t)},0)}};return u}function P(e){let n=document.activeElement;if(e?.isConnected&&(!n||n===document.body))e.focus()}
2
- export{Nt};
1
+ import{j1}from"./studio-9mccjwjh.js";import{T,I,Cs,Km}from"./studio-g1shz58g.js";import{y}from"./studio-55h4mstj.js";import{Ie}from"./studio-0bhx5hz6.js";var v={$schema:"https://jxsuite.com/schema/v1",$id:"StudioMenu",$description:"A Studio menu: one jx-menu whose rows are a projection of command records the adapter hands in as `rows`. Nothing here decides what a row says; a row prints its record's title, chord, disabled reason and destructive flag, a divider falls where the adapter marked a group boundary, and a row with children owns a one-level submenu of the same shape. The chord and the reason are rendered only when present, so a row's text is its title.",tagName:"jx-menu",$props:{label:{$ref:"#/state/label"},x:{$ref:"#/state/x"},y:{$ref:"#/state/y"},floor:{$ref:"#/state/floor"},placement:{$ref:"#/state/placement"}},onselect:{$ref:"#/state/select"},children:[{$prototype:"Array",items:{$ref:"#/state/rows"},key:{$ref:"$map/item/id"},map:{tagName:"div",attributes:{role:"none"},children:[{tagName:"div",attributes:{role:"none"},$switch:{$ref:"$map/item/dividerAbove"},cases:{true:{tagName:"hr"}}},{tagName:"jx-menu-item",$props:{value:{$ref:"$map/item/id"},disabled:{$ref:"$map/item/disabled"},destructive:{$ref:"$map/item/destructive"},requires:{$ref:"$map/item/requires"},checked:{$ref:"$map/item/checked"},haspopup:{$ref:"$map/item/haspopup"}},attributes:{"data-command-id":"${$map.item.id}"},children:[{tagName:"span",textContent:"${$map.item.title}"},{tagName:"span",attributes:{slot:"value"},$switch:{$ref:"$map/item/noChord"},cases:{false:{tagName:"kbd",textContent:"${$map.item.chord}"}}},{tagName:"span",attributes:{slot:"description"},$switch:{$ref:"$map/item/enabled"},cases:{false:{tagName:"span",textContent:"Needs ${$map.item.requires}"}}},{tagName:"span",attributes:{slot:"submenu"},$switch:{$ref:"$map/item/haspopup"},cases:{true:{tagName:"jx-menu",$props:{label:{$ref:"$map/item/submenuLabel"}},children:[{$prototype:"Array",items:{$ref:"$map/item/children"},key:{$ref:"$map/item/id"},map:{tagName:"div",attributes:{role:"none"},children:[{tagName:"div",attributes:{role:"none"},$switch:{$ref:"$map/item/dividerAbove"},cases:{true:{tagName:"hr"}}},{tagName:"jx-menu-item",$props:{value:{$ref:"$map/item/id"},disabled:{$ref:"$map/item/disabled"},destructive:{$ref:"$map/item/destructive"},requires:{$ref:"$map/item/requires"},checked:{$ref:"$map/item/checked"}},attributes:{"data-command-id":"${$map.item.id}"},children:[{tagName:"span",textContent:"${$map.item.title}"},{tagName:"span",attributes:{slot:"value"},$switch:{$ref:"$map/item/noChord"},cases:{false:{tagName:"kbd",textContent:"${$map.item.chord}"}}},{tagName:"span",attributes:{slot:"description"},$switch:{$ref:"$map/item/enabled"},cases:{false:{tagName:"span",textContent:"Needs ${$map.item.requires}"}}}]}]}}]}}}]}]}}]};T("menu",v);var M="block-end span-inline-end";function j(e){if(e.placement!==void 0)return e.placement;return e.opener&&!e.origin&&!e.place&&!e.floor?M:""}function E(e){if(!e)return{x:0,y:0};let n=Ie(e);return{x:Math.round(n.left),y:Math.round(n.bottom)}}function p(e,n=0){let r=n===0?(e.children??[]).map((t)=>p(t,1)):[];return{...e,checked:e.checked??"",children:r,chord:e.chord??"",enabled:!e.disabled,haspopup:r.length>0,noChord:!e.chord,noDivider:!e.dividerAbove,requires:e.requires??"",submenuLabel:e.submenuLabel??e.title}}function N(e,n){for(let r of e){if(r.id===n)return r;let t=r.children.find((d)=>d.id===n);if(t)return t}return}var L={bottom:0,height:0,left:0,right:0,top:0,width:0,x:0,y:0};function Pt(e){let n=Cs("popover",e.region),r=new AbortController,t=null,d=null,i=!1,f=()=>{if(i)return;i=!0,r.abort(),d?.(),d=null,Km("popover",e.region),P(e.opener??null),e.onClosed?.(u)},h=e.place?e.place(L):e.origin??E(e.opener),l=y({floor:e.floor?.()??0,label:e.label,placement:j(e),rows:e.rows.map((o)=>p(o)),select:(o,m)=>{let a=String(m.detail),s=N(l.rows,a);if(!s)return;if(s.run)s.run();else e.run?.(a);u.close()},x:h.x,y:h.y}),b=()=>{if(i||!t||!e.place)return;let o=e.place(Ie(t));l.x=o.x,l.y=o.y},w=(async()=>{let o=await I("menu",l,n,{signal:r.signal});if(r.signal.aborted)return;if({dispose:d}=o,t=o.root,t.addEventListener("toggle",(a)=>{if(a.newState==="closed")f()}),!t.hasAttribute("popover"))await new Promise((a)=>{t.addEventListener("jx-ready",()=>a(),{once:!0})});if(r.signal.aborted)return;let m=e.opener instanceof HTMLElement&&e.opener!==document.body?e.opener:void 0;t.showPopover(m?{source:m}:void 0),b(),requestAnimationFrame(b)})(),u={close:()=>{if(i)return;if(t?.open)t.hidePopover();f()},host:n,ready:w,setRows:(o)=>{if(i)return;let a=document.activeElement?.closest("jx-menu"),s=a&&a!==t?a.parentElement?.closest("jx-menu-item")?.dataset.commandId:void 0;l.rows=o.map((c)=>p(c)),setTimeout(()=>{if(i||!t||t.contains(document.activeElement))return;let c=s?t.querySelector(`jx-menu-item[data-command-id="${s}"]`):null,g=c?.querySelector("jx-menu")??null;if(c&&!(g?.open&&g.querySelector("jx-menu-item")))c.focus();else j1(t)},0)}};return u}function P(e){let n=document.activeElement;if(e?.isConnected&&(!n||n===document.body))e.focus()}
2
+ export{Pt};
3
3
 
4
- //# debugId=78207AFC52B59A5764756E2164756E21
5
- //# sourceMappingURL=studio-8xcwewjq.js.map
4
+ //# debugId=8220ACE363CD03AB64756E2164756E21
5
+ //# sourceMappingURL=studio-h46vtzk8.js.map
@@ -0,0 +1,9 @@
1
+ var I=()=>new Map,ae=(t)=>{let e=I();return t.forEach((n,r)=>{e.set(r,n)}),e},M=(t,e,n)=>{let r=t.get(e);if(r===void 0)t.set(e,r=n());return r},ur=(t,e)=>{let n=[];for(let[r,s]of t)n.push(e(s,r));return n},dr=(t,e)=>{for(let[n,r]of t)if(e(r,n))return!0;return!1};var j=()=>new Set;var he=(t)=>t[t.length-1];var fr=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},F=Array.from,ue=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},Rt=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1};var pr=(t,e)=>{let n=Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n};var K=Array.isArray;class de{constructor(){this._observers=I()}on(t,e){return M(this._observers,t,j).add(e),e}once(t,e){let n=(...r)=>{this.off(t,n),e(...r)};this.on(t,n)}off(t,e){let n=this._observers.get(t);if(n!==void 0){if(n.delete(e),n.size===0)this._observers.delete(t)}}emit(t,e){return F((this._observers.get(t)||I()).values()).forEach((n)=>n(...e))}destroy(){this._observers=I()}}class A0{constructor(){this._observers=I()}on(t,e){M(this._observers,t,j).add(e)}once(t,e){let n=(...r)=>{this.off(t,n),e(...r)};this.on(t,n)}off(t,e){let n=this._observers.get(t);if(n!==void 0){if(n.delete(e),n.size===0)this._observers.delete(t)}}emit(t,e){return F((this._observers.get(t)||I()).values()).forEach((n)=>n(...e))}destroy(){this._observers=I()}}var Io=Math.floor;var tt=Math.abs;var fe=(t,e)=>t<e?t:e,W=(t,e)=>t>e?t:e;var pe=(t)=>t!==0?t<0:1/t<0;var on=1,cn=2,ge=4,me=8;var ht=32,V=64,A=128;var Mt=31,$t=63,Z=127;var gr=2147483647;var{MAX_SAFE_INTEGER:ut,MIN_SAFE_INTEGER:an}=Number;var mr=Number.isInteger||((t)=>typeof t==="number"&&isFinite(t)&&Io(t)===t);var{fromCharCode:un,fromCodePoint:xi}=String,Zc=un(65535),yi=(t)=>t.toLowerCase(),bi=/^\s*/g,ki=(t)=>t.replace(bi,""),_i=/([A-Z])/g,dn=(t,e)=>ki(t.replace(_i,(n)=>`${e}${yi(n)}`));var Si=(t)=>{let e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},pt=typeof TextEncoder<"u"?new TextEncoder:null,Ei=(t)=>pt.encode(t),xr=pt?Ei:Si;var dt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(dt&&dt.decode(new Uint8Array).length===1)dt=null;var yr=(t,e)=>pr(e,()=>t).join("");class mt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var ha=()=>new mt;var P0=(t)=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e};var Kr=(t)=>{let e=new Uint8Array(P0(t)),n=0;for(let r=0;r<t.bufs.length;r++){let s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},Ii=(t,e)=>{let n=t.cbuf.length;if(n-t.cpos<e)t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(W(n,e)*2),t.cpos=0},U=(t,e)=>{let n=t.cbuf.length;if(t.cpos===n)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0;t.cbuf[t.cpos++]=e};var xe=U;var ft=(t,e)=>{while(e>Z)U(t,A|Z&e),e=Io(e/128);U(t,Z&e)},ye=(t,e)=>{let n=pe(e);if(n)e=-e;U(t,(e>$t?A:0)|(n?V:0)|$t&e),e=Io(e/64);while(e>0)U(t,(e>Z?A:0)|Z&e),e=Io(e/128)},fn=new Uint8Array(30000),Ui=fn.length/3,Ti=(t,e)=>{if(e.length<Ui){let n=pt.encodeInto(e,fn).written||0;ft(t,n);for(let r=0;r<n;r++)U(t,fn[r])}else wr(t,xr(e))},Ai=(t,e)=>{let n=unescape(encodeURIComponent(e)),r=n.length;ft(t,r);for(let s=0;s<r;s++)U(t,n.codePointAt(s))},pa=pt&&pt.encodeInto?Ti:Ai;var Ft=(t,e)=>{let n=t.cbuf.length,r=t.cpos,s=fe(n-r,e.length),i=e.length-s;if(t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,i>0)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(W(n*2,i)),t.cbuf.set(e.subarray(s)),t.cpos=i},wr=(t,e)=>{ft(t,e.byteLength),Ft(t,e)},pn=(t,e)=>{Ii(t,e);let n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},Ci=(t,e)=>pn(t,4).setFloat32(0,e,!1),Di=(t,e)=>pn(t,8).setFloat64(0,e,!1),Bi=(t,e)=>pn(t,8).setBigInt64(0,e,!1);var br=new DataView(new ArrayBuffer(4)),Oi=(t)=>(br.setFloat32(0,t),br.getFloat32(0)===t),gt=(t,e)=>{switch(typeof e){case"string":U(t,119),pa(t,e);break;case"number":if(mr(e)&&tt(e)<=gr)U(t,125),ye(t,e);else if(Oi(e))U(t,124),Ci(t,e);else U(t,123),Di(t,e);break;case"bigint":U(t,122),Bi(t,e);break;case"object":if(e===null)U(t,126);else if(K(e)){U(t,117),ft(t,e.length);for(let n=0;n<e.length;n++)gt(t,e[n])}else if(e instanceof Uint8Array)U(t,116),wr(t,e);else{U(t,118);let n=Object.keys(e);ft(t,n.length);for(let r=0;r<n.length;r++){let s=n[r];pa(t,s),gt(t,e[s])}}break;case"boolean":U(t,e?120:121);break;default:U(t,127)}};class be extends mt{constructor(t){super();this.w=t,this.s=null,this.count=0}write(t){if(this.s===t)this.count++;else{if(this.count>0)ft(this,this.count-1);this.count=1,this.w(this,t),this.s=t}}}var kr=(t)=>{if(t.count>0){if(ye(t.encoder,t.count===1?t.s:-t.s),t.count>1)ft(t.encoder,t.count-2)}};class wt{constructor(){this.encoder=new mt,this.s=0,this.count=0}write(t){if(this.s===t)this.count++;else kr(this),this.count=1,this.s=t}toUint8Array(){return kr(this),Kr(this.encoder)}}var _r=(t)=>{if(t.count>0){let e=t.diff*2+(t.count===1?0:1);if(ye(t.encoder,e),t.count>1)ft(t.encoder,t.count-2)}};class jt{constructor(){this.encoder=new mt,this.s=0,this.count=0,this.diff=0}write(t){if(this.diff===t-this.s)this.s=t,this.count++;else _r(this),this.count=1,this.diff=t-this.s,this.s=t}toUint8Array(){return _r(this),Kr(this.encoder)}}class gn{constructor(){this.sarr=[],this.s="",this.lensE=new wt}write(t){if(this.s+=t,this.s.length>19)this.sarr.push(this.s),this.s="";this.lensE.write(t.length)}toUint8Array(){let t=new mt;return this.sarr.push(this.s),this.s="",pa(t,this.sarr.join("")),Ft(t,this.lensE.toUint8Array()),Kr(t)}}var v=(t)=>Error(t),N=()=>{throw v("Method unimplemented")},B=()=>{throw v("Unexpected case")};var ke=v("Unexpected end of array"),Er=v("Integer out of Range"),vi=(t,e,n)=>{if(e<0||n<0||e+n>t.length)throw ke;return new Uint8Array(t.buffer,t.byteOffset+e,n)},Ni=(t,e,n)=>{if(e<0||n<0||e+n>t.length)throw ke;return new DataView(t.buffer,t.byteOffset+e,n)};class qt{constructor(t){this.arr=t,this.pos=0}}var fa=(t)=>new qt(t),Ir=(t)=>t.pos!==t.arr.length;var Ri=(t,e)=>{let n=vi(t.arr,t.pos,e);return t.pos+=e,n},Rr=(t)=>Ri(t,Et(t));var et=(t)=>t.arr[t.pos++];var Et=(t)=>{let e=0,n=1,r=t.arr.length;while(t.pos<r){let s=t.arr[t.pos++];if(e=e+(s&Z)*n,n*=128,s<A)return e;if(e>ut)throw Er}throw ke},_e=(t)=>{let e=t.arr[t.pos++],n=e&$t,r=64,s=(e&V)>0?-1:1;if((e&A)===0)return s*n;let i=t.arr.length;while(t.pos<i){if(e=t.arr[t.pos++],n=n+(e&Z)*r,r*=128,e<A)return s*n;if(n>ut)throw Er}throw ke};var Li=(t)=>{let e=Et(t);if(e===0)return"";else{let n=String.fromCodePoint(et(t));if(--e<100)while(e--)n+=String.fromCodePoint(et(t));else while(e>0){let r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},Vi=(t)=>dt.decode(Rr(t)),ma=dt?Vi:Li;var wn=(t,e)=>{let n=Ni(t.arr,t.pos,e);return t.pos+=e,n},Mi=(t)=>wn(t,4).getFloat32(0,!1),$i=(t)=>wn(t,8).getFloat64(0,!1),Fi=(t)=>wn(t,8).getBigInt64(0,!1);var ji=[(t)=>{return},(t)=>null,_e,Mi,$i,Fi,(t)=>!1,(t)=>!0,ma,(t)=>{let e=Et(t),n={};for(let r=0;r<e;r++){let s=ma(t);n[s]=xt(t)}return n},(t)=>{let e=Et(t),n=[];for(let r=0;r<e;r++)n.push(xt(t));return n},Rr],xt=(t)=>ji[127-et(t)](t);class Se extends qt{constructor(t,e){super(t);this.reader=e,this.s=null,this.count=0}read(){if(this.count===0)if(this.s=this.reader(this),Ir(this))this.count=Et(this)+1;else this.count=-1;return this.count--,this.s}}class yt extends qt{constructor(t){super(t);this.s=0,this.count=0}read(){if(this.count===0){this.s=_e(this);let t=pe(this.s);if(this.count=1,t)this.s=-this.s,this.count=Et(this)+2}return this.count--,this.s}}class Gt extends qt{constructor(t){super(t);this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=_e(this),e=t&1;if(this.diff=Io(t/2),this.count=1,e)this.count=Et(this)+2}return this.s+=this.diff,this.count--,this.s}}class xn{constructor(t){this.decoder=new yt(t),this.str=ma(this.decoder),this.spos=0}read(){let t=this.spos+this.decoder.read(),e=this.str.slice(this.spos,t);return this.spos=t,e}}var Yc=crypto.subtle,Tr=crypto.getRandomValues.bind(crypto);var yn=()=>Tr(new Uint32Array(1))[0];var qi=[1e7]+-1000+-4000+-8000+-100000000000,Ar=()=>qi.replace(/[018]/g,(t)=>(t^yn()&15>>t/4).toString(16));var hd=Date.now;var bn=(t)=>new Promise(t);var nl=Promise.all.bind(Promise);var kn=(t)=>t===void 0?null:t;class Dr{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}}var Br=new Dr,Ji=!0;try{if(typeof localStorage<"u"&&localStorage)Br=localStorage,Ji=!1}catch(t){}var Or=Br;var nt=Symbol("Equality"),Ee=(t,e)=>t===e||!!t?.[nt]?.(e)||!1;var vr=(t)=>typeof t==="object",{assign:Nr,keys:Ki}=Object;var Lr=(t,e)=>{for(let n in t)e(t[n],n)};var zt=(t)=>Ki(t).length;var Vr=(t)=>{for(let e in t)return!1;return!0},bt=(t,e)=>{for(let n in t)if(!e(t[n],n))return!1;return!0},Ht=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Sn=(t,e)=>t===e||zt(t)===zt(e)&&bt(t,(n,r)=>(n!==void 0||Ht(e,r))&&Ee(e[r],n)),Wi=Object.freeze,En=(t)=>{for(let e in t){let n=t[e];if(typeof n==="object"||typeof n==="function")En(t[e])}return Wi(t)};var Jt=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{if(n<t.length)Jt(t,e,n+1)}};var Mr=(t)=>t;var Iu=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[nt]!=null)return t[nt](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(let n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(let n of t.keys())if(!e.has(n)||!Iu(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(zt(t)!==zt(e))return!1;for(let n in t)if(!Ht(t,n)||!Iu(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Iu(t[n],e[n]))return!1;break;default:return!1}return!0},$r=(t,e)=>e.includes(t);var Pt=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";var rl=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,q,Zi=[],Xi=()=>{if(q===void 0)if(Pt){q=I();let t=process.argv,e=null;for(let n=0;n<t.length;n++){let r=t[n];if(r[0]==="-"){if(e!==null)q.set(e,"");e=r}else if(e!==null)q.set(e,r),e=null;else Zi.push(r)}if(e!==null)q.set(e,"")}else if(typeof location==="object")q=I(),(location.search||"?").slice(1).split("&").forEach((t)=>{if(t.length!==0){let[e,n]=t.split("=");q.set(`--${dn(e,"-")}`,n),q.set(`-${dn(e,"-")}`,n)}});else q=I();return q},Tn=(t)=>Xi().has(t);var Kt=(t)=>Pt?kn(process.env[t.toUpperCase().replaceAll("-","_")]):kn(Or.getItem(t));var Fr=(t)=>Tn("--"+t)||Kt(t)!==null,jr=Fr("production"),Qi=Pt&&$r(process.env.FORCE_COLOR,["true","1","2"]),qr=Qi||!Tn("--no-colors")&&!Fr("no-color")&&(!Pt||process.stdout.isTTY)&&(!Pt||Tn("--color")||Kt("COLORTERM")!==null||(Kt("TERM")||"").includes("color"));var Yi=(t)=>new Uint8Array(t);var Gr=(t)=>{let e=Yi(t.byteLength);return e.set(t),e};class zr{constructor(t,e){this.left=t,this.right=e}}var G=(t,e)=>new zr(t,e);var Cn=(t)=>t.next()>=0.5,Ie=(t,e,n)=>Io(t.next()*(n+1-e)+e);var Dn=(t,e,n)=>Io(t.next()*(n+1-e)+e);var Bn=(t,e,n)=>Dn(t,e,n);var no=(t)=>un(Bn(t,97,122)),Hr=(t,e=0,n=20)=>{let r=Bn(t,e,n),s="";for(let i=0;i<r;i++)s+=no(t);return s};var Ue=(t,e)=>e[Bn(t,0,e.length-1)];var so=Symbol("0schema");class Pr{constructor(){this._rerrs=[]}extend(t,e,n,r=null){this._rerrs.push({path:t,expected:e,has:n,message:r})}toString(){let t=[];for(let e=this._rerrs.length-1;e>0;e--){let n=this._rerrs[e];t.push(yr(" ",(this._rerrs.length-e)*2)+`${n.path!=null?`[${n.path}] `:""}${n.has} doesn't match ${n.expected}. ${n.message}`)}return t.join(`
2
+ `)}}var On=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor)return!1;if(t[nt])return Ee(t,e);if(K(t))return ue(t,(n)=>Rt(e,(r)=>On(n,r)));else if(vr(t))return bt(t,(n,r)=>On(n,e[r]));return!1};class C{static _dilutes=!1;extends(t){let[e,n]=[this.shape,t.shape];if(this.constructor._dilutes)[n,e]=[e,n];return On(e,n)}equals(t){return this.constructor===t.constructor&&Iu(this.shape,t.shape)}[so](){return!0}[nt](t){return this.equals(t)}validate(t){return this.check(t)}check(t,e){N()}get nullable(){return It(this,Re)}get optional(){return new vn(this)}cast(t){return Jr(t,this),t}expect(t){return Jr(t,this),t}}class Ce extends C{constructor(t,e){super();this.shape=t,this._c=e}check(t,e=void 0){let n=t?.constructor===this.shape&&(this._c==null||this._c(t));return!n&&e?.extend(null,this.shape.name,t?.constructor.name,t?.constructor!==this.shape?"Constructor match failed":"Check failed"),n}}var k=(t,e=null)=>new Ce(t,e),il=k(Ce);class De extends C{constructor(t){super();this.shape=t}check(t,e){let n=this.shape(t);return!n&&e?.extend(null,"custom prop",t?.constructor.name,"failed to check custom prop"),n}}var _=(t)=>new De(t),ol=k(De);class Zt extends C{constructor(t){super();this.shape=t}check(t,e){let n=this.shape.some((r)=>r===t);return!n&&e?.extend(null,this.shape.join(" | "),t.toString()),n}}var Be=(...t)=>new Zt(t),Wr=k(Zt),io=RegExp.escape||((t)=>t.replace(/[().|&,$^[\]]/g,(e)=>"\\"+e)),Zr=(t)=>{if(St.check(t))return[io(t)];if(Wr.check(t))return t.shape.map((e)=>e+"");if(ss.check(t))return["[+-]?\\d+.?\\d*"];if(is.check(t))return[".*"];if(Te.check(t))return t.shape.map(Zr).flat(1);B()};class Xr extends C{constructor(t){super();this.shape=t,this._r=new RegExp("^"+t.map(Zr).map((e)=>`(${e.join("|")})`).join("")+"$")}check(t,e){let n=this._r.exec(t)!=null;return!n&&e?.extend(null,this._r.toString(),t.toString(),"String doesn't match string template."),n}}var cl=k(Xr),oo=Symbol("optional");class vn extends C{constructor(t){super();this.shape=t}check(t,e){let n=t===void 0||this.shape.check(t);return!n&&e?.extend(null,"undefined (optional)","()"),n}get[oo](){return!0}}var co=k(vn);class Nn extends C{check(t,e){return e?.extend(null,"never",typeof t),!1}}var ll=new Nn,al=k(Nn);class Oe extends C{constructor(t,e=!1){super();this.shape=t,this._isPartial=e}static _dilutes=!0;get partial(){return new Oe(this.shape,!0)}check(t,e){if(t==null)return e?.extend(null,"object","null"),!1;return bt(this.shape,(n,r)=>{let s=this._isPartial&&!Ht(t,r)||n.check(t[r],e);return!s&&e?.extend(r.toString(),n.toString(),typeof t[r],"Object property does not match"),s})}}var lo=(t)=>new Oe(t),ao=k(Oe),ho=_((t)=>t!=null&&(t.constructor===Object||t.constructor==null));class Rn extends C{constructor(t,e){super();this.shape={keys:t,values:e}}check(t,e){return t!=null&&bt(t,(n,r)=>{let s=this.shape.keys.check(r,e);return!s&&e?.extend(r+"","Record",typeof t,s?"Key doesn't match schema":"Value doesn't match value"),s&&this.shape.values.check(n,e)})}}var Qr=(t,e)=>new Rn(t,e),uo=k(Rn);class Ln extends C{constructor(t){super();this.shape=t}check(t,e){return t!=null&&bt(this.shape,(n,r)=>{let s=n.check(t[r],e);return!s&&e?.extend(r.toString(),"Tuple",typeof n),s})}}var fo=(...t)=>new Ln(t),hl=k(Ln);class Vn extends C{constructor(t){super();this.shape=t.length===1?t[0]:new ve(t)}check(t,e){let n=K(t)&&ue(t,(r)=>this.shape.check(r));return!n&&e?.extend(null,"Array",""),n}}var Yr=(...t)=>new Vn(t),po=k(Vn),go=_((t)=>K(t));class Mn extends C{constructor(t,e){super();this.shape=t,this._c=e}check(t,e){let n=t instanceof this.shape&&(this._c==null||this._c(t));return!n&&e?.extend(null,this.shape.name,t?.constructor.name),n}}var mo=(t,e=null)=>new Mn(t,e),ul=k(Mn),wo=mo(C);class ts extends C{constructor(t){super();this.len=t.length-1,this.args=fo(...t.slice(-1)),this.res=t[this.len]}check(t,e){let n=t.constructor===Function&&t.length<=this.len;return!n&&e?.extend(null,"function",typeof t),n}}var xo=k(ts),yo=_((t)=>typeof t==="function");class es extends C{constructor(t){super();this.shape=t}check(t,e){let n=ue(this.shape,(r)=>r.check(t,e));return!n&&e?.extend(null,"Intersectinon",typeof t),n}}var dl=k(es,(t)=>t.shape.length>0);class ve extends C{static _dilutes=!0;constructor(t){super();this.shape=t}check(t,e){let n=Rt(this.shape,(r)=>r.check(t,e));return e?.extend(null,"Union",typeof t),n}}var It=(...t)=>t.findIndex((e)=>Te.check(e))>=0?It(...t.map((e)=>Wt(e)).map((e)=>Te.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new ve(t),Te=k(ve),ns=()=>!0,Ae=_(ns),bo=k(De,(t)=>t.shape===ns),$n=_((t)=>typeof t==="bigint"),ko=_((t)=>t===$n),rs=_((t)=>typeof t==="symbol"),fl=_((t)=>t===rs),_t=_((t)=>typeof t==="number"),ss=_((t)=>t===_t),St=_((t)=>typeof t==="string"),is=_((t)=>t===St),Ne=_((t)=>typeof t==="boolean"),_o=_((t)=>t===Ne),os=Be(void 0),pl=k(Zt,(t)=>t.shape.length===1&&t.shape[0]===void 0),gl=Be(void 0);var Re=Be(null),So=k(Zt,(t)=>t.shape.length===1&&t.shape[0]===null),ml=k(Uint8Array),wl=k(Ce,(t)=>t.shape===Uint8Array),Eo=It(_t,St,Re,os,$n,Ne,rs),xl=(()=>{let t=Yr(Ae),e=Qr(St,Ae),n=It(_t,St,Re,Ne,t,e);return t.shape=n,e.shape.values=n,n})(),Wt=(t)=>{if(wo.check(t))return t;else if(ho.check(t)){let e={};for(let n in t)e[n]=Wt(t[n]);return lo(e)}else if(go.check(t))return It(...t.map(Wt));else if(Eo.check(t))return Be(t);else if(yo.check(t))return k(t);B()},Jr=jr?()=>{}:(t,e)=>{let n=new Pr;if(!e.check(t,n))throw v(`Expected value to be of type ${e.constructor.name}.
3
+ ${n.toString()}`)};class cs{constructor(t){this.patterns=[],this.$state=t}if(t,e){return this.patterns.push({if:Wt(t),h:e}),this}else(t){return this.if(Ae,t)}done(){return(t,e)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(t))return r.h(t,e)}throw v("Unhandled pattern")}}}var Uo=(t)=>new cs(t),ls=Uo(Ae).if(ss,(t,e)=>Ie(e,an,ut)).if(is,(t,e)=>Hr(e)).if(_o,(t,e)=>Cn(e)).if(ko,(t,e)=>BigInt(Ie(e,an,ut))).if(Te,(t,e)=>kt(e,Ue(e,t.shape))).if(ao,(t,e)=>{let n={};for(let r in t.shape){let s=t.shape[r];if(co.check(s)){if(Cn(e))continue;s=s.shape}n[r]=ls(s,e)}return n}).if(po,(t,e)=>{let n=[],r=Dn(e,0,42);for(let s=0;s<r;s++)n.push(kt(e,t.shape));return n}).if(Wr,(t,e)=>Ue(e,t.shape)).if(So,(t,e)=>null).if(xo,(t,e)=>{let n=kt(e,t.res);return()=>n}).if(bo,(t,e)=>kt(e,Ue(e,[_t,St,Re,os,$n,Ne,Yr(_t),Qr(It("a","b","c"),_t)]))).if(uo,(t,e)=>{let n={},r=Ie(e,0,3);for(let s=0;s<r;s++){let i=kt(e,t.shape.keys),o=kt(e,t.shape.values);n[i]=o}return n}).done(),kt=(t,e)=>ls(Wt(e),t);var rt=typeof document<"u"?document:{};var yl=_((t)=>t.nodeType===Bo);var bl=typeof DOMParser<"u"?new DOMParser:null;var kl=_((t)=>t.nodeType===Ao);var _l=_((t)=>t.nodeType===Co);var as=(t)=>ur(t,(e,n)=>`${n}:${e};`).join("");var{ELEMENT_NODE:Ao,TEXT_NODE:Co,CDATA_SECTION_NODE:Sl,COMMENT_NODE:El,DOCUMENT_NODE:Do,DOCUMENT_TYPE_NODE:Il,DOCUMENT_FRAGMENT_NODE:Bo}=rt,Ul=_((t)=>t.nodeType===Do);var z=Symbol;var Xt=z(),Qt=z(),Fn=z(),jn=z(),qn=z(),Yt=z(),Gn=z(),Ut=z(),zn=z(),hs=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],n=[],r=0;for(;r<t.length;r++){let s=t[r];if(s===void 0)break;else if(s.constructor===String||s.constructor===Number)e.push(s);else if(s.constructor===Object)break}if(r>0)n.push(e.join(""));for(;r<t.length;r++){let s=t[r];if(!(s instanceof Symbol))n.push(s)}return n};var Tl=hd();var Ro={[Xt]:G("font-weight","bold"),[Qt]:G("font-weight","normal"),[Fn]:G("color","blue"),[qn]:G("color","green"),[jn]:G("color","grey"),[Yt]:G("color","red"),[Gn]:G("color","purple"),[Ut]:G("color","orange"),[zn]:G("color","black")},Lo=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],n=[],r=I(),s=[],i=0;for(;i<t.length;i++){let o=t[i],c=Ro[o];if(c!==void 0)r.set(c.left,c.right);else{if(o===void 0)break;if(o.constructor===String||o.constructor===Number){let a=as(r);if(i>0||a.length>0)e.push("%c"+o),n.push(a);else e.push(o)}else break}}if(i>0)s=n,s.unshift(e.join(""));for(;i<t.length;i++){let o=t[i];if(!(o instanceof Symbol))s.push(o)}return s},us=qr?Lo:hs,ds=(...t)=>{console.log(...us(t)),fs.forEach((e)=>e.print(t))},Hn=(...t)=>{console.warn(...us(t)),t.unshift(Ut),fs.forEach((e)=>e.print(t))};var fs=j();var gs=(t)=>({[Symbol.iterator](){return this},next:t}),ms=(t,e)=>gs(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Le=(t,e)=>gs(()=>{let{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class se{constructor(t,e){this.clock=t,this.len=e}}class lt{constructor(){this.clients=new Map}}var Ct=(t,e,n)=>e.clients.forEach((r,s)=>{let i=t.doc.store.clients.get(s);if(i!=null){let o=i[i.length-1],c=o.id.clock+o.length;for(let a=0,d=r[a];a<r.length&&d.clock<c;d=r[++a])Hs(t,i,d.clock,d.len,n)}}),$o=(t,e)=>{let n=0,r=t.length-1;while(n<=r){let s=Io((n+r)/2),i=t[s],o=i.clock;if(o<=e){if(e<o+i.len)return s;n=s+1}else r=s-1}return null},ie=(t,e)=>{let n=t.clients.get(e.client);return n!==void 0&&$o(n,e.clock)!==null},Xn=(t)=>{t.clients.forEach((e)=>{e.sort((s,i)=>s.clock-i.clock);let n,r;for(n=1,r=1;n<e.length;n++){let s=e[r-1],i=e[n];if(s.clock+s.len>=i.clock)e[r-1]=new se(s.clock,W(s.len,i.clock+i.len-s.clock));else{if(r<n)e[r]=i;r++}}e.length=r})},Pn=(t)=>{let e=new lt;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){let i=r.slice();for(let o=n+1;o<t.length;o++)fr(i,t[o].clients.get(s)||[]);e.clients.set(s,i)}});return Xn(e),e},te=(t,e,n,r)=>{M(t.clients,e,()=>[]).push(new se(n,r))},Os=()=>new lt,Fo=(t)=>{let e=Os();return t.clients.forEach((n,r)=>{let s=[];for(let i=0;i<n.length;i++){let o=n[i];if(o.deleted){let c=o.id.clock,a=o.length;if(i+1<n.length)for(let d=n[i+1];i+1<n.length&&d.deleted;d=n[++i+1])a+=d.length;s.push(new se(c,a))}}if(s.length>0)e.clients.set(r,s)}),e},Bt=(t,e)=>{ft(t.restEncoder,e.clients.size),F(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),ft(t.restEncoder,n);let s=r.length;ft(t.restEncoder,s);for(let i=0;i<s;i++){let o=r[i];t.writeDsClock(o.clock),t.writeDsLen(o.len)}})},Qn=(t)=>{let e=new lt,n=Et(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();let s=Et(t.restDecoder),i=Et(t.restDecoder);if(i>0){let o=M(e.clients,s,()=>[]);for(let c=0;c<i;c++)o.push(new se(t.readDsClock(),t.readDsLen()))}}return e},ws=(t,e,n)=>{let r=new lt,s=Et(t.restDecoder);for(let i=0;i<s;i++){t.resetDsCurVal();let o=Et(t.restDecoder),c=Et(t.restDecoder),a=n.clients.get(o)||[],d=y(n,o);for(let l=0;l<c;l++){let h=t.readDsClock(),u=h+t.readDsLen();if(h<d){if(d<u)te(r,o,d,u-d);let f=H(a,h),p=a[f];if(!p.deleted&&p.id.clock<h)a.splice(f+1,0,Xe(e,p,h-p.id.clock)),f++;while(f<a.length)if(p=a[f++],p.id.clock<u){if(!p.deleted){if(u<p.id.clock+p.length)a.splice(f,0,Xe(e,p,u-p.id.clock));p.delete(e)}}else break}else te(r,o,h,u-h)}}if(r.clients.size>0){let i=new Y;return ft(i.restEncoder,0),Bt(i,r),i.toUint8Array()}return null};var vs=yn;class vc extends de{constructor({guid:t=Ar(),collectionid:e=null,gc:n=!0,gcFilter:r=()=>!0,meta:s=null,autoLoad:i=!1,shouldLoad:o=!0}={}){super();this.gc=n,this.gcFilter=r,this.clientID=vs(),this.guid=t,this.collectionid=e,this.share=new Map,this.store=new sr,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=i,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=bn((a)=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});let c=()=>bn((a)=>{let d=(l)=>{if(l===void 0||l===!0)this.off("sync",d),a()};this.on("sync",d)});this.on("sync",(a)=>{if(a===!1&&this.isSynced)this.whenSynced=c();if(this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded)this.emit("load",[this])}),this.whenSynced=c()}load(){let t=this._item;if(t!==null&&!this.shouldLoad)w(t.parent.doc,(e)=>{e.subdocsLoaded.add(this)},null,!0);this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(F(this.subdocs).map((t)=>t.guid))}transact(t,e=null){return w(this,t,e)}get(t,e=S){let n=M(this.share,t,()=>{let s=new e;return s._integrate(this,null),s}),r=n.constructor;if(e!==S&&r!==e)if(r===S){let s=new e;s._map=n._map,n._map.forEach((i)=>{for(;i!==null;i=i.left)i.parent=s}),s._start=n._start;for(let i=s._start;i!==null;i=i.right)i.parent=s;return s._length=n._length,this.share.set(t,s),s._integrate(this,null),s}else throw Error(`Type with the name ${t} has already been defined with a different constructor`);return n}getArray(t=""){return this.get(t,Bs)}getText(t=""){return this.get(t,ps)}getMap(t=""){return this.get(t,Zo)}getXmlElement(t=""){return this.get(t,Dt)}getXmlFragment(t=""){return this.get(t,ot)}toJSON(){let t={};return this.share.forEach((e,n)=>{t[n]=e.toJSON()}),t}destroy(){this.isDestroyed=!0,F(this.subdocs).forEach((e)=>e.destroy());let t=this._item;if(t!==null){this._item=null;let e=t.content;e.doc=new vc({guid:this.guid,...e.opts,shouldLoad:!1}),e.doc._item=t,w(t.parent.doc,(n)=>{let r=e.doc;if(!t.deleted)n.subdocsAdded.add(r);n.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class Yn{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return Et(this.restDecoder)}readDsLen(){return Et(this.restDecoder)}}class tr extends Yn{readLeftID(){return g(Et(this.restDecoder),Et(this.restDecoder))}readRightID(){return g(Et(this.restDecoder),Et(this.restDecoder))}readClient(){return Et(this.restDecoder)}readInfo(){return et(this.restDecoder)}readString(){return ma(this.restDecoder)}readParentInfo(){return Et(this.restDecoder)===1}readTypeRef(){return Et(this.restDecoder)}readLen(){return Et(this.restDecoder)}readAny(){return xt(this.restDecoder)}readBuf(){return Gr(Rr(this.restDecoder))}readJSON(){return JSON.parse(ma(this.restDecoder))}readKey(){return ma(this.restDecoder)}}class Ns{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Et(this.restDecoder),this.dsCurrVal}readDsLen(){let t=Et(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class it extends Ns{constructor(t){super(t);this.keys=[],Et(t),this.keyClockDecoder=new Gt(Rr(t)),this.clientDecoder=new yt(Rr(t)),this.leftClockDecoder=new Gt(Rr(t)),this.rightClockDecoder=new Gt(Rr(t)),this.infoDecoder=new Se(Rr(t),et),this.stringDecoder=new xn(Rr(t)),this.parentInfoDecoder=new Se(Rr(t),et),this.typeRefDecoder=new yt(Rr(t)),this.lenDecoder=new yt(Rr(t))}readLeftID(){return new st(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new st(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return xt(this.restDecoder)}readBuf(){return Rr(this.restDecoder)}readJSON(){return xt(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];else{let e=this.stringDecoder.read();return this.keys.push(e),e}}}class er{constructor(){this.restEncoder=ha()}toUint8Array(){return Kr(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){ft(this.restEncoder,t)}writeDsLen(t){ft(this.restEncoder,t)}}class Ot extends er{writeLeftID(t){ft(this.restEncoder,t.client),ft(this.restEncoder,t.clock)}writeRightID(t){ft(this.restEncoder,t.client),ft(this.restEncoder,t.clock)}writeClient(t){ft(this.restEncoder,t)}writeInfo(t){xe(this.restEncoder,t)}writeString(t){pa(this.restEncoder,t)}writeParentInfo(t){ft(this.restEncoder,t?1:0)}writeTypeRef(t){ft(this.restEncoder,t)}writeLen(t){ft(this.restEncoder,t)}writeAny(t){gt(this.restEncoder,t)}writeBuf(t){wr(this.restEncoder,t)}writeJSON(t){pa(this.restEncoder,JSON.stringify(t))}writeKey(t){pa(this.restEncoder,t)}}class nr{constructor(){this.restEncoder=ha(),this.dsCurrVal=0}toUint8Array(){return Kr(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let e=t-this.dsCurrVal;this.dsCurrVal=t,ft(this.restEncoder,e)}writeDsLen(t){if(t===0)B();ft(this.restEncoder,t-1),this.dsCurrVal+=t}}class Y extends nr{constructor(){super();this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new jt,this.clientEncoder=new wt,this.leftClockEncoder=new jt,this.rightClockEncoder=new jt,this.infoEncoder=new be(xe),this.stringEncoder=new gn,this.parentInfoEncoder=new be(xe),this.typeRefEncoder=new wt,this.lenEncoder=new wt}toUint8Array(){let t=ha();return ft(t,0),wr(t,this.keyClockEncoder.toUint8Array()),wr(t,this.clientEncoder.toUint8Array()),wr(t,this.leftClockEncoder.toUint8Array()),wr(t,this.rightClockEncoder.toUint8Array()),wr(t,Kr(this.infoEncoder)),wr(t,this.stringEncoder.toUint8Array()),wr(t,Kr(this.parentInfoEncoder)),wr(t,this.typeRefEncoder.toUint8Array()),wr(t,this.lenEncoder.toUint8Array()),Ft(t,Kr(this.restEncoder)),Kr(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){gt(this.restEncoder,t)}writeBuf(t){wr(this.restEncoder,t)}writeJSON(t){gt(this.restEncoder,t)}writeKey(t){let e=this.keyMap.get(t);if(e===void 0)this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t);else this.keyClockEncoder.write(e)}}var jo=(t,e,n,r)=>{r=W(r,e[0].id.clock);let s=H(e,r);ft(t.restEncoder,e.length-s),t.writeClient(n),ft(t.restEncoder,r);let i=e[s];i.write(t,r-i.id.clock);for(let o=s+1;o<e.length;o++)e[o].write(t,0)},rr=(t,e,n)=>{let r=new Map;n.forEach((s,i)=>{if(y(e,i)>s)r.set(i,s)}),Qe(e).forEach((s,i)=>{if(!n.has(i))r.set(i,0)}),ft(t.restEncoder,r.size),F(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{jo(t,e.clients.get(s),s,i)})},qo=(t,e)=>{let n=I(),r=Et(t.restDecoder);for(let s=0;s<r;s++){let i=Et(t.restDecoder),o=Array(i),c=t.readClient(),a=Et(t.restDecoder);n.set(c,{i:0,refs:o});for(let d=0;d<i;d++){let l=t.readInfo();switch(Mt&l){case 0:{let h=t.readLen();o[d]=new R(g(c,a),h),a+=h;break}case 10:{let h=Et(t.restDecoder);o[d]=new L(g(c,a),h),a+=h;break}default:{let h=(l&(V|A))===0,u=new x(g(c,a),null,(l&A)===A?t.readLeftID():null,null,(l&V)===V?t.readRightID():null,h?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,h&&(l&ht)===ht?t.readString():null,gi(t,l));o[d]=u,a+=u.length}}}}return n},Go=(t,e,n)=>{let r=[],s=F(n.keys()).sort((f,p)=>f-p);if(s.length===0)return null;let i=()=>{if(s.length===0)return null;let f=n.get(s[s.length-1]);while(f.refs.length===f.i)if(s.pop(),s.length>0)f=n.get(s[s.length-1]);else return null;return f},o=i();if(o===null)return null;let c=new sr,a=new Map,d=(f,p)=>{let m=a.get(f);if(m==null||m>p)a.set(f,p)},l=o.refs[o.i++],h=new Map,u=()=>{for(let f of r){let p=f.id.client,m=n.get(p);if(m)m.i--,c.clients.set(p,m.refs.slice(m.i)),n.delete(p),m.i=0,m.refs=[];else c.clients.set(p,[f]);s=s.filter((T)=>T!==p)}r.length=0};while(!0){if(l.constructor!==L){let p=M(h,l.id.client,()=>y(e,l.id.client))-l.id.clock;if(p<0)r.push(l),d(l.id.client,l.id.clock-1),u();else{let m=l.getMissing(t,e);if(m!==null){r.push(l);let T=n.get(m)||{refs:[],i:0};if(T.refs.length===T.i)d(m,y(e,m)),u();else{l=T.refs[T.i++];continue}}else if(p===0||p<l.length)l.integrate(t,p),h.set(l.id.client,l.id.clock+l.length)}}if(r.length>0)l=r.pop();else if(o!==null&&o.i<o.refs.length)l=o.refs[o.i++];else if(o=i(),o===null)break;else l=o.refs[o.i++]}if(c.clients.size>0){let f=new Y;return rr(f,c,new Map),ft(f.restEncoder,0),{missing:a,update:f.toUint8Array()}}return null},zo=(t,e)=>rr(t,e.doc.store,e.beforeState),Ho=(t,e,n,r=new it(t))=>w(e,(s)=>{s.local=!1;let i=!1,o=s.doc,c=o.store,a=qo(r,o),d=Go(s,c,a),l=c.pendingStructs;if(l){for(let[u,f]of l.missing)if(f<y(c,u)){i=!0;break}if(d){for(let[u,f]of d.missing){let p=l.missing.get(u);if(p==null||p>f)l.missing.set(u,f)}l.update=ze([l.update,d.update])}}else c.pendingStructs=d;let h=ws(r,s,c);if(c.pendingDs){let u=new it(fa(c.pendingDs));Et(u.restDecoder);let f=ws(u,s,c);if(h&&f)c.pendingDs=ze([h,f]);else c.pendingDs=h||f}else c.pendingDs=h;if(i){let u=c.pendingStructs.update;c.pendingStructs=null,Rs(s.doc,u)}},n,!1);var Rs=(t,e,n,r=it)=>{let s=fa(e);Ho(s,t,n,new r(s))},Ik=(t,e,n)=>Rs(t,e,n,tr),Jo=(t,e,n=new Map)=>{rr(t,e.store,n),Bt(t,Fo(e.store))},Po=(t,e=new Uint8Array([0]),n=new Y)=>{let r=Ls(e);Jo(n,t,r);let s=[n.toUint8Array()];if(t.store.pendingDs)s.push(t.store.pendingDs);if(t.store.pendingStructs)s.push(lc(t.store.pendingStructs.update,e));if(s.length>1){if(n.constructor===Ot)return oc(s.map((i,o)=>o===0?i:hc(i)));else if(n.constructor===Y)return ze(s)}return s[0]},Dk=(t,e)=>Po(t,e,new Ot),Ko=(t)=>{let e=new Map,n=Et(t.restDecoder);for(let r=0;r<n;r++){let s=Et(t.restDecoder),i=Et(t.restDecoder);e.set(s,i)}return e},Ls=(t)=>Ko(new Yn(fa(t))),Vs=(t,e)=>(ft(t.restEncoder,e.size),F(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{ft(t.restEncoder,n),ft(t.restEncoder,r)}),t),Wo=(t,e)=>Vs(t,Qe(e.store)),Xo=(t,e=new nr)=>{if(t instanceof Map)Vs(e,t);else Wo(e,t);return e.toUint8Array()},Nk=(t)=>Xo(t,new er);class Ms{constructor(){this.l=[]}}var xs=()=>new Ms,ys=(t,e)=>t.l.push(e),bs=(t,e)=>{let n=t.l,r=n.length;if(t.l=n.filter((s)=>e!==s),r===t.l.length)console.error("[yjs] Tried to remove event handler that doesn't exist.")},$s=(t,e,n)=>Jt(t.l,[e,n]);class st{constructor(t,e){this.client=t,this.clock=e}}var Ve=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,g=(t,e)=>new st(t,e);var Fs=(t)=>{for(let[e,n]of t.doc.share.entries())if(n===t)return e;throw B()},Ge=(t,e)=>{while(e!==null){if(e.parent===t)return!0;e=e.parent._item}return!1};class js{constructor(t,e,n,r=0){this.type=t,this.tname=e,this.item=n,this.assoc=r}}class qs{constructor(t,e,n=0){this.type=t,this.index=e,this.assoc=n}}var Qo=(t,e,n=0)=>new qs(t,e,n),Me=(t,e,n)=>{let r=null,s=null;if(t._item===null)s=Fs(t);else r=g(t._item.id.client,t._item.id.clock);return new js(r,s,e,n)},ow=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return Me(t,null,n);e--}while(r!==null){if(!r.deleted&&r.countable){if(r.length>e)return Me(t,g(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return Me(t,r.lastId,n);r=r.right}return Me(t,null,n)};var Yo=(t,e)=>{let n=At(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},Hf=(t,e,n=!0)=>{let r=e.store,{item:s,type:i,tname:o,assoc:c}=t,a=null,d=0;if(s!==null){if(y(r,s.client)<=s.clock)return null;let l=n?Zn(r,s):Yo(r,s),h=l.item;if(!(h instanceof x))return null;if(a=h.parent,a._item===null||!a._item.deleted){d=h.deleted||!h.countable?0:l.diff+(c>=0?0:1);let u=h.left;while(u!==null){if(!u.deleted&&u.countable)d+=u.length;u=u.left}}}else{if(o!==null)a=e.get(o);else if(i!==null){if(y(r,i.client)<=i.clock)return null;let{item:l}=n?Zn(r,i):{item:At(r,i)};if(l instanceof x&&l.content instanceof P)a=l.content.type;else return null}else throw B();if(c>=0)d=a._length;else d=0}return Qo(a,d,t.assoc)};class Gs{constructor(t,e){this.ds=t,this.sv=e}}var tc=(t,e)=>new Gs(t,e),Ml=tc(Os(),new Map);var Tt=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!ie(e.ds,t.id),Kn=(t,e)=>{let n=M(t.meta,Kn,j),r=t.doc.store;if(!n.has(e))e.sv.forEach((s,i)=>{if(s<y(r,i))O(t,g(i,s))}),Ct(t,e.ds,(s)=>{}),n.add(e)};class sr{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}var Qe=(t)=>{let e=new Map;return t.clients.forEach((n,r)=>{let s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},y=(t,e)=>{let n=t.clients.get(e);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},zs=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{let r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw B()}n.push(e)},H=(t,e)=>{let n=0,r=t.length-1,s=t[r],i=s.id.clock;if(i===e)return r;let o=Io(e/(i+s.length-1)*r);while(n<=r){if(s=t[o],i=s.id.clock,i<=e){if(e<i+s.length)return o;n=o+1}else r=o-1;o=Io((n+r)/2)}throw B()},ec=(t,e)=>{let n=t.clients.get(e.client);return n[H(n,e.clock)]},At=ec,Wn=(t,e,n)=>{let r=H(e,n),s=e[r];if(s.id.clock<n&&s instanceof x)return e.splice(r+1,0,Xe(t,s,n-s.id.clock)),r+1;return r},O=(t,e)=>{let n=t.doc.store.clients.get(e.client);return n[Wn(t,n,e.clock)]},ks=(t,e,n)=>{let r=e.clients.get(n.client),s=H(r,n.clock),i=r[s];if(n.clock!==i.id.clock+i.length-1&&i.constructor!==R)r.splice(s+1,0,Xe(t,i,n.clock-i.id.clock+1));return i},nc=(t,e,n)=>{let r=t.clients.get(e.id.client);r[H(r,e.id.clock)]=n},Hs=(t,e,n,r,s)=>{if(r===0)return;let i=n+r,o=Wn(t,e,n),c;do{if(c=e[o++],i<c.id.clock+c.length)Wn(t,e,i);s(c)}while(o<e.length&&e[o].id.clock<i)};class Js{constructor(t,e,n){this.doc=t,this.deleteSet=new lt,this.beforeState=Qe(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=e,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}var _s=(t,e)=>{if(e.deleteSet.clients.size===0&&!dr(e.afterState,(n,r)=>e.beforeState.get(r)!==n))return!1;return Xn(e.deleteSet),zo(t,e),Bt(t,e.deleteSet),!0},Ss=(t,e,n)=>{let r=e._item;if(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)M(t.changed,e,j).add(n)},je=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor){if(r.mergeWith(n)){if(n instanceof x&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n)n.parent._map.set(n.parentSub,r);continue}}break}let i=e-s;if(i)t.splice(e+1-i,i);return i},rc=(t,e,n)=>{for(let[r,s]of t.clients.entries()){let i=e.clients.get(r);for(let o=s.length-1;o>=0;o--){let c=s[o],a=c.clock+c.len;for(let d=H(i,c.clock),l=i[d];d<i.length&&l.id.clock<a;l=i[++d]){let h=i[d];if(c.clock+c.len<=h.id.clock)break;if(h instanceof x&&h.deleted&&!h.keep&&n(h))h.gc(e,!1)}}}},sc=(t,e)=>{t.clients.forEach((n,r)=>{let s=e.clients.get(r);for(let i=n.length-1;i>=0;i--){let o=n[i],c=fe(s.length-1,1+H(s,o.clock+o.len-1));for(let a=c,d=s[a];a>0&&d.id.clock>=o.clock;d=s[a])a-=1+je(s,a)}})};var Ps=(t,e)=>{if(e<t.length){let n=t[e],r=n.doc,s=r.store,{deleteSet:i,_mergeStructs:o}=n;try{Xn(i),n.afterState=Qe(n.doc.store),r.emit("beforeObserverCalls",[n,r]);let c=[];n.changed.forEach((a,d)=>c.push(()=>{if(d._item===null||!d._item.deleted)d._callObserver(n,a)})),c.push(()=>{n.changedParentTypes.forEach((a,d)=>{if(d._dEH.l.length>0&&(d._item===null||!d._item.deleted))c.push(()=>{a=a.filter((l)=>l.target._item===null||!l.target._item.deleted),a.forEach((l)=>{l.currentTarget=d,l._path=null}),a.sort((l,h)=>l.path.length-h.path.length),$s(d._dEH,a,n)})}),c.push(()=>r.emit("afterTransaction",[n,r])),c.push(()=>{if(n._needFormattingCleanup)kc(n)})}),Jt(c,[])}finally{if(r.gc)rc(i,s,r.gcFilter);sc(i,s),n.afterState.forEach((l,h)=>{let u=n.beforeState.get(h)||0;if(u!==l){let f=s.clients.get(h),p=W(H(f,u),1);for(let m=f.length-1;m>=p;)m-=1+je(f,m)}});for(let l=o.length-1;l>=0;l--){let{client:h,clock:u}=o[l].id,f=s.clients.get(h),p=H(f,u);if(p+1<f.length){if(je(f,p+1)>1)continue}if(p>0)je(f,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID))ds(Ut,Xt,"[yjs] ",Qt,Yt,"Changed the client-id because another client seems to be using it."),r.clientID=vs();if(r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){let l=new Ot;if(_s(l,n))r.emit("update",[l.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){let l=new Y;if(_s(l,n))r.emit("updateV2",[l.toUint8Array(),n.origin,r,n])}let{subdocsAdded:c,subdocsLoaded:a,subdocsRemoved:d}=n;if(c.size>0||d.size>0||a.size>0)c.forEach((l)=>{if(l.clientID=r.clientID,l.collectionid==null)l.collectionid=r.collectionid;r.subdocs.add(l)}),d.forEach((l)=>r.subdocs.delete(l)),r.emit("subdocs",[{loaded:a,added:c,removed:d},r,n]),d.forEach((l)=>l.destroy());if(t.length<=e+1)r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t]);else Ps(t,e+1)}}},w=(t,e,n=null,r=!0)=>{let s=t._transactionCleanups,i=!1,o=null;if(t._transaction===null){if(i=!0,t._transaction=new Js(t,n,r),s.push(t._transaction),s.length===1)t.emit("beforeAllTransactions",[t]);t.emit("beforeTransaction",[t._transaction,t])}try{o=e(t._transaction)}finally{if(i){let c=t._transaction===s[0];if(t._transaction=null,c)Ps(s,0)}}return o};class Ks{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}}var Es=(t,e,n)=>{Ct(t,n.deletions,(r)=>{if(r instanceof x&&e.scope.some((s)=>s===t.doc||Ge(s,r)))ar(r,!1)})},Is=(t,e,n)=>{let r=null,{doc:s,scope:i}=t;w(s,(c)=>{while(e.length>0&&t.currStackItem===null){let a=s.store,d=e.pop(),l=new Set,h=[],u=!1;Ct(c,d.insertions,(f)=>{if(f instanceof x){if(f.redone!==null){let{item:p,diff:m}=Zn(a,f.id);if(m>0)p=O(c,g(p.id.client,p.id.clock+m));f=p}if(!f.deleted&&i.some((p)=>p===c.doc||Ge(p,f)))h.push(f)}}),Ct(c,d.deletions,(f)=>{if(f instanceof x&&i.some((p)=>p===c.doc||Ge(p,f))&&!ie(d.insertions,f.id))l.add(f)}),l.forEach((f)=>{u=pi(c,f,l,d.insertions,t.ignoreRemoteMapChanges,t)!==null||u});for(let f=h.length-1;f>=0;f--){let p=h[f];if(t.deleteFilter(p))p.delete(c),u=!0}t.currStackItem=u?d:null}c.changed.forEach((a,d)=>{if(a.has(null)&&d._searchMarker)d._searchMarker.length=0}),r=c},t);let o=t.currStackItem;if(o!=null){let c=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:c,origin:t},t]),t.currStackItem=null}return o};class pI extends de{constructor(t,{captureTimeout:e=500,captureTransaction:n=(c)=>!0,deleteFilter:r=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:i=!1,doc:o=K(t)?t[0].doc:t instanceof vc?t:t.doc}={}){super();this.scope=[],this.doc=o,this.addToScope(t),this.deleteFilter=r,s.add(this),this.trackedOrigins=s,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=i,this.captureTimeout=e,this.afterTransactionHandler=(c)=>{if(!this.captureTransaction(c)||!this.scope.some((m)=>c.changedParentTypes.has(m)||m===this.doc)||!this.trackedOrigins.has(c.origin)&&(!c.origin||!this.trackedOrigins.has(c.origin.constructor)))return;let a=this.undoing,d=this.redoing,l=a?this.redoStack:this.undoStack;if(a)this.stopCapturing();else if(!d)this.clear(!1,!0);let h=new lt;c.afterState.forEach((m,T)=>{let b=c.beforeState.get(T)||0,hr=m-b;if(hr>0)te(h,T,b,hr)});let u=hd(),f=!1;if(this.lastChange>0&&u-this.lastChange<this.captureTimeout&&l.length>0&&!a&&!d){let m=l[l.length-1];m.deletions=Pn([m.deletions,c.deleteSet]),m.insertions=Pn([m.insertions,h])}else l.push(new Ks(c.deleteSet,h)),f=!0;if(!a&&!d)this.lastChange=u;Ct(c,c.deleteSet,(m)=>{if(m instanceof x&&this.scope.some((T)=>T===c.doc||Ge(T,m)))ar(m,!0)});let p=[{stackItem:l[l.length-1],origin:c.origin,type:a?"redo":"undo",changedParentTypes:c.changedParentTypes},this];if(f)this.emit("stack-item-added",p);else this.emit("stack-item-updated",p)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(t){let e=new Set(this.scope);t=K(t)?t:[t],t.forEach((n)=>{if(!e.has(n)){if(e.add(n),n instanceof S?n.doc!==this.doc:n!==this.doc)Hn("[yjs#509] Not same Y.Doc");this.scope.push(n)}})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,e=!0){if(t&&this.canUndo()||e&&this.canRedo())this.doc.transact((n)=>{if(t)this.undoStack.forEach((r)=>Es(n,this,r)),this.undoStack=[];if(e)this.redoStack.forEach((r)=>Es(n,this,r)),this.redoStack=[];this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=Is(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=Is(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}}function*ic(t){let e=Et(t.restDecoder);for(let n=0;n<e;n++){let r=Et(t.restDecoder),s=t.readClient(),i=Et(t.restDecoder);for(let o=0;o<r;o++){let c=t.readInfo();if(c===10){let a=Et(t.restDecoder);yield new L(g(s,i),a),i+=a}else if((Mt&c)!==0){let a=(c&(V|A))===0,d=new x(g(s,i),null,(c&A)===A?t.readLeftID():null,null,(c&V)===V?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(c&ht)===ht?t.readString():null,gi(t,c));yield d,i+=d.length}else{let a=t.readLen();yield new R(g(s,i),a),i+=a}}}}class Ye{constructor(t,e){this.gen=ic(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===L);return this.curr}}class tn{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}var oc=(t)=>ze(t,tr,Ot);var cc=(t,e)=>{if(t.constructor===R){let{client:n,clock:r}=t.id;return new R(g(n,r+e),t.length-e)}else if(t.constructor===L){let{client:n,clock:r}=t.id;return new L(g(n,r+e),t.length-e)}else{let n=t,{client:r,clock:s}=n.id;return new x(g(r,s+e),null,g(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},ze=(t,e=it,n=Y)=>{if(t.length===1)return t[0];let r=t.map((l)=>new e(fa(l))),s=r.map((l)=>new Ye(l,!0)),i=null,o=new n,c=new tn(o);while(!0){if(s=s.filter((u)=>u.curr!==null),s.sort((u,f)=>{if(u.curr.id.client===f.curr.id.client){let p=u.curr.id.clock-f.curr.id.clock;if(p===0)return u.curr.constructor===f.curr.constructor?0:u.curr.constructor===L?1:-1;else return p}else return f.curr.id.client-u.curr.id.client}),s.length===0)break;let l=s[0],h=l.curr.id.client;if(i!==null){let u=l.curr,f=!1;while(u!==null&&u.id.clock+u.length<=i.struct.id.clock+i.struct.length&&u.id.client>=i.struct.id.client)u=l.next(),f=!0;if(u===null||u.id.client!==h||f&&u.id.clock>i.struct.id.clock+i.struct.length)continue;if(h!==i.struct.id.client)X(c,i.struct,i.offset),i={struct:u,offset:0},l.next();else if(i.struct.id.clock+i.struct.length<u.id.clock)if(i.struct.constructor===L)i.struct.length=u.id.clock+u.length-i.struct.id.clock;else{X(c,i.struct,i.offset);let p=u.id.clock-i.struct.id.clock-i.struct.length;i={struct:new L(g(h,i.struct.id.clock+i.struct.length),p),offset:0}}else{let p=i.struct.id.clock+i.struct.length-u.id.clock;if(p>0)if(i.struct.constructor===L)i.struct.length-=p;else u=cc(u,p);if(!i.struct.mergeWith(u))X(c,i.struct,i.offset),i={struct:u,offset:0},l.next()}}else i={struct:l.curr,offset:0},l.next();for(let u=l.curr;u!==null&&u.id.client===h&&u.id.clock===i.struct.id.clock+i.struct.length&&u.constructor!==L;u=l.next())X(c,i.struct,i.offset),i={struct:u,offset:0}}if(i!==null)X(c,i.struct,i.offset),i=null;ir(c);let a=r.map((l)=>Qn(l)),d=Pn(a);return Bt(o,d),o.toUint8Array()},lc=(t,e,n=it,r=Y)=>{let s=Ls(e),i=new r,o=new tn(i),c=new n(fa(t)),a=new Ye(c,!1);while(a.curr){let l=a.curr,h=l.id.client,u=s.get(h)||0;if(a.curr.constructor===L){a.next();continue}if(l.id.clock+l.length>u){X(o,l,W(u-l.id.clock,0)),a.next();while(a.curr&&a.curr.id.client===h)X(o,a.curr,0),a.next()}else while(a.curr&&a.curr.id.client===h&&a.curr.id.clock+a.curr.length<=u)a.next()}ir(o);let d=Qn(c);return Bt(i,d),i.toUint8Array()};var Ws=(t)=>{if(t.written>0)t.clientStructs.push({written:t.written,restEncoder:Kr(t.encoder.restEncoder)}),t.encoder.restEncoder=ha(),t.written=0},X=(t,e,n)=>{if(t.written>0&&t.currClient!==e.id.client)Ws(t);if(t.written===0)t.currClient=e.id.client,t.encoder.writeClient(e.id.client),ft(t.encoder.restEncoder,e.id.clock+n);e.write(t.encoder,n),t.written++},ir=(t)=>{Ws(t);let e=t.encoder.restEncoder;ft(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){let r=t.clientStructs[n];ft(e,r.written),Ft(e,r.restEncoder)}},ac=(t,e,n,r)=>{let s=new n(fa(t)),i=new Ye(s,!1),o=new r,c=new tn(o);for(let d=i.curr;d!==null;d=i.next())X(c,e(d),0);ir(c);let a=Qn(s);return Bt(o,a),o.toUint8Array()};var hc=(t)=>ac(t,Mr,it,Ot),Us="You must not compute changes after the event-handler fired.";class oe{constructor(t,e){this.target=t,this.currentTarget=t,this.transaction=e,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=uc(this.currentTarget,this.target))}deletes(t){return ie(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw v(Us);let t=new Map,e=this.target;this.transaction.changed.get(e).forEach((r)=>{if(r!==null){let s=e._map.get(r),i,o;if(this.adds(s)){let c=s.left;while(c!==null&&this.adds(c))c=c.left;if(this.deletes(s))if(c!==null&&this.deletes(c))i="delete",o=he(c.content.getContent());else return;else if(c!==null&&this.deletes(c))i="update",o=he(c.content.getContent());else i="add",o=void 0}else if(this.deletes(s))i="delete",o=he(s.content.getContent());else return;t.set(r,{action:i,oldValue:o})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw v(Us);let e=this.target,n=j(),r=j(),s=[];if(t={added:n,deleted:r,delta:s,keys:this.keys},this.transaction.changed.get(e).has(null)){let o=null,c=()=>{if(o)s.push(o)};for(let a=e._start;a!==null;a=a.right)if(a.deleted){if(this.deletes(a)&&!this.adds(a)){if(o===null||o.delete===void 0)c(),o={delete:0};o.delete+=a.length,r.add(a)}}else if(this.adds(a)){if(o===null||o.insert===void 0)c(),o={insert:[]};o.insert=o.insert.concat(a.content.getContent()),n.add(a)}else{if(o===null||o.retain===void 0)c(),o={retain:0};o.retain+=a.length}if(o!==null&&o.retain===void 0)c()}this._changes=t}return t}}var uc=(t,e)=>{let n=[];while(e._item!==null&&e!==t){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;while(s!==e._item&&s!==null){if(!s.deleted&&s.countable)r+=s.length;s=s.right}n.unshift(r)}e=e._item.parent}return n},D=()=>{Hn("Invalid access: Add Yjs type to a document before reading data.")},Zs=80,or=0;class Xs{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=or++}}var dc=(t)=>{t.timestamp=or++},Qs=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=or++},fc=(t,e,n)=>{if(t.length>=Zs){let r=t.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return Qs(r,e,n),r}else{let r=new Xs(e,n);return t.push(r),r}},en=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;let n=t._searchMarker.length===0?null:t._searchMarker.reduce((i,o)=>tt(e-i.index)<tt(e-o.index)?i:o),r=t._start,s=0;if(n!==null)r=n.p,s=n.index,dc(n);while(r.right!==null&&s<e){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}while(r.left!==null&&s>e)if(r=r.left,!r.deleted&&r.countable)s-=r.length;while(r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock)if(r=r.left,!r.deleted&&r.countable)s-=r.length;if(n!==null&&tt(n.index-s)<r.parent.length/Zs)return Qs(n,r,s),n;else return fc(t._searchMarker,r,s)},ee=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){let s=t[r];if(n>0){let i=s.p;i.marker=!1;while(i&&(i.deleted||!i.countable))if(i=i.left,i&&!i.deleted&&i.countable)s.index-=i.length;if(i===null||i.marker===!0){t.splice(r,1);continue}s.p=i,i.marker=!0}if(e<s.index||n>0&&e===s.index)s.index=W(e,s.index+n)}};var nn=(t,e,n)=>{let r=t,s=e.changedParentTypes;while(!0){if(M(s,t,()=>[]).push(n),t._item===null)break;t=t._item.parent}$s(r._eH,n,e)};class S{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=xs(),this._dEH=xs(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw N()}clone(){throw N()}_write(t){}get _first(){let t=this._start;while(t!==null&&t.deleted)t=t.right;return t}_callObserver(t,e){if(!t.local&&this._searchMarker)this._searchMarker.length=0}observe(t){ys(this._eH,t)}observeDeep(t){ys(this._dEH,t)}unobserve(t){bs(this._eH,t)}unobserveDeep(t){bs(this._dEH,t)}toJSON(){}}var Ys=(t,e,n)=>{if(t.doc??D(),e<0)e=t._length+e;if(n<0)n=t._length+n;let r=n-e,s=[],i=t._start;while(i!==null&&r>0){if(i.countable&&!i.deleted){let o=i.content.getContent();if(o.length<=e)e-=o.length;else{for(let c=e;c<o.length&&r>0;c++)s.push(o[c]),r--;e=0}}i=i.right}return s},ti=(t)=>{t.doc??D();let e=[],n=t._start;while(n!==null){if(n.countable&&!n.deleted){let r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e};var ne=(t,e)=>{let n=0,r=t._start;t.doc??D();while(r!==null){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let i=0;i<s.length;i++)e(s[i],n++,t)}r=r.right}},ei=(t,e)=>{let n=[];return ne(t,(r,s)=>{n.push(e(r,s,t))}),n},pc=(t)=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){while(e!==null&&e.deleted)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}let s=n[r++];if(n.length<=r)n=null;return{done:!1,value:s}}}},ni=(t,e)=>{t.doc??D();let n=en(t,e),r=t._start;if(n!==null)r=n.p,e-=n.index;for(;r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},He=(t,e,n,r)=>{let s=n,i=t.doc,{clientID:o,store:c}=i,a=n===null?e._start:n.right,d=[],l=()=>{if(d.length>0)s=new x(g(o,y(c,o)),s,s&&s.lastId,a,a&&a.id,e,null,new ct(d)),s.integrate(t,0),d=[]};r.forEach((h)=>{if(h===null)d.push(h);else switch(h.constructor){case Number:case Object:case Boolean:case Array:case String:d.push(h);break;default:switch(l(),h.constructor){case Uint8Array:case ArrayBuffer:s=new x(g(o,y(c,o)),s,s&&s.lastId,a,a&&a.id,e,null,new ce(new Uint8Array(h))),s.integrate(t,0);break;case vc:s=new x(g(o,y(c,o)),s,s&&s.lastId,a,a&&a.id,e,null,new le(h)),s.integrate(t,0);break;default:if(h instanceof S)s=new x(g(o,y(c,o)),s,s&&s.lastId,a,a&&a.id,e,null,new P(h)),s.integrate(t,0);else throw Error("Unexpected content type in insert operation")}}}),l()},ri=()=>v("Length exceeded!"),si=(t,e,n,r)=>{if(n>e._length)throw ri();if(n===0){if(e._searchMarker)ee(e._searchMarker,n,r.length);return He(t,e,null,r)}let s=n,i=en(e,n),o=e._start;if(i!==null){if(o=i.p,n-=i.index,n===0)o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0}for(;o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){if(n<o.length)O(t,g(o.id.client,o.id.clock+n));break}n-=o.length}if(e._searchMarker)ee(e._searchMarker,s,r.length);return He(t,e,o,r)},gc=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:e._start}).p;if(s)while(s.right)s=s.right;return He(t,e,s,n)},ii=(t,e,n,r)=>{if(r===0)return;let s=n,i=r,o=en(e,n),c=e._start;if(o!==null)c=o.p,n-=o.index;for(;c!==null&&n>0;c=c.right)if(!c.deleted&&c.countable){if(n<c.length)O(t,g(c.id.client,c.id.clock+n));n-=c.length}while(r>0&&c!==null){if(!c.deleted){if(r<c.length)O(t,g(c.id.client,c.id.clock+r));c.delete(t),r-=c.length}c=c.right}if(r>0)throw ri();if(e._searchMarker)ee(e._searchMarker,s,-i+r)},Je=(t,e,n)=>{let r=e._map.get(n);if(r!==void 0)r.delete(t)},cr=(t,e,n,r)=>{let s=e._map.get(n)||null,i=t.doc,o=i.clientID,c;if(r==null)c=new ct([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new ct([r]);break;case Uint8Array:c=new ce(r);break;case vc:c=new le(r);break;default:if(r instanceof S)c=new P(r);else throw Error("Unexpected content type")}new x(g(o,y(i.store,o)),s,s&&s.lastId,null,null,e,n,c).integrate(t,0)},lr=(t,e)=>{t.doc??D();let n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},oi=(t)=>{let e={};return t.doc??D(),t._map.forEach((n,r)=>{if(!n.deleted)e[r]=n.content.getContent()[n.length-1]}),e},ci=(t,e)=>{t.doc??D();let n=t._map.get(e);return n!==void 0&&!n.deleted};var mc=(t,e)=>{let n={};return t._map.forEach((r,s)=>{let i=r;while(i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0)))i=i.left;if(i!==null&&Tt(i,e))n[s]=i.content.getContent()[i.length-1]}),n},$e=(t)=>(t.doc??D(),ms(t._map.entries(),(e)=>!e[1].deleted));class Zg extends oe{}class Bs extends S{constructor(){super();this._prelimContent=[],this._searchMarker=[]}static from(t){let e=new Bs;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Bs}clone(){let t=new Bs;return t.insert(0,this.toArray().map((e)=>e instanceof S?e.clone():e)),t}get length(){return this.doc??D(),this._length}_callObserver(t,e){super._callObserver(t,e),nn(this,t,new Zg(this,t))}insert(t,e){if(this.doc!==null)w(this.doc,(n)=>{si(n,this,t,e)});else this._prelimContent.splice(t,0,...e)}push(t){if(this.doc!==null)w(this.doc,(e)=>{gc(e,this,t)});else this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){if(this.doc!==null)w(this.doc,(n)=>{ii(n,this,t,e)});else this._prelimContent.splice(t,e)}get(t){return ni(this,t)}toArray(){return ti(this)}slice(t=0,e=this.length){return Ys(this,t,e)}toJSON(){return this.map((t)=>t instanceof S?t.toJSON():t)}map(t){return ei(this,t)}forEach(t){ne(this,t)}[Symbol.iterator](){return pc(this)}_write(t){t.writeTypeRef($c)}}var wc=(t)=>new Bs;class sw extends oe{constructor(t,e,n){super(t,e);this.keysChanged=n}}class Zo extends S{constructor(t){super();if(this._prelimContent=null,t===void 0)this._prelimContent=new Map;else this._prelimContent=new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach((n,r)=>{this.set(r,n)}),this._prelimContent=null}_copy(){return new Zo}clone(){let t=new Zo;return this.forEach((e,n)=>{t.set(n,e instanceof S?e.clone():e)}),t}_callObserver(t,e){nn(this,t,new sw(this,t,e))}toJSON(){this.doc??D();let t={};return this._map.forEach((e,n)=>{if(!e.deleted){let r=e.content.getContent()[e.length-1];t[n]=r instanceof S?r.toJSON():r}}),t}get size(){return[...$e(this)].length}keys(){return Le($e(this),(t)=>t[0])}values(){return Le($e(this),(t)=>t[1].content.getContent()[t[1].length-1])}entries(){return Le($e(this),(t)=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??D(),this._map.forEach((e,n)=>{if(!e.deleted)t(e.content.getContent()[e.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(t){if(this.doc!==null)w(this.doc,(e)=>{Je(e,this,t)});else this._prelimContent.delete(t)}set(t,e){if(this.doc!==null)w(this.doc,(n)=>{cr(n,this,t,e)});else this._prelimContent.set(t,e);return e}get(t){return lr(this,t)}has(t){return ci(this,t)}clear(){if(this.doc!==null)w(this.doc,(t)=>{this.forEach(function(e,n,r){Je(t,r,n)})});else this._prelimContent.clear()}_write(t){t.writeTypeRef(Fc)}}var xc=(t)=>new Zo,Q=(t,e)=>t===e||typeof t==="object"&&typeof e==="object"&&t&&e&&Sn(t,e);class Pe{constructor(t,e,n,r){this.left=t,this.right=e,this.index=n,this.currentAttributes=r}forward(){if(this.right===null)B();switch(this.right.content.constructor){case E:if(!this.right.deleted)vt(this.currentAttributes,this.right.content);break;default:if(!this.right.deleted)this.index+=this.right.length;break}this.left=this.right,this.right=this.right.right}}var Ts=(t,e,n)=>{while(e.right!==null&&n>0){switch(e.right.content.constructor){case E:if(!e.right.deleted)vt(e.currentAttributes,e.right.content);break;default:if(!e.right.deleted){if(n<e.right.length)O(t,g(e.right.id.client,e.right.id.clock+n));e.index+=e.right.length,n-=e.right.length}break}e.left=e.right,e.right=e.right.right}return e},Fe=(t,e,n,r)=>{let s=new Map,i=r?en(e,n):null;if(i){let o=new Pe(i.p.left,i.p,i.index,s);return Ts(t,o,n-i.index)}else{let o=new Pe(null,e._start,0,s);return Ts(t,o,n)}},li=(t,e,n,r)=>{while(n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===E&&Q(r.get(n.right.content.key),n.right.content.value))){if(!n.right.deleted)r.delete(n.right.content.key);n.forward()}let s=t.doc,i=s.clientID;r.forEach((o,c)=>{let{left:a,right:d}=n,l=new x(g(i,y(s.store,i)),a,a&&a.lastId,d,d&&d.id,e,null,new E(c,o));l.integrate(t,0),n.right=l,n.forward()})},vt=(t,e)=>{let{key:n,value:r}=e;if(r===null)t.delete(n);else t.set(n,r)},ai=(t,e)=>{while(!0){if(t.right===null)break;else if(t.right.deleted||t.right.content.constructor===E&&Q(e[t.right.content.key]??null,t.right.content.value));else break;t.forward()}},hi=(t,e,n,r)=>{let s=t.doc,i=s.clientID,o=new Map;for(let c in r){let a=r[c],d=n.currentAttributes.get(c)??null;if(!Q(d,a)){o.set(c,d);let{left:l,right:h}=n;n.right=new x(g(i,y(s.store,i)),l,l&&l.lastId,h,h&&h.id,e,null,new E(c,a)),n.right.integrate(t,0),n.forward()}}return o},Jn=(t,e,n,r,s)=>{n.currentAttributes.forEach((u,f)=>{if(s[f]===void 0)s[f]=null});let i=t.doc,o=i.clientID;ai(n,s);let c=hi(t,e,n,s),a=r.constructor===String?new J(r):r instanceof S?new P(r):new at(r),{left:d,right:l,index:h}=n;if(e._searchMarker)ee(e._searchMarker,n.index,a.getLength());l=new x(g(o,y(i.store,o)),d,d&&d.lastId,l,l&&l.id,e,null,a),l.integrate(t,0),n.right=l,n.index=h,n.forward(),li(t,e,n,c)},As=(t,e,n,r,s)=>{let i=t.doc,o=i.clientID;ai(n,s);let c=hi(t,e,n,s);t:while(n.right!==null&&(r>0||c.size>0&&(n.right.deleted||n.right.content.constructor===E))){if(!n.right.deleted)switch(n.right.content.constructor){case E:{let{key:a,value:d}=n.right.content,l=s[a];if(l!==void 0){if(Q(l,d))c.delete(a);else{if(r===0)break t;c.set(a,d)}n.right.delete(t)}else n.currentAttributes.set(a,d);break}default:if(r<n.right.length)O(t,g(n.right.id.client,n.right.id.clock+r));r-=n.right.length;break}n.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
4
+ `;n.right=new x(g(o,y(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new J(a)),n.right.integrate(t,0),n.forward()}li(t,e,n,c)},ui=(t,e,n,r,s)=>{let i=e,o=I();while(i&&(!i.countable||i.deleted)){if(!i.deleted&&i.content.constructor===E){let d=i.content;o.set(d.key,d)}i=i.right}let c=0,a=!1;while(e!==i){if(n===e)a=!0;if(!e.deleted){let d=e.content;switch(d.constructor){case E:{let{key:l,value:h}=d,u=r.get(l)??null;if(o.get(l)!==d||u===h){if(e.delete(t),c++,!a&&(s.get(l)??null)===h&&u!==h)if(u===null)s.delete(l);else s.set(l,u)}if(!a&&!e.deleted)vt(s,d);break}}}e=e.right}return c},yc=(t,e)=>{while(e&&e.right&&(e.right.deleted||!e.right.countable))e=e.right;let n=new Set;while(e&&(e.deleted||!e.countable)){if(!e.deleted&&e.content.constructor===E){let r=e.content.key;if(n.has(r))e.delete(t);else n.add(r)}e=e.left}},bc=(t)=>{let e=0;return w(t.doc,(n)=>{let{_start:r,_start:s}=t,i=I(),o=ae(i);while(s){if(s.deleted===!1)switch(s.content.constructor){case E:vt(o,s.content);break;default:e+=ui(n,r,s,i,o),i=ae(o),r=s;break}s=s.right}}),e},kc=(t)=>{let e=new Set,n=t.doc;for(let[r,s]of t.afterState.entries()){let i=t.beforeState.get(r)||0;if(s===i)continue;Hs(t,n.store.clients.get(r),i,s,(o)=>{if(!o.deleted&&o.content.constructor===E&&o.constructor!==R)e.add(o.parent)})}w(n,(r)=>{Ct(t,t.deleteSet,(s)=>{if(s instanceof R||!s.parent._hasFormatting||e.has(s.parent))return;let i=s.parent;if(s.content.constructor===E)e.add(i);else yc(r,s)});for(let s of e)bc(s)})},Cs=(t,e,n)=>{let r=n,s=ae(e.currentAttributes),i=e.right;while(n>0&&e.right!==null){if(e.right.deleted===!1)switch(e.right.content.constructor){case P:case at:case J:if(n<e.right.length)O(t,g(e.right.id.client,e.right.id.clock+n));n-=e.right.length,e.right.delete(t);break}e.forward()}if(i)ui(t,i,e.right,s,e.currentAttributes);let o=(e.left||e.right).parent;if(o._searchMarker)ee(o._searchMarker,e.index,-r+n);return e};class aw extends oe{constructor(t,e,n){super(t,e);this.childListChanged=!1,this.keysChanged=new Set,n.forEach((r)=>{if(r===null)this.childListChanged=!0;else this.keysChanged.add(r)})}get changes(){if(this._changes===null){let t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){let t=this.target.doc,e=[];w(t,(n)=>{let r=new Map,s=new Map,i=this.target._start,o=null,c={},a="",d=0,l=0,h=()=>{if(o!==null){let u=null;switch(o){case"delete":if(l>0)u={delete:l};l=0;break;case"insert":if(typeof a==="object"||a.length>0){if(u={insert:a},r.size>0)u.attributes={},r.forEach((f,p)=>{if(f!==null)u.attributes[p]=f})}a="";break;case"retain":if(d>0){if(u={retain:d},!Vr(c))u.attributes=Nr({},c)}d=0;break}if(u)e.push(u);o=null}};while(i!==null){switch(i.content.constructor){case P:case at:if(this.adds(i)){if(!this.deletes(i))h(),o="insert",a=i.content.getContent()[0],h()}else if(this.deletes(i)){if(o!=="delete")h(),o="delete";l+=1}else if(!i.deleted){if(o!=="retain")h(),o="retain";d+=1}break;case J:if(this.adds(i)){if(!this.deletes(i)){if(o!=="insert")h(),o="insert";a+=i.content.str}}else if(this.deletes(i)){if(o!=="delete")h(),o="delete";l+=i.length}else if(!i.deleted){if(o!=="retain")h(),o="retain";d+=i.length}break;case E:{let{key:u,value:f}=i.content;if(this.adds(i)){if(!this.deletes(i)){let p=r.get(u)??null;if(!Q(p,f)){if(o==="retain")h();if(Q(f,s.get(u)??null))delete c[u];else c[u]=f}else if(f!==null)i.delete(n)}}else if(this.deletes(i)){s.set(u,f);let p=r.get(u)??null;if(!Q(p,f)){if(o==="retain")h();c[u]=p}}else if(!i.deleted){s.set(u,f);let p=c[u];if(p!==void 0){if(!Q(p,f)){if(o==="retain")h();if(f===null)delete c[u];else c[u]=f}else if(p!==null)i.delete(n)}}if(!i.deleted){if(o==="insert")h();vt(r,i.content)}break}}i=i.right}h();while(e.length>0){let u=e[e.length-1];if(u.retain!==void 0&&u.attributes===void 0)e.pop();else break}}),this._delta=e}return this._delta}}class ps extends S{constructor(t){super();this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??D(),this._length}_integrate(t,e){super._integrate(t,e);try{this._pending.forEach((n)=>n())}catch(n){console.error(n)}this._pending=null}_copy(){return new ps}clone(){let t=new ps;return t.applyDelta(this.toDelta()),t}_callObserver(t,e){super._callObserver(t,e);let n=new aw(this,t,e);if(nn(this,t,n),!t.local&&this._hasFormatting)t._needFormattingCleanup=!0}toString(){this.doc??D();let t="",e=this._start;while(e!==null){if(!e.deleted&&e.countable&&e.content.constructor===J)t+=e.content.str;e=e.right}return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:e=!0}={}){if(this.doc!==null)w(this.doc,(n)=>{let r=new Pe(null,this._start,0,new Map);for(let s=0;s<t.length;s++){let i=t[s];if(i.insert!==void 0){let o=!e&&typeof i.insert==="string"&&s===t.length-1&&r.right===null&&i.insert.slice(-1)===`
5
+ `?i.insert.slice(0,-1):i.insert;if(typeof o!=="string"||o.length>0)Jn(n,this,r,o,i.attributes||{})}else if(i.retain!==void 0)As(n,this,r,i.retain,i.attributes||{});else if(i.delete!==void 0)Cs(n,r,i.delete)}});else this._pending.push(()=>this.applyDelta(t))}toDelta(t,e,n){this.doc??D();let r=[],s=new Map,i=this.doc,o="",c=this._start;function a(){if(o.length>0){let l={},h=!1;s.forEach((f,p)=>{h=!0,l[p]=f});let u={insert:o};if(h)u.attributes=l;r.push(u),o=""}}let d=()=>{while(c!==null){if(Tt(c,t)||e!==void 0&&Tt(c,e))switch(c.content.constructor){case J:{let l=s.get("ychange");if(t!==void 0&&!Tt(c,t)){if(l===void 0||l.user!==c.id.client||l.type!=="removed")a(),s.set("ychange",n?n("removed",c.id):{type:"removed"})}else if(e!==void 0&&!Tt(c,e)){if(l===void 0||l.user!==c.id.client||l.type!=="added")a(),s.set("ychange",n?n("added",c.id):{type:"added"})}else if(l!==void 0)a(),s.delete("ychange");o+=c.content.str;break}case P:case at:{a();let l={insert:c.content.getContent()[0]};if(s.size>0){let h={};l.attributes=h,s.forEach((u,f)=>{h[f]=u})}r.push(l);break}case E:if(Tt(c,t))a(),vt(s,c.content);break}c=c.right}a()};if(t||e)w(i,(l)=>{if(t)Kn(l,t);if(e)Kn(l,e);d()},"cleanup");else d();return r}insert(t,e,n){if(e.length<=0)return;let r=this.doc;if(r!==null)w(r,(s)=>{let i=Fe(s,this,t,!n);if(!n)n={},i.currentAttributes.forEach((o,c)=>{n[c]=o});Jn(s,this,i,e,n)});else this._pending.push(()=>this.insert(t,e,n))}insertEmbed(t,e,n){let r=this.doc;if(r!==null)w(r,(s)=>{let i=Fe(s,this,t,!n);Jn(s,this,i,e,n||{})});else this._pending.push(()=>this.insertEmbed(t,e,n||{}))}delete(t,e){if(e===0)return;let n=this.doc;if(n!==null)w(n,(r)=>{Cs(r,Fe(r,this,t,!0),e)});else this._pending.push(()=>this.delete(t,e))}format(t,e,n){if(e===0)return;let r=this.doc;if(r!==null)w(r,(s)=>{let i=Fe(s,this,t,!1);if(i.right===null)return;As(s,this,i,e,n)});else this._pending.push(()=>this.format(t,e,n))}removeAttribute(t){if(this.doc!==null)w(this.doc,(e)=>{Je(e,this,t)});else this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,e){if(this.doc!==null)w(this.doc,(n)=>{cr(n,this,t,e)});else this._pending.push(()=>this.setAttribute(t,e))}getAttribute(t){return lr(this,t)}getAttributes(){return oi(this)}_write(t){t.writeTypeRef(jc)}}var _c=(t)=>new ps;class qe{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??D()}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(e)))do if(e=t.content.type,!t.deleted&&(e.constructor===Dt||e.constructor===ot)&&e._start!==null)t=e._start;else while(t!==null){let n=t.next;if(n!==null){t=n;break}else if(t.parent===this._root)t=null;else t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));if(this._firstCall=!1,t===null)return{value:void 0,done:!0};return this._currentNode=t,{value:t.content.type,done:!1}}}class ot extends S{constructor(){super();this._prelimContent=[]}get firstChild(){let t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ot}clone(){let t=new ot;return t.insert(0,this.toArray().map((e)=>e instanceof S?e.clone():e)),t}get length(){return this.doc??D(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new qe(this,t)}querySelector(t){t=t.toUpperCase();let n=new qe(this,(r)=>r.nodeName&&r.nodeName.toUpperCase()===t).next();if(n.done)return null;else return n.value}querySelectorAll(t){return t=t.toUpperCase(),F(new qe(this,(e)=>e.nodeName&&e.nodeName.toUpperCase()===t))}_callObserver(t,e){nn(this,t,new di(this,e,t))}toString(){return ei(this,(t)=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},n){let r=t.createDocumentFragment();if(n!==void 0)n._createAssociation(r,this);return ne(this,(s)=>{r.insertBefore(s.toDOM(t,e,n),null)}),r}insert(t,e){if(this.doc!==null)w(this.doc,(n)=>{si(n,this,t,e)});else this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(this.doc!==null)w(this.doc,(n)=>{let r=t&&t instanceof S?t._item:t;He(n,this,r,e)});else{let n=this._prelimContent,r=t===null?0:n.findIndex((s)=>s===t)+1;if(r===0&&t!==null)throw v("Reference item not found");n.splice(r,0,...e)}}delete(t,e=1){if(this.doc!==null)w(this.doc,(n)=>{ii(n,this,t,e)});else this._prelimContent.splice(t,e)}toArray(){return ti(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return ni(this,t)}slice(t=0,e=this.length){return Ys(this,t,e)}forEach(t){ne(this,t)}_write(t){t.writeTypeRef(Gc)}}var Sc=(t)=>new ot;class Dt extends ot{constructor(t="UNDEFINED"){super();this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,e){super._integrate(t,e),this._prelimAttrs.forEach((n,r)=>{this.setAttribute(r,n)}),this._prelimAttrs=null}_copy(){return new Dt(this.nodeName)}clone(){let t=new Dt(this.nodeName),e=this.getAttributes();return Lr(e,(n,r)=>{t.setAttribute(r,n)}),t.insert(0,this.toArray().map((n)=>n instanceof S?n.clone():n)),t}toString(){let t=this.getAttributes(),e=[],n=[];for(let o in t)n.push(o);n.sort();let r=n.length;for(let o=0;o<r;o++){let c=n[o];e.push(c+'="'+t[c]+'"')}let s=this.nodeName.toLocaleLowerCase(),i=e.length>0?" "+e.join(" "):"";return`<${s}${i}>${super.toString()}</${s}>`}removeAttribute(t){if(this.doc!==null)w(this.doc,(e)=>{Je(e,this,t)});else this._prelimAttrs.delete(t)}setAttribute(t,e){if(this.doc!==null)w(this.doc,(n)=>{cr(n,this,t,e)});else this._prelimAttrs.set(t,e)}getAttribute(t){return lr(this,t)}hasAttribute(t){return ci(this,t)}getAttributes(t){return t?mc(this,t):oi(this)}toDOM(t=document,e={},n){let r=t.createElement(this.nodeName),s=this.getAttributes();for(let i in s){let o=s[i];if(typeof o==="string")r.setAttribute(i,o)}if(ne(this,(i)=>{r.appendChild(i.toDOM(t,e,n))}),n!==void 0)n._createAssociation(r,this);return r}_write(t){t.writeTypeRef(qc),t.writeKey(this.nodeName)}}var Ec=(t)=>new Dt(t.readKey());class di extends oe{constructor(t,e,n){super(t,n);this.childListChanged=!1,this.attributesChanged=new Set,e.forEach((r)=>{if(r===null)this.childListChanged=!0;else this.attributesChanged.add(r)})}}class Ke extends Zo{constructor(t){super();this.hookName=t}_copy(){return new Ke(this.hookName)}clone(){let t=new Ke(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(t=document,e={},n){let r=e[this.hookName],s;if(r!==void 0)s=r.createDom(this);else s=document.createElement(this.hookName);if(s.setAttribute("data-yjs-hook",this.hookName),n!==void 0)n._createAssociation(s,this);return s}_write(t){t.writeTypeRef(zc),t.writeKey(this.hookName)}}var Ic=(t)=>new Ke(t.readKey());class We extends ps{get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new We}clone(){let t=new We;return t.applyDelta(this.toDelta()),t}toDOM(t=document,e,n){let r=t.createTextNode(this.toString());if(n!==void 0)n._createAssociation(r,this);return r}toString(){return this.toDelta().map((t)=>{let e=[];for(let r in t.attributes){let s=[];for(let i in t.attributes[r])s.push({key:i,value:t.attributes[r][i]});s.sort((i,o)=>i.key<o.key?-1:1),e.push({nodeName:r,attrs:s})}e.sort((r,s)=>r.nodeName<s.nodeName?-1:1);let n="";for(let r=0;r<e.length;r++){let s=e[r];n+=`<${s.nodeName}`;for(let i=0;i<s.attrs.length;i++){let o=s.attrs[i];n+=` ${o.key}="${o.value}"`}n+=">"}n+=t.insert;for(let r=e.length-1;r>=0;r--)n+=`</${e[r].nodeName}>`;return n}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Hc)}}var Uc=(t)=>new We;class rn{constructor(t,e){this.id=t,this.length=e}get deleted(){throw N()}mergeWith(t){return!1}write(t,e,n){throw N()}integrate(t,e){throw N()}}var Tc=0;class R extends rn{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){if(e>0)this.id.clock+=e,this.length-=e;zs(t.doc.store,this)}write(t,e){t.writeInfo(Tc),t.writeLen(this.length-e)}getMissing(t,e){return null}}class ce{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new ce(this.content)}splice(t){throw N()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}var Ac=(t)=>new ce(t.readBuf());class re{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new re(this.len)}splice(t){let e=new re(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){te(t.deleteSet,e.id.client,e.id.clock,this.len),e.markDeleted()}delete(t){}gc(t){}write(t,e){t.writeLen(this.len-e)}getRef(){return 1}}var Cc=(t)=>new re(t.readLen()),fi=(t,e)=>new vc({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class le{constructor(t){if(t._item)console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid.");this.doc=t;let e={};if(this.opts=e,!t.gc)e.gc=!1;if(t.autoLoad)e.autoLoad=!0;if(t.meta!==null)e.meta=t.meta}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new le(fi(this.doc.guid,this.opts))}splice(t){throw N()}mergeWith(t){return!1}integrate(t,e){if(this.doc._item=e,t.subdocsAdded.add(this.doc),this.doc.shouldLoad)t.subdocsLoaded.add(this.doc)}delete(t){if(t.subdocsAdded.has(this.doc))t.subdocsAdded.delete(this.doc);else t.subdocsRemoved.add(this.doc)}gc(t){}write(t,e){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}var Dc=(t)=>new le(fi(t.readString(),t.readAny()));class at{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new at(this.embed)}splice(t){throw N()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}var Bc=(t)=>new at(t.readJSON());class E{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new E(this.key,this.value)}splice(t){throw N()}mergeWith(t){return!1}integrate(t,e){let n=e.parent;n._searchMarker=null,n._hasFormatting=!0}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}var Oc=(t)=>new E(t.readKey(),t.readJSON());class Ze{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Ze(this.arr)}splice(t){let e=new Ze(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){let s=this.arr[r];t.writeString(s===void 0?"undefined":JSON.stringify(s))}}getRef(){return 2}}var Nc=(t)=>{let e=t.readLen(),n=[];for(let r=0;r<e;r++){let s=t.readString();if(s==="undefined")n.push(void 0);else n.push(JSON.parse(s))}return new Ze(n)},Rc=Kt("node_env")==="development";class ct{constructor(t){this.arr=t,Rc&&En(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ct(this.arr)}splice(t){let e=new ct(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){let s=this.arr[r];t.writeAny(s)}}getRef(){return 8}}var Lc=(t)=>{let e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new ct(n)};class J{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new J(this.str)}splice(t){let e=new J(this.str.slice(t));this.str=this.str.slice(0,t);let n=this.str.charCodeAt(t-1);if(n>=55296&&n<=56319)this.str=this.str.slice(0,t-1)+"�",e.str="�"+e.str.slice(1);return e}mergeWith(t){return this.str+=t.str,!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(e===0?this.str:this.str.slice(e))}getRef(){return 4}}var Vc=(t)=>new J(t.readString()),Mc=[wc,xc,_c,Ec,Sc,Ic,Uc],$c=0,Fc=1,jc=2,qc=3,Gc=4,zc=5,Hc=6;class P{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new P(this.type._copy())}splice(t){throw N()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;while(e!==null){if(!e.deleted)e.delete(t);else if(e.id.clock<(t.beforeState.get(e.id.client)||0))t._mergeStructs.push(e);e=e.right}this.type._map.forEach((n)=>{if(!n.deleted)n.delete(t);else if(n.id.clock<(t.beforeState.get(n.id.client)||0))t._mergeStructs.push(n)}),t.changed.delete(this.type)}gc(t){let e=this.type._start;while(e!==null)e.gc(t,!0),e=e.right;this.type._start=null,this.type._map.forEach((n)=>{while(n!==null)n.gc(t,!0),n=n.left}),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}var Jc=(t)=>new P(Mc[t.readTypeRef()](t)),Zn=(t,e)=>{let n=e,r=0,s;do{if(r>0)n=g(n.client,n.clock+r);s=At(t,n),r=n.clock-s.id.clock,n=s.redone}while(n!==null&&s instanceof x);return{item:s,diff:r}},ar=(t,e)=>{while(t!==null&&t.keep!==e)t.keep=e,t=t.parent._item},Xe=(t,e,n)=>{let{client:r,clock:s}=e.id,i=new x(g(r,s+n),e,g(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));if(e.deleted)i.markDeleted();if(e.keep)i.keep=!0;if(e.redone!==null)i.redone=g(e.redone.client,e.redone.clock+n);if(e.right=i,i.right!==null)i.right.left=i;if(t._mergeStructs.push(i),i.parentSub!==null&&i.right===null)i.parent._map.set(i.parentSub,i);return e.length=n,i},Ds=(t,e)=>Rt(t,(n)=>ie(n.deletions,e)),pi=(t,e,n,r,s,i)=>{let o=t.doc,{store:c,clientID:a}=o,d=e.redone;if(d!==null)return O(t,d);let l=e.parent._item,h=null,u;if(l!==null&&l.deleted===!0){if(l.redone===null&&(!n.has(l)||pi(t,l,n,r,s,i)===null))return null;while(l.redone!==null)l=O(t,l.redone)}let f=l===null?e.parent:l.content.type;if(e.parentSub===null){h=e.left,u=e;while(h!==null){let b=h;while(b!==null&&b.parent._item!==l)b=b.redone===null?null:O(t,b.redone);if(b!==null&&b.parent._item===l){h=b;break}h=h.left}while(u!==null){let b=u;while(b!==null&&b.parent._item!==l)b=b.redone===null?null:O(t,b.redone);if(b!==null&&b.parent._item===l){u=b;break}u=u.right}}else{if(u=null,e.right&&!s){h=e;while(h!==null&&h.right!==null&&(h.right.redone||ie(r,h.right.id)||Ds(i.undoStack,h.right.id)||Ds(i.redoStack,h.right.id))){h=h.right;while(h.redone)h=O(t,h.redone)}if(h&&h.right!==null)return null}else h=f._map.get(e.parentSub)||null;if(h!==null&&h.parent._item!==l)h=f._map.get(e.parentSub)||null}let p=y(c,a),m=g(a,p),T=new x(m,h,h&&h.lastId,u,u&&u.id,f,e.parentSub,e.content.copy());return e.redone=m,ar(T,!0),T.integrate(t,0),T};class x extends rn{constructor(t,e,n,r,s,i,o,c){super(t,c.getLength());this.origin=n,this.left=e,this.right=r,this.rightOrigin=s,this.parent=i,this.parentSub=o,this.redone=null,this.content=c,this.info=this.content.isCountable()?cn:0}set marker(t){if((this.info&me)>0!==t)this.info^=me}get marker(){return(this.info&me)>0}get keep(){return(this.info&on)>0}set keep(t){if(this.keep!==t)this.info^=on}get countable(){return(this.info&cn)>0}get deleted(){return(this.info&ge)>0}set deleted(t){if(this.deleted!==t)this.info^=ge}markDeleted(){this.info|=ge}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=y(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=y(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===st&&this.id.client!==this.parent.client&&this.parent.clock>=y(e,this.parent.client))return this.parent.client;if(this.origin)this.left=ks(t,e,this.origin),this.origin=this.left.lastId;if(this.rightOrigin)this.right=O(t,this.rightOrigin),this.rightOrigin=this.right.id;if(this.left&&this.left.constructor===R||this.right&&this.right.constructor===R)this.parent=null;else if(!this.parent){if(this.left&&this.left.constructor===x)this.parent=this.left.parent,this.parentSub=this.left.parentSub;else if(this.right&&this.right.constructor===x)this.parent=this.right.parent,this.parentSub=this.right.parentSub}else if(this.parent.constructor===st){let n=At(e,this.parent);if(n.constructor===R)this.parent=null;else this.parent=n.content.type}return null}integrate(t,e){if(e>0)this.id.clock+=e,this.left=ks(t,t.doc.store,g(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(e),this.length-=e;if(this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let n=this.left,r;if(n!==null)r=n.right;else if(this.parentSub!==null){r=this.parent._map.get(this.parentSub)||null;while(r!==null&&r.left!==null)r=r.left}else r=this.parent._start;let s=new Set,i=new Set;while(r!==null&&r!==this.right){if(i.add(r),s.add(r),Ve(this.origin,r.origin)){if(r.id.client<this.id.client)n=r,s.clear();else if(Ve(this.rightOrigin,r.rightOrigin))break}else if(r.origin!==null&&i.has(At(t.doc.store,r.origin))){if(!s.has(At(t.doc.store,r.origin)))n=r,s.clear()}else break;r=r.right}this.left=n}if(this.left!==null){let n=this.left.right;this.right=n,this.left.right=this}else{let n;if(this.parentSub!==null){n=this.parent._map.get(this.parentSub)||null;while(n!==null&&n.left!==null)n=n.left}else n=this.parent._start,this.parent._start=this;this.right=n}if(this.right!==null)this.right.left=this;else if(this.parentSub!==null){if(this.parent._map.set(this.parentSub,this),this.left!==null)this.left.delete(t)}if(this.parentSub===null&&this.countable&&!this.deleted)this.parent._length+=this.length;if(zs(t.doc.store,this),this.content.integrate(t,this),Ss(t,this.parent,this.parentSub),this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)this.delete(t)}else new R(this.id,this.length).integrate(t,0)}get next(){let t=this.right;while(t!==null&&t.deleted)t=t.right;return t}get prev(){let t=this.left;while(t!==null&&t.deleted)t=t.left;return t}get lastId(){return this.length===1?this.id:g(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Ve(t.origin,this.lastId)&&this.right===t&&Ve(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){let e=this.parent._searchMarker;if(e)e.forEach((n)=>{if(n.p===t){if(n.p=this,!this.deleted&&this.countable)n.index-=this.length}});if(t.keep)this.keep=!0;if(this.right=t.right,this.right!==null)this.right.left=this;return this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){let e=this.parent;if(this.countable&&this.parentSub===null)e._length-=this.length;this.markDeleted(),te(t.deleteSet,this.id.client,this.id.clock,this.length),Ss(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw B();if(this.content.gc(t),e)nc(t,this,new R(this.id,this.length));else this.content=new re(this.length)}write(t,e){let n=e>0?g(this.id.client,this.id.clock+e-1):this.origin,r=this.rightOrigin,s=this.parentSub,i=this.content.getRef()&Mt|(n===null?0:A)|(r===null?0:V)|(s===null?0:ht);if(t.writeInfo(i),n!==null)t.writeLeftID(n);if(r!==null)t.writeRightID(r);if(n===null&&r===null){let o=this.parent;if(o._item!==void 0){let c=o._item;if(c===null){let a=Fs(o);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(c.id)}else if(o.constructor===String)t.writeParentInfo(!0),t.writeString(o);else if(o.constructor===st)t.writeParentInfo(!1),t.writeLeftID(o);else B();if(s!==null)t.writeString(s)}this.content.write(t,e)}}var gi=(t,e)=>Pc[e&Mt](t),Pc=[()=>{B()},Cc,Nc,Ac,Vc,Bc,Oc,Jc,Lc,Dc,()=>{B()}],Kc=10;class L extends rn{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){B()}write(t,e){t.writeInfo(Kc),ft(t.restEncoder,this.length-e)}getMissing(t,e){return null}}var mi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},wi="__ $YJS$ __";if(mi[wi]===!0)console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");mi[wi]=!0;var Ok=0,Ak=1,Pk=2,Mk=3;class Bf extends Error{constructor(t){super(t);this.name="EnvelopeError"}}function M0(t){let e=ha();switch(t.type){case"doc-sync":{ft(e,Ok),pa(e,t.path),ft(e,t.epoch),wr(e,t.body);break}case"awareness":{ft(e,Ak),wr(e,t.body);break}case"doc-close":{ft(e,Pk),pa(e,t.path);break}case"control":{ft(e,Mk),pa(e,JSON.stringify(t.message));break}default:throw new Bf(`unknown-frame:${t.type}`)}return Kr(e)}function F0(t){try{let e=fa(t),n=Et(e);switch(n){case Ok:{let r=ma(e),s=Et(e);return{body:Rr(e),epoch:s,path:r,type:"doc-sync"}}case Ak:return{body:Rr(e),type:"awareness"};case Pk:return{path:ma(e),type:"doc-close"};case Mk:{let r=JSON.parse(ma(e));if(typeof r!=="object"||typeof r.type!=="string")throw new Bf("malformed-control");return{message:r,type:"control"}}default:throw new Bf(`unknown-frame-type:${n}`)}}catch(e){if(e instanceof Bf)throw e;throw new Bf(`malformed-frame: ${e instanceof Error?e.message:String(e)}`)}}
6
+ export{A0,Io,ha,P0,Kr,ft,pa,wr,fa,Rr,Et,ma,hd,Iu,vc,Ik,Dk,Nk,ow,Hf,pI,Zg,Bs,sw,Zo,aw,ps,Ok,Ak,Pk,Mk,Bf,M0,F0};
7
+
8
+ //# debugId=B9AEFB48F64726C964756E2164756E21
9
+ //# sourceMappingURL=studio-j03zga3y.js.map
@@ -1,5 +1,5 @@
1
- import{p}from"./studio-y7jehjrp.js";import{rt,zt,T,R,Ct}from"./studio-7qvs7v0m.js";import{v}from"./studio-fqq890ap.js";import{Ir}from"./studio-xkfs0dp2.js";import{Al,Ld,_c,Gi,Va,Id,Bu}from"./studio-e47215hh.js";import{sb,bE,ab,yE,wE}from"./studio-fthwn4kf.js";import{Cc}from"./studio-5d7wfmnp.js";import{Tv,Ai}from"./studio-tp642n5g.js";import{Oe}from"./studio-vavmwshr.js";var E={$schema:"https://jxsuite.com/schema/v1",$id:"StudioMediaField",$description:"The media field: a thumbnail of what the value names, the value itself, and the two doors to a different one. It is a LEAF a caller interpolates — the Inspector's Content tab, the Signals panel and the grid's image-cell panel each draw an empty host and `ui/media-picker.ts` mounts this into it — so it has no chrome of its own and takes its width from whatever row it lands in. **Browse is addressed through its `part`, not through a class.** `ui/regions.ts` derives `inspector/field:<prop>/browse` by finding the Browse control inside the Inspector's own `[data-prop]` row; the handle used to be `.media-picker-browse`, and a document emits no class, so `[part=\"browse\"]` is the handle now. The four `.media-picker*` rules from `styles/overlays.css` are TRANSCRIBED here rather than shared, for the reason `doc-header.json` gives: a class a document does not emit cannot style it. `--radius` becomes `--jx-radius-sm` on the way, because a document mounted in a pane's stage is outside `<sp-theme>` and would otherwise take a fallback rather than follow the theme.",tagName:"div",attributes:{part:"media-field"},style:{$description:"The row's own layout and the four transcribed `.media-picker*` rules. Upload and Browse never shrink, so the FIELD is what yields width when the row is narrow — the buttons would otherwise collapse into unreadable stubs before the text did.",display:"flex",alignItems:"center",gap:"var(--jx-space-1)",flex:"1",minWidth:"0",fontFamily:"var(--jx-font-sans)",fontSize:"var(--jx-text-md)",color:"var(--fg)",'& [part="value"]':{flex:"1",minWidth:"0"},'& [part="upload"]':{flexShrink:"0"},'& [part="browse"]':{flexShrink:"0"},'& [part="thumb"]':{width:"24px",height:"24px",objectFit:"cover",borderRadius:"var(--jx-radius-sm)",border:"1px solid var(--border)",flexShrink:"0"}},children:[{tagName:"span",attributes:{part:"thumb-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/thumbState"},cases:{shown:{$description:"Decorative on purpose: the field beside it already states the path in text, so a caption here would be the same fact twice to a screen reader and nothing to anyone else.",tagName:"img",attributes:{part:"thumb",src:"${state.thumbSrc}",alt:""}}}},{tagName:"jx-textfield",attributes:{part:"value"},$props:{size:"sm",label:"${state.label}",placeholder:"/image.jpg",value:{$ref:"#/state/value"}},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/edit"},value:[{$ref:"event#/target/value"}]}],description:"Every keystroke, because the host debounces it: the canvas follows the typing without a document write per character."},onfocus:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/warm"},value:[]}],description:"Entering the field is the earliest honest signal that a pick is coming, so the project's media are listed then rather than when Browse is pressed."}},{tagName:"jx-action-button",attributes:{part:"upload"},$props:{size:"sm",quiet:!0,icon:"upload-simple",label:"Upload media",hint:"Upload media"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/upload"},value:[]}]}},{tagName:"jx-action-button",attributes:{part:"browse"},$props:{size:"sm",quiet:!0,icon:"image",label:"Browse media",hint:"Browse media"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/browse"},value:[{$ref:"event#/currentTarget"}]}],description:"The button hands over ITSELF: the browser is a popover and the platform wants its invoker, both so a second press on this control toggles rather than reopens and so focus comes back here when it closes."}}]};T("media-field",E);function O(t,e){t.label=e.label,t.value=e.value,t.thumbState=e.thumbState,t.thumbSrc=e.thumbSrc}function j(t,e,r){let i=v({browse:r.browse,edit:r.edit,label:e.label,thumbSrc:e.thumbSrc,thumbState:e.thumbState,upload:r.upload,value:e.value,warm:r.warm}),a=null,o=!1;return R("media-field",i,t).then((n)=>{if(o){n.dispose();return}a=n}),{dispose(){o=!0,a?.dispose(),a=null},update:(n)=>O(i,n)}}function ld(t){let{anchor:e,name:r,scope:i,slot:a}=t,o=document.createElement("div");o.style.pointerEvents="auto",o.setAttribute(rt,zt("popover",a)),Ct("popover").append(o);let n=new AbortController,s=null,w=null,c=!1,F=(m)=>{if(c)return;if(c=!0,n.abort(),w?.dispose(),w=null,o.remove(),m)t.onDismissed?.()},A=(async()=>{let m=await R(r,i,o,{signal:n.signal,...t.onNodeCreated?{onNodeCreated:t.onNodeCreated}:{}});if(n.signal.aborted)return;if(w=m,s=m.root,s.setAttribute(rt,zt("popover",a)),s.addEventListener("toggle",(b)=>{if(b.newState==="closed")F(!0)}),!s.hasAttribute("popover"))await new Promise((b)=>{s?.addEventListener("jx-ready",()=>b(),{once:!0})});if(n.signal.aborted)return;s.showPopover(e?{source:e}:void 0)})();return{close:()=>{if(c)return;if(s?.open)s.hidePopover();F(!1)},host:o,isOpen:()=>!c,ready:A}}var L={$schema:"https://jxsuite.com/schema/v1",$id:"StudioMediaBrowser",$description:'The project\'s media, offered under whatever control asked for them. **Not the kit menu, and the difference is the thumbnails.** `surfaces/menu.json` is the settled answer to "a list of actions" and a `MenuRowProjection` carries a title, a chord and a gate — there is nowhere in it for a picture, nowhere for the size caption beside it, and a `jx-menu` is itself `popover=auto`, so a filter field cannot stand above one inside a panel. This is a browser: you pick an image by looking at it. **It is a `jx-popover`, so the PLATFORM owns dismissal** — light dismiss, Escape, the top layer and focus back to the invoker are the popover\'s contract, which is why nothing here binds a document listener and why the panel can paint over a modal `<dialog>` that the layer-div popover it replaces could not. The rows are plain buttons in a group, exactly as `grid-views.json`\'s saved views are: a list of buttons is reachable by Tab, and a `role="listbox"` would be a keyboard contract nothing here implements.',tagName:"jx-popover",attributes:{part:"media-browser"},$props:{label:"Project media",x:{$ref:"#/state/x"},y:{$ref:"#/state/y"}},children:[{tagName:"div",attributes:{part:"body"},style:{$description:"A search box that stays put and a list that scrolls under it. The panel itself never scrolls — `jx-popover` says why — so the box is here rather than on the host.",display:"flex",flexDirection:"column",gap:"var(--jx-space-2)",padding:"var(--jx-space-2)",minWidth:"260px",maxHeight:"360px",fontFamily:"var(--jx-font-sans)",fontSize:"var(--jx-text-md)",color:"var(--fg)",'& [part="rows"]':{display:"flex",flexDirection:"column",gap:"2px",overflowY:"auto",minHeight:"0"},'& [part="row"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-2)",textAlign:"left",background:"none",border:"none",color:"var(--fg)",font:"inherit",padding:"var(--jx-space-1) var(--jx-space-2)",borderRadius:"var(--jx-radius-sm)",cursor:"pointer",minWidth:"0"},'& [part="row"]:hover':{background:"var(--bg-hover)"},'& [part="row"]:focus-visible':{outline:"var(--jx-focus-ring)",outlineOffset:"-2px"},'& [part="row-thumb"]':{width:"24px",height:"24px",objectFit:"cover",borderRadius:"var(--jx-radius-sm)",flexShrink:"0"},'& [part="row-text"]':{display:"flex",flexDirection:"column",minWidth:"0"},'& [part="row-name"]':{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},'& [part="row-caption"]':{color:"var(--fg-dim)",fontSize:"var(--jx-text-xs)"},'& [part="empty"]':{margin:"0",color:"var(--fg-dim)",fontSize:"var(--jx-text-xs)"},'& [part="more"]':{margin:"0",color:"var(--fg-dim)",fontSize:"var(--jx-text-xs)"}},children:[{tagName:"jx-textfield",attributes:{part:"filter"},$props:{type:"search",size:"sm",label:"Search media",placeholder:"Search media…",autocomplete:"off",value:{$ref:"#/state/filter"}},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setFilter"},value:[{$ref:"event#/target/value"}]}]}},{tagName:"div",attributes:{part:"rows-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/rowsState"},cases:{empty:{tagName:"p",attributes:{part:"empty"},textContent:"${state.emptyLabel}"},listed:{tagName:"div",attributes:{part:"rows"},children:[{$prototype:"Array",items:{$ref:"#/state/rows"},key:{$ref:"$map/item/key"},map:{$description:"One file. The row hands back the value a pick writes — the site URL — rather than an index, so the list may be filtered under it without changing what any row means.",tagName:"button",attributes:{part:"row",type:"button","data-path":"${$map.item.path}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/pick"},value:[{$ref:"$map/item/path"}]}]},children:[{tagName:"span",attributes:{part:"row-thumb-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/thumbState"},cases:{shown:{$description:"Decorative: the row's own text names the file. The load handler is the whole of the dimensions caption — measuring an image is a decode the `<img>` has finished by the time `load` fires, so the numbers are a read of work already done rather than a second fetch per row.",tagName:"img",attributes:{part:"row-thumb",src:"${$map.item.thumbSrc}",alt:""},onload:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/measure"},value:[{$ref:"$map/item/file"},{$ref:"event#/target/naturalWidth"},{$ref:"event#/target/naturalHeight"}]}]}}}},{tagName:"span",attributes:{part:"row-text"},children:[{tagName:"span",attributes:{part:"row-name"},textContent:"${$map.item.name}"},{tagName:"span",attributes:{part:"row-caption-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/captionState"},cases:{shown:{tagName:"span",attributes:{part:"row-caption"},textContent:"${$map.item.caption}"}}}]}]}}]}}},{tagName:"div",attributes:{part:"more-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/moreState"},cases:{shown:{$description:'A truncated list says so. Fifty rows is the cap the list has always had; the sentence is what keeps the cap from reading as "that is all there is".',tagName:"p",attributes:{part:"more"},textContent:"${state.moreLabel}"}}}]}]};T("media-browser",L);var D="media-picker";function V(t,e){t.x=e.x,t.y=e.y,t.filter=e.filter,t.rowsState=e.rowsState,t.rows=e.rows,t.emptyLabel=e.emptyLabel,t.moreState=e.moreState,t.moreLabel=e.moreLabel}function N(t,e,r){let i=v({emptyLabel:t.emptyLabel,filter:t.filter,measure:e.measure,moreLabel:t.moreLabel,moreState:t.moreState,pick:e.pick,rows:t.rows,rowsState:t.rowsState,setFilter:e.setFilter,x:t.x,y:t.y}),a=ld({anchor:r,name:"media-browser",scope:i,slot:D,...e.dismissed?{onDismissed:e.dismissed}:{}});return a.ready.then(()=>{if(a.isOpen())a.host.querySelector('[part="filter"] [part="input"]')?.focus()}),{close:a.close,host:a.host,isOpen:a.isOpen,ready:a.ready,update:(o)=>V(i,o)}}var h=[],S=!1;async function P(t,e){let r=[];try{let i=await Ir(()=>e.listDirectory(t));bE(i);for(let a of i)if(a.type==="directory"){let o=await P(a.path,e);r.push(...o)}else{let o=Gi(a.name);if(Ld.has(o))r.push({file:a.path,isImage:Al.has(o),name:a.name,path:Id(a.path)})}}catch{}return r}async function g(){if(S)return;let t=p();h=await P("public",t),S=!0,Ai("leftPanel","rightPanel","frontmatterPanel")}function Y_(){h=[],S=!1,yE()}var y=50,d=null,u=null,l="",M={x:0,y:0};function k(){let t=l.toLowerCase(),e=t?h.filter((a)=>a.path.toLowerCase().includes(t)||a.name.toLowerCase().includes(t)):h,i=e.slice(0,y).map((a)=>{let o=wE(sb(a.file));return{caption:o,captionState:o?"shown":"hidden",file:a.file,key:a.file,name:a.name,path:a.path,thumbSrc:a.isImage?Bu(a.file):"",thumbState:a.isImage?"shown":"hidden"}});return{emptyLabel:"No matches",filter:l,moreLabel:`…${e.length-y} more`,moreState:e.length>y?"shown":"hidden",rows:i,rowsState:i.length>0?"listed":"empty",x:M.x,y:M.y}}function B(){let t=d;d=null,u=null,l="",t?.close()}var x=0;function z(t,e,r){if(!ab(t,e,r)||x!==0)return;x=requestAnimationFrame(()=>{x=0,d?.update(k())})}function XR(t,e){B(),u=e;let r=Oe(t);M={x:r.left,y:r.bottom+4},d=N(k(),{dismissed:()=>{d=null,u=null,l=""},measure:z,pick:(i)=>{let a=u;B(),a?.(i)},setFilter:(i)=>{l=i,d?.update(k())}},t)}async function QR(t,e){let r=await Va([...t]),[i]=r;if(i)e(i.ref)}function e$(t){let e=document.createElement("input");e.type="file",e.multiple=!0,e.accept=_c(),e.addEventListener("change",()=>{if(e.files?.length)QR(e.files,t)}),e.click()}var _=400,f=new WeakMap;function H(t,e){let r=Al.has(Gi(e));return{label:t,thumbSrc:r&&e?Cc(e):"",thumbState:r&&e?"shown":"hidden",value:e}}function cd(t,e,r,i){g();let a=f.get(t);if(a){a.prop=e,a.commit=i,a.handle.update(H(e,r));return}let o={commit:i,handle:null,prop:e};o.handle=j(t,H(e,r),{browse:(n)=>{g(),XR(n,(s)=>o.commit(s))},edit:(n)=>Tv(`media:${o.prop}`,_,(s)=>o.commit(s))(n),upload:()=>e$((n)=>o.commit(n)),warm:()=>{g()}}),f.set(t,o)}function uw(t){let e=f.get(t);if(e)f.delete(t),e.handle.dispose()}
2
- export{ld,Y_,XR,QR,e$,cd,uw};
1
+ import{ot,zt,T,I,Ct}from"./studio-g1shz58g.js";import{y}from"./studio-55h4mstj.js";import{p}from"./studio-xz2yxfcb.js";import{Ao}from"./studio-pcgz8heb.js";import{Ul,Hd,Oc,Ji,tl,Bd,th}from"./studio-gx4dnjzd.js";import{xb,OE,_b,PE,ME}from"./studio-4tanh828.js";import{Ac}from"./studio-74k29dy9.js";import{Uy,Ai}from"./studio-yn9f8vtx.js";import{Ie}from"./studio-0bhx5hz6.js";function wd(t){let{anchor:e,name:r,scope:i,slot:a}=t,o=document.createElement("div");o.style.pointerEvents="auto",o.setAttribute(ot,zt("popover",a)),Ct("popover").append(o);let n=new AbortController,s=null,w=null,c=!1,F=(m)=>{if(c)return;if(c=!0,n.abort(),w?.dispose(),w=null,o.remove(),m)t.onDismissed?.()},A=(async()=>{let m=await I(r,i,o,{signal:n.signal,...t.onNodeCreated?{onNodeCreated:t.onNodeCreated}:{}});if(n.signal.aborted)return;if(w=m,s=m.root,s.setAttribute(ot,zt("popover",a)),s.addEventListener("toggle",(b)=>{if(b.newState==="closed")F(!0)}),!s.hasAttribute("popover"))await new Promise((b)=>{s?.addEventListener("jx-ready",()=>b(),{once:!0})});if(n.signal.aborted)return;s.showPopover(e?{source:e}:void 0)})();return{close:()=>{if(c)return;if(s?.open)s.hidePopover();F(!1)},host:o,isOpen:()=>!c,ready:A}}var E={$schema:"https://jxsuite.com/schema/v1",$id:"StudioMediaField",$description:"The media field: a thumbnail of what the value names, the value itself, and the two doors to a different one. It is a LEAF a caller interpolates — the Inspector's Content tab, the Signals panel and the grid's image-cell panel each draw an empty host and `ui/media-picker.ts` mounts this into it — so it has no chrome of its own and takes its width from whatever row it lands in. **Browse is addressed through its `part`, not through a class.** `ui/regions.ts` derives `inspector/field:<prop>/browse` by finding the Browse control inside the Inspector's own `[data-prop]` row; the handle used to be `.media-picker-browse`, and a document emits no class, so `[part=\"browse\"]` is the handle now. The four `.media-picker*` rules from `styles/overlays.css` are TRANSCRIBED here rather than shared, for the reason `doc-header.json` gives: a class a document does not emit cannot style it. `--radius` becomes `--jx-radius-sm` on the way, because a document mounted in a pane's stage is outside `<sp-theme>` and would otherwise take a fallback rather than follow the theme.",tagName:"div",attributes:{part:"media-field"},style:{$description:"The row's own layout and the four transcribed `.media-picker*` rules. Upload and Browse never shrink, so the FIELD is what yields width when the row is narrow — the buttons would otherwise collapse into unreadable stubs before the text did.",display:"flex",alignItems:"center",gap:"var(--jx-space-1)",flex:"1",minWidth:"0",fontFamily:"var(--jx-font-sans)",fontSize:"var(--jx-text-md)",color:"var(--fg)",'& [part="value"]':{flex:"1",minWidth:"0"},'& [part="upload"]':{flexShrink:"0"},'& [part="browse"]':{flexShrink:"0"},'& [part="thumb"]':{width:"24px",height:"24px",objectFit:"cover",borderRadius:"var(--jx-radius-sm)",border:"1px solid var(--border)",flexShrink:"0"}},children:[{tagName:"span",attributes:{part:"thumb-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/thumbState"},cases:{shown:{$description:"Decorative on purpose: the field beside it already states the path in text, so a caption here would be the same fact twice to a screen reader and nothing to anyone else.",tagName:"img",attributes:{part:"thumb",src:"${state.thumbSrc}",alt:""}}}},{tagName:"jx-textfield",attributes:{part:"value"},$props:{size:"sm",label:"${state.label}",placeholder:"/image.jpg",value:{$ref:"#/state/value"}},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/edit"},value:[{$ref:"event#/target/value"}]}],description:"Every keystroke, because the host debounces it: the canvas follows the typing without a document write per character."},onfocus:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/warm"},value:[]}],description:"Entering the field is the earliest honest signal that a pick is coming, so the project's media are listed then rather than when Browse is pressed."}},{tagName:"jx-action-button",attributes:{part:"upload"},$props:{size:"sm",quiet:!0,icon:"upload-simple",label:"Upload media",hint:"Upload media"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/upload"},value:[]}]}},{tagName:"jx-action-button",attributes:{part:"browse"},$props:{size:"sm",quiet:!0,icon:"image",label:"Browse media",hint:"Browse media"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/browse"},value:[{$ref:"event#/currentTarget"}]}],description:"The button hands over ITSELF: the browser is a popover and the platform wants its invoker, both so a second press on this control toggles rather than reopens and so focus comes back here when it closes."}}]};T("media-field",E);function C(t,e){t.label=e.label,t.value=e.value,t.thumbState=e.thumbState,t.thumbSrc=e.thumbSrc}function j(t,e,r){let i=y({browse:r.browse,edit:r.edit,label:e.label,thumbSrc:e.thumbSrc,thumbState:e.thumbState,upload:r.upload,value:e.value,warm:r.warm}),a=null,o=!1;return I("media-field",i,t).then((n)=>{if(o){n.dispose();return}a=n}),{dispose(){o=!0,a?.dispose(),a=null},update:(n)=>C(i,n)}}var L={$schema:"https://jxsuite.com/schema/v1",$id:"StudioMediaBrowser",$description:'The project\'s media, offered under whatever control asked for them. **Not the kit menu, and the difference is the thumbnails.** `surfaces/menu.json` is the settled answer to "a list of actions" and a `MenuRowProjection` carries a title, a chord and a gate — there is nowhere in it for a picture, nowhere for the size caption beside it, and a `jx-menu` is itself `popover=auto`, so a filter field cannot stand above one inside a panel. This is a browser: you pick an image by looking at it. **It is a `jx-popover`, so the PLATFORM owns dismissal** — light dismiss, Escape, the top layer and focus back to the invoker are the popover\'s contract, which is why nothing here binds a document listener and why the panel can paint over a modal `<dialog>` that the layer-div popover it replaces could not. The rows are plain buttons in a group, exactly as `grid-views.json`\'s saved views are: a list of buttons is reachable by Tab, and a `role="listbox"` would be a keyboard contract nothing here implements.',tagName:"jx-popover",attributes:{part:"media-browser"},$props:{label:"Project media",x:{$ref:"#/state/x"},y:{$ref:"#/state/y"}},children:[{tagName:"div",attributes:{part:"body"},style:{$description:"A search box that stays put and a list that scrolls under it. The panel itself never scrolls — `jx-popover` says why — so the box is here rather than on the host.",display:"flex",flexDirection:"column",gap:"var(--jx-space-2)",padding:"var(--jx-space-2)",minWidth:"260px",maxHeight:"360px",fontFamily:"var(--jx-font-sans)",fontSize:"var(--jx-text-md)",color:"var(--fg)",'& [part="rows"]':{display:"flex",flexDirection:"column",gap:"2px",overflowY:"auto",minHeight:"0"},'& [part="row"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-2)",textAlign:"left",background:"none",border:"none",color:"var(--fg)",font:"inherit",padding:"var(--jx-space-1) var(--jx-space-2)",borderRadius:"var(--jx-radius-sm)",cursor:"pointer",minWidth:"0"},'& [part="row"]:hover':{background:"var(--bg-hover)"},'& [part="row"]:focus-visible':{outline:"var(--jx-focus-ring)",outlineOffset:"-2px"},'& [part="row-thumb"]':{width:"24px",height:"24px",objectFit:"cover",borderRadius:"var(--jx-radius-sm)",flexShrink:"0"},'& [part="row-text"]':{display:"flex",flexDirection:"column",minWidth:"0"},'& [part="row-name"]':{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},'& [part="row-caption"]':{color:"var(--fg-dim)",fontSize:"var(--jx-text-xs)"},'& [part="empty"]':{margin:"0",color:"var(--fg-dim)",fontSize:"var(--jx-text-xs)"},'& [part="more"]':{margin:"0",color:"var(--fg-dim)",fontSize:"var(--jx-text-xs)"}},children:[{tagName:"jx-textfield",attributes:{part:"filter"},$props:{type:"search",size:"sm",label:"Search media",placeholder:"Search media…",autocomplete:"off",value:{$ref:"#/state/filter"}},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setFilter"},value:[{$ref:"event#/target/value"}]}]}},{tagName:"div",attributes:{part:"rows-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/rowsState"},cases:{empty:{tagName:"p",attributes:{part:"empty"},textContent:"${state.emptyLabel}"},listed:{tagName:"div",attributes:{part:"rows"},children:[{$prototype:"Array",items:{$ref:"#/state/rows"},key:{$ref:"$map/item/key"},map:{$description:"One file. The row hands back the value a pick writes — the site URL — rather than an index, so the list may be filtered under it without changing what any row means.",tagName:"button",attributes:{part:"row",type:"button","data-path":"${$map.item.path}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/pick"},value:[{$ref:"$map/item/path"}]}]},children:[{tagName:"span",attributes:{part:"row-thumb-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/thumbState"},cases:{shown:{$description:"Decorative: the row's own text names the file. The load handler is the whole of the dimensions caption — measuring an image is a decode the `<img>` has finished by the time `load` fires, so the numbers are a read of work already done rather than a second fetch per row.",tagName:"img",attributes:{part:"row-thumb",src:"${$map.item.thumbSrc}",alt:""},onload:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/measure"},value:[{$ref:"$map/item/file"},{$ref:"event#/target/naturalWidth"},{$ref:"event#/target/naturalHeight"}]}]}}}},{tagName:"span",attributes:{part:"row-text"},children:[{tagName:"span",attributes:{part:"row-name"},textContent:"${$map.item.name}"},{tagName:"span",attributes:{part:"row-caption-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/captionState"},cases:{shown:{tagName:"span",attributes:{part:"row-caption"},textContent:"${$map.item.caption}"}}}]}]}}]}}},{tagName:"div",attributes:{part:"more-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/moreState"},cases:{shown:{$description:'A truncated list says so. Fifty rows is the cap the list has always had; the sentence is what keeps the cap from reading as "that is all there is".',tagName:"p",attributes:{part:"more"},textContent:"${state.moreLabel}"}}}]}]};T("media-browser",L);var D="media-picker";function V(t,e){t.x=e.x,t.y=e.y,t.filter=e.filter,t.rowsState=e.rowsState,t.rows=e.rows,t.emptyLabel=e.emptyLabel,t.moreState=e.moreState,t.moreLabel=e.moreLabel}function N(t,e,r){let i=y({emptyLabel:t.emptyLabel,filter:t.filter,measure:e.measure,moreLabel:t.moreLabel,moreState:t.moreState,pick:e.pick,rows:t.rows,rowsState:t.rowsState,setFilter:e.setFilter,x:t.x,y:t.y}),a=wd({anchor:r,name:"media-browser",scope:i,slot:D,...e.dismissed?{onDismissed:e.dismissed}:{}});return a.ready.then(()=>{if(a.isOpen())a.host.querySelector('[part="filter"] [part="input"]')?.focus()}),{close:a.close,host:a.host,isOpen:a.isOpen,ready:a.ready,update:(o)=>V(i,o)}}var h=[],S=!1;async function P(t,e){let r=[];try{let i=await Ao(()=>e.listDirectory(t));OE(i);for(let a of i)if(a.type==="directory"){let o=await P(a.path,e);r.push(...o)}else{let o=Ji(a.name);if(Hd.has(o))r.push({file:a.path,isImage:Ul.has(o),name:a.name,path:Bd(a.path)})}}catch{}return r}async function g(){if(S)return;let t=p();h=await P("public",t),S=!0,Ai("leftPanel","rightPanel","frontmatterPanel")}function pS(){h=[],S=!1,PE()}var v=50,d=null,u=null,l="",M={x:0,y:0};function k(){let t=l.toLowerCase(),e=t?h.filter((a)=>a.path.toLowerCase().includes(t)||a.name.toLowerCase().includes(t)):h,i=e.slice(0,v).map((a)=>{let o=ME(xb(a.file));return{caption:o,captionState:o?"shown":"hidden",file:a.file,key:a.file,name:a.name,path:a.path,thumbSrc:a.isImage?th(a.file):"",thumbState:a.isImage?"shown":"hidden"}});return{emptyLabel:"No matches",filter:l,moreLabel:`…${e.length-v} more`,moreState:e.length>v?"shown":"hidden",rows:i,rowsState:i.length>0?"listed":"empty",x:M.x,y:M.y}}function B(){let t=d;d=null,u=null,l="",t?.close()}var x=0;function z(t,e,r){if(!_b(t,e,r)||x!==0)return;x=requestAnimationFrame(()=>{x=0,d?.update(k())})}function mI(t,e){B(),u=e;let r=Ie(t);M={x:r.left,y:r.bottom+4},d=N(k(),{dismissed:()=>{d=null,u=null,l=""},measure:z,pick:(i)=>{let a=u;B(),a?.(i)},setFilter:(i)=>{l=i,d?.update(k())}},t)}async function gI(t,e){let r=await tl([...t]),[i]=r;if(i)e(i.ref)}function bI(t){let e=document.createElement("input");e.type="file",e.multiple=!0,e.accept=Oc(),e.addEventListener("change",()=>{if(e.files?.length)gI(e.files,t)}),e.click()}var _=400,f=new WeakMap;function H(t,e){let r=Ul.has(Ji(e));return{label:t,thumbSrc:r&&e?Ac(e):"",thumbState:r&&e?"shown":"hidden",value:e}}function xd(t,e,r,i){g();let a=f.get(t);if(a){a.prop=e,a.commit=i,a.handle.update(H(e,r));return}let o={commit:i,handle:null,prop:e};o.handle=j(t,H(e,r),{browse:(n)=>{g(),mI(n,(s)=>o.commit(s))},edit:(n)=>Uy(`media:${o.prop}`,_,(s)=>o.commit(s))(n),upload:()=>bI((n)=>o.commit(n)),warm:()=>{g()}}),f.set(t,o)}function Tw(t){let e=f.get(t);if(e)f.delete(t),e.handle.dispose()}
2
+ export{wd,pS,mI,gI,bI,xd,Tw};
3
3
 
4
- //# debugId=E3994757D515F61664756E2164756E21
5
- //# sourceMappingURL=studio-4r0sjtx8.js.map
4
+ //# debugId=F5681A65C0944C7164756E2164756E21
5
+ //# sourceMappingURL=studio-jhpxeckz.js.map
@@ -1,5 +1,5 @@
1
- import{Oe}from"./studio-vavmwshr.js";var p=3;function H(e,t,n){return Math.min(n,Math.max(t,e))}function bw(e){let t=Math.max(0,Math.trunc(e.count)),n=Math.max(1,Math.trunc(e.columns??1)),o=Math.ceil(t/n);if(!(e.rowHeight>0)||!(e.viewportHeight>0))return{end:t,padBottom:0,padTop:0,start:0,totalRows:o};let r=Math.max(0,Math.trunc(e.overscanRows??p)),i=Math.max(0,e.scrollTop),m=Math.floor(i/e.rowHeight),w=Math.ceil(e.viewportHeight/e.rowHeight)+1,l=H(m-r,0,o),a=H(m+w+r,l,o);return{end:Math.min(t,a*n),padBottom:(o-a)*e.rowHeight,padTop:l*e.rowHeight,start:Math.min(t,l*n),totalRows:o}}function M(e,t){return e.start===t.start&&e.end===t.end&&e.totalRows===t.totalRows&&e.padTop===t.padTop&&e.padBottom===t.padBottom}function v(e){let{scroller:t,list:n,count:o,rowHeight:r,columns:i,onChange:m,overscanRows:w}=e,l={end:0,padBottom:0,padTop:0,start:0,totalRows:0},a=!1;function c(){if(a)return;let d=bw({columns:i?.()??1,count:o(),overscanRows:w??p,rowHeight:r(),scrollTop:n?g(t,n):t.scrollTop,viewportHeight:t.clientHeight}),T=!M(l,d);if(l=d,T)m(d)}t.addEventListener("scroll",c,{passive:!0});let u=0,b=()=>{if(u!==0)return;u=requestAnimationFrame(()=>{u=0,c()})},s=null;if(typeof ResizeObserver==="function"){if(s=new ResizeObserver(b),s.observe(t),n)s.observe(n)}return c(),{destroy(){if(a=!0,t.removeEventListener("scroll",c),s?.disconnect(),s=null,u!==0)cancelAnimationFrame(u),u=0},measure:c,range:()=>l}}function R(e){for(let t=e;t;t=t.parentElement){if(t.scrollHeight<=t.clientHeight)continue;let n=getComputedStyle(t).overflowY;if(n==="auto"||n==="scroll"||n==="overlay")return t}return null}function f(e){let t=h.get(e);if(t&&t.isConnected&&e.isConnected&&t.contains(e))return t;let n=R(e);if(n)h.set(e,n);else h.delete(e);return n}function g(e,t){if(e===t)return Math.max(0,e.scrollTop);return Math.max(0,Oe(e).top-Oe(t).top)}function eb(e,t){let n=e?.isConnected===!0?f(e):null;if(!n||!e){let o=Math.max(0,Math.trunc(t.count));return{end:o,padBottom:0,padTop:0,start:0,totalRows:o}}return bw({columns:t.columns??1,count:t.count,...t.overscanRows===void 0?{}:{overscanRows:t.overscanRows},rowHeight:t.rowHeight,scrollTop:g(n,e),viewportHeight:n.clientHeight})}function x(e){let t=e.listOffset+e.index*e.rowHeight,n=t+e.rowHeight;if(t<e.scrollTop)return Math.max(0,t);if(n>e.scrollTop+e.viewportHeight)return Math.max(0,n-e.viewportHeight);return null}function tb(e,t,n){let o=e?.isConnected===!0?f(e):null;if(!o||!e||t<0||!(n>0))return!1;let{scrollTop:r}=o,i=x({index:t,listOffset:r-g(o,e),rowHeight:n,scrollTop:r,viewportHeight:o.clientHeight});if(i===null)return!1;return o.scrollTop=i,!0}function dE(e,t,n){let o=e?.querySelector(t);return o&&o.offsetHeight>0?o.offsetHeight:n}var h=new WeakMap;function nb(e,t,n){let o=f(t);if(e&&e.list===t&&e.scroller===o)return e;if(e?.window.destroy(),!o)return null;return{list:t,scroller:o,window:v({count:n.count,list:t,onChange:()=>n.onChange(),rowHeight:n.rowHeight,scroller:o})}}
2
- export{bw,eb,tb,dE,nb};
1
+ import{Ie}from"./studio-0bhx5hz6.js";var p=3;function H(e,t,n){return Math.min(n,Math.max(t,e))}function Nw(e){let t=Math.max(0,Math.trunc(e.count)),n=Math.max(1,Math.trunc(e.columns??1)),o=Math.ceil(t/n);if(!(e.rowHeight>0)||!(e.viewportHeight>0))return{end:t,padBottom:0,padTop:0,start:0,totalRows:o};let r=Math.max(0,Math.trunc(e.overscanRows??p)),i=Math.max(0,e.scrollTop),m=Math.floor(i/e.rowHeight),w=Math.ceil(e.viewportHeight/e.rowHeight)+1,l=H(m-r,0,o),a=H(m+w+r,l,o);return{end:Math.min(t,a*n),padBottom:(o-a)*e.rowHeight,padTop:l*e.rowHeight,start:Math.min(t,l*n),totalRows:o}}function M(e,t){return e.start===t.start&&e.end===t.end&&e.totalRows===t.totalRows&&e.padTop===t.padTop&&e.padBottom===t.padBottom}function v(e){let{scroller:t,list:n,count:o,rowHeight:r,columns:i,onChange:m,overscanRows:w}=e,l={end:0,padBottom:0,padTop:0,start:0,totalRows:0},a=!1;function c(){if(a)return;let d=Nw({columns:i?.()??1,count:o(),overscanRows:w??p,rowHeight:r(),scrollTop:n?g(t,n):t.scrollTop,viewportHeight:t.clientHeight}),T=!M(l,d);if(l=d,T)m(d)}t.addEventListener("scroll",c,{passive:!0});let u=0,b=()=>{if(u!==0)return;u=requestAnimationFrame(()=>{u=0,c()})},s=null;if(typeof ResizeObserver==="function"){if(s=new ResizeObserver(b),s.observe(t),n)s.observe(n)}return c(),{destroy(){if(a=!0,t.removeEventListener("scroll",c),s?.disconnect(),s=null,u!==0)cancelAnimationFrame(u),u=0},measure:c,range:()=>l}}function R(e){for(let t=e;t;t=t.parentElement){if(t.scrollHeight<=t.clientHeight)continue;let n=getComputedStyle(t).overflowY;if(n==="auto"||n==="scroll"||n==="overlay")return t}return null}function f(e){let t=h.get(e);if(t&&t.isConnected&&e.isConnected&&t.contains(e))return t;let n=R(e);if(n)h.set(e,n);else h.delete(e);return n}function g(e,t){if(e===t)return Math.max(0,e.scrollTop);return Math.max(0,Ie(e).top-Ie(t).top)}function mb(e,t){let n=e?.isConnected===!0?f(e):null;if(!n||!e){let o=Math.max(0,Math.trunc(t.count));return{end:o,padBottom:0,padTop:0,start:0,totalRows:o}}return Nw({columns:t.columns??1,count:t.count,...t.overscanRows===void 0?{}:{overscanRows:t.overscanRows},rowHeight:t.rowHeight,scrollTop:g(n,e),viewportHeight:n.clientHeight})}function x(e){let t=e.listOffset+e.index*e.rowHeight,n=t+e.rowHeight;if(t<e.scrollTop)return Math.max(0,t);if(n>e.scrollTop+e.viewportHeight)return Math.max(0,n-e.viewportHeight);return null}function gb(e,t,n){let o=e?.isConnected===!0?f(e):null;if(!o||!e||t<0||!(n>0))return!1;let{scrollTop:r}=o,i=x({index:t,listOffset:r-g(o,e),rowHeight:n,scrollTop:r,viewportHeight:o.clientHeight});if(i===null)return!1;return o.scrollTop=i,!0}function TE(e,t,n){let o=e?.querySelector(t);return o&&o.offsetHeight>0?o.offsetHeight:n}var h=new WeakMap;function bb(e,t,n){let o=f(t);if(e&&e.list===t&&e.scroller===o)return e;if(e?.window.destroy(),!o)return null;return{list:t,scroller:o,window:v({count:n.count,list:t,onChange:()=>n.onChange(),rowHeight:n.rowHeight,scroller:o})}}
2
+ export{Nw,mb,gb,TE,bb};
3
3
 
4
- //# debugId=E26C4E342C88CB2D64756E2164756E21
5
- //# sourceMappingURL=studio-zd4kayn2.js.map
4
+ //# debugId=51E74C36C036F85564756E2164756E21
5
+ //# sourceMappingURL=studio-k01r7ykp.js.map