@panphora/clayjs 1.24.1 → 1.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/dist/all.js +1 -1
  2. package/dist/clay-dom.js +1 -1
  3. package/dist/clay-events.js +1 -1
  4. package/dist/clay-internals.js +1 -1
  5. package/dist/clay-options.js +1 -1
  6. package/dist/clay-router.js +1 -1
  7. package/dist/clay-ui.js +1 -1
  8. package/dist/clay-utils.js +1 -1
  9. package/dist/clay.js +1 -1
  10. package/dist/clay.standalone.js +2044 -1247
  11. package/dist/m/attrs/{refetch-on-save-DPGJJMGN.js → refetch-on-save-5CBFUJUF.js} +1 -1
  12. package/dist/m/attrs/save-freeze-MH3AOD56.js +1 -0
  13. package/dist/m/{c-SXGEWPFC.js → c-3E2IK5HU.js} +1 -1
  14. package/dist/m/{c-A4L7APIU.js → c-4AE2A2LK.js} +1 -1
  15. package/dist/m/{c-YDW4VCHP.js → c-4Q6QIODW.js} +1 -1
  16. package/dist/m/{c-RO73MKKR.js → c-52OC3OH3.js} +1 -1
  17. package/dist/m/{c-ZGCO4J3H.js → c-5PZYDWTW.js} +1 -1
  18. package/dist/m/c-5Q5XBN56.js +1 -0
  19. package/dist/m/c-5SZ6KFR5.js +1 -0
  20. package/dist/m/{c-ZRGEN6QQ.js → c-AI3H6ETU.js} +2 -2
  21. package/dist/m/{c-7V6MGMX2.js → c-BCWYEG6P.js} +1 -1
  22. package/dist/m/{c-C5AKJVRH.js → c-BJ2RRQBQ.js} +1 -1
  23. package/dist/m/{c-CTGRDT6E.js → c-C6YZNU6E.js} +1 -1
  24. package/dist/m/{c-EDE45NM7.js → c-C7SUMNMI.js} +1 -1
  25. package/dist/m/c-CITLTVQ4.js +4 -0
  26. package/dist/m/{c-STRI73GQ.js → c-CL5LSATX.js} +1 -1
  27. package/dist/m/{c-Z4G2UK6T.js → c-CU33V6RW.js} +1 -1
  28. package/dist/m/{c-6LEYVQJK.js → c-D62HRSZK.js} +1 -1
  29. package/dist/m/{c-DD26VXAP.js → c-DT7E76Z2.js} +1 -1
  30. package/dist/m/{c-P2HKMJAW.js → c-EAV7A6BT.js} +1 -1
  31. package/dist/m/{c-QQFHEODI.js → c-EQ5NBOGA.js} +1 -1
  32. package/dist/m/{c-KQKKIVLW.js → c-FBOO2UY3.js} +1 -1
  33. package/dist/m/{c-JQF2EUCG.js → c-FJDTDGDA.js} +1 -1
  34. package/dist/m/{c-MQKSKQHG.js → c-FKTALXNV.js} +1 -1
  35. package/dist/m/{c-HL6BLJNA.js → c-GDNZEOOZ.js} +1 -1
  36. package/dist/m/{c-SUXHUL7U.js → c-GEAG5XAK.js} +1 -1
  37. package/dist/m/{c-LSVN3OLG.js → c-GY4BREDT.js} +1 -1
  38. package/dist/m/{c-4PO3YGDC.js → c-HGG7M2S3.js} +1 -1
  39. package/dist/m/{c-DDS23EY6.js → c-HXGNH6GY.js} +1 -1
  40. package/dist/m/{c-FLEIU6CG.js → c-IESDKFO6.js} +1 -1
  41. package/dist/m/{c-CJ7QYEWI.js → c-IJHF4IO6.js} +1 -1
  42. package/dist/m/{c-SGGGCIVD.js → c-IL5IVTOG.js} +1 -1
  43. package/dist/m/c-JB5YU57S.js +1 -0
  44. package/dist/m/{c-MP6S4AZU.js → c-JD2VFAYG.js} +2 -2
  45. package/dist/m/{c-CV4T65JE.js → c-JWW6BHWD.js} +3 -3
  46. package/dist/m/{c-42ZNV7LI.js → c-K4M76VPM.js} +1 -1
  47. package/dist/m/{c-6IJEVE6B.js → c-KU3PX7LL.js} +1 -1
  48. package/dist/m/{c-2PVGJFI5.js → c-KYTVZT4D.js} +1 -1
  49. package/dist/m/{c-BGN7RCTJ.js → c-M7ITYKMF.js} +1 -1
  50. package/dist/m/c-MFB74XVN.js +3 -0
  51. package/dist/m/c-MOP5KBWZ.js +1 -0
  52. package/dist/m/{c-YLHTD3KX.js → c-MUM53J5J.js} +1 -1
  53. package/dist/m/{c-YK2L436K.js → c-MV7TEUTD.js} +1 -1
  54. package/dist/m/{c-LA2BW7UY.js → c-MZCOGNZL.js} +1 -1
  55. package/dist/m/{c-XW5TIYYB.js → c-N4GEJMXW.js} +1 -1
  56. package/dist/m/{c-NQAPWM7O.js → c-NADLYVAH.js} +1 -1
  57. package/dist/m/{c-RS77ODLY.js → c-NL4I4KNG.js} +1 -1
  58. package/dist/m/{c-X75G43SZ.js → c-O2QZDVZ2.js} +1 -1
  59. package/dist/m/{c-LTSPHVAK.js → c-OBMZASYQ.js} +1 -1
  60. package/dist/m/{c-LUXAB2XI.js → c-ORLPQFNU.js} +1 -1
  61. package/dist/m/c-P73XPAOA.js +1 -0
  62. package/dist/m/{c-PWJSJEJU.js → c-PNZIJFG7.js} +1 -1
  63. package/dist/m/{c-ZKKAF4UT.js → c-PRZNJUYZ.js} +2 -2
  64. package/dist/m/{c-B7GOFGQR.js → c-Q2CB57UG.js} +1 -1
  65. package/dist/m/{c-TWCXBWS3.js → c-QCDVDZIR.js} +1 -1
  66. package/dist/m/{c-UOOIF2AL.js → c-QDVG4NAZ.js} +1 -1
  67. package/dist/m/c-QWB53KRW.js +1 -0
  68. package/dist/m/{c-GNI7WHKF.js → c-RGAALCDU.js} +1 -1
  69. package/dist/m/c-RHPHMTF2.js +2 -0
  70. package/dist/m/{c-3UW5EJ77.js → c-RWJ3OSCP.js} +1 -1
  71. package/dist/m/{c-5FXEKU4Y.js → c-SEVOS4UE.js} +1 -1
  72. package/dist/m/{c-HDVH3MVC.js → c-SFYTKRU7.js} +1 -1
  73. package/dist/m/{c-47IBJGPQ.js → c-SFZRY6RT.js} +1 -1
  74. package/dist/m/{c-QENKN7QI.js → c-SGG6MUXW.js} +1 -1
  75. package/dist/m/c-SMLAJASY.js +1 -0
  76. package/dist/m/{c-DFKBGSN2.js → c-SUAC5RSG.js} +1 -1
  77. package/dist/m/{c-6RGEQNVV.js → c-SXZYVXD6.js} +1 -1
  78. package/dist/m/{c-ZFO5RW6G.js → c-TCFVG3I4.js} +1 -1
  79. package/dist/m/{c-OCYG4NBQ.js → c-TLQINES7.js} +2 -2
  80. package/dist/m/c-U4TWEIKZ.js +1 -0
  81. package/dist/m/{c-MQYEDF3Q.js → c-U65PREMC.js} +1 -1
  82. package/dist/m/{c-PDBNCJCT.js → c-U7F66I64.js} +1 -1
  83. package/dist/m/{c-LATNQ6Q5.js → c-UD4VDBGJ.js} +1 -1
  84. package/dist/m/{c-PCNJETUA.js → c-V2FPBRO6.js} +1 -1
  85. package/dist/m/{c-ND3Q2G2I.js → c-V4B3RUWB.js} +1 -1
  86. package/dist/m/{c-JWDCQL6J.js → c-V5L6HWVL.js} +1 -1
  87. package/dist/m/c-VMXCX52Q.js +1 -0
  88. package/dist/m/{c-CZHTXGJS.js → c-VO6RSFCO.js} +1 -1
  89. package/dist/m/c-WDFQ7PBU.js +1 -0
  90. package/dist/m/{c-OG6GFSUX.js → c-WGQVSKKC.js} +1 -1
  91. package/dist/m/c-WSTUCBHV.js +1 -0
  92. package/dist/m/{c-FEC6LGFF.js → c-WVCT3ITX.js} +1 -1
  93. package/dist/m/{c-SE3SIY7Y.js → c-X3V4RWMA.js} +1 -1
  94. package/dist/m/{c-HIX5H5L7.js → c-XHZIKRCV.js} +1 -1
  95. package/dist/m/{c-2BLVA6IN.js → c-XQTERKQA.js} +1 -1
  96. package/dist/m/{c-PYG2NGWU.js → c-YFO6ZJLQ.js} +1 -1
  97. package/dist/m/{c-7CM4GMTS.js → c-YX2MC7YL.js} +1 -1
  98. package/dist/m/{c-OYHI67B6.js → c-YYGUHSZR.js} +1 -1
  99. package/dist/m/{c-YYMZWQLR.js → c-Z2OZFX3N.js} +1 -1
  100. package/dist/m/{c-AT7GLQGV.js → c-ZEA3DCG3.js} +1 -1
  101. package/dist/m/{c-T3P3AXEW.js → c-ZJG6C2WL.js} +1 -1
  102. package/dist/m/{c-FVPNX2GO.js → c-ZORVIXUR.js} +1 -1
  103. package/dist/m/{c-SKMIR5HQ.js → c-ZPI7M5U5.js} +1 -1
  104. package/dist/m/core/{admin-attrs-ONRWVXPK.js → admin-attrs-ZI6K6UGM.js} +1 -1
  105. package/dist/m/core/{autosave-TBKAAAFB.js → autosave-BSM2ABJL.js} +1 -1
  106. package/dist/m/core/{conflict-notice-FOEE6I7E.js → conflict-notice-7EQLDYPA.js} +1 -1
  107. package/dist/m/core/draft-mode-M5XNYBMY.js +1 -0
  108. package/dist/m/core/{host-permission-X4BENZEU.js → host-permission-5BYP24GC.js} +1 -1
  109. package/dist/m/core/{is-edit-mode-FFHCQ5DR.js → is-edit-mode-73OXKK5H.js} +1 -1
  110. package/dist/m/core/{persist-6ILUR34S.js → persist-2SZO3PCE.js} +1 -1
  111. package/dist/m/core/{recovery-APWADU4K.js → recovery-VZF7RJZF.js} +1 -1
  112. package/dist/m/core/{save-6HT2LABE.js → save-K6Q47J2X.js} +1 -1
  113. package/dist/m/core/{save-core-EVMNZQ4V.js → save-core-U3Z44XBO.js} +1 -1
  114. package/dist/m/core/{site-edits-G4BOZMV4.js → site-edits-CFMF6GHD.js} +1 -1
  115. package/dist/m/core/{snapshot-FJP5IJL3.js → snapshot-PWCHYFL6.js} +1 -1
  116. package/dist/m/core/unsaved-warning-2WRZLJH5.js +1 -0
  117. package/dist/m/events/{index-B6TGDYMG.js → index-YKQIBZE5.js} +1 -1
  118. package/dist/m/internals/index-FSLC4M7J.js +1 -0
  119. package/dist/m/lib/{cache-bust-NH7VBWHO.js → cache-bust-BL4KUQAJ.js} +1 -1
  120. package/dist/m/{loader-GLLVDUZA.js → loader-RC54UV7H.js} +1 -1
  121. package/dist/m/manifest-3B84C829.js +1 -0
  122. package/dist/m/manifest-edit-1CB79AD4.js +1 -0
  123. package/dist/m/manifest.json +1165 -1115
  124. package/dist/m/options/{options-55LQHSJ4.js → options-LKIZ7YTG.js} +1 -1
  125. package/dist/m/page/{editor-KAZDJNND.js → editor-PKSPJ2XJ.js} +2 -2
  126. package/dist/m/plugins/{ai-edit-LABECCSN.js → ai-edit-3LG6MGS3.js} +1 -1
  127. package/dist/m/plugins/{demo-T7B4RIKL.js → demo-LMCMBILC.js} +1 -1
  128. package/dist/m/plugins/{derive-6LPJOCAV.js → derive-7DR5TUDH.js} +1 -1
  129. package/dist/m/plugins/{indicator-J4ABFARX.js → indicator-CTKX4EY7.js} +1 -1
  130. package/dist/m/plugins/{live-PGBIEMGB.js → live-IFLL6YN5.js} +1 -1
  131. package/dist/m/plugins/{menu-YZL3X2AJ.js → menu-YJZ3JWBC.js} +1 -1
  132. package/dist/m/plugins/{page-WOCNX2IN.js → page-GTDPYGE4.js} +2 -2
  133. package/dist/m/plugins/{page-view-SJODOOGE.js → page-view-NMCCU6MF.js} +1 -1
  134. package/dist/m/plugins/{people-C4TCWFOQ.js → people-6WIWCZEG.js} +1 -1
  135. package/dist/m/plugins/{richclay-Y2NV44NA.js → richclay-L3BZMX4I.js} +2 -2
  136. package/dist/m/plugins/{sortable-XCHQG65Z.js → sortable-365SRRL3.js} +1 -1
  137. package/dist/m/plugins/{source-YK7MO23W.js → source-7LSGOV46.js} +1 -1
  138. package/dist/m/plugins/{undo-VLRBQNPN.js → undo-UES4KS7B.js} +1 -1
  139. package/dist/m/plugins/{upgrade-NNTJBSK2.js → upgrade-MMPZUCDM.js} +1 -1
  140. package/dist/m/plugins/{upload-ZKKJV76X.js → upload-NZET3DNQ.js} +1 -1
  141. package/dist/m/plugins/visitor-drafts-V5YB7XDH.js +20 -0
  142. package/dist/m/plugins/{visitor-drafts-owner-LHUHFU3L.js → visitor-drafts-owner-TLECTYWS.js} +1 -1
  143. package/dist/m/plugins/{visitor-menu-FY4KM2SW.js → visitor-menu-QDV2MYJN.js} +1 -1
  144. package/dist/m/plugins/wire-3YGUO3GE.js +1 -0
  145. package/dist/m/{reader-core-T2S3JC4E.js → reader-core-VR7EL4WV.js} +2 -2
  146. package/dist/m/sync/live-sync-XMXXZS3G.js +1 -0
  147. package/dist/m/vendor/sap-core.vendor-JANUQULT.js +7 -0
  148. package/dist/offline-manifest.json +665 -635
  149. package/docs/guide.md +1 -0
  150. package/entries/sap.js +6 -5
  151. package/package.json +1 -1
  152. package/src/core/draft-mode.js +5 -0
  153. package/src/core/save-core.js +10 -10
  154. package/src/core/save.js +1 -1
  155. package/src/lib/dirty-gate.js +19 -0
  156. package/src/plugins/menu/visitor.js +33 -1
  157. package/src/plugins/visitor-drafts/commit.js +50 -3
  158. package/src/plugins/visitor-drafts/idb.js +8 -2
  159. package/src/plugins/visitor-drafts/recovery-menu.js +118 -0
  160. package/src/plugins/visitor-drafts/recovery.js +64 -0
  161. package/src/plugins/visitor-drafts/session.js +61 -13
  162. package/src/plugins/visitor-drafts/store.js +44 -8
  163. package/src/plugins/visitor-drafts.js +34 -5
  164. package/src/sync/live-sync.js +1 -1
  165. package/src/sync/wire-profile.js +9 -4
  166. package/src/vendor/sap-core.vendor.js +6 -5
  167. package/src/vendor/sap-ownership.vendor.js +181 -11
  168. package/tool-generation/system.md +1 -1
  169. package/dist/m/attrs/save-freeze-JZHKRQLR.js +0 -1
  170. package/dist/m/c-6Q6RGFBF.js +0 -1
  171. package/dist/m/c-APGHGDZM.js +0 -1
  172. package/dist/m/c-EILLN2H2.js +0 -1
  173. package/dist/m/c-HTLYXCUH.js +0 -1
  174. package/dist/m/c-MFOSMAVM.js +0 -3
  175. package/dist/m/c-R23UHMXG.js +0 -1
  176. package/dist/m/c-SGH3UTF3.js +0 -1
  177. package/dist/m/c-U4NTUVDZ.js +0 -1
  178. package/dist/m/c-V2U3F4QX.js +0 -1
  179. package/dist/m/c-VG5XIN4T.js +0 -1
  180. package/dist/m/c-VHSMPITY.js +0 -1
  181. package/dist/m/core/draft-mode-4MCL3LYI.js +0 -1
  182. package/dist/m/core/unsaved-warning-ITZDIZ2I.js +0 -1
  183. package/dist/m/internals/index-HS3CQDFW.js +0 -1
  184. package/dist/m/manifest-50FF1C45.js +0 -1
  185. package/dist/m/manifest-edit-BE1A621D.js +0 -1
  186. package/dist/m/plugins/visitor-drafts-RTZNONHT.js +0 -20
  187. package/dist/m/plugins/wire-M2NR354P.js +0 -1
  188. package/dist/m/sync/live-sync-Z64YREWQ.js +0 -1
  189. package/dist/m/vendor/sap-core.vendor-QAEPMETX.js +0 -6
  190. /package/dist/m/plugins/{richclay-Y2NV44NA.js.LEGAL.txt → richclay-L3BZMX4I.js.LEGAL.txt} +0 -0
