@panphora/clayjs 1.24.1 → 1.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/dist/all.js +1 -1
  2. package/dist/clay-dom.js +1 -1
  3. package/dist/clay-events.js +1 -1
  4. package/dist/clay-internals.js +1 -1
  5. package/dist/clay-options.js +1 -1
  6. package/dist/clay-router.js +1 -1
  7. package/dist/clay-ui.js +1 -1
  8. package/dist/clay-utils.js +1 -1
  9. package/dist/clay.js +1 -1
  10. package/dist/clay.standalone.js +2044 -1247
  11. package/dist/m/attrs/{refetch-on-save-DPGJJMGN.js → refetch-on-save-5CBFUJUF.js} +1 -1
  12. package/dist/m/attrs/save-freeze-MH3AOD56.js +1 -0
  13. package/dist/m/{c-SXGEWPFC.js → c-3E2IK5HU.js} +1 -1
  14. package/dist/m/{c-A4L7APIU.js → c-4AE2A2LK.js} +1 -1
  15. package/dist/m/{c-YDW4VCHP.js → c-4Q6QIODW.js} +1 -1
  16. package/dist/m/{c-RO73MKKR.js → c-52OC3OH3.js} +1 -1
  17. package/dist/m/{c-ZGCO4J3H.js → c-5PZYDWTW.js} +1 -1
  18. package/dist/m/c-5Q5XBN56.js +1 -0
  19. package/dist/m/c-5SZ6KFR5.js +1 -0
  20. package/dist/m/{c-ZRGEN6QQ.js → c-AI3H6ETU.js} +2 -2
  21. package/dist/m/{c-7V6MGMX2.js → c-BCWYEG6P.js} +1 -1
  22. package/dist/m/{c-C5AKJVRH.js → c-BJ2RRQBQ.js} +1 -1
  23. package/dist/m/{c-CTGRDT6E.js → c-C6YZNU6E.js} +1 -1
  24. package/dist/m/{c-EDE45NM7.js → c-C7SUMNMI.js} +1 -1
  25. package/dist/m/c-CITLTVQ4.js +4 -0
  26. package/dist/m/{c-STRI73GQ.js → c-CL5LSATX.js} +1 -1
  27. package/dist/m/{c-Z4G2UK6T.js → c-CU33V6RW.js} +1 -1
  28. package/dist/m/{c-6LEYVQJK.js → c-D62HRSZK.js} +1 -1
  29. package/dist/m/{c-DD26VXAP.js → c-DT7E76Z2.js} +1 -1
  30. package/dist/m/{c-P2HKMJAW.js → c-EAV7A6BT.js} +1 -1
  31. package/dist/m/{c-QQFHEODI.js → c-EQ5NBOGA.js} +1 -1
  32. package/dist/m/{c-KQKKIVLW.js → c-FBOO2UY3.js} +1 -1
  33. package/dist/m/{c-JQF2EUCG.js → c-FJDTDGDA.js} +1 -1
  34. package/dist/m/{c-MQKSKQHG.js → c-FKTALXNV.js} +1 -1
  35. package/dist/m/{c-HL6BLJNA.js → c-GDNZEOOZ.js} +1 -1
  36. package/dist/m/{c-SUXHUL7U.js → c-GEAG5XAK.js} +1 -1
  37. package/dist/m/{c-LSVN3OLG.js → c-GY4BREDT.js} +1 -1
  38. package/dist/m/{c-4PO3YGDC.js → c-HGG7M2S3.js} +1 -1
  39. package/dist/m/{c-DDS23EY6.js → c-HXGNH6GY.js} +1 -1
  40. package/dist/m/{c-FLEIU6CG.js → c-IESDKFO6.js} +1 -1
  41. package/dist/m/{c-CJ7QYEWI.js → c-IJHF4IO6.js} +1 -1
  42. package/dist/m/{c-SGGGCIVD.js → c-IL5IVTOG.js} +1 -1
  43. package/dist/m/c-JB5YU57S.js +1 -0
  44. package/dist/m/{c-MP6S4AZU.js → c-JD2VFAYG.js} +2 -2
  45. package/dist/m/{c-CV4T65JE.js → c-JWW6BHWD.js} +3 -3
  46. package/dist/m/{c-42ZNV7LI.js → c-K4M76VPM.js} +1 -1
  47. package/dist/m/{c-6IJEVE6B.js → c-KU3PX7LL.js} +1 -1
  48. package/dist/m/{c-2PVGJFI5.js → c-KYTVZT4D.js} +1 -1
  49. package/dist/m/{c-BGN7RCTJ.js → c-M7ITYKMF.js} +1 -1
  50. package/dist/m/c-MFB74XVN.js +3 -0
  51. package/dist/m/c-MOP5KBWZ.js +1 -0
  52. package/dist/m/{c-YLHTD3KX.js → c-MUM53J5J.js} +1 -1
  53. package/dist/m/{c-YK2L436K.js → c-MV7TEUTD.js} +1 -1
  54. package/dist/m/{c-LA2BW7UY.js → c-MZCOGNZL.js} +1 -1
  55. package/dist/m/{c-XW5TIYYB.js → c-N4GEJMXW.js} +1 -1
  56. package/dist/m/{c-NQAPWM7O.js → c-NADLYVAH.js} +1 -1
  57. package/dist/m/{c-RS77ODLY.js → c-NL4I4KNG.js} +1 -1
  58. package/dist/m/{c-X75G43SZ.js → c-O2QZDVZ2.js} +1 -1
  59. package/dist/m/{c-LTSPHVAK.js → c-OBMZASYQ.js} +1 -1
  60. package/dist/m/{c-LUXAB2XI.js → c-ORLPQFNU.js} +1 -1
  61. package/dist/m/c-P73XPAOA.js +1 -0
  62. package/dist/m/{c-PWJSJEJU.js → c-PNZIJFG7.js} +1 -1
  63. package/dist/m/{c-ZKKAF4UT.js → c-PRZNJUYZ.js} +2 -2
  64. package/dist/m/{c-B7GOFGQR.js → c-Q2CB57UG.js} +1 -1
  65. package/dist/m/{c-TWCXBWS3.js → c-QCDVDZIR.js} +1 -1
  66. package/dist/m/{c-UOOIF2AL.js → c-QDVG4NAZ.js} +1 -1
  67. package/dist/m/c-QWB53KRW.js +1 -0
  68. package/dist/m/{c-GNI7WHKF.js → c-RGAALCDU.js} +1 -1
  69. package/dist/m/c-RHPHMTF2.js +2 -0
  70. package/dist/m/{c-3UW5EJ77.js → c-RWJ3OSCP.js} +1 -1
  71. package/dist/m/{c-5FXEKU4Y.js → c-SEVOS4UE.js} +1 -1
  72. package/dist/m/{c-HDVH3MVC.js → c-SFYTKRU7.js} +1 -1
  73. package/dist/m/{c-47IBJGPQ.js → c-SFZRY6RT.js} +1 -1
  74. package/dist/m/{c-QENKN7QI.js → c-SGG6MUXW.js} +1 -1
  75. package/dist/m/c-SMLAJASY.js +1 -0
  76. package/dist/m/{c-DFKBGSN2.js → c-SUAC5RSG.js} +1 -1
  77. package/dist/m/{c-6RGEQNVV.js → c-SXZYVXD6.js} +1 -1
  78. package/dist/m/{c-ZFO5RW6G.js → c-TCFVG3I4.js} +1 -1
  79. package/dist/m/{c-OCYG4NBQ.js → c-TLQINES7.js} +2 -2
  80. package/dist/m/c-U4TWEIKZ.js +1 -0
  81. package/dist/m/{c-MQYEDF3Q.js → c-U65PREMC.js} +1 -1
  82. package/dist/m/{c-PDBNCJCT.js → c-U7F66I64.js} +1 -1
  83. package/dist/m/{c-LATNQ6Q5.js → c-UD4VDBGJ.js} +1 -1
  84. package/dist/m/{c-PCNJETUA.js → c-V2FPBRO6.js} +1 -1
  85. package/dist/m/{c-ND3Q2G2I.js → c-V4B3RUWB.js} +1 -1
  86. package/dist/m/{c-JWDCQL6J.js → c-V5L6HWVL.js} +1 -1
  87. package/dist/m/c-VMXCX52Q.js +1 -0
  88. package/dist/m/{c-CZHTXGJS.js → c-VO6RSFCO.js} +1 -1
  89. package/dist/m/c-WDFQ7PBU.js +1 -0
  90. package/dist/m/{c-OG6GFSUX.js → c-WGQVSKKC.js} +1 -1
  91. package/dist/m/c-WSTUCBHV.js +1 -0
  92. package/dist/m/{c-FEC6LGFF.js → c-WVCT3ITX.js} +1 -1
  93. package/dist/m/{c-SE3SIY7Y.js → c-X3V4RWMA.js} +1 -1
  94. package/dist/m/{c-HIX5H5L7.js → c-XHZIKRCV.js} +1 -1
  95. package/dist/m/{c-2BLVA6IN.js → c-XQTERKQA.js} +1 -1
  96. package/dist/m/{c-PYG2NGWU.js → c-YFO6ZJLQ.js} +1 -1
  97. package/dist/m/{c-7CM4GMTS.js → c-YX2MC7YL.js} +1 -1
  98. package/dist/m/{c-OYHI67B6.js → c-YYGUHSZR.js} +1 -1
  99. package/dist/m/{c-YYMZWQLR.js → c-Z2OZFX3N.js} +1 -1
  100. package/dist/m/{c-AT7GLQGV.js → c-ZEA3DCG3.js} +1 -1
  101. package/dist/m/{c-T3P3AXEW.js → c-ZJG6C2WL.js} +1 -1
  102. package/dist/m/{c-FVPNX2GO.js → c-ZORVIXUR.js} +1 -1
  103. package/dist/m/{c-SKMIR5HQ.js → c-ZPI7M5U5.js} +1 -1
  104. package/dist/m/core/{admin-attrs-ONRWVXPK.js → admin-attrs-ZI6K6UGM.js} +1 -1
  105. package/dist/m/core/{autosave-TBKAAAFB.js → autosave-BSM2ABJL.js} +1 -1
  106. package/dist/m/core/{conflict-notice-FOEE6I7E.js → conflict-notice-7EQLDYPA.js} +1 -1
  107. package/dist/m/core/draft-mode-M5XNYBMY.js +1 -0
  108. package/dist/m/core/{host-permission-X4BENZEU.js → host-permission-5BYP24GC.js} +1 -1
  109. package/dist/m/core/{is-edit-mode-FFHCQ5DR.js → is-edit-mode-73OXKK5H.js} +1 -1
  110. package/dist/m/core/{persist-6ILUR34S.js → persist-2SZO3PCE.js} +1 -1
  111. package/dist/m/core/{recovery-APWADU4K.js → recovery-VZF7RJZF.js} +1 -1
  112. package/dist/m/core/{save-6HT2LABE.js → save-K6Q47J2X.js} +1 -1
  113. package/dist/m/core/{save-core-EVMNZQ4V.js → save-core-U3Z44XBO.js} +1 -1
  114. package/dist/m/core/{site-edits-G4BOZMV4.js → site-edits-CFMF6GHD.js} +1 -1
  115. package/dist/m/core/{snapshot-FJP5IJL3.js → snapshot-PWCHYFL6.js} +1 -1
  116. package/dist/m/core/unsaved-warning-2WRZLJH5.js +1 -0
  117. package/dist/m/events/{index-B6TGDYMG.js → index-YKQIBZE5.js} +1 -1
  118. package/dist/m/internals/index-FSLC4M7J.js +1 -0
  119. package/dist/m/lib/{cache-bust-NH7VBWHO.js → cache-bust-BL4KUQAJ.js} +1 -1
  120. package/dist/m/{loader-GLLVDUZA.js → loader-RC54UV7H.js} +1 -1
  121. package/dist/m/manifest-3B84C829.js +1 -0
  122. package/dist/m/manifest-edit-1CB79AD4.js +1 -0
  123. package/dist/m/manifest.json +1165 -1115
  124. package/dist/m/options/{options-55LQHSJ4.js → options-LKIZ7YTG.js} +1 -1
  125. package/dist/m/page/{editor-KAZDJNND.js → editor-PKSPJ2XJ.js} +2 -2
  126. package/dist/m/plugins/{ai-edit-LABECCSN.js → ai-edit-3LG6MGS3.js} +1 -1
  127. package/dist/m/plugins/{demo-T7B4RIKL.js → demo-LMCMBILC.js} +1 -1
  128. package/dist/m/plugins/{derive-6LPJOCAV.js → derive-7DR5TUDH.js} +1 -1
  129. package/dist/m/plugins/{indicator-J4ABFARX.js → indicator-CTKX4EY7.js} +1 -1
  130. package/dist/m/plugins/{live-PGBIEMGB.js → live-IFLL6YN5.js} +1 -1
  131. package/dist/m/plugins/{menu-YZL3X2AJ.js → menu-YJZ3JWBC.js} +1 -1
  132. package/dist/m/plugins/{page-WOCNX2IN.js → page-GTDPYGE4.js} +2 -2
  133. package/dist/m/plugins/{page-view-SJODOOGE.js → page-view-NMCCU6MF.js} +1 -1
  134. package/dist/m/plugins/{people-C4TCWFOQ.js → people-6WIWCZEG.js} +1 -1
  135. package/dist/m/plugins/{richclay-Y2NV44NA.js → richclay-L3BZMX4I.js} +2 -2
  136. package/dist/m/plugins/{sortable-XCHQG65Z.js → sortable-365SRRL3.js} +1 -1
  137. package/dist/m/plugins/{source-YK7MO23W.js → source-7LSGOV46.js} +1 -1
  138. package/dist/m/plugins/{undo-VLRBQNPN.js → undo-UES4KS7B.js} +1 -1
  139. package/dist/m/plugins/{upgrade-NNTJBSK2.js → upgrade-MMPZUCDM.js} +1 -1
  140. package/dist/m/plugins/{upload-ZKKJV76X.js → upload-NZET3DNQ.js} +1 -1
  141. package/dist/m/plugins/visitor-drafts-V5YB7XDH.js +20 -0
  142. package/dist/m/plugins/{visitor-drafts-owner-LHUHFU3L.js → visitor-drafts-owner-TLECTYWS.js} +1 -1
  143. package/dist/m/plugins/{visitor-menu-FY4KM2SW.js → visitor-menu-QDV2MYJN.js} +1 -1
  144. package/dist/m/plugins/wire-3YGUO3GE.js +1 -0
  145. package/dist/m/{reader-core-T2S3JC4E.js → reader-core-VR7EL4WV.js} +2 -2
  146. package/dist/m/sync/live-sync-XMXXZS3G.js +1 -0
  147. package/dist/m/vendor/sap-core.vendor-JANUQULT.js +7 -0
  148. package/dist/offline-manifest.json +665 -635
  149. package/docs/guide.md +1 -0
  150. package/entries/sap.js +6 -5
  151. package/package.json +1 -1
  152. package/src/core/draft-mode.js +5 -0
  153. package/src/core/save-core.js +10 -10
  154. package/src/core/save.js +1 -1
  155. package/src/lib/dirty-gate.js +19 -0
  156. package/src/plugins/menu/visitor.js +33 -1
  157. package/src/plugins/visitor-drafts/commit.js +50 -3
  158. package/src/plugins/visitor-drafts/idb.js +8 -2
  159. package/src/plugins/visitor-drafts/recovery-menu.js +118 -0
  160. package/src/plugins/visitor-drafts/recovery.js +64 -0
  161. package/src/plugins/visitor-drafts/session.js +61 -13
  162. package/src/plugins/visitor-drafts/store.js +44 -8
  163. package/src/plugins/visitor-drafts.js +34 -5
  164. package/src/sync/live-sync.js +1 -1
  165. package/src/sync/wire-profile.js +9 -4
  166. package/src/vendor/sap-core.vendor.js +6 -5
  167. package/src/vendor/sap-ownership.vendor.js +181 -11
  168. package/tool-generation/system.md +1 -1
  169. package/dist/m/attrs/save-freeze-JZHKRQLR.js +0 -1
  170. package/dist/m/c-6Q6RGFBF.js +0 -1
  171. package/dist/m/c-APGHGDZM.js +0 -1
  172. package/dist/m/c-EILLN2H2.js +0 -1
  173. package/dist/m/c-HTLYXCUH.js +0 -1
  174. package/dist/m/c-MFOSMAVM.js +0 -3
  175. package/dist/m/c-R23UHMXG.js +0 -1
  176. package/dist/m/c-SGH3UTF3.js +0 -1
  177. package/dist/m/c-U4NTUVDZ.js +0 -1
  178. package/dist/m/c-V2U3F4QX.js +0 -1
  179. package/dist/m/c-VG5XIN4T.js +0 -1
  180. package/dist/m/c-VHSMPITY.js +0 -1
  181. package/dist/m/core/draft-mode-4MCL3LYI.js +0 -1
  182. package/dist/m/core/unsaved-warning-ITZDIZ2I.js +0 -1
  183. package/dist/m/internals/index-HS3CQDFW.js +0 -1
  184. package/dist/m/manifest-50FF1C45.js +0 -1
  185. package/dist/m/manifest-edit-BE1A621D.js +0 -1
  186. package/dist/m/plugins/visitor-drafts-RTZNONHT.js +0 -20
  187. package/dist/m/plugins/wire-M2NR354P.js +0 -1
  188. package/dist/m/sync/live-sync-Z64YREWQ.js +0 -1
  189. package/dist/m/vendor/sap-core.vendor-QAEPMETX.js +0 -6
  190. /package/dist/m/plugins/{richclay-Y2NV44NA.js.LEGAL.txt → richclay-L3BZMX4I.js.LEGAL.txt} +0 -0
@@ -1 +1 @@
1
- import{a as r}from"../c-LA2BW7UY.js";import"../c-IJUK2GPW.js";import{a as o,b as i,c as u,d as s}from"../c-S7LK4KUE.js";import"../c-VG5XIN4T.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";function m(e){if(e.parentNode){r.pause();try{e.remove()}finally{r.resume()}}}function p(e){let a=o(e);if(!a||s(e))return;let t=new URL(e.getAttribute(a),location.href);t.searchParams.set("v",Date.now());let f=t.origin===location.origin?t.pathname+t.search:t.href;r.pause();try{let n=document.createElement(e.tagName);for(let{name:d,value:l}of e.attributes)n.setAttribute(d,l);i(n,a,f),u(e),e.insertAdjacentElement("afterend",n),n.onload=()=>m(e),setTimeout(()=>m(e),2e3)}finally{r.resume()}}function c(){document.addEventListener("clay:save-saved",()=>{document.querySelectorAll("[refetch-on-save]").forEach(p)})}c();var g=c;export{g as default};
1
+ import{a as r}from"../c-MZCOGNZL.js";import"../c-IJUK2GPW.js";import{a as o,b as i,c as u,d as s}from"../c-S7LK4KUE.js";import"../c-MOP5KBWZ.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";function m(e){if(e.parentNode){r.pause();try{e.remove()}finally{r.resume()}}}function p(e){let a=o(e);if(!a||s(e))return;let t=new URL(e.getAttribute(a),location.href);t.searchParams.set("v",Date.now());let f=t.origin===location.origin?t.pathname+t.search:t.href;r.pause();try{let n=document.createElement(e.tagName);for(let{name:d,value:l}of e.attributes)n.setAttribute(d,l);i(n,a,f),u(e),e.insertAdjacentElement("afterend",n),n.onload=()=>m(e),setTimeout(()=>m(e),2e3)}finally{r.resume()}}function c(){document.addEventListener("clay:save-saved",()=>{document.querySelectorAll("[refetch-on-save]").forEach(p)})}c();var g=c;export{g as default};
@@ -0,0 +1 @@
1
+ import{a}from"../c-MV7TEUTD.js";import"../c-QCDVDZIR.js";import"../c-MZCOGNZL.js";import"../c-IJUK2GPW.js";import"../c-PNZIJFG7.js";import"../c-XQXZAO7N.js";import"../c-S7LK4KUE.js";import"../c-MOP5KBWZ.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";export{a as default};
@@ -1,4 +1,4 @@
1
- import{b as F,c as M}from"./c-DD26VXAP.js";import{C as N,d as $}from"./c-ZRGEN6QQ.js";import{A,b as X,c as Y,d as w,x as U}from"./c-OH2FPYSY.js";import{b as P}from"./c-QY7F6EN6.js";import"./c-RETTCOWO.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var y=5;function v(n){let u=0;for(let i=0;i<n.childCount;i++){let s=n.child(i);if(s.type===w.nodes.heading&&s.attrs.level===1&&s.attrs.parent==null)return{index:i,at:u,node:s};u+=s.nodeSize}return null}var O=`
1
+ import{b as F,c as M}from"./c-DT7E76Z2.js";import{C as N,d as $}from"./c-AI3H6ETU.js";import{A,b as X,c as Y,d as w,x as U}from"./c-OH2FPYSY.js";import{b as P}from"./c-QY7F6EN6.js";import"./c-RETTCOWO.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var y=5;function v(n){let u=0;for(let i=0;i<n.childCount;i++){let s=n.child(i);if(s.type===w.nodes.heading&&s.attrs.level===1&&s.attrs.parent==null)return{index:i,at:u,node:s};u+=s.nodeSize}return null}var O=`
2
2
  :host{font:inherit !important;color:inherit !important}
3
3
  .blockeditor-cover-panel{display:flex;align-items:center;gap:8px;margin:8px 0;padding:6px 10px;border:1px solid var(--blockeditor-pop-line);border-radius:8px;background:var(--blockeditor-pop-bg);color:var(--blockeditor-pop-ink);box-shadow:var(--blockeditor-pop-shadow);font-size:.88em}
4
4
  .blockeditor-cover-msg{max-width:34ch}
