@panphora/clayjs 1.18.1 → 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 (180) hide show
  1. package/README.md +1 -1
  2. package/dist/all.js +1 -1
  3. package/dist/clay-dom.js +1 -1
  4. package/dist/clay-events.js +1 -1
  5. package/dist/clay-internals.js +1 -1
  6. package/dist/clay-options.js +1 -1
  7. package/dist/clay-router.js +1 -1
  8. package/dist/clay-ui.js +1 -1
  9. package/dist/clay-utils.js +1 -1
  10. package/dist/clay.js +1 -1
  11. package/dist/clay.standalone.js +8773 -8444
  12. package/dist/m/attrs/{refetch-on-save-ZUE7PSCI.js → refetch-on-save-DPGJJMGN.js} +1 -1
  13. package/dist/m/attrs/save-freeze-MTFVVYV5.js +1 -0
  14. package/dist/m/{c-KP64LT2A.js → c-2VB555FG.js} +1 -1
  15. package/dist/m/{c-KGHVFRR3.js → c-3AXJDL2P.js} +1 -1
  16. package/dist/m/{c-372N6H3B.js → c-3GJ4XARY.js} +1 -1
  17. package/dist/m/c-3TWCKFOP.js +1 -0
  18. package/dist/m/{c-U7SHNWDH.js → c-3YH6JSIL.js} +1 -1
  19. package/dist/m/{c-AMU3BPPR.js → c-44B5ODN7.js} +2 -2
  20. package/dist/m/{c-S2U6NJU4.js → c-62HZW5DH.js} +1 -1
  21. package/dist/m/{c-ZK4GIZH2.js → c-67ILSNPR.js} +1 -1
  22. package/dist/m/c-67LGZ52V.js +20 -0
  23. package/dist/m/{c-W6DQSHXI.js → c-7SXYQCN4.js} +1 -1
  24. package/dist/m/{c-5OOVFCJM.js → c-AL4RBJF2.js} +1 -1
  25. package/dist/m/{c-L42OLXWM.js → c-ANNFZFLN.js} +1 -1
  26. package/dist/m/{c-QO4HNGCQ.js → c-B4VYNXTQ.js} +1 -1
  27. package/dist/m/{c-7PRJCA3E.js → c-BJPZCWAV.js} +1 -1
  28. package/dist/m/{c-SW4YEG2D.js → c-BTLFLLML.js} +1 -1
  29. package/dist/m/c-C4IIQZGJ.js +1 -0
  30. package/dist/m/{c-5T6NZHNM.js → c-CAWNFER6.js} +1 -1
  31. package/dist/m/c-CSNE5EIF.js +1 -0
  32. package/dist/m/{c-DVYGFTSK.js → c-DDDOKPI6.js} +2 -2
  33. package/dist/m/{c-6DB2OLRJ.js → c-DHXPDLW6.js} +1 -1
  34. package/dist/m/{c-WCXLG3MV.js → c-E4IBSAQM.js} +1 -1
  35. package/dist/m/{c-IVTRVENZ.js → c-EDSPKYMA.js} +1 -1
  36. package/dist/m/{c-UORXLSD3.js → c-EFD6QNTE.js} +1 -1
  37. package/dist/m/{c-7MG5RU63.js → c-EGTIAL6P.js} +1 -1
  38. package/dist/m/{c-SPZPGD3R.js → c-EOCKLMKX.js} +1 -1
  39. package/dist/m/{c-HMV6P4RX.js → c-EOCZ2YVL.js} +1 -1
  40. package/dist/m/{c-B5UJQT7W.js → c-EZ7B5AZT.js} +1 -1
  41. package/dist/m/{c-UPD33ZPE.js → c-FDAXZ2PM.js} +1 -1
  42. package/dist/m/{c-RND3G2S2.js → c-FNVQAACK.js} +1 -1
  43. package/dist/m/c-FSWRGBVQ.js +1 -0
  44. package/dist/m/c-FTWGYI5E.js +1 -0
  45. package/dist/m/{c-CCQ25GFY.js → c-GKEATME6.js} +1 -1
  46. package/dist/m/{c-YBKHUAK7.js → c-GPGYKER7.js} +1 -1
  47. package/dist/m/{c-FWKHM4E7.js → c-GSRLXYWL.js} +1 -1
  48. package/dist/m/{c-B7J4K2AE.js → c-GVPNDIKJ.js} +2 -2
  49. package/dist/m/{c-AMYEFA2E.js → c-I2IFKJX2.js} +1 -1
  50. package/dist/m/c-ICMAOOGK.js +1 -0
  51. package/dist/m/{c-BUAYFEV5.js → c-J3BXFTZS.js} +1 -1
  52. package/dist/m/{c-BIJALSRD.js → c-JDZDF2QM.js} +1 -1
  53. package/dist/m/{c-UDHIVLYH.js → c-JH5FF4NL.js} +1 -1
  54. package/dist/m/{c-OYRZ7XG2.js → c-JHJR5BQX.js} +1 -1
  55. package/dist/m/{c-V44KWI2L.js → c-JOH753EJ.js} +2 -2
  56. package/dist/m/{c-P3OFYUMA.js → c-JUE7B4OX.js} +1 -1
  57. package/dist/m/c-K76AUL4I.js +7 -0
  58. package/dist/m/{c-ZWIOJGMT.js → c-LA2BW7UY.js} +1 -1
  59. package/dist/m/{c-ICJYHABF.js → c-LDUNOR57.js} +1 -1
  60. package/dist/m/{c-C6IPRG34.js → c-LIBE4HPD.js} +1 -1
  61. package/dist/m/c-LPUJXRXW.js +1 -0
  62. package/dist/m/{c-TTB5EK4S.js → c-LQU7TXIH.js} +1 -1
  63. package/dist/m/{c-5ZQV7KC4.js → c-LV5MABYD.js} +1 -1
  64. package/dist/m/{c-URSMSFCB.js → c-M4FSPNQ2.js} +1 -1
  65. package/dist/m/{c-2KIEGNC4.js → c-MEWUGR4D.js} +1 -1
  66. package/dist/m/c-MIL4B2JQ.js +1 -0
  67. package/dist/m/{c-IVMD3FEM.js → c-N7Y52HJH.js} +1 -1
  68. package/dist/m/{c-PLN76GF3.js → c-NFR673TL.js} +2 -2
  69. package/dist/m/{c-T637T7SN.js → c-NLZ5AN4L.js} +1 -1
  70. package/dist/m/{c-OPLUZR3A.js → c-OABVRYOT.js} +1 -1
  71. package/dist/m/c-PIVIYLTY.js +1 -0
  72. package/dist/m/{c-L7JL5TL3.js → c-QY7F6EN6.js} +1 -1
  73. package/dist/m/{c-UY4QX42B.js → c-RG6XUZFA.js} +1 -1
  74. package/dist/m/c-RHMPKZZ7.js +1 -0
  75. package/dist/m/{c-TJAXGIRV.js → c-RQRMPZXD.js} +1 -1
  76. package/dist/m/{c-GY422N3Q.js → c-RS77ODLY.js} +1 -1
  77. package/dist/m/{c-IMZCWYHR.js → c-RT3C74GY.js} +1 -1
  78. package/dist/m/{c-CAS3NND4.js → c-S5IEIZCN.js} +1 -1
  79. package/dist/m/{c-K3ADYNLU.js → c-SBSMJIPC.js} +1 -1
  80. package/dist/m/c-SFKI6OLM.js +2 -0
  81. package/dist/m/{c-4TXNLX4K.js → c-SJPD46ZO.js} +4 -4
  82. package/dist/m/{c-HHGJBU4D.js → c-SO63UGPQ.js} +1 -1
  83. package/dist/m/{c-PLP4JKFC.js → c-TUGVINJR.js} +1 -1
  84. package/dist/m/{c-Q26MME6N.js → c-TWCXBWS3.js} +1 -1
  85. package/dist/m/{c-GNDL3TKB.js → c-U5X57T4L.js} +1 -1
  86. package/dist/m/{c-4YU3BR4D.js → c-UXEVJ63W.js} +1 -1
  87. package/dist/m/{c-KJJPV77R.js → c-V2J5C5MT.js} +1 -1
  88. package/dist/m/{c-6UGWFMQC.js → c-VBLFAQD2.js} +1 -1
  89. package/dist/m/{c-ERQSNR6K.js → c-VQCEOGKH.js} +2 -2
  90. package/dist/m/{c-YVZ2L7CE.js → c-VSPAFOKU.js} +1 -1
  91. package/dist/m/{c-5ONTYIUI.js → c-VY6XRBOW.js} +1 -1
  92. package/dist/m/{c-2KL3BD52.js → c-W23KVGUO.js} +1 -1
  93. package/dist/m/{c-COPTL5WB.js → c-W3K23S72.js} +1 -1
  94. package/dist/m/c-WFMRX5RZ.js +1 -0
  95. package/dist/m/{c-BWFVSBDF.js → c-WN3MXOLT.js} +1 -1
  96. package/dist/m/{c-X5TSXZYJ.js → c-XD5MOROJ.js} +1 -1
  97. package/dist/m/{c-MWXFLW4J.js → c-XQSXKIKM.js} +1 -1
  98. package/dist/m/{c-OTMKN2OO.js → c-Y33LUUIQ.js} +1 -1
  99. package/dist/m/{c-JNLX3RJB.js → c-YQUJ74R3.js} +1 -1
  100. package/dist/m/{c-2GRUM77Q.js → c-YSB6JKV2.js} +2 -2
  101. package/dist/m/{c-WQWIRWO3.js → c-Z32V4MHK.js} +1 -1
  102. package/dist/m/{c-BHZYSHW4.js → c-ZJLU56DV.js} +1 -1
  103. package/dist/m/{c-DKLS74XB.js → c-ZQXNHZZT.js} +2 -2
  104. package/dist/m/{c-TNEM3RNM.js → c-ZSCBEB7I.js} +1 -1
  105. package/dist/m/core/{admin-attrs-YY7T5FGU.js → admin-attrs-ZG7R5V3E.js} +1 -1
  106. package/dist/m/core/{autosave-S6OMNDCK.js → autosave-VPORYJSE.js} +1 -1
  107. package/dist/m/core/{conflict-notice-IWHMHH43.js → conflict-notice-JMAZLVRX.js} +1 -1
  108. package/dist/m/core/{persist-UKXV5KLA.js → persist-3OPWJKZS.js} +1 -1
  109. package/dist/m/core/{save-LYY7K6U7.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-DZZLUBVB.js +1 -0
  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 +1336 -1281
  121. package/dist/m/options/{options-EJMS3K24.js → options-55LQHSJ4.js} +1 -1
  122. package/dist/m/page/{editor-6LRB3GE4.js → editor-EY2WAAGB.js} +2 -2
  123. package/dist/m/plugins/{ai-edit-UTV7YO2I.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/like-EV7MTZ56.js +1 -0
  126. package/dist/m/plugins/{live-AD4H6XSL.js → live-5EZN2EYP.js} +1 -1
  127. package/dist/m/plugins/menu-KGWKT6CS.js +1 -0
  128. package/dist/m/plugins/{page-MD3T2ZX3.js → page-LVW5DWA4.js} +2 -2
  129. package/dist/m/plugins/{page-view-PAWVZNFY.js → page-view-5KQ76IJB.js} +1 -1
  130. package/dist/m/plugins/{sortable-4S6SQC3D.js → sortable-WJZZBM7R.js} +1 -1
  131. package/dist/m/plugins/{source-TJXOIOYY.js → source-CCEUM3OR.js} +1 -1
  132. package/dist/m/plugins/{undo-NLPGCJQY.js → undo-3JEYK5QY.js} +1 -1
  133. package/dist/m/plugins/{upgrade-HSUNDNJD.js → upgrade-NW556WJD.js} +1 -1
  134. package/dist/m/plugins/{upload-NHGJXZK2.js → upload-TTCQRIM5.js} +1 -1
  135. package/dist/m/plugins/{visitor-drafts-BW43DGY3.js → visitor-drafts-2AWNT23K.js} +2 -2
  136. package/dist/m/plugins/{visitor-drafts-owner-7ODQG7JX.js → visitor-drafts-owner-MZP45XSG.js} +1 -1
  137. package/dist/m/plugins/{wire-VBWXEXU2.js → wire-VRYPY6EJ.js} +1 -1
  138. package/dist/m/{reader-core-4W2KYEWQ.js → reader-core-2GXY7SHY.js} +2 -2
  139. package/dist/m/sync/{live-sync-MO5DH33W.js → live-sync-SKPMFYOO.js} +1 -1
  140. package/dist/m/ui/{index-IVWN2QC4.js → index-QNIPDHXQ.js} +1 -1
  141. package/dist/offline-manifest.json +652 -616
  142. package/docs/guide.md +25 -8
  143. package/package.json +4 -2
  144. package/src/core/conflict-download.js +8 -7
  145. package/src/core/conflict-notice-ui.js +4 -4
  146. package/src/core/copy-content.js +103 -0
  147. package/src/core/download.js +14 -2
  148. package/src/core/save-size-notice.js +2 -2
  149. package/src/core/upgrade-run.js +5 -1
  150. package/src/lib/region-policy.js +1 -1
  151. package/src/loader-logic.js +5 -1
  152. package/src/loader.js +2 -0
  153. package/src/page/features/export-html.js +4 -4
  154. package/src/page/features/export-markdown.js +2 -2
  155. package/src/page/recovery-ui.js +2 -2
  156. package/src/page/save-states.js +4 -4
  157. package/src/plugins/like.js +254 -0
  158. package/src/plugins/menu/actions.js +1 -1
  159. package/src/plugins/page.js +4 -4
  160. package/src/plugins/visitor-drafts/prompt.js +12 -12
  161. package/src/plugins/wire.js +3 -1
  162. package/dist/m/attrs/save-freeze-LWGF6XUN.js +0 -1
  163. package/dist/m/c-D5IKEKXW.js +0 -7
  164. package/dist/m/c-DCFSEJZG.js +0 -1
  165. package/dist/m/c-EVYAISP3.js +0 -1
  166. package/dist/m/c-GRXHHFPO.js +0 -1
  167. package/dist/m/c-HT2DKBV2.js +0 -1
  168. package/dist/m/c-MCOOHCSG.js +0 -1
  169. package/dist/m/c-VILENZTD.js +0 -1
  170. package/dist/m/c-VR2BJ4AN.js +0 -1
  171. package/dist/m/c-WGW764WX.js +0 -1
  172. package/dist/m/c-WNTYKCDG.js +0 -1
  173. package/dist/m/c-YBSS55KU.js +0 -20
  174. package/dist/m/core/unsaved-warning-7QTKEN7Z.js +0 -1
  175. package/dist/m/loader-3BBNZZGM.js +0 -1
  176. package/dist/m/manifest-26C55578.js +0 -1
  177. package/dist/m/manifest-edit-4396A009.js +0 -1
  178. package/dist/m/plugins/menu-M5WW7DBF.js +0 -1
  179. /package/dist/m/{c-QTTJYJMA.js → c-FILLTJA7.js} +0 -0
  180. /package/dist/m/plugins/{people-JCHVPF7P.js → people-C7TVBBMR.js} +0 -0
@@ -1 +1 @@
1
- import{a as u}from"./c-5ZQV7KC4.js";import"./c-N326R2JD.js";import{f as n}from"./c-TJAXGIRV.js";import{b as h,c as a}from"./c-BWFVSBDF.js";import{b as T,g as _}from"./c-IVMD3FEM.js";import{b as p}from"./c-TNEM3RNM.js";import{b}from"./c-PLP4JKFC.js";import"./c-Q26MME6N.js";import"./c-VKEDWYDF.js";import{A as v,B as g,J as k,L as E,P as w,q as f,r as m,x as y}from"./c-T637T7SN.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-FWKHM4E7.js";import"./c-X5LNHET5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-ZWIOJGMT.js";import"./c-B7J4K2AE.js";import"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import"./c-IJUK2GPW.js";import"./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 x=250,A=2e3,c=["focusin","focusout","selectionchange","clay:sync-applied","clay:workspace-background","clay:workspace-foreground"],S=t=>n.setGeneric(t),o=class{constructor({send:e=S,now:i=()=>Date.now()}){this.send=e,this.now=i,this.others=!1,this.background=!1,this.sent=null,this.lastAt=-1/0,this.timer=null,this.poked=null,this.inflight=!1,this.retry=null,this.stopped=!1,this._onEvent=s=>{s.type==="clay:workspace-background"&&(this.background=!0),s.type==="clay:workspace-foreground"&&(this.background=!1),this.poke()}}start(){this.stopped=!1;for(let e of c)document.addEventListener(e,this._onEvent)}resume(){this.stopped&&(this.start(),this.sent=null,this.schedule())}stop(){this.stopped=!0;for(let e of c)document.removeEventListener(e,this._onEvent);clearTimeout(this.timer),clearTimeout(this.poked),clearTimeout(this.retry),this.timer=null,this.poked=null,this.retry=null}roster(e){let s=(e&&Array.isArray(e.people)?e.people:[]).some(r=>r&&r.you!==!0);s!==this.others&&(this.others=s,this.schedule())}reconnected(){this.sent=null,this.schedule()}wanted(){return!this.others||this.background?null:a(h(document.activeElement))}poke(){this.poked===null&&(this.poked=setTimeout(()=>{this.poked=null,this.schedule()},0))}schedule(){if(this.stopped||this.timer!==null||this.inflight||this.wanted()===this.sent)return;let e=Math.max(0,this.lastAt+x-this.now());this.timer=setTimeout(()=>{this.timer=null,this.flush()},e)}flush(){if(this.inflight)return;let e=this.wanted();if(e===this.sent)return;this.sent=e,this.lastAt=this.now(),this.inflight=!0;let i=s=>{if(this.inflight=!1,!this.stopped){if(s)clearTimeout(this.retry),this.retry=null;else if(this.sent===e){this.sent=void 0,this.retry===null&&(this.retry=setTimeout(()=>{this.retry=null,this.schedule()},A));return}this.schedule()}};Promise.resolve(this.send(e)).then(s=>i(!!s),()=>i(!1))}};function P(t){let e=()=>(t._presenceQuiesced=!0,t._editing?.stop(),n.setGeneric(null),n.releaseTarget(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-quiesce")),t.lane==="live"&&t._morphInFlight?{ok:!1,code:"pending-input"}:{ok:!0}),i=()=>{t._presenceQuiesced=!1,t._editing?.resume(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))},s=()=>{t._presenceQuiesced=!1,t.stop(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))};return{id:"clay:sync",order:50,async prepare(r){if(await u(),r?.initial)return{quiesce:e,resume:i,dispose:s};let l=!1;return{quiesce:e,resume:i,enable(){let d=t.currentFile;t.stop(),t.start(d,{lane:"live"}),l=!0},dispose:()=>{t._presenceQuiesced=!1,l&&t.stop(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))}}}}}export{o as EditingSender,k as baselineSettled,m as conflictResolvedBySync,_ as enableAdminInputs,p as enableAdminResources,b as enableContentEditable,T as enableOnClick,v as getLastSavedBytes,f as isSaveConflicted,w as savePageThrottled,E as schedulePaintHeal,g as setLastSavedBaselines,y as setUnsavedChanges,P as syncParticipant};
1
+ import{a as u}from"./c-LV5MABYD.js";import{f as n}from"./c-RQRMPZXD.js";import{b as h,c as a}from"./c-WN3MXOLT.js";import"./c-N326R2JD.js";import{b as T,g as _}from"./c-N7Y52HJH.js";import{b as p}from"./c-ZSCBEB7I.js";import{b}from"./c-TUGVINJR.js";import"./c-TWCXBWS3.js";import"./c-VKEDWYDF.js";import{A as v,B as g,J as k,L as E,P as w,q as f,r as m,x as y}from"./c-NLZ5AN4L.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-GSRLXYWL.js";import"./c-X5LNHET5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-LA2BW7UY.js";import"./c-GVPNDIKJ.js";import"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import"./c-IJUK2GPW.js";import"./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 x=250,A=2e3,c=["focusin","focusout","selectionchange","clay:sync-applied","clay:workspace-background","clay:workspace-foreground"],S=t=>n.setGeneric(t),o=class{constructor({send:e=S,now:i=()=>Date.now()}){this.send=e,this.now=i,this.others=!1,this.background=!1,this.sent=null,this.lastAt=-1/0,this.timer=null,this.poked=null,this.inflight=!1,this.retry=null,this.stopped=!1,this._onEvent=s=>{s.type==="clay:workspace-background"&&(this.background=!0),s.type==="clay:workspace-foreground"&&(this.background=!1),this.poke()}}start(){this.stopped=!1;for(let e of c)document.addEventListener(e,this._onEvent)}resume(){this.stopped&&(this.start(),this.sent=null,this.schedule())}stop(){this.stopped=!0;for(let e of c)document.removeEventListener(e,this._onEvent);clearTimeout(this.timer),clearTimeout(this.poked),clearTimeout(this.retry),this.timer=null,this.poked=null,this.retry=null}roster(e){let s=(e&&Array.isArray(e.people)?e.people:[]).some(r=>r&&r.you!==!0);s!==this.others&&(this.others=s,this.schedule())}reconnected(){this.sent=null,this.schedule()}wanted(){return!this.others||this.background?null:a(h(document.activeElement))}poke(){this.poked===null&&(this.poked=setTimeout(()=>{this.poked=null,this.schedule()},0))}schedule(){if(this.stopped||this.timer!==null||this.inflight||this.wanted()===this.sent)return;let e=Math.max(0,this.lastAt+x-this.now());this.timer=setTimeout(()=>{this.timer=null,this.flush()},e)}flush(){if(this.inflight)return;let e=this.wanted();if(e===this.sent)return;this.sent=e,this.lastAt=this.now(),this.inflight=!0;let i=s=>{if(this.inflight=!1,!this.stopped){if(s)clearTimeout(this.retry),this.retry=null;else if(this.sent===e){this.sent=void 0,this.retry===null&&(this.retry=setTimeout(()=>{this.retry=null,this.schedule()},A));return}this.schedule()}};Promise.resolve(this.send(e)).then(s=>i(!!s),()=>i(!1))}};function P(t){let e=()=>(t._presenceQuiesced=!0,t._editing?.stop(),n.setGeneric(null),n.releaseTarget(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-quiesce")),t.lane==="live"&&t._morphInFlight?{ok:!1,code:"pending-input"}:{ok:!0}),i=()=>{t._presenceQuiesced=!1,t._editing?.resume(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))},s=()=>{t._presenceQuiesced=!1,t.stop(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))};return{id:"clay:sync",order:50,async prepare(r){if(await u(),r?.initial)return{quiesce:e,resume:i,dispose:s};let l=!1;return{quiesce:e,resume:i,enable(){let d=t.currentFile;t.stop(),t.start(d,{lane:"live"}),l=!0},dispose:()=>{t._presenceQuiesced=!1,l&&t.stop(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))}}}}}export{o as EditingSender,k as baselineSettled,m as conflictResolvedBySync,_ as enableAdminInputs,p as enableAdminResources,b as enableContentEditable,T as enableOnClick,v as getLastSavedBytes,f as isSaveConflicted,w as savePageThrottled,E as schedulePaintHeal,g as setLastSavedBaselines,y as setUnsavedChanges,P as syncParticipant};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e}from"./c-W23KVGUO.js";import"./c-BRLCTNMC.js";import"./c-QHWJ5ZIJ.js";import"./c-RG6XUZFA.js";import"./c-UL2YUY52.js";import"./c-QY7F6EN6.js";import"./c-CJFDLD43.js";import"./c-BJ7YQ5QZ.js";import"./c-4JZDZFF6.js";import"./c-VAK7SG37.js";import"./c-MHI3GYKF.js";import"./c-46XYM55L.js";import"./c-NUHP2XDB.js";import"./c-VKEDWYDF.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{a as ask,b as consent,e as init,d as snippet,c as tell};
@@ -0,0 +1 @@
1
+ import{e as a,f as b,g as c}from"./c-RQRMPZXD.js";import"./c-WN3MXOLT.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-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{a as PresenceStore,c as default,b as presence};
@@ -1,4 +1,4 @@
1
- import{c as h}from"./c-GBKB5WDL.js";import{w as d}from"./c-4TXNLX4K.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-MWXFLW4J.js";import"./c-ZK4GIZH2.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-AMU3BPPR.js";import{m as p}from"./c-QIXT3Q7C.js";import{a as s}from"./c-BYTKL6UX.js";import"./c-WCXLG3MV.js";import"./c-3LDGIBMN.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var c=`
1
+ import{c as h}from"./c-GBKB5WDL.js";import{w as d}from"./c-SJPD46ZO.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-XQSXKIKM.js";import"./c-67ILSNPR.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-44B5ODN7.js";import{m as p}from"./c-QIXT3Q7C.js";import{a as s}from"./c-BYTKL6UX.js";import"./c-E4IBSAQM.js";import"./c-3LDGIBMN.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var c=`
2
2
  .page-tool-block { position: relative; min-height: 48px; border: 1px solid var(--page-rule); border-radius: 8px; padding: 12px; }
3
3
  .page-tool-settings { position: absolute; top: 4px; inset-inline-end: 4px; border: 0; border-radius: 5px; background: var(--page-pop-bg); color: var(--page-ink-soft); font: 12px var(--page-font); padding: 5px 8px; cursor: pointer; opacity: 0; }
4
4
  .page-tool-block:hover .page-tool-settings, .page-tool-block:focus-within .page-tool-settings { opacity: 1; }
@@ -1,4 +1,4 @@
1
- import{b as F,c as M}from"./c-MWXFLW4J.js";import{B as N,d as $}from"./c-AMU3BPPR.js";import{G as U,J as A,k as X,l as Y,m as w}from"./c-QIXT3Q7C.js";import{b as P}from"./c-L7JL5TL3.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var k=5;function v(n){let u=0;for(let s=0;s<n.childCount;s++){let i=n.child(s);if(i.type===w.nodes.heading&&i.attrs.level===1&&i.attrs.parent==null)return{index:s,at:u,node:i};u+=i.nodeSize}return null}var O=`
1
+ import{b as F,c as M}from"./c-XQSXKIKM.js";import{B as N,d as $}from"./c-44B5ODN7.js";import{G as U,J as A,k as X,l as Y,m as w}from"./c-QIXT3Q7C.js";import{b as P}from"./c-QY7F6EN6.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var k=5;function v(n){let u=0;for(let s=0;s<n.childCount;s++){let i=n.child(s);if(i.type===w.nodes.heading&&i.attrs.level===1&&i.attrs.parent==null)return{index:s,at:u,node:i};u+=i.nodeSize}return null}var O=`
2
2
  :host{font:inherit !important;color:inherit !important}
3
3
  .page-cover-panel{display:flex;align-items:center;gap:8px;margin:8px 0;padding:6px 10px;border:1px solid var(--page-pop-line);border-radius:8px;background:var(--page-pop-bg);color:var(--page-pop-ink);box-shadow:var(--page-pop-shadow);font-size:.88em}
4
4
  .page-cover-msg{max-width:34ch}
@@ -1 +1 @@
1
- import{a as r}from"./c-WYFDLITL.js";import{a as p}from"./c-ZWIOJGMT.js";import{f as u}from"./c-3O7OBDCM.js";import{n as d,o as l}from"./c-DCFSEJZG.js";var n=0,g=0,c=!1,m=!1,y=!1,i=!1;function o(){!u||i||(i=!0,queueMicrotask(()=>{if(i=!1,typeof document>"u")return;let e=C();if(e===y)return;y=e;let t=document.documentElement;e?t.setAttribute("unsaved","true"):t.removeAttribute("unsaved"),document.dispatchEvent(new CustomEvent(e?"clay:dirty":"clay:clean"))}))}var T=`input${r}, textarea${r}, select${r}`,h=`${d}, ${l}`,a=new WeakMap;function v(){let e=[];for(let t of document.querySelectorAll(T))t.closest(h)||e.push(t);return e}function E(e){let t=e.target;!t||t.nodeType!==1||(t.matches("input, textarea, select")||t.isContentEditable)&&(t.closest(h)||(n++,o()))}function x(){m||(m=!0,p.onAnyChange({omitChangeDetails:!0,require:"dirty"},()=>{c||(n++,o())}),document.addEventListener("input",E,!0),document.addEventListener("change",E,!0))}function L(){c=!0}function k(){c=!1}function f(e){return e instanceof HTMLSelectElement?Array.from(e.selectedOptions,t=>t.value).join("\0"):e instanceof HTMLInputElement&&(e.type==="checkbox"||e.type==="radio")?e.checked?"1":"0":e.value}function M(e){return e instanceof HTMLSelectElement?Array.from(e.options).every(t=>t.selected===t.defaultSelected):e instanceof HTMLInputElement?e.type==="checkbox"||e.type==="radio"?e.checked===e.defaultChecked:e.value===e.defaultValue:e instanceof HTMLTextAreaElement?e.hasAttribute("data-value")?e.value===e.getAttribute("data-value"):e.value===e.defaultValue:!0}function S(){for(let e of v()){let t=f(e);if(a.get(e)!==t){if(M(e)){a.set(e,t);continue}return!0}}return!1}function C(){return n>g||S()}function D(){return n}function O(){let e=[];for(let t of v())e.push([t,f(t)]);return{gen:n,probe:e}}function b(){n++,o()}function H(e){if(e){n===e.gen&&(g=e.gen);for(let[t,s]of e.probe)f(t)===s&&a.set(t,s);o()}}typeof document<"u"&&u&&x();typeof window<"u"&&(window.clay=window.clay||{},window.clay.markDirty=b);export{x as a,L as b,k as c,C as d,D as e,O as f,b as g,H as h};
1
+ import{a as r}from"./c-WYFDLITL.js";import{a as p}from"./c-LA2BW7UY.js";import{f as u}from"./c-3O7OBDCM.js";import{n as d,o as l}from"./c-ICMAOOGK.js";var n=0,g=0,c=!1,m=!1,y=!1,i=!1;function o(){!u||i||(i=!0,queueMicrotask(()=>{if(i=!1,typeof document>"u")return;let e=C();if(e===y)return;y=e;let t=document.documentElement;e?t.setAttribute("unsaved","true"):t.removeAttribute("unsaved"),document.dispatchEvent(new CustomEvent(e?"clay:dirty":"clay:clean"))}))}var T=`input${r}, textarea${r}, select${r}`,h=`${d}, ${l}`,a=new WeakMap;function v(){let e=[];for(let t of document.querySelectorAll(T))t.closest(h)||e.push(t);return e}function E(e){let t=e.target;!t||t.nodeType!==1||(t.matches("input, textarea, select")||t.isContentEditable)&&(t.closest(h)||(n++,o()))}function x(){m||(m=!0,p.onAnyChange({omitChangeDetails:!0,require:"dirty"},()=>{c||(n++,o())}),document.addEventListener("input",E,!0),document.addEventListener("change",E,!0))}function L(){c=!0}function k(){c=!1}function f(e){return e instanceof HTMLSelectElement?Array.from(e.selectedOptions,t=>t.value).join("\0"):e instanceof HTMLInputElement&&(e.type==="checkbox"||e.type==="radio")?e.checked?"1":"0":e.value}function M(e){return e instanceof HTMLSelectElement?Array.from(e.options).every(t=>t.selected===t.defaultSelected):e instanceof HTMLInputElement?e.type==="checkbox"||e.type==="radio"?e.checked===e.defaultChecked:e.value===e.defaultValue:e instanceof HTMLTextAreaElement?e.hasAttribute("data-value")?e.value===e.getAttribute("data-value"):e.value===e.defaultValue:!0}function S(){for(let e of v()){let t=f(e);if(a.get(e)!==t){if(M(e)){a.set(e,t);continue}return!0}}return!1}function C(){return n>g||S()}function D(){return n}function O(){let e=[];for(let t of v())e.push([t,f(t)]);return{gen:n,probe:e}}function b(){n++,o()}function H(e){if(e){n===e.gen&&(g=e.gen);for(let[t,s]of e.probe)f(t)===s&&a.set(t,s);o()}}typeof document<"u"&&u&&x();typeof window<"u"&&(window.clay=window.clay||{},window.clay.markDirty=b);export{x as a,L as b,k as c,C as d,D as e,O as f,b as g,H as h};
@@ -1,3 +1,3 @@
1
- import{b as U}from"./c-ATKAOH23.js";import{a as oe,g as ie,h as C}from"./c-EK63G3CG.js";import{a as ne,b as re,c as M}from"./c-NQJRVJ56.js";import{d as w}from"./c-XGH4GS2T.js";import{c as V,e as q,g as Z}from"./c-IJUK2GPW.js";import{b as R,f as N}from"./c-3O7OBDCM.js";import{c as X}from"./c-BPF2NSPV.js";import{g as Y}from"./c-N7JPUPGC.js";import{a as k,g as Q,h as ee,i as te}from"./c-7MG5RU63.js";var D=null,ae=null,A=null;function we(e){let t=e?.document?.maxBytes;return Number.isSafeInteger(t)&&t>0?t:null}function se(e){return D=we(e),ae=e?.document?.maxBytesMeasures==="file"?"file":null,D}var Ae=/<script\b[^>]*\bmerge=(["'])page\1[^>]*>[\s\S]*?<\/script\s*>/i;function F(e,t=ae){if(t!=="file"||typeof e!="string")return e;let n=Ae.exec(e);if(!n)return e;let o=n.index,s=o+n[0].length,r=e.lastIndexOf(`
1
+ import{b as U}from"./c-ATKAOH23.js";import{a as oe,g as ie,h as C}from"./c-EK63G3CG.js";import{a as ne,b as re,c as M}from"./c-NQJRVJ56.js";import{d as w}from"./c-XGH4GS2T.js";import{c as V,e as q,g as Z}from"./c-IJUK2GPW.js";import{b as R,f as N}from"./c-3O7OBDCM.js";import{c as X}from"./c-BPF2NSPV.js";import{g as Y}from"./c-N7JPUPGC.js";import{a as k,g as Q,h as ee,i as te}from"./c-EGTIAL6P.js";var D=null,ae=null,A=null;function we(e){let t=e?.document?.maxBytes;return Number.isSafeInteger(t)&&t>0?t:null}function se(e){return D=we(e),ae=e?.document?.maxBytesMeasures==="file"?"file":null,D}var Ae=/<script\b[^>]*\bmerge=(["'])page\1[^>]*>[\s\S]*?<\/script\s*>/i;function F(e,t=ae){if(t!=="file"||typeof e!="string")return e;let n=Ae.exec(e);if(!n)return e;let o=n.index,s=o+n[0].length,r=e.lastIndexOf(`
2
2
  `,o-1)+1,l=e.indexOf(`
3
- `,s),c=l===-1?e.length:l+1;return!/\S/.test(e.slice(r,o))&&!/\S/.test(e.slice(s,c))&&(o=r,s=c),e.slice(0,o)+e.slice(s)}function B(e,t){let n=new TextEncoder().encode(e).byteLength,o=Number.isSafeInteger(t)&&t>0;return{bytes:n,maxBytes:o?t:null,state:o?n>t?"over":n>=Math.ceil(t*.8)?"near":"ok":"unknown"}}function le(){return D}function P({fresh:e=!1}={}){return e?(A=w({fresh:!0}).then(se),A):(A||(A=w().then(se)),A)}function vt({fresh:e=!1}={}){return P({fresh:e}).then(t=>({maxBytes:t}))}async function yt(e){let t=await P();return B(F(e),t)}function ue(e){let t=new CustomEvent("clay:save-size",{detail:e});document.dispatchEvent(t),(e.state==="near"||e.state==="over")&&import("./c-HT2DKBV2.js").then(n=>n.start(t),()=>{})}var L="/_/clayjs/",Te=/[\u0000-\u001F\u007F]/,be=/^[\t\n\f\r ]|[\t\n\f\r ]$/,Oe=/^https:\/\/clayjs\.com\/v(\d+)\/([\s\S]*)$/,Ee=/^https:\/\/clayjs\.com\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,ce=/^\/_\/clayjs\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,$e=/%2e|%2f|%5c/i;function Re(e){if(typeof e!="string")return null;let t=/^(\d+)\.\d+\.\d+$/.exec(e);return t?t[1]:null}function ke(e){if(typeof e!="string"||e==="")return null;try{return new URL(e).origin}catch{return null}}function Me(e){let t=e.indexOf("#"),n=t<0?"":e.slice(t),o=t<0?e:e.slice(0,t),s=o.indexOf("?"),r=s<0?"":o.slice(s);return{head:s<0?o:o.slice(0,s),search:r,hash:n}}function Pe(e){if(e===""||e.includes("\\")||$e.test(e))return null;let t=e.split("/"),n=[];for(let o of t){if(o===""||o==="."||o==="..")return null;let s;try{s=decodeURIComponent(o)}catch{return null}if(s.includes("/")||s.includes("\\")||s==="."||s==="..")return null;n.push(s)}return n.join("/")}function T(e,{documentURL:t}={}){if(typeof e!="string"||e===""||be.test(e)||Te.test(e))return null;let{head:n,search:o,hash:s}=Me(e),r=null,l=null,c=null,u=null,i=Oe.exec(n);if(i&&(r="rolling",c=i[1],u=i[2]),r||(i=Ee.exec(n),i&&(r="exact",l=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],u=i[4])),r||(i=ce.exec(n),i&&(r="local",l=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],u=i[4])),!r){let d=ke(t);d&&n.startsWith(`${d}/`)&&(i=ce.exec(n.slice(d.length)),i&&(r="local",l=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],u=i[4]))}if(!r)return null;let a=Pe(u);return a===null?null:{kind:r,major:c,version:l,rawPath:u,path:a,search:o,hash:s}}function Le(e,t){let n=e&&typeof e=="object"?e[t]:null;return n&&typeof n.files=="object"&&n.files?n.files:null}function je(e){return!e||typeof e!="object"?[]:Array.isArray(e.entries)?e.entries.filter(t=>t&&typeof t=="object"):[]}function Ie(e,t,n){if(!n)return!0;let o=Le(n,t);return!!(o&&Object.hasOwn(o,e.path))}function fe(e,{descriptor:t,releases:n,documentURL:o,aliases:s}={}){let r=T(e,{documentURL:o});if(!r||r.kind!=="local")return e;let l=je(t),c=Re(r.version);for(let u of l){if(u.local!==e||typeof u.original!="string")continue;let i=n?.[r.version]?.aliases??s;if(i&&typeof i=="object"&&!r.search&&!r.hash&&Object.hasOwn(i,u.original)&&i[u.original]===r.path)return u.original;let a=T(u.original);if(a&&!(a.kind!=="rolling"&&a.kind!=="exact")&&a.rawPath===r.rawPath&&a.search===r.search&&a.hash===r.hash&&!(a.kind==="rolling"?a.major!==c:a.version!==r.version)&&Ie(r,r.version,n))return a.kind==="exact"?u.original:`https://clayjs.com/v${a.major}/${r.rawPath}${r.search}${r.hash}`}for(let u of l){if(typeof u.original!="string")continue;let i=T(u.original);if(i&&!(i.kind!=="rolling"&&i.kind!=="exact")&&i.rawPath===r.rawPath&&!(i.kind==="rolling"?i.major!==c:i.version!==r.version))return i.kind==="rolling"?`https://clayjs.com/v${i.major}/${r.rawPath}${r.search}${r.hash}`:`https://clayjs.com/${i.version}/${r.rawPath}${r.search}${r.hash}`}return`https://clayjs.com/${r.version}/${r.rawPath}${r.search}${r.hash}`}var _e=Object.freeze({"https://cdn.jsdelivr.net/npm/overtype@2.6.1/dist/overtype.min.js":"compat/overtype-2.6.1.min.js","https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js":"compat/highlight-11.9.0.min.js","https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;0,600;1,400;1,500&family=IBM+Plex+Sans:wght@400;500;600&display=swap":"fonts/ibm-plex.css"}),J="clay-runtime-map",Ne=new Set(["stylesheet","preload","modulepreload"]),de=null,H=null;function Ue(e){let t;try{t=JSON.parse(e)}catch{return null}return!t||typeof t!="object"||t.schema!==1?null:t}function Ce(){if(typeof document>"u")return null;let e=document.getElementById(J);if(!e)return null;let t=e.textContent??"";return t===de||(de=t,H=Ue(t)),H}var De=`script[src*="${L}"], link[href*="${L}"], #${J}`;function he(e){if(e.querySelector(De))return!0;for(let t of e.querySelectorAll("template"))if(he(t.content))return!0;return!1}function Fe(e){let t=[],n=[e];for(;n.length;){let o=n.pop();for(let s of o.children??[])t.push(s),n.push(s),s.content&&n.push(s.content)}return t}function Be(e){return e.tagName==="SCRIPT"&&e.hasAttribute("src")?"src":e.tagName!=="LINK"||!e.hasAttribute("href")?null:(e.getAttribute("rel")??"").toLowerCase().split(/\s+/).some(n=>Ne.has(n))?"href":null}function He(e){if(!e||!he(e))return;let t=[],n=!1;for(let r of Fe(e)){if(r.getAttribute("id")===J){r.remove();continue}let l=Be(r);l&&(t.push({element:r,name:l}),!n&&(r.getAttribute(l)??"").includes(L)&&(n=!0))}if(!n)return;let o=location.href,s=Ce();for(let{element:r,name:l}of t){let c=r.getAttribute(l),u=T(c,{documentURL:o});!u||u.kind!=="local"||r.setAttribute(l,fe(c,{descriptor:s,documentURL:o,aliases:_e}))}}te(He);var y=!1,E=null,pe="/_/save",ze=12e3,me=6e4,Ge=1024*1024,Se="text/plain;charset=UTF-8",j=null,$=!1,G=new Map;function Ft(e,t){t==null?G.delete(e):G.set(e,String(t))}async function Bt(e,t){$=!!e;try{return await t()}finally{$=!1}}function Ht(){return y}function Jt(){return y?null:(y=!0,E={reserved:!0},E)}function zt(e){!e||E!==e||(E=null,y=!1)}function Gt(){return $}var I=[],_=[];function Kt(e){return I.push(e),()=>{let t=I.indexOf(e);t>=0&&I.splice(t,1)}}function Wt(e){return _.push(e),()=>{let t=_.indexOf(e);t>=0&&_.splice(t,1)}}function Ke(e){for(let t of I)try{t(e)}catch(n){console.error("clayjs: onSaveAttempt hook failed:",n)}}function We(e){for(let t of _)try{t(e)}catch(n){console.error("clayjs: onSaveOutcome hook failed:",n)}}function ge(e){return{ok:!0,msg:e.msg??"Saved",msgType:e.msgType||"success",code:e.code??null,etag:e.etag??null}}var b=[],Xe=8,v=null;function Xt(){return v!==null}function ve(){let e=window.crypto?.randomUUID?.();if(e)return e;if(window.crypto?.getRandomValues){let n=new Uint8Array(16);return window.crypto.getRandomValues(n),Array.from(n,o=>o.toString(16).padStart(2,"0")).join("")}let t=()=>Math.random().toString(36).slice(2,12).padEnd(10,"0");return`${Date.now().toString(36)}-${t()}${t()}${t()}`}function Ye(e){b.push(e),b.length>Xe&&b.shift()}function Ve(e){return typeof e=="string"&&e!==""&&b.includes(e)}function Yt(){b.length=0,v=null}function K(e){let t=e.name==="AbortError",n=!t&&e.status===412,o=!t&&!n&&e.code==="save-already-applied";return{ok:!1,msg:t?"Server not responding":e.message||"Save failed",msgType:t||o?"unknown":n?"conflict":"error",code:t?"timeout":n?"conflict":e.code??null,changedBy:n?e.changedBy??null:null,afterTimeout:n&&v!==null,conflictEtag:n?e.etag??null:null,status:Number.isInteger(e.status)?e.status:null,hadTimeout:t||e.hadTimeout===!0,reason:e.reason??null,retryAfter:e.retryAfter??null,saveOutcome:e.saveOutcome??null,etag:null}}function O(e){return{ok:!1,msg:e,msgType:"skipped",code:null,etag:null}}function qe(e){let t=new Error(`This document is ${e.bytes} bytes; this host saves at most ${e.maxBytes}`);return t.code="save-too-large",{...K(t),sent:!1,size:e}}var S=null;function Ze(e){return S?null:(S={kind:e},S)}function Qe(e){S===e&&(S=null)}function et(){return S?S.kind:null}function tt(){return{ok:!1,msg:"Invalid page conversion metadata",msgType:"error",code:"invalid-header",etag:null}}var nt=3,rt=/^(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT|(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), \d{2}-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{2} \d{2}:\d{2}:\d{2} GMT|(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?: \d|\d{2}) \d{2}:\d{2}:\d{2} \d{4})$/;function ot(e){if(e==null)return null;let t=String(e).trim();if(!t)return null;if(/^-?\d+$/.test(t))return Math.max(0,Math.min(3600,Number(t)));if(!rt.test(t))return null;let n=Date.parse(t);return Number.isNaN(n)?null:Math.max(0,Math.min(3600,Math.round((n-Date.now())/1e3)))}var it=/^[0-9a-f]{64}$/,st=/^[A-Za-z0-9-]{1,64}$/;function at(e){if(e==null)return{header:null};if(typeof e!="object")return{invalid:!0};let{source:t,base:n,epoch:o}=e;return typeof n!="string"||!it.test(n)?{invalid:!0}:t==="file"?o!=null?{invalid:!0}:{header:`v1; source=file; base=${n}`}:t==="room"?typeof o!="string"||!st.test(o)?{invalid:!0}:{header:`v1; source=room; base=${n}; epoch=${o}`}:{invalid:!0}}function lt(e,t,n,o,s,r=!1,l=null){let c=X(),u=c?`${pe}/${c}`:pe,i={method:"POST",credentials:c?"omit":"same-origin",signal:n,headers:{"Document-URL":window.location.href,"Page-URL":window.location.href,"Save-Trigger":t?"user":"auto","Save-ID":o,[oe]:String(1)},body:ut(e)};for(let[a,d]of G)i.headers[a]=d;return typeof i.body!="string"&&(i.headers["Content-Type"]=Se),l&&(i.headers["Page-Conversion"]=l),s&&(i.headers["If-Match"]=s),r&&e.length<me&&new Blob([e]).size<me&&(i.keepalive=!0),{url:ct(u),options:i}}function ut(e){if(e.length<Ge)return e;if(j&&j.content===e)return j.blob;let t=new Blob([e],{type:Se});return j={content:e,blob:t},t}function ye(){let e=ne();return re()&&e?e:null}function ct(e){let t=window.location.origin;return!t||t==="null"?e:new URL(e,t).href}function z(e,t){let n=JSON.stringify(t);return{ok:e>=200&&e<300,status:e,statusText:e===200?"OK":"Insufficient Storage",text:()=>Promise.resolve(n)}}function ft(e){let t=Y();return t?Promise.resolve().then(()=>{try{return t(e),z(200,{msg:"Saved in this browser",msgType:"success"})}catch(n){return z(507,{msg:"Couldn't save in this browser. Storage is full or turned off.",msgType:"error",code:n.code||"draft-storage"})}}):Promise.resolve(z(503,{msg:"Saving in this browser is not ready yet",msgType:"error",code:"draft-not-ready"}))}function dt(e,t,n,{captureId:o=null,conversionHeader:s=null,attempts:r=[]}={}){let l=new AbortController,c=setTimeout(()=>l.abort(),ze),u=q(),i=Z(),a=u||i,d=$;$=!1;let{url:m,options:x}=lt(e,a,l.signal,t,n,d,s);return Ye(t),R||(r.some(f=>f.saveId===t&&f.etag===(n??null))||r.push({saveId:t,etag:n??null}),Ke({captureId:o,saveId:t,html:e,etag:n??null})),(R?ft(e):fetch(m,x)).then(f=>f.text().then(p=>{let h={};if(p)try{h=JSON.parse(p)}catch{if(f.ok)throw new Error("Server sent a response that was not JSON")}if(!f.ok){let g=new Error(h.msg||h.error||`HTTP ${f.status}: ${f.statusText}`);throw g.code=f.status===413?"save-too-large":h.code??null,g.status=f.status,g.changedBy=h.changedBy??null,g.etag=h.etag??null,g.saveId=h.saveId??null,g.reason=typeof h.reason=="string"?h.reason:null,g.saveOutcome=h.saveOutcome??null,g.retryAfter=ot(f.headers?.get?.("Retry-After")),g}return M(h.etag??null),v=null,h})).catch(f=>{throw console.error("Failed to save page:",f),f.name==="AbortError"&&(v={saveId:t,etag:n}),a&&V(),f}).finally(()=>{clearTimeout(c)})}async function ht(){let e=v;if(!e)return{landed:null,resend:!1};let n=(await w({fresh:!0})).document,o=typeof n?.etag=="string"&&n.etag?n.etag:null;return o?n.saveId&&n.saveId===e.saveId?(M(o),v=null,{landed:{msg:"Saved",msgType:"success",etag:o},resend:!1}):(n.saveId&&(v=null),{landed:null,resend:!!e.etag,etag:e.etag}):{landed:null,resend:!1}}async function pt(e,{captureId:t=null,conversionHeader:n=null,attempts:o=[]}={}){let s=ve(),r=ye(),l=!1,c=!1,u=0,i=t??k();for(;;)try{return await dt(e,s,r,{captureId:t,conversionHeader:n,attempts:o})}catch(a){if(l&&(a.hadTimeout=!0),a.name==="AbortError"){if(l)throw a;let{landed:d,resend:m,etag:x}=await ht();if(d)return d;if(!m)throw a;r=x,l=!0;continue}if(a.status===412&&!c&&Ve(a.saveId)){M(a.etag??null),v=null,s=ve(),r=ye(),c=!0;continue}if(a.code==="page-converting"&&u<nt){if(k()!==i||(u+=1,await new Promise(d=>setTimeout(d,Math.max(0,a.retryAfter??1)*1e3)),k()!==i))throw a;continue}throw a}}function W(e,t,n,o,s=null,r=0,l=null){return e=ie(e,Math.max(C(),r)),new Promise(c=>{let u=[],i=Q(s),a=()=>l!==null&&E===l,d=()=>{a()||(y=!1)},m=(p,h=!1)=>{h&&U(e,t??null,i),ee(s),We({captureId:t??null,result:p,attempts:u,sent:u.length>0}),typeof n=="function"&&n(p),c(p)};if(!N&&!window.clay?.testMode)return m(O("Not in edit mode"));if(y&&!a())return m(O("Save already in progress"));let x=at(o);if(x.invalid)return m(tt());if(y=!0,window.clay?.testMode){setTimeout(()=>{d(),m(ge({msg:"Test mode: save skipped"}))},0);return}P();let f=B(F(e),le());if(ue(f),f.state==="over")return d(),m(qe(f));pt(e,{captureId:t,conversionHeader:x.header,attempts:u}).then(ge,K).then(p=>{d(),p.code==="save-too-large"&&!p.size&&(p.size=f),p.ok&&U(e,t??null,i),m(p)})})}function mt(e,t=()=>{}){return W(e,null,t,null)}function Vt(e,t,n=()=>{},{conversion:o,capture:s=null,pageFormatFloor:r,lane:l=null}={}){return W(e,t,n,o,s,r,l)}function qt({html:e,captureId:t,conversion:n}){return W(e,t??null,void 0,n)}function Zt(e,t=()=>{}){return new Promise(n=>{let o=null,s=r=>{Qe(o),typeof t=="function"&&t(r),n(r)};if(!N)return s(O("Not in edit mode"));if(et())return s(O("Another document operation is in progress"));if(y)return s(O("Save already in progress"));if(R)return s(!1);o=Ze("replace"),fetch(new URL(e,window.location.href).href).then(r=>{if(!r.ok)throw new Error(`Template fetch failed: HTTP ${r.status} ${r.statusText}`);return r.text()}).then(r=>mt(r)).then(s).catch(r=>{console.error("Failed to fetch template:",r),s(K(r))})})}var xe=null;function Qt(e){xe=e}function en(){return xe}export{P as a,vt as b,yt as c,Ft as d,Bt as e,Ht as f,Jt as g,zt as h,Gt as i,Kt as j,Wt as k,Xt as l,ve as m,Yt as n,Ze as o,Qe as p,et as q,lt as r,mt as s,Vt as t,qt as u,Zt as v,Qt as w,en as x};
3
+ `,s),c=l===-1?e.length:l+1;return!/\S/.test(e.slice(r,o))&&!/\S/.test(e.slice(s,c))&&(o=r,s=c),e.slice(0,o)+e.slice(s)}function B(e,t){let n=new TextEncoder().encode(e).byteLength,o=Number.isSafeInteger(t)&&t>0;return{bytes:n,maxBytes:o?t:null,state:o?n>t?"over":n>=Math.ceil(t*.8)?"near":"ok":"unknown"}}function le(){return D}function P({fresh:e=!1}={}){return e?(A=w({fresh:!0}).then(se),A):(A||(A=w().then(se)),A)}function vt({fresh:e=!1}={}){return P({fresh:e}).then(t=>({maxBytes:t}))}async function yt(e){let t=await P();return B(F(e),t)}function ue(e){let t=new CustomEvent("clay:save-size",{detail:e});document.dispatchEvent(t),(e.state==="near"||e.state==="over")&&import("./c-PIVIYLTY.js").then(n=>n.start(t),()=>{})}var L="/_/clayjs/",Te=/[\u0000-\u001F\u007F]/,be=/^[\t\n\f\r ]|[\t\n\f\r ]$/,Oe=/^https:\/\/clayjs\.com\/v(\d+)\/([\s\S]*)$/,Ee=/^https:\/\/clayjs\.com\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,ce=/^\/_\/clayjs\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,$e=/%2e|%2f|%5c/i;function Re(e){if(typeof e!="string")return null;let t=/^(\d+)\.\d+\.\d+$/.exec(e);return t?t[1]:null}function ke(e){if(typeof e!="string"||e==="")return null;try{return new URL(e).origin}catch{return null}}function Me(e){let t=e.indexOf("#"),n=t<0?"":e.slice(t),o=t<0?e:e.slice(0,t),s=o.indexOf("?"),r=s<0?"":o.slice(s);return{head:s<0?o:o.slice(0,s),search:r,hash:n}}function Pe(e){if(e===""||e.includes("\\")||$e.test(e))return null;let t=e.split("/"),n=[];for(let o of t){if(o===""||o==="."||o==="..")return null;let s;try{s=decodeURIComponent(o)}catch{return null}if(s.includes("/")||s.includes("\\")||s==="."||s==="..")return null;n.push(s)}return n.join("/")}function T(e,{documentURL:t}={}){if(typeof e!="string"||e===""||be.test(e)||Te.test(e))return null;let{head:n,search:o,hash:s}=Me(e),r=null,l=null,c=null,u=null,i=Oe.exec(n);if(i&&(r="rolling",c=i[1],u=i[2]),r||(i=Ee.exec(n),i&&(r="exact",l=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],u=i[4])),r||(i=ce.exec(n),i&&(r="local",l=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],u=i[4])),!r){let d=ke(t);d&&n.startsWith(`${d}/`)&&(i=ce.exec(n.slice(d.length)),i&&(r="local",l=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],u=i[4]))}if(!r)return null;let a=Pe(u);return a===null?null:{kind:r,major:c,version:l,rawPath:u,path:a,search:o,hash:s}}function Le(e,t){let n=e&&typeof e=="object"?e[t]:null;return n&&typeof n.files=="object"&&n.files?n.files:null}function je(e){return!e||typeof e!="object"?[]:Array.isArray(e.entries)?e.entries.filter(t=>t&&typeof t=="object"):[]}function Ie(e,t,n){if(!n)return!0;let o=Le(n,t);return!!(o&&Object.hasOwn(o,e.path))}function fe(e,{descriptor:t,releases:n,documentURL:o,aliases:s}={}){let r=T(e,{documentURL:o});if(!r||r.kind!=="local")return e;let l=je(t),c=Re(r.version);for(let u of l){if(u.local!==e||typeof u.original!="string")continue;let i=n?.[r.version]?.aliases??s;if(i&&typeof i=="object"&&!r.search&&!r.hash&&Object.hasOwn(i,u.original)&&i[u.original]===r.path)return u.original;let a=T(u.original);if(a&&!(a.kind!=="rolling"&&a.kind!=="exact")&&a.rawPath===r.rawPath&&a.search===r.search&&a.hash===r.hash&&!(a.kind==="rolling"?a.major!==c:a.version!==r.version)&&Ie(r,r.version,n))return a.kind==="exact"?u.original:`https://clayjs.com/v${a.major}/${r.rawPath}${r.search}${r.hash}`}for(let u of l){if(typeof u.original!="string")continue;let i=T(u.original);if(i&&!(i.kind!=="rolling"&&i.kind!=="exact")&&i.rawPath===r.rawPath&&!(i.kind==="rolling"?i.major!==c:i.version!==r.version))return i.kind==="rolling"?`https://clayjs.com/v${i.major}/${r.rawPath}${r.search}${r.hash}`:`https://clayjs.com/${i.version}/${r.rawPath}${r.search}${r.hash}`}return`https://clayjs.com/${r.version}/${r.rawPath}${r.search}${r.hash}`}var _e=Object.freeze({"https://cdn.jsdelivr.net/npm/overtype@2.6.1/dist/overtype.min.js":"compat/overtype-2.6.1.min.js","https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js":"compat/highlight-11.9.0.min.js","https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;0,600;1,400;1,500&family=IBM+Plex+Sans:wght@400;500;600&display=swap":"fonts/ibm-plex.css"}),J="clay-runtime-map",Ne=new Set(["stylesheet","preload","modulepreload"]),de=null,H=null;function Ue(e){let t;try{t=JSON.parse(e)}catch{return null}return!t||typeof t!="object"||t.schema!==1?null:t}function Ce(){if(typeof document>"u")return null;let e=document.getElementById(J);if(!e)return null;let t=e.textContent??"";return t===de||(de=t,H=Ue(t)),H}var De=`script[src*="${L}"], link[href*="${L}"], #${J}`;function he(e){if(e.querySelector(De))return!0;for(let t of e.querySelectorAll("template"))if(he(t.content))return!0;return!1}function Fe(e){let t=[],n=[e];for(;n.length;){let o=n.pop();for(let s of o.children??[])t.push(s),n.push(s),s.content&&n.push(s.content)}return t}function Be(e){return e.tagName==="SCRIPT"&&e.hasAttribute("src")?"src":e.tagName!=="LINK"||!e.hasAttribute("href")?null:(e.getAttribute("rel")??"").toLowerCase().split(/\s+/).some(n=>Ne.has(n))?"href":null}function He(e){if(!e||!he(e))return;let t=[],n=!1;for(let r of Fe(e)){if(r.getAttribute("id")===J){r.remove();continue}let l=Be(r);l&&(t.push({element:r,name:l}),!n&&(r.getAttribute(l)??"").includes(L)&&(n=!0))}if(!n)return;let o=location.href,s=Ce();for(let{element:r,name:l}of t){let c=r.getAttribute(l),u=T(c,{documentURL:o});!u||u.kind!=="local"||r.setAttribute(l,fe(c,{descriptor:s,documentURL:o,aliases:_e}))}}te(He);var y=!1,E=null,pe="/_/save",ze=12e3,me=6e4,Ge=1024*1024,Se="text/plain;charset=UTF-8",j=null,$=!1,G=new Map;function Ft(e,t){t==null?G.delete(e):G.set(e,String(t))}async function Bt(e,t){$=!!e;try{return await t()}finally{$=!1}}function Ht(){return y}function Jt(){return y?null:(y=!0,E={reserved:!0},E)}function zt(e){!e||E!==e||(E=null,y=!1)}function Gt(){return $}var I=[],_=[];function Kt(e){return I.push(e),()=>{let t=I.indexOf(e);t>=0&&I.splice(t,1)}}function Wt(e){return _.push(e),()=>{let t=_.indexOf(e);t>=0&&_.splice(t,1)}}function Ke(e){for(let t of I)try{t(e)}catch(n){console.error("clayjs: onSaveAttempt hook failed:",n)}}function We(e){for(let t of _)try{t(e)}catch(n){console.error("clayjs: onSaveOutcome hook failed:",n)}}function ge(e){return{ok:!0,msg:e.msg??"Saved",msgType:e.msgType||"success",code:e.code??null,etag:e.etag??null}}var b=[],Xe=8,v=null;function Xt(){return v!==null}function ve(){let e=window.crypto?.randomUUID?.();if(e)return e;if(window.crypto?.getRandomValues){let n=new Uint8Array(16);return window.crypto.getRandomValues(n),Array.from(n,o=>o.toString(16).padStart(2,"0")).join("")}let t=()=>Math.random().toString(36).slice(2,12).padEnd(10,"0");return`${Date.now().toString(36)}-${t()}${t()}${t()}`}function Ye(e){b.push(e),b.length>Xe&&b.shift()}function Ve(e){return typeof e=="string"&&e!==""&&b.includes(e)}function Yt(){b.length=0,v=null}function K(e){let t=e.name==="AbortError",n=!t&&e.status===412,o=!t&&!n&&e.code==="save-already-applied";return{ok:!1,msg:t?"Server not responding":e.message||"Save failed",msgType:t||o?"unknown":n?"conflict":"error",code:t?"timeout":n?"conflict":e.code??null,changedBy:n?e.changedBy??null:null,afterTimeout:n&&v!==null,conflictEtag:n?e.etag??null:null,status:Number.isInteger(e.status)?e.status:null,hadTimeout:t||e.hadTimeout===!0,reason:e.reason??null,retryAfter:e.retryAfter??null,saveOutcome:e.saveOutcome??null,etag:null}}function O(e){return{ok:!1,msg:e,msgType:"skipped",code:null,etag:null}}function qe(e){let t=new Error(`This document is ${e.bytes} bytes; this host saves at most ${e.maxBytes}`);return t.code="save-too-large",{...K(t),sent:!1,size:e}}var S=null;function Ze(e){return S?null:(S={kind:e},S)}function Qe(e){S===e&&(S=null)}function et(){return S?S.kind:null}function tt(){return{ok:!1,msg:"Invalid page conversion metadata",msgType:"error",code:"invalid-header",etag:null}}var nt=3,rt=/^(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT|(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), \d{2}-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{2} \d{2}:\d{2}:\d{2} GMT|(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?: \d|\d{2}) \d{2}:\d{2}:\d{2} \d{4})$/;function ot(e){if(e==null)return null;let t=String(e).trim();if(!t)return null;if(/^-?\d+$/.test(t))return Math.max(0,Math.min(3600,Number(t)));if(!rt.test(t))return null;let n=Date.parse(t);return Number.isNaN(n)?null:Math.max(0,Math.min(3600,Math.round((n-Date.now())/1e3)))}var it=/^[0-9a-f]{64}$/,st=/^[A-Za-z0-9-]{1,64}$/;function at(e){if(e==null)return{header:null};if(typeof e!="object")return{invalid:!0};let{source:t,base:n,epoch:o}=e;return typeof n!="string"||!it.test(n)?{invalid:!0}:t==="file"?o!=null?{invalid:!0}:{header:`v1; source=file; base=${n}`}:t==="room"?typeof o!="string"||!st.test(o)?{invalid:!0}:{header:`v1; source=room; base=${n}; epoch=${o}`}:{invalid:!0}}function lt(e,t,n,o,s,r=!1,l=null){let c=X(),u=c?`${pe}/${c}`:pe,i={method:"POST",credentials:c?"omit":"same-origin",signal:n,headers:{"Document-URL":window.location.href,"Page-URL":window.location.href,"Save-Trigger":t?"user":"auto","Save-ID":o,[oe]:String(1)},body:ut(e)};for(let[a,d]of G)i.headers[a]=d;return typeof i.body!="string"&&(i.headers["Content-Type"]=Se),l&&(i.headers["Page-Conversion"]=l),s&&(i.headers["If-Match"]=s),r&&e.length<me&&new Blob([e]).size<me&&(i.keepalive=!0),{url:ct(u),options:i}}function ut(e){if(e.length<Ge)return e;if(j&&j.content===e)return j.blob;let t=new Blob([e],{type:Se});return j={content:e,blob:t},t}function ye(){let e=ne();return re()&&e?e:null}function ct(e){let t=window.location.origin;return!t||t==="null"?e:new URL(e,t).href}function z(e,t){let n=JSON.stringify(t);return{ok:e>=200&&e<300,status:e,statusText:e===200?"OK":"Insufficient Storage",text:()=>Promise.resolve(n)}}function ft(e){let t=Y();return t?Promise.resolve().then(()=>{try{return t(e),z(200,{msg:"Saved in this browser",msgType:"success"})}catch(n){return z(507,{msg:"Couldn't save in this browser. Storage is full or turned off.",msgType:"error",code:n.code||"draft-storage"})}}):Promise.resolve(z(503,{msg:"Saving in this browser is not ready yet",msgType:"error",code:"draft-not-ready"}))}function dt(e,t,n,{captureId:o=null,conversionHeader:s=null,attempts:r=[]}={}){let l=new AbortController,c=setTimeout(()=>l.abort(),ze),u=q(),i=Z(),a=u||i,d=$;$=!1;let{url:m,options:x}=lt(e,a,l.signal,t,n,d,s);return Ye(t),R||(r.some(f=>f.saveId===t&&f.etag===(n??null))||r.push({saveId:t,etag:n??null}),Ke({captureId:o,saveId:t,html:e,etag:n??null})),(R?ft(e):fetch(m,x)).then(f=>f.text().then(p=>{let h={};if(p)try{h=JSON.parse(p)}catch{if(f.ok)throw new Error("Server sent a response that was not JSON")}if(!f.ok){let g=new Error(h.msg||h.error||`HTTP ${f.status}: ${f.statusText}`);throw g.code=f.status===413?"save-too-large":h.code??null,g.status=f.status,g.changedBy=h.changedBy??null,g.etag=h.etag??null,g.saveId=h.saveId??null,g.reason=typeof h.reason=="string"?h.reason:null,g.saveOutcome=h.saveOutcome??null,g.retryAfter=ot(f.headers?.get?.("Retry-After")),g}return M(h.etag??null),v=null,h})).catch(f=>{throw console.error("Failed to save page:",f),f.name==="AbortError"&&(v={saveId:t,etag:n}),a&&V(),f}).finally(()=>{clearTimeout(c)})}async function ht(){let e=v;if(!e)return{landed:null,resend:!1};let n=(await w({fresh:!0})).document,o=typeof n?.etag=="string"&&n.etag?n.etag:null;return o?n.saveId&&n.saveId===e.saveId?(M(o),v=null,{landed:{msg:"Saved",msgType:"success",etag:o},resend:!1}):(n.saveId&&(v=null),{landed:null,resend:!!e.etag,etag:e.etag}):{landed:null,resend:!1}}async function pt(e,{captureId:t=null,conversionHeader:n=null,attempts:o=[]}={}){let s=ve(),r=ye(),l=!1,c=!1,u=0,i=t??k();for(;;)try{return await dt(e,s,r,{captureId:t,conversionHeader:n,attempts:o})}catch(a){if(l&&(a.hadTimeout=!0),a.name==="AbortError"){if(l)throw a;let{landed:d,resend:m,etag:x}=await ht();if(d)return d;if(!m)throw a;r=x,l=!0;continue}if(a.status===412&&!c&&Ve(a.saveId)){M(a.etag??null),v=null,s=ve(),r=ye(),c=!0;continue}if(a.code==="page-converting"&&u<nt){if(k()!==i||(u+=1,await new Promise(d=>setTimeout(d,Math.max(0,a.retryAfter??1)*1e3)),k()!==i))throw a;continue}throw a}}function W(e,t,n,o,s=null,r=0,l=null){return e=ie(e,Math.max(C(),r)),new Promise(c=>{let u=[],i=Q(s),a=()=>l!==null&&E===l,d=()=>{a()||(y=!1)},m=(p,h=!1)=>{h&&U(e,t??null,i),ee(s),We({captureId:t??null,result:p,attempts:u,sent:u.length>0}),typeof n=="function"&&n(p),c(p)};if(!N&&!window.clay?.testMode)return m(O("Not in edit mode"));if(y&&!a())return m(O("Save already in progress"));let x=at(o);if(x.invalid)return m(tt());if(y=!0,window.clay?.testMode){setTimeout(()=>{d(),m(ge({msg:"Test mode: save skipped"}))},0);return}P();let f=B(F(e),le());if(ue(f),f.state==="over")return d(),m(qe(f));pt(e,{captureId:t,conversionHeader:x.header,attempts:u}).then(ge,K).then(p=>{d(),p.code==="save-too-large"&&!p.size&&(p.size=f),p.ok&&U(e,t??null,i),m(p)})})}function mt(e,t=()=>{}){return W(e,null,t,null)}function Vt(e,t,n=()=>{},{conversion:o,capture:s=null,pageFormatFloor:r,lane:l=null}={}){return W(e,t,n,o,s,r,l)}function qt({html:e,captureId:t,conversion:n}){return W(e,t??null,void 0,n)}function Zt(e,t=()=>{}){return new Promise(n=>{let o=null,s=r=>{Qe(o),typeof t=="function"&&t(r),n(r)};if(!N)return s(O("Not in edit mode"));if(et())return s(O("Another document operation is in progress"));if(y)return s(O("Save already in progress"));if(R)return s(!1);o=Ze("replace"),fetch(new URL(e,window.location.href).href).then(r=>{if(!r.ok)throw new Error(`Template fetch failed: HTTP ${r.status} ${r.statusText}`);return r.text()}).then(r=>mt(r)).then(s).catch(r=>{console.error("Failed to fetch template:",r),s(K(r))})})}var xe=null;function Qt(e){xe=e}function en(){return xe}export{P as a,vt as b,yt as c,Ft as d,Bt as e,Ht as f,Jt as g,zt as h,Gt as i,Kt as j,Wt as k,Xt as l,ve as m,Yt as n,Ze as o,Qe as p,et as q,lt as r,mt as s,Vt as t,qt as u,Zt as v,Qt as w,en as x};
@@ -1 +1 @@
1
- import{d as A,e as I}from"./c-XGH4GS2T.js";import{f as b,j as T}from"./c-3O7OBDCM.js";import{c as M}from"./c-BPF2NSPV.js";var B=15e3,P=12e4,K=15e3,V=4e3,W=5e3,U=50,y=new Set(["sent","acked"]),R=new Set(["done","error","cancelled"]),j="wire",i=new Map,k=new Set,f=null,g=null,D=0,h=null;function Q(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`page-${Date.now()}-${Math.random().toString(16).slice(2)}`}function H(e){return new URL(e,window.location.origin).href}function N(){let e=M();return typeof e=="string"&&e!==""?e:null}function w(e){return{id:e.id,type:e.type,state:e.state,helper:e.helper,text:e.text,result:e.result,error:e.error,errorCode:e.errorCode,errorDetails:e.errorDetails,errorSource:e.errorSource,startedAt:e.startedAt}}function m(e,t){let n=w(e);for(let r of k)try{r(n,t||null)}catch(s){console.error("clay.wire: a listener threw",s)}document.dispatchEvent(new CustomEvent("clay:wire-state",{detail:n}))}function Y(e,t){e.state!==t&&(e.state=t,m(e))}function v(e,t,n,{cancelFirst:r=!1,errorCode:s=null}={}){clearTimeout(e.timer),e.timer=setTimeout(()=>{e.timer=null,r&&z(e),l(e,"error",n,{errorCode:s,errorSource:"client"})},t)}function q(e){clearTimeout(e.timer),e.timer=null}function Z(){if(!(i.size<=U))for(let[e,t]of i){if(i.size<=U)break;!y.has(t.state)&&t.state!=="landing"&&i.delete(e)}}function ee(){if(g)return g;let e=N(),t=`/_/wire/subscribe?page-url=${encodeURIComponent(window.location.href)}`+(e?`&token=${encodeURIComponent(e)}`:"");return f=new EventSource(H(t)),f.onmessage=n=>{let r;try{r=JSON.parse(n.data)}catch{return}te(r)},f.onerror=()=>{},g=new Promise(n=>{let r=!1,s=()=>{r||(r=!0,n())};f.onopen=s,setTimeout(s,2e3)}),g}function L(){for(let e of i.values())if(y.has(e.state))return;f&&(f.close(),f=null,g=null)}function te(e){if(!e||typeof e.id!="string")return;let t=i.get(e.id);if(!(!t||!y.has(t.state)))switch(e.type){case"wire/ack":e.payload?.mode==="jsonl"&&Number.isFinite(e.payload.budgetMs)&&e.payload.budgetMs>0?(t.structured=!0,v(t,e.payload.budgetMs+K,"the helper did not finish within its execution budget",{cancelFirst:!0,errorCode:"helper_timeout"})):v(t,P,"the agent stopped responding"),Y(t,"acked");break;case"wire/status":t.structured||v(t,P,"the agent stopped responding"),t.text=typeof e.text=="string"?e.text:"",t.state="acked",ne(t,e),m(t,e);break;case"wire/done":t.result=Object.prototype.hasOwnProperty.call(e,"payload")?e.payload:null,t.document==="edit"?ae(t):l(t,"done",null);break;case"wire/error":re(t,e);break;default:break}}function ne(e,t){if(!e.onStatus||typeof t.text!="string")return;let n={text:t.text};t.payload&&typeof t.payload=="object"&&Object.prototype.hasOwnProperty.call(t.payload,"progress")&&(n.progress=t.payload.progress);try{e.onStatus(n)}catch(r){console.error("clay.wire: an onStatus listener threw",r)}}function re(e,t){let n=t.payload,r=n&&typeof n=="object"&&!Array.isArray(n)&&(n.source==="application"||n.source==="host")&&typeof n.code=="string"&&n.code,s=typeof t.text=="string"&&t.text?t.text:"the handler reported an error";if(!r){l(e,"error",s);return}let a=n.source==="host"&&n.code==="helper_cancelled"?"cancelled":"error";l(e,a,s,{errorCode:n.code,errorDetails:Object.prototype.hasOwnProperty.call(n,"details")?n.details:null,errorSource:n.source})}function oe(){h||(h=e=>{if(e.detail?.source!=="peer"){for(let t of i.values())if(t.state==="landing"){l(t,"done",null);return}}},document.addEventListener("clay:sync-applied",h))}function se(){D>0||!h||(document.removeEventListener("clay:sync-applied",h),h=null)}function ae(e){R.has(e.state)||e.state==="landing"||(q(e),e.state="landing",D++,oe(),e.landingTimer=setTimeout(()=>{l(e,"done",null)},V),m(e),L())}function l(e,t,n,r={}){if(R.has(e.state))return;let s=e.state==="landing";if(q(e),clearTimeout(e.landingTimer),e.landingTimer=null,e.abort?.abort(),s&&(D--,se()),e.error=n,Object.prototype.hasOwnProperty.call(r,"errorCode")&&(e.errorCode=r.errorCode),Object.prototype.hasOwnProperty.call(r,"errorDetails")&&(e.errorDetails=r.errorDetails),Object.prototype.hasOwnProperty.call(r,"errorSource")&&(e.errorSource=r.errorSource),e.state=t,e.signal&&e.signalHandler&&(e.signal.removeEventListener("abort",e.signalHandler),e.signalHandler=null),ue(e),m(e),L(),Z(),e.settle){let a=e.settle;e.settle=null,a(w(e))}}var C=0,$=null,E=null;function ie(){return E||(E=import("./core/save-LYY7K6U7.js")),E}async function le(e){if(!b||e.holdsSave)return;let t=await ie();e.state==="sent"&&($=t,e.holdsSave=!0,!(C++>0)&&t.suspendAutosave())}function ue(e){e.holdsSave&&(e.holdsSave=!1,!(--C>0)&&(C=0,$?.resumeAutosave()))}var c=null,de=()=>!c||c.admitted,ce=(e,t,n)=>Object.assign(new Error(`clay.wire: ${e}`),{code:t,pending:n});function O(e){return e.document!=="edit"||e.generation===T().generation&&de()?!0:(l(e,"error","the page changed mode before this request went out",{errorCode:"stale-document",errorSource:"client"}),!1)}function _e(){return{id:"clay:wire",order:900,prepare(e={}){let t={admitted:e.initial===!0};return c=t,{enable(){c===t&&(t.admitted=!0)},quiesce(){if(c!==t)return;t.admitted=!1;let n=[...i.values()].filter(r=>r.document==="edit"&&(r.holdsSave||y.has(r.state))).map(r=>r.id);if(n.length)throw ce("a request on this page has not settled","pending-input",n)},resume(){c===t&&(t.admitted=!0)},dispose(){c===t&&(c=null)}}}}}function fe(e,t){return new Promise(n=>{let r=!1,s=()=>{r||(r=!0,document.removeEventListener(e,s),n())};document.addEventListener(e,s),setTimeout(s,t)})}async function pe(){if(!b)return;let e=window.clay;if(!e||typeof e.save!="function")return;let{isSaveInProgress:t}=await import("./core/save-core-MKRPSEEO.js"),{savesHeld:n,saveHoldReason:r}=await import("./core/save-LYY7K6U7.js");if(n())throw new Error(r());let s=Date.now()+W;for(let a=0;a<3;a++){t()&&await fe("clay:save-saved",Math.max(0,s-Date.now()));let u=await e.save();if(u?.ok||u?.msgType==="skipped"&&!t())return;if(u?.msgType==="error"||u?.msgType==="unknown")throw new Error(`could not save this page first: ${u.msg||u.msgType}`);if(Date.now()>=s)break}throw new Error("could not save this page before sending")}async function F(e,t){let n={"Content-Type":"application/json","Page-URL":window.location.href},r=N();r&&(n["Save-Token"]=r);let s=await fetch(H("/_/wire/send"),{method:"POST",headers:n,body:JSON.stringify(e),signal:t}),a=null;try{a=await s.json()}catch{a=null}return{ok:s.ok,status:s.status,reply:a}}function he(e,t={}){let n=typeof t.id=="string"&&t.id?t.id:Q(),r=typeof t.type=="string"&&t.type?t.type:"wire/request",s=Object.prototype.hasOwnProperty.call(t,"helper"),a=s&&typeof t.helper=="string"&&t.helper?t.helper:null,u=t.document===void 0?a?"none":"edit":t.document;if(s&&!a)return _(n,r,null,"helper must be a nonempty string","invalid_helper");if(u!=="edit"&&u!=="none")return _(n,r,a,'document must be "edit" or "none"',"invalid_document");if(i.has(n))return _(n,r,a,"a request with this id is already on the wire","duplicate_request");let o={id:n,type:r,state:"sent",helper:a,document:u,structured:!1,onStatus:typeof t.onStatus=="function"?t.onStatus:null,text:"",result:null,error:null,errorCode:null,errorDetails:null,errorSource:null,startedAt:Date.now(),timer:null,landingTimer:null,abort:typeof AbortController=="function"?new AbortController:null,holdsSave:!1,generation:T().generation,settle:null,signal:t.signal&&typeof t.signal.addEventListener=="function"?t.signal:null,signalHandler:null};return o.done=new Promise(d=>{o.settle=d}),i.set(n,o),m(o),o.signal&&(o.signalHandler=()=>x(n),o.signal.addEventListener("abort",o.signalHandler,{once:!0}),o.signal.aborted&&o.signalHandler()),(async()=>{if(o.state!=="sent")return;if(o.helper){let X=await I(j);if(o.state!=="sent")return;if(!X){l(o,"error","this host does not support named wire helpers",{errorCode:"helper_protocol_unsupported",errorSource:"client"});return}}if(!O(o)||o.document==="edit"&&(await le(o),o.state!=="sent"||!O(o)||(await pe(),o.state!=="sent")||!O(o)))return;if(await ee(),o.state!=="sent"){L();return}v(o,B,"the agent never answered",o.helper?{cancelFirst:!0,errorCode:"ack_timeout"}:void 0);let d={type:o.type,id:o.id,text:t.text,payload:e};o.helper&&(d.helper=o.helper),(o.helper||t.document!==void 0)&&(d.document=o.document);let{ok:G,status:J,reply:S}=await F(d,o.abort?.signal);if(o.state!=="sent")return;if(!G){l(o,"error",`the wire refused this request (${J})`);return}let p=S&&S.refused;if(p&&typeof p.code=="string"&&p.code){l(o,"error",p.message||"the handler refused this request",{errorCode:p.code,errorSource:p.source==="application"?"application":"host",errorDetails:null});return}(!S||S.delivered===0)&&l(o,"error","no agent is attached to this file")})().catch(d=>{l(o,"error",d&&d.message?d.message:String(d))}),{id:n,get state(){return o.state},done:o.done,cancel:()=>x(n)}}function _(e,t,n,r,s){let a={id:e,type:t,state:"error",helper:n,text:"",result:null,error:r,errorCode:s,errorDetails:null,errorSource:"client",startedAt:Date.now()};return{id:e,get state(){return a.state},done:Promise.resolve(w(a)),cancel:()=>!1}}function x(e){let t=i.get(e);return!t||!y.has(t.state)?!1:(z(t),l(t,"cancelled",null),!0)}function z(e){F({type:"wire/cancel",id:e.id}).catch(()=>{})}function ye(e){let t=i.get(e);return t?w(t):void 0}function ge(){return[...i.values()].map(w)}function we(){for(let e of i.values())if(y.has(e.state))return!0;return!1}function me(e){return typeof e!="function"?()=>{}:(k.add(e),()=>k.delete(e))}async function Se(){let e=await A({fresh:!0});if(!e.extensions.includes(j))return[];let t=e.document?.helpers;return Array.isArray(t)?t.filter(n=>n&&typeof n.name=="string"&&["ready","denied","unavailable"].includes(n.state)).map(({name:n,state:r})=>({name:n,state:r})):[]}var ve={send:he,cancel:x,get:ye,list:ge,isBusy:we,on:me,helpers:Se},ke=ve;export{_e as a,ve as b,ke as c};
1
+ import{d as A,e as I}from"./c-XGH4GS2T.js";import{f as b,j as T}from"./c-3O7OBDCM.js";import{c as M}from"./c-BPF2NSPV.js";var B=15e3,P=12e4,K=15e3,V=4e3,W=5e3,U=50,y=new Set(["sent","acked"]),R=new Set(["done","error","cancelled"]),j="wire",a=new Map,k=new Set,f=null,g=null,D=0,h=null;function Q(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`page-${Date.now()}-${Math.random().toString(16).slice(2)}`}function H(e){return new URL(e,window.location.origin).href}function N(){let e=M();return typeof e=="string"&&e!==""?e:null}function w(e){return{id:e.id,type:e.type,state:e.state,helper:e.helper,text:e.text,result:e.result,error:e.error,errorCode:e.errorCode,errorDetails:e.errorDetails,errorSource:e.errorSource,startedAt:e.startedAt}}function m(e,t){let n=w(e);for(let r of k)try{r(n,t||null)}catch(s){console.error("clay.wire: a listener threw",s)}document.dispatchEvent(new CustomEvent("clay:wire-state",{detail:n}))}function Y(e,t){e.state!==t&&(e.state=t,m(e))}function v(e,t,n,{cancelFirst:r=!1,errorCode:s=null}={}){clearTimeout(e.timer),e.timer=setTimeout(()=>{e.timer=null,r&&z(e),l(e,"error",n,{errorCode:s,errorSource:"client"})},t)}function q(e){clearTimeout(e.timer),e.timer=null}function Z(){if(!(a.size<=U))for(let[e,t]of a){if(a.size<=U)break;!y.has(t.state)&&t.state!=="landing"&&a.delete(e)}}function ee(){if(g)return g;let e=N(),t=`/_/wire/subscribe?page-url=${encodeURIComponent(window.location.href)}`+(e?`&token=${encodeURIComponent(e)}`:"");return f=new EventSource(H(t)),f.onmessage=n=>{let r;try{r=JSON.parse(n.data)}catch{return}te(r)},f.onerror=()=>{},g=new Promise(n=>{let r=!1,s=()=>{r||(r=!0,n())};f.onopen=s,setTimeout(s,2e3)}),g}function L(){for(let e of a.values())if(y.has(e.state))return;f&&(f.close(),f=null,g=null)}function te(e){if(!e||typeof e.id!="string")return;let t=a.get(e.id);if(!(!t||!y.has(t.state)))switch(e.type){case"wire/ack":e.payload?.mode==="jsonl"&&Number.isFinite(e.payload.budgetMs)&&e.payload.budgetMs>0?(t.structured=!0,v(t,e.payload.budgetMs+K,"the helper did not finish within its execution budget",{cancelFirst:!0,errorCode:"helper_timeout"})):v(t,P,"the agent stopped responding"),Y(t,"acked");break;case"wire/status":t.structured||v(t,P,"the agent stopped responding"),t.text=typeof e.text=="string"?e.text:"",t.state="acked",ne(t,e),m(t,e);break;case"wire/done":t.result=Object.prototype.hasOwnProperty.call(e,"payload")?e.payload:null,t.document==="edit"?ie(t):l(t,"done",null);break;case"wire/error":re(t,e);break;default:break}}function ne(e,t){if(!e.onStatus||typeof t.text!="string")return;let n={text:t.text};t.payload&&typeof t.payload=="object"&&Object.prototype.hasOwnProperty.call(t.payload,"progress")&&(n.progress=t.payload.progress);try{e.onStatus(n)}catch(r){console.error("clay.wire: an onStatus listener threw",r)}}function re(e,t){let n=t.payload,r=n&&typeof n=="object"&&!Array.isArray(n)&&(n.source==="application"||n.source==="host")&&typeof n.code=="string"&&n.code,s=typeof t.text=="string"&&t.text?t.text:"the handler reported an error";if(!r){l(e,"error",s);return}let i=n.source==="host"&&n.code==="helper_cancelled"?"cancelled":"error";l(e,i,s,{errorCode:n.code,errorDetails:Object.prototype.hasOwnProperty.call(n,"details")?n.details:null,errorSource:n.source})}function oe(){h||(h=e=>{if(e.detail?.source!=="peer"){for(let t of a.values())if(t.state==="landing"){l(t,"done",null);return}}},document.addEventListener("clay:sync-applied",h))}function se(){D>0||!h||(document.removeEventListener("clay:sync-applied",h),h=null)}function ie(e){R.has(e.state)||e.state==="landing"||(q(e),e.state="landing",D++,oe(),e.landingTimer=setTimeout(()=>{l(e,"done",null)},V),m(e),L())}function l(e,t,n,r={}){if(R.has(e.state))return;let s=e.state==="landing";if(q(e),clearTimeout(e.landingTimer),e.landingTimer=null,e.abort?.abort(),s&&(D--,se()),e.error=n,Object.prototype.hasOwnProperty.call(r,"errorCode")&&(e.errorCode=r.errorCode),Object.prototype.hasOwnProperty.call(r,"errorDetails")&&(e.errorDetails=r.errorDetails),Object.prototype.hasOwnProperty.call(r,"errorSource")&&(e.errorSource=r.errorSource),e.state=t,e.signal&&e.signalHandler&&(e.signal.removeEventListener("abort",e.signalHandler),e.signalHandler=null),ue(e),m(e),L(),Z(),e.settle){let i=e.settle;e.settle=null,i(w(e))}}var C=0,$=null,E=null;function ae(){return E||(E=import("./core/save-AOJBDSOK.js")),E}async function le(e){if(!b||e.holdsSave)return;let t=await ae();e.state==="sent"&&($=t,e.holdsSave=!0,!(C++>0)&&t.suspendAutosave())}function ue(e){e.holdsSave&&(e.holdsSave=!1,!(--C>0)&&(C=0,$?.resumeAutosave()))}var c=null,de=()=>!c||c.admitted,ce=(e,t,n)=>Object.assign(new Error(`clay.wire: ${e}`),{code:t,pending:n});function O(e){return e.document!=="edit"||e.generation===T().generation&&de()?!0:(l(e,"error","the page changed mode before this request went out",{errorCode:"stale-document",errorSource:"client"}),!1)}function _e(){return{id:"clay:wire",order:900,prepare(e={}){let t={admitted:e.initial===!0};return c=t,{enable(){c===t&&(t.admitted=!0)},quiesce(){if(c!==t)return;t.admitted=!1;let n=[...a.values()].filter(r=>r.document==="edit"&&(r.holdsSave||y.has(r.state))).map(r=>r.id);if(n.length)throw ce("a request on this page has not settled","pending-input",n)},resume(){c===t&&(t.admitted=!0)},dispose(){c===t&&(c=null)}}}}}function fe(e,t){return new Promise(n=>{let r=!1,s=()=>{r||(r=!0,document.removeEventListener(e,s),n())};document.addEventListener(e,s),setTimeout(s,t)})}async function pe(){if(!b)return;let e=window.clay;if(!e||typeof e.save!="function")return;let{isSaveInProgress:t}=await import("./core/save-core-IOCMXO5L.js"),{savesHeld:n,saveHoldReason:r}=await import("./core/save-AOJBDSOK.js");if(n())throw new Error(r());let s=Date.now()+W;for(let i=0;i<3;i++){t()&&await fe("clay:save-saved",Math.max(0,s-Date.now()));let u=await e.save();if(u?.ok||u?.msgType==="skipped"&&!t())return;if(u?.msgType==="error"||u?.msgType==="unknown")throw new Error(`could not save this page first: ${u.msg||u.msgType}`);if(Date.now()>=s)break}throw new Error("could not save this page before sending")}async function F(e,t){let n={"Content-Type":"application/json","Page-URL":window.location.href},r=N();r&&(n["Save-Token"]=r);let s=await fetch(H("/_/wire/send"),{method:"POST",headers:n,body:JSON.stringify(e),signal:t}),i=null;try{i=await s.json()}catch{i=null}return{ok:s.ok,status:s.status,reply:i}}function he(e,t={}){let n=typeof t.id=="string"&&t.id?t.id:Q(),r=typeof t.type=="string"&&t.type?t.type:"wire/request",s=Object.prototype.hasOwnProperty.call(t,"helper"),i=s&&typeof t.helper=="string"&&t.helper?t.helper:null,u=t.document===void 0?i?"none":"edit":t.document;if(s&&!i)return _(n,r,null,"helper must be a nonempty string","invalid_helper");if(u!=="edit"&&u!=="none")return _(n,r,i,'document must be "edit" or "none"',"invalid_document");if(a.has(n))return _(n,r,i,"a request with this id is already on the wire","duplicate_request");let o={id:n,type:r,state:"sent",helper:i,document:u,structured:!1,onStatus:typeof t.onStatus=="function"?t.onStatus:null,text:"",result:null,error:null,errorCode:null,errorDetails:null,errorSource:null,startedAt:Date.now(),timer:null,landingTimer:null,abort:typeof AbortController=="function"?new AbortController:null,holdsSave:!1,generation:T().generation,settle:null,signal:t.signal&&typeof t.signal.addEventListener=="function"?t.signal:null,signalHandler:null};return o.done=new Promise(d=>{o.settle=d}),a.set(n,o),m(o),o.signal&&(o.signalHandler=()=>x(n),o.signal.addEventListener("abort",o.signalHandler,{once:!0}),o.signal.aborted&&o.signalHandler()),(async()=>{if(o.state!=="sent")return;if(o.helper){let X=await I(j);if(o.state!=="sent")return;if(!X){l(o,"error","this host does not support named wire helpers",{errorCode:"helper_protocol_unsupported",errorSource:"client"});return}}if(!O(o)||o.document==="edit"&&(await le(o),o.state!=="sent"||!O(o)||(await pe(),o.state!=="sent")||!O(o)))return;if(await ee(),o.state!=="sent"){L();return}v(o,B,"the agent never answered",o.helper?{cancelFirst:!0,errorCode:"ack_timeout"}:void 0);let d={type:o.type,id:o.id,text:t.text,payload:e};o.helper&&(d.helper=o.helper),(o.helper||t.document!==void 0)&&(d.document=o.document);let{ok:G,status:J,reply:S}=await F(d,o.abort?.signal);if(o.state!=="sent")return;if(!G){l(o,"error",`the wire refused this request (${J})`);return}let p=S&&S.refused;if(p&&typeof p.code=="string"&&p.code){l(o,"error",p.message||"the handler refused this request",{errorCode:p.code,errorSource:p.source==="application"?"application":"host",errorDetails:null});return}(!S||S.delivered===0)&&l(o,"error",o.helper?`The local program "${o.helper}" is not connected to this file.`:"No program is connected to this file.")})().catch(d=>{l(o,"error",d&&d.message?d.message:String(d))}),{id:n,get state(){return o.state},done:o.done,cancel:()=>x(n)}}function _(e,t,n,r,s){let i={id:e,type:t,state:"error",helper:n,text:"",result:null,error:r,errorCode:s,errorDetails:null,errorSource:"client",startedAt:Date.now()};return{id:e,get state(){return i.state},done:Promise.resolve(w(i)),cancel:()=>!1}}function x(e){let t=a.get(e);return!t||!y.has(t.state)?!1:(z(t),l(t,"cancelled",null),!0)}function z(e){F({type:"wire/cancel",id:e.id}).catch(()=>{})}function ye(e){let t=a.get(e);return t?w(t):void 0}function ge(){return[...a.values()].map(w)}function we(){for(let e of a.values())if(y.has(e.state))return!0;return!1}function me(e){return typeof e!="function"?()=>{}:(k.add(e),()=>k.delete(e))}async function Se(){let e=await A({fresh:!0});if(!e.extensions.includes(j))return[];let t=e.document?.helpers;return Array.isArray(t)?t.filter(n=>n&&typeof n.name=="string"&&["ready","denied","unavailable"].includes(n.state)).map(({name:n,state:r})=>({name:n,state:r})):[]}var ve={send:he,cancel:x,get:ye,list:ge,isBusy:we,on:me,helpers:Se},ke=ve;export{_e as a,ve as b,ke as c};
@@ -0,0 +1 @@
1
+ import{b as E,c as g,d as c,e as f,f as v}from"./c-WRBKEJD4.js";var w=['[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]"],N=["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"],u=w.join(","),_=new RegExp("^(?:"+N.join("|")+")(?:-|$)");function X(e){if(!(!e||!e.querySelectorAll))try{for(let a of e.querySelectorAll(u))a.remove();let t=a=>{let r=a.attributes;if(!r)return;let n=null;for(let s=0;s<r.length;s++){let o=r[s].name;_.test(o.toLowerCase())&&(n||(n=[])).push(o)}if(n)for(let s of n)a.removeAttribute(s)};t(e);for(let a of e.querySelectorAll("*"))t(a)}catch(t){typeof console<"u"&&console.warn("[clay] stripExtensionNoise skipped:",t)}}var l={FULL:"full",FROZEN:"frozen",NONE:"none"},k=["no-save","no-trigger-autosave","no-dirty","no-undo","no-watch","no-data","freeze","editor-ui","live"],A=[...E,"no-copy","no-copy-unless:paid-forms"],i=g;function z(e,t){let a=new Set((e.getAttribute("clay")||"").trim().split(/\s+/).filter(Boolean));a.has(t)||(a.add(t),e.setAttribute("clay",Array.from(a).join(" ")))}var T=`${f("save")}, [save-remove]`,y='[clay~="freeze"], [freeze], [save-freeze]',h='[clay~="no-save"], [clay~="no-trigger-autosave"], [clay~="no-dirty"], [clay~="freeze"], [clay~="no-watch"], [no-save], [save-remove], [no-trigger-autosave], [no-dirty], [save-ignore], [freeze], [save-freeze], [no-watch], [mutations-ignore], [clay~="live"]',x='[clay~="no-trigger-autosave"], [no-trigger-autosave]',j='[clay~="live"]',R='[clay~="no-dirty"], [no-dirty], [save-ignore]',S='[clay~="no-save"], [clay~="no-dirty"], [clay~="freeze"], [clay~="no-watch"], [no-save], [save-remove], [no-dirty], [save-ignore], [freeze], [save-freeze], [no-watch], [mutations-ignore], [clay~="live"]',p=`${f("snapshot")}, [snapshot-remove]`,O=f("data");function I(e){let t=m(e);return!!(t&&t.closest&&t.closest(p))}function b(e){return v(e,"data")}var d={full:0,frozen:1,none:2},C=["full","frozen","none"];function m(e){return e&&e.nodeType!==1?e.parentElement:e}function L(e){let t=m(e);if(t&&t.closest&&t.closest(u))return{watched:!1,autosaveTriggered:!1,dirtyTracked:!1,undoable:!1,persist:l.FULL,extension:!0};let a=!0,r=!0,n=!1,s=!1,o=0;for(;t&&t.nodeType===1;)t.hasAttribute&&(c(t,"no-watch")&&(a=!1),i(t,"no-trigger-autosave")&&(n=!0),i(t,"no-dirty")&&(n=!0,s=!0),i(t,"live")&&(n=!0,s=!0,r=!1),c(t,"no-undo")&&(r=!1),c(t,"no-save")&&(o=Math.max(o,d.none)),i(t,"freeze")&&(o=Math.max(o,d.frozen)),i(t,"mutations-ignore")&&(a=!1),i(t,"save-remove")&&(o=Math.max(o,d.none),r=!1),i(t,"save-ignore")&&(n=!0,s=!0,r=!1),i(t,"save-freeze")&&(o=Math.max(o,d.frozen),r=!1)),t=t.parentElement;return a||(n=!0,r=!1,s=!0),o>0&&(n=!0,s=!0),{watched:a,autosaveTriggered:!n,dirtyTracked:!s,undoable:r,persist:C[o],extension:!1}}function P(e){let t=m(e);if(t&&t.closest&&t.closest(u))return!0;for(;t&&t.nodeType===1;){if(t.hasAttribute&&(c(t,"no-watch")||i(t,"mutations-ignore")))return!0;t=t.parentElement}return!1}function F(e,t){return{watched:e.watched&&t.watched,autosaveTriggered:e.autosaveTriggered&&t.autosaveTriggered,dirtyTracked:e.dirtyTracked&&t.dirtyTracked,undoable:e.undoable&&t.undoable,persist:d[e.persist]>=d[t.persist]?e.persist:t.persist,extension:e.extension||t.extension}}var D={"no-watch":e=>!e.watched,"mutations-ignore":e=>!e.watched,"no-save":e=>e.persist===l.NONE,"save-remove":e=>e.persist===l.NONE,freeze:e=>e.persist===l.FROZEN,"save-freeze":e=>e.persist===l.FROZEN,"no-trigger-autosave":e=>!e.autosaveTriggered,"no-dirty":e=>!e.dirtyTracked,"save-ignore":e=>!e.dirtyTracked,"no-undo":e=>!e.undoable};function M(e,t,a){if(e.extension)return!0;if(a&&a.length)return a.some(r=>D[r]?.(e)||!1);switch(t){case"observed":return!e.watched;case"autosave":return!e.autosaveTriggered;case"dirty":return!e.dirtyTracked;case"undo":return!e.undoable;default:return!e.watched||!e.autosaveTriggered||e.persist!==l.FULL}}var K={resolveRegionPolicy:L,isInert:P,isSnapshotRemoved:I,isDataExcluded:b,skipForPolicy:M,strictestPolicy:F,addRegionToken:z,PERSIST:l,TOKENS:A,REGION_ATTRS:k,STRIP_FROM_SAVE:T,STRIP_FROM_COMPARISON:h,STRIP_FROM_DIRTY_CHECK:S,NO_TRIGGER_AUTOSAVE_SELECTOR:x,NO_DIRTY_SELECTOR:R,SNAPSHOT_REMOVE_SELECTOR:p,NO_DATA_SELECTOR:O,FREEZE_SELECTOR:y,selectors:{stripFromSave:T,stripFromComparison:h,stripFromDirtyCheck:S,noTriggerAutosave:x,noDirty:R,snapshotRemove:p,noData:O,freeze:y}},q=K;export{u as a,_ as b,X as c,l as d,k as e,A as f,z as g,T as h,y as i,h as j,x as k,j as l,R as m,S as n,p as o,O as p,I as q,b as r,L as s,P as t,F as u,M as v,K as w,q as x};
@@ -1 +1 @@
1
- import{a as j}from"./c-UGNV5MFB.js";import{b as S,c as A,f as C,i as l,j as P,l as L,n as B}from"./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";var y=0,x=[],b=[],d=null,I=!1,E=!1,v=null,M=null,$=15e3,u=()=>P().mode,p=(e,t)=>Object.assign(new Error(`clay.modeLifecycle: ${e}`),{code:t});function U(){document.dispatchEvent(new Event("clay:modechange"))}function h(e,t="idle",o={}){return l({phase:t,reason:e}),{ok:!1,mode:u(),code:e,...o}}function k(e){for(let t of[...e].reverse())try{t.dispose?.()}catch{}}function D(e){try{e?.reclaimArticle?.()}catch{}try{e?.resume?.()}catch{}}function O(e){document.documentElement.setAttribute("editmode",e?"true":"false")}function G(){try{let e=new URL(window.location.href);if(!e.searchParams.has("editmode"))return;e.searchParams.delete("editmode"),window.history.replaceState(window.history.state,"",`${e.pathname}${e.search}${e.hash}`)}catch(e){console.warn("clayjs: the URL could not be rewritten after the mode switch",e)}}var N=e=>[...e?.edit?.core??[],...e?.edit?.plugins??[],...e?.edit?.late??[]];function X(e){let t=[];for(let o of N(e)){let n=j(o);if(n!=="export"&&typeof n!="function")continue;let r=e.loaded?.[o];r&&t.push(typeof n=="function"?n(r):r.modeParticipant?.())}return t}async function _(e){let t=new Set(b.map(({id:n})=>n)),o=n=>{if(typeof n?.id!="string"||typeof n.prepare!="function")throw p("a participant needs an id and a prepare()","unsupported-plugin");t.has(n.id)||(t.add(n.id),b.push(n))};if(e)for(let n of X(e))o(await n);for(let n of B())o(await n);return[...b].sort((n,r)=>(n.order??0)-(r.order??0))}function z(e){let t=b.findIndex(o=>o.id===e);t!==-1&&b.splice(t,1)}L(z);function H(e,t){if(!e||e.bytes===null)return!1;let o=t??{};return typeof e.seq=="number"&&typeof o.seq=="number"&&e.seq!==o.seq?e.seq>o.seq:(e.etag??null)!==(o.etag??null)}async function V(e=null){let t=u(),o=C,n=new AbortController,r={generation:++y,destination:P().destination,signal:n.signal,represented:null,reader:null,initial:!1,isCurrent:()=>r.generation===y&&!n.signal.aborted};l({phase:"entering",generation:r.generation,reason:null}),e||(I=!0,E=!1,v=null);let s=[],c=[],f=null,i=null,w=!1,m=(async()=>{try{if(e){let a=await import("./c-KJJPV77R.js");i=await a.prepareReader(e,r),c.push(...await a.importPlan(e,e.edit,{signal:n.signal})),await i?.reconcile(),r.represented=i?i.represented:null,r.reader=i,M=r.represented}f=e?.loaded?.["core/save.js"]??await import("./core/save-LYY7K6U7.js");for(let a of await _(e)){w=!0;let g=await a.prepare(r);if(g){if(s.push(g),!r.isCurrent())throw p(`"${a.id}" prepared for a stale generation`,"stale-document");if(g.ready&&await g.ready,!r.isCurrent())throw p(`"${a.id}" became ready for a stale generation`,"stale-document")}}if(e||!o){let a=f.adoptEntryBaseline({represented:r.represented});if(a&&a.ok===!1)throw Object.assign(p("the page moved since the last session",a.code||"pending-input"),a);if(H(i?.held??i?.represented,r.represented))throw p("the reader holds a newer file than the session was built from","stale-document")}return!0}catch(a){throw k(s),a}})(),q=null,W=new Promise(a=>{q=setTimeout(()=>{n.abort(),a(!1)},$)}),T;try{T=await Promise.race([m,W])}catch(a){return clearTimeout(q),n.abort(),w?(D(i),h(a?.code||"load-failed","blocked",{message:a?.message})):(D(i),l({phase:"idle",reason:null}),null)}if(clearTimeout(q),!T)return m.catch(()=>{}),k(s.splice(0)),D(i),h("timeout");i?.commit(),l({mode:S?"draft":"edit",isEditMode:!0}),e&&G(),O(!0),f?.setSaveGeneration(r.generation);try{for(let a of s)a.enable()}catch(a){return l({mode:t,isEditMode:o}),O(!1),k(s),n.abort(),e&&(await import("./c-KJJPV77R.js").catch(()=>null))?.startReader(e,M),h(a?.code||"load-failed","blocked",{message:a?.message})}x=s,l({phase:"idle",reason:null}),U();for(let a of c)e?.announce?.(a);return{ok:!0,mode:u(),changed:t!==u()}}async function J(e){if(!e)return[];let t=[];for(let r of N(e)){let s=j(r);if(s!=="export"&&typeof s!="function")continue;let c=e.loaded?.[r];if(!c)continue;let f=await(typeof s=="function"?s(c):c.modeParticipant?.());if(typeof f?.id!="string"||typeof f.prepare!="function")return null;t.push(f)}t.sort((r,s)=>(r.order??0)-(s.order??0));let o=[],n={generation:y,destination:P().destination,signal:void 0,represented:null,reader:null,initial:!0,isCurrent:()=>!0};for(let r of t){let s=null;try{s=await r.prepare(n)}catch{return null}s&&o.push(s)}return o}async function K(e){return(e?.loaded?.["core/save.js"]??await import("./core/save-LYY7K6U7.js").catch(()=>null))?.acceptedReceipt?.(y)??null}var R=Symbol("the exit deadline passed");function Q(){let e=null,t=Date.now()+$;return{expired:new Promise(n=>{e=setTimeout(()=>n(R),$)}),remaining:()=>Math.max(0,t-Date.now()),clear:()=>clearTimeout(e)}}async function Y(e,t){if(!e)return;let n=(await import("./c-KJJPV77R.js")).importPlan(e,e.view);n.catch(()=>{});let r=await Promise.race([n.then(()=>null,s=>s),t]);if(r&&r!==R)throw r}async function Z(e=null){let t=Q();try{return await ee(e,t)}finally{t.clear()}}async function ee(e,t){let o=I;l({phase:"leaving"});let n=await import("./c-U7SHNWDH.js").catch(()=>null);if(!n)return h("load-failed");let r=x;if(o&&!E){v??=J(e);let i=await Promise.race([v,t.expired]);if(i===R)return h("timeout");if(!i)return v=null,l({phase:"idle",reason:null}),null;E=!0,r=[...i,...r],x=r}try{await Y(e,t.expired)}catch(i){return h(i?.code||"load-failed","idle",{message:i?.message})}let s=[],c=null;try{if(c=n.claimOperation("mode"),!c)throw p("another document operation is in progress","busy");for(let w of[...r].reverse()){s.push(w);let m=await Promise.race([Promise.resolve(w.quiesce?.()),t.expired]);if(m===R)throw p("the exit deadline passed while a lease quiesced","timeout");if(m&&m.ok===!1)throw Object.assign(p("a lease refused the exit",m.code||"pending-input"),m)}let i=await n.runSaveBarrier({operation:c,timeoutMs:t.remaining()});if(!i.ok)throw Object.assign(p("the exit barrier refused",i.code||"save-failed"),i)}catch(i){for(let w of[...s].reverse())try{w.resume?.()}catch{}return l({phase:"idle",reason:i?.code||"save-failed"}),{ok:!1,mode:u(),code:i?.code||"save-failed",state:i?.state,pending:i?.pending}}finally{c&&n.releaseOperation(c)}k(r),x=[],I=!1,E=!1,v=null;let f=await K(e)??M;return M=null,e&&(await import("./c-KJJPV77R.js").catch(()=>null))?.startReader(e,f),y++,O(!1),l({mode:"view",isEditMode:!1,phase:"idle",generation:y,reason:null}),G(),U(),{ok:!0,mode:"view",changed:!0}}function F(e,t=null){if(e!=="edit"&&e!=="view")throw new TypeError(`clay.modeLifecycle: unknown mode "${e}"`);if(d)return d.target===e?d.promise:{ok:!1,mode:u(),code:"busy"};if(e===u())return{ok:!0,mode:u(),changed:!1};if(S||e==="edit"&&!A)return{ok:!1,mode:u(),code:"not-allowed"};let o=(e==="edit"?V(t):Z(t)).finally(()=>{d=null});return d={target:e,promise:o},o}async function re(e,t){let o=await import("./c-KJJPV77R.js").catch(()=>null);return!o||!o.liveAllowed(t)?null:(d||e===u()||e==="edit"&&o.openResources(),F(e,t))}async function oe(){if(u()==="view")return{ok:!0,mode:"view",changed:!1};if(d)return d.promise;let e=V().finally(()=>{d=null});return d={target:"edit",promise:e},e}export{oe as activateInitial,z as forgetParticipant,F as requestMode,re as switchMode};
1
+ import{a as j}from"./c-UGNV5MFB.js";import{b as S,c as A,f as C,i as l,j as P,l as L,n as B}from"./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";var y=0,x=[],b=[],d=null,I=!1,E=!1,v=null,M=null,$=15e3,u=()=>P().mode,p=(e,t)=>Object.assign(new Error(`clay.modeLifecycle: ${e}`),{code:t});function U(){document.dispatchEvent(new Event("clay:modechange"))}function h(e,t="idle",o={}){return l({phase:t,reason:e}),{ok:!1,mode:u(),code:e,...o}}function k(e){for(let t of[...e].reverse())try{t.dispose?.()}catch{}}function D(e){try{e?.reclaimArticle?.()}catch{}try{e?.resume?.()}catch{}}function O(e){document.documentElement.setAttribute("editmode",e?"true":"false")}function G(){try{let e=new URL(window.location.href);if(!e.searchParams.has("editmode"))return;e.searchParams.delete("editmode"),window.history.replaceState(window.history.state,"",`${e.pathname}${e.search}${e.hash}`)}catch(e){console.warn("clayjs: the URL could not be rewritten after the mode switch",e)}}var N=e=>[...e?.edit?.core??[],...e?.edit?.plugins??[],...e?.edit?.late??[]];function X(e){let t=[];for(let o of N(e)){let n=j(o);if(n!=="export"&&typeof n!="function")continue;let r=e.loaded?.[o];r&&t.push(typeof n=="function"?n(r):r.modeParticipant?.())}return t}async function _(e){let t=new Set(b.map(({id:n})=>n)),o=n=>{if(typeof n?.id!="string"||typeof n.prepare!="function")throw p("a participant needs an id and a prepare()","unsupported-plugin");t.has(n.id)||(t.add(n.id),b.push(n))};if(e)for(let n of X(e))o(await n);for(let n of B())o(await n);return[...b].sort((n,r)=>(n.order??0)-(r.order??0))}function z(e){let t=b.findIndex(o=>o.id===e);t!==-1&&b.splice(t,1)}L(z);function H(e,t){if(!e||e.bytes===null)return!1;let o=t??{};return typeof e.seq=="number"&&typeof o.seq=="number"&&e.seq!==o.seq?e.seq>o.seq:(e.etag??null)!==(o.etag??null)}async function V(e=null){let t=u(),o=C,n=new AbortController,r={generation:++y,destination:P().destination,signal:n.signal,represented:null,reader:null,initial:!1,isCurrent:()=>r.generation===y&&!n.signal.aborted};l({phase:"entering",generation:r.generation,reason:null}),e||(I=!0,E=!1,v=null);let s=[],c=[],f=null,i=null,w=!1,m=(async()=>{try{if(e){let a=await import("./c-V2J5C5MT.js");i=await a.prepareReader(e,r),c.push(...await a.importPlan(e,e.edit,{signal:n.signal})),await i?.reconcile(),r.represented=i?i.represented:null,r.reader=i,M=r.represented}f=e?.loaded?.["core/save.js"]??await import("./core/save-AOJBDSOK.js");for(let a of await _(e)){w=!0;let g=await a.prepare(r);if(g){if(s.push(g),!r.isCurrent())throw p(`"${a.id}" prepared for a stale generation`,"stale-document");if(g.ready&&await g.ready,!r.isCurrent())throw p(`"${a.id}" became ready for a stale generation`,"stale-document")}}if(e||!o){let a=f.adoptEntryBaseline({represented:r.represented});if(a&&a.ok===!1)throw Object.assign(p("the page moved since the last session",a.code||"pending-input"),a);if(H(i?.held??i?.represented,r.represented))throw p("the reader holds a newer file than the session was built from","stale-document")}return!0}catch(a){throw k(s),a}})(),q=null,W=new Promise(a=>{q=setTimeout(()=>{n.abort(),a(!1)},$)}),T;try{T=await Promise.race([m,W])}catch(a){return clearTimeout(q),n.abort(),w?(D(i),h(a?.code||"load-failed","blocked",{message:a?.message})):(D(i),l({phase:"idle",reason:null}),null)}if(clearTimeout(q),!T)return m.catch(()=>{}),k(s.splice(0)),D(i),h("timeout");i?.commit(),l({mode:S?"draft":"edit",isEditMode:!0}),e&&G(),O(!0),f?.setSaveGeneration(r.generation);try{for(let a of s)a.enable()}catch(a){return l({mode:t,isEditMode:o}),O(!1),k(s),n.abort(),e&&(await import("./c-V2J5C5MT.js").catch(()=>null))?.startReader(e,M),h(a?.code||"load-failed","blocked",{message:a?.message})}x=s,l({phase:"idle",reason:null}),U();for(let a of c)e?.announce?.(a);return{ok:!0,mode:u(),changed:t!==u()}}async function J(e){if(!e)return[];let t=[];for(let r of N(e)){let s=j(r);if(s!=="export"&&typeof s!="function")continue;let c=e.loaded?.[r];if(!c)continue;let f=await(typeof s=="function"?s(c):c.modeParticipant?.());if(typeof f?.id!="string"||typeof f.prepare!="function")return null;t.push(f)}t.sort((r,s)=>(r.order??0)-(s.order??0));let o=[],n={generation:y,destination:P().destination,signal:void 0,represented:null,reader:null,initial:!0,isCurrent:()=>!0};for(let r of t){let s=null;try{s=await r.prepare(n)}catch{return null}s&&o.push(s)}return o}async function K(e){return(e?.loaded?.["core/save.js"]??await import("./core/save-AOJBDSOK.js").catch(()=>null))?.acceptedReceipt?.(y)??null}var R=Symbol("the exit deadline passed");function Q(){let e=null,t=Date.now()+$;return{expired:new Promise(n=>{e=setTimeout(()=>n(R),$)}),remaining:()=>Math.max(0,t-Date.now()),clear:()=>clearTimeout(e)}}async function Y(e,t){if(!e)return;let n=(await import("./c-V2J5C5MT.js")).importPlan(e,e.view);n.catch(()=>{});let r=await Promise.race([n.then(()=>null,s=>s),t]);if(r&&r!==R)throw r}async function Z(e=null){let t=Q();try{return await ee(e,t)}finally{t.clear()}}async function ee(e,t){let o=I;l({phase:"leaving"});let n=await import("./c-3YH6JSIL.js").catch(()=>null);if(!n)return h("load-failed");let r=x;if(o&&!E){v??=J(e);let i=await Promise.race([v,t.expired]);if(i===R)return h("timeout");if(!i)return v=null,l({phase:"idle",reason:null}),null;E=!0,r=[...i,...r],x=r}try{await Y(e,t.expired)}catch(i){return h(i?.code||"load-failed","idle",{message:i?.message})}let s=[],c=null;try{if(c=n.claimOperation("mode"),!c)throw p("another document operation is in progress","busy");for(let w of[...r].reverse()){s.push(w);let m=await Promise.race([Promise.resolve(w.quiesce?.()),t.expired]);if(m===R)throw p("the exit deadline passed while a lease quiesced","timeout");if(m&&m.ok===!1)throw Object.assign(p("a lease refused the exit",m.code||"pending-input"),m)}let i=await n.runSaveBarrier({operation:c,timeoutMs:t.remaining()});if(!i.ok)throw Object.assign(p("the exit barrier refused",i.code||"save-failed"),i)}catch(i){for(let w of[...s].reverse())try{w.resume?.()}catch{}return l({phase:"idle",reason:i?.code||"save-failed"}),{ok:!1,mode:u(),code:i?.code||"save-failed",state:i?.state,pending:i?.pending}}finally{c&&n.releaseOperation(c)}k(r),x=[],I=!1,E=!1,v=null;let f=await K(e)??M;return M=null,e&&(await import("./c-V2J5C5MT.js").catch(()=>null))?.startReader(e,f),y++,O(!1),l({mode:"view",isEditMode:!1,phase:"idle",generation:y,reason:null}),G(),U(),{ok:!0,mode:"view",changed:!0}}function F(e,t=null){if(e!=="edit"&&e!=="view")throw new TypeError(`clay.modeLifecycle: unknown mode "${e}"`);if(d)return d.target===e?d.promise:{ok:!1,mode:u(),code:"busy"};if(e===u())return{ok:!0,mode:u(),changed:!1};if(S||e==="edit"&&!A)return{ok:!1,mode:u(),code:"not-allowed"};let o=(e==="edit"?V(t):Z(t)).finally(()=>{d=null});return d={target:e,promise:o},o}async function re(e,t){let o=await import("./c-V2J5C5MT.js").catch(()=>null);return!o||!o.liveAllowed(t)?null:(d||e===u()||e==="edit"&&o.openResources(),F(e,t))}async function oe(){if(u()==="view")return{ok:!0,mode:"view",changed:!1};if(d)return d.promise;let e=V().finally(()=>{d=null});return d={target:"edit",promise:e},e}export{oe as activateInitial,z as forgetParticipant,F as requestMode,re as switchMode};
@@ -1 +1 @@
1
- import{a as T,b as x,c as m,d as D,e as P}from"./c-IW6GGOU2.js";import{a as y}from"./c-HAWFNBYG.js";import{b}from"./c-QIXT3Q7C.js";import{a as f}from"./c-ZWIOJGMT.js";var E="\uFFFC";function g(t){let r=[];for(let s=0;s<t.childCount;s++){let n=t.child(s);if(n.type.name!=="heading"||n.attrs.level!==1||(n.attrs.parent??null)!==null)continue;let o="";n.forEach(l=>{o+=l.isText?l.text:l.type.name==="hard_break"?E:""}),r.push({t:"heading",level:1,parent:null,c:o});break}return r}function d(t){if(!t||t.isDestroyed)return null;let r=t.dom?.ownerDocument??(typeof document>"u"?null:document);if(!r)return null;let s=g(t.state.doc),{custom:n,title:o}=P(r,s);if(n)return o;let l=m(r);if(l===""&&!s.length||l===o)return o;f.pause();try{D(r,o)}finally{f.resume()}return o}function L(t){let r=t?.dom?.ownerDocument??null;if(!r||T(r)||g(t.state.doc).length||["",y].includes(m(r).trim()))return!1;f.pause();try{return x(r)}finally{f.resume()}}function C(){return new b.Plugin({view(t){let r=null,s=()=>{r=t.state.doc,d(t)};return L(t),s(),{update(n){n.state.doc!==r&&s()}}}})}function O(t){let r=t?.dom?.ownerDocument?.head??null;if(!r)return{refresh:()=>d(t),dispose(){}};let s=!1,n=()=>{s||(s=!0,queueMicrotask(()=>{s=!1,d(t)}))},o=new MutationObserver(n);return o.observe(r,{childList:!0,characterData:!0,subtree:!0,attributeFilter:["content","name"]}),d(t),{refresh:n,dispose(){o.disconnect()}}}function I({load:t,install:r,reportError:s=n=>console.error("clayjs: an editor feature failed to load",n)}){let n=new Map,o=new Map,l=new Map,c=!1;function v(e){if(c)return Promise.reject(new Error(`page: feature loader disposed before ${e}`));let u=l.get(e);return u||(u=Promise.resolve(t(e)),l.set(e,u),u.catch(()=>{})),u}function F(e){let u=l.get(e);return u?(l.delete(e),u):t(e)}function M(e,{signal:u}={}){if(c)return Promise.reject(new Error(`page: feature loader disposed before ${e}`));if(n.has(e))return Promise.resolve(n.get(e));let i=o.get(e);return i||(i=F(e).then(a=>c?null:Promise.resolve(r(e,a))).then(a=>c?(a?.dispose?.(),a):(n.set(e,a),a)),i.catch(a=>{c||s(a,e)}).finally(()=>o.delete(e)),o.set(e,i)),u?u.aborted?Promise.reject(u.reason):new Promise((a,p)=>{let h=()=>p(u.reason);u.addEventListener("abort",h,{once:!0}),i.then(a,p).finally(()=>u.removeEventListener("abort",h))}):i}return{prepare:v,ensure:M,has:e=>n.has(e),dispose(){c=!0;for(let e of n.values())e?.dispose?.();n.clear(),o.clear(),l.clear()}}}export{C as a,O as b,I as c};
1
+ import{a as T,b as x,c as m,d as D,e as P}from"./c-IW6GGOU2.js";import{a as y}from"./c-HAWFNBYG.js";import{b}from"./c-QIXT3Q7C.js";import{a as f}from"./c-LA2BW7UY.js";var E="\uFFFC";function g(t){let r=[];for(let s=0;s<t.childCount;s++){let n=t.child(s);if(n.type.name!=="heading"||n.attrs.level!==1||(n.attrs.parent??null)!==null)continue;let o="";n.forEach(l=>{o+=l.isText?l.text:l.type.name==="hard_break"?E:""}),r.push({t:"heading",level:1,parent:null,c:o});break}return r}function d(t){if(!t||t.isDestroyed)return null;let r=t.dom?.ownerDocument??(typeof document>"u"?null:document);if(!r)return null;let s=g(t.state.doc),{custom:n,title:o}=P(r,s);if(n)return o;let l=m(r);if(l===""&&!s.length||l===o)return o;f.pause();try{D(r,o)}finally{f.resume()}return o}function L(t){let r=t?.dom?.ownerDocument??null;if(!r||T(r)||g(t.state.doc).length||["",y].includes(m(r).trim()))return!1;f.pause();try{return x(r)}finally{f.resume()}}function C(){return new b.Plugin({view(t){let r=null,s=()=>{r=t.state.doc,d(t)};return L(t),s(),{update(n){n.state.doc!==r&&s()}}}})}function O(t){let r=t?.dom?.ownerDocument?.head??null;if(!r)return{refresh:()=>d(t),dispose(){}};let s=!1,n=()=>{s||(s=!0,queueMicrotask(()=>{s=!1,d(t)}))},o=new MutationObserver(n);return o.observe(r,{childList:!0,characterData:!0,subtree:!0,attributeFilter:["content","name"]}),d(t),{refresh:n,dispose(){o.disconnect()}}}function I({load:t,install:r,reportError:s=n=>console.error("clayjs: an editor feature failed to load",n)}){let n=new Map,o=new Map,l=new Map,c=!1;function v(e){if(c)return Promise.reject(new Error(`page: feature loader disposed before ${e}`));let u=l.get(e);return u||(u=Promise.resolve(t(e)),l.set(e,u),u.catch(()=>{})),u}function F(e){let u=l.get(e);return u?(l.delete(e),u):t(e)}function M(e,{signal:u}={}){if(c)return Promise.reject(new Error(`page: feature loader disposed before ${e}`));if(n.has(e))return Promise.resolve(n.get(e));let i=o.get(e);return i||(i=F(e).then(a=>c?null:Promise.resolve(r(e,a))).then(a=>c?(a?.dispose?.(),a):(n.set(e,a),a)),i.catch(a=>{c||s(a,e)}).finally(()=>o.delete(e)),o.set(e,i)),u?u.aborted?Promise.reject(u.reason):new Promise((a,p)=>{let h=()=>p(u.reason);u.addEventListener("abort",h,{once:!0}),i.then(a,p).finally(()=>u.removeEventListener("abort",h))}):i}return{prepare:v,ensure:M,has:e=>n.has(e),dispose(){c=!0;for(let e of n.values())e?.dispose?.();n.clear(),o.clear(),l.clear()}}}export{C as a,O as b,I as c};
@@ -1,4 +1,4 @@
1
- import{b as a}from"./c-Y6F2FORL.js";import{b as p}from"./c-L7JL5TL3.js";import{a as m}from"./c-2YYDMLNZ.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var h=`html:has(> body > .clay-intro) { height: auto !important; overflow-y: auto !important; }
1
+ import{b as a}from"./c-Y6F2FORL.js";import{b as p}from"./c-QY7F6EN6.js";import{a as m}from"./c-2YYDMLNZ.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var h=`html:has(> body > .clay-intro) { height: auto !important; overflow-y: auto !important; }
2
2
  body:has(> .clay-intro) { height: auto !important; overflow: visible !important; }
3
3
  .clay-intro {
4
4
  position: relative;
@@ -1 +1 @@
1
- import{e as c,f as s}from"./c-Q26MME6N.js";import{k as g,q as u}from"./c-7MG5RU63.js";import{i as l}from"./c-DCFSEJZG.js";var p={debug:!1};function t(...n){p.debug&&console.log("[save-freeze]",...n)}var f=new WeakMap;function m(n,o){f=new WeakMap;let e=n.querySelectorAll(l);t("freezing clone:",e.length);for(let r of e){let a=o.original(r);if(!a)continue;let i=c(a);i!==void 0&&(f.set(r,i),r.innerHTML!==i&&(t("restoring original"),r.innerHTML=i))}}function d(n){for(let o of n.querySelectorAll(l)){let e=f.get(o);e!==void 0&&o.innerHTML!==e&&(t("re-restoring original after prepare-phase change"),o.innerHTML=e)}}function E(){t("init"),s(),g(m),u(d)}E();var h=p;export{h as a};
1
+ import{e as c,f as s}from"./c-TWCXBWS3.js";import{k as g,q as u}from"./c-EGTIAL6P.js";import{i as l}from"./c-ICMAOOGK.js";var p={debug:!1};function t(...n){p.debug&&console.log("[save-freeze]",...n)}var f=new WeakMap;function m(n,o){f=new WeakMap;let e=n.querySelectorAll(l);t("freezing clone:",e.length);for(let r of e){let a=o.original(r);if(!a)continue;let i=c(a);i!==void 0&&(f.set(r,i),r.innerHTML!==i&&(t("restoring original"),r.innerHTML=i))}}function d(n){for(let o of n.querySelectorAll(l)){let e=f.get(o);e!==void 0&&o.innerHTML!==e&&(t("re-restoring original after prepare-phase change"),o.innerHTML=e)}}function E(){t("init"),s(),g(m),u(d)}E();var h=p;export{h as a};
@@ -1,4 +1,4 @@
1
- import{a as j,c as re}from"./c-6DNRCPNM.js";import{a as Le}from"./c-Q3XOWZEV.js";import{a as Me}from"./c-4ASQPRQL.js";import{i as Re}from"./c-B7J4K2AE.js";import{a as Ce}from"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import{a as Ae}from"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import"./c-IJUK2GPW.js";import"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import{b as Y,c as Oe,d as Ie,l as ce,t as fe}from"./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 Et=16384;function Ot(e){let t=new Map,n=e?.onParseError;return{parser:new Le({...e,onParseError:s=>{t.set(s.code,(t.get(s.code)||0)+1),n?.(s)}}),errors:t}}function It(e,t,n,r){let s=Math.min(n+r,t.length);return e.tokenizer.write(t.slice(n,s),s>=t.length),s}function*de(e,t,{chunk:n=Et}={}){let{parser:r,errors:s}=Ot(t),o=0;do o=It(r,e,o,n),o<e.length&&(yield);while(o<e.length);return{document:r.document,errors:s}}var ge=new Set(["script","style","xmp","iframe","noembed","noframes","plaintext","noscript"]),Je=new Set(["textarea","title"]),be=e=>ge.has(e)?"raw":Je.has(e)?"rcdata":"normal",pe=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),$e="http://www.w3.org/1999/xhtml",K=1500,Ct=e=>e.replace(/&/g,"&amp;").replace(/ /g,"&nbsp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),Fe=e=>e.replace(/&/g,"&amp;").replace(/ /g,"&nbsp;").replace(/"/g,"&quot;");function Qe(e){return j(ie(e))}function*ie(e){let{document:t,errors:n}=yield*de(e,{sourceCodeLocationInfo:!0});return We(e,t,n)}function We(e,t,n){let r=t.childNodes.find(l=>l.nodeName==="html"),s=t.childNodes.filter(l=>l!==r).map(l=>l.nodeName==="#documentType"?{kind:"doctype",name:l.name||"",publicId:l.publicId||"",systemId:l.systemId||""}:{kind:l.nodeName==="#comment"?"comment":l.nodeName,value:l.data}),o=r?ze(r,null,e):null;return o&&Ve(o,e),{src:e,doc:t,outside:s,root:o,parseErrors:n,relocated:o?me(o):null,movedIn:o?me(o,"movedIn"):null,tailOwner:o?He(o):null}}function ze(e,t,n){let r=e.sourceCodeLocation||null,s=e.nodeName==="#text"?"text":e.nodeName==="#comment"?"comment":"element",o={node:e,parent:t,live:null,kind:s,children:[],from:r?r.startOffset:-1,to:r?r.endOffset:-1};if(s==="text")return o.value=e.value,o;if(s==="comment")return o.value=e.data,o;o.tag=e.tagName,o.located=!!(r&&r.startTag),o.openFrom=o.located?r.startTag.startOffset:-1,o.openTo=o.located?r.startTag.endOffset:-1,o.closeFrom=r&&r.endTag?r.endTag.startOffset:o.located?o.to:-1,o.closeTo=r&&r.endTag?r.endTag.endOffset:o.located?o.to:-1,o.endTagged=!!(r&&r.endTag),o.located&&(o.to<o.openTo&&(o.to=o.openTo),o.closeFrom<o.openTo&&(o.closeFrom=o.closeTo=o.openTo)),o.attrs=[];let l=o.located&&r.startTag.attrs||r&&r.attrs||{};for(let a of e.attrs){let g=a.prefix?a.prefix+":"+a.name:a.name,c=l[g.toLowerCase()];o.attrs.push({name:g,key:g.toLowerCase(),value:a.value,from:c?c.startOffset:-1,to:c?c.endOffset:-1})}let d=e.nodeName==="template"&&e.content?e.content.childNodes:e.childNodes;for(let a of d)a.nodeName!=="#documentType"&&o.children.push(ze(a,o,n));if(!o.located){let a=o.children.filter(p=>p.from>=0),g=a.length?Math.min(...a.map(p=>p.from)):-1,c=a.length?Math.max(...a.map(p=>p.to)):-1;o.openFrom=o.openTo=g,o.closeFrom=o.closeTo=c,o.from=g,o.to=c}return o}function Ve(e,t,n=1/0){if(e.kind!=="element")return;for(let o of e.children){if(o.from>=n&&!(o.kind==="text"&&!/\S/.test(o.value))&&(e.movedIn=!0),o.from>=0&&e.located){let l=Math.max(e.openTo,Math.min(o.to,e.closeFrom)),d=Math.min(Math.max(o.from,e.openTo),l);if(d!==o.from||l!==o.to){if(o.kind==="text"&&!ge.has(e.tag)&&!Je.has(e.tag)){let a=t.slice(l,o.to).replace(/<!--[\s\S]*?-->|<[^>]*>/g,"").replace(/\r\n?/g,`
1
+ import{a as j,c as re}from"./c-6DNRCPNM.js";import{a as Re}from"./c-Q3XOWZEV.js";import{a as Le}from"./c-4ASQPRQL.js";import{i as Me}from"./c-GVPNDIKJ.js";import{a as Ce}from"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import{a as Ae}from"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import"./c-IJUK2GPW.js";import"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import{b as Y,c as Oe,d as Ie,l as ce,t as fe}from"./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 Et=16384;function Ot(e){let t=new Map,n=e?.onParseError;return{parser:new Re({...e,onParseError:s=>{t.set(s.code,(t.get(s.code)||0)+1),n?.(s)}}),errors:t}}function It(e,t,n,r){let s=Math.min(n+r,t.length);return e.tokenizer.write(t.slice(n,s),s>=t.length),s}function*de(e,t,{chunk:n=Et}={}){let{parser:r,errors:s}=Ot(t),o=0;do o=It(r,e,o,n),o<e.length&&(yield);while(o<e.length);return{document:r.document,errors:s}}var ge=new Set(["script","style","xmp","iframe","noembed","noframes","plaintext","noscript"]),Je=new Set(["textarea","title"]),be=e=>ge.has(e)?"raw":Je.has(e)?"rcdata":"normal",pe=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),$e="http://www.w3.org/1999/xhtml",K=1500,Ct=e=>e.replace(/&/g,"&amp;").replace(/ /g,"&nbsp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),Fe=e=>e.replace(/&/g,"&amp;").replace(/ /g,"&nbsp;").replace(/"/g,"&quot;");function Qe(e){return j(ie(e))}function*ie(e){let{document:t,errors:n}=yield*de(e,{sourceCodeLocationInfo:!0});return We(e,t,n)}function We(e,t,n){let r=t.childNodes.find(l=>l.nodeName==="html"),s=t.childNodes.filter(l=>l!==r).map(l=>l.nodeName==="#documentType"?{kind:"doctype",name:l.name||"",publicId:l.publicId||"",systemId:l.systemId||""}:{kind:l.nodeName==="#comment"?"comment":l.nodeName,value:l.data}),o=r?ze(r,null,e):null;return o&&Ve(o,e),{src:e,doc:t,outside:s,root:o,parseErrors:n,relocated:o?me(o):null,movedIn:o?me(o,"movedIn"):null,tailOwner:o?He(o):null}}function ze(e,t,n){let r=e.sourceCodeLocation||null,s=e.nodeName==="#text"?"text":e.nodeName==="#comment"?"comment":"element",o={node:e,parent:t,live:null,kind:s,children:[],from:r?r.startOffset:-1,to:r?r.endOffset:-1};if(s==="text")return o.value=e.value,o;if(s==="comment")return o.value=e.data,o;o.tag=e.tagName,o.located=!!(r&&r.startTag),o.openFrom=o.located?r.startTag.startOffset:-1,o.openTo=o.located?r.startTag.endOffset:-1,o.closeFrom=r&&r.endTag?r.endTag.startOffset:o.located?o.to:-1,o.closeTo=r&&r.endTag?r.endTag.endOffset:o.located?o.to:-1,o.endTagged=!!(r&&r.endTag),o.located&&(o.to<o.openTo&&(o.to=o.openTo),o.closeFrom<o.openTo&&(o.closeFrom=o.closeTo=o.openTo)),o.attrs=[];let l=o.located&&r.startTag.attrs||r&&r.attrs||{};for(let a of e.attrs){let g=a.prefix?a.prefix+":"+a.name:a.name,c=l[g.toLowerCase()];o.attrs.push({name:g,key:g.toLowerCase(),value:a.value,from:c?c.startOffset:-1,to:c?c.endOffset:-1})}let d=e.nodeName==="template"&&e.content?e.content.childNodes:e.childNodes;for(let a of d)a.nodeName!=="#documentType"&&o.children.push(ze(a,o,n));if(!o.located){let a=o.children.filter(p=>p.from>=0),g=a.length?Math.min(...a.map(p=>p.from)):-1,c=a.length?Math.max(...a.map(p=>p.to)):-1;o.openFrom=o.openTo=g,o.closeFrom=o.closeTo=c,o.from=g,o.to=c}return o}function Ve(e,t,n=1/0){if(e.kind!=="element")return;for(let o of e.children){if(o.from>=n&&!(o.kind==="text"&&!/\S/.test(o.value))&&(e.movedIn=!0),o.from>=0&&e.located){let l=Math.max(e.openTo,Math.min(o.to,e.closeFrom)),d=Math.min(Math.max(o.from,e.openTo),l);if(d!==o.from||l!==o.to){if(o.kind==="text"&&!ge.has(e.tag)&&!Je.has(e.tag)){let a=t.slice(l,o.to).replace(/<!--[\s\S]*?-->|<[^>]*>/g,"").replace(/\r\n?/g,`
2
2
  `);a&&!/\S/.test(a)&&o.value.endsWith(a)&&(o.outsideTail=a)}o.clamped=!0,o.from=d,o.to=l}}o.kind==="element"&&o.located&&!o.endTagged&&o.closeFrom>o.to&&(o.closeFrom=o.closeTo=o.to)}let r=e.located?e.openTo:-1;for(let o of e.children)if(!(o.from<0)){if(o.from<r){e.outOfOrder=!0;break}r=o.to}let s=e.located&&e.endTagged?Math.min(n,e.closeTo):n;for(let o of e.children)Ve(o,t,s)}function me(e,t="outOfOrder"){if(e[t])return e.tag;for(let n of e.children){if(n.kind!=="element")continue;let r=me(n,t);if(r)return r}return null}function He(e){if(e.outsideTail)return e;for(let t of e.children||[]){let n=He(t);if(n)return n}return null}function Z(e,t){if(!e.root)return"source has no <html> element";if(e.root.openFrom<0)return"source has no content inside <html>";if(e.relocated)return"the parser moved content out of <"+e.relocated+">, so source order and tree order disagree";if(e.movedIn)return"the parser moved content written after the end of <"+e.movedIn+"> back inside it, so source order and tree order disagree";let n=Rt(t),r=e.outside.map(At);if(n.length!==r.length)return"outside <html>: "+JSON.stringify(r)+" vs live "+JSON.stringify(n);for(let s=0;s<n.length;s++)if(n[s]!==r[s])return"outside <html>: "+r[s]+" vs live "+n[s];return null}function At(e){return e.kind==="doctype"?"doctype:"+e.name+"|"+e.publicId+"|"+e.systemId:e.kind+":"+e.value}function Rt(e){let t=[];for(let n of e.childNodes)n.nodeType===10?t.push("doctype:"+n.name+"|"+n.publicId+"|"+n.systemId):n.nodeType===8?t.push("comment:"+n.data):n.nodeType!==1&&t.push("#"+n.nodeType+":"+(n.data||""));return t}var ae="\0",Ge={align:0,hashKey:0};function Pe(e,t){for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function J(e){Ge.hashKey++;let t=2166136261,n=5381;for(let r of e)t=Pe(t,r),n=(Math.imul(n,33)^Pe(t^2654435769,r))>>>0;return t.toString(36)+"."+n.toString(36)}function q(e){let t=e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content.childNodes:e.childNodes,n=[];for(let r of t)(r.nodeType===1||r.nodeType===3||r.nodeType===8)&&n.push(r);return n}var ye=e=>Array.from(e.attributes,t=>t.name.toLowerCase()+"="+t.value).sort().join(ae),Xe=e=>e.attrs.map(t=>t.key+"="+t.value).sort().join(ae);function Ye(e,t){let n;if(e.nodeType===3)n={tag:"#text",shallow:"t:"+e.data,content:"t:"+e.data,deep:"t:"+e.data};else if(e.nodeType===8)n={tag:"#comment",shallow:"c:"+e.data,content:"c:"+e.data,deep:"c:"+e.data};else{let r=q(e).map(o=>Ye(o,t)),s="e:"+e.localName+"|"+ye(e);n={tag:e.localName,shallow:s,content:"e:"+e.localName+"|"+J(r.map(o=>o.content)),deep:s+"|"+J(r.map(o=>o.deep))}}return t.set(e,n),n}function*Ke(e,t,n){++n.n%K===0&&(yield);let r;if(e.nodeType===3)r={tag:"#text",shallow:"t:"+e.data,content:"t:"+e.data,deep:"t:"+e.data};else if(e.nodeType===8)r={tag:"#comment",shallow:"c:"+e.data,content:"c:"+e.data,deep:"c:"+e.data};else{let s=[];for(let l of q(e))s.push(yield*Ke(l,t,n));let o="e:"+e.localName+"|"+ye(e);r={tag:e.localName,shallow:o,content:"e:"+e.localName+"|"+J(s.map(l=>l.content)),deep:o+"|"+J(s.map(l=>l.deep))}}return t.set(e,r),r}function*Ze(e,t){if(++t.n%K===0&&(yield),e.kind==="text")return e.keys={tag:"#text",shallow:"t:"+e.value,content:"t:"+e.value,deep:"t:"+e.value};if(e.kind==="comment")return e.keys={tag:"#comment",shallow:"c:"+e.value,content:"c:"+e.value,deep:"c:"+e.value};let n=[];for(let s of e.children)n.push(yield*Ze(s,t));let r="e:"+e.tag+"|"+Xe(e);return e.keys={tag:e.tag,shallow:r,content:"e:"+e.tag+"|"+J(n.map(s=>s.content)),deep:r+"|"+J(n.map(s=>s.deep))}}var De=["deep","content","shallow","tag"],Mt=4096;function Lt(e,t){Ge.align++;let n=[],r=e.map((p,y)=>y),s=t.map((p,y)=>y);g(r,s,0);let o=new Set(n.map(p=>p[0])),l=new Set(n.map(p=>p[1])),d=r.filter(p=>!o.has(p)),a=s.filter(p=>!l.has(p));return d.length&&a.length&&g(d,a,0),n.sort((p,y)=>p[0]-y[0]),n;function g(p,y,S){let w=0,h=p.length,v=0,N=y.length;if(w>=h||v>=N)return;if(S>=De.length)return c(p,y);let b=De[S];for(;w<h&&v<N&&e[p[w]][b]===t[y[v]][b];)n.push([p[w],y[v]]),w++,v++;for(;w<h&&v<N&&e[p[h-1]][b]===t[y[N-1]][b];)h--,N--,n.push([p[h],y[N]]);if(w>=h||v>=N)return;let P=new Map,Q=new Map;for(let I=w;I<h;I++){let A=e[p[I]][b];P.set(A,P.has(A)?-1:I)}for(let I=v;I<N;I++){let A=t[y[I]][b];Q.set(A,Q.has(A)?-1:I)}let ne=[];for(let I=w;I<h;I++){let A=e[p[I]][b];if(P.get(A)===I){let D=Q.get(A);D!==void 0&&D>=0&&ne.push([I,D])}}let W=bt(ne);if(!W.length){if((h-w)*(N-v)<=Mt){let I=Ft(e,t,p,y,w,h,v,N,b);if(I.length){let A=w,D=v;for(let[H,G]of I)n.push([p[H],y[G]]),g(p.slice(A,H),y.slice(D,G),S+1),A=H+1,D=G+1;g(p.slice(A,h),y.slice(D,N),S+1);return}}return g(p.slice(w,h),y.slice(v,N),S+1)}let z=w,V=v;for(let[I,A]of W)n.push([p[I],y[A]]),g(p.slice(z,I),y.slice(V,A),S),z=I+1,V=A+1;g(p.slice(z,h),y.slice(V,N),S)}function c(p,y){let S=new Map,w=new Map;for(let h of p){let v=e[h].tag;S.has(v)||S.set(v,[]),S.get(v).push(h)}for(let h of y){let v=t[h].tag;w.has(v)||w.set(v,[]),w.get(v).push(h)}for(let[h,v]of S){let N=w.get(h);N&&N.length===v.length&&h!=="#text"&&h!=="#comment"&&v.forEach((b,P)=>n.push([b,N[P]]))}}}function bt(e){let t=[],n=[],r=new Array(e.length).fill(-1);for(let l=0;l<e.length;l++){let d=e[l][1],a=0,g=t.length;for(;a<g;){let c=a+g>>1;t[c]<d?a=c+1:g=c}t[a]=d,n[a]=l,r[l]=a>0?n[a-1]:-1}let s=[],o=n.length?n[n.length-1]:-1;for(;o>=0;)s.push(e[o]),o=r[o];return s.reverse()}function Ft(e,t,n,r,s,o,l,d,a){let g=o-s,c=d-l,p=(v,N)=>e[n[s+v]][a]===t[r[l+N]][a],y=Array.from({length:g+1},()=>new Uint16Array(c+1));for(let v=g-1;v>=0;v--)for(let N=c-1;N>=0;N--)y[v][N]=p(v,N)?y[v+1][N+1]+1:Math.max(y[v+1][N],y[v][N+1]);let S=[],w=0,h=0;for(;w<g&&h<c;)p(w,h)?(S.push([s+w,l+h]),w++,h++):y[w+1][h]>=y[w][h+1]?w++:h++;return S}function Be(e){return e.nodeType===3?"#text "+JSON.stringify(e.data.slice(0,40)):e.nodeType===8?"#comment":"<"+e.localName+Array.from(e.attributes,t=>" "+t.name+'="'+t.value.slice(0,30)+'"').join("")+">"}function je(e){return e.kind==="text"?"#text "+JSON.stringify(e.value.slice(0,40)):e.kind==="comment"?"#comment":"<"+e.tag+e.attrs.map(t=>" "+t.name+'="'+t.value.slice(0,30)+'"').join("")+">"}function et(e,t,n=r=>r){return j(we(e,t,n))}function*we(e,t,n=r=>r){let r=new WeakMap,s=new Map,o={n:0};yield*Ke(e,s,o),yield*Ze(t.root,o);let l={paired:0,unmatchedLive:[],unmatchedSource:[],attrDiffs:[],textDiffs:0,unresolved:0},d={};return t.gen=d,yield*tt(e,t.root,r,s,l,"html",n,d,o),{map:r,stats:l}}function*tt(e,t,n,r,s,o,l,d,a){++a.n%K===0&&(yield);let g=l(e);if(g?(n.set(g,t),t.gen=d,s.paired++):s.unresolved++,t.kind!=="element"){e.data!==t.value&&s.textDiffs++;return}ye(e)!==Xe(t)&&s.attrDiffs.push({path:o,live:Be(e),source:je(t)});let c=q(e),p=t.children,y=Lt(c.map(h=>r.get(h)),p.map(h=>h.keys)),S=new Set,w=new Set;for(let[h,v]of y)S.add(h),w.add(v),yield*tt(c[h],p[v],n,r,s,o+">"+(c[h].nodeType===1?c[h].localName:"#")+"["+h+"]",l,d,a);for(let h=0;h<c.length;h++)S.has(h)||s.unmatchedLive.push({path:o,node:Be(c[h])});for(let h=0;h<p.length;h++)w.has(h)||s.unmatchedSource.push({path:o,node:je(p[h])})}function*nt(e,t,n=r=>r){if(!t.root)return null;let r=[],s=yield*rt(e,t.root,n,r,{n:0});if(s<0)return null;let o=new WeakMap,l={};t.gen=l;let d=0;for(let[a,g]of r)a&&(o.set(a,g),g.gen=l,d++);return{map:o,stats:{paired:d,unmatchedLive:[],unmatchedSource:[],attrDiffs:[],textDiffs:0,unresolved:s}}}function*rt(e,t,n,r,s){if(++s.n%K===0&&(yield),t.kind==="text"){if(e.nodeType!==3||e.data!==t.value)return-1}else if(t.kind==="comment"){if(e.nodeType!==8||e.data!==t.value)return-1}else if(e.nodeType!==1||e.localName!==t.tag||e.namespaceURI!==t.node.namespaceURI||Pt(e)!==Dt(t.node))return-1;let o=n(e);r.push([o,t]);let l=o?0:1;if(t.kind!=="element")return l;let d=Bt(e),a=t.children;if(d.length!==a.length)return-1;for(let g=0;g<d.length;g++){let c=yield*rt(d[g],a[g],n,r,s);if(c<0)return-1;l+=c}return l}var ot=e=>JSON.stringify(e),Pt=e=>Array.from(e.attributes,t=>ot([t.namespaceURI||"",t.name,t.value])).sort().join(ae),Dt=e=>e.attrs.map(t=>ot([t.namespace||"",t.prefix?t.prefix+":"+t.name:t.name,t.value])).sort().join(ae);function Bt(e){let t=e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content.childNodes:e.childNodes,n=[];for(let r of t)(r.nodeType===1||r.nodeType===3||r.nodeType===8)&&n.push(r);return n}function st(e,t,n){let r=t.get(e);if(!r||r.gen!==n.gen||r.from<0||r.to<0||r.kind==="element"&&r.located&&n.src.slice(r.openFrom,r.openFrom+r.tag.length+1).toLowerCase()!=="<"+r.tag.toLowerCase())return null;let s=jt(n),o=Ut(s,r.from);return{from:r.from,to:r.to,line:o+1,column:r.from-s[o]+1}}function jt(e){if(!e.lineStarts){let t=[0];for(let n=0;n<e.src.length;n++)e.src.charCodeAt(n)===10&&t.push(n+1);e.lineStarts=t}return e.lineStarts}function Ut(e,t){let n=0,r=e.length-1;for(;n<r;){let s=n+r+1>>1;e[s]<=t?n=s:r=s-1}return n}function it(e,t,n,r,s={}){let o=()=>typeof performance<"u"?performance.now():Date.now(),l=o(),d=n.src,a=[],g=0,c=(u,m)=>{if(!(u>=0&&m>u))return;let f=a.length>g?a[a.length-1]:null;f&&f.text===void 0&&f.to===u?f.to=m:a.push({from:u,to:m})},p=u=>{u&&a.push({text:u})},y=0,S=u=>{if(y)return null;let m=r(u),f=m?t.get(m):null;return f&&f.gen===n.gen?f:null},w=null,h=-1,v=!1,N=n.root;if(c(0,N.openFrom),I(e,N),c(N.closeTo,d.length),n.tailOwner&&h>=0&&!v){for(let u=h;u<a.length;u++)a[u]={text:Q(P(a[u]))};w&&w.tail&&a.splice(w.at,0,{text:w.tail})}return{text:a.map(P).join(""),ms:o()-l};function P(u){return u.text!==void 0?u.text:d.slice(u.from,u.to)}function Q(u){return u.split(/(<!--[\s\S]*?-->|<[^>]*>)/).map((m,f)=>f%2?m:m.replace(/[\t\n\f\r ]+/g,"")).join("")}function ne(){h=a.length,g=a.length,v=!!w&&w.whole&&/^(?:<\/[^>]*>)*$/.test(a.slice(w.at).map(P).join(""))}function W(u,m){if(u.nodeType===3)return V(u,m);if(u.nodeType===8)return z(u);if(u.nodeType===1){if(s.print&&s.print.has(u)){y++;try{I(u,null)}finally{y--}}else I(u,S(u));u.localName==="body"&&u.parentNode===e&&ne()}}function z(u){let m=S(u);m&&m.kind==="comment"&&m.value===u.data&&m.from>=0&&!s.breakText?c(m.from,m.to):p("<!--"+u.data+"-->")}function V(u,m){let f=S(u),x=u.data;s.corrupt==="drop-first-text"&&!s.corrupted&&x.trim()&&(s.corrupted=!0,x=x.slice(1));let T=f&&f.parent&&be(f.parent.tag)===be(m);if(f&&f.kind==="text"&&f.value===x&&f.from>=0&&!s.breakText&&T){c(f.from,f.to),s.doubleCopied!==void 0&&x===s.doubleCopied&&c(f.from,f.to),f.outsideTail&&(w={at:a.length,tail:f.outsideTail,whole:!0},g=a.length);return}let M=null;if(f&&f.kind==="text"&&f.outsideTail){let R=x.endsWith(f.outsideTail);R&&(x=x.slice(0,x.length-f.outsideTail.length)),M={tail:R?f.outsideTail:"",whole:R}}p(ge.has(m)?x:Ct(x)),M&&(w={at:a.length,...M},g=a.length)}function I(u,m){let f=u.localName,x=pe.has(f)&&u.namespaceURI===$e,T=m&&m.kind==="element"&&!s.breakTags?m:null;if(T&&!T.located){if(u.attributes.length===0){if(T.openFrom>=0){X(u,T,f);return}q(u).length&&X(u,null,f);return}if(p(A(u)),x)return;X(u,T.openFrom>=0?T:null,f),p("</"+f+">");return}if(!T){if(p(A(u)),x)return;X(u,null,f),p("</"+f+">");return}H(u,T),!x&&(X(u,T,f),c(T.closeFrom,T.closeTo))}function A(u){let m="<"+u.localName;for(let f of u.attributes)m+=" "+f.name+(f.value===""?"":'="'+Fe(f.value)+'"');return m+">"}function D(u,m){let f=u.attributes;if(f.length!==m.attrs.length)return!1;for(let x=0;x<f.length;x++){let T=m.attrs[x];if(T.from<0||f[x].value!==T.value||f[x].name.toLowerCase()!==T.key)return!1}return!0}function H(u,m){if(D(u,m)){c(m.openFrom,m.openTo);return}let f=new Map;for(let O of u.attributes)f.set(O.name.toLowerCase(),O);let x=new Set,T=m.openFrom;for(let O of m.attrs){if(O.from<0){let _=f.get(O.key);_&&_.value===O.value&&x.add(O.key);continue}let L=f.get(O.key);if(x.add(O.key),!L){c(T,G(T,O.from)),T=O.to;continue}if(L.value===O.value){c(T,O.to),T=O.to;continue}c(T,O.from),p(xt(d.slice(O.from,O.to),L.value)),T=O.to}let M=m.openTo-1,R=m.attrs.reduce((O,L)=>L.to>O?L.to:O,m.openFrom);d[M-1]==="/"&&M-1>=R&&M--,c(T,M);for(let O of u.attributes)x.has(O.name.toLowerCase())||p(" "+O.name+(O.value===""?"":'="'+Fe(O.value)+'"'));c(M,m.openTo)}function G(u,m){let f=m;for(;f>u&&/[ \t\n\r\f]/.test(d[f-1]);)f--;return f}function xt(u,m){let f=u.indexOf("="),x=(f<0?u:u.slice(0,f)).trimEnd(),T=f<0?"":u.slice(f+1).trim(),M=T[0]==="'"?"'":T[0]==='"'?'"':"",R=m.replace(/&/g,"&amp;").replace(/ /g,"&nbsp;");return M==="'"&&!m.includes("'")?x+"='"+R+"'":M===""&&T!==""&&m!==""&&!/[\s"'=<>`]/.test(m)?x+"="+R:x+'="'+R.replace(/"/g,"&quot;")+'"'}function St(u){if(u.nodeType!==1||y||s.print&&s.print.has(u))return null;let m=S(u);return m&&m.kind==="element"&&m.located&&!m.endTagged&&!pe.has(m.tag)&&!s.breakTags?m:null}function ue(u){let m=St(u);if(!m)return null;let f=q(u);return((f.length?ue(f[f.length-1]):null)||[]).concat(m.tag)}function X(u,m,f){let x=q(u),T=null,M=(C,k)=>{T&&!(k>=0&&T.j>=0&&k===T.j+1)&&p(T.tags.map(E=>"</"+E+">").join("")),T=null};if(!m){for(let C of x){M(-1,-1),W(C,f);let k=ue(C);k&&(T={tags:k,j:-1})}return}let R=m.children,O=new Map(R.map((C,k)=>[C,k])),L=x.map(C=>{let k=S(C);return k&&k.parent===m&&k.from>=0?O.get(k):-1}),_=new Set;if(!s.breakText&&!s.breakTags){let C=new Set(L),k=new Map;R.forEach((E,F)=>{C.has(F)||E.from<0||!E.keys||(k.has(E.keys.deep)||k.set(E.keys.deep,[]),k.get(E.keys.deep).push(F))}),k.size&&x.forEach((E,F)=>{if(L[F]>=0||S(E))return;let B=k.get(Ye(E,new Map).deep);B&&B.length&&(L[F]=B.shift(),_.add(F))})}let Se=(C,k)=>{if(!_.has(k))return W(C,f);let E=R[L[k]];c(E.from,E.to),E.outsideTail&&(w={at:a.length,tail:E.outsideTail,whole:!0},g=a.length)},kt=(C,k)=>{if(!_.has(k))return ue(C);let E=R[L[k]];return E.kind==="element"&&E.located&&!E.endTagged&&!pe.has(E.tag)?[E.tag]:null},Nt=new Set(_t(L)),U=m.openTo,ke=-1,Ne=C=>{for(let k=ke+1;k<C;k++){let E=R[k];E.from<0||(c(U,E.from),U=Math.max(U,E.to))}};for(let C=0;C<x.length;C++){let k=x[C],E=kt(k,C);if(Nt.has(C)){let B=L[C],Ee=R[B];M(C,B),Ne(B),c(U,Ee.from),Se(k,C),U=Math.max(U,Ee.to),ke=B,T=E?{tags:E,j:B}:null;continue}let F=S(k);M(C,F&&F.parent===m?O.get(F):-1),Se(k,C),T=E?{tags:E,j:-1}:null}Ne(R.length),c(U,m.closeFrom)}}function _t(e){let t=[],n=[],r=new Array(e.length).fill(-1);for(let l=0;l<e.length;l++){let d=e[l];if(d<0)continue;let a=0,g=t.length;for(;a<g;){let c=a+g>>1;t[c]<d?a=c+1:g=c}t[a]=d,n[a]=l,r[l]=a>0?n[a-1]:-1}let s=[],o=n.length?n[n.length-1]:-1;for(;o>=0;)s.push(o),o=r[o];return s.reverse()}function*at(e,t,n,r=null,s=null){return yield*ve(e,t,n,r,s,!0)}function*ve(e,t,n,r,s,o){let l=new DOMParser,d=l.parseFromString(e,"text/html"),a=qe(d),g=qe(n);if(a.join(`
3
3
  `)!==g.join(`
4
- `))return{ok:!1,diff:"document: outside <html> "+JSON.stringify(a)+" vs live "+JSON.stringify(g)};let c=null,p=null;if(r&&(c=[],p=yield*se(d.documentElement,r,"html",c),!p)){let h=yield*Ue(e,s,o);return h.diff?{ok:!1,diff:h.diff}:o?_e({ok:!0,diff:null,oracle:"clone"},h,e,n):{ok:!0,diff:null,oracle:"clone"}}let y=l.parseFromString(t,"text/html"),S=yield*se(d.documentElement,y.documentElement,"html"),w=S?null:yield*Ue(e,s,o);return S?r?{ok:!1,diff:S,at:c}:{ok:!1,diff:S}:w.diff?{ok:!1,diff:w.diff}:o?_e({ok:!0,diff:null,oracle:"today"},w,e,n):{ok:!0,diff:null,oracle:"today"}}function lt(e,t){let n=e;for(let r of t){let s=he(n);if(r>=s.length)return null;n=s[r]}return n}function*Ue(e,t,n){if(!t)return{diff:null};let{document:r,errors:s}=yield*de(e,n?{sourceCodeLocationInfo:!0}:{});for(let[o,l]of s){let d=t.get(o)||0;if(l>d)return{diff:`the render introduced parse errors the source does not have: ${o} ${d} -> ${l}`}}return n?{diff:null,doc:r,parseErrors:s}:{diff:null}}function _e(e,t,n,r){if(!t.doc)return e;let s=We(n,t.doc,t.parseErrors);return Z(s,r)||(e.model=s),e}function qe(e){let t=[];for(let n of e.childNodes)n.nodeType===10?t.push("doctype "+n.name+"|"+n.publicId+"|"+n.systemId):n.nodeType===8?t.push("comment "+n.data):n.nodeType!==1&&t.push("node"+n.nodeType+" "+(n.data||""));return t}function*qt(e,t,n,r){let s=new DOMParser,o=l=>{let d=Array.from(l.childNodes);return d.length&&d.every(a=>a.nodeType===3)?d.map(a=>a.data).join(""):l.innerHTML};return yield*se(s.parseFromString(e.innerHTML,"text/html").body,s.parseFromString(o(t),"text/html").body,n+">#noscript",[],r)}function he(e){let t=e.localName==="template"&&e.content?e.content.childNodes:e.childNodes,n=[];for(let r=0;r<t.length;r++){let s=t[r];(s.nodeType===1||s.nodeType===3||s.nodeType===8)&&n.push(s)}return n}var oe=e=>Array.from(e.attributes,t=>(t.namespaceURI||"")+" "+t.name+"="+JSON.stringify(t.value)).sort().join("; ");function Jt(e,t){let n=e.attributes,r=t.attributes;if(n.length!==r.length)return!1;for(let s=0;s<n.length;s++){let o=n[s],l=r[s];if(o.name!==l.name||o.value!==l.value||o.namespaceURI!==l.namespaceURI)return!1}return!0}function*se(e,t,n,r=[],s={n:0}){if(++s.n%K===0&&(yield),e.nodeType!==t.nodeType)return n+": node type "+e.nodeType+" vs "+t.nodeType;if(e.nodeType===3||e.nodeType===8)return e.data===t.data?null:n+": text "+JSON.stringify(e.data.slice(0,60))+" vs "+JSON.stringify(t.data.slice(0,60));if(e.localName!==t.localName||e.namespaceURI!==t.namespaceURI)return n+": tag "+e.localName+" vs "+t.localName;if(!Jt(e,t)&&oe(e)!==oe(t))return n+": attrs "+oe(e)+" vs "+oe(t);if(e.localName==="noscript"&&e.namespaceURI===$e)return yield*qt(e,t,n,s);let o=he(e),l=he(t);if(o.length!==l.length)return n+": "+o.length+" vs "+l.length+" children";for(let d=0;d<o.length;d++){r.push(d);let a=yield*se(o[d],l[d],n+">"+(o[d].localName||"#")+"["+d+"]",r,s);if(a)return a;r.pop()}return null}var i={installed:!1,refused:null,session:0,model:null,map:null,stats:null,saves:0,reprints:0,lastReprint:null,partialReprints:0,lastPartialReprint:null,lastOutcome:null,lastRenderMs:null,lastBytes:null,timing:{fetch:null,model:null,pair:null,refresh:null},refreshes:0,repairs:0,refreshQueued:!1,pendingBytes:null,refetch:!1,adoptions:0},$t=2,$=()=>typeof performance<"u"?performance.now():Date.now(),dt=4,le=Object.freeze({superseded:!0});function pt(e){return document.hidden||Re()?!1:e>=307200}var mt='<script type="application/json" id="clay-runtime-map"',ht=e=>e.includes(mt)||e.includes("/_/clayjs/");async function gt(e){let t=await fetch(e,{cache:"no-store",redirect:"manual",credentials:"same-origin",headers:{"Clay-Source":"1"}});if(!t.ok)throw new Error(`source fetch: status ${t.status}`);if(t.redirected||t.type==="opaqueredirect")throw new Error("source fetch: redirected");let n=(t.headers.get("content-type")||"").toLowerCase();if(!n.startsWith("text/html"))throw new Error(`source fetch: content-type ${n||"missing"}`);let r=await t.text();if(r.includes(mt))throw new Error("source fetch: projected response");return r}function yt(e){let t=fe({flushUndo:!1,authored:!1});return et(t,e,Y)}function*Qt(e){let t=fe({flushUndo:!1,authored:!1});return yield*we(t,e,Y)}function Wt(e){let t=e.doc&&e.doc.childNodes.find(r=>r.nodeName==="html"),n=t&&Array.isArray(t.attrs)?t.attrs.find(r=>r.name==="documentetag"):null;return n&&n.value?n.value:null}function zt(e){let t=e&&e.represented&&e.represented.etag;if(t)return t;let n=Ae();return n||e===null&&document.documentElement.getAttribute("documentetag")||null}function Vt(e,t){let n=Wt(e),r=zt(t);return!n||!r||n===r?null:`source refused: the fetch answered version ${n} while this page holds ${r}`}async function wt(e,t=null,n=0,r=!0,s=null){let o=i.session,l=$(),d=i.adoptions;i.refused=null;let a=s?s():null,g=a&&typeof a.bytes=="string"&&!ht(a.bytes)?a.bytes:null;try{let c=g!==null?g:await gt(e);if(o!==i.session)return null;let p=$(),y=await Ht({src:c,context:t,render:r,session:o,generation:d,t0:l,t1:p});if(y!==le)return y;if(n<$t)return wt(e,t,n+1,r,s);throw new Error("source refused: a save replaced the file while the fetch was in flight")}catch(c){return o!==i.session||(i.refused=String(c&&c.message?c.message:c),console.info(`clayjs: source map off (${i.refused}); saves use the full serialization`)),null}}function*ut(e){let t=yield*ie(e.src),n=Z(t,document);if(n)throw new Error(`source refused: ${n}`);let r=Vt(t,e.context);if(r)throw new Error(r);if(i.adoptions!==e.generation)return le;let s=$();if(yield,i.session!==e.session)return null;if(i.adoptions!==e.generation)return le;let{map:o,stats:l}=yield*Qt(t);if(i.session!==e.session)return null;if(i.adoptions!==e.generation)return le;let d=$();return i.model=t,i.map=o,i.stats=l,i.timing={fetch:e.t1-e.t0,model:s-e.t1,pair:d-s,refresh:null},i.installed=!0,e.render&&ce(Gt,{steps:vt}),Tt()}async function Ht(e){if(!pt(e.src.length))return j(ut(e));let t={get aborted(){return i.session!==e.session}},n=await re(ut(e),{budgetMs:dt,signal:t});return n&&n.aborted===!0?null:n}function Gt(e,t,n={}){return j(vt(e,t,n))}function*vt(e,t,n={}){if(!i.installed)return t;yield*xe();let r=i.session,s=i.repairs,o=Oe(),l=!!o&&!o.authoredHandlers,d=new Set,a=null;for(let g=0;g<=Yt;g++){let c;try{c=it(e,i.map,i.model,Y,{...n,print:d})}catch(y){return ee("render threw: "+(y&&y.message?y.message:y),t)}let p=l?yield*at(c.text,t,document,e,i.model.parseErrors):yield*ve(c.text,t,document,e,i.model.parseErrors,!1);if(p.ok){let y=ct(r,s);if(y)return ee(y,t);let S=d.size?{text:c.text,scope:"partial",reason:a,printed:d.size}:{text:c.text,scope:null},w=p.model?yield*nt(e,p.model,Y):null,h=ct(r,s);return h?ee(h,t):(i.lastRenderMs=c.ms,i.lastBytes=c.text.length,i.lastOutcome=S,p.model&&Xt(p.model,c.text,o,w),c.text)}if(a===null&&(a=p.diff),!p.at||!Kt(e,lt(e,p.at),d))return ee(a,t)}return ee(a,t)}function ct(e,t){return i.session!==e?"render refused: the session ended while this render ran":i.installed?i.repairs!==t?"render refused: the map was re-paired while this render ran":null:"render refused: the source map was uninstalled while this render ran"}function Xt(e,t,n,r){r&&Ie({captureId:n.captureId,html:t,source:{model:e,map:r.map,stats:r.stats,repairGeneration:i.repairs,outcome:i.lastOutcome}})}var Yt=8;function Kt(e,t,n){let r=t&&t.nodeType===1?t:t&&t.parentNode;for(let s=r;s&&s!==e;s=s.parentNode)if(n.has(s)){n.delete(s),r=s.parentNode;break}return!r||r.nodeType!==1||r===e?!1:(n.add(r),!0)}function ee(e,t){return i.lastOutcome={text:t,scope:"full",reason:e},t}function Zt(e){i.reprints++,i.lastReprint=e,console.warn("clayjs: source map did not verify, saving the full serialization instead:",e),document.dispatchEvent(new CustomEvent("clay:save-reprinted",{detail:{reason:e,scope:"full"}}))}function en(e,t){i.partialReprints++,i.lastPartialReprint=e,console.info(`clayjs: source map printed ${t} element(s) in full to match the page:`,e),document.dispatchEvent(new CustomEvent("clay:save-reprinted",{detail:{reason:e,scope:"partial",printed:t}}))}function tn(e,t){i.adoptions++,i.installed&&(rn(e,t&&t.artifact?t.artifact.source.outcome:null),!nn(e,t)&&(i.pendingBytes=e,Te()))}function nn(e,t){let n=t&&t.artifact;return!n||!n.source||n.html!==e||t.captureId===null||t.captureId===void 0||n.captureId!==t.captureId||n.source.repairGeneration!==i.repairs||i.refreshQueued||i.pendingBytes!==null?!1:(i.model=n.source.model,i.map=n.source.map,i.stats=n.source.stats,!0)}function rn(e,t=null){let n=i.lastOutcome&&i.lastOutcome.text===e?i.lastOutcome:t;!n||n.text!==e||(i.lastOutcome===n&&(i.lastOutcome=null),i.saves++,n.scope==="full"?Zt(n.reason):n.scope==="partial"&&en(n.reason,n.printed))}function on(e){let t=e&&e.detail;t&&t.source==="disk"&&typeof t.html=="string"&&i.adoptions++,i.installed&&(t&&t.source==="disk"&&typeof t.html=="string"&&(ht(t.html)?i.refetch=!0:i.pendingBytes=t.html),Te())}function Te(){i.refreshQueued||(i.refreshQueued=!0,typeof requestIdleCallback=="function"?requestIdleCallback(ft,{timeout:2e3}):setTimeout(ft,0))}function ft(){if(!pt(sn())){te();return}an()}function sn(){return typeof i.pendingBytes=="string"?i.pendingBytes.length:i.model?i.model.src.length:0}async function an(){let e=i.session,t={get aborted(){return i.session!==e}};try{await re(xe(),{budgetMs:dt,signal:t})}catch(n){console.warn("clayjs: source map could not run the queued repair:",n)}!i.refreshQueued||!i.installed||i.session!==e||(i.refreshQueued=!1,Te())}function te(){j(xe())}function*xe(){if(!i.refreshQueued)return;if(!i.installed){i.refreshQueued=!1;return}let e=i.session,t=i.repairs,n=i.adoptions,r=i.pendingBytes,s=i.refetch&&r===null,o=$(),l=i.model;if(r!==null)try{let a=yield*ie(r),g=Z(a,document);if(g)throw new Error(g);l=a}catch(a){console.warn("clayjs: source map kept the previous model, the accepted bytes did not model:",a)}if(yield,!ln(e,t,n))return;let d=null;try{d=yt(l)}catch(a){console.warn("clayjs: source map could not re-pair, continuing on the previous map:",a)}i.refreshQueued=!1,i.pendingBytes=null,s&&(i.refetch=!1),i.repairs++,d&&(i.model=l,i.map=d.map,i.stats=d.stats,i.refreshes++,i.timing.refresh=$()-o),s&&un()}function ln(e,t,n){return i.session===e&&i.installed&&i.repairs===t&&i.adoptions===n}function un(){let e=i.repairs,t=i.adoptions;gt(window.location.href).then(n=>{let r=Qe(n),s=Z(r,document);if(s)throw new Error(s);return r}).then(n=>{if(!(i.repairs!==e||i.adoptions!==t))try{i.repairs++,i.adoptions++;let{map:r,stats:s}=yt(n);i.model=n,i.map=r,i.stats=s,i.refreshes++}catch(r){console.warn("clayjs: source map could not re-pair, continuing on the previous map:",r)}}).catch(n=>{console.warn("clayjs: source map kept the previous model, the accepted bytes did not model:",n)})}function Tt(){let e=i.stats;return{installed:i.installed,refused:i.refused,sourceBytes:i.model?i.model.src.length:null,paired:e?e.paired:0,unresolved:e?e.unresolved:0,unmatchedLive:e?e.unmatchedLive.length:0,unmatchedSource:e?e.unmatchedSource.length:0,attrDiffs:e?e.attrDiffs.length:0,saves:i.saves,reprints:i.reprints,lastReprint:i.lastReprint,partialReprints:i.partialReprints,lastPartialReprint:i.lastPartialReprint,lastRenderMs:i.lastRenderMs,lastBytes:i.lastBytes,refreshes:i.refreshes,timing:i.timing}}function kn(){return te(),i.model?i.model.src:null}function Nn(e){return te(),i.installed&&e?st(e,i.map,i.model):null}function En(){return te(),i.stats?{live:i.stats.unmatchedLive.slice(0,50),source:i.stats.unmatchedSource.slice(0,50)}:null}function On(){return te(),Tt()}var In=()=>i.installed,Cn=()=>i.repairs;function An(){cn()}function cn(){i.session++,i.installed=!1,i.refreshQueued=!1,i.pendingBytes=null,i.refetch=!1,ce(null)}function Rn({context:e=null,latest:t=null}={}){return wt(window.location.href,e,0,!0,t)}Ce(tn);document.addEventListener("clay:sync-applied",on);export{tn as adoptAccepted,In as installed,Nn as locateLive,xe as refreshNowSteps,An as release,Gt as renderSave,vt as renderSaveSteps,Cn as repairGeneration,Rn as start,On as stats,kn as text,En as unpaired};
4
+ `))return{ok:!1,diff:"document: outside <html> "+JSON.stringify(a)+" vs live "+JSON.stringify(g)};let c=null,p=null;if(r&&(c=[],p=yield*se(d.documentElement,r,"html",c),!p)){let h=yield*Ue(e,s,o);return h.diff?{ok:!1,diff:h.diff}:o?_e({ok:!0,diff:null,oracle:"clone"},h,e,n):{ok:!0,diff:null,oracle:"clone"}}let y=l.parseFromString(t,"text/html"),S=yield*se(d.documentElement,y.documentElement,"html"),w=S?null:yield*Ue(e,s,o);return S?r?{ok:!1,diff:S,at:c}:{ok:!1,diff:S}:w.diff?{ok:!1,diff:w.diff}:o?_e({ok:!0,diff:null,oracle:"today"},w,e,n):{ok:!0,diff:null,oracle:"today"}}function lt(e,t){let n=e;for(let r of t){let s=he(n);if(r>=s.length)return null;n=s[r]}return n}function*Ue(e,t,n){if(!t)return{diff:null};let{document:r,errors:s}=yield*de(e,n?{sourceCodeLocationInfo:!0}:{});for(let[o,l]of s){let d=t.get(o)||0;if(l>d)return{diff:`the render introduced parse errors the source does not have: ${o} ${d} -> ${l}`}}return n?{diff:null,doc:r,parseErrors:s}:{diff:null}}function _e(e,t,n,r){if(!t.doc)return e;let s=We(n,t.doc,t.parseErrors);return Z(s,r)||(e.model=s),e}function qe(e){let t=[];for(let n of e.childNodes)n.nodeType===10?t.push("doctype "+n.name+"|"+n.publicId+"|"+n.systemId):n.nodeType===8?t.push("comment "+n.data):n.nodeType!==1&&t.push("node"+n.nodeType+" "+(n.data||""));return t}function*qt(e,t,n,r){let s=new DOMParser,o=l=>{let d=Array.from(l.childNodes);return d.length&&d.every(a=>a.nodeType===3)?d.map(a=>a.data).join(""):l.innerHTML};return yield*se(s.parseFromString(e.innerHTML,"text/html").body,s.parseFromString(o(t),"text/html").body,n+">#noscript",[],r)}function he(e){let t=e.localName==="template"&&e.content?e.content.childNodes:e.childNodes,n=[];for(let r=0;r<t.length;r++){let s=t[r];(s.nodeType===1||s.nodeType===3||s.nodeType===8)&&n.push(s)}return n}var oe=e=>Array.from(e.attributes,t=>(t.namespaceURI||"")+" "+t.name+"="+JSON.stringify(t.value)).sort().join("; ");function Jt(e,t){let n=e.attributes,r=t.attributes;if(n.length!==r.length)return!1;for(let s=0;s<n.length;s++){let o=n[s],l=r[s];if(o.name!==l.name||o.value!==l.value||o.namespaceURI!==l.namespaceURI)return!1}return!0}function*se(e,t,n,r=[],s={n:0}){if(++s.n%K===0&&(yield),e.nodeType!==t.nodeType)return n+": node type "+e.nodeType+" vs "+t.nodeType;if(e.nodeType===3||e.nodeType===8)return e.data===t.data?null:n+": text "+JSON.stringify(e.data.slice(0,60))+" vs "+JSON.stringify(t.data.slice(0,60));if(e.localName!==t.localName||e.namespaceURI!==t.namespaceURI)return n+": tag "+e.localName+" vs "+t.localName;if(!Jt(e,t)&&oe(e)!==oe(t))return n+": attrs "+oe(e)+" vs "+oe(t);if(e.localName==="noscript"&&e.namespaceURI===$e)return yield*qt(e,t,n,s);let o=he(e),l=he(t);if(o.length!==l.length)return n+": "+o.length+" vs "+l.length+" children";for(let d=0;d<o.length;d++){r.push(d);let a=yield*se(o[d],l[d],n+">"+(o[d].localName||"#")+"["+d+"]",r,s);if(a)return a;r.pop()}return null}var i={installed:!1,refused:null,session:0,model:null,map:null,stats:null,saves:0,reprints:0,lastReprint:null,partialReprints:0,lastPartialReprint:null,lastOutcome:null,lastRenderMs:null,lastBytes:null,timing:{fetch:null,model:null,pair:null,refresh:null},refreshes:0,repairs:0,refreshQueued:!1,pendingBytes:null,refetch:!1,adoptions:0},$t=2,$=()=>typeof performance<"u"?performance.now():Date.now(),dt=4,le=Object.freeze({superseded:!0});function pt(e){return document.hidden||Me()?!1:e>=307200}var mt='<script type="application/json" id="clay-runtime-map"',ht=e=>e.includes(mt)||e.includes("/_/clayjs/");async function gt(e){let t=await fetch(e,{cache:"no-store",redirect:"manual",credentials:"same-origin",headers:{"Clay-Source":"1"}});if(!t.ok)throw new Error(`source fetch: status ${t.status}`);if(t.redirected||t.type==="opaqueredirect")throw new Error("source fetch: redirected");let n=(t.headers.get("content-type")||"").toLowerCase();if(!n.startsWith("text/html"))throw new Error(`source fetch: content-type ${n||"missing"}`);let r=await t.text();if(r.includes(mt))throw new Error("source fetch: projected response");return r}function yt(e){let t=fe({flushUndo:!1,authored:!1});return et(t,e,Y)}function*Qt(e){let t=fe({flushUndo:!1,authored:!1});return yield*we(t,e,Y)}function Wt(e){let t=e.doc&&e.doc.childNodes.find(r=>r.nodeName==="html"),n=t&&Array.isArray(t.attrs)?t.attrs.find(r=>r.name==="documentetag"):null;return n&&n.value?n.value:null}function zt(e){let t=e&&e.represented&&e.represented.etag;if(t)return t;let n=Ae();return n||e===null&&document.documentElement.getAttribute("documentetag")||null}function Vt(e,t){let n=Wt(e),r=zt(t);return!n||!r||n===r?null:`source refused: the fetch answered version ${n} while this page holds ${r}`}async function wt(e,t=null,n=0,r=!0,s=null){let o=i.session,l=$(),d=i.adoptions;i.refused=null;let a=s?s():null,g=a&&typeof a.bytes=="string"&&!ht(a.bytes)?a.bytes:null;try{let c=g!==null?g:await gt(e);if(o!==i.session)return null;let p=$(),y=await Ht({src:c,context:t,render:r,session:o,generation:d,t0:l,t1:p});if(y!==le)return y;if(n<$t)return wt(e,t,n+1,r,s);throw new Error("source refused: a save replaced the file while the fetch was in flight")}catch(c){return o!==i.session||(i.refused=String(c&&c.message?c.message:c),console.info(`clayjs: source map off (${i.refused}); saves use the full serialization`)),null}}function*ut(e){let t=yield*ie(e.src),n=Z(t,document);if(n)throw new Error(`source refused: ${n}`);let r=Vt(t,e.context);if(r)throw new Error(r);if(i.adoptions!==e.generation)return le;let s=$();if(yield,i.session!==e.session)return null;if(i.adoptions!==e.generation)return le;let{map:o,stats:l}=yield*Qt(t);if(i.session!==e.session)return null;if(i.adoptions!==e.generation)return le;let d=$();return i.model=t,i.map=o,i.stats=l,i.timing={fetch:e.t1-e.t0,model:s-e.t1,pair:d-s,refresh:null},i.installed=!0,e.render&&ce(Gt,{steps:vt}),Tt()}async function Ht(e){if(!pt(e.src.length))return j(ut(e));let t={get aborted(){return i.session!==e.session}},n=await re(ut(e),{budgetMs:dt,signal:t});return n&&n.aborted===!0?null:n}function Gt(e,t,n={}){return j(vt(e,t,n))}function*vt(e,t,n={}){if(!i.installed)return t;yield*xe();let r=i.session,s=i.repairs,o=Oe(),l=!!o&&!o.authoredHandlers,d=new Set,a=null;for(let g=0;g<=Yt;g++){let c;try{c=it(e,i.map,i.model,Y,{...n,print:d})}catch(y){return ee("render threw: "+(y&&y.message?y.message:y),t)}let p=l?yield*at(c.text,t,document,e,i.model.parseErrors):yield*ve(c.text,t,document,e,i.model.parseErrors,!1);if(p.ok){let y=ct(r,s);if(y)return ee(y,t);let S=d.size?{text:c.text,scope:"partial",reason:a,printed:d.size}:{text:c.text,scope:null},w=p.model?yield*nt(e,p.model,Y):null,h=ct(r,s);return h?ee(h,t):(i.lastRenderMs=c.ms,i.lastBytes=c.text.length,i.lastOutcome=S,p.model&&Xt(p.model,c.text,o,w),c.text)}if(a===null&&(a=p.diff),!p.at||!Kt(e,lt(e,p.at),d))return ee(a,t)}return ee(a,t)}function ct(e,t){return i.session!==e?"render refused: the session ended while this render ran":i.installed?i.repairs!==t?"render refused: the map was re-paired while this render ran":null:"render refused: the source map was uninstalled while this render ran"}function Xt(e,t,n,r){r&&Ie({captureId:n.captureId,html:t,source:{model:e,map:r.map,stats:r.stats,repairGeneration:i.repairs,outcome:i.lastOutcome}})}var Yt=8;function Kt(e,t,n){let r=t&&t.nodeType===1?t:t&&t.parentNode;for(let s=r;s&&s!==e;s=s.parentNode)if(n.has(s)){n.delete(s),r=s.parentNode;break}return!r||r.nodeType!==1||r===e?!1:(n.add(r),!0)}function ee(e,t){return i.lastOutcome={text:t,scope:"full",reason:e},t}function Zt(e){i.reprints++,i.lastReprint=e,console.warn("clayjs: source map did not verify, saving the full serialization instead:",e),document.dispatchEvent(new CustomEvent("clay:save-reprinted",{detail:{reason:e,scope:"full"}}))}function en(e,t){i.partialReprints++,i.lastPartialReprint=e,console.info(`clayjs: source map printed ${t} element(s) in full to match the page:`,e),document.dispatchEvent(new CustomEvent("clay:save-reprinted",{detail:{reason:e,scope:"partial",printed:t}}))}function tn(e,t){i.adoptions++,i.installed&&(rn(e,t&&t.artifact?t.artifact.source.outcome:null),!nn(e,t)&&(i.pendingBytes=e,Te()))}function nn(e,t){let n=t&&t.artifact;return!n||!n.source||n.html!==e||t.captureId===null||t.captureId===void 0||n.captureId!==t.captureId||n.source.repairGeneration!==i.repairs||i.refreshQueued||i.pendingBytes!==null?!1:(i.model=n.source.model,i.map=n.source.map,i.stats=n.source.stats,!0)}function rn(e,t=null){let n=i.lastOutcome&&i.lastOutcome.text===e?i.lastOutcome:t;!n||n.text!==e||(i.lastOutcome===n&&(i.lastOutcome=null),i.saves++,n.scope==="full"?Zt(n.reason):n.scope==="partial"&&en(n.reason,n.printed))}function on(e){let t=e&&e.detail;t&&t.source==="disk"&&typeof t.html=="string"&&i.adoptions++,i.installed&&(t&&t.source==="disk"&&typeof t.html=="string"&&(ht(t.html)?i.refetch=!0:i.pendingBytes=t.html),Te())}function Te(){i.refreshQueued||(i.refreshQueued=!0,typeof requestIdleCallback=="function"?requestIdleCallback(ft,{timeout:2e3}):setTimeout(ft,0))}function ft(){if(!pt(sn())){te();return}an()}function sn(){return typeof i.pendingBytes=="string"?i.pendingBytes.length:i.model?i.model.src.length:0}async function an(){let e=i.session,t={get aborted(){return i.session!==e}};try{await re(xe(),{budgetMs:dt,signal:t})}catch(n){console.warn("clayjs: source map could not run the queued repair:",n)}!i.refreshQueued||!i.installed||i.session!==e||(i.refreshQueued=!1,Te())}function te(){j(xe())}function*xe(){if(!i.refreshQueued)return;if(!i.installed){i.refreshQueued=!1;return}let e=i.session,t=i.repairs,n=i.adoptions,r=i.pendingBytes,s=i.refetch&&r===null,o=$(),l=i.model;if(r!==null)try{let a=yield*ie(r),g=Z(a,document);if(g)throw new Error(g);l=a}catch(a){console.warn("clayjs: source map kept the previous model, the accepted bytes did not model:",a)}if(yield,!ln(e,t,n))return;let d=null;try{d=yt(l)}catch(a){console.warn("clayjs: source map could not re-pair, continuing on the previous map:",a)}i.refreshQueued=!1,i.pendingBytes=null,s&&(i.refetch=!1),i.repairs++,d&&(i.model=l,i.map=d.map,i.stats=d.stats,i.refreshes++,i.timing.refresh=$()-o),s&&un()}function ln(e,t,n){return i.session===e&&i.installed&&i.repairs===t&&i.adoptions===n}function un(){let e=i.repairs,t=i.adoptions;gt(window.location.href).then(n=>{let r=Qe(n),s=Z(r,document);if(s)throw new Error(s);return r}).then(n=>{if(!(i.repairs!==e||i.adoptions!==t))try{i.repairs++,i.adoptions++;let{map:r,stats:s}=yt(n);i.model=n,i.map=r,i.stats=s,i.refreshes++}catch(r){console.warn("clayjs: source map could not re-pair, continuing on the previous map:",r)}}).catch(n=>{console.warn("clayjs: source map kept the previous model, the accepted bytes did not model:",n)})}function Tt(){let e=i.stats;return{installed:i.installed,refused:i.refused,sourceBytes:i.model?i.model.src.length:null,paired:e?e.paired:0,unresolved:e?e.unresolved:0,unmatchedLive:e?e.unmatchedLive.length:0,unmatchedSource:e?e.unmatchedSource.length:0,attrDiffs:e?e.attrDiffs.length:0,saves:i.saves,reprints:i.reprints,lastReprint:i.lastReprint,partialReprints:i.partialReprints,lastPartialReprint:i.lastPartialReprint,lastRenderMs:i.lastRenderMs,lastBytes:i.lastBytes,refreshes:i.refreshes,timing:i.timing}}function kn(){return te(),i.model?i.model.src:null}function Nn(e){return te(),i.installed&&e?st(e,i.map,i.model):null}function En(){return te(),i.stats?{live:i.stats.unmatchedLive.slice(0,50),source:i.stats.unmatchedSource.slice(0,50)}:null}function On(){return te(),Tt()}var In=()=>i.installed,Cn=()=>i.repairs;function An(){cn()}function cn(){i.session++,i.installed=!1,i.refreshQueued=!1,i.pendingBytes=null,i.refetch=!1,ce(null)}function Rn({context:e=null,latest:t=null}={}){return wt(window.location.href,e,0,!0,t)}Ce(tn);document.addEventListener("clay:sync-applied",on);export{tn as adoptAccepted,In as installed,Nn as locateLive,xe as refreshNowSteps,An as release,Gt as renderSave,vt as renderSaveSteps,Cn as repairGeneration,Rn as start,On as stats,kn as text,En as unpaired};
@@ -1 +1 @@
1
- import{a as _,d as v}from"./c-BWFVSBDF.js";import{b as c}from"./c-RVMWGXEJ.js";import{b as u,c as s}from"./c-NUHP2XDB.js";import{e as b}from"./c-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-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var d="#FFFCF6",l=["all:initial","color-scheme:inherit","direction:ltr","unicode-bidi:isolate"],y=18,h=3,p=null,f=null;function C(){return f??=Promise.all([import("./c-2ZZBC45O.js"),import("./c-ZE46QDIH.js")]).then(([i,e])=>p={RUNTIME_ONLY:i.RUNTIME_ONLY,CHIP_FONT:`600 11px/16px ${e.FONT_MONO}`}).catch(i=>{throw f=null,i}),f}var $=()=>C().then(()=>!0,()=>!1);function a(i){return i.setAttribute("clay",p.RUNTIME_ONLY),i}function A(i){let e=i&&Array.isArray(i.people)?i.people:[],o=[];for(let t of e){if(!t||t.you===!0||typeof t.id!="string"||!t.id||typeof t.editing!="string"||!_.test(t.editing))continue;let n=typeof t.name=="string"&&t.name.trim()?t.name.trim():"Someone";o.push({id:t.id,name:n,path:t.editing})}return o}var m=class{constructor(){this.editors=[],this.root=null,this._gate=null,this._frame=0,this._following=!1,this._onMove=()=>this.schedule()}supported(){return this._gate||(this._gate=b("presence").then(e=>e===!0,()=>!1)),this._gate}async update(e){this.editors=A(e),await this.supported()&&await this.render()}clear(){this.editors=[],this.follow(!1),this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this.root&&this.root.remove(),this.root=null}schedule(){this._frame||(this._frame=requestAnimationFrame(()=>{this._frame=0,this.render()}))}render(){return p?(this.paint(),Promise.resolve()):$().then(e=>{e&&this.paint()})}paint(){let e=new Map;for(let t of this.editors){let n=v(t.path);n&&(e.has(n)||e.set(n,[]),e.get(n).push(t))}let o=[];for(let[t,n]of e){let r=this.box(t,n);r&&o.push(r)}if(!o.length){this.root&&(this.root.textContent="",u(this.root,"display","none")),this.follow(this.editors.length>0);return}this.build()&&(this.root.textContent="",this.root.append(...o),u(this.root,"display","block"),this.follow(!0))}box(e,o){let t=e.getBoundingClientRect();if(!(t.width||t.height))return null;let n=c(o[0].id),r=a(s("div",[...l,"position:fixed","box-sizing:border-box","pointer-events:none",`top:${Math.round(t.top-h)}px`,`left:${Math.round(t.left-h)}px`,`width:${Math.round(t.width+h*2)}px`,`height:${Math.round(t.height+h*2)}px`,`border:2px solid ${n}`,`box-shadow:0 0 0 1px ${d}, inset 0 0 0 1px ${d}`]));r.setAttribute("data-clay-editing-marker","");let M=t.top-h>=y+2,x=a(s("div",[...l,"position:absolute","left:-2px",M?"bottom:100%":"top:100%","display:flex","gap:2px","pointer-events:none"]));for(let g of o){let w=a(s("span",[...l,"box-sizing:border-box",`height:${y}px`,"padding:1px 6px",`font:${p.CHIP_FONT}`,"letter-spacing:.02em","white-space:nowrap","max-width:180px","overflow:hidden","text-overflow:ellipsis",`background-color:${c(g.id)}`,`color:${d}`,`box-shadow:0 0 0 1px ${d}`],g.name));w.setAttribute("data-clay-editing-chip",""),x.appendChild(w)}return r.appendChild(x),r}build(){return this.root&&this.root.isConnected?!0:typeof document>"u"||!document.body?!1:(this.root=a(s("div",[...l,"position:fixed","top:0","left:0","width:0","height:0","overflow:visible","z-index:2147482999","pointer-events:none","display:none"])),this.root.setAttribute("data-clay-editing",""),document.body.appendChild(this.root),!0)}follow(e){if(typeof window>"u"||!!e===this._following)return;this._following=!!e;let o=e?"addEventListener":"removeEventListener";window[o]("scroll",this._onMove,{capture:!0,passive:!0}),window[o]("resize",this._onMove,{passive:!0}),document[o]("input",this._onMove),document[o]("clay:sync-applied",this._onMove)}},N=new m;var O=N;export{m as EditingMarker,O as default,N as editingMarker};
1
+ import{a as _,d as v}from"./c-WN3MXOLT.js";import{b as c}from"./c-RVMWGXEJ.js";import{b as u,c as s}from"./c-NUHP2XDB.js";import{e as b}from"./c-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-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var d="#FFFCF6",l=["all:initial","color-scheme:inherit","direction:ltr","unicode-bidi:isolate"],y=18,h=3,p=null,f=null;function C(){return f??=Promise.all([import("./c-2ZZBC45O.js"),import("./c-ZE46QDIH.js")]).then(([i,e])=>p={RUNTIME_ONLY:i.RUNTIME_ONLY,CHIP_FONT:`600 11px/16px ${e.FONT_MONO}`}).catch(i=>{throw f=null,i}),f}var $=()=>C().then(()=>!0,()=>!1);function a(i){return i.setAttribute("clay",p.RUNTIME_ONLY),i}function A(i){let e=i&&Array.isArray(i.people)?i.people:[],o=[];for(let t of e){if(!t||t.you===!0||typeof t.id!="string"||!t.id||typeof t.editing!="string"||!_.test(t.editing))continue;let n=typeof t.name=="string"&&t.name.trim()?t.name.trim():"Someone";o.push({id:t.id,name:n,path:t.editing})}return o}var m=class{constructor(){this.editors=[],this.root=null,this._gate=null,this._frame=0,this._following=!1,this._onMove=()=>this.schedule()}supported(){return this._gate||(this._gate=b("presence").then(e=>e===!0,()=>!1)),this._gate}async update(e){this.editors=A(e),await this.supported()&&await this.render()}clear(){this.editors=[],this.follow(!1),this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this.root&&this.root.remove(),this.root=null}schedule(){this._frame||(this._frame=requestAnimationFrame(()=>{this._frame=0,this.render()}))}render(){return p?(this.paint(),Promise.resolve()):$().then(e=>{e&&this.paint()})}paint(){let e=new Map;for(let t of this.editors){let n=v(t.path);n&&(e.has(n)||e.set(n,[]),e.get(n).push(t))}let o=[];for(let[t,n]of e){let r=this.box(t,n);r&&o.push(r)}if(!o.length){this.root&&(this.root.textContent="",u(this.root,"display","none")),this.follow(this.editors.length>0);return}this.build()&&(this.root.textContent="",this.root.append(...o),u(this.root,"display","block"),this.follow(!0))}box(e,o){let t=e.getBoundingClientRect();if(!(t.width||t.height))return null;let n=c(o[0].id),r=a(s("div",[...l,"position:fixed","box-sizing:border-box","pointer-events:none",`top:${Math.round(t.top-h)}px`,`left:${Math.round(t.left-h)}px`,`width:${Math.round(t.width+h*2)}px`,`height:${Math.round(t.height+h*2)}px`,`border:2px solid ${n}`,`box-shadow:0 0 0 1px ${d}, inset 0 0 0 1px ${d}`]));r.setAttribute("data-clay-editing-marker","");let M=t.top-h>=y+2,x=a(s("div",[...l,"position:absolute","left:-2px",M?"bottom:100%":"top:100%","display:flex","gap:2px","pointer-events:none"]));for(let g of o){let w=a(s("span",[...l,"box-sizing:border-box",`height:${y}px`,"padding:1px 6px",`font:${p.CHIP_FONT}`,"letter-spacing:.02em","white-space:nowrap","max-width:180px","overflow:hidden","text-overflow:ellipsis",`background-color:${c(g.id)}`,`color:${d}`,`box-shadow:0 0 0 1px ${d}`],g.name));w.setAttribute("data-clay-editing-chip",""),x.appendChild(w)}return r.appendChild(x),r}build(){return this.root&&this.root.isConnected?!0:typeof document>"u"||!document.body?!1:(this.root=a(s("div",[...l,"position:fixed","top:0","left:0","width:0","height:0","overflow:visible","z-index:2147482999","pointer-events:none","display:none"])),this.root.setAttribute("data-clay-editing",""),document.body.appendChild(this.root),!0)}follow(e){if(typeof window>"u"||!!e===this._following)return;this._following=!!e;let o=e?"addEventListener":"removeEventListener";window[o]("scroll",this._onMove,{capture:!0,passive:!0}),window[o]("resize",this._onMove,{passive:!0}),document[o]("input",this._onMove),document[o]("clay:sync-applied",this._onMove)}},N=new m;var O=N;export{m as EditingMarker,O as default,N as editingMarker};
@@ -0,0 +1,7 @@
1
+ import{d as Ae,h as Ve,i as qe}from"./c-TRS6TM6O.js";import{a as Ne,b as Pe}from"./c-CSNE5EIF.js";import{a as Ie,b as Oe}from"./c-PZ4XEPUP.js";import"./c-SFKI6OLM.js";import"./c-Q3XOWZEV.js";import{e as ke,f as Ke,g as W,h as Ue,l as re,m as $e,n as p}from"./c-BJ7YQ5QZ.js";import"./c-4JZDZFF6.js";import{b as U,c as Z,e as l,f as Ye}from"./c-VAK7SG37.js";import{b as He}from"./c-MHI3GYKF.js";import"./c-RHMPKZZ7.js";import{b as T,c as Fe}from"./c-NUHP2XDB.js";import{a as We,q as V}from"./c-NLZ5AN4L.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import{f as Te}from"./c-GSRLXYWL.js";import"./c-X5LNHET5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-LA2BW7UY.js";import"./c-GVPNDIKJ.js";import"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import"./c-IJUK2GPW.js";import{f as _e}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 E="light-dark(#D08A1E, #E3A33F)",lt=5e3,st=4e3,dt=500,ct={"another-tab":"in another tab","another-person":"by someone else","an-agent":"by an agent"},pt='<svg viewBox="0 0 12 12" width="12" height="12" aria-hidden="true"><path d="M2.5 9.5h7" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="square"/></svg>',F=(e,t)=>`${e} ${t}${e===1?"":"s"}`,ut="This spot changed again. Review the latest edit or download your copy.",ft="A data value can't be put back from here. Download your copy to keep yours.",m="hidden",P=!1,S=[],J=new Set,M=new Set,h=null,Ee=0,I=null,v=null,le=null,u=null,R=!1,Y=!1,ve=!1,G=new Map,se=0,ae=!1,te=!1,b=null,j=null,L=null,Se=0,D=!1,de=0,ce=null,ne=null,k=[],x=[],oe=!1,pe=null,ue=null,s=null,B=null,q=new Map,z=()=>window.clay?.conflicts||null,Qe=()=>k.reduce((e,t)=>e+t.conflicts.length,0)+x.length,Le=()=>{let e=window.clay?.undo;return e&&typeof e.kept=="function"?e:null},fe=()=>z()?.list().filter(e=>!e.claimedBy&&e.kind!=="apply-incomplete")??[],De=()=>z()?.list().filter(e=>!e.claimedBy&&e.kind==="apply-incomplete")??[];function ze(){return I?"upgraded":h?"refused":fe().length?"replaced":De().length?"failed":k.length||x.length?"recovered":null}function f(e,t,n){let o=Fe(e,t,n);return t[0]==="all:initial"&&T(o,"color-scheme","inherit"),o.setAttribute("clay",ke),o}function _(e,t){return q.set(t,e),e}function ie(){if(!s)return;let e=window.visualViewport,t=e?Math.max(0,window.innerHeight-e.height-e.offsetTop):0;T(s,"bottom",`calc(${16+t}px + env(safe-area-inset-bottom,0px))`),ne&&T(ne,"max-height",`${Math.max(160,(e?.height||window.innerHeight)-32)}px`)}function ht(){s=f("div",["all:initial","position:fixed","left:50%","transform:translateX(-50%)","z-index:2147483001","display:none","flex-direction:column","align-items:center","max-width:calc(100vw - 24px)",`font:14px/1.5 ${U}`,`color:${l.ink}`,"text-align:left"]),s.setAttribute("data-clay-conflict",""),document.body.appendChild(s),window.visualViewport?.addEventListener("resize",ie),window.visualViewport?.addEventListener("scroll",ie)}function d(){if(ae)return;ae=!0;let e=()=>{ae=!1,w()};typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16)}function w(){te&&(te=!1,h&&!V()&&(h=null));let e=ze();if(e?m==="hidden"&&(m="bar"):(m="hidden",P=!1,J.clear(),M.clear(),S=[],y(),ce=null,D=!1),!s){if(m==="hidden"&&!b||!document.body)return;ht()}!s.isConnected&&document.body&&document.body.appendChild(s);let t=document.activeElement,n=null;for(let[a,r]of q)r===t&&(n=a);let o=B?B.scrollTop:0;q=new Map,B=null,ne=null,s.replaceChildren(),b?s.append(wt(b)):m==="bar"?s.append(yt(e)):m==="panel"&&s.append(xt(e)),T(s,"display",b||m!=="hidden"?"flex":"none"),B&&(B.scrollTop=o);let i=L||n;i&&q.has(i)&&q.get(i).focus({preventScroll:!0}),b||(L=null),ie(),He(s)}function Xe(){return f("span",["all:initial","display:inline-block","flex:none","width:8px","height:8px","border-radius:50%",`background:${E}`])}function Ze(){return ct[h?.changedBy]||null}function gt(e,t){if(e==="upgraded")return I;if(e==="refused"){let n=Ze();return!n&&h.afterTimeout?"This page changed elsewhere, possibly by your own save that timed out. Your edits here are safe.":`This page changed ${n||"elsewhere"}. Your edits here are safe.`}return e==="failed"?"A sync update did not finish. Your edits here are safe.":e==="recovered"?`${F(t,"change")} replaced before this page loaded ${t===1?"is":"are"} still here.`:`Another edit replaced ${F(t,"change")}.`}function mt(e,t){return e==="upgraded"?I:e==="refused"?`This page changed ${Ze()||"elsewhere"}`:e==="failed"?"A sync update did not finish":e==="recovered"?`${F(t,"change")} kept from before this page loaded`:`Another edit replaced ${F(t,"change")}`}function wt(e){let t=re("div",["display:block",`border-left:3px solid ${l.teal}`,"padding:10px 14px","width:max-content","max-width:calc(100vw - 24px)"]);return t.setAttribute("role","status"),t.textContent=e,t}function yt(e){let t=e==="failed"?De().length:e==="recovered"?Qe():fe().length,n=re("div",["display:flex","flex-wrap:wrap","align-items:center","gap:10px 12px","padding:8px 8px 8px 14px","width:max-content","max-width:calc(100vw - 24px)"]),o=gt(e,t);return o!==ce&&(n.setAttribute("role",e==="refused"?"alert":"status"),ce=o),n.append(Xe(),p("span",[],o)),e==="upgraded"?(n.append(_(W("Reload",{variant:"primary",onClick:()=>window.location.reload()}),"reload")),n):(n.append(_(W("Review",{onClick:Dt}),"review")),n)}function $(e,t,{variant:n="default",onClick:o,push:i=!1}={}){let r=window.innerWidth<480?["flex:1 1 100%",...n==="primary"?["order:-1"]:[]]:i?["margin-left:auto"]:[];return _(W(e,{variant:n,onClick:o,extra:r}),t)}function A(e){return p("div",["display:block","padding:0 16px 12px",`color:${l["ink-2"]}`,"font-size:13.5px"],e)}function xt(e){let t=e==="replaced"?fe():e==="failed"?De():[],n=e==="refused"?fe():t,o=e==="recovered"?Qe():t.length;if(J.size)for(let c of t)J.has(c.id)||M.add(c.id);for(let c of[...M])t.some(N=>N.id===c)||M.delete(c);let i=mt(e,o),a=Math.max(160,(window.visualViewport?.height||window.innerHeight)-32),r=re("div",["display:flex","flex-direction:column","width:520px","max-width:calc(100vw - 24px)",`max-height:${a}px`]);ne=r,r.setAttribute("role","dialog"),r.setAttribute("aria-label",i);let g=f("div",["all:initial","display:flex","align-items:center","gap:8px","padding:12px 12px 8px 16px",`font:14px/1.5 ${U}`,`color:${l.ink}`]),K=_(p("b",["font-weight:600","font-size:14.5px","outline:none"],i),"title");K.setAttribute("tabindex","-1"),g.append(Xe(),K),e==="replaced"&&M.size&&g.append(p("span",[`font:600 10.5px/1 ${Z}`,"letter-spacing:.12em","text-transform:uppercase","padding:3px 6px",`color:color-mix(in srgb, ${l.brass} 80%, ${l.ink})`,`background:${l["brass-soft"]}`],`${M.size} new`));let X=f("span",["all:initial","display:inline-flex","margin-left:auto"]),Be=_(Ue(pt,{label:"Minimize",onClick:Je}),"minimize");if(Be.title="Minimize to the bar. Nothing is accepted until you choose.",X.append(Be),g.append(X),r.append(g),e==="recovered")return Et(r),r;if(e==="refused"){if(r.append(A("Your edits here are safe and not saved yet; nothing will be overwritten until you choose. Their version is not on this page, so there is no list of edits to compare. Keep yours, which saves over theirs, or accept theirs, which reloads the page and drops your unsaved edits.")),n.length&&r.append(A(`${F(n.length,"earlier replaced edit")} ${n.length===1?"is":"are"} also held in this tab. Download my copy includes them.`)),R&&r.append(A("That did not save either. Your edits here are still here.")),D&&r.append(A("Something changed on the page after your first press, so nothing was dropped. Press Accept theirs again if you still want their version.")),v){let c=f("div",["all:initial","display:block","margin:0 16px 12px","padding:8px 10px",`border-left:3px solid ${E}`,`background:color-mix(in srgb, ${E} 14%, transparent)`,`color:${l.ink}`,`font:13px/1.5 ${U}`]);c.append(f("b",["all:initial","font:inherit","font-weight:700","color:inherit"],"This drops your unsaved edits."),document.createTextNode(" Download your copy first if you might want them. Press again to confirm.")),r.append(c)}}else e==="upgraded"?r.append(A("Its layout and code changed with it, so this page stops here. Reload to see the new version.")):e==="failed"?r.append(A("Part of an update from elsewhere could not be applied, so this page may be missing some of it. Your edits here are safe. Download a copy of the page as you had it, or accept to keep the page as it is.")):r.append(A("The page is showing the other edit. This stays until you choose. You can also save a copy of the page as you had it."));let O=f("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","padding:0 16px 14px"]);if(e==="upgraded")return O.append($("Reload","reload",{variant:"primary",onClick:()=>window.location.reload(),push:!0})),r.append(O),S=[],r;let at=$(ve?"Try again":Y?"Downloaded":"Download my copy","download",{onClick:Bt});if(O.append(at),e==="refused"){let c=$(u==="overwrite"?"Saving\u2026":R?"Try again":"Keep mine","keep",{onClick:Pt});c.setDisabled(u==="overwrite"),O.append(c,$(v?"Yes, drop my edits":"Accept theirs","accept",{variant:"primary",onClick:Ft,push:!0}))}else{if(e==="replaced"){let c=z().hasPendingApply(),N=$(c?"Finishing the incoming edit\u2026":u==="revert"?"Putting back\u2026":"Revert to mine","revert",{onClick:Mt});N.setDisabled(c||u==="revert"),O.append(N)}O.append($("Accept theirs","accept",{variant:"primary",onClick:zt,push:!0}))}if(r.append(O),e==="replaced")if(P)r.append(vt(t));else{let c=f("div",["all:initial","display:flex","align-items:center","gap:8px",`border-top:1px solid ${l.line}`,"padding:8px 10px 8px 16px",`color:${l.muted}`,`font:13px/1.5 ${U}`]),N=f("span",["all:initial","display:inline-flex","margin-left:auto"]);N.append(_(W("See the edits",{small:!0,onClick:et}),"list")),c.append(f("span",["all:initial","font:inherit","color:inherit"],F(t.length,"edit")),N),r.append(c)}S=n.map(c=>c.id);for(let c of t)J.add(c.id);return r}function vt(e){let t=$e(["flex:1 1 auto","margin:0 16px 12px","min-height:0","overflow:auto",`background:${l.sunk}`,`border:1px solid ${l["line-2"]}`]),n=f("div",["all:initial","position:sticky","top:0","z-index:1","display:flex","align-items:center","gap:8px","padding:8px 12px",`background:${l.sunk}`,`border-bottom:1px solid ${l["line-2"]}`,`color:${l.muted}`,`font:600 10.5px/1 ${Z}`,"letter-spacing:.12em","text-transform:uppercase"]),o=f("span",["all:initial","display:inline-flex","margin-left:auto"]);return o.append(_(W("Hide",{small:!0,variant:"quiet",onClick:et}),"list")),n.append(f("span",["all:initial","font:inherit","color:inherit","letter-spacing:inherit","text-transform:inherit"],"Replaced edits"),o),t.append(n),e.forEach((i,a)=>t.append(St(i,a))),B=t,t}function Me(e){let t=e.context?.label||e.name||(e.context?.kind==="entry"?"Entry":"Edit");return e.context?.field?`${t} \xB7 ${e.context.field}`:t}var bt={"content-changed":"the page changed there","structure-changed":"the structure changed there","target-detached":"that part of the page is gone","duplicate-id":"another part of the page now has the same id",protected:"that region keeps its own history",unsupported:"this kind of step cannot be put back"},kt=e=>bt[e]||"the page changed there";function $t(e,t){let n=Array.isArray(e)?e:[];for(let o of n){if(!o||o.kind!=="text"&&o.kind!=="value")continue;let i=t==="redo"?o.after:o.before;if(typeof i=="string"&&i)return{text:i,id:o.target?.id??null}}for(let o of n){if(!o||o.kind!=="add"&&o.kind!=="remove")continue;let i=Array.isArray(o.nodes)?o.nodes.find(a=>typeof a?.html=="string"&&a.html):null;if(i)return{text:Ie(i.html).replace(/\s+/g," ").trim(),id:o.parent?.id??null}}for(let o of n){if(!o)continue;let i=t==="redo"?o.after:o.before;if(typeof i=="string"&&i)return{text:i,id:o.target?.id??null}}return{text:"",id:null}}function Tt(e){if(e==null||typeof document>"u")return"";let t=window.CSS?.escape?window.CSS.escape(String(e)):String(e).replace(/["\\]/g,"\\$&"),n=null;try{n=document.querySelector(`[data-id="${t}"]`)}catch{return""}if(!n)return"";let o=n.matches?.("input, textarea, select")?n.value:null;return(typeof o=="string"?o:n.textContent??"").replace(/\s+/g," ").trim()}function At(e){let t=e?.payload&&typeof e.payload=="object"?e.payload:{},n=String(e?.key??""),o={id:e?.id,revision:e?.revision,record:e,kind:e?.kind??"conflict"};if(n.startsWith("app:"))return{...o,name:typeof t.label=="string"&&t.label?t.label:n.slice(4),sentence:"",yours:typeof t.text=="string"?t.text:"",now:""};let i=t.direction==="redo"?"redo":"undo",g=((Array.isArray(t.context)?t.context:[]).find(X=>typeof X?.label=="string"&&X.label)??null)?.label||typeof t.label=="string"&&t.label||"Edit",K=$t(t.steps,i);return{...o,name:g,sentence:`The ${i} of "${g}" was not applied because ${kt(t.code)}.`,yours:K.text,now:K.id==null?"":Tt(K.id)}}function Ct(e){let t=Le();if(!e.record||typeof t?.reviewActionsFor!="function")return[];try{return(t.reviewActionsFor(e.record)||[]).filter(n=>n&&typeof n.run=="function"&&n.label)}catch{return[]}}var Ge=e=>({before:"",hit:e,after:"",cutBefore:!1,cutAfter:!1});function je(e){let t=p("div",["display:block","padding:8px 12px 10px"]),n=p("div",["display:flex","align-items:center","gap:8px","font-size:12.5px","font-weight:600",`color:${l["ink-2"]}`,"margin-bottom:4px"]);if(n.append(p("span",[],Me(e))),t.append(n),e.sentence&&t.append(p("div",["display:block","font-size:13px",`color:${l["ink-2"]}`],e.sentence)),e.yours){let i=p("div",["display:grid","grid-template-columns:44px 1fr","gap:3px 10px","align-items:start",`font:12.5px/1.5 ${Z}`,...e.sentence?["margin-top:4px"]:[]]);i.append(...he("Yours",Ge(e.yours),{mine:!0})),e.now&&i.append(...he("Now",Ge(e.now),{mine:!1})),t.append(i)}let o=f("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","margin-top:8px"]);return Ct(e).forEach((i,a)=>{let r=$(i.label,`run:${e.id}:${a}`,{onClick:()=>Nt(e,i,r)});o.append(r)}),o.append($(pe===e.id?"Copied":"Copy",`copy:${e.id}`,{onClick:()=>It(e)})),o.append($("Dismiss",`dismiss:${e.id}`,{onClick:()=>tt(e)})),t.append(o),t}function Et(e){e.append(A(k.length?"These copies were replaced before this page loaded. The page never puts them back on its own. Copy or download the ones you want; dismiss one when you no longer need it.":"These copies were kept because an undo could not be put back or the page set them aside. The page never puts them back on its own. Copy or download the ones you want; dismiss one when you no longer need it.")),oe&&e.append(A("That action did not run. The copy is still here."));let t=$e(["flex:1 1 auto","margin:0 16px 12px","min-height:0","overflow:auto",`background:${l.sunk}`,`border:1px solid ${l["line-2"]}`]);for(let o of k)for(let i of o.conflicts)t.append(je(i));for(let o of x)t.append(je(o));B=t,e.append(t);let n=f("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","padding:0 16px 14px"]);(k.some(o=>o.root)||x.length)&&n.append($(Y?"Downloaded":"Download my copy","download",{onClick:Ot})),e.append(n),S=[]}function he(e,t,{mine:n}){let o=[p("span",[`color:${l.faint}`,`font-family:${U}`],e)],i=p("span",["display:-webkit-box","-webkit-line-clamp:2","-webkit-box-orient:vertical","overflow:hidden","overflow-wrap:anywhere",...n?[`color:${l.ink}`]:[`color:${l.muted}`]]),a=(t.cutBefore?"\u2026":"")+t.before+t.hit+t.after+(t.cutAfter?"\u2026":"");i.title=a,t.before&&i.append(p("span",[`color:${l.faint}`],(t.cutBefore?"\u2026":"")+t.before));let r=p("span",n?[`background:color-mix(in srgb, ${E} 18%, transparent)`,"padding:0 4px"]:t.before||t.after?["text-decoration:underline",`text-decoration-color:color-mix(in srgb, ${E} 70%, transparent)`,"text-underline-offset:3px"]:[],t.hit||"(empty)");return i.append(r),t.after&&i.append(p("span",[`color:${l.faint}`],t.after+(t.cutAfter?"\u2026":""))),o.push(i),o}function St(e,t){let n=Oe(e),o=p("div",["display:block","padding:8px 12px 10px",...t?[`border-top:1px solid ${l.line}`]:[]]),i=p("div",["display:flex","align-items:center","gap:4px","font-size:12.5px","font-weight:600",`color:${l["ink-2"]}`,"margin-bottom:4px"]);if(i.append(p("span",[],n.name)),n.target&&n.target.isConnected&&i.append(_(Rt(n),`eye:${e.id}`)),o.append(i),n.sentence&&o.append(p("div",["display:block","font-size:13px",`color:${l["ink-2"]}`],n.sentence)),G.has(e.id)&&o.append(p("div",["display:block","font-size:13px","margin-top:4px",`color:${E}`],G.get(e.id))),n.yours){let a=p("div",["display:grid","grid-template-columns:44px 1fr","gap:3px 10px","align-items:start",`font:12.5px/1.5 ${Z}`,...n.sentence?["margin-top:4px"]:[]]);a.append(...he("Yours",n.yours,{mine:!0})),n.now&&a.append(...he("Now",n.now,{mine:!1})),o.append(a)}return o}function Rt(e){let t=["all:initial","color-scheme:inherit","box-sizing:border-box","cursor:pointer","display:inline-grid","place-items:center","width:22px","height:20px",`color:${l.ink}`],n=f("button",t);n.type="button",n.innerHTML=Ye.conflictEye,Ke(n.firstElementChild,16),n.setAttribute("aria-label",`Show ${e.name} on page`),n.title="Show on page";let o=i=>{n.style.cssText="";for(let a of[...t,...i]){let r=a.indexOf(":");n.style.setProperty(a.slice(0,r),a.slice(r+1),"important")}};return n.addEventListener("pointerenter",()=>o([`background:color-mix(in srgb, ${E} 16%, transparent)`])),n.addEventListener("pointerleave",()=>o([])),n.addEventListener("focus",()=>o([`outline:2px solid ${l.brass}`,"outline-offset:1px"])),n.addEventListener("blur",()=>o([])),n.addEventListener("click",()=>Lt(e.target)),n}var C=null,ge=null,me=null;function we(){clearTimeout(ge),window.removeEventListener("scroll",ee,!0),window.removeEventListener("resize",ee),C?.remove(),C=null,me=null}function ee(){if(!C||!me)return;let e=me.getBoundingClientRect();T(C,"left",`${e.left}px`),T(C,"top",`${e.top}px`),T(C,"width",`${e.width}px`),T(C,"height",`${e.height}px`)}function Lt(e){if(we(),!e||!e.isConnected)return;let n=!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches?"instant":"smooth",o=s?.getBoundingClientRect().top??0,i=s&&o>0?Math.max(0,window.innerHeight-o):0;if(!i)e.scrollIntoView?.({block:"center",behavior:n});else{e.scrollIntoView?.({block:"center",behavior:"instant"});let a=e.getBoundingClientRect(),r=window.innerHeight-i,g=a.height>r-24?a.top-12:a.top+a.height/2-r/2;window.scrollBy?.({top:g,behavior:n})}me=e,C=f("div",["all:initial","color-scheme:inherit","position:fixed","pointer-events:none","z-index:2147483001",`outline:2px solid ${E}`,"outline-offset:3px",`background:color-mix(in srgb, ${E} 14%, transparent)`]),document.body.appendChild(C),ee(),window.addEventListener("scroll",ee,!0),window.addEventListener("resize",ee),ge=setTimeout(we,2500)}function Dt(){I||(m="panel",L="title",w())}function Je(){we(),m="bar",y(),L="review",w()}function et(){P=!P,P&&M.clear(),w()}function zt(){let e=z(),t=S.filter(n=>{let o=e?.get(n);return o&&!o.claimedBy});e&&t.length&&e.acknowledge(t,{reason:"accepted"}),m=ze()?"bar":"hidden",L="review",d()}async function Mt(){let e=z();if(u||!e||e.hasPendingApply())return;let t=S.filter(r=>{let g=e.get(r);return g&&!g.claimedBy});if(!t.length)return;u="revert",w();let n=!0,o=r=>{n=!!s?.contains(r.target)};document.addEventListener("focus",o,!0);let i;try{let{revertConflicts:r}=await import("./c-LIBE4HPD.js");i=await r(t)}catch(r){console.error("[clay] Revert to mine did not finish",r),i={revertedIds:[],blockedIds:t,saveResult:null}}finally{document.removeEventListener("focus",o,!0)}u=null;for(let r of i.blockedIds)G.set(r,z()?.get(r)?.kind==="json"?ft:ut);m=ze()?"bar":"hidden",L=n?"review":null;let a=i.saveResult&&(i.saveResult.ok||i.saveResult.msg==="Save already in progress");i.revertedIds.length&&a?be(`Put back ${F(i.revertedIds.length,"change")}. Saving.`):w()}var Q=null;async function Bt(){let e=z(),t=h?e?.list()??[]:S.map(o=>e?.get(o)).filter(Boolean),n=await Pe(t,{refused:!!h});ve=!n,Y=n,clearTimeout(Q),n&&(Q=setTimeout(()=>{Y=!1,d()},1200)),w()}async function H(){let e=null;if(Ae())try{e=await Ve()}catch{e=null}let t=Le(),n=null;if(t)try{n=await t.kept()}catch{n=null}let o=!1;if(e?.ok?(k=e.records,o=!0):!Ae()&&k.length&&(k=[],o=!0),n?.ok){let i=(Array.isArray(n.records)?n.records:[]).filter(r=>r&&r.supported!==!1).map(At);i.length===x.length&&i.every((r,g)=>r.id===x[g].id&&r.revision===x[g].revision)||(o=!0),x=i}else n&&x.length&&(x=[],o=!0);o&&d()}async function _t(e){try{return await navigator.clipboard.writeText(e),!0}catch{}let t=document.createElement("textarea");t.value=e,t.setAttribute("clay",ke),t.style.setProperty("position","fixed","important"),t.style.setProperty("opacity","0","important"),document.body?.append(t),t.select();let n=!1;try{n=document.execCommand?.("copy")===!0}catch{}return t.remove(),n}async function It(e){let t=e.record?e.yours:`${Me(e)}
2
+
3
+ Yours:
4
+ ${e.yours}
5
+
6
+ Now:
7
+ ${e.now}`;if(!await _t(t)){be("Could not copy. Select the text instead.");return}pe=e.id,clearTimeout(ue),ue=setTimeout(()=>{pe=null,d()},1200),w()}async function Ot(){let e=k.find(o=>o.root),t=[];for(let o of k)for(let i of o.conflicts)t.push({id:i.id,kind:i.kind,name:Me(i),yours:i.yours,now:i.now,sentence:i.sentence});for(let o of x)t.push({id:o.id,kind:o.kind,name:o.name,yours:o.yours,now:o.now,sentence:o.sentence});let n=await Ne({html:e?.root??null,edits:t});ve=!n,Y=n,clearTimeout(Q),n&&(Q=setTimeout(()=>{Y=!1,d()},1200)),w()}async function tt(e){let t;try{t=e.record?await Le()?.dismissKept(e.id,{revision:e.revision}):await qe([e.id]),t||={ok:!1}}catch{t={ok:!1}}t.ok||be("That copy could not be dismissed."),await H(),d()}var Ce=new Set;async function Nt(e,t,n=null){if(!Ce.has(t)){Ce.add(t),n&&(n.disabled=!0,n.setAttribute("aria-busy","true")),oe=!1;try{let o=null;try{o=await t.run(e.record)}catch{o=null}if(o?.ok===!0&&o?.dismiss===!0){await tt(e);return}oe=o?.ok!==!0,await H(),d()}finally{Ce.delete(t),n&&n.isConnected&&(n.disabled=!1,n.removeAttribute("aria-busy"))}}}function nt(e){e?.detail?.ok===!0&&(oe=!1,H(),d())}function y(){clearTimeout(le),le=null,v=null}async function Pt(){if(u)return;let e=++de;u="overwrite",R=!1,y(),w();let t;try{t=await window.clay?.save?.overwrite?.()}catch{t={ok:!1}}e!==de||u!=="overwrite"||(!t?.ok&&V()&&(u=null,R=!0),d())}function Ft(){if(!v){v={refusalGeneration:Ee,ledgerRevision:se,dirtyGeneration:Te().gen},Se=Date.now(),D=!1,clearTimeout(le),le=setTimeout(()=>{y(),d()},lt),w();return}if(Date.now()-Se<dt)return;let e=v;We({isCurrent:()=>v===e&&e.refusalGeneration===Ee&&e.ledgerRevision===se&&e.dirtyGeneration===Te().gen,reload:()=>window.location.reload()})||(y(),D=!0,w())}function be(e){b=e,clearTimeout(j),j=setTimeout(()=>{b=null,d()},st),w()}function Yt(){H(),d()}function ot(){se++,v&&y();for(let e of[...G.keys()])z()?.get(e)||G.delete(e);H(),d()}function it(e){I=e?.detail&&e.detail.message||"This document was upgraded.",b=null,clearTimeout(j),y(),u=null,R=!1,D=!1,m="bar",d()}function rt(e){let t=e?.detail||{};h={generation:++Ee,changedBy:t.changedBy,afterTimeout:!!t.afterTimeout,etag:t.etag??null},b=null,clearTimeout(j),y(),u=null,R=!1,de++,D=!1,d()}function Re(e){if(V()){e.type==="clay:save-saved"&&queueMicrotask(()=>{V()||Re(e)});return}let t=u==="overwrite"&&e.type==="clay:save-saved";(h||u)&&(h=null,u=null,R=!1,D=!1,y()),t?be("Saved your version over theirs."):d()}function Ht(){h&&(te=!0,d())}function Kt(){!h||V()||(h=null,u=null,R=!1,D=!1,y(),d())}function Ut(e){if(e.key!=="Escape")return;if(v){e.preventDefault(),y(),w();return}if(m!=="panel")return;let t=document.activeElement;t&&t!==document.body&&!s?.contains(t)||(e.preventDefault(),Je())}function Wt(e){!v||s?.contains(e.target)||(y(),d())}function Vt(e){b&&L&&!s?.contains(e.target)&&(L=null)}function qt(){xe=new AbortController;let{signal:e}=xe;document.addEventListener("clay:document-upgraded",it,{signal:e}),_e&&(document.addEventListener("clay:sync-conflicts-changed",ot,{signal:e}),document.addEventListener("clay:unsaved-state-changed",d,{signal:e}),document.addEventListener("clay:save-conflict",rt,{signal:e}),document.addEventListener("clay:save-saved",Re,{signal:e}),document.addEventListener("clay:save-conflict-resolved",Re,{signal:e}),document.addEventListener("clay:sync-applied",Ht,{signal:e}),document.addEventListener("clay:save-conflict-released",Kt,{signal:e}),document.addEventListener("keydown",Ut,{signal:e}),document.addEventListener("input",Wt,{capture:!0,signal:e}),document.addEventListener("focus",Vt,{capture:!0,signal:e}),document.addEventListener("clay:conflict-store-changed",Yt,{signal:e}),document.addEventListener("clay:undo-kept",nt,{signal:e}),z()?.size&&d(),H(),Promise.resolve(window.clay?.ready).catch(()=>{}).then(()=>{e.aborted||H()}))}var Gt={"clay:sync-conflicts-changed":ot,"clay:save-conflict":rt,"clay:document-upgraded":it,"clay:undo-kept":nt},ye=!1,xe=null;function an(e){ye||(ye=!0,qt());let t=e&&Gt[e.type];t&&t(e),h&&(te=!0,d())}function ln(){ye&&(ye=!1,xe?.abort(),xe=null,y(),clearTimeout(j),j=null,clearTimeout(Q),Q=null,clearTimeout(ue),ue=null,clearTimeout(ge),ge=null,we(),window.visualViewport?.removeEventListener("resize",ie),window.visualViewport?.removeEventListener("scroll",ie),s?.remove(),s=null,q=new Map,B=null,ne=null,m="hidden",P=!1,S=[],J.clear(),M.clear(),G.clear(),b=null,h=null,I=null,u=null,R=!1,de++,v=null,Se=0,D=!1,k=[],x=[],oe=!1,ae=!1,te=!1,L=null,ce=null,Y=!1,ve=!1,pe=null)}var sn={state:()=>({view:m,listOpen:P,renderedIds:S.slice(),refused:h,armed:v,busy:u,ledgerRevision:se,upgraded:I}),render:w,resetUpgrade:()=>{I=null}};export{E as WARN,sn as _test,d as schedule,an as start,ln as stop,be as toast};