@panphora/clayjs 1.24.0 → 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 (209) 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 +16610 -14400
  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-277QP5ET.js +1 -0
  14. package/dist/m/{c-SXGEWPFC.js → c-3E2IK5HU.js} +1 -1
  15. package/dist/m/{c-A4L7APIU.js → c-4AE2A2LK.js} +1 -1
  16. package/dist/m/{c-DZPO22O3.js → c-4Q6QIODW.js} +1 -1
  17. package/dist/m/{c-RO73MKKR.js → c-52OC3OH3.js} +1 -1
  18. package/dist/m/{c-VNAYHV2J.js → c-5PZYDWTW.js} +1 -1
  19. package/dist/m/c-5Q5XBN56.js +1 -0
  20. package/dist/m/c-5SZ6KFR5.js +1 -0
  21. package/dist/m/{c-ZRGEN6QQ.js → c-AI3H6ETU.js} +2 -2
  22. package/dist/m/{c-7V6MGMX2.js → c-BCWYEG6P.js} +1 -1
  23. package/dist/m/{c-A7N5TNSL.js → c-BJ2RRQBQ.js} +1 -1
  24. package/dist/m/{c-CTGRDT6E.js → c-C6YZNU6E.js} +1 -1
  25. package/dist/m/{c-DLBX4JCJ.js → c-C7SUMNMI.js} +1 -1
  26. package/dist/m/c-CITLTVQ4.js +4 -0
  27. package/dist/m/{c-TWOXQQKV.js → c-CL5LSATX.js} +1 -1
  28. package/dist/m/c-CU33V6RW.js +4 -0
  29. package/dist/m/{c-2R4OBWIP.js → c-D62HRSZK.js} +1 -1
  30. package/dist/m/{c-DD26VXAP.js → c-DT7E76Z2.js} +1 -1
  31. package/dist/m/{c-54ZZZYUN.js → c-EAV7A6BT.js} +1 -1
  32. package/dist/m/{c-RBPZNU2D.js → c-EQ5NBOGA.js} +1 -1
  33. package/dist/m/{c-KQKKIVLW.js → c-FBOO2UY3.js} +1 -1
  34. package/dist/m/{c-RTSRGGTP.js → c-FJDTDGDA.js} +1 -1
  35. package/dist/m/{c-MQKSKQHG.js → c-FKTALXNV.js} +1 -1
  36. package/dist/m/{c-GNIVHLEJ.js → c-GDNZEOOZ.js} +1 -1
  37. package/dist/m/{c-SUXHUL7U.js → c-GEAG5XAK.js} +1 -1
  38. package/dist/m/{c-UM7VZDTW.js → c-GY4BREDT.js} +1 -1
  39. package/dist/m/{c-4PO3YGDC.js → c-HGG7M2S3.js} +1 -1
  40. package/dist/m/c-HKSLOVU4.js +1 -0
  41. package/dist/m/{c-KJHVB2KG.js → c-HXGNH6GY.js} +1 -1
  42. package/dist/m/{c-FLEIU6CG.js → c-IESDKFO6.js} +1 -1
  43. package/dist/m/{c-SNVDWMM3.js → c-IJHF4IO6.js} +1 -1
  44. package/dist/m/{c-SGGGCIVD.js → c-IL5IVTOG.js} +1 -1
  45. package/dist/m/c-JB5YU57S.js +1 -0
  46. package/dist/m/{c-MP6S4AZU.js → c-JD2VFAYG.js} +2 -2
  47. package/dist/m/{c-CV4T65JE.js → c-JWW6BHWD.js} +3 -3
  48. package/dist/m/{c-GM7OA6EJ.js → c-K4M76VPM.js} +1 -1
  49. package/dist/m/{c-RXTPKCMC.js → c-KU3PX7LL.js} +1 -1
  50. package/dist/m/{c-2PVGJFI5.js → c-KYTVZT4D.js} +1 -1
  51. package/dist/m/{c-RJKKRWHW.js → c-M7ITYKMF.js} +1 -1
  52. package/dist/m/c-MFB74XVN.js +3 -0
  53. package/dist/m/c-MOP5KBWZ.js +1 -0
  54. package/dist/m/{c-YB3CDTDZ.js → c-MUM53J5J.js} +1 -1
  55. package/dist/m/{c-YK2L436K.js → c-MV7TEUTD.js} +1 -1
  56. package/dist/m/{c-LA2BW7UY.js → c-MZCOGNZL.js} +1 -1
  57. package/dist/m/{c-YGGO2G2L.js → c-N4GEJMXW.js} +1 -1
  58. package/dist/m/{c-NQAPWM7O.js → c-NADLYVAH.js} +1 -1
  59. package/dist/m/{c-RS77ODLY.js → c-NL4I4KNG.js} +1 -1
  60. package/dist/m/{c-6UPEKW6O.js → c-O2QZDVZ2.js} +1 -1
  61. package/dist/m/{c-LTSPHVAK.js → c-OBMZASYQ.js} +1 -1
  62. package/dist/m/{c-LUXAB2XI.js → c-ORLPQFNU.js} +1 -1
  63. package/dist/m/c-P73XPAOA.js +1 -0
  64. package/dist/m/{c-PWJSJEJU.js → c-PNZIJFG7.js} +1 -1
  65. package/dist/m/{c-ZKKAF4UT.js → c-PRZNJUYZ.js} +2 -2
  66. package/dist/m/{c-Q6VNQDJE.js → c-Q2CB57UG.js} +1 -1
  67. package/dist/m/{c-TWCXBWS3.js → c-QCDVDZIR.js} +1 -1
  68. package/dist/m/{c-P5NKFRL4.js → c-QDVG4NAZ.js} +1 -1
  69. package/dist/m/c-QWB53KRW.js +1 -0
  70. package/dist/m/{c-GNI7WHKF.js → c-RGAALCDU.js} +1 -1
  71. package/dist/m/c-RHPHMTF2.js +2 -0
  72. package/dist/m/{c-BULK5J4M.js → c-RWJ3OSCP.js} +1 -1
  73. package/dist/m/{c-5FXEKU4Y.js → c-SEVOS4UE.js} +1 -1
  74. package/dist/m/{c-PMRRMT72.js → c-SFYTKRU7.js} +1 -1
  75. package/dist/m/{c-47IBJGPQ.js → c-SFZRY6RT.js} +1 -1
  76. package/dist/m/{c-QENKN7QI.js → c-SGG6MUXW.js} +1 -1
  77. package/dist/m/c-SMLAJASY.js +1 -0
  78. package/dist/m/{c-VSEUFJAO.js → c-SUAC5RSG.js} +1 -1
  79. package/dist/m/{c-6RGEQNVV.js → c-SXZYVXD6.js} +1 -1
  80. package/dist/m/{c-ZFO5RW6G.js → c-TCFVG3I4.js} +1 -1
  81. package/dist/m/{c-PZRWZZRO.js → c-TLQINES7.js} +2 -2
  82. package/dist/m/c-U4TWEIKZ.js +1 -0
  83. package/dist/m/{c-FZRZPIFS.js → c-U65PREMC.js} +1 -1
  84. package/dist/m/{c-7YETSAVY.js → c-U7F66I64.js} +1 -1
  85. package/dist/m/{c-WOELSNWS.js → c-UD4VDBGJ.js} +1 -1
  86. package/dist/m/{c-VI3BJHCM.js → c-V2FPBRO6.js} +1 -1
  87. package/dist/m/{c-2OIKXOY6.js → c-V4B3RUWB.js} +1 -1
  88. package/dist/m/{c-O5ARALMJ.js → c-V5L6HWVL.js} +1 -1
  89. package/dist/m/c-VMXCX52Q.js +1 -0
  90. package/dist/m/{c-PVJMJL3P.js → c-VO6RSFCO.js} +1 -1
  91. package/dist/m/c-WDFQ7PBU.js +1 -0
  92. package/dist/m/{c-OG6GFSUX.js → c-WGQVSKKC.js} +1 -1
  93. package/dist/m/c-WSTUCBHV.js +1 -0
  94. package/dist/m/{c-EY5KDUZF.js → c-WVCT3ITX.js} +1 -1
  95. package/dist/m/{c-SE3SIY7Y.js → c-X3V4RWMA.js} +1 -1
  96. package/dist/m/{c-HIX5H5L7.js → c-XHZIKRCV.js} +1 -1
  97. package/dist/m/{c-2BLVA6IN.js → c-XQTERKQA.js} +1 -1
  98. package/dist/m/{c-A5ZBFICF.js → c-YFO6ZJLQ.js} +1 -1
  99. package/dist/m/{c-PD5AKHY3.js → c-YX2MC7YL.js} +1 -1
  100. package/dist/m/{c-OYHI67B6.js → c-YYGUHSZR.js} +1 -1
  101. package/dist/m/{c-YYMZWQLR.js → c-Z2OZFX3N.js} +1 -1
  102. package/dist/m/{c-AT7GLQGV.js → c-ZEA3DCG3.js} +1 -1
  103. package/dist/m/{c-75N3KG35.js → c-ZJG6C2WL.js} +1 -1
  104. package/dist/m/{c-FVPNX2GO.js → c-ZORVIXUR.js} +1 -1
  105. package/dist/m/{c-FV46ZKGX.js → c-ZPI7M5U5.js} +1 -1
  106. package/dist/m/core/{admin-attrs-5UGMYCKW.js → admin-attrs-ZI6K6UGM.js} +1 -1
  107. package/dist/m/core/{autosave-4P66VXX7.js → autosave-BSM2ABJL.js} +1 -1
  108. package/dist/m/core/{conflict-notice-BAR23OWH.js → conflict-notice-7EQLDYPA.js} +1 -1
  109. package/dist/m/core/draft-mode-M5XNYBMY.js +1 -0
  110. package/dist/m/core/{host-permission-3HE4CFD6.js → host-permission-5BYP24GC.js} +1 -1
  111. package/dist/m/core/{is-edit-mode-GK7IFFMT.js → is-edit-mode-73OXKK5H.js} +1 -1
  112. package/dist/m/core/{persist-AIJGTKKI.js → persist-2SZO3PCE.js} +1 -1
  113. package/dist/m/core/{recovery-LPB6X72P.js → recovery-VZF7RJZF.js} +1 -1
  114. package/dist/m/core/{save-FV4ZCKBI.js → save-K6Q47J2X.js} +1 -1
  115. package/dist/m/core/{save-core-K7XFAWQ4.js → save-core-U3Z44XBO.js} +1 -1
  116. package/dist/m/core/{site-edits-TEQORBJU.js → site-edits-CFMF6GHD.js} +1 -1
  117. package/dist/m/core/{snapshot-FJP5IJL3.js → snapshot-PWCHYFL6.js} +1 -1
  118. package/dist/m/core/unsaved-warning-2WRZLJH5.js +1 -0
  119. package/dist/m/events/{index-B6TGDYMG.js → index-YKQIBZE5.js} +1 -1
  120. package/dist/m/internals/index-FSLC4M7J.js +1 -0
  121. package/dist/m/lib/{cache-bust-NH7VBWHO.js → cache-bust-BL4KUQAJ.js} +1 -1
  122. package/dist/m/loader-RC54UV7H.js +1 -0
  123. package/dist/m/manifest-3B84C829.js +1 -0
  124. package/dist/m/manifest-edit-1CB79AD4.js +1 -0
  125. package/dist/m/manifest.json +1215 -1129
  126. package/dist/m/options/{options-55LQHSJ4.js → options-LKIZ7YTG.js} +1 -1
  127. package/dist/m/page/{editor-KAZDJNND.js → editor-PKSPJ2XJ.js} +2 -2
  128. package/dist/m/plugins/{ai-edit-CUKQQWJX.js → ai-edit-3LG6MGS3.js} +1 -1
  129. package/dist/m/plugins/{cms-JANMGPHM.js → cms-T2HLI7JG.js} +16 -16
  130. package/dist/m/plugins/{demo-JIR7DXJA.js → demo-LMCMBILC.js} +1 -1
  131. package/dist/m/plugins/{derive-QVI3LI3A.js → derive-7DR5TUDH.js} +1 -1
  132. package/dist/m/plugins/{indicator-DAKZGAWI.js → indicator-CTKX4EY7.js} +1 -1
  133. package/dist/m/plugins/{live-UAJGWRNP.js → live-IFLL6YN5.js} +1 -1
  134. package/dist/m/plugins/{menu-BFJ644YX.js → menu-YJZ3JWBC.js} +1 -1
  135. package/dist/m/plugins/page-GTDPYGE4.js +2 -0
  136. package/dist/m/plugins/{page-view-OYN7Z5TS.js → page-view-NMCCU6MF.js} +1 -1
  137. package/dist/m/plugins/{people-VBDR5Y22.js → people-6WIWCZEG.js} +1 -1
  138. package/dist/m/plugins/{richclay-CBLZRFB4.js → richclay-L3BZMX4I.js} +3 -3
  139. package/dist/m/plugins/sortable-365SRRL3.js +1 -0
  140. package/dist/m/plugins/{source-ZXDD7F6X.js → source-7LSGOV46.js} +1 -1
  141. package/dist/m/plugins/{undo-5JI5G7CQ.js → undo-UES4KS7B.js} +1 -1
  142. package/dist/m/plugins/{upgrade-6B6QS3NR.js → upgrade-MMPZUCDM.js} +1 -1
  143. package/dist/m/plugins/{upload-DNJNW6H3.js → upload-NZET3DNQ.js} +1 -1
  144. package/dist/m/plugins/visitor-drafts-V5YB7XDH.js +20 -0
  145. package/dist/m/plugins/{visitor-drafts-owner-VIAZC3CF.js → visitor-drafts-owner-TLECTYWS.js} +1 -1
  146. package/dist/m/plugins/{visitor-menu-ZHKWIKKY.js → visitor-menu-QDV2MYJN.js} +1 -1
  147. package/dist/m/plugins/wire-3YGUO3GE.js +1 -0
  148. package/dist/m/{reader-core-F6RY3V64.js → reader-core-VR7EL4WV.js} +2 -2
  149. package/dist/m/sync/live-sync-XMXXZS3G.js +1 -0
  150. package/dist/m/vendor/sap-core.vendor-JANUQULT.js +7 -0
  151. package/dist/offline-manifest.json +724 -664
  152. package/docs/guide.md +1 -0
  153. package/entries/clay-data.js +1 -1
  154. package/entries/sap.js +6 -5
  155. package/package.json +2 -2
  156. package/src/core/draft-mode.js +11 -0
  157. package/src/core/save-core.js +16 -17
  158. package/src/core/save.js +1 -1
  159. package/src/core/unsaved-warning.js +2 -2
  160. package/src/lib/dirty-gate.js +19 -0
  161. package/src/lib/idb-error-code.js +20 -0
  162. package/src/loader.js +2 -0
  163. package/src/plugins/menu/visitor.js +33 -1
  164. package/src/plugins/page.js +19 -5
  165. package/src/plugins/sortable.js +7 -0
  166. package/src/plugins/visitor-drafts/commit.js +350 -0
  167. package/src/plugins/visitor-drafts/idb.js +227 -0
  168. package/src/plugins/visitor-drafts/prompt.js +23 -3
  169. package/src/plugins/visitor-drafts/recovery-menu.js +118 -0
  170. package/src/plugins/visitor-drafts/recovery.js +64 -0
  171. package/src/plugins/visitor-drafts/session.js +393 -0
  172. package/src/plugins/visitor-drafts/store.js +247 -27
  173. package/src/plugins/visitor-drafts.js +177 -28
  174. package/src/sync/live-sync.js +1 -1
  175. package/src/sync/wire-profile.js +9 -4
  176. package/src/vendor/hyper-html-api-data.vendor.js +1 -1
  177. package/src/vendor/hyper-html-api-upgrade.vendor.js +2 -2
  178. package/src/vendor/hypercms.vendor.js +16 -16
  179. package/src/vendor/richclay.vendor.js +1 -1
  180. package/src/vendor/sap-core.vendor.js +6 -5
  181. package/src/vendor/sap-ownership.vendor.js +181 -11
  182. package/tool-generation/system.md +1 -1
  183. package/dist/m/attrs/save-freeze-JZHKRQLR.js +0 -1
  184. package/dist/m/c-234RSEIW.js +0 -1
  185. package/dist/m/c-2YIJ6ZA6.js +0 -1
  186. package/dist/m/c-H2H7TI6O.js +0 -1
  187. package/dist/m/c-HSNGLIFB.js +0 -3
  188. package/dist/m/c-JMDKPBMC.js +0 -4
  189. package/dist/m/c-LO4C4J77.js +0 -1
  190. package/dist/m/c-N7JPUPGC.js +0 -1
  191. package/dist/m/c-NEXFVJIT.js +0 -1
  192. package/dist/m/c-R23UHMXG.js +0 -1
  193. package/dist/m/c-T527QHOB.js +0 -1
  194. package/dist/m/c-V2U3F4QX.js +0 -1
  195. package/dist/m/c-VG5XIN4T.js +0 -1
  196. package/dist/m/c-YINHPF4V.js +0 -1
  197. package/dist/m/core/draft-mode-WSQAT67S.js +0 -1
  198. package/dist/m/core/unsaved-warning-FF63QGKI.js +0 -1
  199. package/dist/m/internals/index-AX4CG7B2.js +0 -1
  200. package/dist/m/loader-5IA5OJ3J.js +0 -1
  201. package/dist/m/manifest-98258645.js +0 -1
  202. package/dist/m/manifest-edit-ABF56000.js +0 -1
  203. package/dist/m/plugins/page-ZBIYHGK4.js +0 -2
  204. package/dist/m/plugins/sortable-HDOQ6GAC.js +0 -1
  205. package/dist/m/plugins/visitor-drafts-A5FDQ2G7.js +0 -20
  206. package/dist/m/plugins/wire-XOT7XKJL.js +0 -1
  207. package/dist/m/sync/live-sync-M2PP2IWY.js +0 -1
  208. package/dist/m/vendor/sap-core.vendor-OA5SKL7Q.js +0 -6
  209. /package/dist/m/plugins/{richclay-CBLZRFB4.js.LEGAL.txt → richclay-L3BZMX4I.js.LEGAL.txt} +0 -0