@@ -1,4 +1,4 @@
1
- import{d as Ae,h as Ve,i as qe}from"./c-TRS6TM6O.js";import{a as Ne,b as Pe}from"./c-4PO3YGDC.js";import{a as Ie,b as Oe}from"./c-PZ4XEPUP.js";import"./c-SFKI6OLM.js";import"./c-Q3XOWZEV.js";import"./c-RHMPKZZ7.js";import{e as ke,f as Ke,g as W,h as Ue,l as re,m as $e,n as p}from"./c-MR75YPRT.js";import"./c-4JZDZFF6.js";import{b as U,c as Z,e as l,f as Ye}from"./c-5RZNFTWD.js";import{b as He}from"./c-PKCCHJ5X.js";import{b as T,c as Fe}from"./c-NUHP2XDB.js";import{a as We,r as V}from"./c-HTLYXCUH.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import{f as Te}from"./c-6Q6RGFBF.js";import"./c-SKMIR5HQ.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-LA2BW7UY.js";import"./c-MFOSMAVM.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-6IJEVE6B.js";import"./c-QQFHEODI.js";import"./c-IJUK2GPW.js";import{f as _e}from"./c-EDE45NM7.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4NTUVDZ.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 E="light-dark(#D08A1E, #E3A33F)",lt=5e3,st=4e3,dt=500,ct={"another-tab":"in another tab","another-person":"by someone else","an-agent":"by an agent"},pt='<svg viewBox="0 0 12 12" width="12" height="12" aria-hidden="true"><path d="M2.5 9.5h7" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="square"/></svg>',F=(e,t)=>`${e} ${t}${e===1?"":"s"}`,ut="This spot changed again. Review the latest edit or download your copy.",ft="A data value can't be put back from here. Download your copy to keep yours.",m="hidden",P=!1,S=[],J=new Set,M=new Set,h=null,Ee=0,I=null,v=null,le=null,u=null,R=!1,Y=!1,ve=!1,G=new Map,se=0,ae=!1,te=!1,b=null,j=null,L=null,Se=0,D=!1,de=0,ce=null,ne=null,k=[],x=[],oe=!1,pe=null,ue=null,s=null,B=null,q=new Map,z=()=>window.clay?.conflicts||null,Qe=()=>k.reduce((e,t)=>e+t.conflicts.length,0)+x.length,Le=()=>{let e=window.clay?.undo;return e&&typeof e.kept=="function"?e:null},fe=()=>z()?.list().filter(e=>!e.claimedBy&&e.kind!=="apply-incomplete")??[],De=()=>z()?.list().filter(e=>!e.claimedBy&&e.kind==="apply-incomplete")??[];function ze(){return I?"upgraded":h?"refused":fe().length?"replaced":De().length?"failed":k.length||x.length?"recovered":null}function f(e,t,n){let o=Fe(e,t,n);return t[0]==="all:initial"&&T(o,"color-scheme","inherit"),o.setAttribute("clay",ke),o}function _(e,t){return q.set(t,e),e}function ie(){if(!s)return;let e=window.visualViewport,t=e?Math.max(0,window.innerHeight-e.height-e.offsetTop):0;T(s,"bottom",`calc(${16+t}px + env(safe-area-inset-bottom,0px))`),ne&&T(ne,"max-height",`${Math.max(160,(e?.height||window.innerHeight)-32)}px`)}function ht(){s=f("div",["all:initial","position:fixed","left:50%","transform:translateX(-50%)","z-index:2147483001","display:none","flex-direction:column","align-items:center","max-width:calc(100vw - 24px)",`font:14px/1.5 ${U}`,`color:${l.ink}`,"text-align:left"]),s.setAttribute("data-clay-conflict",""),document.body.appendChild(s),window.visualViewport?.addEventListener("resize",ie),window.visualViewport?.addEventListener("scroll",ie)}function d(){if(ae)return;ae=!0;let e=()=>{ae=!1,w()};typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16)}function w(){te&&(te=!1,h&&!V()&&(h=null));let e=ze();if(e?m==="hidden"&&(m="bar"):(m="hidden",P=!1,J.clear(),M.clear(),S=[],y(),ce=null,D=!1),!s){if(m==="hidden"&&!b||!document.body)return;ht()}!s.isConnected&&document.body&&document.body.appendChild(s);let t=document.activeElement,n=null;for(let[a,r]of q)r===t&&(n=a);let o=B?B.scrollTop:0;q=new Map,B=null,ne=null,s.replaceChildren(),b?s.append(wt(b)):m==="bar"?s.append(yt(e)):m==="panel"&&s.append(xt(e)),T(s,"display",b||m!=="hidden"?"flex":"none"),B&&(B.scrollTop=o);let i=L||n;i&&q.has(i)&&q.get(i).focus({preventScroll:!0}),b||(L=null),ie(),He(s)}function Xe(){return f("span",["all:initial","display:inline-block","flex:none","width:8px","height:8px","border-radius:50%",`background:${E}`])}function Ze(){return ct[h?.changedBy]||null}function gt(e,t){if(e==="upgraded")return I;if(e==="refused"){let n=Ze();return!n&&h.afterTimeout?"This page changed elsewhere, possibly by your own save that timed out. Your edits here are safe.":`This page changed ${n||"elsewhere"}. Your edits here are safe.`}return e==="failed"?"A sync update did not finish. Your edits here are safe.":e==="recovered"?`${F(t,"change")} replaced before this page loaded ${t===1?"is":"are"} still here.`:`Another edit replaced ${F(t,"change")}.`}function mt(e,t){return e==="upgraded"?I:e==="refused"?`This page changed ${Ze()||"elsewhere"}`:e==="failed"?"A sync update did not finish":e==="recovered"?`${F(t,"change")} kept from before this page loaded`:`Another edit replaced ${F(t,"change")}`}function wt(e){let t=re("div",["display:block",`border-left:3px solid ${l.teal}`,"padding:10px 14px","width:max-content","max-width:calc(100vw - 24px)"]);return t.setAttribute("role","status"),t.textContent=e,t}function yt(e){let t=e==="failed"?De().length:e==="recovered"?Qe():fe().length,n=re("div",["display:flex","flex-wrap:wrap","align-items:center","gap:10px 12px","padding:8px 8px 8px 14px","width:max-content","max-width:calc(100vw - 24px)"]),o=gt(e,t);return o!==ce&&(n.setAttribute("role",e==="refused"?"alert":"status"),ce=o),n.append(Xe(),p("span",[],o)),e==="upgraded"?(n.append(_(W("Reload",{variant:"primary",onClick:()=>window.location.reload()}),"reload")),n):(n.append(_(W("Review",{onClick:Dt}),"review")),n)}function $(e,t,{variant:n="default",onClick:o,push:i=!1}={}){let r=window.innerWidth<480?["flex:1 1 100%",...n==="primary"?["order:-1"]:[]]:i?["margin-left:auto"]:[];return _(W(e,{variant:n,onClick:o,extra:r}),t)}function A(e){return p("div",["display:block","padding:0 16px 12px",`color:${l["ink-2"]}`,"font-size:13.5px"],e)}function xt(e){let t=e==="replaced"?fe():e==="failed"?De():[],n=e==="refused"?fe():t,o=e==="recovered"?Qe():t.length;if(J.size)for(let c of t)J.has(c.id)||M.add(c.id);for(let c of[...M])t.some(N=>N.id===c)||M.delete(c);let i=mt(e,o),a=Math.max(160,(window.visualViewport?.height||window.innerHeight)-32),r=re("div",["display:flex","flex-direction:column","width:520px","max-width:calc(100vw - 24px)",`max-height:${a}px`]);ne=r,r.setAttribute("role","dialog"),r.setAttribute("aria-label",i);let g=f("div",["all:initial","display:flex","align-items:center","gap:8px","padding:12px 12px 8px 16px",`font:14px/1.5 ${U}`,`color:${l.ink}`]),K=_(p("b",["font-weight:600","font-size:14.5px","outline:none"],i),"title");K.setAttribute("tabindex","-1"),g.append(Xe(),K),e==="replaced"&&M.size&&g.append(p("span",[`font:600 10.5px/1 ${Z}`,"letter-spacing:.12em","text-transform:uppercase","padding:3px 6px",`color:color-mix(in srgb, ${l.brass} 80%, ${l.ink})`,`background:${l["brass-soft"]}`],`${M.size} new`));let X=f("span",["all:initial","display:inline-flex","margin-left:auto"]),Be=_(Ue(pt,{label:"Minimize",onClick:Je}),"minimize");if(Be.title="Minimize to the bar. Nothing is accepted until you choose.",X.append(Be),g.append(X),r.append(g),e==="recovered")return Et(r),r;if(e==="refused"){if(r.append(A("Your edits here are safe and not saved yet; nothing will be overwritten until you choose. Their version is not on this page, so there is no list of edits to compare. Keep yours, which saves over theirs, or accept theirs, which reloads the page and drops your unsaved edits.")),n.length&&r.append(A(`${F(n.length,"earlier replaced edit")} ${n.length===1?"is":"are"} also held in this tab. Download my copy includes them.`)),R&&r.append(A("That did not save either. Your edits here are still here.")),D&&r.append(A("Something changed on the page after your first press, so nothing was dropped. Press Accept theirs again if you still want their version.")),v){let c=f("div",["all:initial","display:block","margin:0 16px 12px","padding:8px 10px",`border-left:3px solid ${E}`,`background:color-mix(in srgb, ${E} 14%, transparent)`,`color:${l.ink}`,`font:13px/1.5 ${U}`]);c.append(f("b",["all:initial","font:inherit","font-weight:700","color:inherit"],"This drops your unsaved edits."),document.createTextNode(" Download your copy first if you might want them. Press again to confirm.")),r.append(c)}}else e==="upgraded"?r.append(A("Its layout and code changed with it, so this page stops here. Reload to see the new version.")):e==="failed"?r.append(A("Part of an update from elsewhere could not be applied, so this page may be missing some of it. Your edits here are safe. Download a copy of the page as you had it, or accept to keep the page as it is.")):r.append(A("The page is showing the other edit. This stays until you choose. You can also save a copy of the page as you had it."));let O=f("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","padding:0 16px 14px"]);if(e==="upgraded")return O.append($("Reload","reload",{variant:"primary",onClick:()=>window.location.reload(),push:!0})),r.append(O),S=[],r;let at=$(ve?"Try again":Y?"Downloaded":"Download my copy","download",{onClick:Bt});if(O.append(at),e==="refused"){let c=$(u==="overwrite"?"Saving\u2026":R?"Try again":"Keep mine","keep",{onClick:Pt});c.setDisabled(u==="overwrite"),O.append(c,$(v?"Yes, drop my edits":"Accept theirs","accept",{variant:"primary",onClick:Ft,push:!0}))}else{if(e==="replaced"){let c=z().hasPendingApply(),N=$(c?"Finishing the incoming edit\u2026":u==="revert"?"Putting back\u2026":"Revert to mine","revert",{onClick:Mt});N.setDisabled(c||u==="revert"),O.append(N)}O.append($("Accept theirs","accept",{variant:"primary",onClick:zt,push:!0}))}if(r.append(O),e==="replaced")if(P)r.append(vt(t));else{let c=f("div",["all:initial","display:flex","align-items:center","gap:8px",`border-top:1px solid ${l.line}`,"padding:8px 10px 8px 16px",`color:${l.muted}`,`font:13px/1.5 ${U}`]),N=f("span",["all:initial","display:inline-flex","margin-left:auto"]);N.append(_(W("See the edits",{small:!0,onClick:et}),"list")),c.append(f("span",["all:initial","font:inherit","color:inherit"],F(t.length,"edit")),N),r.append(c)}S=n.map(c=>c.id);for(let c of t)J.add(c.id);return r}function vt(e){let t=$e(["flex:1 1 auto","margin:0 16px 12px","min-height:0","overflow:auto",`background:${l.sunk}`,`border:1px solid ${l["line-2"]}`]),n=f("div",["all:initial","position:sticky","top:0","z-index:1","display:flex","align-items:center","gap:8px","padding:8px 12px",`background:${l.sunk}`,`border-bottom:1px solid ${l["line-2"]}`,`color:${l.muted}`,`font:600 10.5px/1 ${Z}`,"letter-spacing:.12em","text-transform:uppercase"]),o=f("span",["all:initial","display:inline-flex","margin-left:auto"]);return o.append(_(W("Hide",{small:!0,variant:"quiet",onClick:et}),"list")),n.append(f("span",["all:initial","font:inherit","color:inherit","letter-spacing:inherit","text-transform:inherit"],"Replaced edits"),o),t.append(n),e.forEach((i,a)=>t.append(St(i,a))),B=t,t}function Me(e){let t=e.context?.label||e.name||(e.context?.kind==="entry"?"Entry":"Edit");return e.context?.field?`${t} \xB7 ${e.context.field}`:t}var bt={"content-changed":"the page changed there","structure-changed":"the structure changed there","target-detached":"that part of the page is gone","duplicate-id":"another part of the page now has the same id",protected:"that region keeps its own history",unsupported:"this kind of step cannot be put back"},kt=e=>bt[e]||"the page changed there";function $t(e,t){let n=Array.isArray(e)?e:[];for(let o of n){if(!o||o.kind!=="text"&&o.kind!=="value")continue;let i=t==="redo"?o.after:o.before;if(typeof i=="string"&&i)return{text:i,id:o.target?.id??null}}for(let o of n){if(!o||o.kind!=="add"&&o.kind!=="remove")continue;let i=Array.isArray(o.nodes)?o.nodes.find(a=>typeof a?.html=="string"&&a.html):null;if(i)return{text:Ie(i.html).replace(/\s+/g," ").trim(),id:o.parent?.id??null}}for(let o of n){if(!o)continue;let i=t==="redo"?o.after:o.before;if(typeof i=="string"&&i)return{text:i,id:o.target?.id??null}}return{text:"",id:null}}function Tt(e){if(e==null||typeof document>"u")return"";let t=window.CSS?.escape?window.CSS.escape(String(e)):String(e).replace(/["\\]/g,"\\$&"),n=null;try{n=document.querySelector(`[data-id="${t}"]`)}catch{return""}if(!n)return"";let o=n.matches?.("input, textarea, select")?n.value:null;return(typeof o=="string"?o:n.textContent??"").replace(/\s+/g," ").trim()}function At(e){let t=e?.payload&&typeof e.payload=="object"?e.payload:{},n=String(e?.key??""),o={id:e?.id,revision:e?.revision,record:e,kind:e?.kind??"conflict"};if(n.startsWith("app:"))return{...o,name:typeof t.label=="string"&&t.label?t.label:n.slice(4),sentence:"",yours:typeof t.text=="string"?t.text:"",now:""};let i=t.direction==="redo"?"redo":"undo",g=((Array.isArray(t.context)?t.context:[]).find(X=>typeof X?.label=="string"&&X.label)??null)?.label||typeof t.label=="string"&&t.label||"Edit",K=$t(t.steps,i);return{...o,name:g,sentence:`The ${i} of "${g}" was not applied because ${kt(t.code)}.`,yours:K.text,now:K.id==null?"":Tt(K.id)}}function Ct(e){let t=Le();if(!e.record||typeof t?.reviewActionsFor!="function")return[];try{return(t.reviewActionsFor(e.record)||[]).filter(n=>n&&typeof n.run=="function"&&n.label)}catch{return[]}}var Ge=e=>({before:"",hit:e,after:"",cutBefore:!1,cutAfter:!1});function je(e){let t=p("div",["display:block","padding:8px 12px 10px"]),n=p("div",["display:flex","align-items:center","gap:8px","font-size:12.5px","font-weight:600",`color:${l["ink-2"]}`,"margin-bottom:4px"]);if(n.append(p("span",[],Me(e))),t.append(n),e.sentence&&t.append(p("div",["display:block","font-size:13px",`color:${l["ink-2"]}`],e.sentence)),e.yours){let i=p("div",["display:grid","grid-template-columns:44px 1fr","gap:3px 10px","align-items:start",`font:12.5px/1.5 ${Z}`,...e.sentence?["margin-top:4px"]:[]]);i.append(...he("Yours",Ge(e.yours),{mine:!0})),e.now&&i.append(...he("Now",Ge(e.now),{mine:!1})),t.append(i)}let o=f("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","margin-top:8px"]);return Ct(e).forEach((i,a)=>{let r=$(i.label,`run:${e.id}:${a}`,{onClick:()=>Nt(e,i,r)});o.append(r)}),o.append($(pe===e.id?"Copied":"Copy",`copy:${e.id}`,{onClick:()=>It(e)})),o.append($("Dismiss",`dismiss:${e.id}`,{onClick:()=>tt(e)})),t.append(o),t}function Et(e){e.append(A(k.length?"These copies were replaced before this page loaded. The page never puts them back on its own. Copy or download the ones you want; dismiss one when you no longer need it.":"These copies were kept because an undo could not be put back or the page set them aside. The page never puts them back on its own. Copy or download the ones you want; dismiss one when you no longer need it.")),oe&&e.append(A("That action did not run. The copy is still here."));let t=$e(["flex:1 1 auto","margin:0 16px 12px","min-height:0","overflow:auto",`background:${l.sunk}`,`border:1px solid ${l["line-2"]}`]);for(let o of k)for(let i of o.conflicts)t.append(je(i));for(let o of x)t.append(je(o));B=t,e.append(t);let n=f("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","padding:0 16px 14px"]);(k.some(o=>o.root)||x.length)&&n.append($(Y?"Downloaded":"Download my copy","download",{onClick:Ot})),e.append(n),S=[]}function he(e,t,{mine:n}){let o=[p("span",[`color:${l.faint}`,`font-family:${U}`],e)],i=p("span",["display:-webkit-box","-webkit-line-clamp:2","-webkit-box-orient:vertical","overflow:hidden","overflow-wrap:anywhere",...n?[`color:${l.ink}`]:[`color:${l.muted}`]]),a=(t.cutBefore?"\u2026":"")+t.before+t.hit+t.after+(t.cutAfter?"\u2026":"");i.title=a,t.before&&i.append(p("span",[`color:${l.faint}`],(t.cutBefore?"\u2026":"")+t.before));let r=p("span",n?[`background:color-mix(in srgb, ${E} 18%, transparent)`,"padding:0 4px"]:t.before||t.after?["text-decoration:underline",`text-decoration-color:color-mix(in srgb, ${E} 70%, transparent)`,"text-underline-offset:3px"]:[],t.hit||"(empty)");return i.append(r),t.after&&i.append(p("span",[`color:${l.faint}`],t.after+(t.cutAfter?"\u2026":""))),o.push(i),o}function St(e,t){let n=Oe(e),o=p("div",["display:block","padding:8px 12px 10px",...t?[`border-top:1px solid ${l.line}`]:[]]),i=p("div",["display:flex","align-items:center","gap:4px","font-size:12.5px","font-weight:600",`color:${l["ink-2"]}`,"margin-bottom:4px"]);if(i.append(p("span",[],n.name)),n.target&&n.target.isConnected&&i.append(_(Rt(n),`eye:${e.id}`)),o.append(i),n.sentence&&o.append(p("div",["display:block","font-size:13px",`color:${l["ink-2"]}`],n.sentence)),G.has(e.id)&&o.append(p("div",["display:block","font-size:13px","margin-top:4px",`color:${E}`],G.get(e.id))),n.yours){let a=p("div",["display:grid","grid-template-columns:44px 1fr","gap:3px 10px","align-items:start",`font:12.5px/1.5 ${Z}`,...n.sentence?["margin-top:4px"]:[]]);a.append(...he("Yours",n.yours,{mine:!0})),n.now&&a.append(...he("Now",n.now,{mine:!1})),o.append(a)}return o}function Rt(e){let t=["all:initial","color-scheme:inherit","box-sizing:border-box","cursor:pointer","display:inline-grid","place-items:center","width:22px","height:20px",`color:${l.ink}`],n=f("button",t);n.type="button",n.innerHTML=Ye.conflictEye,Ke(n.firstElementChild,16),n.setAttribute("aria-label",`Show ${e.name} on page`),n.title="Show on page";let o=i=>{n.style.cssText="";for(let a of[...t,...i]){let r=a.indexOf(":");n.style.setProperty(a.slice(0,r),a.slice(r+1),"important")}};return n.addEventListener("pointerenter",()=>o([`background:color-mix(in srgb, ${E} 16%, transparent)`])),n.addEventListener("pointerleave",()=>o([])),n.addEventListener("focus",()=>o([`outline:2px solid ${l.brass}`,"outline-offset:1px"])),n.addEventListener("blur",()=>o([])),n.addEventListener("click",()=>Lt(e.target)),n}var C=null,ge=null,me=null;function we(){clearTimeout(ge),window.removeEventListener("scroll",ee,!0),window.removeEventListener("resize",ee),C?.remove(),C=null,me=null}function ee(){if(!C||!me)return;let e=me.getBoundingClientRect();T(C,"left",`${e.left}px`),T(C,"top",`${e.top}px`),T(C,"width",`${e.width}px`),T(C,"height",`${e.height}px`)}function Lt(e){if(we(),!e||!e.isConnected)return;let n=!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches?"instant":"smooth",o=s?.getBoundingClientRect().top??0,i=s&&o>0?Math.max(0,window.innerHeight-o):0;if(!i)e.scrollIntoView?.({block:"center",behavior:n});else{e.scrollIntoView?.({block:"center",behavior:"instant"});let a=e.getBoundingClientRect(),r=window.innerHeight-i,g=a.height>r-24?a.top-12:a.top+a.height/2-r/2;window.scrollBy?.({top:g,behavior:n})}me=e,C=f("div",["all:initial","color-scheme:inherit","position:fixed","pointer-events:none","z-index:2147483001",`outline:2px solid ${E}`,"outline-offset:3px",`background:color-mix(in srgb, ${E} 14%, transparent)`]),document.body.appendChild(C),ee(),window.addEventListener("scroll",ee,!0),window.addEventListener("resize",ee),ge=setTimeout(we,2500)}function Dt(){I||(m="panel",L="title",w())}function Je(){we(),m="bar",y(),L="review",w()}function et(){P=!P,P&&M.clear(),w()}function zt(){let e=z(),t=S.filter(n=>{let o=e?.get(n);return o&&!o.claimedBy});e&&t.length&&e.acknowledge(t,{reason:"accepted"}),m=ze()?"bar":"hidden",L="review",d()}async function Mt(){let e=z();if(u||!e||e.hasPendingApply())return;let t=S.filter(r=>{let g=e.get(r);return g&&!g.claimedBy});if(!t.length)return;u="revert",w();let n=!0,o=r=>{n=!!s?.contains(r.target)};document.addEventListener("focus",o,!0);let i;try{let{revertConflicts:r}=await import("./c-LSVN3OLG.js");i=await r(t)}catch(r){console.error("[clay] Revert to mine did not finish",r),i={revertedIds:[],blockedIds:t,saveResult:null}}finally{document.removeEventListener("focus",o,!0)}u=null;for(let r of i.blockedIds)G.set(r,z()?.get(r)?.kind==="json"?ft:ut);m=ze()?"bar":"hidden",L=n?"review":null;let a=i.saveResult&&(i.saveResult.ok||i.saveResult.msg==="Save already in progress");i.revertedIds.length&&a?be(`Put back ${F(i.revertedIds.length,"change")}. Saving.`):w()}var Q=null;async function Bt(){let e=z(),t=h?e?.list()??[]:S.map(o=>e?.get(o)).filter(Boolean),n=await Pe(t,{refused:!!h});ve=!n,Y=n,clearTimeout(Q),n&&(Q=setTimeout(()=>{Y=!1,d()},1200)),w()}async function H(){let e=null;if(Ae())try{e=await Ve()}catch{e=null}let t=Le(),n=null;if(t)try{n=await t.kept()}catch{n=null}let o=!1;if(e?.ok?(k=e.records,o=!0):!Ae()&&k.length&&(k=[],o=!0),n?.ok){let i=(Array.isArray(n.records)?n.records:[]).filter(r=>r&&r.supported!==!1).map(At);i.length===x.length&&i.every((r,g)=>r.id===x[g].id&&r.revision===x[g].revision)||(o=!0),x=i}else n&&x.length&&(x=[],o=!0);o&&d()}async function _t(e){try{return await navigator.clipboard.writeText(e),!0}catch{}let t=document.createElement("textarea");t.value=e,t.setAttribute("clay",ke),t.style.setProperty("position","fixed","important"),t.style.setProperty("opacity","0","important"),document.body?.append(t),t.select();let n=!1;try{n=document.execCommand?.("copy")===!0}catch{}return t.remove(),n}async function It(e){let t=e.record?e.yours:`${Me(e)}
1
+ import{d as Ae,h as Ve,i as qe}from"./c-TRS6TM6O.js";import{a as Ne,b as Pe}from"./c-HGG7M2S3.js";import{a as Ie,b as Oe}from"./c-PZ4XEPUP.js";import"./c-SFKI6OLM.js";import"./c-Q3XOWZEV.js";import"./c-RHMPKZZ7.js";import{e as ke,f as Ke,g as W,h as Ue,l as re,m as $e,n as p}from"./c-MR75YPRT.js";import"./c-4JZDZFF6.js";import{b as U,c as Z,e as l,f as Ye}from"./c-5RZNFTWD.js";import{b as He}from"./c-PKCCHJ5X.js";import{b as T,c as Fe}from"./c-NUHP2XDB.js";import{a as We,r as V}from"./c-VMXCX52Q.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import{f as Te}from"./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{f as _e}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 E="light-dark(#D08A1E, #E3A33F)",lt=5e3,st=4e3,dt=500,ct={"another-tab":"in another tab","another-person":"by someone else","an-agent":"by an agent"},pt='<svg viewBox="0 0 12 12" width="12" height="12" aria-hidden="true"><path d="M2.5 9.5h7" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="square"/></svg>',F=(e,t)=>`${e} ${t}${e===1?"":"s"}`,ut="This spot changed again. Review the latest edit or download your copy.",ft="A data value can't be put back from here. Download your copy to keep yours.",m="hidden",P=!1,S=[],J=new Set,M=new Set,h=null,Ee=0,I=null,v=null,le=null,u=null,R=!1,Y=!1,ve=!1,G=new Map,se=0,ae=!1,te=!1,b=null,j=null,L=null,Se=0,D=!1,de=0,ce=null,ne=null,k=[],x=[],oe=!1,pe=null,ue=null,s=null,B=null,q=new Map,z=()=>window.clay?.conflicts||null,Qe=()=>k.reduce((e,t)=>e+t.conflicts.length,0)+x.length,Le=()=>{let e=window.clay?.undo;return e&&typeof e.kept=="function"?e:null},fe=()=>z()?.list().filter(e=>!e.claimedBy&&e.kind!=="apply-incomplete")??[],De=()=>z()?.list().filter(e=>!e.claimedBy&&e.kind==="apply-incomplete")??[];function ze(){return I?"upgraded":h?"refused":fe().length?"replaced":De().length?"failed":k.length||x.length?"recovered":null}function f(e,t,n){let o=Fe(e,t,n);return t[0]==="all:initial"&&T(o,"color-scheme","inherit"),o.setAttribute("clay",ke),o}function _(e,t){return q.set(t,e),e}function ie(){if(!s)return;let e=window.visualViewport,t=e?Math.max(0,window.innerHeight-e.height-e.offsetTop):0;T(s,"bottom",`calc(${16+t}px + env(safe-area-inset-bottom,0px))`),ne&&T(ne,"max-height",`${Math.max(160,(e?.height||window.innerHeight)-32)}px`)}function ht(){s=f("div",["all:initial","position:fixed","left:50%","transform:translateX(-50%)","z-index:2147483001","display:none","flex-direction:column","align-items:center","max-width:calc(100vw - 24px)",`font:14px/1.5 ${U}`,`color:${l.ink}`,"text-align:left"]),s.setAttribute("data-clay-conflict",""),document.body.appendChild(s),window.visualViewport?.addEventListener("resize",ie),window.visualViewport?.addEventListener("scroll",ie)}function d(){if(ae)return;ae=!0;let e=()=>{ae=!1,w()};typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16)}function w(){te&&(te=!1,h&&!V()&&(h=null));let e=ze();if(e?m==="hidden"&&(m="bar"):(m="hidden",P=!1,J.clear(),M.clear(),S=[],y(),ce=null,D=!1),!s){if(m==="hidden"&&!b||!document.body)return;ht()}!s.isConnected&&document.body&&document.body.appendChild(s);let t=document.activeElement,n=null;for(let[a,r]of q)r===t&&(n=a);let o=B?B.scrollTop:0;q=new Map,B=null,ne=null,s.replaceChildren(),b?s.append(wt(b)):m==="bar"?s.append(yt(e)):m==="panel"&&s.append(xt(e)),T(s,"display",b||m!=="hidden"?"flex":"none"),B&&(B.scrollTop=o);let i=L||n;i&&q.has(i)&&q.get(i).focus({preventScroll:!0}),b||(L=null),ie(),He(s)}function Xe(){return f("span",["all:initial","display:inline-block","flex:none","width:8px","height:8px","border-radius:50%",`background:${E}`])}function Ze(){return ct[h?.changedBy]||null}function gt(e,t){if(e==="upgraded")return I;if(e==="refused"){let n=Ze();return!n&&h.afterTimeout?"This page changed elsewhere, possibly by your own save that timed out. Your edits here are safe.":`This page changed ${n||"elsewhere"}. Your edits here are safe.`}return e==="failed"?"A sync update did not finish. Your edits here are safe.":e==="recovered"?`${F(t,"change")} replaced before this page loaded ${t===1?"is":"are"} still here.`:`Another edit replaced ${F(t,"change")}.`}function mt(e,t){return e==="upgraded"?I:e==="refused"?`This page changed ${Ze()||"elsewhere"}`:e==="failed"?"A sync update did not finish":e==="recovered"?`${F(t,"change")} kept from before this page loaded`:`Another edit replaced ${F(t,"change")}`}function wt(e){let t=re("div",["display:block",`border-left:3px solid ${l.teal}`,"padding:10px 14px","width:max-content","max-width:calc(100vw - 24px)"]);return t.setAttribute("role","status"),t.textContent=e,t}function yt(e){let t=e==="failed"?De().length:e==="recovered"?Qe():fe().length,n=re("div",["display:flex","flex-wrap:wrap","align-items:center","gap:10px 12px","padding:8px 8px 8px 14px","width:max-content","max-width:calc(100vw - 24px)"]),o=gt(e,t);return o!==ce&&(n.setAttribute("role",e==="refused"?"alert":"status"),ce=o),n.append(Xe(),p("span",[],o)),e==="upgraded"?(n.append(_(W("Reload",{variant:"primary",onClick:()=>window.location.reload()}),"reload")),n):(n.append(_(W("Review",{onClick:Dt}),"review")),n)}function $(e,t,{variant:n="default",onClick:o,push:i=!1}={}){let r=window.innerWidth<480?["flex:1 1 100%",...n==="primary"?["order:-1"]:[]]:i?["margin-left:auto"]:[];return _(W(e,{variant:n,onClick:o,extra:r}),t)}function A(e){return p("div",["display:block","padding:0 16px 12px",`color:${l["ink-2"]}`,"font-size:13.5px"],e)}function xt(e){let t=e==="replaced"?fe():e==="failed"?De():[],n=e==="refused"?fe():t,o=e==="recovered"?Qe():t.length;if(J.size)for(let c of t)J.has(c.id)||M.add(c.id);for(let c of[...M])t.some(N=>N.id===c)||M.delete(c);let i=mt(e,o),a=Math.max(160,(window.visualViewport?.height||window.innerHeight)-32),r=re("div",["display:flex","flex-direction:column","width:520px","max-width:calc(100vw - 24px)",`max-height:${a}px`]);ne=r,r.setAttribute("role","dialog"),r.setAttribute("aria-label",i);let g=f("div",["all:initial","display:flex","align-items:center","gap:8px","padding:12px 12px 8px 16px",`font:14px/1.5 ${U}`,`color:${l.ink}`]),K=_(p("b",["font-weight:600","font-size:14.5px","outline:none"],i),"title");K.setAttribute("tabindex","-1"),g.append(Xe(),K),e==="replaced"&&M.size&&g.append(p("span",[`font:600 10.5px/1 ${Z}`,"letter-spacing:.12em","text-transform:uppercase","padding:3px 6px",`color:color-mix(in srgb, ${l.brass} 80%, ${l.ink})`,`background:${l["brass-soft"]}`],`${M.size} new`));let X=f("span",["all:initial","display:inline-flex","margin-left:auto"]),Be=_(Ue(pt,{label:"Minimize",onClick:Je}),"minimize");if(Be.title="Minimize to the bar. Nothing is accepted until you choose.",X.append(Be),g.append(X),r.append(g),e==="recovered")return Et(r),r;if(e==="refused"){if(r.append(A("Your edits here are safe and not saved yet; nothing will be overwritten until you choose. Their version is not on this page, so there is no list of edits to compare. Keep yours, which saves over theirs, or accept theirs, which reloads the page and drops your unsaved edits.")),n.length&&r.append(A(`${F(n.length,"earlier replaced edit")} ${n.length===1?"is":"are"} also held in this tab. Download my copy includes them.`)),R&&r.append(A("That did not save either. Your edits here are still here.")),D&&r.append(A("Something changed on the page after your first press, so nothing was dropped. Press Accept theirs again if you still want their version.")),v){let c=f("div",["all:initial","display:block","margin:0 16px 12px","padding:8px 10px",`border-left:3px solid ${E}`,`background:color-mix(in srgb, ${E} 14%, transparent)`,`color:${l.ink}`,`font:13px/1.5 ${U}`]);c.append(f("b",["all:initial","font:inherit","font-weight:700","color:inherit"],"This drops your unsaved edits."),document.createTextNode(" Download your copy first if you might want them. Press again to confirm.")),r.append(c)}}else e==="upgraded"?r.append(A("Its layout and code changed with it, so this page stops here. Reload to see the new version.")):e==="failed"?r.append(A("Part of an update from elsewhere could not be applied, so this page may be missing some of it. Your edits here are safe. Download a copy of the page as you had it, or accept to keep the page as it is.")):r.append(A("The page is showing the other edit. This stays until you choose. You can also save a copy of the page as you had it."));let O=f("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","padding:0 16px 14px"]);if(e==="upgraded")return O.append($("Reload","reload",{variant:"primary",onClick:()=>window.location.reload(),push:!0})),r.append(O),S=[],r;let at=$(ve?"Try again":Y?"Downloaded":"Download my copy","download",{onClick:Bt});if(O.append(at),e==="refused"){let c=$(u==="overwrite"?"Saving\u2026":R?"Try again":"Keep mine","keep",{onClick:Pt});c.setDisabled(u==="overwrite"),O.append(c,$(v?"Yes, drop my edits":"Accept theirs","accept",{variant:"primary",onClick:Ft,push:!0}))}else{if(e==="replaced"){let c=z().hasPendingApply(),N=$(c?"Finishing the incoming edit\u2026":u==="revert"?"Putting back\u2026":"Revert to mine","revert",{onClick:Mt});N.setDisabled(c||u==="revert"),O.append(N)}O.append($("Accept theirs","accept",{variant:"primary",onClick:zt,push:!0}))}if(r.append(O),e==="replaced")if(P)r.append(vt(t));else{let c=f("div",["all:initial","display:flex","align-items:center","gap:8px",`border-top:1px solid ${l.line}`,"padding:8px 10px 8px 16px",`color:${l.muted}`,`font:13px/1.5 ${U}`]),N=f("span",["all:initial","display:inline-flex","margin-left:auto"]);N.append(_(W("See the edits",{small:!0,onClick:et}),"list")),c.append(f("span",["all:initial","font:inherit","color:inherit"],F(t.length,"edit")),N),r.append(c)}S=n.map(c=>c.id);for(let c of t)J.add(c.id);return r}function vt(e){let t=$e(["flex:1 1 auto","margin:0 16px 12px","min-height:0","overflow:auto",`background:${l.sunk}`,`border:1px solid ${l["line-2"]}`]),n=f("div",["all:initial","position:sticky","top:0","z-index:1","display:flex","align-items:center","gap:8px","padding:8px 12px",`background:${l.sunk}`,`border-bottom:1px solid ${l["line-2"]}`,`color:${l.muted}`,`font:600 10.5px/1 ${Z}`,"letter-spacing:.12em","text-transform:uppercase"]),o=f("span",["all:initial","display:inline-flex","margin-left:auto"]);return o.append(_(W("Hide",{small:!0,variant:"quiet",onClick:et}),"list")),n.append(f("span",["all:initial","font:inherit","color:inherit","letter-spacing:inherit","text-transform:inherit"],"Replaced edits"),o),t.append(n),e.forEach((i,a)=>t.append(St(i,a))),B=t,t}function Me(e){let t=e.context?.label||e.name||(e.context?.kind==="entry"?"Entry":"Edit");return e.context?.field?`${t} \xB7 ${e.context.field}`:t}var bt={"content-changed":"the page changed there","structure-changed":"the structure changed there","target-detached":"that part of the page is gone","duplicate-id":"another part of the page now has the same id",protected:"that region keeps its own history",unsupported:"this kind of step cannot be put back"},kt=e=>bt[e]||"the page changed there";function $t(e,t){let n=Array.isArray(e)?e:[];for(let o of n){if(!o||o.kind!=="text"&&o.kind!=="value")continue;let i=t==="redo"?o.after:o.before;if(typeof i=="string"&&i)return{text:i,id:o.target?.id??null}}for(let o of n){if(!o||o.kind!=="add"&&o.kind!=="remove")continue;let i=Array.isArray(o.nodes)?o.nodes.find(a=>typeof a?.html=="string"&&a.html):null;if(i)return{text:Ie(i.html).replace(/\s+/g," ").trim(),id:o.parent?.id??null}}for(let o of n){if(!o)continue;let i=t==="redo"?o.after:o.before;if(typeof i=="string"&&i)return{text:i,id:o.target?.id??null}}return{text:"",id:null}}function Tt(e){if(e==null||typeof document>"u")return"";let t=window.CSS?.escape?window.CSS.escape(String(e)):String(e).replace(/["\\]/g,"\\$&"),n=null;try{n=document.querySelector(`[data-id="${t}"]`)}catch{return""}if(!n)return"";let o=n.matches?.("input, textarea, select")?n.value:null;return(typeof o=="string"?o:n.textContent??"").replace(/\s+/g," ").trim()}function At(e){let t=e?.payload&&typeof e.payload=="object"?e.payload:{},n=String(e?.key??""),o={id:e?.id,revision:e?.revision,record:e,kind:e?.kind??"conflict"};if(n.startsWith("app:"))return{...o,name:typeof t.label=="string"&&t.label?t.label:n.slice(4),sentence:"",yours:typeof t.text=="string"?t.text:"",now:""};let i=t.direction==="redo"?"redo":"undo",g=((Array.isArray(t.context)?t.context:[]).find(X=>typeof X?.label=="string"&&X.label)??null)?.label||typeof t.label=="string"&&t.label||"Edit",K=$t(t.steps,i);return{...o,name:g,sentence:`The ${i} of "${g}" was not applied because ${kt(t.code)}.`,yours:K.text,now:K.id==null?"":Tt(K.id)}}function Ct(e){let t=Le();if(!e.record||typeof t?.reviewActionsFor!="function")return[];try{return(t.reviewActionsFor(e.record)||[]).filter(n=>n&&typeof n.run=="function"&&n.label)}catch{return[]}}var Ge=e=>({before:"",hit:e,after:"",cutBefore:!1,cutAfter:!1});function je(e){let t=p("div",["display:block","padding:8px 12px 10px"]),n=p("div",["display:flex","align-items:center","gap:8px","font-size:12.5px","font-weight:600",`color:${l["ink-2"]}`,"margin-bottom:4px"]);if(n.append(p("span",[],Me(e))),t.append(n),e.sentence&&t.append(p("div",["display:block","font-size:13px",`color:${l["ink-2"]}`],e.sentence)),e.yours){let i=p("div",["display:grid","grid-template-columns:44px 1fr","gap:3px 10px","align-items:start",`font:12.5px/1.5 ${Z}`,...e.sentence?["margin-top:4px"]:[]]);i.append(...he("Yours",Ge(e.yours),{mine:!0})),e.now&&i.append(...he("Now",Ge(e.now),{mine:!1})),t.append(i)}let o=f("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","margin-top:8px"]);return Ct(e).forEach((i,a)=>{let r=$(i.label,`run:${e.id}:${a}`,{onClick:()=>Nt(e,i,r)});o.append(r)}),o.append($(pe===e.id?"Copied":"Copy",`copy:${e.id}`,{onClick:()=>It(e)})),o.append($("Dismiss",`dismiss:${e.id}`,{onClick:()=>tt(e)})),t.append(o),t}function Et(e){e.append(A(k.length?"These copies were replaced before this page loaded. The page never puts them back on its own. Copy or download the ones you want; dismiss one when you no longer need it.":"These copies were kept because an undo could not be put back or the page set them aside. The page never puts them back on its own. Copy or download the ones you want; dismiss one when you no longer need it.")),oe&&e.append(A("That action did not run. The copy is still here."));let t=$e(["flex:1 1 auto","margin:0 16px 12px","min-height:0","overflow:auto",`background:${l.sunk}`,`border:1px solid ${l["line-2"]}`]);for(let o of k)for(let i of o.conflicts)t.append(je(i));for(let o of x)t.append(je(o));B=t,e.append(t);let n=f("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","padding:0 16px 14px"]);(k.some(o=>o.root)||x.length)&&n.append($(Y?"Downloaded":"Download my copy","download",{onClick:Ot})),e.append(n),S=[]}function he(e,t,{mine:n}){let o=[p("span",[`color:${l.faint}`,`font-family:${U}`],e)],i=p("span",["display:-webkit-box","-webkit-line-clamp:2","-webkit-box-orient:vertical","overflow:hidden","overflow-wrap:anywhere",...n?[`color:${l.ink}`]:[`color:${l.muted}`]]),a=(t.cutBefore?"\u2026":"")+t.before+t.hit+t.after+(t.cutAfter?"\u2026":"");i.title=a,t.before&&i.append(p("span",[`color:${l.faint}`],(t.cutBefore?"\u2026":"")+t.before));let r=p("span",n?[`background:color-mix(in srgb, ${E} 18%, transparent)`,"padding:0 4px"]:t.before||t.after?["text-decoration:underline",`text-decoration-color:color-mix(in srgb, ${E} 70%, transparent)`,"text-underline-offset:3px"]:[],t.hit||"(empty)");return i.append(r),t.after&&i.append(p("span",[`color:${l.faint}`],t.after+(t.cutAfter?"\u2026":""))),o.push(i),o}function St(e,t){let n=Oe(e),o=p("div",["display:block","padding:8px 12px 10px",...t?[`border-top:1px solid ${l.line}`]:[]]),i=p("div",["display:flex","align-items:center","gap:4px","font-size:12.5px","font-weight:600",`color:${l["ink-2"]}`,"margin-bottom:4px"]);if(i.append(p("span",[],n.name)),n.target&&n.target.isConnected&&i.append(_(Rt(n),`eye:${e.id}`)),o.append(i),n.sentence&&o.append(p("div",["display:block","font-size:13px",`color:${l["ink-2"]}`],n.sentence)),G.has(e.id)&&o.append(p("div",["display:block","font-size:13px","margin-top:4px",`color:${E}`],G.get(e.id))),n.yours){let a=p("div",["display:grid","grid-template-columns:44px 1fr","gap:3px 10px","align-items:start",`font:12.5px/1.5 ${Z}`,...n.sentence?["margin-top:4px"]:[]]);a.append(...he("Yours",n.yours,{mine:!0})),n.now&&a.append(...he("Now",n.now,{mine:!1})),o.append(a)}return o}function Rt(e){let t=["all:initial","color-scheme:inherit","box-sizing:border-box","cursor:pointer","display:inline-grid","place-items:center","width:22px","height:20px",`color:${l.ink}`],n=f("button",t);n.type="button",n.innerHTML=Ye.conflictEye,Ke(n.firstElementChild,16),n.setAttribute("aria-label",`Show ${e.name} on page`),n.title="Show on page";let o=i=>{n.style.cssText="";for(let a of[...t,...i]){let r=a.indexOf(":");n.style.setProperty(a.slice(0,r),a.slice(r+1),"important")}};return n.addEventListener("pointerenter",()=>o([`background:color-mix(in srgb, ${E} 16%, transparent)`])),n.addEventListener("pointerleave",()=>o([])),n.addEventListener("focus",()=>o([`outline:2px solid ${l.brass}`,"outline-offset:1px"])),n.addEventListener("blur",()=>o([])),n.addEventListener("click",()=>Lt(e.target)),n}var C=null,ge=null,me=null;function we(){clearTimeout(ge),window.removeEventListener("scroll",ee,!0),window.removeEventListener("resize",ee),C?.remove(),C=null,me=null}function ee(){if(!C||!me)return;let e=me.getBoundingClientRect();T(C,"left",`${e.left}px`),T(C,"top",`${e.top}px`),T(C,"width",`${e.width}px`),T(C,"height",`${e.height}px`)}function Lt(e){if(we(),!e||!e.isConnected)return;let n=!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches?"instant":"smooth",o=s?.getBoundingClientRect().top??0,i=s&&o>0?Math.max(0,window.innerHeight-o):0;if(!i)e.scrollIntoView?.({block:"center",behavior:n});else{e.scrollIntoView?.({block:"center",behavior:"instant"});let a=e.getBoundingClientRect(),r=window.innerHeight-i,g=a.height>r-24?a.top-12:a.top+a.height/2-r/2;window.scrollBy?.({top:g,behavior:n})}me=e,C=f("div",["all:initial","color-scheme:inherit","position:fixed","pointer-events:none","z-index:2147483001",`outline:2px solid ${E}`,"outline-offset:3px",`background:color-mix(in srgb, ${E} 14%, transparent)`]),document.body.appendChild(C),ee(),window.addEventListener("scroll",ee,!0),window.addEventListener("resize",ee),ge=setTimeout(we,2500)}function Dt(){I||(m="panel",L="title",w())}function Je(){we(),m="bar",y(),L="review",w()}function et(){P=!P,P&&M.clear(),w()}function zt(){let e=z(),t=S.filter(n=>{let o=e?.get(n);return o&&!o.claimedBy});e&&t.length&&e.acknowledge(t,{reason:"accepted"}),m=ze()?"bar":"hidden",L="review",d()}async function Mt(){let e=z();if(u||!e||e.hasPendingApply())return;let t=S.filter(r=>{let g=e.get(r);return g&&!g.claimedBy});if(!t.length)return;u="revert",w();let n=!0,o=r=>{n=!!s?.contains(r.target)};document.addEventListener("focus",o,!0);let i;try{let{revertConflicts:r}=await import("./c-GY4BREDT.js");i=await r(t)}catch(r){console.error("[clay] Revert to mine did not finish",r),i={revertedIds:[],blockedIds:t,saveResult:null}}finally{document.removeEventListener("focus",o,!0)}u=null;for(let r of i.blockedIds)G.set(r,z()?.get(r)?.kind==="json"?ft:ut);m=ze()?"bar":"hidden",L=n?"review":null;let a=i.saveResult&&(i.saveResult.ok||i.saveResult.msg==="Save already in progress");i.revertedIds.length&&a?be(`Put back ${F(i.revertedIds.length,"change")}. Saving.`):w()}var Q=null;async function Bt(){let e=z(),t=h?e?.list()??[]:S.map(o=>e?.get(o)).filter(Boolean),n=await Pe(t,{refused:!!h});ve=!n,Y=n,clearTimeout(Q),n&&(Q=setTimeout(()=>{Y=!1,d()},1200)),w()}async function H(){let e=null;if(Ae())try{e=await Ve()}catch{e=null}let t=Le(),n=null;if(t)try{n=await t.kept()}catch{n=null}let o=!1;if(e?.ok?(k=e.records,o=!0):!Ae()&&k.length&&(k=[],o=!0),n?.ok){let i=(Array.isArray(n.records)?n.records:[]).filter(r=>r&&r.supported!==!1).map(At);i.length===x.length&&i.every((r,g)=>r.id===x[g].id&&r.revision===x[g].revision)||(o=!0),x=i}else n&&x.length&&(x=[],o=!0);o&&d()}async function _t(e){try{return await navigator.clipboard.writeText(e),!0}catch{}let t=document.createElement("textarea");t.value=e,t.setAttribute("clay",ke),t.style.setProperty("position","fixed","important"),t.style.setProperty("opacity","0","important"),document.body?.append(t),t.select();let n=!1;try{n=document.execCommand?.("copy")===!0}catch{}return t.remove(),n}async function It(e){let t=e.record?e.yours:`${Me(e)}
2
2
 
3
3
  Yours:
4
4
  ${e.yours}
@@ -1 +1 @@
1
- import{d as i}from"./c-QQFHEODI.js";import{f as l}from"./c-EDE45NM7.js";import{a as r}from"./c-BPF2NSPV.js";var e=r,a=r,s=!1,n=0;function k(){return e}function w(){return s}function p(t){e=typeof t=="string"&&t!==""?t:null,n++,a=e}function L(){return a}function g(){a=null}function m(){p(null)}function c(t){typeof t.spec=="number"&&(s=t.extensions.includes("conditional"))}async function b(){return c(await i()),s}async function y({fresh:t=!1,clearIfMissing:d=t}={}){let f=n,u=await i({fresh:t});if(c(u),n!==f||r&&!(t&&d))return e;let o=u.document?.etag;return typeof o=="string"&&o!==""?(e=o,n++):d&&(e=null,n++),e}document.addEventListener("clay:sync-applied",t=>{t.detail?.source==="disk"&&(typeof t.detail.etag=="string"&&t.detail.etag||g())});document.addEventListener("clay:sync-applied",t=>{l&&t.detail?.source==="disk"&&(typeof t.detail.etag=="string"&&t.detail.etag||(m(),y({fresh:!0})))});export{k as a,w as b,p as c,L as d,g as e,m as f,b as g,y as h};
1
+ import{d as i}from"./c-EQ5NBOGA.js";import{f as l}from"./c-C7SUMNMI.js";import{a as r}from"./c-BPF2NSPV.js";var e=r,a=r,s=!1,n=0;function k(){return e}function w(){return s}function p(t){e=typeof t=="string"&&t!==""?t:null,n++,a=e}function L(){return a}function g(){a=null}function m(){p(null)}function c(t){typeof t.spec=="number"&&(s=t.extensions.includes("conditional"))}async function b(){return c(await i()),s}async function y({fresh:t=!1,clearIfMissing:d=t}={}){let f=n,u=await i({fresh:t});if(c(u),n!==f||r&&!(t&&d))return e;let o=u.document?.etag;return typeof o=="string"&&o!==""?(e=o,n++):d&&(e=null,n++),e}document.addEventListener("clay:sync-applied",t=>{t.detail?.source==="disk"&&(typeof t.detail.etag=="string"&&t.detail.etag||g())});document.addEventListener("clay:sync-applied",t=>{l&&t.detail?.source==="disk"&&(typeof t.detail.etag=="string"&&t.detail.etag||(m(),y({fresh:!0})))});export{k as a,w as b,p as c,L as d,g as e,m as f,b as g,y as h};
@@ -1 +1 @@
1
- import{c as M,g as _,h as A,w as q}from"./c-CV4T65JE.js";import{C as G}from"./c-ZRGEN6QQ.js";import{A as B,D as R,Q as j,R as U,d as p,ea as F,u as O,x as $,z as y}from"./c-OH2FPYSY.js";import{b as z}from"./c-RETTCOWO.js";import{a as x}from"./c-WCG6AKA7.js";import{a as K}from"./c-I2SCCUEW.js";var{TextSelection:J}=z,S=new WeakMap,D=new Set;function k(n,t){let e=null;return n.forEach(s=>{s.type===p.nodes.table&&s.attrs.id===t&&(e=s)}),e}function N(n){return n?F({[n.attrs.id]:R(n)})[0]:null}function Q(n,t,e){let s=y(n.attrs.cols);if(!s.length)return null;let i=M(n),o=s.filter(a=>a!==s[0]&&i[a]==="number");return o.length?{id:B(),pos:t,parent:e,source:n.attrs.id,kind:"bar",x:s[0],series:o,title:"",highlight:null}:null}function gt(n,t){let e=n.state.doc,s=e.nodeAt(t);if(s?.type!==p.nodes.table)return!1;let i=t+s.nodeSize,o=e.maybeChild(e.resolve(i).index(0)),a=Q(s,$(s.attrs.pos,o?.attrs.pos??null),s.attrs.parent);return a?(D.add(a.id),n.dispatch(n.state.tr.insert(i,p.nodes.chart.create(a))),!0):(x("This table has no number column to chart yet."),!0)}function W(n,t,e,s){let i=n.state.tr;if(s&&i.delete(s.from,s.to),!k(i.doc,e.attrs.id)||t>=i.doc.childCount)return!1;let o=0;for(let b=0;b<t;b++)o+=i.doc.child(b).nodeSize;let a=i.doc.child(t),c=a.isTextblock&&a.content.size===0,h=i.doc.maybeChild(t+1),f=c?a.attrs.pos:$(a.attrs.pos,h?.attrs.pos??null),d=Q(e,f,a.attrs.parent??null);if(!d)return s&&n.dispatch(n.state.tr.delete(s.from,s.to)),x("This table has no number column to chart yet."),!0;let g=p.nodes.chart.create(d);return i=c?i.replaceWith(o,o+a.nodeSize,g):i.insert(o+a.nodeSize,g),D.add(d.id),n.dispatch(i.scrollIntoView()),!0}var X=n=>y(n.attrs.cols).map(t=>n.attrs.cols[t].name||"Untitled").join(", ");function wt(n,t,e=null){let s=_(n.state.doc);if(!s.length)return e&&n.dispatch(n.state.tr.delete(e.from,e.to)),x("Add a table first: a chart plots the numbers in a table on this page."),!0;if(s.length===1)return W(n,t,s[0],e);let i=n.state.doc,o=n.nodeDOM(i.resolve(n.state.selection.head).before(1))??n.dom;return q(n,o,s.map(a=>({label:A(i,a.attrs.id)??"",description:`${a.childCount} ${a.childCount===1?"row":"rows"} \xB7 ${X(a)}`,icon:"\u25A6",run:()=>W(n,t,a,e)})))}var V=n=>`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`,Z=V('<rect x="2.5" y="3" width="11" height="10" rx="1.5"/><path d="M2.5 6.5h11M6 6.5V13"/>'),tt=V('<g transform="scale(0.6667)" stroke-width="2.25"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></g>'),et=V('<path d="M2.75 4.5h10.5M6.25 4.5V2.75h3.5V4.5M4.25 4.5l.6 8.75h6.3l.6-8.75"/>'),st=[["bar","Bar"],["line","Line"],["pie","Pie"]],it="Untitled chart";function nt(n,t){let e=null;return n.forEach((s,i)=>{e===null&&s.type===p.nodes.table&&s.attrs.id===t&&(e=i)}),e}function E(n){let t=[];return n.forEach(e=>{e.type===p.nodes.table&&y(e.attrs.cols).length>1&&t.push(e)}),t.map(e=>({id:e.attrs.id,name:A(n,e.attrs.id),rows:e.childCount}))}function ot(n){let t=y(n.attrs.cols);if(!t.length)return null;let e=M(n),s=t.find(o=>e[o]!=="number")??t[0],i=t.filter(o=>o!==s&&e[o]==="number");return{x:s,series:i.length?i:t.filter(o=>o!==s).slice(0,1)}}function l(n,t,e,s=null){let i=n.createElement(t);return e&&(i.className=e),s!==null&&(i.textContent=s),i}function C(n,t,e,s=!1){let i=l(n,"option","",e);return i.value=t,i.selected=s,i}function T(n,t,e){let s=l(n,"select","blockeditor-chart-select");return s.dataset.field=t,s.setAttribute("aria-label",e),s}var Y=class{constructor(t,e,s){this.node=t,this.view=e,this.getPos=s,this.source=void 0,this.tables=null,this.frame=null,this.unsaved=null,this.titleInput=null;let i=e.dom.ownerDocument;this.doc=i,this.dom=i.createElement("figure"),this.dom.className="blockeditor-chart",this.dom.dataset.id=t.attrs.id??"",this.dom.dataset.type="chart",this.head=l(i,"div","blockeditor-chart-head"),this.head.contentEditable="false",this.title=l(i,"span","blockeditor-chart-title"),this.chip=l(i,"button","blockeditor-chart-source"),this.chip.type="button",this.chip.contentEditable="false",this.chip.setAttribute("aria-label","Go to source table"),this.chip.innerHTML=Z,this.chipName=l(i,"span","blockeditor-chart-source-name"),this.chip.append(this.chipName),this.chip.addEventListener("click",()=>this.goToSource()),this.edit=l(i,"button","blockeditor-chart-edit"),this.edit.type="button",this.edit.contentEditable="false",this.edit.setAttribute("aria-haspopup","dialog"),this.edit.setAttribute("aria-expanded","false"),this.edit.innerHTML=tt,this.edit.append("Edit chart"),this.edit.addEventListener("click",()=>this.panel.isConnected?this.closePanel(!0):this.openPanel()),this.head.append(this.title,this.chip,this.edit),this.plot=l(i,"div","blockeditor-chart-plot"),this.broken=l(i,"div","blockeditor-chart-broken"),this.broken.hidden=!0,this.broken.contentEditable="false",this.brokenKey=null,this.brokenSelect=null,this.broken.addEventListener("click",o=>this.brokenClick(o)),this.panel=l(i,"div","blockeditor-chart-panel"),this.panel.tabIndex=-1,this.panel.contentEditable="false",this.panel.setAttribute("role","dialog"),this.panel.setAttribute("aria-label","Chart settings"),this.panel.addEventListener("click",o=>this.panelClick(o)),this.panel.addEventListener("change",o=>this.panelChange(o)),this.panel.addEventListener("mousedown",o=>{o.target.closest?.("button")&&o.preventDefault()}),this.outside=o=>{!this.panel.isConnected||this.dom.contains(o.target)||(this.commitTitle(),this.closePanel())},this.escape=o=>{!this.panel.isConnected||o.key!=="Escape"||(o.preventDefault(),o.stopPropagation(),this.closePanel(!0))},i.addEventListener("mousedown",this.outside,!0),i.addEventListener("keydown",this.escape,!0),this.dom.append(this.head,this.plot,this.broken),S.has(e)||S.set(e,new Set),S.get(e).add(this),this.refresh(),D.delete(t.attrs.id)&&this.openSoon()}refresh(){this.renderHead(),this.panel.isConnected&&this.panelKey()!==this.renderedKey&&this.redrawPanel();let t=this.view.state.doc,e=k(t,this.node.attrs.source),s=E(t).map(i=>`${i.id}:${i.name}:${i.rows}`).join("|");e===this.source&&s===this.tables||(this.source=e,this.tables=s,this.schedule())}schedule(){if(this.frame!==null)return;let t=this.dom.ownerDocument.defaultView,e=t.requestAnimationFrame?.bind(t)??(s=>t.setTimeout(s,0));this.frame=e(()=>{this.frame=null,this.draw()})}draw(){let t=this.node.attrs,e=j({id:t.id,type:t.kind,x:t.x,series:t.series,title:t.title,highlight:t.highlight},N(this.source));this.plot.innerHTML=U(e,{width:640,height:320,narrow:this.dom.getBoundingClientRect().width<480}),this.renderBroken(e)}renderBroken(t){let e=t.state==="missing"&&t.reason==="table";if(this.plot.hidden=e,this.broken.hidden=!e,!e){this.brokenKey!==null&&(this.broken.textContent="",this.brokenKey=null,this.brokenSelect=null);return}let s=E(this.view.state.doc),i=s.map(h=>`${h.id}:${h.name}:${h.rows}`).join("|");if(this.brokenKey===i)return;this.brokenKey=i,this.brokenSelect=null;let o=this.doc;this.broken.textContent="",this.broken.append(l(o,"div","blockeditor-chart-broken-head","This chart's table was deleted"),l(o,"p","blockeditor-chart-broken-text","Pick another table in this document, or delete the chart. Undo brings the table back."));let a=l(o,"div","blockeditor-chart-broken-actions");if(s.length){let h=T(o,"rescue","Source table");for(let d of s)h.append(C(o,d.id,`${d.name} (${d.rows} ${d.rows===1?"row":"rows"})`));this.brokenSelect=h;let f=l(o,"button","blockeditor-chart-use","Use this table");f.type="button",f.dataset.action="use",a.append(h,f)}let c=l(o,"button","blockeditor-chart-delete","Delete chart");c.type="button",c.dataset.action="delete",a.append(c),this.broken.append(a)}brokenClick(t){let e=t.target.closest?.("button[data-action]");e&&(e.dataset.action==="delete"?this.removeChart():e.dataset.action==="use"&&this.switchSource(this.brokenSelect?.value??""))}openSoon(){let t=this.dom.ownerDocument.defaultView;(t.requestAnimationFrame?.bind(t)??(s=>t.setTimeout(s,0)))(()=>{!this.view.isDestroyed&&this.dom.isConnected&&this.openPanel()})}renderHead(){let t=this.node.attrs,e=A(this.view.state.doc,t.source),s=!k(this.view.state.doc,t.source);this.title.textContent=t.title||it,this.title.classList.toggle("is-empty",!t.title),this.chipName.textContent=s?"No table":e??"",this.chip.disabled=s}setAttrs(t){let e=this.getPos();if(e==null)return;let s=this.view.state.doc.nodeAt(e);s?.type===p.nodes.chart&&this.view.dispatch(this.view.state.tr.setNodeMarkup(e,null,{...s.attrs,...t}))}row(t,...e){let s=l(this.doc,"div","blockeditor-chart-row");return t&&s.append(l(this.doc,"span","blockeditor-chart-label",t)),s.append(...e),s}panelKey(){let t=this.view.state.doc,e=E(t).map(s=>`${s.id}:${s.name}:${s.rows}`).join("|");return JSON.stringify([this.node.attrs,e,N(k(t,this.node.attrs.source))])}redrawPanel(){let t=this.doc.activeElement,e=t&&this.panel.contains(t)?t.dataset??{}:null,s=this.titleInput,i=s&&s.value!==this.renderedTitle?{value:s.value,start:s.selectionStart,end:s.selectionEnd}:null;if(this.renderPanel(),i&&this.titleInput&&(this.titleInput.value=i.value),!e)return;let o=[...this.panel.querySelectorAll("button, input, select")].find(a=>["field","kind","col","action"].every(c=>a.dataset[c]===e[c]));if(!o)return this.panel.focus();o.focus(),i&&o===this.titleInput&&o.setSelectionRange?.(i.start,i.end)}renderPanel(){let t=this.doc;this.renderedKey=this.panelKey(),this.renderedTitle=this.node.attrs.title??"";let e=this.node.attrs,s=N(this.source),i=s?.cols??[],o=s?.rows??[],a=e.kind==="pie";this.unsaved?.dispose(),this.unsaved=null,this.titleInput=null,this.panel.textContent="";let c=l(t,"div","blockeditor-chart-types");for(let[r,P]of st){let m=l(t,"button","blockeditor-chart-type",P);m.type="button",m.dataset.kind=r,m.setAttribute("aria-pressed",String(e.kind===r)),c.append(m)}this.panel.append(this.row("Chart type",c));let h=T(t,"source","Source table");for(let r of E(this.view.state.doc))h.append(C(t,r.id,`${r.name} (${r.rows} ${r.rows===1?"row":"rows"})`,r.id===e.source));this.panel.append(this.row("Source table",h));let f=T(t,"labels","Labels column");for(let r of i)f.append(C(t,r.id,r.name||r.id,r.id===e.x));this.panel.append(this.row("Labels column",f));let d=l(t,"div","blockeditor-chart-values");i.filter(r=>r.id!==e.x).forEach((r,P)=>{let m=l(t,"label","blockeditor-chart-value"),v=l(t,"input");v.type="checkbox",v.dataset.field="series",v.dataset.col=r.id,v.checked=e.series.includes(r.id);let I=l(t,"span","blockeditor-chart-swatch");I.style.background=`var(--chart-${P%6+1})`,I.setAttribute("aria-hidden","true"),m.append(v,I,l(t,"span","blockeditor-chart-value-name",r.name||r.id)),d.append(m)});let g=this.row(a?"Value column":"Value columns",d);a&&g.append(l(t,"span","blockeditor-chart-hint","Pie charts plot the first value column across rows.")),this.panel.append(g);let b=T(t,"highlight","Highlight row");b.append(C(t,"","None",!e.highlight));for(let r of o)b.append(C(t,r.id,O(r.cells?.[e.x])||r.id,r.id===e.highlight));this.panel.append(this.row("Highlight row",b));let u=l(t,"input","blockeditor-chart-title-input");u.type="text",u.dataset.field="title",u.setAttribute("aria-label","Chart title"),u.value=e.title??"",u.addEventListener("keydown",r=>{r.isComposing||r.keyCode===229||r.key==="Enter"&&(r.preventDefault(),r.stopPropagation(),this.commitTitle())}),u.addEventListener("change",()=>this.commitTitle()),u.addEventListener("blur",()=>this.commitTitle()),this.titleInput=u,this.panel.append(this.row("Chart title",u));let H=l(t,"div","blockeditor-chart-foot"),w=l(t,"button","blockeditor-chart-remove");w.type="button",w.dataset.action="remove",w.innerHTML=et,w.append("Remove");let L=l(t,"button","blockeditor-chart-done","Done");L.type="button",L.dataset.action="done",H.append(w,L),this.panel.append(H),this.unsaved=K({id:"chart-title",isPending:()=>u.isConnected&&u.value!==(this.node.attrs.title??"")})}openPanel(){this.panel.isConnected||(this.renderPanel(),this.dom.append(this.panel),this.edit.setAttribute("aria-expanded","true"),this.panel.focus())}closePanel(t=!1){this.panel.isConnected&&(this.unsaved?.dispose(),this.unsaved=null,this.titleInput=null,this.panel.remove(),this.edit.setAttribute("aria-expanded","false"),t&&this.edit.focus())}panelClick(t){let e=t.target.closest?.("button");e&&(e.dataset.action==="done"?(this.commitTitle(),this.closePanel(!0)):e.dataset.action==="remove"?this.removeChart():e.dataset.kind&&this.setAttrs({kind:e.dataset.kind}))}panelChange(t){let e=t.target;if(e?.dataset){if(e.dataset.field==="source")this.switchSource(e.value);else if(e.dataset.field==="labels")this.setAttrs({x:e.value,series:this.node.attrs.series.filter(s=>s!==e.value)});else if(e.dataset.field==="highlight")this.setAttrs({highlight:e.value||null});else if(e.dataset.field==="series"){let s=this.node.attrs.series.filter(i=>i!==e.dataset.col);this.setAttrs({series:e.checked?[...s,e.dataset.col]:s})}}}switchSource(t){let e=k(this.view.state.doc,t),s=e?ot(e):null;s&&this.setAttrs({source:t,x:s.x,series:s.series})}commitTitle(){let t=this.titleInput;!t||t.value===(this.node.attrs.title??"")||this.setAttrs({title:t.value})}goToSource(){let t=this.view.state.doc,e=nt(t,this.node.attrs.source),s=e===null?null:t.nodeAt(e);if(!s?.childCount||!s.child(0).childCount)return;let i=e+3;this.view.dispatch(this.view.state.tr.setSelection(J.create(t,i)).scrollIntoView()),this.view.focus?.()}removeChart(){let t=this.getPos();if(t==null)return;let e=this.view.state.doc.nodeAt(t);if(e?.type!==p.nodes.chart)return;this.closePanel();let s=this.view.state.tr.delete(t,t+e.nodeSize);s.setSelection(J.near(s.doc.resolve(Math.min(t,s.doc.content.size)),-1)),this.view.dispatch(G(s).scrollIntoView())}update(t){if(t.type!==p.nodes.chart)return!1;let e=!t.sameMarkup(this.node);return this.node=t,this.dom.dataset.id=t.attrs.id??"",e&&(this.source=k(this.view.state.doc,t.attrs.source),this.renderHead(),this.schedule()),!0}stopEvent(t){return!!t.target.closest?.(".blockeditor-chart-head, .blockeditor-chart-panel")}destroy(){if(this.unsaved?.dispose(),this.unsaved=null,this.doc.removeEventListener("mousedown",this.outside,!0),this.doc.removeEventListener("keydown",this.escape,!0),S.get(this.view)?.delete(this),this.frame!==null){let t=this.dom.ownerDocument.defaultView;t.cancelAnimationFrame?t.cancelAnimationFrame(this.frame):t.clearTimeout(this.frame)}}};function vt(n){for(let t of S.get(n)??[])t.refresh()}export{gt as a,X as b,wt as c,Y as d,vt as e};
1
+ import{c as M,g as _,h as A,w as q}from"./c-JWW6BHWD.js";import{C as G}from"./c-AI3H6ETU.js";import{A as B,D as R,Q as j,R as U,d as p,ea as F,u as O,x as $,z as y}from"./c-OH2FPYSY.js";import{b as z}from"./c-RETTCOWO.js";import{a as x}from"./c-WCG6AKA7.js";import{a as K}from"./c-I2SCCUEW.js";var{TextSelection:J}=z,S=new WeakMap,D=new Set;function k(n,t){let e=null;return n.forEach(s=>{s.type===p.nodes.table&&s.attrs.id===t&&(e=s)}),e}function N(n){return n?F({[n.attrs.id]:R(n)})[0]:null}function Q(n,t,e){let s=y(n.attrs.cols);if(!s.length)return null;let i=M(n),o=s.filter(a=>a!==s[0]&&i[a]==="number");return o.length?{id:B(),pos:t,parent:e,source:n.attrs.id,kind:"bar",x:s[0],series:o,title:"",highlight:null}:null}function gt(n,t){let e=n.state.doc,s=e.nodeAt(t);if(s?.type!==p.nodes.table)return!1;let i=t+s.nodeSize,o=e.maybeChild(e.resolve(i).index(0)),a=Q(s,$(s.attrs.pos,o?.attrs.pos??null),s.attrs.parent);return a?(D.add(a.id),n.dispatch(n.state.tr.insert(i,p.nodes.chart.create(a))),!0):(x("This table has no number column to chart yet."),!0)}function W(n,t,e,s){let i=n.state.tr;if(s&&i.delete(s.from,s.to),!k(i.doc,e.attrs.id)||t>=i.doc.childCount)return!1;let o=0;for(let b=0;b<t;b++)o+=i.doc.child(b).nodeSize;let a=i.doc.child(t),c=a.isTextblock&&a.content.size===0,h=i.doc.maybeChild(t+1),f=c?a.attrs.pos:$(a.attrs.pos,h?.attrs.pos??null),d=Q(e,f,a.attrs.parent??null);if(!d)return s&&n.dispatch(n.state.tr.delete(s.from,s.to)),x("This table has no number column to chart yet."),!0;let g=p.nodes.chart.create(d);return i=c?i.replaceWith(o,o+a.nodeSize,g):i.insert(o+a.nodeSize,g),D.add(d.id),n.dispatch(i.scrollIntoView()),!0}var X=n=>y(n.attrs.cols).map(t=>n.attrs.cols[t].name||"Untitled").join(", ");function wt(n,t,e=null){let s=_(n.state.doc);if(!s.length)return e&&n.dispatch(n.state.tr.delete(e.from,e.to)),x("Add a table first: a chart plots the numbers in a table on this page."),!0;if(s.length===1)return W(n,t,s[0],e);let i=n.state.doc,o=n.nodeDOM(i.resolve(n.state.selection.head).before(1))??n.dom;return q(n,o,s.map(a=>({label:A(i,a.attrs.id)??"",description:`${a.childCount} ${a.childCount===1?"row":"rows"} \xB7 ${X(a)}`,icon:"\u25A6",run:()=>W(n,t,a,e)})))}var V=n=>`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`,Z=V('<rect x="2.5" y="3" width="11" height="10" rx="1.5"/><path d="M2.5 6.5h11M6 6.5V13"/>'),tt=V('<g transform="scale(0.6667)" stroke-width="2.25"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></g>'),et=V('<path d="M2.75 4.5h10.5M6.25 4.5V2.75h3.5V4.5M4.25 4.5l.6 8.75h6.3l.6-8.75"/>'),st=[["bar","Bar"],["line","Line"],["pie","Pie"]],it="Untitled chart";function nt(n,t){let e=null;return n.forEach((s,i)=>{e===null&&s.type===p.nodes.table&&s.attrs.id===t&&(e=i)}),e}function E(n){let t=[];return n.forEach(e=>{e.type===p.nodes.table&&y(e.attrs.cols).length>1&&t.push(e)}),t.map(e=>({id:e.attrs.id,name:A(n,e.attrs.id),rows:e.childCount}))}function ot(n){let t=y(n.attrs.cols);if(!t.length)return null;let e=M(n),s=t.find(o=>e[o]!=="number")??t[0],i=t.filter(o=>o!==s&&e[o]==="number");return{x:s,series:i.length?i:t.filter(o=>o!==s).slice(0,1)}}function l(n,t,e,s=null){let i=n.createElement(t);return e&&(i.className=e),s!==null&&(i.textContent=s),i}function C(n,t,e,s=!1){let i=l(n,"option","",e);return i.value=t,i.selected=s,i}function T(n,t,e){let s=l(n,"select","blockeditor-chart-select");return s.dataset.field=t,s.setAttribute("aria-label",e),s}var Y=class{constructor(t,e,s){this.node=t,this.view=e,this.getPos=s,this.source=void 0,this.tables=null,this.frame=null,this.unsaved=null,this.titleInput=null;let i=e.dom.ownerDocument;this.doc=i,this.dom=i.createElement("figure"),this.dom.className="blockeditor-chart",this.dom.dataset.id=t.attrs.id??"",this.dom.dataset.type="chart",this.head=l(i,"div","blockeditor-chart-head"),this.head.contentEditable="false",this.title=l(i,"span","blockeditor-chart-title"),this.chip=l(i,"button","blockeditor-chart-source"),this.chip.type="button",this.chip.contentEditable="false",this.chip.setAttribute("aria-label","Go to source table"),this.chip.innerHTML=Z,this.chipName=l(i,"span","blockeditor-chart-source-name"),this.chip.append(this.chipName),this.chip.addEventListener("click",()=>this.goToSource()),this.edit=l(i,"button","blockeditor-chart-edit"),this.edit.type="button",this.edit.contentEditable="false",this.edit.setAttribute("aria-haspopup","dialog"),this.edit.setAttribute("aria-expanded","false"),this.edit.innerHTML=tt,this.edit.append("Edit chart"),this.edit.addEventListener("click",()=>this.panel.isConnected?this.closePanel(!0):this.openPanel()),this.head.append(this.title,this.chip,this.edit),this.plot=l(i,"div","blockeditor-chart-plot"),this.broken=l(i,"div","blockeditor-chart-broken"),this.broken.hidden=!0,this.broken.contentEditable="false",this.brokenKey=null,this.brokenSelect=null,this.broken.addEventListener("click",o=>this.brokenClick(o)),this.panel=l(i,"div","blockeditor-chart-panel"),this.panel.tabIndex=-1,this.panel.contentEditable="false",this.panel.setAttribute("role","dialog"),this.panel.setAttribute("aria-label","Chart settings"),this.panel.addEventListener("click",o=>this.panelClick(o)),this.panel.addEventListener("change",o=>this.panelChange(o)),this.panel.addEventListener("mousedown",o=>{o.target.closest?.("button")&&o.preventDefault()}),this.outside=o=>{!this.panel.isConnected||this.dom.contains(o.target)||(this.commitTitle(),this.closePanel())},this.escape=o=>{!this.panel.isConnected||o.key!=="Escape"||(o.preventDefault(),o.stopPropagation(),this.closePanel(!0))},i.addEventListener("mousedown",this.outside,!0),i.addEventListener("keydown",this.escape,!0),this.dom.append(this.head,this.plot,this.broken),S.has(e)||S.set(e,new Set),S.get(e).add(this),this.refresh(),D.delete(t.attrs.id)&&this.openSoon()}refresh(){this.renderHead(),this.panel.isConnected&&this.panelKey()!==this.renderedKey&&this.redrawPanel();let t=this.view.state.doc,e=k(t,this.node.attrs.source),s=E(t).map(i=>`${i.id}:${i.name}:${i.rows}`).join("|");e===this.source&&s===this.tables||(this.source=e,this.tables=s,this.schedule())}schedule(){if(this.frame!==null)return;let t=this.dom.ownerDocument.defaultView,e=t.requestAnimationFrame?.bind(t)??(s=>t.setTimeout(s,0));this.frame=e(()=>{this.frame=null,this.draw()})}draw(){let t=this.node.attrs,e=j({id:t.id,type:t.kind,x:t.x,series:t.series,title:t.title,highlight:t.highlight},N(this.source));this.plot.innerHTML=U(e,{width:640,height:320,narrow:this.dom.getBoundingClientRect().width<480}),this.renderBroken(e)}renderBroken(t){let e=t.state==="missing"&&t.reason==="table";if(this.plot.hidden=e,this.broken.hidden=!e,!e){this.brokenKey!==null&&(this.broken.textContent="",this.brokenKey=null,this.brokenSelect=null);return}let s=E(this.view.state.doc),i=s.map(h=>`${h.id}:${h.name}:${h.rows}`).join("|");if(this.brokenKey===i)return;this.brokenKey=i,this.brokenSelect=null;let o=this.doc;this.broken.textContent="",this.broken.append(l(o,"div","blockeditor-chart-broken-head","This chart's table was deleted"),l(o,"p","blockeditor-chart-broken-text","Pick another table in this document, or delete the chart. Undo brings the table back."));let a=l(o,"div","blockeditor-chart-broken-actions");if(s.length){let h=T(o,"rescue","Source table");for(let d of s)h.append(C(o,d.id,`${d.name} (${d.rows} ${d.rows===1?"row":"rows"})`));this.brokenSelect=h;let f=l(o,"button","blockeditor-chart-use","Use this table");f.type="button",f.dataset.action="use",a.append(h,f)}let c=l(o,"button","blockeditor-chart-delete","Delete chart");c.type="button",c.dataset.action="delete",a.append(c),this.broken.append(a)}brokenClick(t){let e=t.target.closest?.("button[data-action]");e&&(e.dataset.action==="delete"?this.removeChart():e.dataset.action==="use"&&this.switchSource(this.brokenSelect?.value??""))}openSoon(){let t=this.dom.ownerDocument.defaultView;(t.requestAnimationFrame?.bind(t)??(s=>t.setTimeout(s,0)))(()=>{!this.view.isDestroyed&&this.dom.isConnected&&this.openPanel()})}renderHead(){let t=this.node.attrs,e=A(this.view.state.doc,t.source),s=!k(this.view.state.doc,t.source);this.title.textContent=t.title||it,this.title.classList.toggle("is-empty",!t.title),this.chipName.textContent=s?"No table":e??"",this.chip.disabled=s}setAttrs(t){let e=this.getPos();if(e==null)return;let s=this.view.state.doc.nodeAt(e);s?.type===p.nodes.chart&&this.view.dispatch(this.view.state.tr.setNodeMarkup(e,null,{...s.attrs,...t}))}row(t,...e){let s=l(this.doc,"div","blockeditor-chart-row");return t&&s.append(l(this.doc,"span","blockeditor-chart-label",t)),s.append(...e),s}panelKey(){let t=this.view.state.doc,e=E(t).map(s=>`${s.id}:${s.name}:${s.rows}`).join("|");return JSON.stringify([this.node.attrs,e,N(k(t,this.node.attrs.source))])}redrawPanel(){let t=this.doc.activeElement,e=t&&this.panel.contains(t)?t.dataset??{}:null,s=this.titleInput,i=s&&s.value!==this.renderedTitle?{value:s.value,start:s.selectionStart,end:s.selectionEnd}:null;if(this.renderPanel(),i&&this.titleInput&&(this.titleInput.value=i.value),!e)return;let o=[...this.panel.querySelectorAll("button, input, select")].find(a=>["field","kind","col","action"].every(c=>a.dataset[c]===e[c]));if(!o)return this.panel.focus();o.focus(),i&&o===this.titleInput&&o.setSelectionRange?.(i.start,i.end)}renderPanel(){let t=this.doc;this.renderedKey=this.panelKey(),this.renderedTitle=this.node.attrs.title??"";let e=this.node.attrs,s=N(this.source),i=s?.cols??[],o=s?.rows??[],a=e.kind==="pie";this.unsaved?.dispose(),this.unsaved=null,this.titleInput=null,this.panel.textContent="";let c=l(t,"div","blockeditor-chart-types");for(let[r,P]of st){let m=l(t,"button","blockeditor-chart-type",P);m.type="button",m.dataset.kind=r,m.setAttribute("aria-pressed",String(e.kind===r)),c.append(m)}this.panel.append(this.row("Chart type",c));let h=T(t,"source","Source table");for(let r of E(this.view.state.doc))h.append(C(t,r.id,`${r.name} (${r.rows} ${r.rows===1?"row":"rows"})`,r.id===e.source));this.panel.append(this.row("Source table",h));let f=T(t,"labels","Labels column");for(let r of i)f.append(C(t,r.id,r.name||r.id,r.id===e.x));this.panel.append(this.row("Labels column",f));let d=l(t,"div","blockeditor-chart-values");i.filter(r=>r.id!==e.x).forEach((r,P)=>{let m=l(t,"label","blockeditor-chart-value"),v=l(t,"input");v.type="checkbox",v.dataset.field="series",v.dataset.col=r.id,v.checked=e.series.includes(r.id);let I=l(t,"span","blockeditor-chart-swatch");I.style.background=`var(--chart-${P%6+1})`,I.setAttribute("aria-hidden","true"),m.append(v,I,l(t,"span","blockeditor-chart-value-name",r.name||r.id)),d.append(m)});let g=this.row(a?"Value column":"Value columns",d);a&&g.append(l(t,"span","blockeditor-chart-hint","Pie charts plot the first value column across rows.")),this.panel.append(g);let b=T(t,"highlight","Highlight row");b.append(C(t,"","None",!e.highlight));for(let r of o)b.append(C(t,r.id,O(r.cells?.[e.x])||r.id,r.id===e.highlight));this.panel.append(this.row("Highlight row",b));let u=l(t,"input","blockeditor-chart-title-input");u.type="text",u.dataset.field="title",u.setAttribute("aria-label","Chart title"),u.value=e.title??"",u.addEventListener("keydown",r=>{r.isComposing||r.keyCode===229||r.key==="Enter"&&(r.preventDefault(),r.stopPropagation(),this.commitTitle())}),u.addEventListener("change",()=>this.commitTitle()),u.addEventListener("blur",()=>this.commitTitle()),this.titleInput=u,this.panel.append(this.row("Chart title",u));let H=l(t,"div","blockeditor-chart-foot"),w=l(t,"button","blockeditor-chart-remove");w.type="button",w.dataset.action="remove",w.innerHTML=et,w.append("Remove");let L=l(t,"button","blockeditor-chart-done","Done");L.type="button",L.dataset.action="done",H.append(w,L),this.panel.append(H),this.unsaved=K({id:"chart-title",isPending:()=>u.isConnected&&u.value!==(this.node.attrs.title??"")})}openPanel(){this.panel.isConnected||(this.renderPanel(),this.dom.append(this.panel),this.edit.setAttribute("aria-expanded","true"),this.panel.focus())}closePanel(t=!1){this.panel.isConnected&&(this.unsaved?.dispose(),this.unsaved=null,this.titleInput=null,this.panel.remove(),this.edit.setAttribute("aria-expanded","false"),t&&this.edit.focus())}panelClick(t){let e=t.target.closest?.("button");e&&(e.dataset.action==="done"?(this.commitTitle(),this.closePanel(!0)):e.dataset.action==="remove"?this.removeChart():e.dataset.kind&&this.setAttrs({kind:e.dataset.kind}))}panelChange(t){let e=t.target;if(e?.dataset){if(e.dataset.field==="source")this.switchSource(e.value);else if(e.dataset.field==="labels")this.setAttrs({x:e.value,series:this.node.attrs.series.filter(s=>s!==e.value)});else if(e.dataset.field==="highlight")this.setAttrs({highlight:e.value||null});else if(e.dataset.field==="series"){let s=this.node.attrs.series.filter(i=>i!==e.dataset.col);this.setAttrs({series:e.checked?[...s,e.dataset.col]:s})}}}switchSource(t){let e=k(this.view.state.doc,t),s=e?ot(e):null;s&&this.setAttrs({source:t,x:s.x,series:s.series})}commitTitle(){let t=this.titleInput;!t||t.value===(this.node.attrs.title??"")||this.setAttrs({title:t.value})}goToSource(){let t=this.view.state.doc,e=nt(t,this.node.attrs.source),s=e===null?null:t.nodeAt(e);if(!s?.childCount||!s.child(0).childCount)return;let i=e+3;this.view.dispatch(this.view.state.tr.setSelection(J.create(t,i)).scrollIntoView()),this.view.focus?.()}removeChart(){let t=this.getPos();if(t==null)return;let e=this.view.state.doc.nodeAt(t);if(e?.type!==p.nodes.chart)return;this.closePanel();let s=this.view.state.tr.delete(t,t+e.nodeSize);s.setSelection(J.near(s.doc.resolve(Math.min(t,s.doc.content.size)),-1)),this.view.dispatch(G(s).scrollIntoView())}update(t){if(t.type!==p.nodes.chart)return!1;let e=!t.sameMarkup(this.node);return this.node=t,this.dom.dataset.id=t.attrs.id??"",e&&(this.source=k(this.view.state.doc,t.attrs.source),this.renderHead(),this.schedule()),!0}stopEvent(t){return!!t.target.closest?.(".blockeditor-chart-head, .blockeditor-chart-panel")}destroy(){if(this.unsaved?.dispose(),this.unsaved=null,this.doc.removeEventListener("mousedown",this.outside,!0),this.doc.removeEventListener("keydown",this.escape,!0),S.get(this.view)?.delete(this),this.frame!==null){let t=this.dom.ownerDocument.defaultView;t.cancelAnimationFrame?t.cancelAnimationFrame(this.frame):t.clearTimeout(this.frame)}}};function vt(n){for(let t of S.get(n)??[])t.refresh()}export{gt as a,X as b,wt as c,Y as d,vt as e};
@@ -1 +1 @@
1
- import{a as d}from"./c-4PO3YGDC.js";import"./c-PZ4XEPUP.js";import"./c-SFKI6OLM.js";import"./c-Q3XOWZEV.js";import"./c-RHMPKZZ7.js";import{g as m,l as v,n as x,q as s}from"./c-MR75YPRT.js";import{a as p}from"./c-4JZDZFF6.js";import{e as f}from"./c-5RZNFTWD.js";import{b as w}from"./c-PKCCHJ5X.js";import{b as c}from"./c-NUHP2XDB.js";import{f as l}from"./c-EDE45NM7.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4NTUVDZ.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 $="Download a copy, then reduce its size; saving still works.",b="Download a copy to keep your work.",t=null,r=null,i=null,a=null;function h(e){return typeof e!="number"||!Number.isFinite(e)||e<0?"an unknown size":e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.max(1,Math.round(e/1024))} KB`:`${e} bytes`}function y({bytes:e,maxBytes:n,state:S}){let u=`At the last save attempt: ${h(e)} of ${h(n)}.`;return S==="over"?`This host can't save a file this size. ${u} ${b}`:`This file is getting large. ${u} ${$}`}function o(){if(!t)return;let e=window.visualViewport,n=e?Math.max(0,window.innerHeight-e.height-e.offsetTop):0;c(t,"bottom",`calc(${16+n}px + env(safe-area-inset-bottom,0px))`)}async function z(){await d({})}function A(){t=v("div",["position:fixed","left:50%","transform:translateX(-50%)","z-index:2147483000","display:flex","align-items:center","gap:10px 12px","width:max-content","max-width:calc(100vw - 24px)","flex-wrap:wrap","padding:8px 8px 8px 14px","text-align:left",`color-scheme:${p()}`]),t.setAttribute("clay","editor-ui"),t.setAttribute("data-clay-save-size",""),t.setAttribute("role","status"),r=x("span",[],""),i=m("Download my copy",{small:!0,onClick:z}),s(i,!1,"inline-flex"),t.append(r,i),document.body.appendChild(t),o(),window.visualViewport?.addEventListener("resize",o),window.visualViewport?.addEventListener("scroll",o)}function M(e){t||A(),r.textContent=y(e),s(i,e.state==="over","inline-flex"),o(),w(t,{background:f.surface})}function E(){t&&(window.visualViewport?.removeEventListener("resize",o),window.visualViewport?.removeEventListener("scroll",o),t.remove(),t=null,r=null,i=null)}function g(e){let n=e?.detail;n&&(n.state==="near"||n.state==="over"?M(n):E())}function k(){l||L()}function N(e){l&&(a||=new AbortController,document.addEventListener("clay:save-size",g,{signal:a.signal}),document.addEventListener("clay:modechange",k,{signal:a.signal}),e?.type==="clay:save-size"&&g(e))}function L(){a?.abort(),a=null,E()}export{N as start,L as stop};
1
+ import{a as d}from"./c-HGG7M2S3.js";import"./c-PZ4XEPUP.js";import"./c-SFKI6OLM.js";import"./c-Q3XOWZEV.js";import"./c-RHMPKZZ7.js";import{g as m,l as v,n as x,q as s}from"./c-MR75YPRT.js";import{a as p}from"./c-4JZDZFF6.js";import{e as f}from"./c-5RZNFTWD.js";import{b as w}from"./c-PKCCHJ5X.js";import{b as c}from"./c-NUHP2XDB.js";import{f as l}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 $="Download a copy, then reduce its size; saving still works.",b="Download a copy to keep your work.",t=null,r=null,i=null,a=null;function h(e){return typeof e!="number"||!Number.isFinite(e)||e<0?"an unknown size":e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.max(1,Math.round(e/1024))} KB`:`${e} bytes`}function y({bytes:e,maxBytes:n,state:S}){let u=`At the last save attempt: ${h(e)} of ${h(n)}.`;return S==="over"?`This host can't save a file this size. ${u} ${b}`:`This file is getting large. ${u} ${$}`}function o(){if(!t)return;let e=window.visualViewport,n=e?Math.max(0,window.innerHeight-e.height-e.offsetTop):0;c(t,"bottom",`calc(${16+n}px + env(safe-area-inset-bottom,0px))`)}async function z(){await d({})}function A(){t=v("div",["position:fixed","left:50%","transform:translateX(-50%)","z-index:2147483000","display:flex","align-items:center","gap:10px 12px","width:max-content","max-width:calc(100vw - 24px)","flex-wrap:wrap","padding:8px 8px 8px 14px","text-align:left",`color-scheme:${p()}`]),t.setAttribute("clay","editor-ui"),t.setAttribute("data-clay-save-size",""),t.setAttribute("role","status"),r=x("span",[],""),i=m("Download my copy",{small:!0,onClick:z}),s(i,!1,"inline-flex"),t.append(r,i),document.body.appendChild(t),o(),window.visualViewport?.addEventListener("resize",o),window.visualViewport?.addEventListener("scroll",o)}function M(e){t||A(),r.textContent=y(e),s(i,e.state==="over","inline-flex"),o(),w(t,{background:f.surface})}function E(){t&&(window.visualViewport?.removeEventListener("resize",o),window.visualViewport?.removeEventListener("scroll",o),t.remove(),t=null,r=null,i=null)}function g(e){let n=e?.detail;n&&(n.state==="near"||n.state==="over"?M(n):E())}function k(){l||L()}function N(e){l&&(a||=new AbortController,document.addEventListener("clay:save-size",g,{signal:a.signal}),document.addEventListener("clay:modechange",k,{signal:a.signal}),e?.type==="clay:save-size"&&g(e))}function L(){a?.abort(),a=null,E()}export{N as start,L as stop};
@@ -0,0 +1,3 @@
1
+ import{b as U}from"./c-LD6UVV5R.js";import{a as se,g as ae,h as C}from"./c-PGSBXHUE.js";import{a as oe,b as ie,c as j}from"./c-KU3PX7LL.js";import{d as A}from"./c-EQ5NBOGA.js";import{c as Z,e as Q,g as ee}from"./c-IJUK2GPW.js";import{b as k,f as D}from"./c-C7SUMNMI.js";import{c as V}from"./c-BPF2NSPV.js";import{i as q}from"./c-U4TWEIKZ.js";import{a as M,g as te,h as ne,i as re}from"./c-PNZIJFG7.js";var F=null,ue=null,T=null;function Te(e){let t=e?.document?.maxBytes;return Number.isSafeInteger(t)&&t>0?t:null}function le(e){return F=Te(e),ue=e?.document?.maxBytesMeasures==="file"?"file":null,F}var be=/<script\b[^>]*\bmerge=(["'])blockeditor\1[^>]*>[\s\S]*?<\/script\s*>/i;function B(e,t=ue){if(t!=="file"||typeof e!="string")return e;let n=be.exec(e);if(!n)return e;let o=n.index,s=o+n[0].length,r=e.lastIndexOf(`
2
+ `,o-1)+1,a=e.indexOf(`
3
+ `,s),c=a===-1?e.length:a+1;return!/\S/.test(e.slice(r,o))&&!/\S/.test(e.slice(s,c))&&(o=r,s=c),e.slice(0,o)+e.slice(s)}function H(e,t){let n=new TextEncoder().encode(e).byteLength,o=Number.isSafeInteger(t)&&t>0;return{bytes:n,maxBytes:o?t:null,state:o?n>t?"over":n>=Math.ceil(t*.8)?"near":"ok":"unknown"}}function ce(){return F}function L({fresh:e=!1}={}){return e?(T=A({fresh:!0}).then(le),T):(T||(T=A().then(le)),T)}function St({fresh:e=!1}={}){return L({fresh:e}).then(t=>({maxBytes:t}))}async function xt(e){let t=await L();return H(B(e),t)}function fe(e){let t=new CustomEvent("clay:save-size",{detail:e});document.dispatchEvent(t),(e.state==="near"||e.state==="over")&&import("./c-M7ITYKMF.js").then(n=>n.start(t),()=>{})}var P="/_/clayjs/",Oe=/[\u0000-\u001F\u007F]/,Ee=/^[\t\n\f\r ]|[\t\n\f\r ]$/,$e=/^https:\/\/clayjs\.com\/v(\d+)\/([\s\S]*)$/,Re=/^https:\/\/clayjs\.com\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,de=/^\/_\/clayjs\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,ke=/%2e|%2f|%5c/i;function Me(e){if(typeof e!="string")return null;let t=/^(\d+)\.\d+\.\d+$/.exec(e);return t?t[1]:null}function je(e){if(typeof e!="string"||e==="")return null;try{return new URL(e).origin}catch{return null}}function Le(e){let t=e.indexOf("#"),n=t<0?"":e.slice(t),o=t<0?e:e.slice(0,t),s=o.indexOf("?"),r=s<0?"":o.slice(s);return{head:s<0?o:o.slice(0,s),search:r,hash:n}}function Pe(e){if(e===""||e.includes("\\")||ke.test(e))return null;let t=e.split("/"),n=[];for(let o of t){if(o===""||o==="."||o==="..")return null;let s;try{s=decodeURIComponent(o)}catch{return null}if(s.includes("/")||s.includes("\\")||s==="."||s==="..")return null;n.push(s)}return n.join("/")}function b(e,{documentURL:t}={}){if(typeof e!="string"||e===""||Ee.test(e)||Oe.test(e))return null;let{head:n,search:o,hash:s}=Le(e),r=null,a=null,c=null,l=null,i=$e.exec(n);if(i&&(r="rolling",c=i[1],l=i[2]),r||(i=Re.exec(n),i&&(r="exact",a=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],l=i[4])),r||(i=de.exec(n),i&&(r="local",a=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],l=i[4])),!r){let f=je(t);f&&n.startsWith(`${f}/`)&&(i=de.exec(n.slice(f.length)),i&&(r="local",a=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],l=i[4]))}if(!r)return null;let u=Pe(l);return u===null?null:{kind:r,major:c,version:a,rawPath:l,path:u,search:o,hash:s}}function Ie(e,t){let n=e&&typeof e=="object"?e[t]:null;return n&&typeof n.files=="object"&&n.files?n.files:null}function _e(e){return!e||typeof e!="object"?[]:Array.isArray(e.entries)?e.entries.filter(t=>t&&typeof t=="object"):[]}function Ne(e,t,n){if(!n)return!0;let o=Ie(n,t);return!!(o&&Object.hasOwn(o,e.path))}function he(e,{descriptor:t,releases:n,documentURL:o,aliases:s}={}){let r=b(e,{documentURL:o});if(!r||r.kind!=="local")return e;let a=_e(t),c=Me(r.version);for(let l of a){if(l.local!==e||typeof l.original!="string")continue;let i=n?.[r.version]?.aliases??s;if(i&&typeof i=="object"&&!r.search&&!r.hash&&Object.hasOwn(i,l.original)&&i[l.original]===r.path)return l.original;let u=b(l.original);if(u&&!(u.kind!=="rolling"&&u.kind!=="exact")&&u.rawPath===r.rawPath&&u.search===r.search&&u.hash===r.hash&&!(u.kind==="rolling"?u.major!==c:u.version!==r.version)&&Ne(r,r.version,n))return u.kind==="exact"?l.original:`https://clayjs.com/v${u.major}/${r.rawPath}${r.search}${r.hash}`}for(let l of a){if(typeof l.original!="string")continue;let i=b(l.original);if(i&&!(i.kind!=="rolling"&&i.kind!=="exact")&&i.rawPath===r.rawPath&&!(i.kind==="rolling"?i.major!==c:i.version!==r.version))return i.kind==="rolling"?`https://clayjs.com/v${i.major}/${r.rawPath}${r.search}${r.hash}`:`https://clayjs.com/${i.version}/${r.rawPath}${r.search}${r.hash}`}return`https://clayjs.com/${r.version}/${r.rawPath}${r.search}${r.hash}`}var De=Object.freeze({"https://cdn.jsdelivr.net/npm/overtype@2.6.1/dist/overtype.min.js":"compat/overtype-2.6.1.min.js","https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js":"compat/highlight-11.9.0.min.js","https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;0,600;1,400;1,500&family=IBM+Plex+Sans:wght@400;500;600&display=swap":"fonts/ibm-plex.css"}),z="clay-runtime-map",Ue=new Set(["stylesheet","preload","modulepreload"]),pe=null,J=null;function Ce(e){let t;try{t=JSON.parse(e)}catch{return null}return!t||typeof t!="object"||t.schema!==1?null:t}function Fe(){if(typeof document>"u")return null;let e=document.getElementById(z);if(!e)return null;let t=e.textContent??"";return t===pe||(pe=t,J=Ce(t)),J}var Be=`script[src*="${P}"], link[href*="${P}"], #${z}`;function me(e){if(e.querySelector(Be))return!0;for(let t of e.querySelectorAll("template"))if(me(t.content))return!0;return!1}function He(e){let t=[],n=[e];for(;n.length;){let o=n.pop();for(let s of o.children??[])t.push(s),n.push(s),s.content&&n.push(s.content)}return t}function Je(e){return e.tagName==="SCRIPT"&&e.hasAttribute("src")?"src":e.tagName!=="LINK"||!e.hasAttribute("href")?null:(e.getAttribute("rel")??"").toLowerCase().split(/\s+/).some(n=>Ue.has(n))?"href":null}function ze(e){if(!e||!me(e))return;let t=[],n=!1;for(let r of He(e)){if(r.getAttribute("id")===z){r.remove();continue}let a=Je(r);a&&(t.push({element:r,name:a}),!n&&(r.getAttribute(a)??"").includes(P)&&(n=!0))}if(!n)return;let o=location.href,s=Fe();for(let{element:r,name:a}of t){let c=r.getAttribute(a),l=b(c,{documentURL:o});!l||l.kind!=="local"||r.setAttribute(a,he(c,{descriptor:s,documentURL:o,aliases:De}))}}re(ze);var x=!1,$=null,ge="/_/save",Ke=12e3,ve=6e4,We=1024*1024,we="text/plain;charset=UTF-8",I=null,R=!1,K=new Map;function Ht(e,t){t==null?K.delete(e):K.set(e,String(t))}var W=new Set;function Jt(e){return W.add(e),()=>W.delete(e)}async function zt(e,t){R=!!e;try{return await t()}finally{R=!1}}function Gt(){return x}function Kt(){return x?null:(x=!0,$={reserved:!0},$)}function Wt(e){!e||$!==e||($=null,x=!1)}function Xt(){return R}var _=[],N=[];function Yt(e){return _.push(e),()=>{let t=_.indexOf(e);t>=0&&_.splice(t,1)}}function Vt(e){return N.push(e),()=>{let t=N.indexOf(e);t>=0&&N.splice(t,1)}}function Xe(e){for(let t of _)try{t(e)}catch(n){console.error("clayjs: onSaveAttempt hook failed:",n)}}function Ye(e){for(let t of N)try{t(e)}catch(n){console.error("clayjs: onSaveOutcome hook failed:",n)}}function ye(e){return{ok:!0,msg:e.msg??"Saved",msgType:e.msgType||"success",code:e.code??null,etag:e.etag??null,...e.siteData?{siteData:e.siteData}:{}}}var O=[],Ve=8,y=null;function qt(){return y!==null}function Se(){let e=window.crypto?.randomUUID?.();if(e)return e;if(window.crypto?.getRandomValues){let n=new Uint8Array(16);return window.crypto.getRandomValues(n),Array.from(n,o=>o.toString(16).padStart(2,"0")).join("")}let t=()=>Math.random().toString(36).slice(2,12).padEnd(10,"0");return`${Date.now().toString(36)}-${t()}${t()}${t()}`}function qe(e){O.push(e),O.length>Ve&&O.shift()}function Ze(e){return typeof e=="string"&&e!==""&&O.includes(e)}function Zt(){O.length=0,y=null}function X(e){let t=e.name==="AbortError",n=!t&&e.status===412,o=!t&&!n&&e.code==="save-already-applied";return{ok:!1,msg:t?"Server not responding":e.message||"Save failed",msgType:t||o?"unknown":n?"conflict":"error",code:t?"timeout":n?"conflict":e.code??null,changedBy:n?e.changedBy??null:null,afterTimeout:n&&y!==null,conflictEtag:n?e.etag??null:null,status:Number.isInteger(e.status)?e.status:null,hadTimeout:t||e.hadTimeout===!0,reason:e.reason??null,retryAfter:e.retryAfter??null,saveOutcome:e.saveOutcome??null,etag:null}}function E(e){return{ok:!1,msg:e,msgType:"skipped",code:null,etag:null}}function Qe(e){let t=new Error(`This document is ${e.bytes} bytes; this host saves at most ${e.maxBytes}`);return t.code="save-too-large",{...X(t),sent:!1,size:e}}var w=null;function et(e){return w?null:(w={kind:e},w)}function tt(e){w===e&&(w=null)}function nt(){return w?w.kind:null}function rt(){return{ok:!1,msg:"Invalid page conversion metadata",msgType:"error",code:"invalid-header",etag:null}}var ot=3,it=/^(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT|(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), \d{2}-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{2} \d{2}:\d{2}:\d{2} GMT|(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?: \d|\d{2}) \d{2}:\d{2}:\d{2} \d{4})$/;function st(e){if(e==null)return null;let t=String(e).trim();if(!t)return null;if(/^-?\d+$/.test(t))return Math.max(0,Math.min(3600,Number(t)));if(!it.test(t))return null;let n=Date.parse(t);return Number.isNaN(n)?null:Math.max(0,Math.min(3600,Math.round((n-Date.now())/1e3)))}var at=/^[0-9a-f]{64}$/,lt=/^[A-Za-z0-9-]{1,64}$/;function ut(e){if(e==null)return{header:null};if(typeof e!="object")return{invalid:!0};let{source:t,base:n,epoch:o}=e;return typeof n!="string"||!at.test(n)?{invalid:!0}:t==="file"?o!=null?{invalid:!0}:{header:`v1; source=file; base=${n}`}:t==="room"?typeof o!="string"||!lt.test(o)?{invalid:!0}:{header:`v1; source=room; base=${n}; epoch=${o}`}:{invalid:!0}}function ct(e,t,n,o,s,r=!1,a=null,c=!0){let l=V(),i=l?`${ge}/${l}`:ge,u={method:"POST",credentials:l?"omit":"same-origin",signal:n,headers:{"Document-URL":window.location.href,"Page-URL":window.location.href,"Save-Trigger":t?"user":"auto","Save-ID":o,[se]:String(1)},body:ft(e)};for(let[f,h]of K)u.headers[f]=h;if(c)for(let f of W){let h=null;try{h=f(e)}catch(p){console.error("clayjs: a save header source failed:",p)}if(h)for(let[p,S]of Object.entries(h))u.headers[p]=String(S)}return typeof u.body!="string"&&(u.headers["Content-Type"]=we),a&&(u.headers["Blockeditor-Conversion"]=a),s&&(u.headers["If-Match"]=s),r&&e.length<ve&&new Blob([e]).size<ve&&(u.keepalive=!0),{url:dt(i),options:u}}function ft(e){if(e.length<We)return e;if(I&&I.content===e)return I.blob;let t=new Blob([e],{type:we});return I={content:e,blob:t},t}function xe(){let e=oe();return ie()&&e?e:null}function dt(e){let t=window.location.origin;return!t||t==="null"?e:new URL(e,t).href}function G(e,t){let n=JSON.stringify(t);return{ok:e>=200&&e<300,status:e,statusText:e===200?"OK":"Insufficient Storage",text:()=>Promise.resolve(n)}}function ht(e,t){let n=q();return n?Promise.resolve().then(()=>n(e,t)).then(()=>G(200,{msg:"Saved in this browser",msgType:"success"}),o=>G(507,{msg:"Couldn't save in this browser. Storage is full or turned off.",msgType:"error",code:o?.code||"draft-storage"})):Promise.resolve(G(503,{msg:"Saving in this browser is not ready yet",msgType:"error",code:"draft-not-ready"}))}function pt(e,t,n,{captureId:o=null,conversionHeader:s=null,attempts:r=[],gateToken:a=null}={}){let c=new AbortController,l=setTimeout(()=>c.abort(),Ke),i=Q(),u=ee(),f=i||u,h=R;R=!1;let{url:p,options:S}=ct(e,f,c.signal,t,n,h,s);return qe(t),k||(r.some(d=>d.saveId===t&&d.etag===(n??null))||r.push({saveId:t,etag:n??null}),Xe({captureId:o,saveId:t,html:e,etag:n??null})),(k?ht(e,a):fetch(p,S)).then(d=>d.text().then(g=>{let m={};if(g)try{m=JSON.parse(g)}catch{if(d.ok)throw new Error("Server sent a response that was not JSON")}if(!d.ok){let v=new Error(m.msg||m.error||`HTTP ${d.status}: ${d.statusText}`);throw v.code=d.status===413?"save-too-large":m.code??null,v.status=d.status,v.changedBy=m.changedBy??null,v.etag=m.etag??null,v.saveId=m.saveId??null,v.reason=typeof m.reason=="string"?m.reason:null,v.saveOutcome=m.saveOutcome??null,v.retryAfter=st(d.headers?.get?.("Retry-After")),v}return j(m.etag??null),y=null,m})).catch(d=>{throw console.error("Failed to save page:",d),d.name==="AbortError"&&(y={saveId:t,etag:n}),f&&Z(),d}).finally(()=>{clearTimeout(l)})}async function mt(){let e=y;if(!e)return{landed:null,resend:!1};let n=(await A({fresh:!0})).document,o=typeof n?.etag=="string"&&n.etag?n.etag:null;return o?n.saveId&&n.saveId===e.saveId?(j(o),y=null,{landed:{msg:"Saved",msgType:"success",etag:o},resend:!1}):(n.saveId&&(y=null),{landed:null,resend:!!e.etag,etag:e.etag}):{landed:null,resend:!1}}async function gt(e,{captureId:t=null,conversionHeader:n=null,attempts:o=[],gateToken:s=null}={}){let r=Se(),a=xe(),c=!1,l=!1,i=0,u=t??M();for(;;)try{return await pt(e,r,a,{captureId:t,conversionHeader:n,attempts:o,gateToken:s})}catch(f){if(c&&(f.hadTimeout=!0),f.name==="AbortError"){if(c)throw f;let{landed:h,resend:p,etag:S}=await mt();if(h)return h;if(!p)throw f;a=S,c=!0;continue}if(f.status===412&&!l&&Ze(f.saveId)){j(f.etag??null),y=null,r=Se(),a=xe(),l=!0;continue}if(f.code==="blockeditor-converting"&&i<ot){if(M()!==u||(i+=1,await new Promise(h=>setTimeout(h,Math.max(0,f.retryAfter??1)*1e3)),M()!==u))throw f;continue}throw f}}function Y(e,t,n,o,s=null,r=0,a=null,c=null){return e=ae(e,Math.max(C(),r)),new Promise(l=>{let i=[],u=te(s),f=()=>a!==null&&$===a,h=()=>{f()||(x=!1)},p=(g,m=!1)=>{m&&U(e,t??null,u),ne(s),Ye({captureId:t??null,result:g,attempts:i,sent:i.length>0}),typeof n=="function"&&n(g),l(g)};if(!D&&!window.clay?.testMode)return p(E("Not in edit mode"));if(x&&!f())return p(E("Save already in progress"));let S=ut(o);if(S.invalid)return p(rt());if(x=!0,window.clay?.testMode){setTimeout(()=>{h(),p(ye({msg:"Test mode: save skipped"}))},0);return}L();let d=H(B(e),ce());if(fe(d),d.state==="over")return h(),p(Qe(d));gt(e,{captureId:t,conversionHeader:S.header,attempts:i,gateToken:c}).then(ye,X).then(g=>{h(),g.code==="save-too-large"&&!g.size&&(g.size=d),g.ok&&U(e,t??null,u,g.siteData??null),p(g)})})}function vt(e,t=()=>{}){return Y(e,null,t,null)}function Qt(e,t,n=()=>{},{conversion:o,capture:s=null,blockeditorFormatFloor:r,lane:a=null,gateToken:c=null}={}){return Y(e,t,n,o,s,r,a,c)}function en({html:e,captureId:t,conversion:n}){return Y(e,t??null,void 0,n)}function tn(e,t=()=>{}){return new Promise(n=>{let o=null,s=r=>{tt(o),typeof t=="function"&&t(r),n(r)};if(!D)return s(E("Not in edit mode"));if(nt())return s(E("Another document operation is in progress"));if(x)return s(E("Save already in progress"));if(k)return s(!1);o=et("replace"),fetch(new URL(e,window.location.href).href).then(r=>{if(!r.ok)throw new Error(`Template fetch failed: HTTP ${r.status} ${r.statusText}`);return r.text()}).then(r=>vt(r)).then(s).catch(r=>{console.error("Failed to fetch template:",r),s(X(r))})})}var Ae=null;function nn(e){Ae=e}function rn(){return Ae}export{L as a,St as b,xt as c,Ht as d,Jt as e,zt as f,Gt as g,Kt as h,Wt as i,Xt as j,Yt as k,Vt as l,qt as m,Se as n,Zt as o,et as p,tt as q,nt as r,ct as s,vt as t,Qt as u,en as v,tn as w,nn as x,rn as y};
@@ -0,0 +1 @@
1
+ import{a as q}from"./c-2YYDMLNZ.js";var f="sap-error",g=[],F=/^(show-when|hide-when|option|option-not):/,O=new Set(["id","data-id","class","style","sap","scope","items","item","bind","state","template","cms-template","sap-ignore"]),C=new Set(["value","checked","selected"]);function D(t){return t.hasAttribute("bind")||t.hasAttribute("persist")||!!t.closest("select[bind]")}function k(t){return t.localName==="template"||t.hasAttribute("template")||t.hasAttribute("cms-template")||t.hasAttribute("sap-ignore")}var M=["sap","item","scope","items","detail","each"],h=[],d={rules:h,within:"",seen:h,counted:0};function v(){let t=typeof window<"u"&&Array.isArray(window.sapPlugins)?window.sapPlugins:h,n=t.length+g.length;if(t===d.seen&&n===d.counted)return d;let e=g.slice();for(let s of t)if(!(!s||!Array.isArray(s.ownership)||g.some(r=>r.plugin===s.name)))for(let r of s.ownership)B(r)&&e.push({...r,plugin:s.name});return d={rules:e,within:[...new Set(e.map(s=>s.within))].join(","),seen:t,counted:n},d}function B(t){if(!t||typeof t.within!="string"||typeof t.select!="string"||t.attrs&&!Array.isArray(t.attrs))return!1;try{let n=document.createDocumentFragment();return n.querySelector(t.within),n.querySelector(t.select),!0}catch{return!1}}function P(t){return!M.some(n=>t.hasAttribute(n))}function y(t,n,e=null){for(let s=t;s;s=s.parentElement){let r=s.closest(n);if(!r)break;if(P(r)&&l(r,e))return r;s=r}return e&&!t.isConnected?y(e,n):null}function E(t,n,e=null){let s=t.parentElement||(t.isConnected?null:e);return s?y(s,n,e):null}function N(t,n,e,s=null){return(!e||e(t.plugin))&&n.matches(t.select)&&!!y(n,t.within,s)}function l(t,n=null){let e=null;for(let s=t;s&&s.nodeType===1;s=s.parentElement){if(k(s))return null;if(s.hasAttribute("sap"))return s;e=s}return n&&e&&!e.isConnected?l(n):null}function _(t,n){let e=t.getAttribute("state");if(!e)return!1;for(let s of e.trim().split(/\s+/))if(s.split("=")[0].split(":")[0]===n)return!0;return!1}function W(t){if(t.hasAttribute("show"))return!0;for(let n of t.attributes)if(F.test(n.name))return!0;return!1}function j(t,n,e=null,s=null){if(!t||t.nodeType!==1||!n)return!1;let{rules:r,within:i}=v();if(r.length&&y(t,i,e)){for(let o of r)if(o.attrs&&o.attrs.includes(n)&&N(o,t,s,e))return!0;if(E(t,i,e))return n===f}return n===f?!!l(t,e):O.has(n)||C.has(n)&&D(t)?!1:n==="hidden"?W(t)&&!!l(t,e):t.hasAttribute("attr:"+n)&&!_(t,n)&&!!l(t,e)}var m=()=>({attrs:[],classes:[],vars:[],text:!1});function A(t,n=null){if(!t||t.nodeType!==1)return null;let{rules:e,within:s}=v();if(!e.length||!y(t,s))return l(t)?x(t,null):null;let r=null;for(let i of e)N(i,t,n)&&(r=L(r,i));return E(t,s)?(t.hasAttribute(f)&&(r||(r=m())).attrs.push(f),r):x(t,r)}function x(t,n){let e=(s,r)=>(n||(n=m()))[s].push(r);for(let s of t.attributes){let r=s.name;if(r==="text"||r.startsWith("text:"))t.hasAttribute("bind")||((n||(n=m())).text=!0);else if(r.startsWith("attr:")){let i=r.slice(5);i&&!O.has(i)&&!(C.has(i)&&D(t))&&!_(t,i)&&e("attrs",i)}else r.startsWith("class:")?e("classes",r.slice(6)):r.startsWith("css:")&&e("vars","--"+r.slice(4))}return W(t)&&e("attrs","hidden"),t.hasAttribute(f)&&e("attrs",f),n}function L(t,n){t=t||m(),n.text&&(t.text=!0);for(let e of n.attrs||h)t.attrs.includes(e)||t.attrs.push(e);return t}function T(t,n,e=null){if(!t||t.nodeType!==1&&t.nodeType!==9)return;let s=t.nodeType===1&&t.hasAttribute("sap")?[t]:[...t.querySelectorAll("[sap]")].filter(i=>!i.parentElement||!i.parentElement.closest("[sap]")),r=v();for(let i of s){if(r.rules.length&&!E(i,r.within)){S(i,r,e,n);continue}for(let o of[i,...i.querySelectorAll("*")]){let c=A(o,e);c&&n(o,c)}}}function S(t,n,e,s){if(k(t)){let o=null;for(let c of t.querySelectorAll("[sap]"))o&&o.contains(c)||(S(c,n,e,s),o=c);return}let r=t.matches(n.within)&&P(t),i=r?A(t,e):x(t,null);if(i&&s(t,i),r)H(t,n.rules,e,s);else for(let o=t.firstElementChild;o;o=o.nextElementSibling)S(o,n,e,s)}function H(t,n,e,s){let r=new Map,i=(u,a)=>r.set(u,L(r.get(u),a)),o=["["+f+"]"],c=h;for(let u of n)if(!(e&&!e(u.plugin))){if(o.push(u.select),t.matches(u.within)){let a=t.querySelectorAll(u.select);for(let w of a)i(w,u);a.length>c.length&&(c=a);continue}for(let a of t.querySelectorAll(u.within))if(!(!P(a)||!l(a))){a.matches(u.select)&&i(a,u);for(let w of a.querySelectorAll(u.select))i(w,u)}}let p=t.querySelectorAll("["+f+"]");for(let u of p){let a=r.get(u)||m();a.attrs.push(f),r.set(u,a)}c.length<r.size&&(c=t.querySelectorAll(o.join(",")));for(let u of c){let a=r.get(u);a&&s(u,a)}}function R(t,n=null){T(t,(e,s)=>{for(let r of s.attrs)e.hasAttribute(r)&&e.removeAttribute(r);for(let r of s.classes)e.classList.contains(r)&&e.classList.remove(r);s.classes.length&&!e.getAttribute("class")&&e.hasAttribute("class")&&e.removeAttribute("class");for(let r of s.vars)e.style.getPropertyValue(r)!==""&&e.style.removeProperty(r);s.vars.length&&e.hasAttribute("style")&&!e.getAttribute("style").trim()&&e.removeAttribute("style"),s.text&&e.firstChild&&e.replaceChildren()},n)}var z=(t,n,e=null)=>j(t,n,e),U=t=>!!t&&t.nodeType===1&&!!A(t)?.text,Z=t=>R(t);function G(t){let n=[];return T(t,(e,s)=>{n.push(e.localName);for(let r of s.attrs)r!=="sap-error"&&n.push(r+"="+(e.getAttribute(r)??"\0"));for(let r of s.classes)n.push("."+r+"="+e.classList.contains(r));for(let r of s.vars)n.push(r+"="+e.style.getPropertyValue(r));s.text&&n.push("#"+e.textContent)}),n.join("")}function $(t){return G(new DOMParser().parseFromString(t,"text/html"))}function V(t,n,e,s,r){return e(t||"").map(i=>i.trim()).filter(i=>i&&!n.includes(r(i))).sort().join(s)}function I(t,n,e,s){let r=A(t);if(!r)return!1;if(n==="class"){if(!r.classes.length)return!1;let o=c=>V(c,r.classes,p=>p.split(/\s+/)," ",p=>p);return o(e)===o(s)}if(!r.vars.length)return!1;let i=o=>V(o,r.vars,c=>c.split(";"),";",c=>c.split(":")[0].trim());return i(e)===i(s)}function tt(t){if(t.__derived!==void 0)return t.__derived;let n=t.element,e=!1;if(n&&n.nodeType===1)if(t.type==="attribute"){let s=t.attribute;e=z(n,s)||(s==="class"||s==="style")&&I(n,s,t.oldValue,t.newValue)}else t.type==="characterData"&&(e=U(n));return t.__derived=e,e}var b=new Set,J=!1;function et(){return b.size>0||q.holdSettle}var K=[];function nt(){for(let t of[...b])try{t()}catch(n){console.error("clayjs: a derived repaint failed:",n)}}var rt={register(t){return b.add(t),()=>b.delete(t)},mounted(){J=!0;for(let t of K.splice(0))t()}};export{z as a,U as b,Z as c,G as d,$ as e,tt as f,et as g,nt as h,rt as i};
@@ -1,4 +1,4 @@
1
- import{a as j,c as re}from"./c-6DNRCPNM.js";import{a as Re}from"./c-Q3XOWZEV.js";import{a as Le}from"./c-4ASQPRQL.js";import{j as Me}from"./c-MFOSMAVM.js";import{a as Ce}from"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import{a as Ae}from"./c-6IJEVE6B.js";import"./c-QQFHEODI.js";import"./c-IJUK2GPW.js";import"./c-EDE45NM7.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4NTUVDZ.js";import{b as Y,c as Oe,d as Ie,l as ce,u as fe}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";var Et=16384;function Ot(e){let t=new Map,n=e?.onParseError;return{parser:new Re({...e,onParseError:s=>{t.set(s.code,(t.get(s.code)||0)+1),n?.(s)}}),errors:t}}function It(e,t,n,r){let s=Math.min(n+r,t.length);return e.tokenizer.write(t.slice(n,s),s>=t.length),s}function*de(e,t,{chunk:n=Et}={}){let{parser:r,errors:s}=Ot(t),o=0;do o=It(r,e,o,n),o<e.length&&(yield);while(o<e.length);return{document:r.document,errors:s}}var ge=new Set(["script","style","xmp","iframe","noembed","noframes","plaintext","noscript"]),Je=new Set(["textarea","title"]),be=e=>ge.has(e)?"raw":Je.has(e)?"rcdata":"normal",pe=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),$e="http://www.w3.org/1999/xhtml",K=1500,Ct=e=>e.replace(/&/g,"&amp;").replace(/ /g,"&nbsp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),Fe=e=>e.replace(/&/g,"&amp;").replace(/ /g,"&nbsp;").replace(/"/g,"&quot;");function Qe(e){return j(ie(e))}function*ie(e){let{document:t,errors:n}=yield*de(e,{sourceCodeLocationInfo:!0});return We(e,t,n)}function We(e,t,n){let r=t.childNodes.find(l=>l.nodeName==="html"),s=t.childNodes.filter(l=>l!==r).map(l=>l.nodeName==="#documentType"?{kind:"doctype",name:l.name||"",publicId:l.publicId||"",systemId:l.systemId||""}:{kind:l.nodeName==="#comment"?"comment":l.nodeName,value:l.data}),o=r?ze(r,null,e):null;return o&&Ve(o,e),{src:e,doc:t,outside:s,root:o,parseErrors:n,relocated:o?me(o):null,movedIn:o?me(o,"movedIn"):null,tailOwner:o?He(o):null}}function ze(e,t,n){let r=e.sourceCodeLocation||null,s=e.nodeName==="#text"?"text":e.nodeName==="#comment"?"comment":"element",o={node:e,parent:t,live:null,kind:s,children:[],from:r?r.startOffset:-1,to:r?r.endOffset:-1};if(s==="text")return o.value=e.value,o;if(s==="comment")return o.value=e.data,o;o.tag=e.tagName,o.located=!!(r&&r.startTag),o.openFrom=o.located?r.startTag.startOffset:-1,o.openTo=o.located?r.startTag.endOffset:-1,o.closeFrom=r&&r.endTag?r.endTag.startOffset:o.located?o.to:-1,o.closeTo=r&&r.endTag?r.endTag.endOffset:o.located?o.to:-1,o.endTagged=!!(r&&r.endTag),o.located&&(o.to<o.openTo&&(o.to=o.openTo),o.closeFrom<o.openTo&&(o.closeFrom=o.closeTo=o.openTo)),o.attrs=[];let l=o.located&&r.startTag.attrs||r&&r.attrs||{};for(let a of e.attrs){let g=a.prefix?a.prefix+":"+a.name:a.name,c=l[g.toLowerCase()];o.attrs.push({name:g,key:g.toLowerCase(),value:a.value,from:c?c.startOffset:-1,to:c?c.endOffset:-1})}let d=e.nodeName==="template"&&e.content?e.content.childNodes:e.childNodes;for(let a of d)a.nodeName!=="#documentType"&&o.children.push(ze(a,o,n));if(!o.located){let a=o.children.filter(p=>p.from>=0),g=a.length?Math.min(...a.map(p=>p.from)):-1,c=a.length?Math.max(...a.map(p=>p.to)):-1;o.openFrom=o.openTo=g,o.closeFrom=o.closeTo=c,o.from=g,o.to=c}return o}function Ve(e,t,n=1/0){if(e.kind!=="element")return;for(let o of e.children){if(o.from>=n&&!(o.kind==="text"&&!/\S/.test(o.value))&&(e.movedIn=!0),o.from>=0&&e.located){let l=Math.max(e.openTo,Math.min(o.to,e.closeFrom)),d=Math.min(Math.max(o.from,e.openTo),l);if(d!==o.from||l!==o.to){if(o.kind==="text"&&!ge.has(e.tag)&&!Je.has(e.tag)){let a=t.slice(l,o.to).replace(/<!--[\s\S]*?-->|<[^>]*>/g,"").replace(/\r\n?/g,`
1
+ import{a as j,c as re}from"./c-6DNRCPNM.js";import{a as Re}from"./c-Q3XOWZEV.js";import{a as Le}from"./c-4ASQPRQL.js";import{j as Me}from"./c-MFB74XVN.js";import{a as Ce}from"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import{a as Ae}from"./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{b as Y,c as Oe,d as Ie,l as ce,u as fe}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";var Et=16384;function Ot(e){let t=new Map,n=e?.onParseError;return{parser:new Re({...e,onParseError:s=>{t.set(s.code,(t.get(s.code)||0)+1),n?.(s)}}),errors:t}}function It(e,t,n,r){let s=Math.min(n+r,t.length);return e.tokenizer.write(t.slice(n,s),s>=t.length),s}function*de(e,t,{chunk:n=Et}={}){let{parser:r,errors:s}=Ot(t),o=0;do o=It(r,e,o,n),o<e.length&&(yield);while(o<e.length);return{document:r.document,errors:s}}var ge=new Set(["script","style","xmp","iframe","noembed","noframes","plaintext","noscript"]),Je=new Set(["textarea","title"]),be=e=>ge.has(e)?"raw":Je.has(e)?"rcdata":"normal",pe=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),$e="http://www.w3.org/1999/xhtml",K=1500,Ct=e=>e.replace(/&/g,"&amp;").replace(/ /g,"&nbsp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),Fe=e=>e.replace(/&/g,"&amp;").replace(/ /g,"&nbsp;").replace(/"/g,"&quot;");function Qe(e){return j(ie(e))}function*ie(e){let{document:t,errors:n}=yield*de(e,{sourceCodeLocationInfo:!0});return We(e,t,n)}function We(e,t,n){let r=t.childNodes.find(l=>l.nodeName==="html"),s=t.childNodes.filter(l=>l!==r).map(l=>l.nodeName==="#documentType"?{kind:"doctype",name:l.name||"",publicId:l.publicId||"",systemId:l.systemId||""}:{kind:l.nodeName==="#comment"?"comment":l.nodeName,value:l.data}),o=r?ze(r,null,e):null;return o&&Ve(o,e),{src:e,doc:t,outside:s,root:o,parseErrors:n,relocated:o?me(o):null,movedIn:o?me(o,"movedIn"):null,tailOwner:o?He(o):null}}function ze(e,t,n){let r=e.sourceCodeLocation||null,s=e.nodeName==="#text"?"text":e.nodeName==="#comment"?"comment":"element",o={node:e,parent:t,live:null,kind:s,children:[],from:r?r.startOffset:-1,to:r?r.endOffset:-1};if(s==="text")return o.value=e.value,o;if(s==="comment")return o.value=e.data,o;o.tag=e.tagName,o.located=!!(r&&r.startTag),o.openFrom=o.located?r.startTag.startOffset:-1,o.openTo=o.located?r.startTag.endOffset:-1,o.closeFrom=r&&r.endTag?r.endTag.startOffset:o.located?o.to:-1,o.closeTo=r&&r.endTag?r.endTag.endOffset:o.located?o.to:-1,o.endTagged=!!(r&&r.endTag),o.located&&(o.to<o.openTo&&(o.to=o.openTo),o.closeFrom<o.openTo&&(o.closeFrom=o.closeTo=o.openTo)),o.attrs=[];let l=o.located&&r.startTag.attrs||r&&r.attrs||{};for(let a of e.attrs){let g=a.prefix?a.prefix+":"+a.name:a.name,c=l[g.toLowerCase()];o.attrs.push({name:g,key:g.toLowerCase(),value:a.value,from:c?c.startOffset:-1,to:c?c.endOffset:-1})}let d=e.nodeName==="template"&&e.content?e.content.childNodes:e.childNodes;for(let a of d)a.nodeName!=="#documentType"&&o.children.push(ze(a,o,n));if(!o.located){let a=o.children.filter(p=>p.from>=0),g=a.length?Math.min(...a.map(p=>p.from)):-1,c=a.length?Math.max(...a.map(p=>p.to)):-1;o.openFrom=o.openTo=g,o.closeFrom=o.closeTo=c,o.from=g,o.to=c}return o}function Ve(e,t,n=1/0){if(e.kind!=="element")return;for(let o of e.children){if(o.from>=n&&!(o.kind==="text"&&!/\S/.test(o.value))&&(e.movedIn=!0),o.from>=0&&e.located){let l=Math.max(e.openTo,Math.min(o.to,e.closeFrom)),d=Math.min(Math.max(o.from,e.openTo),l);if(d!==o.from||l!==o.to){if(o.kind==="text"&&!ge.has(e.tag)&&!Je.has(e.tag)){let a=t.slice(l,o.to).replace(/<!--[\s\S]*?-->|<[^>]*>/g,"").replace(/\r\n?/g,`
2
2
  `);a&&!/\S/.test(a)&&o.value.endsWith(a)&&(o.outsideTail=a)}o.clamped=!0,o.from=d,o.to=l}}o.kind==="element"&&o.located&&!o.endTagged&&o.closeFrom>o.to&&(o.closeFrom=o.closeTo=o.to)}let r=e.located?e.openTo:-1;for(let o of e.children)if(!(o.from<0)){if(o.from<r){e.outOfOrder=!0;break}r=o.to}let s=e.located&&e.endTagged?Math.min(n,e.closeTo):n;for(let o of e.children)Ve(o,t,s)}function me(e,t="outOfOrder"){if(e[t])return e.tag;for(let n of e.children){if(n.kind!=="element")continue;let r=me(n,t);if(r)return r}return null}function He(e){if(e.outsideTail)return e;for(let t of e.children||[]){let n=He(t);if(n)return n}return null}function Z(e,t){if(!e.root)return"source has no <html> element";if(e.root.openFrom<0)return"source has no content inside <html>";if(e.relocated)return"the parser moved content out of <"+e.relocated+">, so source order and tree order disagree";if(e.movedIn)return"the parser moved content written after the end of <"+e.movedIn+"> back inside it, so source order and tree order disagree";let n=Rt(t),r=e.outside.map(At);if(n.length!==r.length)return"outside <html>: "+JSON.stringify(r)+" vs live "+JSON.stringify(n);for(let s=0;s<n.length;s++)if(n[s]!==r[s])return"outside <html>: "+r[s]+" vs live "+n[s];return null}function At(e){return e.kind==="doctype"?"doctype:"+e.name+"|"+e.publicId+"|"+e.systemId:e.kind+":"+e.value}function Rt(e){let t=[];for(let n of e.childNodes)n.nodeType===10?t.push("doctype:"+n.name+"|"+n.publicId+"|"+n.systemId):n.nodeType===8?t.push("comment:"+n.data):n.nodeType!==1&&t.push("#"+n.nodeType+":"+(n.data||""));return t}var ae="\0",Ge={align:0,hashKey:0};function Pe(e,t){for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function J(e){Ge.hashKey++;let t=2166136261,n=5381;for(let r of e)t=Pe(t,r),n=(Math.imul(n,33)^Pe(t^2654435769,r))>>>0;return t.toString(36)+"."+n.toString(36)}function q(e){let t=e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content.childNodes:e.childNodes,n=[];for(let r of t)(r.nodeType===1||r.nodeType===3||r.nodeType===8)&&n.push(r);return n}var ye=e=>Array.from(e.attributes,t=>t.name.toLowerCase()+"="+t.value).sort().join(ae),Xe=e=>e.attrs.map(t=>t.key+"="+t.value).sort().join(ae);function Ye(e,t){let n;if(e.nodeType===3)n={tag:"#text",shallow:"t:"+e.data,content:"t:"+e.data,deep:"t:"+e.data};else if(e.nodeType===8)n={tag:"#comment",shallow:"c:"+e.data,content:"c:"+e.data,deep:"c:"+e.data};else{let r=q(e).map(o=>Ye(o,t)),s="e:"+e.localName+"|"+ye(e);n={tag:e.localName,shallow:s,content:"e:"+e.localName+"|"+J(r.map(o=>o.content)),deep:s+"|"+J(r.map(o=>o.deep))}}return t.set(e,n),n}function*Ke(e,t,n){++n.n%K===0&&(yield);let r;if(e.nodeType===3)r={tag:"#text",shallow:"t:"+e.data,content:"t:"+e.data,deep:"t:"+e.data};else if(e.nodeType===8)r={tag:"#comment",shallow:"c:"+e.data,content:"c:"+e.data,deep:"c:"+e.data};else{let s=[];for(let l of q(e))s.push(yield*Ke(l,t,n));let o="e:"+e.localName+"|"+ye(e);r={tag:e.localName,shallow:o,content:"e:"+e.localName+"|"+J(s.map(l=>l.content)),deep:o+"|"+J(s.map(l=>l.deep))}}return t.set(e,r),r}function*Ze(e,t){if(++t.n%K===0&&(yield),e.kind==="text")return e.keys={tag:"#text",shallow:"t:"+e.value,content:"t:"+e.value,deep:"t:"+e.value};if(e.kind==="comment")return e.keys={tag:"#comment",shallow:"c:"+e.value,content:"c:"+e.value,deep:"c:"+e.value};let n=[];for(let s of e.children)n.push(yield*Ze(s,t));let r="e:"+e.tag+"|"+Xe(e);return e.keys={tag:e.tag,shallow:r,content:"e:"+e.tag+"|"+J(n.map(s=>s.content)),deep:r+"|"+J(n.map(s=>s.deep))}}var De=["deep","content","shallow","tag"],Mt=4096;function Lt(e,t){Ge.align++;let n=[],r=e.map((p,y)=>y),s=t.map((p,y)=>y);g(r,s,0);let o=new Set(n.map(p=>p[0])),l=new Set(n.map(p=>p[1])),d=r.filter(p=>!o.has(p)),a=s.filter(p=>!l.has(p));return d.length&&a.length&&g(d,a,0),n.sort((p,y)=>p[0]-y[0]),n;function g(p,y,S){let w=0,h=p.length,v=0,N=y.length;if(w>=h||v>=N)return;if(S>=De.length)return c(p,y);let b=De[S];for(;w<h&&v<N&&e[p[w]][b]===t[y[v]][b];)n.push([p[w],y[v]]),w++,v++;for(;w<h&&v<N&&e[p[h-1]][b]===t[y[N-1]][b];)h--,N--,n.push([p[h],y[N]]);if(w>=h||v>=N)return;let P=new Map,Q=new Map;for(let I=w;I<h;I++){let A=e[p[I]][b];P.set(A,P.has(A)?-1:I)}for(let I=v;I<N;I++){let A=t[y[I]][b];Q.set(A,Q.has(A)?-1:I)}let ne=[];for(let I=w;I<h;I++){let A=e[p[I]][b];if(P.get(A)===I){let D=Q.get(A);D!==void 0&&D>=0&&ne.push([I,D])}}let W=bt(ne);if(!W.length){if((h-w)*(N-v)<=Mt){let I=Ft(e,t,p,y,w,h,v,N,b);if(I.length){let A=w,D=v;for(let[H,G]of I)n.push([p[H],y[G]]),g(p.slice(A,H),y.slice(D,G),S+1),A=H+1,D=G+1;g(p.slice(A,h),y.slice(D,N),S+1);return}}return g(p.slice(w,h),y.slice(v,N),S+1)}let z=w,V=v;for(let[I,A]of W)n.push([p[I],y[A]]),g(p.slice(z,I),y.slice(V,A),S),z=I+1,V=A+1;g(p.slice(z,h),y.slice(V,N),S)}function c(p,y){let S=new Map,w=new Map;for(let h of p){let v=e[h].tag;S.has(v)||S.set(v,[]),S.get(v).push(h)}for(let h of y){let v=t[h].tag;w.has(v)||w.set(v,[]),w.get(v).push(h)}for(let[h,v]of S){let N=w.get(h);N&&N.length===v.length&&h!=="#text"&&h!=="#comment"&&v.forEach((b,P)=>n.push([b,N[P]]))}}}function bt(e){let t=[],n=[],r=new Array(e.length).fill(-1);for(let l=0;l<e.length;l++){let d=e[l][1],a=0,g=t.length;for(;a<g;){let c=a+g>>1;t[c]<d?a=c+1:g=c}t[a]=d,n[a]=l,r[l]=a>0?n[a-1]:-1}let s=[],o=n.length?n[n.length-1]:-1;for(;o>=0;)s.push(e[o]),o=r[o];return s.reverse()}function Ft(e,t,n,r,s,o,l,d,a){let g=o-s,c=d-l,p=(v,N)=>e[n[s+v]][a]===t[r[l+N]][a],y=Array.from({length:g+1},()=>new Uint16Array(c+1));for(let v=g-1;v>=0;v--)for(let N=c-1;N>=0;N--)y[v][N]=p(v,N)?y[v+1][N+1]+1:Math.max(y[v+1][N],y[v][N+1]);let S=[],w=0,h=0;for(;w<g&&h<c;)p(w,h)?(S.push([s+w,l+h]),w++,h++):y[w+1][h]>=y[w][h+1]?w++:h++;return S}function Be(e){return e.nodeType===3?"#text "+JSON.stringify(e.data.slice(0,40)):e.nodeType===8?"#comment":"<"+e.localName+Array.from(e.attributes,t=>" "+t.name+'="'+t.value.slice(0,30)+'"').join("")+">"}function je(e){return e.kind==="text"?"#text "+JSON.stringify(e.value.slice(0,40)):e.kind==="comment"?"#comment":"<"+e.tag+e.attrs.map(t=>" "+t.name+'="'+t.value.slice(0,30)+'"').join("")+">"}function et(e,t,n=r=>r){return j(we(e,t,n))}function*we(e,t,n=r=>r){let r=new WeakMap,s=new Map,o={n:0};yield*Ke(e,s,o),yield*Ze(t.root,o);let l={paired:0,unmatchedLive:[],unmatchedSource:[],attrDiffs:[],textDiffs:0,unresolved:0},d={};return t.gen=d,yield*tt(e,t.root,r,s,l,"html",n,d,o),{map:r,stats:l}}function*tt(e,t,n,r,s,o,l,d,a){++a.n%K===0&&(yield);let g=l(e);if(g?(n.set(g,t),t.gen=d,s.paired++):s.unresolved++,t.kind!=="element"){e.data!==t.value&&s.textDiffs++;return}ye(e)!==Xe(t)&&s.attrDiffs.push({path:o,live:Be(e),source:je(t)});let c=q(e),p=t.children,y=Lt(c.map(h=>r.get(h)),p.map(h=>h.keys)),S=new Set,w=new Set;for(let[h,v]of y)S.add(h),w.add(v),yield*tt(c[h],p[v],n,r,s,o+">"+(c[h].nodeType===1?c[h].localName:"#")+"["+h+"]",l,d,a);for(let h=0;h<c.length;h++)S.has(h)||s.unmatchedLive.push({path:o,node:Be(c[h])});for(let h=0;h<p.length;h++)w.has(h)||s.unmatchedSource.push({path:o,node:je(p[h])})}function*nt(e,t,n=r=>r){if(!t.root)return null;let r=[],s=yield*rt(e,t.root,n,r,{n:0});if(s<0)return null;let o=new WeakMap,l={};t.gen=l;let d=0;for(let[a,g]of r)a&&(o.set(a,g),g.gen=l,d++);return{map:o,stats:{paired:d,unmatchedLive:[],unmatchedSource:[],attrDiffs:[],textDiffs:0,unresolved:s}}}function*rt(e,t,n,r,s){if(++s.n%K===0&&(yield),t.kind==="text"){if(e.nodeType!==3||e.data!==t.value)return-1}else if(t.kind==="comment"){if(e.nodeType!==8||e.data!==t.value)return-1}else if(e.nodeType!==1||e.localName!==t.tag||e.namespaceURI!==t.node.namespaceURI||Pt(e)!==Dt(t.node))return-1;let o=n(e);r.push([o,t]);let l=o?0:1;if(t.kind!=="element")return l;let d=Bt(e),a=t.children;if(d.length!==a.length)return-1;for(let g=0;g<d.length;g++){let c=yield*rt(d[g],a[g],n,r,s);if(c<0)return-1;l+=c}return l}var ot=e=>JSON.stringify(e),Pt=e=>Array.from(e.attributes,t=>ot([t.namespaceURI||"",t.name,t.value])).sort().join(ae),Dt=e=>e.attrs.map(t=>ot([t.namespace||"",t.prefix?t.prefix+":"+t.name:t.name,t.value])).sort().join(ae);function Bt(e){let t=e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content.childNodes:e.childNodes,n=[];for(let r of t)(r.nodeType===1||r.nodeType===3||r.nodeType===8)&&n.push(r);return n}function st(e,t,n){let r=t.get(e);if(!r||r.gen!==n.gen||r.from<0||r.to<0||r.kind==="element"&&r.located&&n.src.slice(r.openFrom,r.openFrom+r.tag.length+1).toLowerCase()!=="<"+r.tag.toLowerCase())return null;let s=jt(n),o=Ut(s,r.from);return{from:r.from,to:r.to,line:o+1,column:r.from-s[o]+1}}function jt(e){if(!e.lineStarts){let t=[0];for(let n=0;n<e.src.length;n++)e.src.charCodeAt(n)===10&&t.push(n+1);e.lineStarts=t}return e.lineStarts}function Ut(e,t){let n=0,r=e.length-1;for(;n<r;){let s=n+r+1>>1;e[s]<=t?n=s:r=s-1}return n}function it(e,t,n,r,s={}){let o=()=>typeof performance<"u"?performance.now():Date.now(),l=o(),d=n.src,a=[],g=0,c=(u,m)=>{if(!(u>=0&&m>u))return;let f=a.length>g?a[a.length-1]:null;f&&f.text===void 0&&f.to===u?f.to=m:a.push({from:u,to:m})},p=u=>{u&&a.push({text:u})},y=0,S=u=>{if(y)return null;let m=r(u),f=m?t.get(m):null;return f&&f.gen===n.gen?f:null},w=null,h=-1,v=!1,N=n.root;if(c(0,N.openFrom),I(e,N),c(N.closeTo,d.length),n.tailOwner&&h>=0&&!v){for(let u=h;u<a.length;u++)a[u]={text:Q(P(a[u]))};w&&w.tail&&a.splice(w.at,0,{text:w.tail})}return{text:a.map(P).join(""),ms:o()-l};function P(u){return u.text!==void 0?u.text:d.slice(u.from,u.to)}function Q(u){return u.split(/(<!--[\s\S]*?-->|<[^>]*>)/).map((m,f)=>f%2?m:m.replace(/[\t\n\f\r ]+/g,"")).join("")}function ne(){h=a.length,g=a.length,v=!!w&&w.whole&&/^(?:<\/[^>]*>)*$/.test(a.slice(w.at).map(P).join(""))}function W(u,m){if(u.nodeType===3)return V(u,m);if(u.nodeType===8)return z(u);if(u.nodeType===1){if(s.print&&s.print.has(u)){y++;try{I(u,null)}finally{y--}}else I(u,S(u));u.localName==="body"&&u.parentNode===e&&ne()}}function z(u){let m=S(u);m&&m.kind==="comment"&&m.value===u.data&&m.from>=0&&!s.breakText?c(m.from,m.to):p("<!--"+u.data+"-->")}function V(u,m){let f=S(u),x=u.data;s.corrupt==="drop-first-text"&&!s.corrupted&&x.trim()&&(s.corrupted=!0,x=x.slice(1));let T=f&&f.parent&&be(f.parent.tag)===be(m);if(f&&f.kind==="text"&&f.value===x&&f.from>=0&&!s.breakText&&T){c(f.from,f.to),s.doubleCopied!==void 0&&x===s.doubleCopied&&c(f.from,f.to),f.outsideTail&&(w={at:a.length,tail:f.outsideTail,whole:!0},g=a.length);return}let M=null;if(f&&f.kind==="text"&&f.outsideTail){let R=x.endsWith(f.outsideTail);R&&(x=x.slice(0,x.length-f.outsideTail.length)),M={tail:R?f.outsideTail:"",whole:R}}p(ge.has(m)?x:Ct(x)),M&&(w={at:a.length,...M},g=a.length)}function I(u,m){let f=u.localName,x=pe.has(f)&&u.namespaceURI===$e,T=m&&m.kind==="element"&&!s.breakTags?m:null;if(T&&!T.located){if(u.attributes.length===0){if(T.openFrom>=0){X(u,T,f);return}q(u).length&&X(u,null,f);return}if(p(A(u)),x)return;X(u,T.openFrom>=0?T:null,f),p("</"+f+">");return}if(!T){if(p(A(u)),x)return;X(u,null,f),p("</"+f+">");return}H(u,T),!x&&(X(u,T,f),c(T.closeFrom,T.closeTo))}function A(u){let m="<"+u.localName;for(let f of u.attributes)m+=" "+f.name+(f.value===""?"":'="'+Fe(f.value)+'"');return m+">"}function D(u,m){let f=u.attributes;if(f.length!==m.attrs.length)return!1;for(let x=0;x<f.length;x++){let T=m.attrs[x];if(T.from<0||f[x].value!==T.value||f[x].name.toLowerCase()!==T.key)return!1}return!0}function H(u,m){if(D(u,m)){c(m.openFrom,m.openTo);return}let f=new Map;for(let O of u.attributes)f.set(O.name.toLowerCase(),O);let x=new Set,T=m.openFrom;for(let O of m.attrs){if(O.from<0){let _=f.get(O.key);_&&_.value===O.value&&x.add(O.key);continue}let L=f.get(O.key);if(x.add(O.key),!L){c(T,G(T,O.from)),T=O.to;continue}if(L.value===O.value){c(T,O.to),T=O.to;continue}c(T,O.from),p(xt(d.slice(O.from,O.to),L.value)),T=O.to}let M=m.openTo-1,R=m.attrs.reduce((O,L)=>L.to>O?L.to:O,m.openFrom);d[M-1]==="/"&&M-1>=R&&M--,c(T,M);for(let O of u.attributes)x.has(O.name.toLowerCase())||p(" "+O.name+(O.value===""?"":'="'+Fe(O.value)+'"'));c(M,m.openTo)}function G(u,m){let f=m;for(;f>u&&/[ \t\n\r\f]/.test(d[f-1]);)f--;return f}function xt(u,m){let f=u.indexOf("="),x=(f<0?u:u.slice(0,f)).trimEnd(),T=f<0?"":u.slice(f+1).trim(),M=T[0]==="'"?"'":T[0]==='"'?'"':"",R=m.replace(/&/g,"&amp;").replace(/ /g,"&nbsp;");return M==="'"&&!m.includes("'")?x+"='"+R+"'":M===""&&T!==""&&m!==""&&!/[\s"'=<>`]/.test(m)?x+"="+R:x+'="'+R.replace(/"/g,"&quot;")+'"'}function St(u){if(u.nodeType!==1||y||s.print&&s.print.has(u))return null;let m=S(u);return m&&m.kind==="element"&&m.located&&!m.endTagged&&!pe.has(m.tag)&&!s.breakTags?m:null}function ue(u){let m=St(u);if(!m)return null;let f=q(u);return((f.length?ue(f[f.length-1]):null)||[]).concat(m.tag)}function X(u,m,f){let x=q(u),T=null,M=(C,k)=>{T&&!(k>=0&&T.j>=0&&k===T.j+1)&&p(T.tags.map(E=>"</"+E+">").join("")),T=null};if(!m){for(let C of x){M(-1,-1),W(C,f);let k=ue(C);k&&(T={tags:k,j:-1})}return}let R=m.children,O=new Map(R.map((C,k)=>[C,k])),L=x.map(C=>{let k=S(C);return k&&k.parent===m&&k.from>=0?O.get(k):-1}),_=new Set;if(!s.breakText&&!s.breakTags){let C=new Set(L),k=new Map;R.forEach((E,F)=>{C.has(F)||E.from<0||!E.keys||(k.has(E.keys.deep)||k.set(E.keys.deep,[]),k.get(E.keys.deep).push(F))}),k.size&&x.forEach((E,F)=>{if(L[F]>=0||S(E))return;let B=k.get(Ye(E,new Map).deep);B&&B.length&&(L[F]=B.shift(),_.add(F))})}let Se=(C,k)=>{if(!_.has(k))return W(C,f);let E=R[L[k]];c(E.from,E.to),E.outsideTail&&(w={at:a.length,tail:E.outsideTail,whole:!0},g=a.length)},kt=(C,k)=>{if(!_.has(k))return ue(C);let E=R[L[k]];return E.kind==="element"&&E.located&&!E.endTagged&&!pe.has(E.tag)?[E.tag]:null},Nt=new Set(_t(L)),U=m.openTo,ke=-1,Ne=C=>{for(let k=ke+1;k<C;k++){let E=R[k];E.from<0||(c(U,E.from),U=Math.max(U,E.to))}};for(let C=0;C<x.length;C++){let k=x[C],E=kt(k,C);if(Nt.has(C)){let B=L[C],Ee=R[B];M(C,B),Ne(B),c(U,Ee.from),Se(k,C),U=Math.max(U,Ee.to),ke=B,T=E?{tags:E,j:B}:null;continue}let F=S(k);M(C,F&&F.parent===m?O.get(F):-1),Se(k,C),T=E?{tags:E,j:-1}:null}Ne(R.length),c(U,m.closeFrom)}}function _t(e){let t=[],n=[],r=new Array(e.length).fill(-1);for(let l=0;l<e.length;l++){let d=e[l];if(d<0)continue;let a=0,g=t.length;for(;a<g;){let c=a+g>>1;t[c]<d?a=c+1:g=c}t[a]=d,n[a]=l,r[l]=a>0?n[a-1]:-1}let s=[],o=n.length?n[n.length-1]:-1;for(;o>=0;)s.push(o),o=r[o];return s.reverse()}function*at(e,t,n,r=null,s=null){return yield*ve(e,t,n,r,s,!0)}function*ve(e,t,n,r,s,o){let l=new DOMParser,d=l.parseFromString(e,"text/html"),a=qe(d),g=qe(n);if(a.join(`
3
3
  `)!==g.join(`
4
4
  `))return{ok:!1,diff:"document: outside <html> "+JSON.stringify(a)+" vs live "+JSON.stringify(g)};let c=null,p=null;if(r&&(c=[],p=yield*se(d.documentElement,r,"html",c),!p)){let h=yield*Ue(e,s,o);return h.diff?{ok:!1,diff:h.diff}:o?_e({ok:!0,diff:null,oracle:"clone"},h,e,n):{ok:!0,diff:null,oracle:"clone"}}let y=l.parseFromString(t,"text/html"),S=yield*se(d.documentElement,y.documentElement,"html"),w=S?null:yield*Ue(e,s,o);return S?r?{ok:!1,diff:S,at:c}:{ok:!1,diff:S}:w.diff?{ok:!1,diff:w.diff}:o?_e({ok:!0,diff:null,oracle:"today"},w,e,n):{ok:!0,diff:null,oracle:"today"}}function lt(e,t){let n=e;for(let r of t){let s=he(n);if(r>=s.length)return null;n=s[r]}return n}function*Ue(e,t,n){if(!t)return{diff:null};let{document:r,errors:s}=yield*de(e,n?{sourceCodeLocationInfo:!0}:{});for(let[o,l]of s){let d=t.get(o)||0;if(l>d)return{diff:`the render introduced parse errors the source does not have: ${o} ${d} -> ${l}`}}return n?{diff:null,doc:r,parseErrors:s}:{diff:null}}function _e(e,t,n,r){if(!t.doc)return e;let s=We(n,t.doc,t.parseErrors);return Z(s,r)||(e.model=s),e}function qe(e){let t=[];for(let n of e.childNodes)n.nodeType===10?t.push("doctype "+n.name+"|"+n.publicId+"|"+n.systemId):n.nodeType===8?t.push("comment "+n.data):n.nodeType!==1&&t.push("node"+n.nodeType+" "+(n.data||""));return t}function*qt(e,t,n,r){let s=new DOMParser,o=l=>{let d=Array.from(l.childNodes);return d.length&&d.every(a=>a.nodeType===3)?d.map(a=>a.data).join(""):l.innerHTML};return yield*se(s.parseFromString(e.innerHTML,"text/html").body,s.parseFromString(o(t),"text/html").body,n+">#noscript",[],r)}function he(e){let t=e.localName==="template"&&e.content?e.content.childNodes:e.childNodes,n=[];for(let r=0;r<t.length;r++){let s=t[r];(s.nodeType===1||s.nodeType===3||s.nodeType===8)&&n.push(s)}return n}var oe=e=>Array.from(e.attributes,t=>(t.namespaceURI||"")+" "+t.name+"="+JSON.stringify(t.value)).sort().join("; ");function Jt(e,t){let n=e.attributes,r=t.attributes;if(n.length!==r.length)return!1;for(let s=0;s<n.length;s++){let o=n[s],l=r[s];if(o.name!==l.name||o.value!==l.value||o.namespaceURI!==l.namespaceURI)return!1}return!0}function*se(e,t,n,r=[],s={n:0}){if(++s.n%K===0&&(yield),e.nodeType!==t.nodeType)return n+": node type "+e.nodeType+" vs "+t.nodeType;if(e.nodeType===3||e.nodeType===8)return e.data===t.data?null:n+": text "+JSON.stringify(e.data.slice(0,60))+" vs "+JSON.stringify(t.data.slice(0,60));if(e.localName!==t.localName||e.namespaceURI!==t.namespaceURI)return n+": tag "+e.localName+" vs "+t.localName;if(!Jt(e,t)&&oe(e)!==oe(t))return n+": attrs "+oe(e)+" vs "+oe(t);if(e.localName==="noscript"&&e.namespaceURI===$e)return yield*qt(e,t,n,s);let o=he(e),l=he(t);if(o.length!==l.length)return n+": "+o.length+" vs "+l.length+" children";for(let d=0;d<o.length;d++){r.push(d);let a=yield*se(o[d],l[d],n+">"+(o[d].localName||"#")+"["+d+"]",r,s);if(a)return a;r.pop()}return null}var i={installed:!1,refused:null,session:0,model:null,map:null,stats:null,saves:0,reprints:0,lastReprint:null,partialReprints:0,lastPartialReprint:null,lastOutcome:null,lastRenderMs:null,lastBytes:null,timing:{fetch:null,model:null,pair:null,refresh:null},refreshes:0,repairs:0,refreshQueued:!1,pendingBytes:null,refetch:!1,adoptions:0},$t=2,$=()=>typeof performance<"u"?performance.now():Date.now(),dt=4,le=Object.freeze({superseded:!0});function pt(e){return document.hidden||Me()?!1:e>=307200}var mt='<script type="application/json" id="clay-runtime-map"',ht=e=>e.includes(mt)||e.includes("/_/clayjs/");async function gt(e){let t=await fetch(e,{cache:"no-store",redirect:"manual",credentials:"same-origin",headers:{"Clay-Source":"1"}});if(!t.ok)throw new Error(`source fetch: status ${t.status}`);if(t.redirected||t.type==="opaqueredirect")throw new Error("source fetch: redirected");let n=(t.headers.get("content-type")||"").toLowerCase();if(!n.startsWith("text/html"))throw new Error(`source fetch: content-type ${n||"missing"}`);let r=await t.text();if(r.includes(mt))throw new Error("source fetch: projected response");return r}function yt(e){let t=fe({flushUndo:!1,authored:!1});return et(t,e,Y)}function*Qt(e){let t=fe({flushUndo:!1,authored:!1});return yield*we(t,e,Y)}function Wt(e){let t=e.doc&&e.doc.childNodes.find(r=>r.nodeName==="html"),n=t&&Array.isArray(t.attrs)?t.attrs.find(r=>r.name==="documentetag"):null;return n&&n.value?n.value:null}function zt(e){let t=e&&e.represented&&e.represented.etag;if(t)return t;let n=Ae();return n||e===null&&document.documentElement.getAttribute("documentetag")||null}function Vt(e,t){let n=Wt(e),r=zt(t);return!n||!r||n===r?null:`source refused: the fetch answered version ${n} while this page holds ${r}`}async function wt(e,t=null,n=0,r=!0,s=null){let o=i.session,l=$(),d=i.adoptions;i.refused=null;let a=s?s():null,g=a&&typeof a.bytes=="string"&&!ht(a.bytes)?a.bytes:null;try{let c=g!==null?g:await gt(e);if(o!==i.session)return null;let p=$(),y=await Ht({src:c,context:t,render:r,session:o,generation:d,t0:l,t1:p});if(y!==le)return y;if(n<$t)return wt(e,t,n+1,r,s);throw new Error("source refused: a save replaced the file while the fetch was in flight")}catch(c){return o!==i.session||(i.refused=String(c&&c.message?c.message:c),console.info(`clayjs: source map off (${i.refused}); saves use the full serialization`)),null}}function*ut(e){let t=yield*ie(e.src),n=Z(t,document);if(n)throw new Error(`source refused: ${n}`);let r=Vt(t,e.context);if(r)throw new Error(r);if(i.adoptions!==e.generation)return le;let s=$();if(yield,i.session!==e.session)return null;if(i.adoptions!==e.generation)return le;let{map:o,stats:l}=yield*Qt(t);if(i.session!==e.session)return null;if(i.adoptions!==e.generation)return le;let d=$();return i.model=t,i.map=o,i.stats=l,i.timing={fetch:e.t1-e.t0,model:s-e.t1,pair:d-s,refresh:null},i.installed=!0,e.render&&ce(Gt,{steps:vt}),Tt()}async function Ht(e){if(!pt(e.src.length))return j(ut(e));let t={get aborted(){return i.session!==e.session}},n=await re(ut(e),{budgetMs:dt,signal:t});return n&&n.aborted===!0?null:n}function Gt(e,t,n={}){return j(vt(e,t,n))}function*vt(e,t,n={}){if(!i.installed)return t;yield*xe();let r=i.session,s=i.repairs,o=Oe(),l=!!o&&!o.authoredHandlers,d=new Set,a=null;for(let g=0;g<=Yt;g++){let c;try{c=it(e,i.map,i.model,Y,{...n,print:d})}catch(y){return ee("render threw: "+(y&&y.message?y.message:y),t)}let p=l?yield*at(c.text,t,document,e,i.model.parseErrors):yield*ve(c.text,t,document,e,i.model.parseErrors,!1);if(p.ok){let y=ct(r,s);if(y)return ee(y,t);let S=d.size?{text:c.text,scope:"partial",reason:a,printed:d.size}:{text:c.text,scope:null},w=p.model?yield*nt(e,p.model,Y):null,h=ct(r,s);return h?ee(h,t):(i.lastRenderMs=c.ms,i.lastBytes=c.text.length,i.lastOutcome=S,p.model&&Xt(p.model,c.text,o,w),c.text)}if(a===null&&(a=p.diff),!p.at||!Kt(e,lt(e,p.at),d))return ee(a,t)}return ee(a,t)}function ct(e,t){return i.session!==e?"render refused: the session ended while this render ran":i.installed?i.repairs!==t?"render refused: the map was re-paired while this render ran":null:"render refused: the source map was uninstalled while this render ran"}function Xt(e,t,n,r){r&&Ie({captureId:n.captureId,html:t,source:{model:e,map:r.map,stats:r.stats,repairGeneration:i.repairs,outcome:i.lastOutcome}})}var Yt=8;function Kt(e,t,n){let r=t&&t.nodeType===1?t:t&&t.parentNode;for(let s=r;s&&s!==e;s=s.parentNode)if(n.has(s)){n.delete(s),r=s.parentNode;break}return!r||r.nodeType!==1||r===e?!1:(n.add(r),!0)}function ee(e,t){return i.lastOutcome={text:t,scope:"full",reason:e},t}function Zt(e){i.reprints++,i.lastReprint=e,console.warn("clayjs: source map did not verify, saving the full serialization instead:",e),document.dispatchEvent(new CustomEvent("clay:save-reprinted",{detail:{reason:e,scope:"full"}}))}function en(e,t){i.partialReprints++,i.lastPartialReprint=e,console.info(`clayjs: source map printed ${t} element(s) in full to match the page:`,e),document.dispatchEvent(new CustomEvent("clay:save-reprinted",{detail:{reason:e,scope:"partial",printed:t}}))}function tn(e,t){i.adoptions++,i.installed&&(rn(e,t&&t.artifact?t.artifact.source.outcome:null),!nn(e,t)&&(i.pendingBytes=e,Te()))}function nn(e,t){let n=t&&t.artifact;return!n||!n.source||n.html!==e||t.captureId===null||t.captureId===void 0||n.captureId!==t.captureId||n.source.repairGeneration!==i.repairs||i.refreshQueued||i.pendingBytes!==null?!1:(i.model=n.source.model,i.map=n.source.map,i.stats=n.source.stats,!0)}function rn(e,t=null){let n=i.lastOutcome&&i.lastOutcome.text===e?i.lastOutcome:t;!n||n.text!==e||(i.lastOutcome===n&&(i.lastOutcome=null),i.saves++,n.scope==="full"?Zt(n.reason):n.scope==="partial"&&en(n.reason,n.printed))}function on(e){let t=e&&e.detail;t&&t.source==="disk"&&typeof t.html=="string"&&i.adoptions++,i.installed&&(t&&t.source==="disk"&&typeof t.html=="string"&&(ht(t.html)?i.refetch=!0:i.pendingBytes=t.html),Te())}function Te(){i.refreshQueued||(i.refreshQueued=!0,typeof requestIdleCallback=="function"?requestIdleCallback(ft,{timeout:2e3}):setTimeout(ft,0))}function ft(){if(!pt(sn())){te();return}an()}function sn(){return typeof i.pendingBytes=="string"?i.pendingBytes.length:i.model?i.model.src.length:0}async function an(){let e=i.session,t={get aborted(){return i.session!==e}};try{await re(xe(),{budgetMs:dt,signal:t})}catch(n){console.warn("clayjs: source map could not run the queued repair:",n)}!i.refreshQueued||!i.installed||i.session!==e||(i.refreshQueued=!1,Te())}function te(){j(xe())}function*xe(){if(!i.refreshQueued)return;if(!i.installed){i.refreshQueued=!1;return}let e=i.session,t=i.repairs,n=i.adoptions,r=i.pendingBytes,s=i.refetch&&r===null,o=$(),l=i.model;if(r!==null)try{let a=yield*ie(r),g=Z(a,document);if(g)throw new Error(g);l=a}catch(a){console.warn("clayjs: source map kept the previous model, the accepted bytes did not model:",a)}if(yield,!ln(e,t,n))return;let d=null;try{d=yt(l)}catch(a){console.warn("clayjs: source map could not re-pair, continuing on the previous map:",a)}i.refreshQueued=!1,i.pendingBytes=null,s&&(i.refetch=!1),i.repairs++,d&&(i.model=l,i.map=d.map,i.stats=d.stats,i.refreshes++,i.timing.refresh=$()-o),s&&un()}function ln(e,t,n){return i.session===e&&i.installed&&i.repairs===t&&i.adoptions===n}function un(){let e=i.repairs,t=i.adoptions;gt(window.location.href).then(n=>{let r=Qe(n),s=Z(r,document);if(s)throw new Error(s);return r}).then(n=>{if(!(i.repairs!==e||i.adoptions!==t))try{i.repairs++,i.adoptions++;let{map:r,stats:s}=yt(n);i.model=n,i.map=r,i.stats=s,i.refreshes++}catch(r){console.warn("clayjs: source map could not re-pair, continuing on the previous map:",r)}}).catch(n=>{console.warn("clayjs: source map kept the previous model, the accepted bytes did not model:",n)})}function Tt(){let e=i.stats;return{installed:i.installed,refused:i.refused,sourceBytes:i.model?i.model.src.length:null,paired:e?e.paired:0,unresolved:e?e.unresolved:0,unmatchedLive:e?e.unmatchedLive.length:0,unmatchedSource:e?e.unmatchedSource.length:0,attrDiffs:e?e.attrDiffs.length:0,saves:i.saves,reprints:i.reprints,lastReprint:i.lastReprint,partialReprints:i.partialReprints,lastPartialReprint:i.lastPartialReprint,lastRenderMs:i.lastRenderMs,lastBytes:i.lastBytes,refreshes:i.refreshes,timing:i.timing}}function kn(){return te(),i.model?i.model.src:null}function Nn(e){return te(),i.installed&&e?st(e,i.map,i.model):null}function En(){return te(),i.stats?{live:i.stats.unmatchedLive.slice(0,50),source:i.stats.unmatchedSource.slice(0,50)}:null}function On(){return te(),Tt()}var In=()=>i.installed,Cn=()=>i.repairs;function An(){cn()}function cn(){i.session++,i.installed=!1,i.refreshQueued=!1,i.pendingBytes=null,i.refetch=!1,ce(null)}function Rn({context:e=null,latest:t=null}={}){return wt(window.location.href,e,0,!0,t)}Ce(tn);document.addEventListener("clay:sync-applied",on);export{tn as adoptAccepted,In as installed,Nn as locateLive,xe as refreshNowSteps,An as release,Gt as renderSave,vt as renderSaveSteps,Cn as repairGeneration,Rn as start,On as stats,kn as text,En as unpaired};
@@ -1 +1 @@
1
- import{e as c,f as s}from"./c-TWCXBWS3.js";import{k as g,r as u}from"./c-PWJSJEJU.js";import{i as l}from"./c-ICMAOOGK.js";var p={debug:!1};function t(...n){p.debug&&console.log("[save-freeze]",...n)}var f=new WeakMap;function m(n,o){f=new WeakMap;let e=n.querySelectorAll(l);t("freezing clone:",e.length);for(let r of e){let a=o.original(r);if(!a)continue;let i=c(a);i!==void 0&&(f.set(r,i),r.innerHTML!==i&&(t("restoring original"),r.innerHTML=i))}}function d(n){for(let o of n.querySelectorAll(l)){let e=f.get(o);e!==void 0&&o.innerHTML!==e&&(t("re-restoring original after prepare-phase change"),o.innerHTML=e)}}function E(){t("init"),s(),g(m),u(d)}E();var h=p;export{h as a};
1
+ import{e as c,f as s}from"./c-QCDVDZIR.js";import{k as g,r as u}from"./c-PNZIJFG7.js";import{i as l}from"./c-ICMAOOGK.js";var p={debug:!1};function t(...n){p.debug&&console.log("[save-freeze]",...n)}var f=new WeakMap;function m(n,o){f=new WeakMap;let e=n.querySelectorAll(l);t("freezing clone:",e.length);for(let r of e){let a=o.original(r);if(!a)continue;let i=c(a);i!==void 0&&(f.set(r,i),r.innerHTML!==i&&(t("restoring original"),r.innerHTML=i))}}function d(n){for(let o of n.querySelectorAll(l)){let e=f.get(o);e!==void 0&&o.innerHTML!==e&&(t("re-restoring original after prepare-phase change"),o.innerHTML=e)}}function E(){t("init"),s(),g(m),u(d)}E();var h=p;export{h as a};
@@ -1 +1 @@
1
- import{b as O,c as N}from"./c-IJUK2GPW.js";import{f as v}from"./c-VG5XIN4T.js";import{a as y,h as k,j as C,k as R}from"./c-HA6INT6J.js";import{b as E,s as g,t as _,u as S,v as m}from"./c-ICMAOOGK.js";import{g as w}from"./c-WRBKEJD4.js";import{a as M}from"./c-VHNSBD2M.js";var L={};M(L,{default:()=>B});var P=document.createElement("div"),x=new Set(k);function T(e){if(e.type!=="attributes")return!1;let t=e.attributeName;return t===R||y(t,e.target)?!0:e.target===document.documentElement&&(x.has(t)||t.startsWith(C))}function A(e){return e.some(T)?e.filter(t=>!T(t)):e}var V={_callbacks:{anyChange:[],addOrRemove:[],addElement:[],removeElement:[],attribute:[]},_observing:!1,_pauseDepth:0,_hasNonPausable:!1,debug:!1,_rawSubscribers:[],_deferredChangeRecords:null,_deferredChangeScheduled:!1,pause(){this._pauseDepth===0&&this._deliverBeforePause(),this._pauseDepth++,typeof window<"u"&&window.clay?.undo?.pause&&window.clay.undo.pause(),this._log("Paused",this._pauseDepth)},_deliverBeforePause(){if(!this._observer)return;let e=this._observer.takeRecords();e.length&&this._onRecords(e)},dropQueued(){this._observer&&this._drainBrowserQueue(this)},resume(){this._pauseDepth!==0&&(this._pauseDepth--,this._pauseDepth===0&&this._observer&&this._drainBrowserQueue(this),typeof window<"u"&&window.clay?.undo?.resume&&window.clay.undo.resume(),this._log("Resumed",this._pauseDepth))},_log(e,t=null,s="log"){if(!this.debug)return;let i=`[Mutation ${new Date().toISOString()}]`;t?console[s](i,e,t):console[s](i,e)},_notify(e,t,s=!1){this._log(`Notifying ${this._callbacks[e].length} callbacks of type "${e}"`,{changes:t});for(let r of this._callbacks[e]){if(s&&r.pausable!==!1)continue;let{fn:i,debounce:u=0,maxWait:l=0,selectorFilter:n,omitChangeDetails:c,require:h,skip:d}=r,f=t.filter(o=>{if(h!=="observed"&&v(o))return!1;let a=m(this._policyForChange(o),h,d);if(!o.policyTransition)return!a;let b=m(o.previousPolicy,h,d);return!(a&&b)});if(!f.length){this._log("No changes passed the region policy, skipping callback");continue}if(n&&(this._log("Applying selector filter",{selectorFilter:n}),f=f.filter(o=>{if(typeof n=="string"){let a=o.element.matches?.(n)||!1;return this._log(`Selector "${n}" match:`,{element:o.element,matches:a}),a}if(typeof n=="function"){let a=n(o.element);return this._log("Custom filter match:",{element:o.element,matches:a}),a}return!1}),this._log("Changes after filtering:",{filteredChanges:f})),!f.length){this._log("No changes passed the filter, skipping callback");continue}if(u===0)try{c?i():i(f)}catch(o){this._log("Error in callback execution:",o,"error"),console.error("Error in Mutation callback:",o)}else{r.timeout&&(clearTimeout(r.timeout),r.timeout=null),r.firstPendingAt||(r.firstPendingAt=Date.now());let o=l>0?Math.max(0,Math.min(u,l-(Date.now()-r.firstPendingAt))):u;c?r.timeout=setTimeout(()=>{r.timeout=null,r.firstPendingAt=null;try{this._log("Executing debounced callback (no details)"),i()}catch(a){this._log("Error in callback execution:",a,"error"),console.error("Error in Mutation callback:",a)}},o):(r.pendingChanges||(r.pendingChanges=[]),r.pendingChanges.push(...f),r.timeout=setTimeout(()=>{let a=r.pendingChanges;r.pendingChanges=null,r.timeout=null,r.firstPendingAt=null;try{this._log("Executing debounced callback with changes:",{changes:a}),a&&a.length>0&&i(a)}catch(b){this._log("Error in callback execution:",b,"error"),console.error("Error in Mutation callback:",b)}},o))}}},_policyForChange(e){if(e.__policy)return e.__policy;let t=e.element,s=g(t);return e.parent&&t&&t.isConnected===!1&&(s=S(s,g(e.parent))),e.__policy=s,s},_onRecords(e){let t=A(e);t.length&&(this._fanOutRaw(t),this._handleMutations(t))},_fanOutRaw(e){if(!(!this._rawSubscribers.length||!e.length))for(let t of this._rawSubscribers)try{t.cb(e)}catch(s){this._log("Error in raw subscriber callback:",s,"error"),console.error("Error in Mutation raw subscriber:",s)}},_drainBrowserQueue(e){let t=A(this._observer?this._observer.takeRecords():[]),s=!!e&&this._rawSubscribers.indexOf(e)!==-1;if(t.length){for(let r of this._rawSubscribers)r!==e&&(r.buffer.push(...t),this._scheduleBufferFlush(r));s?this._deferChangeLane(t):this._hasNonPausable&&this._processMutations(t,!0)}if(s){let r=e.buffer;return e.buffer=[],r.length?r.concat(t):t}return t},_scheduleBufferFlush(e){e._flushScheduled||(e._flushScheduled=!0,queueMicrotask(()=>{if(e._flushScheduled=!1,!e.buffer.length)return;let t=e.buffer;e.buffer=[];try{e.cb(t)}catch(s){this._log("Error in raw subscriber flush:",s,"error"),console.error("Error in Mutation raw subscriber:",s)}}))},_deferChangeLane(e){this._deferredChangeRecords||(this._deferredChangeRecords=[]),this._deferredChangeRecords.push(...e),!this._deferredChangeScheduled&&(this._deferredChangeScheduled=!0,queueMicrotask(()=>{this._deferredChangeScheduled=!1;let t=this._deferredChangeRecords;this._deferredChangeRecords=null,t&&t.length&&this._handleMutations(t)}))},subscribeRaw(e){let t={cb:e,buffer:[],_flushScheduled:!1};return this._rawSubscribers.push(t),this._startObserving(),{drain:()=>this._drainBrowserQueue(t),unsubscribe:()=>{let s=this._rawSubscribers.indexOf(t);s!==-1&&this._rawSubscribers.splice(s,1)}}},createObserver(e){let t=null;return{observe:s=>{if(s!==document.body)throw new Error("Mutation.createObserver only supports observing document.body");this._startObserving(),t||(t=this.subscribeRaw(e))},disconnect:()=>{t&&(t.unsubscribe(),t=null)},takeRecords:()=>t?t.drain():[]}},_handleMutations(e){if(this._pauseDepth>0){if(!this._hasNonPausable){this._log(`Skipping ${e.length} mutations (paused)`);return}this._processMutations(e,!0);return}this._processMutations(e,!1)},_processMutations(e,t=!1){let s=[],r={add:[],remove:[],attribute:[],characterData:[]};for(let i of e){let u=i.type==="attributes"&&w(i.attributeName);if(!(!u&&_(i.target))&&!(i.type==="attributes"&&i.attributeName&&E.test(i.attributeName.toLowerCase()))){if(i.type==="characterData"){this._log("Processing characterData mutation",{element:i.target.parentElement,oldValue:i.oldValue,newValue:i.target.textContent});let l={type:"characterData",element:i.target.parentElement??P,oldValue:i.oldValue,newValue:i.target.textContent};s.push(l),r.characterData.push(l)}if(i.type==="childList"){this._log("Processing childList mutation",{addedNodes:i.addedNodes,removedNodes:i.removedNodes});for(let n of i.addedNodes)if(n.nodeType===1&&!_(n)){let c=[n,...n.querySelectorAll("*")];this._log(`Processing ${c.length} added nodes`,{addedNodes:c});for(let h of c){let d={type:"add",element:h,parent:i.target,previousSibling:i.previousSibling,nextSibling:i.nextSibling};s.push(d),r.add.push(d)}}for(let n of i.removedNodes)if(n.nodeType===1&&!_(n)){let c=[n,...n.querySelectorAll("*")];this._log(`Processing ${c.length} removed nodes`,{removedNodes:c});for(let h of c){let d={type:"remove",element:h,parent:i.target,previousSibling:i.previousSibling,nextSibling:i.nextSibling};s.push(d),r.remove.push(d)}}let l=!1;for(let n of i.addedNodes)if(n.nodeType===3){l=!0;break}if(!l){for(let n of i.removedNodes)if(n.nodeType===3){l=!0;break}}if(l&&i.target.nodeType===1){let n={type:"characterData",element:i.target,oldValue:void 0,newValue:i.target.textContent};s.push(n),r.characterData.push(n)}}if(i.type==="attributes"){this._log("Processing attribute mutation",{element:i.target,attribute:i.attributeName,oldValue:i.oldValue,newValue:i.target.getAttribute(i.attributeName)});let l={type:"attribute",element:i.target,attribute:i.attributeName,oldValue:i.oldValue,newValue:i.target.getAttribute(i.attributeName),policyTransition:u,previousPolicy:u?F(i):null};s.push(l),r.attribute.push(l)}}}if(s.length){if(this._log("Processing collected changes",{total:s.length,byType:{add:r.add.length,remove:r.remove.length,attribute:r.attribute.length}}),!t&&O()){for(let u of s)if(!v(u)&&!m(this._policyForChange(u),"dirty")){N();break}}this._notify("anyChange",s,t);let i=[...r.add,...r.remove];i.length&&this._notify("addOrRemove",i,t),r.add.length&&this._notify("addElement",r.add,t),r.remove.length&&this._notify("removeElement",r.remove,t),r.attribute.length&&this._notify("attribute",r.attribute,t)}},_observer:null,_initializeObserver(){this._observer||(this._log("Initializing MutationObserver"),this._observer=new MutationObserver(this._onRecords.bind(this)))},_addCallback(e,t={},s){this._log("Adding callback",{type:e,options:t}),t.debug&&(this.debug=!0);let r={fn:s,debounce:t.debounce||0,maxWait:t.maxWait||0,selectorFilter:t.selectorFilter,omitChangeDetails:t.omitChangeDetails,require:t.require,skip:t.skip,pausable:t.pausable!==!1,timeout:null,pendingChanges:null,firstPendingAt:null};return this._callbacks[e].push(r),this._recomputeHasNonPausable(),this._log(`Added callback to ${e}. Total callbacks:`,{[e]:this._callbacks[e].length}),this._startObserving(),()=>{this._log("Removing callback",{type:e});let i=this._callbacks[e].indexOf(r);i!==-1&&(clearTimeout(r.timeout),r.pendingChanges=null,this._callbacks[e].splice(i,1),this._recomputeHasNonPausable(),this._log(`Removed callback from ${e}. Remaining callbacks:`,{[e]:this._callbacks[e].length}))}},_recomputeHasNonPausable(){this._hasNonPausable=Object.values(this._callbacks).some(e=>e.some(t=>t.pausable===!1))},_startObserving(){if(this._observing){this._log("Already observing, skipping initialization");return}this._log("Starting observation"),this._initializeObserver(),this._observer.observe(document.documentElement,{childList:!0,attributes:!0,subtree:!0,characterData:!0,attributeOldValue:!0,characterDataOldValue:!0}),this._observing=!0,this._log("Observation started")},onAnyChange(e={},t){return this._addCallback("anyChange",e,t)},onAddOrRemove(e={},t){return this._addCallback("addOrRemove",e,t)},onAddElement(e={},t){return this._addCallback("addElement",e,t)},onRemoveElement(e={},t){return this._addCallback("removeElement",e,t)},onAttribute(e={},t){return this._addCallback("attribute",e,t)},ensureObserving(){this._startObserving()}},D=typeof window<"u"&&window.__clayMutation,p=D||V;if(typeof window<"u"&&!D){window.__clayMutation=p,window.clay=window.clay||{},window.clay.Mutation=p;try{document.dispatchEvent(new CustomEvent("clay:mutation-ready",{detail:{Mutation:p}}))}catch{}}var B=p;function F(e){let t=e.target,s=t.cloneNode(!1),r=s;for(;t.parentElement;){t=t.parentElement;let i=t.cloneNode(!1);i.appendChild(s),s=i}return e.oldValue==null?r.removeAttribute(e.attributeName):r.setAttribute(e.attributeName,e.oldValue),g(r)}export{B as a,L as b};
1
+ import{b as O,c as N}from"./c-IJUK2GPW.js";import{f as v}from"./c-MOP5KBWZ.js";import{a as y,h as k,j as C,k as R}from"./c-HA6INT6J.js";import{b as E,s as g,t as _,u as S,v as m}from"./c-ICMAOOGK.js";import{g as w}from"./c-WRBKEJD4.js";import{a as M}from"./c-VHNSBD2M.js";var L={};M(L,{default:()=>B});var P=document.createElement("div"),x=new Set(k);function T(e){if(e.type!=="attributes")return!1;let t=e.attributeName;return t===R||y(t,e.target)?!0:e.target===document.documentElement&&(x.has(t)||t.startsWith(C))}function A(e){return e.some(T)?e.filter(t=>!T(t)):e}var V={_callbacks:{anyChange:[],addOrRemove:[],addElement:[],removeElement:[],attribute:[]},_observing:!1,_pauseDepth:0,_hasNonPausable:!1,debug:!1,_rawSubscribers:[],_deferredChangeRecords:null,_deferredChangeScheduled:!1,pause(){this._pauseDepth===0&&this._deliverBeforePause(),this._pauseDepth++,typeof window<"u"&&window.clay?.undo?.pause&&window.clay.undo.pause(),this._log("Paused",this._pauseDepth)},_deliverBeforePause(){if(!this._observer)return;let e=this._observer.takeRecords();e.length&&this._onRecords(e)},dropQueued(){this._observer&&this._drainBrowserQueue(this)},resume(){this._pauseDepth!==0&&(this._pauseDepth--,this._pauseDepth===0&&this._observer&&this._drainBrowserQueue(this),typeof window<"u"&&window.clay?.undo?.resume&&window.clay.undo.resume(),this._log("Resumed",this._pauseDepth))},_log(e,t=null,s="log"){if(!this.debug)return;let i=`[Mutation ${new Date().toISOString()}]`;t?console[s](i,e,t):console[s](i,e)},_notify(e,t,s=!1){this._log(`Notifying ${this._callbacks[e].length} callbacks of type "${e}"`,{changes:t});for(let r of this._callbacks[e]){if(s&&r.pausable!==!1)continue;let{fn:i,debounce:u=0,maxWait:l=0,selectorFilter:n,omitChangeDetails:c,require:h,skip:d}=r,f=t.filter(o=>{if(h!=="observed"&&v(o))return!1;let a=m(this._policyForChange(o),h,d);if(!o.policyTransition)return!a;let b=m(o.previousPolicy,h,d);return!(a&&b)});if(!f.length){this._log("No changes passed the region policy, skipping callback");continue}if(n&&(this._log("Applying selector filter",{selectorFilter:n}),f=f.filter(o=>{if(typeof n=="string"){let a=o.element.matches?.(n)||!1;return this._log(`Selector "${n}" match:`,{element:o.element,matches:a}),a}if(typeof n=="function"){let a=n(o.element);return this._log("Custom filter match:",{element:o.element,matches:a}),a}return!1}),this._log("Changes after filtering:",{filteredChanges:f})),!f.length){this._log("No changes passed the filter, skipping callback");continue}if(u===0)try{c?i():i(f)}catch(o){this._log("Error in callback execution:",o,"error"),console.error("Error in Mutation callback:",o)}else{r.timeout&&(clearTimeout(r.timeout),r.timeout=null),r.firstPendingAt||(r.firstPendingAt=Date.now());let o=l>0?Math.max(0,Math.min(u,l-(Date.now()-r.firstPendingAt))):u;c?r.timeout=setTimeout(()=>{r.timeout=null,r.firstPendingAt=null;try{this._log("Executing debounced callback (no details)"),i()}catch(a){this._log("Error in callback execution:",a,"error"),console.error("Error in Mutation callback:",a)}},o):(r.pendingChanges||(r.pendingChanges=[]),r.pendingChanges.push(...f),r.timeout=setTimeout(()=>{let a=r.pendingChanges;r.pendingChanges=null,r.timeout=null,r.firstPendingAt=null;try{this._log("Executing debounced callback with changes:",{changes:a}),a&&a.length>0&&i(a)}catch(b){this._log("Error in callback execution:",b,"error"),console.error("Error in Mutation callback:",b)}},o))}}},_policyForChange(e){if(e.__policy)return e.__policy;let t=e.element,s=g(t);return e.parent&&t&&t.isConnected===!1&&(s=S(s,g(e.parent))),e.__policy=s,s},_onRecords(e){let t=A(e);t.length&&(this._fanOutRaw(t),this._handleMutations(t))},_fanOutRaw(e){if(!(!this._rawSubscribers.length||!e.length))for(let t of this._rawSubscribers)try{t.cb(e)}catch(s){this._log("Error in raw subscriber callback:",s,"error"),console.error("Error in Mutation raw subscriber:",s)}},_drainBrowserQueue(e){let t=A(this._observer?this._observer.takeRecords():[]),s=!!e&&this._rawSubscribers.indexOf(e)!==-1;if(t.length){for(let r of this._rawSubscribers)r!==e&&(r.buffer.push(...t),this._scheduleBufferFlush(r));s?this._deferChangeLane(t):this._hasNonPausable&&this._processMutations(t,!0)}if(s){let r=e.buffer;return e.buffer=[],r.length?r.concat(t):t}return t},_scheduleBufferFlush(e){e._flushScheduled||(e._flushScheduled=!0,queueMicrotask(()=>{if(e._flushScheduled=!1,!e.buffer.length)return;let t=e.buffer;e.buffer=[];try{e.cb(t)}catch(s){this._log("Error in raw subscriber flush:",s,"error"),console.error("Error in Mutation raw subscriber:",s)}}))},_deferChangeLane(e){this._deferredChangeRecords||(this._deferredChangeRecords=[]),this._deferredChangeRecords.push(...e),!this._deferredChangeScheduled&&(this._deferredChangeScheduled=!0,queueMicrotask(()=>{this._deferredChangeScheduled=!1;let t=this._deferredChangeRecords;this._deferredChangeRecords=null,t&&t.length&&this._handleMutations(t)}))},subscribeRaw(e){let t={cb:e,buffer:[],_flushScheduled:!1};return this._rawSubscribers.push(t),this._startObserving(),{drain:()=>this._drainBrowserQueue(t),unsubscribe:()=>{let s=this._rawSubscribers.indexOf(t);s!==-1&&this._rawSubscribers.splice(s,1)}}},createObserver(e){let t=null;return{observe:s=>{if(s!==document.body)throw new Error("Mutation.createObserver only supports observing document.body");this._startObserving(),t||(t=this.subscribeRaw(e))},disconnect:()=>{t&&(t.unsubscribe(),t=null)},takeRecords:()=>t?t.drain():[]}},_handleMutations(e){if(this._pauseDepth>0){if(!this._hasNonPausable){this._log(`Skipping ${e.length} mutations (paused)`);return}this._processMutations(e,!0);return}this._processMutations(e,!1)},_processMutations(e,t=!1){let s=[],r={add:[],remove:[],attribute:[],characterData:[]};for(let i of e){let u=i.type==="attributes"&&w(i.attributeName);if(!(!u&&_(i.target))&&!(i.type==="attributes"&&i.attributeName&&E.test(i.attributeName.toLowerCase()))){if(i.type==="characterData"){this._log("Processing characterData mutation",{element:i.target.parentElement,oldValue:i.oldValue,newValue:i.target.textContent});let l={type:"characterData",element:i.target.parentElement??P,oldValue:i.oldValue,newValue:i.target.textContent};s.push(l),r.characterData.push(l)}if(i.type==="childList"){this._log("Processing childList mutation",{addedNodes:i.addedNodes,removedNodes:i.removedNodes});for(let n of i.addedNodes)if(n.nodeType===1&&!_(n)){let c=[n,...n.querySelectorAll("*")];this._log(`Processing ${c.length} added nodes`,{addedNodes:c});for(let h of c){let d={type:"add",element:h,parent:i.target,previousSibling:i.previousSibling,nextSibling:i.nextSibling};s.push(d),r.add.push(d)}}for(let n of i.removedNodes)if(n.nodeType===1&&!_(n)){let c=[n,...n.querySelectorAll("*")];this._log(`Processing ${c.length} removed nodes`,{removedNodes:c});for(let h of c){let d={type:"remove",element:h,parent:i.target,previousSibling:i.previousSibling,nextSibling:i.nextSibling};s.push(d),r.remove.push(d)}}let l=!1;for(let n of i.addedNodes)if(n.nodeType===3){l=!0;break}if(!l){for(let n of i.removedNodes)if(n.nodeType===3){l=!0;break}}if(l&&i.target.nodeType===1){let n={type:"characterData",element:i.target,oldValue:void 0,newValue:i.target.textContent};s.push(n),r.characterData.push(n)}}if(i.type==="attributes"){this._log("Processing attribute mutation",{element:i.target,attribute:i.attributeName,oldValue:i.oldValue,newValue:i.target.getAttribute(i.attributeName)});let l={type:"attribute",element:i.target,attribute:i.attributeName,oldValue:i.oldValue,newValue:i.target.getAttribute(i.attributeName),policyTransition:u,previousPolicy:u?F(i):null};s.push(l),r.attribute.push(l)}}}if(s.length){if(this._log("Processing collected changes",{total:s.length,byType:{add:r.add.length,remove:r.remove.length,attribute:r.attribute.length}}),!t&&O()){for(let u of s)if(!v(u)&&!m(this._policyForChange(u),"dirty")){N();break}}this._notify("anyChange",s,t);let i=[...r.add,...r.remove];i.length&&this._notify("addOrRemove",i,t),r.add.length&&this._notify("addElement",r.add,t),r.remove.length&&this._notify("removeElement",r.remove,t),r.attribute.length&&this._notify("attribute",r.attribute,t)}},_observer:null,_initializeObserver(){this._observer||(this._log("Initializing MutationObserver"),this._observer=new MutationObserver(this._onRecords.bind(this)))},_addCallback(e,t={},s){this._log("Adding callback",{type:e,options:t}),t.debug&&(this.debug=!0);let r={fn:s,debounce:t.debounce||0,maxWait:t.maxWait||0,selectorFilter:t.selectorFilter,omitChangeDetails:t.omitChangeDetails,require:t.require,skip:t.skip,pausable:t.pausable!==!1,timeout:null,pendingChanges:null,firstPendingAt:null};return this._callbacks[e].push(r),this._recomputeHasNonPausable(),this._log(`Added callback to ${e}. Total callbacks:`,{[e]:this._callbacks[e].length}),this._startObserving(),()=>{this._log("Removing callback",{type:e});let i=this._callbacks[e].indexOf(r);i!==-1&&(clearTimeout(r.timeout),r.pendingChanges=null,this._callbacks[e].splice(i,1),this._recomputeHasNonPausable(),this._log(`Removed callback from ${e}. Remaining callbacks:`,{[e]:this._callbacks[e].length}))}},_recomputeHasNonPausable(){this._hasNonPausable=Object.values(this._callbacks).some(e=>e.some(t=>t.pausable===!1))},_startObserving(){if(this._observing){this._log("Already observing, skipping initialization");return}this._log("Starting observation"),this._initializeObserver(),this._observer.observe(document.documentElement,{childList:!0,attributes:!0,subtree:!0,characterData:!0,attributeOldValue:!0,characterDataOldValue:!0}),this._observing=!0,this._log("Observation started")},onAnyChange(e={},t){return this._addCallback("anyChange",e,t)},onAddOrRemove(e={},t){return this._addCallback("addOrRemove",e,t)},onAddElement(e={},t){return this._addCallback("addElement",e,t)},onRemoveElement(e={},t){return this._addCallback("removeElement",e,t)},onAttribute(e={},t){return this._addCallback("attribute",e,t)},ensureObserving(){this._startObserving()}},D=typeof window<"u"&&window.__clayMutation,p=D||V;if(typeof window<"u"&&!D){window.__clayMutation=p,window.clay=window.clay||{},window.clay.Mutation=p;try{document.dispatchEvent(new CustomEvent("clay:mutation-ready",{detail:{Mutation:p}}))}catch{}}var B=p;function F(e){let t=e.target,s=t.cloneNode(!1),r=s;for(;t.parentElement;){t=t.parentElement;let i=t.cloneNode(!1);i.appendChild(s),s=i}return e.oldValue==null?r.removeAttribute(e.attributeName):r.setAttribute(e.attributeName,e.oldValue),g(r)}export{B as a,L as b};
@@ -1,4 +1,4 @@
1
- import{a as u,b as m,c as b,d as k}from"./c-Y6F2FORL.js";import{b as y}from"./c-QY7F6EN6.js";import{d as v}from"./c-PKCCHJ5X.js";import{b as g}from"./c-EDE45NM7.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4NTUVDZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var A=.8,c={draft:"You're seeing a private draft, like a visitor.",draftAction:"Edit the original",edit:"You're editing the original. Visitors get these changes.",editAction:"Back to my draft",close:"Hide this note"},L=`.clay-owner {
1
+ import{a as u,b as m,c as b,d as k}from"./c-Y6F2FORL.js";import{b as y}from"./c-QY7F6EN6.js";import{d as v}from"./c-PKCCHJ5X.js";import{b as g}from"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var A=.8,c={draft:"You're seeing a private draft, like a visitor.",draftAction:"Edit the original",edit:"You're editing the original. Visitors get these changes.",editAction:"Back to my draft",close:"Hide this note"},L=`.clay-owner {
2
2
  --hcp-surface: light-dark(#FFFCF6, #11131E);
3
3
  --hcp-ground: var(--bevel-surface, var(--hcp-surface));
4
4
  --hcp-ink: light-dark(#2B241B, #ECEAF2);
@@ -1 +1 @@
1
- import{a as d}from"./c-BKM46LUJ.js";import{d as h,h as p,w as g}from"./c-ZRGEN6QQ.js";import{E as u,X as c,d as m,ea as f}from"./c-OH2FPYSY.js";import{b as l}from"./c-RETTCOWO.js";import"./c-VHNSBD2M.js";var{TextSelection:b}=l;function T(r,t){let e=p(r.state.doc),n=e.findIndex(o=>o.node.attrs.id===t);if(n<0)return h(r,"That link's block is gone"),null;let s=[];for(let o=e[n].up;o>=0;o=e[o].up)e[o].node.type===m.nodes.toggle&&!e[o].open&&s.push(e[o].node.attrs.id);let i=r.state.tr.setSelection(b.create(r.state.doc,e[n].at+1)).setMeta("addToHistory",!1);return r.dispatch(g(i,s).scrollIntoView()),e[n]}var a=class{constructor(t,e){this.node=t,this.view=e,this.doc=e.state.doc;let n=e.dom.ownerDocument;this.dom=n.createElement("div"),this.dom.className="blockeditor-toc",this.dom.contentEditable="false",this.dom.setAttribute("role","group"),this.dom.setAttribute("aria-label","Table of contents"),this.dom.addEventListener("mousedown",s=>{s.target.closest?.("a")&&s.preventDefault()}),this.dom.addEventListener("click",s=>{let i=s.target.closest?.("a");if(!i)return;s.preventDefault();let o=d(i.getAttribute("href"));o!==null&&T(this.view,o)}),this.render()}update(t){return this.node=t,this.view.state.doc!==this.doc&&(this.doc=this.view.state.doc,this.render()),!0}render(){let t=c(this.node.attrs,f(u(this.doc)));this.dom.innerHTML!==t&&(this.dom.innerHTML=t)}stopEvent(t){return!!t.target.closest?.("a")}ignoreMutation(){return!0}};function I(){return{id:"toc",nodeViews:{toc:(r,t)=>new a(r,t)},css:null,dispose(){}}}export{a as TocView,I as createFeature,T as followTocLink};
1
+ import{a as d}from"./c-BKM46LUJ.js";import{d as h,h as p,w as g}from"./c-AI3H6ETU.js";import{E as u,X as c,d as m,ea as f}from"./c-OH2FPYSY.js";import{b as l}from"./c-RETTCOWO.js";import"./c-VHNSBD2M.js";var{TextSelection:b}=l;function T(r,t){let e=p(r.state.doc),n=e.findIndex(o=>o.node.attrs.id===t);if(n<0)return h(r,"That link's block is gone"),null;let s=[];for(let o=e[n].up;o>=0;o=e[o].up)e[o].node.type===m.nodes.toggle&&!e[o].open&&s.push(e[o].node.attrs.id);let i=r.state.tr.setSelection(b.create(r.state.doc,e[n].at+1)).setMeta("addToHistory",!1);return r.dispatch(g(i,s).scrollIntoView()),e[n]}var a=class{constructor(t,e){this.node=t,this.view=e,this.doc=e.state.doc;let n=e.dom.ownerDocument;this.dom=n.createElement("div"),this.dom.className="blockeditor-toc",this.dom.contentEditable="false",this.dom.setAttribute("role","group"),this.dom.setAttribute("aria-label","Table of contents"),this.dom.addEventListener("mousedown",s=>{s.target.closest?.("a")&&s.preventDefault()}),this.dom.addEventListener("click",s=>{let i=s.target.closest?.("a");if(!i)return;s.preventDefault();let o=d(i.getAttribute("href"));o!==null&&T(this.view,o)}),this.render()}update(t){return this.node=t,this.view.state.doc!==this.doc&&(this.doc=this.view.state.doc,this.render()),!0}render(){let t=c(this.node.attrs,f(u(this.doc)));this.dom.innerHTML!==t&&(this.dom.innerHTML=t)}stopEvent(t){return!!t.target.closest?.("a")}ignoreMutation(){return!0}};function I(){return{id:"toc",nodeViews:{toc:(r,t)=>new a(r,t)},css:null,dispose(){}}}export{a as TocView,I as createFeature,T as followTocLink};
@@ -1 +1 @@
1
- import{a as f,b as u}from"./c-7SWMYKAI.js";import{b as l}from"./c-UGHH4MB3.js";import{a as s}from"./c-LA2BW7UY.js";var c=(t=[])=>i=>{let e=(i.getAttribute("clay")??"").split(/\s+/).filter(Boolean),n=["no-dirty",...t].filter(r=>!e.includes(r));n.length&&i.setAttribute("clay",[...e,...n].join(" "))},p=c();function S(t,i){return y(t,i)}function b(t,i,e,n=[]){return y(t,i,e,n)}function y(t,i,e,n=[]){let r=typeof i=="string",a=r?{name:t,legacyId:e}:{href:f(t)},d=e===void 0?[]:document.querySelectorAll(`style[id="${e}"]:not([data-name])`);s.pause();try{l(a);for(let o of d)o.dataset.name=t;if(r){let o=u(t,i,c(n));return e!==void 0&&(o.id=e),o}return u(t,o=>{p(o),o.getAttribute("href")!==t&&o.setAttribute("href",t)})}finally{s.resume()}}export{S as a,b};
1
+ import{a as f,b as u}from"./c-7SWMYKAI.js";import{b as l}from"./c-UGHH4MB3.js";import{a as s}from"./c-MZCOGNZL.js";var c=(t=[])=>i=>{let e=(i.getAttribute("clay")??"").split(/\s+/).filter(Boolean),n=["no-dirty",...t].filter(r=>!e.includes(r));n.length&&i.setAttribute("clay",[...e,...n].join(" "))},p=c();function S(t,i){return y(t,i)}function b(t,i,e,n=[]){return y(t,i,e,n)}function y(t,i,e,n=[]){let r=typeof i=="string",a=r?{name:t,legacyId:e}:{href:f(t)},d=e===void 0?[]:document.querySelectorAll(`style[id="${e}"]:not([data-name])`);s.pause();try{l(a);for(let o of d)o.dataset.name=t;if(r){let o=u(t,i,c(n));return e!==void 0&&(o.id=e),o}return u(t,o=>{p(o),o.getAttribute("href")!==t&&o.setAttribute("href",t)})}finally{s.resume()}}export{S as a,b};
@@ -1 +1 @@
1
- import{a as _,d as v}from"./c-WN3MXOLT.js";import{b as c}from"./c-RVMWGXEJ.js";import{b as u,c as s}from"./c-NUHP2XDB.js";import{e as b}from"./c-QQFHEODI.js";import"./c-EDE45NM7.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4NTUVDZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var d="#FFFCF6",l=["all:initial","color-scheme:inherit","direction:ltr","unicode-bidi:isolate"],y=18,h=3,p=null,f=null;function C(){return f??=Promise.all([import("./c-TFLRT5JX.js"),import("./c-46LJAZZJ.js")]).then(([i,e])=>p={RUNTIME_ONLY:i.RUNTIME_ONLY,CHIP_FONT:`600 11px/16px ${e.FONT_MONO}`}).catch(i=>{throw f=null,i}),f}var $=()=>C().then(()=>!0,()=>!1);function a(i){return i.setAttribute("clay",p.RUNTIME_ONLY),i}function A(i){let e=i&&Array.isArray(i.people)?i.people:[],o=[];for(let t of e){if(!t||t.you===!0||typeof t.id!="string"||!t.id||typeof t.editing!="string"||!_.test(t.editing))continue;let n=typeof t.name=="string"&&t.name.trim()?t.name.trim():"Someone";o.push({id:t.id,name:n,path:t.editing})}return o}var m=class{constructor(){this.editors=[],this.root=null,this._gate=null,this._frame=0,this._following=!1,this._onMove=()=>this.schedule()}supported(){return this._gate||(this._gate=b("presence").then(e=>e===!0,()=>!1)),this._gate}async update(e){this.editors=A(e),await this.supported()&&await this.render()}clear(){this.editors=[],this.follow(!1),this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this.root&&this.root.remove(),this.root=null}schedule(){this._frame||(this._frame=requestAnimationFrame(()=>{this._frame=0,this.render()}))}render(){return p?(this.paint(),Promise.resolve()):$().then(e=>{e&&this.paint()})}paint(){let e=new Map;for(let t of this.editors){let n=v(t.path);n&&(e.has(n)||e.set(n,[]),e.get(n).push(t))}let o=[];for(let[t,n]of e){let r=this.box(t,n);r&&o.push(r)}if(!o.length){this.root&&(this.root.textContent="",u(this.root,"display","none")),this.follow(this.editors.length>0);return}this.build()&&(this.root.textContent="",this.root.append(...o),u(this.root,"display","block"),this.follow(!0))}box(e,o){let t=e.getBoundingClientRect();if(!(t.width||t.height))return null;let n=c(o[0].id),r=a(s("div",[...l,"position:fixed","box-sizing:border-box","pointer-events:none",`top:${Math.round(t.top-h)}px`,`left:${Math.round(t.left-h)}px`,`width:${Math.round(t.width+h*2)}px`,`height:${Math.round(t.height+h*2)}px`,`border:2px solid ${n}`,`box-shadow:0 0 0 1px ${d}, inset 0 0 0 1px ${d}`]));r.setAttribute("data-clay-editing-marker","");let M=t.top-h>=y+2,x=a(s("div",[...l,"position:absolute","left:-2px",M?"bottom:100%":"top:100%","display:flex","gap:2px","pointer-events:none"]));for(let g of o){let w=a(s("span",[...l,"box-sizing:border-box",`height:${y}px`,"padding:1px 6px",`font:${p.CHIP_FONT}`,"letter-spacing:.02em","white-space:nowrap","max-width:180px","overflow:hidden","text-overflow:ellipsis",`background-color:${c(g.id)}`,`color:${d}`,`box-shadow:0 0 0 1px ${d}`],g.name));w.setAttribute("data-clay-editing-chip",""),x.appendChild(w)}return r.appendChild(x),r}build(){return this.root&&this.root.isConnected?!0:typeof document>"u"||!document.body?!1:(this.root=a(s("div",[...l,"position:fixed","top:0","left:0","width:0","height:0","overflow:visible","z-index:2147482999","pointer-events:none","display:none"])),this.root.setAttribute("data-clay-editing",""),document.body.appendChild(this.root),!0)}follow(e){if(typeof window>"u"||!!e===this._following)return;this._following=!!e;let o=e?"addEventListener":"removeEventListener";window[o]("scroll",this._onMove,{capture:!0,passive:!0}),window[o]("resize",this._onMove,{passive:!0}),document[o]("input",this._onMove),document[o]("clay:sync-applied",this._onMove)}},N=new m;var O=N;export{m as EditingMarker,O as default,N as editingMarker};
1
+ import{a as _,d as v}from"./c-WN3MXOLT.js";import{b as c}from"./c-RVMWGXEJ.js";import{b as u,c as s}from"./c-NUHP2XDB.js";import{e as b}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-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var d="#FFFCF6",l=["all:initial","color-scheme:inherit","direction:ltr","unicode-bidi:isolate"],y=18,h=3,p=null,f=null;function C(){return f??=Promise.all([import("./c-TFLRT5JX.js"),import("./c-46LJAZZJ.js")]).then(([i,e])=>p={RUNTIME_ONLY:i.RUNTIME_ONLY,CHIP_FONT:`600 11px/16px ${e.FONT_MONO}`}).catch(i=>{throw f=null,i}),f}var $=()=>C().then(()=>!0,()=>!1);function a(i){return i.setAttribute("clay",p.RUNTIME_ONLY),i}function A(i){let e=i&&Array.isArray(i.people)?i.people:[],o=[];for(let t of e){if(!t||t.you===!0||typeof t.id!="string"||!t.id||typeof t.editing!="string"||!_.test(t.editing))continue;let n=typeof t.name=="string"&&t.name.trim()?t.name.trim():"Someone";o.push({id:t.id,name:n,path:t.editing})}return o}var m=class{constructor(){this.editors=[],this.root=null,this._gate=null,this._frame=0,this._following=!1,this._onMove=()=>this.schedule()}supported(){return this._gate||(this._gate=b("presence").then(e=>e===!0,()=>!1)),this._gate}async update(e){this.editors=A(e),await this.supported()&&await this.render()}clear(){this.editors=[],this.follow(!1),this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this.root&&this.root.remove(),this.root=null}schedule(){this._frame||(this._frame=requestAnimationFrame(()=>{this._frame=0,this.render()}))}render(){return p?(this.paint(),Promise.resolve()):$().then(e=>{e&&this.paint()})}paint(){let e=new Map;for(let t of this.editors){let n=v(t.path);n&&(e.has(n)||e.set(n,[]),e.get(n).push(t))}let o=[];for(let[t,n]of e){let r=this.box(t,n);r&&o.push(r)}if(!o.length){this.root&&(this.root.textContent="",u(this.root,"display","none")),this.follow(this.editors.length>0);return}this.build()&&(this.root.textContent="",this.root.append(...o),u(this.root,"display","block"),this.follow(!0))}box(e,o){let t=e.getBoundingClientRect();if(!(t.width||t.height))return null;let n=c(o[0].id),r=a(s("div",[...l,"position:fixed","box-sizing:border-box","pointer-events:none",`top:${Math.round(t.top-h)}px`,`left:${Math.round(t.left-h)}px`,`width:${Math.round(t.width+h*2)}px`,`height:${Math.round(t.height+h*2)}px`,`border:2px solid ${n}`,`box-shadow:0 0 0 1px ${d}, inset 0 0 0 1px ${d}`]));r.setAttribute("data-clay-editing-marker","");let M=t.top-h>=y+2,x=a(s("div",[...l,"position:absolute","left:-2px",M?"bottom:100%":"top:100%","display:flex","gap:2px","pointer-events:none"]));for(let g of o){let w=a(s("span",[...l,"box-sizing:border-box",`height:${y}px`,"padding:1px 6px",`font:${p.CHIP_FONT}`,"letter-spacing:.02em","white-space:nowrap","max-width:180px","overflow:hidden","text-overflow:ellipsis",`background-color:${c(g.id)}`,`color:${d}`,`box-shadow:0 0 0 1px ${d}`],g.name));w.setAttribute("data-clay-editing-chip",""),x.appendChild(w)}return r.appendChild(x),r}build(){return this.root&&this.root.isConnected?!0:typeof document>"u"||!document.body?!1:(this.root=a(s("div",[...l,"position:fixed","top:0","left:0","width:0","height:0","overflow:visible","z-index:2147482999","pointer-events:none","display:none"])),this.root.setAttribute("data-clay-editing",""),document.body.appendChild(this.root),!0)}follow(e){if(typeof window>"u"||!!e===this._following)return;this._following=!!e;let o=e?"addEventListener":"removeEventListener";window[o]("scroll",this._onMove,{capture:!0,passive:!0}),window[o]("resize",this._onMove,{passive:!0}),document[o]("input",this._onMove),document[o]("clay:sync-applied",this._onMove)}},N=new m;var O=N;export{m as EditingMarker,O as default,N as editingMarker};
@@ -1 +1 @@
1
- import{a as T,b as x,c as m,d as D,e as P}from"./c-IW6GGOU2.js";import{a as y}from"./c-HAWFNBYG.js";import{b}from"./c-RETTCOWO.js";import{a as f}from"./c-LA2BW7UY.js";var E="\uFFFC";function g(t){let r=[];for(let s=0;s<t.childCount;s++){let n=t.child(s);if(n.type.name!=="heading"||n.attrs.level!==1||(n.attrs.parent??null)!==null)continue;let o="";n.forEach(l=>{o+=l.isText?l.text:l.type.name==="hard_break"?E:""}),r.push({t:"heading",level:1,parent:null,c:o});break}return r}function d(t){if(!t||t.isDestroyed)return null;let r=t.dom?.ownerDocument??(typeof document>"u"?null:document);if(!r)return null;let s=g(t.state.doc),{custom:n,title:o}=P(r,s);if(n)return o;let l=m(r);if(l===""&&!s.length||l===o)return o;f.pause();try{D(r,o)}finally{f.resume()}return o}function L(t){let r=t?.dom?.ownerDocument??null;if(!r||T(r)||g(t.state.doc).length||["",y].includes(m(r).trim()))return!1;f.pause();try{return x(r)}finally{f.resume()}}function C(){return new b.Plugin({view(t){let r=null,s=()=>{r=t.state.doc,d(t)};return L(t),s(),{update(n){n.state.doc!==r&&s()}}}})}function O(t){let r=t?.dom?.ownerDocument?.head??null;if(!r)return{refresh:()=>d(t),dispose(){}};let s=!1,n=()=>{s||(s=!0,queueMicrotask(()=>{s=!1,d(t)}))},o=new MutationObserver(n);return o.observe(r,{childList:!0,characterData:!0,subtree:!0,attributeFilter:["content","name"]}),d(t),{refresh:n,dispose(){o.disconnect()}}}function I({load:t,install:r,reportError:s=n=>console.error("clayjs: an editor feature failed to load",n)}){let n=new Map,o=new Map,l=new Map,c=!1;function v(e){if(c)return Promise.reject(new Error(`page: feature loader disposed before ${e}`));let u=l.get(e);return u||(u=Promise.resolve(t(e)),l.set(e,u),u.catch(()=>{})),u}function F(e){let u=l.get(e);return u?(l.delete(e),u):t(e)}function M(e,{signal:u}={}){if(c)return Promise.reject(new Error(`page: feature loader disposed before ${e}`));if(n.has(e))return Promise.resolve(n.get(e));let i=o.get(e);return i||(i=F(e).then(a=>c?null:Promise.resolve(r(e,a))).then(a=>c?(a?.dispose?.(),a):(n.set(e,a),a)),i.catch(a=>{c||s(a,e)}).finally(()=>o.delete(e)),o.set(e,i)),u?u.aborted?Promise.reject(u.reason):new Promise((a,p)=>{let h=()=>p(u.reason);u.addEventListener("abort",h,{once:!0}),i.then(a,p).finally(()=>u.removeEventListener("abort",h))}):i}return{prepare:v,ensure:M,has:e=>n.has(e),dispose(){c=!0;for(let e of n.values())e?.dispose?.();n.clear(),o.clear(),l.clear()}}}export{C as a,O as b,I as c};
1
+ import{a as T,b as x,c as m,d as D,e as P}from"./c-IW6GGOU2.js";import{a as y}from"./c-HAWFNBYG.js";import{b}from"./c-RETTCOWO.js";import{a as f}from"./c-MZCOGNZL.js";var E="\uFFFC";function g(t){let r=[];for(let s=0;s<t.childCount;s++){let n=t.child(s);if(n.type.name!=="heading"||n.attrs.level!==1||(n.attrs.parent??null)!==null)continue;let o="";n.forEach(l=>{o+=l.isText?l.text:l.type.name==="hard_break"?E:""}),r.push({t:"heading",level:1,parent:null,c:o});break}return r}function d(t){if(!t||t.isDestroyed)return null;let r=t.dom?.ownerDocument??(typeof document>"u"?null:document);if(!r)return null;let s=g(t.state.doc),{custom:n,title:o}=P(r,s);if(n)return o;let l=m(r);if(l===""&&!s.length||l===o)return o;f.pause();try{D(r,o)}finally{f.resume()}return o}function L(t){let r=t?.dom?.ownerDocument??null;if(!r||T(r)||g(t.state.doc).length||["",y].includes(m(r).trim()))return!1;f.pause();try{return x(r)}finally{f.resume()}}function C(){return new b.Plugin({view(t){let r=null,s=()=>{r=t.state.doc,d(t)};return L(t),s(),{update(n){n.state.doc!==r&&s()}}}})}function O(t){let r=t?.dom?.ownerDocument?.head??null;if(!r)return{refresh:()=>d(t),dispose(){}};let s=!1,n=()=>{s||(s=!0,queueMicrotask(()=>{s=!1,d(t)}))},o=new MutationObserver(n);return o.observe(r,{childList:!0,characterData:!0,subtree:!0,attributeFilter:["content","name"]}),d(t),{refresh:n,dispose(){o.disconnect()}}}function I({load:t,install:r,reportError:s=n=>console.error("clayjs: an editor feature failed to load",n)}){let n=new Map,o=new Map,l=new Map,c=!1;function v(e){if(c)return Promise.reject(new Error(`page: feature loader disposed before ${e}`));let u=l.get(e);return u||(u=Promise.resolve(t(e)),l.set(e,u),u.catch(()=>{})),u}function F(e){let u=l.get(e);return u?(l.delete(e),u):t(e)}function M(e,{signal:u}={}){if(c)return Promise.reject(new Error(`page: feature loader disposed before ${e}`));if(n.has(e))return Promise.resolve(n.get(e));let i=o.get(e);return i||(i=F(e).then(a=>c?null:Promise.resolve(r(e,a))).then(a=>c?(a?.dispose?.(),a):(n.set(e,a),a)),i.catch(a=>{c||s(a,e)}).finally(()=>o.delete(e)),o.set(e,i)),u?u.aborted?Promise.reject(u.reason):new Promise((a,p)=>{let h=()=>p(u.reason);u.addEventListener("abort",h,{once:!0}),i.then(a,p).finally(()=>u.removeEventListener("abort",h))}):i}return{prepare:v,ensure:M,has:e=>n.has(e),dispose(){c=!0;for(let e of n.values())e?.dispose?.();n.clear(),o.clear(),l.clear()}}}export{C as a,O as b,I as c};
@@ -1 +1 @@
1
- import{b as a}from"./c-PZ4XEPUP.js";import{L as u}from"./c-PWJSJEJU.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import{i as s}from"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var d=20,i=null,l=!1,c=[];function h(){i||l||(l=!0,import("./c-OIDRZKAF.js").then(e=>{i=e,l=!1,f()},e=>{l=!1,console.error("clayjs: the conflict recovery module could not be downloaded; conflicts stay in this tab only",e)}))}function f(){if(!i){h();return}for(;c.length;){let e=c.shift();try{i.recordConflicts(e)}catch(o){console.error("clayjs: the conflict could not be stored for a later reload; it is still here",o)}}}function m(e,o){let t=null;try{t=a(e)}catch{}let n=r=>r?(r.cutBefore?"\u2026":"")+r.before+r.hit+r.after+(r.cutAfter?"\u2026":""):"";return{id:String(e.id),kind:String(e.kind??""),key:e.recovery?.key==null?"":String(e.recovery.key),name:t?.name?String(t.name):"",sentence:t?.sentence?String(t.sentence):"",yours:n(t?.yours),now:n(t?.now),context:o}}function y(e){try{let t=(e.recoveryRoot??e.root)?.cloneNode?.(!0);if(!t)return null;for(let n of s)t.removeAttribute(n);return u(t,{prepared:e.domain==="save"})}catch(o){return console.error("clayjs: the conflict recovery page could not be serialized; the conflict text is still stored",o),null}}function k({apply:e,records:o}){try{c.push({apply:{id:e.id,source:e.source,domain:e.domain,seq:e.seq,etag:e.etag,ticket:e.ticket},root:y(e),conflicts:o.map(({rec:t,context:n})=>m(t,n))}),c.length>d&&c.shift(),f()}catch(t){console.error("clayjs: the conflict could not be stored for a later reload; it is still here",t)}}function A(e){import("./c-OIDRZKAF.js").then(o=>o.dismissConflicts(e),()=>{}).catch(()=>{})}export{A as dismiss,k as keep};
1
+ import{b as a}from"./c-PZ4XEPUP.js";import{L as u}from"./c-PNZIJFG7.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import{i as s}from"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var d=20,i=null,l=!1,c=[];function h(){i||l||(l=!0,import("./c-OIDRZKAF.js").then(e=>{i=e,l=!1,f()},e=>{l=!1,console.error("clayjs: the conflict recovery module could not be downloaded; conflicts stay in this tab only",e)}))}function f(){if(!i){h();return}for(;c.length;){let e=c.shift();try{i.recordConflicts(e)}catch(o){console.error("clayjs: the conflict could not be stored for a later reload; it is still here",o)}}}function m(e,o){let t=null;try{t=a(e)}catch{}let n=r=>r?(r.cutBefore?"\u2026":"")+r.before+r.hit+r.after+(r.cutAfter?"\u2026":""):"";return{id:String(e.id),kind:String(e.kind??""),key:e.recovery?.key==null?"":String(e.recovery.key),name:t?.name?String(t.name):"",sentence:t?.sentence?String(t.sentence):"",yours:n(t?.yours),now:n(t?.now),context:o}}function y(e){try{let t=(e.recoveryRoot??e.root)?.cloneNode?.(!0);if(!t)return null;for(let n of s)t.removeAttribute(n);return u(t,{prepared:e.domain==="save"})}catch(o){return console.error("clayjs: the conflict recovery page could not be serialized; the conflict text is still stored",o),null}}function k({apply:e,records:o}){try{c.push({apply:{id:e.id,source:e.source,domain:e.domain,seq:e.seq,etag:e.etag,ticket:e.ticket},root:y(e),conflicts:o.map(({rec:t,context:n})=>m(t,n))}),c.length>d&&c.shift(),f()}catch(t){console.error("clayjs: the conflict could not be stored for a later reload; it is still here",t)}}function A(e){import("./c-OIDRZKAF.js").then(o=>o.dismissConflicts(e),()=>{}).catch(()=>{})}export{A as dismiss,k as keep};
@@ -0,0 +1 @@
1
+ import{a as u}from"./c-WYFDLITL.js";import{a as o}from"./c-MZCOGNZL.js";import{f as c}from"./c-C7SUMNMI.js";import{f as l}from"./c-U4TWEIKZ.js";import{n as p,o as m}from"./c-ICMAOOGK.js";var n=0,h=0,d=!1,y=!1,g=!1,f=!1;function i(){!c||f||(f=!0,queueMicrotask(()=>{if(f=!1,typeof document>"u")return;let e=C();if(e===g)return;g=e;let t=document.documentElement;e?t.setAttribute("unsaved","true"):t.removeAttribute("unsaved"),document.dispatchEvent(new CustomEvent(e?"clay:dirty":"clay:clean"))}))}var S=`input${u}, textarea${u}, select${u}`,v=`${p}, ${m}`,s=new WeakMap;function x(){let e=[];for(let t of document.querySelectorAll(S))t.closest(v)||e.push(t);return e}function E(e){let t=e.target;!t||t.nodeType!==1||(t.matches("input, textarea, select")||t.isContentEditable)&&(t.closest(v)||(n++,i()))}function T(){y||(y=!0,o.onAnyChange({omitChangeDetails:!0,require:"dirty"},()=>{d||(n++,i())}),document.addEventListener("input",E,!0),document.addEventListener("change",E,!0),l({token:w,unchangedSince:R}))}function P(){d=!0}function H(){d=!1}function a(e){return e instanceof HTMLSelectElement?Array.from(e.selectedOptions,t=>t.value).join("\0"):e instanceof HTMLInputElement&&(e.type==="checkbox"||e.type==="radio")?e.checked?"1":"0":e.value}function M(e){return e instanceof HTMLSelectElement?Array.from(e.options).every(t=>t.selected===t.defaultSelected):e instanceof HTMLInputElement?e.type==="checkbox"||e.type==="radio"?e.checked===e.defaultChecked:e.value===e.defaultValue:e instanceof HTMLTextAreaElement?e.hasAttribute("data-value")?e.value===e.getAttribute("data-value"):e.value===e.defaultValue:!0}function b(){for(let e of x()){let t=a(e);if(s.get(e)!==t){if(M(e)){s.set(e,t);continue}return!0}}return!1}function C(){return n>h||b()}function G(){return n}function A(){let e=[];for(let t of x())e.push([t,a(t)]);return{gen:n,probe:e}}function w(){return o._deliverBeforePause(),A()}function R(e){return e?(o._deliverBeforePause(),n===e.gen&&e.probe.every(([t,r])=>a(t)===r)):!1}function D(){n++,i()}function $(e){if(e){n===e.gen&&(h=e.gen);for(let[t,r]of e.probe)a(t)===r&&s.set(t,r);i()}}typeof document<"u"&&c&&T();typeof window<"u"&&(window.clay=window.clay||{},window.clay.markDirty=D);export{T as a,P as b,H as c,C as d,G as e,A as f,D as g,$ as h};