@@ -1 +1 @@
1
- import{b}from"./c-NEQRFC4O.js";import{a as T,d as h}from"./c-IW6GGOU2.js";import{b as y}from"./c-HAWFNBYG.js";import{n as d}from"./c-GO635CRU.js";import{ea as s,ha as m,ia as p,ja as g}from"./c-OH2FPYSY.js";import{a as c}from"./c-TCCA5BZN.js";import{r as f}from"./c-PWJSJEJU.js";var x="article[data-blockeditor]",S=/^blockeditor(\.[0-9]+)?$/;function k(t){return[...t.querySelectorAll('script[merge][clay~="live"]')].filter(e=>S.test(e.getAttribute("merge")))}var i=null;function v(t){let e=t.join("\0");if(i&&i.key===e)return i;let r=t.map(a=>{try{return c(a)}catch{throw new d("invalid-json","Cannot read the page data as JSON")}}),n=b(r),o=s(n);return i={key:e,html:g(o,{fallbackOf:a=>{let u=n[a]?.artifact?.fallbackHtml;return typeof u=="string"?u:""},clean:p(document)}),rev:m(o),model:o,title:y(o)},i}function O(t){let e=t.querySelector(x);if(!e)return;let r=k(t);if(!r.length)return;let{html:n,rev:o,title:l}=v(r.map(a=>a.textContent));e.innerHTML!==n&&(e.innerHTML=n),e.setAttribute("data-rev",o),T(t)||h(t,l)}function A(t){let e=k(t);if(e.length!==1)return null;let r;try{r=c(e[0].textContent)}catch{return null}let{v:n,g:o,y:l}=r??{};return n!==1||!l||typeof l!="object"||Array.isArray(l)?null:{v:n,g:o,y:{...l}}}function M(t){return v([typeof t=="string"?t:JSON.stringify(t)]).html}function D(t){if(typeof t!="string")return null;try{let e=new DOMParser().parseFromString(t,"text/html"),r=A(e),n=e.querySelector(x);if(!r||!n)return null;let o=e.createElement("article");return o.innerHTML=M(r),n.innerHTML===o.innerHTML?r:null}catch{return null}}f(O);export{x as a,k as b,v as c,A as d,M as e,D as f};
1
+ import{b}from"./c-NEQRFC4O.js";import{a as T,d as h}from"./c-IW6GGOU2.js";import{b as y}from"./c-HAWFNBYG.js";import{n as d}from"./c-GO635CRU.js";import{ea as s,ha as m,ia as p,ja as g}from"./c-OH2FPYSY.js";import{a as c}from"./c-TCCA5BZN.js";import{r as f}from"./c-PNZIJFG7.js";var x="article[data-blockeditor]",S=/^blockeditor(\.[0-9]+)?$/;function k(t){return[...t.querySelectorAll('script[merge][clay~="live"]')].filter(e=>S.test(e.getAttribute("merge")))}var i=null;function v(t){let e=t.join("\0");if(i&&i.key===e)return i;let r=t.map(a=>{try{return c(a)}catch{throw new d("invalid-json","Cannot read the page data as JSON")}}),n=b(r),o=s(n);return i={key:e,html:g(o,{fallbackOf:a=>{let u=n[a]?.artifact?.fallbackHtml;return typeof u=="string"?u:""},clean:p(document)}),rev:m(o),model:o,title:y(o)},i}function O(t){let e=t.querySelector(x);if(!e)return;let r=k(t);if(!r.length)return;let{html:n,rev:o,title:l}=v(r.map(a=>a.textContent));e.innerHTML!==n&&(e.innerHTML=n),e.setAttribute("data-rev",o),T(t)||h(t,l)}function A(t){let e=k(t);if(e.length!==1)return null;let r;try{r=c(e[0].textContent)}catch{return null}let{v:n,g:o,y:l}=r??{};return n!==1||!l||typeof l!="object"||Array.isArray(l)?null:{v:n,g:o,y:{...l}}}function M(t){return v([typeof t=="string"?t:JSON.stringify(t)]).html}function D(t){if(typeof t!="string")return null;try{let e=new DOMParser().parseFromString(t,"text/html"),r=A(e),n=e.querySelector(x);if(!r||!n)return null;let o=e.createElement("article");return o.innerHTML=M(r),n.innerHTML===o.innerHTML?r:null}catch{return null}}f(O);export{x as a,k as b,v as c,A as d,M as e,D as f};
@@ -1 +1 @@
1
- import{n as g,s as k}from"./c-MFOSMAVM.js";import{a as u,b as r,c as d,h as p}from"./c-6IJEVE6B.js";var v=3e4;function a(){return{ok:!1,code:"failed"}}async function x(n,{etag:o}={}){if(typeof n!="string"||n==="")return a();let m=o!==void 0,y=typeof o=="string"&&o?o:null;if(r()||await p(),!r())return{ok:!1,code:"unsupported"};let s=m?y:u();if(!s)return{ok:!1,code:"conflict"};let i=new AbortController,S=setTimeout(()=>i.abort(),v);try{let{url:c,options:b}=k(n,!0,i.signal,g(),s,!1,null,!1),t=await fetch(c,b),f=await t.text(),e={};if(f)try{e=JSON.parse(f)}catch{e={}}if(!t.ok)return t.status===412?{ok:!1,code:"conflict"}:t.status===401||t.status===403?{ok:!1,code:"forbidden"}:a();let l=typeof e.etag=="string"&&e.etag?e.etag:null;return d(l),{ok:!0,etag:l}}catch{return a()}finally{clearTimeout(S)}}export{x as a};
1
+ import{n as g,s as k}from"./c-MFB74XVN.js";import{a as u,b as r,c as d,h as p}from"./c-KU3PX7LL.js";var v=3e4;function a(){return{ok:!1,code:"failed"}}async function x(n,{etag:o}={}){if(typeof n!="string"||n==="")return a();let m=o!==void 0,y=typeof o=="string"&&o?o:null;if(r()||await p(),!r())return{ok:!1,code:"unsupported"};let s=m?y:u();if(!s)return{ok:!1,code:"conflict"};let i=new AbortController,S=setTimeout(()=>i.abort(),v);try{let{url:c,options:b}=k(n,!0,i.signal,g(),s,!1,null,!1),t=await fetch(c,b),f=await t.text(),e={};if(f)try{e=JSON.parse(f)}catch{e={}}if(!t.ok)return t.status===412?{ok:!1,code:"conflict"}:t.status===401||t.status===403?{ok:!1,code:"forbidden"}:a();let l=typeof e.etag=="string"&&e.etag?e.etag:null;return d(l),{ok:!0,etag:l}}catch{return a()}finally{clearTimeout(S)}}export{x as a};
@@ -1 +1 @@
1
- import{n as p,p as f,s as i,v as y}from"./c-PWJSJEJU.js";import{i as m}from"./c-HA6INT6J.js";var S="http://www.w3.org/1999/xhtml",C=64*1024,g=256;function E(e){return e.namespaceURI===S&&e.localName!=="template"&&e.getElementsByTagName("*").length>=g}function*d(e,t,l,o){for(let n of e.childNodes){if(n.nodeType===1&&E(n)){yield*T(n,l,o);continue}let r;n.nodeType===1?r=n.outerHTML:(t.replaceChildren(n.cloneNode(!1)),r=t.innerHTML),l.push(r),o.bytes+=r.length,o.bytes>=C&&(o.bytes=0,yield)}}function*T(e,t,l){let o=i(e,!1),n=o.outerHTML,r=`</${o.localName}>`;t.push(n.slice(0,n.length-r.length)),yield*d(e,o,t,l),t.push(r)}function*h(e){let t=["<!DOCTYPE html>"];return yield*T(e,t,{bytes:0}),t.join("")}function*k(e){let t=p(e);if(!t.length)return yield*h(e);let l=f(t),o;try{o=yield*h(e)}finally{for(let[n,r]of t)n.replaceChildren(...r)}for(let[n,r]of l)o=o.split(n).join(r);return o}function*M(e){return y(e),yield*h(e)}function*b(e){let t=i(e,!1);for(let s of m)t.removeAttribute(s);let l=t.outerHTML,o=`</${t.localName}>`,n=["<!DOCTYPE html>",l.slice(0,l.length-o.length)],r=p(e),u=r.length?f(r):[];try{yield*d(e,i(e,!1),n,{bytes:0})}finally{for(let[s,a]of r)s.replaceChildren(...a)}n.push(o);let c=n.join("");for(let[s,a]of u)c=c.split(s).join(a);return c}export{h as a,k as b,M as c,b as d};
1
+ import{n as p,p as f,s as i,v as y}from"./c-PNZIJFG7.js";import{i as m}from"./c-HA6INT6J.js";var S="http://www.w3.org/1999/xhtml",C=64*1024,g=256;function E(e){return e.namespaceURI===S&&e.localName!=="template"&&e.getElementsByTagName("*").length>=g}function*d(e,t,l,o){for(let n of e.childNodes){if(n.nodeType===1&&E(n)){yield*T(n,l,o);continue}let r;n.nodeType===1?r=n.outerHTML:(t.replaceChildren(n.cloneNode(!1)),r=t.innerHTML),l.push(r),o.bytes+=r.length,o.bytes>=C&&(o.bytes=0,yield)}}function*T(e,t,l){let o=i(e,!1),n=o.outerHTML,r=`</${o.localName}>`;t.push(n.slice(0,n.length-r.length)),yield*d(e,o,t,l),t.push(r)}function*h(e){let t=["<!DOCTYPE html>"];return yield*T(e,t,{bytes:0}),t.join("")}function*k(e){let t=p(e);if(!t.length)return yield*h(e);let l=f(t),o;try{o=yield*h(e)}finally{for(let[n,r]of t)n.replaceChildren(...r)}for(let[n,r]of l)o=o.split(n).join(r);return o}function*M(e){return y(e),yield*h(e)}function*b(e){let t=i(e,!1);for(let s of m)t.removeAttribute(s);let l=t.outerHTML,o=`</${t.localName}>`,n=["<!DOCTYPE html>",l.slice(0,l.length-o.length)],r=p(e),u=r.length?f(r):[];try{yield*d(e,i(e,!1),n,{bytes:0})}finally{for(let[s,a]of r)s.replaceChildren(...a)}n.push(o);let c=n.join("");for(let[s,a]of u)c=c.split(s).join(a);return c}export{h as a,k as b,M as c,b as d};
@@ -1,4 +1,4 @@
1
- import{e as X,f as G,h as J,i as Q,j as P,k as U}from"./c-NICICT4P.js";import{a as C,f as L}from"./c-CZHTXGJS.js";import"./c-WN3MXOLT.js";import"./c-V2V5FKXX.js";import{a as O,b as N,k as z,l as K,m as j,n as V,v as T}from"./c-WMRJKQ2V.js";import{p as w}from"./c-ZRGEN6QQ.js";import"./c-OH2FPYSY.js";import{b as y,d as H}from"./c-RETTCOWO.js";import{b as W}from"./c-RS77ODLY.js";import"./c-7SWMYKAI.js";import"./c-UGHH4MB3.js";import"./c-LA2BW7UY.js";import{d as q}from"./c-QQFHEODI.js";import"./c-IJUK2GPW.js";import"./c-EDE45NM7.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4NTUVDZ.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var ce=128,D=r=>r.depth?r.node(1).attrs.id:null,Z=r=>!!r.depth&&r.node(1).type.name==="table",ae=(r,t,o,e,n)=>O(K(z(r.flow,J(t,o.holes,e,o.visible),n)));function te({pd:r,w:t,doc:o},e){if(!r||!t||!o||!e)return null;if(e instanceof y.TextSelection){let n=e.$anchor,s=e.$head;if(Z(n)||Z(s)){let a=P(o,n.pos),u=P(o,s.pos);return!a||!u||a.table!==u.table||a.row!==u.row||a.col!==u.col?null:{kind:"cell",block:a.table,row:a.row,col:a.col}}let i=Math.min(e.from,e.to),l=a=>{let u=D(a);return u===null?null:{block:u,rel:ae(r,o,t,a.pos,e.empty||a.pos===i?0:-1)}},c=l(n),m=l(s);return c&&m?{kind:"text",anchor:c,head:m}:null}if(e instanceof w||e instanceof y.NodeSelection){let n=[];if(e instanceof w){let{lo:s,hi:i}=e.span();o.forEach((l,c,m)=>{m>=s&&m<=i&&n.push(l.attrs.id)})}else{let s=o.nodeAt(e.from);s&&n.push(s.attrs.id)}if(!n.length)return null;if(n.length>ce){let s=D(e.$from);return s?{kind:"blocks",ids:[s]}:null}return{kind:"blocks",ids:n}}return null}var ue=(r,t)=>{if(!t||typeof t!="object"||typeof t.block!="string"||!t.block||typeof t.rel!="string"||!t.rel)return null;let o;try{o=j(N(t.rel))}catch{return null}let e;try{e=V(o,r.ydoc)}catch{return null}return!e||e.type!==r.flow?null:e.index},fe=(r,t)=>{let o=0;for(let e=r.flow._start;e;e=e.right){let n=o+e.length;if(t<n)return!e.deleted;o=n}return!1},de=(r,t)=>{for(let o=r.flow._start;o;o=o.right)if(!o.deleted&&o.content instanceof T&&o.content.embed?.b===t)return!0;return!1},me=(r,t)=>{let o=0,e=null,n=0;for(let s=r.flow._start;s;s=s.right)if(s.content instanceof T&&s.content.embed?.b!==void 0&&(e=s.content.embed.b,n=o+s.length),o+=s.length,o>t&&e!==null)return{id:e,offset:t-n};return e===null?null:{id:e,offset:t-n}},pe=(r,t,o)=>{let e=null;return r.forEach((n,s)=>{e===null&&n.attrs.id===t&&n.isTextblock&&(e=s+1+Math.min(Math.max(o,0),n.content.size))}),e},ee=({pd:r,w:t,doc:o},e)=>{let n=ue(r,e);if(n===null)return null;let s=Q(o,t.holes,t.tokens,n,t.visible);if(D(o.resolve(s))===e.block)return s;let i=me(r,n);if(i&&i.id===e.block){let l=pe(o,e.block,i.offset);if(l!==null)return l}return de(r,e.block)||!fe(r,n)||t.holes.some(l=>n>=G(t.holes,l.at)&&n<X(t.holes,l.at))?null:o.resolve(s).parent.inlineContent?s:null};function oe({pd:r,w:t,doc:o},e){if(!r||!t||!o||!e||typeof e!="object")return null;if(e.kind==="text"){let n=ee({pd:r,w:t,doc:o},e.anchor),s=ee({pd:r,w:t,doc:o},e.head);return n===null||s===null?null:{kind:"text",from:Math.min(n,s),to:Math.max(n,s)}}if(e.kind==="cell"){let n=U(o,{table:e.block,row:e.row,col:e.col,offset:0});return n?{kind:"cell",from:n.from,to:n.to,block:n.block,row:n.row,col:n.col}:null}if(e.kind==="blocks"){let n=[],s=[];for(let i of Array.isArray(e.ids)?e.ids:[])o.forEach((l,c)=>{l.attrs.id!==i||n.includes(i)||(n.push(i),s.push({from:c,to:c+l.nodeSize}))});return s.length?{kind:"blocks",ids:n,ranges:s}:null}return null}var{Plugin:be,PluginKey:ge}=y,{Decoration:h,DecorationSet:x}=H,k=new ge("blockeditor-awareness"),ne="blockeditor-awareness-style",he=`
1
+ import{e as X,f as G,h as J,i as Q,j as P,k as U}from"./c-NICICT4P.js";import{a as C,f as L}from"./c-VO6RSFCO.js";import"./c-WN3MXOLT.js";import"./c-V2V5FKXX.js";import{a as O,b as N,k as z,l as K,m as j,n as V,v as T}from"./c-WMRJKQ2V.js";import{p as w}from"./c-AI3H6ETU.js";import"./c-OH2FPYSY.js";import{b as y,d as H}from"./c-RETTCOWO.js";import{b as W}from"./c-NL4I4KNG.js";import"./c-7SWMYKAI.js";import"./c-UGHH4MB3.js";import"./c-MZCOGNZL.js";import{d as q}from"./c-EQ5NBOGA.js";import"./c-IJUK2GPW.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var ce=128,D=r=>r.depth?r.node(1).attrs.id:null,Z=r=>!!r.depth&&r.node(1).type.name==="table",ae=(r,t,o,e,n)=>O(K(z(r.flow,J(t,o.holes,e,o.visible),n)));function te({pd:r,w:t,doc:o},e){if(!r||!t||!o||!e)return null;if(e instanceof y.TextSelection){let n=e.$anchor,s=e.$head;if(Z(n)||Z(s)){let a=P(o,n.pos),u=P(o,s.pos);return!a||!u||a.table!==u.table||a.row!==u.row||a.col!==u.col?null:{kind:"cell",block:a.table,row:a.row,col:a.col}}let i=Math.min(e.from,e.to),l=a=>{let u=D(a);return u===null?null:{block:u,rel:ae(r,o,t,a.pos,e.empty||a.pos===i?0:-1)}},c=l(n),m=l(s);return c&&m?{kind:"text",anchor:c,head:m}:null}if(e instanceof w||e instanceof y.NodeSelection){let n=[];if(e instanceof w){let{lo:s,hi:i}=e.span();o.forEach((l,c,m)=>{m>=s&&m<=i&&n.push(l.attrs.id)})}else{let s=o.nodeAt(e.from);s&&n.push(s.attrs.id)}if(!n.length)return null;if(n.length>ce){let s=D(e.$from);return s?{kind:"blocks",ids:[s]}:null}return{kind:"blocks",ids:n}}return null}var ue=(r,t)=>{if(!t||typeof t!="object"||typeof t.block!="string"||!t.block||typeof t.rel!="string"||!t.rel)return null;let o;try{o=j(N(t.rel))}catch{return null}let e;try{e=V(o,r.ydoc)}catch{return null}return!e||e.type!==r.flow?null:e.index},fe=(r,t)=>{let o=0;for(let e=r.flow._start;e;e=e.right){let n=o+e.length;if(t<n)return!e.deleted;o=n}return!1},de=(r,t)=>{for(let o=r.flow._start;o;o=o.right)if(!o.deleted&&o.content instanceof T&&o.content.embed?.b===t)return!0;return!1},me=(r,t)=>{let o=0,e=null,n=0;for(let s=r.flow._start;s;s=s.right)if(s.content instanceof T&&s.content.embed?.b!==void 0&&(e=s.content.embed.b,n=o+s.length),o+=s.length,o>t&&e!==null)return{id:e,offset:t-n};return e===null?null:{id:e,offset:t-n}},pe=(r,t,o)=>{let e=null;return r.forEach((n,s)=>{e===null&&n.attrs.id===t&&n.isTextblock&&(e=s+1+Math.min(Math.max(o,0),n.content.size))}),e},ee=({pd:r,w:t,doc:o},e)=>{let n=ue(r,e);if(n===null)return null;let s=Q(o,t.holes,t.tokens,n,t.visible);if(D(o.resolve(s))===e.block)return s;let i=me(r,n);if(i&&i.id===e.block){let l=pe(o,e.block,i.offset);if(l!==null)return l}return de(r,e.block)||!fe(r,n)||t.holes.some(l=>n>=G(t.holes,l.at)&&n<X(t.holes,l.at))?null:o.resolve(s).parent.inlineContent?s:null};function oe({pd:r,w:t,doc:o},e){if(!r||!t||!o||!e||typeof e!="object")return null;if(e.kind==="text"){let n=ee({pd:r,w:t,doc:o},e.anchor),s=ee({pd:r,w:t,doc:o},e.head);return n===null||s===null?null:{kind:"text",from:Math.min(n,s),to:Math.max(n,s)}}if(e.kind==="cell"){let n=U(o,{table:e.block,row:e.row,col:e.col,offset:0});return n?{kind:"cell",from:n.from,to:n.to,block:n.block,row:n.row,col:n.col}:null}if(e.kind==="blocks"){let n=[],s=[];for(let i of Array.isArray(e.ids)?e.ids:[])o.forEach((l,c)=>{l.attrs.id!==i||n.includes(i)||(n.push(i),s.push({from:c,to:c+l.nodeSize}))});return s.length?{kind:"blocks",ids:n,ranges:s}:null}return null}var{Plugin:be,PluginKey:ge}=y,{Decoration:h,DecorationSet:x}=H,k=new ge("blockeditor-awareness"),ne="blockeditor-awareness-style",he=`
2
2
  .blockeditor-remote-selection { background-color: color-mix(in srgb, var(--blockeditor-remote-color, currentColor) 22%, transparent); }
3
3
  .blockeditor-remote-caret { position: relative; display: inline-block; width: 0; height: 1.1em; vertical-align: text-bottom; }
4
4
  .blockeditor-remote-caret::before { content: ""; position: absolute; inset-inline-start: -1px; top: 0; bottom: 0; width: 2px; background: var(--blockeditor-remote-color, currentColor); }