@@ -1,4 +1,4 @@
1
- import{a as Et,b as Jn,c as Ro,f as Yo}from"./c-A4L7APIU.js";import{a as $o}from"./c-WNOLMHI2.js";import{a as Bn,b as Dn,e as zn,f as it,g as Mt}from"./c-LS7IVQVW.js";import{a as Po}from"./c-NEQRFC4O.js";import{a as Ct,b as It,c as At,d as ze,e as Ye,f as Kn,g as Tt,h as Hn,i as qn,j as Pt,l as Rt}from"./c-NICICT4P.js";import{b as Co,c as Io}from"./c-LTSPHVAK.js";import"./c-IW6GGOU2.js";import"./c-HAWFNBYG.js";import{a as Re,b as _n,p as Nn,q as Fn,u as Ao,v as To}from"./c-CV4T65JE.js";import{A as An,B as Be,C as ot,D as Tn,E as Pn,F as De,G as Rn,H as Pe,I as rt,J as Yn,K as St,L as $n,M as st,N as jn,O as ue,a as Le,b as kt,c as wn,d as xn,f as Sn,j as On,m as Eo,p as Mn,q as En,r as Cn,s as In,t as vt,v as wt,x as xt,z as Oe}from"./c-GO635CRU.js";import{a as me,b as hn,d as Me,e as _e,g as xe,h as Ne,i as ye,j as Ee,k as gn,l as Fe,m as nt,n as be,o as bn,p as kn,q as Se,r as Ce,u as yn,v as vn,w as yt}from"./c-V2V5FKXX.js";import"./c-DD26VXAP.js";import"./c-CTGRDT6E.js";import"./c-7K4SCQB7.js";import{f as tn,g as nn,i as Qe,j as Ze,k as dt,n as pt,o as et,p as on,s as mt,t as rn,u as Ae,v as de,w as Te,x as ht,y as sn}from"./c-WMRJKQ2V.js";import{g as Ln,p as Ot}from"./c-ZRGEN6QQ.js";import{E as gt,H as bt,I as dn,d as fe,fa as je,g as an,i as fn,ia as pn,ja as mn,na as tt,w as un}from"./c-OH2FPYSY.js";import{b as Vt}from"./c-QY7F6EN6.js";import"./c-FSQXFG5T.js";import{b as pe,c as ln,e as cn}from"./c-RETTCOWO.js";import{a as Wt,b as Ut,d as ft}from"./c-WCG6AKA7.js";import{a as Zt}from"./c-TCCA5BZN.js";import"./c-3LDGIBMN.js";import{c as en}from"./c-57XDY6HC.js";import"./c-YK2L436K.js";import{a as Qt,b as ut}from"./c-QTTJYJMA.js";import"./c-TWCXBWS3.js";import{e as Gt,f as Xt}from"./c-2YIJ6ZA6.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-LO4C4J77.js";import"./c-FV46ZKGX.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-LA2BW7UY.js";import"./c-HSNGLIFB.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-RXTPKCMC.js";import"./c-RBPZNU2D.js";import"./c-IJUK2GPW.js";import"./c-DLBX4JCJ.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-PWJSJEJU.js";import"./c-XQXZAO7N.js";import"./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";var Yt=new Set(["paragraph","heading","list_item","callout","quote","code_block","toggle"]),Je=(e,o)=>je(e)===je(o);function $t(e,o){let n=o.createElement("article");return n.setAttribute("data-blockeditor",""),n.innerHTML=mn([{id:e.id,t:"paragraph",c:e.c??"",...e.m?{m:e.m}:{}}],{clean:pn(o)}),n}function jo(e,o){let n=new Map(e.map((f,u)=>[f.id,u])),r=new Set(o.map(f=>f.id)),t=new Map,s=0;return o.map(f=>{let u=n.get(f.id);if(u!==void 0)return s=u+1,f;let p={c:f.c??"",m:f.m??null};for(let b=s;b<e.length;b++){let C=e[b];if(!(r.has(C.id)||C.t!==f.t||!Je({c:C.c??"",m:C.m??null},p)))return r.add(C.id),s=b+1,t.set(f.id,C.id),{...f,id:C.id}}return f}).map(f=>t.has(f.parent)?{...f,parent:t.get(f.parent)}:f)}function jt(e,o,n,{doc:r,merge3:t,mergeJson:s}){let a=[],f=jo(e,n),u=new Map(e.map(c=>[c.id,c])),p=new Map(o.map(c=>[c.id,c])),b=new Map(f.map(c=>[c.id,c])),C=o.map(c=>({...c})),M=f.map(c=>({...c})),h=new Map(C.map(c=>[c.id,c])),w=new Map(M.map(c=>[c.id,c]));for(let[c,E]of u){let i=p.get(c),g=b.get(c);if(!i||!g||!Yt.has(E.t)||!Yt.has(i.t)||!Yt.has(g.t))continue;let A={c:E.c??"",m:E.m??null},z={c:i.c??"",m:i.m??null},W={c:g.c??"",m:g.m??null};if(Je(z,A)||Je(W,A)||Je(z,W))continue;if(E.t==="code_block"){for(let P of[h.get(c),w.get(c)])P.c=g.c??"",g.m?P.m=g.m:delete P.m;a.push({id:c,kind:"text",local:i.c??"",remote:g.c??""});continue}let T=t($t(E,r),$t(i,r),$t(g,r));for(let P of T.conflicts)a.push({id:c,kind:"text",local:P.local?.textContent??null,remote:P.remote?.textContent??null});let[U]=tt(T.root,{seed:"",known:new Map});for(let P of[h.get(c),w.get(c)])P.c=U.c,U.m?P.m=U.m:delete P.m}let y=o.map(c=>c.id);for(let[c,E]of u){let i=h.get(c);if(!i||b.has(c)||Je(p.get(c),E))continue;let g=y.indexOf(c)-1;for(;g>=0&&!w.has(y[g]);)g--;let A=g<0?0:M.findIndex(z=>z.id===y[g])+1;M.splice(A,0,{...i}),w.set(c,M[A]),a.push({id:c,kind:"kept-edit"})}let N=s(e,C,M,{onConflict:c=>a.push({kind:"field",path:c.path,local:c.local,remote:c.remote,resolved:c.resolved})}),B=new Set(N.map(c=>c.id)),v=c=>(p.get(c)??u.get(c)??b.get(c))?.parent??null,L=N.map(c=>{let E=c.parent??null;for(;E&&!B.has(E);)E=v(E);return E===(c.parent??null)?c:{...c,parent:E}}),Y=new Map(L.map(c=>[c.id,c.parent??null])),$=c=>{let E=new Set([c]);for(let i=Y.get(c);i;i=Y.get(i)){if(E.has(i))return!0;E.add(i)}return!1};for(let c of L)if($(c.id)){for(let E of[p.get(c.id)?.parent,u.get(c.id)?.parent,null])if(Y.set(c.id,E&&B.has(E)?E:null),!$(c.id))break}return{items:L.map(c=>(c.parent??null)===Y.get(c.id)?c:{...c,parent:Y.get(c.id)}),conflicts:a}}var _o=e=>{try{return Zt(e)}catch{return null}},$e={ok:!0,outcome:"unchanged"},Ke={ok:!1,outcome:"disposed",reason:"adoption-disposed"},He={ok:!1,outcome:"refused",reason:"adoption-refused"},No={ok:!1,outcome:"refused",reason:"adoption-timeout"},Fo={ok:!1,outcome:"error",reason:"adoption-error"},Lo={ok:!0,outcome:"writer-adopts"},Vn=e=>({ok:!0,outcome:"adopted",counts:e}),Wn=1e4;function Bo(e){let o=e.querySelector(Et);return o?{article:o.cloneNode(!0),tags:Jn(e).map(n=>_o(n.textContent))}:null}function Un(e){return new Promise(o=>{if(!e.composing)return o();e.dom.addEventListener("compositionend",()=>setTimeout(()=>o(Un(e)),0),{once:!0})})}function Do({view:e,source:o=null,ready:n=Promise.resolve(),isAdopter:r=()=>!0,idle:t=()=>Un(e),requestCheckpoint:s=()=>{},notice:a=()=>{},snapshot:f=()=>null,mergeTagless:u=!1,seeded:p=!1,writerReady:b=()=>Promise.resolve(),adopted:C=()=>{},hold:M=Gt,release:h=Xt,holdMs:w=Wn,doc:y=document}){let N=o?o.article.innerHTML:null,B=o?o.article:null,v=new Map,L=P=>{let I=P.getAttribute("data-rev");if(!I)return;let K=v.get(I)??[];v.delete(I),v.set(I,K),K.push(P),K.length>10&&K.shift(),v.size>20&&v.delete(v.keys().next().value)};B&&L(B);let Y=Promise.resolve(),$=!1,x,c=new Promise(P=>x=P);async function E(){let P,I=new Promise(K=>{P=setTimeout(()=>K("timeout"),w)});try{return await Promise.race([Promise.resolve(n).then(()=>t()).then(()=>"ready"),c.then(()=>"disposed"),I])}finally{clearTimeout(P)}}function i(P,I,K,j){let{HyperMorph:Q}=Qt(),le=jt(K,I,j,{doc:y,merge3:Q.merge3,mergeJson:Q.mergeJson}),ee=le.conflicts.filter(D=>D.kind==="text"||D.kind==="field"),m=ee.length?f():null,l=Dn(P,le.items,I),k=l&&zn(e.state,l);if(!k)return null;e.dispatch(k),e.dispatch(cn.closeHistory(e.state.tr));let F={edited:l.edited.size,created:l.created.size,deleted:l.deleted.length,moved:l.reordered},{displaced:R}=k.getMeta(Bn);return Object.keys(R).length&&(F.displaced=R),ee.length&&(F.conflicts=ee),m&&(F.copy=m),F}async function g(P){if(u&&!P.tags.length)return A(P);let I=Mt(P.article,P.tags);if(I.kind==="unbased"&&console.warn("page: the article and its data changed together; kept the data"),I.kind!=="adopt")return $e;if(!r())return Lo;M();try{if(await ut(),$)return Ke;if(!r())return He;let K=await E();if(K==="timeout"&&console.warn("page: gave up waiting for the editor; the hand edit was not adopted"),K==="disposed"||$)return Ke;if(K!=="ready")return No;if(!r())return He;let j=gt(e.state.doc),Q=i(j,it(j,y),I.baseItems,I.parsed);return Q?(C(I.A),Vn(Q)):$e}finally{h()}}async function A(P){let I=P.article.getAttribute("data-rev"),K=I&&v.get(I)||[],j=K.at(-1)??B;if(K.slice(0,-1).some(Q=>Q.innerHTML===P.article.innerHTML)||(L(P.article),B=P.article,!j)||j.outerHTML===P.article.outerHTML)return $e;M();try{if(await ut(),$)return Ke;if(!r())return He;if(await b(),$)return Ke;if(!r())return He;if(await E()==="disposed"||$)return Ke;if(!r())return He;let le=gt(e.state.doc),ee=it(le,y),m=new Map(ee.map(F=>[F.id,F])),l=F=>tt(F,{seed:F.getAttribute("data-rev")??"",known:m}),k=i(le,ee,l(j),l(P.article));return k?Vn(k):$e}finally{h()}}async function z(P){try{return await g(P)}catch(I){return console.error("page: adoption failed",I),Fo}}let W=null;function T(P,I=!1){return Y=Y.then(()=>z(P)).then(K=>(I&&(W=K),!K.ok||K.outcome!=="adopted"||(s(),a(K.counts),y.dispatchEvent(new CustomEvent("clay:blockeditor-adopted",{detail:K.counts}))),K)),Y}function U(P){let I=P.detail?.html;if($||typeof I!="string")return;let K=Bo(new DOMParser().parseFromString(I,"text/html"));!K||K.article.innerHTML===N||(N=K.article.innerHTML,T(K))}return y.addEventListener("clay:sync-applied",U),o&&!p&&T(o,!0),{idle:async()=>(await Y,W),saved(P){if(!u||typeof P!="string")return;let I=new DOMParser().parseFromString(P,"text/html").querySelector(Et);I&&(L(I),B=I)},dispose(){$=!0,x(),y.removeEventListener("clay:sync-applied",U)}}}var Gn='["text-delete",',Xn=(e,o)=>o instanceof rn&&o._item&&o._item.parent===e.attrs&&typeof o._item.parentSub=="string"?o._item.parentSub:null,Qn=e=>e==="t"||e==="parent",_t=e=>e.content instanceof de&&e.content.embed.b!==void 0,zo=e=>e.content instanceof ht||e.content instanceof Te||e.content instanceof de&&e.content.embed.b===void 0,eo=e=>{let o=new Map;for(let n of e.stops)(o.get(n.client)??o.set(n.client,[]).get(n.client)).push(n);return o},to=(e,o)=>{let n=o.get(e.id.client);if(!n)return!1;let r=e.id.clock,t=r+e.length;return n.some(s=>s.clock<t&&r<s.clock+s.len)},Jo=(e,o)=>{for(let n=e.left;n;n=n.left){if(n.deleted){if(to(n,o))return null;continue}if(_t(n))return n}return null};function no(e,o,n){let r=eo(n),t=new Set,s=new Set,a=o.changed.get(e.tableFields)??new Set;for(let[h,w]of o.changed){if(h===e.flow)continue;if(h===e.attrs){if(!o.local)return null;for(let N of w){let B=e.attrs.get(N);if(!(B instanceof Ae)||B._item.left||B._item.id.clock<(o.beforeState.get(B._item.id.client)??0))return null;s.add(N)}if(s.size>1)return null;continue}if(h===e.tableFields){for(let N of w){let B=e.tableFields.has(N)?En(N,e.tableFields.get(N)):null;if(B===null)return null;t.add(B)}continue}let y=Xn(e,h);if(y!==null){for(let N of w)if(Qn(N))return null;t.add(y);continue}if(h!==e.gone)return null;for(let N of w)if(typeof N!="string"||!N.startsWith(Gn))return null}let f=e.ydoc.store,u=null,p=null,b=!1,C=h=>{if(!(h instanceof sn))return!1;if(h.parent===e.gone)return typeof h.parentSub=="string"&&h.parentSub.startsWith(Gn);if(h.parent===e.tableFields)return a.has(h.parentSub);if(h.parent===e.attrs)return s.has(h.parentSub);if(h.parent!==e.flow){let y=Xn(e,h.parent);return y!==null&&(s.has(y)||t.has(y)&&!Qn(h.parentSub))}if(_t(h)){if(h.deleted||!s.has(h.content.embed.b))return!1;p=h}else if(!zo(h))return!1;let w=Jo(h,r);return!w||u&&w!==u?!1:(u=w,h.content instanceof Te&&(b=!0),!0)};for(let[h,w]of o.afterState)for(let y=o.beforeState.get(h)??0;y<w;){let N=et(f,{client:h,clock:y});if(!C(N))return null;y=N.id.clock+N.length}let M=!1;for(let[h,w]of o.deleteSet.clients)for(let{clock:y,len:N}of w)for(let B=y;B<y+N;){let v=et(f,{client:h,clock:B});if(!C(v))return null;M=!0,B=v.id.clock+v.length}return s.size&&!p?null:u||t.size?{marker:u,split:p,deleted:M,formats:b,fields:t,remote:!o.local}:null}var Ko=e=>{for(let o in e)return{...e};return null};function oo(e,o,n,r=null){let t=r?.formats??!0,s=r?.split??null,a=o.visible,f=-1,u=0;for(let i=0;i<a.length;i++){let g=a[i];if(g.brk&&g.brk.client===n.id.client&&g.brk.clock===n.id.clock){f=i;break}u+=g.len}if(f<0)return null;let p=a[f];if(p.implicit||p.atom||p.opaque||p.recovered||p.hide)return null;let b=p.runs.findIndex(i=>i.hole!==void 0);if(b>=0&&t||p.items&&o.copies.has(p.baseId))return null;let C=eo(o),M={...p.fmtIn??{}},h=null,w={...p,runs:[],len:1};p.items&&(w.items=[]);let y=w,N=!1,B=Ye(o.holes,u),v=B+1;for(let i=n.right;i;i=i.right){if(i.deleted){if(to(i,C))return null;continue}if(_t(i)&&(i!==s||y!==w)){N=!0;break}let g=v;i.countable&&(v+=i.length);let A=i.content;if(i===s){let z=A.embed.b,W=e.attrs.get(z)?.get("t")||"paragraph";if(!Object.hasOwn(fe.nodes,W)||!fe.nodes[W].isTextblock)return null;let T=Ko(M);w.fmtOut=T,y={kind:"b",id:z,baseId:z,brk:{client:i.id.client,clock:i.id.clock},implicit:!1,runs:[],len:1,atom:!1,items:null,fmtIn:T,fmtOut:null,t:W,opaque:!1},h=null;continue}if(A instanceof Te){A.value===null?delete M[A.key]:M[A.key]=A.value,h=null;continue}if(A instanceof de){y.runs.push({br:!0}),y.items&&y.items.push({at:g,id:Ee(i.id),client:i.id.client,clock:i.id.clock,length:i.length,kind:"br",text:null,blockId:null,raw:{...M}}),y.len+=1;continue}if(A instanceof ht){if(!h){let z=vn(M,y.t);h={marks:z,mk:yn(z)}}y.runs.push({text:A.str,marks:h.marks,mk:h.mk}),y.items&&y.items.push({at:g,id:Ee(i.id),client:i.id.client,clock:i.id.clock,length:i.length,kind:"text",text:A.str,blockId:null,raw:{...M}}),y.len+=A.str.length}else if(i.countable)return null}let L=p.len;if(b<0){if(!ye(M,p.fmtOut??{}))return null}else{if(!N||y.t!==p.t)return null;L=1;for(let i=0;i<b;i++)L+=p.runs[i].br?1:p.runs[i].text.length}let Y=y===w?[w]:[w,y],$=Y.reduce((i,g)=>i+g.len,0)-L,x=B+L,c=i=>i.at>=x?{...i,at:i.at+$}:i;y.fmtOut=p.fmtOut,b>=0&&(y.runs=y.runs.concat(p.runs.slice(b)),y.len+=p.len-L,y.items&&(y.items=y.items.concat(p.items.filter(i=>i.at>=x).map(c))));let E={...o,visible:a.slice(),tokens:o.tokens+$};if(E.visible.splice(f,1,...Y),$){let i=u+L;E.holes=o.holes.map(g=>g.at>=i?{at:g.at+$,len:g.len}:g),E.hidden=o.hidden.map(g=>g.at>=x?{...g,at:g.at+$,items:g.items.map(c)}:g);for(let g=f+Y.length;g<E.visible.length;g+=1){let A=E.visible[g];A.items?.length&&(E.visible[g]={...A,items:A.items.map(c)})}}return E}var Ho=e=>e.br?`
1
+ import{a as Et,b as Jn,c as Ro,f as Yo}from"./c-4AE2A2LK.js";import{a as $o}from"./c-WNOLMHI2.js";import{a as Bn,b as Dn,e as zn,f as it,g as Mt}from"./c-LS7IVQVW.js";import{a as Po}from"./c-NEQRFC4O.js";import{a as Ct,b as It,c as At,d as ze,e as Ye,f as Kn,g as Tt,h as Hn,i as qn,j as Pt,l as Rt}from"./c-NICICT4P.js";import{b as Co,c as Io}from"./c-OBMZASYQ.js";import"./c-IW6GGOU2.js";import"./c-HAWFNBYG.js";import{a as Re,b as _n,p as Nn,q as Fn,u as Ao,v as To}from"./c-JWW6BHWD.js";import{A as An,B as Be,C as ot,D as Tn,E as Pn,F as De,G as Rn,H as Pe,I as rt,J as Yn,K as St,L as $n,M as st,N as jn,O as ue,a as Le,b as kt,c as wn,d as xn,f as Sn,j as On,m as Eo,p as Mn,q as En,r as Cn,s as In,t as vt,v as wt,x as xt,z as Oe}from"./c-GO635CRU.js";import{a as me,b as hn,d as Me,e as _e,g as xe,h as Ne,i as ye,j as Ee,k as gn,l as Fe,m as nt,n as be,o as bn,p as kn,q as Se,r as Ce,u as yn,v as vn,w as yt}from"./c-V2V5FKXX.js";import"./c-DT7E76Z2.js";import"./c-C6YZNU6E.js";import"./c-7K4SCQB7.js";import{f as tn,g as nn,i as Qe,j as Ze,k as dt,n as pt,o as et,p as on,s as mt,t as rn,u as Ae,v as de,w as Te,x as ht,y as sn}from"./c-WMRJKQ2V.js";import{g as Ln,p as Ot}from"./c-AI3H6ETU.js";import{E as gt,H as bt,I as dn,d as fe,fa as je,g as an,i as fn,ia as pn,ja as mn,na as tt,w as un}from"./c-OH2FPYSY.js";import{b as Vt}from"./c-QY7F6EN6.js";import"./c-FSQXFG5T.js";import{b as pe,c as ln,e as cn}from"./c-RETTCOWO.js";import{a as Wt,b as Ut,d as ft}from"./c-WCG6AKA7.js";import{a as Zt}from"./c-TCCA5BZN.js";import"./c-3LDGIBMN.js";import{c as en}from"./c-57XDY6HC.js";import"./c-MV7TEUTD.js";import{a as Qt,b as ut}from"./c-QTTJYJMA.js";import"./c-QCDVDZIR.js";import{e as Gt,f as Xt}from"./c-VMXCX52Q.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-P73XPAOA.js";import"./c-ZPI7M5U5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-MZCOGNZL.js";import"./c-MFB74XVN.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-KU3PX7LL.js";import"./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-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";var Yt=new Set(["paragraph","heading","list_item","callout","quote","code_block","toggle"]),Je=(e,o)=>je(e)===je(o);function $t(e,o){let n=o.createElement("article");return n.setAttribute("data-blockeditor",""),n.innerHTML=mn([{id:e.id,t:"paragraph",c:e.c??"",...e.m?{m:e.m}:{}}],{clean:pn(o)}),n}function jo(e,o){let n=new Map(e.map((f,u)=>[f.id,u])),r=new Set(o.map(f=>f.id)),t=new Map,s=0;return o.map(f=>{let u=n.get(f.id);if(u!==void 0)return s=u+1,f;let p={c:f.c??"",m:f.m??null};for(let b=s;b<e.length;b++){let C=e[b];if(!(r.has(C.id)||C.t!==f.t||!Je({c:C.c??"",m:C.m??null},p)))return r.add(C.id),s=b+1,t.set(f.id,C.id),{...f,id:C.id}}return f}).map(f=>t.has(f.parent)?{...f,parent:t.get(f.parent)}:f)}function jt(e,o,n,{doc:r,merge3:t,mergeJson:s}){let a=[],f=jo(e,n),u=new Map(e.map(c=>[c.id,c])),p=new Map(o.map(c=>[c.id,c])),b=new Map(f.map(c=>[c.id,c])),C=o.map(c=>({...c})),M=f.map(c=>({...c})),h=new Map(C.map(c=>[c.id,c])),w=new Map(M.map(c=>[c.id,c]));for(let[c,E]of u){let i=p.get(c),g=b.get(c);if(!i||!g||!Yt.has(E.t)||!Yt.has(i.t)||!Yt.has(g.t))continue;let A={c:E.c??"",m:E.m??null},z={c:i.c??"",m:i.m??null},W={c:g.c??"",m:g.m??null};if(Je(z,A)||Je(W,A)||Je(z,W))continue;if(E.t==="code_block"){for(let P of[h.get(c),w.get(c)])P.c=g.c??"",g.m?P.m=g.m:delete P.m;a.push({id:c,kind:"text",local:i.c??"",remote:g.c??""});continue}let T=t($t(E,r),$t(i,r),$t(g,r));for(let P of T.conflicts)a.push({id:c,kind:"text",local:P.local?.textContent??null,remote:P.remote?.textContent??null});let[U]=tt(T.root,{seed:"",known:new Map});for(let P of[h.get(c),w.get(c)])P.c=U.c,U.m?P.m=U.m:delete P.m}let y=o.map(c=>c.id);for(let[c,E]of u){let i=h.get(c);if(!i||b.has(c)||Je(p.get(c),E))continue;let g=y.indexOf(c)-1;for(;g>=0&&!w.has(y[g]);)g--;let A=g<0?0:M.findIndex(z=>z.id===y[g])+1;M.splice(A,0,{...i}),w.set(c,M[A]),a.push({id:c,kind:"kept-edit"})}let N=s(e,C,M,{onConflict:c=>a.push({kind:"field",path:c.path,local:c.local,remote:c.remote,resolved:c.resolved})}),B=new Set(N.map(c=>c.id)),v=c=>(p.get(c)??u.get(c)??b.get(c))?.parent??null,L=N.map(c=>{let E=c.parent??null;for(;E&&!B.has(E);)E=v(E);return E===(c.parent??null)?c:{...c,parent:E}}),Y=new Map(L.map(c=>[c.id,c.parent??null])),$=c=>{let E=new Set([c]);for(let i=Y.get(c);i;i=Y.get(i)){if(E.has(i))return!0;E.add(i)}return!1};for(let c of L)if($(c.id)){for(let E of[p.get(c.id)?.parent,u.get(c.id)?.parent,null])if(Y.set(c.id,E&&B.has(E)?E:null),!$(c.id))break}return{items:L.map(c=>(c.parent??null)===Y.get(c.id)?c:{...c,parent:Y.get(c.id)}),conflicts:a}}var _o=e=>{try{return Zt(e)}catch{return null}},$e={ok:!0,outcome:"unchanged"},Ke={ok:!1,outcome:"disposed",reason:"adoption-disposed"},He={ok:!1,outcome:"refused",reason:"adoption-refused"},No={ok:!1,outcome:"refused",reason:"adoption-timeout"},Fo={ok:!1,outcome:"error",reason:"adoption-error"},Lo={ok:!0,outcome:"writer-adopts"},Vn=e=>({ok:!0,outcome:"adopted",counts:e}),Wn=1e4;function Bo(e){let o=e.querySelector(Et);return o?{article:o.cloneNode(!0),tags:Jn(e).map(n=>_o(n.textContent))}:null}function Un(e){return new Promise(o=>{if(!e.composing)return o();e.dom.addEventListener("compositionend",()=>setTimeout(()=>o(Un(e)),0),{once:!0})})}function Do({view:e,source:o=null,ready:n=Promise.resolve(),isAdopter:r=()=>!0,idle:t=()=>Un(e),requestCheckpoint:s=()=>{},notice:a=()=>{},snapshot:f=()=>null,mergeTagless:u=!1,seeded:p=!1,writerReady:b=()=>Promise.resolve(),adopted:C=()=>{},hold:M=Gt,release:h=Xt,holdMs:w=Wn,doc:y=document}){let N=o?o.article.innerHTML:null,B=o?o.article:null,v=new Map,L=P=>{let I=P.getAttribute("data-rev");if(!I)return;let K=v.get(I)??[];v.delete(I),v.set(I,K),K.push(P),K.length>10&&K.shift(),v.size>20&&v.delete(v.keys().next().value)};B&&L(B);let Y=Promise.resolve(),$=!1,x,c=new Promise(P=>x=P);async function E(){let P,I=new Promise(K=>{P=setTimeout(()=>K("timeout"),w)});try{return await Promise.race([Promise.resolve(n).then(()=>t()).then(()=>"ready"),c.then(()=>"disposed"),I])}finally{clearTimeout(P)}}function i(P,I,K,j){let{HyperMorph:Q}=Qt(),le=jt(K,I,j,{doc:y,merge3:Q.merge3,mergeJson:Q.mergeJson}),ee=le.conflicts.filter(D=>D.kind==="text"||D.kind==="field"),m=ee.length?f():null,l=Dn(P,le.items,I),k=l&&zn(e.state,l);if(!k)return null;e.dispatch(k),e.dispatch(cn.closeHistory(e.state.tr));let F={edited:l.edited.size,created:l.created.size,deleted:l.deleted.length,moved:l.reordered},{displaced:R}=k.getMeta(Bn);return Object.keys(R).length&&(F.displaced=R),ee.length&&(F.conflicts=ee),m&&(F.copy=m),F}async function g(P){if(u&&!P.tags.length)return A(P);let I=Mt(P.article,P.tags);if(I.kind==="unbased"&&console.warn("page: the article and its data changed together; kept the data"),I.kind!=="adopt")return $e;if(!r())return Lo;M();try{if(await ut(),$)return Ke;if(!r())return He;let K=await E();if(K==="timeout"&&console.warn("page: gave up waiting for the editor; the hand edit was not adopted"),K==="disposed"||$)return Ke;if(K!=="ready")return No;if(!r())return He;let j=gt(e.state.doc),Q=i(j,it(j,y),I.baseItems,I.parsed);return Q?(C(I.A),Vn(Q)):$e}finally{h()}}async function A(P){let I=P.article.getAttribute("data-rev"),K=I&&v.get(I)||[],j=K.at(-1)??B;if(K.slice(0,-1).some(Q=>Q.innerHTML===P.article.innerHTML)||(L(P.article),B=P.article,!j)||j.outerHTML===P.article.outerHTML)return $e;M();try{if(await ut(),$)return Ke;if(!r())return He;if(await b(),$)return Ke;if(!r())return He;if(await E()==="disposed"||$)return Ke;if(!r())return He;let le=gt(e.state.doc),ee=it(le,y),m=new Map(ee.map(F=>[F.id,F])),l=F=>tt(F,{seed:F.getAttribute("data-rev")??"",known:m}),k=i(le,ee,l(j),l(P.article));return k?Vn(k):$e}finally{h()}}async function z(P){try{return await g(P)}catch(I){return console.error("page: adoption failed",I),Fo}}let W=null;function T(P,I=!1){return Y=Y.then(()=>z(P)).then(K=>(I&&(W=K),!K.ok||K.outcome!=="adopted"||(s(),a(K.counts),y.dispatchEvent(new CustomEvent("clay:blockeditor-adopted",{detail:K.counts}))),K)),Y}function U(P){let I=P.detail?.html;if($||typeof I!="string")return;let K=Bo(new DOMParser().parseFromString(I,"text/html"));!K||K.article.innerHTML===N||(N=K.article.innerHTML,T(K))}return y.addEventListener("clay:sync-applied",U),o&&!p&&T(o,!0),{idle:async()=>(await Y,W),saved(P){if(!u||typeof P!="string")return;let I=new DOMParser().parseFromString(P,"text/html").querySelector(Et);I&&(L(I),B=I)},dispose(){$=!0,x(),y.removeEventListener("clay:sync-applied",U)}}}var Gn='["text-delete",',Xn=(e,o)=>o instanceof rn&&o._item&&o._item.parent===e.attrs&&typeof o._item.parentSub=="string"?o._item.parentSub:null,Qn=e=>e==="t"||e==="parent",_t=e=>e.content instanceof de&&e.content.embed.b!==void 0,zo=e=>e.content instanceof ht||e.content instanceof Te||e.content instanceof de&&e.content.embed.b===void 0,eo=e=>{let o=new Map;for(let n of e.stops)(o.get(n.client)??o.set(n.client,[]).get(n.client)).push(n);return o},to=(e,o)=>{let n=o.get(e.id.client);if(!n)return!1;let r=e.id.clock,t=r+e.length;return n.some(s=>s.clock<t&&r<s.clock+s.len)},Jo=(e,o)=>{for(let n=e.left;n;n=n.left){if(n.deleted){if(to(n,o))return null;continue}if(_t(n))return n}return null};function no(e,o,n){let r=eo(n),t=new Set,s=new Set,a=o.changed.get(e.tableFields)??new Set;for(let[h,w]of o.changed){if(h===e.flow)continue;if(h===e.attrs){if(!o.local)return null;for(let N of w){let B=e.attrs.get(N);if(!(B instanceof Ae)||B._item.left||B._item.id.clock<(o.beforeState.get(B._item.id.client)??0))return null;s.add(N)}if(s.size>1)return null;continue}if(h===e.tableFields){for(let N of w){let B=e.tableFields.has(N)?En(N,e.tableFields.get(N)):null;if(B===null)return null;t.add(B)}continue}let y=Xn(e,h);if(y!==null){for(let N of w)if(Qn(N))return null;t.add(y);continue}if(h!==e.gone)return null;for(let N of w)if(typeof N!="string"||!N.startsWith(Gn))return null}let f=e.ydoc.store,u=null,p=null,b=!1,C=h=>{if(!(h instanceof sn))return!1;if(h.parent===e.gone)return typeof h.parentSub=="string"&&h.parentSub.startsWith(Gn);if(h.parent===e.tableFields)return a.has(h.parentSub);if(h.parent===e.attrs)return s.has(h.parentSub);if(h.parent!==e.flow){let y=Xn(e,h.parent);return y!==null&&(s.has(y)||t.has(y)&&!Qn(h.parentSub))}if(_t(h)){if(h.deleted||!s.has(h.content.embed.b))return!1;p=h}else if(!zo(h))return!1;let w=Jo(h,r);return!w||u&&w!==u?!1:(u=w,h.content instanceof Te&&(b=!0),!0)};for(let[h,w]of o.afterState)for(let y=o.beforeState.get(h)??0;y<w;){let N=et(f,{client:h,clock:y});if(!C(N))return null;y=N.id.clock+N.length}let M=!1;for(let[h,w]of o.deleteSet.clients)for(let{clock:y,len:N}of w)for(let B=y;B<y+N;){let v=et(f,{client:h,clock:B});if(!C(v))return null;M=!0,B=v.id.clock+v.length}return s.size&&!p?null:u||t.size?{marker:u,split:p,deleted:M,formats:b,fields:t,remote:!o.local}:null}var Ko=e=>{for(let o in e)return{...e};return null};function oo(e,o,n,r=null){let t=r?.formats??!0,s=r?.split??null,a=o.visible,f=-1,u=0;for(let i=0;i<a.length;i++){let g=a[i];if(g.brk&&g.brk.client===n.id.client&&g.brk.clock===n.id.clock){f=i;break}u+=g.len}if(f<0)return null;let p=a[f];if(p.implicit||p.atom||p.opaque||p.recovered||p.hide)return null;let b=p.runs.findIndex(i=>i.hole!==void 0);if(b>=0&&t||p.items&&o.copies.has(p.baseId))return null;let C=eo(o),M={...p.fmtIn??{}},h=null,w={...p,runs:[],len:1};p.items&&(w.items=[]);let y=w,N=!1,B=Ye(o.holes,u),v=B+1;for(let i=n.right;i;i=i.right){if(i.deleted){if(to(i,C))return null;continue}if(_t(i)&&(i!==s||y!==w)){N=!0;break}let g=v;i.countable&&(v+=i.length);let A=i.content;if(i===s){let z=A.embed.b,W=e.attrs.get(z)?.get("t")||"paragraph";if(!Object.hasOwn(fe.nodes,W)||!fe.nodes[W].isTextblock)return null;let T=Ko(M);w.fmtOut=T,y={kind:"b",id:z,baseId:z,brk:{client:i.id.client,clock:i.id.clock},implicit:!1,runs:[],len:1,atom:!1,items:null,fmtIn:T,fmtOut:null,t:W,opaque:!1},h=null;continue}if(A instanceof Te){A.value===null?delete M[A.key]:M[A.key]=A.value,h=null;continue}if(A instanceof de){y.runs.push({br:!0}),y.items&&y.items.push({at:g,id:Ee(i.id),client:i.id.client,clock:i.id.clock,length:i.length,kind:"br",text:null,blockId:null,raw:{...M}}),y.len+=1;continue}if(A instanceof ht){if(!h){let z=vn(M,y.t);h={marks:z,mk:yn(z)}}y.runs.push({text:A.str,marks:h.marks,mk:h.mk}),y.items&&y.items.push({at:g,id:Ee(i.id),client:i.id.client,clock:i.id.clock,length:i.length,kind:"text",text:A.str,blockId:null,raw:{...M}}),y.len+=A.str.length}else if(i.countable)return null}let L=p.len;if(b<0){if(!ye(M,p.fmtOut??{}))return null}else{if(!N||y.t!==p.t)return null;L=1;for(let i=0;i<b;i++)L+=p.runs[i].br?1:p.runs[i].text.length}let Y=y===w?[w]:[w,y],$=Y.reduce((i,g)=>i+g.len,0)-L,x=B+L,c=i=>i.at>=x?{...i,at:i.at+$}:i;y.fmtOut=p.fmtOut,b>=0&&(y.runs=y.runs.concat(p.runs.slice(b)),y.len+=p.len-L,y.items&&(y.items=y.items.concat(p.items.filter(i=>i.at>=x).map(c))));let E={...o,visible:a.slice(),tokens:o.tokens+$};if(E.visible.splice(f,1,...Y),$){let i=u+L;E.holes=o.holes.map(g=>g.at>=i?{at:g.at+$,len:g.len}:g),E.hidden=o.hidden.map(g=>g.at>=x?{...g,at:g.at+$,items:g.items.map(c)}:g);for(let g=f+Y.length;g<E.visible.length;g+=1){let A=E.visible[g];A.items?.length&&(E.visible[g]={...A,items:A.items.map(c)})}}return E}var Ho=e=>e.br?`
2
2
  `:e.hole!==void 0?{hole:e.hole}:{text:e.text,mk:e.mk},qo=e=>{let o=[];for(let n of e.map(Ho)){let r=o[o.length-1];r&&typeof r=="object"&&typeof n=="object"&&r.text!==void 0&&n.text!==void 0&&r.mk===n.mk?o[o.length-1]={text:r.text+n.text,mk:n.mk}:o.push(n)}return o},Zn=(e,o)=>{let n=et(e.ydoc.store,{client:o.client,clock:o.clock});return{client:n.id.client,clock:n.id.clock,len:n.length}},Ve=(e,o)=>rt({...o,copies:[...o.copies],fences:o.fences.map(n=>Zn(e,n)),stops:o.stops.map(n=>Zn(e,n)),visible:o.visible.map(n=>({...n,runs:qo(n.runs)}))});var ro=e=>e===!0?{}:e,so=(e,o)=>ye(ro(e),ro(o));function co(e,o,n,r){let t=e.attrs.get(o);t||(t=new Ae,e.attrs.set(o,t));let s=fe.nodes[n];if(!s){t.get("t")!==n&&t.set("t",n);for(let[p,b]of Object.entries(r??{}))p==="t"||p==="pos"||ye(t.has(p)?t.get(p):void 0,b)||t.set(p,b);return}let a=n==="table"&&t.get("t")==="table"&&!St(o),f=n==="board"&&!St(o),u=a?Cn(e.tableFields,o,In(e,o)):f?wt(e.boardFields,o):null;t.get("t")!==n&&t.set("t",n);for(let p of xe(s)){if(a&&(p==="rows"||p==="cols")||f&&(p==="columns"||p==="cards"))continue;let b=t.has(p)?t.get(p):Ne(s,p);ye(b,r[p])||t.set(p,r[p])}a&&vt(e,o,u,r),f&&xt(e,o,u,r)}function io(e,o){let n=new Map,r=o;for(let t=e.flow._start;t&&r>0;t=t.right){if(t.deleted)continue;let s=t.content;s instanceof Te?s.value===null?n.delete(s.key):n.set(s.key,s.value):t.countable&&(r-=t.length)}return n}function Vo(e){let o=new Set;for(let[r,t]of e)Ce(r)&&t&&o.add(r.split("!")[0]);let n=[];for(let[r,t]of e)!Ce(r)&&t!==null&&t!==void 0&&!o.has(r)&&fe.marks[Se(r)]&&n.push([r,t]);return n}function ao(e){let o=new Set;for(let[r,t]of e)Ce(r)&&t&&o.add(r.split("!")[0]);let n=[];for(let[r,t]of e)!Ce(r)&&t!==null&&t!==void 0&&!o.has(r)&&!fe.marks[Se(r)]&&n.push([r,t]);return n}function fo(e,o={}){let n={},r=!1;for(let[t,s]of e)(Ce(t)||fe.marks[Se(t)])&&(n[t]=s);for(let[t,s]of ao(e))r=!0,o[Se(t)]!==void 0&&(n[t]=s);return{attrs:n,opaque:r}}function Wo(e,o,n){let r=be(e),t={},s=Vo(o),a=new Set;for(let[u,p]of s){let b=Se(u),C=n[b];C!==void 0&&so(C,p)?a.add(b):t[`${u}!${r}`]=!0}for(let[u,p]of ao(o)){let b=Se(u);n[b]!==void 0&&so(n[b],p)&&a.add(b)}for(let[u,p]of Object.entries(n))a.has(u)||(t[`${u}~${be(e)}`]=p);let f=fo(o,n);if(!(!Object.keys(t).length&&!f.opaque))return{...f.attrs,...t}}var Nt=2e3;function Uo(e){let o=[],n=[],r=0;for(let t=0;t<e.length;t++)if(n.push(e[t]),r+=1,r>=Nt&&t+1<e.length){let s=e[t];if(s.k==="c"&&Fe(s.ch.charCodeAt(0)))continue;o.push(n),n=[],r=0}return n.length&&o.push(n),o}function lt(e,o,n,r=s=>s(),t=null){let s=o;for(let a of Uo(n))r(()=>{s+=Xo(e,s,a,t)});return s-o}var Go=(e,o,n)=>{if(!n||!n.length)return null;let r=o,t=e.flow._start;for(;t&&r>0;){if(!t.deleted&&t.countable){if(r<t.length)return null;r-=t.length}t=t.right}for(;t&&(t.deleted||!t.countable);t=t.right)if(t.deleted&&n.some(s=>s.client===t.id.client&&s.clock>=t.id.clock&&s.clock<t.id.clock+t.length))return t;return null},We=(e,o,n,r)=>{let t=Go(e,o,n);if(!t)return r();t.deleted=!1;try{return r()}finally{t.deleted=!0,e.flow._searchMarker&&(e.flow._searchMarker.length=0)}};function Xo(e,o,n,r=null){let t=o,s="",a=null,f=null,u=()=>{if(!s)return;let b=Wo(e,io(e,t),f??{});We(e,t,r,()=>e.flow.insert(t,s,b)),t+=s.length,s=""},p=b=>{let C=fo(io(e,t)).attrs;We(e,t,r,()=>e.flow.insertEmbed(t,b,C)),t+=1};for(let b of n)b.k==="c"?(a!==null&&b.mk!==a&&u(),a=b.mk,f=b.ma,s+=b.ch):b.k==="h"?(u(),a=null,p({br:1})):(u(),a=null,p({b:b.id}),co(e,b.id,b.t,b.attrs));return u(),t-o}var Qo=(e,o,n,r)=>{let t=0;for(let s=e.flow._start;s&&t<r;s=s.right){if(s.deleted||!s.countable)continue;let a=t;if(t+=s.length,t<=n||s.content instanceof de&&s.content.embed?.b!==void 0)continue;let f=Math.max(0,n-a),u=Math.min(s.length,r-a);u<=f||e.gone.set(Pn(s.id.client,s.id.clock+f,o.operationId),{length:u-f,actor:e.ydoc.clientID,sv:o.sv})}};function lo(e,o,n,r=null){for(let t=n.length-1;t>=0;t--){let[s,a]=n[t];if(a<=s)continue;let f=o.physicalRanges(s,a);for(let u=f.length-1;u>=0;u--){let[p,b]=f[u];b<=p||(r&&Qo(e,r,p,b),e.flow.delete(p,b-p))}}}function Zo(e,o,n){let r=!1;for(let t=e.flow._start;t;t=t.right){let s=Ee(t.id);if(s===o){r=!0;continue}if(!r)continue;let a=t.content instanceof de?t.content.embed:null;if(a&&a.b!==void 0&&a.b!==n)return s}return null}function Ft(e,o,n,r,t=null){let{pd:s,map:a,bt:f}=e,u=i=>t===null||t[i],p=0;for(;p<n.length&&p<r.length&&ze(n[p],r[p])&&u(p);)p++;let b=0;for(;b<n.length-p&&b<r.length-p&&ze(n[n.length-1-b],r[r.length-1-b])&&u(n.length-1-b);)b++;let C=i=>i&&i.k==="c"?i.ch.charCodeAt(0):-1;p>0&&Fe(C(n[p-1]))&&(nt(C(n[p]))||nt(C(r[p])))&&p--,b>0&&nt(C(n[n.length-b]))&&(Fe(C(n[n.length-b-1]))||Fe(C(r[r.length-b-1])))&&b--;let M=n.slice(p,n.length-b),h=r.slice(p,r.length-b),w=o+p,y=w+M.length,N=M.filter(i=>i.k==="b").map(i=>i.id).join(",");if(!(M.some(i=>i.k==="b")&&N===h.filter(i=>i.k==="b").map(i=>i.id).join(","))){let i=Le(s.origins);try{for(let T of M){if(T.k!=="b"||!T.brk)continue;let U=i.resolve(T.brk);i.boundaryOf(U)||e.tx(()=>i.recordBoundary(U,{blockId:T.id,kind:"removed"}))}}finally{i.dispose()}let g=new Set;M.forEach((T,U)=>{if(T.k!=="b"||!T.brk)return;let P=w+U,I=P+1;for(;I<f.length&&f[I].k!=="b";)I++;let K=I<=y&&I!==P+1,j=I<f.length?f[I].brk:null;K&&(e.tx(()=>s.gone.set(Be(Ee(T.brk),e.operationId),{blockId:T.id,end:j?Ee(j):null,sv:e.sv})),g.add(P))});let A=[],z=w;for(let T=w;T<y;T++)g.has(T)&&(T>z&&A.push([z,T]),z=T+1);y>z&&A.push([z,y]),e.tx(()=>lo(s,a,A,M.some(T=>T.k==="b")?null:e));let W=new Set(h.filter(T=>T.k==="b").map(T=>T.id));for(let T of M)if(!(T.k!=="b"||!T.brk||W.has(T.id)))for(let U of e.copies.get(T.id)??[]){let P=Be(U,e.operationId);s.gone.has(P)||e.tx(()=>s.gone.set(P,{blockId:T.id,end:Zo(s,U,T.id),sv:e.sv}))}h.length&&lt(s,a.toPhysical(w,"before"),h,e.tx,e.fences);return}let v=[],L=[],Y=[],$=w,x=0,c=0;for(;x<M.length||c<h.length;){let i=x;for(;i<M.length&&M[i].k!=="b";)i++;let g=c;for(;g<h.length&&h[g].k!=="b";)g++;let A=M.slice(x,i),z=h.slice(c,g);if(A.length&&v.push([$,$+A.length]),z.length&&L.push({at:$,toks:z}),$+=A.length,i<M.length&&(Y.push([M[i],h[g]]),$+=1),x=i+(i<M.length?1:0),c=g+(g<h.length?1:0),i>=M.length&&g>=h.length)break}let E=[...v.map(i=>({at:i[0],d:i})),...L.map(i=>({at:i.at,i}))].sort((i,g)=>g.at-i.at||(i.d?-1:1));for(let i of E)i.d?e.tx(()=>lo(s,a,[i.d],e)):lt(s,a.toPhysical(i.at,"before"),i.i.toks,e.tx,e.fences);for(let[i,g]of Y)e.tx(()=>{if(!fe.nodes[g.t])return;let A=e.recovered.get(i.id);if(A){i.t!==g.t&&s.gone.set(De(A,"t"),g.t);for(let T of xe(fe.nodes[g.t]))ye(i.attrs[T],g.attrs[T])||s.gone.set(De(A,T),g.attrs[T]);return}let z=i.id,W=s.attrs.get(z);if(W){let T=i.t==="table"&&g.t==="table"&&W.get("t")==="table",U=g.t==="board",P=U?i.t==="board"&&W.get("t")==="board"?i.attrs:wt(s.boardFields,z):null;i.t!==g.t&&W.set("t",g.t);for(let I of xe(fe.nodes[g.t])){if(T&&(I==="rows"||I==="cols")||U&&(I==="columns"||I==="cards"))continue;let K=W.has(I)?W.get(I):Ne(fe.nodes[g.t],I);ye(K,g.attrs[I])||W.set(I,g.attrs[I])}T&&vt(s,z,i.attrs,g.attrs),U&&xt(s,z,P,g.attrs)}else co(s,z,g.t,g.attrs)})}function Lt(e,o,n,r,t,s){let{pd:a,map:f}=e,u=`${r}~${be(a)}`,p=be(a),b=o;for(;b<n;){if(s[b].k!=="c"){b++;continue}let C=b;for(;C<n&&s[C].k==="c";)C++;let M=f.physicalRanges(b,C);if(t!==null)for(let[h,w]of M)a.flow.format(h,w-h,{[u]:t});else{let h=0;for(let w of a.flow.toDelta()){let y=typeof w.insert=="string"?w.insert.length:1;for(let[N,B]of M){if(h>=B)break;let v=Math.max(h,N),L=Math.min(h+y,B);if(L>v&&w.attributes){let Y={};for(let[$,x]of Object.entries(w.attributes))Se($)===r&&!Ce($)&&x!==null&&(Y[`${$}!${p}`]=!0);Object.keys(Y).length&&a.flow.format(v,L-v,Y)}}h+=y}}b=C}}var{AddMarkStep:uo,RemoveMarkStep:er,AttrStep:tr,ReplaceStep:nr,Mapping:ct}=ln,po=(e,o,n)=>{let r=e.resolve(o),t=e.resolve(n);return[r.depth&&r.node(1).type.name==="table"?r.before(1):o,t.depth&&t.node(1).type.name==="table"?t.after(1):n]},or=(e,o,n)=>{let r=!1;return e.nodesBetween(o,n,t=>(t.type.name==="table"&&(r=!0),!r&&t.type.name!=="table")),r};function mo(e,o,n,r,t=null,s=!0,a=null,{join:f=!1,open:u=!1}={}){let p=()=>{if(a){let l=a;a=null,l()}},b=[],C=[],M=[];for(let l of o)l.steps.forEach((k,F)=>{b.push(k),C.push(l.docs[F]),M.push(k.getMap())});if(!b.length)return;let h=new ct(M),w=[...Qe(Ze(e.ydoc)).entries()].sort((l,k)=>l[0]-k[0]),y=be(e),N=C[0],B=o[o.length-1].doc,v=n.visible.length===0&&N.childCount===1&&N.firstChild.type.name==="paragraph"?[{id:N.firstChild.attrs.id,implicit:!0,t:"paragraph",len:0}]:n.visible,L=new Map,Y=[];{let l=0;v.forEach(k=>{k.implicit&&Y.push({tok:l,id:k.id,t:k.t}),l+=k.len})}Y.sort((l,k)=>k.tok-l.tok);for(let l of Y)l.alias=bn(e),L.set(l.id,l.alias);let $=L.size?n.holes.map(l=>({at:l.at+Y.filter(k=>k.tok<l.at).length,len:l.len})):n.holes,x=Tt(n.tokens+L.size,$,e.flow.length+L.size),c=[],E=[];b.forEach((l,k)=>{let F=l instanceof uo||l instanceof er;if(F&&!or(C[k],l.from,l.to)){E.push({i:k,step:l});return}let R=new ct(M.slice(0,k)).invert(),D=new ct(M.slice(k+1)),q=[];l instanceof tr?q.push([l.pos,l.pos+1,l.pos,l.pos+1]):F?q.push([l.from,l.to,l.from,l.to]):l.getMap().forEach((O,te,X,G)=>q.push([O,te,X,G]));for(let[O,te,X,G]of q){let[Z,oe]=po(N,R.map(O,-1),R.map(te,1)),[ne,Ge]=po(B,D.map(X,-1),D.map(G,1));c.push({oa:Z,ob:oe,na:ne,nb:Ge})}}),c.sort((l,k)=>l.oa-k.oa||l.na-k.na);let i=[];for(let l of c){let k=i[i.length-1];k&&(l.oa<=k.ob||l.na<=k.nb)?(k.ob=Math.max(k.ob,l.ob),k.nb=Math.max(k.nb,l.nb)):i.push({...l})}let g=!Y.length&&!E.length&&b.every(l=>l instanceof nr)&&o.every(dn),A=g?null:It(N,L,v),z=g?null:It(B,L,v),W=g?[]:Ct(N,L,v),T=g?[]:Ct(B,L,v),U=g?i.map(l=>({r:l,old:At(N,l.oa,l.ob),next:At(B,l.na,l.nb)})):null,P=g?U.reduce((l,k)=>l+k.next.end-k.next.start,0):i.reduce((l,k)=>l+(z[k.nb]-z[k.na]),0),I=P>Nt,K=I?l=>e.ydoc.transact(k=>{k.meta.set(_e,s),p(),l()},me):l=>l(),j={pd:e,map:x,bt:W,tx:K,copies:n.copies,fences:n.fences,sv:w,operationId:y,recovered:new Map(n.visible.filter(l=>l.recovered).map(l=>[l.id,l.sourceKey]))},Q=l=>l.filter(k=>k.k==="b").map(k=>`${k.id}|${k.t}|${JSON.stringify(k.attrs)}`).join(`
