@panphora/clayjs 1.19.0 → 1.20.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 (176) 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 +8186 -8076
  11. package/dist/m/attrs/{refetch-on-save-ZUE7PSCI.js → refetch-on-save-DPGJJMGN.js} +1 -1
  12. package/dist/m/attrs/save-freeze-MTFVVYV5.js +1 -0
  13. package/dist/m/{c-DHUCEMXE.js → c-2VB555FG.js} +1 -1
  14. package/dist/m/{c-KGHVFRR3.js → c-3AXJDL2P.js} +1 -1
  15. package/dist/m/{c-FOOE4GML.js → c-3GJ4XARY.js} +1 -1
  16. package/dist/m/c-3TWCKFOP.js +1 -0
  17. package/dist/m/{c-LPCZOYTX.js → c-3YH6JSIL.js} +1 -1
  18. package/dist/m/{c-AIWN4QN4.js → c-44B5ODN7.js} +2 -2
  19. package/dist/m/{c-S2U6NJU4.js → c-62HZW5DH.js} +1 -1
  20. package/dist/m/{c-ZGDYHKG3.js → c-67ILSNPR.js} +1 -1
  21. package/dist/m/c-67LGZ52V.js +20 -0
  22. package/dist/m/{c-ZRUQ5FSU.js → c-7SXYQCN4.js} +1 -1
  23. package/dist/m/{c-LACAAQFB.js → c-AL4RBJF2.js} +1 -1
  24. package/dist/m/{c-L42OLXWM.js → c-ANNFZFLN.js} +1 -1
  25. package/dist/m/{c-QO4HNGCQ.js → c-B4VYNXTQ.js} +1 -1
  26. package/dist/m/{c-7PRJCA3E.js → c-BJPZCWAV.js} +1 -1
  27. package/dist/m/{c-V52FE5FI.js → c-BTLFLLML.js} +1 -1
  28. package/dist/m/c-C4IIQZGJ.js +1 -0
  29. package/dist/m/{c-5T6NZHNM.js → c-CAWNFER6.js} +1 -1
  30. package/dist/m/c-CSNE5EIF.js +1 -0
  31. package/dist/m/{c-DVYGFTSK.js → c-DDDOKPI6.js} +2 -2
  32. package/dist/m/{c-2RARVIAK.js → c-DHXPDLW6.js} +1 -1
  33. package/dist/m/{c-WCXLG3MV.js → c-E4IBSAQM.js} +1 -1
  34. package/dist/m/{c-IVTRVENZ.js → c-EDSPKYMA.js} +1 -1
  35. package/dist/m/{c-2Y4DOHSY.js → c-EFD6QNTE.js} +1 -1
  36. package/dist/m/{c-7MG5RU63.js → c-EGTIAL6P.js} +1 -1
  37. package/dist/m/{c-FCNAO2MI.js → c-EOCKLMKX.js} +1 -1
  38. package/dist/m/{c-UXFUJEZO.js → c-EOCZ2YVL.js} +1 -1
  39. package/dist/m/{c-K72SY2TL.js → c-EZ7B5AZT.js} +1 -1
  40. package/dist/m/{c-UPD33ZPE.js → c-FDAXZ2PM.js} +1 -1
  41. package/dist/m/{c-P3CK66NT.js → c-FNVQAACK.js} +1 -1
  42. package/dist/m/c-FSWRGBVQ.js +1 -0
  43. package/dist/m/c-FTWGYI5E.js +1 -0
  44. package/dist/m/{c-WKNRJX3C.js → c-GKEATME6.js} +1 -1
  45. package/dist/m/{c-QINHDETP.js → c-GPGYKER7.js} +1 -1
  46. package/dist/m/{c-FWKHM4E7.js → c-GSRLXYWL.js} +1 -1
  47. package/dist/m/{c-B7J4K2AE.js → c-GVPNDIKJ.js} +2 -2
  48. package/dist/m/{c-FTQKI7SP.js → c-I2IFKJX2.js} +1 -1
  49. package/dist/m/c-ICMAOOGK.js +1 -0
  50. package/dist/m/{c-HUISJXHF.js → c-J3BXFTZS.js} +1 -1
  51. package/dist/m/{c-BIJALSRD.js → c-JDZDF2QM.js} +1 -1
  52. package/dist/m/{c-UDHIVLYH.js → c-JH5FF4NL.js} +1 -1
  53. package/dist/m/{c-OYRZ7XG2.js → c-JHJR5BQX.js} +1 -1
  54. package/dist/m/{c-V44KWI2L.js → c-JOH753EJ.js} +2 -2
  55. package/dist/m/{c-P3OFYUMA.js → c-JUE7B4OX.js} +1 -1
  56. package/dist/m/c-K76AUL4I.js +7 -0
  57. package/dist/m/{c-ZWIOJGMT.js → c-LA2BW7UY.js} +1 -1
  58. package/dist/m/{c-ICJYHABF.js → c-LDUNOR57.js} +1 -1
  59. package/dist/m/{c-XSZKP646.js → c-LIBE4HPD.js} +1 -1
  60. package/dist/m/c-LPUJXRXW.js +1 -0
  61. package/dist/m/{c-JK3PHE7J.js → c-LQU7TXIH.js} +1 -1
  62. package/dist/m/{c-5ZQV7KC4.js → c-LV5MABYD.js} +1 -1
  63. package/dist/m/{c-GWNC3UGL.js → c-M4FSPNQ2.js} +1 -1
  64. package/dist/m/{c-2KIEGNC4.js → c-MEWUGR4D.js} +1 -1
  65. package/dist/m/c-MIL4B2JQ.js +1 -0
  66. package/dist/m/{c-IVMD3FEM.js → c-N7Y52HJH.js} +1 -1
  67. package/dist/m/{c-O4JMKN6U.js → c-NFR673TL.js} +2 -2
  68. package/dist/m/{c-ZKNBMNN3.js → c-NLZ5AN4L.js} +1 -1
  69. package/dist/m/{c-RRZJWFLE.js → c-OABVRYOT.js} +1 -1
  70. package/dist/m/c-PIVIYLTY.js +1 -0
  71. package/dist/m/{c-L7JL5TL3.js → c-QY7F6EN6.js} +1 -1
  72. package/dist/m/{c-UY4QX42B.js → c-RG6XUZFA.js} +1 -1
  73. package/dist/m/c-RHMPKZZ7.js +1 -0
  74. package/dist/m/{c-TJAXGIRV.js → c-RQRMPZXD.js} +1 -1
  75. package/dist/m/{c-GY422N3Q.js → c-RS77ODLY.js} +1 -1
  76. package/dist/m/{c-BAUBNYXK.js → c-RT3C74GY.js} +1 -1
  77. package/dist/m/{c-CAS3NND4.js → c-S5IEIZCN.js} +1 -1
  78. package/dist/m/{c-HXPHZN7Q.js → c-SBSMJIPC.js} +1 -1
  79. package/dist/m/c-SFKI6OLM.js +2 -0
  80. package/dist/m/{c-4FJTBE6I.js → c-SJPD46ZO.js} +4 -4
  81. package/dist/m/{c-JCP3XDSJ.js → c-SO63UGPQ.js} +1 -1
  82. package/dist/m/{c-PLP4JKFC.js → c-TUGVINJR.js} +1 -1
  83. package/dist/m/{c-Q26MME6N.js → c-TWCXBWS3.js} +1 -1
  84. package/dist/m/{c-GNDL3TKB.js → c-U5X57T4L.js} +1 -1
  85. package/dist/m/{c-ZS4US2XV.js → c-UXEVJ63W.js} +1 -1
  86. package/dist/m/{c-KJJPV77R.js → c-V2J5C5MT.js} +1 -1
  87. package/dist/m/{c-7PYNAULW.js → c-VBLFAQD2.js} +1 -1
  88. package/dist/m/{c-ERQSNR6K.js → c-VQCEOGKH.js} +2 -2
  89. package/dist/m/{c-YVZ2L7CE.js → c-VSPAFOKU.js} +1 -1
  90. package/dist/m/{c-L6FLIUXP.js → c-VY6XRBOW.js} +1 -1
  91. package/dist/m/{c-2KL3BD52.js → c-W23KVGUO.js} +1 -1
  92. package/dist/m/{c-AXGY2WTB.js → c-W3K23S72.js} +1 -1
  93. package/dist/m/c-WFMRX5RZ.js +1 -0
  94. package/dist/m/{c-BWFVSBDF.js → c-WN3MXOLT.js} +1 -1
  95. package/dist/m/{c-MIKZEG5I.js → c-XD5MOROJ.js} +1 -1
  96. package/dist/m/{c-CQQDL6O4.js → c-XQSXKIKM.js} +1 -1
  97. package/dist/m/{c-I4MQHOEY.js → c-Y33LUUIQ.js} +1 -1
  98. package/dist/m/{c-JDARJDOT.js → c-YQUJ74R3.js} +1 -1
  99. package/dist/m/{c-F6G2OGYG.js → c-YSB6JKV2.js} +2 -2
  100. package/dist/m/{c-WQWIRWO3.js → c-Z32V4MHK.js} +1 -1
  101. package/dist/m/{c-BHZYSHW4.js → c-ZJLU56DV.js} +1 -1
  102. package/dist/m/{c-DKLS74XB.js → c-ZQXNHZZT.js} +2 -2
  103. package/dist/m/{c-TNEM3RNM.js → c-ZSCBEB7I.js} +1 -1
  104. package/dist/m/core/{admin-attrs-YY7T5FGU.js → admin-attrs-ZG7R5V3E.js} +1 -1
  105. package/dist/m/core/{autosave-RVJPYLRT.js → autosave-VPORYJSE.js} +1 -1
  106. package/dist/m/core/{conflict-notice-2WGT52LH.js → conflict-notice-JMAZLVRX.js} +1 -1
  107. package/dist/m/core/{persist-UKXV5KLA.js → persist-3OPWJKZS.js} +1 -1
  108. package/dist/m/core/{recovery-ZOUOJVIX.js → recovery-DRFZRJED.js} +1 -1
  109. package/dist/m/core/{save-A5JXV6ME.js → save-AOJBDSOK.js} +1 -1
  110. package/dist/m/core/{save-core-MKRPSEEO.js → save-core-IOCMXO5L.js} +1 -1
  111. package/dist/m/core/{snapshot-NU3YM6GR.js → snapshot-O7II2AGG.js} +1 -1
  112. package/dist/m/core/unsaved-warning-U5VUJFOE.js +1 -0
  113. package/dist/m/events/{index-RN2JNGBV.js → index-B6TGDYMG.js} +1 -1
  114. package/dist/m/internals/{index-TGLQINN3.js → index-HDRANDWE.js} +1 -1
  115. package/dist/m/lib/{cache-bust-MUMFXZK6.js → cache-bust-NH7VBWHO.js} +1 -1
  116. package/dist/m/lib/{region-policy-SB2AWVG5.js → region-policy-KWBPROWF.js} +1 -1
  117. package/dist/m/{loader-34YPFKOH.js → loader-DZZLUBVB.js} +1 -1
  118. package/dist/m/manifest-3AEF5191.js +1 -0
  119. package/dist/m/manifest-edit-29A26F22.js +1 -0
  120. package/dist/m/manifest.json +1202 -1158
  121. package/dist/m/options/{options-EJMS3K24.js → options-55LQHSJ4.js} +1 -1
  122. package/dist/m/page/{editor-WRQGHDSG.js → editor-EY2WAAGB.js} +2 -2
  123. package/dist/m/plugins/{ai-edit-X2L2KIEP.js → ai-edit-J5VLSW5I.js} +1 -1
  124. package/dist/m/plugins/{demo-OYO5GCAO.js → demo-42BSYQ7T.js} +1 -1
  125. package/dist/m/plugins/{live-7C36XEI2.js → live-5EZN2EYP.js} +1 -1
  126. package/dist/m/plugins/menu-KGWKT6CS.js +1 -0
  127. package/dist/m/plugins/{page-BSW6MGDO.js → page-LVW5DWA4.js} +2 -2
  128. package/dist/m/plugins/{page-view-WFZVTPQK.js → page-view-5KQ76IJB.js} +1 -1
  129. package/dist/m/plugins/{sortable-4S6SQC3D.js → sortable-WJZZBM7R.js} +1 -1
  130. package/dist/m/plugins/{source-TJXOIOYY.js → source-CCEUM3OR.js} +1 -1
  131. package/dist/m/plugins/{undo-NLPGCJQY.js → undo-3JEYK5QY.js} +1 -1
  132. package/dist/m/plugins/{upgrade-HSUNDNJD.js → upgrade-NW556WJD.js} +1 -1
  133. package/dist/m/plugins/{upload-NHGJXZK2.js → upload-TTCQRIM5.js} +1 -1
  134. package/dist/m/plugins/{visitor-drafts-BW43DGY3.js → visitor-drafts-2AWNT23K.js} +2 -2
  135. package/dist/m/plugins/{visitor-drafts-owner-7ODQG7JX.js → visitor-drafts-owner-MZP45XSG.js} +1 -1
  136. package/dist/m/plugins/{wire-6OSIL3I7.js → wire-VRYPY6EJ.js} +1 -1
  137. package/dist/m/{reader-core-PLZYLYLT.js → reader-core-2GXY7SHY.js} +2 -2
  138. package/dist/m/sync/{live-sync-UXNI6ZF6.js → live-sync-SKPMFYOO.js} +1 -1
  139. package/dist/m/ui/{index-IVWN2QC4.js → index-QNIPDHXQ.js} +1 -1
  140. package/dist/offline-manifest.json +634 -610
  141. package/docs/guide.md +24 -8
  142. package/package.json +3 -2
  143. package/src/core/conflict-download.js +8 -7
  144. package/src/core/conflict-notice-ui.js +4 -4
  145. package/src/core/copy-content.js +103 -0
  146. package/src/core/download.js +14 -2
  147. package/src/core/save-size-notice.js +2 -2
  148. package/src/core/upgrade-run.js +5 -1
  149. package/src/lib/region-policy.js +1 -1
  150. package/src/page/features/export-html.js +4 -4
  151. package/src/page/features/export-markdown.js +2 -2
  152. package/src/page/recovery-ui.js +2 -2
  153. package/src/page/save-states.js +4 -4
  154. package/src/plugins/menu/actions.js +1 -1
  155. package/src/plugins/page.js +4 -4
  156. package/src/plugins/visitor-drafts/prompt.js +12 -12
  157. package/src/plugins/wire.js +3 -1
  158. package/dist/m/attrs/save-freeze-LWGF6XUN.js +0 -1
  159. package/dist/m/c-DCFSEJZG.js +0 -1
  160. package/dist/m/c-EXEDYU4H.js +0 -1
  161. package/dist/m/c-GRXHHFPO.js +0 -1
  162. package/dist/m/c-HT2DKBV2.js +0 -1
  163. package/dist/m/c-MCOOHCSG.js +0 -1
  164. package/dist/m/c-MMXKAX2W.js +0 -1
  165. package/dist/m/c-VE7RKNKZ.js +0 -7
  166. package/dist/m/c-VR2BJ4AN.js +0 -1
  167. package/dist/m/c-WGW764WX.js +0 -1
  168. package/dist/m/c-WNTYKCDG.js +0 -1
  169. package/dist/m/c-YBSS55KU.js +0 -20
  170. package/dist/m/core/unsaved-warning-4ZPEV7BF.js +0 -1
  171. package/dist/m/manifest-0D166F4F.js +0 -1
  172. package/dist/m/manifest-edit-3877153E.js +0 -1
  173. package/dist/m/plugins/menu-MFC4DI5E.js +0 -1
  174. /package/dist/m/{c-QTTJYJMA.js → c-FILLTJA7.js} +0 -0
  175. /package/dist/m/{c-5JLFROUB.js → c-X5LNHET5.js} +0 -0
  176. /package/dist/m/plugins/{people-JCHVPF7P.js → people-C7TVBBMR.js} +0 -0