@@ -0,0 +1 @@
1
+ import{l as ne}from"./c-U4TWEIKZ.js";import"./c-VHNSBD2M.js";function J(e){let r=e?.name||"";return r==="QuotaExceededError"||r==="NS_ERROR_DOM_QUOTA_REACHED"?"quota":r==="VersionError"?"unknown-schema":r==="DataCloneError"?"uncloneable":r==="AbortError"||r==="TransactionInactiveError"||r==="InvalidStateError"?"aborted":r==="SecurityError"||r==="UnknownError"||r==="NotSupportedError"?"unavailable":"error"}var Te="clay-visitor-drafts",Ie=1,V="records",Q="parts",xe=2e3;function _(e,r){let d=new Error(`visitor-drafts: the draft database failed (${e})`);return d.code=e,r!==void 0&&(d.cause=r),d}function me(e,r){return new Promise((d,h)=>{let m=[],l=e.openCursor(r);l.onerror=()=>h(l.error),l.onsuccess=()=>{let s=l.result;if(!s)return d(m);m.push([s.key,s.value]),s.continue()}})}function ve({factory:e=globalThis.indexedDB,keyRange:r=globalThis.IDBKeyRange,name:d=Te,timeout:h=xe}={}){return new Promise((m,l)=>{if(!e||typeof e.open!="function"||!r)return l(_("unavailable"));let s;try{s=e.open(d,Ie)}catch(n){return l(_(J(n),n))}let b=!1,E=(n,k)=>b?!1:(b=!0,clearTimeout(a),n(k),!0),a=setTimeout(()=>E(l,_("blocked")),h);s.onupgradeneeded=()=>{let n=s.result;n.objectStoreNames.contains(V)||n.createObjectStore(V),n.objectStoreNames.contains(Q)||n.createObjectStore(Q)},s.onsuccess=()=>{let n=s.result;E(m,Ne(n,r))||n.close()},s.onerror=()=>E(l,_(J(s.error),s.error)),s.onblocked=()=>E(l,_("blocked"))})}function Ne(e,r){let d=!1;e.onversionchange=()=>{d=!0;try{e.close()}catch{}};function h(a,n){if(d)throw _("closed");try{return e.transaction(a,n)}catch(k){throw _(J(k),k)}}async function m(a){let n=h(V,"readonly"),k=r.bound(a,a+":\uFFFF");try{let v=await me(n.objectStore(V),k);return new Map(v.filter(([u])=>u===a||u.startsWith(a+":")))}catch(v){throw _(J(v),v)}}async function l(a,n){let k=h(Q,"readonly"),v=r.bound([a,n],[a,n,[]]);try{let u=await me(k.objectStore(Q),v);return new Map(u.map(([I,o])=>[I[2],o]))}catch(u){throw _(J(u),u)}}function s(a,n,{timeout:k=0,recovery:v=!1}={}){return new Promise((u,I)=>{let o;try{o=h([V,Q],"readwrite")}catch(i){return I(i)}let f=null,P,y=!1,D,C=(i,g)=>{y||(y=!0,clearTimeout(D),i(g))};k>0&&(D=setTimeout(()=>{f=_("blocked");try{o.abort()}catch{}C(I,f)},k)),o.oncomplete=()=>C(u,P),o.onabort=()=>C(I,f||_(o.error?J(o.error):"aborted",o.error));try{let i=o.objectStore(V),g=r.bound(a+":op:",a+":op:\uFFFF"),w={record:i.get(a),meta:i.get(a+":meta"),v1base:i.get(a+":v1base"),names:i.getAllKeys(g),values:i.getAll(g)},S=v?r.bound(a+":recovery:",a+":recovery:\uFFFF"):null;S&&(w.copyNames=i.getAllKeys(S),w.copyValues=i.getAll(S)),(w.copyValues??w.values).onsuccess=()=>{if(!y)try{let A={record:w.record.result??null,meta:w.meta.result??null,v1base:w.v1base.result??null,rows:w.names.result.map((N,R)=>[N,w.values.result[R]]),...S&&{recovery:w.copyNames.result.map((N,R)=>[N,w.copyValues.result[R]])}},M=n(A);for(let[N,R]of M.puts)i.put(R,N);for(let N of M.deletes)i.delete(N);P=M.result}catch(A){f=_(J(A),A);try{o.abort()}catch{}}}}catch(i){f=_(J(i),i);try{o.abort()}catch{}}})}function b(a,n){return new Promise((k,v)=>{if(!/:op:[^:]+$/.test(a))return v(_("bad-op"));let u;try{u=h(V,"readwrite"),u.objectStore(V).put(n,a),u.commit?.()}catch(I){return v(I instanceof Error&&I.code?I:_(J(I),I))}u.oncomplete=()=>k(),u.onabort=()=>v(_(u.error?J(u.error):"aborted",u.error))})}function E(){d=!0;try{e.close()}catch{}}return{readAll:m,readParts:l,change:s,putRow:b,close:E}}var x=e=>e===void 0?void 0:JSON.parse(JSON.stringify(e)),K=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Re=e=>e+":meta",ce=(e,r)=>`${e}:op:${r}`,ge=(e,r)=>r===void 0?e+":conflict":`${e}:conflict:${r}`,oe=(e,r)=>`${e}:recovery:${r}`,X=e=>K(e)&&e.v===1&&e.w===void 0&&K(e.data),L=e=>typeof e.id=="string"?e.id:"at:"+e.savedAt,we=(e,r)=>`${e}~${r}`;function Z(e){let r=/^(\d+)~/.exec(e??"");return r?Number(r[1]):null}function _e(e,r,d){let h={...e},m={...e};for(let[l,s]of Object.entries(r))"b"in s?h[l]=s.b:delete h[l],"m"in s?m[l]=s.m:delete m[l];return d(h,m,e)}var G=e=>K(e)&&typeof e.tab=="string"&&typeof e.reset=="string"&&Array.isArray(e.ops),$=e=>G(e)?`op:${e.tab}:${e.ops.at(-1)?.seq??e.acked??0}`:L(e);function se(e,r){if(K(e)&&e.v===1&&K(e.data))return x(e);if(!G(e)||!e.ops.length)return null;let d=x(r),h=null;for(let m of e.ops){for(let[l,s]of Object.entries(m.keys??{}))"m"in s?Object.defineProperty(d,l,{value:x(s.m),enumerable:!0,writable:!0,configurable:!0}):delete d[l];m.unit!==void 0&&(h=m.unit.to)}return{v:1,savedAt:e.ops.at(-1).savedAt,data:d,...h&&{live:x(h.live),blockeditor:x(h.blockeditor)}}}function fe(e,r){if(K(e)&&r.recovery?.includes($(e)))return!0;if(!G(e))return!1;let d=Math.max(e.acked??0,e.reset===r.reset?r.tabs[e.tab]?.seq??0:0);return e.ops.every(h=>h.seq<=d)}function ue(e=null){return{gen:Z(e)??1,rev:0,reset:e??"",tabs:{},foreign:null,unit:null}}var q=e=>e&&e.blockeditor?{live:e.live,blockeditor:e.blockeditor}:null;function ae(e,r,d){let h=[...e,r?.id,...r?.ancestry??[]].filter(m=>typeof m=="string");return h.length?h.slice(0,32):["root:"+d.reset]}function Me(e,{record:r,seen:d,direct:h,v1base:m,meta:l}){let s=K(d)&&d.v===1&&K(d.data)&&d.w?.reset===l.reset?d:null,b=a=>a&&typeof a.id=="string"?e.indexOf(a.id):-1,E=[[r,b(r)],[s,s&&h?0:b(s)],[m,b(m)]].filter(([,a])=>a>=0);return E.length?E.reduce((a,n)=>n[1]<a[1]?n:a)[0]:null}function De(e,{seed:r,newId:d,now:h,merge3:m,same:l,unitMark:s,marker:b=null,resets:E=[],chains:a=[],local:n=null,seen:k=null,direct:v=!1,recovery:u=null,copies:I=[]}){let o=e.meta?x(e.meta):ue(b);!e.meta&&Number.isInteger(n?.w?.rev)&&(o.rev=n.w.rev);let f=e.record?x(e.record):null,P=e.v1base?x(e.v1base):null,y={conflicts:[],recovered:[],released:[],dropped:[],stale:[],applied:{},changed:!e.meta};function D(i,g=[]){let w=$(i);if(o.recovery?.includes(w))return;y.recovered.push(x(i));let S=[w,...(o.recovery??[]).filter(A=>A!==w&&!g.includes(A))].slice(0,8);return y.dropped=[...new Set([...y.dropped,...o.recovery??[]])].filter(A=>!S.includes(A)),o.recovery=S,y.changed=!0,!0}let C=[...E];b&&b!==o.reset&&C.push({ends:Z(b)===null?null:Z(b)-1,marker:b});for(let i of C){if(i.marker===o.reset||o.ended?.includes(i.marker)||i.ends!==null&&i.ends<o.gen)continue;i.ends!==o.gen&&f&&D(f);let g=typeof n?.reset=="string"?n.reset===i.marker:i.ends===null||Array.isArray(n?.ancestry)&&n.ancestry.includes("root:"+i.marker);X(n)&&L(n)!==o.foreign&&!g&&(D(n),o.foreign=L(n)),o.ended=[...o.ended??[],o.reset].slice(-32),Object.assign(o,{gen:o.gen+1,reset:i.marker,tabs:{},unit:null}),o.rev++,f=null,P=null,y.changed=!0}if(!e.meta&&!f&&K(n)&&n.v===1&&K(n.data)&&(n.w===void 0||n.w.reset===o.reset)){let{w:i,...g}=n;f=x(g),i===void 0&&(P=x(g),o.foreign=L(n),o.rev++)}if(e.meta||(o.unit=s(q(f))),e.meta&&X(n)&&L(n)!==o.foreign){let i=L(n),g=Array.isArray(n.ancestry)?n.ancestry:[],w=f?Me(g,{record:f,seen:k,direct:v,v1base:P,meta:o}):null;if(typeof n.reset=="string"&&o.ended?.includes(n.reset))D(n,g)&&y.released.push(x(n));else if(!f)f=x(n),P=x(n),o.unit=s(q(f)),o.rev++;else if(w){let S=m(w.data,n.data,f.data),A=q(n),M=!!A&&s(A)!==s(q(w)),N=M&&q(f)&&s(q(w))!==o.unit;(S.conflict||N)&&y.conflicts.push(x(f));let R=M?A:q(f);f={v:1,savedAt:n.savedAt??new Date(h).toISOString(),id:d(),ancestry:ae(typeof n.id=="string"?[n.id]:[],f,o),data:S.value,...R&&{live:R.live,blockeditor:R.blockeditor}},M&&(o.unit=s(R)),P=x(n),o.rev++}else D(n,g)&&y.released.push(x(n));o.foreign=i,y.changed=!0}for(let i of a){if(!G(i))continue;if(i.reset!==o.reset){let S=i.reset===e.meta?.reset?e.meta.tabs[i.tab]?.seq??0:0;i.ops.some(A=>A.seq>Math.max(S,i.acked??0))&&D(i),y.stale.includes(i.tab)||y.stale.push(i.tab);continue}let g=o.tabs[i.tab]?.seq??0,w=Math.max(g,Number.isInteger(i.acked)?i.acked:0);for(let S of i.ops){if(S.seq<=w)continue;if(S.seq!==w+1)break;let A=_e(f?f.data:r,S.keys??{},m),M=S.unit!==void 0&&f&&q(f)&&S.unit.seen!==o.unit;f&&(A.conflict||M)&&y.conflicts.push(x(f));let N=S.unit!==void 0?S.unit.to:q(f),R=d();f={v:1,savedAt:S.savedAt??new Date(h).toISOString(),id:R,ancestry:ae([],f,o),data:A.value,...N&&{live:N.live,blockeditor:N.blockeditor}},S.unit!==void 0&&(o.unit=s(N)),o.rev++,w=S.seq,y.changed=!0}(w!==g||o.tabs[i.tab])&&(o.tabs[i.tab]={seq:w,at:h},y.changed=!0),y.applied[i.tab]=w}if(u){let i=I.find(([g])=>g===u.mark);if(!i)throw new Error("That draft is no longer available. Open the list again.");if(u.type==="remove")o.recovery=(o.recovery??[]).filter(g=>g!==u.mark),y.dropped.push(u.mark),y.removedMark=u.mark,y.changed=!0;else if(u.type==="restore"&&u.reset===o.reset){let g=se(i[1],r);if(!g)throw new Error("This draft cannot be restored by this version.");o.recovery?.includes(u.mark)&&(o.recovery=[u.mark,...o.recovery.filter(S=>S!==u.mark)]);let w=f&&I.some(([S,A])=>{if(!o.recovery?.includes(S))return!1;let M=se(A,r);return M&&l(f.data,M.data)&&l(q(f),q(M))});f&&!w&&D(f),f={v:1,savedAt:new Date(h).toISOString(),id:d(),ancestry:ae([],f,o),data:g.data,...g.blockeditor&&{live:g.live,blockeditor:g.blockeditor}},o.unit=s(q(f)),o.rev++,y.changed=!0,y.restoredCopy=!0}}for(let[i,g]of Object.entries(o.tabs))h-(g.at??0)>2592e6&&(delete o.tabs[i],y.changed=!0);return{meta:o,record:f,v1base:P,...y}}var z=e=>{if(e==null)return null;try{return JSON.parse(e)}catch{return null}};function ye(e,r,d,h){return e.change(r,m=>{let l={meta:z(m.meta),record:z(m.record),v1base:z(m.v1base)},s=m.rows.map(([v,u])=>[v,z(u)]),b=d(l),E=(m.recovery??[]).map(([v,u])=>[v.slice((r+":recovery:").length),z(u)]),a=De(l,{...b,copies:E,chains:[...s.map(([,v])=>v),...b.chains??[]]}),n=[],k=[];a.changed&&(n.push([Re(r),JSON.stringify(a.meta)]),a.record?n.push([r,JSON.stringify(a.record)]):l.record&&k.push(r),a.v1base?n.push([r+":v1base",JSON.stringify(a.v1base)]):l.v1base&&k.push(r+":v1base"));for(let v of a.conflicts)n.push([ge(r,L(v)),JSON.stringify(v)]);a.conflicts.length&&n.push([ge(r),JSON.stringify(a.conflicts[a.conflicts.length-1])]);for(let v of a.recovered)n.push([oe(r,$(v)),JSON.stringify(v)]);for(let v of a.dropped)k.push(oe(r,v));for(let[v,u]of s)(fe(u,a.meta)||a.removedMark&&G(u)&&$(u)===a.removedMark)&&k.push(v);return{puts:n,deletes:k,result:a}},h)}var Pe=256*1024,qe=2*1024,Je=new Set(["v","savedAt","id","ancestry","reset","data"]),Ce=10*1e3,Ke=1500,be=2e3,Le="This draft was started over in another tab.",Ve="This draft was started over in another tab. The earlier draft was kept aside in this browser.",$e="A tab that was open before an update saved another copy of this draft. That copy was kept aside, and this draft was not changed. Reload that tab to go on from this draft.",U=e=>{if(e==null)return null;try{return JSON.parse(e)}catch{return null}};function je(e,r){let d={},h=Object.keys(e).every(m=>Je.has(m));for(let[m,l]of Object.entries(e.data))JSON.stringify(l).length<qe?d[m]=l:h=!1;return JSON.stringify({v:2,savedAt:e.savedAt,id:e.id,ancestry:e.ancestry,idb:!0,...h&&{full:!0},data:d,w:r})}async function Qe({store:e,storage:r,doc:d=document,now:h=()=>Date.now(),reload:m=()=>window.location.reload()}){let l=await ve(),{key:s}=e,b=s+":reset",E=t=>{try{return r?.getItem(t)??null}catch{return null}},a=t=>{try{r?.removeItem(t)}catch{}},n=s+":started-over",k=s+":recovery-notice";try{window.sessionStorage.getItem(n)&&(window.sessionStorage.removeItem(n),window.sessionStorage.getItem(k)||import("./c-NVU3DORS.js").then(t=>t.toastPersistent(Le,"info")).catch(()=>{}))}catch{}let v=null,u="",I=null,o=null,f=null,P=0,y=!1,D=!1,C=e.held()?.id,i=null,g=null,w=new Set;try{let t=window.sessionStorage.getItem(k);if(t){window.sessionStorage.removeItem(k);let c=U(t);le({id:c?.mark??t},!!c?.reset)}}catch{}function S(t){try{window.sessionStorage.setItem(k,JSON.stringify({mark:t,reset:!0}))}catch{}}function A(t){try{window.sessionStorage.setItem(s+":generation",JSON.stringify({marker:u,reset:t}))}catch{}}function M(){let t=E(b);u=t??"";let c=e.journalSlots().filter(T=>T!==e.slotKey).map(T=>U(E(T)));f=e.stopped()?null:o,P=e.chain().ops.at(-1)?.seq??0;let p=e.held();p?.v===1&&p.w!==void 0&&(i=p);let O=f?[f]:[];return{seed:e.seed(),newId:e.newId,merge3:e.merge3,same:e.same,unitMark:e.unitMark,now:h(),marker:t,resets:O,local:p,seen:i,direct:g!==null&&E(s)===g,chains:e.pending()?[...c,e.chain()]:c}}function N(t,c){let p=h();for(let O of e.journalSlots()){if(O===e.slotKey)continue;let T=U(E(O));(c&&G(T)&&$(T)===c||fe(T,t)&&p-(T?.at??0)>Ce)&&a(O)}}function R({meta:t,record:c}){let p=e.held();if(X(p)&&L(p)!==t.foreign)return void setTimeout(Y,0);if((E(b)??"")!==t.reset)return;if(!c)return void(p&&a(s));if(p?.w&&p.w.reset===t.reset&&p.w.rev>=t.rev)return;let O={rev:t.rev,reset:t.reset},T=JSON.stringify({...c,w:O});try{if(T.length<=Pe){r.setItem(s,T),i={...c,w:O};return}}catch{}try{r.setItem(s,je(c,O))}catch{}}async function de(){if(e.stop({keepPending:!0}),e.unsafe()){try{await l.putRow(ce(s,e.tab),JSON.stringify(e.chain()))}catch(t){throw e.failed(t)}e.acknowledge(e.chain().ops.at(-1)?.seq??0)}}async function ie(t){try{e.captureLate()}catch(W){throw e.failed(W)}y=!0;let c=e.chain(),p=$(c),O=c.ops.some(W=>W.seq>P)||t.meta.recovery?.includes(p)?p:t.meta.recovery?.includes(C)?C:null;e.acknowledge(P),await de(),R(t),O&&S(O);let T=e.held();T?.w&&T.w.reset!==t.meta.reset&&a(s);try{window.sessionStorage.setItem(n,"1")}catch{}return A(t.meta.reset),y=!1,m(),t}async function Se(){let t=e.generation(),c=()=>{e.stop(),ne(!1)},p=()=>(E(b)??"")!==t&&(I===null||(E(b)??"")!==u);if(p())return c();let O=I??Z(t);if(O===null){let F=await re.catch(()=>l.change(s,({meta:H})=>({puts:[],deletes:[],result:{meta:U(H)??ue(t)}}),{timeout:be}));if(p())return c();if(O=F.meta.gen,F.meta.reset!==t){o={ends:null,marker:t};let H=await te();if(e.stopped())return c();O=H.meta.gen}}let T=we(O+1,e.newId());o={ends:O,marker:T};let W=E(s);e.held()?.w&&a(s);try{r.setItem(b,T)}catch{}let he;try{let F=te();E(b)!==T?await F:await Promise.race([F.catch(()=>{}),new Promise(H=>{he=setTimeout(H,Ke)})]),c()}catch(F){if(o=null,W!==null&&E(s)===null&&(E(b)??"")===t)try{r.setItem(s,W)}catch{}throw F}finally{clearTimeout(he)}}function le(t,c=!1){console.warn(c?"visitor-drafts: the draft was started over; the earlier draft was kept in this browser's draft database under":"visitor-drafts: a tab on an earlier ClayJS saved a copy that could not be merged exactly; it was kept in this browser's draft database under",oe(s,$(t))),!w.has(c)&&(w.add(c),import("./c-NVU3DORS.js").then(p=>p.toastPersistent(c?Ve:$e,"warning")).catch(()=>{}))}function Ee(t){let{meta:c,record:p}=t;if(u!==c.reset&&(E(b)??"")===u)try{r.setItem(b,c.reset)}catch{}if(f&&f===o&&c.reset!==e.generation()&&(f.marker===c.reset&&A(c.reset),e.stop(),ne(!1)),f===o&&(o=null),e.stopped())return y?ie(t):(R(t),t);if(t.conflicts.length&&console.warn("visitor-drafts: another tab changed the same thing; its copy was kept in this browser's draft database under",s+":conflict"),t.stale.includes(e.tab))return ie(t);if(c.reset!==e.generation()){if(!e.fresh())return ie(t);e.enter(c.reset)}t.released.length&&le(t.released[0]),I=c.gen,A(c.reset);let O=e.acknowledge(c.tabs[e.tab]?.seq??0);if(N(c,t.removedMark),R(t),e.pending()||(O&&(ne(!1),d.dispatchEvent(new CustomEvent("clay:drafts-saved",{detail:{data:p.data}}))),D))return t;if(!e.shown())return v=c.rev,t;e.changed()||(p&&c.rev!==v&&e.take(p.data),C=p?.id,v=c.rev);let T=e.externalUnit(p);return T&&d.dispatchEvent(new CustomEvent("clay:drafts-blockeditor-external",{detail:{live:T.live,adopted:()=>e.adoptedUnit(T)}})),t}let j=null,B=null;function ee(t,c=null){return j=ye(l,s,()=>{if(c?.type==="restore"){if(e.stopped())throw new Error("This page has started over. Reload it before restoring a draft.");e.captureNow()}return{...M(),recovery:c}},t).then(Ee,O=>{throw e.pending()?e.failed(O):O}).finally(()=>{j=null}),j}function te(){return B||(j?(B=j.then(()=>{},()=>{}).then(()=>(B=null,ee())),B):ee())}async function pe(t){for(;j||B;)await(B??j).catch(()=>{});return ee({recovery:!0},t)}async function ke(t){if(D)throw new Error("A draft is already being restored.");D=!0;try{if(e.stopped())throw new Error("This page has started over. Reload it before restoring a draft.");e.captureNow();let c;do if(c=await pe({type:"restore",mark:t,reset:e.generation()}),!c.restoredCopy||e.stopped())throw new Error("This page has started over. Reload it before restoring a draft.");while(e.pending());try{e.captureLate("restored:"+e.tab)}catch(p){throw e.failed(p)}return await de(),m(),c}finally{D=!1}}async function Oe(){await re.catch(()=>{});let t=s+":recovery:";return[...await l.readAll(s)].filter(([p])=>p.startsWith(t)).map(([p,O])=>({mark:p.slice(t.length),copy:U(O)}))}let Y=()=>{te().catch(()=>{})};function Ae(){e.unsafe()&&l.putRow(ce(s,e.tab),JSON.stringify(e.chain())).catch(()=>{}),e.pending()&&Y()}window.addEventListener("storage",t=>{if(t.key===s){let[c,p]=[U(t.oldValue),U(t.newValue)];p?.v===1&&p.w!==void 0?i=p:X(p)&&c?.v===1&&c.w!==void 0&&([i,g]=[c,t.newValue])}(t.key===null||t.key===s||t.key===b)&&Y()}),window.addEventListener("pageshow",t=>{t.persisted&&Y()}),d.addEventListener("clay:drafts-blockeditor-listening",Y);let re=ee({timeout:be});return re.catch(()=>{}),{first:re,sync:te,hide:Ae,startOver:Se,listRecovery:Oe,restoreRecovery:ke,recoveryRecord:t=>se(t,e.seed()),removeRecovery:t=>pe({type:"remove",mark:t})}}export{Pe as FULL_COPY_LIMIT,Qe as openSession};
@@ -0,0 +1 @@
1
+ import{a as b,b as c,c as d,d as e,e as f}from"./c-KYTVZT4D.js";import{g as a}from"./c-JWW6BHWD.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-DT7E76Z2.js";import"./c-C6YZNU6E.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-AI3H6ETU.js";import"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import"./c-RETTCOWO.js";import"./c-WCG6AKA7.js";import"./c-57XDY6HC.js";import"./c-I2SCCUEW.js";import"./c-VHNSBD2M.js";export{e as ChartView,d as chartFromSlash,a as chartTables,b as insertChartAfterTable,f as refreshCharts,c as tableLabel};
@@ -1,4 +1,4 @@
1
1
  import{$ as Xt,A as V,U as Ut,V as ut,W as Ft,Z as Wt,_ as Gt,a as L,b as et,d as T,da as ft,e as nt,h as Rt,k as qt,ka as Qt,m as ct,q as _t,r as Kt,s as Ht,t as jt,v as ot,y as lt,z as dt}from"./c-OH2FPYSY.js";import{a as O,b as D,d as $,e as Z,f as Vt,g as tt}from"./c-RETTCOWO.js";var be=e=>e==="left"||e==="right"?e:null,{Plugin:wt,PluginKey:ke,TextSelection:I,NodeSelection:Yt,Selection:st}=D,M=T.nodes,S=e=>e.type===M.list_item,A=e=>e.type===M.toggle,k=e=>e.attrs.parent??null,Et="blockeditor-step",q="blockeditor-move",Mt=e=>e&&(n=>e(Z.closeHistory(n).setMeta(Et,!0)));function y(e,n=null){let t=[],o=new Map,r=[];e.forEach((s,i)=>{let a=t.length,l=t[a-1],c=k(s),d=c!==null&&o.has(c)?o.get(c):-1,f=d;if(S(s)){for(l&&S(l.node)&&k(l.node)===c||(r=[]);r.length&&t[r[r.length-1]].node.attrs.indent>=s.attrs.indent;)r.pop();r.length&&(f=r[r.length-1]),r.push(a)}else r=[];let p=A(s)&&(s.attrs.open||!!n?.has(s.attrs.id)),u=d>=0&&(t[d].hidden||!t[d].open);t.push({node:s,at:i,end:i+s.nodeSize,i:a,up:f,depth:d>=0?t[d].depth+1:0,hidden:u,open:p,subEnd:a}),A(s)&&s.attrs.id&&o.set(s.attrs.id,a)});for(let s=t.length-1;s>=0;s--){let i=t[s].up;i>=0&&t[s].subEnd>t[i].subEnd&&(t[i].subEnd=t[s].subEnd)}return t}var Jn=(e,n)=>({from:e[n].at,to:e[e[n].subEnd].end});function xe(e,n=null){let t=new Map;n?.forEach(c=>{c.attrs.id&&t.set(c.attrs.id,k(c))}),e.forEach(c=>{c.attrs.id&&t.set(c.attrs.id,k(c))});let o=[];e.forEach((c,d)=>o.push({node:c,at:d}));let r=new Array(o.length).fill(null);for(let c=o.length-2;c>=0;c--){let d=k(o[c+1].node);r[c]=d!==k(o[c].node)?d:r[c+1]}let s=[],i=[null],a=null,l=[];return o.forEach(({node:c,at:d},f)=>{let p=k(c),u=new Set;for(;p!==null&&!i.includes(p)&&!u.has(p);)u.add(p),p=t.has(p)?t.get(p):null;i.includes(p)||(p=null);let h=r[f];i.indexOf(h)>i.indexOf(p)&&(p=h);let m=i.slice(0,i.indexOf(p)+1),g=c.attrs.indent;if(S(c)){let E=Number.isInteger(g)&&g>0?g:0,b=a&&S(a.node)&&a.parent===p;for(b||(l=[]);l.length&&l[l.length-1].orig>E;)l.pop();let N=0;if(l.length){let C=l[l.length-1];N=C.shift,C.orig===E&&l.pop()}g=Math.max(0,Math.min(E-N,b?a.indent+1:0)),l.push({orig:E,shift:E-g})}else l=[];(p!==k(c)||S(c)&&g!==c.attrs.indent)&&s.push({at:d,attrs:{...c.attrs,parent:p,...S(c)?{indent:g}:{}}}),a={node:c,parent:p,indent:g},i=A(c)&&c.attrs.id?[...m,c.attrs.id]:m}),s}function Zn(){let e=new WeakSet;return new wt({appendTransaction(n,t,o){if(!n.some(i=>i.docChanged&&!i.getMeta(ot)))return null;if(e.has(t.doc)&&je(t.doc,o.doc))return e.add(o.doc),null;let r=xe(o.doc,t.doc);if(!r.length)return e.add(o.doc),null;let s=o.tr;for(let i of r)s.setNodeMarkup(i.at,null,i.attrs);return s}})}function it(e,n,t){let o=e.resolve(n.from).index(0),r=Math.min(e.resolve(n.to).index(0),t.length-1);return r>o&&n.to<=t[r].at&&r--,[Math.min(o,t.length-1),r]}var ne=it;function z(e,n,t){let o=n;for(;e[o].up>=0&&t>e[e[o].up].subEnd;)o=e[o].up;let r=e[o].up,s=e[o].subEnd;for(;s<t;)s=e[s+1].subEnd;return{lo:o,hi:s,up:r}}var ye=(e,n,t)=>{let o=e.resolve(Math.max(0,Math.min(n,e.content.size)));return o.depth===0?o.pos:t<0?o.before(1):o.after(1)},Jt=e=>({id:e.node.attrs.id,at:e.at,node:e.node}),bt=(e,n)=>n.id?e.node.attrs.id===n.id:e.at===n.at&&e.node.type===n.node.type&&e.node.content.eq(n.node.content);function Ae(e,n,t){let o=[];for(let r=n;r<=t;r=e[r].subEnd+1)o.push(Jt(e[r]));return{roots:o,members:e.slice(n,t+1).map(Jt)}}function Se(e,n){let t=n.roots.map(i=>e.findIndex(a=>bt(a,i))).filter(i=>i>=0);if(!t.length||t.some(i=>e[i].hidden))return null;let o=t[0],r=e[o].up,s=e[o].subEnd;for(let i of t.slice(1)){if(i!==s+1||e[i].up!==r)return null;s=e[i].subEnd}return e.slice(o,s+1).some(i=>!n.members.some(a=>bt(i,a)))?null:{lo:o,hi:s}}var we=(e,n)=>{let t=o=>({...o,at:n.map(o.at,1)});return{roots:e.roots.map(t),members:e.members.map(t)}},x=class e extends st{map(n,t){return this.getBookmark().map(t).resolve(n)}eq(n){return n instanceof e&&n.anchor===this.anchor&&n.head===this.head}toJSON(){return{type:"blockeditor-block",anchor:this.anchor,head:this.head}}static fromJSON(n,t){return new e(n.resolve(t.anchor),n.resolve(t.head))}getBookmark(){let{lo:n,hi:t}=this.span();return new kt(this.anchor,this.head,Ae(y(this.$from.doc),n,t))}span(n=this.$from.doc){return{lo:n.resolve(this.from).index(0),hi:n.resolve(this.to).index(0)-1}}};x.prototype.visible=!1;st.jsonID("blockeditor-block",x);var kt=class e{constructor(n,t,o){this.anchor=n,this.head=t,this.span=o}map(n){let t=this.anchor<=this.head;return new e(n.map(this.anchor,t?1:-1),n.map(this.head,t?-1:1),we(this.span,n))}resolve(n){let t=y(n),o=Se(t,this.span);if(!o){let i=t.find(a=>bt(a,this.span.roots[0]));return st.near(n.resolve(i?.at??ye(n,Math.min(this.anchor,this.head),-1)))}let r=t[o.lo].at,s=t[o.hi].end;return this.anchor<=this.head?new x(n.resolve(r),n.resolve(s)):new x(n.resolve(s),n.resolve(r))}},oe=(e,n)=>{for(let t=n-1;t>=0;t--)if(e[t].up===e[n].up)return t;return-1};function G(e,n,t,o,r=()=>null){let s=r(e[n])||{},i="parent"in s?s.parent:k(e[n].node),a=null;for(let d=0;d<e.length&&e[d].end<=o;d++)d>=n&&d<=t||k(e[d].node)===i&&(a=e[d].node.attrs.id);let l=[],c={};for(let d=n;d<=t;d++){let f=e[d].node,p=r(e[d]);l.push(f.attrs.id),p&&"indent"in p&&p.indent!==f.attrs.indent&&(c[f.attrs.id]={indent:p.indent})}return{ids:l,afterId:a,parent:i,attrs:c}}function re(e,n,t,o,r,s=()=>null,i=e.selection){let a=n[t].at,l=n[o].end,c=l-a,d=[];for(let h=t;h<=o;h++){let m=n[h].node;d.push(m.type.create({...m.attrs,...s(n[h])||{},pos:null},m.content,m.marks))}let f=e.tr.delete(a,l),p=r>a?r-c:r;f.insert(p,d);let u=p-a;return i instanceof x?f.setSelection(new x(f.doc.resolve(i.anchor+u),f.doc.resolve(i.head+u))):i instanceof Yt?f.setSelection(Yt.create(f.doc,i.from+u)):f.setSelection(I.create(f.doc,i.anchor+u,i.head+u)),f.setMeta(q,G(n,t,o,r,s))}function xt(e,n,t){let o=e[t].node;if(A(o)){let s=o.attrs.id,i=k(o);return a=>k(a.node)===s?{parent:i}:null}let r=o.attrs.indent-e[n].node.attrs.indent;return s=>S(s.node)?{indent:s.node.attrs.indent+r}:null}var Zt=e=>(n,t)=>{t=Mt(t);let o=y(n.doc);if(!o.length)return!1;let[r,s]=it(n.doc,n.selection,o),{lo:i,hi:a,up:l}=z(o,r,s),c,d=()=>null;if(e<0){let f=oe(o,i);if(f>=0)c=o[f].at;else if(l>=0)c=o[l].at,d=xt(o,i,l);else return!0}else{let f=a+1;if(f<o.length&&o[f].up===l)c=o[o[f].subEnd].end;else if(l>=0)c=o[o[l].subEnd].end,d=xt(o,i,l);else return!0}return t&&t(re(n,o,i,a,c,d).scrollIntoView()),!0},Ee=8,rt=(e,n)=>S(e.node)&&S(n.node)&&k(e.node)===k(n.node);function Me(e,n){n=Mt(n);let t=y(e.doc);if(!t.length)return!1;let[o,r]=it(e.doc,e.selection,t),s=t[o];if(S(s.node)&&o>0&&rt(t[o-1],s)){if(s.node.attrs.indent>t[o-1].node.attrs.indent)return!0;for(let a=o;a<=Math.max(r,s.subEnd);a++)if(t[a].node.attrs.indent>=Ee)return!0;if(n){let a=e.tr,l=r;for(let d=o;d<=l;d++)l=Math.max(l,t[d].subEnd);let c=o-1;for(let d=o;d<=l&&rt(t[d],s);d++)a.setNodeMarkup(t[d].at,null,{...t[d].node.attrs,indent:t[d].node.attrs.indent+1}),c=d;a.setMeta(q,G(t,o,c,t[o].at,d=>d.i>=o&&d.i<=c?{indent:d.node.attrs.indent+1}:null)),n(a)}return!0}let i=oe(t,o);if(i<0||!A(t[i].node)||t[i].subEnd!==o-1)return!0;if(n){let{hi:a}=z(t,o,r),l=e.tr,c=k(s.node),d=t[i].node.attrs.id,f=[];for(let u=o;u<=a;u++)k(t[u].node)===c&&(l.setNodeMarkup(t[u].at,null,{...t[u].node.attrs,parent:d}),f.push(t[u].node.attrs.id));t[i].node.attrs.open||l.setNodeMarkup(t[i].at,null,{...t[i].node.attrs,open:!0});let p=G(t,o,a,t[o].at,u=>u.i>=o&&u.i<=a&&k(u.node)===c?{parent:d}:null);l.setMeta(q,{...p,ids:f,attrs:t[i].node.attrs.open?p.attrs:{...p.attrs,[d]:{open:!0}}}),n(l)}return!0}function vt(e,n){n=Mt(n);let t=y(e.doc);if(!t.length)return!1;let[o,r]=it(e.doc,e.selection,t),s=t[o];if(S(s.node)&&s.node.attrs.indent>0){if(n){let{lo:d,hi:f}=z(t,o,r),p=e.tr,u=new Set;for(let h=o;h<=r;){let m=t[h];if(S(m.node)&&m.node.attrs.indent>0)for(let g=h;g<=m.subEnd;g++)S(t[g].node)&&(p.setNodeMarkup(t[g].at,null,{...t[g].node.attrs,indent:t[g].node.attrs.indent-1}),u.add(g));h=m.subEnd+1}p.setMeta(q,G(t,d,f,t[d].at,h=>u.has(h.i)?{indent:h.node.attrs.indent-1}:null)),n(p)}return!0}if(k(s.node)===null)return!0;let{lo:a,hi:l}=z(t,o,r),c=t[a].up;for(;c>=0&&!A(t[c].node);)c=t[c].up;if(c<0)return!0;if(n){let d=xt(t,a,c),f=t[c].subEnd;if(l===f){let p=e.tr;for(let u=a;u<=l;u++){let h=d(t[u]);h&&p.setNodeMarkup(t[u].at,null,{...t[u].node.attrs,...h})}p.setMeta(q,G(t,a,l,t[a].at,d)),n(p)}else n(re(e,t,a,l,t[f].end,d).scrollIntoView())}return!0}function se(e){let n=e.tr;return e.selection.empty||n.deleteSelection(),n}function ve(e,n){let{$from:t,$to:o,empty:r}=e.selection;if(t.depth!==1||!S(t.parent)||!t.sameParent(o))return!1;if(r&&t.parent.content.size===0){let h=t.parent;return h.attrs.indent>0?vt(e,n):(n&&n(e.tr.setNodeMarkup(t.before(),M.paragraph,{id:h.attrs.id,pos:h.attrs.pos,parent:h.attrs.parent})),!0)}let s=se(e),i=s.selection.$from,a=i.parent,l=y(s.doc),c=i.index(0),d=i.parentOffset===0,f=i.parentOffset===a.content.size,p=l[c+1],u=f&&p&&rt(p,l[c])&&p.node.attrs.indent>a.attrs.indent;return d?(s.split(i.pos,1,[{type:M.list_item,attrs:a.attrs}]),s.setNodeMarkup(l[c].at,null,{...a.attrs,checked:!1})):s.split(i.pos,1,[{type:M.list_item,attrs:{...a.attrs,checked:!1,indent:a.attrs.indent+(u?1:0)}}]),n&&n(s.scrollIntoView()),!0}function Te(e,n){let{$from:t,$to:o}=e.selection;if(t.depth!==1||!A(t.parent)||!t.sameParent(o))return!1;let r=se(e),s=r.selection.$from,i=s.parent,a=y(r.doc),l=s.index(0),c=a[l],d=c.subEnd>l;if(i.content.size===0&&!d)return r.setNodeMarkup(c.at,M.paragraph,{id:i.attrs.id,pos:i.attrs.pos,parent:i.attrs.parent}),n&&n(r),!0;if(s.parentOffset===0&&i.content.size>0)return r.insert(c.at,M.paragraph.create({parent:k(i)})),n&&n(r.scrollIntoView()),!0;let f=i.content.cut(s.parentOffset);if(i.attrs.open)r.split(s.pos,1,[{type:M.paragraph,attrs:{parent:i.attrs.id}}]);else{let p=a[c.subEnd].end,u=r.steps.length;r.delete(s.pos,c.end-1);let h=r.mapping.slice(u).map(p);r.insert(h,M.toggle.create({parent:k(i),open:!1},f)),r.setSelection(I.create(r.doc,h+1))}return n&&n(r.scrollIntoView()),!0}function Ne(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||t.parent.type!==M.paragraph||t.parent.content.size)return!1;let r=k(t.parent);if(r===null)return!1;let s=y(e.doc),i=t.index(0),a=s.findIndex(l=>l.node.attrs.id===r);if(a<0||s[a].subEnd!==i)return!1;if(n){let l=s[i].node.attrs.id,c=k(s[a].node),d=i>0?s[i-1].node:null,f=e.tr.setNodeMarkup(s[i].at,null,{...t.parent.attrs,parent:c});f.setMeta(q,{ids:[l],afterId:d?d.attrs.id:null,parent:k(d??s[i].node),attrs:{[l]:{parent:c}}}),n(f)}return!0}function Ie(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||!t.parent.isTextblock||t.parent.type.spec.code)return!1;let r=t.parent;if(S(r)||A(r)||k(r)===null||t.parentOffset!==r.content.size)return!1;if(n){let s=e.tr.split(t.pos,1,[{type:M.paragraph,attrs:{parent:k(r)}}]);n(s.scrollIntoView())}return!0}function Ce(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||!S(t.parent)||t.parentOffset!==0)return!1;if(t.parent.attrs.indent>0)return vt(e,n);let r=t.parent;return n&&n(e.tr.setNodeMarkup(t.before(),M.paragraph,{id:r.attrs.id,pos:r.attrs.pos,parent:r.attrs.parent})),!0}function Oe(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||!A(t.parent)||t.parentOffset!==0)return!1;let r=t.parent;return n&&n(e.tr.setNodeMarkup(t.before(),M.paragraph,{id:r.attrs.id,pos:r.attrs.pos,parent:r.attrs.parent})),!0}function Tt(e,n){if(n<=0||!e[n-1].hidden)return-1;let t=n-1;for(;t>=0&&e[t].hidden;)t--;return t>=0&&A(e[t].node)&&e[t].subEnd>=n-1?t:-1}function Nt(e,n,t,o){let r=e.tr,s=n[o],i=n[t].end-1;return r.delete(s.at,s.end),s.node.content.size&&r.insert(i,s.node.content),r.setSelection(I.create(r.doc,i))}function De(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||t.parentOffset!==0||!t.parent.isTextblock)return!1;let r=y(e.doc),s=t.index(0),i=Tt(r,s);return i<0?!1:(n&&n(Nt(e,r,i,s).scrollIntoView()),!0)}function $e(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||!A(t.parent)||t.parent.attrs.open||t.parentOffset!==t.parent.content.size)return!1;let r=y(e.doc),s=t.index(0),i=r[s].subEnd+1;return i===s+1?!1:(i>=r.length||!r[i].node.isTextblock||n&&n(Nt(e,r,s,i).scrollIntoView()),!0)}function Le(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1)return!1;let r=t.parent,s=t.index(0);if(!r.isTextblock||r.type.spec.code||A(r)||!r.content.size||t.parentOffset!==r.content.size||s+1>=e.doc.childCount||!A(e.doc.child(s+1)))return!1;if(n&&r.type!==M.paragraph)n(e.tr.setSelection(I.create(e.doc,t.after()+1)).scrollIntoView());else if(n){let i=t.before(),a=e.tr.insert(t.after()+1,r.content).delete(i,t.after());n(a.setSelection(I.create(a.doc,i+1+r.content.size)).scrollIntoView())}return!0}var ie=e=>(n,t)=>{let{$from:o,empty:r}=n.selection;if(!r||o.depth!==1||!o.parent.isTextblock)return!1;let s=o.parent,i=o.index(0);if(o.parentOffset!==(e<0?0:s.content.size))return!1;let a=y(n.doc),l=e<0?Tt(a,i):-1,c=l>=0?l:i+e;if(c<0||c>=a.length)return!1;let d=a[c].node;if(!d.isTextblock||!s.type.spec.code&&!d.type.spec.code)return!1;if(!t)return!0;let f=n.tr,p=a[i],u=a[c],h=e<0?u.end-1:u.at+1;return!s.content.size&&!s.type.spec.code?f.delete(p.at,p.end).setSelection(I.create(f.doc,f.mapping.map(h))):!d.content.size&&!d.type.spec.code?f.delete(u.at,u.end):f.setSelection(I.create(f.doc,h)),t(f.scrollIntoView()),!0},Be=ie(-1),Pe=ie(1);function ze(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||t.parentOffset!==0||!t.parent.isTextblock)return!1;let r=t.parent;if(S(r)||A(r)||k(r)===null)return!1;let s=t.index(0);return e.doc.child(s-1).attrs.id!==k(r)?!1:(n&&n(Nt(e,y(e.doc),s-1,s).scrollIntoView()),!0)}var It="blockeditor-reveal";function to(e,n){return n.length?e.setMeta(It,{add:n}):e}function ae(e,n,t,o=y(e.doc)){let r=o[n];return e.tr.setNodeMarkup(r.at,null,{...r.node.attrs,open:t}).setMeta("addToHistory",!1).setMeta(It,{clear:[r.node.attrs.id]})}function Ve(e,n){let{$from:t}=e.selection;return t.depth!==1||!A(t.parent)?!1:(n&&n(ae(e,t.index(0),!t.parent.attrs.open)),!0)}function Re(e){let n=[];for(let t of e)!A(t.node)||t.hidden||t.open||t.subEnd===t.i||n.push({line:t.at+1,sumEnd:t.end-1,from:t.end,to:e[t.subEnd].end});return n}var yt=(e,n)=>n>e.from&&n<e.to;function At(e,n,t,o){if(o>0){let r=t.to;for(;;){let s=st.findFrom(e.resolve(r),1,!0);if(!s)break;let i=n.find(a=>yt(a,s.head));if(!i)return s.head;r=i.to}}return t.sumEnd}function te(e,n,t,o=-1,r=!1){if(!t.length)return null;let{anchor:s,head:i}=n;if(!(n instanceof I)){let c=t.find(d=>n.from>=d.from&&n.from<d.to);return c?I.create(e,c.sumEnd):null}let a=t.find(c=>yt(c,i));a&&(i=At(e,t,a,o));let l=t.find(c=>yt(c,s));if(l&&(s=l.sumEnd),!r&&s!==i){let c=Math.min(s,i),d=Math.max(s,i),f=t.find(p=>(c>p.line||c===p.sumEnd)&&c<p.from&&d>=p.to);if(f){let p=c===f.sumEnd?At(e,t,f,1):f.line;s<i?s=p:i=p}}return s===n.anchor&&i===n.head?null:I.create(e,s,i)}var qe=e=>{let n="";for(;e>0;)e--,n=String.fromCharCode(97+e%26)+n,e=Math.floor(e/26);return n},_e=e=>[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]].reduce((n,[t,o])=>{for(;e>=t;)n+=o,e-=t;return n},"");function Ke(e){let n=new Map,t=[];return e.forEach((o,r)=>{if(!S(o.node)){t=[];return}r>0&&!rt(e[r-1],o)&&(t=[]);let s=o.node.attrs.indent;if(t.length=s+1,o.node.attrs.kind!=="ordered"){t[s]=0;return}t[s]=(t[s]||0)+1;let i=t[s];n.set(r,`${s%3===0?i:s%3===1?qe(i):_e(i)}.`)}),n}var F=new ke("blockeditor-collapse"),He=["id","parent","indent","kind","open"];function je(e,n){if(e.childCount!==n.childCount)return!1;for(let t=0;t<e.childCount;t++){let o=e.child(t),r=n.child(t);if(o!==r){if(o.type!==r.type)return!1;for(let s of He)if(o.attrs[s]!==r.attrs[s])return!1}}return!0}var Ue=new Set;function pt(e,n=Ue){let t=y(e,n);return{decos:Ge(e,t),ranges:Re(t),reveal:n}}var Fe=null,We=()=>Fe??=class extends $.DecorationSet{forChild(e,n){if(n.isLeaf)return $.DecorationSet.empty;let t=this.children,o=0,r=t.length/3;for(;o<r;){let s=o+r>>1;t[s*3]<e?o=s+1:r=s}return o*3<t.length&&t[o*3]===e?t[o*3+2]:$.DecorationSet.empty}};function Ge(e,n=y(e)){let{Decoration:t,DecorationSet:o}=$,r=Ke(n),s=[],i=[];for(let a of n){let l={};if(a.hidden&&(l.class="blockeditor-hidden",l["aria-hidden"]="true"),a.depth&&(l.style=`--blockeditor-depth:${a.depth}`),r.has(a.i)&&(l["data-marker"]=r.get(a.i)),A(a.node)&&(l["data-expanded"]=a.open?"true":"false"),Object.keys(l).length&&s.push(t.node(a.at,a.end,l)),A(a.node)&&!a.hidden){let c=t.widget(0,()=>Xe(a.node,a.open),{side:-1,ignoreSelection:!0,key:`t:${a.node.attrs.id}:${a.open}`});i.push(a.at,a.end,new o([c],[]))}}return!s.length&&!i.length?o.empty:new(We())(s,i)}function Xe(e,n=e.attrs.open){let t=document.createElement("button");return t.type="button",t.className="blockeditor-toggle-button",t.contentEditable="false",t.setAttribute("aria-label",n?"Collapse":"Expand"),t.setAttribute("aria-expanded",n?"true":"false"),t.setAttribute("data-toggle",e.attrs.id||""),t}function eo(){let e=!1;return new wt({key:F,state:{init:(n,t)=>pt(t.doc),apply(n,t,o,r){let s=n.getMeta(It);if(s){let i=new Set(t.reveal);for(let a of s.add??[])i.add(a);for(let a of s.clear??[])i.delete(a);return pt(r.doc,i)}return n.docChanged?pt(r.doc,t.reveal):t}},appendTransaction(n,t,o){if(!n.some(a=>a.docChanged||a.selectionSet))return null;let s=n.some(a=>a.selectionSet)&&o.selection.head>=t.selection.head?1:-1,i=te(o.doc,o.selection,F.getState(o).ranges,s,e);return i?o.tr.setSelection(i):null},props:{decorations:n=>F.getState(n).decos,handleDOMEvents:{mousedown:(n,t)=>{let o=t.target.closest?.(".blockeditor-toggle-button");if(o){t.preventDefault();let i=y(n.state.doc),a=i.findIndex(l=>l.node.attrs.id===o.dataset.toggle);return a>=0&&n.dispatch(ae(n.state,a,!i[a].node.attrs.open,i)),!0}e=!0;let r=n.dom.ownerDocument.defaultView,s=()=>{e=!1,r.removeEventListener("mouseup",s,!0);let i=te(n.state.doc,n.state.selection,F.getState(n.state).ranges,1,!1);i&&n.dispatch(n.state.tr.setSelection(i))};return r.addEventListener("mouseup",s,!0),!1}},handleKeyDown(n,t){let o={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1}[t.key];if(!o||t.altKey||t.metaKey||t.ctrlKey)return!1;let{head:r}=n.state.selection,i=t.key==="ArrowDown"||t.key==="ArrowUp"?o>0?"down":"up":o>0?"forward":"backward";if(!n.endOfTextblock(i))return!1;let a=y(n.state.doc),{ranges:l}=F.getState(n.state),d=n.state.doc.resolve(r).index(0),f=null;if(o>0){let u=l.find(h=>h.from===a[d].end);u&&(f=At(n.state.doc,l,u,1))}else{let u=Tt(a,d);u>=0&&(f=t.shiftKey?a[u].at+1:a[u].end-1)}if(f===null||f===r)return!1;let p=t.shiftKey?n.state.selection.anchor:f;return n.dispatch(n.state.tr.setSelection(I.create(n.state.doc,p,f)).scrollIntoView()),!0}}})}var ee=/^([ \t]*)(?:([-*+•])|(\d+)[.)])[ \t]+(?:\[([ xX])\][ \t]+)?(.*)$/;function Qe(e){let n=e.replace(/\r\n?/g,`
2
2
  `).split(`
3
- `);if(!n.some(r=>ee.test(r)))return null;let t=[],o=[];for(let r of n){if(!r.trim())continue;let s=ee.exec(r);if(!s){t.length=0,o.push(M.paragraph.create(null,r.trim()?T.text(r.trim()):null));continue}let i=s[1].replace(/\t/g," ").length;for(;t.length&&t[t.length-1]>i;)t.pop();(!t.length||t[t.length-1]<i)&&t.push(i);let a=Math.min(t.length-1,o.length&&S(o[o.length-1])?o[o.length-1].attrs.indent+1:0),l=s[4]!==void 0?"check":s[3]!==void 0?"ordered":"bullet";o.push(M.list_item.create({kind:l,indent:a,checked:s[4]==="x"||s[4]==="X"},s[5]?T.text(s[5]):null))}return new O.Slice(O.Fragment.from(o),0,0)}var ht=new Set(["UL","OL"]),mt=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","PRE","BLOCKQUOTE","UL","OL","LI","DETAILS","SUMMARY","TABLE","HR","FIGURE"]);function Ye(e){let n=e.querySelector(":scope > input[type=checkbox], :scope > p > input[type=checkbox], :scope > label > input[type=checkbox]");if(n)return{check:!0,checked:n.checked||n.hasAttribute("checked")};if(e.getAttribute("role")==="checkbox"||e.hasAttribute("aria-checked"))return{check:!0,checked:e.getAttribute("aria-checked")==="true"};if(e.hasAttribute("data-checked"))return{check:!0,checked:e.getAttribute("data-checked")==="true"};let o=e.className||"";return/\b(checked|task-list-item|to-do)\b/.test(o)||e.closest?.("ul.to-do-list, ul.contains-task-list")?{check:!0,checked:/\bchecked\b/.test(o)||!!e.querySelector(".checkbox-on")}:{check:!1,checked:!1}}function Je(e){let n=(e.getAttribute("style")||"")+";"+(e.parentElement?.getAttribute("style")||""),t=/list-style-type\s*:\s*([a-z-]+)/i.exec(e.getAttribute("style")||"")?.[1];return t?/decimal|alpha|roman|latin|greek/.test(t)?"ordered":"bullet":e.parentElement?.tagName==="OL"?"ordered":"bullet"}function Ze(e,n=globalThis.document){let t=n.createElement("div");t.innerHTML=e;for(let u of t.querySelectorAll('b[style*="font-weight:normal"], b[style*="font-weight: normal"]'))u.replaceWith(...u.childNodes);let o=0,r=n.createElement("div"),s=u=>{let h=parseInt(u.getAttribute("aria-level"),10);if(h>0)return h-1;let m=-1;for(let g=u.parentElement;g&&g!==t;g=g.parentElement)ht.has(g.tagName)&&m++;return Math.max(0,m)},i=[];function a(u,h,m){let g=n.createElement("div"),{check:E,checked:b}=Ye(u);g.setAttribute("data-blockeditor-li",""),g.setAttribute("data-kind",E?"check":Je(u)),g.setAttribute("data-checked",b?"true":"false"),g.dataset.depth=String(s(u)),h&&g.setAttribute("data-blockeditor-parent",h);let N=!0,C=[];for(let w of[...u.childNodes]){if(w.nodeType===1&&ht.has(w.tagName)){C.push(w);continue}if(!(w.nodeType===1&&w.tagName==="INPUT")){if(w.nodeType===1&&mt.has(w.tagName)){N||g.appendChild(n.createElement("br"));for(let P of[...w.childNodes])P.nodeType===1&&P.tagName==="INPUT"||g.appendChild(P);N=!1;continue}g.appendChild(w),(w.nodeType!==3||w.textContent.trim())&&(N=!1)}}m.appendChild(g),i.push(g);for(let w of C)l(w,h,m)}function l(u,h,m){let g=null,E=b=>{g||(g=n.createElement("p"),h&&g.setAttribute("data-blockeditor-parent",h),m.appendChild(g)),g.appendChild(b)};for(let b of[...u.childNodes])if(!(b.nodeType===1&&(b.tagName==="META"||b.tagName==="STYLE"))){if(b.nodeType===1&&b.tagName==="BR"){g=null;continue}if(b.nodeType!==1){b.nodeType===3&&(g||b.textContent.trim())&&E(b);continue}if(!mt.has(b.tagName)&&b.tagName!=="ASIDE"){E(b);continue}if(g=null,ht.has(b.tagName)){l(b,h,m);continue}if(b.tagName==="LI"){a(b,h,m);continue}if(b.tagName==="DETAILS"){let N=`paste-${++o}`,C=b.querySelector(":scope > summary"),w=n.createElement("div");w.setAttribute("data-blockeditor-toggle",N),b.hasAttribute("open")&&w.setAttribute("data-open","true"),h&&w.setAttribute("data-blockeditor-parent",h);let P=C?.querySelector(":scope > h1, :scope > h2, :scope > h3");P?(w.setAttribute("data-level",P.tagName[1]),w.append(...P.childNodes)):C&&w.append(...C.childNodes),m.appendChild(w);for(let Pt of[...b.childNodes])if(Pt!==C){let zt=n.createElement("div");zt.appendChild(Pt),l(zt,N,m)}continue}if(b.tagName==="DIV"&&!b.hasAttribute("data-blockeditor-li")&&[...b.children].some(N=>mt.has(N.tagName))){l(b,h,m);continue}h&&b.setAttribute("data-blockeditor-parent",h),m.appendChild(b)}}l(t,null,r);let c=i.length?Math.min(...i.map(u=>+u.dataset.depth)):0,d=null;for(let u of i){let h=+u.dataset.depth-c,m=d&&u.previousElementSibling===d?+d.getAttribute("data-indent")+1:0;u.setAttribute("data-indent",String(Math.min(h,m))),u.removeAttribute("data-depth"),d=u}let f=u=>{if(u.nodeType!==1||u.tagName==="IMG")return[u.cloneNode(!0)];let h=[],m=u.cloneNode(!1);for(let g of u.childNodes)for(let E of f(g))E.nodeType===1&&E.tagName==="IMG"?(m.hasChildNodes()&&h.push(m),h.push(E),m=u.cloneNode(!1)):m.appendChild(E);return(m.hasChildNodes()||!h.length)&&h.push(m),h};for(let u of[...r.children]){if(!u.matches("p, h1, h2, h3, h4, h5, h6, aside, div[data-blockeditor-li], div.blockeditor-li")||!u.querySelector("img"))continue;let h=f(u),m=u.getAttribute("data-blockeditor-parent");if(m)for(let g of h)g.setAttribute("data-blockeditor-parent",m);u.replaceWith(...h)}let p=t.querySelector("[data-pm-slice]");return p&&r.firstElementChild?.setAttribute("data-pm-slice",p.dataset.pmSlice),r.innerHTML}var gt=(e,n=0)=>e!==null&&e!==""&&Number.isInteger(+e)&&+e>=n?+e:null,v=e=>e.getAttribute("data-blockeditor-parent")||null,tn=Rt([]).type,en=Object.create(T,{marks:{value:{...T.marks,[nt]:tn}}}),ce=e=>{let n;try{n=Qt(e)}catch{return null}return!n||typeof n.t!="string"||n.t==="opaque_block"||Object.hasOwn(Ft,n.t)?null:n},nn=e=>{let n=ce(e);return n?{raw:n,parent:v(e)}:!1},on=e=>{let n=ce(e);if(!n||typeof n.c!="string"||!n.c)return O.Fragment.empty;let t=Ht(n.m,n.c.length);return O.Fragment.from(jt(T,n.c,t,T.nodes.opaque_block))},rn=e=>{try{return{entries:Wt(e.getAttribute(ut))}}catch{return!1}},X=null,sn=()=>import("./c-SE3SIY7Y.js").then(e=>{X=e},()=>{}),an=new O.DOMParser(en,[{tag:"table",node:"table",getAttrs:e=>X?.table(e)??!1,getContent:e=>X.rows(e)},{tag:`div[${Ut}]`,node:"opaque_block",getAttrs:nn,getContent:on},{tag:`span[${ut}]`,mark:nt,getAttrs:rn},{tag:"div[data-blockeditor-li]",node:"list_item",getAttrs:e=>({kind:e.getAttribute("data-kind")||"bullet",indent:+e.getAttribute("data-indent")||0,checked:e.getAttribute("data-checked")==="true",parent:v(e)})},{tag:"div.blockeditor-li",node:"list_item",getAttrs:e=>({kind:e.getAttribute("data-kind")||"bullet",indent:+e.getAttribute("data-indent")||0,checked:e.getAttribute("data-checked")==="true",parent:v(e)})},{tag:"div[data-blockeditor-toggle]",node:"toggle",getAttrs:e=>({id:e.getAttribute("data-blockeditor-toggle"),open:e.getAttribute("data-open")==="true",parent:v(e),level:ft(Number(e.getAttribute("data-level")))})},{tag:"div.blockeditor-toggle",node:"toggle",getAttrs:e=>({id:e.getAttribute("data-id"),open:e.getAttribute("data-open")==="true",parent:null,level:ft(Number(e.getAttribute("data-level")))})},{tag:"h1",node:"heading",getAttrs:e=>({level:1,parent:v(e)})},{tag:"h2",node:"heading",getAttrs:e=>({level:2,parent:v(e)})},{tag:"h3",node:"heading",getAttrs:e=>({level:3,parent:v(e)})},{tag:"h4",node:"heading",getAttrs:e=>({level:3,parent:v(e)})},{tag:"pre",node:"code_block",preserveWhitespace:"full",getAttrs:e=>({lang:e.getAttribute("data-lang")||"",parent:v(e)})},{tag:"hr",node:"divider",getAttrs:e=>({parent:v(e)})},{tag:"aside.blockeditor-callout",node:"callout",getAttrs:e=>({parent:v(e)})},{tag:'figure:not([data-type]), figure[data-type="image"]',node:"image",getAttrs:e=>{let n=e.querySelector("img"),t=et(n?.getAttribute("src"));return t?{src:t,alt:n.getAttribute("alt")||"",caption:e.querySelector("figcaption")?.textContent||"",width:gt(e.getAttribute("data-width")??n.getAttribute("width"),1),align:be(e.getAttribute("data-align")),parent:v(e)}:!1}},{tag:"img[src]",node:"image",getAttrs:e=>{let n=et(e.getAttribute("src"));return n?{src:n,alt:e.getAttribute("alt")||"",width:gt(e.getAttribute("width"),1),parent:v(e)}:!1}},{tag:'div.blockeditor-file, div[data-type="file"]',node:"file",getAttrs:e=>{let n=L(e.getAttribute("data-src"));return n?{src:n,name:e.getAttribute("data-name")||"file",size:gt(e.getAttribute("data-size")),mime:e.getAttribute("data-mime")||null,parent:v(e)}:!1}},{tag:"p",node:"paragraph",getAttrs:e=>({parent:v(e)})},{tag:"br",node:"hard_break"},{tag:"strong",mark:"strong"},{tag:"b",mark:"strong",getAttrs:e=>/font-weight\s*:\s*(normal|[1-5]00)\b/.test(e.getAttribute("style")||"")?!1:null},{tag:"span",mark:"strong",getAttrs:e=>/font-weight\s*:\s*(bold|[6-9]00)\b/.test(e.getAttribute("style")||"")?null:!1},{tag:"em",mark:"em"},{tag:"i",mark:"em"},{tag:"span",mark:"em",getAttrs:e=>/font-style\s*:\s*italic/.test(e.getAttribute("style")||"")?null:!1},{tag:"s",mark:"strike"},{tag:"del",mark:"strike"},{tag:"code",mark:"code"},{tag:"a[href]",mark:"link",getAttrs:e=>{let n=L(e.getAttribute("href"));return n?{href:n}:!1}},{tag:"blockquote",node:"quote",getAttrs:e=>({parent:v(e)})},{tag:"u",mark:"underline"},{tag:"mark",mark:"highlight",getAttrs:e=>ct("highlight",{color:e.getAttribute("data-color")})??!1},{tag:"span[data-color]",mark:"text_color",getAttrs:e=>ct("text_color",{color:e.getAttribute("data-color")})??!1}]);function cn(e,n){let t=n.selection.$from,o=n.selection instanceof x,r=o?n.doc.child(n.selection.span().lo):t.depth>=1?t.node(1):null,s=r?k(r):null,i=r&&S(r)?r.attrs.indent:0,a=new Map;e.content.forEach(m=>{A(m)&&m.attrs.id&&a.set(m.attrs.id,V())});let l=[];e.content.forEach(m=>{if(!m.type.spec.group?.includes("block")){l.push(m);return}let g=k(m),E={...m.attrs,pos:null,id:A(m)?a.get(m.attrs.id)??null:null,parent:g!==null&&a.has(g)?a.get(g):s};S(m)&&(E.indent=m.attrs.indent+i),l.push(m.type.create(E,m.content,m.marks))});let c=!r||!(S(r)||A(r)),d=m=>m&&(S(m)||A(m)),f=c&&d(l[0])?0:e.openStart,p=l[l.length-1],u=new Set(a.values()),h=c&&(d(p)||p&&u.has(k(p)))?0:e.openEnd;return new O.Slice(O.Fragment.from(l),o?0:f,o?0:h)}var St=class extends O.DOMSerializer{serializeFragment(n,t,o){let r=super.serializeFragment(n,t,o);if(!n.firstChild?.isBlock)return r;let s=[...r.childNodes];return n.forEach((i,a,l)=>{let c=s[l];!c||c.nodeType!==1||(k(i)!==null&&c.setAttribute("data-blockeditor-parent",k(i)),A(i)&&i.attrs.id&&c.setAttribute("data-blockeditor-toggle",i.attrs.id),i.type===M.image&&i.attrs.width&&c.setAttribute("data-width",String(i.attrs.width)))}),X?.copy(n,s),r}},le=O.DOMSerializer.fromSchema(T),ln=e=>{let{t:n,...t}=e.attrs.raw??{},{c:o,m:r}=_t(e.content);return o?{t:n,...t,c:o,...r.some(Boolean)?{m:Kt(r)}:{}}:{t:n,...t}},dn=e=>["div",{"data-type":"newer-format",...Gt(ln(e))},0],un=e=>["span",Xt(e.attrs.entries),0],fn={...le.nodes,opaque_block:dn},pn={...le.marks,[nt]:un},hn=new St(fn,pn);function mn(e,n,t){let{$from:o}=e.state.selection,r=o.depth>=1?o.node(1):null;if(!r||!A(r)||r.attrs.open||t.content.childCount<2)return!1;let s=e.state.tr.setNodeMarkup(o.before(1),null,{...r.attrs,open:!0}).replaceSelection(t);return e.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function gn(e){let n=!1;return e?.content?.descendants(t=>n?!1:((t.type===M.quote||t.isText&&t.marks.some(o=>qt.has(o.type.name)))&&(n=!0),!n)),n}function bn(e,n,t){let o=e.state.selection.from,r=e.state.selection.to,s=e.state.doc,i=()=>{let a=t.content.textBetween(0,t.content.size,`
4
- `," ");return!e.isDestroyed&&a&&e.state.doc===s&&e.dispatch(e.state.tr.insertText(a,o,r)),!1};return import("./c-ZFO5RW6G.js").then(({pasteFormats:a})=>a(e,t,o,r),i),!0}function no(){return new wt({view(){return sn(),{}},props:{handlePaste(e,n,t){return gn(t)?bn(e,n,t):mn(e,n,t)},clipboardSerializer:hn,clipboardTextSerializer:e=>X?.text(e),transformPastedHTML:e=>Ze(e),clipboardParser:an,clipboardTextParser:(e,n,t)=>t?null:Qe(e),transformPasted:(e,n)=>cn(e,n.state)}})}var W=tt.chainCommands(Ce,Oe,Be,ze,De),R=tt.chainCommands($e,Le,Pe),oo={Enter:tt.chainCommands(ve,Te,Ne,Ie),Backspace:W,"Shift-Backspace":W,"Mod-Backspace":W,"Alt-Backspace":W,"Ctrl-h":W,Delete:R,"Shift-Delete":R,"Mod-Delete":R,"Alt-Delete":R,"Ctrl-d":R,"Ctrl-Alt-Backspace":R,Tab:Me,"Shift-Tab":vt,"Mod-Shift-ArrowUp":Zt(-1),"Mod-Shift-ArrowDown":Zt(1),"Mod-Enter":Ve};function ao(){return new D.Plugin({view(e){let n=e.dom.ownerDocument.createElement("div");return n.className="blockeditor-live",n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),e.dom.parentElement.appendChild(n),{destroy:()=>n.remove()}}})}function Ct(e,n){let t=e.dom.parentElement?.querySelector(".blockeditor-live");t&&(t.textContent="",t.textContent=n)}var de=new D.PluginKey("tableRect");var{Selection:kn,TextSelection:K,NodeSelection:xn,Plugin:yn,PluginKey:An}=D,Q=T.nodes,H=e=>Z.closeHistory(e).setMeta(Et,!0);function Y(e,n,t=n,o=y(e)){let{lo:r,hi:s}=z(o,Math.min(n,t),Math.max(n,t)),i=o[r].at,a=o[s].end;return n<=t?new x(e.resolve(i),e.resolve(a)):new x(e.resolve(a),e.resolve(i))}function Sn(e,n=y(e.doc)){let[t,o]=ne(e.doc,e.selection,n);return z(n,t,o)}var _=(e,n,t)=>{for(let o=n;o>=0&&o<e.length;o+=t)if(!e[o].hidden)return o;return-1};function wn(e,n){if(e.selection instanceof x)return!1;let t=Math.min(e.selection.$head.index(0),e.doc.childCount-1);return n&&n(e.tr.setSelection(Y(e.doc,t))),!0}var ue=e=>(n,t)=>{let o=n.selection;if(!(o instanceof x))return!1;let r=y(n.doc),{lo:s,hi:i}=o.span(n.doc),a=e<0?_(r,s-1,-1):_(r,i+1,1);return a<0||t&&t(n.tr.setSelection(Y(n.doc,a)).scrollIntoView()),!0};function Dt(e,n,t,o){if(o<0)return n;let r=n;for(;e[r].subEnd<t;)r=e[r].subEnd+1;return r}function En(e,n){for(let t=n-1;t>=0;t--)if(e[t].up===e[n].up)return t;return n}var fe=e=>(n,t)=>{let o=n.selection;if(!(o instanceof x))return!1;let r=y(n.doc),{lo:s,hi:i}=o.span(n.doc),a=o.anchor<=o.head,l=a?s:Dt(r,s,i,1),c=a?Dt(r,s,i,1):s;return e>0?a||s===i||c===l?c=_(r,(a?i:c)+1,1):c=_(r,r[c].subEnd+1,1):!a||c===l?c=_(r,(a?c:s)-1,-1):c=En(r,c),c<0||t&&t(n.tr.setSelection(Y(n.doc,l,c,r)).scrollIntoView()),!0};function at(e,n){let t=e.selection;if(!(t instanceof x))return!1;if(n){let o=e.tr.delete(t.from,t.to);o.doc.content.size===0&&o.insert(0,Q.paragraph.create()),o.setSelection(kn.near(o.doc.resolve(Math.min(t.from,o.doc.content.size)),-1)),n(H(o).scrollIntoView())}return!0}function Mn({columns:e={},cards:n={}}){let t=dt(e),o=new Map(t.map(i=>[i,V("c")])),r=lt(null,null,t.length),s={};for(let i of new Set([...t,...Object.values(n).map(a=>a.col)])){let a=dt(Object.fromEntries(Object.entries(n).filter(([,c])=>c.col===i))),l=lt(null,null,a.length);a.forEach((c,d)=>{s[V("k")]={...n[c],col:o.get(i)??i,pos:l[d]}})}return{columns:Object.fromEntries(t.map((i,a)=>[o.get(i),{...e[i],pos:r[a]}])),cards:s}}function vn(e,n){let t=y(e.doc);if(!t.length)return!1;let{lo:o,hi:r}=Sn(e,t);if(n){let s=new Map;for(let f=o;f<=r;f++)t[f].node.type===Q.toggle&&t[f].node.attrs.id&&s.set(t[f].node.attrs.id,V());let i=[];for(let f=o;f<=r;f++){let p=t[f].node,u=p.attrs.parent??null;i.push(p.type.create({...p.attrs,...p.type===Q.board?Mn(p.attrs):{},id:s.get(p.attrs.id)??null,pos:null,parent:s.get(u)??u},p.content,p.marks))}let a=t[r].end,l=a-t[o].at,c=e.tr.insert(a,i),d=e.selection;c.setSelection(d instanceof x?new x(c.doc.resolve(a),c.doc.resolve(a+l)):K.create(c.doc,d.anchor+l,d.head+l)),n(H(c).scrollIntoView())}return!0}var he=(e,n,t,o)=>{for(let r=t;r<=o;r++)if(n[r].node.isTextblock)return n[r].end-1;return-1};function pe(e,n){let t=e.selection;if(!(t instanceof x))return!1;let o=y(e.doc),{lo:r,hi:s}=t.span(e.doc);if(n){let i=he(e.doc,o,r,s);n(e.tr.setSelection(i>=0?K.create(e.doc,i):xn.create(e.doc,o[r].at)))}return!0}var Tn=({$from:e,$to:n})=>{if(e.depth<2||n.depth<2)return null;let t=e.node(1);return t.type.name==="table"&&n.node(1)===t?{from:e.before(1),to:e.after(1)}:null};function Nn(e,n){let t=e.selection,{$from:o,$to:r}=t,s=o.parent.isTextblock&&o.sameParent(r)&&!de.getState(e),i=s&&o.parentOffset===0&&r.parentOffset===r.parent.content.size;if(s&&!i&&o.parent.content.size)return n&&n(e.tr.setSelection(K.create(e.doc,o.start(),o.end()))),!0;let a=Tn(t);return a&&!(t instanceof x&&t.from===a.from&&t.to===a.to)?(n&&n(e.tr.setSelection(new x(e.doc.resolve(a.from),e.doc.resolve(a.to)))),!0):(n&&n(e.tr.setSelection(new x(e.doc.resolve(0),e.doc.resolve(e.doc.content.size)))),!0)}var In=(e,n)=>{let t=e.state,o=t.selection;if(!(o instanceof x))return!1;let r=y(t.doc),{lo:s,hi:i}=o.span(t.doc),a=he(t.doc,r,s,i),l=t.tr;if(a<0){let c=r[i].end;l.insert(c,Q.paragraph.create({parent:r[s].node.attrs.parent??null})),l.setSelection(K.create(l.doc,c+1)),H(l)}else l.setSelection(K.create(l.doc,a));return l.insertText(n),e.dispatch(l.scrollIntoView()),!0},Cn=(e,n,t)=>{let o=e.selection;if(!(o instanceof K)||!t?.endOfTextblock("down"))return!1;let{$anchor:r,$head:s}=o;if(r.depth!==1||r.parent.type!==Q.toggle||r.parent.attrs.open||r.index(0)!==s.index(0))return!1;let i=y(e.doc),a=r.index(0),l=_(i,i[a].subEnd+1,1);return l<0?!1:(n&&n(e.tr.setSelection(Y(e.doc,a,l,i)).scrollIntoView()),!0)},On=e=>(n,t,o)=>n.selection instanceof x&&e(n,t,o),Dn={Escape:(e,n)=>pe(e,n)||wn(e,n),Enter:On(pe),ArrowUp:ue(-1),ArrowDown:ue(1),"Shift-ArrowUp":fe(-1),"Shift-ArrowDown":(e,n,t)=>fe(1)(e,n)||Cn(e,n,t),Backspace:at,"Alt-Backspace":at,"Ctrl-h":at,Delete:at,"Mod-d":vn,"Mod-a":Nn},Ot=new An("blockeditor-blocksel"),$n=e=>{let n=e.selection,{lo:t,hi:o}=n.span(e.doc);return y(e.doc).filter(r=>r.i>=t&&r.i<=o&&!r.hidden).length};function ko(){let e=Vt.keymap(Dn);return new yn({key:Ot,state:{init:()=>0,apply:(n,t,o,r)=>n.getMeta(ot)&&o.selection instanceof x&&!(r.selection instanceof x)?t+1:t},props:{handleKeyDown:(n,t)=>e.props.handleKeyDown(n,t),handleTextInput:(n,t,o,r)=>In(n,r),decorations(n){let t=n.selection;if(!(t instanceof x))return null;let o=[];return n.doc.nodesBetween(t.from,t.to,(r,s)=>(o.push($.Decoration.node(s,s+r.nodeSize,{class:"blockeditor-block-selected"})),!1)),$.DecorationSet.create(n.doc,o)},createSelectionBetween(n,t,o){let r=n.state.selection;return r instanceof x&&t.pos===r.anchor&&o.pos===r.head?r:null},handleDOMEvents:{mousedown(n,t){let o=n.state.selection;if(!t.shiftKey||!(o instanceof x)||t.button!==0)return!1;let r=n.posAtCoords({left:t.clientX,top:t.clientY});if(!r)return!1;let s=y(n.state.doc),i=Math.min(n.state.doc.resolve(r.inside>=0?r.inside:r.pos).index(0),s.length-1),{lo:a,hi:l}=o.span(n.state.doc),c=o.anchor<=o.head?a:Dt(s,a,l,1);return t.preventDefault(),n.dispatch(n.state.tr.setSelection(Y(n.state.doc,c,i,s))),!0}}},view:()=>({update(n,t){let o=n.state.selection,r=t.selection;if(o instanceof x&&!o.eq(r)){let s=$n(n.state);Ct(n,`${s} ${s===1?"block":"blocks"} selected`)}else r instanceof x&&!(o instanceof x)&&Ct(n,Ot.getState(n.state)!==Ot.getState(t)?"Block selection cleared because the document changed":"Selection cleared")}})})}var{Plugin:Ln,PluginKey:Bn,TextSelection:J}=D,{Decoration:Pn,DecorationSet:zn}=$,U=T.marks.link,Vn=e=>/^(https?:\/\/|mailto:|tel:|www\.)\S+$/i.test(e.trim())&&L(e)!==null;function $t(e,n){let t=e.resolve(n);if(!t.parent.inlineContent)return null;let o=U.isInSet((t.nodeAfter??t.nodeBefore)?.marks??[]);if(!o)return null;let r=[];t.parent.forEach((c,d)=>r.push({n:c,off:d}));let s=r.findIndex(({n:c,off:d})=>d<=t.parentOffset&&t.parentOffset<=d+c.nodeSize&&o.isInSet(c.marks));if(s<0)return null;let i=s,a=s;for(;i>0&&o.isInSet(r[i-1].n.marks);)i--;for(;a<r.length-1&&o.isInSet(r[a+1].n.marks);)a++;let l=t.start();return{from:l+r[i].off,to:l+r[a].off+r[a].n.nodeSize,href:o.attrs.href}}function me(e,n,t,o){let r=e.tr.removeMark(n,t,U);return o&&r.addMark(n,t,U.create({href:o})),H(r)}var B=new Bn("blockeditor-link"),Lt=new WeakMap,ge=e=>`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e}</svg>`,Rn=ge('<path d="M9 3h4v4M13 3 7.5 8.5M11 9.5V13H3V5h3.5"/>'),qn=ge('<path d="M4 4l8 8M12 4l-8 8"/>');function j(e,n,t,o={}){let r=e.createElement(n);t&&(r.className=t);for(let[s,i]of Object.entries(o))r.setAttribute(s,i);return r}function _n(e,n,t){let o=null;return e.doc.nodesBetween(n,t,r=>{let s=U.isInSet(r.marks);s&&(o=s.attrs.href)}),o}var Bt=class{constructor(n){this.view=n,this.shell=n.dom.parentElement,this.doc=n.dom.ownerDocument,this.mode=null,this.range=null;let t=this.doc;this.dom=j(t,"div","blockeditor-link",{role:"dialog","aria-label":"Link",hidden:""}),this.input=j(t,"input","blockeditor-link-input",{type:"url","aria-label":"Link address",placeholder:"Paste or type a link",autocomplete:"off",spellcheck:"false"}),this.url=j(t,"a","blockeditor-link-url",{target:"_blank",rel:"noopener noreferrer"}),this.open=j(t,"a","blockeditor-link-btn",{"data-act":"open",target:"_blank",rel:"noopener noreferrer","aria-label":"Open link in a new tab",title:"Open in a new tab"}),this.open.innerHTML=Rn,this.edit=j(t,"button","blockeditor-link-btn",{type:"button","data-act":"edit"}),this.edit.textContent="Edit",this.remove=j(t,"button","blockeditor-link-btn",{type:"button","data-act":"remove","aria-label":"Remove link",title:"Remove link"}),this.remove.innerHTML=qn,this.dom.append(this.input,this.url,this.open,this.edit,this.remove),this.shell.append(this.dom),Lt.set(n,this),this.dom.addEventListener("mousedown",o=>{o.target!==this.input&&o.preventDefault()}),this.edit.addEventListener("click",()=>this.openEdit()),this.remove.addEventListener("click",()=>this.apply("")),this.input.addEventListener("keydown",o=>{o.isComposing||o.keyCode===229||(o.key==="Enter"?(o.preventDefault(),this.apply(this.input.value)):o.key==="Escape"&&(o.preventDefault(),this.close()))}),this.onDocDown=o=>{this.mode==="edit"&&!this.dom.contains(o.target)&&this.close(!1)},this.doc.addEventListener("mousedown",this.onDocDown,!0)}openEdit(){let n=this.view.state,t=n.selection;if(!(t instanceof J)||!t.$from.sameParent(t.$to)||!t.$from.parent.inlineContent||t.$from.parent.type.spec.code)return!1;let o=t.empty?$t(n.doc,t.head):null;return this.range=o??{from:t.from,to:t.to,href:t.empty?null:_n(n,t.from,t.to)},this.mode="edit",this.view.dispatch(n.tr.setMeta(B,{from:this.range.from,to:this.range.to})),this.render(),this.input.value=this.range.href??"",this.input.removeAttribute("aria-invalid"),this.input.focus(),this.input.select(),!0}apply(n){let t=String(n).trim(),o=t?L(t):null;if(t&&!o){this.input.setAttribute("aria-invalid","true");return}let r=this.view.state,s=B.getState(r)??(this.mode==="view"?this.range:null);if(!s)return this.close();let i;if(s.from===s.to){if(!o)return this.close();i=r.tr.insert(s.from,T.text(t,[U.create({href:o})])),i.setSelection(J.create(i.doc,s.from+t.length))}else i=me(r,s.from,s.to,o),i.setSelection(J.create(i.doc,s.to));this.view.dispatch(H(i).setMeta(B,null)),this.close()}close(n=!0){this.mode=null,this.range=null,B.getState(this.view.state)&&this.view.dispatch(this.view.state.tr.setMeta(B,null)),this.dom.hidden=!0,this.dom.dataset.mode="",n&&this.view.focus(),this.update(this.view)}render(){let n=this.mode==="edit",t=L(this.range?.href);this.dom.dataset.mode=this.mode??"",this.input.hidden=!n,this.url.hidden=n,this.edit.hidden=n,this.open.hidden=!t,this.remove.hidden=!this.range?.href,t?(this.open.href=t,this.url.href=t,this.url.textContent=t.replace(/^https?:\/\//,"")):(this.open.removeAttribute("href"),this.url.removeAttribute("href"),this.url.textContent=""),this.dom.hidden=!1,this.place()}place(){let n=this.range;if(!n)return;let t=this.shell.getBoundingClientRect(),o=this.view.coordsAtPos(n.from),r=this.view.coordsAtPos(n.to,-1);this.dom.style.setProperty("--blockeditor-pop-x",`${Math.min(o.left,r.left)-t.left}px`),this.dom.style.setProperty("--blockeditor-pop-y",`${Math.max(o.bottom,r.bottom)-t.top+6}px`)}update(n){if(this.view=n,this.mode==="edit"){let r=B.getState(n.state);if(r)return this.range={...this.range,...r},this.place();this.mode=null,this.range=null,this.dom.hidden=!0,this.dom.dataset.mode="";return}let t=n.state.selection,o=t instanceof J&&t.empty&&n.hasFocus()?$t(n.state.doc,t.head):null;if(!o||t.head===o.from||t.head===o.to){this.mode=null,this.range=null,this.dom.hidden=!0,this.dom.dataset.mode="";return}this.mode="view",this.range=o,this.render()}destroy(){this.doc.removeEventListener("mousedown",this.onDocDown,!0),this.dom.remove(),Lt.delete(this.view)}},Kn=e=>Lt.get(e)?.openEdit()??!1;function Hn(e,n){if(n.clipboardData?.files?.length)return!1;let t=n.clipboardData?.getData("text/plain")??"";if(!Vn(t))return!1;let o=e.state.selection;if(!(o instanceof J)||!o.$from.sameParent(o.$to)||o.$from.parent.type.spec.code)return!1;let r=L(t),s=o.empty?e.state.tr.replaceSelectionWith(T.text(t.trim(),[U.create({href:r})]),!1):me(e.state,o.from,o.to,r);return e.dispatch(s.scrollIntoView().setMeta("uiEvent","paste")),!0}function Eo(){return new Ln({key:B,state:{init:()=>null,apply(e,n){let t=e.getMeta(B);if(t!==void 0)return t;if(!n||!e.docChanged)return n;let o=e.mapping.mapResult(n.from,1),r=e.mapping.mapResult(n.to,n.from===n.to?1:-1);return o.deletedAcross||r.deletedAcross||n.from!==n.to&&o.pos>=r.pos?null:{from:o.pos,to:r.pos}}},view:e=>new Bt(e),props:{decorations(e){let n=B.getState(e);return n&&n.from<n.to?zn.create(e.doc,[Pn.inline(n.from,n.to,{class:"blockeditor-link-pending"})]):null},handleKeyDown(e,n){return(n.metaKey||n.ctrlKey)&&!n.altKey&&!n.shiftKey&&n.key.toLowerCase()==="k"?(n.preventDefault(),Kn(e)||!0):!1},handlePaste:Hn,handleClick(e,n,t){if(!(t.metaKey||t.ctrlKey))return!1;let o=$t(e.state.doc,n),r=L(o?.href);return r?(e.dom.ownerDocument.defaultView.open(r,"_blank","noopener,noreferrer"),!0):!1}}})}export{Kn as a,Eo as b,ao as c,Ct as d,de as e,Et as f,q as g,y as h,Jn as i,xe as j,Zn as k,ne as l,z as m,Ae as n,Se as o,x as p,G as q,re as r,Zt as s,Ee as t,Me as u,vt as v,to as w,eo as x,an as y,hn as z,no as A,oo as B,H as C,Y as D,Sn as E,at as F,vn as G,In as H,ko as I};
3
+ `);if(!n.some(r=>ee.test(r)))return null;let t=[],o=[];for(let r of n){if(!r.trim())continue;let s=ee.exec(r);if(!s){t.length=0,o.push(M.paragraph.create(null,r.trim()?T.text(r.trim()):null));continue}let i=s[1].replace(/\t/g," ").length;for(;t.length&&t[t.length-1]>i;)t.pop();(!t.length||t[t.length-1]<i)&&t.push(i);let a=Math.min(t.length-1,o.length&&S(o[o.length-1])?o[o.length-1].attrs.indent+1:0),l=s[4]!==void 0?"check":s[3]!==void 0?"ordered":"bullet";o.push(M.list_item.create({kind:l,indent:a,checked:s[4]==="x"||s[4]==="X"},s[5]?T.text(s[5]):null))}return new O.Slice(O.Fragment.from(o),0,0)}var ht=new Set(["UL","OL"]),mt=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","PRE","BLOCKQUOTE","UL","OL","LI","DETAILS","SUMMARY","TABLE","HR","FIGURE"]);function Ye(e){let n=e.querySelector(":scope > input[type=checkbox], :scope > p > input[type=checkbox], :scope > label > input[type=checkbox]");if(n)return{check:!0,checked:n.checked||n.hasAttribute("checked")};if(e.getAttribute("role")==="checkbox"||e.hasAttribute("aria-checked"))return{check:!0,checked:e.getAttribute("aria-checked")==="true"};if(e.hasAttribute("data-checked"))return{check:!0,checked:e.getAttribute("data-checked")==="true"};let o=e.className||"";return/\b(checked|task-list-item|to-do)\b/.test(o)||e.closest?.("ul.to-do-list, ul.contains-task-list")?{check:!0,checked:/\bchecked\b/.test(o)||!!e.querySelector(".checkbox-on")}:{check:!1,checked:!1}}function Je(e){let n=(e.getAttribute("style")||"")+";"+(e.parentElement?.getAttribute("style")||""),t=/list-style-type\s*:\s*([a-z-]+)/i.exec(e.getAttribute("style")||"")?.[1];return t?/decimal|alpha|roman|latin|greek/.test(t)?"ordered":"bullet":e.parentElement?.tagName==="OL"?"ordered":"bullet"}function Ze(e,n=globalThis.document){let t=n.createElement("div");t.innerHTML=e;for(let u of t.querySelectorAll('b[style*="font-weight:normal"], b[style*="font-weight: normal"]'))u.replaceWith(...u.childNodes);let o=0,r=n.createElement("div"),s=u=>{let h=parseInt(u.getAttribute("aria-level"),10);if(h>0)return h-1;let m=-1;for(let g=u.parentElement;g&&g!==t;g=g.parentElement)ht.has(g.tagName)&&m++;return Math.max(0,m)},i=[];function a(u,h,m){let g=n.createElement("div"),{check:E,checked:b}=Ye(u);g.setAttribute("data-blockeditor-li",""),g.setAttribute("data-kind",E?"check":Je(u)),g.setAttribute("data-checked",b?"true":"false"),g.dataset.depth=String(s(u)),h&&g.setAttribute("data-blockeditor-parent",h);let N=!0,C=[];for(let w of[...u.childNodes]){if(w.nodeType===1&&ht.has(w.tagName)){C.push(w);continue}if(!(w.nodeType===1&&w.tagName==="INPUT")){if(w.nodeType===1&&mt.has(w.tagName)){N||g.appendChild(n.createElement("br"));for(let P of[...w.childNodes])P.nodeType===1&&P.tagName==="INPUT"||g.appendChild(P);N=!1;continue}g.appendChild(w),(w.nodeType!==3||w.textContent.trim())&&(N=!1)}}m.appendChild(g),i.push(g);for(let w of C)l(w,h,m)}function l(u,h,m){let g=null,E=b=>{g||(g=n.createElement("p"),h&&g.setAttribute("data-blockeditor-parent",h),m.appendChild(g)),g.appendChild(b)};for(let b of[...u.childNodes])if(!(b.nodeType===1&&(b.tagName==="META"||b.tagName==="STYLE"))){if(b.nodeType===1&&b.tagName==="BR"){g=null;continue}if(b.nodeType!==1){b.nodeType===3&&(g||b.textContent.trim())&&E(b);continue}if(!mt.has(b.tagName)&&b.tagName!=="ASIDE"){E(b);continue}if(g=null,ht.has(b.tagName)){l(b,h,m);continue}if(b.tagName==="LI"){a(b,h,m);continue}if(b.tagName==="DETAILS"){let N=`paste-${++o}`,C=b.querySelector(":scope > summary"),w=n.createElement("div");w.setAttribute("data-blockeditor-toggle",N),b.hasAttribute("open")&&w.setAttribute("data-open","true"),h&&w.setAttribute("data-blockeditor-parent",h);let P=C?.querySelector(":scope > h1, :scope > h2, :scope > h3");P?(w.setAttribute("data-level",P.tagName[1]),w.append(...P.childNodes)):C&&w.append(...C.childNodes),m.appendChild(w);for(let Pt of[...b.childNodes])if(Pt!==C){let zt=n.createElement("div");zt.appendChild(Pt),l(zt,N,m)}continue}if(b.tagName==="DIV"&&!b.hasAttribute("data-blockeditor-li")&&[...b.children].some(N=>mt.has(N.tagName))){l(b,h,m);continue}h&&b.setAttribute("data-blockeditor-parent",h),m.appendChild(b)}}l(t,null,r);let c=i.length?Math.min(...i.map(u=>+u.dataset.depth)):0,d=null;for(let u of i){let h=+u.dataset.depth-c,m=d&&u.previousElementSibling===d?+d.getAttribute("data-indent")+1:0;u.setAttribute("data-indent",String(Math.min(h,m))),u.removeAttribute("data-depth"),d=u}let f=u=>{if(u.nodeType!==1||u.tagName==="IMG")return[u.cloneNode(!0)];let h=[],m=u.cloneNode(!1);for(let g of u.childNodes)for(let E of f(g))E.nodeType===1&&E.tagName==="IMG"?(m.hasChildNodes()&&h.push(m),h.push(E),m=u.cloneNode(!1)):m.appendChild(E);return(m.hasChildNodes()||!h.length)&&h.push(m),h};for(let u of[...r.children]){if(!u.matches("p, h1, h2, h3, h4, h5, h6, aside, div[data-blockeditor-li], div.blockeditor-li")||!u.querySelector("img"))continue;let h=f(u),m=u.getAttribute("data-blockeditor-parent");if(m)for(let g of h)g.setAttribute("data-blockeditor-parent",m);u.replaceWith(...h)}let p=t.querySelector("[data-pm-slice]");return p&&r.firstElementChild?.setAttribute("data-pm-slice",p.dataset.pmSlice),r.innerHTML}var gt=(e,n=0)=>e!==null&&e!==""&&Number.isInteger(+e)&&+e>=n?+e:null,v=e=>e.getAttribute("data-blockeditor-parent")||null,tn=Rt([]).type,en=Object.create(T,{marks:{value:{...T.marks,[nt]:tn}}}),ce=e=>{let n;try{n=Qt(e)}catch{return null}return!n||typeof n.t!="string"||n.t==="opaque_block"||Object.hasOwn(Ft,n.t)?null:n},nn=e=>{let n=ce(e);return n?{raw:n,parent:v(e)}:!1},on=e=>{let n=ce(e);if(!n||typeof n.c!="string"||!n.c)return O.Fragment.empty;let t=Ht(n.m,n.c.length);return O.Fragment.from(jt(T,n.c,t,T.nodes.opaque_block))},rn=e=>{try{return{entries:Wt(e.getAttribute(ut))}}catch{return!1}},X=null,sn=()=>import("./c-X3V4RWMA.js").then(e=>{X=e},()=>{}),an=new O.DOMParser(en,[{tag:"table",node:"table",getAttrs:e=>X?.table(e)??!1,getContent:e=>X.rows(e)},{tag:`div[${Ut}]`,node:"opaque_block",getAttrs:nn,getContent:on},{tag:`span[${ut}]`,mark:nt,getAttrs:rn},{tag:"div[data-blockeditor-li]",node:"list_item",getAttrs:e=>({kind:e.getAttribute("data-kind")||"bullet",indent:+e.getAttribute("data-indent")||0,checked:e.getAttribute("data-checked")==="true",parent:v(e)})},{tag:"div.blockeditor-li",node:"list_item",getAttrs:e=>({kind:e.getAttribute("data-kind")||"bullet",indent:+e.getAttribute("data-indent")||0,checked:e.getAttribute("data-checked")==="true",parent:v(e)})},{tag:"div[data-blockeditor-toggle]",node:"toggle",getAttrs:e=>({id:e.getAttribute("data-blockeditor-toggle"),open:e.getAttribute("data-open")==="true",parent:v(e),level:ft(Number(e.getAttribute("data-level")))})},{tag:"div.blockeditor-toggle",node:"toggle",getAttrs:e=>({id:e.getAttribute("data-id"),open:e.getAttribute("data-open")==="true",parent:null,level:ft(Number(e.getAttribute("data-level")))})},{tag:"h1",node:"heading",getAttrs:e=>({level:1,parent:v(e)})},{tag:"h2",node:"heading",getAttrs:e=>({level:2,parent:v(e)})},{tag:"h3",node:"heading",getAttrs:e=>({level:3,parent:v(e)})},{tag:"h4",node:"heading",getAttrs:e=>({level:3,parent:v(e)})},{tag:"pre",node:"code_block",preserveWhitespace:"full",getAttrs:e=>({lang:e.getAttribute("data-lang")||"",parent:v(e)})},{tag:"hr",node:"divider",getAttrs:e=>({parent:v(e)})},{tag:"aside.blockeditor-callout",node:"callout",getAttrs:e=>({parent:v(e)})},{tag:'figure:not([data-type]), figure[data-type="image"]',node:"image",getAttrs:e=>{let n=e.querySelector("img"),t=et(n?.getAttribute("src"));return t?{src:t,alt:n.getAttribute("alt")||"",caption:e.querySelector("figcaption")?.textContent||"",width:gt(e.getAttribute("data-width")??n.getAttribute("width"),1),align:be(e.getAttribute("data-align")),parent:v(e)}:!1}},{tag:"img[src]",node:"image",getAttrs:e=>{let n=et(e.getAttribute("src"));return n?{src:n,alt:e.getAttribute("alt")||"",width:gt(e.getAttribute("width"),1),parent:v(e)}:!1}},{tag:'div.blockeditor-file, div[data-type="file"]',node:"file",getAttrs:e=>{let n=L(e.getAttribute("data-src"));return n?{src:n,name:e.getAttribute("data-name")||"file",size:gt(e.getAttribute("data-size")),mime:e.getAttribute("data-mime")||null,parent:v(e)}:!1}},{tag:"p",node:"paragraph",getAttrs:e=>({parent:v(e)})},{tag:"br",node:"hard_break"},{tag:"strong",mark:"strong"},{tag:"b",mark:"strong",getAttrs:e=>/font-weight\s*:\s*(normal|[1-5]00)\b/.test(e.getAttribute("style")||"")?!1:null},{tag:"span",mark:"strong",getAttrs:e=>/font-weight\s*:\s*(bold|[6-9]00)\b/.test(e.getAttribute("style")||"")?null:!1},{tag:"em",mark:"em"},{tag:"i",mark:"em"},{tag:"span",mark:"em",getAttrs:e=>/font-style\s*:\s*italic/.test(e.getAttribute("style")||"")?null:!1},{tag:"s",mark:"strike"},{tag:"del",mark:"strike"},{tag:"code",mark:"code"},{tag:"a[href]",mark:"link",getAttrs:e=>{let n=L(e.getAttribute("href"));return n?{href:n}:!1}},{tag:"blockquote",node:"quote",getAttrs:e=>({parent:v(e)})},{tag:"u",mark:"underline"},{tag:"mark",mark:"highlight",getAttrs:e=>ct("highlight",{color:e.getAttribute("data-color")})??!1},{tag:"span[data-color]",mark:"text_color",getAttrs:e=>ct("text_color",{color:e.getAttribute("data-color")})??!1}]);function cn(e,n){let t=n.selection.$from,o=n.selection instanceof x,r=o?n.doc.child(n.selection.span().lo):t.depth>=1?t.node(1):null,s=r?k(r):null,i=r&&S(r)?r.attrs.indent:0,a=new Map;e.content.forEach(m=>{A(m)&&m.attrs.id&&a.set(m.attrs.id,V())});let l=[];e.content.forEach(m=>{if(!m.type.spec.group?.includes("block")){l.push(m);return}let g=k(m),E={...m.attrs,pos:null,id:A(m)?a.get(m.attrs.id)??null:null,parent:g!==null&&a.has(g)?a.get(g):s};S(m)&&(E.indent=m.attrs.indent+i),l.push(m.type.create(E,m.content,m.marks))});let c=!r||!(S(r)||A(r)),d=m=>m&&(S(m)||A(m)),f=c&&d(l[0])?0:e.openStart,p=l[l.length-1],u=new Set(a.values()),h=c&&(d(p)||p&&u.has(k(p)))?0:e.openEnd;return new O.Slice(O.Fragment.from(l),o?0:f,o?0:h)}var St=class extends O.DOMSerializer{serializeFragment(n,t,o){let r=super.serializeFragment(n,t,o);if(!n.firstChild?.isBlock)return r;let s=[...r.childNodes];return n.forEach((i,a,l)=>{let c=s[l];!c||c.nodeType!==1||(k(i)!==null&&c.setAttribute("data-blockeditor-parent",k(i)),A(i)&&i.attrs.id&&c.setAttribute("data-blockeditor-toggle",i.attrs.id),i.type===M.image&&i.attrs.width&&c.setAttribute("data-width",String(i.attrs.width)))}),X?.copy(n,s),r}},le=O.DOMSerializer.fromSchema(T),ln=e=>{let{t:n,...t}=e.attrs.raw??{},{c:o,m:r}=_t(e.content);return o?{t:n,...t,c:o,...r.some(Boolean)?{m:Kt(r)}:{}}:{t:n,...t}},dn=e=>["div",{"data-type":"newer-format",...Gt(ln(e))},0],un=e=>["span",Xt(e.attrs.entries),0],fn={...le.nodes,opaque_block:dn},pn={...le.marks,[nt]:un},hn=new St(fn,pn);function mn(e,n,t){let{$from:o}=e.state.selection,r=o.depth>=1?o.node(1):null;if(!r||!A(r)||r.attrs.open||t.content.childCount<2)return!1;let s=e.state.tr.setNodeMarkup(o.before(1),null,{...r.attrs,open:!0}).replaceSelection(t);return e.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function gn(e){let n=!1;return e?.content?.descendants(t=>n?!1:((t.type===M.quote||t.isText&&t.marks.some(o=>qt.has(o.type.name)))&&(n=!0),!n)),n}function bn(e,n,t){let o=e.state.selection.from,r=e.state.selection.to,s=e.state.doc,i=()=>{let a=t.content.textBetween(0,t.content.size,`
4
+ `," ");return!e.isDestroyed&&a&&e.state.doc===s&&e.dispatch(e.state.tr.insertText(a,o,r)),!1};return import("./c-TCFVG3I4.js").then(({pasteFormats:a})=>a(e,t,o,r),i),!0}function no(){return new wt({view(){return sn(),{}},props:{handlePaste(e,n,t){return gn(t)?bn(e,n,t):mn(e,n,t)},clipboardSerializer:hn,clipboardTextSerializer:e=>X?.text(e),transformPastedHTML:e=>Ze(e),clipboardParser:an,clipboardTextParser:(e,n,t)=>t?null:Qe(e),transformPasted:(e,n)=>cn(e,n.state)}})}var W=tt.chainCommands(Ce,Oe,Be,ze,De),R=tt.chainCommands($e,Le,Pe),oo={Enter:tt.chainCommands(ve,Te,Ne,Ie),Backspace:W,"Shift-Backspace":W,"Mod-Backspace":W,"Alt-Backspace":W,"Ctrl-h":W,Delete:R,"Shift-Delete":R,"Mod-Delete":R,"Alt-Delete":R,"Ctrl-d":R,"Ctrl-Alt-Backspace":R,Tab:Me,"Shift-Tab":vt,"Mod-Shift-ArrowUp":Zt(-1),"Mod-Shift-ArrowDown":Zt(1),"Mod-Enter":Ve};function ao(){return new D.Plugin({view(e){let n=e.dom.ownerDocument.createElement("div");return n.className="blockeditor-live",n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),e.dom.parentElement.appendChild(n),{destroy:()=>n.remove()}}})}function Ct(e,n){let t=e.dom.parentElement?.querySelector(".blockeditor-live");t&&(t.textContent="",t.textContent=n)}var de=new D.PluginKey("tableRect");var{Selection:kn,TextSelection:K,NodeSelection:xn,Plugin:yn,PluginKey:An}=D,Q=T.nodes,H=e=>Z.closeHistory(e).setMeta(Et,!0);function Y(e,n,t=n,o=y(e)){let{lo:r,hi:s}=z(o,Math.min(n,t),Math.max(n,t)),i=o[r].at,a=o[s].end;return n<=t?new x(e.resolve(i),e.resolve(a)):new x(e.resolve(a),e.resolve(i))}function Sn(e,n=y(e.doc)){let[t,o]=ne(e.doc,e.selection,n);return z(n,t,o)}var _=(e,n,t)=>{for(let o=n;o>=0&&o<e.length;o+=t)if(!e[o].hidden)return o;return-1};function wn(e,n){if(e.selection instanceof x)return!1;let t=Math.min(e.selection.$head.index(0),e.doc.childCount-1);return n&&n(e.tr.setSelection(Y(e.doc,t))),!0}var ue=e=>(n,t)=>{let o=n.selection;if(!(o instanceof x))return!1;let r=y(n.doc),{lo:s,hi:i}=o.span(n.doc),a=e<0?_(r,s-1,-1):_(r,i+1,1);return a<0||t&&t(n.tr.setSelection(Y(n.doc,a)).scrollIntoView()),!0};function Dt(e,n,t,o){if(o<0)return n;let r=n;for(;e[r].subEnd<t;)r=e[r].subEnd+1;return r}function En(e,n){for(let t=n-1;t>=0;t--)if(e[t].up===e[n].up)return t;return n}var fe=e=>(n,t)=>{let o=n.selection;if(!(o instanceof x))return!1;let r=y(n.doc),{lo:s,hi:i}=o.span(n.doc),a=o.anchor<=o.head,l=a?s:Dt(r,s,i,1),c=a?Dt(r,s,i,1):s;return e>0?a||s===i||c===l?c=_(r,(a?i:c)+1,1):c=_(r,r[c].subEnd+1,1):!a||c===l?c=_(r,(a?c:s)-1,-1):c=En(r,c),c<0||t&&t(n.tr.setSelection(Y(n.doc,l,c,r)).scrollIntoView()),!0};function at(e,n){let t=e.selection;if(!(t instanceof x))return!1;if(n){let o=e.tr.delete(t.from,t.to);o.doc.content.size===0&&o.insert(0,Q.paragraph.create()),o.setSelection(kn.near(o.doc.resolve(Math.min(t.from,o.doc.content.size)),-1)),n(H(o).scrollIntoView())}return!0}function Mn({columns:e={},cards:n={}}){let t=dt(e),o=new Map(t.map(i=>[i,V("c")])),r=lt(null,null,t.length),s={};for(let i of new Set([...t,...Object.values(n).map(a=>a.col)])){let a=dt(Object.fromEntries(Object.entries(n).filter(([,c])=>c.col===i))),l=lt(null,null,a.length);a.forEach((c,d)=>{s[V("k")]={...n[c],col:o.get(i)??i,pos:l[d]}})}return{columns:Object.fromEntries(t.map((i,a)=>[o.get(i),{...e[i],pos:r[a]}])),cards:s}}function vn(e,n){let t=y(e.doc);if(!t.length)return!1;let{lo:o,hi:r}=Sn(e,t);if(n){let s=new Map;for(let f=o;f<=r;f++)t[f].node.type===Q.toggle&&t[f].node.attrs.id&&s.set(t[f].node.attrs.id,V());let i=[];for(let f=o;f<=r;f++){let p=t[f].node,u=p.attrs.parent??null;i.push(p.type.create({...p.attrs,...p.type===Q.board?Mn(p.attrs):{},id:s.get(p.attrs.id)??null,pos:null,parent:s.get(u)??u},p.content,p.marks))}let a=t[r].end,l=a-t[o].at,c=e.tr.insert(a,i),d=e.selection;c.setSelection(d instanceof x?new x(c.doc.resolve(a),c.doc.resolve(a+l)):K.create(c.doc,d.anchor+l,d.head+l)),n(H(c).scrollIntoView())}return!0}var he=(e,n,t,o)=>{for(let r=t;r<=o;r++)if(n[r].node.isTextblock)return n[r].end-1;return-1};function pe(e,n){let t=e.selection;if(!(t instanceof x))return!1;let o=y(e.doc),{lo:r,hi:s}=t.span(e.doc);if(n){let i=he(e.doc,o,r,s);n(e.tr.setSelection(i>=0?K.create(e.doc,i):xn.create(e.doc,o[r].at)))}return!0}var Tn=({$from:e,$to:n})=>{if(e.depth<2||n.depth<2)return null;let t=e.node(1);return t.type.name==="table"&&n.node(1)===t?{from:e.before(1),to:e.after(1)}:null};function Nn(e,n){let t=e.selection,{$from:o,$to:r}=t,s=o.parent.isTextblock&&o.sameParent(r)&&!de.getState(e),i=s&&o.parentOffset===0&&r.parentOffset===r.parent.content.size;if(s&&!i&&o.parent.content.size)return n&&n(e.tr.setSelection(K.create(e.doc,o.start(),o.end()))),!0;let a=Tn(t);return a&&!(t instanceof x&&t.from===a.from&&t.to===a.to)?(n&&n(e.tr.setSelection(new x(e.doc.resolve(a.from),e.doc.resolve(a.to)))),!0):(n&&n(e.tr.setSelection(new x(e.doc.resolve(0),e.doc.resolve(e.doc.content.size)))),!0)}var In=(e,n)=>{let t=e.state,o=t.selection;if(!(o instanceof x))return!1;let r=y(t.doc),{lo:s,hi:i}=o.span(t.doc),a=he(t.doc,r,s,i),l=t.tr;if(a<0){let c=r[i].end;l.insert(c,Q.paragraph.create({parent:r[s].node.attrs.parent??null})),l.setSelection(K.create(l.doc,c+1)),H(l)}else l.setSelection(K.create(l.doc,a));return l.insertText(n),e.dispatch(l.scrollIntoView()),!0},Cn=(e,n,t)=>{let o=e.selection;if(!(o instanceof K)||!t?.endOfTextblock("down"))return!1;let{$anchor:r,$head:s}=o;if(r.depth!==1||r.parent.type!==Q.toggle||r.parent.attrs.open||r.index(0)!==s.index(0))return!1;let i=y(e.doc),a=r.index(0),l=_(i,i[a].subEnd+1,1);return l<0?!1:(n&&n(e.tr.setSelection(Y(e.doc,a,l,i)).scrollIntoView()),!0)},On=e=>(n,t,o)=>n.selection instanceof x&&e(n,t,o),Dn={Escape:(e,n)=>pe(e,n)||wn(e,n),Enter:On(pe),ArrowUp:ue(-1),ArrowDown:ue(1),"Shift-ArrowUp":fe(-1),"Shift-ArrowDown":(e,n,t)=>fe(1)(e,n)||Cn(e,n,t),Backspace:at,"Alt-Backspace":at,"Ctrl-h":at,Delete:at,"Mod-d":vn,"Mod-a":Nn},Ot=new An("blockeditor-blocksel"),$n=e=>{let n=e.selection,{lo:t,hi:o}=n.span(e.doc);return y(e.doc).filter(r=>r.i>=t&&r.i<=o&&!r.hidden).length};function ko(){let e=Vt.keymap(Dn);return new yn({key:Ot,state:{init:()=>0,apply:(n,t,o,r)=>n.getMeta(ot)&&o.selection instanceof x&&!(r.selection instanceof x)?t+1:t},props:{handleKeyDown:(n,t)=>e.props.handleKeyDown(n,t),handleTextInput:(n,t,o,r)=>In(n,r),decorations(n){let t=n.selection;if(!(t instanceof x))return null;let o=[];return n.doc.nodesBetween(t.from,t.to,(r,s)=>(o.push($.Decoration.node(s,s+r.nodeSize,{class:"blockeditor-block-selected"})),!1)),$.DecorationSet.create(n.doc,o)},createSelectionBetween(n,t,o){let r=n.state.selection;return r instanceof x&&t.pos===r.anchor&&o.pos===r.head?r:null},handleDOMEvents:{mousedown(n,t){let o=n.state.selection;if(!t.shiftKey||!(o instanceof x)||t.button!==0)return!1;let r=n.posAtCoords({left:t.clientX,top:t.clientY});if(!r)return!1;let s=y(n.state.doc),i=Math.min(n.state.doc.resolve(r.inside>=0?r.inside:r.pos).index(0),s.length-1),{lo:a,hi:l}=o.span(n.state.doc),c=o.anchor<=o.head?a:Dt(s,a,l,1);return t.preventDefault(),n.dispatch(n.state.tr.setSelection(Y(n.state.doc,c,i,s))),!0}}},view:()=>({update(n,t){let o=n.state.selection,r=t.selection;if(o instanceof x&&!o.eq(r)){let s=$n(n.state);Ct(n,`${s} ${s===1?"block":"blocks"} selected`)}else r instanceof x&&!(o instanceof x)&&Ct(n,Ot.getState(n.state)!==Ot.getState(t)?"Block selection cleared because the document changed":"Selection cleared")}})})}var{Plugin:Ln,PluginKey:Bn,TextSelection:J}=D,{Decoration:Pn,DecorationSet:zn}=$,U=T.marks.link,Vn=e=>/^(https?:\/\/|mailto:|tel:|www\.)\S+$/i.test(e.trim())&&L(e)!==null;function $t(e,n){let t=e.resolve(n);if(!t.parent.inlineContent)return null;let o=U.isInSet((t.nodeAfter??t.nodeBefore)?.marks??[]);if(!o)return null;let r=[];t.parent.forEach((c,d)=>r.push({n:c,off:d}));let s=r.findIndex(({n:c,off:d})=>d<=t.parentOffset&&t.parentOffset<=d+c.nodeSize&&o.isInSet(c.marks));if(s<0)return null;let i=s,a=s;for(;i>0&&o.isInSet(r[i-1].n.marks);)i--;for(;a<r.length-1&&o.isInSet(r[a+1].n.marks);)a++;let l=t.start();return{from:l+r[i].off,to:l+r[a].off+r[a].n.nodeSize,href:o.attrs.href}}function me(e,n,t,o){let r=e.tr.removeMark(n,t,U);return o&&r.addMark(n,t,U.create({href:o})),H(r)}var B=new Bn("blockeditor-link"),Lt=new WeakMap,ge=e=>`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e}</svg>`,Rn=ge('<path d="M9 3h4v4M13 3 7.5 8.5M11 9.5V13H3V5h3.5"/>'),qn=ge('<path d="M4 4l8 8M12 4l-8 8"/>');function j(e,n,t,o={}){let r=e.createElement(n);t&&(r.className=t);for(let[s,i]of Object.entries(o))r.setAttribute(s,i);return r}function _n(e,n,t){let o=null;return e.doc.nodesBetween(n,t,r=>{let s=U.isInSet(r.marks);s&&(o=s.attrs.href)}),o}var Bt=class{constructor(n){this.view=n,this.shell=n.dom.parentElement,this.doc=n.dom.ownerDocument,this.mode=null,this.range=null;let t=this.doc;this.dom=j(t,"div","blockeditor-link",{role:"dialog","aria-label":"Link",hidden:""}),this.input=j(t,"input","blockeditor-link-input",{type:"url","aria-label":"Link address",placeholder:"Paste or type a link",autocomplete:"off",spellcheck:"false"}),this.url=j(t,"a","blockeditor-link-url",{target:"_blank",rel:"noopener noreferrer"}),this.open=j(t,"a","blockeditor-link-btn",{"data-act":"open",target:"_blank",rel:"noopener noreferrer","aria-label":"Open link in a new tab",title:"Open in a new tab"}),this.open.innerHTML=Rn,this.edit=j(t,"button","blockeditor-link-btn",{type:"button","data-act":"edit"}),this.edit.textContent="Edit",this.remove=j(t,"button","blockeditor-link-btn",{type:"button","data-act":"remove","aria-label":"Remove link",title:"Remove link"}),this.remove.innerHTML=qn,this.dom.append(this.input,this.url,this.open,this.edit,this.remove),this.shell.append(this.dom),Lt.set(n,this),this.dom.addEventListener("mousedown",o=>{o.target!==this.input&&o.preventDefault()}),this.edit.addEventListener("click",()=>this.openEdit()),this.remove.addEventListener("click",()=>this.apply("")),this.input.addEventListener("keydown",o=>{o.isComposing||o.keyCode===229||(o.key==="Enter"?(o.preventDefault(),this.apply(this.input.value)):o.key==="Escape"&&(o.preventDefault(),this.close()))}),this.onDocDown=o=>{this.mode==="edit"&&!this.dom.contains(o.target)&&this.close(!1)},this.doc.addEventListener("mousedown",this.onDocDown,!0)}openEdit(){let n=this.view.state,t=n.selection;if(!(t instanceof J)||!t.$from.sameParent(t.$to)||!t.$from.parent.inlineContent||t.$from.parent.type.spec.code)return!1;let o=t.empty?$t(n.doc,t.head):null;return this.range=o??{from:t.from,to:t.to,href:t.empty?null:_n(n,t.from,t.to)},this.mode="edit",this.view.dispatch(n.tr.setMeta(B,{from:this.range.from,to:this.range.to})),this.render(),this.input.value=this.range.href??"",this.input.removeAttribute("aria-invalid"),this.input.focus(),this.input.select(),!0}apply(n){let t=String(n).trim(),o=t?L(t):null;if(t&&!o){this.input.setAttribute("aria-invalid","true");return}let r=this.view.state,s=B.getState(r)??(this.mode==="view"?this.range:null);if(!s)return this.close();let i;if(s.from===s.to){if(!o)return this.close();i=r.tr.insert(s.from,T.text(t,[U.create({href:o})])),i.setSelection(J.create(i.doc,s.from+t.length))}else i=me(r,s.from,s.to,o),i.setSelection(J.create(i.doc,s.to));this.view.dispatch(H(i).setMeta(B,null)),this.close()}close(n=!0){this.mode=null,this.range=null,B.getState(this.view.state)&&this.view.dispatch(this.view.state.tr.setMeta(B,null)),this.dom.hidden=!0,this.dom.dataset.mode="",n&&this.view.focus(),this.update(this.view)}render(){let n=this.mode==="edit",t=L(this.range?.href);this.dom.dataset.mode=this.mode??"",this.input.hidden=!n,this.url.hidden=n,this.edit.hidden=n,this.open.hidden=!t,this.remove.hidden=!this.range?.href,t?(this.open.href=t,this.url.href=t,this.url.textContent=t.replace(/^https?:\/\//,"")):(this.open.removeAttribute("href"),this.url.removeAttribute("href"),this.url.textContent=""),this.dom.hidden=!1,this.place()}place(){let n=this.range;if(!n)return;let t=this.shell.getBoundingClientRect(),o=this.view.coordsAtPos(n.from),r=this.view.coordsAtPos(n.to,-1);this.dom.style.setProperty("--blockeditor-pop-x",`${Math.min(o.left,r.left)-t.left}px`),this.dom.style.setProperty("--blockeditor-pop-y",`${Math.max(o.bottom,r.bottom)-t.top+6}px`)}update(n){if(this.view=n,this.mode==="edit"){let r=B.getState(n.state);if(r)return this.range={...this.range,...r},this.place();this.mode=null,this.range=null,this.dom.hidden=!0,this.dom.dataset.mode="";return}let t=n.state.selection,o=t instanceof J&&t.empty&&n.hasFocus()?$t(n.state.doc,t.head):null;if(!o||t.head===o.from||t.head===o.to){this.mode=null,this.range=null,this.dom.hidden=!0,this.dom.dataset.mode="";return}this.mode="view",this.range=o,this.render()}destroy(){this.doc.removeEventListener("mousedown",this.onDocDown,!0),this.dom.remove(),Lt.delete(this.view)}},Kn=e=>Lt.get(e)?.openEdit()??!1;function Hn(e,n){if(n.clipboardData?.files?.length)return!1;let t=n.clipboardData?.getData("text/plain")??"";if(!Vn(t))return!1;let o=e.state.selection;if(!(o instanceof J)||!o.$from.sameParent(o.$to)||o.$from.parent.type.spec.code)return!1;let r=L(t),s=o.empty?e.state.tr.replaceSelectionWith(T.text(t.trim(),[U.create({href:r})]),!1):me(e.state,o.from,o.to,r);return e.dispatch(s.scrollIntoView().setMeta("uiEvent","paste")),!0}function Eo(){return new Ln({key:B,state:{init:()=>null,apply(e,n){let t=e.getMeta(B);if(t!==void 0)return t;if(!n||!e.docChanged)return n;let o=e.mapping.mapResult(n.from,1),r=e.mapping.mapResult(n.to,n.from===n.to?1:-1);return o.deletedAcross||r.deletedAcross||n.from!==n.to&&o.pos>=r.pos?null:{from:o.pos,to:r.pos}}},view:e=>new Bt(e),props:{decorations(e){let n=B.getState(e);return n&&n.from<n.to?zn.create(e.doc,[Pn.inline(n.from,n.to,{class:"blockeditor-link-pending"})]):null},handleKeyDown(e,n){return(n.metaKey||n.ctrlKey)&&!n.altKey&&!n.shiftKey&&n.key.toLowerCase()==="k"?(n.preventDefault(),Kn(e)||!0):!1},handlePaste:Hn,handleClick(e,n,t){if(!(t.metaKey||t.ctrlKey))return!1;let o=$t(e.state.doc,n),r=L(o?.href);return r?(e.dom.ownerDocument.defaultView.open(r,"_blank","noopener,noreferrer"),!0):!1}}})}export{Kn as a,Eo as b,ao as c,Ct as d,de as e,Et as f,q as g,y as h,Jn as i,xe as j,Zn as k,ne as l,z as m,Ae as n,Se as o,x as p,G as q,re as r,Zt as s,Ee as t,Me as u,vt as v,to as w,eo as x,an as y,hn as z,no as A,oo as B,H as C,Y as D,Sn as E,at as F,vn as G,In as H,ko as I};
@@ -1 +1 @@
1
- import{C as J}from"./c-ZRGEN6QQ.js";import{d as F}from"./c-OH2FPYSY.js";import{c as z}from"./c-FSQXFG5T.js";import{d as _}from"./c-RETTCOWO.js";import"./c-VHNSBD2M.js";var{Decoration:tt,DecorationSet:et}=_,a=(e,o,n,t={},r=null)=>{let l=e.createElement(o);n&&(l.className=n);for(let[s,i]of Object.entries(t))i!=null&&i!==!1&&l.setAttribute(s,i===!0?"":String(i));return r!==null&&(l.textContent=r),l},ot=(e,o)=>a(e,"span","blockeditor-board-face",{"aria-hidden":"true"},([...String(o).trim()][0]??"?").toUpperCase());function I(e,o){let n=null;return e.state.doc.forEach((t,r)=>{t.attrs.id===o&&t.type===F.nodes.list_item&&t.attrs.kind==="check"&&(n={node:t,pos:r})}),n}function X(e,o,n,t){let r=I(e,o);r&&e.dispatch(J(e.state.tr.setNodeMarkup(r.pos,null,{...r.node.attrs,[n]:t||null})))}var L={person:'<circle cx="8" cy="5.4" r="2.3"/><path d="M3.6 13.2c.6-2.1 2.2-3.3 4.4-3.3s3.8 1.2 4.4 3.3"/>',calendar:'<rect x="2.5" y="3.5" width="11" height="10"/><path d="M2.5 6.8h11M5.5 2v2.4M10.5 2v2.4"/>',clock:'<circle cx="8" cy="8" r="5.5"/><path d="M8 4.8v3.4l2.3 1.4"/>',tick:'<path d="M3.5 8.3l3 3 6-6.2"/>',plus:'<path d="M8 3.5v9M3.5 8h9"/>',clear:'<path d="M4.8 4.8l6.4 6.4M11.2 4.8l-6.4 6.4"/>',"chevron-left":'<path d="M9.8 3.6L5.4 8l4.4 4.4"/>',"chevron-right":'<path d="M6.2 3.6L10.6 8l-4.4 4.4"/>'};function q(e,o){let n=e.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("viewBox","0 0 16 16"),n.setAttribute("width","14"),n.setAttribute("height","14"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.5"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.setAttribute("aria-hidden","true"),n.innerHTML=o,n}var Z=e=>String(e).padStart(2,"0"),B=/^\d{4}-\d{2}-\d{2}$/,S=(e=new Date)=>`${e.getFullYear()}-${Z(e.getMonth()+1)}-${Z(e.getDate())}`,nt=e=>{let o=new Date(`${e}T00:00:00Z`);return o.setUTCDate(o.getUTCDate()+1),o.toISOString().slice(0,10)};function rt(e,o){if(!e)return"No date";if(!B.test(e))return e;if(e===o)return"Today";if(e===nt(o))return"Tomorrow";let n=e.slice(0,4)===o.slice(0,4);return new Date(`${e}T00:00:00Z`).toLocaleDateString("en-US",{month:"short",day:"numeric",...n?{}:{year:"numeric"},timeZone:"UTC"})}function j(e,{name:o,paths:n,label:t,aria:r,filled:l,overdue:s=!1}){let i=a(e,"button","blockeditor-check-chip",{type:"button","data-check":o,"data-filled":String(l),"data-overdue":s?"true":null,"aria-expanded":"false","aria-label":r});return i.append(q(e,n),a(e,"span","blockeditor-check-chip-label",{},t)),i}var N=null;function G(e,o,{className:n,label:t,check:r,onKey:l=null}){let s=o.ownerDocument,i=s.defaultView;N&&N.close();for(let d of s.querySelectorAll(".blockeditor-check-popup"))d.remove();let y=e.dom.parentNode,h=["relative","absolute","fixed","sticky"].includes(i?.getComputedStyle?.(y)?.position??""),k=y&&h?y:s.body,f=a(s,"div",`blockeditor-check-popup ${n}`,{role:"dialog","aria-label":t,"data-check":r}),A=!1,E=()=>{let d=o.getBoundingClientRect(),c=k===s.body?{top:-(i?.scrollY??0),left:-(i?.scrollX??0)}:k.getBoundingClientRect(),p=f.getBoundingClientRect(),u=p.width||Math.min(264,(i?.innerWidth||292)-28),b=(i?.innerHeight??0)-d.bottom-2,g=p.height>0&&b<p.height;f.style.left=`${Math.round(d.right-u-c.left)}px`,f.style.top=`${Math.round((g?d.top-p.height-2:d.bottom+2)-c.top)}px`},C=d=>{if(!f.isConnected)return w();f.contains(d.target)||o.contains(d.target)||w()},w=({focusAnchor:d=!1}={})=>{if(A)return;A=!0,s.removeEventListener("mousedown",C,!0),i?.removeEventListener("resize",E),i?.removeEventListener("scroll",E,!0),N?.panel===f&&(N=null),f.remove(),o.setAttribute("aria-expanded","false");let c=o.dataset.fromKeys==="true";delete o.dataset.fromKeys,d&&c?e.focus():d&&o.focus()};return f.addEventListener("keydown",d=>{if(d.stopPropagation(),d.key==="Escape"){d.preventDefault(),w({focusAnchor:!0});return}l?.(d,f)}),k.append(f),o.setAttribute("aria-expanded","true"),N={panel:f,close:()=>w()},s.addEventListener("mousedown",C,!0),i?.addEventListener("resize",E),i?.addEventListener("scroll",E,!0),{panel:f,close:w,place:E}}function ct(e,o){let n=new Map;e.state.doc.forEach(t=>{if(t.type!==F.nodes.list_item||t.attrs.kind!=="check")return;let r=String(t.attrs.owner??"").trim();if(!r)return;let l=r.toLowerCase(),s=n.get(l)??{name:r,count:0};s.count+=1,n.set(l,s)});for(let t of o??[]){let r=String((typeof t=="string"?t:t?.name)??"").trim();r&&!n.has(r.toLowerCase())&&n.set(r.toLowerCase(),{name:r,count:0})}return[...n.values()].sort((t,r)=>t.name.localeCompare(r.name))}function at(e,o,n){let t=n.ownerDocument,r=I(e,o)?.node.attrs.owner||"",{panel:l,close:s,place:i}=G(e,n,{className:"blockeditor-check-owner",label:"Assignee",check:"owner-panel",onKey:(c,p)=>{if(c.key!=="ArrowDown"&&c.key!=="ArrowUp")return;c.preventDefault();let u=[...p.querySelectorAll("input, button:not([disabled])")],b=u.indexOf(t.activeElement),g=c.key==="ArrowDown"?1:-1;(b<0?g>0?u[0]:u[u.length-1]:u[(b+g+u.length)%u.length])?.focus()}}),y=a(t,"input","blockeditor-check-search",{type:"text",placeholder:"Find or type a name","aria-label":"Find or type a name"}),h=a(t,"div","blockeditor-check-people"),k=a(t,"button","blockeditor-check-person blockeditor-check-danger",{type:"button","data-check":"clear-owner"});k.append(q(t,L.clear),a(t,"span","blockeditor-check-person-name",{},"Remove assignee")),k.disabled=!r,k.addEventListener("click",()=>A(null)),l.append(y,a(t,"div","blockeditor-check-subhead",{},"People in this document"),h,a(t,"div","blockeditor-check-divider"),k);let f=[],A=c=>{s(),X(e,o,"owner",c)},E=(c,p)=>{let u=c.toLowerCase()===String(r).toLowerCase(),b=a(t,"button","blockeditor-check-person",{type:"button","data-check":"owner-option","data-name":c,"aria-pressed":String(u)});return b.append(ot(t,c),a(t,"span","blockeditor-check-person-name",{},c),a(t,"span","blockeditor-check-person-meta",{},`${p} ${p===1?"item":"items"}`)),u&&b.append(q(t,L.tick)),b.addEventListener("click",()=>A(c)),b},C=c=>{let p=a(t,"button","blockeditor-check-person",{type:"button","data-check":"owner-new","data-name":c}),u=a(t,"span","blockeditor-check-person-name",{},"Assign to ");return u.append(a(t,"strong",null,{},c)),p.append(q(t,L.plus),u,a(t,"span","blockeditor-check-person-meta",{},"New")),p.addEventListener("click",()=>A(c)),p},w=()=>{let c=y.value.trim(),p=c.toLowerCase(),u=ct(e,f),b=[];c&&!u.some(g=>g.name.toLowerCase()===p)&&b.push(C(c));for(let g of u)p&&!g.name.toLowerCase().includes(p)||b.push(E(g.name,g.count));h.replaceChildren(...b)};y.addEventListener("keydown",c=>{if(c.stopPropagation(),c.key==="Escape"){c.preventDefault(),s({focusAnchor:!0});return}c.key==="Enter"&&(c.preventDefault(),h.querySelector("button[data-check]")?.click())}),y.addEventListener("input",w),w(),i(),y.focus();let d=globalThis.clay?.people?.available;d&&Promise.resolve().then(()=>d()).then(c=>{!N||N.panel!==l||(f=Array.isArray(c)?c:[],w())}).catch(()=>{})}var st=["January","February","March","April","May","June","July","August","September","October","November","December"],$=(e,o,n)=>new Date(e,o,n),it=e=>e.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"}),lt=e=>e.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"}),W=e=>{if(!e||!B.test(e))return null;let[o,n,t]=e.split("-").map(Number);return $(o,n-1,t)};function dt(e,o,n){let t=n.ownerDocument,r=I(e,o)?.node.attrs.due||null,l=S(),s=new Date,i=$(s.getFullYear(),s.getMonth(),s.getDate()),y=W(r)??i,h=y.getFullYear(),k=y.getMonth(),{panel:f,close:A,place:E}=G(e,n,{className:"blockeditor-check-date",label:"Due date",check:"date-panel",onKey:(m,D)=>Q(m,D)}),C=m=>{A(),X(e,o,"due",m)},w=a(t,"div","blockeditor-check-quick"),d=(m,D)=>{let M=$(i.getFullYear(),i.getMonth(),i.getDate()+D),x=a(t,"button","blockeditor-check-quick-row",{type:"button","data-check":"date-quick","data-date":S(M)});return x.append(q(t,L.calendar),a(t,"span","blockeditor-check-quick-label",{},m),a(t,"span","blockeditor-check-quick-meta",{},it(M))),x.addEventListener("click",()=>C(S(M))),x};w.append(d("Today",0),d("Tomorrow",1),d("Next week",7));let c=a(t,"div","blockeditor-check-cal"),p=a(t,"div","blockeditor-check-cal-head"),u=a(t,"span","blockeditor-check-cal-month"),b=a(t,"span","blockeditor-check-cal-nav"),g=m=>{let D=$(h,k+m,1);h=D.getFullYear(),k=D.getMonth(),H()},U=a(t,"button","blockeditor-check-cal-btn",{type:"button","aria-label":"Previous month"}),O=a(t,"button","blockeditor-check-cal-btn",{type:"button","aria-label":"Next month"});U.append(q(t,L["chevron-left"])),O.append(q(t,L["chevron-right"])),U.addEventListener("click",()=>g(-1)),O.addEventListener("click",()=>g(1)),b.append(U,O),p.append(u,b);let Y=a(t,"div","blockeditor-check-cal-grid");c.append(p,Y);let H=()=>{u.replaceChildren(a(t,"span",null,{},`${st[k]} `),a(t,"span","blockeditor-check-cal-year",{},String(h)));let m=$(h,k,1),D=$(h,k+1,0).getDate(),M=Math.ceil((m.getDay()+D)/7)*7,x=["S","M","T","W","T","F","S"].map(v=>a(t,"span","blockeditor-check-cal-dow",{},v)),T=[];for(let v=0;v<M;v+=1){let P=$(h,k,1-m.getDay()+v),R=S(P),V=a(t,"button","blockeditor-check-cal-day",{type:"button","data-check":"date-day","data-date":R,"data-outside":String(P.getMonth()!==k),"data-today":String(R===l),"aria-pressed":String(R===r),"aria-label":lt(P)},String(P.getDate()));V.addEventListener("click",()=>C(R)),T.push(V)}Y.replaceChildren(...x,...T)},Q=(m,D)=>{let M=t.activeElement?.closest?.('[data-check="date-day"]');if(!M)return;if(m.key==="Enter"||m.key===" "){m.preventDefault(),M.click();return}let x={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7}[m.key];if(!x)return;m.preventDefault();let T=W(M.dataset.date),v=$(T.getFullYear(),T.getMonth(),T.getDate()+x);(v.getMonth()!==k||v.getFullYear()!==h)&&(h=v.getFullYear(),k=v.getMonth(),H()),D.querySelector(`[data-check="date-day"][data-date="${S(v)}"]`)?.focus()},K=a(t,"button","blockeditor-check-quick-row blockeditor-check-danger",{type:"button","data-check":"clear-date"});K.append(q(t,L.clear),a(t,"span","blockeditor-check-quick-label",{},"Clear date")),K.disabled=!r,K.addEventListener("click",()=>C(null)),f.append(w,c,a(t,"div","blockeditor-check-divider"),K),H(),E(),(Y.querySelector('[data-check="date-day"][aria-pressed="true"]')??Y.querySelector('[data-check="date-day"][data-today="true"]'))?.focus()}function ut(e,o){let n=e.dom.ownerDocument,t=n.createElement("span");t.className="blockeditor-check-controls",t.contentEditable="false",t.dataset.empty=String(!o.attrs.owner&&!o.attrs.due);let r=S(),l=o.attrs.owner||"Unassigned",s=j(n,{name:"owner",paths:L.person,label:l,aria:`Assignee: ${l}`,filled:!!o.attrs.owner}),i=rt(o.attrs.due,r),y=!!o.attrs.due&&!o.attrs.checked&&B.test(o.attrs.due)&&o.attrs.due<r,h=j(n,{name:"date",paths:y?L.clock:L.calendar,label:i,aria:`Due date: ${i}`,filled:!!o.attrs.due,overdue:y});return s.addEventListener("click",()=>at(e,o.attrs.id,s)),h.addEventListener("click",()=>dt(e,o.attrs.id,h)),t.append(s,h),t}function pt(e,o){let n=e.state.selection.$head;if(n.depth!==1||n.parent.type!==F.nodes.list_item||n.parent.attrs.kind!=="check")return!1;let t=n.parent.attrs.id,l=[...e.dom.querySelectorAll(".blockeditor-check-controls")].find(s=>s.dataset.item===t)?.querySelector(`[data-check="${o}"]`);return l?(l.dataset.fromKeys="true",l.click(),!0):!1}function ht(e){let o=[],n=S();return e.doc.forEach((t,r)=>{t.type!==F.nodes.list_item||t.attrs.kind!=="check"||o.push(tt.widget(r+t.nodeSize-1,l=>{let s=ut(l,t);return s.dataset.item=t.attrs.id,s},{key:`${t.attrs.id}:${t.attrs.owner}:${t.attrs.due}:${t.attrs.checked}:${n}`,side:-1,stopEvent:l=>!!l.target.closest?.(".blockeditor-check-chip, .blockeditor-check-popup"),ignoreSelection:!0}))}),et.create(e.doc,o)}function kt(e){let o=S(),n=()=>{e.isDestroyed||S()===o||(o=S(),e.dispatch(e.state.tr.setMeta("addToHistory",!1)))},t=e.dom.ownerDocument.defaultView,r=t.setInterval(n,6e4);return t.document.addEventListener("visibilitychange",n),()=>{t.clearInterval(r),t.document.removeEventListener("visibilitychange",n)}}function gt({view:e=null}={}){let o=e?z(e,{decorations:ht,focusControl:pt}):()=>{},n=e?kt(e):()=>{};return e&&!e.isDestroyed&&e.dispatch(e.state.tr.setMeta("addToHistory",!1)),{id:"checklist",dispose(){o(),n()}}}export{gt as createFeature,ht as decorations,pt as focusControl};
1
+ import{C as J}from"./c-AI3H6ETU.js";import{d as F}from"./c-OH2FPYSY.js";import{c as z}from"./c-FSQXFG5T.js";import{d as _}from"./c-RETTCOWO.js";import"./c-VHNSBD2M.js";var{Decoration:tt,DecorationSet:et}=_,a=(e,o,n,t={},r=null)=>{let l=e.createElement(o);n&&(l.className=n);for(let[s,i]of Object.entries(t))i!=null&&i!==!1&&l.setAttribute(s,i===!0?"":String(i));return r!==null&&(l.textContent=r),l},ot=(e,o)=>a(e,"span","blockeditor-board-face",{"aria-hidden":"true"},([...String(o).trim()][0]??"?").toUpperCase());function I(e,o){let n=null;return e.state.doc.forEach((t,r)=>{t.attrs.id===o&&t.type===F.nodes.list_item&&t.attrs.kind==="check"&&(n={node:t,pos:r})}),n}function X(e,o,n,t){let r=I(e,o);r&&e.dispatch(J(e.state.tr.setNodeMarkup(r.pos,null,{...r.node.attrs,[n]:t||null})))}var L={person:'<circle cx="8" cy="5.4" r="2.3"/><path d="M3.6 13.2c.6-2.1 2.2-3.3 4.4-3.3s3.8 1.2 4.4 3.3"/>',calendar:'<rect x="2.5" y="3.5" width="11" height="10"/><path d="M2.5 6.8h11M5.5 2v2.4M10.5 2v2.4"/>',clock:'<circle cx="8" cy="8" r="5.5"/><path d="M8 4.8v3.4l2.3 1.4"/>',tick:'<path d="M3.5 8.3l3 3 6-6.2"/>',plus:'<path d="M8 3.5v9M3.5 8h9"/>',clear:'<path d="M4.8 4.8l6.4 6.4M11.2 4.8l-6.4 6.4"/>',"chevron-left":'<path d="M9.8 3.6L5.4 8l4.4 4.4"/>',"chevron-right":'<path d="M6.2 3.6L10.6 8l-4.4 4.4"/>'};function q(e,o){let n=e.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("viewBox","0 0 16 16"),n.setAttribute("width","14"),n.setAttribute("height","14"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.5"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.setAttribute("aria-hidden","true"),n.innerHTML=o,n}var Z=e=>String(e).padStart(2,"0"),B=/^\d{4}-\d{2}-\d{2}$/,S=(e=new Date)=>`${e.getFullYear()}-${Z(e.getMonth()+1)}-${Z(e.getDate())}`,nt=e=>{let o=new Date(`${e}T00:00:00Z`);return o.setUTCDate(o.getUTCDate()+1),o.toISOString().slice(0,10)};function rt(e,o){if(!e)return"No date";if(!B.test(e))return e;if(e===o)return"Today";if(e===nt(o))return"Tomorrow";let n=e.slice(0,4)===o.slice(0,4);return new Date(`${e}T00:00:00Z`).toLocaleDateString("en-US",{month:"short",day:"numeric",...n?{}:{year:"numeric"},timeZone:"UTC"})}function j(e,{name:o,paths:n,label:t,aria:r,filled:l,overdue:s=!1}){let i=a(e,"button","blockeditor-check-chip",{type:"button","data-check":o,"data-filled":String(l),"data-overdue":s?"true":null,"aria-expanded":"false","aria-label":r});return i.append(q(e,n),a(e,"span","blockeditor-check-chip-label",{},t)),i}var N=null;function G(e,o,{className:n,label:t,check:r,onKey:l=null}){let s=o.ownerDocument,i=s.defaultView;N&&N.close();for(let d of s.querySelectorAll(".blockeditor-check-popup"))d.remove();let y=e.dom.parentNode,h=["relative","absolute","fixed","sticky"].includes(i?.getComputedStyle?.(y)?.position??""),k=y&&h?y:s.body,f=a(s,"div",`blockeditor-check-popup ${n}`,{role:"dialog","aria-label":t,"data-check":r}),A=!1,E=()=>{let d=o.getBoundingClientRect(),c=k===s.body?{top:-(i?.scrollY??0),left:-(i?.scrollX??0)}:k.getBoundingClientRect(),p=f.getBoundingClientRect(),u=p.width||Math.min(264,(i?.innerWidth||292)-28),b=(i?.innerHeight??0)-d.bottom-2,g=p.height>0&&b<p.height;f.style.left=`${Math.round(d.right-u-c.left)}px`,f.style.top=`${Math.round((g?d.top-p.height-2:d.bottom+2)-c.top)}px`},C=d=>{if(!f.isConnected)return w();f.contains(d.target)||o.contains(d.target)||w()},w=({focusAnchor:d=!1}={})=>{if(A)return;A=!0,s.removeEventListener("mousedown",C,!0),i?.removeEventListener("resize",E),i?.removeEventListener("scroll",E,!0),N?.panel===f&&(N=null),f.remove(),o.setAttribute("aria-expanded","false");let c=o.dataset.fromKeys==="true";delete o.dataset.fromKeys,d&&c?e.focus():d&&o.focus()};return f.addEventListener("keydown",d=>{if(d.stopPropagation(),d.key==="Escape"){d.preventDefault(),w({focusAnchor:!0});return}l?.(d,f)}),k.append(f),o.setAttribute("aria-expanded","true"),N={panel:f,close:()=>w()},s.addEventListener("mousedown",C,!0),i?.addEventListener("resize",E),i?.addEventListener("scroll",E,!0),{panel:f,close:w,place:E}}function ct(e,o){let n=new Map;e.state.doc.forEach(t=>{if(t.type!==F.nodes.list_item||t.attrs.kind!=="check")return;let r=String(t.attrs.owner??"").trim();if(!r)return;let l=r.toLowerCase(),s=n.get(l)??{name:r,count:0};s.count+=1,n.set(l,s)});for(let t of o??[]){let r=String((typeof t=="string"?t:t?.name)??"").trim();r&&!n.has(r.toLowerCase())&&n.set(r.toLowerCase(),{name:r,count:0})}return[...n.values()].sort((t,r)=>t.name.localeCompare(r.name))}function at(e,o,n){let t=n.ownerDocument,r=I(e,o)?.node.attrs.owner||"",{panel:l,close:s,place:i}=G(e,n,{className:"blockeditor-check-owner",label:"Assignee",check:"owner-panel",onKey:(c,p)=>{if(c.key!=="ArrowDown"&&c.key!=="ArrowUp")return;c.preventDefault();let u=[...p.querySelectorAll("input, button:not([disabled])")],b=u.indexOf(t.activeElement),g=c.key==="ArrowDown"?1:-1;(b<0?g>0?u[0]:u[u.length-1]:u[(b+g+u.length)%u.length])?.focus()}}),y=a(t,"input","blockeditor-check-search",{type:"text",placeholder:"Find or type a name","aria-label":"Find or type a name"}),h=a(t,"div","blockeditor-check-people"),k=a(t,"button","blockeditor-check-person blockeditor-check-danger",{type:"button","data-check":"clear-owner"});k.append(q(t,L.clear),a(t,"span","blockeditor-check-person-name",{},"Remove assignee")),k.disabled=!r,k.addEventListener("click",()=>A(null)),l.append(y,a(t,"div","blockeditor-check-subhead",{},"People in this document"),h,a(t,"div","blockeditor-check-divider"),k);let f=[],A=c=>{s(),X(e,o,"owner",c)},E=(c,p)=>{let u=c.toLowerCase()===String(r).toLowerCase(),b=a(t,"button","blockeditor-check-person",{type:"button","data-check":"owner-option","data-name":c,"aria-pressed":String(u)});return b.append(ot(t,c),a(t,"span","blockeditor-check-person-name",{},c),a(t,"span","blockeditor-check-person-meta",{},`${p} ${p===1?"item":"items"}`)),u&&b.append(q(t,L.tick)),b.addEventListener("click",()=>A(c)),b},C=c=>{let p=a(t,"button","blockeditor-check-person",{type:"button","data-check":"owner-new","data-name":c}),u=a(t,"span","blockeditor-check-person-name",{},"Assign to ");return u.append(a(t,"strong",null,{},c)),p.append(q(t,L.plus),u,a(t,"span","blockeditor-check-person-meta",{},"New")),p.addEventListener("click",()=>A(c)),p},w=()=>{let c=y.value.trim(),p=c.toLowerCase(),u=ct(e,f),b=[];c&&!u.some(g=>g.name.toLowerCase()===p)&&b.push(C(c));for(let g of u)p&&!g.name.toLowerCase().includes(p)||b.push(E(g.name,g.count));h.replaceChildren(...b)};y.addEventListener("keydown",c=>{if(c.stopPropagation(),c.key==="Escape"){c.preventDefault(),s({focusAnchor:!0});return}c.key==="Enter"&&(c.preventDefault(),h.querySelector("button[data-check]")?.click())}),y.addEventListener("input",w),w(),i(),y.focus();let d=globalThis.clay?.people?.available;d&&Promise.resolve().then(()=>d()).then(c=>{!N||N.panel!==l||(f=Array.isArray(c)?c:[],w())}).catch(()=>{})}var st=["January","February","March","April","May","June","July","August","September","October","November","December"],$=(e,o,n)=>new Date(e,o,n),it=e=>e.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"}),lt=e=>e.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"}),W=e=>{if(!e||!B.test(e))return null;let[o,n,t]=e.split("-").map(Number);return $(o,n-1,t)};function dt(e,o,n){let t=n.ownerDocument,r=I(e,o)?.node.attrs.due||null,l=S(),s=new Date,i=$(s.getFullYear(),s.getMonth(),s.getDate()),y=W(r)??i,h=y.getFullYear(),k=y.getMonth(),{panel:f,close:A,place:E}=G(e,n,{className:"blockeditor-check-date",label:"Due date",check:"date-panel",onKey:(m,D)=>Q(m,D)}),C=m=>{A(),X(e,o,"due",m)},w=a(t,"div","blockeditor-check-quick"),d=(m,D)=>{let M=$(i.getFullYear(),i.getMonth(),i.getDate()+D),x=a(t,"button","blockeditor-check-quick-row",{type:"button","data-check":"date-quick","data-date":S(M)});return x.append(q(t,L.calendar),a(t,"span","blockeditor-check-quick-label",{},m),a(t,"span","blockeditor-check-quick-meta",{},it(M))),x.addEventListener("click",()=>C(S(M))),x};w.append(d("Today",0),d("Tomorrow",1),d("Next week",7));let c=a(t,"div","blockeditor-check-cal"),p=a(t,"div","blockeditor-check-cal-head"),u=a(t,"span","blockeditor-check-cal-month"),b=a(t,"span","blockeditor-check-cal-nav"),g=m=>{let D=$(h,k+m,1);h=D.getFullYear(),k=D.getMonth(),H()},U=a(t,"button","blockeditor-check-cal-btn",{type:"button","aria-label":"Previous month"}),O=a(t,"button","blockeditor-check-cal-btn",{type:"button","aria-label":"Next month"});U.append(q(t,L["chevron-left"])),O.append(q(t,L["chevron-right"])),U.addEventListener("click",()=>g(-1)),O.addEventListener("click",()=>g(1)),b.append(U,O),p.append(u,b);let Y=a(t,"div","blockeditor-check-cal-grid");c.append(p,Y);let H=()=>{u.replaceChildren(a(t,"span",null,{},`${st[k]} `),a(t,"span","blockeditor-check-cal-year",{},String(h)));let m=$(h,k,1),D=$(h,k+1,0).getDate(),M=Math.ceil((m.getDay()+D)/7)*7,x=["S","M","T","W","T","F","S"].map(v=>a(t,"span","blockeditor-check-cal-dow",{},v)),T=[];for(let v=0;v<M;v+=1){let P=$(h,k,1-m.getDay()+v),R=S(P),V=a(t,"button","blockeditor-check-cal-day",{type:"button","data-check":"date-day","data-date":R,"data-outside":String(P.getMonth()!==k),"data-today":String(R===l),"aria-pressed":String(R===r),"aria-label":lt(P)},String(P.getDate()));V.addEventListener("click",()=>C(R)),T.push(V)}Y.replaceChildren(...x,...T)},Q=(m,D)=>{let M=t.activeElement?.closest?.('[data-check="date-day"]');if(!M)return;if(m.key==="Enter"||m.key===" "){m.preventDefault(),M.click();return}let x={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7}[m.key];if(!x)return;m.preventDefault();let T=W(M.dataset.date),v=$(T.getFullYear(),T.getMonth(),T.getDate()+x);(v.getMonth()!==k||v.getFullYear()!==h)&&(h=v.getFullYear(),k=v.getMonth(),H()),D.querySelector(`[data-check="date-day"][data-date="${S(v)}"]`)?.focus()},K=a(t,"button","blockeditor-check-quick-row blockeditor-check-danger",{type:"button","data-check":"clear-date"});K.append(q(t,L.clear),a(t,"span","blockeditor-check-quick-label",{},"Clear date")),K.disabled=!r,K.addEventListener("click",()=>C(null)),f.append(w,c,a(t,"div","blockeditor-check-divider"),K),H(),E(),(Y.querySelector('[data-check="date-day"][aria-pressed="true"]')??Y.querySelector('[data-check="date-day"][data-today="true"]'))?.focus()}function ut(e,o){let n=e.dom.ownerDocument,t=n.createElement("span");t.className="blockeditor-check-controls",t.contentEditable="false",t.dataset.empty=String(!o.attrs.owner&&!o.attrs.due);let r=S(),l=o.attrs.owner||"Unassigned",s=j(n,{name:"owner",paths:L.person,label:l,aria:`Assignee: ${l}`,filled:!!o.attrs.owner}),i=rt(o.attrs.due,r),y=!!o.attrs.due&&!o.attrs.checked&&B.test(o.attrs.due)&&o.attrs.due<r,h=j(n,{name:"date",paths:y?L.clock:L.calendar,label:i,aria:`Due date: ${i}`,filled:!!o.attrs.due,overdue:y});return s.addEventListener("click",()=>at(e,o.attrs.id,s)),h.addEventListener("click",()=>dt(e,o.attrs.id,h)),t.append(s,h),t}function pt(e,o){let n=e.state.selection.$head;if(n.depth!==1||n.parent.type!==F.nodes.list_item||n.parent.attrs.kind!=="check")return!1;let t=n.parent.attrs.id,l=[...e.dom.querySelectorAll(".blockeditor-check-controls")].find(s=>s.dataset.item===t)?.querySelector(`[data-check="${o}"]`);return l?(l.dataset.fromKeys="true",l.click(),!0):!1}function ht(e){let o=[],n=S();return e.doc.forEach((t,r)=>{t.type!==F.nodes.list_item||t.attrs.kind!=="check"||o.push(tt.widget(r+t.nodeSize-1,l=>{let s=ut(l,t);return s.dataset.item=t.attrs.id,s},{key:`${t.attrs.id}:${t.attrs.owner}:${t.attrs.due}:${t.attrs.checked}:${n}`,side:-1,stopEvent:l=>!!l.target.closest?.(".blockeditor-check-chip, .blockeditor-check-popup"),ignoreSelection:!0}))}),et.create(e.doc,o)}function kt(e){let o=S(),n=()=>{e.isDestroyed||S()===o||(o=S(),e.dispatch(e.state.tr.setMeta("addToHistory",!1)))},t=e.dom.ownerDocument.defaultView,r=t.setInterval(n,6e4);return t.document.addEventListener("visibilitychange",n),()=>{t.clearInterval(r),t.document.removeEventListener("visibilitychange",n)}}function gt({view:e=null}={}){let o=e?z(e,{decorations:ht,focusControl:pt}):()=>{},n=e?kt(e):()=>{};return e&&!e.isDestroyed&&e.dispatch(e.state.tr.setMeta("addToHistory",!1)),{id:"checklist",dispose(){o(),n()}}}export{gt as createFeature,ht as decorations,pt as focusControl};
@@ -1 +1 @@
1
- import{a as D,b as x}from"./c-A7LS5UZW.js";import{b as L,c as M,d as _,f as N}from"./c-CZHTXGJS.js";import"./c-WN3MXOLT.js";import"./c-QQFHEODI.js";import"./c-EDE45NM7.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4NTUVDZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var m="This computer",C=64,O=64,R=/^[\x20-\x7e]{1,128}$/;function X(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36)}function B(e){return typeof e!="string"?m:e.trim().slice(0,O)||m}function v(e){let r=_(e===void 0?null:e);return r.ok?r.target:null}function j(e,r){let c=null,f=-1;for(let l of r)l.editing===null||l.n<=f||(c=l.editing,f=l.n);return e.editing!==null&&e.n>=f?e.editing:c}function Y({scope:e=null,key:r=null,store:c=N,channel:f=null,label:l=m}={}){let S=B(l),w=r??"clay-live:"+(e??(typeof window<"u"?window.location.pathname:"/")),P="local:"+(e??w),b=X(),i=new Map,d=null,u=0,p=null,I=null,s=null,g=null,a=!1;function h(n){p&&p.post({type:D,from:b,...n})}function y(){let n={id:b,you:!0,n:u,editing:d},t=[];for(let o of i.values())t.push({id:o.id,you:!1,n:o.n,editing:o.editing});let E=[n,...t].sort((o,A)=>o.id<A.id?-1:o.id>A.id?1:0);c.receive({people:[{id:P,name:S,you:!0,canEdit:!0,editing:j(n,t),sessions:E}],anonymous:0})}function T(n){if(!n||n.from===b||typeof n.from!="string"||!R.test(n.from))return;let t=i.get(n.from);if(n.op==="bye"){t&&i.delete(n.from),y();return}if(n.op!=="hello"&&n.op!=="update"&&n.op!=="beat"||!t&&i.size>=C)return;let E=n.op==="beat"?t?t.editing:null:v(n.editing),o=Number.isSafeInteger(n.n)&&n.n>=0?n.n:0;t&&o<t.n||(i.set(n.from,{id:n.from,n:o,editing:E,seenAt:Date.now()}),n.op==="hello"&&!t&&h({op:"hello",n:u,editing:d,label:S}),y())}function U(){if(!a)return;h({op:"beat",n:u});let n=Date.now(),t=!1;for(let[E,o]of i)n-o.seenAt<=M||(i.delete(E),t=!0);t&&y()}function k(n){let t=n&&typeof n=="object"&&"editing"in n?n.editing:null;return d=v(t),u+=1,h({op:"update",n:u,editing:d}),y(),!0}return{sessionId:b,start(){return a||(a=!0,p=f??x(w),I=p.subscribe("presence",T),s=c.attachTransport({send:k}),h({op:"hello",n:u,editing:d,label:S}),y(),g=setInterval(U,L)),s},stop(){a&&(a=!1,g!==null&&clearInterval(g),g=null,h({op:"bye"}),i.clear(),I?.(),I=null,p=null,s?.detach(),s=null)}}}export{m as LOCAL_LABEL,C as MAX_SESSIONS,Y as localPresence};
1
+ import{a as D,b as x}from"./c-A7LS5UZW.js";import{b as L,c as M,d as _,f as N}from"./c-VO6RSFCO.js";import"./c-WN3MXOLT.js";import"./c-EQ5NBOGA.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var m="This computer",C=64,O=64,R=/^[\x20-\x7e]{1,128}$/;function X(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36)}function B(e){return typeof e!="string"?m:e.trim().slice(0,O)||m}function v(e){let r=_(e===void 0?null:e);return r.ok?r.target:null}function j(e,r){let c=null,f=-1;for(let l of r)l.editing===null||l.n<=f||(c=l.editing,f=l.n);return e.editing!==null&&e.n>=f?e.editing:c}function Y({scope:e=null,key:r=null,store:c=N,channel:f=null,label:l=m}={}){let S=B(l),w=r??"clay-live:"+(e??(typeof window<"u"?window.location.pathname:"/")),P="local:"+(e??w),b=X(),i=new Map,d=null,u=0,p=null,I=null,s=null,g=null,a=!1;function h(n){p&&p.post({type:D,from:b,...n})}function y(){let n={id:b,you:!0,n:u,editing:d},t=[];for(let o of i.values())t.push({id:o.id,you:!1,n:o.n,editing:o.editing});let E=[n,...t].sort((o,A)=>o.id<A.id?-1:o.id>A.id?1:0);c.receive({people:[{id:P,name:S,you:!0,canEdit:!0,editing:j(n,t),sessions:E}],anonymous:0})}function T(n){if(!n||n.from===b||typeof n.from!="string"||!R.test(n.from))return;let t=i.get(n.from);if(n.op==="bye"){t&&i.delete(n.from),y();return}if(n.op!=="hello"&&n.op!=="update"&&n.op!=="beat"||!t&&i.size>=C)return;let E=n.op==="beat"?t?t.editing:null:v(n.editing),o=Number.isSafeInteger(n.n)&&n.n>=0?n.n:0;t&&o<t.n||(i.set(n.from,{id:n.from,n:o,editing:E,seenAt:Date.now()}),n.op==="hello"&&!t&&h({op:"hello",n:u,editing:d,label:S}),y())}function U(){if(!a)return;h({op:"beat",n:u});let n=Date.now(),t=!1;for(let[E,o]of i)n-o.seenAt<=M||(i.delete(E),t=!0);t&&y()}function k(n){let t=n&&typeof n=="object"&&"editing"in n?n.editing:null;return d=v(t),u+=1,h({op:"update",n:u,editing:d}),y(),!0}return{sessionId:b,start(){return a||(a=!0,p=f??x(w),I=p.subscribe("presence",T),s=c.attachTransport({send:k}),h({op:"hello",n:u,editing:d,label:S}),y(),g=setInterval(U,L)),s},stop(){a&&(a=!1,g!==null&&clearInterval(g),g=null,h({op:"bye"}),i.clear(),I?.(),I=null,p=null,s?.detach(),s=null)}}}export{m as LOCAL_LABEL,C as MAX_SESSIONS,Y as localPresence};
@@ -1 +1 @@
1
- import{C as H,D as X,d as M,g as L,h as O,j as D,m as I,n as R,o as k,p as C,q as A,r as N,t as $}from"./c-ZRGEN6QQ.js";import{d as B}from"./c-OH2FPYSY.js";var _=new WeakMap;function g(s){let t=_.get(s);return t||_.set(s,t=O(s)),t}var F=B.nodes,w=s=>s.type===F.list_item,S=s=>s.type===F.toggle,y=s=>s.attrs.parent??null;function J(s,t,e){if(e<0)return[null];let n=[],i=s[e].node;S(i)&&i.attrs.open&&!s[e].hidden&&n.unshift(i.attrs.id);for(let r=y(i);r!==null&&!n.includes(r);){let c=s[t.get(r)];if(!c)break;n.unshift(r),r=y(c.node)}let o=[null];for(let r of n){let c=s[t.get(r)];if(!c.node.attrs.open||c.hidden)break;o.push(r)}return o}function Y(s,t,e,n){let i=y(s[t].node),o=w(s[t].node)?n.indent-s[t].node.attrs.indent:0;return r=>r.i<t||r.i>e||y(r.node)!==i?null:w(r.node)?{parent:n.parent,indent:r.node.attrs.indent+o}:{parent:n.parent}}function Q(s,t){let e=null;s.doc.forEach((n,i)=>{n.attrs.id===t&&S(n)&&(e={n,off:i})}),e&&!e.n.attrs.open&&s.setNodeMarkup(e.off,null,{...e.n.attrs,open:!0})}function P(s,t,e,n,i,o=null){let r=Y(t,e,n,i),c=t[e].at,d=t[n].end,h=o??new C(s.doc.resolve(c),s.doc.resolve(d)),a;if(i.at===c||i.at===d){a=s.tr;for(let l=e;l<=n;l++){let p=r(t[l]);p&&a.setNodeMarkup(t[l].at,null,{...t[l].node.attrs,...p})}a.setSelection(h.map(a.doc,a.mapping)),a.setMeta(L,A(t,e,n,i.at,r))}else a=N(s,t,e,n,i.at,r,h);if(i.open){Q(a,i.open);let l=a.getMeta(L);l&&a.setMeta(L,{...l,attrs:{...l.attrs,[i.open]:{open:!0}}})}return a}function K(s,t,e,n,i){if(i.parent!=null&&t.slice(e,n+1).some(a=>a.node.attrs.id===i.parent))return!1;let o=t[n].end-t[e].at,r=Y(t,e,n,i);for(let a=e;a<=n;a++)if(w(t[a].node)&&(r(t[a])?.indent??t[a].node.attrs.indent)>$)return!1;let c=P(s,t,e,n,i),h=i.at===t[e].at||i.at===t[n].end?t[e].at:i.at>t[e].at?i.at-o:i.at;return D(c.doc,s.doc).every(a=>a.at>=h&&a.at<h+o)}function U(s,t,e,n,i){let o=new Map;t.forEach(l=>{S(l.node)&&l.node.attrs.id&&o.set(l.node.attrs.id,l.i)});let r=i<0?s.doc.content.size:t[i].at;if(r>t[e].at&&r<t[n].end)return[];let c=(i<0?t.length:i)-1,d=J(t,o,c),h=d.indexOf(i<0?null:y(t[i].node)),a=[];for(let l of d.slice(Math.max(0,h))){let p=l===null?0:t[o.get(l)].depth+1,E=c>=0&&w(t[c].node)&&y(t[c].node)===l?t[c].node:null,f=w(t[e].node)&&E?E.attrs.indent+1:0;for(let u=0;u<=f;u++){let m={at:r,parent:l,indent:u,depth:p+(w(t[e].node)?u:0)};K(s,t,e,n,m)&&a.push(m)}}return a}function q(s,t,e,n,i){let o=t[i];if(!o||!S(o.node)||o.node.attrs.open||o.hidden||i>=e&&i<=n||o.at>t[e].at&&o.at<t[n].end)return null;let r=o.node.attrs.id,c={at:t[o.subEnd].end,parent:r,indent:0,depth:o.depth+1,open:r};return K(s,t,e,n,c)?c:null}function z(s,t){let e=null;for(let n of s)(!e||Math.abs(n.depth-t)<Math.abs(e.depth-t))&&(e=n);return e}var Z=4,tt=250,V=8,b=56,W=18;function et(s){for(let t=s.parentElement;t;t=t.parentElement){let e=getComputedStyle(t).overflowY;if((e==="auto"||e==="scroll")&&t.scrollHeight>t.clientHeight)return t}return s.ownerDocument.scrollingElement}var j=new WeakMap;function nt(s,t){let e=j.get(s);if(!e){e=[];for(let n of s){if(n.hidden)continue;let i=t.nodeDOM(n.at);i?.getBoundingClientRect&&e.push({i:n.i,dom:i})}j.set(s,e)}return e}function it(s,t){let e=0,n=s.length;for(;e<n;){let i=e+n>>1,o=s[i].dom.getBoundingClientRect();t<o.top+o.height/2?n=i:e=i+1}return e<s.length?e:-1}var G=class{constructor(t,e,{index:n,onClick:i}){this.view=t,this.grip=e,this.index=n,this.onClick=i,this.shell=t.dom.parentElement,this.line=document.createElement("div"),this.line.className="blockeditor-drop",this.line.hidden=!0,this.line.setAttribute("aria-hidden","true"),this.shell.append(this.line),this.state=null,this.onMove=o=>this.move(o),this.onUp=o=>this.end(o),this.onCancel=o=>{o.pointerId===this.state?.pointer&&this.cancel()},this.onKey=o=>{o.key==="Escape"&&this.state?.active&&(o.preventDefault(),o.stopPropagation(),this.cancel())},this.onOther=o=>{this.state&&o.pointerId!==this.state.pointer&&this.cancel()},this.onBlur=()=>this.cancel(),this.onScroll=()=>{this.state&&!this.state.active&&this.stop()},e.addEventListener("pointerdown",o=>this.start(o))}start(t){if(t.button!==0||this.state)return;let e=this.view.state,n=g(e.doc),i=e.selection,o=Math.min(this.index(),n.length-1),r=i instanceof C&&n[o].at>=i.from&&n[o].end<=i.to,{lo:c,hi:d}=r?i.span(e.doc):I(n,o,o);if(this.state={index:o,span:R(n,c,d),touch:t.pointerType==="touch",pointer:t.pointerId,x0:t.clientX,y0:t.clientY,x:t.clientX,y:t.clientY,hold:0,active:!1,raf:0,gap:void 0,targets:[],target:null},this.grip.setPointerCapture?.(t.pointerId),this.grip.addEventListener("pointermove",this.onMove),this.grip.addEventListener("pointerup",this.onUp),this.grip.addEventListener("pointercancel",this.onCancel),this.grip.addEventListener("lostpointercapture",this.onCancel),this.state.touch){let h=this.state;h.hold=setTimeout(()=>this.held(h),tt),window.addEventListener("pointerdown",this.onOther,!0),window.addEventListener("blur",this.onBlur),window.addEventListener("scroll",this.onScroll,!0)}t.preventDefault()}held(t){if(!(this.state!==t||t.active)){if(t.hold=0,Math.hypot(t.x-t.x0,t.y-t.y0)>V||!this.view.editable)return this.stop();this.begin()}}move(t){let e=this.state;if(!(!e||t.pointerId!==e.pointer)){if(e.x=t.clientX,e.y=t.clientY,e.touch&&!this.view.editable)return e.active?this.cancel():this.stop();if(!e.active){let n=Math.hypot(e.x-e.x0,e.y-e.y0);if(e.touch){n>V&&this.stop();return}if(n<=Z)return;this.begin()}this.track()}}begin(){let t=this.state;if(!t||t.active)return;let e=this.view.state,n=g(e.doc),i=k(n,t.span);if(!i)return this.cancel();t.active=!0,this.view.dispatch(e.tr.setSelection(X(e.doc,i.lo,i.hi))),this.shell.classList.add("is-dragging");let o=this.shell.appendChild(document.createElement("div"));o.style.cssText="position:absolute;visibility:hidden;width:var(--blockeditor-indent)",this.indentPx=o.getBoundingClientRect().width||27,o.remove(),this.scroller=et(this.view.dom),window.addEventListener("keydown",this.onKey,!0),this.loop(),this.track()}track(){let t=this.state,e=this.view,n=e.state;if(!t)return;let i=g(n.doc),o=k(i,t.span);if(!o)return this.cancel();let{lo:r,hi:c}=o,d=nt(i,e),h=it(d,t.y),a=-1,l=null,p=null,E=h<0?d.length:h+1;for(let x=Math.max(0,E-2);x<E;x++){let v=d[x].dom.getBoundingClientRect();t.y>=v.top+v.height/4&&t.y<=v.bottom-v.height/4&&(p={i:d[x].i,bottom:v.bottom}),l=v.bottom+2}h>=0&&(a=d[h].i,l=d[h].dom.getBoundingClientRect().top-2);let f=r<0?null:p&&q(n,i,r,c,p.i),u=f?`summary:${p.i}`:a;(u!==t.gap||n.doc!==t.doc)&&(t.gap=u,t.doc=n.doc,t.targets=r<0?[]:f?[f]:U(n,i,r,c,a)),f&&(l=p.bottom+2);let m=e.dom.getBoundingClientRect().left;t.target=z(t.targets,(t.x-m)/this.indentPx);let T=this.shell.getBoundingClientRect();if(!t.target||l===null){this.line.hidden=!0,this.shell.dataset.drop="none";return}this.shell.dataset.drop="ok",this.line.hidden=!1,this.line.style.setProperty("--blockeditor-drop-y",`${l-T.top}px`),this.line.style.setProperty("--blockeditor-drop-x",`${m-T.left+t.target.depth*this.indentPx}px`),this.line.style.setProperty("--blockeditor-drop-w",`${e.dom.getBoundingClientRect().right-m-t.target.depth*this.indentPx}px`)}loop(){let t=()=>{let e=this.state;if(!e?.active)return;if(e.touch&&!this.view.editable)return this.cancel();let n=this.scroller,i=n===n.ownerDocument.scrollingElement?{top:0,bottom:window.innerHeight}:n.getBoundingClientRect(),o=0;e.y<i.top+b?o=-W*Math.min(1,(i.top+b-e.y)/b):e.y>i.bottom-b&&(o=W*Math.min(1,(e.y-(i.bottom-b))/b)),o&&(n.scrollTop+=o,this.track()),e.raf=requestAnimationFrame(t)};this.state.raf=requestAnimationFrame(t)}end(t){let e=this.state;if(!e||t.pointerId!==e.pointer)return;if(!e.active){if(this.stop(),t.type==="pointerup"){let l=g(this.view.state.doc),p=k(l,e.span);p&&this.onClick(p.lo)}return}if(this.track(),this.state!==e)return;let n=e.target,i=this.view.state,o=g(i.doc),r=k(o,e.span);if(this.stop(),!n||!r)return;let{lo:c,hi:d}=r;if(!n.open&&(n.at===o[c].at||n.at===o[d].end)&&n.parent===(o[c].node.attrs.parent??null)&&(o[c].node.type.name!=="list_item"||n.indent===o[c].node.attrs.indent))return;if(this.view.dispatch(H(P(i,o,c,d,n)).scrollIntoView()),this.view.state.doc===i.doc)return M(this.view,"Move cancelled");let a=d-c+1;M(this.view,`Moved ${a} ${a===1?"block":"blocks"}`),this.view.focus()}cancel(){this.stop(),M(this.view,"Move cancelled")}stop(){let t=this.state;t&&(this.state=null,clearTimeout(t.hold),cancelAnimationFrame(t.raf),this.grip.removeEventListener("pointermove",this.onMove),this.grip.removeEventListener("pointerup",this.onUp),this.grip.removeEventListener("pointercancel",this.onCancel),this.grip.removeEventListener("lostpointercapture",this.onCancel),this.grip.releasePointerCapture?.(t.pointer),window.removeEventListener("pointerdown",this.onOther,!0),window.removeEventListener("blur",this.onBlur),window.removeEventListener("scroll",this.onScroll,!0),window.removeEventListener("keydown",this.onKey,!0),this.shell.classList.remove("is-dragging"),delete this.shell.dataset.drop,this.line.hidden=!0)}destroy(){this.stop(),this.line.remove()}};export{g as a,et as b,G as c};
1
+ import{C as H,D as X,d as M,g as L,h as O,j as D,m as I,n as R,o as k,p as C,q as A,r as N,t as $}from"./c-AI3H6ETU.js";import{d as B}from"./c-OH2FPYSY.js";var _=new WeakMap;function g(s){let t=_.get(s);return t||_.set(s,t=O(s)),t}var F=B.nodes,w=s=>s.type===F.list_item,S=s=>s.type===F.toggle,y=s=>s.attrs.parent??null;function J(s,t,e){if(e<0)return[null];let n=[],i=s[e].node;S(i)&&i.attrs.open&&!s[e].hidden&&n.unshift(i.attrs.id);for(let r=y(i);r!==null&&!n.includes(r);){let c=s[t.get(r)];if(!c)break;n.unshift(r),r=y(c.node)}let o=[null];for(let r of n){let c=s[t.get(r)];if(!c.node.attrs.open||c.hidden)break;o.push(r)}return o}function Y(s,t,e,n){let i=y(s[t].node),o=w(s[t].node)?n.indent-s[t].node.attrs.indent:0;return r=>r.i<t||r.i>e||y(r.node)!==i?null:w(r.node)?{parent:n.parent,indent:r.node.attrs.indent+o}:{parent:n.parent}}function Q(s,t){let e=null;s.doc.forEach((n,i)=>{n.attrs.id===t&&S(n)&&(e={n,off:i})}),e&&!e.n.attrs.open&&s.setNodeMarkup(e.off,null,{...e.n.attrs,open:!0})}function P(s,t,e,n,i,o=null){let r=Y(t,e,n,i),c=t[e].at,d=t[n].end,h=o??new C(s.doc.resolve(c),s.doc.resolve(d)),a;if(i.at===c||i.at===d){a=s.tr;for(let l=e;l<=n;l++){let p=r(t[l]);p&&a.setNodeMarkup(t[l].at,null,{...t[l].node.attrs,...p})}a.setSelection(h.map(a.doc,a.mapping)),a.setMeta(L,A(t,e,n,i.at,r))}else a=N(s,t,e,n,i.at,r,h);if(i.open){Q(a,i.open);let l=a.getMeta(L);l&&a.setMeta(L,{...l,attrs:{...l.attrs,[i.open]:{open:!0}}})}return a}function K(s,t,e,n,i){if(i.parent!=null&&t.slice(e,n+1).some(a=>a.node.attrs.id===i.parent))return!1;let o=t[n].end-t[e].at,r=Y(t,e,n,i);for(let a=e;a<=n;a++)if(w(t[a].node)&&(r(t[a])?.indent??t[a].node.attrs.indent)>$)return!1;let c=P(s,t,e,n,i),h=i.at===t[e].at||i.at===t[n].end?t[e].at:i.at>t[e].at?i.at-o:i.at;return D(c.doc,s.doc).every(a=>a.at>=h&&a.at<h+o)}function U(s,t,e,n,i){let o=new Map;t.forEach(l=>{S(l.node)&&l.node.attrs.id&&o.set(l.node.attrs.id,l.i)});let r=i<0?s.doc.content.size:t[i].at;if(r>t[e].at&&r<t[n].end)return[];let c=(i<0?t.length:i)-1,d=J(t,o,c),h=d.indexOf(i<0?null:y(t[i].node)),a=[];for(let l of d.slice(Math.max(0,h))){let p=l===null?0:t[o.get(l)].depth+1,E=c>=0&&w(t[c].node)&&y(t[c].node)===l?t[c].node:null,f=w(t[e].node)&&E?E.attrs.indent+1:0;for(let u=0;u<=f;u++){let m={at:r,parent:l,indent:u,depth:p+(w(t[e].node)?u:0)};K(s,t,e,n,m)&&a.push(m)}}return a}function q(s,t,e,n,i){let o=t[i];if(!o||!S(o.node)||o.node.attrs.open||o.hidden||i>=e&&i<=n||o.at>t[e].at&&o.at<t[n].end)return null;let r=o.node.attrs.id,c={at:t[o.subEnd].end,parent:r,indent:0,depth:o.depth+1,open:r};return K(s,t,e,n,c)?c:null}function z(s,t){let e=null;for(let n of s)(!e||Math.abs(n.depth-t)<Math.abs(e.depth-t))&&(e=n);return e}var Z=4,tt=250,V=8,b=56,W=18;function et(s){for(let t=s.parentElement;t;t=t.parentElement){let e=getComputedStyle(t).overflowY;if((e==="auto"||e==="scroll")&&t.scrollHeight>t.clientHeight)return t}return s.ownerDocument.scrollingElement}var j=new WeakMap;function nt(s,t){let e=j.get(s);if(!e){e=[];for(let n of s){if(n.hidden)continue;let i=t.nodeDOM(n.at);i?.getBoundingClientRect&&e.push({i:n.i,dom:i})}j.set(s,e)}return e}function it(s,t){let e=0,n=s.length;for(;e<n;){let i=e+n>>1,o=s[i].dom.getBoundingClientRect();t<o.top+o.height/2?n=i:e=i+1}return e<s.length?e:-1}var G=class{constructor(t,e,{index:n,onClick:i}){this.view=t,this.grip=e,this.index=n,this.onClick=i,this.shell=t.dom.parentElement,this.line=document.createElement("div"),this.line.className="blockeditor-drop",this.line.hidden=!0,this.line.setAttribute("aria-hidden","true"),this.shell.append(this.line),this.state=null,this.onMove=o=>this.move(o),this.onUp=o=>this.end(o),this.onCancel=o=>{o.pointerId===this.state?.pointer&&this.cancel()},this.onKey=o=>{o.key==="Escape"&&this.state?.active&&(o.preventDefault(),o.stopPropagation(),this.cancel())},this.onOther=o=>{this.state&&o.pointerId!==this.state.pointer&&this.cancel()},this.onBlur=()=>this.cancel(),this.onScroll=()=>{this.state&&!this.state.active&&this.stop()},e.addEventListener("pointerdown",o=>this.start(o))}start(t){if(t.button!==0||this.state)return;let e=this.view.state,n=g(e.doc),i=e.selection,o=Math.min(this.index(),n.length-1),r=i instanceof C&&n[o].at>=i.from&&n[o].end<=i.to,{lo:c,hi:d}=r?i.span(e.doc):I(n,o,o);if(this.state={index:o,span:R(n,c,d),touch:t.pointerType==="touch",pointer:t.pointerId,x0:t.clientX,y0:t.clientY,x:t.clientX,y:t.clientY,hold:0,active:!1,raf:0,gap:void 0,targets:[],target:null},this.grip.setPointerCapture?.(t.pointerId),this.grip.addEventListener("pointermove",this.onMove),this.grip.addEventListener("pointerup",this.onUp),this.grip.addEventListener("pointercancel",this.onCancel),this.grip.addEventListener("lostpointercapture",this.onCancel),this.state.touch){let h=this.state;h.hold=setTimeout(()=>this.held(h),tt),window.addEventListener("pointerdown",this.onOther,!0),window.addEventListener("blur",this.onBlur),window.addEventListener("scroll",this.onScroll,!0)}t.preventDefault()}held(t){if(!(this.state!==t||t.active)){if(t.hold=0,Math.hypot(t.x-t.x0,t.y-t.y0)>V||!this.view.editable)return this.stop();this.begin()}}move(t){let e=this.state;if(!(!e||t.pointerId!==e.pointer)){if(e.x=t.clientX,e.y=t.clientY,e.touch&&!this.view.editable)return e.active?this.cancel():this.stop();if(!e.active){let n=Math.hypot(e.x-e.x0,e.y-e.y0);if(e.touch){n>V&&this.stop();return}if(n<=Z)return;this.begin()}this.track()}}begin(){let t=this.state;if(!t||t.active)return;let e=this.view.state,n=g(e.doc),i=k(n,t.span);if(!i)return this.cancel();t.active=!0,this.view.dispatch(e.tr.setSelection(X(e.doc,i.lo,i.hi))),this.shell.classList.add("is-dragging");let o=this.shell.appendChild(document.createElement("div"));o.style.cssText="position:absolute;visibility:hidden;width:var(--blockeditor-indent)",this.indentPx=o.getBoundingClientRect().width||27,o.remove(),this.scroller=et(this.view.dom),window.addEventListener("keydown",this.onKey,!0),this.loop(),this.track()}track(){let t=this.state,e=this.view,n=e.state;if(!t)return;let i=g(n.doc),o=k(i,t.span);if(!o)return this.cancel();let{lo:r,hi:c}=o,d=nt(i,e),h=it(d,t.y),a=-1,l=null,p=null,E=h<0?d.length:h+1;for(let x=Math.max(0,E-2);x<E;x++){let v=d[x].dom.getBoundingClientRect();t.y>=v.top+v.height/4&&t.y<=v.bottom-v.height/4&&(p={i:d[x].i,bottom:v.bottom}),l=v.bottom+2}h>=0&&(a=d[h].i,l=d[h].dom.getBoundingClientRect().top-2);let f=r<0?null:p&&q(n,i,r,c,p.i),u=f?`summary:${p.i}`:a;(u!==t.gap||n.doc!==t.doc)&&(t.gap=u,t.doc=n.doc,t.targets=r<0?[]:f?[f]:U(n,i,r,c,a)),f&&(l=p.bottom+2);let m=e.dom.getBoundingClientRect().left;t.target=z(t.targets,(t.x-m)/this.indentPx);let T=this.shell.getBoundingClientRect();if(!t.target||l===null){this.line.hidden=!0,this.shell.dataset.drop="none";return}this.shell.dataset.drop="ok",this.line.hidden=!1,this.line.style.setProperty("--blockeditor-drop-y",`${l-T.top}px`),this.line.style.setProperty("--blockeditor-drop-x",`${m-T.left+t.target.depth*this.indentPx}px`),this.line.style.setProperty("--blockeditor-drop-w",`${e.dom.getBoundingClientRect().right-m-t.target.depth*this.indentPx}px`)}loop(){let t=()=>{let e=this.state;if(!e?.active)return;if(e.touch&&!this.view.editable)return this.cancel();let n=this.scroller,i=n===n.ownerDocument.scrollingElement?{top:0,bottom:window.innerHeight}:n.getBoundingClientRect(),o=0;e.y<i.top+b?o=-W*Math.min(1,(i.top+b-e.y)/b):e.y>i.bottom-b&&(o=W*Math.min(1,(e.y-(i.bottom-b))/b)),o&&(n.scrollTop+=o,this.track()),e.raf=requestAnimationFrame(t)};this.state.raf=requestAnimationFrame(t)}end(t){let e=this.state;if(!e||t.pointerId!==e.pointer)return;if(!e.active){if(this.stop(),t.type==="pointerup"){let l=g(this.view.state.doc),p=k(l,e.span);p&&this.onClick(p.lo)}return}if(this.track(),this.state!==e)return;let n=e.target,i=this.view.state,o=g(i.doc),r=k(o,e.span);if(this.stop(),!n||!r)return;let{lo:c,hi:d}=r;if(!n.open&&(n.at===o[c].at||n.at===o[d].end)&&n.parent===(o[c].node.attrs.parent??null)&&(o[c].node.type.name!=="list_item"||n.indent===o[c].node.attrs.indent))return;if(this.view.dispatch(H(P(i,o,c,d,n)).scrollIntoView()),this.view.state.doc===i.doc)return M(this.view,"Move cancelled");let a=d-c+1;M(this.view,`Moved ${a} ${a===1?"block":"blocks"}`),this.view.focus()}cancel(){this.stop(),M(this.view,"Move cancelled")}stop(){let t=this.state;t&&(this.state=null,clearTimeout(t.hold),cancelAnimationFrame(t.raf),this.grip.removeEventListener("pointermove",this.onMove),this.grip.removeEventListener("pointerup",this.onUp),this.grip.removeEventListener("pointercancel",this.onCancel),this.grip.removeEventListener("lostpointercapture",this.onCancel),this.grip.releasePointerCapture?.(t.pointer),window.removeEventListener("pointerdown",this.onOther,!0),window.removeEventListener("blur",this.onBlur),window.removeEventListener("scroll",this.onScroll,!0),window.removeEventListener("keydown",this.onKey,!0),this.shell.classList.remove("is-dragging"),delete this.shell.dataset.drop,this.line.hidden=!0)}destroy(){this.stop(),this.line.remove()}};export{g as a,et as b,G as c};
@@ -1 +1 @@
1
- import{b as k,d as l,e as i}from"./c-BPF2NSPV.js";import{a as M}from"./c-P7KNDG34.js";import{a as S}from"./c-CYWLPPUS.js";import{e as b}from"./c-U4NTUVDZ.js";var A=Object.fromEntries(new URLSearchParams(window.location.search)),n=A;var w=()=>S("mode-receipt"),R=3e4;function T(){try{return performance.getEntriesByType("navigation")[0]?.type??null}catch{return null}}function P(){let e=null;try{e=sessionStorage.getItem(w()),sessionStorage.removeItem(w())}catch{return null}if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}return t?.v!==1||t.path!==location.pathname||t.mode!=="edit"&&t.mode!=="view"||Date.now()-t.at>R||!t.internal&&T()!=="reload"?null:t}function J({mode:e,canEdit:t,internal:s}){try{sessionStorage.setItem(w(),JSON.stringify({v:1,path:location.pathname,mode:e,canEdit:t,at:Date.now(),internal:s}))}catch{}}var o=null;typeof window<"u"&&(window.clayEditMode!=null?o=!!window.clayEditMode:window.__hyperclayEditMode!=null&&(o=!!window.__hyperclayEditMode));var r=typeof document<"u"&&document.documentElement.hasAttribute("viewonly"),B=typeof document<"u"&&b(),p=!!M.get("isAdminOfCurrentResource"),g=n.editmode==="document",y=B&&n.editmode!=="false"&&!((n.editmode==="true"||g)&&p)&&!r&&!i()&&o==null&&!l(),u=typeof window<"u"?P():null,x=typeof document<"u"&&document.documentElement.getAttribute("opens-in")==="edit",D=g?!r&&!i()&&o!==!1:n.editmode?n.editmode==="true"||!r&&!i()&&(o??(l()||p)):r||i()?!1:o??(l()||p),V=u?.canEdit===!0&&o!==!1&&!i()&&!(r&&n.editmode!=="true"),h=D||V,q=y||i()||o===!1||n.editmode==="false"||r&&n.editmode!=="true",m=h,I=null;function z(e){I=typeof e=="boolean"?e:null;let t=e===!1?!1:e===!0?h||!q:h;t!==m&&(m=t,typeof document<"u"&&document.dispatchEvent(new Event("clay:capabilitychange")))}function Q(){return I}var F=u?u.mode==="edit"||x&&!u.internal:n.editmode&&!g?n.editmode==="true":o===!0||x,d=y?!0:m&&F,O=y?"draft":d?"edit":"view",Y=p,c={phase:"idle",destination:y?"draft":"host",generation:0,reason:null};function Z(e){e.mode!==void 0&&(O=e.mode),e.isEditMode!==void 0&&(d=e.isEditMode,typeof window<"u"&&(window.__hyperclayEditMode=d)),e.canEdit!==void 0&&(m=e.canEdit);for(let t in c)e[t]!==void 0&&(c[t]=e[t])}var U=()=>({mode:O,...c});function ee(){return d&&U().phase==="idle"}var a=typeof window>"u"||!window.clay?[]:(window.clay.modeParticipants||Object.defineProperty(window.clay,"modeParticipants",{value:[],writable:!0,configurable:!0}),window.clay.modeParticipants),f=new Set,_=()=>{},te=e=>_=e,ne=()=>a.slice(),E=e=>{throw new TypeError(`clay.modeLifecycle: ${e}`)},W=()=>{(c.phase!=="idle"||d)&&E("the page is not idle in view")},C=()=>{c.phase==="blocked"&&!d||W()};function oe(){return f.clear(),a.splice(0)}function ie(e){let t=e&&e.id;(typeof t!="string"||!t||typeof e.prepare!="function")&&E("a participant needs an id and a prepare()"),f.has(t)&&E(`duplicate participant id "${t}"`),C(),f.add(t),a.push(e);let s=!0;return()=>{if(!s)return;C(),s=!1,f.delete(t);let v=a.indexOf(e);v!==-1&&a.splice(v,1),_(t)}}var re=k;export{J as a,y as b,m as c,z as d,Q as e,d as f,O as g,Y as h,Z as i,U as j,ee as k,te as l,ne as m,oe as n,ie as o,re as p};
1
+ import{b as k,d as l,e as i}from"./c-BPF2NSPV.js";import{a as M}from"./c-P7KNDG34.js";import{a as S}from"./c-CYWLPPUS.js";import{e as b}from"./c-U4TWEIKZ.js";var A=Object.fromEntries(new URLSearchParams(window.location.search)),n=A;var w=()=>S("mode-receipt"),R=3e4;function T(){try{return performance.getEntriesByType("navigation")[0]?.type??null}catch{return null}}function P(){let e=null;try{e=sessionStorage.getItem(w()),sessionStorage.removeItem(w())}catch{return null}if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}return t?.v!==1||t.path!==location.pathname||t.mode!=="edit"&&t.mode!=="view"||Date.now()-t.at>R||!t.internal&&T()!=="reload"?null:t}function J({mode:e,canEdit:t,internal:s}){try{sessionStorage.setItem(w(),JSON.stringify({v:1,path:location.pathname,mode:e,canEdit:t,at:Date.now(),internal:s}))}catch{}}var o=null;typeof window<"u"&&(window.clayEditMode!=null?o=!!window.clayEditMode:window.__hyperclayEditMode!=null&&(o=!!window.__hyperclayEditMode));var r=typeof document<"u"&&document.documentElement.hasAttribute("viewonly"),B=typeof document<"u"&&b(),p=!!M.get("isAdminOfCurrentResource"),g=n.editmode==="document",y=B&&n.editmode!=="false"&&!((n.editmode==="true"||g)&&p)&&!r&&!i()&&o==null&&!l(),u=typeof window<"u"?P():null,x=typeof document<"u"&&document.documentElement.getAttribute("opens-in")==="edit",D=g?!r&&!i()&&o!==!1:n.editmode?n.editmode==="true"||!r&&!i()&&(o??(l()||p)):r||i()?!1:o??(l()||p),V=u?.canEdit===!0&&o!==!1&&!i()&&!(r&&n.editmode!=="true"),h=D||V,q=y||i()||o===!1||n.editmode==="false"||r&&n.editmode!=="true",m=h,I=null;function z(e){I=typeof e=="boolean"?e:null;let t=e===!1?!1:e===!0?h||!q:h;t!==m&&(m=t,typeof document<"u"&&document.dispatchEvent(new Event("clay:capabilitychange")))}function Q(){return I}var F=u?u.mode==="edit"||x&&!u.internal:n.editmode&&!g?n.editmode==="true":o===!0||x,d=y?!0:m&&F,O=y?"draft":d?"edit":"view",Y=p,c={phase:"idle",destination:y?"draft":"host",generation:0,reason:null};function Z(e){e.mode!==void 0&&(O=e.mode),e.isEditMode!==void 0&&(d=e.isEditMode,typeof window<"u"&&(window.__hyperclayEditMode=d)),e.canEdit!==void 0&&(m=e.canEdit);for(let t in c)e[t]!==void 0&&(c[t]=e[t])}var U=()=>({mode:O,...c});function ee(){return d&&U().phase==="idle"}var a=typeof window>"u"||!window.clay?[]:(window.clay.modeParticipants||Object.defineProperty(window.clay,"modeParticipants",{value:[],writable:!0,configurable:!0}),window.clay.modeParticipants),f=new Set,_=()=>{},te=e=>_=e,ne=()=>a.slice(),E=e=>{throw new TypeError(`clay.modeLifecycle: ${e}`)},W=()=>{(c.phase!=="idle"||d)&&E("the page is not idle in view")},C=()=>{c.phase==="blocked"&&!d||W()};function oe(){return f.clear(),a.splice(0)}function ie(e){let t=e&&e.id;(typeof t!="string"||!t||typeof e.prepare!="function")&&E("a participant needs an id and a prepare()"),f.has(t)&&E(`duplicate participant id "${t}"`),C(),f.add(t),a.push(e);let s=!0;return()=>{if(!s)return;C(),s=!1,f.delete(t);let v=a.indexOf(e);v!==-1&&a.splice(v,1),_(t)}}var re=k;export{J as a,y as b,m as c,z as d,Q as e,d as f,O as g,Y as h,Z as i,U as j,ee as k,te as l,ne as m,oe as n,ie as o,re as p};
@@ -0,0 +1,4 @@
1
+ import{b as h,c as p}from"./c-HKSLOVU4.js";import{a as m,b as A}from"./c-RHMPKZZ7.js";function E(t){return(t.getAttribute("type")||"text").toLowerCase()}function y(t,a=t){let u=t.tagName;if(u==="INPUT"){let n=E(t);n==="checkbox"||n==="radio"?a.checked?t.hasAttribute("checked")||t.setAttribute("checked",""):t.removeAttribute("checked"):a.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",a.value);return}if(u==="TEXTAREA"){let n=a.value.startsWith(`
2
+ `)?`
3
+ `+a.value:a.value;t.textContent!==n&&(t.textContent=n),t.removeAttribute("data-value");return}if(u==="SELECT"){let n=t.options,d=a.options;for(let i=0;i<n.length;i++)d[i]&&d[i].selected?n[i].hasAttribute("selected")||n[i].setAttribute("selected",""):n[i].removeAttribute("selected")}}var S={label:"Earlier drafts",intro:"This page kept your earlier drafts aside, listed by time."};function D({store:t,session:a,getHTML:u=()=>window.clay.getHTML(),download:n=A}){let d=r=>a.recoveryRecord(r),i=r=>r?.savedAt??r?.ops?.at(-1)?.savedAt??(r?.at?new Date(r.at).toISOString():null);async function b(){return(await a.listRecovery()).map(({mark:o,copy:e})=>{let s=d(e),c=e?.ops?new Set(e.ops.flatMap(l=>Object.keys(l.keys??{}))).size:Object.keys(s?.data??{}).length;return{mark:o,copy:e,savedAt:i(e),fields:c,available:!!s}}).sort((o,e)=>(Date.parse(e.savedAt)||0)-(Date.parse(o.savedAt)||0))}function v(r){let o=d(r);if(!o)throw new Error("This draft cannot be opened by this version.");let e=new DOMParser().parseFromString(u(),"text/html");if(p(e,t.seed(),t.rules),p(e,o.data,t.rules),!t.fitsInto(o.data,h(e,t.rules)))throw new Error("This draft no longer fits the page. Its saved copy is still kept.");let s=o.blockeditor?o:t.servedUnit(),c=e.querySelector("article[data-blockeditor]");if(s){if(!c)throw new Error("This draft's page editor is no longer available.");for(let l of e.querySelectorAll('script[type="application/json"][merge][clay~="live"]'))l.remove();for(let[l,k]of Object.entries(s.live)){let f=e.createElement("script");f.type="application/json",f.setAttribute("merge",l),f.setAttribute("clay","live"),f.textContent=JSON.stringify(k).replace(/</g,"\\u003c"),c.before(f)}c.setAttribute("data-rev",s.blockeditor.rev),c.innerHTML=s.blockeditor.html}for(let l of e.querySelectorAll('input:not([type="password"]):not([type="file"]), textarea, select'))y(l);return`<!DOCTYPE html>
4
+ `+e.documentElement.outerHTML}async function w(r){if(!await n({html:v(r),name:m()+".htmlclay"}))throw new Error("The download could not be made. Try again.");return!0}async function T(r){let o=(await b()).find(e=>e.mark===r);if(!o)throw new Error("That draft is no longer available. Open the list again.");return v(o.copy),a.restoreRecovery(r)}return{list:b,html:v,download:w,restore:T,remove:r=>a.removeRecovery(r)}}export{S as a,D as b};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h}from"./c-6IJEVE6B.js";import"./c-QQFHEODI.js";import"./c-EDE45NM7.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4NTUVDZ.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{b as conditionalSaves,f as forgetEtag,e as forgetRepresentedEtag,a as lastSeenEtag,g as learnConditionalSaves,c as recordEtag,d as representedEtag,h as seedEtag};
1
+ import{a,b,c,d,e,f,g,h}from"./c-KU3PX7LL.js";import"./c-EQ5NBOGA.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{b as conditionalSaves,f as forgetEtag,e as forgetRepresentedEtag,a as lastSeenEtag,g as learnConditionalSaves,c as recordEtag,d as representedEtag,h as seedEtag};