3
3
  `),le=!g&&(E.length>0||Q(W)!==Q(T)),ee=()=>{for(let F of Y)lt(e,Ye(n.holes,F.tok),[{k:"b",id:F.alias,t:F.t,attrs:Object.fromEntries(xe(fe.nodes[F.t]).map(R=>[R,Ne(fe.nodes[F.t],R)]))}],K);for(let F=i.length-1;F>=0;F--)if(g){let{r:R,old:D,next:q}=U[F],O=D.tokens.map((te,X)=>{let G=h.mapResult(R.oa+X,1),Z=h.mapResult(R.oa+X+1,-1),oe=G.pos-R.na;return!G.deleted&&!Z.deleted&&Z.pos===G.pos+1&&oe>=0&&oe<q.tokens.length&&ze(te,q.tokens[oe])});Ft(j,D.start,D.tokens,q.tokens,O)}else{let R=i[F],D=A[R.oa],q=A[R.ob];Ft(j,D,W.slice(D,q),T.slice(z[R.na],z[R.nb]))}let l=E.length?ue(e):null,k=l?{...j,map:Tt(l.tokens,l.holes,e.flow.length)}:null;for(let{i:F,step:R}of E){let D=new ct(M.slice(F+1)),q=z[D.map(R.from,1)],O=z[D.map(R.to,-1)];if(O<=q)continue;let te=R.mark.type.name,X=R instanceof uo?R.mark.attrs&&Object.keys(R.mark.attrs).length?{...R.mark.attrs}:!0:null;if(an(R.mark)){if(X===null)continue;let G=fn(R.mark.attrs.entries);K(()=>{for(let[Z,oe]of Object.entries(G))Lt(k,q,O,Z,oe,T)});continue}K(()=>Lt(k,q,O,te,X,T))}};f||t?.stopCapturing();let m=t?.captureTimeout;t&&(t.captureTimeout=1/0);try{I?ee():e.ydoc.transact(l=>{l.meta.set(_e,s),p(),ee()},me)}finally{t&&(t.captureTimeout=m),u||t?.stopCapturing()}r.groups++,r.lastGroup={chunked:I,structural:le,regional:g,span:P}}var ke=e=>({status:"refused",code:e}),ho=e=>{if(!e)return"";let o=[];for(let n of Object.keys(e).sort())o.push(`${n}=${JSON.stringify(e[n])}`);return o.join(`
4
4
  `)},rr=(e,o,n)=>{let r=n?n.state.doc:null,s=r&&r.childCount===o.visible.length&&o.visible.every((f,u)=>r.child(u).attrs.id===f.id)?r:Re(e,o),a=[];return s.forEach(f=>{f.attrs.id===null||f.attrs.id===void 0||a.push({id:f.attrs.id,parent:f.attrs.parent??null,t:f.type.name})}),a},sr=(e,o)=>{let n=[],r=e.get(o)?.parent??null,t=0;for(;r!=null&&t++<=e.size;)n.push(r),r=e.get(r)?.parent??null;return n},bo=(e,o,n)=>sr(e,n).includes(o),Bt=(e,o,n)=>o===n||bo(e,n,o),Dt=(e,o,n,r,t)=>{if(o?.recovered){let a=De(o.sourceKey,r);(e.gone.has(a)?e.gone.get(a):o.fields?.[r]??null)!==t&&e.gone.set(a,t);return}let s=e.attrs.get(n);s||(s=new Ae,e.attrs.set(n,s)),s.get(r)!==t&&s.set(r,t)},at=(e,o,n,r)=>Dt(e,o,n,"parent",r),ir=8,go={indent:(e,o)=>o.t==="list_item"&&Number.isInteger(e)&&e>=0&&e<=ir,open:(e,o)=>o.t==="toggle"&&typeof e=="boolean",parent:(e,o,n)=>e===null||typeof e=="string"&&n.get(e)?.t==="toggle"&&!Bt(n,e,o.id)},lr=(e,o)=>{if(e?.attrs===void 0)return[];if(!e.attrs||typeof e.attrs!="object"||Array.isArray(e.attrs))return null;let n=[];for(let[r,t]of Object.entries(e.attrs)){let s=o.get(r);if(!s||!t||typeof t!="object"||Array.isArray(t))return null;for(let[a,f]of Object.entries(t)){if(!go[a]||!go[a](f,s,o))return null;n.push({id:r,field:a,value:f})}}return n},cr=(e,o)=>{let n=kt(e.flow,0,e.flow.length),r=[],t=0;for(let s of e.flow.toDelta()){let a=s.attributes;if(typeof s.insert=="string")for(let f=0;f<s.insert.length;f++)r.push({ch:s.insert[f],attrs:a,source:o.resolve(n[t++])});else r.push({embed:s.insert,attrs:a,source:o.resolve(n[t++])})}if(t!==n.length)throw new Error(`The flow delta has ${t} units but the document has ${n.length}`);return r},ar=(e,o,n)=>{let r=new Map;for(let s of o.visible)n.has(s.id)&&s.brk&&r.set(Oe(s.brk),s.id);for(let s of n)for(let a of o.copies.get(s)??[])r.set(a,s);let t=[];for(let s=e.flow._start;s;s=s.right){if(s.deleted||!(s.content instanceof de))continue;let a=s.content.embed?.b;if(a===void 0||r.get(Oe(s.id))!==a)continue;let f=null;for(let u=s.right;u;u=u.right){if(u.deleted||!(u.content instanceof de))continue;let p=u.content.embed?.b;if(!(p===void 0||p===a)){f=Oe(u.id);break}}t.push({key:Oe(s.id),blockId:a,end:f})}return t};function zt({pd:e,view:o,um:n,origins:r,render:t,walked:s=null},a={}){let f=Array.isArray(a?.ids)?[...new Set(a.ids)]:[],u=a?.afterId===void 0?null:a.afterId,p=a?.parent!==void 0,b=s??ue(e,r),C=new Set(b.visible.filter(m=>m.opaque).map(m=>m.id)),M=rr(e,b,o),h=new Map(M.map(m=>[m.id,m])),w=M.map(m=>m.id);if(!f.length)return ke("missing-source");for(let m of f)if(!h.has(m))return ke("missing-source");let y=lr(a,h);if(!y)return ke("invalid-attrs");let N=y.filter(m=>m.field==="parent"),B=new Set(f.filter(m=>!f.some(l=>l!==m&&bo(h,l,m)))),v=M.filter(m=>f.some(l=>Bt(h,m.id,l))),L=new Set(v.map(m=>m.id));if(v.some(m=>C.has(m.id))||y.some(m=>C.has(m.id)))return ke("unsupported-format");let Y=new Map(b.visible.map(m=>[m.id,m]));for(let m of v){let l=Y.get(m.id);if(!l||l.implicit||!l.brk)return ke("missing-source")}let $;if(p)$=a.parent??null;else{let m=new Set(v.filter(l=>B.has(l.id)).map(l=>l.parent));if(m.size!==1)return ke("invalid-parent");$=[...m][0]}if(p&&$!==null){let m=h.get($);if(!m||m.t!=="toggle")return ke("invalid-parent");if(L.has($))return ke("cycle")}if(u!==null){if(typeof u!="string"||!h.has(u))return ke("missing-destination");if(L.has(u))return ke("cycle");if(h.get(u).parent!==$)return ke("missing-destination")}let x=M.filter(m=>!L.has(m.id)),c=0;if(u===null){if($!==null){let m=x.findIndex(k=>k.parent===$),l=x.findIndex(k=>k.id===$);c=m>=0?m:l<0?0:l+1}}else for(c=x.findIndex(m=>m.id===u)+1;c<x.length&&Bt(h,x[c].id,u);)c++;let E=[...x.slice(0,c),...v,...x.slice(c)],i=E.length===w.length&&E.every((m,l)=>m.id===w[l]),g=v.filter(m=>B.has(m.id)&&m.parent!==$),A=v.map(m=>m.id);if(i&&!g.length&&!y.length)return{status:"unchanged"};let z=(()=>{let m=o?.state.selection;if(!(m instanceof pe.TextSelection))return null;let l=R=>{let D=o.state.doc.resolve(R);return D.depth?{id:D.node(1).attrs.id,offset:D.parentOffset}:null},k=l(m.anchor),F=l(m.head);return k&&F&&(L.has(k.id)||L.has(F.id))?{anchor:k,head:F}:null})(),W=()=>{if(!z||!o)return;let m=({id:F,offset:R})=>{let D=null;return o.state.doc.forEach((q,O)=>{D===null&&q.attrs.id===F&&(D=O+1+Math.min(R,q.content.size))}),D},l=m(z.anchor),k=m(z.head);l!==null&&k!==null&&o.dispatch(o.state.tr.setSelection(pe.TextSelection.create(o.state.doc,l,k)).setMeta(Me,!0).setMeta("addToHistory",!1))};if(i)return n?.stopCapturing(),e.ydoc.transact(()=>{if(N.length)for(let m of N)at(e,Y.get(m.id),m.id,m.value);else for(let m of g)at(e,Y.get(m.id),m.id,$);for(let m of y)m.field!=="parent"&&Dt(e,Y.get(m.id),m.id,m.field,m.value)},me),n?.stopCapturing(),t(),W(),{status:"moved",ids:A};let T=[...Qe(Ze(e.ydoc)).entries()].sort((m,l)=>m[0]-l[0]),U=be(e),P=cr(e,r),I=yt(b,e.flow.length),K=[],j=0;for(let m of b.visible){if(L.has(m.id)){let l=[];for(let[k,F]of I.physicalRanges(j,j+m.len))for(let R=k;R<F;R++)l.push(P[R]);K.push({seg:m,units:l})}j+=m.len}for(let m=0;m<K.length;m++){let l=K[m];if(l.seg.id!==A[m])throw new Error(`Captured ${l.seg.id} where ${A[m]} was expected`);if(!l.units.length||l.units[0].embed===void 0||l.units[0].embed.b!==l.seg.id)throw new Error(`The selected block ${l.seg.id} has no physical marker to copy`)}let Q=ar(e,b,L),le=Pe(e.gone),ee=new Map;for(let m of v){let l=Y.get(m.id);if(!l.recovered)continue;let k=b.removals.filter(D=>D.sourceKey===l.sourceKey),F=$n(l.sourceKey,k,le),R=le.restores.find(D=>D.key===F?.key)?.baseline??{type:l.t,attrs:l.fields??{}};ee.set(l.sourceKey,{covers:k.map(D=>D.key),baseline:JSON.parse(JSON.stringify(R))})}if(!Q.length)throw new Error("The selected blocks have no live physical markers to retire");return n?.stopCapturing(),e.ydoc.transact(()=>{for(let O of Q)e.gone.set(Be(O.key,U),{blockId:O.blockId,end:O.end,sv:T});let m=ue(e,r),l=yt(m,e.flow.length),k=m.visible.map(O=>O.id),F=0;if(c>0){let O=k.indexOf(x[c-1].id);F=O<0?0:O+1}let R=0;for(let O=0;O<F;O++)R+=m.visible[O].len;let D=l.toPhysical(R,"before"),q=[];for(let O of K){let te=D,X=null,G=null,Z=()=>{X!==null&&(We(e,D,m.fences,()=>e.flow.insert(D,X,G??void 0)),D+=X.length,X=null)};for(let ne of O.units)ne.ch!==void 0?(X!==null&&ho(ne.attrs)!==ho(G)&&Z(),X===null&&(X="",G=ne.attrs),X+=ne.ch):(Z(),We(e,D,m.fences,()=>e.flow.insertEmbed(D,ne.embed,ne.attrs)),D+=1);Z();let oe=kt(e.flow,te,D);if(oe.length!==O.units.length)throw new Error(`Copied ${O.seg.id} as ${oe.length} units instead of ${O.units.length}`);for(let ne=1;ne<O.units.length;ne++)q.push({dest:oe[ne],source:O.units[ne].source});r.recordBoundary(oe[0],O.seg.recovered?{blockId:O.seg.id,kind:"copy",recoveryOf:O.seg.sourceKey}:{blockId:O.seg.id,kind:"copy"}),O.seg.recovered&&e.gone.set(ot(O.seg.sourceKey,U),ee.get(O.seg.sourceKey)),e.gone.set(Tn(Oe(oe[0])),!0)}if(q.length&&r.recordSpans(q),N.length)for(let O of N)at(e,Y.get(O.id),O.id,O.value);else for(let O of g)at(e,Y.get(O.id),O.id,$);for(let O of y)O.field!=="parent"&&Dt(e,Y.get(O.id),O.id,O.field,O.value)},me),n?.stopCapturing(),t(),W(),{status:"moved",ids:A}}var Jt=e=>{let o=[];return e.forEach(n=>o.push([n.type.name,JSON.stringify(Object.fromEntries(xe(n.type).map(r=>[r,n.attrs[r]]))),n.isTextblock||n.type.name==="table"?JSON.stringify(n.content.toJSON()):null])),JSON.stringify(o)};function fr(e,o){if(e.childCount!==o.childCount)return!1;for(let n=0;n<e.childCount;n++){let r=e.child(n),t=o.child(n);if(r!==t&&(r.type!==t.type||xe(r.type).some(s=>!ye(r.attrs[s],t.attrs[s]))||(r.isTextblock||r.type.name==="table")&&!r.content.eq(t.content)))return!1}return!0}var ur=e=>{let o=[];return e.forEach((n,r)=>{n.type.name==="opaque_block"&&o.push([r,r+n.nodeSize])}),o},dr=(e,o)=>{let n=typeof e.from=="number"?e.from:typeof e.pos=="number"?e.pos:null;if(n===null)return!1;let r=typeof e.to=="number"?e.to:n+1;return o.some(([t,s])=>n<s&&r>t)},Ue=(e,o)=>{let n=e.resolve(o);return n.depth&&n.node(1).type.name==="table"?[n.before(1),n.after(1)]:null};function ko(e,o){let n=e.content.findDiffStart(o.content);if(n===null)return null;let{a:r,b:t}=e.content.findDiffEnd(o.content),s=n-Math.min(r,t);s>0&&(r+=s,t+=s);let a=(f,u)=>{let p=f.resolve(n);return p.parent.isTextblock&&p.sameParent(f.resolve(u))};return(Ue(e,n)||Ue(e,r))&&!(a(e,r)&&a(o,t))?(n=Ue(e,n)?.[0]??n,r=Ue(e,r)?.[1]??r,t=Ue(o,t)?.[1]??t,{start:n,endA:r,endB:t,tables:!0}):{start:n,endA:r,endB:t}}function Kt(e,o=null){let n=new Map;o?.forEach(u=>{u.attrs.id&&n.set(u.attrs.id,u)});let r=[];e.forEach(u=>r.push(u));let t=r.map(u=>({id:u.attrs.id,pos:n.get(u.attrs.id)?.attrs.pos??u.attrs.pos})),s=bt(t,"b"),a=!1,f=r.map((u,p)=>{let b=s[p]?.pos??t[p].pos,C=u.content;if(u.type.name==="table"){let w=[];u.forEach(v=>w.push(v));let y=w.map(v=>({id:v.attrs.id,pos:v.attrs.pos})),N=bt(y,"r"),B=w.map((v,L)=>{let Y=N[L]?.pos??y[L].pos;return Y===v.attrs.pos?v:v.type.create({...v.attrs,pos:Y},v.content,v.marks)});B.some((v,L)=>v!==w[L])&&(C=B)}if(b===u.attrs.pos&&C===u.content)return u;a=!0;let M={...u.attrs,pos:b},h=n.get(u.attrs.id);return h&&C===u.content&&h.hasMarkup(u.type,M,u.marks)&&h.content.eq(C)?h:u.type.create(M,C,u.marks)});return a?e.type.create(e.attrs,f):e}var yo=e=>{let o=new Set,n=null;for(let r=0;r<e.childCount;r++){let{id:t,pos:s}=e.child(r).attrs;if(!t||o.has(t)||!un(s)||n!==null&&n>=s)return!1;o.add(t),n=s}return!0},pr=(e,o)=>{for(let n in e.attrs)if(n!=="pos"&&e.attrs[n]!==o.attrs[n])return!1;return!0};function mr(e,o){if(e.childCount!==o.childCount||!yo(e))return!1;for(let n=0;n<e.childCount;n++){let r=e.child(n),t=o.child(n);if(r===t)continue;if(!(r.type===t.type&&r.marks===t.marks&&pr(r,t))&&!r.hasMarkup(t.type,{...t.attrs,pos:r.attrs.pos},t.marks)||!r.content.eq(t.content)||r.type.name==="table"&&!yo(r))return!1}return!0}var wo=e=>{if(e&&typeof e=="object"){for(let o of Object.keys(e))wo(e[o]);Object.freeze(e)}return e},vo=e=>wo(JSON.parse(JSON.stringify(e))),hr=(e,o)=>{let n=gn(o),r=0;for(let t=e.flow._start;t;t=t.right){if(t.id.client===n.client&&t.id.clock===n.clock)return t.deleted?r:r+t.length;!t.deleted&&t.countable&&(r+=t.length)}return r},gr=(e,o)=>{let n=null;for(let r=e.flow._start;r;r=r.right)r.id.client!==e.ydoc.clientID||!(r.content instanceof de)||r.content.embed?.b!==o||(!n||r.id.clock>n.clock)&&(n=r.id);return n};function xo({pd:e,onNotice:o=()=>{},ownedTokens:n=[],authorToken:r=null,stats:t={groups:0,mismatch:0,renders:0,first:null},captureTimeout:s=500}){let a=null,f=null,u=0,p=-1,b=null,C=0,M=new WeakMap,h=Le(e.origins);f=ue(e,h);let w=new on([e.flow,e.attrs,e.gone,e.tableFields,e.boardFields],{trackedOrigins:new Set([me]),captureTimeout:s,captureTransaction:d=>d.meta.get(_e)!==!1,deleteFilter:d=>{if(d.parent!==e.flow||!(d.content instanceof de))return!0;let S=h.resolve(d.id);return S.client!==d.id.client||S.clock!==d.id.clock||h.boundaryOf(d.id)?.kind!=="copy"}}),y=wn(e,w,h,d=>Pe(d).textDeletes),N=new Set,B=new Set(r?[...n,r]:n),v=r?()=>{let d=An(e.ydoc.clientID);e.origins.get(d)!==r&&e.origins.set(d,r)}:null,L=new Set,Y=new Set,$=0,x=null,c=null,E=d=>{let S=new Set;for(let J of d.blocks)for(let V of J.runs){if(!V.displaced)continue;let H=Rn(V.source)?.client===e.ydoc.clientID;V.author&&(H||B.has(V.author))?S.add(V.author):H&&S.add(null)}if(!S.size)return null;let _=[...S].filter(Boolean).sort();return{kind:"recovered-change",source:d.source,revision:d.revision,blockId:d.blockId,author:_[0]??null,authors:_}},i=d=>{let S=d.list.filter(J=>J.recoverable).map(J=>vo(J)),_=vo(S.map(J=>E(J)).filter(J=>J&&!L.has(`${J.source}\0${J.revision}`)));return Object.freeze({recoverable:Object.freeze(S),notices:Object.freeze(_)})},g=(d,S)=>{if(JSON.stringify(i(st(e,{index:h,walked:S})))===JSON.stringify(d)){t.provedRecoveries=(t.provedRecoveries??0)+1;return}throw t.walkMismatch=(t.walkMismatch??0)+1,new Error("Recovery snapshot built from the displacing sources diverged from a full reduction")},A=()=>{if(x&&x.version===$)return x.snapshot;let d=p===u?f:void 0,S=i(jn(e,{index:h,walked:d}));return t.proveWalks&&g(S,d),x={version:$,snapshot:S},S},z=d=>rt({recoverable:d.recoverable.map(S=>[S.source,S.revision]),notices:d.notices}),W=()=>{$++;let d=A();for(let _ of d.notices){let J=`${_.source}\0${_.revision}`;N.has(J)||(N.add(J),o(_))}if(!Y.size){c=null;return}let S=z(d);if(S!==c){c=S;for(let _ of[...Y])_(d)}},T=d=>{f=d,p=u,b=null,C=0},U=()=>p===u?f:null,P=d=>{let S=Ve(e,d),_=Ve(e,ue(e));if(S===_){t.provedWalks=(t.provedWalks??0)+1;return}throw t.walkMismatch=(t.walkMismatch??0)+1,new Error(`Incremental walk diverged from the full walk:
@@ -27,4 +27,4 @@ ${_}`)},Q=()=>{if(JSON.stringify(i(st(e,{index:h,walked:f})))!==JSON.stringify(A
27
27
  .blockeditor-recover-row button, .blockeditor-recover-head button { min-height: 44px; }
28
28
  }
29
29
  `,yr={heading:"Heading",list_item:"List item",toggle:"Toggle",quote:"Quote",code_block:"Code",callout:"Callout",table:"Table",image:"Image"},qt=280,ve=(e,o,n,r={})=>{let t=e.createElement(o);n&&(t.className=n);for(let[s,a]of Object.entries(r))t.setAttribute(s,a);return t};function vr(e,o){let n=ve(e,"div","blockeditor-recover-text"),r=0;for(let t of o.blocks){for(let s of t.runs){if(s.kind!=="text"||r>=qt)continue;let a=s.text.slice(0,qt-r);r+=a.length,n.append(s.displaced?Object.assign(e.createElement("mark"),{textContent:a}):e.createTextNode(a))}r<qt&&t!==o.blocks[o.blocks.length-1]&&n.append(e.createTextNode(" / "))}return n.textContent||(n.textContent="(no text)"),n}function wr(e){let o=new Set;for(let n of e.blocks)for(let r of n.runs)r.displaced&&o.add(r.author??null);return[...o]}function xr(e,o){let n=null;return e.state.doc.forEach((r,t)=>{n===null&&r.attrs.id===o&&(n=r.isTextblock?t+1:t)}),n===null?!1:(e.dispatch(e.state.tr.setSelection(pe.Selection.near(e.state.doc.resolve(n))).scrollIntoView()),e.focus(),!0)}function Sr({binding:e,mount:o,ownTokens:n=[],onRestored:r=()=>{},onStale:t=()=>{}}){let s=o.ownerDocument,a=new Set(n.filter(Boolean)),f=ve(s,"button","blockeditor-recover",{type:"button","aria-haspopup":"dialog","aria-expanded":"false"}),u=ve(s,"div","blockeditor-recover-panel",{role:"dialog","aria-label":"Recover changes"});f.hidden=!0,u.hidden=!0;let p=ve(s,"div","blockeditor-recover-root");p.append(f,u);let b=Vt({name:"blockeditor-recover",content:p,css:[kr],parent:o}),C={recoverable:[],notices:[]},M=null,h="",w=x=>x.some(c=>a.has(c))?x.length>1?"You and others":"You":x.some(c=>c!==null)?"Another editor":"An earlier edit",y=()=>{u.hidden=!0,M=null,f.setAttribute("aria-expanded","false")},N=x=>{let c;try{c=e.restore(x.source,x.revision)}catch(E){return console.error("[clay] Restore failed:",E),Wt("This change could not be restored.","error"),{status:"failed"}}return c.status==="restored"||c.status==="resolved"?r(c.id):c.status==="stale"&&t(c),c},B=()=>{u.replaceChildren();let x=ve(s,"div","blockeditor-recover-head");x.append(s.createTextNode("Recover changes"));let c=ve(s,"button","",{type:"button"});c.textContent="Close",c.addEventListener("click",()=>{y(),f.focus()}),x.append(c);let E=ve(s,"p","blockeditor-recover-note");E.textContent="Text typed while its block was moved or removed. Restore puts it back as a new block.",u.append(x,E);for(let i of C.recoverable){let g=ve(s,"div","blockeditor-recover-row",{"data-source":i.source});i.source===M&&g.classList.add("is-target");let A=ve(s,"div","blockeditor-recover-meta");A.textContent=`${yr[i.type]??"Paragraph"} \xB7 ${w(wr(i))}`;let z=ve(s,"button","",{type:"button"});z.textContent="Restore",z.addEventListener("click",()=>N(i)),g.append(A,vr(s,i),z),u.append(g)}},v=(x=null)=>{if(!C.recoverable.length)return;M=x,u.hidden=!1,f.setAttribute("aria-expanded","true"),B();let c=[...u.querySelectorAll(".blockeditor-recover-row")];(c.find(i=>i.dataset.source===x)??c[0])?.querySelector("button")?.focus()},L=x=>{let c=x.map(E=>`${E.source}\0${E.revision}`).join(`
30
- `);if(c!==h){if(h=c,!x.length){ft(Ht);return}Ut(Ht,"warning",{actions:[{label:"Review",onClick:()=>v(x[0].source)},{label:"Dismiss",onClick:()=>{for(let E of x)e.dismiss(E.source,E.revision)}}]})}},Y=x=>{C=x;let c=x.recoverable.length;f.hidden=c===0,f.textContent=`Recover changes (${c})`,c?u.hidden||B():y(),L(x.notices)};f.addEventListener("click",()=>u.hidden?v():y()),u.addEventListener("keydown",x=>{x.key==="Escape"&&(x.stopPropagation(),y(),f.focus())});let $=e.subscribeRecovery(Y);return{open:v,close:y,restore:N,get count(){return C.recoverable.length},destroy(){$(),ft(Ht),b.remove()}}}import("./page/editor-KAZDJNND.js").catch(()=>null);export{Wn as ADOPTION_TIMEOUT_MS,Yo as acceptedPageState,Po as blocksFromYValue,je as canon,Mt as classifyFile,Io as createFeatureLoader,Sr as createRecoverList,br as createYPageBinding,xr as focusBlock,To as heldSlashRange,Ao as holdSlashRange,Do as installAdoption,jt as mergePageModels,Co as observeDocumentTitle,it as readBack,Ro as renderFromTags,$o as seedPageFromArticle,Eo as yValueOf};
30
+ `);if(c!==h){if(h=c,!x.length){ft(Ht);return}Ut(Ht,"warning",{actions:[{label:"Review",onClick:()=>v(x[0].source)},{label:"Dismiss",onClick:()=>{for(let E of x)e.dismiss(E.source,E.revision)}}]})}},Y=x=>{C=x;let c=x.recoverable.length;f.hidden=c===0,f.textContent=`Recover changes (${c})`,c?u.hidden||B():y(),L(x.notices)};f.addEventListener("click",()=>u.hidden?v():y()),u.addEventListener("keydown",x=>{x.key==="Escape"&&(x.stopPropagation(),y(),f.focus())});let $=e.subscribeRecovery(Y);return{open:v,close:y,restore:N,get count(){return C.recoverable.length},destroy(){$(),ft(Ht),b.remove()}}}import("./page/editor-PKSPJ2XJ.js").catch(()=>null);export{Wn as ADOPTION_TIMEOUT_MS,Yo as acceptedPageState,Po as blocksFromYValue,je as canon,Mt as classifyFile,Io as createFeatureLoader,Sr as createRecoverList,br as createYPageBinding,xr as focusBlock,To as heldSlashRange,Ao as holdSlashRange,Do as installAdoption,jt as mergePageModels,Co as observeDocumentTitle,it as readBack,Ro as renderFromTags,$o as seedPageFromArticle,Eo as yValueOf};
@@ -0,0 +1 @@
1
+ var d=/^[A-Za-z0-9._-]{1,100}$/,p="visitor-drafts",x="visitor-drafts",s=!1,u=null,i=!1,a=(t,e)=>(t?.get?.(e)||"").split(",").map(r=>r.trim()).includes(x);function g(t){s=a(t,"plugins")&&!a(t,"exclude")}function h(t=document){let e=t.documentElement.getAttribute(p);return e&&d.test(e)?e:null}var l=!1;function m(t){let e=t.querySelector('script[data-rules-name~="api"]');if(!e)return!1;let r=e.getAttribute("data-rules-version"),n=null;if(r!=="1")n=`the api rules tag says data-rules-version="${r??""}" and this version reads version 1`;else try{JSON.parse(e.textContent)}catch{n="the api rules tag does not hold readable JSON"}return n?(l||(l=!0,console.warn(`visitor-drafts: this page keeps no draft (${n})`)),!1):!0}function v(t=document,e=window.location){return s&&(e.protocol==="https:"||e.protocol==="http:")&&h(t)!==null&&m(t)}var f=null;function D(t){f=t}function S(){return f}function T(t){u=t}function y(){return u}var o=null;function A(t){o=t}function F(){if(!o)return!0;try{return o()!==!1}catch{return!1}}function b(t){i=!!t}function R(){return i}var c=null;function w(t){c=t}function B(){try{return!!c?.()}catch{return!0}}export{p as a,x as b,g as c,h as d,v as e,D as f,S as g,T as h,y as i,A as j,F as k,b as l,R as m,w as n,B as o};
@@ -1 +1 @@
1
- import{a as r}from"./c-VKEDWYDF.js";import{f as o}from"./c-DLBX4JCJ.js";import{r as c}from"./c-PWJSJEJU.js";var l="[editmode\\:resource]:is(style, link, script)",u='[editmode\\:resource]:is(style, link, script)[type^="inert/"]',i="inert/";function s(e){let t=e.getAttribute("type");return t&&t.startsWith(i)?!1:(e.setAttribute("type",i+(t||"")),!0)}function m(e){let t=e.getAttribute("type").slice(i.length);t?e.setAttribute("type",t):e.removeAttribute("type")}function d(){c(e=>{e.querySelectorAll(l).forEach(s)})}function f(){o&&r(()=>{a()})}function a(e=document){let t=(e.ownerDocument||e)===document;e.querySelectorAll(u).forEach(n=>{m(n),t&&n.replaceWith(n.cloneNode(!0))})}function R(){document.querySelectorAll(l).forEach(e=>{s(e)&&e.replaceWith(e.cloneNode(!0))})}function b(){d(),f()}export{l as a,a as b,R as c,b as d};
1
+ import{a as r}from"./c-VKEDWYDF.js";import{f as o}from"./c-C7SUMNMI.js";import{r as c}from"./c-PNZIJFG7.js";var l="[editmode\\:resource]:is(style, link, script)",u='[editmode\\:resource]:is(style, link, script)[type^="inert/"]',i="inert/";function s(e){let t=e.getAttribute("type");return t&&t.startsWith(i)?!1:(e.setAttribute("type",i+(t||"")),!0)}function m(e){let t=e.getAttribute("type").slice(i.length);t?e.setAttribute("type",t):e.removeAttribute("type")}function d(){c(e=>{e.querySelectorAll(l).forEach(s)})}function f(){o&&r(()=>{a()})}function a(e=document){let t=(e.ownerDocument||e)===document;e.querySelectorAll(u).forEach(n=>{m(n),t&&n.replaceWith(n.cloneNode(!0))})}function R(){document.querySelectorAll(l).forEach(e=>{s(e)&&e.replaceWith(e.cloneNode(!0))})}function b(){d(),f()}export{l as a,a as b,R as c,b as d};
@@ -1 +1 @@
1
- import{a as u}from"./c-BULK5J4M.js";import"./c-N326R2JD.js";import{f as n}from"./c-PVJMJL3P.js";import{b as h,c as a}from"./c-WN3MXOLT.js";import{b as T,g as _}from"./c-SNVDWMM3.js";import{b as p}from"./c-FZRZPIFS.js";import{b}from"./c-RTSRGGTP.js";import"./c-TWCXBWS3.js";import"./c-VKEDWYDF.js";import{B as v,C as g,K as k,M as E,Q as w,r as f,s as m,y}from"./c-2YIJ6ZA6.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-LO4C4J77.js";import"./c-FV46ZKGX.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-LA2BW7UY.js";import"./c-HSNGLIFB.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-RXTPKCMC.js";import"./c-RBPZNU2D.js";import"./c-IJUK2GPW.js";import"./c-DLBX4JCJ.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-PWJSJEJU.js";import"./c-XQXZAO7N.js";import"./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";var x=250,A=2e3,c=["focusin","focusout","selectionchange","clay:sync-applied","clay:workspace-background","clay:workspace-foreground"],S=t=>n.setGeneric(t),o=class{constructor({send:e=S,now:i=()=>Date.now()}){this.send=e,this.now=i,this.others=!1,this.background=!1,this.sent=null,this.lastAt=-1/0,this.timer=null,this.poked=null,this.inflight=!1,this.retry=null,this.stopped=!1,this._onEvent=s=>{s.type==="clay:workspace-background"&&(this.background=!0),s.type==="clay:workspace-foreground"&&(this.background=!1),this.poke()}}start(){this.stopped=!1;for(let e of c)document.addEventListener(e,this._onEvent)}resume(){this.stopped&&(this.start(),this.sent=null,this.schedule())}stop(){this.stopped=!0;for(let e of c)document.removeEventListener(e,this._onEvent);clearTimeout(this.timer),clearTimeout(this.poked),clearTimeout(this.retry),this.timer=null,this.poked=null,this.retry=null}roster(e){let s=(e&&Array.isArray(e.people)?e.people:[]).some(r=>r&&r.you!==!0);s!==this.others&&(this.others=s,this.schedule())}reconnected(){this.sent=null,this.schedule()}wanted(){return!this.others||this.background?null:a(h(document.activeElement))}poke(){this.poked===null&&(this.poked=setTimeout(()=>{this.poked=null,this.schedule()},0))}schedule(){if(this.stopped||this.timer!==null||this.inflight||this.wanted()===this.sent)return;let e=Math.max(0,this.lastAt+x-this.now());this.timer=setTimeout(()=>{this.timer=null,this.flush()},e)}flush(){if(this.inflight)return;let e=this.wanted();if(e===this.sent)return;this.sent=e,this.lastAt=this.now(),this.inflight=!0;let i=s=>{if(this.inflight=!1,!this.stopped){if(s)clearTimeout(this.retry),this.retry=null;else if(this.sent===e){this.sent=void 0,this.retry===null&&(this.retry=setTimeout(()=>{this.retry=null,this.schedule()},A));return}this.schedule()}};Promise.resolve(this.send(e)).then(s=>i(!!s),()=>i(!1))}};function P(t){let e=()=>(t._presenceQuiesced=!0,t._editing?.stop(),n.setGeneric(null),n.releaseTarget(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-quiesce")),t.lane==="live"&&t._morphInFlight?{ok:!1,code:"pending-input"}:{ok:!0}),i=()=>{t._presenceQuiesced=!1,t._editing?.resume(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))},s=()=>{t._presenceQuiesced=!1,t.stop(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))};return{id:"clay:sync",order:50,async prepare(r){if(await u(),r?.initial)return{quiesce:e,resume:i,dispose:s};let l=!1;return{quiesce:e,resume:i,enable(){let d=t.currentFile;t.stop(),t.start(d,{lane:"live"}),l=!0},dispose:()=>{t._presenceQuiesced=!1,l&&t.stop(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))}}}}}export{o as EditingSender,k as baselineSettled,m as conflictResolvedBySync,_ as enableAdminInputs,p as enableAdminResources,b as enableContentEditable,T as enableOnClick,v as getLastSavedBytes,f as isSaveConflicted,w as savePageThrottled,E as schedulePaintHeal,g as setLastSavedBaselines,y as setUnsavedChanges,P as syncParticipant};
1
+ import{a as u}from"./c-RWJ3OSCP.js";import"./c-N326R2JD.js";import{f as n}from"./c-VO6RSFCO.js";import{b as h,c as a}from"./c-WN3MXOLT.js";import{b as T,g as _}from"./c-IJHF4IO6.js";import{b as p}from"./c-U65PREMC.js";import{b}from"./c-FJDTDGDA.js";import"./c-QCDVDZIR.js";import"./c-VKEDWYDF.js";import{B as v,C as g,K as k,M as E,Q as w,r as f,s as m,y}from"./c-VMXCX52Q.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-P73XPAOA.js";import"./c-ZPI7M5U5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-MZCOGNZL.js";import"./c-MFB74XVN.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-KU3PX7LL.js";import"./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-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";var x=250,A=2e3,c=["focusin","focusout","selectionchange","clay:sync-applied","clay:workspace-background","clay:workspace-foreground"],S=t=>n.setGeneric(t),o=class{constructor({send:e=S,now:i=()=>Date.now()}){this.send=e,this.now=i,this.others=!1,this.background=!1,this.sent=null,this.lastAt=-1/0,this.timer=null,this.poked=null,this.inflight=!1,this.retry=null,this.stopped=!1,this._onEvent=s=>{s.type==="clay:workspace-background"&&(this.background=!0),s.type==="clay:workspace-foreground"&&(this.background=!1),this.poke()}}start(){this.stopped=!1;for(let e of c)document.addEventListener(e,this._onEvent)}resume(){this.stopped&&(this.start(),this.sent=null,this.schedule())}stop(){this.stopped=!0;for(let e of c)document.removeEventListener(e,this._onEvent);clearTimeout(this.timer),clearTimeout(this.poked),clearTimeout(this.retry),this.timer=null,this.poked=null,this.retry=null}roster(e){let s=(e&&Array.isArray(e.people)?e.people:[]).some(r=>r&&r.you!==!0);s!==this.others&&(this.others=s,this.schedule())}reconnected(){this.sent=null,this.schedule()}wanted(){return!this.others||this.background?null:a(h(document.activeElement))}poke(){this.poked===null&&(this.poked=setTimeout(()=>{this.poked=null,this.schedule()},0))}schedule(){if(this.stopped||this.timer!==null||this.inflight||this.wanted()===this.sent)return;let e=Math.max(0,this.lastAt+x-this.now());this.timer=setTimeout(()=>{this.timer=null,this.flush()},e)}flush(){if(this.inflight)return;let e=this.wanted();if(e===this.sent)return;this.sent=e,this.lastAt=this.now(),this.inflight=!0;let i=s=>{if(this.inflight=!1,!this.stopped){if(s)clearTimeout(this.retry),this.retry=null;else if(this.sent===e){this.sent=void 0,this.retry===null&&(this.retry=setTimeout(()=>{this.retry=null,this.schedule()},A));return}this.schedule()}};Promise.resolve(this.send(e)).then(s=>i(!!s),()=>i(!1))}};function P(t){let e=()=>(t._presenceQuiesced=!0,t._editing?.stop(),n.setGeneric(null),n.releaseTarget(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-quiesce")),t.lane==="live"&&t._morphInFlight?{ok:!1,code:"pending-input"}:{ok:!0}),i=()=>{t._presenceQuiesced=!1,t._editing?.resume(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))},s=()=>{t._presenceQuiesced=!1,t.stop(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))};return{id:"clay:sync",order:50,async prepare(r){if(await u(),r?.initial)return{quiesce:e,resume:i,dispose:s};let l=!1;return{quiesce:e,resume:i,enable(){let d=t.currentFile;t.stop(),t.start(d,{lane:"live"}),l=!0},dispose:()=>{t._presenceQuiesced=!1,l&&t.stop(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))}}}}}export{o as EditingSender,k as baselineSettled,m as conflictResolvedBySync,_ as enableAdminInputs,p as enableAdminResources,b as enableContentEditable,T as enableOnClick,v as getLastSavedBytes,f as isSaveConflicted,w as savePageThrottled,E as schedulePaintHeal,g as setLastSavedBaselines,y as setUnsavedChanges,P as syncParticipant};
@@ -1 +1 @@
1
- import{G as x,c as b,r as f,t as m,v as h,w as k}from"./c-2YIJ6ZA6.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import{b as c,d as S}from"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-LO4C4J77.js";import"./c-FV46ZKGX.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-LA2BW7UY.js";import{m as s,p as D,q as y,r as E}from"./c-HSNGLIFB.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-RXTPKCMC.js";import"./c-RBPZNU2D.js";import"./c-IJUK2GPW.js";import"./c-DLBX4JCJ.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-PWJSJEJU.js";import"./c-XQXZAO7N.js";import"./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";var O=15e3,M=Symbol("the barrier deadline passed"),A=2,e=(i,r={})=>({ok:!1,code:i,...r});async function I(i,r){let u=null,l=new Promise(a=>{u=setTimeout(()=>a(M),Math.max(0,r-Date.now()))});try{return await Promise.race([Promise.resolve(i),l])}finally{clearTimeout(u)}}async function _({generation:i=m(),keepalive:r=!1,timeoutMs:u=O,operation:l=null}={}){let a=l?null:D("mode");if(!l&&!a)return e("busy");let n=Date.now()+u,d=h(i),g=new AbortController;try{for(let w=0;;w++){if(i!==m())return e("stale-document");if(Date.now()>=n)return e("timeout");let P={permit:d,deadline:n,keepalive:r,signal:g.signal,timeoutMs:Math.max(0,n-Date.now())},t=await I(S(P),n);if(t===M)return e("timeout",{pending:c()});if(!t.ok)return f()?e("conflict",{pending:t.pending}):s()?e("save-unknown",{pending:t.pending}):e("pending-input",{pending:t.pending});if(t.pending.length)return e("pending-input",{pending:t.pending});if(f())return e("conflict");if(s())return e("save-unknown");let o;try{o=await x({keepalive:r,timeoutMs:Math.max(0,n-Date.now()),permit:d})}catch(p){return p?.state==="conflict"?e("conflict"):p?.state==="blocked"?e("pending-input",{pending:c()}):s()?e("save-unknown"):p?.timedOut||Date.now()>=n?e("timeout"):e("save-failed")}if(o.state!=="clean"&&o.state!=="saved")return e("save-failed");if(f())return e("conflict");if(s())return e("save-unknown");let v=c();if(v.length)return e("pending-input",{pending:v});if(b()){if(w+1<A&&Date.now()<n)continue;return e("pending-input")}return{ok:!0,state:o.state,etag:o.etag??null}}}finally{g.abort(),k(d),a&&y(a)}}export{D as claimOperation,E as operationKind,y as releaseOperation,_ as runSaveBarrier};
1
+ import{G as x,c as b,r as f,t as m,v as h,w as k}from"./c-VMXCX52Q.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import{b as c,d as S}from"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-P73XPAOA.js";import"./c-ZPI7M5U5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-MZCOGNZL.js";import{m as s,p as D,q as y,r as E}from"./c-MFB74XVN.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-KU3PX7LL.js";import"./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-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";var O=15e3,M=Symbol("the barrier deadline passed"),A=2,e=(i,r={})=>({ok:!1,code:i,...r});async function I(i,r){let u=null,l=new Promise(a=>{u=setTimeout(()=>a(M),Math.max(0,r-Date.now()))});try{return await Promise.race([Promise.resolve(i),l])}finally{clearTimeout(u)}}async function _({generation:i=m(),keepalive:r=!1,timeoutMs:u=O,operation:l=null}={}){let a=l?null:D("mode");if(!l&&!a)return e("busy");let n=Date.now()+u,d=h(i),g=new AbortController;try{for(let w=0;;w++){if(i!==m())return e("stale-document");if(Date.now()>=n)return e("timeout");let P={permit:d,deadline:n,keepalive:r,signal:g.signal,timeoutMs:Math.max(0,n-Date.now())},t=await I(S(P),n);if(t===M)return e("timeout",{pending:c()});if(!t.ok)return f()?e("conflict",{pending:t.pending}):s()?e("save-unknown",{pending:t.pending}):e("pending-input",{pending:t.pending});if(t.pending.length)return e("pending-input",{pending:t.pending});if(f())return e("conflict");if(s())return e("save-unknown");let o;try{o=await x({keepalive:r,timeoutMs:Math.max(0,n-Date.now()),permit:d})}catch(p){return p?.state==="conflict"?e("conflict"):p?.state==="blocked"?e("pending-input",{pending:c()}):s()?e("save-unknown"):p?.timedOut||Date.now()>=n?e("timeout"):e("save-failed")}if(o.state!=="clean"&&o.state!=="saved")return e("save-failed");if(f())return e("conflict");if(s())return e("save-unknown");let v=c();if(v.length)return e("pending-input",{pending:v});if(b()){if(w+1<A&&Date.now()<n)continue;return e("pending-input")}return{ok:!0,state:o.state,etag:o.etag??null}}}finally{g.abort(),k(d),a&&y(a)}}export{D as claimOperation,E as operationKind,y as releaseOperation,_ as runSaveBarrier};
@@ -1 +1 @@
1
- import"./c-VHNSBD2M.js";var M="data-write",E="Waiting for the page data write to finish";function n(e,t,r){let a=new Error(t);return a.code=e,a.details=r,a}async function U(e){if(typeof e.json=="function")return e.json();let t=await e.text();return t?JSON.parse(t):null}async function R(e){let t={};try{t=await U(e)||{}}catch{}let r=t.message||t.error||e.statusText||`Request failed (${e.status})`,a=new Error(r);return a.status=e.status,a.error=t.error,a.details=t.details,a}function F(e){let t=e.headers?.get?.("ETag");return typeof t=="string"&&t?t:null}function q(e,t){let r=`${t.origin}${t.pathname}`;return e!==void 0?`${r}?data=${encodeURIComponent(JSON.stringify(e))}`:`${t.origin}/_/api${t.pathname}`}function D(e){return!!e&&!e.isDestroyed&&e.sse?.readyState===1}function x(e,t){let r=[],a=null,o=null,c=null,p=i=>i?.source==="disk"&&(a===null||i.etag===a),P=i=>i?.source==="disk"&&(i.etag==null||a===null||i.etag===a),d=()=>{clearTimeout(c),e.removeEventListener("clay:sync-applied",w)},w=i=>{if(r.push(i.detail),!o||!P(i.detail))return;let u=o;o=null,d(),u(!0)};return e.addEventListener("clay:sync-applied",w),{waitFor(i){return a=i,r.some(p)?(d(),Promise.resolve(!0)):new Promise(u=>{o=u,c=setTimeout(()=>{o=null,d(),u(!1)},t)})},cancel:d}}function $(e){let t=new AbortController,r,a=new Promise((c,p)=>{r=p}),o=setTimeout(()=>{let c=new Error("The page data write timed out.");c.name="TimeoutError",t.abort(c),r(c)},e);return{signal:t.signal,waitFor(c){return Promise.race([c,a])},cancel(){clearTimeout(o)}}}async function j(){let[e,t,r,a,o]=await Promise.all([import("./core/save-FV4ZCKBI.js"),import("./core/save-core-K7XFAWQ4.js"),import("./c-TWOXQQKV.js"),import("./core/unsaved-warning-FF63QGKI.js"),import("./core/is-edit-mode-GK7IFFMT.js")]);return{...e,...t,...r,...a,...o}}async function H(){let{isDraftMode:e}=await import("./core/is-edit-mode-GK7IFFMT.js");return e?n("DataUnavailableInDraft","Page data is kept in this browser for this visitor."):null}function N({supports:e,token:t,fetchImpl:r,getLocation:a,eventTarget:o,getLiveSync:c,loadWriteModules:p=j,syncTimeoutMs:P=12e3,httpTimeoutMs:d=3e4}){let w=!1,i=!1;function u(l,{checkHold:m=!0}={}){if(l.savesAdmitted&&!l.savesAdmitted())throw n("ModeTransition","The page is switching modes. Write page data again when it has settled.");if(i)throw n("DataWriteOutcomeUnknown","A previous page data write has an unknown outcome. Reload before writing again.");if(w)throw n("DataWriteInProgress","Another page data write is already running.");if(l.isSaveInProgress())throw n("SaveInProgress","The page is already being saved.");if(l.saveFateIsUnknown())throw n("SaveOutcomeUnknown","The page's last save has an unknown outcome.");if(m&&(l.savesHeld()||l.isSaveConflicted()))throw n("SavesHeld","The page cannot write data while another save hold is active.");if(l.hasUnsavedChanges())throw n("UnsavedChanges","Save or discard the page's unsaved changes before writing data.");if(!D(c()))throw n("SyncRequired","Page data writes require the sync plugin to be connected.")}async function A(l){l.baselineSettled()||await new Promise(m=>o.addEventListener("clay:baseline-settled",m,{once:!0}))}async function I(l,{rules:m,ifMatch:O}={}){let b=await H();if(b)throw b;if(!await e(M))throw n("DataWriteUnsupported","This host does not support writing page data.");let s=await p();if(!s.isEditMode)throw n("DataWriteUnavailable","Page data writes require an editable page.");await A(s),u(s);let v=O;if(v==null&&(v=s.lastSeenEtag()||await s.seedEtag()),typeof v!="string"||v==="")throw n("DataWriteVersionRequired","Page data writes require a trustworthy document ETag.");u(s),w=!0,s.holdAllSaves(E);let g=null;try{if(s.isSaveInProgress())throw n("SaveInProgress","The page is already being saved.");if(s.saveFateIsUnknown())throw n("SaveOutcomeUnknown","The page's last save has an unknown outcome.");if(s.isSaveConflicted())throw n("SavesHeld","The page cannot write data while another save hold is active.");if(s.hasUnsavedChanges())throw n("UnsavedChanges","Save or discard the page's unsaved changes before writing data.");if(s.savesAdmitted&&!s.savesAdmitted())throw n("ModeTransition","The page is switching modes. Write page data again when it has settled.");if(!D(c()))throw n("SyncRequired","Page data writes require the sync plugin to be connected.");let W={"Content-Type":"application/json","If-Match":v},k=t();k&&(W["Save-Token"]=k);let _=JSON.stringify(l);g=x(o,P);let h=$(d),y;try{y=await h.waitFor(r(q(m,a()),{method:"POST",credentials:"same-origin",redirect:"error",headers:W,body:_,signal:h.signal}))}catch(T){throw h.cancel(),i=!0,Object.assign(n("DataWriteOutcomeUnknown","The page data write has an unknown outcome. Do not retry automatically."),{cause:T,unknownOutcome:!0})}let S;try{if(!y.ok)throw await h.waitFor(R(y));S=await h.waitFor(U(y))}catch(T){throw T?.status?T:(i=!0,Object.assign(n("DataWriteOutcomeUnknown","The page data was written, but its response could not be read."),{cause:T,unknownOutcome:!0}))}finally{h.cancel()}let f=F(y);if(f&&f===s.lastSeenEtag())return g.cancel(),g=null,{data:S,etag:f};let C=await g.waitFor(f);return g=null,C?{data:S,etag:f}:{data:S,etag:f,pageUpdatePending:!0,message:"Written, page update pending."}}finally{g?.cancel(),w=!1,s.releaseAllSaves({reason:E})}}return{writeData:I}}export{N as createPageDataWrite};
1
+ import"./c-VHNSBD2M.js";var M="data-write",E="Waiting for the page data write to finish";function n(e,t,r){let a=new Error(t);return a.code=e,a.details=r,a}async function U(e){if(typeof e.json=="function")return e.json();let t=await e.text();return t?JSON.parse(t):null}async function R(e){let t={};try{t=await U(e)||{}}catch{}let r=t.message||t.error||e.statusText||`Request failed (${e.status})`,a=new Error(r);return a.status=e.status,a.error=t.error,a.details=t.details,a}function F(e){let t=e.headers?.get?.("ETag");return typeof t=="string"&&t?t:null}function q(e,t){let r=`${t.origin}${t.pathname}`;return e!==void 0?`${r}?data=${encodeURIComponent(JSON.stringify(e))}`:`${t.origin}/_/api${t.pathname}`}function D(e){return!!e&&!e.isDestroyed&&e.sse?.readyState===1}function x(e,t){let r=[],a=null,o=null,c=null,p=i=>i?.source==="disk"&&(a===null||i.etag===a),P=i=>i?.source==="disk"&&(i.etag==null||a===null||i.etag===a),d=()=>{clearTimeout(c),e.removeEventListener("clay:sync-applied",w)},w=i=>{if(r.push(i.detail),!o||!P(i.detail))return;let u=o;o=null,d(),u(!0)};return e.addEventListener("clay:sync-applied",w),{waitFor(i){return a=i,r.some(p)?(d(),Promise.resolve(!0)):new Promise(u=>{o=u,c=setTimeout(()=>{o=null,d(),u(!1)},t)})},cancel:d}}function $(e){let t=new AbortController,r,a=new Promise((c,p)=>{r=p}),o=setTimeout(()=>{let c=new Error("The page data write timed out.");c.name="TimeoutError",t.abort(c),r(c)},e);return{signal:t.signal,waitFor(c){return Promise.race([c,a])},cancel(){clearTimeout(o)}}}async function j(){let[e,t,r,a,o]=await Promise.all([import("./core/save-K6Q47J2X.js"),import("./core/save-core-U3Z44XBO.js"),import("./c-CL5LSATX.js"),import("./core/unsaved-warning-2WRZLJH5.js"),import("./core/is-edit-mode-73OXKK5H.js")]);return{...e,...t,...r,...a,...o}}async function H(){let{isDraftMode:e}=await import("./core/is-edit-mode-73OXKK5H.js");return e?n("DataUnavailableInDraft","Page data is kept in this browser for this visitor."):null}function N({supports:e,token:t,fetchImpl:r,getLocation:a,eventTarget:o,getLiveSync:c,loadWriteModules:p=j,syncTimeoutMs:P=12e3,httpTimeoutMs:d=3e4}){let w=!1,i=!1;function u(l,{checkHold:m=!0}={}){if(l.savesAdmitted&&!l.savesAdmitted())throw n("ModeTransition","The page is switching modes. Write page data again when it has settled.");if(i)throw n("DataWriteOutcomeUnknown","A previous page data write has an unknown outcome. Reload before writing again.");if(w)throw n("DataWriteInProgress","Another page data write is already running.");if(l.isSaveInProgress())throw n("SaveInProgress","The page is already being saved.");if(l.saveFateIsUnknown())throw n("SaveOutcomeUnknown","The page's last save has an unknown outcome.");if(m&&(l.savesHeld()||l.isSaveConflicted()))throw n("SavesHeld","The page cannot write data while another save hold is active.");if(l.hasUnsavedChanges())throw n("UnsavedChanges","Save or discard the page's unsaved changes before writing data.");if(!D(c()))throw n("SyncRequired","Page data writes require the sync plugin to be connected.")}async function A(l){l.baselineSettled()||await new Promise(m=>o.addEventListener("clay:baseline-settled",m,{once:!0}))}async function I(l,{rules:m,ifMatch:O}={}){let b=await H();if(b)throw b;if(!await e(M))throw n("DataWriteUnsupported","This host does not support writing page data.");let s=await p();if(!s.isEditMode)throw n("DataWriteUnavailable","Page data writes require an editable page.");await A(s),u(s);let v=O;if(v==null&&(v=s.lastSeenEtag()||await s.seedEtag()),typeof v!="string"||v==="")throw n("DataWriteVersionRequired","Page data writes require a trustworthy document ETag.");u(s),w=!0,s.holdAllSaves(E);let g=null;try{if(s.isSaveInProgress())throw n("SaveInProgress","The page is already being saved.");if(s.saveFateIsUnknown())throw n("SaveOutcomeUnknown","The page's last save has an unknown outcome.");if(s.isSaveConflicted())throw n("SavesHeld","The page cannot write data while another save hold is active.");if(s.hasUnsavedChanges())throw n("UnsavedChanges","Save or discard the page's unsaved changes before writing data.");if(s.savesAdmitted&&!s.savesAdmitted())throw n("ModeTransition","The page is switching modes. Write page data again when it has settled.");if(!D(c()))throw n("SyncRequired","Page data writes require the sync plugin to be connected.");let W={"Content-Type":"application/json","If-Match":v},k=t();k&&(W["Save-Token"]=k);let _=JSON.stringify(l);g=x(o,P);let h=$(d),y;try{y=await h.waitFor(r(q(m,a()),{method:"POST",credentials:"same-origin",redirect:"error",headers:W,body:_,signal:h.signal}))}catch(T){throw h.cancel(),i=!0,Object.assign(n("DataWriteOutcomeUnknown","The page data write has an unknown outcome. Do not retry automatically."),{cause:T,unknownOutcome:!0})}let S;try{if(!y.ok)throw await h.waitFor(R(y));S=await h.waitFor(U(y))}catch(T){throw T?.status?T:(i=!0,Object.assign(n("DataWriteOutcomeUnknown","The page data was written, but its response could not be read."),{cause:T,unknownOutcome:!0}))}finally{h.cancel()}let f=F(y);if(f&&f===s.lastSeenEtag())return g.cancel(),g=null,{data:S,etag:f};let C=await g.waitFor(f);return g=null,C?{data:S,etag:f}:{data:S,etag:f,pageUpdatePending:!0,message:"Written, page update pending."}}finally{g?.cancel(),w=!1,s.releaseAllSaves({reason:E})}}return{writeData:I}}export{N as createPageDataWrite};
@@ -1 +1 @@
1
- import"./c-7WZSUTYP.js";import{b as s,d as n,f as l,h as m}from"./c-PGSBXHUE.js";import{f as i}from"./c-RBPZNU2D.js";import"./c-DLBX4JCJ.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var p="blockeditor-format-activation-failed";function u(){let e=document.querySelector(`meta[name="${s}"]`);return e?l(e.outerHTML):0}var F=async e=>(await import("./core/save-FV4ZCKBI.js")).savePageForce(()=>{},e),P=4,f=1e4,w=e=>e?.ok===!1&&e?.msgType==="skipped"&&/in progress/i.test(e?.msg??""),A=async()=>{let{isSaveInProgress:e}=await import("./core/save-core-K7XFAWQ4.js"),a=Date.now()+f;for(;e()&&Date.now()<a;)await new Promise(c=>setTimeout(c,50))};function k({save:e=F,settles:a=A,supported:c=()=>i().then(o=>o===1)}={}){return{read(){return{floor:Math.max(m(),u()),revision:null}},capabilities(){return[]},supported:c,async activate({floor:o=1}={}){let t;try{t=await e({blockeditorFormatFloor:o});for(let r=1;r<P&&w(t);r+=1)await a(),t=await e({blockeditorFormatFloor:o})}catch(r){return{accepted:!1,code:r?.code??p}}return t?.ok?{accepted:!0,revision:null,receipt:t.receipt??t.etag??null}:t?.code===n?{accepted:!1,code:n}:{accepted:!1,code:t?.code??p}}}}export{k as createFormatHost};
1
+ import"./c-7WZSUTYP.js";import{b as s,d as n,f as l,h as m}from"./c-PGSBXHUE.js";import{f as i}from"./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";var p="blockeditor-format-activation-failed";function u(){let e=document.querySelector(`meta[name="${s}"]`);return e?l(e.outerHTML):0}var F=async e=>(await import("./core/save-K6Q47J2X.js")).savePageForce(()=>{},e),P=4,f=1e4,w=e=>e?.ok===!1&&e?.msgType==="skipped"&&/in progress/i.test(e?.msg??""),A=async()=>{let{isSaveInProgress:e}=await import("./core/save-core-U3Z44XBO.js"),a=Date.now()+f;for(;e()&&Date.now()<a;)await new Promise(c=>setTimeout(c,50))};function k({save:e=F,settles:a=A,supported:c=()=>i().then(o=>o===1)}={}){return{read(){return{floor:Math.max(m(),u()),revision:null}},capabilities(){return[]},supported:c,async activate({floor:o=1}={}){let t;try{t=await e({blockeditorFormatFloor:o});for(let r=1;r<P&&w(t);r+=1)await a(),t=await e({blockeditorFormatFloor:o})}catch(r){return{accepted:!1,code:r?.code??p}}return t?.ok?{accepted:!0,revision:null,receipt:t.receipt??t.etag??null}:t?.code===n?{accepted:!1,code:n}:{accepted:!1,code:t?.code??p}}}}export{k as createFormatHost};
@@ -1 +1 @@
1
- import{e as g,f as h}from"./c-TRS6TM6O.js";import{d as m}from"./c-RXTPKCMC.js";import"./c-RBPZNU2D.js";import"./c-DLBX4JCJ.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import{b as f}from"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var v="clay.undo",S=1,x="conflict",N="text",k="undo";function R(){let e=f.local.get(k);return Number.isFinite(e?.count)&&e.count>0?e.count:0}function _(e){e>0?f.local.set(k,{count:e,at:Date.now()}):f.local.remove(k)}function T(){return(globalThis.window?.clay??globalThis.clay)?.recovery??null}var y=null;function p(){let e=T();if(!e||typeof e.register!="function")return null;if(y?.service===e)return y.channel;try{y={service:e,channel:e.register({channel:v,version:S})}}catch{return null}return y.channel}var O=(e,t)=>`refused:${e}:${t}`;function D(e){if(e==null||typeof document>"u")return null;let t=globalThis.CSS?.escape?globalThis.CSS.escape(String(e)):String(e).replace(/["\\]/g,"\\$&");try{return document.querySelector(`[data-id="${t}"]`)}catch{return null}}function E(){let t=(globalThis.window?.clay??globalThis.clay)?.conflicts;return typeof t?.contextFor=="function"?t:null}function A({id:e=null}={}){let t=e==null?null:String(e),r=E();return(r?r.contextFor({source:"undo",id:t,element:D(t)},null):null)??{kind:null,id:t,label:null,field:null}}function C(e){return e.map(t=>h(A(t)))}async function F(e,t,r){let n;try{n=await e.list()}catch{return}if(n?.ok){for(let o of n.records)if(!(o.key!==t||String(o.id)===String(r)))try{await e.dismiss(o.id,{revision:o.revision})}catch{}}}var w=Promise.resolve();function H(e,t){let r=w.then(()=>I(e,t));return w=r.catch(()=>{}),r}async function I(e,t){let r=p();if(!r)return{ok:!1,code:"unavailable"};let n=null;try{n=e?.describe?.(t?.entryId)??null}catch{n=null}if(!n)return{ok:!1,code:"unknown-entry"};let o=n.refused&&typeof n.refused=="object"?n.refused:{},c=t?.direction??o.direction??null,i=(Array.isArray(o.targets)?o.targets:[]).map(l=>({id:l?.id==null?null:String(l.id),kind:l?.kind==null?null:String(l.kind)})),s=O(n.id??t?.entryId,c),a=g({label:n.label??null,direction:c,code:t?.code??o.code??null,targets:i,context:C(i),steps:n.steps??[]},[],""),u;try{u=r.stage({key:s,kind:x,baseEtag:m()??null,base:null,payload:a})}catch(l){return console.error("clayjs: the refused step could not be kept for a later reload; it is still in this tab's history",l),{ok:!1,code:"error"}}let d=await r.flush();return d?.ok&&(await F(r,s,u.id),await b()),d?.ok?d:{ok:!1,code:d?.code||"error"}}async function K({key:e,label:t=null,context:r=null,payload:n=null}={}){let o=p();if(!o)return{ok:!1,code:"unavailable"};let c=e==null?"":String(e);if(!c)return{ok:!1,code:"invalid"};let i=n&&typeof n=="object"?n:{},s=g({...i,label:t,context:h(r)},[],"");try{o.stage({key:`app:${c}`,kind:typeof i.text=="string"?N:x,payload:s})}catch(u){return console.error("clayjs: the app's recovery copy could not be kept; it is still in this tab only",u),{ok:!1,code:"error"}}let a=await o.flush();return a?.ok&&await b(),a}async function b(){let e=p();if(!e)return{ok:!0,records:[]};let t=await e.list();return t?.ok&&_(Array.isArray(t.records)?t.records.length:0),t}async function q(e,{revision:t}={}){let r=p();if(!r)return{ok:!1,code:"unavailable"};let n=await r.dismiss(e,{revision:t});if(n?.ok)try{await b()}catch{}return n}export{v as UNDO_CHANNEL,x as UNDO_KIND,N as UNDO_TEXT,S as UNDO_VERSION,A as contextForTarget,q as dismissKept,K as keep,H as keepRefusal,b as kept,R as pendingUndo};
1
+ import{e as g,f as h}from"./c-TRS6TM6O.js";import{d as m}from"./c-KU3PX7LL.js";import"./c-EQ5NBOGA.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import{b as f}from"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var v="clay.undo",S=1,x="conflict",N="text",k="undo";function R(){let e=f.local.get(k);return Number.isFinite(e?.count)&&e.count>0?e.count:0}function _(e){e>0?f.local.set(k,{count:e,at:Date.now()}):f.local.remove(k)}function T(){return(globalThis.window?.clay??globalThis.clay)?.recovery??null}var y=null;function p(){let e=T();if(!e||typeof e.register!="function")return null;if(y?.service===e)return y.channel;try{y={service:e,channel:e.register({channel:v,version:S})}}catch{return null}return y.channel}var O=(e,t)=>`refused:${e}:${t}`;function D(e){if(e==null||typeof document>"u")return null;let t=globalThis.CSS?.escape?globalThis.CSS.escape(String(e)):String(e).replace(/["\\]/g,"\\$&");try{return document.querySelector(`[data-id="${t}"]`)}catch{return null}}function E(){let t=(globalThis.window?.clay??globalThis.clay)?.conflicts;return typeof t?.contextFor=="function"?t:null}function A({id:e=null}={}){let t=e==null?null:String(e),r=E();return(r?r.contextFor({source:"undo",id:t,element:D(t)},null):null)??{kind:null,id:t,label:null,field:null}}function C(e){return e.map(t=>h(A(t)))}async function F(e,t,r){let n;try{n=await e.list()}catch{return}if(n?.ok){for(let o of n.records)if(!(o.key!==t||String(o.id)===String(r)))try{await e.dismiss(o.id,{revision:o.revision})}catch{}}}var w=Promise.resolve();function H(e,t){let r=w.then(()=>I(e,t));return w=r.catch(()=>{}),r}async function I(e,t){let r=p();if(!r)return{ok:!1,code:"unavailable"};let n=null;try{n=e?.describe?.(t?.entryId)??null}catch{n=null}if(!n)return{ok:!1,code:"unknown-entry"};let o=n.refused&&typeof n.refused=="object"?n.refused:{},c=t?.direction??o.direction??null,i=(Array.isArray(o.targets)?o.targets:[]).map(l=>({id:l?.id==null?null:String(l.id),kind:l?.kind==null?null:String(l.kind)})),s=O(n.id??t?.entryId,c),a=g({label:n.label??null,direction:c,code:t?.code??o.code??null,targets:i,context:C(i),steps:n.steps??[]},[],""),u;try{u=r.stage({key:s,kind:x,baseEtag:m()??null,base:null,payload:a})}catch(l){return console.error("clayjs: the refused step could not be kept for a later reload; it is still in this tab's history",l),{ok:!1,code:"error"}}let d=await r.flush();return d?.ok&&(await F(r,s,u.id),await b()),d?.ok?d:{ok:!1,code:d?.code||"error"}}async function K({key:e,label:t=null,context:r=null,payload:n=null}={}){let o=p();if(!o)return{ok:!1,code:"unavailable"};let c=e==null?"":String(e);if(!c)return{ok:!1,code:"invalid"};let i=n&&typeof n=="object"?n:{},s=g({...i,label:t,context:h(r)},[],"");try{o.stage({key:`app:${c}`,kind:typeof i.text=="string"?N:x,payload:s})}catch(u){return console.error("clayjs: the app's recovery copy could not be kept; it is still in this tab only",u),{ok:!1,code:"error"}}let a=await o.flush();return a?.ok&&await b(),a}async function b(){let e=p();if(!e)return{ok:!0,records:[]};let t=await e.list();return t?.ok&&_(Array.isArray(t.records)?t.records.length:0),t}async function q(e,{revision:t}={}){let r=p();if(!r)return{ok:!1,code:"unavailable"};let n=await r.dismiss(e,{revision:t});if(n?.ok)try{await b()}catch{}return n}export{v as UNDO_CHANNEL,x as UNDO_KIND,N as UNDO_TEXT,S as UNDO_VERSION,A as contextForTarget,q as dismissKept,K as keep,H as keepRefusal,b as kept,R as pendingUndo};
@@ -0,0 +1 @@
1
+ import{a as Qt}from"./c-4ASQPRQL.js";import{a as Ot}from"./c-GQ6F6IDK.js";import{c as F}from"./c-I2SCCUEW.js";import{b as We}from"./c-5VYOWDTI.js";import{a as Vt,d as $,e as Ge,f as R,h as N}from"./c-P73XPAOA.js";import{a as Ke,b as Yt,c as jt,d as zt}from"./c-ZPI7M5U5.js";import{a as $t}from"./c-UGHH4MB3.js";import{a as Lt}from"./c-MZCOGNZL.js";import{a as Rt,f as Ft,g as P,h as Ut,i as qt,j as Bt,m as Ht,u as Gt,w as Wt,x as Kt}from"./c-MFB74XVN.js";import{b as Nt,h as He}from"./c-PGSBXHUE.js";import{a as qe,c as It,g as bt,h as Be}from"./c-KU3PX7LL.js";import{a as be,f as Re,h as Q}from"./c-IJUK2GPW.js";import{b as K,e as Pt,f as A}from"./c-C7SUMNMI.js";import{k as Ct,m as Mt,o as xt}from"./c-U4TWEIKZ.js";import{E as Ue,h as Ne,r as Fe,u as kt,y as V,z as me}from"./c-PNZIJFG7.js";import{d as Dt}from"./c-MOP5KBWZ.js";import{a as pe}from"./c-2YYDMLNZ.js";import{d as Et,e as wt,g as At,h as Tt}from"./c-HA6INT6J.js";import{k as _t}from"./c-ICMAOOGK.js";var An="clay:debug:autosave";function ve(){try{return localStorage.getItem(An)==="true"}catch{return!1}}function ge(){return import("./c-CFHW5AMY.js").catch(e=>(console.warn("[autosave-debug] Failed to load the debug logger:",e),null))}function he(e,t){ve()&&ge().then(n=>n?.logSaveCheck(e,t))}function re(e,t=""){ve()&&ge().then(n=>n?.logBaseline(e,t))}function Xt(e,t){ve()&&ge().then(n=>n?.logUnloadDiffSync(e,t))}function Jt(){ve()&&ge().then(e=>e?.preloadIfEnabled())}var U=Number.NEGATIVE_INFINITY;function Tn({firstDirtyAt:e=U,lastActivityAt:t=U,finishedAt:n=U,costMs:o=0}={}){let r=e??U,i=t??U,a=n??U,f=Math.min(3e4,Math.max(1200,4*o)),u=Math.max(i,a)+1500,m=Math.max(r+1e4,a+f);return Math.max(a+1200,Math.min(u,m))}function Zt({now:e=()=>Date.now(),setTimer:t=(r,i)=>setTimeout(r,i),clearTimer:n=r=>clearTimeout(r),run:o=()=>{}}={}){let r=null,i=null,a=U,f=0,u=null,m=null,c=!1,p=!1;function S(){return Tn({firstDirtyAt:r,lastActivityAt:i,finishedAt:a,costMs:f})}function y(){if(!c||p)return;let E=S();if(u!==null){if(m===E)return;n(u)}m=E,u=t(d,Math.max(0,E-e()))}function d(){if(u=null,m=null,!(!c||p)){if(e()<S()){y();return}g()}}function g(){c=!1,p=!0,r=null,i=null;let E;try{E=o()}catch{l();return}Promise.resolve(E).then(l,l)}function l(){p=!1,a=e(),c&&y()}function s({at:E=e()}={}){r===null&&(r=E),i=E,c=!0,y()}function v(){c=!0,y()}function M(E){E>0&&(f=Math.max(E,f*.8))}return{noteActivity:s,request:v,noteCost:M,dueAt:S,costEstimate:()=>f,pending:()=>c||p,running:()=>p}}Fe(e=>{for(let t of Tt)e.removeAttribute(t)});Fe(e=>{for(let t of[...Et,...wt,...At])e.removeAttribute(t)});var x=null;function w(e,t="",n="",o=null){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus",e);let r=new CustomEvent(`clay:save-${e}`,{detail:{msg:t,msgType:n,timestamp:Date.now(),...o||{}}});document.dispatchEvent(r),Mn(e,r.detail)}var an=Symbol.for("clay.saveFailureClaimed"),Br=e=>{e?.detail&&(e.detail[an]=!0)},Ee=null,un=()=>(Ee??=import("./c-BOMQIQ3V.js").catch(e=>{throw Ee=null,e}),Ee),Cn=()=>{un().then(e=>e.warm(),()=>{})};for(let e of["beforeinput","keydown","pointerdown"])document.addEventListener(e,Cn,{once:!0,capture:!0});function Mn(e,t){if(e==="saved"){Ee?.then(n=>n.clearFailures(),()=>{});return}e!=="error"&&e!=="offline"||t?.[an]||un().then(n=>n.reportFailure(e),n=>{console.error("clayjs: a save failed and the notice for it could not be downloaded",n)})}function ot(){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus","offline")}function xn(){x=setTimeout(()=>{w("saving")},500)}window.addEventListener("offline",()=>{ot()});window.addEventListener("online",()=>{document.documentElement.getAttribute("savestatus")==="offline"&&I().then(e=>{e.msgType==="skipped"&&document.documentElement.getAttribute("savestatus")==="offline"&&document.documentElement.setAttribute("savestatus","saved")})});var q=!1,k="",C="",ie=0,we=new Set,D=!1,L=!1,Ae=!1,B=0,je=!1;function Pn(){B++}function ln(){B!==0&&(B--,!(B>0)&&(fe&&(fe=!1,Z=setTimeout(mt,0)),je&&(je=!1,Oe())))}function _n(){return B>0}var Y=0,ne=!1,ae=!1,Te=!1;function de(e=null){return Y===0||dn(e)}function st(){return ne}function Dn(){if(ne)return!0;try{let e=V({flushUndo:!1});return St(e)?!1:e!==C}catch{return!0}}function Ln(){let e="idle",t=0;return{get phase(){return e},get open(){return e==="open"},changedWhileClosed(){return e==="quiesced"&&Ge()!==t},start(){e==="idle"&&(e="open")},quiesce(){e==="open"&&(e="quiesced",t=Ge(),Y++)},resume(){e==="quiesced"&&(e="open",Y--,!(Y>0)&&(zn(),on()))},stop(){if(e==="stopped")return;let n=e==="quiesced";(n||e==="open")&&Dn()&&(Te=!0),e="stopped",n&&(Y--,Y===0&&on())}}}var en=!1,oe=null,ze=null,Xe=!1;function Hr(e=b){if(!oe||oe.generation!==e)return null;let{bytes:t,etag:n}=oe;return{bytes:t,etag:n}}function Gr({represented:e}={}){let t=R(),{forComparison:n,forDirty:o}=me(),r=typeof e?.etag=="string"&&e.etag?e.etag:null;return!(Xe&&r!==null&&r!==ze)&&Te&&(n!==k||o!==C)?{ok:!1,code:"pending-input"}:(Te=!1,ue(n,o),W=n,ee=!1,vt=!0,ze=r,Xe=!0,N(t),document.documentElement.setAttribute("savestatus","saved"),document.dispatchEvent(new CustomEvent("clay:baseline-settled")),{ok:!0})}var it=Promise.resolve(!1),Ce=!1,kn=()=>(Ce=!0,bt().catch(()=>!1).then(e=>(Ce=!1,e)));function Wr(){return{id:"clay:save",order:10,prepare(e={}){let t=Ln();return e.initial===!0&&t.start(),{enable(){it=kn();let n=e.represented?.etag;typeof n=="string"&&n&&It(n),e.initial!==!0&&(On(),t.start())},quiesce:()=>t.quiesce(),resume:()=>t.resume(),dispose:()=>t.stop()}}}}function On(){en||(en=!0,Vt(),be(),En(),wn())}var O=0,Je=!1,Me=!1,at="Waiting for the AI edit to be kept or reverted",j=new Map;function Kr(e=at){O++,j.set(e,(j.get(e)||0)+1)}function Qr({replay:e=!0,reason:t=at}={}){let n=j.get(t)||0;if(n===0||(n===1?j.delete(t):j.set(t,n-1),O--,O>0))return;let o=Je,r=Me;Je=!1,Me=!1,e&&(o?I():r&&Oe())}function Vr(){return O>0}function ut(){return O===0?null:j.keys().next().value||at}function fn(e,t){if(O===0)return!1;Je=!0,Q();let n=h(ut());return e(n),t(n),n}var H=!1,se=null;function In(e){se=e??null,!H&&(H=!0,Pn())}function bn(){H&&(H=!1,se=null,ln())}function Ze(){return H}function $r(e){if(!H||se&&e!==se)return;H=!1,se=null,!We()&&$()||(document.documentElement.getAttribute("savestatus")==="conflict"&&document.documentElement.setAttribute("savestatus","saved"),document.dispatchEvent(new CustomEvent("clay:save-conflict-resolved",{detail:{timestamp:Date.now()}}))),document.dispatchEvent(new CustomEvent("clay:save-conflict-released",{detail:{etag:e??null}})),ln()}function h(e){return{ok:!1,msg:e,msgType:"skipped",code:null,etag:null}}function lt(e){return($()||F())&&(ne=!0),h(e)}function cn(){return{ok:!1,msg:"You are not allowed to save this document.",msgType:"forbidden",code:"forbidden",status:403,sent:!1,etag:null}}function ft(){return Pt()===!1}var ct=new Set,b=0;function Yr(){return b}function jr(e){typeof e=="number"&&(b=e)}function Rn(e=b){let t=Object.freeze({generation:e});return ct.add(t),t}function Nn(e){ct.delete(e)}function dn(e){return!!e&&ct.has(e)&&e.generation===b}function z(e,t){e!=null&&zt({captureId:e,ok:t.ok===!0,etag:t.etag??null})}function Fn(e,t,n,o,r,i=null,a=null,f=!1){if(z(a,e),e.ok)ne=!1,ue(t,n),xe=i,oe={bytes:i,etag:qe(),generation:b},ze=oe.etag,Xe=!0,Te=!1,q=!1,N(r),w("saved",e.msg||"Saved",e.msgType,{etag:e.etag??null,captureId:a}),re(o,`${k.length} chars`),bn();else if(e.msgType==="conflict"){if(f){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus","saved");return}In(e.conflictEtag),w("conflict",e.msg,e.msgType,{hadTimeout:e.hadTimeout===!0,changedBy:e.changedBy??null,afterTimeout:e.afterTimeout===!0,etag:e.conflictEtag??null,code:e.code??null,reason:e.reason??null,retryAfter:e.retryAfter??null,captureId:a})}else if(e.msgType!=="skipped"){let u={status:e.status??null,hadTimeout:e.hadTimeout===!0,code:e.code??null,reason:e.reason??null,retryAfter:e.retryAfter??null,captureId:a};navigator.onLine?w("error",e.msg,"",u):w("offline",e.msg,"",u)}}function pn(){if(!(!D&&!L)&&!Ht()){if(D){D=!1,L=!1,I();return}L=!1,nt.request()}}function zr(){return q}function Xr(e){q=e}function Jr(){return k}function dt(){return C}var xe=null;function Zr(){return xe}function ue(e,t){k=e,C=t,ie++}function eo(e){ue(e,e)}var G=()=>typeof performance<"u"&&performance.now?performance.now():Date.now();var Un=4,tn="Save cancelled: the page changed while it prepared",X=null,le=null,Qe=null,mn=!1;function vn(){return Qe||(Qe=import("./c-WGQVSKKC.js").then(e=>(le=e,e),e=>(mn=!0,console.info("clayjs: sliced save off ("+(e&&e.message?e.message:e)+"); saves prepare in one task"),null))),Qe}function qn(){try{return performance.getEntriesByType("navigation")[0]?.decodedBodySize||0}catch{return 0}}var Bn=()=>typeof xe=="string"?xe.length:qn();function Pe(){return mn||document.hidden||Bt()?!1:Bn()>=307200}function nn(e,t,n){return n?"morph":b!==t.generation||!A?"mode":de(e.permit)?ft()?"refused":ie!==t.baselines?"newer save":Math.max(He(),e.blockeditorFormatFloor)>t.floor?"floor":null:"session"}function Hn(e=150,t=2e3){return new Promise(n=>{let o=G(),r=null,i=()=>{document.removeEventListener("clay:sync-applied",a),n()},a=()=>{clearTimeout(r),r=setTimeout(i,Math.max(0,Math.min(e,t-(G()-o))))};document.addEventListener("clay:sync-applied",a),a()})}async function pt({explicit:e,forced:t=!1,forSave:n,forComparison:o,forDirty:r,captureId:i,gateToken:a,costMs:f,blockeditorFormatFloor:u=0,quietConflict:m=!1,laneHeld:c=!1,lane:p=null,capture:S,noteRecovery:y,release:d,callback:g}){if(y(),e&&!t){if(q=r!==C,he("savePage dirty check",!q),!q){Q(),N(a),d();let s=h("No changes to save");return z(i,s),typeof g=="function"&&g(s),{result:s,dispatched:!1}}}else if(!e){let s=!ee||o!==W,v=o!==k;if(he("throttled vs baseline",!s),he("throttled vs lastSave",!v),!(s&&v)){let M=!1;try{M=!v&&(!document.querySelector(_t)||$()&&r===C)}catch(yt){console.error("savePageThrottled: dirty domain check failed",yt)}M&&N(a),nt.noteCost(f),d();let E=h("No changes to save");return z(i,E),typeof g=="function"&&g(E),{result:E,dispatched:!1}}if(q=!0,!c&&P()){D=!0,d();let M=h("Save already in progress");return z(i,M),typeof g=="function"&&g(M),{result:M,dispatched:!1}}}xn();let l={forComparison:o,forDirty:r};return we.add(l),Ae=!0,new Promise(s=>{Gt(n,i,v=>{Ae=!1,we.delete(l);let M=G();Fn(v,l.forComparison,l.forDirty,t?"updated after force save":"updated after save",a,n,i,m),e||nt.noteCost(f+(G()-M)),typeof g=="function"&&g(v),s({result:v,dispatched:!0}),c||pn()},{capture:S,blockeditorFormatFloor:u,lane:p,gateToken:a})})}async function Gn(e,t){let n={over:!1},o=()=>{n.over=!0};document.addEventListener("clay:sync-applied",o);try{for(let i=0;i<2;i++){let a=R(),f={generation:b,baselines:ie,floor:Math.max(He(),e.blockeditorFormatFloor)},u=le.beginSaveCapture({requestRefresh:!0,forRequest:!0,pageFormatMarker:f.floor?{name:Nt,content:String(f.floor)}:null});Yt(u.captureId);let m=null,c={get aborted(){let d=nn(e,f,n.over);return d&&(m=d),!!d}},p;try{p=await le.runPreparedSteps(u.steps(),{budgetMs:Un,signal:c})}catch(d){console.error(`${e.explicit?"savePage":"savePageThrottled"}: preparing the save failed`,d),u.drop();let g={msg:d&&d.message?d.message:"Save failed",msgType:"error",code:d?.code??null,etag:null};return w("error",g.msg,"",{sent:!1,code:g.code}),z(u.captureId,g),typeof e.callback=="function"&&e.callback(g),{result:g,dispatched:!1}}let S=p.aborted?m:nn(e,f,n.over);if(!S){let d=p.result;return await pt({explicit:e.explicit,forced:e.forced,forSave:d.forSave,forComparison:d.forComparison,forDirty:d.forDirty,captureId:d.captureId,gateToken:a,costMs:p.activeMs,blockeditorFormatFloor:e.blockeditorFormatFloor,quietConflict:e.quietConflict,laneHeld:!0,lane:t,capture:d,noteRecovery:()=>jt(d.captureId,d.forSave),release:()=>u.drop(),callback:e.callback})}u.drop();let y=h(tn);if(S==="session"&&(ae=!0),z(u.captureId,y),!(S==="floor"&&i===0)){if(S==="morph"&&e.explicit&&i===0){await Hn(),n.over=!1;continue}return typeof e.callback=="function"&&e.callback(y),{result:y,dispatched:!1}}}let r=h(tn);return typeof e.callback=="function"&&e.callback(r),{result:r,dispatched:!1}}finally{document.removeEventListener("clay:sync-applied",o),qt(t)}}function gn(e){let t=Ut();if(!t)return!1;let n=Gn(e,t).catch(o=>{console.error("save: preparing the save failed",o);let r={msg:o&&o.message?o.message:"Save failed",msgType:"error",code:o?.code??null,etag:null};return w("error",r.msg,"",{sent:!1,code:r.code}),typeof e.callback=="function"&&e.callback(r),{result:r,dispatched:!1}});return X=n,n.then(o=>{X===n&&(X=null),e.resolve(o.result),e.settleSoonQueued(o.result),(o.dispatched||D||L||Le.length)&&pn()}),!0}function ke(e,t=()=>{}){return Ce?it.then(()=>ke(e,t)):te?ce.then(()=>De(e,t)):De(e,t)}function _e(e,t){let n=!1,o=setTimeout(()=>{n=!0,w("saving")},500);return e.then(()=>(clearTimeout(o),t())).then(r=>(n&&!P()&&!$()&&document.documentElement.getAttribute("savestatus")==="saving"&&(document.documentElement.setAttribute("savestatus","saved"),document.dispatchEvent(new CustomEvent("clay:save-status",{detail:{state:"saved"}}))),r))}function De({kind:e,permit:t=null},n=()=>{}){let o=e==="explicit";return new Promise(r=>{if(!A&&!window.clay?.testMode){o&&Q();let s=h("Not in edit mode");return T().forEach(v=>v(s)),n(s),r(s)}if(!de(t)){ae=!0;let s=lt("Save session is quiesced");return o&&T().forEach(v=>v(s)),n(s),r(s)}if(ft()){o&&Q();let s=cn();return w("error",s.msg,"",{code:s.code,status:s.status,sent:!1}),T().forEach(v=>v(s)),n(s),r(s)}if(o){let s=fn(n,r);if(s){T().forEach(v=>v(s));return}if(P()){D=!0;let v=h("Save already in progress");return n(v),r(v)}}else{if(O>0){Me=!0;let s=h(ut());return n(s),r(s)}if(P()&&!ee&&Ae){L=!0;let s=h("Save already in progress");return n(s),r(s)}if(X){L=!0;let s=h("Save already in progress");return n(s),r(s)}if(!ee&&!$()){let s=h("No changes to save");return n(s),r(s)}}let i=window.clay?.source?.ensureForSave?.();if(i)return r(_e(i,()=>De({kind:e,permit:t},n)));if(Pe()&&!le){r(_e(vn(),()=>De({kind:e,permit:t},n)));return}let a=o?T():[],f=s=>a.forEach(v=>v(s));if(!navigator.onLine&&ot(),Pe()&&gn({explicit:o,forced:!1,permit:t,blockeditorFormatFloor:0,quietConflict:!1,settleSoonQueued:f,callback:n,resolve:r}))return;let m=G(),c,p,S,y,d,g=R();try{c=Ue({requestRefresh:!0,forRequest:!0}),{forSave:p,forComparison:S,forDirty:y,captureId:d}=c}catch(s){console.error(`${o?"savePage":"savePageThrottled"}: captureForSaveAndComparison failed`,s),o?(Q(),w("error",s.message,"",{sent:!1,code:s.code??null})):w("error",s.message);let v={msg:s.message,msgType:"error",code:o?s.code??null:null,etag:null};typeof n=="function"&&n(v),r(v),f(v);return}let l=G()-m;pt({explicit:o,forSave:p,forComparison:S,forDirty:y,captureId:d,gateToken:g,costMs:l,capture:c,noteRecovery:()=>Ke({captureId:d,html:p}),release:()=>Ne(c),callback:n}).then(s=>{r(s.result),f(s.result)})})}function I(e=()=>{}){return ke({kind:"explicit"},e)}function Wn(e,t=()=>{}){return ke({kind:"explicit",permit:e},t)}function J(e=()=>{},{quietConflict:t=!1,blockeditorFormatFloor:n=0,permit:o=null}={}){return Ce?it.then(()=>J(e,{quietConflict:t,blockeditorFormatFloor:n,permit:o})):new Promise(r=>{if(!A&&!window.clay?.testMode){let l=h("Not in edit mode");return T().forEach(s=>s(l)),e(l),r(l)}if(!de(o)||o&&!dn(o)){let l=lt("Save session is quiesced");return T().forEach(s=>s(l)),e(l),r(l)}if(ft()){let l=cn();return w("error",l.msg,"",{code:l.code,status:l.status,sent:!1}),T().forEach(s=>s(l)),e(l),r(l)}let i=fn(e,r);if(i){T().forEach(l=>l(i));return}if(P()){D=!0;let l=h("Save already in progress");return T().forEach(s=>s(l)),e(l),r(l)}let a=window.clay?.source?.ensureForSave?.();if(a)return r(_e(a,()=>J(e,{quietConflict:t,blockeditorFormatFloor:n,permit:o})));if(!navigator.onLine&&ot(),Pe()&&!le){r(_e(vn(),()=>J(e,{quietConflict:t,blockeditorFormatFloor:n,permit:o})));return}let u=T(),m=l=>u.forEach(s=>s(l));if(Pe()&&gn({explicit:!0,forced:!0,permit:o,blockeditorFormatFloor:n,quietConflict:t,settleSoonQueued:m,callback:e,resolve:r}))return;let c,p,S,y,d,g=R();try{c=Ue({requestRefresh:!0,forRequest:!0}),{forSave:p,forComparison:S,forDirty:y,captureId:d}=c}catch(l){console.error("savePageForce: captureForSaveAndComparison failed",l),w("error",l.message,"",{sent:!1,code:l.code??null});let s={msg:l.message,msgType:"error",code:l.code??null,etag:null};typeof e=="function"&&e(s),r(s),m(s);return}pt({explicit:!0,forced:!0,forSave:p,forComparison:S,forDirty:y,captureId:d,gateToken:g,costMs:0,blockeditorFormatFloor:n,quietConflict:t,capture:c,noteRecovery:()=>Ke({captureId:d,html:p}),release:()=>Ne(c),callback:e}).then(l=>{r(l.result),m(l.result)})})}Kt(e=>J(()=>{},{permit:e}));function Kn(e){let t=["clay:save-saved","clay:save-error","clay:save-offline","clay:save-conflict"];return new Promise((n,o)=>{let r=null,i=()=>{clearTimeout(r);for(let u of t)document.removeEventListener(u,a)},a=()=>{i(),n()},f=e-Date.now();if(f<=0){o(Object.assign(new Error("Save timed out."),{state:"failed"}));return}r=setTimeout(()=>{i(),o(Object.assign(new Error("Save timed out."),{state:"failed"}))},f);for(let u of t)document.addEventListener(u,a)})}function _(e,t){return Object.assign(new Error(e),{state:t})}function Qn(e,t){return new Promise((n,o)=>{let r=t-Date.now();if(r<=0)return o(_("Save timed out.","failed"));let i=setTimeout(()=>{document.removeEventListener(e,a),o(_("Save timed out.","failed"))},r),a=()=>{clearTimeout(i),n()};document.addEventListener(e,a,{once:!0})})}async function to({keepalive:e=!1,timeoutMs:t=15e3,permit:n=null}={}){if(!A)return{state:"view",etag:null};let o=Date.now()+t,r=n||Rn(),i={over:!1},a=null,f=new Promise((u,m)=>{a=setTimeout(()=>m(Object.assign(_("Save timed out.","failed"),{timedOut:!0})),Math.max(0,t))});try{return await Promise.race([Vn(e,o,r,i),f])}catch(u){throw u&&typeof u.state=="string"?u:_(u?.message||"Save failed","failed")}finally{i.over=!0,clearTimeout(a),n||Nn(r)}}async function Vn(e,t,n,o={over:!1}){if(hn()||await Qn("clay:baseline-settled",t),o.over)return null;let r=!1,i=null;for(let a=0;a<4;a++){if(X&&(await X,o.over)||P()&&(await Kn(t),o.over))return null;if(Ze())throw _("This document has a conflict to resolve.","conflict");let f=R();if(!rt()){if(N(f),F())throw _("This document has unsaved work a save cannot write.","blocked");return ne=!1,{state:r?"saved":"clean",etag:i??qe()}}if(o.over)return null;let u=await Ft(e,()=>Wn(n));if(u.msgType!=="skipped"){if(!u.ok)throw _(u.msg||"Save failed",u.msgType==="conflict"||Ze()?"conflict":"failed");r=!0,i=u.etag??null}}throw _("The document kept changing while saving.","failed")}async function no(e=()=>{}){return await Be({fresh:!0}),J(e)}function ro(e){!A||K||Wt(e,t=>{t.ok?window.location.reload():t.msgType==="skipped"?w("error",t.msg||"Template not saved"):w("error",t.msg||"Failed to save template")})}var $n=Ot(e=>ke({kind:"automatic"},e),1200),Yn=250,jn=1e3,Z=null,rn=0,et=[],Le=[],fe=!1,T=()=>{let e=Le;return Le=[],e};function mt(){if(Z=null,B>0||!de()){fe=!0;return}let e=et;if(et=[],P()){Le.push(...e),I();return}I().then(t=>e.forEach(n=>n(t)))}function oo(){let e=Date.now();return Z===null?rn=e:clearTimeout(Z),new Promise(t=>{et.push(t),Z=setTimeout(mt,Math.max(0,Math.min(Yn,rn+jn-e)))})}function zn(){ae&&(ae=!1,Oe())}function on(){fe&&(fe=!1,Z=setTimeout(mt,0))}var W="",ee=!0,vt=!1;function hn(){return vt}var Ve=!1,Xn=250,Jn=1250,$e=null,Sn="clay:paint-heal:"+location.pathname;function yn(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)|0;return String(t>>>0)}function Zn(e){try{return localStorage.getItem(Sn)===yn(e)}catch{return!1}}function er(e){try{localStorage.setItem(Sn,yn(e))}catch{}}function tr(){return Dt(kt({flushUndo:!1}))}function so(e){!A||K||(clearTimeout($e),$e=setTimeout(async()=>{$e=null,te&&await ce;let t=typeof e=="function"?e():e;t==null||!We()||!hn()||Ze()||_n()||V({flushUndo:!1})===C&&t!==tr()&&(Zn(t)||(er(t),J(()=>{},{quietConflict:!0})))},Xn+Math.random()*Jn))}var Se=null,Ye=null,te=0,ce=Promise.resolve(),gt=!1,ht=[];function nr(){return Ye??=import("./c-KNPDOMDY.js").catch(e=>(Ye=null,console.error("style-comparisons failed to load",e),null)),Ye}async function rr(e){try{if(Se||(Se=(await nr())?.styleComparisonStripper??null),!Se)return;let t=Se(e);k=t(k),C=t(C),W=t(W);for(let n of we)n.forComparison=t(n.forComparison),n.forDirty=t(n.forDirty)}catch(t){console.error("style adoption failed",t)}finally{te--,ht.shift()}}var ye=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;");function or(e){if(e.name!==void 0){let n=[`data-name="${ye(e.name)}"`];return e.legacyId!==void 0&&n.push(`id="${ye(e.legacyId)}"`),n}let t=[ye(e.href)];try{let{pathname:n}=new URL(e.href);n&&t.push(ye(n))}catch{}return t}function sr(e){let t=[k,C,W];for(let n of we)t.push(n.forComparison,n.forDirty);return t.some(n=>n&&e.some(o=>o&&n.includes(o)))}function ir(e,t){let n=[];for(let{markers:i,tag:a}of t)for(let f of i)for(let u=e.indexOf(f);u>=0;u=e.indexOf(f,u+f.length)){let m=e.lastIndexOf("<",u);if(m<0||e.slice(m+1,m+1+a.length).toLowerCase()!==a)continue;let c=a==="style"?e.indexOf("</style",u):u;if(c<0)continue;let p=e.indexOf(">",c);p>=0&&n.push([m,p+1])}n.sort((i,a)=>i[0]-a[0]);let o="",r=0;for(let[i,a]of n)i<r||(o+=e.slice(r,i),r=a);return o+e.slice(r)}$t(e=>{let t=or(e);sr(t)&&(te||(gt=!1),te++,ht.push({markers:t,tag:e.name!==void 0?"style":"link"}),ce=ce.then(()=>rr(e)))});function io(){return ce}function St(e){return!te||gt||F()||P()||D||L||ne||typeof e!="string"?!1:e===ir(C,ht)}var ar=500,ur=3e3,lr=1e4,tt=null;function fr(){pe.holdSettle=!1,tt&&tt()}function sn(){if(!A)return;let e=!1,t=null,{forComparison:n,forDirty:o}=me();ue(n,o);let r=ie;W=n,re("immediate capture",`${n.length} chars`);let i=["keydown","pointerdown","drop","input","change","paste"],a=new Set(["Shift","Control","Alt","Meta"]),f=c=>{c.type==="keydown"&&a.has(c.key)||(gt=!0,e||(Ve=!0))};i.forEach(c=>document.addEventListener(c,f,!0));let u=()=>{if(!e){if(e=!0,t&&t(),!Ve&&ie===r){let c=R(),{forComparison:p,forDirty:S}=me();ue(p,S),W=p,N(c),re("settled capture",`${p.length} chars`)}else re("settled skipped",Ve?"user edited":"save occurred during settle");ee=!1,document.documentElement.setAttribute("savestatus","saved"),vt=!0,document.dispatchEvent(new CustomEvent("clay:baseline-settled"))}};tt=u;let m=()=>{pe.holdSettle||u()};t=Lt.onAnyChange({debounce:ar,omitChangeDetails:!0,require:"autosave"},m),setTimeout(()=>{e||m()},ur),setTimeout(()=>{!e&&pe.holdSettle&&fr()},lr)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",sn):sn();function Oe(e=()=>{}){if(!A){let t=h("Not in edit mode");return e(t),Promise.resolve(t)}if(O>0){Me=!0;let t=h(ut());return e(t),Promise.resolve(t)}if(!de()){ae=!0;let t=lt("Save session is quiesced");return e(t),Promise.resolve(t)}if(B>0){je=!0;let t=h("Autosave suspended");return e(t),Promise.resolve(t)}if(!ee&&Ae){L=!0;let t=h("Save already in progress");return e(t),Promise.resolve(t)}return $n(e).catch(t=>{let n={ok:!1,msg:t?.message||"Save failed",msgType:"error",code:null,etag:null};return w("error",n.msg),n})}var nt=Zt({now:G,run:()=>Oe()});function En(){document.addEventListener("keydown",function(e){if((window.navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)&&e.keyCode==83){if(!A)return;e.preventDefault(),e.isTrusted&&Re(),I()}})}function wn(){document.addEventListener("click",e=>{e.target.closest("[trigger-save]")&&(e.isTrusted&&Re(),I())})}function cr(){A&&(Be(),Rt(),be(),En(),wn())}cr();var ao=I;var Ie=!1;function go({isCurrent:e,reload:t}){return e()?(Ie=!0,setTimeout(()=>{Ie=!1},1e3),t(),!0):!1}Jt();function dr(){return st()?!0:A?F()?!0:K?Mt()||xt():window.clay?.demo?!1:rt():!1}function rt(){if(!A)return!1;try{let e=V();return St(e)?!1:e!==dt()}catch{return!0}}window.addEventListener("beforeunload",e=>{if(!A&&!st())return;if(Ie){Ie=!1;return}if(!((!K||Ct())&&!dr())&&(e.preventDefault(),e.returnValue="",!window.clay?.demo&&!F()))try{let n=V(),o=dt();n!==o&&Xt(n,o)}catch{}});export{go as a,dr as b,rt as c,Br as d,Pn as e,ln as f,_n as g,de as h,st as i,Ln as j,Hr as k,Gr as l,Wr as m,Kr as n,Qr as o,Vr as p,ut as q,Ze as r,$r as s,Yr as t,jr as u,Rn as v,Nn as w,zr as x,Xr as y,Jr as z,dt as A,Zr as B,ue as C,eo as D,I as E,J as F,to as G,no as H,ro as I,oo as J,hn as K,tr as L,so as M,io as N,St as O,fr as P,Oe as Q,nt as R,En as S,wn as T,cr as U,ao as V};
@@ -1 +1 @@
1
- import{a as O}from"./c-WN3MXOLT.js";import{d as A}from"./c-RBPZNU2D.js";var p=1,D=8*1024,B=256,L=1024,Y=128,X=128,G=Object.freeze(["title","description","labels","members","dates","checklist","comment","attachments"]),m=250,E=5e3,it=15e3;var W=new Set(["kind","id","field"]),$=new Set(["kind","v","epoch","generation","selection"]),q=new Set(["kind","anchor","head"]),F=new Set(["kind","ids"]),J=new Set(["kind","block","row","col"]),V=new Set(["block","rel"]),H=/^[\x20-\x7e]+$/,U=/^[A-Za-z0-9+/]+={0,2}$/,Z=/[\u0000-\u001f\u007f]/,o=t=>({ok:!1,reason:t}),a=t=>({ok:!0,target:t}),g=t=>!!t&&typeof t=="object"&&!Array.isArray(t),d=(t,e)=>{for(let n of Object.keys(t))if(!e.has(n))return!1;return!0};function T(t){let e=0;for(let n of t){let s=n.codePointAt(0);e+=s<128?1:s<2048?2:s<65536?3:4}return e}function u(t){return typeof t=="string"&&t.length>0&&!Z.test(t)&&T(t)<=B}function Q(t){if(typeof t!="string"||!t.length||t.length%4!==0||!U.test(t))return!1;let e=t.endsWith("==")?2:t.endsWith("=")?1:0;return t.length/4*3-e<=L}function _(t){return!g(t)||!d(t,V)||!u(t.block)||!Q(t.rel)?null:{block:t.block,rel:t.rel}}function v(t){if(!g(t))return null;if(t.kind==="text"){if(!d(t,q))return null;let e=_(t.anchor),n=_(t.head);return e&&n?{kind:"text",anchor:e,head:n}:null}if(t.kind==="blocks"){if(!d(t,F)||!Array.isArray(t.ids)||!t.ids.length||t.ids.length>X)return null;for(let e of t.ids)if(!u(e))return null;return{kind:"blocks",ids:[...t.ids]}}return t.kind==="cell"?!d(t,J)||!u(t.block)||!u(t.row)||!u(t.col)?null:{kind:"cell",block:t.block,row:t.row,col:t.col}:null}function w(t){return T(JSON.stringify(t))<=D}function tt(t){if(!d(t,W))return o("key");let e=t.id;if(typeof e!="string"||!e.length||e.length>Y||!H.test(e))return o("id");if(t.field===void 0){let s={kind:"record",id:e};return w(s)?a(s):o("size")}if(typeof t.field!="string"||!G.includes(t.field))return o("field");let n={kind:"record",id:e,field:t.field};return w(n)?a(n):o("size")}function et(t){if(!d(t,$))return o("key");if(t.v!==p)return o("version");if(!u(t.epoch))return o("epoch");if(!Number.isSafeInteger(t.generation)||t.generation<0)return o("generation");let e=v(t.selection);if(!e)return o("selection");let n={kind:"blockeditor",v:p,epoch:t.epoch,generation:t.generation,selection:e};return w(n)?a(n):o("size")}function y(t){return t===null?a(null):typeof t=="string"?O.test(t)?a(t):o("path"):g(t)?t.kind==="record"?tt(t):t.kind==="blockeditor"?et(t):o("kind"):o("shape")}function R(t){let e=y(t===void 0?null:t);return!e.ok||e.target!==null&&typeof e.target=="object"&&e.target.kind!=="record"?null:e.target}function z(t){return t==null?"":typeof t=="string"?`path:${t}`:`target:${JSON.stringify(t)}`}function C(t,e=null){let n=Array.isArray(t)?t:[],s=[];for(let i of n){if(!g(i))continue;let r=u(i.id)?i.id:null;if(!r)continue;let h=Number.isSafeInteger(i.n)&&i.n>=0?i.n:0,c=e&&e.get(r);if(c&&h<c.n){s.push(c);continue}let f=y(i.editing===void 0?null:i.editing);s.push({id:r,you:i.you===!0,n:h,editing:f.ok?f.target:null})}return s}function I(t){if(!g(t))return null;let e=u(t.id)?t.id:null,n=typeof t.token=="string"&&t.token.length?t.token:null;return e&&n?{id:e,token:n}:null}function N({target:t=null,session:e=null,n=0}){if(t==null||typeof t=="string")return{editing:t??null};let s=e&&typeof e.token=="string"&&e.token.length?e.token:null;return s?!Number.isSafeInteger(n)||n<0?null:{v:p,session:s,n,editing:t}:t.kind==="record"?{editing:t}:null}var nt=()=>Object.freeze({supported:!1,recordAwareness:!1,pageAwareness:!1,people:Object.freeze([]),anonymous:0}),k=class{constructor(){this.supported=!1,this.recordAwareness=!1,this.pageAwareness=!1,this.people=[],this.anonymous=0,this.snapshot=nt(),this.listeners=new Set,this.sessions=new Map,this.session=null,this.target=null,this.heldKey="",this.owner=null,this.explicit=!1,this.connecting=null,this.n=0,this.sentKey=null,this.timer=null,this.timerKind=null,this.inflight=!1,this.inflightOwner=null,this.inflightKey=null}getSnapshot(){return this.snapshot}subscribe(e){if(typeof e!="function")throw new TypeError("clay.presence.subscribe needs a listener function");return this.listeners.add(e),e(this.snapshot),()=>{this.listeners.delete(e)}}setCapabilities({supported:e=!1,recordAwareness:n=!1,pageAwareness:s=!1}={}){let i=e===!0,r=n===!0,h=s===!0;return i===this.supported&&r===this.recordAwareness&&h===this.pageAwareness?this.snapshot:(this.supported=i,this.recordAwareness=r,this.pageAwareness=h,this.emit())}receive(e){let n=e&&typeof e=="object"?e:{},s=Array.isArray(n.people)?n.people:[],i=this.sessions,r=new Map,h=[];for(let l of s){if(!l||typeof l.id!="string"||!l.id)continue;let P=typeof l.name=="string"&&l.name.trim()?l.name.trim():"Someone",b=C(l.sessions,i);for(let K of b)r.set(K.id,K);let x={id:l.id,name:P,you:l.you===!0,editing:R(l.editing),sessions:b};typeof l.canEdit=="boolean"&&(x.canEdit=l.canEdit),h.push(x)}this.people=h,this.sessions=r;let c=n.anonymous;this.anonymous=typeof c=="number"&&Number.isFinite(c)&&c>0?Math.floor(c):0;let f=I(n.selfSession),M=!this.session||!this.session.token;f&&(this.session=f);let j=this.emit();return f&&M&&this.owner&&this.target!==null&&(this.sentKey=null,this.flush()),j}clear(){return this.people=[],this.anonymous=0,this.sessions=new Map,this.session=null,this.cancel(),this.sentKey=null,this.emit()}setTarget(e){let n=y(e===void 0?null:e);return n.ok?(this.explicit=!0,this.hold(n.target)):!1}setGeneric(e){if(this.explicit)return!1;let n=y(e===void 0?null:e);return n.ok?this.hold(n.target):!1}releaseTarget(){return this.explicit?(this.explicit=!1,this.hold(null)):!1}hold(e){let n=z(e);return n===this.heldKey?(this.owner&&this.sentKey!==n&&this.schedule(m),!0):(this.target=e,this.heldKey=n,e===null?(this.cancel(),this.flush(),!0):(this.schedule(m),!0))}attachTransport(e){if(!e||typeof e.send!="function")throw new TypeError("clay.presence.attachTransport needs a transport with a send function");let n=this,s={send:e.send,get active(){return n.owner===s},detach(){if(n.owner!==s)return;let i=n.heldKey===""&&typeof n.inflightKey=="string"&&n.inflightKey!=="";if(n.owner=null,n.session=null,n.n=0,n.sentKey=null,n.inflight=!1,n.inflightOwner=null,n.inflightKey=null,n.cancel(),n.target=null,n.heldKey="",n.explicit=!1,n.clear(),i)try{Promise.resolve(s.send({editing:null})).catch(()=>{})}catch{}}};return this.owner=s,this.session=null,this.n=0,this.sentKey=null,this.inflight=!1,this.inflightOwner=null,this.inflightKey=null,this.cancel(),this.target!==null&&this.flush(),s}connect({send:e=null}={}){return this.connecting?this.connecting:(this.connecting=A().then(n=>{let s=Array.isArray(n?.extensions)?n.extensions:[],i=n?.document&&typeof n.document=="object"?n.document.awareness:null;if(i&&i.transport==="broadcast"&&(s.includes("blockeditor-awareness-v1")||s.includes("record-awareness-v1"))){let r=typeof i.scope=="string"&&i.scope?i.scope:null;return import("./c-A7N5TNSL.js").then(({localPresence:h})=>{let c=h({scope:r,store:this}),f=c.start();return f?Object.defineProperty(f,"stop",{value:()=>c.stop()}):null})}return typeof e=="function"&&s.includes("presence-editing")?this.attachTransport({send:e}):null}).finally(()=>{this.connecting=null}),this.connecting)}reconnect(){this.session=null,this.n=0,this.sentKey=null,this.cancel(),!(!this.owner||this.target===null)&&this.flush()}emit(){let e=this.people.map(n=>Object.freeze({...n,sessions:Object.freeze(n.sessions)}));this.snapshot=Object.freeze({supported:this.supported,recordAwareness:this.recordAwareness,pageAwareness:this.pageAwareness,people:Object.freeze(e),anonymous:this.anonymous});for(let n of[...this.listeners])n(this.snapshot);return this.snapshot}schedule(e,n="coalesce"){if(this.timer!==null){if(this.timerKind==="coalesce")return;clearTimeout(this.timer)}this.timerKind=n,this.timer=setTimeout(()=>{this.timer=null,this.timerKind=null,this.flush()},e)}cancel(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null,this.timerKind=null)}renew(){this.timer!==null||!this.owner||this.target===null||this.schedule(E,"renew")}flush(){if(this.inflight)return;let e=this.owner;if(!e)return;let n=this.n+1,s=N({target:this.target,session:this.session,n});if(!s)return;this.cancel(),this.sentKey=this.heldKey,this.inflight=!0,this.inflightOwner=e,this.inflightKey=this.sentKey,s.v===p&&(this.n=n);let i=r=>{if(this.inflightOwner===e&&(this.inflight=!1,this.inflightOwner=null,this.inflightKey=null,this.owner===e)){if(this.heldKey!==this.sentKey){this.flush();return}r?this.renew():this.schedule(E,"renew")}};Promise.resolve(e.send(s)).then(r=>i(!!r),()=>i(!1))}},S=new k,ct=S;if(typeof window<"u"&&(window.clay=window.clay||{},!window.clay.presence)){window.clay.presence=S;try{document.dispatchEvent(new CustomEvent("clay:presence-ready",{detail:{presence:S}}))}catch{}}export{p as a,E as b,it as c,y as d,k as e,S as f,ct as g};
1
+ import{a as O}from"./c-WN3MXOLT.js";import{d as A}from"./c-EQ5NBOGA.js";var p=1,D=8*1024,B=256,L=1024,Y=128,X=128,G=Object.freeze(["title","description","labels","members","dates","checklist","comment","attachments"]),m=250,E=5e3,it=15e3;var W=new Set(["kind","id","field"]),$=new Set(["kind","v","epoch","generation","selection"]),q=new Set(["kind","anchor","head"]),F=new Set(["kind","ids"]),J=new Set(["kind","block","row","col"]),V=new Set(["block","rel"]),H=/^[\x20-\x7e]+$/,U=/^[A-Za-z0-9+/]+={0,2}$/,Z=/[\u0000-\u001f\u007f]/,o=t=>({ok:!1,reason:t}),a=t=>({ok:!0,target:t}),g=t=>!!t&&typeof t=="object"&&!Array.isArray(t),d=(t,e)=>{for(let n of Object.keys(t))if(!e.has(n))return!1;return!0};function T(t){let e=0;for(let n of t){let s=n.codePointAt(0);e+=s<128?1:s<2048?2:s<65536?3:4}return e}function u(t){return typeof t=="string"&&t.length>0&&!Z.test(t)&&T(t)<=B}function Q(t){if(typeof t!="string"||!t.length||t.length%4!==0||!U.test(t))return!1;let e=t.endsWith("==")?2:t.endsWith("=")?1:0;return t.length/4*3-e<=L}function _(t){return!g(t)||!d(t,V)||!u(t.block)||!Q(t.rel)?null:{block:t.block,rel:t.rel}}function v(t){if(!g(t))return null;if(t.kind==="text"){if(!d(t,q))return null;let e=_(t.anchor),n=_(t.head);return e&&n?{kind:"text",anchor:e,head:n}:null}if(t.kind==="blocks"){if(!d(t,F)||!Array.isArray(t.ids)||!t.ids.length||t.ids.length>X)return null;for(let e of t.ids)if(!u(e))return null;return{kind:"blocks",ids:[...t.ids]}}return t.kind==="cell"?!d(t,J)||!u(t.block)||!u(t.row)||!u(t.col)?null:{kind:"cell",block:t.block,row:t.row,col:t.col}:null}function w(t){return T(JSON.stringify(t))<=D}function tt(t){if(!d(t,W))return o("key");let e=t.id;if(typeof e!="string"||!e.length||e.length>Y||!H.test(e))return o("id");if(t.field===void 0){let s={kind:"record",id:e};return w(s)?a(s):o("size")}if(typeof t.field!="string"||!G.includes(t.field))return o("field");let n={kind:"record",id:e,field:t.field};return w(n)?a(n):o("size")}function et(t){if(!d(t,$))return o("key");if(t.v!==p)return o("version");if(!u(t.epoch))return o("epoch");if(!Number.isSafeInteger(t.generation)||t.generation<0)return o("generation");let e=v(t.selection);if(!e)return o("selection");let n={kind:"blockeditor",v:p,epoch:t.epoch,generation:t.generation,selection:e};return w(n)?a(n):o("size")}function y(t){return t===null?a(null):typeof t=="string"?O.test(t)?a(t):o("path"):g(t)?t.kind==="record"?tt(t):t.kind==="blockeditor"?et(t):o("kind"):o("shape")}function R(t){let e=y(t===void 0?null:t);return!e.ok||e.target!==null&&typeof e.target=="object"&&e.target.kind!=="record"?null:e.target}function z(t){return t==null?"":typeof t=="string"?`path:${t}`:`target:${JSON.stringify(t)}`}function C(t,e=null){let n=Array.isArray(t)?t:[],s=[];for(let i of n){if(!g(i))continue;let r=u(i.id)?i.id:null;if(!r)continue;let h=Number.isSafeInteger(i.n)&&i.n>=0?i.n:0,c=e&&e.get(r);if(c&&h<c.n){s.push(c);continue}let f=y(i.editing===void 0?null:i.editing);s.push({id:r,you:i.you===!0,n:h,editing:f.ok?f.target:null})}return s}function I(t){if(!g(t))return null;let e=u(t.id)?t.id:null,n=typeof t.token=="string"&&t.token.length?t.token:null;return e&&n?{id:e,token:n}:null}function N({target:t=null,session:e=null,n=0}){if(t==null||typeof t=="string")return{editing:t??null};let s=e&&typeof e.token=="string"&&e.token.length?e.token:null;return s?!Number.isSafeInteger(n)||n<0?null:{v:p,session:s,n,editing:t}:t.kind==="record"?{editing:t}:null}var nt=()=>Object.freeze({supported:!1,recordAwareness:!1,pageAwareness:!1,people:Object.freeze([]),anonymous:0}),k=class{constructor(){this.supported=!1,this.recordAwareness=!1,this.pageAwareness=!1,this.people=[],this.anonymous=0,this.snapshot=nt(),this.listeners=new Set,this.sessions=new Map,this.session=null,this.target=null,this.heldKey="",this.owner=null,this.explicit=!1,this.connecting=null,this.n=0,this.sentKey=null,this.timer=null,this.timerKind=null,this.inflight=!1,this.inflightOwner=null,this.inflightKey=null}getSnapshot(){return this.snapshot}subscribe(e){if(typeof e!="function")throw new TypeError("clay.presence.subscribe needs a listener function");return this.listeners.add(e),e(this.snapshot),()=>{this.listeners.delete(e)}}setCapabilities({supported:e=!1,recordAwareness:n=!1,pageAwareness:s=!1}={}){let i=e===!0,r=n===!0,h=s===!0;return i===this.supported&&r===this.recordAwareness&&h===this.pageAwareness?this.snapshot:(this.supported=i,this.recordAwareness=r,this.pageAwareness=h,this.emit())}receive(e){let n=e&&typeof e=="object"?e:{},s=Array.isArray(n.people)?n.people:[],i=this.sessions,r=new Map,h=[];for(let l of s){if(!l||typeof l.id!="string"||!l.id)continue;let P=typeof l.name=="string"&&l.name.trim()?l.name.trim():"Someone",b=C(l.sessions,i);for(let K of b)r.set(K.id,K);let x={id:l.id,name:P,you:l.you===!0,editing:R(l.editing),sessions:b};typeof l.canEdit=="boolean"&&(x.canEdit=l.canEdit),h.push(x)}this.people=h,this.sessions=r;let c=n.anonymous;this.anonymous=typeof c=="number"&&Number.isFinite(c)&&c>0?Math.floor(c):0;let f=I(n.selfSession),M=!this.session||!this.session.token;f&&(this.session=f);let j=this.emit();return f&&M&&this.owner&&this.target!==null&&(this.sentKey=null,this.flush()),j}clear(){return this.people=[],this.anonymous=0,this.sessions=new Map,this.session=null,this.cancel(),this.sentKey=null,this.emit()}setTarget(e){let n=y(e===void 0?null:e);return n.ok?(this.explicit=!0,this.hold(n.target)):!1}setGeneric(e){if(this.explicit)return!1;let n=y(e===void 0?null:e);return n.ok?this.hold(n.target):!1}releaseTarget(){return this.explicit?(this.explicit=!1,this.hold(null)):!1}hold(e){let n=z(e);return n===this.heldKey?(this.owner&&this.sentKey!==n&&this.schedule(m),!0):(this.target=e,this.heldKey=n,e===null?(this.cancel(),this.flush(),!0):(this.schedule(m),!0))}attachTransport(e){if(!e||typeof e.send!="function")throw new TypeError("clay.presence.attachTransport needs a transport with a send function");let n=this,s={send:e.send,get active(){return n.owner===s},detach(){if(n.owner!==s)return;let i=n.heldKey===""&&typeof n.inflightKey=="string"&&n.inflightKey!=="";if(n.owner=null,n.session=null,n.n=0,n.sentKey=null,n.inflight=!1,n.inflightOwner=null,n.inflightKey=null,n.cancel(),n.target=null,n.heldKey="",n.explicit=!1,n.clear(),i)try{Promise.resolve(s.send({editing:null})).catch(()=>{})}catch{}}};return this.owner=s,this.session=null,this.n=0,this.sentKey=null,this.inflight=!1,this.inflightOwner=null,this.inflightKey=null,this.cancel(),this.target!==null&&this.flush(),s}connect({send:e=null}={}){return this.connecting?this.connecting:(this.connecting=A().then(n=>{let s=Array.isArray(n?.extensions)?n.extensions:[],i=n?.document&&typeof n.document=="object"?n.document.awareness:null;if(i&&i.transport==="broadcast"&&(s.includes("blockeditor-awareness-v1")||s.includes("record-awareness-v1"))){let r=typeof i.scope=="string"&&i.scope?i.scope:null;return import("./c-BJ2RRQBQ.js").then(({localPresence:h})=>{let c=h({scope:r,store:this}),f=c.start();return f?Object.defineProperty(f,"stop",{value:()=>c.stop()}):null})}return typeof e=="function"&&s.includes("presence-editing")?this.attachTransport({send:e}):null}).finally(()=>{this.connecting=null}),this.connecting)}reconnect(){this.session=null,this.n=0,this.sentKey=null,this.cancel(),!(!this.owner||this.target===null)&&this.flush()}emit(){let e=this.people.map(n=>Object.freeze({...n,sessions:Object.freeze(n.sessions)}));this.snapshot=Object.freeze({supported:this.supported,recordAwareness:this.recordAwareness,pageAwareness:this.pageAwareness,people:Object.freeze(e),anonymous:this.anonymous});for(let n of[...this.listeners])n(this.snapshot);return this.snapshot}schedule(e,n="coalesce"){if(this.timer!==null){if(this.timerKind==="coalesce")return;clearTimeout(this.timer)}this.timerKind=n,this.timer=setTimeout(()=>{this.timer=null,this.timerKind=null,this.flush()},e)}cancel(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null,this.timerKind=null)}renew(){this.timer!==null||!this.owner||this.target===null||this.schedule(E,"renew")}flush(){if(this.inflight)return;let e=this.owner;if(!e)return;let n=this.n+1,s=N({target:this.target,session:this.session,n});if(!s)return;this.cancel(),this.sentKey=this.heldKey,this.inflight=!0,this.inflightOwner=e,this.inflightKey=this.sentKey,s.v===p&&(this.n=n);let i=r=>{if(this.inflightOwner===e&&(this.inflight=!1,this.inflightOwner=null,this.inflightKey=null,this.owner===e)){if(this.heldKey!==this.sentKey){this.flush();return}r?this.renew():this.schedule(E,"renew")}};Promise.resolve(e.send(s)).then(r=>i(!!r),()=>i(!1))}},S=new k,ct=S;if(typeof window<"u"&&(window.clay=window.clay||{},!window.clay.presence)){window.clay.presence=S;try{document.dispatchEvent(new CustomEvent("clay:presence-ready",{detail:{presence:S}}))}catch{}}export{p as a,E as b,it as c,y as d,k as e,S as f,ct as g};
@@ -0,0 +1 @@
1
+ import{b as f}from"./c-QTEUO2K6.js";import{a as s,e as u,f as v,g as y,h,k as E}from"./c-DIKR7H57.js";import{b as d,c,d as b,e as r,f as k}from"./c-CUMXGHVD.js";import"./c-QY7F6EN6.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";function R(){let e=()=>{let n=r()&&c(r());document.dispatchEvent(new CustomEvent("clay:variant-change",{detail:{active:n,shown:n}}))},t=n=>d().some(o=>c(o)===n)?(document.documentElement.setAttribute("look",n),k(n),window.clay?.save?.soon?.(),e(),{ok:!0}):{ok:!1,code:"unknown-variant"};d().length>=2&&(window.clay.variants={list:()=>d().map(n=>({name:c(n),label:b(n),active:n===r()})),get active(){return r()&&c(r())},get shown(){return r()&&c(r())},preview:t,choose:t,keep:()=>Promise.resolve({ok:!1,code:"not-editing"})},document.addEventListener("clay:drafts-restored",()=>{e()}))}var A='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round" aria-hidden="true"><path d="M12 9a3 3 0 1 1 0 6 3 3 0 0 1 0-6M10 3h4l1.5 3 3.5-.5 2 4-2 2.5 2 2.5-2 4-3.5-.5-1.5 3h-4l-1.5-3-3.5.5-2-4 2-2.5-2-2.5 2-4 3.5.5Z"/></svg>',w=()=>window.clay?.blockeditor?.history??window.clay?.undo??null;function M({addItem:e,beforeOpen:t}){let n=null,o=()=>{let a=w();if(!a)return;let i=n??{canUndo:!!a.canUndo,canRedo:!!a.canRedo};e({id:"clay.undo",pair:[{id:"clay.undo.undo",label:"Undo",keys:f("\u2318Z","Ctrl+Z"),disabled:!i.canUndo,run:()=>w()?.undo()},{id:"clay.undo.redo",label:"Redo",keys:f("\u2318\u21E7Z","Ctrl+Shift+Z"),disabled:!i.canRedo,run:()=>w()?.redo()}]})};document.addEventListener("clay:undo-change",a=>{n={canUndo:!!a.detail?.canUndo,canRedo:!!a.detail?.canRedo},o()}),o(),t.push(o)}function B(e=window.location){let t=e.pathname.replace(/\/+$/,"")||"/";return`/_/copy${t==="/"?"":t}`}function C({addItem:e,removeItem:t}){let n=o=>{if(o?.kind!=="trial"||!o.dismissed){t("clay.bar.host"),t("clay.bar.show");return}let a=Array.isArray(o.actions)?o.actions.find(i=>i?.id==="host"):null;typeof a?.href=="string"&&e({id:"clay.bar.host",label:"Host and share online",href:a.href}),typeof o.show=="function"&&e({id:"clay.bar.show",label:"Show draft bar",run:()=>o.show()})};document.addEventListener("hyperclay:bar",o=>n(o.detail)),n(window.hyperclayBar)}function T(){if(document.querySelector('clay-editor-ui[data-clay-ui="menu"]'))return;let e=E({sections:[["clay.undo"],null],icon:A,label:"Settings"}),{embedded:t,skin:n,addItem:o,removeItem:a,open:i,close:g,note:U,goo:L,beforeOpen:p}=e;e.mount(t?[s,u,n??y,h]:[s,u,v,y,h]);let m;p.push(()=>{typeof globalThis.indexedDB?.open!="function"||!globalThis.IDBKeyRange||(m??=import("./c-RHPHMTF2.js").then(async({attachRecoveryMenu:l})=>{let{recoveryDrafts:S}=await import("./plugins/visitor-drafts-V5YB7XDH.js");l(e,S)}).catch(l=>{m=null,console.warn("visitor-menu: earlier drafts did not load",l)}))}),R(),M({addItem:o,beforeOpen:p}),o({id:"clay.download",label:"Download copy",run:()=>window.clay.visitorDrafts.download()}),o({id:"clay.copy",label:"Make your own copy",href:B()}),C({addItem:o,removeItem:a}),window.clay.menu={addItem:o,removeItem:a,open:i,close:g,note:U,embedded:t,button:L},document.dispatchEvent(new CustomEvent("clay:menu-ready"))}export{T as start};
@@ -1 +1 @@
1
- import{b as y,c as S}from"./c-6DNRCPNM.js";import{b as C,c as s}from"./c-RO73MKKR.js";import{A as d,B as f,C as m,D as p,q as i}from"./c-PWJSJEJU.js";import"./c-XQXZAO7N.js";import"./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 b(e={}){let t=d({...e,sliced:!0});return Object.freeze({captureId:t.captureId,steps:()=>h(t),drop:()=>p(t)})}function v(e,t){let r=e.querySelector("head");if(!r)return;let n=e.querySelector(`meta[name="${t.name}"]`);if(n){n.getAttribute("content")!==t.content&&n.setAttribute("content",t.content);return}let o=e.ownerDocument.createElement("meta");o.setAttribute("name",t.name),o.setAttribute("content",t.content),r.appendChild(o)}function*g(e,t,r){if(!r.renderer)return t;let n=null;for(;;){let o;try{o=i(r.context,()=>(n||=r.rendererSteps?r.rendererSteps(e,t):!1,n?n.next():{done:!0,value:r.renderer(e,t)}))}catch(c){return console.error("clayjs: save renderer failed, sending the full serialization",c),t}if(o.done)return o.value;yield}}function*h(e){f(e);let t=yield*C(e.clone);yield;let r=e.compareClone?yield*s(e.compareClone):null;yield;let n=e.dirtyClone?yield*s(e.dirtyClone):r;yield,e.pageFormatMarker&&v(e.clone,e.pageFormatMarker);let o=yield*g(e.clone,t,e);return m(e,{forSave:o,forComparison:r,forDirty:n})}var l=()=>globalThis.performance?globalThis.performance.now():Date.now();async function F(e,{budgetMs:t=4,signal:r=null}={}){let n=0,o=l(),c=async()=>{n+=l()-o,await y(),o=l()},a;try{a=await S(e,{budgetMs:t,signal:r,yieldTask:c})}finally{n+=l()-o}let u=a!==null&&typeof a=="object"&&a.aborted===!0;return{result:u?null:a,aborted:u,activeMs:n}}export{b as beginSaveCapture,F as runPreparedSteps};
1
+ import{b as y,c as S}from"./c-6DNRCPNM.js";import{b as C,c as s}from"./c-52OC3OH3.js";import{A as d,B as f,C as m,D as p,q as i}from"./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";function b(e={}){let t=d({...e,sliced:!0});return Object.freeze({captureId:t.captureId,steps:()=>h(t),drop:()=>p(t)})}function v(e,t){let r=e.querySelector("head");if(!r)return;let n=e.querySelector(`meta[name="${t.name}"]`);if(n){n.getAttribute("content")!==t.content&&n.setAttribute("content",t.content);return}let o=e.ownerDocument.createElement("meta");o.setAttribute("name",t.name),o.setAttribute("content",t.content),r.appendChild(o)}function*g(e,t,r){if(!r.renderer)return t;let n=null;for(;;){let o;try{o=i(r.context,()=>(n||=r.rendererSteps?r.rendererSteps(e,t):!1,n?n.next():{done:!0,value:r.renderer(e,t)}))}catch(c){return console.error("clayjs: save renderer failed, sending the full serialization",c),t}if(o.done)return o.value;yield}}function*h(e){f(e);let t=yield*C(e.clone);yield;let r=e.compareClone?yield*s(e.compareClone):null;yield;let n=e.dirtyClone?yield*s(e.dirtyClone):r;yield,e.pageFormatMarker&&v(e.clone,e.pageFormatMarker);let o=yield*g(e.clone,t,e);return m(e,{forSave:o,forComparison:r,forDirty:n})}var l=()=>globalThis.performance?globalThis.performance.now():Date.now();async function F(e,{budgetMs:t=4,signal:r=null}={}){let n=0,o=l(),c=async()=>{n+=l()-o,await y(),o=l()},a;try{a=await S(e,{budgetMs:t,signal:r,yieldTask:c})}finally{n+=l()-o}let u=a!==null&&typeof a=="object"&&a.aborted===!0;return{result:u?null:a,aborted:u,activeMs:n}}export{b as beginSaveCapture,F as runPreparedSteps};
@@ -0,0 +1 @@
1
+ import{a,b}from"./c-CITLTVQ4.js";import"./c-HKSLOVU4.js";import"./c-RHMPKZZ7.js";import"./c-VHNSBD2M.js";export{a as COPY,b as createRecovery};
@@ -1 +1 @@
1
- import{a as w}from"./c-MJ7GVE46.js";import{b as m,c as v}from"./c-FZRZPIFS.js";import"./c-VKEDWYDF.js";import{m as f,o as y}from"./c-DLBX4JCJ.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-PWJSJEJU.js";import"./c-XQXZAO7N.js";import"./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";var L="script[editmode\\:resource]";function d(e=document){let t=[...e.querySelectorAll(L)];return{reversible:t.length===0,scripts:t}}function R(e=document){return{enable(){m(e)},quiesce(){},resume(){},dispose(){v()}}}function g(e=document){return{id:"clay:resources",order:100,prepare(){let{reversible:t}=d(e);if(!t)throw Object.assign(new Error("clay.modeLifecycle: an editmode:resource script cannot be re-run"),{code:"unsupported-plugin"});return R(e)}}}var b=!1,S=()=>{let e=new Set;for(let t of f()){if(typeof t?.then=="function")continue;let n=t?.id;if(typeof n!="string"||typeof t?.prepare!="function"||e.has(n))return!1;e.add(n)}return!0},j=e=>[...e?.edit?.core??[],...e?.edit?.plugins??[],...e?.edit?.late??[],...e?.view?.plugins??[],...e?.view?.late??[]];function A(e){return[...new Set(j(e))].filter(t=>w(t)===null)}function T(e){return S()&&A(e).length===0&&d().reversible}function _(){b||(b=!0,y(g()))}var l=()=>Object.assign(new Error("clay.modeLifecycle: the import was cancelled"),{name:"AbortError",code:"aborted"}),O=15e3,E=(e,t)=>Object.assign(new Error(`clayjs: ${e}`),{code:t}),q=(e,t)=>new Promise((n,s)=>{if(t?.aborted)return s(l());let o=()=>s(l());t?.addEventListener?.("abort",o),Promise.resolve(e).then(i=>{t?.removeEventListener?.("abort",o),n(i)},i=>{t?.removeEventListener?.("abort",o),s(i)})}),h=e=>!e?.represented||e.represented.bytes===null,P=e=>e&&(e.liveSync??e.default??e)||null;async function k(e,t={}){let n=t.signal,s={signal:n,deadline:O},o=e?.loaded?.["plugins/page-view.js"];if(o?.ready){await q(o.acquired,n);let a=await o.prepareHandoff(s);if(h(a))throw E("the reader has no file to hand over","not-acquired");return a}let i=P(e?.loaded?.["sync/live-sync.js"]);if(i&&!i.isDestroyed&&i.lane==="saved"){let a=await i.prepareHandoff(s);if(h(a))throw E("the reader has no file to hand over","not-acquired");return a}return null}function I(e,t=null){let n=e?.loaded?.["plugins/page-view.js"],s=Array.isArray(e?.view?.plugins)?e.view.plugins.includes("sync/live-sync.js"):!!e?.loaded?.["sync/live-sync.js"];if(n&&((n.restart??n.start)({sync:s,represented:t}),!s))return;let o=P(e?.loaded?.["sync/live-sync.js"]);if(o)return o.start(o.currentFile,{lane:"saved",represented:t})}async function V(e,t,{signal:n}={}){let s=e.inflight||=new Map,o=[],i=()=>{if(n?.aborted)throw l()},a=e.loadEditHints?.();if(a)try{await a}catch{}let u=r=>{if(!s.has(r)){let c=Promise.resolve().then(()=>e.modules[r]()).catch(x=>{throw s.delete(r),x});s.set(r,c)}return s.get(r)};for(let r of t.core??[]){if(e.loaded[r])continue;i();let c=await u(r);e.loaded[r]=c,c.install?.()}e.attachEditCore(e.loaded);for(let r of t.plugins??[]){if(e.loaded[r])continue;i();let c=await u(r);e.loaded[r]=c,e.attach(r,c),o.push(r)}let p=(t.late??[]).filter(r=>!e.loaded[r]);if(p.length){i();try{await e.late}catch{}for(let r of p){if(e.loaded[r])continue;i();let c=await u(r);e.loaded[r]=c,e.attach(r,c),o.push(r)}}return o}export{V as importPlan,T as liveAllowed,_ as openResources,k as prepareReader,I as startReader,A as unsupportedPaths};
1
+ import{a as w}from"./c-MJ7GVE46.js";import{b as m,c as v}from"./c-U65PREMC.js";import"./c-VKEDWYDF.js";import{m as f,o as y}from"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.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";var L="script[editmode\\:resource]";function d(e=document){let t=[...e.querySelectorAll(L)];return{reversible:t.length===0,scripts:t}}function R(e=document){return{enable(){m(e)},quiesce(){},resume(){},dispose(){v()}}}function g(e=document){return{id:"clay:resources",order:100,prepare(){let{reversible:t}=d(e);if(!t)throw Object.assign(new Error("clay.modeLifecycle: an editmode:resource script cannot be re-run"),{code:"unsupported-plugin"});return R(e)}}}var b=!1,S=()=>{let e=new Set;for(let t of f()){if(typeof t?.then=="function")continue;let n=t?.id;if(typeof n!="string"||typeof t?.prepare!="function"||e.has(n))return!1;e.add(n)}return!0},j=e=>[...e?.edit?.core??[],...e?.edit?.plugins??[],...e?.edit?.late??[],...e?.view?.plugins??[],...e?.view?.late??[]];function A(e){return[...new Set(j(e))].filter(t=>w(t)===null)}function T(e){return S()&&A(e).length===0&&d().reversible}function _(){b||(b=!0,y(g()))}var l=()=>Object.assign(new Error("clay.modeLifecycle: the import was cancelled"),{name:"AbortError",code:"aborted"}),O=15e3,E=(e,t)=>Object.assign(new Error(`clayjs: ${e}`),{code:t}),q=(e,t)=>new Promise((n,s)=>{if(t?.aborted)return s(l());let o=()=>s(l());t?.addEventListener?.("abort",o),Promise.resolve(e).then(i=>{t?.removeEventListener?.("abort",o),n(i)},i=>{t?.removeEventListener?.("abort",o),s(i)})}),h=e=>!e?.represented||e.represented.bytes===null,P=e=>e&&(e.liveSync??e.default??e)||null;async function k(e,t={}){let n=t.signal,s={signal:n,deadline:O},o=e?.loaded?.["plugins/page-view.js"];if(o?.ready){await q(o.acquired,n);let a=await o.prepareHandoff(s);if(h(a))throw E("the reader has no file to hand over","not-acquired");return a}let i=P(e?.loaded?.["sync/live-sync.js"]);if(i&&!i.isDestroyed&&i.lane==="saved"){let a=await i.prepareHandoff(s);if(h(a))throw E("the reader has no file to hand over","not-acquired");return a}return null}function I(e,t=null){let n=e?.loaded?.["plugins/page-view.js"],s=Array.isArray(e?.view?.plugins)?e.view.plugins.includes("sync/live-sync.js"):!!e?.loaded?.["sync/live-sync.js"];if(n&&((n.restart??n.start)({sync:s,represented:t}),!s))return;let o=P(e?.loaded?.["sync/live-sync.js"]);if(o)return o.start(o.currentFile,{lane:"saved",represented:t})}async function V(e,t,{signal:n}={}){let s=e.inflight||=new Map,o=[],i=()=>{if(n?.aborted)throw l()},a=e.loadEditHints?.();if(a)try{await a}catch{}let u=r=>{if(!s.has(r)){let c=Promise.resolve().then(()=>e.modules[r]()).catch(x=>{throw s.delete(r),x});s.set(r,c)}return s.get(r)};for(let r of t.core??[]){if(e.loaded[r])continue;i();let c=await u(r);e.loaded[r]=c,c.install?.()}e.attachEditCore(e.loaded);for(let r of t.plugins??[]){if(e.loaded[r])continue;i();let c=await u(r);e.loaded[r]=c,e.attach(r,c),o.push(r)}let p=(t.late??[]).filter(r=>!e.loaded[r]);if(p.length){i();try{await e.late}catch{}for(let r of p){if(e.loaded[r])continue;i();let c=await u(r);e.loaded[r]=c,e.attach(r,c),o.push(r)}}return o}export{V as importPlan,T as liveAllowed,_ as openResources,k as prepareReader,I as startReader,A as unsupportedPaths};
@@ -1,4 +1,4 @@
1
- import{y as O}from"./c-ZRGEN6QQ.js";import{A as $,d as N,y as x,z as C}from"./c-OH2FPYSY.js";import{a as A}from"./c-RETTCOWO.js";import"./c-VHNSBD2M.js";var g=N.nodes,H=e=>e.attrs.parent??null,_=e=>{let a=new Set;return e.forEach(t=>t.forEach(o=>a.add(o.attrs.col))),C(e.attrs.cols).filter(t=>a.has(t))};function S(e,a){let t=a.ownerDocument,o=t.createElement("thead").appendChild(t.createElement("tr"));for(let s of _(e)){let p=e.attrs.cols[s],r=o.appendChild(t.createElement("th"));r.setAttribute("data-col",s),r.setAttribute("scope","col"),p.kind&&r.setAttribute("data-kind",p.kind),p.width&&(r.setAttribute("data-width",String(p.width)),r.style.width=`${p.width}px`),r.textContent=p.name??""}a.prepend(o.parentNode),e.attrs.sort&&a.setAttribute("data-sort",JSON.stringify(e.attrs.sort))}function v(e,a){let t=[];e.forEach((o,s,p)=>{let r=a[p];if(!r||r.nodeType!==1)return;if(o.type===g.table&&S(o,r),o.type!==g.list_item||H(o)!==null){t=[];return}let f=r.ownerDocument,{indent:d,kind:i}=o.attrs,l=i==="ordered"?"OL":"UL";for(;t.length&&t.at(-1).indent>d;)t.pop();if(t.at(-1)?.indent===d&&t.at(-1).list.tagName!==l&&t.pop(),!t.length||t.at(-1).indent<d){let c=f.createElement(l);t.length?t.at(-1).li.append(c):r.before(c),t.push({indent:d,list:c,li:null})}let u=f.createElement("li");i==="check"&&(u.innerHTML=`<input type="checkbox" disabled${o.attrs.checked?" checked":""}>`),u.append(...r.childNodes),t.at(-1).list.append(u),t.at(-1).li=u,r.remove()})}var T=e=>/[\t\n\r"]/.test(e)?`"${e.replace(/"/g,'""')}"`:e;function q(e){if(!e.content.firstChild?.type.spec.group?.includes("block"))return null;let a="",t=[],o=!1;return e.content.forEach((s,p,r)=>{let f=s.type===g.list_item,d=s.textBetween(0,s.content.size,`
1
+ import{y as O}from"./c-AI3H6ETU.js";import{A as $,d as N,y as x,z as C}from"./c-OH2FPYSY.js";import{a as A}from"./c-RETTCOWO.js";import"./c-VHNSBD2M.js";var g=N.nodes,H=e=>e.attrs.parent??null,_=e=>{let a=new Set;return e.forEach(t=>t.forEach(o=>a.add(o.attrs.col))),C(e.attrs.cols).filter(t=>a.has(t))};function S(e,a){let t=a.ownerDocument,o=t.createElement("thead").appendChild(t.createElement("tr"));for(let s of _(e)){let p=e.attrs.cols[s],r=o.appendChild(t.createElement("th"));r.setAttribute("data-col",s),r.setAttribute("scope","col"),p.kind&&r.setAttribute("data-kind",p.kind),p.width&&(r.setAttribute("data-width",String(p.width)),r.style.width=`${p.width}px`),r.textContent=p.name??""}a.prepend(o.parentNode),e.attrs.sort&&a.setAttribute("data-sort",JSON.stringify(e.attrs.sort))}function v(e,a){let t=[];e.forEach((o,s,p)=>{let r=a[p];if(!r||r.nodeType!==1)return;if(o.type===g.table&&S(o,r),o.type!==g.list_item||H(o)!==null){t=[];return}let f=r.ownerDocument,{indent:d,kind:i}=o.attrs,l=i==="ordered"?"OL":"UL";for(;t.length&&t.at(-1).indent>d;)t.pop();if(t.at(-1)?.indent===d&&t.at(-1).list.tagName!==l&&t.pop(),!t.length||t.at(-1).indent<d){let c=f.createElement(l);t.length?t.at(-1).li.append(c):r.before(c),t.push({indent:d,list:c,li:null})}let u=f.createElement("li");i==="check"&&(u.innerHTML=`<input type="checkbox" disabled${o.attrs.checked?" checked":""}>`),u.append(...r.childNodes),t.at(-1).list.append(u),t.at(-1).li=u,r.remove()})}var T=e=>/[\t\n\r"]/.test(e)?`"${e.replace(/"/g,'""')}"`:e;function q(e){if(!e.content.firstChild?.type.spec.group?.includes("block"))return null;let a="",t=[],o=!1;return e.content.forEach((s,p,r)=>{let f=s.type===g.list_item,d=s.textBetween(0,s.content.size,`
2
2
 
3
3
  `);if(f){let{indent:i,kind:l}=s.attrs;for(;t.length&&t.at(-1).indent>i;)t.pop();t.at(-1)?.indent===i&&t.at(-1).kind!==l&&t.pop(),(!t.length||t.at(-1).indent<i)&&t.push({indent:i,kind:l,n:0});let u=t.at(-1),c=l==="ordered"?`${++u.n}.`:l==="check"?`- [${s.attrs.checked?"x":" "}]`:"-";d=`${" ".repeat(t.length-1)}${c} ${d}`}else t=[];if(s.type===g.table){let i=[_(s).map(l=>T(s.attrs.cols[l].name??""))];s.forEach(l=>{let u=[];l.forEach(c=>u.push(T(c.textContent))),i.push(u)}),d=i.map(l=>l.join(" ")).join(`
4
4
  `)}a+=(r?o&&f?`
@@ -1 +1 @@
1
- import{c as A}from"./c-Q6BG3ZLO.js";import{j as b}from"./c-CV4T65JE.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-DD26VXAP.js";import"./c-CTGRDT6E.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{C as x}from"./c-ZRGEN6QQ.js";import"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import{b as h}from"./c-RETTCOWO.js";import"./c-WCG6AKA7.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";function S(o){let s=String(o??""),n=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter("en",{granularity:"grapheme"}):null;return n?[...n.segment(s)].map(a=>a.segment):[...s]}var I=o=>S(o).length===1&&!/^\s*$/.test(String(o??""));function L(o){let s=[];for(let[n,a]of Object.entries(o??{}))for(let u of Array.isArray(a)?a:[]){let[f,m,d=""]=u??[];typeof f!="string"||typeof m!="string"||s.push({id:`${n}:${m}`,char:f,name:`${f} ${m}`,keywords:`${m} ${d}`})}return s}var P=(o,s)=>{let n=String(s??"").trim().toLowerCase();return n?o.filter(a=>a.char===n||a.keywords.toLowerCase().includes(n)):o};function T(o=()=>import("./c-SZGYW5HT.js")){let s=null;return()=>(s??=Promise.resolve().then(()=>o()).then(n=>L(n.EMOJI)).catch(n=>{throw s=null,n}),s)}function w({view:o=null,load:s=()=>import("./c-SZGYW5HT.js")}={}){if(!o)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let n=o.dom.ownerDocument,a=T(s),u=null;function f(t){let e=o.state,r=e.selection;if(r.from!==t.from||r.to!==t.to||t.from<0||t.to>e.doc.content.size)return null;let c=e.doc.resolve(t.from),i=e.doc.resolve(t.to);return!c.parent.isTextblock||c.parent!==i.parent?null:{from:t.from,to:t.to}}function m(t){try{let e=o.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=o.coordsAtPos(t.from);return{x:Math.max(8,r.left-e.left),y:r.bottom+6-e.top}}catch{return null}}function d(t){let e=t.picker.activeId();e?o.dom.setAttribute("aria-activedescendant",e):o.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&o.dom.removeAttribute("aria-activedescendant")}function l(){let t=u;if(t){u=null;for(let[e,r,c,i]of t.listen)e.removeEventListener(r,c,i);o.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&o.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function j(t,e){let r=o.state.tr.insertText(e,t.from,t.to);return r.setSelection(h.TextSelection.create(r.doc,t.from+e.length)),o.dispatch(x(r)),o.focus(),{ok:!0,emoji:e}}function p(t){let e=u;if(!e)return{ok:!1,code:"not-editing"};let r=e.picker.personAt(t),c=f(e);return!r||c===null||!I(r.char)?(l(),r?c===null?{ok:!1,code:"stale-target"}:{ok:!1,code:"invalid-emoji"}:{ok:!1,code:"no-emoji"}):(l(),j(c,r.char))}function E(t){let e=u;if(!e||b(t,o))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),e.picker.move(t.key==="ArrowDown"?1:-1),d(e)):t.key==="Enter"?(r(),p(e.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),l())}async function $(t={}){l();let e={from:o.state.selection.from,to:o.state.selection.to,picker:null,listen:[]};e.picker=A({document:n,label:"Insert an emoji",empty:"No emoji found",onPick:i=>p(i)}),u=e;let r=(i,k,g,y)=>{i.addEventListener(k,g,y),e.listen.push([i,k,g,y])};r(n,"keydown",i=>E(i),!0),r(o.dom,"input",()=>l()),r(n,"mousedown",i=>{e.picker.el.contains(i.target)||l()},!0),(o.dom.parentElement??n.body).appendChild(e.picker.el);let c;try{c=await a()}catch(i){return l(),{ok:!1,code:"unavailable",error:i}}return u!==e?{ok:!1,code:"not-editing"}:f(e)===null?(l(),{ok:!1,code:"stale-target"}):(e.picker.show(P(c,t?.query),m(e)),d(e),{ok:!0,picker:!0})}return{async run(t){return $(t)},dispose(){l()}}}export{w as createFeature,L as emojiEntries,T as emojiLibrary,P as filterEmoji,S as graphemes,I as isEmojiText};
1
+ import{c as A}from"./c-Q6BG3ZLO.js";import{j as b}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 as x}from"./c-AI3H6ETU.js";import"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import{b as h}from"./c-RETTCOWO.js";import"./c-WCG6AKA7.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";function S(o){let s=String(o??""),n=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter("en",{granularity:"grapheme"}):null;return n?[...n.segment(s)].map(a=>a.segment):[...s]}var I=o=>S(o).length===1&&!/^\s*$/.test(String(o??""));function L(o){let s=[];for(let[n,a]of Object.entries(o??{}))for(let u of Array.isArray(a)?a:[]){let[f,m,d=""]=u??[];typeof f!="string"||typeof m!="string"||s.push({id:`${n}:${m}`,char:f,name:`${f} ${m}`,keywords:`${m} ${d}`})}return s}var P=(o,s)=>{let n=String(s??"").trim().toLowerCase();return n?o.filter(a=>a.char===n||a.keywords.toLowerCase().includes(n)):o};function T(o=()=>import("./c-SZGYW5HT.js")){let s=null;return()=>(s??=Promise.resolve().then(()=>o()).then(n=>L(n.EMOJI)).catch(n=>{throw s=null,n}),s)}function w({view:o=null,load:s=()=>import("./c-SZGYW5HT.js")}={}){if(!o)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let n=o.dom.ownerDocument,a=T(s),u=null;function f(t){let e=o.state,r=e.selection;if(r.from!==t.from||r.to!==t.to||t.from<0||t.to>e.doc.content.size)return null;let c=e.doc.resolve(t.from),i=e.doc.resolve(t.to);return!c.parent.isTextblock||c.parent!==i.parent?null:{from:t.from,to:t.to}}function m(t){try{let e=o.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=o.coordsAtPos(t.from);return{x:Math.max(8,r.left-e.left),y:r.bottom+6-e.top}}catch{return null}}function d(t){let e=t.picker.activeId();e?o.dom.setAttribute("aria-activedescendant",e):o.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&o.dom.removeAttribute("aria-activedescendant")}function l(){let t=u;if(t){u=null;for(let[e,r,c,i]of t.listen)e.removeEventListener(r,c,i);o.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&o.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function j(t,e){let r=o.state.tr.insertText(e,t.from,t.to);return r.setSelection(h.TextSelection.create(r.doc,t.from+e.length)),o.dispatch(x(r)),o.focus(),{ok:!0,emoji:e}}function p(t){let e=u;if(!e)return{ok:!1,code:"not-editing"};let r=e.picker.personAt(t),c=f(e);return!r||c===null||!I(r.char)?(l(),r?c===null?{ok:!1,code:"stale-target"}:{ok:!1,code:"invalid-emoji"}:{ok:!1,code:"no-emoji"}):(l(),j(c,r.char))}function E(t){let e=u;if(!e||b(t,o))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),e.picker.move(t.key==="ArrowDown"?1:-1),d(e)):t.key==="Enter"?(r(),p(e.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),l())}async function $(t={}){l();let e={from:o.state.selection.from,to:o.state.selection.to,picker:null,listen:[]};e.picker=A({document:n,label:"Insert an emoji",empty:"No emoji found",onPick:i=>p(i)}),u=e;let r=(i,k,g,y)=>{i.addEventListener(k,g,y),e.listen.push([i,k,g,y])};r(n,"keydown",i=>E(i),!0),r(o.dom,"input",()=>l()),r(n,"mousedown",i=>{e.picker.el.contains(i.target)||l()},!0),(o.dom.parentElement??n.body).appendChild(e.picker.el);let c;try{c=await a()}catch(i){return l(),{ok:!1,code:"unavailable",error:i}}return u!==e?{ok:!1,code:"not-editing"}:f(e)===null?(l(),{ok:!1,code:"stale-target"}):(e.picker.show(P(c,t?.query),m(e)),d(e),{ok:!0,picker:!0})}return{async run(t){return $(t)},dispose(){l()}}}export{w as createFeature,L as emojiEntries,T as emojiLibrary,P as filterEmoji,S as graphemes,I as isEmojiText};
@@ -1,4 +1,4 @@
1
- import{c as p}from"./c-H3FNLBHN.js";import{w as u}from"./c-CV4T65JE.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-DD26VXAP.js";import"./c-CTGRDT6E.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-ZRGEN6QQ.js";import{d as h}from"./c-OH2FPYSY.js";import{a as n,b as r}from"./c-Q26XHBLQ.js";import"./c-FSQXFG5T.js";import"./c-RETTCOWO.js";import"./c-WCG6AKA7.js";import"./c-3LDGIBMN.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var m=`
1
+ import{c as p}from"./c-H3FNLBHN.js";import{w as u}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{d as h}from"./c-OH2FPYSY.js";import{a as n,b as r}from"./c-Q26XHBLQ.js";import"./c-FSQXFG5T.js";import"./c-RETTCOWO.js";import"./c-WCG6AKA7.js";import"./c-3LDGIBMN.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var m=`
2
2
  .blockeditor-tool-block { position: relative; min-height: 48px; border: 1px solid var(--blockeditor-rule); border-radius: 8px; padding: 12px; }
3
3
  .blockeditor-tool-settings { position: absolute; top: 4px; inset-inline-end: 4px; border: 0; border-radius: 5px; background: var(--blockeditor-pop-bg); color: var(--blockeditor-ink-soft); font: 12px var(--blockeditor-font); padding: 5px 8px; cursor: pointer; opacity: 0; }
4
4
  .blockeditor-tool-block:hover .blockeditor-tool-settings, .blockeditor-tool-block:focus-within .blockeditor-tool-settings { opacity: 1; }
@@ -1 +1 @@
1
- import{a,b,c,d,e,f}from"./c-BULK5J4M.js";import"./c-N326R2JD.js";import"./c-I2SCCUEW.js";import"./c-DLBX4JCJ.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{c as beginApply,d as completeApply,f as conflicts,e as failApply,a as loadEdit,b as registerContext};
1
+ import{a,b,c,d,e,f}from"./c-RWJ3OSCP.js";import"./c-N326R2JD.js";import"./c-I2SCCUEW.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{c as beginApply,d as completeApply,f as conflicts,e as failApply,a as loadEdit,b as registerContext};