@@ -1 +1 @@
1
- import"../c-B7J4K2AE.js";import{a as d}from"../c-ATKAOH23.js";import"../c-EK63G3CG.js";import"../c-NQJRVJ56.js";import"../c-XGH4GS2T.js";import"../c-IJUK2GPW.js";import{k as p}from"../c-3O7OBDCM.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-N7JPUPGC.js";import"../c-7MG5RU63.js";import"../c-XQXZAO7N.js";import"../c-S7LK4KUE.js";import"../c-VG5XIN4T.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import"../c-DCFSEJZG.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var g={installed:!1,refused:null,sourceBytes:null,paired:0,unresolved:0,unmatchedLive:0,unmatchedSource:0,attrDiffs:0,saves:0,reprints:0,lastReprint:null,partialReprints:0,lastPartialReprint:null,lastRenderMs:null,lastBytes:null,refreshes:0,timing:{fetch:null,model:null,pair:null,refresh:null}},n=null,c=null,i=null,u=p(),s=0,r=null,a=!1,o=null;function v(){return o??=import("../c-V44KWI2L.js").catch(e=>{throw o=null,e}),o}function f(e,t,l){typeof e=="string"&&(i=Object.freeze({bytes:e,etag:t??null,seq:l??null}))}function h(){if(r)return r;let e=s,t=c;return r=v().then(l=>(n=l,e!==s?(r=null,null):l.start({context:t,latest:()=>i}))).catch(l=>(r=null,console.info("clayjs: source map off ("+(l&&l.message?l.message:l)+"); saves use the full serialization"),null)).then(l=>(e===s&&(a=!0),l)),r}function x(){return!u||a?null:h()}function m(){s++,u=!1,a=!1,r=null,c=null,n&&n.release()}d((e,t)=>{f(e,i?i.etag:null,i?i.seq:null),n&&!n.installed()&&n.adoptAccepted(e,t)});document.addEventListener("clay:sync-applied",e=>{let t=e&&e.detail;!t||t.source!=="disk"||typeof t.html!="string"||(f(t.html,t.etag,t.seq),n&&!n.installed()&&n.adoptAccepted(t.html,null))});function y(e,t,l={}){return n?n.renderSave(e,t,l):t}var A={get ready(){return u?h():null},stats:()=>n?n.stats():{...g},text:()=>n?n.text():null,locate:e=>n?n.locateLive(e):null,unpaired:()=>n?n.unpaired():null,ensureForSave:x,get repairGeneration(){return n?n.repairGeneration():0}};function L(){return{id:"clay:source",order:30,prepare(e={}){let t=e&&e.represented;if(t&&(c={represented:t},f(t.bytes,t.etag,t.seq)),e&&e.initial===!0)return u=!0,{enable(){},quiesce(){},resume(){},dispose:m};let l=++s;return u=!1,a=!1,r=null,{enable(){l===s&&(u=!0)},quiesce(){},resume(){l===s&&(u=!0)},dispose(){l===s&&m()}}}}}var R=A;export{R as default,L as modeParticipant,y as renderSave,A as source,L as sourceParticipant};
1
+ import"../c-GVPNDIKJ.js";import{a as d}from"../c-ATKAOH23.js";import"../c-EK63G3CG.js";import"../c-NQJRVJ56.js";import"../c-XGH4GS2T.js";import"../c-IJUK2GPW.js";import{k as p}from"../c-3O7OBDCM.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-N7JPUPGC.js";import"../c-EGTIAL6P.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 g={installed:!1,refused:null,sourceBytes:null,paired:0,unresolved:0,unmatchedLive:0,unmatchedSource:0,attrDiffs:0,saves:0,reprints:0,lastReprint:null,partialReprints:0,lastPartialReprint:null,lastRenderMs:null,lastBytes:null,refreshes:0,timing:{fetch:null,model:null,pair:null,refresh:null}},n=null,c=null,i=null,u=p(),s=0,r=null,a=!1,o=null;function v(){return o??=import("../c-JOH753EJ.js").catch(e=>{throw o=null,e}),o}function f(e,t,l){typeof e=="string"&&(i=Object.freeze({bytes:e,etag:t??null,seq:l??null}))}function h(){if(r)return r;let e=s,t=c;return r=v().then(l=>(n=l,e!==s?(r=null,null):l.start({context:t,latest:()=>i}))).catch(l=>(r=null,console.info("clayjs: source map off ("+(l&&l.message?l.message:l)+"); saves use the full serialization"),null)).then(l=>(e===s&&(a=!0),l)),r}function x(){return!u||a?null:h()}function m(){s++,u=!1,a=!1,r=null,c=null,n&&n.release()}d((e,t)=>{f(e,i?i.etag:null,i?i.seq:null),n&&!n.installed()&&n.adoptAccepted(e,t)});document.addEventListener("clay:sync-applied",e=>{let t=e&&e.detail;!t||t.source!=="disk"||typeof t.html!="string"||(f(t.html,t.etag,t.seq),n&&!n.installed()&&n.adoptAccepted(t.html,null))});function y(e,t,l={}){return n?n.renderSave(e,t,l):t}var A={get ready(){return u?h():null},stats:()=>n?n.stats():{...g},text:()=>n?n.text():null,locate:e=>n?n.locateLive(e):null,unpaired:()=>n?n.unpaired():null,ensureForSave:x,get repairGeneration(){return n?n.repairGeneration():0}};function L(){return{id:"clay:source",order:30,prepare(e={}){let t=e&&e.represented;if(t&&(c={represented:t},f(t.bytes,t.etag,t.seq)),e&&e.initial===!0)return u=!0,{enable(){},quiesce(){},resume(){},dispose:m};let l=++s;return u=!1,a=!1,r=null,{enable(){l===s&&(u=!0)},quiesce(){},resume(){l===s&&(u=!0)},dispose(){l===s&&m()}}}}}var R=A;export{R as default,L as modeParticipant,y as renderSave,A as source,L as sourceParticipant};
@@ -1 +1 @@
1
- import{b as Ze,c as Qe}from"../c-7DJDKPGL.js";import{g as re}from"../c-FWKHM4E7.js";import{a as te}from"../c-WYFDLITL.js";import"../c-ZWIOJGMT.js";import"../c-IJUK2GPW.js";import{k as Ge}from"../c-3O7OBDCM.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-N7JPUPGC.js";import{a as Ye}from"../c-VG5XIN4T.js";import"../c-2YYDMLNZ.js";import{l as Xe}from"../c-HA6INT6J.js";import"../c-DCFSEJZG.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var et=(()=>{var d=Object.defineProperty,f=Object.getOwnPropertyDescriptor,k=Object.getOwnPropertyNames,v=Object.prototype.hasOwnProperty,N=(e,r)=>{for(var t in r)d(e,t,{get:r[t],enumerable:!0})},W=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of k(r))!v.call(e,i)&&i!==t&&d(e,i,{get:()=>r[i],enumerable:!(n=f(r,i))||n.enumerable});return e},X=e=>W(d({},"__esModule",{value:!0}),e),C={};N(C,{default:()=>Xt,undo:()=>se});function G(e,r=null){let t=[];if(e.type==="attributes"){let n=e.target,i=e.attributeName,a=e.oldValue,l=n.getAttribute(i);return a==null&&l!=null?t.push({kind:"attr-add",target:n,name:i,newValue:l}):a!=null&&l==null?t.push({kind:"attr-remove",target:n,name:i,oldValue:a}):a!==l&&t.push({kind:"attr-set",target:n,name:i,oldValue:a,newValue:l}),t}if(e.type==="characterData")return t.push({kind:"text",target:e.target,oldValue:e.oldValue,newValue:e.target.data}),t;if(e.type==="childList"){let n=e.target,i=e.nextSibling,a=e.nextSibling;for(;a&&r?.(a);)a=a.nextSibling;let l=e.previousSibling;for(;l&&r?.(l);)l=l.previousSibling;let s=r?Array.from(e.addedNodes).filter(b=>!r(b)):Array.from(e.addedNodes),p=r?Array.from(e.removedNodes).filter(b=>!r(b)):Array.from(e.removedNodes);return s.length>0&&t.push({kind:"add",parent:n,nodes:s,before:i,afterAuthored:a,beforeAuthored:l,record:e}),p.length>0&&t.push({kind:"remove",parent:n,nodes:p,before:i,afterAuthored:a,beforeAuthored:l,record:e}),t}return t}function ut(e,r=null){let t=[],n=new Map;for(let i of e){if(i.type==="attributes"){let a=i.target,l=i.attributeName,s=n.get(a);s||(s=new Map,n.set(a,s)),s.has(l)||(s.set(l,{idx:t.length,oldValue:i.oldValue}),t.push(null));continue}for(let a of G(i,r))t.push(a)}for(let[i,a]of n)for(let[l,s]of a){let p=s.oldValue,b=i.getAttribute(l),h=null;p===b?h=null:p==null?h={kind:"attr-add",target:i,name:l,newValue:b}:b==null?h={kind:"attr-remove",target:i,name:l,oldValue:p}:h={kind:"attr-set",target:i,name:l,oldValue:p,newValue:b},t[s.idx]=h}return t.filter(i=>i!=null)}function lt(e){let r=[],t=new Map;for(let i of e){let a=ke(i);if(a==null){r.push(i);continue}let l=t.get(i.target);l||(l=new Map,t.set(i.target,l));let s=l.get(a);if(s==null){let p=Ae(i);if(p.oldValue===p.newValue)continue;l.set(a,r.length),r.push({...i,...p})}else r[s]={...r[s],newValue:Ae(i).newValue}}let n=[];for(let i of r){if(ke(i)==null){n.push(i);continue}i.oldValue!==i.newValue&&n.push(st(i))}return n}var dt=new Set(["attr-set","attr-add","attr-remove","text","value"]);function ke(e){return dt.has(e.kind)?e.kind==="text"?"#text":e.kind==="value"?`#${e.prop||"value"}`:e.name==null?null:`@${e.name}`:null}function Ae(e){return e.kind==="attr-add"?{oldValue:null,newValue:e.newValue}:e.kind==="attr-remove"?{oldValue:e.oldValue,newValue:null}:{oldValue:e.oldValue,newValue:e.newValue}}function st(e){return e.kind!=="attr-add"&&e.kind!=="attr-remove"?e:e.oldValue==null&&e.newValue!=null?{...e,kind:"attr-add"}:e.oldValue!=null&&e.newValue==null?{...e,kind:"attr-remove"}:{...e,kind:"attr-set"}}var Ve=new WeakMap,ct=0;function O(e){let r=Ve.get(e);return r||(r=`n${++ct}`,Ve.set(e,r)),r}function x(e){return!!e&&typeof e=="object"&&typeof e.nodeType=="number"}function ft(e){return e.kind==="add"||e.kind==="remove"}function Ee(e,r){let t=[],n=e.childNodes;if(!n)return t;for(let i of n)r&&r(i)||t.push(O(i));return t}function H(e,r,t=null,n=null){if(!x(e))return null;if(e.nodeType===3)return`#text:${JSON.stringify(e.data)}`;if(e.nodeType===8)return`#comment:${JSON.stringify(e.data)}`;if(e.nodeType!==1)return`#node:${e.nodeType}`;let i=[];if(e.attributes){for(let l of e.attributes)pt(l.name,e,r,t)||i.push(`${l.name}=${JSON.stringify(l.value)}`);i.sort()}let a=[];if(e.childNodes)for(let l of e.childNodes)mt(l,n)||a.push(H(l,r,t,n));return`<${String(e.tagName||"").toLowerCase()}${i.length?` ${i.join(" ")}`:""}>${a.join("")}</>`}function oe(e,r=[]){if(!x(e))return r;if(e.nodeType===1){let t=e.getAttribute&&e.getAttribute("data-id");t&&r.push(t)}if(e.childNodes)for(let t of e.childNodes)oe(t,r);return r}function pt(e,r,t,n=null){if(typeof t!="function")return!1;try{return!!t(e,r,n)}catch{return!1}}function mt(e,r){if(typeof r!="function")return!1;try{return!!r(e)}catch{return!1}}function Ne(e,r){if(typeof r!="function")return[];let t=[],n=i=>{if(!x(i))return;let a=!1;try{a=!!r(i)}catch{a=!1}if(a&&t.push(R(i,"protected")),i.childNodes)for(let l of i.childNodes)n(l)};for(let i of e)n(i);return t}function R(e,r,t=null){let n=e;n&&n.nodeType!==1&&(n=n.parentElement);let i=n&&typeof n.closest=="function"?n.closest("[data-id]"):null;return!i&&t&&typeof t.closest=="function"&&(i=t.closest("[data-id]")),{id:(i?i.getAttribute("data-id"):null)||null,kind:r||null}}function gt(e,r,t=null){return(e||[]).filter(x).map(n=>R(n,r,t))}function J(e){return{replayable:!1,reason:e,steps:[]}}function Y(e,r){let t=[[r.afterAuthored,i=>i],[r.beforeAuthored,i=>i+1],[r.before,i=>i]],n=!1;for(let[i,a]of t){if(!x(i))continue;n=!0;let l=e.indexOf(O(i));if(l>=0)return a(l)}return n?null:e.length}function ht(e,r={}){let t=r.isIgnored||null,n=r.ignoreAttribute||null,i=lt(e),a=[];for(let h of i){if(!ft(h)){if(!x(h.target))return J("non-dom-target");continue}if(!x(h.parent))return J("non-dom-parent");let A=Array.from(h.nodes||[]).filter(x);if(A.length!==0){if(A.length!==Array.from(h.nodes||[]).length)return J("non-dom-node");a.push({primitive:h,nodes:A,parent:h.parent})}}if(yt(a))return J("in-record-move");let l=wt(a,t);if(!l)return J("ambiguous-structure");let s=bt(a,l),p=new Map(a.map(h=>[h.primitive,h])),b=[];for(let h of i){let A=p.get(h);if(!A){b.push(kt(h));continue}let E=s.get(A);if(E){E.at===A&&b.push(E.step);continue}b.push(vt(A,l.get(A),n,t))}return{replayable:!0,reason:null,steps:b}}function yt(e){let r=new Map;for(let t of e){let n=t.primitive.record;if(!n)continue;let i=r.get(n);i||(i=new Map,r.set(n,i));for(let a of t.nodes){let l=i.get(a);l||(l=new Set,i.set(a,l)),l.add(t.primitive.kind)}}for(let t of r.values())for(let n of t.values())if(n.size>1)return!0;return!1}function wt(e,r){let t=new Map;for(let i of e)t.has(i.parent)||t.set(i.parent,Ee(i.parent,r));let n=new Map;for(let i=e.length-1;i>=0;i--){let a=e[i],l=t.get(a.parent);if(!l)return null;let s=l.slice(),p;if(a.primitive.kind==="add"){let b=a.nodes.map(O);if(!b.every(h=>l.includes(h)))return null;p=l.filter(h=>!b.includes(h))}else{let b=Y(s,a.primitive);if(b==null)return null;p=s.slice(),p.splice(b,0,...a.nodes.map(O))}n.set(a,{before:p,after:s}),t.set(a.parent,p)}return n}function bt(e,r){let t=new Map,n=new Map;e.forEach((a,l)=>{for(let s of a.nodes){let p=O(s);a.primitive.kind==="remove"?t.set(p,{item:a,index:l,node:s}):n.set(p,{item:a,index:l,node:s})}});let i=new Map;for(let[a,l]of t){let s=n.get(a);if(!s||s.index<l.index||l.item.nodes.length!==1||s.item.nodes.length!==1)continue;let p={type:"move",node:l.node,sourceParent:l.item.parent,destParent:s.item.parent,source:r.get(l.item),dest:r.get(s.item),sourceSlot:l.item.primitive,destSlot:s.item.primitive,targets:[R(l.node,"move")]};i.set(l.item,{step:p,at:s.item}),i.set(s.item,{step:p,at:s.item})}return i}function vt(e,r,t,n){let i=e.primitive.kind;return{type:i==="add"?"add":"restore",parent:e.parent,nodes:e.nodes,seqBefore:r.before,seqAfter:r.after,slot:e.primitive,content:e.nodes.map(a=>H(a,t,e.parent,n)),ids:i==="remove"?e.nodes.flatMap(a=>oe(a)):[],targets:gt(e.nodes,i==="add"?"added":"removed",e.parent)}}function kt(e){return{type:e.kind,primitive:e,targets:[R(e.target,e.name||e.prop||"text")]}}function At(e,r,t={}){if(!e||!e.replayable)return{ok:!1,code:"unsupported",targets:[]};let n={isIgnored:t.isIgnored||null,ignoreAttribute:t.ignoreAttribute||null,isProtected:t.isProtected||null,inScope:t.inScope||(()=>!0),liveNodesWithIds:t.liveNodesWithIds||(()=>[]),sim:new Map,planned:new Map,operations:[]};for(let i=0;i<e.steps.length;i++){let a=e.steps[r==="undo"?e.steps.length-1-i:i],l=Et(a,r,n);if(l)return{ok:!1,code:l.code,targets:l.targets}}return{ok:!0,operations:n.operations}}function q(e,r){return e.sim.has(r)||e.sim.set(r,Ee(r,e.isIgnored)),e.sim.get(r)}function L(e,r){for(let t=e;t;t=t.parentNode)if(r.planned.has(t))return r.planned.get(t);return r.inScope(e)}function xe(e,r){return r.liveNodesWithIds(e).filter(t=>L(t,r)).length>0}function V(e,r){return{code:e,targets:r||[]}}function Vt(e){return e.kind==="text"?e.target.data:e.kind==="value"?typeof e.read=="function"?e.read(e.target):e.target[e.prop||"value"]:e.target.getAttribute(e.name)}function Et(e,r,t){let n=r==="undo";return e.type==="move"?St(e,n,t):e.type==="add"?xt(e,n,t):e.type==="restore"?Pt(e,n,t):Nt(e,n,t)}function Nt(e,r,t){let n=e.primitive,i=r?n.newValue:n.oldValue,a=r?n.oldValue:n.newValue;return x(n.target)?L(n.target,t)?n.kind==="value"&&typeof n.write=="function"&&typeof n.read!="function"?V("unsupported",e.targets):Vt(n)!==i?V("content-changed",e.targets):(n.kind==="value"?t.operations.push({type:"value",target:n.target,prop:n.prop||"value",value:a,read:n.read||null,write:n.write||null}):n.kind==="text"?t.operations.push({type:"text",target:n.target,data:a}):t.operations.push({type:"attr",target:n.target,name:n.name,value:a??null}),null):V("target-detached",e.targets):V("unsupported",e.targets)}function xt(e,r,t){if(!x(e.parent)||!L(e.parent,t))return V("target-detached",e.targets);if(r){if(!$(q(t,e.parent),e.seqAfter))return V("structure-changed",e.targets);let s=Ne(e.nodes,t.isProtected);if(s.length>0)return V("protected",s);for(let p=0;p<e.nodes.length;p++)if(H(e.nodes[p],t.ignoreAttribute,e.parent,t.isIgnored)!==e.content[p])return V("content-changed",e.targets);for(let p of e.nodes)t.operations.push({type:"remove",node:p}),t.planned.set(p,!1);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!$(q(t,e.parent),e.seqBefore))return V("structure-changed",e.targets);for(let s of e.nodes)if(s.parentNode)return V("structure-changed",e.targets);let n=e.nodes.flatMap(s=>oe(s));if(n.length>0&&xe(n,t))return V("duplicate-id",e.targets);let i=Y(e.seqBefore,e.slot);if(i==null)return V("unsupported",e.targets);let a=e.seqBefore.slice(),l=i;for(let s of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:s,beforeId:a[l]??null}),a=a.slice(0,l).concat(O(s),a.slice(l)),l+=1,t.planned.set(s,!0);return t.sim.set(e.parent,e.seqAfter.slice()),null}function Pt(e,r,t){if(!x(e.parent)||!L(e.parent,t))return V("target-detached",e.targets);if(r){if(!$(q(t,e.parent),e.seqAfter))return V("structure-changed",e.targets);for(let p=0;p<e.nodes.length;p++){let b=e.nodes[p];if(b.parentNode||H(b,t.ignoreAttribute,e.parent,t.isIgnored)!==e.content[p])return V("content-changed",e.targets)}if(e.ids.length>0&&xe(e.ids,t))return V("duplicate-id",e.targets);let a=Y(e.seqAfter,e.slot);if(a==null)return V("unsupported",e.targets);let l=e.seqAfter.slice(),s=a;for(let p of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:p,beforeId:l[s]??null}),l=l.slice(0,s).concat(O(p),l.slice(s)),s+=1,t.planned.set(p,!0);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!$(q(t,e.parent),e.seqBefore))return V("structure-changed",e.targets);let n=Ne(e.nodes,t.isProtected);if(n.length>0)return V("protected",n);let i=a=>t.planned.get(a)===!0||typeof t.isIgnored=="function"&&t.isIgnored(a);for(let a=0;a<e.nodes.length;a++){let l=e.nodes[a];if(l.parentNode!==e.parent||H(l,t.ignoreAttribute,e.parent,i)!==e.content[a])return V("content-changed",e.targets)}for(let a of e.nodes)t.operations.push({type:"remove",node:a}),t.planned.set(a,!1);return t.sim.set(e.parent,e.seqAfter.slice()),null}function It(e,r){let t=e.indexOf(r);return t<0?null:e.slice(0,t).concat(e.slice(t+1))}function St(e,r,t){let n=O(e.node),i=r?e.destParent:e.sourceParent,a=r?e.sourceParent:e.destParent,l=q(t,i),s=q(t,a),p=r?e.dest.after:e.source.before,b=r?e.source.after:e.dest.before,h=r?e.sourceSlot:e.destSlot;if(!x(i)||!x(a)||!L(i,t)||!L(a,t))return V("target-detached",e.targets);if(!$(l,p))return V("structure-changed",e.targets);let A=i===a?It(s,n):s;if(!$(A,b))return V("structure-changed",e.targets);let E=Y(b,h);return E==null?V("unsupported",e.targets):(t.operations.push({type:"insert",parent:a,node:e.node,beforeId:b[E]??null}),t.planned.set(e.node,!0),r?(t.sim.set(a,e.source.before.slice()),i!==a&&t.sim.set(i,e.dest.before.slice())):(t.sim.set(a,e.dest.after.slice()),i!==a&&t.sim.set(i,e.source.after.slice())),null)}function $(e,r){if(!e||!r||e.length!==r.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==r[t])return!1;return!0}function Rt(e,r){for(let t of e.childNodes||[])if(O(t)===r)return t;return null}function Pe(e,r){typeof e.write=="function"?e.write(e.target,r):e.target[e.prop]=r}function Ct(e){let r=[];try{for(let t of e)Ot(t,r);return{ok:!0}}catch(t){for(let n=r.length-1;n>=0;n--)try{r[n]()}catch{}return{ok:!1,error:t}}}function Ot(e,r){if(e.type==="attr"){let t=e.target.getAttribute(e.name);e.value==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,e.value),r.push(()=>{t==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,t)});return}if(e.type==="text"){let t=e.target.data;e.target.data=e.data,r.push(()=>{e.target.data=t});return}if(e.type==="value"){let t=typeof e.read=="function"?e.read(e.target):e.target[e.prop];Pe(e,e.value),r.push(()=>Pe(e,t));return}if(e.type==="insert"){let t=e.beforeId==null?null:Rt(e.parent,e.beforeId);if(e.beforeId!=null&&!t)throw new Error("hyper-undo: replay anchor vanished");let n=e.node.parentNode,i=e.node.nextSibling;e.parent.insertBefore(e.node,t),r.push(()=>{n?n.insertBefore(e.node,i&&i.parentNode===n?i:null):e.node.parentNode===e.parent&&e.parent.removeChild(e.node)});return}if(e.type==="remove"){let t=e.node.parentNode;if(!t)throw new Error("hyper-undo: replay target is no longer attached");let n=e.node.nextSibling;t.removeChild(e.node),r.push(()=>t.insertBefore(e.node,n))}}var Mt=['[src^="chrome-extension://"]','[href^="chrome-extension://"]','[src^="moz-extension://"]','[href^="moz-extension://"]','[src^="safari-web-extension://"]','[href^="safari-web-extension://"]','[id="1p-menu-live-region"]',"com-1password-button","com-1password-menu","com-1password-notification","grammarly-extension","grammarly-desktop-integration","lt-div","lt-card","lt-toolbar","lt-highlighter","[data-lastpass-root]","[data-lastpass-icon-root]","[data-dashlane-shadowhost]","[data-klarna-extension]",'[class*="klarna-extension"]',".skiptranslate","#goog-gt-tt",".goog-te-banner-frame",".goog-te-balloon-frame","style.darkreader","style[data-darkreader-mode]","style[data-darkreader-scheme]","#loom-companion-mv3","loom-container","[ext-id]"],Tt=["data-grammarly","data-lt","data-1p","data-com-onepassword","data-lastpass","data-lp","data-kwimpala","data-bitwarden","data-bw","data-dashlane","data-np","data-protonpass","data-proton-pass","data-keeper","data-rf","data-roboform","data-honey","data-rakuten","data-capital-one","data-wikibuy","data-klarna","data-darkreader","data-evernote","data-pocket","data-pin"],jt=Mt.join(","),qt=new RegExp("^(?:"+Tt.join("|")+")(?:-|$)"),zr=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),Lt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),$t=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function ie(e,r){if(!e||e.nodeType!==1)return!1;let t=e.getAttribute?.("clay");return!!(t&&t.split(/\s+/).includes(r)||e.hasAttribute?.(r))}function Ie(e,r){if(ie(e,r))return!0;for(let[t,n]of Object.entries(Lt))if(n.includes(r)&&ie(e,t))return!0;return!1}function Kt(e){return e==="clay"||$t.includes(e)}var zt=["mutations-ignore","save-remove","save-ignore","save-freeze","no-undo","no-watch"];function Dt(){if(typeof window>"u")return null;let e=window.clay?.region||window.hyperclay?.region;return e&&typeof e.resolveRegionPolicy=="function"?e.resolveRegionPolicy:null}function ae(e){let r=Dt();if(r)try{if(!r(e).undoable)return!0}catch{}let t=e&&e.nodeType!==1?e.parentElement:e;if(t&&t.closest&&t.closest(jt))return!0;for(;t&&t.nodeType===1;){if(Ie(t,"no-undo")||Ie(t,"no-watch"))return!0;for(let n of zt)if(ie(t,n))return!0;t=t.parentElement}return!1}function _t(e){let r=e.target,t=r.cloneNode(!1),n=t;for(;r.parentElement;){r=r.parentElement;let i=r.cloneNode(!1);i.appendChild(t),t=i}return e.oldValue==null?n.removeAttribute(e.attributeName):n.setAttribute(e.attributeName,e.oldValue),ae(n)}function ue(e,r,t){if(t?.type==="attributes"&&Kt(t.attributeName)){if(ae(e)&&_t(t))return!0}else if(ae(e))return!0;if(t&&t.type==="attributes"){if(t.attributeName&&qt.test(t.attributeName.toLowerCase()))return!0;if(r)try{if(r(t.attributeName,t.target))return!0}catch{}}return!1}function Ut(){let e=new Map;function r(i,a){let l=e.get(i);return l||(l=new Set,e.set(i,l)),l.add(a),()=>t(i,a)}function t(i,a){let l=e.get(i);l&&l.delete(a)}function n(i,a){let l=e.get(i);if(l)for(let s of Array.from(l))try{s(a)}catch(p){console.error("[hyper-undo] listener threw",p)}}return{on:r,off:t,emit:n}}var Bt={maxHistory:100,idleWindowMs:500,idleLabel:"Edit",recording:"automatic",ignoreAttribute:null,isProtected:null,ignoreNode:null,debug:!1};function Se(e){let r={...Bt,...e};if(!r.scope)throw new Error("hyper-undo: scope is required");let t=Ut(),n=[],i=[],a=`u${Math.random().toString(36).slice(2,8)}`,l=0,s=null,p=[],b=null,h=null,A=0,E=!1,K=r.recording==="commands"?"commands":"automatic",I=null,z=!1;function P(...o){r.debug&&console.log("[hyper-undo]",...o)}function Gt(){E||(E=!0,h=Yt(D),h.observe(r.scope,{childList:!0,attributes:!0,characterData:!0,subtree:!0,attributeOldValue:!0,characterDataOldValue:!0}),P("started"))}function Yt(o){let u=typeof document<"u"&&r.scope===document.body,c=typeof window<"u"&&(window.clay?.Mutation||window.hyperclay?.Mutation)||null;return u&&c&&typeof c.createObserver=="function"?(P("sourcing records from the platform Mutation hub (shared observer)"),c.createObserver(o)):new MutationObserver(o)}function Me(){E&&(E=!1,h&&(h.disconnect(),h=null),_(),n.length=0,i.length=0,p=[],s=null,I=null,z=!1,A=0,P("stopped"))}function Zt(){let o=r.scope;return!!(o&&o.nodeType===1&&o.isConnected===!1)}function D(o){Te(o,!1)}function Te(o,u){if(I){for(let m of o)I.records.push(m);return}if(K==="commands"||A>0)return;let c=ce(Qt(o),u);if(c.length>0){for(let m of c)p.push(m);je()}}function Qt(o){return typeof r.ignoreNode!="function"?o:o.filter(u=>{if(u.type!=="childList")return!0;let c=[...u.addedNodes,...u.removedNodes];return c.length===0?!0:!c.every(m=>er(m))})}function er(o){try{return!!r.ignoreNode(o)}catch{return!1}}function ce(o,u=!1){let c=yr(o),m=o.filter(y=>(ge(y.target)||c(y.target)||u&&Fe(y.target))&&!ue(y.target,r.ignoreAttribute,y));return ut(m,y=>ue(y,r.ignoreAttribute))}function je(){_(),b=setTimeout(qe,r.idleWindowMs)}function _(){b!=null&&(clearTimeout(b),b=null)}function qe(){if(b=null,p.length===0)return;let o=p;p=[],Z(r.idleLabel,o)}function Z(o,u){let c=ht(u,{isIgnored:fe,ignoreAttribute:Le});if(c.steps.length===0)return P("commit",o,"with nothing to record"),t.emit("commit"),null;let m={id:`${a}-${++l}`,label:o,timestamp:Date.now(),primitives:u,certificate:c};for(n.push(m),i.length=0,s=null;n.length>r.maxHistory;)n.shift();return P("commit",o,"primitives:",u.length),t.emit("commit"),m}function fe(o){return ue(o,r.ignoreAttribute)}function Le(o,u,c=null){if(typeof r.ignoreAttribute!="function")return!1;try{return!!r.ignoreAttribute(o,u,c)}catch{return!1}}function tr(o){if(typeof r.isProtected!="function")return!1;try{return!!r.isProtected(o)}catch{return!1}}function rr(o,u){if(!E)throw new Error("hyper-undo: scope not started");if(K==="commands")return ze(o,u,{honorPause:!0,receipt:!1});D(h.takeRecords()),U();let c=A===0?$e():null,m=u();if(m&&typeof m.then=="function")throw new Error("hyper-undo: commit() fn must be synchronous; returned a Promise");if(Te(h.takeRecords(),!0),c!=null&&Ke(c),p.length===0){t.emit("commit");return}_();let y=p;p=[],Z(o,y)}function nr(o){if(!E)throw new Error("hyper-undo: scope not started");if(!h)return;if(A>1){h.takeRecords();return}U();let u=ce(h.takeRecords(),!0);u.length!==0&&(_(),Z(o,u))}function or(){h&&h.takeRecords()}function pe(){let o=r.scope;return o&&o.ownerDocument||(typeof document<"u"?document:null)}function Q(){let o=pe();return!o||!o.head||typeof o.head.querySelector!="function"?null:o.head.querySelector("title")}function $e(){let o=Q();return o?o.textContent:null}function Ke(o){let u=Q();if(!u||o==null)return;let c=u.textContent;c!==o&&_e({kind:"value",target:u,prop:"textContent",oldValue:o,newValue:c})}function ir(o){if(!o)return null;let u=pe();if(!u||o.target!==u||o.prop!=="title")return o;let c=Q();return c?{kind:"value",target:c,prop:"textContent",oldValue:o.oldValue,newValue:o.newValue}:null}function ar(){if(typeof window>"u")return!1;let o=window.clay?.effect||window.hyperclay?.effect;return!!(o&&o.running)}function ur(){h&&D(h.takeRecords()),U(),I={records:[],primitives:[]}}function lr(){let o=I;if(I=null,!o)return[];let u=ce(o.records,!0);for(let c of o.primitives)u.push(c);return u}function ze(o,u,{honorPause:c,receipt:m}){if(typeof u!="function")throw new Error("hyper-undo: command() needs a synchronous function");if(I)throw new Error("hyper-undo: command() cannot nest inside another command");if(z)throw new Error("hyper-undo: command() cannot run during undo or redo");if(ar())throw new Error("hyper-undo: command() cannot run inside a derived-effect context");if(u.constructor&&u.constructor.name==="AsyncFunction")throw new Error("hyper-undo: command() fn must be synchronous; it was declared async");let y=c&&A>0,S=y?null:$e();ur();let M=[],j=null,B;try{try{B=u()}catch(kr){j=kr}if(h&&D(h.takeRecords()),B&&typeof B.then=="function"){try{B.then(void 0,()=>{})}catch{}j||(j=new Error("hyper-undo: command() fn must be synchronous; returned a Promise"))}y||Ke(S)}finally{M=lr()}let ee=y||M.length===0?null:Z(o,M);if(j)throw j;return m?ee?{id:ee.id,label:ee.label}:null:ee}function dr(o,u){if(!E)throw new Error("hyper-undo: scope not started");return ze(o,u,{honorPause:!1,receipt:!0})}function sr(o){if(o!=="automatic"&&o!=="commands")throw new Error("hyper-undo: setRecording() takes 'automatic' or 'commands'");if(I)throw new Error("hyper-undo: setRecording() cannot change while a command is running");return K===o||(U(),K=o,P("recording",o)),K}function De(o){if(!E||!o||!I&&(A>0||K==="commands"))return;let u=ir(o);u&&_e(u)}function _e(o){if(I){I.primitives.push(o);return}p.push(o),je()}function cr(o,{prop:u="value",oldValue:c,newValue:m,read:y,write:S}={}){!o||c===m||De({kind:"value",target:o,prop:u,oldValue:c,newValue:m,read:y,write:S})}function U(){A===0&&h&&D(h.takeRecords()),p.length!==0&&(_(),qe())}function Ue(){A===0&&h&&D(h.takeRecords()),A++,P("paused",A)}function Be(){A!==0&&(A--,A===0&&h&&h.takeRecords(),P("resumed",A))}function We(o,u){if(Zt())return Me(),{ok:!1,code:"disconnected"};U();let c=o==="undo"?n:i,m=o==="undo"?i:n,y=c.at(-1);if(!y)return{ok:!1,code:"empty"};if(u&&u!==y.id){let B=He(u)||y;return me(B,o,"stale-entry")}let S;z=!0;try{S=At(y.certificate,o,{isIgnored:fe,ignoreAttribute:Le,isProtected:tr,inScope:wr,liveNodesWithIds:br})}finally{z=!1}if(!S.ok)return me(y,o,S.code,S.targets);Ue();let M;z=!0;try{M=Ct(S.operations)}finally{z=!1,Be()}if(!M.ok)return P(`${o} failed and was rolled back`,M.error),me(y,o,"replay-error");c.pop(),m.push(y),s=null;let j={ok:!0,entryId:y.id,label:y.label,direction:o};return P(o,y.label),t.emit(o,j),j}function fr(o){return We("undo",o&&o.entryId)}function pr(o){return We("redo",o&&o.entryId)}function He(o){return n.find(u=>u.id===o)||i.find(u=>u.id===o)||null}function me(o,u,c,m=[]){return s={entryId:o.id,direction:u,code:c,targets:m},P("refused",u,c),t.emit("refused",{entryId:o.id,label:o.label,direction:u,code:c,targets:m}),{ok:!1,code:c,entryId:o.id,label:o.label,direction:u}}function mr(o){if(!s||s.entryId!==o)return{ok:!1,code:"not-refused",entryId:o};let u=s.direction,c=u==="undo"?n:i,m=c.at(-1);return!m||m.id!==o?{ok:!1,code:"stale-entry",entryId:o}:(c.pop(),s=null,P("discarded",m.label),t.emit("discard",{entryId:o,label:m.label,direction:u}),{ok:!0,entryId:o,direction:u})}function gr(o){let u=He(o);if(!u||!u.certificate||!u.certificate.replayable)return null;let c=s&&s.entryId===u.id?{direction:s.direction,code:s.code,targets:(s.targets||[]).map(m=>({id:m.id??null,kind:m.kind??null}))}:null;return{id:u.id,label:u.label,timestamp:u.timestamp,refused:c,steps:u.certificate.steps.map(hr)}}function hr(o){if(o.type==="move")return{kind:"move",node:{id:R(o.node).id},from:{id:R(o.sourceParent).id},to:{id:R(o.destParent).id}};if(o.type==="add"||o.type==="restore")return{kind:o.type==="add"?"add":"remove",parent:{id:R(o.parent).id},nodes:o.nodes.map((S,M)=>({id:R(S).id,html:o.content[M]??null}))};let u=o.primitive,c={id:R(u.target).id},m=u.oldValue??null,y=u.newValue??null;return o.type==="value"?{kind:"value",target:c,prop:u.prop??"value",before:m,after:y}:o.type==="text"?{kind:"text",target:c,before:m,after:y}:o.type==="attr-set"||o.type==="attr-add"||o.type==="attr-remove"?{kind:"attribute",target:c,name:u.name??null,before:m,after:y}:{kind:o.type,target:c,before:m,after:y}}function yr(o){let u=new Set,c=!0;for(;c;){c=!1;for(let m of o)if(!(m.type!=="childList"||!m.removedNodes?.length)&&!(!ge(m.target)&&!Je(m.target,u)))for(let y of m.removedNodes)u.has(y)||(u.add(y),c=!0)}return m=>!ge(m)&&Je(m,u)}function Je(o,u){for(let c=o;c;c=c.parentNode)if(u.has(c))return!0;return!1}function ge(o){let u=r.scope;return!u||!o?!1:o===u||typeof u.contains=="function"&&u.contains(o)}function Fe(o){let u=pe(),c=u&&u.head;if(!c||!o)return!1;let m=o.nodeType===1?o:o.parentElement;for(;m&&m!==c;m=m.parentElement)if(m.localName==="title")return!1;return m===c}function wr(o){let u=r.scope;return!o||!u?!1:o===u||Q()===o||Fe(o)?!0:typeof u.contains=="function"?u.contains(o):!1}function br(o){let u=r.scope;if(!o||o.length===0||typeof u?.querySelectorAll!="function")return[];let c=new Set(o),m=[];for(let y of u.querySelectorAll("[data-id]"))c.has(y.getAttribute("data-id"))&&(fe(y)||m.push(y));return m}function vr(){h&&h.takeRecords(),n.length=0,i.length=0,p=[],s=null,_(),P("cleared"),t.emit("clear")}return{_config:r,start:Gt,stop:Me,commit:rr,commitCaptured:nr,discardCaptured:or,flush:U,command:dr,setRecording:sr,record:De,recordValue:cr,undo:fr,redo:pr,clear:vr,discard:mr,describe:gr,pause:Ue,resume:Be,on:t.on,off:t.off,get canUndo(){return n.length>0},get canRedo(){return i.length>0},get isPaused(){return A>0},get history(){return n.map(o=>{let u={id:o.id,label:o.label,timestamp:o.timestamp};return s&&s.entryId===o.id&&(u.refused={direction:s.direction,code:s.code,targets:s.targets}),u})},get future(){return i.map(o=>{let u={id:o.id,label:o.label,timestamp:o.timestamp};return s&&s.entryId===o.id&&(u.refused={direction:s.direction,code:s.code,targets:s.targets}),u}).reverse()},get scope(){return r.scope}}}var Wt=new Set(["checkbox","radio","button","submit","reset","image","file","range","color"]);function Ht(e){let r=typeof e.composedPath=="function"?e.composedPath():[],t=r.length>0?r:Jt(e.target);for(let n of t){if(!n||n.nodeType!==1)continue;let i=String(n.tagName||"").toUpperCase();if(i==="TEXTAREA"||i==="SELECT"||i==="INPUT"&&!Wt.has(String(n.type||n.getAttribute?.("type")||"text").toLowerCase())||n.isContentEditable===!0)return!0;let a=n.getAttribute&&n.getAttribute("contenteditable");if(a!=null&&String(a).toLowerCase()!=="false")return!0}return!1}function Jt(e){let r=[];for(let t=e;t;t=t.parentNode||(t.host??null))r.push(t);return r}function Ft(e,r){let t=n=>{let i=e.scope;if(i&&i.nodeType===1&&i.isConnected===!1){r&&r();return}if(n.defaultPrevented||n.isComposing||n.keyCode===229||Ht(n))return;let a=n.target,l=e._config.shadowKeydownIn;if(a&&a.closest&&Array.isArray(l))for(let p of l)try{if(a.closest(p))return}catch{}if(!(n.metaKey||n.ctrlKey))return;let s=(n.key||"").toLowerCase();if(s==="z"&&!n.shiftKey){n.preventDefault(),n.stopPropagation(),e.undo();return}if(s==="z"&&n.shiftKey){n.preventDefault(),n.stopPropagation(),e.redo();return}if(s==="y"&&!n.shiftKey){n.preventDefault(),n.stopPropagation(),e.redo();return}};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)}var le=[".CodeMirror",".cm-editor",".monaco-editor",".ace_editor",".ql-editor",".tiptap",".ProseMirror",".overtype-input","[data-richclay-active]"],g=null,de=null,Re=null,T=null;function Ce(e,r){if(T){if(T.inst===e)return T.cleanup;throw new Error("hyper-undo: another scope already owns the global Cmd+Z binding (bindKeys: true). Stop it first, or use bindKeys: false for additional scopes.")}let t=Ft(e,r);return T={inst:e,cleanup:t},t}function Oe(e){T&&T.inst===e&&(T.cleanup(),T=null)}var se={defaults:{shadowKeydownIn:le},start(e={}){let r=e.scope||(typeof document<"u"?document.body:null);if(!r)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");if(g){if(de===r)return console.warn("[hyper-undo] start() called again on existing singleton; ignoring new options"),g;throw new Error("hyper-undo: start() called with a different scope while the singleton is already started. Use undo.create({ scope }) for additional scopes, or call undo.stop() first.")}let t={...e,scope:r,shadowKeydownIn:e.shadowKeydownIn||le};return g=Se(t),g.start(),de=r,e.bindKeys!==!1&&(Re=Ce(g,()=>se.stop())),g},stop(){g&&(Oe(g),Re=null,g.stop(),g=null,de=null)},create(e={}){let r=e.scope||(typeof document<"u"?document.body:null);if(!r)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");let t={...e,scope:r,shadowKeydownIn:e.shadowKeydownIn||le},n=Se(t),i=null,a={_config:n._config,commit:n.commit,command:n.command,setRecording:n.setRecording,commitCaptured:n.commitCaptured,discardCaptured:n.discardCaptured,flush:n.flush,record:n.record,recordValue:n.recordValue,undo:n.undo,redo:n.redo,clear:n.clear,discard:n.discard,describe:n.describe,pause:n.pause,resume:n.resume,on:n.on,off:n.off,get canUndo(){return n.canUndo},get canRedo(){return n.canRedo},get isPaused(){return n.isPaused},get history(){return n.history},get future(){return n.future},get scope(){return n.scope},start(){e.bindKeys&&(i=Ce(n,()=>a.stop())),n.start()},stop(){Oe(n),i=null,n.stop()}};return a},commit(e,r){return g?g.commit(e,r):void 0},command(e,r){return g?g.command(e,r):void 0},setRecording(e){return g?g.setRecording(e):void 0},commitCaptured(e){return g?g.commitCaptured(e):void 0},discardCaptured(){return g?g.discardCaptured():void 0},record(e){return g?g.record(e):void 0},recordValue(e,r){return g?g.recordValue(e,r):void 0},undo(e){return g?g.undo(e):void 0},redo(e){return g?g.redo(e):void 0},clear(){return g?g.clear():void 0},discard(e){return g?g.discard(e):void 0},describe(e){return g?g.describe(e):void 0},pause(){return g?g.pause():void 0},resume(){return g?g.resume():void 0},flush(){return g?g.flush():void 0},on(e,r){return g?g.on(e,r):void 0},off(e,r){return g?g.off(e,r):void 0},get canUndo(){return g?g.canUndo:!1},get canRedo(){return g?g.canRedo:!1},get history(){return g?g.history:[]},get future(){return g?g.future:[]},get isPaused(){return g?g.isPaused:!1}},Xt=se;return X(C)})();window.__hyperclayNoAutoExport||(window.hyperclay=window.hyperclay||{},window.hyperclay.undo=et.undo,window.h=window.hyperclay);var w=et.undo;var ye=new Set,it=(d={})=>{let f=d.ignoreAttribute;return{...d,ignoreAttribute:(k,v,N)=>ye.has(k)||Xe(k,v)||Ye(v,k,N)||Ze(k,v)||(f?f(k,v,N):!1),isProtected:d.isProtected||Ar,ignoreNode:d.ignoreNode||Qe}};function Ar(d){let f=window.clay?.region?.resolveRegionPolicy;if(!f||d.nodeType!==1)return!1;let k=f(d);if(k.undoable!==!1||k.persist==="none")return!1;let v=d.parentElement;return!v||f(v).undoable!==!1}var Vr=w.create.bind(w);w.create=d=>Vr(it(d));var we=null,Er=w.setRecording.bind(w);w.setRecording=d=>(we=d??null,Er(d));var tt=()=>w.history.at(-1)?.id??null,Nr=w.command.bind(w);w.command=(d,f)=>{let k=Nr(d,f);return k&&re(),k};var xr=w.commit.bind(w),rt=!1;w.commit=(d,f)=>{!rt&&window.clay?.effect?.running&&(rt=!0,console.warn(`clay.effect: undo.commit("${d}") was called inside an effect. Run commands from event handlers, not from an effect.`));let k=tt(),v=xr(d,f);return(v||tt()!==k)&&re(),v};var Pr=`input${te}:not([type="password"]):not([type="hidden"]):not([type="file"]), textarea${te}, select${te}`;function Ir(){let d=f=>window.clay?.region?.resolveRegionPolicy?.(f)?.undoable!==!1;document.querySelectorAll(Pr).forEach(f=>{if(!d(f))return;if(f.tagName==="SELECT"){for(let C of f.options){let G=C.hasAttribute("selected");C.selected!==G&&(C.selected=G)}return}let k=(f.getAttribute("type")||"text").toLowerCase();if(f.tagName==="INPUT"&&(k==="checkbox"||k==="radio")){let C=f.hasAttribute("checked");f.checked!==C&&(f.checked=C);return}let v=f.tagName==="TEXTAREA"?f.getAttribute("data-value")??f.textContent:f.getAttribute("value")??"";if(f.value===v)return;let N=f===document.activeElement,W,X;try{W=f.selectionStart,X=f.selectionEnd}catch{}if(f.value=v,N&&W!=null)try{f.setSelectionRange(Math.min(W,v.length),Math.min(X,v.length))}catch{}})}var nt=d=>{d?.ok&&(re(),Ir())},ot=({entryId:d,label:f,direction:k,code:v})=>{document.dispatchEvent(new CustomEvent("clay:undo-refused",{detail:{ok:!1,code:v,entryId:d,label:f,direction:k}})),Sr({ok:!1,code:v,entryId:d,label:f,direction:k})},he=null;function at(){return he??=import("../c-NEL7HQW3.js").catch(d=>(he=null,console.error("clayjs: the undo recovery module could not be downloaded; a refused step stays in this tab only",d),null)),he}async function Sr(d){let f={ok:!1,code:"unavailable"};try{let v=await at();v&&(f=await v.keepRefusal(w,d))}catch{f={ok:!1,code:"error"}}let k=f?.ok===!0?{ok:!0,entryId:d.entryId,direction:d.direction}:{ok:!1,code:f?.code||"error",entryId:d.entryId,direction:d.direction};document.dispatchEvent(new CustomEvent("clay:undo-kept",{detail:k}))}var ve=(d,f)=>(...k)=>at().then(v=>v?v[d](...k):f,()=>f),Rr=ve("keep",{ok:!1,code:"unavailable"});w.ignoreAttribute=d=>{let f=String(d||"");return f?(ye.add(f),()=>{ye.delete(f)}):()=>{}};w.keep=async d=>{let f=await Rr(d);return f?.ok===!0&&document.dispatchEvent(new CustomEvent("clay:undo-kept",{detail:{ok:!0,key:d?.key==null?null:`app:${d.key}`}})),f};w.kept=ve("kept",{ok:!1,code:"unavailable",records:[]});w.dismissKept=ve("dismissKept",{ok:!1,code:"unavailable"});var be=new Set;w.reviewActions=d=>typeof d!="function"?()=>{}:(be.add(d),()=>{be.delete(d)});w.reviewActionsFor=d=>{let f=[];for(let k of be){let v;try{v=k(d)}catch(N){console.error("clayjs: a review action could not describe itself; the copy stays reviewable",N);continue}for(let N of Array.isArray(v)?v:[])N&&typeof N.run=="function"&&N.label&&f.push(N)}return f};var Cr=["commit","undo","redo","refused","discard","clear"],ne=()=>{let d=!!F?.started;document.dispatchEvent(new CustomEvent("clay:undo-change",{detail:{canUndo:d&&w.canUndo,canRedo:d&&w.canRedo,undo:d&&w.history.at(-1)||null,redo:d&&w.future?.[0]||null}}))},F=null;function Or(){return{started:!1,admitted:!1,subscriptions:[]}}var Mr=d=>d?d.signal?.aborted?!0:typeof d.isCurrent=="function"&&!d.isCurrent():!1;function Tr(){return typeof document>"u"||document.readyState!=="loading"?Promise.resolve():new Promise(d=>document.addEventListener("DOMContentLoaded",d,{once:!0}))}function jr(d){return{enable(){if(!d.started){d.started=!0,d.admitted=!0,w.start(it({bindKeys:!0,...we?{recording:we}:{}}));for(let f of["undo","redo"])w.on(f,nt),d.subscriptions.push({type:f,handler:nt});w.on("refused",ot),d.subscriptions.push({type:"refused",handler:ot});for(let f of Cr)w.on(f,ne),d.subscriptions.push({type:f,handler:ne});ne()}},quiesce(){d.admitted&&(d.admitted=!1,w.pause())},resume(){d.admitted||(d.admitted=!0,w.resume())},dispose(){if(d.admitted=!1,F===d&&(F=null),!!d.started){d.started=!1;for(let{type:f,handler:k}of d.subscriptions.splice(0))w.off(f,k);w.stop(),ne()}}}}function qr(){return{id:"clay:undo",order:350,async prepare(d={}){if(d.initial===!0)return Lr();if(await Tr(),Mr(d))throw Object.assign(new Error("clay:undo prepared for a stale generation"),{code:"stale-document"});return jr(F||(F=Or()))}}}async function Lr(){let d=await Kr;return{enable(){},quiesce:()=>d?.quiesce(),resume:()=>d?.resume(),dispose:()=>d?.dispose()}}async function $r(){if(!Ge()||typeof document>"u")return null;let d=await qr().prepare();return d.enable(),d}var Kr=$r();var Gr=w;export{Gr as default,$r as init,qr as modeParticipant,Kr as ready,Ir as restoreControls,w as undo,qr as undoParticipant};
1
+ import{b as Ze,c as Qe}from"../c-7DJDKPGL.js";import{g as re}from"../c-GSRLXYWL.js";import{a as te}from"../c-WYFDLITL.js";import"../c-LA2BW7UY.js";import"../c-IJUK2GPW.js";import{k as Ge}from"../c-3O7OBDCM.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-N7JPUPGC.js";import{a as Ye}from"../c-VG5XIN4T.js";import"../c-2YYDMLNZ.js";import{l as Xe}from"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var et=(()=>{var d=Object.defineProperty,f=Object.getOwnPropertyDescriptor,k=Object.getOwnPropertyNames,v=Object.prototype.hasOwnProperty,N=(e,r)=>{for(var t in r)d(e,t,{get:r[t],enumerable:!0})},W=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of k(r))!v.call(e,i)&&i!==t&&d(e,i,{get:()=>r[i],enumerable:!(n=f(r,i))||n.enumerable});return e},X=e=>W(d({},"__esModule",{value:!0}),e),C={};N(C,{default:()=>Xt,undo:()=>se});function G(e,r=null){let t=[];if(e.type==="attributes"){let n=e.target,i=e.attributeName,a=e.oldValue,l=n.getAttribute(i);return a==null&&l!=null?t.push({kind:"attr-add",target:n,name:i,newValue:l}):a!=null&&l==null?t.push({kind:"attr-remove",target:n,name:i,oldValue:a}):a!==l&&t.push({kind:"attr-set",target:n,name:i,oldValue:a,newValue:l}),t}if(e.type==="characterData")return t.push({kind:"text",target:e.target,oldValue:e.oldValue,newValue:e.target.data}),t;if(e.type==="childList"){let n=e.target,i=e.nextSibling,a=e.nextSibling;for(;a&&r?.(a);)a=a.nextSibling;let l=e.previousSibling;for(;l&&r?.(l);)l=l.previousSibling;let s=r?Array.from(e.addedNodes).filter(b=>!r(b)):Array.from(e.addedNodes),p=r?Array.from(e.removedNodes).filter(b=>!r(b)):Array.from(e.removedNodes);return s.length>0&&t.push({kind:"add",parent:n,nodes:s,before:i,afterAuthored:a,beforeAuthored:l,record:e}),p.length>0&&t.push({kind:"remove",parent:n,nodes:p,before:i,afterAuthored:a,beforeAuthored:l,record:e}),t}return t}function ut(e,r=null){let t=[],n=new Map;for(let i of e){if(i.type==="attributes"){let a=i.target,l=i.attributeName,s=n.get(a);s||(s=new Map,n.set(a,s)),s.has(l)||(s.set(l,{idx:t.length,oldValue:i.oldValue}),t.push(null));continue}for(let a of G(i,r))t.push(a)}for(let[i,a]of n)for(let[l,s]of a){let p=s.oldValue,b=i.getAttribute(l),h=null;p===b?h=null:p==null?h={kind:"attr-add",target:i,name:l,newValue:b}:b==null?h={kind:"attr-remove",target:i,name:l,oldValue:p}:h={kind:"attr-set",target:i,name:l,oldValue:p,newValue:b},t[s.idx]=h}return t.filter(i=>i!=null)}function lt(e){let r=[],t=new Map;for(let i of e){let a=ke(i);if(a==null){r.push(i);continue}let l=t.get(i.target);l||(l=new Map,t.set(i.target,l));let s=l.get(a);if(s==null){let p=Ae(i);if(p.oldValue===p.newValue)continue;l.set(a,r.length),r.push({...i,...p})}else r[s]={...r[s],newValue:Ae(i).newValue}}let n=[];for(let i of r){if(ke(i)==null){n.push(i);continue}i.oldValue!==i.newValue&&n.push(st(i))}return n}var dt=new Set(["attr-set","attr-add","attr-remove","text","value"]);function ke(e){return dt.has(e.kind)?e.kind==="text"?"#text":e.kind==="value"?`#${e.prop||"value"}`:e.name==null?null:`@${e.name}`:null}function Ae(e){return e.kind==="attr-add"?{oldValue:null,newValue:e.newValue}:e.kind==="attr-remove"?{oldValue:e.oldValue,newValue:null}:{oldValue:e.oldValue,newValue:e.newValue}}function st(e){return e.kind!=="attr-add"&&e.kind!=="attr-remove"?e:e.oldValue==null&&e.newValue!=null?{...e,kind:"attr-add"}:e.oldValue!=null&&e.newValue==null?{...e,kind:"attr-remove"}:{...e,kind:"attr-set"}}var Ve=new WeakMap,ct=0;function O(e){let r=Ve.get(e);return r||(r=`n${++ct}`,Ve.set(e,r)),r}function x(e){return!!e&&typeof e=="object"&&typeof e.nodeType=="number"}function ft(e){return e.kind==="add"||e.kind==="remove"}function Ee(e,r){let t=[],n=e.childNodes;if(!n)return t;for(let i of n)r&&r(i)||t.push(O(i));return t}function H(e,r,t=null,n=null){if(!x(e))return null;if(e.nodeType===3)return`#text:${JSON.stringify(e.data)}`;if(e.nodeType===8)return`#comment:${JSON.stringify(e.data)}`;if(e.nodeType!==1)return`#node:${e.nodeType}`;let i=[];if(e.attributes){for(let l of e.attributes)pt(l.name,e,r,t)||i.push(`${l.name}=${JSON.stringify(l.value)}`);i.sort()}let a=[];if(e.childNodes)for(let l of e.childNodes)mt(l,n)||a.push(H(l,r,t,n));return`<${String(e.tagName||"").toLowerCase()}${i.length?` ${i.join(" ")}`:""}>${a.join("")}</>`}function oe(e,r=[]){if(!x(e))return r;if(e.nodeType===1){let t=e.getAttribute&&e.getAttribute("data-id");t&&r.push(t)}if(e.childNodes)for(let t of e.childNodes)oe(t,r);return r}function pt(e,r,t,n=null){if(typeof t!="function")return!1;try{return!!t(e,r,n)}catch{return!1}}function mt(e,r){if(typeof r!="function")return!1;try{return!!r(e)}catch{return!1}}function Ne(e,r){if(typeof r!="function")return[];let t=[],n=i=>{if(!x(i))return;let a=!1;try{a=!!r(i)}catch{a=!1}if(a&&t.push(R(i,"protected")),i.childNodes)for(let l of i.childNodes)n(l)};for(let i of e)n(i);return t}function R(e,r,t=null){let n=e;n&&n.nodeType!==1&&(n=n.parentElement);let i=n&&typeof n.closest=="function"?n.closest("[data-id]"):null;return!i&&t&&typeof t.closest=="function"&&(i=t.closest("[data-id]")),{id:(i?i.getAttribute("data-id"):null)||null,kind:r||null}}function gt(e,r,t=null){return(e||[]).filter(x).map(n=>R(n,r,t))}function J(e){return{replayable:!1,reason:e,steps:[]}}function Y(e,r){let t=[[r.afterAuthored,i=>i],[r.beforeAuthored,i=>i+1],[r.before,i=>i]],n=!1;for(let[i,a]of t){if(!x(i))continue;n=!0;let l=e.indexOf(O(i));if(l>=0)return a(l)}return n?null:e.length}function ht(e,r={}){let t=r.isIgnored||null,n=r.ignoreAttribute||null,i=lt(e),a=[];for(let h of i){if(!ft(h)){if(!x(h.target))return J("non-dom-target");continue}if(!x(h.parent))return J("non-dom-parent");let A=Array.from(h.nodes||[]).filter(x);if(A.length!==0){if(A.length!==Array.from(h.nodes||[]).length)return J("non-dom-node");a.push({primitive:h,nodes:A,parent:h.parent})}}if(yt(a))return J("in-record-move");let l=wt(a,t);if(!l)return J("ambiguous-structure");let s=bt(a,l),p=new Map(a.map(h=>[h.primitive,h])),b=[];for(let h of i){let A=p.get(h);if(!A){b.push(kt(h));continue}let E=s.get(A);if(E){E.at===A&&b.push(E.step);continue}b.push(vt(A,l.get(A),n,t))}return{replayable:!0,reason:null,steps:b}}function yt(e){let r=new Map;for(let t of e){let n=t.primitive.record;if(!n)continue;let i=r.get(n);i||(i=new Map,r.set(n,i));for(let a of t.nodes){let l=i.get(a);l||(l=new Set,i.set(a,l)),l.add(t.primitive.kind)}}for(let t of r.values())for(let n of t.values())if(n.size>1)return!0;return!1}function wt(e,r){let t=new Map;for(let i of e)t.has(i.parent)||t.set(i.parent,Ee(i.parent,r));let n=new Map;for(let i=e.length-1;i>=0;i--){let a=e[i],l=t.get(a.parent);if(!l)return null;let s=l.slice(),p;if(a.primitive.kind==="add"){let b=a.nodes.map(O);if(!b.every(h=>l.includes(h)))return null;p=l.filter(h=>!b.includes(h))}else{let b=Y(s,a.primitive);if(b==null)return null;p=s.slice(),p.splice(b,0,...a.nodes.map(O))}n.set(a,{before:p,after:s}),t.set(a.parent,p)}return n}function bt(e,r){let t=new Map,n=new Map;e.forEach((a,l)=>{for(let s of a.nodes){let p=O(s);a.primitive.kind==="remove"?t.set(p,{item:a,index:l,node:s}):n.set(p,{item:a,index:l,node:s})}});let i=new Map;for(let[a,l]of t){let s=n.get(a);if(!s||s.index<l.index||l.item.nodes.length!==1||s.item.nodes.length!==1)continue;let p={type:"move",node:l.node,sourceParent:l.item.parent,destParent:s.item.parent,source:r.get(l.item),dest:r.get(s.item),sourceSlot:l.item.primitive,destSlot:s.item.primitive,targets:[R(l.node,"move")]};i.set(l.item,{step:p,at:s.item}),i.set(s.item,{step:p,at:s.item})}return i}function vt(e,r,t,n){let i=e.primitive.kind;return{type:i==="add"?"add":"restore",parent:e.parent,nodes:e.nodes,seqBefore:r.before,seqAfter:r.after,slot:e.primitive,content:e.nodes.map(a=>H(a,t,e.parent,n)),ids:i==="remove"?e.nodes.flatMap(a=>oe(a)):[],targets:gt(e.nodes,i==="add"?"added":"removed",e.parent)}}function kt(e){return{type:e.kind,primitive:e,targets:[R(e.target,e.name||e.prop||"text")]}}function At(e,r,t={}){if(!e||!e.replayable)return{ok:!1,code:"unsupported",targets:[]};let n={isIgnored:t.isIgnored||null,ignoreAttribute:t.ignoreAttribute||null,isProtected:t.isProtected||null,inScope:t.inScope||(()=>!0),liveNodesWithIds:t.liveNodesWithIds||(()=>[]),sim:new Map,planned:new Map,operations:[]};for(let i=0;i<e.steps.length;i++){let a=e.steps[r==="undo"?e.steps.length-1-i:i],l=Et(a,r,n);if(l)return{ok:!1,code:l.code,targets:l.targets}}return{ok:!0,operations:n.operations}}function q(e,r){return e.sim.has(r)||e.sim.set(r,Ee(r,e.isIgnored)),e.sim.get(r)}function L(e,r){for(let t=e;t;t=t.parentNode)if(r.planned.has(t))return r.planned.get(t);return r.inScope(e)}function xe(e,r){return r.liveNodesWithIds(e).filter(t=>L(t,r)).length>0}function V(e,r){return{code:e,targets:r||[]}}function Vt(e){return e.kind==="text"?e.target.data:e.kind==="value"?typeof e.read=="function"?e.read(e.target):e.target[e.prop||"value"]:e.target.getAttribute(e.name)}function Et(e,r,t){let n=r==="undo";return e.type==="move"?St(e,n,t):e.type==="add"?xt(e,n,t):e.type==="restore"?Pt(e,n,t):Nt(e,n,t)}function Nt(e,r,t){let n=e.primitive,i=r?n.newValue:n.oldValue,a=r?n.oldValue:n.newValue;return x(n.target)?L(n.target,t)?n.kind==="value"&&typeof n.write=="function"&&typeof n.read!="function"?V("unsupported",e.targets):Vt(n)!==i?V("content-changed",e.targets):(n.kind==="value"?t.operations.push({type:"value",target:n.target,prop:n.prop||"value",value:a,read:n.read||null,write:n.write||null}):n.kind==="text"?t.operations.push({type:"text",target:n.target,data:a}):t.operations.push({type:"attr",target:n.target,name:n.name,value:a??null}),null):V("target-detached",e.targets):V("unsupported",e.targets)}function xt(e,r,t){if(!x(e.parent)||!L(e.parent,t))return V("target-detached",e.targets);if(r){if(!$(q(t,e.parent),e.seqAfter))return V("structure-changed",e.targets);let s=Ne(e.nodes,t.isProtected);if(s.length>0)return V("protected",s);for(let p=0;p<e.nodes.length;p++)if(H(e.nodes[p],t.ignoreAttribute,e.parent,t.isIgnored)!==e.content[p])return V("content-changed",e.targets);for(let p of e.nodes)t.operations.push({type:"remove",node:p}),t.planned.set(p,!1);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!$(q(t,e.parent),e.seqBefore))return V("structure-changed",e.targets);for(let s of e.nodes)if(s.parentNode)return V("structure-changed",e.targets);let n=e.nodes.flatMap(s=>oe(s));if(n.length>0&&xe(n,t))return V("duplicate-id",e.targets);let i=Y(e.seqBefore,e.slot);if(i==null)return V("unsupported",e.targets);let a=e.seqBefore.slice(),l=i;for(let s of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:s,beforeId:a[l]??null}),a=a.slice(0,l).concat(O(s),a.slice(l)),l+=1,t.planned.set(s,!0);return t.sim.set(e.parent,e.seqAfter.slice()),null}function Pt(e,r,t){if(!x(e.parent)||!L(e.parent,t))return V("target-detached",e.targets);if(r){if(!$(q(t,e.parent),e.seqAfter))return V("structure-changed",e.targets);for(let p=0;p<e.nodes.length;p++){let b=e.nodes[p];if(b.parentNode||H(b,t.ignoreAttribute,e.parent,t.isIgnored)!==e.content[p])return V("content-changed",e.targets)}if(e.ids.length>0&&xe(e.ids,t))return V("duplicate-id",e.targets);let a=Y(e.seqAfter,e.slot);if(a==null)return V("unsupported",e.targets);let l=e.seqAfter.slice(),s=a;for(let p of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:p,beforeId:l[s]??null}),l=l.slice(0,s).concat(O(p),l.slice(s)),s+=1,t.planned.set(p,!0);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!$(q(t,e.parent),e.seqBefore))return V("structure-changed",e.targets);let n=Ne(e.nodes,t.isProtected);if(n.length>0)return V("protected",n);let i=a=>t.planned.get(a)===!0||typeof t.isIgnored=="function"&&t.isIgnored(a);for(let a=0;a<e.nodes.length;a++){let l=e.nodes[a];if(l.parentNode!==e.parent||H(l,t.ignoreAttribute,e.parent,i)!==e.content[a])return V("content-changed",e.targets)}for(let a of e.nodes)t.operations.push({type:"remove",node:a}),t.planned.set(a,!1);return t.sim.set(e.parent,e.seqAfter.slice()),null}function It(e,r){let t=e.indexOf(r);return t<0?null:e.slice(0,t).concat(e.slice(t+1))}function St(e,r,t){let n=O(e.node),i=r?e.destParent:e.sourceParent,a=r?e.sourceParent:e.destParent,l=q(t,i),s=q(t,a),p=r?e.dest.after:e.source.before,b=r?e.source.after:e.dest.before,h=r?e.sourceSlot:e.destSlot;if(!x(i)||!x(a)||!L(i,t)||!L(a,t))return V("target-detached",e.targets);if(!$(l,p))return V("structure-changed",e.targets);let A=i===a?It(s,n):s;if(!$(A,b))return V("structure-changed",e.targets);let E=Y(b,h);return E==null?V("unsupported",e.targets):(t.operations.push({type:"insert",parent:a,node:e.node,beforeId:b[E]??null}),t.planned.set(e.node,!0),r?(t.sim.set(a,e.source.before.slice()),i!==a&&t.sim.set(i,e.dest.before.slice())):(t.sim.set(a,e.dest.after.slice()),i!==a&&t.sim.set(i,e.source.after.slice())),null)}function $(e,r){if(!e||!r||e.length!==r.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==r[t])return!1;return!0}function Rt(e,r){for(let t of e.childNodes||[])if(O(t)===r)return t;return null}function Pe(e,r){typeof e.write=="function"?e.write(e.target,r):e.target[e.prop]=r}function Ct(e){let r=[];try{for(let t of e)Ot(t,r);return{ok:!0}}catch(t){for(let n=r.length-1;n>=0;n--)try{r[n]()}catch{}return{ok:!1,error:t}}}function Ot(e,r){if(e.type==="attr"){let t=e.target.getAttribute(e.name);e.value==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,e.value),r.push(()=>{t==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,t)});return}if(e.type==="text"){let t=e.target.data;e.target.data=e.data,r.push(()=>{e.target.data=t});return}if(e.type==="value"){let t=typeof e.read=="function"?e.read(e.target):e.target[e.prop];Pe(e,e.value),r.push(()=>Pe(e,t));return}if(e.type==="insert"){let t=e.beforeId==null?null:Rt(e.parent,e.beforeId);if(e.beforeId!=null&&!t)throw new Error("hyper-undo: replay anchor vanished");let n=e.node.parentNode,i=e.node.nextSibling;e.parent.insertBefore(e.node,t),r.push(()=>{n?n.insertBefore(e.node,i&&i.parentNode===n?i:null):e.node.parentNode===e.parent&&e.parent.removeChild(e.node)});return}if(e.type==="remove"){let t=e.node.parentNode;if(!t)throw new Error("hyper-undo: replay target is no longer attached");let n=e.node.nextSibling;t.removeChild(e.node),r.push(()=>t.insertBefore(e.node,n))}}var Mt=['[src^="chrome-extension://"]','[href^="chrome-extension://"]','[src^="moz-extension://"]','[href^="moz-extension://"]','[src^="safari-web-extension://"]','[href^="safari-web-extension://"]','[id="1p-menu-live-region"]',"com-1password-button","com-1password-menu","com-1password-notification","grammarly-extension","grammarly-desktop-integration","lt-div","lt-card","lt-toolbar","lt-highlighter","[data-lastpass-root]","[data-lastpass-icon-root]","[data-dashlane-shadowhost]","[data-klarna-extension]",'[class*="klarna-extension"]',".skiptranslate","#goog-gt-tt",".goog-te-banner-frame",".goog-te-balloon-frame","style.darkreader","style[data-darkreader-mode]","style[data-darkreader-scheme]","#loom-companion-mv3","loom-container","[ext-id]"],Tt=["data-grammarly","data-lt","data-1p","data-com-onepassword","data-lastpass","data-lp","data-kwimpala","data-bitwarden","data-bw","data-dashlane","data-np","data-protonpass","data-proton-pass","data-keeper","data-rf","data-roboform","data-honey","data-rakuten","data-capital-one","data-wikibuy","data-klarna","data-darkreader","data-evernote","data-pocket","data-pin"],jt=Mt.join(","),qt=new RegExp("^(?:"+Tt.join("|")+")(?:-|$)"),zr=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),Lt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),$t=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function ie(e,r){if(!e||e.nodeType!==1)return!1;let t=e.getAttribute?.("clay");return!!(t&&t.split(/\s+/).includes(r)||e.hasAttribute?.(r))}function Ie(e,r){if(ie(e,r))return!0;for(let[t,n]of Object.entries(Lt))if(n.includes(r)&&ie(e,t))return!0;return!1}function Kt(e){return e==="clay"||$t.includes(e)}var zt=["mutations-ignore","save-remove","save-ignore","save-freeze","no-undo","no-watch"];function Dt(){if(typeof window>"u")return null;let e=window.clay?.region||window.hyperclay?.region;return e&&typeof e.resolveRegionPolicy=="function"?e.resolveRegionPolicy:null}function ae(e){let r=Dt();if(r)try{if(!r(e).undoable)return!0}catch{}let t=e&&e.nodeType!==1?e.parentElement:e;if(t&&t.closest&&t.closest(jt))return!0;for(;t&&t.nodeType===1;){if(Ie(t,"no-undo")||Ie(t,"no-watch"))return!0;for(let n of zt)if(ie(t,n))return!0;t=t.parentElement}return!1}function _t(e){let r=e.target,t=r.cloneNode(!1),n=t;for(;r.parentElement;){r=r.parentElement;let i=r.cloneNode(!1);i.appendChild(t),t=i}return e.oldValue==null?n.removeAttribute(e.attributeName):n.setAttribute(e.attributeName,e.oldValue),ae(n)}function ue(e,r,t){if(t?.type==="attributes"&&Kt(t.attributeName)){if(ae(e)&&_t(t))return!0}else if(ae(e))return!0;if(t&&t.type==="attributes"){if(t.attributeName&&qt.test(t.attributeName.toLowerCase()))return!0;if(r)try{if(r(t.attributeName,t.target))return!0}catch{}}return!1}function Ut(){let e=new Map;function r(i,a){let l=e.get(i);return l||(l=new Set,e.set(i,l)),l.add(a),()=>t(i,a)}function t(i,a){let l=e.get(i);l&&l.delete(a)}function n(i,a){let l=e.get(i);if(l)for(let s of Array.from(l))try{s(a)}catch(p){console.error("[hyper-undo] listener threw",p)}}return{on:r,off:t,emit:n}}var Bt={maxHistory:100,idleWindowMs:500,idleLabel:"Edit",recording:"automatic",ignoreAttribute:null,isProtected:null,ignoreNode:null,debug:!1};function Se(e){let r={...Bt,...e};if(!r.scope)throw new Error("hyper-undo: scope is required");let t=Ut(),n=[],i=[],a=`u${Math.random().toString(36).slice(2,8)}`,l=0,s=null,p=[],b=null,h=null,A=0,E=!1,K=r.recording==="commands"?"commands":"automatic",I=null,z=!1;function P(...o){r.debug&&console.log("[hyper-undo]",...o)}function Gt(){E||(E=!0,h=Yt(D),h.observe(r.scope,{childList:!0,attributes:!0,characterData:!0,subtree:!0,attributeOldValue:!0,characterDataOldValue:!0}),P("started"))}function Yt(o){let u=typeof document<"u"&&r.scope===document.body,c=typeof window<"u"&&(window.clay?.Mutation||window.hyperclay?.Mutation)||null;return u&&c&&typeof c.createObserver=="function"?(P("sourcing records from the platform Mutation hub (shared observer)"),c.createObserver(o)):new MutationObserver(o)}function Me(){E&&(E=!1,h&&(h.disconnect(),h=null),_(),n.length=0,i.length=0,p=[],s=null,I=null,z=!1,A=0,P("stopped"))}function Zt(){let o=r.scope;return!!(o&&o.nodeType===1&&o.isConnected===!1)}function D(o){Te(o,!1)}function Te(o,u){if(I){for(let m of o)I.records.push(m);return}if(K==="commands"||A>0)return;let c=ce(Qt(o),u);if(c.length>0){for(let m of c)p.push(m);je()}}function Qt(o){return typeof r.ignoreNode!="function"?o:o.filter(u=>{if(u.type!=="childList")return!0;let c=[...u.addedNodes,...u.removedNodes];return c.length===0?!0:!c.every(m=>er(m))})}function er(o){try{return!!r.ignoreNode(o)}catch{return!1}}function ce(o,u=!1){let c=yr(o),m=o.filter(y=>(ge(y.target)||c(y.target)||u&&Fe(y.target))&&!ue(y.target,r.ignoreAttribute,y));return ut(m,y=>ue(y,r.ignoreAttribute))}function je(){_(),b=setTimeout(qe,r.idleWindowMs)}function _(){b!=null&&(clearTimeout(b),b=null)}function qe(){if(b=null,p.length===0)return;let o=p;p=[],Z(r.idleLabel,o)}function Z(o,u){let c=ht(u,{isIgnored:fe,ignoreAttribute:Le});if(c.steps.length===0)return P("commit",o,"with nothing to record"),t.emit("commit"),null;let m={id:`${a}-${++l}`,label:o,timestamp:Date.now(),primitives:u,certificate:c};for(n.push(m),i.length=0,s=null;n.length>r.maxHistory;)n.shift();return P("commit",o,"primitives:",u.length),t.emit("commit"),m}function fe(o){return ue(o,r.ignoreAttribute)}function Le(o,u,c=null){if(typeof r.ignoreAttribute!="function")return!1;try{return!!r.ignoreAttribute(o,u,c)}catch{return!1}}function tr(o){if(typeof r.isProtected!="function")return!1;try{return!!r.isProtected(o)}catch{return!1}}function rr(o,u){if(!E)throw new Error("hyper-undo: scope not started");if(K==="commands")return ze(o,u,{honorPause:!0,receipt:!1});D(h.takeRecords()),U();let c=A===0?$e():null,m=u();if(m&&typeof m.then=="function")throw new Error("hyper-undo: commit() fn must be synchronous; returned a Promise");if(Te(h.takeRecords(),!0),c!=null&&Ke(c),p.length===0){t.emit("commit");return}_();let y=p;p=[],Z(o,y)}function nr(o){if(!E)throw new Error("hyper-undo: scope not started");if(!h)return;if(A>1){h.takeRecords();return}U();let u=ce(h.takeRecords(),!0);u.length!==0&&(_(),Z(o,u))}function or(){h&&h.takeRecords()}function pe(){let o=r.scope;return o&&o.ownerDocument||(typeof document<"u"?document:null)}function Q(){let o=pe();return!o||!o.head||typeof o.head.querySelector!="function"?null:o.head.querySelector("title")}function $e(){let o=Q();return o?o.textContent:null}function Ke(o){let u=Q();if(!u||o==null)return;let c=u.textContent;c!==o&&_e({kind:"value",target:u,prop:"textContent",oldValue:o,newValue:c})}function ir(o){if(!o)return null;let u=pe();if(!u||o.target!==u||o.prop!=="title")return o;let c=Q();return c?{kind:"value",target:c,prop:"textContent",oldValue:o.oldValue,newValue:o.newValue}:null}function ar(){if(typeof window>"u")return!1;let o=window.clay?.effect||window.hyperclay?.effect;return!!(o&&o.running)}function ur(){h&&D(h.takeRecords()),U(),I={records:[],primitives:[]}}function lr(){let o=I;if(I=null,!o)return[];let u=ce(o.records,!0);for(let c of o.primitives)u.push(c);return u}function ze(o,u,{honorPause:c,receipt:m}){if(typeof u!="function")throw new Error("hyper-undo: command() needs a synchronous function");if(I)throw new Error("hyper-undo: command() cannot nest inside another command");if(z)throw new Error("hyper-undo: command() cannot run during undo or redo");if(ar())throw new Error("hyper-undo: command() cannot run inside a derived-effect context");if(u.constructor&&u.constructor.name==="AsyncFunction")throw new Error("hyper-undo: command() fn must be synchronous; it was declared async");let y=c&&A>0,S=y?null:$e();ur();let M=[],j=null,B;try{try{B=u()}catch(kr){j=kr}if(h&&D(h.takeRecords()),B&&typeof B.then=="function"){try{B.then(void 0,()=>{})}catch{}j||(j=new Error("hyper-undo: command() fn must be synchronous; returned a Promise"))}y||Ke(S)}finally{M=lr()}let ee=y||M.length===0?null:Z(o,M);if(j)throw j;return m?ee?{id:ee.id,label:ee.label}:null:ee}function dr(o,u){if(!E)throw new Error("hyper-undo: scope not started");return ze(o,u,{honorPause:!1,receipt:!0})}function sr(o){if(o!=="automatic"&&o!=="commands")throw new Error("hyper-undo: setRecording() takes 'automatic' or 'commands'");if(I)throw new Error("hyper-undo: setRecording() cannot change while a command is running");return K===o||(U(),K=o,P("recording",o)),K}function De(o){if(!E||!o||!I&&(A>0||K==="commands"))return;let u=ir(o);u&&_e(u)}function _e(o){if(I){I.primitives.push(o);return}p.push(o),je()}function cr(o,{prop:u="value",oldValue:c,newValue:m,read:y,write:S}={}){!o||c===m||De({kind:"value",target:o,prop:u,oldValue:c,newValue:m,read:y,write:S})}function U(){A===0&&h&&D(h.takeRecords()),p.length!==0&&(_(),qe())}function Ue(){A===0&&h&&D(h.takeRecords()),A++,P("paused",A)}function Be(){A!==0&&(A--,A===0&&h&&h.takeRecords(),P("resumed",A))}function We(o,u){if(Zt())return Me(),{ok:!1,code:"disconnected"};U();let c=o==="undo"?n:i,m=o==="undo"?i:n,y=c.at(-1);if(!y)return{ok:!1,code:"empty"};if(u&&u!==y.id){let B=He(u)||y;return me(B,o,"stale-entry")}let S;z=!0;try{S=At(y.certificate,o,{isIgnored:fe,ignoreAttribute:Le,isProtected:tr,inScope:wr,liveNodesWithIds:br})}finally{z=!1}if(!S.ok)return me(y,o,S.code,S.targets);Ue();let M;z=!0;try{M=Ct(S.operations)}finally{z=!1,Be()}if(!M.ok)return P(`${o} failed and was rolled back`,M.error),me(y,o,"replay-error");c.pop(),m.push(y),s=null;let j={ok:!0,entryId:y.id,label:y.label,direction:o};return P(o,y.label),t.emit(o,j),j}function fr(o){return We("undo",o&&o.entryId)}function pr(o){return We("redo",o&&o.entryId)}function He(o){return n.find(u=>u.id===o)||i.find(u=>u.id===o)||null}function me(o,u,c,m=[]){return s={entryId:o.id,direction:u,code:c,targets:m},P("refused",u,c),t.emit("refused",{entryId:o.id,label:o.label,direction:u,code:c,targets:m}),{ok:!1,code:c,entryId:o.id,label:o.label,direction:u}}function mr(o){if(!s||s.entryId!==o)return{ok:!1,code:"not-refused",entryId:o};let u=s.direction,c=u==="undo"?n:i,m=c.at(-1);return!m||m.id!==o?{ok:!1,code:"stale-entry",entryId:o}:(c.pop(),s=null,P("discarded",m.label),t.emit("discard",{entryId:o,label:m.label,direction:u}),{ok:!0,entryId:o,direction:u})}function gr(o){let u=He(o);if(!u||!u.certificate||!u.certificate.replayable)return null;let c=s&&s.entryId===u.id?{direction:s.direction,code:s.code,targets:(s.targets||[]).map(m=>({id:m.id??null,kind:m.kind??null}))}:null;return{id:u.id,label:u.label,timestamp:u.timestamp,refused:c,steps:u.certificate.steps.map(hr)}}function hr(o){if(o.type==="move")return{kind:"move",node:{id:R(o.node).id},from:{id:R(o.sourceParent).id},to:{id:R(o.destParent).id}};if(o.type==="add"||o.type==="restore")return{kind:o.type==="add"?"add":"remove",parent:{id:R(o.parent).id},nodes:o.nodes.map((S,M)=>({id:R(S).id,html:o.content[M]??null}))};let u=o.primitive,c={id:R(u.target).id},m=u.oldValue??null,y=u.newValue??null;return o.type==="value"?{kind:"value",target:c,prop:u.prop??"value",before:m,after:y}:o.type==="text"?{kind:"text",target:c,before:m,after:y}:o.type==="attr-set"||o.type==="attr-add"||o.type==="attr-remove"?{kind:"attribute",target:c,name:u.name??null,before:m,after:y}:{kind:o.type,target:c,before:m,after:y}}function yr(o){let u=new Set,c=!0;for(;c;){c=!1;for(let m of o)if(!(m.type!=="childList"||!m.removedNodes?.length)&&!(!ge(m.target)&&!Je(m.target,u)))for(let y of m.removedNodes)u.has(y)||(u.add(y),c=!0)}return m=>!ge(m)&&Je(m,u)}function Je(o,u){for(let c=o;c;c=c.parentNode)if(u.has(c))return!0;return!1}function ge(o){let u=r.scope;return!u||!o?!1:o===u||typeof u.contains=="function"&&u.contains(o)}function Fe(o){let u=pe(),c=u&&u.head;if(!c||!o)return!1;let m=o.nodeType===1?o:o.parentElement;for(;m&&m!==c;m=m.parentElement)if(m.localName==="title")return!1;return m===c}function wr(o){let u=r.scope;return!o||!u?!1:o===u||Q()===o||Fe(o)?!0:typeof u.contains=="function"?u.contains(o):!1}function br(o){let u=r.scope;if(!o||o.length===0||typeof u?.querySelectorAll!="function")return[];let c=new Set(o),m=[];for(let y of u.querySelectorAll("[data-id]"))c.has(y.getAttribute("data-id"))&&(fe(y)||m.push(y));return m}function vr(){h&&h.takeRecords(),n.length=0,i.length=0,p=[],s=null,_(),P("cleared"),t.emit("clear")}return{_config:r,start:Gt,stop:Me,commit:rr,commitCaptured:nr,discardCaptured:or,flush:U,command:dr,setRecording:sr,record:De,recordValue:cr,undo:fr,redo:pr,clear:vr,discard:mr,describe:gr,pause:Ue,resume:Be,on:t.on,off:t.off,get canUndo(){return n.length>0},get canRedo(){return i.length>0},get isPaused(){return A>0},get history(){return n.map(o=>{let u={id:o.id,label:o.label,timestamp:o.timestamp};return s&&s.entryId===o.id&&(u.refused={direction:s.direction,code:s.code,targets:s.targets}),u})},get future(){return i.map(o=>{let u={id:o.id,label:o.label,timestamp:o.timestamp};return s&&s.entryId===o.id&&(u.refused={direction:s.direction,code:s.code,targets:s.targets}),u}).reverse()},get scope(){return r.scope}}}var Wt=new Set(["checkbox","radio","button","submit","reset","image","file","range","color"]);function Ht(e){let r=typeof e.composedPath=="function"?e.composedPath():[],t=r.length>0?r:Jt(e.target);for(let n of t){if(!n||n.nodeType!==1)continue;let i=String(n.tagName||"").toUpperCase();if(i==="TEXTAREA"||i==="SELECT"||i==="INPUT"&&!Wt.has(String(n.type||n.getAttribute?.("type")||"text").toLowerCase())||n.isContentEditable===!0)return!0;let a=n.getAttribute&&n.getAttribute("contenteditable");if(a!=null&&String(a).toLowerCase()!=="false")return!0}return!1}function Jt(e){let r=[];for(let t=e;t;t=t.parentNode||(t.host??null))r.push(t);return r}function Ft(e,r){let t=n=>{let i=e.scope;if(i&&i.nodeType===1&&i.isConnected===!1){r&&r();return}if(n.defaultPrevented||n.isComposing||n.keyCode===229||Ht(n))return;let a=n.target,l=e._config.shadowKeydownIn;if(a&&a.closest&&Array.isArray(l))for(let p of l)try{if(a.closest(p))return}catch{}if(!(n.metaKey||n.ctrlKey))return;let s=(n.key||"").toLowerCase();if(s==="z"&&!n.shiftKey){n.preventDefault(),n.stopPropagation(),e.undo();return}if(s==="z"&&n.shiftKey){n.preventDefault(),n.stopPropagation(),e.redo();return}if(s==="y"&&!n.shiftKey){n.preventDefault(),n.stopPropagation(),e.redo();return}};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)}var le=[".CodeMirror",".cm-editor",".monaco-editor",".ace_editor",".ql-editor",".tiptap",".ProseMirror",".overtype-input","[data-richclay-active]"],g=null,de=null,Re=null,T=null;function Ce(e,r){if(T){if(T.inst===e)return T.cleanup;throw new Error("hyper-undo: another scope already owns the global Cmd+Z binding (bindKeys: true). Stop it first, or use bindKeys: false for additional scopes.")}let t=Ft(e,r);return T={inst:e,cleanup:t},t}function Oe(e){T&&T.inst===e&&(T.cleanup(),T=null)}var se={defaults:{shadowKeydownIn:le},start(e={}){let r=e.scope||(typeof document<"u"?document.body:null);if(!r)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");if(g){if(de===r)return console.warn("[hyper-undo] start() called again on existing singleton; ignoring new options"),g;throw new Error("hyper-undo: start() called with a different scope while the singleton is already started. Use undo.create({ scope }) for additional scopes, or call undo.stop() first.")}let t={...e,scope:r,shadowKeydownIn:e.shadowKeydownIn||le};return g=Se(t),g.start(),de=r,e.bindKeys!==!1&&(Re=Ce(g,()=>se.stop())),g},stop(){g&&(Oe(g),Re=null,g.stop(),g=null,de=null)},create(e={}){let r=e.scope||(typeof document<"u"?document.body:null);if(!r)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");let t={...e,scope:r,shadowKeydownIn:e.shadowKeydownIn||le},n=Se(t),i=null,a={_config:n._config,commit:n.commit,command:n.command,setRecording:n.setRecording,commitCaptured:n.commitCaptured,discardCaptured:n.discardCaptured,flush:n.flush,record:n.record,recordValue:n.recordValue,undo:n.undo,redo:n.redo,clear:n.clear,discard:n.discard,describe:n.describe,pause:n.pause,resume:n.resume,on:n.on,off:n.off,get canUndo(){return n.canUndo},get canRedo(){return n.canRedo},get isPaused(){return n.isPaused},get history(){return n.history},get future(){return n.future},get scope(){return n.scope},start(){e.bindKeys&&(i=Ce(n,()=>a.stop())),n.start()},stop(){Oe(n),i=null,n.stop()}};return a},commit(e,r){return g?g.commit(e,r):void 0},command(e,r){return g?g.command(e,r):void 0},setRecording(e){return g?g.setRecording(e):void 0},commitCaptured(e){return g?g.commitCaptured(e):void 0},discardCaptured(){return g?g.discardCaptured():void 0},record(e){return g?g.record(e):void 0},recordValue(e,r){return g?g.recordValue(e,r):void 0},undo(e){return g?g.undo(e):void 0},redo(e){return g?g.redo(e):void 0},clear(){return g?g.clear():void 0},discard(e){return g?g.discard(e):void 0},describe(e){return g?g.describe(e):void 0},pause(){return g?g.pause():void 0},resume(){return g?g.resume():void 0},flush(){return g?g.flush():void 0},on(e,r){return g?g.on(e,r):void 0},off(e,r){return g?g.off(e,r):void 0},get canUndo(){return g?g.canUndo:!1},get canRedo(){return g?g.canRedo:!1},get history(){return g?g.history:[]},get future(){return g?g.future:[]},get isPaused(){return g?g.isPaused:!1}},Xt=se;return X(C)})();window.__hyperclayNoAutoExport||(window.hyperclay=window.hyperclay||{},window.hyperclay.undo=et.undo,window.h=window.hyperclay);var w=et.undo;var ye=new Set,it=(d={})=>{let f=d.ignoreAttribute;return{...d,ignoreAttribute:(k,v,N)=>ye.has(k)||Xe(k,v)||Ye(v,k,N)||Ze(k,v)||(f?f(k,v,N):!1),isProtected:d.isProtected||Ar,ignoreNode:d.ignoreNode||Qe}};function Ar(d){let f=window.clay?.region?.resolveRegionPolicy;if(!f||d.nodeType!==1)return!1;let k=f(d);if(k.undoable!==!1||k.persist==="none")return!1;let v=d.parentElement;return!v||f(v).undoable!==!1}var Vr=w.create.bind(w);w.create=d=>Vr(it(d));var we=null,Er=w.setRecording.bind(w);w.setRecording=d=>(we=d??null,Er(d));var tt=()=>w.history.at(-1)?.id??null,Nr=w.command.bind(w);w.command=(d,f)=>{let k=Nr(d,f);return k&&re(),k};var xr=w.commit.bind(w),rt=!1;w.commit=(d,f)=>{!rt&&window.clay?.effect?.running&&(rt=!0,console.warn(`clay.effect: undo.commit("${d}") was called inside an effect. Run commands from event handlers, not from an effect.`));let k=tt(),v=xr(d,f);return(v||tt()!==k)&&re(),v};var Pr=`input${te}:not([type="password"]):not([type="hidden"]):not([type="file"]), textarea${te}, select${te}`;function Ir(){let d=f=>window.clay?.region?.resolveRegionPolicy?.(f)?.undoable!==!1;document.querySelectorAll(Pr).forEach(f=>{if(!d(f))return;if(f.tagName==="SELECT"){for(let C of f.options){let G=C.hasAttribute("selected");C.selected!==G&&(C.selected=G)}return}let k=(f.getAttribute("type")||"text").toLowerCase();if(f.tagName==="INPUT"&&(k==="checkbox"||k==="radio")){let C=f.hasAttribute("checked");f.checked!==C&&(f.checked=C);return}let v=f.tagName==="TEXTAREA"?f.getAttribute("data-value")??f.textContent:f.getAttribute("value")??"";if(f.value===v)return;let N=f===document.activeElement,W,X;try{W=f.selectionStart,X=f.selectionEnd}catch{}if(f.value=v,N&&W!=null)try{f.setSelectionRange(Math.min(W,v.length),Math.min(X,v.length))}catch{}})}var nt=d=>{d?.ok&&(re(),Ir())},ot=({entryId:d,label:f,direction:k,code:v})=>{document.dispatchEvent(new CustomEvent("clay:undo-refused",{detail:{ok:!1,code:v,entryId:d,label:f,direction:k}})),Sr({ok:!1,code:v,entryId:d,label:f,direction:k})},he=null;function at(){return he??=import("../c-NEL7HQW3.js").catch(d=>(he=null,console.error("clayjs: the undo recovery module could not be downloaded; a refused step stays in this tab only",d),null)),he}async function Sr(d){let f={ok:!1,code:"unavailable"};try{let v=await at();v&&(f=await v.keepRefusal(w,d))}catch{f={ok:!1,code:"error"}}let k=f?.ok===!0?{ok:!0,entryId:d.entryId,direction:d.direction}:{ok:!1,code:f?.code||"error",entryId:d.entryId,direction:d.direction};document.dispatchEvent(new CustomEvent("clay:undo-kept",{detail:k}))}var ve=(d,f)=>(...k)=>at().then(v=>v?v[d](...k):f,()=>f),Rr=ve("keep",{ok:!1,code:"unavailable"});w.ignoreAttribute=d=>{let f=String(d||"");return f?(ye.add(f),()=>{ye.delete(f)}):()=>{}};w.keep=async d=>{let f=await Rr(d);return f?.ok===!0&&document.dispatchEvent(new CustomEvent("clay:undo-kept",{detail:{ok:!0,key:d?.key==null?null:`app:${d.key}`}})),f};w.kept=ve("kept",{ok:!1,code:"unavailable",records:[]});w.dismissKept=ve("dismissKept",{ok:!1,code:"unavailable"});var be=new Set;w.reviewActions=d=>typeof d!="function"?()=>{}:(be.add(d),()=>{be.delete(d)});w.reviewActionsFor=d=>{let f=[];for(let k of be){let v;try{v=k(d)}catch(N){console.error("clayjs: a review action could not describe itself; the copy stays reviewable",N);continue}for(let N of Array.isArray(v)?v:[])N&&typeof N.run=="function"&&N.label&&f.push(N)}return f};var Cr=["commit","undo","redo","refused","discard","clear"],ne=()=>{let d=!!F?.started;document.dispatchEvent(new CustomEvent("clay:undo-change",{detail:{canUndo:d&&w.canUndo,canRedo:d&&w.canRedo,undo:d&&w.history.at(-1)||null,redo:d&&w.future?.[0]||null}}))},F=null;function Or(){return{started:!1,admitted:!1,subscriptions:[]}}var Mr=d=>d?d.signal?.aborted?!0:typeof d.isCurrent=="function"&&!d.isCurrent():!1;function Tr(){return typeof document>"u"||document.readyState!=="loading"?Promise.resolve():new Promise(d=>document.addEventListener("DOMContentLoaded",d,{once:!0}))}function jr(d){return{enable(){if(!d.started){d.started=!0,d.admitted=!0,w.start(it({bindKeys:!0,...we?{recording:we}:{}}));for(let f of["undo","redo"])w.on(f,nt),d.subscriptions.push({type:f,handler:nt});w.on("refused",ot),d.subscriptions.push({type:"refused",handler:ot});for(let f of Cr)w.on(f,ne),d.subscriptions.push({type:f,handler:ne});ne()}},quiesce(){d.admitted&&(d.admitted=!1,w.pause())},resume(){d.admitted||(d.admitted=!0,w.resume())},dispose(){if(d.admitted=!1,F===d&&(F=null),!!d.started){d.started=!1;for(let{type:f,handler:k}of d.subscriptions.splice(0))w.off(f,k);w.stop(),ne()}}}}function qr(){return{id:"clay:undo",order:350,async prepare(d={}){if(d.initial===!0)return Lr();if(await Tr(),Mr(d))throw Object.assign(new Error("clay:undo prepared for a stale generation"),{code:"stale-document"});return jr(F||(F=Or()))}}}async function Lr(){let d=await Kr;return{enable(){},quiesce:()=>d?.quiesce(),resume:()=>d?.resume(),dispose:()=>d?.dispose()}}async function $r(){if(!Ge()||typeof document>"u")return null;let d=await qr().prepare();return d.enable(),d}var Kr=$r();var Gr=w;export{Gr as default,$r as init,qr as modeParticipant,Kr as ready,Ir as restoreControls,w as undo,qr as undoParticipant};
@@ -1 +1 @@
1
- import{a as f,b as v}from"../c-3G2DGZUP.js";import"../c-VHNSBD2M.js";var T="hha:upgrade-check:",V=1440*60*1e3,S="upgrade-dismissed",M="A new version of this template is available.";function b(e,t){let n=e.querySelector(`meta[name="${t}"]`),r=n?n.getAttribute("content"):null;return r&&r.trim()?r.trim():null}function P(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function j(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function x(e){let t=globalThis.crypto&&globalThis.crypto.subtle;if(!t)return null;let n=await t.digest("SHA-256",e);return[...new Uint8Array(n)].map(r=>r.toString(16).padStart(2,"0")).join("")}async function L(e,t){try{let n=await e(t,{credentials:"omit"});return n.ok?n:null}catch{return null}}async function N(e,t,{fetchFn:n,now:r}){let o=new URL(e);o.pathname=o.pathname.replace(/\.html$/,".json");let a=`${T}${o.href}:${t}`,u=P(a);if(u&&typeof u.checkedAt=="number"&&r-u.checkedAt<V)return{latest:u.latest,latestUrl:o};let i=await L(n,o.href);if(!i)return{latest:null,latestUrl:o};let c=null;try{c=await i.json()}catch{return{latest:null,latestUrl:o}}return j(a,{checkedAt:r,latest:c}),{latest:c,latestUrl:o}}function A({doc:e,loc:t}){let n=typeof window<"u"&&window.clay||{};if(!n.canEdit||n.isDraftMode)return null;let r=b(e,"hyper-source"),o=b(e,"hyper-version");if(!r||!o)return null;let a;try{a=new URL(r,t?t.href:void 0)}catch{return null}return!a.pathname.endsWith(".html")||t&&a.origin===t.origin&&a.pathname===t.pathname?null:{source:a,currentVersion:o}}async function C({doc:e=document,loc:t=location,fetchFn:n=(o,a)=>fetch(o,a),now:r=Date.now()}={}){let o=A({doc:e,loc:t});if(!o)return{status:"none",version:null,update:null};let{source:a,currentVersion:u}=o,i=($,R=null)=>({status:$,version:u,update:R}),c=new URL(a.href);c.pathname=c.pathname.replace(/\.html$/,".json");let{latest:s}=await N(a.href,u,{fetchFn:n,now:r});if(!s||typeof s!="object"||typeof s.version!="string"||!f(s.version)||!f(u))return i("unknown");if(!v(s.version,u))return i("current");let h=typeof window<"u"&&window.clay||{},w=h.storage&&h.storage.local;if(w&&w.get(S)===s.version||typeof s.html!="string"||!s.html)return i("unknown");let m=new URL(s.html,c).href,y=await L(n,m);if(!y)return i("unknown");let g;try{g=await y.arrayBuffer()}catch{return i("unknown")}let d=await x(g);return!d||d!==String(s.sha256||"").toLowerCase()?i("unknown"):i("update",{version:s.version,html:m,sha256:d,latestUrl:c.href})}async function H(e){return(await C(e)).update}async function k(e,t){let n=window.clay;if(await I(n),!p(n)||!t)return;let r=e==="current"?`This doc is at latest version (${t})`:`Version ${t}`;n.menu.addItem({id:"upgrade",label:r,text:!0})}function O(e){let t=window.clay,n=t&&t.storage&&t.storage.local;n&&n.set(S,e)}function D(e){return!!(e&&Array.isArray(e.plugins)&&e.plugins.includes("menu"))}function p(e){return!!(e&&e.menu&&typeof e.menu.addItem=="function")}function I(e){return p(e)||!D(e)?Promise.resolve():new Promise(t=>{let n=r=>{!r.detail||r.detail.plugin!=="menu"||(document.removeEventListener("clay:plugin-ready",n),document.removeEventListener("clay:plugin-failed",n),t())};document.addEventListener("clay:plugin-ready",n),document.addEventListener("clay:plugin-failed",n)})}async function q(e,t=typeof window<"u"?window.clay:null){let n=()=>document.dispatchEvent(new CustomEvent("clay:upgrade-requested",{detail:e}));return await I(t),p(t)?(t.menu.addItem({id:"upgrade",label:`Upgrade to version ${e.version}`,badge:!0,run:n}),"menu"):t&&typeof t.toastPersistent=="function"?(t.toastPersistent(M,"info",{actions:[{label:"Upgrade",onClick:n},{label:"Not now",onClick:()=>O(e.version)}]}),"notice"):null}var U=!1;async function E(e={}){if(U)return null;U=!0;let t=window.clay;await Promise.resolve(t&&t.loaded&&t.loaded.ui).catch(()=>{});let n=A({doc:e.doc||document,loc:e.loc||location});n&&k("checking",n.currentVersion);let{status:r,version:o,update:a}=await C(e).catch(()=>({status:"unknown",version:n&&n.currentVersion,update:null}));return a?(await q(a),a):(r!=="none"&&await k(r,o),null)}async function J(e,t){return(await import("../c-GNDL3TKB.js")).replace(e,t)}function B(e){import("../c-DVYGFTSK.js").then(t=>t.start(e.detail)).catch(t=>console.error("clayjs: the upgrade could not start:",t))}var l=typeof window<"u"?window.clay:null;if(l&&l.canEdit&&!l.isDraftMode){document.addEventListener("clay:upgrade-requested",B);let e=l.ready;e&&typeof e.then=="function"?e.then(()=>E(),()=>{}):E()}export{q as announce,C as checkUpdate,H as findUpdate,J as replace,E as start};
1
+ import{a as f,b as v}from"../c-3G2DGZUP.js";import"../c-VHNSBD2M.js";var T="hha:upgrade-check:",V=1440*60*1e3,S="upgrade-dismissed",M="A new version of this template is available.";function b(e,t){let n=e.querySelector(`meta[name="${t}"]`),r=n?n.getAttribute("content"):null;return r&&r.trim()?r.trim():null}function P(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function j(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function x(e){let t=globalThis.crypto&&globalThis.crypto.subtle;if(!t)return null;let n=await t.digest("SHA-256",e);return[...new Uint8Array(n)].map(r=>r.toString(16).padStart(2,"0")).join("")}async function L(e,t){try{let n=await e(t,{credentials:"omit"});return n.ok?n:null}catch{return null}}async function N(e,t,{fetchFn:n,now:r}){let o=new URL(e);o.pathname=o.pathname.replace(/\.html$/,".json");let a=`${T}${o.href}:${t}`,u=P(a);if(u&&typeof u.checkedAt=="number"&&r-u.checkedAt<V)return{latest:u.latest,latestUrl:o};let i=await L(n,o.href);if(!i)return{latest:null,latestUrl:o};let c=null;try{c=await i.json()}catch{return{latest:null,latestUrl:o}}return j(a,{checkedAt:r,latest:c}),{latest:c,latestUrl:o}}function A({doc:e,loc:t}){let n=typeof window<"u"&&window.clay||{};if(!n.canEdit||n.isDraftMode)return null;let r=b(e,"hyper-source"),o=b(e,"hyper-version");if(!r||!o)return null;let a;try{a=new URL(r,t?t.href:void 0)}catch{return null}return!a.pathname.endsWith(".html")||t&&a.origin===t.origin&&a.pathname===t.pathname?null:{source:a,currentVersion:o}}async function C({doc:e=document,loc:t=location,fetchFn:n=(o,a)=>fetch(o,a),now:r=Date.now()}={}){let o=A({doc:e,loc:t});if(!o)return{status:"none",version:null,update:null};let{source:a,currentVersion:u}=o,i=($,R=null)=>({status:$,version:u,update:R}),c=new URL(a.href);c.pathname=c.pathname.replace(/\.html$/,".json");let{latest:s}=await N(a.href,u,{fetchFn:n,now:r});if(!s||typeof s!="object"||typeof s.version!="string"||!f(s.version)||!f(u))return i("unknown");if(!v(s.version,u))return i("current");let h=typeof window<"u"&&window.clay||{},w=h.storage&&h.storage.local;if(w&&w.get(S)===s.version||typeof s.html!="string"||!s.html)return i("unknown");let m=new URL(s.html,c).href,y=await L(n,m);if(!y)return i("unknown");let g;try{g=await y.arrayBuffer()}catch{return i("unknown")}let d=await x(g);return!d||d!==String(s.sha256||"").toLowerCase()?i("unknown"):i("update",{version:s.version,html:m,sha256:d,latestUrl:c.href})}async function H(e){return(await C(e)).update}async function k(e,t){let n=window.clay;if(await I(n),!p(n)||!t)return;let r=e==="current"?`This doc is at latest version (${t})`:`Version ${t}`;n.menu.addItem({id:"upgrade",label:r,text:!0})}function O(e){let t=window.clay,n=t&&t.storage&&t.storage.local;n&&n.set(S,e)}function D(e){return!!(e&&Array.isArray(e.plugins)&&e.plugins.includes("menu"))}function p(e){return!!(e&&e.menu&&typeof e.menu.addItem=="function")}function I(e){return p(e)||!D(e)?Promise.resolve():new Promise(t=>{let n=r=>{!r.detail||r.detail.plugin!=="menu"||(document.removeEventListener("clay:plugin-ready",n),document.removeEventListener("clay:plugin-failed",n),t())};document.addEventListener("clay:plugin-ready",n),document.addEventListener("clay:plugin-failed",n)})}async function q(e,t=typeof window<"u"?window.clay:null){let n=()=>document.dispatchEvent(new CustomEvent("clay:upgrade-requested",{detail:e}));return await I(t),p(t)?(t.menu.addItem({id:"upgrade",label:`Upgrade to version ${e.version}`,badge:!0,run:n}),"menu"):t&&typeof t.toastPersistent=="function"?(t.toastPersistent(M,"info",{actions:[{label:"Upgrade",onClick:n},{label:"Not now",onClick:()=>O(e.version)}]}),"notice"):null}var U=!1;async function E(e={}){if(U)return null;U=!0;let t=window.clay;await Promise.resolve(t&&t.loaded&&t.loaded.ui).catch(()=>{});let n=A({doc:e.doc||document,loc:e.loc||location});n&&k("checking",n.currentVersion);let{status:r,version:o,update:a}=await C(e).catch(()=>({status:"unknown",version:n&&n.currentVersion,update:null}));return a?(await q(a),a):(r!=="none"&&await k(r,o),null)}async function J(e,t){return(await import("../c-U5X57T4L.js")).replace(e,t)}function B(e){import("../c-DDDOKPI6.js").then(t=>t.start(e.detail)).catch(t=>console.error("clayjs: the upgrade could not start:",t))}var l=typeof window<"u"?window.clay:null;if(l&&l.canEdit&&!l.isDraftMode){document.addEventListener("clay:upgrade-requested",B);let e=l.ready;e&&typeof e.then=="function"?e.then(()=>E(),()=>{}):E()}export{q as announce,C as checkUpdate,H as findUpdate,J as replace,E as start};
@@ -1 +1 @@
1
- import{b as r,c as p,d as n,e as u}from"../c-5B4YBZXC.js";import"../c-I2SCCUEW.js";import"../c-XGH4GS2T.js";import"../c-3O7OBDCM.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-N7JPUPGC.js";import"../c-HA6INT6J.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";function o(a,{requiredAccess:t,...i}={}){return r(t),p(a,{...i,requiredAccess:t})}o.mount=async(a,t)=>(await import("../c-L42OLXWM.js")).mount(a,t);o.start=n;var c=o;export{c as default,u as modeParticipant,o as upload};
1
+ import{b as r,c as p,d as n,e as u}from"../c-5B4YBZXC.js";import"../c-I2SCCUEW.js";import"../c-XGH4GS2T.js";import"../c-3O7OBDCM.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-N7JPUPGC.js";import"../c-HA6INT6J.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";function o(a,{requiredAccess:t,...i}={}){return r(t),p(a,{...i,requiredAccess:t})}o.mount=async(a,t)=>(await import("../c-ANNFZFLN.js")).mount(a,t);o.start=n;var c=o;export{c as default,u as modeParticipant,o as upload};
@@ -1,4 +1,4 @@
1
- import{b as Je,c as Ze}from"../c-Y6F2FORL.js";import{b as Ke}from"../c-L7JL5TL3.js";import{a as Xe,b as Ye,c as Ge,d as Qe}from"../c-MTQHWQC3.js";import{b as Ve,f as Fe,h as Ee}from"../c-3O7OBDCM.js";import{d as qe}from"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import{d as ie,f as _e,h as ze,j as J}from"../c-N7JPUPGC.js";import"../c-HA6INT6J.js";import"../c-DCFSEJZG.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var Gt=Object.defineProperty,Qt=(e,t)=>{for(var r in t)Gt(e,r,{get:t[r],enumerable:!0})},gt=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],er=new Set(gt),tr=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),vt=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),et=new Set(["checked","selected","disabled","readOnly","paused"]);function rr(e,t){return t==null?et.has(e)?!1:"":et.has(e)?t==="false"?!1:!!t:t}var P={};Qt(P,{EmptyListInsert:()=>G,MAX_RULE_DEPTH:()=>pe,MaxRuleDepthExceeded:()=>Re,NoRulesTag:()=>lr,RuleTargetReadOnly:()=>At,RulesParseError:()=>Le,ShapeMismatch:()=>bt,UnknownRulesVersion:()=>wt,WriteNotRoundTripped:()=>or,WriteRefused:()=>Et,WriteRejected:()=>ir});var Le=class extends Error{constructor(e,t){super(e),this.name="RulesParseError",this.cause=t}},wt=class extends Error{constructor(e){super(`unknown rules version: ${e}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=e}},pe=20,Re=class extends Error{constructor(e){super(`rule depth exceeded ${pe} at path: ${e.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=e}},bt=class extends Error{constructor(e){super(`shape mismatch: ${e.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=e}},G=class extends Error{constructor(e,t){super(t?`cannot add items to empty list at "${e.join(".")}" \u2014 ${t}`:`cannot add items to empty list at "${e.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=e}},At=class extends Error{constructor(e){super(`cannot write to read-only DOM property "${e}"`),this.name="RuleTargetReadOnly",this.target=e}},Et=class extends Error{constructor(e){super(`write refused: ${e.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=e}};function nr(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t?`${t}.${r}`:String(r),"")||"(root)"}var or=class extends Error{constructor(e){super(`write did not round-trip at "${nr(e)}"`),this.name="WriteNotRoundTripped",this.path=e}},lr=class extends Error{constructor(e){super(`no <script data-rules-name~="${e}"> rules tag in this document`),this.name="NoRulesTag",this.token=e}},ir=class extends Error{constructor(e,t){super(`write rejected: ${e.length} unknown key(s), ${t.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=e,this.unmatched=t}};function z(e){let t=0,r=null,o=-1;for(let n=0;n<e.length;n++){let l=e[n];l==="\\"?n++:r?l===r&&(r=null):l==='"'||l==="'"?r=l:l==="["||l==="("?t++:l==="]"||l===")"?t>0&&t--:l==="@"&&t===0&&(o=n)}return o}function ar(e){let t=z(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function xt(e){let t=0,r=null,o=-1,n=!1;for(let l=0;l<e.length;l++){let s=e[l];s==="\\"?l++:r?s===r&&(r=null):s==='"'||s==="'"?r=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:t===0&&s===">"?o=l:t===0&&s===","&&(n=!0)}return n||o===-1||!sr(e,o+1)?null:e.slice(0,o).trim()||null}function sr(e,t){let r=t,o=e.replace(/\s+$/,"").length;for(;r<o&&/\s/.test(e[r]);)r++;let n=0,l=null;for(;r<o;r++){let s=e[r];if(s==="\\")r++;else if(l)s===l&&(l=null);else if(s==='"'||s==="'")l=s;else if(s==="["||s==="(")n++;else if(s==="]"||s===")")n>0&&n--;else if(n===0&&(s==="+"||s==="~"||/\s/.test(s)))return!1}return!0}var ur=/^--[A-Za-z0-9_-]+$/;function Ce(e){return typeof e=="string"&&ur.test(e)}function Tt(e){let t=[],r=[],o=null,n=0;for(let l=0;l<e.length;l++){let s=e[l];if(o){s==="\\"?l++:s===o&&(o=null);continue}if(s==="/"&&e[l+1]==="*"){let i=e.indexOf("*/",l+2);l=i===-1?e.length:i+1;continue}s==='"'||s==="'"?o=s:s==="("?r.push(")"):s==="["?r.push("]"):s==="{"?r.push("}"):(s===")"||s==="]"||s==="}")&&r[r.length-1]===s?r.pop():s===";"&&r.length===0&&(t.push(e.slice(n,l)),n=l+1)}return t.push(e.slice(n)),t}function cr(e){let t="",r=null;for(let o=0;o<e.length;o++){let n=e[o];if(r){t+=n,n==="\\"&&o+1<e.length?t+=e[++o]:n===r&&(r=null);continue}if(n==="/"&&e[o+1]==="*"){let l=e.indexOf("*/",o+2);o=l===-1?e.length:l+1,t+=" ";continue}(n==='"'||n==="'")&&(r=n),t+=n}return t}function Ot(e){e=cr(e);let t=e.indexOf(":");if(t===-1)return null;let r=e.slice(0,t).trim(),o=e.slice(t+1).trim(),n=/!\s*important\s*$/i.exec(o);return n&&(o=o.slice(0,n.index).trim()),{name:r,value:o,important:!!n}}function $e(e,t){if(e==null)return null;let r=null;for(let o of Tt(String(e))){let n=Ot(o);!n||n.name!==t||(!r||n.important||!r.important)&&(r=n)}return r?r.value:null}function fr(e,t,r){let o=e==null?"":String(e),n=r==null||r==="",l=Tt(o),s=l.map(Ot),i=s.some(d=>d&&d.name===t&&d.important),a=[],u=!1;l.forEach((d,p)=>{let A=s[p];if(!A||A.name!==t){a.push(d);return}if(n||u)return;let f=/^\s*/.exec(d)[0];a.push(`${f}${t}: ${r}${i?" !important":""}`),u=!0});let c=a.join(";");if(!n&&!u){let d=c.trimEnd();c=d===""?`${t}: ${r}`:`${d}${d.endsWith(";")?" ":"; "}${t}: ${r}`}return c.trim()===""?null:c}function kt(e,t,r,o){let n=e.attr(t,"style");if(($e(n,r)??"")===o)return;let l=fr(n,r,o);l==null?e.removeAttr(t,"style"):e.attr(t,"style",l)}function ue(e,t,r,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return xe(e,t,r,{depth:0,path:[]},o)}function xe(e,t,r,o,n){if(o.depth>pe)throw new Re(o.path);if(typeof r=="string")return dr(e,t,r,o,n);if(Array.isArray(r)){let[l,s]=r,i=e.find(t,l,n);return St(n,o,i),i.map((a,u)=>xe(e,a,s,{depth:o.depth+1,path:[...o.path,u]},n))}if(typeof r=="object"&&r!==null){let l={};for(let[s,i]of Object.entries(r))l[s]=xe(e,t,i,{depth:o.depth+1,path:[...o.path,s]},n);return l}return null}function dr(e,t,r,o,n){if(r.endsWith("[]")){let i=r.slice(0,-2),a=e.find(t,i,n);return St(n,o,a),a.map(u=>e.text(u))}if(r.startsWith("@"))return tt(e,t,r.slice(1));let l=z(r);if(l!==-1){let i=r.slice(0,l),a=r.slice(l+1),u=i?e.find(t,i,n):[t];return u.length===0?null:tt(e,u[0],a)}if(r===".")return e.text(t);let s=e.find(t,r,n);return s.length===0?null:e.text(s[0])}function St(e,t,r){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),r)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function tt(e,t,r){if(Ce(r))return $e(e.attr(t,"style"),r);if(er.has(r)){let n=e.prop(t,r);return n==null?null:String(n)}return e.attr(t,r)??null}function pr(e,t,r,o){let n=e.length,l=t.length,s=new Array(n).fill(-1);if(o){let h=new Set;for(let y=0;y<n;y++){let v=o[y];!(v>=0&&v<l)||h.has(v)||(s[y]=v,h.add(v))}}if(n===0||l===0)return s;let i=e.map(h=>rt(h,r)),a=t.map(h=>rt(h,r)),u=new Array(l).fill(!1);for(let h of s)h>=0&&(u[h]=!0);let c=new Map;a.forEach((h,y)=>{u[y]||c.set(h,c.has(h)?-1:y)});let d=new Map;i.forEach((h,y)=>{s[y]>=0||d.set(h,(d.get(h)||0)+1)}),i.forEach((h,y)=>{if(s[y]>=0||d.get(h)!==1)return;let v=c.get(h);v===void 0||v===-1||u[v]||(s[y]=v,u[v]=!0)});let p=[];for(let h=0;h<n;h++)s[h]<0&&p.push(h);let A=[];for(let h=0;h<l;h++)u[h]||A.push(h);if(p.length===0||A.length===0)return s;let f=n*l+1,m=hr(e,t,r),g=(h,y)=>m(h,y)*f+Math.abs(h-y);for(let[h,y]of mr(p,A,g))s[h]=y;return s}var Nt=e=>typeof e=="object"&&e!==null;function rt(e,t){if(!Nt(t))return e==null?" null":String(e);let r=Object.keys(t);return JSON.stringify(r.map(o=>{let n=JSON.stringify(e?.[o]);return n===void 0?" undef":n}))}function hr(e,t,r){if(!Nt(r))return(i,a)=>e[i]===t[a]?0:1;let o=Object.keys(r),n=i=>o.map(a=>JSON.stringify(i?.[a])),l=e.map(n),s=t.map(n);return(i,a)=>{let u=l[i],c=s[a],d=0;for(let p=0;p<o.length;p++)u[p]!==c[p]&&d++;return d}}function mr(e,t,r){return e.length<=t.length?nt(e,t,r,!1):nt(t,e,(o,n)=>r(n,o),!0)}function nt(e,t,r,o){let n=e.length,l=t.length,s=[];for(let d=0;d<=n;d++)s.push(new Float64Array(l+1).fill(1/0));let i=[];for(let d=0;d<=n;d++)i.push(new Uint8Array(l+1));for(let d=0;d<=l;d++)s[n][d]=0;for(let d=n-1;d>=0;d--)for(let p=l-1;p>=0;p--){let A=r(e[d],t[p])+s[d+1][p+1],f=s[d][p+1];A<=f?(s[d][p]=A,i[d][p]=1):s[d][p]=f}let a=[],u=0,c=0;for(;u<n&&c<l;)i[u][c]&&(a.push(o?[t[c],e[u]]:[e[u],t[c]]),u++),c++;return a}function Lt(e,t,r,o,n,l,s,i={}){let a=e.find(t,r,i);if(n.length===0){a.forEach(T=>e.remove(T)),Te(i,"onRowsApplied",l.path,[]);return}let u=n.length>a.length,c=a[0]||null;if(u&&!c&&(c=wr(e,t,r,i),!c))throw new G(l.path);let d=a.map(T=>vr(e,T,o,i)),p=null;if(u&&c){p=e.clone(c),i.templateAttr&&e.removeAttr(p,i.templateAttr);let T=e.stripIds(p);T>0&&console.warn(`[hyper-html-api] stripped ${T} id attribute(s) from cloned template at "${l.path.join(".")||"(root)"}"`)}let A=pr(n,d,o,yr(e,a,n,l,i)),f=a.length>0?e.parent(a[0]):xr(e,t,r,c,l,i),m=a.length>0?Rt(e,f,a[0]):0,g=kr(e,a),h=new Set,y=[],v=n.map((T,O)=>{let x=A[O];if(x>=0)return h.add(x),y.push(!1),a[x];y.push(!0);let S=e.clone(p);return e.stripIds(S),S});a.forEach((T,O)=>{h.has(O)||e.remove(T)}),g?Or(e,f,m,v,y):Sr(e,v,y,f,m),gr(e,v,o,n,l,s,i),Te(i,"onRowsApplied",l.path,v)}function Te(e,t,r,o){if(typeof e[t]=="function")try{return e[t](r.slice(),o)}catch(n){console.warn(`[hyper-html-api] ${t} threw at "${r.join(".")||"(root)"}"`,n);return}}function yr(e,t,r,o,n){let l=Te(n,"identifyRows",o.path,r);if(!Array.isArray(l))return null;let s=new Array(r.length).fill(-1),i=new Set,a=new Map(t.map((u,c)=>[e.identity(u),c]));for(let u=0;u<r.length;u++){if(!l[u])continue;let c=a.get(e.identity(l[u]));c===void 0||i.has(c)||(s[u]=c,i.add(c))}return s}function gr(e,t,r,o,n,l,s){t.forEach((i,a)=>{if(r===null){let u=o[a],c=u==null?"":String(u);e.text(i)!==c&&e.text(i,c)}else{let u=l(e,i,r,o[a],{depth:n.depth+1,path:[...n.path,a]},s);u&&u!==i&&(t[a]=u)}})}function vr(e,t,r,o){return r===null?e.text(t):ue(e,t,r,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function Rt(e,t,r){let o=e.children(t);for(let n=0;n<o.length;n++)if(e.sameNode(o[n],r))return n;return-1}function wr(e,t,r,o){if(!o.templateAttr)return null;let n=/^\s*:scope\s*>\s*/.test(r),l=new RegExp(":not\\(\\["+o.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),s=r.replace(/^\s*:scope\s*>\s*/,"").replace(l,""),i=n?br(s):0,a=xt(s),u=t;for(;u;){let c=e.find(u,s,{includeRulesTag:!1,templateAttr:null});for(let d of c)if(e.attr(d,o.templateAttr)!=null&&!(n&&!Er(e,t,d,i))&&!(a&&!e.matches(e.parent(d),a)))return d;u=e.parent(u)}return null}function br(e){let t=0,r=null,o=1;for(let n=0;n<e.length;n++){let l=e[n];if(l==="\\")n++;else if(r)l===r&&(r=null);else if(l==='"'||l==="'")r=l;else if(l==="["||l==="(")t++;else if(l==="]"||l===")")t>0&&t--;else if(t===0&&l===">")o++;else{if(t===0&&(l==="+"||l==="~"))return null;if(t===0&&/\s/.test(l)){if(!Ar(e,n))return null;for(;n+1<e.length&&/\s/.test(e[n+1]);)n++}}}return o}function Ar(e,t){let r=t;for(;r<e.length&&/\s/.test(e[r]);)r++;let o=t>0?e[t-1]:"",n=r<e.length?e[r]:"";return ot(o)||ot(n)}function ot(e){return e===">"||e==="+"||e==="~"}function Er(e,t,r,o){if(o===null)return!0;let n=r;for(let a=0;a<o;a++)if(n=e.parent(n),!n)return!1;let l=e.prop(t,"tagName");if(!l)return!0;let s=e.prop(n,"tagName");if(!s||String(s).toLowerCase()!==String(l).toLowerCase())return!1;let i=new Set(lt(e,n));return lt(e,t).every(a=>i.has(a))}function lt(e,t){let r=e.attr(t,"class");return r?String(r).split(/\s+/).filter(Boolean):[]}function xr(e,t,r,o,n,l){let s=e.parent(o);if(s&&Tr(e,t,s)&&!at(e,s,l))return s;let i=xt(r);if(!i)throw new G(n.path,`the list selector "${r}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let a=(i===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,i,l)).filter(u=>!at(e,u,l));if(a.length===0)throw new G(n.path,`no container matching "${i}" inside this context to hold the new rows`);if(a.length>1)throw new G(n.path,`"${i}" matches ${a.length} containers inside this context, so the new rows have no single destination`);return a[0]}function Tr(e,t,r){let o=r;for(;o;){if(e.sameNode(o,t))return!0;o=e.parent(o)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(n=>e.sameNode(n,r))}var it=["no-data","editor-ui"];function at(e,t,r){let o=t;for(;o;){if(r.templateAttr&&e.attr(o,r.templateAttr)!=null||it.some(l=>e.attr(o,l)!=null))return!0;let n=e.attr(o,"clay");if(n&&n.split(/\s+/).some(l=>it.includes(l)))return!0;o=e.parent(o)}return!1}function Or(e,t,r,o,n){let l=e.children(t),s=l.map(a=>e.identity(a)),i=!1;o.forEach((a,u)=>{let c=e.identity(a),d=r+u;if(s[d]===c)return;if(!n[u]){let A=s.indexOf(c);A!==-1&&(s.splice(A,1),l.splice(A,1))}let p=Math.min(d,l.length);p<l.length?e.insertBefore(l[p],a):l.length?i?e.insertAfter(l[l.length-1],a):(e.insertAt(t,a,d),i=!0):e.insertAt(t,a,0),s.splice(p,0,c),l.splice(p,0,a)})}function kr(e,t){if(t.length<=1)return!0;let r=e.parent(t[0]);if(!r)return!1;let o=new Map(e.children(r).map((l,s)=>[e.identity(l),s])),n=[];for(let l of t){let s=o.get(e.identity(l));if(s===void 0)return!1;n.push(s)}return n.sort((l,s)=>l-s),n[n.length-1]-n[0]===n.length-1}function Sr(e,t,r,o,n){let l=null,s=n;for(let i=0;i<t.length;i++){if(!r[i]){l=t[i];continue}let a=l?e.parent(l):o;if(!a)continue;let u=l?Rt(e,a,l)+1:s++;e.insertAt(a,t[i],u),l=t[i]}}function ce(e,t,r,o,n={}){if(Object.prototype.hasOwnProperty.call(n,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let l=[];if(Oe(r,o,[],l),l.length)throw new bt(l);fe(e,t,r,o,{depth:0,path:[]},n)}function fe(e,t,r,o,n,l={}){if(n.depth>pe)throw new Re(n.path);if(o===void 0)return t;if(typeof r=="string")return Nr(e,t,r,o,n,l);if(Array.isArray(r)){let[s,i]=r;return Lt(e,t,s,i,o,n,fe,l),t}if(typeof r=="object"&&r!==null){for(let[s,i]of Object.entries(r)){let a=fe(e,t,i,o==null?o:o[s],{depth:n.depth+1,path:[...n.path,s]},l);a&&a!==t&&(t=a)}return t}return t}function Nr(e,t,r,o,n,l){if(r.endsWith("[]")){let a=r.slice(0,-2);return Lt(e,t,a,null,o,n,fe,l),t}if(r.startsWith("@"))return ut(e,t,r.slice(1),o);let s=z(r);if(s!==-1){let a=r.slice(0,s),u=r.slice(s+1),c=a?e.find(t,a,l):[t];return c.length===0||ut(e,c[0],u,o),t}if(r===".")return st(e,t,o),t;let i=e.find(t,r,l);return i.length===0||st(e,i[0],o),t}function st(e,t,r){let o=r==null?"":String(r);e.text(t)!==o&&e.text(t,o)}function Lr(e,t,r,o){if(e.styleVar){e.styleVar(t,r,o);return}kt(e,t,r,o)}function ut(e,t,r,o){if(Ce(r))return Lr(e,t,r,o==null?"":String(o).trim()),t;if(vt.has(r)){let n=e.prop(t,r);if(n===o||n!=null&&o!=null&&String(n)===String(o))return t;throw new At(r)}if(r==="outerHTML"){let n=o==null?"":String(o);return e.replaceWith(t,n)}if(tr.has(r)){let n=rr(r,o);return e.prop(t,r)!==n&&e.prop(t,r,n),t}if(o==null)e.attr(t,r)!=null&&e.removeAttr(t,r);else{let n=String(o);e.attr(t,r)!==n&&e.attr(t,r,n)}return t}function Oe(e,t,r,o){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((n,l)=>{typeof n=="object"&&n!==null&&o.push({path:X([...r,l]),expected:"scalar",got:Z(n)})}):o.push({path:X(r),expected:"array",got:Z(t)});return}t!==null&&typeof t=="object"&&o.push({path:X(r),expected:"scalar",got:Z(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:X(r),expected:"array",got:Z(t)});return}let n=e[1];t.forEach((l,s)=>Oe(n,l,[...r,s],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:X(r),expected:"object",got:Z(t)});return}for(let[n,l]of Object.entries(e))Oe(l,t[n],[...r,n],o)}}}function Z(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function X(e){return e.join(".")}function Rr(e){try{return JSON.parse(e)}catch(t){throw new Le(`Invalid strict JSON: ${t.message}`,t)}}function Ct(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function r(n){let l=[],s=0;for(;s<n.length;){let i=n[s];if(/\s/.test(i)){s++;continue}if("{}".includes(i)){l.push({type:i,value:i}),s++;continue}if(i==="["){let d=!1,p=s+1;for(;p<n.length&&/\s/.test(n[p]);)p++;if(p<n.length&&/[a-zA-Z_]/.test(n[p])&&(d=!0),!d){l.push({type:i,value:i}),s++;continue}}if(i==="]"){l.push({type:i,value:i}),s++;continue}if(i===":"){l.push({type:t.COLON,value:i}),s++;continue}if(i===","){l.push({type:t.COMMA,value:i}),s++;continue}if(i==='"'||i==="'"){let d=i,p=s+1;for(;p<n.length&&n[p]!==d;)n[p]==="\\"&&p++,p++;l.push({type:t.STRING,value:n.substring(s+1,p),quoted:!0,sourceQuote:d}),s=p+1;continue}let a=s,u;for(;a<n.length&&!/[{},]/.test(n[a]);)if(n[a]===":"){let d=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],p=!1;for(let A of d){let f=A.substring(1);if(n.substring(a+1,a+1+f.length)===f){p=!0,a+=f.length;break}}if(!p)break}else if(n[a]==="["){for(a++;a<n.length&&n[a]!=="]";){if(n[a]==='"'||n[a]==="'"){let d=n[a];for(a++;a<n.length&&n[a]!==d;)n[a]==="\\"&&a++,a++}a++}a<n.length&&n[a]==="]"&&a++}else a++;u=n.substring(s,a);let c=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?c=t.NUMBER:u==="true"||u==="false"||u==="null"?c=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(c=t.SELECTOR),l.push({type:c,value:u,quoted:!1}),s=a}return l}function o(n){let l="";for(let s=0;s<n.length;s++){let i=n[s];if("{}".includes(i.type)||"[]".includes(i.type)){l+=i.value;continue}if(i.type===t.COLON){l+=i.value;continue}if(i.type===t.COMMA){let a=n[s+1];if(a&&(a.type==="}"||a.type==="]"))continue;l+=i.value;continue}if(i.type===t.STRING&&i.quoted){let a=i.value;i.sourceQuote==="'"&&(a=a.replace(/\\'/g,"'"),a=a.replace(/(\\*)"/g,(u,c)=>c.length%2===0?c+'\\"':u)),l+=`"${a}"`;continue}if(i.type===t.NUMBER||i.type===t.BOOLEAN){l+=i.value;continue}if(i.type===t.SELECTOR||i.type===t.IDENTIFIER){l+=`"${i.value}"`;continue}l+=`"${i.value}"`}return l}try{let n=r(e),l=o(n);return JSON.parse(l)}catch(n){throw new Le("Invalid extraction rules syntax: "+n.message,n)}}var Cr="1",ct=/^[a-zA-Z0-9_-]+$/;function Ie(e,t,r){let o;if(r===void 0)o="script[data-rules-name]";else{if(typeof r!="string"||!ct.test(r))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(r)} (must match ${ct})`);o=`script[data-rules-name~="${r}"]`}let n=e.find(t,o,{includeRulesTag:!0});if(n.length===0)return null;r!==void 0&&n.length>1&&console.warn(`hyper-html-api: ${n.length} rules tags match data-rules-name~="${r}"; using the first.`);let l=n[0],s=e.attr(l,"data-rules-version");if(s!==Cr)throw new wt(s);return{rules:Ct(e.text(l)),tagNode:l}}var Me=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),$r=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Ir=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function de(e,t){if(!e||e.nodeType!==1)return!1;let r=e.getAttribute?.("clay");return!!(r&&r.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function $t(e,t){if(de(e,t))return!0;for(let[r,o]of Object.entries($r))if(o.includes(t)&&de(e,r))return!0;return!1}function ke(e){let t=Me[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(r=>[`[clay~="${r}"]`,`[${r}]`]).join(", ")}function Mr(e,t){let r=e&&e.nodeType===1?e:e?.parentElement;for(;r&&r.nodeType===1;){let o=Me[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(n=>$t(r,n))||o.bundles.some(n=>de(r,n)))return r;r=r.parentElement}return null}function jr(e,t){return!!Mr(e,t)}var je=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...Ir],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})}),Dr=new Set(["textContent","innerText"]);function Pr(e){let t=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return t?t[1].toLowerCase():null}var Ur=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function Wr(e,t,r=je){if(!Ur.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let o=String(e).toLowerCase();if(r.refusedAttributePrefixes.some(n=>o.startsWith(n)))return`attribute "${o}" can run script`;if(r.refusedAttributes.includes(o))return`attribute "${o}" is not content`;if(r.urlAttributes.includes(o)&&t!=null){let n=o==="srcset"?String(t).split(",").map(l=>l.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let l of n){let s=Pr(l);if(s&&r.refusedSchemes.includes(s))return`"${s}:" URLs are not allowed in "${o}"`}}return null}function De(e,t){let r=e.prop(t,"tagName");return r?String(r).toLowerCase():""}function Br(e,t){let r=De(e,t)||"node",o=e.attr(t,"id");return o?`<${r}#${o}>`:`<${r}>`}function Hr(e,t,r){let o=t;for(;o;){let n=De(e,o);if(n&&r.refusedTargets.includes(n))return n;o=e.parent(o)}return null}function It(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function qr(e,t){return De(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:It(e,t)}function _r(e){if(/[\u0000-\u001f\u007f]/.test(e))return"control characters are not allowed in a custom property value";let t=[],r=null;for(let o=0;o<e.length;o++){let n=e[o];if(r){n===r&&(r=null);continue}if(n==='"'||n==="'")r=n;else{if(n==="/"&&e[o+1]==="*")return"comments are not allowed in a custom property value";if(n==="(")t.push(")");else if(n==="[")t.push("]");else if((n===")"||n==="]")&&t.pop()!==n)return`"${n}" does not close anything in this custom property value`}}return r?"a custom property value must close its quotes":t.length?"a custom property value must close its brackets":null}function zr(e,t=je){let r=t.customPropertyValues,o=String(e);if(o.length>r.maxLength)return`custom property values are limited to ${r.maxLength} characters`;let n=r.refusedCharacters.find(a=>o.includes(a));if(n)return`${JSON.stringify(n)} is not allowed in a custom property value`;let l=_r(o);if(l)return l;let s=o.toLowerCase(),i=r.refusedFunctions.find(a=>new RegExp(`(^|[^a-z0-9_-])${a.replace(/[-]/g,"\\-")}\\s*\\(`).test(s));return i?`"${i}()" is not allowed in a custom property value`:null}function ft(e,t=je){let r=[],o=(i,a)=>(r.push({target:Br(e,i),reason:a}),!1),n=i=>{let a=Hr(e,i,t);return a?o(i,`inside <${a}>, which is not content`):!0},l=i=>n(i)?It(e,i)?o(i,"a text write here would delete the data rules tag"):!0:!1,s=(i,a,u)=>{if(!n(i))return!1;let c=Wr(a,u,t);return c?o(i,c):!0};return{...e,text(i,a){if(a===void 0)return e.text(i);l(i)&&e.text(i,a)},attr(i,a,u){if(u===void 0)return e.attr(i,a);s(i,a,u)&&e.attr(i,a,u)},removeAttr(i,a){s(i,a,null)&&e.removeAttr(i,a)},styleVar(i,a,u){if(($e(e.attr(i,"style"),a)??"")!==u&&n(i)){if(!Ce(a))return o(i,`"${a}" is not a custom property`);if(u!==""){let c=zr(u,t);if(c)return o(i,c)}kt(e,i,a,u)}},prop(i,a,u){if(u===void 0)return e.prop(i,a);if(t.refusedRuleForms.includes(a))return o(i,`"@${a}" writes HTML, only text is allowed`);if(Dr.has(a)){l(i)&&e.prop(i,a,u);return}s(i,a==="className"?"class":a,u)&&e.prop(i,a,u)},remove(i){if(qr(e,i)){o(i,"removing this would delete the data rules tag");return}e.remove(i)},replaceWith(i,a){return a===e.prop(i,"outerHTML")||o(i,'"@outerHTML" writes HTML, only text is allowed'),i},refusals:r,assertClean(){if(r.length)throw new Et(r.slice())}}}function Y(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function dt(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t?`${t}.${r}`:r,"")}function Vr(e,t,r,o,n={}){let l=[],s=[];function i(u,c,d){if(Array.isArray(u)){let[,p]=u;if(!Array.isArray(c)||!Y(p))return;c.forEach((A,f)=>i(p,A,[...d,f]));return}if(!(!Y(u)||!Y(c)))for(let p of Object.keys(c))Object.prototype.hasOwnProperty.call(u,p)?i(u[p],c[p],[...d,p]):l.push(dt([...d,p]))}function a(u,c,d,p){if(d!==void 0){if(typeof c=="string"){if(c.endsWith("[]")||c==="."||c.startsWith("@"))return;let A=z(c),f=A===-1?c:c.slice(0,A);if(!f)return;e.find(u,f,n).length===0&&s.push({path:dt(p),selector:f});return}if(!Array.isArray(c)&&Y(c)&&Y(d))for(let[A,f]of Object.entries(c))a(u,f,d[A],[...p,A])}}return i(r,o,[]),a(t,r,o,[]),{unknownKeys:l,unmatched:s}}function pt(e,t,r){if(r&&typeof r=="object")return{rules:r,tagNode:null};if(typeof r=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return Ie(e,o,r)}return null}var Fr=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Kr(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let r=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&r!=="checkbox"&&r!=="radio"&&r!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(r==="checkbox"||r==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function ht(e,t,r,o){if(o)return!!e.closest?.(t);let n=e;for(;n?.nodeType===1;){if(n.matches(t))return!0;if(n===r)break;n=n.parentElement}return!1}function mt(e,t,r,o,n,l){return(l?jr(e,t):ht(e,r,n,!1))||!!(o&&(l&&e!==n?e.matches(o):ht(e,o,n,l)))}function Jr(e,t){let r=Me[t];return r.tokens.some(o=>$t(e,o))||r.bundles.some(o=>de(e,o))}var Zr=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function Mt(e,t,r,o){if(e.nodeType===1&&o(e)){r.dropped.push(t);return}r.cloneToLive.set(t,e),r.liveToClone.set(e,t);let n=e,l=t;if(e.nodeType===1){if(Zr.has(e.tagName)&&r.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);n=e.content,l=t.content,r.cloneToLive.set(l,n),r.liveToClone.set(n,l)}}else if(e.nodeType!==11)return;let s=l.firstChild;for(let i=n.firstChild;i&&s;i=i.nextSibling)Mt(i,s,r,o),s=s.nextSibling}function ae(e,{capability:t="data",exclude:r=null,inherit:o=!0,provenance:n=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let l=e.nodeType===9?e:e.ownerDocument;if(!l?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=l.implementation.createHTMLDocument(""),i=n||new WeakMap,a=new WeakMap,u=e.nodeType===9?e.documentElement:e;r&&s.documentElement.matches(r);let c=ke(t),d=o?f=>Jr(f,t)||!!(r&&f.matches(r)):f=>mt(f,t,c,r,u,!1),p=null;if(u.nodeType!==1||!mt(u,t,c,r,u,o)){p=s.importNode(u,!0);let f={cloneToLive:i,liveToClone:a,dropped:[],controls:[]};Mt(u,p,f,d);for(let m of f.dropped)m.remove();for(let m=0;m<f.controls.length;m+=2)Kr(f.controls[m],f.controls[m+1])}e.nodeType===9&&p&&(s.replaceChild(p,s.documentElement),a.set(e,s),i.set(s,e));let A=f=>{if(Fr.test(f))throw new Error(`Filtered content queries do not support stateful selector: ${f}`)};return{root:p,document:s,capability:t,selector:ke(t),cloneToLive:i,liveToClone:a,original(f){return i.get(f)||null},cloneOf(f){return a.get(f)||null},query(f,m=p){return A(f),Array.from(m.querySelectorAll(f),g=>i.get(g)||g)},text(f=p){return(f===p?p:a.get(f))?.textContent||""},html(f=p){return(f===p?p:a.get(f))?.innerHTML??""},clone(f=p){let m=f===p?p:a.get(f);return m?s.importNode(m,!0):null}}}function jt(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Xr(e){return e?(e.nodeType===9||e.nodeType,e):null}function yt(e,t,r){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=r===null?"":r:t==="checked"&&e.tagName==="INPUT"?e.checked=r!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=r!==null))}function Dt(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function Pt(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let r of t)if(r.tagName==="TEXTAREA")r.value=r.defaultValue;else if(r.tagName==="INPUT"){let o=r.type;o!=="file"&&o!=="checkbox"&&o!=="radio"&&(r.value=r.defaultValue),r.checked=r.defaultChecked}else r.tagName==="OPTION"&&(r.selected=r.defaultSelected)}var N={semanticExclude:!0,find(e,t,r={}){let o=Xr(e);if(!o||!o.querySelectorAll)return[];let n=Array.from(o.querySelectorAll(t));r.includeRulesTag||(n=n.filter(i=>!jt(i)));let l=[];r.skip&&l.push(r.skip);let s=r.templateAttr===null?null:r.templateAttr||"cms-template";if(s&&l.push("["+s+"]"),l.length){let i=l.join(", ");n=n.filter(a=>!a.closest||!a.closest(i))}return n},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,Dt(e,t)},attr(e,t,r){if(r===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,r),yt(e,t,r)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),yt(e,t,null)},prop(e,t,r){if(r===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=r},clone(e){let t=e.cloneNode(!0);return Pt(t),t},insertAt(e,t,r){let o=e.children[r]||null;e.insertBefore(t,o)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let r=e.ownerDocument.createElement("template");r.innerHTML=t;let o=r.content.firstElementChild;if(!o)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(o,e),o},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(r=>{r.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function W(e,t={}){if(t.exclude===null)return N;let r=[ke("data"),t.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,n=e.nodeType===9?e.documentElement:e;if(!t._write&&!n?.matches?.(r)&&!n?.querySelector?.(r)&&!o?.querySelector?.(r))return N;let l=e.nodeType===9||!e.isConnected?e:e.ownerDocument,s=e.nodeType===9?e:e.ownerDocument,i=null,a=()=>i||(i=ae(l,{capability:"data",exclude:t.exclude||null})),u=f=>{let m=a();return f===e?m.cloneOf(e):m.cloneOf(f)||f},c=f=>i?.original(f)||f,d=(f,m)=>{a().liveToClone.set(f,m),a().cloneToLive.set(m,f);let g=f.childNodes||[],h=m.childNodes||[];for(let y=0;y<Math.min(g.length,h.length);y++)d(g[y],h[y])},p=(f,m,g,h)=>{let y=Array.from(f.childNodes).filter(x=>i.cloneOf(x)),v=y[0];for(;v&&y.includes(v);)v=v.nextSibling;for(let x of y)x.remove();if(g==="innerHTML"){let x=s.createElement("template");x.innerHTML=h;for(let S of Array.from(x.content.childNodes))f.insertBefore(S,v||null)}else f.insertBefore(s.createTextNode(h),v||null),Dt(f,h);let T=ae(f,{capability:"data",exclude:t.exclude||null});m.replaceChildren(...Array.from(T.root?.childNodes||[]));let O=x=>{let S=T.original(x);S&&(i.liveToClone.set(S,x),i.cloneToLive.set(x,S));for(let K of Array.from(x.childNodes||[]))O(K)};for(let x of Array.from(m.childNodes))O(x)},A={...N,find(f,m,g={}){let h=u(f);if(!h?.querySelectorAll)return[];let y=a().query(m,h);g.includeRulesTag||(y=y.filter(O=>!jt(O)));let v=[];g.skip&&v.push(g.skip);let T=g.templateAttr===null?null:g.templateAttr||"cms-template";if(T&&v.push(`[${T}]`),v.length){let O=v.join(", ");y=y.filter(x=>!x.closest?.(O))}return y},parent(f){let m=u(f)?.parentElement;return m?c(m):null},children(f){return Array.from(u(f)?.children||[],c)},text(f,m){if(m===void 0){let y=c(f);return!y?.matches?.(r)&&!y?.querySelector?.(r)?N.text(y):(u(f)?.textContent||"").trim()}let g=c(f);if(!g?.matches?.(r)&&!g?.querySelector?.(r)&&!i){N.text(g,m);return}let h=a().cloneOf(g);h?p(g,h,"textContent",m):N.text(g,m)},attr(f,m,g){let h=c(f);if(g===void 0)return N.attr(h,m);N.attr(h,m,g);let y=i?.cloneOf(h);y&&(N.attr(y,m,g),ae(h,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),i.liveToClone.delete(h),i.cloneToLive.delete(y)))},removeAttr(f,m){let g=c(f);N.removeAttr(g,m);let h=i?.cloneOf(g);h&&N.removeAttr(h,m)},prop(f,m,g){let h=c(f);if(g===void 0)return m==="innerHTML"||m==="outerHTML"||m==="textContent"||m==="innerText"?N.prop(u(h),m):N.prop(h,m);let y=m==="innerHTML"||m==="textContent"||m==="innerText",v=y?a().cloneOf(h):i?.cloneOf(h);v&&y?p(h,v,m,g):(N.prop(h,m,g),v&&N.prop(v,m,g))},clone(f){let m=u(f);if(m===f)return N.clone(f);let g=s.importNode(m,!0);return Pt(g),g},insertAt(f,m,g){let h=c(f),y=A.children(h)[g]||(()=>{for(let O=h.children.length-1;O>=0;O--){let x=h.children[O];if(a().cloneOf(x))return x.nextElementSibling}return h.firstElementChild})(),v=c(m);h.insertBefore(v,y||null);let T=a().cloneOf(h);if(T){let O=a().cloneOf(v);O||(O=s.importNode(v,!0),d(v,O));let x=Array.from(T.children);T.insertBefore(O,x[g]||null)}},insertBefore(f,m){let g=c(f),h=c(m);g.parentNode.insertBefore(h,g);let y=a().cloneOf(g.parentNode);if(y){let v=a().cloneOf(h);v||(v=s.importNode(h,!0),d(h,v));let T=a().cloneOf(g);T?T.before(v):y.appendChild(v)}},insertAfter(f,m){let g=c(f),h=c(m);g.parentNode.insertBefore(h,g.nextSibling);let y=a().cloneOf(g.parentNode);if(y){let v=a().cloneOf(h);v||(v=s.importNode(h,!0),d(h,v));let T=a().cloneOf(g);T?T.after(v):y.appendChild(v)}},identity(f){return c(f)||null},remove(f){let m=c(f),g=a().cloneOf(m);N.remove(m),g&&N.remove(g)},replaceWith(f,m){let g=c(f),h=a().cloneOf(g),y=N.replaceWith(g,m);if(h){let v=ae(y,{capability:"data",exclude:t.exclude||null});if(!v.root)h.remove();else{h.replaceWith(v.root);let T=O=>{let x=v.original(O);x&&(i.liveToClone.set(x,O),i.cloneToLive.set(O,x));for(let S of Array.from(O.childNodes||[]))T(S)};T(v.root)}}return y}};return A}var se=N,he={extract:(e,t,r={})=>ue(W(e,r),e,t,r),apply:(e,t,r,o={})=>ce(W(e,{...o,_write:!0}),e,t,r,o),findRulesIn:(e,t)=>Ie(se,e,t),findRules:(e,t)=>pt(se,e,t),bind:(e,t,r={})=>{let o=pt(se,e,t);if(!o){let n=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${n}`)}return{...o,get:()=>ue(W(e,r),e,o.rules,r),set:n=>ce(W(e,{...r,_write:!0}),e,o.rules,n,r)}},parseStrict:Rr,parseRelaxed:Ct,ruleAttrIndex:z,splitRule:ar,errors:P,DOM_PROPERTIES:gt},Se=e=>!!e&&typeof e.nodeType=="number";function Ut(e){let t=e&&e.ownerDocument?e.ownerDocument:e,r=Ie(se,t,"api");if(!r)throw new P.NoRulesTag("api");return r.rules}function Yr(e){if(e.nodeType===9)return e;let t=e.ownerDocument?.documentElement;if(t?.contains(e))return t;let r=e;for(;r.parentNode;)r=r.parentNode;return r}function Gr(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let t=e.ownerDocument.createDocumentFragment();for(let r of e.childNodes)t.appendChild(r.cloneNode(!0));return t}function Qr(e,t){let r=[];for(;t!==e;){let o=t.parentNode;r.push(Array.prototype.indexOf.call(o.childNodes,t)),t=o}return r.reverse()}function en(e,t){return t.reduce((r,o)=>r.childNodes[o],e)}function _(e,t){let r=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&r.unshift(e),r}function tn(e,t){let r=_(e,"option"),o=_(t,"option");r.forEach((a,u)=>o[u].selected=a.selected);let n=_(e,"input"),l=_(t,"input");n.forEach((a,u)=>{let c=a.type.toLowerCase();c!=="file"&&(l[u].value=a.value),(c==="checkbox"||c==="radio")&&(l[u].checked=a.checked)});let s=_(e,"textarea"),i=_(t,"textarea");s.forEach((a,u)=>i[u].value=a.value)}function Ne(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let r=e.startsWith("@")?0:z(e);if(r===-1)return;let o=e.slice(r+1);if(vt.has(o))throw new P.RuleTargetReadOnly(o);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(r=>Ne(e[1],r));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[r,o]of Object.entries(e))Ne(o,t[r])}}function rn(e,t,r){let o={templateAttr:"cms-template"},n=Yr(e),l=Qr(n,e),s=Gr(n);tn(n,s);let i=en(s,l),a=W(s,{...o,_write:!0}),u=Vr(a,i,t,r,o);if(u.unknownKeys.length||u.unmatched.length)throw new P.WriteRejected(u.unknownKeys,u.unmatched);let c=ft(a);ce(c,i,t,r,o),c.assertClean(),Ne(t,r);let d=ft(W(n,{...o,_write:!0}));ce(d,e,t,r,o),d.assertClean()}function nn(e){if(!(e instanceof Error))return e;let t=e.name||"Error";try{e.code=t}catch{Object.defineProperty(e,"code",{value:t,configurable:!0,enumerable:!0})}return e instanceof P.WriteRefused?e.details=e.refusals:e instanceof P.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof P.ShapeMismatch?e.details=e.mismatches:Array.isArray(e.path)?e.details={path:e.path}:typeof e.target=="string"?e.details={target:e.target}:e.token!==void 0?e.details={token:e.token}:e.version!==void 0?e.details={version:e.version}:e.details={},e}function Q(e,t){let r=Se(e)?e:document,o=Se(e)?t:e;return o===void 0?ue(W(r),r,Ut(r)):he.bind(r,o).get()}function ee(e,t,r){try{if(!Se(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let o=r===void 0?Ut(e):he.bind(e,r).rules;rn(e,o,t)}catch(o){throw nn(o)}return e}var qt="clay:visitor-drafts:",Wt=1;function B(e=window.location.pathname){let r=String(e||"/").replace(/\/{2,}/g,"/").match(/^(.*?\/[^/]+\.(?:html|htmlclay))(?:\/|$)/i),o=r?r[1]:"/";return o.toLowerCase()==="/index.html"?"/":o}var Ue=e=>qt+e,_t=(e,t=B())=>`${qt}${e}@${t}`;function ve(){try{return window.localStorage}catch{return null}}var j=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);function on(e){let t=[];for(let r of e.matchAll(/([^.[\]]+)|\[(\d+)\]/g))t.push(r[2]!==void 0?Number(r[2]):r[1]);return t}function ln(e,t){let r=on(t),o=e;for(let n=0;n<r.length-1;n++)if(o=o?.[r[n]],o==null||typeof o!="object")return;o&&typeof o=="object"&&delete o[r[r.length-1]]}function U(e,t){return Array.isArray(e)?Array.isArray(t)&&t.length===e.length&&e.every((r,o)=>U(r,t[o])):j(e)?j(t)&&Object.keys(e).every(r=>U(e[r],t[r])):e===t}function V(e,t){return U(e,t)&&U(t,e)}var F=e=>Array.isArray(e)&&e.every(t=>j(t)&&(typeof t.id=="string"||typeof t.id=="number"))&&new Set(e.map(t=>t.id)).size===e.length;function me(e,t,r=!1){if(j(e)&&j(t)){let o={...e};for(let n of Object.keys(t))n in e?o[n]=me(e[n],t[n]):r||(o[n]=t[n]);return o}if(F(e)&&F(t)){let o=new Map(t.map(n=>[n.id,n]));return e.map(n=>o.has(n.id)?me(n,o.get(n.id)):n)}return e}var Bt=(e,t)=>e.length===t.length&&e.every((r,o)=>r===t[o]);function an(e,t,r){let o=d=>new Map(d.map(p=>[p.id,p])),n=o(e),l=o(t),s=o(r),i=d=>d.filter(p=>n.has(p.id)&&l.has(p.id)&&s.has(p.id)).map(p=>p.id),a=i(e);if(!Bt(a,i(t))||!Bt(a,i(r)))return null;for(let[d,p]of n)if(l.has(d)&&!s.has(d)&&!V(l.get(d),p)||!l.has(d)&&s.has(d)&&!V(s.get(d),p))return null;let u=!1,c=[];for(let d of t){if(n.has(d.id)&&!s.has(d.id))continue;if(!s.has(d.id)){c.push(d);continue}let p=ye(n.get(d.id),d,s.get(d.id),!0);u||=p.conflict,c.push(p.value)}return r.forEach((d,p)=>{if(n.has(d.id)||l.has(d.id))return;let A=0;for(let f=p-1;f>=0;f--){let m=c.findIndex(g=>g.id===r[f].id);if(m!==-1){A=m+1;break}}c.splice(A,0,d)}),{value:c,conflict:u}}function ye(e,t,r,o){if(V(t,r)||V(r,e))return{value:t,conflict:!1};if(V(t,e))return{value:r,conflict:!1};if(j(t)&&j(r)){let n={},l=!1;for(let s of new Set([...Object.keys(t),...Object.keys(r)])){let i=ye(j(e)?e[s]:void 0,t[s],r[s],o);l||=i.conflict,i.value!==void 0&&(n[s]=i.value)}return{value:n,conflict:l}}if(o&&F(e)&&F(t)&&F(r)){let n=an(e,t,r);if(n)return n}return{value:t,conflict:!0}}function ge(e,t=new Map){if(Array.isArray(e)){if(F(e))for(let r of e)t.set(r.id,(t.get(r.id)||0)+1);for(let r of e)ge(r,t)}else if(j(e))for(let r of Object.values(e))ge(r,t);return t}function sn(e,t,r){let o=ye(e,t,r,!0),n=ge(t);for(let[l,s]of ge(o.value))if(s>1&&s>(n.get(l)||0))return ye(e,t,r,!1);return o}function Pe(e,t){J(!0),e.dispatchEvent(new CustomEvent("clay:drafts-store-failed",{detail:{error:t}}));let r=new Error("Couldn't save in this browser. Storage is full or turned off.");return r.code="draft-storage",r}var Ht=e=>{try{return String(JSON.parse(e)?.savedAt??"")}catch{return""}};function zt(e,{path:t=B(),storage:r=ve()}={}){let o=Ue(e),n=_t(e,t),l=n+":legacy";try{let s=r?.getItem(n),i=r?.getItem(o);if(i==null){let d=r?.getItem(o+":ui");return d!=null&&r.getItem(n+":ui")==null&&r.getItem(n+":ui-legacy")==null&&(r.setItem(n+":ui",d),r.setItem(n+":ui-legacy","1")),"none"}let a=Ht(i),u=r.getItem(l);if(u===a)return"none";let c=r.getItem(n);if(c!==s)return"none";if(c==null||u!=null&&Ht(c)===u?r.setItem(n,i):c!==i&&(r.setItem(n+":conflict",i),console.warn("visitor-drafts: an older tab changed this draft after it moved; its copy was kept under",n+":conflict")),u==null){let d=r.getItem(o+":ui");d!=null&&r.getItem(n+":ui")==null&&r.setItem(n+":ui",d)}return r.setItem(l,a),"copied"}catch{return"failed"}}function Vt({doc:e=document,storage:t=ve(),now:r=()=>new Date,path:o=B(),fallback:n=null}={}){let l=ie(e),s=_t(l,o),i=he.findRulesIn(e,"api").rules,a=null,u=null,c=null,d=!1;function p(){try{if(!t)return null;let b=t.getItem(s);return b==null&&n?t.getItem(n):b}catch{return null}}function A(b){try{let w=JSON.parse(b);if(j(w)&&w.v===Wt&&j(w.data))return w}catch{}return null}function f(){let b=p();return b==null?null:{raw:b,record:A(b)}}function m(){return Q(e,i)}function g(){let b=window.clay?.getHTML;return typeof b!="function"?m():Q(new DOMParser().parseFromString(b.call(window.clay),"text/html"),i)}function h(){try{if(typeof t.keys=="function")return t.keys();let b=[];for(let w=0;w<t.length;w++)b.push(t.key(w));return b}catch{return[]}}function y(){try{return JSON.stringify(g())}catch{return null}}function v(b,{keepSlot:w=!1}={}){let k=h().find(M=>M.startsWith(s+":unreadable:")&&t.getItem(M)===b);if(k){if(c=null,!w)try{t.removeItem(s)}catch{}return k}let L=s+":unreadable:"+r().toISOString();try{t.setItem(L,b)}catch{return c=b,console.warn("visitor-drafts: this browser's saved copy no longer fits the page, and there is no room to keep it aside; nothing will be saved over it"),null}if(c=null,!w)try{t.removeItem(s)}catch{}return console.warn(w?"visitor-drafts: part of this browser's saved copy no longer fits the page; the original was kept under":"visitor-drafts: this browser's saved copy no longer fits the page; it was kept under",L),L}function T(b){let w=me(JSON.parse(JSON.stringify(b)),m(),!0),k=[];for(let L=0;L<4;L++){let M=e.cloneNode(!0);try{ee(M,w,i)}catch(C){let be=C?.details?.unknownKeys??C?.unknownKeys;if(Array.isArray(be)&&be.length){for(let q of be)ln(w,q);continue}let Ae=Object.keys(w).filter(q=>{try{return ee(e.cloneNode(!0),{[q]:w[q]},i),!1}catch{return!0}});if(!Ae.length)return null;for(let q of Ae)delete w[q];k.push(...Ae);continue}let le=Q(M,i),H=Object.keys(w).filter(C=>!U(w[C],le[C]));if(!H.length)return{data:w,dropped:k};for(let C of H)delete w[C];k.push(...H)}return null}function O(b){let w=v(b);return w||(a=b),u=m(),w?{restored:!1,hadDraft:!0,parked:!0}:{restored:!1,hadDraft:!0,parked:!1,blocked:!0}}function x(){let b=f();if(!b)return u=m(),{restored:!1,hadDraft:!1};if(!b.record)return O(b.raw);let w=T(b.record.data);if(!w||!Object.keys(w.data).length)return O(b.raw);if(ee(e,w.data,i),a=b.raw,u=m(),w.dropped.length){let k=v(b.raw,{keepSlot:!0});return{restored:!0,hadDraft:!0,data:w.data,partial:!0,parked:!!k,blocked:!k}}return{restored:!0,hadDraft:!0,data:w.data}}function S(){if(d)return!1;try{return!U(g(),u)}catch{return!0}}function K(b){let w=s+":conflict";try{t.setItem(w,b)}catch(k){throw Pe(e,k)}console.warn("visitor-drafts: another tab changed the same thing; its copy was kept under",w)}function we(b){let w=p(),k=w==null?null:A(w);if(!k)return{data:b,stored:null};let L=b;if(w!==a){let M=sn(u,b,k.data);M.conflict&&K(w),L=M.value}return L=me(L,k.data),{data:L,stored:V(L,k.data)?w:null}}function ne(b){let w=T(b);if(!w||!Object.keys(w.data).length)return null;ee(e,w.data,i);try{window.Sap?.refresh?.()}catch{}return e.dispatchEvent(new CustomEvent("clay:drafts-restored",{detail:{restored:!0,hadDraft:!0,parked:!1,external:!0}})),w.data}function oe(b){if(d)return null;if(c!=null&&v(c,{keepSlot:!0})===null)throw Pe(e,new Error("an earlier saved copy could not be kept aside"));let w=Q(new DOMParser().parseFromString(b,"text/html"),i),k=p();if(U(w,u)&&(k===a||k==null))return J(!1),e.dispatchEvent(new CustomEvent("clay:drafts-saved",{detail:{data:w,unchanged:!0}})),w;let{data:L,stored:M}=we(w),le=M??JSON.stringify({v:Wt,savedAt:r().toISOString(),data:L});if(!M)try{if(!t)throw new Error("no storage");t.setItem(s,le)}catch(C){throw Pe(e,C)}let H=Object.keys(w).filter(C=>!U(w[C],L[C]));return H.length&&ne(Object.fromEntries(H.map(C=>[C,L[C]]))),a=le,u=L,J(!1),e.dispatchEvent(new CustomEvent("clay:drafts-saved",{detail:{data:L}})),L}function E(){try{return oe(window.clay.getHTML()),!0}catch{return!1}}function R(){return d||!S()?!0:E()}function $(){if(d)return!1;let b=p();if(b==null||b===a||S())return!1;let w=A(b),k=w&&ne(w.data);return k?(a=b,u={...u,...k},!0):!1}function D(){d=!0,c=null,J(!1);try{t.removeItem(s)}catch{}}return{slot:l,key:s,rules:i,read:f,restore:x,write:oe,writeLive:E,flush:R,changed:S,adoptExternal:$,park:v,clear:D,snapshot:y}}function Ft(e,t){let r=`${e}:ui`,o=()=>({v:1,prompt:{},intro:{done:null},src:null}),n=o();try{let l=JSON.parse(t?.getItem(r)||"null");l&&typeof l=="object"&&l.v===1&&(n={...o(),...l})}catch{}return{get:()=>n,save(){try{t?.setItem(r,JSON.stringify(n))}catch{}},reset(){n=o();try{t?.removeItem(r)}catch{}}}}var un=/^[a-z0-9][a-z0-9-]{0,39}$/;function Kt(e,t=window.location.search){let r=e.get(),o=null;try{o=new URLSearchParams(t).get("src")}catch{}return!r.src&&o&&un.test(o)&&(r.src=o,e.save()),r.src}function Jt(e,t=window.location){let r=B(t.pathname);return`/_/download${r==="/"?"":r}?as=htmlclay${e?`&src=${encodeURIComponent(e)}`:""}`}var cn=`<aside class="hcp" id="hcp" hidden aria-label="Download this app" data-hcp-state="tab" data-hcp-reason="open" sap-ignore clay="editor-ui">
1
+ import{b as Je,c as Ze}from"../c-Y6F2FORL.js";import{b as Ke}from"../c-QY7F6EN6.js";import{a as Xe,b as Ye,c as Ge,d as Qe}from"../c-MTQHWQC3.js";import{b as Ve,f as Fe,h as Ee}from"../c-3O7OBDCM.js";import{d as qe}from"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import{d as le,f as _e,h as ze,j as K}from"../c-N7JPUPGC.js";import"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var Gt=Object.defineProperty,Qt=(e,t)=>{for(var r in t)Gt(e,r,{get:t[r],enumerable:!0})},gt=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],er=new Set(gt),tr=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),wt=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),et=new Set(["checked","selected","disabled","readOnly","paused"]);function rr(e,t){return t==null?et.has(e)?!1:"":et.has(e)?t==="false"?!1:!!t:t}var D={};Qt(D,{EmptyListInsert:()=>Y,MAX_RULE_DEPTH:()=>de,MaxRuleDepthExceeded:()=>Re,NoRulesTag:()=>lr,RuleTargetReadOnly:()=>At,RulesParseError:()=>Le,ShapeMismatch:()=>bt,UnknownRulesVersion:()=>vt,WriteNotRoundTripped:()=>or,WriteRefused:()=>Et,WriteRejected:()=>ir});var Le=class extends Error{constructor(e,t){super(e),this.name="RulesParseError",this.cause=t}},vt=class extends Error{constructor(e){super(`unknown rules version: ${e}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=e}},de=20,Re=class extends Error{constructor(e){super(`rule depth exceeded ${de} at path: ${e.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=e}},bt=class extends Error{constructor(e){super(`shape mismatch: ${e.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=e}},Y=class extends Error{constructor(e,t){super(t?`cannot add items to empty list at "${e.join(".")}" \u2014 ${t}`:`cannot add items to empty list at "${e.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=e}},At=class extends Error{constructor(e){super(`cannot write to read-only DOM property "${e}"`),this.name="RuleTargetReadOnly",this.target=e}},Et=class extends Error{constructor(e){super(`write refused: ${e.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=e}};function nr(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t?`${t}.${r}`:String(r),"")||"(root)"}var or=class extends Error{constructor(e){super(`write did not round-trip at "${nr(e)}"`),this.name="WriteNotRoundTripped",this.path=e}},lr=class extends Error{constructor(e){super(`no <script data-rules-name~="${e}"> rules tag in this document`),this.name="NoRulesTag",this.token=e}},ir=class extends Error{constructor(e,t){super(`write rejected: ${e.length} unknown key(s), ${t.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=e,this.unmatched=t}};function _(e){let t=0,r=null,o=-1;for(let n=0;n<e.length;n++){let l=e[n];l==="\\"?n++:r?l===r&&(r=null):l==='"'||l==="'"?r=l:l==="["||l==="("?t++:l==="]"||l===")"?t>0&&t--:l==="@"&&t===0&&(o=n)}return o}function ar(e){let t=_(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function xt(e){let t=0,r=null,o=-1,n=!1;for(let l=0;l<e.length;l++){let s=e[l];s==="\\"?l++:r?s===r&&(r=null):s==='"'||s==="'"?r=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:t===0&&s===">"?o=l:t===0&&s===","&&(n=!0)}return n||o===-1||!sr(e,o+1)?null:e.slice(0,o).trim()||null}function sr(e,t){let r=t,o=e.replace(/\s+$/,"").length;for(;r<o&&/\s/.test(e[r]);)r++;let n=0,l=null;for(;r<o;r++){let s=e[r];if(s==="\\")r++;else if(l)s===l&&(l=null);else if(s==='"'||s==="'")l=s;else if(s==="["||s==="(")n++;else if(s==="]"||s===")")n>0&&n--;else if(n===0&&(s==="+"||s==="~"||/\s/.test(s)))return!1}return!0}var ur=/^--[A-Za-z0-9_-]+$/;function Ce(e){return typeof e=="string"&&ur.test(e)}function Tt(e){let t=[],r=[],o=null,n=0;for(let l=0;l<e.length;l++){let s=e[l];if(o){s==="\\"?l++:s===o&&(o=null);continue}if(s==="/"&&e[l+1]==="*"){let i=e.indexOf("*/",l+2);l=i===-1?e.length:i+1;continue}s==='"'||s==="'"?o=s:s==="("?r.push(")"):s==="["?r.push("]"):s==="{"?r.push("}"):(s===")"||s==="]"||s==="}")&&r[r.length-1]===s?r.pop():s===";"&&r.length===0&&(t.push(e.slice(n,l)),n=l+1)}return t.push(e.slice(n)),t}function cr(e){let t="",r=null;for(let o=0;o<e.length;o++){let n=e[o];if(r){t+=n,n==="\\"&&o+1<e.length?t+=e[++o]:n===r&&(r=null);continue}if(n==="/"&&e[o+1]==="*"){let l=e.indexOf("*/",o+2);o=l===-1?e.length:l+1,t+=" ";continue}(n==='"'||n==="'")&&(r=n),t+=n}return t}function Ot(e){e=cr(e);let t=e.indexOf(":");if(t===-1)return null;let r=e.slice(0,t).trim(),o=e.slice(t+1).trim(),n=/!\s*important\s*$/i.exec(o);return n&&(o=o.slice(0,n.index).trim()),{name:r,value:o,important:!!n}}function $e(e,t){if(e==null)return null;let r=null;for(let o of Tt(String(e))){let n=Ot(o);!n||n.name!==t||(!r||n.important||!r.important)&&(r=n)}return r?r.value:null}function fr(e,t,r){let o=e==null?"":String(e),n=r==null||r==="",l=Tt(o),s=l.map(Ot),i=s.some(d=>d&&d.name===t&&d.important),a=[],u=!1;l.forEach((d,p)=>{let A=s[p];if(!A||A.name!==t){a.push(d);return}if(n||u)return;let f=/^\s*/.exec(d)[0];a.push(`${f}${t}: ${r}${i?" !important":""}`),u=!0});let c=a.join(";");if(!n&&!u){let d=c.trimEnd();c=d===""?`${t}: ${r}`:`${d}${d.endsWith(";")?" ":"; "}${t}: ${r}`}return c.trim()===""?null:c}function kt(e,t,r,o){let n=e.attr(t,"style");if(($e(n,r)??"")===o)return;let l=fr(n,r,o);l==null?e.removeAttr(t,"style"):e.attr(t,"style",l)}function se(e,t,r,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return xe(e,t,r,{depth:0,path:[]},o)}function xe(e,t,r,o,n){if(o.depth>de)throw new Re(o.path);if(typeof r=="string")return dr(e,t,r,o,n);if(Array.isArray(r)){let[l,s]=r,i=e.find(t,l,n);return St(n,o,i),i.map((a,u)=>xe(e,a,s,{depth:o.depth+1,path:[...o.path,u]},n))}if(typeof r=="object"&&r!==null){let l={};for(let[s,i]of Object.entries(r))l[s]=xe(e,t,i,{depth:o.depth+1,path:[...o.path,s]},n);return l}return null}function dr(e,t,r,o,n){if(r.endsWith("[]")){let i=r.slice(0,-2),a=e.find(t,i,n);return St(n,o,a),a.map(u=>e.text(u))}if(r.startsWith("@"))return tt(e,t,r.slice(1));let l=_(r);if(l!==-1){let i=r.slice(0,l),a=r.slice(l+1),u=i?e.find(t,i,n):[t];return u.length===0?null:tt(e,u[0],a)}if(r===".")return e.text(t);let s=e.find(t,r,n);return s.length===0?null:e.text(s[0])}function St(e,t,r){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),r)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function tt(e,t,r){if(Ce(r))return $e(e.attr(t,"style"),r);if(er.has(r)){let n=e.prop(t,r);return n==null?null:String(n)}return e.attr(t,r)??null}function pr(e,t,r,o){let n=e.length,l=t.length,s=new Array(n).fill(-1);if(o){let h=new Set;for(let y=0;y<n;y++){let w=o[y];!(w>=0&&w<l)||h.has(w)||(s[y]=w,h.add(w))}}if(n===0||l===0)return s;let i=e.map(h=>rt(h,r)),a=t.map(h=>rt(h,r)),u=new Array(l).fill(!1);for(let h of s)h>=0&&(u[h]=!0);let c=new Map;a.forEach((h,y)=>{u[y]||c.set(h,c.has(h)?-1:y)});let d=new Map;i.forEach((h,y)=>{s[y]>=0||d.set(h,(d.get(h)||0)+1)}),i.forEach((h,y)=>{if(s[y]>=0||d.get(h)!==1)return;let w=c.get(h);w===void 0||w===-1||u[w]||(s[y]=w,u[w]=!0)});let p=[];for(let h=0;h<n;h++)s[h]<0&&p.push(h);let A=[];for(let h=0;h<l;h++)u[h]||A.push(h);if(p.length===0||A.length===0)return s;let f=n*l+1,m=hr(e,t,r),g=(h,y)=>m(h,y)*f+Math.abs(h-y);for(let[h,y]of mr(p,A,g))s[h]=y;return s}var Nt=e=>typeof e=="object"&&e!==null;function rt(e,t){if(!Nt(t))return e==null?" null":String(e);let r=Object.keys(t);return JSON.stringify(r.map(o=>{let n=JSON.stringify(e?.[o]);return n===void 0?" undef":n}))}function hr(e,t,r){if(!Nt(r))return(i,a)=>e[i]===t[a]?0:1;let o=Object.keys(r),n=i=>o.map(a=>JSON.stringify(i?.[a])),l=e.map(n),s=t.map(n);return(i,a)=>{let u=l[i],c=s[a],d=0;for(let p=0;p<o.length;p++)u[p]!==c[p]&&d++;return d}}function mr(e,t,r){return e.length<=t.length?nt(e,t,r,!1):nt(t,e,(o,n)=>r(n,o),!0)}function nt(e,t,r,o){let n=e.length,l=t.length,s=[];for(let d=0;d<=n;d++)s.push(new Float64Array(l+1).fill(1/0));let i=[];for(let d=0;d<=n;d++)i.push(new Uint8Array(l+1));for(let d=0;d<=l;d++)s[n][d]=0;for(let d=n-1;d>=0;d--)for(let p=l-1;p>=0;p--){let A=r(e[d],t[p])+s[d+1][p+1],f=s[d][p+1];A<=f?(s[d][p]=A,i[d][p]=1):s[d][p]=f}let a=[],u=0,c=0;for(;u<n&&c<l;)i[u][c]&&(a.push(o?[t[c],e[u]]:[e[u],t[c]]),u++),c++;return a}function Lt(e,t,r,o,n,l,s,i={}){let a=e.find(t,r,i);if(n.length===0){a.forEach(T=>e.remove(T)),Te(i,"onRowsApplied",l.path,[]);return}let u=n.length>a.length,c=a[0]||null;if(u&&!c&&(c=vr(e,t,r,i),!c))throw new Y(l.path);let d=a.map(T=>wr(e,T,o,i)),p=null;if(u&&c){p=e.clone(c),i.templateAttr&&e.removeAttr(p,i.templateAttr);let T=e.stripIds(p);T>0&&console.warn(`[hyper-html-api] stripped ${T} id attribute(s) from cloned template at "${l.path.join(".")||"(root)"}"`)}let A=pr(n,d,o,yr(e,a,n,l,i)),f=a.length>0?e.parent(a[0]):xr(e,t,r,c,l,i),m=a.length>0?Rt(e,f,a[0]):0,g=kr(e,a),h=new Set,y=[],w=n.map((T,O)=>{let x=A[O];if(x>=0)return h.add(x),y.push(!1),a[x];y.push(!0);let S=e.clone(p);return e.stripIds(S),S});a.forEach((T,O)=>{h.has(O)||e.remove(T)}),g?Or(e,f,m,w,y):Sr(e,w,y,f,m),gr(e,w,o,n,l,s,i),Te(i,"onRowsApplied",l.path,w)}function Te(e,t,r,o){if(typeof e[t]=="function")try{return e[t](r.slice(),o)}catch(n){console.warn(`[hyper-html-api] ${t} threw at "${r.join(".")||"(root)"}"`,n);return}}function yr(e,t,r,o,n){let l=Te(n,"identifyRows",o.path,r);if(!Array.isArray(l))return null;let s=new Array(r.length).fill(-1),i=new Set,a=new Map(t.map((u,c)=>[e.identity(u),c]));for(let u=0;u<r.length;u++){if(!l[u])continue;let c=a.get(e.identity(l[u]));c===void 0||i.has(c)||(s[u]=c,i.add(c))}return s}function gr(e,t,r,o,n,l,s){t.forEach((i,a)=>{if(r===null){let u=o[a],c=u==null?"":String(u);e.text(i)!==c&&e.text(i,c)}else{let u=l(e,i,r,o[a],{depth:n.depth+1,path:[...n.path,a]},s);u&&u!==i&&(t[a]=u)}})}function wr(e,t,r,o){return r===null?e.text(t):se(e,t,r,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function Rt(e,t,r){let o=e.children(t);for(let n=0;n<o.length;n++)if(e.sameNode(o[n],r))return n;return-1}function vr(e,t,r,o){if(!o.templateAttr)return null;let n=/^\s*:scope\s*>\s*/.test(r),l=new RegExp(":not\\(\\["+o.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),s=r.replace(/^\s*:scope\s*>\s*/,"").replace(l,""),i=n?br(s):0,a=xt(s),u=t;for(;u;){let c=e.find(u,s,{includeRulesTag:!1,templateAttr:null});for(let d of c)if(e.attr(d,o.templateAttr)!=null&&!(n&&!Er(e,t,d,i))&&!(a&&!e.matches(e.parent(d),a)))return d;u=e.parent(u)}return null}function br(e){let t=0,r=null,o=1;for(let n=0;n<e.length;n++){let l=e[n];if(l==="\\")n++;else if(r)l===r&&(r=null);else if(l==='"'||l==="'")r=l;else if(l==="["||l==="(")t++;else if(l==="]"||l===")")t>0&&t--;else if(t===0&&l===">")o++;else{if(t===0&&(l==="+"||l==="~"))return null;if(t===0&&/\s/.test(l)){if(!Ar(e,n))return null;for(;n+1<e.length&&/\s/.test(e[n+1]);)n++}}}return o}function Ar(e,t){let r=t;for(;r<e.length&&/\s/.test(e[r]);)r++;let o=t>0?e[t-1]:"",n=r<e.length?e[r]:"";return ot(o)||ot(n)}function ot(e){return e===">"||e==="+"||e==="~"}function Er(e,t,r,o){if(o===null)return!0;let n=r;for(let a=0;a<o;a++)if(n=e.parent(n),!n)return!1;let l=e.prop(t,"tagName");if(!l)return!0;let s=e.prop(n,"tagName");if(!s||String(s).toLowerCase()!==String(l).toLowerCase())return!1;let i=new Set(lt(e,n));return lt(e,t).every(a=>i.has(a))}function lt(e,t){let r=e.attr(t,"class");return r?String(r).split(/\s+/).filter(Boolean):[]}function xr(e,t,r,o,n,l){let s=e.parent(o);if(s&&Tr(e,t,s)&&!at(e,s,l))return s;let i=xt(r);if(!i)throw new Y(n.path,`the list selector "${r}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let a=(i===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,i,l)).filter(u=>!at(e,u,l));if(a.length===0)throw new Y(n.path,`no container matching "${i}" inside this context to hold the new rows`);if(a.length>1)throw new Y(n.path,`"${i}" matches ${a.length} containers inside this context, so the new rows have no single destination`);return a[0]}function Tr(e,t,r){let o=r;for(;o;){if(e.sameNode(o,t))return!0;o=e.parent(o)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(n=>e.sameNode(n,r))}var it=["no-data","editor-ui"];function at(e,t,r){let o=t;for(;o;){if(r.templateAttr&&e.attr(o,r.templateAttr)!=null||it.some(l=>e.attr(o,l)!=null))return!0;let n=e.attr(o,"clay");if(n&&n.split(/\s+/).some(l=>it.includes(l)))return!0;o=e.parent(o)}return!1}function Or(e,t,r,o,n){let l=e.children(t),s=l.map(a=>e.identity(a)),i=!1;o.forEach((a,u)=>{let c=e.identity(a),d=r+u;if(s[d]===c)return;if(!n[u]){let A=s.indexOf(c);A!==-1&&(s.splice(A,1),l.splice(A,1))}let p=Math.min(d,l.length);p<l.length?e.insertBefore(l[p],a):l.length?i?e.insertAfter(l[l.length-1],a):(e.insertAt(t,a,d),i=!0):e.insertAt(t,a,0),s.splice(p,0,c),l.splice(p,0,a)})}function kr(e,t){if(t.length<=1)return!0;let r=e.parent(t[0]);if(!r)return!1;let o=new Map(e.children(r).map((l,s)=>[e.identity(l),s])),n=[];for(let l of t){let s=o.get(e.identity(l));if(s===void 0)return!1;n.push(s)}return n.sort((l,s)=>l-s),n[n.length-1]-n[0]===n.length-1}function Sr(e,t,r,o,n){let l=null,s=n;for(let i=0;i<t.length;i++){if(!r[i]){l=t[i];continue}let a=l?e.parent(l):o;if(!a)continue;let u=l?Rt(e,a,l)+1:s++;e.insertAt(a,t[i],u),l=t[i]}}function ue(e,t,r,o,n={}){if(Object.prototype.hasOwnProperty.call(n,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let l=[];if(Oe(r,o,[],l),l.length)throw new bt(l);ce(e,t,r,o,{depth:0,path:[]},n)}function ce(e,t,r,o,n,l={}){if(n.depth>de)throw new Re(n.path);if(o===void 0)return t;if(typeof r=="string")return Nr(e,t,r,o,n,l);if(Array.isArray(r)){let[s,i]=r;return Lt(e,t,s,i,o,n,ce,l),t}if(typeof r=="object"&&r!==null){for(let[s,i]of Object.entries(r)){let a=ce(e,t,i,o==null?o:o[s],{depth:n.depth+1,path:[...n.path,s]},l);a&&a!==t&&(t=a)}return t}return t}function Nr(e,t,r,o,n,l){if(r.endsWith("[]")){let a=r.slice(0,-2);return Lt(e,t,a,null,o,n,ce,l),t}if(r.startsWith("@"))return ut(e,t,r.slice(1),o);let s=_(r);if(s!==-1){let a=r.slice(0,s),u=r.slice(s+1),c=a?e.find(t,a,l):[t];return c.length===0||ut(e,c[0],u,o),t}if(r===".")return st(e,t,o),t;let i=e.find(t,r,l);return i.length===0||st(e,i[0],o),t}function st(e,t,r){let o=r==null?"":String(r);e.text(t)!==o&&e.text(t,o)}function Lr(e,t,r,o){if(e.styleVar){e.styleVar(t,r,o);return}kt(e,t,r,o)}function ut(e,t,r,o){if(Ce(r))return Lr(e,t,r,o==null?"":String(o).trim()),t;if(wt.has(r)){let n=e.prop(t,r);if(n===o||n!=null&&o!=null&&String(n)===String(o))return t;throw new At(r)}if(r==="outerHTML"){let n=o==null?"":String(o);return e.replaceWith(t,n)}if(tr.has(r)){let n=rr(r,o);return e.prop(t,r)!==n&&e.prop(t,r,n),t}if(o==null)e.attr(t,r)!=null&&e.removeAttr(t,r);else{let n=String(o);e.attr(t,r)!==n&&e.attr(t,r,n)}return t}function Oe(e,t,r,o){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((n,l)=>{typeof n=="object"&&n!==null&&o.push({path:Z([...r,l]),expected:"scalar",got:J(n)})}):o.push({path:Z(r),expected:"array",got:J(t)});return}t!==null&&typeof t=="object"&&o.push({path:Z(r),expected:"scalar",got:J(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:Z(r),expected:"array",got:J(t)});return}let n=e[1];t.forEach((l,s)=>Oe(n,l,[...r,s],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:Z(r),expected:"object",got:J(t)});return}for(let[n,l]of Object.entries(e))Oe(l,t[n],[...r,n],o)}}}function J(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function Z(e){return e.join(".")}function Rr(e){try{return JSON.parse(e)}catch(t){throw new Le(`Invalid strict JSON: ${t.message}`,t)}}function Ct(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function r(n){let l=[],s=0;for(;s<n.length;){let i=n[s];if(/\s/.test(i)){s++;continue}if("{}".includes(i)){l.push({type:i,value:i}),s++;continue}if(i==="["){let d=!1,p=s+1;for(;p<n.length&&/\s/.test(n[p]);)p++;if(p<n.length&&/[a-zA-Z_]/.test(n[p])&&(d=!0),!d){l.push({type:i,value:i}),s++;continue}}if(i==="]"){l.push({type:i,value:i}),s++;continue}if(i===":"){l.push({type:t.COLON,value:i}),s++;continue}if(i===","){l.push({type:t.COMMA,value:i}),s++;continue}if(i==='"'||i==="'"){let d=i,p=s+1;for(;p<n.length&&n[p]!==d;)n[p]==="\\"&&p++,p++;l.push({type:t.STRING,value:n.substring(s+1,p),quoted:!0,sourceQuote:d}),s=p+1;continue}let a=s,u;for(;a<n.length&&!/[{},]/.test(n[a]);)if(n[a]===":"){let d=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],p=!1;for(let A of d){let f=A.substring(1);if(n.substring(a+1,a+1+f.length)===f){p=!0,a+=f.length;break}}if(!p)break}else if(n[a]==="["){for(a++;a<n.length&&n[a]!=="]";){if(n[a]==='"'||n[a]==="'"){let d=n[a];for(a++;a<n.length&&n[a]!==d;)n[a]==="\\"&&a++,a++}a++}a<n.length&&n[a]==="]"&&a++}else a++;u=n.substring(s,a);let c=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?c=t.NUMBER:u==="true"||u==="false"||u==="null"?c=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(c=t.SELECTOR),l.push({type:c,value:u,quoted:!1}),s=a}return l}function o(n){let l="";for(let s=0;s<n.length;s++){let i=n[s];if("{}".includes(i.type)||"[]".includes(i.type)){l+=i.value;continue}if(i.type===t.COLON){l+=i.value;continue}if(i.type===t.COMMA){let a=n[s+1];if(a&&(a.type==="}"||a.type==="]"))continue;l+=i.value;continue}if(i.type===t.STRING&&i.quoted){let a=i.value;i.sourceQuote==="'"&&(a=a.replace(/\\'/g,"'"),a=a.replace(/(\\*)"/g,(u,c)=>c.length%2===0?c+'\\"':u)),l+=`"${a}"`;continue}if(i.type===t.NUMBER||i.type===t.BOOLEAN){l+=i.value;continue}if(i.type===t.SELECTOR||i.type===t.IDENTIFIER){l+=`"${i.value}"`;continue}l+=`"${i.value}"`}return l}try{let n=r(e),l=o(n);return JSON.parse(l)}catch(n){throw new Le("Invalid extraction rules syntax: "+n.message,n)}}var Cr="1",ct=/^[a-zA-Z0-9_-]+$/;function Ie(e,t,r){let o;if(r===void 0)o="script[data-rules-name]";else{if(typeof r!="string"||!ct.test(r))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(r)} (must match ${ct})`);o=`script[data-rules-name~="${r}"]`}let n=e.find(t,o,{includeRulesTag:!0});if(n.length===0)return null;r!==void 0&&n.length>1&&console.warn(`hyper-html-api: ${n.length} rules tags match data-rules-name~="${r}"; using the first.`);let l=n[0],s=e.attr(l,"data-rules-version");if(s!==Cr)throw new vt(s);return{rules:Ct(e.text(l)),tagNode:l}}var Me=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),$r=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Ir=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function fe(e,t){if(!e||e.nodeType!==1)return!1;let r=e.getAttribute?.("clay");return!!(r&&r.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function $t(e,t){if(fe(e,t))return!0;for(let[r,o]of Object.entries($r))if(o.includes(t)&&fe(e,r))return!0;return!1}function ke(e){let t=Me[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(r=>[`[clay~="${r}"]`,`[${r}]`]).join(", ")}function Mr(e,t){let r=e&&e.nodeType===1?e:e?.parentElement;for(;r&&r.nodeType===1;){let o=Me[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(n=>$t(r,n))||o.bundles.some(n=>fe(r,n)))return r;r=r.parentElement}return null}function jr(e,t){return!!Mr(e,t)}var je=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...Ir],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})}),Dr=new Set(["textContent","innerText"]);function Pr(e){let t=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return t?t[1].toLowerCase():null}var Hr=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function Wr(e,t,r=je){if(!Hr.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let o=String(e).toLowerCase();if(r.refusedAttributePrefixes.some(n=>o.startsWith(n)))return`attribute "${o}" can run script`;if(r.refusedAttributes.includes(o))return`attribute "${o}" is not content`;if(r.urlAttributes.includes(o)&&t!=null){let n=o==="srcset"?String(t).split(",").map(l=>l.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let l of n){let s=Pr(l);if(s&&r.refusedSchemes.includes(s))return`"${s}:" URLs are not allowed in "${o}"`}}return null}function De(e,t){let r=e.prop(t,"tagName");return r?String(r).toLowerCase():""}function Br(e,t){let r=De(e,t)||"node",o=e.attr(t,"id");return o?`<${r}#${o}>`:`<${r}>`}function Ur(e,t,r){let o=t;for(;o;){let n=De(e,o);if(n&&r.refusedTargets.includes(n))return n;o=e.parent(o)}return null}function It(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function qr(e,t){return De(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:It(e,t)}function _r(e){if(/[\u0000-\u001f\u007f]/.test(e))return"control characters are not allowed in a custom property value";let t=[],r=null;for(let o=0;o<e.length;o++){let n=e[o];if(r){n===r&&(r=null);continue}if(n==='"'||n==="'")r=n;else{if(n==="/"&&e[o+1]==="*")return"comments are not allowed in a custom property value";if(n==="(")t.push(")");else if(n==="[")t.push("]");else if((n===")"||n==="]")&&t.pop()!==n)return`"${n}" does not close anything in this custom property value`}}return r?"a custom property value must close its quotes":t.length?"a custom property value must close its brackets":null}function zr(e,t=je){let r=t.customPropertyValues,o=String(e);if(o.length>r.maxLength)return`custom property values are limited to ${r.maxLength} characters`;let n=r.refusedCharacters.find(a=>o.includes(a));if(n)return`${JSON.stringify(n)} is not allowed in a custom property value`;let l=_r(o);if(l)return l;let s=o.toLowerCase(),i=r.refusedFunctions.find(a=>new RegExp(`(^|[^a-z0-9_-])${a.replace(/[-]/g,"\\-")}\\s*\\(`).test(s));return i?`"${i}()" is not allowed in a custom property value`:null}function ft(e,t=je){let r=[],o=(i,a)=>(r.push({target:Br(e,i),reason:a}),!1),n=i=>{let a=Ur(e,i,t);return a?o(i,`inside <${a}>, which is not content`):!0},l=i=>n(i)?It(e,i)?o(i,"a text write here would delete the data rules tag"):!0:!1,s=(i,a,u)=>{if(!n(i))return!1;let c=Wr(a,u,t);return c?o(i,c):!0};return{...e,text(i,a){if(a===void 0)return e.text(i);l(i)&&e.text(i,a)},attr(i,a,u){if(u===void 0)return e.attr(i,a);s(i,a,u)&&e.attr(i,a,u)},removeAttr(i,a){s(i,a,null)&&e.removeAttr(i,a)},styleVar(i,a,u){if(($e(e.attr(i,"style"),a)??"")!==u&&n(i)){if(!Ce(a))return o(i,`"${a}" is not a custom property`);if(u!==""){let c=zr(u,t);if(c)return o(i,c)}kt(e,i,a,u)}},prop(i,a,u){if(u===void 0)return e.prop(i,a);if(t.refusedRuleForms.includes(a))return o(i,`"@${a}" writes HTML, only text is allowed`);if(Dr.has(a)){l(i)&&e.prop(i,a,u);return}s(i,a==="className"?"class":a,u)&&e.prop(i,a,u)},remove(i){if(qr(e,i)){o(i,"removing this would delete the data rules tag");return}e.remove(i)},replaceWith(i,a){return a===e.prop(i,"outerHTML")||o(i,'"@outerHTML" writes HTML, only text is allowed'),i},refusals:r,assertClean(){if(r.length)throw new Et(r.slice())}}}function X(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function dt(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t?`${t}.${r}`:r,"")}function Vr(e,t,r,o,n={}){let l=[],s=[];function i(u,c,d){if(Array.isArray(u)){let[,p]=u;if(!Array.isArray(c)||!X(p))return;c.forEach((A,f)=>i(p,A,[...d,f]));return}if(!(!X(u)||!X(c)))for(let p of Object.keys(c))Object.prototype.hasOwnProperty.call(u,p)?i(u[p],c[p],[...d,p]):l.push(dt([...d,p]))}function a(u,c,d,p){if(d!==void 0){if(typeof c=="string"){if(c.endsWith("[]")||c==="."||c.startsWith("@"))return;let A=_(c),f=A===-1?c:c.slice(0,A);if(!f)return;e.find(u,f,n).length===0&&s.push({path:dt(p),selector:f});return}if(!Array.isArray(c)&&X(c)&&X(d))for(let[A,f]of Object.entries(c))a(u,f,d[A],[...p,A])}}return i(r,o,[]),a(t,r,o,[]),{unknownKeys:l,unmatched:s}}function pt(e,t,r){if(r&&typeof r=="object")return{rules:r,tagNode:null};if(typeof r=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return Ie(e,o,r)}return null}var Fr=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Kr(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let r=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&r!=="checkbox"&&r!=="radio"&&r!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(r==="checkbox"||r==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function ht(e,t,r,o){if(o)return!!e.closest?.(t);let n=e;for(;n?.nodeType===1;){if(n.matches(t))return!0;if(n===r)break;n=n.parentElement}return!1}function mt(e,t,r,o,n,l){return(l?jr(e,t):ht(e,r,n,!1))||!!(o&&(l&&e!==n?e.matches(o):ht(e,o,n,l)))}function Jr(e,t){let r=Me[t];return r.tokens.some(o=>$t(e,o))||r.bundles.some(o=>fe(e,o))}var Zr=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function Mt(e,t,r,o){if(e.nodeType===1&&o(e)){r.dropped.push(t);return}r.cloneToLive.set(t,e),r.liveToClone.set(e,t);let n=e,l=t;if(e.nodeType===1){if(Zr.has(e.tagName)&&r.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);n=e.content,l=t.content,r.cloneToLive.set(l,n),r.liveToClone.set(n,l)}}else if(e.nodeType!==11)return;let s=l.firstChild;for(let i=n.firstChild;i&&s;i=i.nextSibling)Mt(i,s,r,o),s=s.nextSibling}function ie(e,{capability:t="data",exclude:r=null,inherit:o=!0,provenance:n=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let l=e.nodeType===9?e:e.ownerDocument;if(!l?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=l.implementation.createHTMLDocument(""),i=n||new WeakMap,a=new WeakMap,u=e.nodeType===9?e.documentElement:e;r&&s.documentElement.matches(r);let c=ke(t),d=o?f=>Jr(f,t)||!!(r&&f.matches(r)):f=>mt(f,t,c,r,u,!1),p=null;if(u.nodeType!==1||!mt(u,t,c,r,u,o)){p=s.importNode(u,!0);let f={cloneToLive:i,liveToClone:a,dropped:[],controls:[]};Mt(u,p,f,d);for(let m of f.dropped)m.remove();for(let m=0;m<f.controls.length;m+=2)Kr(f.controls[m],f.controls[m+1])}e.nodeType===9&&p&&(s.replaceChild(p,s.documentElement),a.set(e,s),i.set(s,e));let A=f=>{if(Fr.test(f))throw new Error(`Filtered content queries do not support stateful selector: ${f}`)};return{root:p,document:s,capability:t,selector:ke(t),cloneToLive:i,liveToClone:a,original(f){return i.get(f)||null},cloneOf(f){return a.get(f)||null},query(f,m=p){return A(f),Array.from(m.querySelectorAll(f),g=>i.get(g)||g)},text(f=p){return(f===p?p:a.get(f))?.textContent||""},html(f=p){return(f===p?p:a.get(f))?.innerHTML??""},clone(f=p){let m=f===p?p:a.get(f);return m?s.importNode(m,!0):null}}}function jt(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Xr(e){return e?(e.nodeType===9||e.nodeType,e):null}function yt(e,t,r){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=r===null?"":r:t==="checked"&&e.tagName==="INPUT"?e.checked=r!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=r!==null))}function Dt(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function Pt(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let r of t)if(r.tagName==="TEXTAREA")r.value=r.defaultValue;else if(r.tagName==="INPUT"){let o=r.type;o!=="file"&&o!=="checkbox"&&o!=="radio"&&(r.value=r.defaultValue),r.checked=r.defaultChecked}else r.tagName==="OPTION"&&(r.selected=r.defaultSelected)}var N={semanticExclude:!0,find(e,t,r={}){let o=Xr(e);if(!o||!o.querySelectorAll)return[];let n=Array.from(o.querySelectorAll(t));r.includeRulesTag||(n=n.filter(i=>!jt(i)));let l=[];r.skip&&l.push(r.skip);let s=r.templateAttr===null?null:r.templateAttr||"cms-template";if(s&&l.push("["+s+"]"),l.length){let i=l.join(", ");n=n.filter(a=>!a.closest||!a.closest(i))}return n},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,Dt(e,t)},attr(e,t,r){if(r===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,r),yt(e,t,r)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),yt(e,t,null)},prop(e,t,r){if(r===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=r},clone(e){let t=e.cloneNode(!0);return Pt(t),t},insertAt(e,t,r){let o=e.children[r]||null;e.insertBefore(t,o)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let r=e.ownerDocument.createElement("template");r.innerHTML=t;let o=r.content.firstElementChild;if(!o)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(o,e),o},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(r=>{r.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function H(e,t={}){if(t.exclude===null)return N;let r=[ke("data"),t.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,n=e.nodeType===9?e.documentElement:e;if(!t._write&&!n?.matches?.(r)&&!n?.querySelector?.(r)&&!o?.querySelector?.(r))return N;let l=e.nodeType===9||!e.isConnected?e:e.ownerDocument,s=e.nodeType===9?e:e.ownerDocument,i=null,a=()=>i||(i=ie(l,{capability:"data",exclude:t.exclude||null})),u=f=>{let m=a();return f===e?m.cloneOf(e):m.cloneOf(f)||f},c=f=>i?.original(f)||f,d=(f,m)=>{a().liveToClone.set(f,m),a().cloneToLive.set(m,f);let g=f.childNodes||[],h=m.childNodes||[];for(let y=0;y<Math.min(g.length,h.length);y++)d(g[y],h[y])},p=(f,m,g,h)=>{let y=Array.from(f.childNodes).filter(x=>i.cloneOf(x)),w=y[0];for(;w&&y.includes(w);)w=w.nextSibling;for(let x of y)x.remove();if(g==="innerHTML"){let x=s.createElement("template");x.innerHTML=h;for(let S of Array.from(x.content.childNodes))f.insertBefore(S,w||null)}else f.insertBefore(s.createTextNode(h),w||null),Dt(f,h);let T=ie(f,{capability:"data",exclude:t.exclude||null});m.replaceChildren(...Array.from(T.root?.childNodes||[]));let O=x=>{let S=T.original(x);S&&(i.liveToClone.set(S,x),i.cloneToLive.set(x,S));for(let F of Array.from(x.childNodes||[]))O(F)};for(let x of Array.from(m.childNodes))O(x)},A={...N,find(f,m,g={}){let h=u(f);if(!h?.querySelectorAll)return[];let y=a().query(m,h);g.includeRulesTag||(y=y.filter(O=>!jt(O)));let w=[];g.skip&&w.push(g.skip);let T=g.templateAttr===null?null:g.templateAttr||"cms-template";if(T&&w.push(`[${T}]`),w.length){let O=w.join(", ");y=y.filter(x=>!x.closest?.(O))}return y},parent(f){let m=u(f)?.parentElement;return m?c(m):null},children(f){return Array.from(u(f)?.children||[],c)},text(f,m){if(m===void 0){let y=c(f);return!y?.matches?.(r)&&!y?.querySelector?.(r)?N.text(y):(u(f)?.textContent||"").trim()}let g=c(f);if(!g?.matches?.(r)&&!g?.querySelector?.(r)&&!i){N.text(g,m);return}let h=a().cloneOf(g);h?p(g,h,"textContent",m):N.text(g,m)},attr(f,m,g){let h=c(f);if(g===void 0)return N.attr(h,m);N.attr(h,m,g);let y=i?.cloneOf(h);y&&(N.attr(y,m,g),ie(h,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),i.liveToClone.delete(h),i.cloneToLive.delete(y)))},removeAttr(f,m){let g=c(f);N.removeAttr(g,m);let h=i?.cloneOf(g);h&&N.removeAttr(h,m)},prop(f,m,g){let h=c(f);if(g===void 0)return m==="innerHTML"||m==="outerHTML"||m==="textContent"||m==="innerText"?N.prop(u(h),m):N.prop(h,m);let y=m==="innerHTML"||m==="textContent"||m==="innerText",w=y?a().cloneOf(h):i?.cloneOf(h);w&&y?p(h,w,m,g):(N.prop(h,m,g),w&&N.prop(w,m,g))},clone(f){let m=u(f);if(m===f)return N.clone(f);let g=s.importNode(m,!0);return Pt(g),g},insertAt(f,m,g){let h=c(f),y=A.children(h)[g]||(()=>{for(let O=h.children.length-1;O>=0;O--){let x=h.children[O];if(a().cloneOf(x))return x.nextElementSibling}return h.firstElementChild})(),w=c(m);h.insertBefore(w,y||null);let T=a().cloneOf(h);if(T){let O=a().cloneOf(w);O||(O=s.importNode(w,!0),d(w,O));let x=Array.from(T.children);T.insertBefore(O,x[g]||null)}},insertBefore(f,m){let g=c(f),h=c(m);g.parentNode.insertBefore(h,g);let y=a().cloneOf(g.parentNode);if(y){let w=a().cloneOf(h);w||(w=s.importNode(h,!0),d(h,w));let T=a().cloneOf(g);T?T.before(w):y.appendChild(w)}},insertAfter(f,m){let g=c(f),h=c(m);g.parentNode.insertBefore(h,g.nextSibling);let y=a().cloneOf(g.parentNode);if(y){let w=a().cloneOf(h);w||(w=s.importNode(h,!0),d(h,w));let T=a().cloneOf(g);T?T.after(w):y.appendChild(w)}},identity(f){return c(f)||null},remove(f){let m=c(f),g=a().cloneOf(m);N.remove(m),g&&N.remove(g)},replaceWith(f,m){let g=c(f),h=a().cloneOf(g),y=N.replaceWith(g,m);if(h){let w=ie(y,{capability:"data",exclude:t.exclude||null});if(!w.root)h.remove();else{h.replaceWith(w.root);let T=O=>{let x=w.original(O);x&&(i.liveToClone.set(x,O),i.cloneToLive.set(O,x));for(let S of Array.from(O.childNodes||[]))T(S)};T(w.root)}}return y}};return A}var ae=N,pe={extract:(e,t,r={})=>se(H(e,r),e,t,r),apply:(e,t,r,o={})=>ue(H(e,{...o,_write:!0}),e,t,r,o),findRulesIn:(e,t)=>Ie(ae,e,t),findRules:(e,t)=>pt(ae,e,t),bind:(e,t,r={})=>{let o=pt(ae,e,t);if(!o){let n=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${n}`)}return{...o,get:()=>se(H(e,r),e,o.rules,r),set:n=>ue(H(e,{...r,_write:!0}),e,o.rules,n,r)}},parseStrict:Rr,parseRelaxed:Ct,ruleAttrIndex:_,splitRule:ar,errors:D,DOM_PROPERTIES:gt},Se=e=>!!e&&typeof e.nodeType=="number";function Ht(e){let t=e&&e.ownerDocument?e.ownerDocument:e,r=Ie(ae,t,"api");if(!r)throw new D.NoRulesTag("api");return r.rules}function Yr(e){if(e.nodeType===9)return e;let t=e.ownerDocument?.documentElement;if(t?.contains(e))return t;let r=e;for(;r.parentNode;)r=r.parentNode;return r}function Gr(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let t=e.ownerDocument.createDocumentFragment();for(let r of e.childNodes)t.appendChild(r.cloneNode(!0));return t}function Qr(e,t){let r=[];for(;t!==e;){let o=t.parentNode;r.push(Array.prototype.indexOf.call(o.childNodes,t)),t=o}return r.reverse()}function en(e,t){return t.reduce((r,o)=>r.childNodes[o],e)}function q(e,t){let r=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&r.unshift(e),r}function tn(e,t){let r=q(e,"option"),o=q(t,"option");r.forEach((a,u)=>o[u].selected=a.selected);let n=q(e,"input"),l=q(t,"input");n.forEach((a,u)=>{let c=a.type.toLowerCase();c!=="file"&&(l[u].value=a.value),(c==="checkbox"||c==="radio")&&(l[u].checked=a.checked)});let s=q(e,"textarea"),i=q(t,"textarea");s.forEach((a,u)=>i[u].value=a.value)}function Ne(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let r=e.startsWith("@")?0:_(e);if(r===-1)return;let o=e.slice(r+1);if(wt.has(o))throw new D.RuleTargetReadOnly(o);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(r=>Ne(e[1],r));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[r,o]of Object.entries(e))Ne(o,t[r])}}function rn(e,t,r){let o={templateAttr:"cms-template"},n=Yr(e),l=Qr(n,e),s=Gr(n);tn(n,s);let i=en(s,l),a=H(s,{...o,_write:!0}),u=Vr(a,i,t,r,o);if(u.unknownKeys.length||u.unmatched.length)throw new D.WriteRejected(u.unknownKeys,u.unmatched);let c=ft(a);ue(c,i,t,r,o),c.assertClean(),Ne(t,r);let d=ft(H(n,{...o,_write:!0}));ue(d,e,t,r,o),d.assertClean()}function nn(e){if(!(e instanceof Error))return e;let t=e.name||"Error";try{e.code=t}catch{Object.defineProperty(e,"code",{value:t,configurable:!0,enumerable:!0})}return e instanceof D.WriteRefused?e.details=e.refusals:e instanceof D.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof D.ShapeMismatch?e.details=e.mismatches:Array.isArray(e.path)?e.details={path:e.path}:typeof e.target=="string"?e.details={target:e.target}:e.token!==void 0?e.details={token:e.token}:e.version!==void 0?e.details={version:e.version}:e.details={},e}function G(e,t){let r=Se(e)?e:document,o=Se(e)?t:e;return o===void 0?se(H(r),r,Ht(r)):pe.bind(r,o).get()}function Q(e,t,r){try{if(!Se(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let o=r===void 0?Ht(e):pe.bind(e,r).rules;rn(e,o,t)}catch(o){throw nn(o)}return e}var qt="clay:visitor-drafts:",Wt=1;function W(e=window.location.pathname){let r=String(e||"/").replace(/\/{2,}/g,"/").match(/^(.*?\/[^/]+\.(?:html|htmlclay))(?:\/|$)/i),o=r?r[1]:"/";return o.toLowerCase()==="/index.html"?"/":o}var He=e=>qt+e,_t=(e,t=W())=>`${qt}${e}@${t}`;function ge(){try{return window.localStorage}catch{return null}}var j=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);function on(e){let t=[];for(let r of e.matchAll(/([^.[\]]+)|\[(\d+)\]/g))t.push(r[2]!==void 0?Number(r[2]):r[1]);return t}function ln(e,t){let r=on(t),o=e;for(let n=0;n<r.length-1;n++)if(o=o?.[r[n]],o==null||typeof o!="object")return;o&&typeof o=="object"&&delete o[r[r.length-1]]}function P(e,t){return Array.isArray(e)?Array.isArray(t)&&t.length===e.length&&e.every((r,o)=>P(r,t[o])):j(e)?j(t)&&Object.keys(e).every(r=>P(e[r],t[r])):e===t}function z(e,t){return P(e,t)&&P(t,e)}var V=e=>Array.isArray(e)&&e.every(t=>j(t)&&(typeof t.id=="string"||typeof t.id=="number"))&&new Set(e.map(t=>t.id)).size===e.length;function he(e,t,r=!1){if(j(e)&&j(t)){let o={...e};for(let n of Object.keys(t))n in e?o[n]=he(e[n],t[n]):r||(o[n]=t[n]);return o}if(V(e)&&V(t)){let o=new Map(t.map(n=>[n.id,n]));return e.map(n=>o.has(n.id)?he(n,o.get(n.id)):n)}return e}var Bt=(e,t)=>e.length===t.length&&e.every((r,o)=>r===t[o]);function an(e,t,r){let o=d=>new Map(d.map(p=>[p.id,p])),n=o(e),l=o(t),s=o(r),i=d=>d.filter(p=>n.has(p.id)&&l.has(p.id)&&s.has(p.id)).map(p=>p.id),a=i(e);if(!Bt(a,i(t))||!Bt(a,i(r)))return null;for(let[d,p]of n)if(l.has(d)&&!s.has(d)&&!z(l.get(d),p)||!l.has(d)&&s.has(d)&&!z(s.get(d),p))return null;let u=!1,c=[];for(let d of t){if(n.has(d.id)&&!s.has(d.id))continue;if(!s.has(d.id)){c.push(d);continue}let p=me(n.get(d.id),d,s.get(d.id),!0);u||=p.conflict,c.push(p.value)}return r.forEach((d,p)=>{if(n.has(d.id)||l.has(d.id))return;let A=0;for(let f=p-1;f>=0;f--){let m=c.findIndex(g=>g.id===r[f].id);if(m!==-1){A=m+1;break}}c.splice(A,0,d)}),{value:c,conflict:u}}function me(e,t,r,o){if(z(t,r)||z(r,e))return{value:t,conflict:!1};if(z(t,e))return{value:r,conflict:!1};if(j(t)&&j(r)){let n={},l=!1;for(let s of new Set([...Object.keys(t),...Object.keys(r)])){let i=me(j(e)?e[s]:void 0,t[s],r[s],o);l||=i.conflict,i.value!==void 0&&(n[s]=i.value)}return{value:n,conflict:l}}if(o&&V(e)&&V(t)&&V(r)){let n=an(e,t,r);if(n)return n}return{value:t,conflict:!0}}function ye(e,t=new Map){if(Array.isArray(e)){if(V(e))for(let r of e)t.set(r.id,(t.get(r.id)||0)+1);for(let r of e)ye(r,t)}else if(j(e))for(let r of Object.values(e))ye(r,t);return t}function sn(e,t,r){let o=me(e,t,r,!0),n=ye(t);for(let[l,s]of ye(o.value))if(s>1&&s>(n.get(l)||0))return me(e,t,r,!1);return o}function Pe(e,t){K(!0),e.dispatchEvent(new CustomEvent("clay:drafts-store-failed",{detail:{error:t}}));let r=new Error("Couldn't save in this browser. Storage is full or turned off.");return r.code="draft-storage",r}var Ut=e=>{try{return String(JSON.parse(e)?.savedAt??"")}catch{return""}};function zt(e,{path:t=W(),storage:r=ge()}={}){let o=He(e),n=_t(e,t),l=n+":legacy";try{let s=r?.getItem(n),i=r?.getItem(o);if(i==null){let d=r?.getItem(o+":ui");return d!=null&&r.getItem(n+":ui")==null&&r.getItem(n+":ui-legacy")==null&&(r.setItem(n+":ui",d),r.setItem(n+":ui-legacy","1")),"none"}let a=Ut(i),u=r.getItem(l);if(u===a)return"none";let c=r.getItem(n);if(c!==s)return"none";if(c==null||u!=null&&Ut(c)===u?r.setItem(n,i):c!==i&&(r.setItem(n+":conflict",i),console.warn("visitor-drafts: an older tab changed this draft after it moved; its copy was kept under",n+":conflict")),u==null){let d=r.getItem(o+":ui");d!=null&&r.getItem(n+":ui")==null&&r.setItem(n+":ui",d)}return r.setItem(l,a),"copied"}catch{return"failed"}}function Vt({doc:e=document,storage:t=ge(),now:r=()=>new Date,path:o=W(),fallback:n=null}={}){let l=le(e),s=_t(l,o),i=pe.findRulesIn(e,"api").rules,a=null,u=null,c=null,d=!1;function p(){try{if(!t)return null;let b=t.getItem(s);return b==null&&n?t.getItem(n):b}catch{return null}}function A(b){try{let v=JSON.parse(b);if(j(v)&&v.v===Wt&&j(v.data))return v}catch{}return null}function f(){let b=p();return b==null?null:{raw:b,record:A(b)}}function m(){return G(e,i)}function g(){let b=window.clay?.getHTML;return typeof b!="function"?m():G(new DOMParser().parseFromString(b.call(window.clay),"text/html"),i)}function h(){try{if(typeof t.keys=="function")return t.keys();let b=[];for(let v=0;v<t.length;v++)b.push(t.key(v));return b}catch{return[]}}function y(){try{return JSON.stringify(g())}catch{return null}}function w(b,{keepSlot:v=!1}={}){let k=h().find(M=>M.startsWith(s+":unreadable:")&&t.getItem(M)===b);if(k){if(c=null,!v)try{t.removeItem(s)}catch{}return k}let L=s+":unreadable:"+r().toISOString();try{t.setItem(L,b)}catch{return c=b,console.warn("visitor-drafts: this browser's saved copy no longer fits the page, and there is no room to keep it aside; nothing will be saved over it"),null}if(c=null,!v)try{t.removeItem(s)}catch{}return console.warn(v?"visitor-drafts: part of this browser's saved copy no longer fits the page; the original was kept under":"visitor-drafts: this browser's saved copy no longer fits the page; it was kept under",L),L}function T(b){let v=he(JSON.parse(JSON.stringify(b)),m(),!0),k=[];for(let L=0;L<4;L++){let M=e.cloneNode(!0);try{Q(M,v,i)}catch(C){let be=C?.details?.unknownKeys??C?.unknownKeys;if(Array.isArray(be)&&be.length){for(let U of be)ln(v,U);continue}let Ae=Object.keys(v).filter(U=>{try{return Q(e.cloneNode(!0),{[U]:v[U]},i),!1}catch{return!0}});if(!Ae.length)return null;for(let U of Ae)delete v[U];k.push(...Ae);continue}let oe=G(M,i),B=Object.keys(v).filter(C=>!P(v[C],oe[C]));if(!B.length)return{data:v,dropped:k};for(let C of B)delete v[C];k.push(...B)}return null}function O(b){let v=w(b);return v||(a=b),u=m(),v?{restored:!1,hadDraft:!0,parked:!0}:{restored:!1,hadDraft:!0,parked:!1,blocked:!0}}function x(){let b=f();if(!b)return u=m(),{restored:!1,hadDraft:!1};if(!b.record)return O(b.raw);let v=T(b.record.data);if(!v||!Object.keys(v.data).length)return O(b.raw);if(Q(e,v.data,i),a=b.raw,u=m(),v.dropped.length){let k=w(b.raw,{keepSlot:!0});return{restored:!0,hadDraft:!0,data:v.data,partial:!0,parked:!!k,blocked:!k}}return{restored:!0,hadDraft:!0,data:v.data}}function S(){if(d)return!1;try{return!P(g(),u)}catch{return!0}}function F(b){let v=s+":conflict";try{t.setItem(v,b)}catch(k){throw Pe(e,k)}console.warn("visitor-drafts: another tab changed the same thing; its copy was kept under",v)}function we(b){let v=p(),k=v==null?null:A(v);if(!k)return{data:b,stored:null};let L=b;if(v!==a){let M=sn(u,b,k.data);M.conflict&&F(v),L=M.value}return L=he(L,k.data),{data:L,stored:z(L,k.data)?v:null}}function re(b){let v=T(b);if(!v||!Object.keys(v.data).length)return null;Q(e,v.data,i);try{window.Sap?.refresh?.()}catch{}return e.dispatchEvent(new CustomEvent("clay:drafts-restored",{detail:{restored:!0,hadDraft:!0,parked:!1,external:!0}})),v.data}function ne(b){if(d)return null;if(c!=null&&w(c,{keepSlot:!0})===null)throw Pe(e,new Error("an earlier saved copy could not be kept aside"));let v=G(new DOMParser().parseFromString(b,"text/html"),i),k=p();if(P(v,u)&&(k===a||k==null))return K(!1),e.dispatchEvent(new CustomEvent("clay:drafts-saved",{detail:{data:v,unchanged:!0}})),v;let{data:L,stored:M}=we(v),oe=M??JSON.stringify({v:Wt,savedAt:r().toISOString(),data:L});if(!M)try{if(!t)throw new Error("no storage");t.setItem(s,oe)}catch(C){throw Pe(e,C)}let B=Object.keys(v).filter(C=>!P(v[C],L[C]));return B.length&&re(Object.fromEntries(B.map(C=>[C,L[C]]))),a=oe,u=L,K(!1),e.dispatchEvent(new CustomEvent("clay:drafts-saved",{detail:{data:L}})),L}function E(){try{return ne(window.clay.getHTML()),!0}catch{return!1}}function R(){return d||!S()?!0:E()}function I(){if(d)return!1;let b=p();if(b==null||b===a||S())return!1;let v=A(b),k=v&&re(v.data);return k?(a=b,u={...u,...k},!0):!1}function ve(){d=!0,c=null,K(!1);try{t.removeItem(s)}catch{}}return{slot:l,key:s,rules:i,read:f,restore:x,write:ne,writeLive:E,flush:R,changed:S,adoptExternal:I,park:w,clear:ve,snapshot:y}}function Ft(e,t){let r=`${e}:ui`,o=()=>({v:1,prompt:{},intro:{done:null},src:null}),n=o();try{let l=JSON.parse(t?.getItem(r)||"null");l&&typeof l=="object"&&l.v===1&&(n={...o(),...l})}catch{}return{get:()=>n,save(){try{t?.setItem(r,JSON.stringify(n))}catch{}},reset(){n=o();try{t?.removeItem(r)}catch{}}}}var un=/^[a-z0-9][a-z0-9-]{0,39}$/;function Kt(e,t=window.location.search){let r=e.get(),o=null;try{o=new URLSearchParams(t).get("src")}catch{}return!r.src&&o&&un.test(o)&&(r.src=o,e.save()),r.src}function Jt(e,t=window.location){let r=W(t.pathname);return`/_/download${r==="/"?"":r}?as=htmlclay${e?`&src=${encodeURIComponent(e)}`:""}`}var cn=`<aside class="hcp" id="hcp" hidden aria-label="Download this app" data-hcp-state="tab" data-hcp-reason="open" sap-ignore clay="editor-ui">
2
2
  <section class="hcp-card" id="hcp-card" role="dialog" aria-modal="false" aria-labelledby="hcp-title">
3
3
  <button type="button" class="hcp-x" data-hcp="minimize" aria-label="Minimize"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" aria-hidden="true"><path d="M5 12h14"/></svg></button>
4
4
  <div class="hcp-kicker">Free download</div>
@@ -17,4 +17,4 @@ import{b as Je,c as Ze}from"../c-Y6F2FORL.js";import{b as Ke}from"../c-L7JL5TL3.
17
17
  <button type="button" class="hcp-btn hcp-tab" data-hcp="open" aria-controls="hcp-card" aria-expanded="false" aria-label="This app is free to keep"><span><svg width="16" height="16" viewBox="0 0 256 256" fill="currentColor" aria-hidden="true"><path d="M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0-11.32-11.32L136,124.69V32a8,8,0,0,0-16,0v92.69L93.66,98.34a8,8,0,0,0-11.32,11.32Z"/></svg><span class="hcp-tab__label">This app is free to keep</span><span class="hcp-tab__mini">Keep</span></span></button>
18
18
  <button type="button" class="hcp-x" data-hcp="minimize" aria-label="Minimize download notice"><svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" aria-hidden="true"><path d="M1.4 0 6 4.6 10.6 0 12 1.4 7.4 6 12 10.6 10.6 12 6 7.4 1.4 12 0 10.6 4.6 6 0 1.4z"/></svg></button>
19
19
  </div>
20
- </aside>`;async function Zt({memory:e,appName:t,link:r}){let{PROMPT_CSS:o}=await import("../c-SGIA4IEQ.js"),l=document.querySelector('clay-editor-ui[data-clay-ui="download-prompt"]')?.shadowRoot.getElementById("hcp");if(!l){let E=document.createElement("template");E.innerHTML=cn,l=E.content.firstElementChild,Ke({name:"download-prompt",content:l,css:[o],attributes:{"sap-ignore":""}})}let s=e.get();(!s.prompt||typeof s.prompt!="object")&&(s.prompt={});let i=s.prompt,a=3,u=2500,c=/^(INPUT|TEXTAREA|SELECT)$/,d="#hcp, .clay-intro, .clay-owner",p=l.querySelector("[data-hcp-link]");p.href=r,t&&(l.querySelector("[data-hcp-name]").textContent=t);let A=l.querySelector("[data-hcp=open]");function f(E,R){l.hidden=!1,l.setAttribute("data-hcp-state",E),R&&l.setAttribute("data-hcp-reason",R),A.setAttribute("aria-expanded",E==="card"?"true":"false"),(E==="card"||E==="mini")&&(i.shown=!0,e.save(),l.setAttribute("data-hcp-arrived","")),S()}function m(E){return E&&!l.contains(E)&&!E.closest(d)&&(c.test(E.tagName)||E.isContentEditable)}let g=null;function h(E){clearTimeout(g),g=setTimeout(()=>{if(i.shown||i.dismissed||l.getAttribute("data-hcp-state")!=="tab")return;let R=document.activeElement;if(m(R)){let $=R.getBoundingClientRect(),D=Math.min(360,innerWidth-32);if(innerWidth<700||$.right>innerWidth-D-32&&$.bottom>innerHeight-380)return}f("card",E)},u)}let y=[];function v(E){l.contains(E.target)||!m(E.target)||(y.indexOf(E.target)<0&&y.push(E.target),i.uses=Math.max(i.uses||0,y.length),i.shown||e.save(),y.length>=a&&h("use"))}function T(E){m(E.target)&&(l.getAttribute("data-hcp-state")==="card"&&f(i.shown?"mini":"tab"),innerWidth<700&&l.setAttribute("data-hcp-typing",""))}function O(){setTimeout(()=>{m(document.activeElement)||l.removeAttribute("data-hcp-typing")},50)}let x=0;function S(){x||(x=requestAnimationFrame(()=>{x=0;let R=Ze(innerWidth-24,$=>l.contains($)||$.closest("[data-hcp-preview], .clay-owner"))+"px";l.style.getPropertyValue("--hcp-lift")!==R&&l.style.setProperty("--hcp-lift",R),Je()}))}function K(){let E=window.clay&&window.clay.getHTML;if(typeof E!="function"||typeof URL>"u"||typeof URL.createObjectURL!="function")return!1;let R=location.pathname.split("/").filter(Boolean).pop()||"index.html",$=URL.createObjectURL(new Blob([E()],{type:"text/html"})),D=document.createElement("a");return D.href=$,D.download=R.replace(/\.html$/,".htmlclay"),document.body.appendChild(D),D.click(),D.remove(),setTimeout(()=>URL.revokeObjectURL?.($),1e3),!0}l.addEventListener("click",E=>{let R=E.target.closest("[data-hcp]");if(R){let $=R.getAttribute("data-hcp");$==="open"?(f("card","open"),p.focus()):$==="minimize"?(f("mini"),A.focus()):$==="dismiss"&&(l.getAttribute("data-hcp-reason")==="error"?(f("mini"),A.focus()):(i.dismissed=!0,f("mini"),A.focus()));return}E.target.closest("[data-hcp-link]")&&(l.getAttribute("data-hcp-reason")==="error"&&(E.preventDefault(),K()),i.downloaded=!0,i.shown=!0,e.save())}),l.addEventListener("animationend",E=>{(E.animationName==="hcp-arrive"||E.animationName==="hcp-arrive-fade")&&l.setAttribute("data-hcp-arrived","")}),l.addEventListener("keydown",E=>{E.key==="Escape"&&l.getAttribute("data-hcp-state")==="card"&&(f("mini"),A.focus())});function we(){f("card","error")}function ne(){l.getAttribute("data-hcp-reason")==="error"&&l.setAttribute("data-hcp-reason","use")}let oe={set:f,root:l,showError:we,clearError:ne};return document.addEventListener("input",v,!0),document.addEventListener("change",v,!0),document.addEventListener("focusin",T),document.addEventListener("focusout",O),addEventListener("scroll",S,{passive:!0}),addEventListener("resize",S),document.addEventListener("transitionend",S,!0),l.addEventListener("transitionend",S),f(i.shown||i.dismissed?"mini":"tab"),!i.shown&&(i.uses||0)>=a&&h("return"),oe}var I=null,re=null,Be=Xe,He=null,Xt=Promise.resolve();function Yt(){return import("../c-ICJYHABF.js").then(e=>e.mountOwnerChip()).catch(e=>(console.warn("visitor-drafts: the owner chip did not load",e),null))}function fn(e){return e.template?import("../c-UDHIVLYH.js").then(t=>t.mountIntro(e)).catch(t=>(console.warn("visitor-drafts: the intro did not load",t),null)):Promise.resolve(null)}var te=ie(),We=document.querySelector('script[data-rules-name~="api"]');if(Ve&&te&&We){let e=B(),t=zt(te,{path:e});I=Vt({path:e,fallback:t==="failed"?Ue(te):null}),_e(a=>I.write(a));let r=I.restore();re={restored:r.restored,hadDraft:r.hadDraft,parked:!!r.parked,...r.partial&&{partial:!0},...r.blocked&&{blocked:!0}},document.dispatchEvent(new CustomEvent("clay:drafts-restored",{detail:re}));let o=Ft(I.key,ve());He=Kt(o),Be=Jt(He);let n=document.querySelector('meta[name="application-name"]')?.content?.trim()||document.title.split(/:|\s\|\s/)[0].trim()||"This app",l=document.querySelector("template[visitor-intro]"),s=()=>{Xt=Zt({memory:o,appName:n,link:Be}).then(a=>fn({memory:o,template:l,appName:n,hadDraft:r.hadDraft}).then(()=>a)).then(a=>(document.addEventListener("clay:drafts-store-failed",()=>a.showError()),document.addEventListener("clay:drafts-saved",()=>a.clearError()),(Ee?Yt():Promise.resolve(null)).then(()=>a)))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",s,{once:!0}):s(),ze(()=>I.flush()),window.addEventListener("storage",a=>{a.key===I.key&&I.adoptExternal()});let i=()=>I.flush();document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&i()}),window.addEventListener("pagehide",i)}else if(!te||!We){let e=[];te||e.push('a visitor-drafts="<slot>" attribute on <html>'),We||e.push('a <script data-rules-name~="api"> rules tag'),console.warn(`visitor-drafts: this page keeps no draft (missing ${e.join(" and ")})`)}else Ee&&Fe&&!qe()&&(Xt=Yt());var Bn=I?{active:!0,slot:I.slot,key:I.key,hasDraft:()=>!!I.read(),restored:()=>re,saveNow:()=>I.writeLive(),reset(){return I.clear(),window.location.reload(),!0},onRestore(e){return re?(e(re),!0):(document.addEventListener("clay:drafts-restored",t=>e(t.detail),{once:!0}),!1)},editOriginal:Ye,backToDraft:Ge,downloadUrl:()=>Be,source:He}:Qe();export{Xt as ready,Bn as visitorDrafts};
20
+ </aside>`;async function Zt({memory:e,appName:t,link:r}){let{PROMPT_CSS:o}=await import("../c-SGIA4IEQ.js"),l=document.querySelector('clay-editor-ui[data-clay-ui="download-prompt"]')?.shadowRoot.getElementById("hcp");if(!l){let E=document.createElement("template");E.innerHTML=cn,l=E.content.firstElementChild,Ke({name:"download-prompt",content:l,css:[o],attributes:{"sap-ignore":""}})}let s=e.get();(!s.prompt||typeof s.prompt!="object")&&(s.prompt={});let i=s.prompt,a=3,u=2500,c=/^(INPUT|TEXTAREA|SELECT)$/,d="#hcp, .clay-intro, .clay-owner",p=l.querySelector("[data-hcp-link]");p.href=r,t&&(l.querySelector("[data-hcp-name]").textContent=t);let A=l.querySelector("[data-hcp=open]");function f(E,R){l.hidden=!1,l.setAttribute("data-hcp-state",E),R&&l.setAttribute("data-hcp-reason",R),A.setAttribute("aria-expanded",E==="card"?"true":"false"),(E==="card"||E==="mini")&&(i.shown=!0,e.save(),l.setAttribute("data-hcp-arrived","")),S()}function m(E){return E&&!l.contains(E)&&!E.closest(d)&&(c.test(E.tagName)||E.isContentEditable)}let g=null;function h(E){clearTimeout(g),g=setTimeout(()=>{if(i.shown||i.dismissed||l.getAttribute("data-hcp-state")!=="tab")return;let R=document.activeElement;if(m(R)){let I=R.getBoundingClientRect(),ve=Math.min(360,innerWidth-32);if(innerWidth<700||I.right>innerWidth-ve-32&&I.bottom>innerHeight-380)return}f("card",E)},u)}let y=[];function w(E){l.contains(E.target)||!m(E.target)||(y.indexOf(E.target)<0&&y.push(E.target),i.uses=Math.max(i.uses||0,y.length),i.shown||e.save(),y.length>=a&&h("use"))}function T(E){m(E.target)&&(l.getAttribute("data-hcp-state")==="card"&&f(i.shown?"mini":"tab"),innerWidth<700&&l.setAttribute("data-hcp-typing",""))}function O(){setTimeout(()=>{m(document.activeElement)||l.removeAttribute("data-hcp-typing")},50)}let x=0;function S(){x||(x=requestAnimationFrame(()=>{x=0;let R=Ze(innerWidth-24,I=>l.contains(I)||I.closest("[data-hcp-preview], .clay-owner"))+"px";l.style.getPropertyValue("--hcp-lift")!==R&&l.style.setProperty("--hcp-lift",R),Je()}))}async function F(){let E=window.clay&&window.clay.getHTML;if(typeof E!="function"||typeof URL>"u"||typeof URL.createObjectURL!="function")return!1;let R=location.pathname.split("/").filter(Boolean).pop()||"index.html";try{let{downloadHtml:I}=await import("../c-3TWCKFOP.js");return await I({html:E(),name:R.replace(/\.html$/,".htmlclay")})}catch{return!1}}l.addEventListener("click",async E=>{let R=E.target.closest("[data-hcp]");if(R){let I=R.getAttribute("data-hcp");I==="open"?(f("card","open"),p.focus()):I==="minimize"?(f("mini"),A.focus()):I==="dismiss"&&(l.getAttribute("data-hcp-reason")==="error"?(f("mini"),A.focus()):(i.dismissed=!0,f("mini"),A.focus()));return}if(E.target.closest("[data-hcp-link]")){if(l.getAttribute("data-hcp-reason")==="error"&&(E.preventDefault(),!await F())){l.querySelector(".hcp-body [data-hcp-for='error']").textContent="The download could not be made. Keep this page open and try Download free again.";return}i.downloaded=!0,i.shown=!0,e.save()}}),l.addEventListener("animationend",E=>{(E.animationName==="hcp-arrive"||E.animationName==="hcp-arrive-fade")&&l.setAttribute("data-hcp-arrived","")}),l.addEventListener("keydown",E=>{E.key==="Escape"&&l.getAttribute("data-hcp-state")==="card"&&(f("mini"),A.focus())});function we(){f("card","error")}function re(){l.getAttribute("data-hcp-reason")==="error"&&l.setAttribute("data-hcp-reason","use")}let ne={set:f,root:l,showError:we,clearError:re};return document.addEventListener("input",w,!0),document.addEventListener("change",w,!0),document.addEventListener("focusin",T),document.addEventListener("focusout",O),addEventListener("scroll",S,{passive:!0}),addEventListener("resize",S),document.addEventListener("transitionend",S,!0),l.addEventListener("transitionend",S),f(i.shown||i.dismissed?"mini":"tab"),!i.shown&&(i.uses||0)>=a&&h("return"),ne}var $=null,te=null,Be=Xe,Ue=null,Xt=Promise.resolve();function Yt(){return import("../c-LDUNOR57.js").then(e=>e.mountOwnerChip()).catch(e=>(console.warn("visitor-drafts: the owner chip did not load",e),null))}function fn(e){return e.template?import("../c-JH5FF4NL.js").then(t=>t.mountIntro(e)).catch(t=>(console.warn("visitor-drafts: the intro did not load",t),null)):Promise.resolve(null)}var ee=le(),We=document.querySelector('script[data-rules-name~="api"]');if(Ve&&ee&&We){let e=W(),t=zt(ee,{path:e});$=Vt({path:e,fallback:t==="failed"?He(ee):null}),_e(a=>$.write(a));let r=$.restore();te={restored:r.restored,hadDraft:r.hadDraft,parked:!!r.parked,...r.partial&&{partial:!0},...r.blocked&&{blocked:!0}},document.dispatchEvent(new CustomEvent("clay:drafts-restored",{detail:te}));let o=Ft($.key,ge());Ue=Kt(o),Be=Jt(Ue);let n=document.querySelector('meta[name="application-name"]')?.content?.trim()||document.title.split(/:|\s\|\s/)[0].trim()||"This app",l=document.querySelector("template[visitor-intro]"),s=()=>{Xt=Zt({memory:o,appName:n,link:Be}).then(a=>fn({memory:o,template:l,appName:n,hadDraft:r.hadDraft}).then(()=>a)).then(a=>(document.addEventListener("clay:drafts-store-failed",()=>a.showError()),document.addEventListener("clay:drafts-saved",()=>a.clearError()),(Ee?Yt():Promise.resolve(null)).then(()=>a)))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",s,{once:!0}):s(),ze(()=>$.flush()),window.addEventListener("storage",a=>{a.key===$.key&&$.adoptExternal()});let i=()=>$.flush();document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&i()}),window.addEventListener("pagehide",i)}else if(!ee||!We){let e=[];ee||e.push('a visitor-drafts="<slot>" attribute on <html>'),We||e.push('a <script data-rules-name~="api"> rules tag'),console.warn(`visitor-drafts: this page keeps no draft (missing ${e.join(" and ")})`)}else Ee&&Fe&&!qe()&&(Xt=Yt());var Bn=$?{active:!0,slot:$.slot,key:$.key,hasDraft:()=>!!$.read(),restored:()=>te,saveNow:()=>$.writeLive(),reset(){return $.clear(),window.location.reload(),!0},onRestore(e){return te?(e(te),!0):(document.addEventListener("clay:drafts-restored",t=>e(t.detail),{once:!0}),!1)},editOriginal:Ye,backToDraft:Ge,downloadUrl:()=>Be,source:Ue}:Qe();export{Xt as ready,Bn as visitorDrafts};
@@ -1 +1 @@
1
- import{d as p}from"../c-MTQHWQC3.js";import{f as l,h as m}from"../c-3O7OBDCM.js";import{d as a}from"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import{d as u}from"../c-N7JPUPGC.js";import"../c-HA6INT6J.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var o=u(),i=document.querySelector('script[data-rules-name~="api"]'),r=null,e=null,s=0,c=()=>m&&l&&!a()&&!!o&&!!i;function f(){if(r)return Promise.resolve(r);if(!e){let t=s;e=import("../c-ICJYHABF.js").then(({mountOwnerChip:d,ownerChip:h})=>{let n=d()||h();return t===s?(r=n,n):(n?.unmount?.(),null)}).finally(()=>{e=null})}return e}function v(){s+=1,r?.unmount?.(),r=null,document.getElementById("clay-owner-vars")?.remove()}if(!o||!i){let t=[];o||t.push('a visitor-drafts="<slot>" attribute on <html>'),i||t.push('a <script data-rules-name~="api"> rules tag'),console.warn(`visitor-drafts: this page keeps no draft (missing ${t.join(" and ")})`)}var g=c()?f():Promise.resolve(null),k=g;function C(){return{id:"clay:drafts-owner",order:400,prepare(t={}){return{enable(){t.initial!==!0&&c()&&f()},quiesce(){},resume(){},dispose(){v()}}}}}var S=p();export{C as draftsOwnerParticipant,C as modeParticipant,k as ready,S as visitorDrafts};
1
+ import{d as p}from"../c-MTQHWQC3.js";import{f as l,h as m}from"../c-3O7OBDCM.js";import{d as a}from"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import{d as u}from"../c-N7JPUPGC.js";import"../c-HA6INT6J.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var o=u(),i=document.querySelector('script[data-rules-name~="api"]'),r=null,e=null,s=0,c=()=>m&&l&&!a()&&!!o&&!!i;function f(){if(r)return Promise.resolve(r);if(!e){let t=s;e=import("../c-LDUNOR57.js").then(({mountOwnerChip:d,ownerChip:h})=>{let n=d()||h();return t===s?(r=n,n):(n?.unmount?.(),null)}).finally(()=>{e=null})}return e}function v(){s+=1,r?.unmount?.(),r=null,document.getElementById("clay-owner-vars")?.remove()}if(!o||!i){let t=[];o||t.push('a visitor-drafts="<slot>" attribute on <html>'),i||t.push('a <script data-rules-name~="api"> rules tag'),console.warn(`visitor-drafts: this page keeps no draft (missing ${t.join(" and ")})`)}var g=c()?f():Promise.resolve(null),k=g;function C(){return{id:"clay:drafts-owner",order:400,prepare(t={}){return{enable(){t.initial!==!0&&c()&&f()},quiesce(){},resume(){},dispose(){v()}}}}}var S=p();export{C as draftsOwnerParticipant,C as modeParticipant,k as ready,S as visitorDrafts};
@@ -1 +1 @@
1
- import{a,b,c}from"../c-FTQKI7SP.js";import"../c-XGH4GS2T.js";import"../c-3O7OBDCM.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-N7JPUPGC.js";import"../c-HA6INT6J.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";export{c as default,a as modeParticipant,b as wire,a as wireParticipant};
1
+ import{a,b,c}from"../c-I2IFKJX2.js";import"../c-XGH4GS2T.js";import"../c-3O7OBDCM.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-N7JPUPGC.js";import"../c-HA6INT6J.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";export{c as default,a as modeParticipant,b as wire,a as wireParticipant};