@panphora/clayjs 1.24.1 → 1.25.1

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 (275) hide show
  1. package/dist/all.js +1 -1
  2. package/dist/clay-dom.js +1 -1
  3. package/dist/clay-events.js +1 -1
  4. package/dist/clay-internals.js +1 -1
  5. package/dist/clay-options.js +1 -1
  6. package/dist/clay-router.js +1 -1
  7. package/dist/clay-ui.js +1 -1
  8. package/dist/clay-utils.js +1 -1
  9. package/dist/clay.js +1 -1
  10. package/dist/clay.standalone.js +6060 -4662
  11. package/dist/m/attrs/{refetch-on-save-DPGJJMGN.js → refetch-on-save-5CBFUJUF.js} +1 -1
  12. package/dist/m/attrs/save-freeze-PUYX32AK.js +1 -0
  13. package/dist/m/{c-HIX5H5L7.js → c-2A2ATCIH.js} +1 -1
  14. package/dist/m/{c-BOMQIQ3V.js → c-2EFMJYGJ.js} +1 -1
  15. package/dist/m/{c-MP6S4AZU.js → c-2GB34XL4.js} +2 -2
  16. package/dist/m/c-2TJCFPX4.js +4 -0
  17. package/dist/m/c-33SS5A4Y.js +1 -0
  18. package/dist/m/{c-PCNJETUA.js → c-34J5HC7N.js} +1 -1
  19. package/dist/m/{c-AT7GLQGV.js → c-3AAQJAKJ.js} +1 -1
  20. package/dist/m/c-3F3AADKG.js +1 -0
  21. package/dist/m/{c-HL6BLJNA.js → c-3WX5FABT.js} +1 -1
  22. package/dist/m/c-3XNTQQEJ.js +1 -0
  23. package/dist/m/{c-ZRGEN6QQ.js → c-3Y234AUB.js} +2 -2
  24. package/dist/m/{c-SUXHUL7U.js → c-42RLKGEY.js} +1 -1
  25. package/dist/m/{c-2BLVA6IN.js → c-44WITKWQ.js} +1 -1
  26. package/dist/m/c-47M4QHCK.js +1 -0
  27. package/dist/m/{c-UOUUI265.js → c-4M2T676V.js} +1 -1
  28. package/dist/m/{c-SXGEWPFC.js → c-4NAYDOWH.js} +1 -1
  29. package/dist/m/{c-OCYG4NBQ.js → c-4OZZ7ENT.js} +2 -2
  30. package/dist/m/{c-UOOIF2AL.js → c-5IIEOPIV.js} +1 -1
  31. package/dist/m/{c-YDW4VCHP.js → c-755ZOHOM.js} +1 -1
  32. package/dist/m/c-7Q4XYDF4.js +1 -0
  33. package/dist/m/c-7RHOMAMR.js +1 -0
  34. package/dist/m/{c-7V6MGMX2.js → c-7Z2625LX.js} +1 -1
  35. package/dist/m/{c-CTGRDT6E.js → c-A3OKSYRI.js} +1 -1
  36. package/dist/m/{c-GNI7WHKF.js → c-A5IYL7JI.js} +1 -1
  37. package/dist/m/c-A5LASUEZ.js +1 -0
  38. package/dist/m/c-AQVQKFKB.js +1 -0
  39. package/dist/m/{c-FLEIU6CG.js → c-ASGHHLFX.js} +1 -1
  40. package/dist/m/c-ASMLERFA.js +7 -0
  41. package/dist/m/{c-LUXAB2XI.js → c-AZM34SPO.js} +1 -1
  42. package/dist/m/{c-ZFO5RW6G.js → c-BHLYQGTA.js} +1 -1
  43. package/dist/m/{c-C5AKJVRH.js → c-BJ2RRQBQ.js} +1 -1
  44. package/dist/m/{c-FVPNX2GO.js → c-C27EVUQ6.js} +1 -1
  45. package/dist/m/{c-DFKBGSN2.js → c-C5UGNOC2.js} +1 -1
  46. package/dist/m/c-C6DXZIXD.js +1 -0
  47. package/dist/m/{c-EDE45NM7.js → c-C7SUMNMI.js} +1 -1
  48. package/dist/m/{c-STRI73GQ.js → c-CL5LSATX.js} +1 -1
  49. package/dist/m/c-CPRGR2II.js +1 -0
  50. package/dist/m/{c-NFQFV7OP.js → c-D2OPWOWO.js} +1 -1
  51. package/dist/m/{c-ZKKAF4UT.js → c-D4N4UJCQ.js} +2 -2
  52. package/dist/m/{c-6LEYVQJK.js → c-DAUQ6JZ3.js} +1 -1
  53. package/dist/m/{c-ZGCO4J3H.js → c-DDCYVLGG.js} +1 -1
  54. package/dist/m/{c-KQKKIVLW.js → c-DVMDYRAE.js} +1 -1
  55. package/dist/m/{c-OG6GFSUX.js → c-DYTBSJBI.js} +1 -1
  56. package/dist/m/{c-P2HKMJAW.js → c-EAV7A6BT.js} +1 -1
  57. package/dist/m/{c-X75G43SZ.js → c-EEWPNUM2.js} +1 -1
  58. package/dist/m/c-EHAR4RJJ.js +3 -0
  59. package/dist/m/c-EIDZHQHZ.js +1 -0
  60. package/dist/m/c-ELXMSEN5.js +1 -0
  61. package/dist/m/{c-QQFHEODI.js → c-EQ5NBOGA.js} +1 -1
  62. package/dist/m/c-FC5RUFPR.js +1 -0
  63. package/dist/m/{c-ND3Q2G2I.js → c-GFASNR55.js} +1 -1
  64. package/dist/m/{c-A4L7APIU.js → c-GNFDX6SU.js} +1 -1
  65. package/dist/m/{c-LATNQ6Q5.js → c-H3M6UDNV.js} +1 -1
  66. package/dist/m/{c-YLHTD3KX.js → c-H4M2T4A6.js} +1 -1
  67. package/dist/m/{c-DDS23EY6.js → c-HXGNH6GY.js} +1 -1
  68. package/dist/m/{c-PDBNCJCT.js → c-HYNM5U6B.js} +1 -1
  69. package/dist/m/c-J2YYLEVM.js +1 -0
  70. package/dist/m/c-J2ZW4HMR.js +1 -0
  71. package/dist/m/{c-WCG6AKA7.js → c-JC4RZW4E.js} +1 -1
  72. package/dist/m/c-K2ZHQMPF.js +1 -0
  73. package/dist/m/{c-6IJEVE6B.js → c-KU3PX7LL.js} +1 -1
  74. package/dist/m/{c-YYMZWQLR.js → c-L6KVXPBO.js} +1 -1
  75. package/dist/m/{c-CV4T65JE.js → c-LUBZU4AZ.js} +4 -4
  76. package/dist/m/{c-5FXEKU4Y.js → c-LYNLY3MR.js} +1 -1
  77. package/dist/m/{c-NQAPWM7O.js → c-MHTO3QAD.js} +1 -1
  78. package/dist/m/{c-HDVH3MVC.js → c-MKAUC6DB.js} +1 -1
  79. package/dist/m/c-MLMJUNRV.js +1 -0
  80. package/dist/m/c-MMEVDN6D.js +1 -0
  81. package/dist/m/c-MOP5KBWZ.js +1 -0
  82. package/dist/m/{c-LA2BW7UY.js → c-MZCOGNZL.js} +1 -1
  83. package/dist/m/{c-XW5TIYYB.js → c-N4GEJMXW.js} +1 -1
  84. package/dist/m/{c-RS77ODLY.js → c-NL4I4KNG.js} +1 -1
  85. package/dist/m/{c-2PVGJFI5.js → c-NW4ZFKCY.js} +1 -1
  86. package/dist/m/{c-PYG2NGWU.js → c-O3DPFZCE.js} +1 -1
  87. package/dist/m/c-O4YIDULY.js +1 -0
  88. package/dist/m/{c-LTSPHVAK.js → c-OBMZASYQ.js} +1 -1
  89. package/dist/m/c-OZOACVUD.js +1 -0
  90. package/dist/m/{c-YK2L436K.js → c-OZVK3TFI.js} +1 -1
  91. package/dist/m/c-P73XPAOA.js +1 -0
  92. package/dist/m/c-PP3CUF3U.js +1 -0
  93. package/dist/m/{c-B7GOFGQR.js → c-Q2CB57UG.js} +1 -1
  94. package/dist/m/{c-TWCXBWS3.js → c-QCDVDZIR.js} +1 -1
  95. package/dist/m/{c-LSVN3OLG.js → c-QL4NYM2L.js} +1 -1
  96. package/dist/m/c-RES2S5Q3.js +1 -0
  97. package/dist/m/c-RFGELYEU.js +2 -0
  98. package/dist/m/c-RGFPLQGV.js +1 -0
  99. package/dist/m/c-SMLAJASY.js +1 -0
  100. package/dist/m/{c-MQKSKQHG.js → c-STAPQ2X6.js} +1 -1
  101. package/dist/m/c-SYVF6ZMF.js +1 -0
  102. package/dist/m/{c-SE3SIY7Y.js → c-T5IWJOMW.js} +1 -1
  103. package/dist/m/{c-DD26VXAP.js → c-T7LOTEWO.js} +1 -1
  104. package/dist/m/{c-47IBJGPQ.js → c-TWB5ZQU4.js} +1 -1
  105. package/dist/m/c-U35T5NAY.js +1 -0
  106. package/dist/m/c-U4TWEIKZ.js +1 -0
  107. package/dist/m/c-UW6MMZ4V.js +1 -0
  108. package/dist/m/{c-JWDCQL6J.js → c-V5L6HWVL.js} +1 -1
  109. package/dist/m/c-VGG3UR7I.js +1 -0
  110. package/dist/m/{c-CZHTXGJS.js → c-VO6RSFCO.js} +1 -1
  111. package/dist/m/c-VU4WEWPH.js +4 -0
  112. package/dist/m/c-W7LWCJHD.js +1 -0
  113. package/dist/m/c-WOJ2RTV4.js +1 -0
  114. package/dist/m/{c-T3P3AXEW.js → c-WOWGGNCJ.js} +1 -1
  115. package/dist/m/{c-6RGEQNVV.js → c-XCOQNISP.js} +1 -1
  116. package/dist/m/{c-SGGGCIVD.js → c-XS7G6U3Z.js} +1 -1
  117. package/dist/m/{c-4PO3YGDC.js → c-Y3J5LDKB.js} +1 -1
  118. package/dist/m/c-Y3MPVURA.js +1 -0
  119. package/dist/m/c-Y6HH7LTM.js +1 -0
  120. package/dist/m/{c-RO73MKKR.js → c-YRDKVEGR.js} +1 -1
  121. package/dist/m/{c-FEC6LGFF.js → c-YZGWSCMT.js} +1 -1
  122. package/dist/m/{c-7CM4GMTS.js → c-ZJ7726FO.js} +1 -1
  123. package/dist/m/{c-SKMIR5HQ.js → c-ZPI7M5U5.js} +1 -1
  124. package/dist/m/core/{admin-attrs-ONRWVXPK.js → admin-attrs-43JBA6JB.js} +1 -1
  125. package/dist/m/core/{autosave-TBKAAAFB.js → autosave-HD7Y7UNV.js} +1 -1
  126. package/dist/m/core/{conflict-notice-FOEE6I7E.js → conflict-notice-Y2NTMDGJ.js} +1 -1
  127. package/dist/m/core/draft-mode-M5XNYBMY.js +1 -0
  128. package/dist/m/core/{host-permission-X4BENZEU.js → host-permission-5BYP24GC.js} +1 -1
  129. package/dist/m/core/{is-edit-mode-FFHCQ5DR.js → is-edit-mode-73OXKK5H.js} +1 -1
  130. package/dist/m/core/{persist-6ILUR34S.js → persist-MX3VYVBN.js} +1 -1
  131. package/dist/m/core/{recovery-APWADU4K.js → recovery-VZF7RJZF.js} +1 -1
  132. package/dist/m/core/{save-6HT2LABE.js → save-JZ7R4ET2.js} +1 -1
  133. package/dist/m/core/{save-core-EVMNZQ4V.js → save-core-I4N6S4ED.js} +1 -1
  134. package/dist/m/core/{site-edits-G4BOZMV4.js → site-edits-TIJDPG6H.js} +1 -1
  135. package/dist/m/core/{snapshot-FJP5IJL3.js → snapshot-N5MKDGNI.js} +1 -1
  136. package/dist/m/core/unsaved-warning-BP6ZY3PG.js +1 -0
  137. package/dist/m/events/{index-B6TGDYMG.js → index-YKQIBZE5.js} +1 -1
  138. package/dist/m/internals/index-3LAVREAU.js +1 -0
  139. package/dist/m/lib/{cache-bust-NH7VBWHO.js → cache-bust-BL4KUQAJ.js} +1 -1
  140. package/dist/m/{loader-GLLVDUZA.js → loader-7ORQVRCK.js} +1 -1
  141. package/dist/m/manifest-A27A4278.js +1 -0
  142. package/dist/m/manifest-edit-E8A61EB4.js +1 -0
  143. package/dist/m/manifest.json +1608 -1498
  144. package/dist/m/options/{options-55LQHSJ4.js → options-LKIZ7YTG.js} +1 -1
  145. package/dist/m/page/{editor-KAZDJNND.js → editor-HS2CAV3W.js} +5 -5
  146. package/dist/m/plugins/{ai-edit-LABECCSN.js → ai-edit-WDV2GLDU.js} +2 -2
  147. package/dist/m/plugins/{cms-T2HLI7JG.js → cms-4KET6RZT.js} +9 -9
  148. package/dist/m/plugins/{demo-T7B4RIKL.js → demo-LMCMBILC.js} +1 -1
  149. package/dist/m/plugins/{derive-6LPJOCAV.js → derive-R4USHZ7P.js} +1 -1
  150. package/dist/m/plugins/{indicator-J4ABFARX.js → indicator-OLPZ4WFI.js} +1 -1
  151. package/dist/m/plugins/{live-PGBIEMGB.js → live-CO4VJS46.js} +1 -1
  152. package/dist/m/plugins/{menu-YZL3X2AJ.js → menu-ESEFQARM.js} +1 -1
  153. package/dist/m/plugins/{page-WOCNX2IN.js → page-L3VKIQU2.js} +2 -2
  154. package/dist/m/plugins/{page-view-SJODOOGE.js → page-view-6KNTXABH.js} +1 -1
  155. package/dist/m/plugins/{people-C4TCWFOQ.js → people-EBWE337I.js} +1 -1
  156. package/dist/m/plugins/quickcrop-VNRXGRPC.js +26 -0
  157. package/dist/m/plugins/{richclay-Y2NV44NA.js → richclay-V6WKJTUF.js} +17 -17
  158. package/dist/m/plugins/sortable-BAG3MSWS.js +1 -0
  159. package/dist/m/plugins/{source-YK7MO23W.js → source-OYHDXKTB.js} +1 -1
  160. package/dist/m/plugins/undo-WUK2NLBA.js +1 -0
  161. package/dist/m/plugins/{upgrade-NNTJBSK2.js → upgrade-SZQJYEQQ.js} +1 -1
  162. package/dist/m/plugins/{upload-ZKKJV76X.js → upload-NZET3DNQ.js} +1 -1
  163. package/dist/m/plugins/visitor-drafts-ZE6PCAFP.js +20 -0
  164. package/dist/m/plugins/{visitor-drafts-owner-LHUHFU3L.js → visitor-drafts-owner-TLECTYWS.js} +1 -1
  165. package/dist/m/plugins/{visitor-menu-FY4KM2SW.js → visitor-menu-5XY57JQA.js} +1 -1
  166. package/dist/m/plugins/wire-S5ATC4QI.js +1 -0
  167. package/dist/m/reader-core-AHOAP5DH.js +77 -0
  168. package/dist/m/sync/live-sync-DX4K5GDB.js +1 -0
  169. package/dist/m/ui/index-G7ZJXNMG.js +1 -0
  170. package/dist/m/vendor/sap-core.vendor-5TWOJYVM.js +7 -0
  171. package/dist/offline-manifest.json +844 -784
  172. package/dist/server/core.cjs +4245 -2614
  173. package/dist/server/markdown.cjs +1 -0
  174. package/dist/server/markdown.mjs +7 -0
  175. package/docs/guide.md +27 -37
  176. package/entries/clay-data.js +1 -1
  177. package/entries/sap.js +6 -5
  178. package/package.json +6 -2
  179. package/packed-contract.json +3 -0
  180. package/src/attrs/save-freeze.js +1 -1
  181. package/src/core/admin-contenteditable.js +1 -1
  182. package/src/core/admin-inputs.js +1 -1
  183. package/src/core/admin-onclick.js +1 -1
  184. package/src/core/admin-resources.js +5 -2
  185. package/src/core/conflict-notice-ui.js +59 -34
  186. package/src/core/draft-mode.js +5 -0
  187. package/src/core/save-core.js +10 -10
  188. package/src/core/save.js +10 -10
  189. package/src/core/snapshot.js +56 -43
  190. package/src/core/stale-host-notice.js +20 -7
  191. package/src/lib/dirty-gate.js +19 -0
  192. package/src/page/editor.js +10 -4
  193. package/src/page/import-markdown.js +22 -8
  194. package/src/page/save-projection.js +1 -1
  195. package/src/plugins/menu/visitor.js +33 -1
  196. package/src/plugins/quickcrop.js +128 -69
  197. package/src/plugins/sortable.js +25 -9
  198. package/src/plugins/visitor-drafts/commit.js +50 -3
  199. package/src/plugins/visitor-drafts/idb.js +8 -2
  200. package/src/plugins/visitor-drafts/recovery-menu.js +118 -0
  201. package/src/plugins/visitor-drafts/recovery.js +64 -0
  202. package/src/plugins/visitor-drafts/session.js +61 -13
  203. package/src/plugins/visitor-drafts/store.js +44 -8
  204. package/src/plugins/visitor-drafts.js +34 -5
  205. package/src/server/markdown/index.js +23 -0
  206. package/src/sync/conflicts.js +3 -1
  207. package/src/sync/data-guard-notice.js +137 -18
  208. package/src/sync/live-sync.js +1 -1
  209. package/src/sync/wire-profile.js +9 -4
  210. package/src/ui/bevel-controls.js +4 -1
  211. package/src/ui/dialogs.js +11 -7
  212. package/src/ui/modal.js +9 -7
  213. package/src/ui/toast.js +67 -32
  214. package/src/vendor/hyper-html-api-data.vendor.js +1 -1
  215. package/src/vendor/hyper-html-api-upgrade.vendor.js +2 -2
  216. package/src/vendor/hyper-undo.vendor.js +1 -1
  217. package/src/vendor/hypercms.vendor.js +7 -7
  218. package/src/vendor/richclay.vendor.js +16 -16
  219. package/src/vendor/sap-core.vendor.js +6 -5
  220. package/src/vendor/sap-ownership.vendor.js +181 -11
  221. package/tool-generation/context.md +69 -0
  222. package/tool-generation/system.md +2 -2
  223. package/dist/m/attrs/save-freeze-JZHKRQLR.js +0 -1
  224. package/dist/m/c-277QP5ET.js +0 -1
  225. package/dist/m/c-3UW5EJ77.js +0 -1
  226. package/dist/m/c-42ZNV7LI.js +0 -7
  227. package/dist/m/c-6Q6RGFBF.js +0 -1
  228. package/dist/m/c-APGHGDZM.js +0 -1
  229. package/dist/m/c-BGN7RCTJ.js +0 -1
  230. package/dist/m/c-CJ7QYEWI.js +0 -1
  231. package/dist/m/c-CVSWLX3X.js +0 -1
  232. package/dist/m/c-DXPOFLEJ.js +0 -1
  233. package/dist/m/c-EILLN2H2.js +0 -1
  234. package/dist/m/c-EODTTNVA.js +0 -1
  235. package/dist/m/c-ESK4S67I.js +0 -1
  236. package/dist/m/c-FDWR3FL7.js +0 -1
  237. package/dist/m/c-FYDKYW6E.js +0 -1
  238. package/dist/m/c-HKSLOVU4.js +0 -1
  239. package/dist/m/c-HTLYXCUH.js +0 -1
  240. package/dist/m/c-IUL7PU4P.js +0 -1
  241. package/dist/m/c-JQF2EUCG.js +0 -1
  242. package/dist/m/c-MFOSMAVM.js +0 -3
  243. package/dist/m/c-MQYEDF3Q.js +0 -1
  244. package/dist/m/c-MR75YPRT.js +0 -1
  245. package/dist/m/c-NHXOBD6A.js +0 -1
  246. package/dist/m/c-NVU3DORS.js +0 -1
  247. package/dist/m/c-OYHI67B6.js +0 -1
  248. package/dist/m/c-PWJSJEJU.js +0 -1
  249. package/dist/m/c-QENKN7QI.js +0 -1
  250. package/dist/m/c-R23UHMXG.js +0 -1
  251. package/dist/m/c-SGH3UTF3.js +0 -1
  252. package/dist/m/c-SXNSSHPP.js +0 -1
  253. package/dist/m/c-TFLRT5JX.js +0 -1
  254. package/dist/m/c-U4NTUVDZ.js +0 -1
  255. package/dist/m/c-V2U3F4QX.js +0 -1
  256. package/dist/m/c-VG5XIN4T.js +0 -1
  257. package/dist/m/c-VHSMPITY.js +0 -1
  258. package/dist/m/c-Z4G2UK6T.js +0 -4
  259. package/dist/m/core/draft-mode-4MCL3LYI.js +0 -1
  260. package/dist/m/core/unsaved-warning-ITZDIZ2I.js +0 -1
  261. package/dist/m/internals/index-HS3CQDFW.js +0 -1
  262. package/dist/m/manifest-50FF1C45.js +0 -1
  263. package/dist/m/manifest-edit-BE1A621D.js +0 -1
  264. package/dist/m/plugins/quickcrop-X5MRIBAP.js +0 -26
  265. package/dist/m/plugins/sortable-XCHQG65Z.js +0 -1
  266. package/dist/m/plugins/undo-VLRBQNPN.js +0 -1
  267. package/dist/m/plugins/visitor-drafts-RTZNONHT.js +0 -20
  268. package/dist/m/plugins/wire-M2NR354P.js +0 -1
  269. package/dist/m/reader-core-T2S3JC4E.js +0 -77
  270. package/dist/m/sync/live-sync-Z64YREWQ.js +0 -1
  271. package/dist/m/ui/index-MGTWOW2C.js +0 -1
  272. package/dist/m/vendor/sap-core.vendor-QAEPMETX.js +0 -6
  273. /package/dist/m/{c-QTTJYJMA.js → c-FILLTJA7.js} +0 -0
  274. /package/dist/m/plugins/{quickcrop-X5MRIBAP.js.LEGAL.txt → quickcrop-VNRXGRPC.js.LEGAL.txt} +0 -0
  275. /package/dist/m/plugins/{richclay-Y2NV44NA.js.LEGAL.txt → richclay-V6WKJTUF.js.LEGAL.txt} +0 -0
@@ -0,0 +1 @@
1
+ module.exports = require('./core.cjs').markdown;
@@ -0,0 +1,7 @@
1
+ import markdown from './markdown.cjs';
2
+ export default markdown;
3
+ export const {
4
+ MAX_BYTES,
5
+ MarkdownImportError,
6
+ markdownArticle,
7
+ } = markdown;
package/docs/guide.md CHANGED
@@ -781,7 +781,7 @@ Four attributes make an element behave differently by mode. A **save transform**
781
781
  |---|---|---|
782
782
  | `editmode:contenteditable` | `contenteditable` renamed to `inert-contenteditable` (value kept) | `contenteditable` restored |
783
783
  | `editmode:onclick` | `onclick` renamed to `inert-onclick` | `onclick` restored |
784
- | `editmode:resource` on `<script>`, `<style>`, `<link>` | `type` prefixed `inert/` | `inert/` prefix stripped and element re-inserted so it runs |
784
+ | `editmode:resource` on `<script>`, `<style>`, `<link>` | `type` prefixed `inert/` | `inert/` prefix stripped (`inert/javascript` becomes `text/javascript`) and element re-inserted so it runs |
785
785
  | `viewmode:disabled`, `viewmode:readonly` on controls | `disabled` / `readonly` added | removed |
786
786
 
787
787
  There is no general `editmode:<anything>`. Only these four attributes exist.
@@ -1148,7 +1148,7 @@ To batch saves in part of an autosaving page, wrap that region in `clay="no-trig
1148
1148
 
1149
1149
  ### 5.7 The save API
1150
1150
 
1151
- `clay.save()` returns `Promise<{ ok, msg, msgType, code, etag }>` and never rejects. One exception in 1.8.2: when capturing the page fails because a registered hook threw ([Hooks](https://clayjs.com/docs/guide/saving/#hooks)), the result has `msgType: "error"` and no `ok` field.
1151
+ `clay.save()` returns `Promise<{ ok, msg, msgType, code, etag }>` and never rejects.
1152
1152
 
1153
1153
  | Result | Meaning |
1154
1154
  |---|---|
@@ -1223,8 +1223,8 @@ Hooks shape the saved bytes without touching the live page. Except for `onafters
1223
1223
  |---|---|---|
1224
1224
  | `onbeforesnapshot="code"` attribute | The clone, for every snapshot: save, change check, sync broadcast | Normalizing tab-local state out of anything that leaves the tab |
1225
1225
  | `onbeforesave="code"` attribute | The save clone and change-check clones (not sync broadcasts) | Cleaning a subtree before it is written |
1226
- | `clay.onSnapshot(fn)` | Every snapshot; `fn(clone, { original })` | Stripping library residue everywhere |
1227
- | `clay.addDocumentTransform(fn)` | The save clone and every change check | Writing derived values into the saved copy only |
1226
+ | `clay.onSnapshot(fn, { required })` | Every snapshot; `fn(clone, { original })` | Stripping library residue everywhere |
1227
+ | `clay.addDocumentTransform(fn, { required })` | The save clone and every change check | Writing derived values into the saved copy only |
1228
1228
  | `onaftersave="code"` attribute | The **live** element after each accepted save | Post-save live DOM updates (rarely) |
1229
1229
 
1230
1230
  In attribute hooks, `this` is the cloned element (or the live element in `onaftersave`). Here, the finance tracker keeps sap's search filter (rows hidden with `hidden`) out of the file and out of peers' copies:
@@ -1236,7 +1236,7 @@ In attribute hooks, `this` is the cloned element (or the live element in `onafte
1236
1236
  Rules:
1237
1237
 
1238
1238
  - **Hooks must be pure and repeatable.** They run on every autosave check, every `hasUnsavedChanges()`, and every `getHTML()`. A hook that writes a timestamp or counter makes the page permanently dirty and autosaves forever.
1239
- - A throwing **attribute** hook aborts only that hook. A throwing `clay.onSnapshot` or `clay.addDocumentTransform` callback aborts the capture: `getHTML()` throws and every `save()` fails with `msgType: "error"` until it stops throwing. Registered callbacks must handle missing elements themselves, because change-check captures have already removed `editor-ui`, `no-save`, and `no-snapshot` regions.
1239
+ - A throwing **attribute** hook aborts only that hook. A `clay.onSnapshot` or `clay.addDocumentTransform` callback that throws before it changes the clone is skipped and logged once so saves continue; one that changed the clone and then threw stops the capture, so its half-done changes are never saved. Pass `{ required: true }`, or throw an error with a string `code`, when a failure must abort the capture and fail the save with `msgType: "error"`. Registered callbacks must still handle missing elements themselves, because change-check captures have already removed `editor-ui`, `no-save`, and `no-snapshot` regions.
1240
1240
  - `onaftersave` writes to the live DOM, so any record change it makes counts as a new edit and causes a save loop with autosave. Mark what it writes `editor-ui`, or write inside a `freeze` scratchpad.
1241
1241
  - `clay:snapshot-ready` listeners receive the shared clone and must not change it.
1242
1242
 
@@ -1286,8 +1286,8 @@ Events, all on `document`:
1286
1286
  | `clay:baseline-settled` | the load-settle baseline was taken | none |
1287
1287
  | `clay:save-saving` | a save has been in flight 500 ms | `{ msg, msgType, timestamp }` (`msgType` is `""`) |
1288
1288
  | `clay:save-saved` | the host accepted | `{ msg, msgType, timestamp, etag, captureId }` |
1289
- | `clay:save-error` | refused, or a network failure while online | `{ msg, msgType, timestamp, captureId }` (`msgType` is `""` in 1.8.2; the event name is the type) |
1290
- | `clay:save-offline` | failed while the browser is offline | `{ msg, msgType, timestamp, captureId }` (`msgType` is `""`) |
1289
+ | `clay:save-error` | refused, or a network failure while online | `{ msg, msgType, timestamp, captureId }` (`msgType` is `"error"` or the host's `msgType`, or `""` on a local writable refusal) |
1290
+ | `clay:save-offline` | failed while the browser is offline | `{ msg, msgType, timestamp, captureId }` (`msgType` is `"error"` or the host's `msgType`) |
1291
1291
  | `clay:save-conflict` | 412 | adds `changedBy`, `afterTimeout`, `etag`, `captureId` |
1292
1292
  | `clay:save-conflict-resolved` | sync merged the version that caused the 412 | `{ timestamp }` |
1293
1293
  | `clay:dirty`, `clay:clean` | unsaved-work state changed | none |
@@ -1403,21 +1403,11 @@ Separate multiple attribute names with spaces. `data-id` is never merged this wa
1403
1403
 
1404
1404
  - `editor-ui`, `no-save`, `no-snapshot`: **ignored on every side.** Your copy is never touched, and the incoming copy is never read.
1405
1405
  - `freeze`: **the element merges, its contents never do.** A frozen element pairs, moves, is inserted and removed with its record, and merges its attributes. Your copy's contents are never touched, the incoming contents are never read, and a frozen element new to this tab arrives empty.
1406
- - `no-dirty`, `no-watch`: **remote wins.** The incoming copy replaces yours with no merge. Use this for derived values that every tab recomputes.
1406
+ - `no-dirty`, `no-watch`: **remote wins.** The incoming copy replaces yours with no merge and records no conflict. Use this for derived values that every tab recomputes.
1407
1407
  - `no-trigger-autosave`: merged like ordinary content.
1408
1408
  - `live`: **ignored by the merge on every side.** The `live` plugin takes the value itself ([Live data: `clay="live"`](https://clayjs.com/docs/guide/live-sync/#live-data-clay-live)).
1409
1409
  - Root attributes the library owns (`editmode`, `savestatus`, tokens) are never written by a frame.
1410
1410
 
1411
- **Known issue (ClayJS 1.8.2):** If a tab holds an unsaved edit outside `no-dirty` and also changed a `no-dirty` region, a frame that replaces that `no-dirty` region logs a loss in `clay.conflicts` and raises the conflict notice, even though `no-dirty` replacements should happen without warning. Because two tabs editing data will each recompute totals differently, this fires on concurrent edits whenever computed totals live in `no-dirty`. Until it is fixed, acknowledge those records yourself, as the finance tracker does:
1412
-
1413
- ```js
1414
- document.addEventListener("clay:sync-applied", () => {
1415
- const derived = clay.conflicts.list().filter((c) =>
1416
- c.detail === "remote-wins" && [c.el, c.local].some((n) => n?.closest?.('[clay~="no-dirty"]')));
1417
- if (derived.length) clay.conflicts.acknowledge(derived.map((c) => c.id), { reason: "reconciled" });
1418
- });
1419
- ```
1420
-
1421
1411
  **JSON.** Without `merge`, a JSON script is one value: if two writers change it, one whole blob goes to the ledger. With `merge="name"`, it merges by key: objects per key, arrays of objects by an `id` field, arrays of primitives by value, and lists without an id (grids, boards, repeated values) position by position when both sides kept the same length. `merge-key="taskId"` names another id field for every list, and `merge-key="players:uid, items:sku"` names one per list path (no spaces inside an entry).
1422
1412
 
1423
1413
  **A key both sides changed takes the incoming value.** The lost value goes to the ledger like any other replaced edit, and the notice shows a row such as `game → players → alice → x` with yours and now. Revert cannot put a JSON value back; Download keeps your copy. Use per-entry keys (`notes: { "n-1": ..., "n-2": ... }`) so two people adding entries never touch the same key. For data several people change at once, use a live store ([Live data: `clay="live"`](https://clayjs.com/docs/guide/live-sync/#live-data-clay-live)) instead. When a merge mixes both sides, the text is rewritten in the incoming text's style (one line stays one line, indented stays indented) with `<` written as `\u003c`.
@@ -1716,7 +1706,7 @@ editor.options.toolbar = [...clay.RichClay.presets.standard, "stamp"];
1716
1706
 
1717
1707
  Traps:
1718
1708
 
1719
- - **Mode by attribute.** `editable` is inline mode and never sanitizes your authored markup on load. `data-richclay` without `editable` is card mode: it sanitizes in place on load with an allowlist that excludes `img`, so **it deletes images on every edit-mode open**. Use `editable`.
1709
+ - **Mode by attribute.** `editable` is inline mode and never sanitizes your authored markup on load. `data-richclay` without `editable` is card mode: on load it keeps authored `img`, `class`, `id`, and `data-*` attributes and strips scripts and event handlers. Paste and `setHTML` in card mode still use a narrower allowlist without `img`.
1720
1710
  - **Nested `editable` regions are refused.** Only the outer region mounts. Siblings are fine.
1721
1711
  - **Custom elements** (tags with a hyphen) are skipped for bare `editable`. Use `clay-editable`.
1722
1712
  - **The floating toolbar mounts on `document.body`, not in the top layer.** Inside `dialog.showModal()` or a `popover`, it is unusable, though shortcuts still work. Do not put `editable` inside a modal dialog. The kanban shows the card itself as a fixed overlay instead ([Detail views: the record is the modal](https://clayjs.com/docs/guide/architecture/#detail-views-the-record-is-the-modal)).
@@ -1776,6 +1766,7 @@ None of this loads for a reader. The input rules, menus, and title adapter are e
1776
1766
  - A `[sortable-handle]` inside the container (outside nested sortables) switches it to handle-only dragging. Nested sortables are separate.
1777
1767
  - Order saves as child order. There is no order attribute.
1778
1768
  - Every drop fires `clay:sorted` (bubbling) with `{ item, from, to, oldIndex, newIndex }`. In a cross-container move, it fires on the source container. Read `item.dataset.id` and `to.closest(...)`, not indexes.
1769
+ - `onsorting="code"` runs synchronously as an item moves with `this` and `evt`. Return `false` to cancel the move, or `1` or `-1` to pick a side. Code that uses `await` runs asynchronously and cannot cancel a move.
1779
1770
  - `onsorted="code"` runs on drop with `this` and `evt`.
1780
1771
  - Containers added later bind after about 200 ms.
1781
1772
  - `window.Sortable` is SortableJS 1.15.6. `Sortable.get(el).option(name, value)` changes an instance.
@@ -1785,7 +1776,6 @@ Traps:
1785
1776
 
1786
1777
  - **Handle-only mode is decided when the container binds.** If handles are injected later (like the writer's gutters), set it yourself: `Sortable.get(blocks).option("handle", "[sortable-handle]")`.
1787
1778
  - **One stray `[sortable-handle]` makes every other item undraggable** except by its handle.
1788
- - **`onsorting` cannot veto a move** because its return value is lost. Use `Sortable.get(el).option("onMove", (evt) => …)`.
1789
1779
  - **Hidden template children count as items.** Keep blueprints in `<template>` outside the list.
1790
1780
  - **Sortable leaves residue** (`draggable="false"`, `style=""`, drag classes) that saves. The `sortable` plugin strips it inside `[sortable]` lists, including from a mid-drag save. A Sortable you load and wire up yourself needs a snapshot hook to strip it.
1791
1781
  - A peer frame arriving mid-drag merges under the drag. Rare at autosave cadence, but possible.
@@ -1856,8 +1846,8 @@ Put the file picker for an image block in chrome: `<input type="file" accept="im
1856
1846
  - `clay.toastPersistent(message, type)` stays until closed.
1857
1847
  - `clay.confirm(prompt)` resolves on confirm and **rejects with `undefined` on cancel**. Always pass a rejection handler: `clay.confirm("Delete this card?").then(del, () => {})`. `try { await clay.confirm(...) } catch (e) { e.message }` throws inside the `catch`.
1858
1848
  - `clay.ask(prompt, onYes, defaultValue)` resolves with the typed text.
1859
- - **Every dialog prompt and title is HTML.** `clay.confirm(prompt, extraContent)`, `clay.ask(prompt)`, `clay.tell(title, ...paragraphs)`, and `clay.snippet(title, code)` insert their strings as markup. ``clay.confirm(`Delete "${card.title}"?`)`` runs whatever markup a collaborator typed into the title. Keep prompts constant, or escape record text first.
1860
- - `clay.modal` is a single modal with `title`, `html`, `yes`, `no`, `onYes`, `open()`, and `close()`. Every setting resets on close, and opening any dialog rejects the one already open.
1849
+ - **Dialog prompts and titles are plain text.** `clay.confirm`, `clay.ask`, `clay.tell`, and `clay.snippet` render strings for prompts, titles, paragraphs, button labels, and snippet code as text, never parsed. Pass a DOM `Node` to show markup. `extraContent` on `ask`, `confirm`, and `snippet` takes an HTML string or a `Node`.
1850
+ - `clay.modal` is a single modal with `title`, `html`, `yes`, `no`, `onYes`, `open()`, and `close()`. `clay.modal.html` takes an HTML string or a `Node`, while `title`, `yes`, and `no` take text or a `Node`. Every setting resets on close, and opening any dialog rejects the one already open.
1861
1851
 
1862
1852
  **Never pass a live record element as `clay.modal.html`.** The modal moves the node into its runtime-only root and removes that root on close. The element is gone from the page, and a save during the dialog drops it from the file. Pass a form built from a template, and write values back to the record on confirm. For card detail, prefer the record-as-modal pattern ([Detail views: the record is the modal](https://clayjs.com/docs/guide/architecture/#detail-views-the-record-is-the-modal)).
1863
1853
 
@@ -1995,7 +1985,7 @@ Rules for sapjs in a malleable file:
1995
1985
  </script>
1996
1986
  ```
1997
1987
 
1998
- It fits fixed-layout content sites such as landing pages, menus, pricing, FAQs, and team pages, where a non-developer changes copy and images. It does not fit apps where editing is the product: its form is a separate surface from the content, new list items clone the first item's attributes (including its state), and rich text inside lists is flattened in the sidebar. A file can use both if the CMS owns the header copy, the app owns `<main>`, and the rules never reach into the app's region. Give every list that can become empty a `cms-template` seed hidden by CSS, not by the `hidden` attribute (which is copied into every new item). Add `sortable` to the plugin list for drag in the sidebar.
1988
+ It fits fixed-layout content sites such as landing pages, menus, pricing, FAQs, and team pages, where a non-developer changes copy and images. It does not fit apps where editing is the product: its form is a separate surface from the content, new list items clone the first item's attributes (including its state), and rich text inside lists is flattened in the sidebar. A file can use both if the CMS owns the header copy, the app owns `<main>`, and the rules never reach into the app's region. Give every list that can become empty a `cms-template` seed hidden with `hidden` or `[cms-template]` CSS, not inline `display: none`. Cloning removes `cms-template` and `hidden` from new items. Add `sortable` to the plugin list for drag in the sidebar.
1999
1989
 
2000
1990
  The rules tag can declare which editor opens. `data-cms-view="inline"` edits text in place and opens small popovers for everything else, while no attribute (or `"sidebar"`) opens the form in a side panel. **Open the CMS (Edit content)** in the menu opens whichever the page declares. The CMS edits only in edit mode: while the page is in view, `clay.cms.open()` answers `{ ok: false, code: "not-allowed" }`, so a button of your own calls `clay.setMode("edit")` first.
2001
1991
 
@@ -2099,7 +2089,7 @@ Pick by whether the saved file must show the value:
2099
2089
  - **Computed only from the records** (counts, progress badges, totals, a card's face): ordinary saved content. Write it into the record markup, ship the file pre-painted, and recompute on every change. With sap, this is a paint ([sap.js: records, views and totals in markup](https://clayjs.com/docs/guide/components/#sap-js-records-views-and-totals-in-markup)) that ClayJS treats as derived. Merges leave it out and the engine repaints it from the merged records, so two tabs that changed different records end with the right value and no conflict. Hand-written derived text in saved content does not get this, so give it `no-dirty`. The starter Kanban paints its list counts and card faces this way.
2100
2090
  - **Different per tab** (search results, which entry is open, "overdue" against today's date, OS shortcut labels, names loaded from the people plugin): write it inside a `clay="freeze"` scratchpad ([Regions: the `clay` attribute](https://clayjs.com/docs/guide/record/#regions-the-clay-attribute)). The element saves and syncs, while its contents never do.
2101
2091
  - **Pure UI** (buttons, menus, handles): `editor-ui`, created from a `<template>` ([Chrome](https://clayjs.com/docs/guide/architecture/#chrome)).
2102
- - **Optionally, `no-dirty`** for a computed value the saved file shows: it saves with the next real edit, never counts as an edit itself, and remote wins under sync. Apply the [Regions and JSON under sync](https://clayjs.com/docs/guide/live-sync/#regions-and-json-under-sync) workaround. The finance tracker does this.
2092
+ - **Optionally, `no-dirty`** for a computed value the saved file shows: it saves with the next real edit, never counts as an edit itself, and remote wins under sync. The finance tracker does this.
2103
2093
  - **Only in the saved file**: compute it into the save clone with `clay.addDocumentTransform`, never the live page.
2104
2094
 
2105
2095
  Always write derived text through a guard, because writing the same text is still a mutation:
@@ -2382,13 +2372,16 @@ The saved file is the data. Everyone who can download it can read everything in
2382
2372
 
2383
2373
  ### 9.4 Data-loss recovery
2384
2374
 
2385
- When a browser save or an outside edit overwrites saved data, ClayJS shows a persistent `Saved data was overwritten` warning. It reports the write source, the removed items or erased values, and a preview of the first changed field. Only editors in edit mode see it. Readers and draft visitors never see it. An owner in view mode sees it on entering edit mode. HTML Clay also shows its own bar in view mode, in edit mode until ClayJS's notice takes over, and always on documents pinned to an older ClayJS that has no notice.
2375
+ When an outside edit or a browser save removes saved data, ClayJS shows a persistent notice in edit mode. An outside change with a `reason` shows `A change from outside this page removed something you typed` (`recent`), `A change from outside this page removed everything you typed` (`all-typed`), `A change from outside this page emptied this page's data` (`emptied`), or `A change from outside this page left its data unreadable` (`unreadable`). An event without `reason` shows `Some saved data was removed`. When a save is in progress or a disk sync frame just landed, ClayJS waits for the merge to settle before showing the notice. Only editors in edit mode see it. Readers and draft visitors never see it. An owner in view mode sees it on entering edit mode. HTML Clay also shows its own bar in view mode, in edit mode until ClayJS's notice takes over, and always on documents pinned to an older ClayJS that has no notice.
2376
+
2377
+ The notice shows up to three buttons:
2386
2378
 
2387
- The notice has three buttons:
2379
+ - `Put it back`, on a reasoned event with `canPutBack: true`, posts `"put-back"` to write your typed values back into the current page while keeping the outside change's other edits, then reloads.
2380
+ - `Restore`, on an event without `reason` and with `restorable: true`, posts `"restore"` to put the lost data back into the current page and reload (removing `droppedAdditions` items added or changed since).
2381
+ - `Undo the change`, when `canRevert` is `true`, posts `"revert"` to restore the whole earlier file and reload, removing any edits made since.
2382
+ - `Keep the change` (or `Keep as is` when `reason` is absent) posts `"dismiss"` to adopt the current page as the baseline and close the notice without reloading.
2388
2383
 
2389
- - `Restore`, when `restorable` is `true`, puts the lost data back into the current page and reloads. When `droppedAdditions` is above `0`, the notice says `Restoring removes N items added or changed since.` The field counts the current list items that have no identical item in the saved data, so a `Restore` removes or overwrites each of them: items added since the loss and items changed since the loss.
2390
- - `Undo the change`, when `canRevert` is `true`, restores the whole earlier file and reloads.
2391
- - `Keep as is` posts `"dismiss"` to adopt the current page as the baseline and closes the notice without reloading. The toast's `X` only hides it in this tab.
2384
+ The toast's `X` only hides it in this tab.
2392
2385
 
2393
2386
  A host announces `data-guard-v1` in `/_/meta` `extensions` and gives each editor a same-origin `document.dataGuard.href` per document. A client never builds that address.
2394
2387
 
@@ -2400,10 +2393,13 @@ A host announces `data-guard-v1` in `/_/meta` `extensions` and gives each editor
2400
2393
  "id": "uuid",
2401
2394
  "firstDetectedAt": 1762700000000,
2402
2395
  "lastWriteAt": 1762700000000,
2396
+ "reason": "recent",
2397
+ "typed": [{ "path": "items[id:2].note", "yours": "draft", "at": 1762699900000 }],
2403
2398
  "lossSummary": { "provenance": "external", "destroyedAtoms": 4, "removedItems": 2, "modifiedAtoms": 0, "paths": ["api.items[2]"] },
2404
2399
  "fieldCount": 1,
2405
2400
  "preview": [{ "key": "items", "now": "2 items", "yours": "4 items" }],
2406
2401
  "droppedAdditions": 0,
2402
+ "canPutBack": true,
2407
2403
  "restorable": true,
2408
2404
  "canRevert": true,
2409
2405
  "status": "pending"
@@ -2411,7 +2407,7 @@ A host announces `data-guard-v1` in `/_/meta` `extensions` and gives each editor
2411
2407
  }
2412
2408
  ```
2413
2409
 
2414
- - `POST <href>` takes `{"id", "choice"}` (`"restore"`, `"revert"` or `"dismiss"`). It answers `200` `{"ok": true, "choice", "status"}`, or `{"error"}` with `400` for an unknown choice, `404` when no event is pending, `409` when another event id is current, and `422` when that choice cannot be applied to the page.
2410
+ - `POST <href>` takes `{"id", "choice"}` (`"put-back"`, `"restore"`, `"revert"` or `"dismiss"`). It answers `200` `{"ok": true, "choice", "status"}`, or `{"error"}` with `400` for an unknown choice, `404` when no event is pending, `409` when another event id is current, and `422` when that choice cannot be applied to the page.
2415
2411
  - A host with `sync` also sends `{"type": "notification", "msgType": "data-loss", "action": "raised" | "resolved", "msg", "data"}` on the document's live lane, with the event in `data` for `"raised"` and `{"id"}` for `"resolved"`.
2416
2412
 
2417
2413
  A host should announce `data-guard-v1` only after the conformance rows for this capability pass.
@@ -2609,6 +2605,7 @@ The rung is where a free document lives, so the details matter:
2609
2605
  - **The save lane is the browser.** `clay.save()` and autosave both run, `savestatus` moves as usual, and the save answers `msgType: "success"` with `msg: "Saved in this browser"`. A storage failure answers the 507 path with `code: "draft-storage"` and fires `clay:drafts-store-failed`; the next good write clears it.
2610
2606
  - **The draft record keeps the block editor state as well as the rules data.** The stored record is `{ v: 1, savedAt, id, ancestry, data, live, blockeditor }`. `data` holds the rules data. `live` holds the values of the document's live stores: `<script type="application/json" merge="blockeditor" clay="live">` and the others such as `blockeditor.tools` and `blockeditor.settings`. The `blockeditor` store's value holds base64 Yjs updates. `blockeditor` is `{ rev, html }`, holding the article's `data-rev` and its HTML. On restore, ClayJS writes the stores and the article into the document before the block editor reads them. When this tab has never edited the article and it still matches the served one, ClayJS does not record it, so a visitor who never wrote in the block editor gets the owner's later article. Once a tab has recorded the article, it keeps recording it, even when the visitor deletes back to the served text. If none of the saved `data` fields fit the current rules, ClayJS still restores the article and live stores and keeps the whole record under the `:unreadable:` key, as for a partial fit.
2611
2607
  - **No request reaches the host.** The download link goes to the host's download page, which holds the email sign-up. Hyperclay's download page sends the host only the rules data. In the visitor's browser, it adds the stored page to the file, writing the page's store tags and article into the file the host returns. The prompt's own stylesheet is a Google Fonts link.
2608
+ - **Links that leave the page can wait for the draft.** A link with the `clay-wait-drafts` attribute, followed by a plain click in the same tab, waits until the visitor's last change is stored where the download page reads it, then navigates. The wait is at most 3 seconds; past that, or when the browser refuses to store the change, the link opens anyway and the download page asks the visitor to go back and try again. Hyperclay's trial bar marks its **Download your copy** and **Host and share online** links this way, so a visitor who clicks right after typing gets that typing in the file. A second click while the first waits does nothing more. Links that open a new tab, and clicks with a modifier key, leave the page open and do not wait. The link can sit inside an open shadow root.
2612
2609
  - **`clay.readData()` and `clay.writeData()` refuse.** Both reject with `code: "DataUnavailableInDraft"`: the saved file belongs to the owner, and this visitor's work is in their browser, so there is nothing for them to read or write there. A document that calls them in draft mode gets that refusal instead of a request ([Import and export](https://clayjs.com/docs/guide/architecture/#import-and-export)).
2613
2610
  - **`clay.visitorDrafts`** is the plugin's whole surface:
2614
2611
 
@@ -2868,12 +2865,10 @@ Each check names the clayjs test that proves the library side.
2868
2865
  | `clay.getHTML()` runs hooks and closes the undo batch | [The save API](https://clayjs.com/docs/guide/saving/#the-save-api) |
2869
2866
  | A 412 conflict stops autosave until resolved | [Conflicts on save (412)](https://clayjs.com/docs/guide/saving/#conflicts-on-save-412) |
2870
2867
  | Impure hooks keep the page permanently dirty | [Hooks](https://clayjs.com/docs/guide/saving/#hooks) |
2871
- | A throwing `onSnapshot` or `addDocumentTransform` callback blocks every save | [Hooks](https://clayjs.com/docs/guide/saving/#hooks) |
2872
2868
  | `onaftersave` writing to the live DOM loops autosave | [Hooks](https://clayjs.com/docs/guide/saving/#hooks) |
2873
2869
  | Without autosave, collaborators see nothing until a save | [What sync is](https://clayjs.com/docs/guide/live-sync/#what-sync-is) |
2874
2870
  | Listeners attached to records are lost when a merge recreates them | [What a merge does](https://clayjs.com/docs/guide/live-sync/#what-a-merge-does) |
2875
2871
  | A peer's frame re-runs inline scripts | [What a merge does](https://clayjs.com/docs/guide/live-sync/#what-a-merge-does), [Starting the app once](https://clayjs.com/docs/guide/architecture/#starting-the-app-once) |
2876
- | A `no-dirty` region replaced by a peer raises a false conflict notice (1.8.2) | [Regions and JSON under sync](https://clayjs.com/docs/guide/live-sync/#regions-and-json-under-sync) |
2877
2872
  | Same-key JSON edits under `merge`: incoming wins, yours goes to the notice | [Regions and JSON under sync](https://clayjs.com/docs/guide/live-sync/#regions-and-json-under-sync) |
2878
2873
  | Two tabs changing one shared `data-*` attribute (labels, a counter) conflict unless a container declares `merge-tokens` or `merge-max` | [Declared attribute merges](https://clayjs.com/docs/guide/live-sync/#declared-attribute-merges) |
2879
2874
  | Rewriting the record at boot makes incoming frames hold | [Focus, typing and long-running editors](https://clayjs.com/docs/guide/live-sync/#focus-typing-and-long-running-editors) |
@@ -2882,14 +2877,12 @@ Each check names the clayjs test that proves the library side.
2882
2877
  | An `api` rule that reads a painted value can read a stale one until a tab repaints and saves | [sap.js: records, views and totals in markup](https://clayjs.com/docs/guide/components/#sap-js-records-views-and-totals-in-markup) |
2883
2878
  | Full sapjs markup under the sapjs core halts with `E50` | [sap.js: records, views and totals in markup](https://clayjs.com/docs/guide/components/#sap-js-records-views-and-totals-in-markup) |
2884
2879
  | Presence is runtime only: the host filters the roster, and a caret it cannot place is not drawn | [Presence](https://clayjs.com/docs/guide/live-sync/#presence) |
2885
- | `data-richclay` card mode deletes images on load | [richclay: rich text (`editable`)](https://clayjs.com/docs/guide/components/#richclay-rich-text-editable) |
2886
2880
  | The richclay toolbar is unusable inside `showModal()` and popovers | [richclay: rich text (`editable`)](https://clayjs.com/docs/guide/components/#richclay-rich-text-editable) |
2887
2881
  | Rich text has its own undo; page undo never records it | [richclay: rich text (`editable`)](https://clayjs.com/docs/guide/components/#richclay-rich-text-editable), [undo: whole-page undo](https://clayjs.com/docs/guide/components/#undo-whole-page-undo) |
2888
2882
  | Squire undo can roll back a peer's edit in the same region | [richclay: rich text (`editable`)](https://clayjs.com/docs/guide/components/#richclay-rich-text-editable) |
2889
2883
  | Global `registerButton` after load does not reach mounted editors | [richclay: rich text (`editable`)](https://clayjs.com/docs/guide/components/#richclay-rich-text-editable) |
2890
2884
  | Screenshot paste does nothing without a `pasteImage` listener | [richclay: rich text (`editable`)](https://clayjs.com/docs/guide/components/#richclay-rich-text-editable) |
2891
2885
  | Sortable handle mode is fixed at bind time | [sortable: drag to reorder](https://clayjs.com/docs/guide/components/#sortable-drag-to-reorder) |
2892
- | `onsorting` cannot veto a move | [sortable: drag to reorder](https://clayjs.com/docs/guide/components/#sortable-drag-to-reorder) |
2893
2886
  | Sortable residue saves | [sortable: drag to reorder](https://clayjs.com/docs/guide/components/#sortable-drag-to-reorder), [Hooks](https://clayjs.com/docs/guide/saving/#hooks) |
2894
2887
  | A plain input's typed value is not content until `persist` or a command writes it, so page undo has nothing to replay for it | [undo: whole-page undo](https://clayjs.com/docs/guide/components/#undo-whole-page-undo) |
2895
2888
  | A refused undo or redo stays on top of the stack until it is replayed or discarded | [undo: whole-page undo](https://clayjs.com/docs/guide/components/#undo-whole-page-undo) |
@@ -2903,10 +2896,7 @@ Each check names the clayjs test that proves the library side.
2903
2896
  | `el.nearest` reads a neighbour record's field | [clay-events, clay-dom and All](https://clayjs.com/docs/guide/components/#clay-events-clay-dom-and-all) |
2904
2897
  | `hide()`, `show()`, `css()` write saved inline styles | [clay-events, clay-dom and All](https://clayjs.com/docs/guide/components/#clay-events-clay-dom-and-all) |
2905
2898
  | A file whose painted values do not match sap's state writes at load | [sap.js: records, views and totals in markup](https://clayjs.com/docs/guide/components/#sap-js-records-views-and-totals-in-markup) |
2906
- | Dialog prompts are HTML: record text in `clay.confirm` runs a collaborator's markup | [clay-ui: toasts and dialogs](https://clayjs.com/docs/guide/components/#clay-ui-toasts-and-dialogs) |
2907
- | `editmode:resource type="inert/javascript"` activates as `javascript` and never runs | [Mode attributes: one file for editors and viewers](https://clayjs.com/docs/guide/edit-mode/#mode-attributes-one-file-for-editors-and-viewers) |
2908
2899
  | Sap's template row shows before sap loads | [sap.js: records, views and totals in markup](https://clayjs.com/docs/guide/components/#sap-js-records-views-and-totals-in-markup) |
2909
- | CMS `cms-template` with `hidden` makes every new item invisible | [cms: content-managed pages](https://clayjs.com/docs/guide/components/#cms-content-managed-pages) |
2910
2900
  | Records stored twice drift | [The record container](https://clayjs.com/docs/guide/architecture/#the-record-container) |
2911
2901
  | `applyData` pairs rows by content and order, not by id | [Import and export](https://clayjs.com/docs/guide/architecture/#import-and-export) |
2912
2902
  | Activity logged from a mutation observer also logs peers and undo | [Commands](https://clayjs.com/docs/guide/architecture/#commands) |
@@ -2,7 +2,7 @@
2
2
  // hyper-html-api/dist/hyper-html-api.engine.min.js via hyper-html-api
3
3
  // `npm run copy-to-clayjs`. Edit the hyper-html-api source and re-run.
4
4
  (function () {
5
- var hyperHtmlApiData=(()=>{var he=Object.defineProperty;var Tt=Object.getOwnPropertyDescriptor;var Ot=Object.getOwnPropertyNames;var St=Object.prototype.hasOwnProperty;var ve=(e,t)=>{for(var n in t)he(e,n,{get:t[n],enumerable:!0})},xt=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ot(t))!St.call(e,r)&&r!==n&&he(e,r,{get:()=>t[r],enumerable:!(i=Tt(t,r))||i.enumerable});return e};var bt=e=>xt(he({},"__esModule",{value:!0}),e);var Tn={};ve(Tn,{applyData:()=>De,default:()=>En,engine:()=>re,extractData:()=>je});var ie=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],oe=new Set(ie),pe=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),B=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),We=new Set(["checked","selected","disabled","readOnly","paused"]);function me(e,t){return t==null?We.has(e)?!1:"":We.has(e)?t==="false"?!1:!!t:t}var R={};ve(R,{CodecRefused:()=>we,EmptyListInsert:()=>P,MAX_RULE_DEPTH:()=>M,MaxRuleDepthExceeded:()=>_,NoRulesTag:()=>ye,RuleTargetReadOnly:()=>z,RulesParseError:()=>C,ShapeMismatch:()=>U,UnknownCodec:()=>K,UnknownRulesVersion:()=>H,WriteNotRoundTripped:()=>se,WriteRefused:()=>F,WriteRejected:()=>ge});var C=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},H=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1" and "2".`),this.name="UnknownRulesVersion",this.version=t}},M=20,_=class extends Error{constructor(t){super(`rule depth exceeded ${M} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},U=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},P=class extends Error{constructor(t,n){super(n?`cannot add items to empty list at "${t.join(".")}" \u2014 ${n}`:`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},z=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},F=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function Rt(e){return e.reduce((n,i)=>typeof i=="number"?`${n}[${i}]`:n?`${n}.${i}`:String(i),"")||"(root)"}var se=class extends Error{constructor(t){super(`write did not round-trip at "${Rt(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},ye=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},ge=class extends Error{constructor(t,n){super(`write rejected: ${t.length} unknown key(s), ${n.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=t,this.unmatched=n}},K=class extends Error{constructor(t){super(`unknown codec "${t}": no codec by that name is given to this call`),this.name="UnknownCodec",this.code="unknown-codec",this.codec=t}},we=class extends Error{constructor(t,n){super(n),this.name="CodecRefused",this.code=t}};function N(e){let t=0,n=null,i=-1;for(let r=0;r<e.length;r++){let o=e[r];o==="\\"?r++:n?o===n&&(n=null):o==='"'||o==="'"?n=o:o==="["||o==="("?t++:o==="]"||o===")"?t>0&&t--:o==="@"&&t===0&&(i=r)}return i}var qe="[*]";function b(e){let t=N(e),n=t===-1?e:e.slice(0,t),i=n.endsWith(qe),r={selector:i?n.slice(0,-qe.length):n,prop:t===-1?null:e.slice(t+1)||null};return i&&(r.all=!0),r}function Ae(e){let t=0,n=null,i=-1,r=!1;for(let o=0;o<e.length;o++){let c=e[o];c==="\\"?o++:n?c===n&&(n=null):c==='"'||c==="'"?n=c:c==="["||c==="("?t++:c==="]"||c===")"?t>0&&t--:t===0&&c===">"?i=o:t===0&&c===","&&(r=!0)}return r||i===-1||!Ct(e,i+1)?null:e.slice(0,i).trim()||null}function Ct(e,t){let n=t,i=e.replace(/\s+$/,"").length;for(;n<i&&/\s/.test(e[n]);)n++;let r=0,o=null;for(;n<i;n++){let c=e[n];if(c==="\\")n++;else if(o)c===o&&(o=null);else if(c==='"'||c==="'")o=c;else if(c==="["||c==="(")r++;else if(c==="]"||c===")")r>0&&r--;else if(r===0&&(c==="+"||c==="~"||/\s/.test(c)))return!1}return!0}var Nt=/^codec\(([a-z][a-z0-9-]*)\)$/;function $(e){if(typeof e!="string")return null;let t=N(e);if(t===-1)return null;let n=Nt.exec(e.slice(t+1));if(!n)return null;let{selector:i,all:r}=b(e);if(r)throw new C("A @codec(name) rule cannot use [*].");return{selector:i,name:n[1]}}var Pt=/^--[A-Za-z0-9_-]+$/;function k(e){return typeof e=="string"&&Pt.test(e)}function Ve(e){let t=[],n=[],i=null,r=0;for(let o=0;o<e.length;o++){let c=e[o];if(i){c==="\\"?o++:c===i&&(i=null);continue}if(c==="/"&&e[o+1]==="*"){let l=e.indexOf("*/",o+2);o=l===-1?e.length:l+1;continue}c==='"'||c==="'"?i=c:c==="("?n.push(")"):c==="["?n.push("]"):c==="{"?n.push("}"):(c===")"||c==="]"||c==="}")&&n[n.length-1]===c?n.pop():c===";"&&n.length===0&&(t.push(e.slice(r,o)),r=o+1)}return t.push(e.slice(r)),t}function Mt(e){let t="",n=null;for(let i=0;i<e.length;i++){let r=e[i];if(n){t+=r,r==="\\"&&i+1<e.length?t+=e[++i]:r===n&&(n=null);continue}if(r==="/"&&e[i+1]==="*"){let o=e.indexOf("*/",i+2);i=o===-1?e.length:o+1,t+=" ";continue}(r==='"'||r==="'")&&(n=r),t+=r}return t}function Be(e){e=Mt(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),i=e.slice(t+1).trim(),r=/!\s*important\s*$/i.exec(i);return r&&(i=i.slice(0,r.index).trim()),{name:n,value:i,important:!!r}}function v(e,t){if(e==null)return null;let n=null;for(let i of Ve(String(e))){let r=Be(i);!r||r.name!==t||(!n||r.important||!n.important)&&(n=r)}return n?n.value:null}function He(e,t,n){let i=e==null?"":String(e),r=n==null||n==="",o=Ve(i),c=o.map(Be),l=c.some(d=>d&&d.name===t&&d.important),s=[],f=!1;o.forEach((d,h)=>{let A=c[h];if(!A||A.name!==t){s.push(d);return}if(r||f)return;let a=/^\s*/.exec(d)[0];s.push(`${a}${t}: ${n}${l?" !important":""}`),f=!0});let u=s.join(";");if(!r&&!f){let d=u.trimEnd();u=d===""?`${t}: ${n}`:`${d}${d.endsWith(";")?" ":"; "}${t}: ${n}`}return u.trim()===""?null:u}function ce(e,t,n,i){let r=e.attr(t,"style");if((v(r,n)??"")===i)return;let o=He(r,n,i);o==null?e.removeAttr(t,"style"):e.attr(t,"style",o)}var Ue=/^[a-z][a-z0-9-]*$/,Ee=new Map;function Te(e,t){if(typeof e!="string"||!Ue.test(e))throw new Error(`hyper-html-api: invalid codec name ${JSON.stringify(e)} (must match ${Ue})`);if(!t||typeof t.read!="function"||typeof t.write!="function"||typeof t.same!="function")throw new Error(`hyper-html-api: codec "${e}" needs read, write and same functions`);Ee.set(e,t)}function Oe(e){return Ee.get(e)??null}function Se(){return Object.fromEntries(Ee)}var kt='The @codec(name) rule form needs a rules tag with data-rules-version="2".',Lt="A @codec(name) rule must be the value of a top level key.";function le(e,t){let n=$(e);return n?{...n,codec:t.codecs[n.name]}:null}function j(e,t={}){let n=t.version??"1",i=t.codecs??{};r(e,0);function r(o,c){if(!(c>M)){if(typeof o=="string"){let l=$(o);if(!l)return;if(n!=="2")throw new C(kt);if(c!==1)throw new C(Lt);if(!Object.prototype.hasOwnProperty.call(i,l.name))throw new K(l.name);return}if(Array.isArray(o)){r(o[1],c+1);return}if(o&&typeof o=="object")for(let l of Object.values(o))r(l,c+1)}}}function L(e,t,n,i={}){if(Object.prototype.hasOwnProperty.call(i,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return j(n,i),be(e,t,n,{depth:0,path:[]},i)}function be(e,t,n,i,r){if(i.depth>M)throw new _(i.path);if(typeof n=="string")return It(e,t,n,i,r);if(Array.isArray(n)){let[o,c]=n,l=e.find(t,o,r);return ze(r,i,l),l.map((s,f)=>be(e,s,c,{depth:i.depth+1,path:[...i.path,f]},r))}if(typeof n=="object"&&n!==null){let o={};for(let[c,l]of Object.entries(n))o[c]=be(e,t,l,{depth:i.depth+1,path:[...i.path,c]},r);return o}return null}function It(e,t,n,i,r){if(n.endsWith("[]")){let u=n.slice(0,-2),d=e.find(t,u,r);return ze(r,i,d),d.map(h=>e.text(h))}let o=le(n,r);if(o)return _t(e,t,o,r);if(n.startsWith("@"))return xe(e,t,n.slice(1));let c=N(n);if(c!==-1){let{selector:u,all:d}=b(n),h=n.slice(c+1),A=u?e.find(t,u,r):[t];return d&&r.allMatches?A.map(a=>xe(e,a,h)):A.length===0?null:xe(e,A[0],h)}if(n===".")return e.text(t);let{selector:l,all:s}=b(n),f=e.find(t,l,r);return s&&r.allMatches?f.map(u=>e.text(u)):f.length===0?null:e.text(f[0])}function _t(e,t,{selector:n,codec:i},r){let o=n?e.find(t,n,r):[t];return o.length===0?null:i.read(e,o[0],{query:r.query,view:r.view,region:r.region})}function ze(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(i){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,i)}}function xe(e,t,n){if(k(n))return v(e.attr(t,"style"),n);if(oe.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let i=e.attr(t,n);return i??null}function Je(e,t,n,i){let r=e.length,o=t.length,c=new Array(r).fill(-1);if(i){let p=new Set;for(let y=0;y<r;y++){let w=i[y];!(w>=0&&w<o)||p.has(w)||(c[y]=w,p.add(w))}}if(r===0||o===0)return c;let l=e.map(p=>Fe(p,n)),s=t.map(p=>Fe(p,n)),f=new Array(o).fill(!1);for(let p of c)p>=0&&(f[p]=!0);let u=new Map;s.forEach((p,y)=>{f[y]||u.set(p,u.has(p)?-1:y)});let d=new Map;l.forEach((p,y)=>{c[y]>=0||d.set(p,(d.get(p)||0)+1)}),l.forEach((p,y)=>{if(c[y]>=0||d.get(p)!==1)return;let w=u.get(p);w===void 0||w===-1||f[w]||(c[y]=w,f[w]=!0)});let h=[];for(let p=0;p<r;p++)c[p]<0&&h.push(p);let A=[];for(let p=0;p<o;p++)f[p]||A.push(p);if(h.length===0||A.length===0)return c;let a=r*o+1,m=$t(e,t,n),g=(p,y)=>m(p,y)*a+Math.abs(p-y);for(let[p,y]of jt(h,A,g))c[p]=y;return c}var Xe=e=>typeof e=="object"&&e!==null;function Fe(e,t){if(!Xe(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(i=>{let r=JSON.stringify(e?.[i]);return r===void 0?" undef":r}))}function $t(e,t,n){if(!Xe(n))return(l,s)=>e[l]===t[s]?0:1;let i=Object.keys(n),r=l=>i.map(s=>JSON.stringify(l?.[s])),o=e.map(r),c=t.map(r);return(l,s)=>{let f=o[l],u=c[s],d=0;for(let h=0;h<i.length;h++)f[h]!==u[h]&&d++;return d}}function jt(e,t,n){return e.length<=t.length?Ke(e,t,n,!1):Ke(t,e,(i,r)=>n(r,i),!0)}function Ke(e,t,n,i){let r=e.length,o=t.length,c=[];for(let d=0;d<=r;d++)c.push(new Float64Array(o+1).fill(1/0));let l=[];for(let d=0;d<=r;d++)l.push(new Uint8Array(o+1));for(let d=0;d<=o;d++)c[r][d]=0;for(let d=r-1;d>=0;d--)for(let h=o-1;h>=0;h--){let A=n(e[d],t[h])+c[d+1][h+1],a=c[d][h+1];A<=a?(c[d][h]=A,l[d][h]=1):c[d][h]=a}let s=[],f=0,u=0;for(;f<r&&u<o;)l[f][u]&&(s.push(i?[t[u],e[f]]:[e[f],t[u]]),f++),u++;return s}function Ce(e,t,n,i,r,o,c,l={}){let s=e.find(t,n,l);if(r.length===0){s.forEach(E=>e.remove(E)),Re(l,"onRowsApplied",o.path,[]);return}let f=r.length>s.length,u=s[0]||null;if(f&&!u&&(u=qt(e,t,n,l),!u))throw new P(o.path);let d=s.map(E=>Wt(e,E,i,l)),h=null;if(f&&u){h=e.clone(u),l.templateAttr&&e.removeAttr(h,l.templateAttr);let E=e.stripIds(h);E>0&&console.warn(`[hyper-html-api] stripped ${E} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let A=Je(r,d,i,Dt(e,s,r,o,l)),a=s.length>0?e.parent(s[0]):Ut(e,t,n,u,o,l),m=s.length>0?et(e,a,s[0]):0,g=Kt(e,s),p=new Set,y=[],w=r.map((E,x)=>{let O=A[x];if(O>=0)return p.add(O),y.push(!1),s[O];y.push(!0);let T=e.clone(h);return e.stripIds(T),T});s.forEach((E,x)=>{p.has(x)||e.remove(E)}),g?Ft(e,a,m,w,y):Jt(e,w,y,a,m),vt(e,w,i,r,o,c,l),Re(l,"onRowsApplied",o.path,w)}function Re(e,t,n,i){if(typeof e[t]=="function")try{return e[t](n.slice(),i)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function Dt(e,t,n,i,r){let o=Re(r,"identifyRows",i.path,n);if(!Array.isArray(o))return null;let c=new Array(n.length).fill(-1),l=new Set,s=new Map(t.map((f,u)=>[e.identity(f),u]));for(let f=0;f<n.length;f++){if(!o[f])continue;let u=s.get(e.identity(o[f]));u===void 0||l.has(u)||(c[f]=u,l.add(u))}return c}function vt(e,t,n,i,r,o,c){t.forEach((l,s)=>{if(n===null){let f=i[s],u=f==null?"":String(f);e.text(l)!==u&&e.text(l,u)}else{let f=o(e,l,n,i[s],{depth:r.depth+1,path:[...r.path,s]},c);f&&f!==l&&(t[s]=f)}})}function Wt(e,t,n,i){return n===null?e.text(t):L(e,t,n,i.onRowsRead?{...i,onRowsRead:void 0}:i)}function et(e,t,n){let i=e.children(t);for(let r=0;r<i.length;r++)if(e.sameNode(i[r],n))return r;return-1}function qt(e,t,n,i){if(!i.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),o=new RegExp(":not\\(\\["+i.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),c=n.replace(/^\s*:scope\s*>\s*/,"").replace(o,""),l=r?Vt(c):0,s=Ae(c),f=t;for(;f;){let u=e.find(f,c,{includeRulesTag:!1,templateAttr:null});for(let d of u)if(e.attr(d,i.templateAttr)!=null&&!(r&&!Ht(e,t,d,l))&&!(s&&!e.matches(e.parent(d),s)))return d;f=e.parent(f)}return null}function Vt(e){let t=0,n=null,i=1;for(let r=0;r<e.length;r++){let o=e[r];if(o==="\\")r++;else if(n)o===n&&(n=null);else if(o==='"'||o==="'")n=o;else if(o==="["||o==="(")t++;else if(o==="]"||o===")")t>0&&t--;else if(t===0&&o===">")i++;else{if(t===0&&(o==="+"||o==="~"))return null;if(t===0&&/\s/.test(o)){if(!Bt(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return i}function Bt(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let i=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return Ye(i)||Ye(r)}function Ye(e){return e===">"||e==="+"||e==="~"}function Ht(e,t,n,i){if(i===null)return!0;let r=n;for(let s=0;s<i;s++)if(r=e.parent(r),!r)return!1;let o=e.prop(t,"tagName");if(!o)return!0;let c=e.prop(r,"tagName");if(!c||String(c).toLowerCase()!==String(o).toLowerCase())return!1;let l=new Set(Ge(e,r));return Ge(e,t).every(s=>l.has(s))}function Ge(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function Ut(e,t,n,i,r,o){let c=e.parent(i);if(c&&zt(e,t,c)&&!Qe(e,c,o))return c;let l=Ae(n);if(!l)throw new P(r.path,`the list selector "${n}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let f=(l===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,l,o)).filter(u=>!Qe(e,u,o));if(f.length===0)throw new P(r.path,`no container matching "${l}" inside this context to hold the new rows`);if(f.length>1)throw new P(r.path,`"${l}" matches ${f.length} containers inside this context, so the new rows have no single destination`);return f[0]}function zt(e,t,n){let i=n;for(;i;){if(e.sameNode(i,t))return!0;i=e.parent(i)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(r=>e.sameNode(r,n))}var Ze=["no-data","editor-ui"];function Qe(e,t,n){let i=t;for(;i;){if(n.templateAttr&&e.attr(i,n.templateAttr)!=null||Ze.some(o=>e.attr(i,o)!=null))return!0;let r=e.attr(i,"clay");if(r&&r.split(/\s+/).some(o=>Ze.includes(o)))return!0;i=e.parent(i)}return!1}function Ft(e,t,n,i,r){let o=e.children(t),c=o.map(s=>e.identity(s)),l=!1;i.forEach((s,f)=>{let u=e.identity(s),d=n+f;if(c[d]===u)return;if(!r[f]){let A=c.indexOf(u);A!==-1&&(c.splice(A,1),o.splice(A,1))}let h=Math.min(d,o.length);h<o.length?e.insertBefore(o[h],s):o.length?l?e.insertAfter(o[o.length-1],s):(e.insertAt(t,s,d),l=!0):e.insertAt(t,s,0),c.splice(h,0,u),o.splice(h,0,s)})}function Kt(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let i=new Map(e.children(n).map((o,c)=>[e.identity(o),c])),r=[];for(let o of t){let c=i.get(e.identity(o));if(c===void 0)return!1;r.push(c)}return r.sort((o,c)=>o-c),r[r.length-1]-r[0]===r.length-1}function Jt(e,t,n,i,r){let o=null,c=r;for(let l=0;l<t.length;l++){if(!n[l]){o=t[l];continue}let s=o?e.parent(o):i;if(!s)continue;let f=o?et(e,s,o)+1:c++;e.insertAt(s,t[l],f),o=t[l]}}function D(e,t,n,i,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");j(n,r);let o=[];if(Ne(n,i,[],o),o.length)throw new U(o);fe(e,t,n,i,{depth:0,path:[]},r)}function fe(e,t,n,i,r,o={}){if(r.depth>M)throw new _(r.path);if(i===void 0)return t;if(typeof n=="string")return Xt(e,t,n,i,r,o);if(Array.isArray(n)){let[c,l]=n;return Ce(e,t,c,l,i,r,fe,o),t}if(typeof n=="object"&&n!==null){for(let[c,l]of Object.entries(n)){let s=fe(e,t,l,i==null?i:i[c],{depth:r.depth+1,path:[...r.path,c]},o);s&&s!==t&&(t=s)}return t}return t}function Xt(e,t,n,i,r,o){if(n.endsWith("[]")){let d=n.slice(0,-2);return Ce(e,t,d,null,i,r,fe,o),t}let c=le(n,o);if(c){let d=c.selector?e.find(t,c.selector,o):[t];return d.length&&c.codec.write(e,d[0],i,{query:o.query}),t}if(n.startsWith("@"))return nt(e,t,n.slice(1),i);let l=N(n);if(l!==-1){let{selector:d,all:h}=b(n),A=n.slice(l+1),a=d?e.find(t,d,o):[t];for(let m of h?a:a.slice(0,1))nt(e,m,A,i);return t}if(n===".")return tt(e,t,i),t;let{selector:s,all:f}=b(n),u=e.find(t,s,o);for(let d of f?u:u.slice(0,1))tt(e,d,i);return t}function tt(e,t,n){let i=n==null?"":String(n);e.text(t)!==i&&e.text(t,i)}function Yt(e,t,n,i){if(e.styleVar){e.styleVar(t,n,i);return}ce(e,t,n,i)}function nt(e,t,n,i){if(k(n))return Yt(e,t,n,i==null?"":String(i).trim()),t;if(B.has(n)){let r=e.prop(t,n);if(r===i||r!=null&&i!=null&&String(r)===String(i))return t;throw new z(n)}if(n==="outerHTML"){let r=i==null?"":String(i);return e.replaceWith(t,r)}if(pe.has(n)){let r=me(n,i);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(i==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(i);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function Ne(e,t,n,i){if(t!==void 0){if(typeof e=="string"){if($(e))return;if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,o)=>{typeof r=="object"&&r!==null&&i.push({path:X([...n,o]),expected:"scalar",got:J(r)})}):i.push({path:X(n),expected:"array",got:J(t)});return}t!==null&&typeof t=="object"&&i.push({path:X(n),expected:"scalar",got:J(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){i.push({path:X(n),expected:"array",got:J(t)});return}let r=e[1];t.forEach((o,c)=>Ne(r,o,[...n,c],i));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){i.push({path:X(n),expected:"object",got:J(t)});return}for(let[r,o]of Object.entries(e))Ne(o,t[r],[...n,r],i)}}}function J(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function X(e){return e.join(".")}function Pe(e){try{return JSON.parse(e)}catch(t){throw new C(`Invalid strict JSON: ${t.message}`,t)}}function Y(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function n(r){let o=[],c=0;for(;c<r.length;){let l=r[c];if(/\s/.test(l)){c++;continue}if("{}".includes(l)){o.push({type:l,value:l}),c++;continue}if(l==="["){let d=!1,h=c+1;for(;h<r.length&&/\s/.test(r[h]);)h++;if(h<r.length&&/[a-zA-Z_]/.test(r[h])&&(d=!0),!d){o.push({type:l,value:l}),c++;continue}}if(l==="]"){o.push({type:l,value:l}),c++;continue}if(l===":"){o.push({type:t.COLON,value:l}),c++;continue}if(l===","){o.push({type:t.COMMA,value:l}),c++;continue}if(l==='"'||l==="'"){let d=l,h=c+1;for(;h<r.length&&r[h]!==d;)r[h]==="\\"&&h++,h++;o.push({type:t.STRING,value:r.substring(c+1,h),quoted:!0,sourceQuote:d}),c=h+1;continue}let s=c,f;for(;s<r.length&&!/[{},]/.test(r[s]);)if(r[s]===":"){let d=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],h=!1;for(let A of d){let a=A.substring(1);if(r.substring(s+1,s+1+a.length)===a){h=!0,s+=a.length;break}}if(!h)break}else if(r[s]==="["){for(s++;s<r.length&&r[s]!=="]";){if(r[s]==='"'||r[s]==="'"){let d=r[s];for(s++;s<r.length&&r[s]!==d;)r[s]==="\\"&&s++,s++}s++}s<r.length&&r[s]==="]"&&s++}else s++;f=r.substring(c,s);let u=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(f)?u=t.NUMBER:f==="true"||f==="false"||f==="null"?u=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(f)&&(u=t.SELECTOR),o.push({type:u,value:f,quoted:!1}),c=s}return o}function i(r){let o="";for(let c=0;c<r.length;c++){let l=r[c];if("{}".includes(l.type)||"[]".includes(l.type)){o+=l.value;continue}if(l.type===t.COLON){o+=l.value;continue}if(l.type===t.COMMA){let s=r[c+1];if(s&&(s.type==="}"||s.type==="]"))continue;o+=l.value;continue}if(l.type===t.STRING&&l.quoted){let s=l.value;l.sourceQuote==="'"&&(s=s.replace(/\\'/g,"'"),s=s.replace(/(\\*)"/g,(f,u)=>u.length%2===0?u+'\\"':f)),o+=`"${s}"`;continue}if(l.type===t.NUMBER||l.type===t.BOOLEAN){o+=l.value;continue}if(l.type===t.SELECTOR||l.type===t.IDENTIFIER){o+=`"${l.value}"`;continue}o+=`"${l.value}"`}return o}try{let r=n(e),o=i(r);return JSON.parse(o)}catch(r){throw new C("Invalid extraction rules syntax: "+r.message,r)}}var it=["1","2"],rt=/^[a-zA-Z0-9_-]+$/;function W(e,t,n){let i;if(n===void 0)i="script[data-rules-name]";else{if(typeof n!="string"||!rt.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${rt})`);i=`script[data-rules-name~="${n}"]`}let r=e.find(t,i,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let o=r[0],c=e.attr(o,"data-rules-version");if(!it.includes(c))throw new H(c);return{rules:Y(e.text(o)),tagNode:o,version:c}}var ue=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),Gt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),ot=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function G(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function Me(e,t){if(G(e,t))return!0;for(let[n,i]of Object.entries(Gt))if(i.includes(t)&&G(e,n))return!0;return!1}function Z(e){let t=ue[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Zt(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let i=ue[t];if(!i)throw new Error(`Unknown region capability: ${t}`);if(i.tokens.some(r=>Me(n,r))||i.bundles.some(r=>G(n,r)))return n;n=n.parentElement}return null}function st(e,t){return!!Zt(e,t)}var ae=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...ot],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})}),Qt=new Set(["textContent","innerText"]);function ct(e){let n=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return n?n[1].toLowerCase():null}var en=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function lt(e,t,n=ae){if(!en.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let i=String(e).toLowerCase();if(n.refusedAttributePrefixes.some(r=>i.startsWith(r)))return`attribute "${i}" can run script`;if(n.refusedAttributes.includes(i))return`attribute "${i}" is not content`;if(n.urlAttributes.includes(i)&&t!=null){let r=i==="srcset"?String(t).split(",").map(o=>o.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let o of r){let c=ct(o);if(c&&n.refusedSchemes.includes(c))return`"${c}:" URLs are not allowed in "${i}"`}}return null}function ke(e,t){let n=e.prop(t,"tagName");return n?String(n).toLowerCase():""}function tn(e,t){let n=ke(e,t)||"node",i=e.attr(t,"id");return i?`<${n}#${i}>`:`<${n}>`}function nn(e,t,n){let i=t;for(;i;){let r=ke(e,i);if(r&&n.refusedTargets.includes(r))return r;i=e.parent(i)}return null}function ft(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function rn(e,t){return ke(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:ft(e,t)}function on(e){if(/[\u0000-\u001f\u007f]/.test(e))return"control characters are not allowed in a custom property value";let t=[],n=null;for(let i=0;i<e.length;i++){let r=e[i];if(n){r===n&&(n=null);continue}if(r==='"'||r==="'")n=r;else{if(r==="/"&&e[i+1]==="*")return"comments are not allowed in a custom property value";if(r==="(")t.push(")");else if(r==="[")t.push("]");else if((r===")"||r==="]")&&t.pop()!==r)return`"${r}" does not close anything in this custom property value`}}return n?"a custom property value must close its quotes":t.length?"a custom property value must close its brackets":null}function ut(e,t=ae){let n=t.customPropertyValues,i=String(e);if(i.length>n.maxLength)return`custom property values are limited to ${n.maxLength} characters`;let r=n.refusedCharacters.find(s=>i.includes(s));if(r)return`${JSON.stringify(r)} is not allowed in a custom property value`;let o=on(i);if(o)return o;let c=i.toLowerCase(),l=n.refusedFunctions.find(s=>new RegExp(`(^|[^a-z0-9_-])${s.replace(/[-]/g,"\\-")}\\s*\\(`).test(c));return l?`"${l}()" is not allowed in a custom property value`:null}function de(e,t=ae){let n=[],i=(s,f)=>(n.push({target:tn(e,s),reason:f}),!1),r=s=>{let f=nn(e,s,t);return f?i(s,`inside <${f}>, which is not content`):!0},o=s=>r(s)?ft(e,s)?i(s,"a text write here would delete the data rules tag"):!0:!1,c=(s,f,u)=>{if(!r(s))return!1;let d=lt(f,u,t);return d?i(s,d):!0};return{...e,text(s,f){if(f===void 0)return e.text(s);o(s)&&e.text(s,f)},attr(s,f,u){if(u===void 0)return e.attr(s,f);c(s,f,u)&&e.attr(s,f,u)},removeAttr(s,f){c(s,f,null)&&e.removeAttr(s,f)},styleVar(s,f,u){if((v(e.attr(s,"style"),f)??"")!==u&&r(s)){if(!k(f))return i(s,`"${f}" is not a custom property`);if(u!==""){let d=ut(u,t);if(d)return i(s,d)}ce(e,s,f,u)}},prop(s,f,u){if(u===void 0)return e.prop(s,f);if(t.refusedRuleForms.includes(f))return i(s,`"@${f}" writes HTML, only text is allowed`);if(Qt.has(f)){o(s)&&e.prop(s,f,u);return}c(s,f==="className"?"class":f,u)&&e.prop(s,f,u)},remove(s){if(rn(e,s)){i(s,"removing this would delete the data rules tag");return}e.remove(s)},replaceWith(s,f){return f===e.prop(s,"outerHTML")||i(s,'"@outerHTML" writes HTML, only text is allowed'),s},refusals:n,assertClean(){if(n.length)throw new F(n.slice())}}}function Q(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function at(e){return e.reduce((t,n)=>typeof n=="number"?`${t}[${n}]`:t?`${t}.${n}`:n,"")}function Le(e,t,n,i,r={}){j(n,r);let o=[],c=[];function l(f,u,d){if(Array.isArray(f)){let[,h]=f;if(!Array.isArray(u)||!Q(h))return;u.forEach((A,a)=>l(h,A,[...d,a]));return}if(!(!Q(f)||!Q(u)))for(let h of Object.keys(u))Object.prototype.hasOwnProperty.call(f,h)?l(f[h],u[h],[...d,h]):o.push(at([...d,h]))}function s(f,u,d,h){if(d!==void 0){if(typeof u=="string"){if(u.endsWith("[]")||u==="."||u.startsWith("@"))return;let{selector:A}=b(u);if(!A)return;e.find(f,A,r).length===0&&c.push({path:at(h),selector:A});return}if(!Array.isArray(u)&&Q(u)&&Q(d))for(let[A,a]of Object.entries(u))s(f,a,d[A],[...h,A])}}return l(n,i,[]),s(t,n,i,[]),{unknownKeys:o,unmatched:c}}function Ie(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null,version:"1"};if(typeof n=="string"){let i=t&&t.ownerDocument?t.ownerDocument:t;return W(e,i,n)}return null}var cn=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function ln(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function dt(e,t,n,i){if(i)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function ht(e,t,n,i,r,o){return(o?st(e,t):dt(e,n,r,!1))||!!(i&&(o&&e!==r?e.matches(i):dt(e,i,r,o)))}function fn(e,t){let n=ue[t];return n.tokens.some(i=>Me(e,i))||n.bundles.some(i=>G(e,i))}var un=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function pt(e,t,n,i){if(e.nodeType===1&&i(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,o=t;if(e.nodeType===1){if(un.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,o=t.content,n.cloneToLive.set(o,r),n.liveToClone.set(r,o)}}else if(e.nodeType!==11)return;let c=o.firstChild;for(let l=r.firstChild;l&&c;l=l.nextSibling)pt(l,c,n,i),c=c.nextSibling}function ee(e,{capability:t="data",exclude:n=null,inherit:i=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let o=e.nodeType===9?e:e.ownerDocument;if(!o?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let c=o.implementation.createHTMLDocument(""),l=r||new WeakMap,s=new WeakMap,f=e.nodeType===9?e.documentElement:e;n&&c.documentElement.matches(n);let u=Z(t),d=i?a=>fn(a,t)||!!(n&&a.matches(n)):a=>ht(a,t,u,n,f,!1),h=null;if(f.nodeType!==1||!ht(f,t,u,n,f,i)){h=c.importNode(f,!0);let a={cloneToLive:l,liveToClone:s,dropped:[],controls:[]};pt(f,h,a,d);for(let m of a.dropped)m.remove();for(let m=0;m<a.controls.length;m+=2)ln(a.controls[m],a.controls[m+1])}e.nodeType===9&&h&&(c.replaceChild(h,c.documentElement),s.set(e,c),l.set(c,e));let A=a=>{if(cn.test(a))throw new Error(`Filtered content queries do not support stateful selector: ${a}`)};return{root:h,document:c,capability:t,selector:Z(t),cloneToLive:l,liveToClone:s,original(a){return l.get(a)||null},cloneOf(a){return s.get(a)||null},query(a,m=h){return A(a),Array.from(m.querySelectorAll(a),g=>l.get(g)||g)},text(a=h){return(a===h?h:s.get(a))?.textContent||""},html(a=h){return(a===h?h:s.get(a))?.innerHTML??""},clone(a=h){let m=a===h?h:s.get(a);return m?c.importNode(m,!0):null}}}function yt(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function an(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function mt(e,t,n){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=n===null?"":n:t==="checked"&&e.tagName==="INPUT"?e.checked=n!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=n!==null))}function gt(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function wt(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let i=n.type;i!=="file"&&i!=="checkbox"&&i!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var S={semanticExclude:!0,find(e,t,n={}){let i=an(e);if(!i||!i.querySelectorAll)return[];let r=Array.from(i.querySelectorAll(t));n.includeRulesTag||(r=r.filter(l=>!yt(l)));let o=[];n.skip&&o.push(n.skip);let c=n.templateAttr===null?null:n.templateAttr||"cms-template";if(c&&o.push("["+c+"]"),o.length){let l=o.join(", ");r=r.filter(s=>!s.closest||!s.closest(l))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,gt(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),mt(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),mt(e,t,null)},prop(e,t,n){if(n===void 0){let i=e?e[t]:void 0;return i!==void 0?i:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return wt(t),t},insertAt(e,t,n){let i=e.children[n]||null;e.insertBefore(t,i)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let i=e.ownerDocument.createElement("template");i.innerHTML=t;let r=i.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(i=>{i.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function I(e,t={}){if(t.exclude===null)return S;let n=[Z("data"),t.exclude].filter(Boolean).join(", "),i=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!i?.querySelector?.(n))return S;let o=e.nodeType===9||!e.isConnected?e:e.ownerDocument,c=e.nodeType===9?e:e.ownerDocument,l=null,s=()=>l||(l=ee(o,{capability:"data",exclude:t.exclude||null})),f=a=>{let m=s();return a===e?m.cloneOf(e):m.cloneOf(a)||a},u=a=>l?.original(a)||a,d=(a,m)=>{s().liveToClone.set(a,m),s().cloneToLive.set(m,a);let g=a.childNodes||[],p=m.childNodes||[];for(let y=0;y<Math.min(g.length,p.length);y++)d(g[y],p[y])},h=(a,m,g,p)=>{let y=Array.from(a.childNodes).filter(T=>l.cloneOf(T)),E=y[0];for(;E&&y.includes(E);)E=E.nextSibling;for(let T of y)T.remove();if(g==="innerHTML"){let T=c.createElement("template");T.innerHTML=p;for(let V of Array.from(T.content.childNodes))a.insertBefore(V,E||null)}else a.insertBefore(c.createTextNode(p),E||null),gt(a,p);let x=ee(a,{capability:"data",exclude:t.exclude||null});m.replaceChildren(...Array.from(x.root?.childNodes||[]));let O=T=>{let V=x.original(T);V&&(l.liveToClone.set(V,T),l.cloneToLive.set(T,V));for(let Et of Array.from(T.childNodes||[]))O(Et)};for(let T of Array.from(m.childNodes))O(T)},A={...S,find(a,m,g={}){let p=f(a);if(!p?.querySelectorAll)return[];let y=s().query(m,p);g.includeRulesTag||(y=y.filter(x=>!yt(x)));let w=[];g.skip&&w.push(g.skip);let E=g.templateAttr===null?null:g.templateAttr||"cms-template";if(E&&w.push(`[${E}]`),w.length){let x=w.join(", ");y=y.filter(O=>!O.closest?.(x))}return y},parent(a){let m=f(a)?.parentElement;return m?u(m):null},children(a){return Array.from(f(a)?.children||[],u)},text(a,m){if(m===void 0){let y=u(a);return!y?.matches?.(n)&&!y?.querySelector?.(n)?S.text(y):(f(a)?.textContent||"").trim()}let g=u(a);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!l){S.text(g,m);return}let p=s().cloneOf(g);p?h(g,p,"textContent",m):S.text(g,m)},attr(a,m,g){let p=u(a);if(g===void 0)return S.attr(p,m);S.attr(p,m,g);let y=l?.cloneOf(p);y&&(S.attr(y,m,g),ee(p,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),l.liveToClone.delete(p),l.cloneToLive.delete(y)))},removeAttr(a,m){let g=u(a);S.removeAttr(g,m);let p=l?.cloneOf(g);p&&S.removeAttr(p,m)},prop(a,m,g){let p=u(a);if(g===void 0)return m==="innerHTML"||m==="outerHTML"||m==="textContent"||m==="innerText"?S.prop(f(p),m):S.prop(p,m);let y=m==="innerHTML"||m==="textContent"||m==="innerText",w=y?s().cloneOf(p):l?.cloneOf(p);w&&y?h(p,w,m,g):(S.prop(p,m,g),w&&S.prop(w,m,g))},clone(a){let m=f(a);if(m===a)return S.clone(a);let g=c.importNode(m,!0);return wt(g),g},insertAt(a,m,g){let p=u(a),w=A.children(p)[g]||(()=>{for(let O=p.children.length-1;O>=0;O--){let T=p.children[O];if(s().cloneOf(T))return T.nextElementSibling}return p.firstElementChild})(),E=u(m);p.insertBefore(E,w||null);let x=s().cloneOf(p);if(x){let O=s().cloneOf(E);O||(O=c.importNode(E,!0),d(E,O));let T=Array.from(x.children);x.insertBefore(O,T[g]||null)}},insertBefore(a,m){let g=u(a),p=u(m);g.parentNode.insertBefore(p,g);let y=s().cloneOf(g.parentNode);if(y){let w=s().cloneOf(p);w||(w=c.importNode(p,!0),d(p,w));let E=s().cloneOf(g);E?E.before(w):y.appendChild(w)}},insertAfter(a,m){let g=u(a),p=u(m);g.parentNode.insertBefore(p,g.nextSibling);let y=s().cloneOf(g.parentNode);if(y){let w=s().cloneOf(p);w||(w=c.importNode(p,!0),d(p,w));let E=s().cloneOf(g);E?E.after(w):y.appendChild(w)}},identity(a){return u(a)||null},remove(a){let m=u(a),g=s().cloneOf(m);S.remove(m),g&&S.remove(g)},replaceWith(a,m){let g=u(a),p=s().cloneOf(g),y=S.replaceWith(g,m);if(p){let w=ee(y,{capability:"data",exclude:t.exclude||null});if(!w.root)p.remove();else{p.replaceWith(w.root);let E=x=>{let O=w.original(x);O&&(l.liveToClone.set(O,x),l.cloneToLive.set(x,O));for(let T of Array.from(x.childNodes||[]))E(T)};E(w.root)}}return y}};return A}var te=S;var ne=e=>({codecs:Se(),...e}),re={extract:(e,t,n={})=>L(I(e,n),e,t,ne(n)),apply:(e,t,n,i={})=>D(I(e,{...i,_write:!0}),e,t,n,ne(i)),findRulesIn:(e,t)=>W(te,e,t),findRules:(e,t)=>Ie(te,e,t),bind:(e,t,n={})=>{let i=Ie(te,e,t);if(!i){let o=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${o}`)}let r=ne({version:i.version,...n});return{...i,get:()=>L(I(e,n),e,i.rules,r),set:o=>D(I(e,{...n,_write:!0}),e,i.rules,o,r)}},codecs:{register:Te,get:Oe},parseStrict:Pe,parseRelaxed:Y,ruleAttrIndex:N,splitRule:b,errors:R,DOM_PROPERTIES:ie},_e=e=>!!e&&typeof e.nodeType=="number";function At(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=W(te,t,"api");if(!n)throw new R.NoRulesTag("api");return{rules:n.rules,version:n.version}}function dn(e){if(e.nodeType===9)return e;let t=e.ownerDocument?.documentElement;if(t?.contains(e))return t;let n=e;for(;n.parentNode;)n=n.parentNode;return n}function hn(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let t=e.ownerDocument.createDocumentFragment();for(let n of e.childNodes)t.appendChild(n.cloneNode(!0));return t}function pn(e,t){let n=[];for(;t!==e;){let i=t.parentNode;n.push(Array.prototype.indexOf.call(i.childNodes,t)),t=i}return n.reverse()}function mn(e,t){return t.reduce((n,i)=>n.childNodes[i],e)}function q(e,t){let n=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&n.unshift(e),n}function yn(e,t){let n=q(e,"option"),i=q(t,"option");n.forEach((s,f)=>i[f].selected=s.selected);let r=q(e,"input"),o=q(t,"input");r.forEach((s,f)=>{let u=s.type.toLowerCase();u!=="file"&&(o[f].value=s.value),(u==="checkbox"||u==="radio")&&(o[f].checked=s.checked)});let c=q(e,"textarea"),l=q(t,"textarea");c.forEach((s,f)=>l[f].value=s.value)}function $e(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let n=e.startsWith("@")?0:N(e);if(n===-1)return;let i=e.slice(n+1);if(B.has(i))throw new R.RuleTargetReadOnly(i);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(n=>$e(e[1],n));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[n,i]of Object.entries(e))$e(i,t[n])}}function gn(e,t,n,i){let r=ne({templateAttr:"cms-template",version:i}),o=dn(e),c=pn(o,e),l=hn(o);yn(o,l);let s=mn(l,c),f=I(l,{...r,_write:!0}),u=Le(f,s,t,n,r);if(u.unknownKeys.length||u.unmatched.length)throw new R.WriteRejected(u.unknownKeys,u.unmatched);let d=de(f);D(d,s,t,n,r),d.assertClean(),$e(t,n);let h=de(I(o,{...r,_write:!0}));D(h,e,t,n,r),h.assertClean()}function wn(e){if(!(e instanceof Error))return e;let n=e instanceof R.UnknownCodec||e instanceof R.CodecRefused?e.code:e.name||"Error";try{e.code=n}catch{Object.defineProperty(e,"code",{value:n,configurable:!0,enumerable:!0})}return e instanceof R.WriteRefused?e.details=e.refusals:e instanceof R.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof R.ShapeMismatch?e.details=e.mismatches:Array.isArray(e.path)?e.details={path:e.path}:typeof e.target=="string"?e.details={target:e.target}:e.token!==void 0?e.details={token:e.token}:e.version!==void 0?e.details={version:e.version}:e.details={},e}function je(e,t){let n=_e(e)?e:document,i=_e(e)?t:e;if(i===void 0){let{rules:r,version:o}=At(n);return L(I(n),n,r,ne({version:o}))}return re.bind(n,i).get()}function De(e,t,n){try{if(!_e(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let{rules:i,version:r}=n===void 0?At(e):re.bind(e,n);gn(e,i,t,r)}catch(i){throw wn(i)}return e}var An={engine:re,extractData:je,applyData:De},En=An;return bt(Tn);})();
5
+ var hyperHtmlApiData=(()=>{var he=Object.defineProperty;var Tt=Object.getOwnPropertyDescriptor;var Ot=Object.getOwnPropertyNames;var St=Object.prototype.hasOwnProperty;var ve=(e,t)=>{for(var n in t)he(e,n,{get:t[n],enumerable:!0})},xt=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ot(t))!St.call(e,r)&&r!==n&&he(e,r,{get:()=>t[r],enumerable:!(i=Tt(t,r))||i.enumerable});return e};var bt=e=>xt(he({},"__esModule",{value:!0}),e);var Tn={};ve(Tn,{applyData:()=>De,default:()=>En,engine:()=>re,extractData:()=>je});var ie=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],oe=new Set(ie),pe=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),B=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),We=new Set(["checked","selected","disabled","readOnly","paused"]);function me(e,t){return t==null?We.has(e)?!1:"":We.has(e)?t==="false"?!1:!!t:t}var R={};ve(R,{CodecRefused:()=>we,EmptyListInsert:()=>P,MAX_RULE_DEPTH:()=>M,MaxRuleDepthExceeded:()=>_,NoRulesTag:()=>ye,RuleTargetReadOnly:()=>z,RulesParseError:()=>C,ShapeMismatch:()=>U,UnknownCodec:()=>K,UnknownRulesVersion:()=>H,WriteNotRoundTripped:()=>se,WriteRefused:()=>F,WriteRejected:()=>ge});var C=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},H=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1" and "2".`),this.name="UnknownRulesVersion",this.version=t}},M=20,_=class extends Error{constructor(t){super(`rule depth exceeded ${M} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},U=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},P=class extends Error{constructor(t,n){super(n?`cannot add items to empty list at "${t.join(".")}" \u2014 ${n}`:`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},z=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},F=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function Rt(e){return e.reduce((n,i)=>typeof i=="number"?`${n}[${i}]`:n?`${n}.${i}`:String(i),"")||"(root)"}var se=class extends Error{constructor(t){super(`write did not round-trip at "${Rt(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},ye=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},ge=class extends Error{constructor(t,n){super(`write rejected: ${t.length} unknown key(s), ${n.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=t,this.unmatched=n}},K=class extends Error{constructor(t){super(`unknown codec "${t}": no codec by that name is given to this call`),this.name="UnknownCodec",this.code="unknown-codec",this.codec=t}},we=class extends Error{constructor(t,n){super(n),this.name="CodecRefused",this.code=t}};function N(e){let t=0,n=null,i=-1;for(let r=0;r<e.length;r++){let o=e[r];o==="\\"?r++:n?o===n&&(n=null):o==='"'||o==="'"?n=o:o==="["||o==="("?t++:o==="]"||o===")"?t>0&&t--:o==="@"&&t===0&&(i=r)}return i}var qe="[*]";function b(e){let t=N(e),n=t===-1?e:e.slice(0,t),i=n.endsWith(qe),r={selector:i?n.slice(0,-qe.length):n,prop:t===-1?null:e.slice(t+1)||null};return i&&(r.all=!0),r}function Ae(e){let t=0,n=null,i=-1,r=!1;for(let o=0;o<e.length;o++){let c=e[o];c==="\\"?o++:n?c===n&&(n=null):c==='"'||c==="'"?n=c:c==="["||c==="("?t++:c==="]"||c===")"?t>0&&t--:t===0&&c===">"?i=o:t===0&&c===","&&(r=!0)}return r||i===-1||!Ct(e,i+1)?null:e.slice(0,i).trim()||null}function Ct(e,t){let n=t,i=e.replace(/\s+$/,"").length;for(;n<i&&/\s/.test(e[n]);)n++;let r=0,o=null;for(;n<i;n++){let c=e[n];if(c==="\\")n++;else if(o)c===o&&(o=null);else if(c==='"'||c==="'")o=c;else if(c==="["||c==="(")r++;else if(c==="]"||c===")")r>0&&r--;else if(r===0&&(c==="+"||c==="~"||/\s/.test(c)))return!1}return!0}var Nt=/^codec\(([a-z][a-z0-9-]*)\)$/;function $(e){if(typeof e!="string")return null;let t=N(e);if(t===-1)return null;let n=Nt.exec(e.slice(t+1));if(!n)return null;let{selector:i,all:r}=b(e);if(r)throw new C("A @codec(name) rule cannot use [*].");return{selector:i,name:n[1]}}var Pt=/^--[A-Za-z0-9_-]+$/;function k(e){return typeof e=="string"&&Pt.test(e)}function Ve(e){let t=[],n=[],i=null,r=0;for(let o=0;o<e.length;o++){let c=e[o];if(i){c==="\\"?o++:c===i&&(i=null);continue}if(c==="/"&&e[o+1]==="*"){let l=e.indexOf("*/",o+2);o=l===-1?e.length:l+1;continue}c==='"'||c==="'"?i=c:c==="("?n.push(")"):c==="["?n.push("]"):c==="{"?n.push("}"):(c===")"||c==="]"||c==="}")&&n[n.length-1]===c?n.pop():c===";"&&n.length===0&&(t.push(e.slice(r,o)),r=o+1)}return t.push(e.slice(r)),t}function Mt(e){let t="",n=null;for(let i=0;i<e.length;i++){let r=e[i];if(n){t+=r,r==="\\"&&i+1<e.length?t+=e[++i]:r===n&&(n=null);continue}if(r==="/"&&e[i+1]==="*"){let o=e.indexOf("*/",i+2);i=o===-1?e.length:o+1,t+=" ";continue}(r==='"'||r==="'")&&(n=r),t+=r}return t}function Be(e){e=Mt(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),i=e.slice(t+1).trim(),r=/!\s*important\s*$/i.exec(i);return r&&(i=i.slice(0,r.index).trim()),{name:n,value:i,important:!!r}}function v(e,t){if(e==null)return null;let n=null;for(let i of Ve(String(e))){let r=Be(i);!r||r.name!==t||(!n||r.important||!n.important)&&(n=r)}return n?n.value:null}function He(e,t,n){let i=e==null?"":String(e),r=n==null||n==="",o=Ve(i),c=o.map(Be),l=c.some(d=>d&&d.name===t&&d.important),s=[],f=!1;o.forEach((d,h)=>{let A=c[h];if(!A||A.name!==t){s.push(d);return}if(r||f)return;let a=/^\s*/.exec(d)[0];s.push(`${a}${t}: ${n}${l?" !important":""}`),f=!0});let u=s.join(";");if(!r&&!f){let d=u.trimEnd();u=d===""?`${t}: ${n}`:`${d}${d.endsWith(";")?" ":"; "}${t}: ${n}`}return u.trim()===""?null:u}function ce(e,t,n,i){let r=e.attr(t,"style");if((v(r,n)??"")===i)return;let o=He(r,n,i);o==null?e.removeAttr(t,"style"):e.attr(t,"style",o)}var Ue=/^[a-z][a-z0-9-]*$/,Ee=new Map;function Te(e,t){if(typeof e!="string"||!Ue.test(e))throw new Error(`hyper-html-api: invalid codec name ${JSON.stringify(e)} (must match ${Ue})`);if(!t||typeof t.read!="function"||typeof t.write!="function"||typeof t.same!="function")throw new Error(`hyper-html-api: codec "${e}" needs read, write and same functions`);Ee.set(e,t)}function Oe(e){return Ee.get(e)??null}function Se(){return Object.fromEntries(Ee)}var kt='The @codec(name) rule form needs a rules tag with data-rules-version="2".',Lt="A @codec(name) rule must be the value of a top level key.";function le(e,t){let n=$(e);return n?{...n,codec:t.codecs[n.name]}:null}function j(e,t={}){let n=t.version??"1",i=t.codecs??{};r(e,0);function r(o,c){if(!(c>M)){if(typeof o=="string"){let l=$(o);if(!l)return;if(n!=="2")throw new C(kt);if(c!==1)throw new C(Lt);if(!Object.prototype.hasOwnProperty.call(i,l.name))throw new K(l.name);return}if(Array.isArray(o)){r(o[1],c+1);return}if(o&&typeof o=="object")for(let l of Object.values(o))r(l,c+1)}}}function L(e,t,n,i={}){if(Object.prototype.hasOwnProperty.call(i,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return j(n,i),be(e,t,n,{depth:0,path:[]},i)}function be(e,t,n,i,r){if(i.depth>M)throw new _(i.path);if(typeof n=="string")return It(e,t,n,i,r);if(Array.isArray(n)){let[o,c]=n,l=e.find(t,o,r);return ze(r,i,l),l.map((s,f)=>be(e,s,c,{depth:i.depth+1,path:[...i.path,f]},r))}if(typeof n=="object"&&n!==null){let o={};for(let[c,l]of Object.entries(n))o[c]=be(e,t,l,{depth:i.depth+1,path:[...i.path,c]},r);return o}return null}function It(e,t,n,i,r){if(n.endsWith("[]")){let u=n.slice(0,-2),d=e.find(t,u,r);return ze(r,i,d),d.map(h=>e.text(h))}let o=le(n,r);if(o)return _t(e,t,o,r);if(n.startsWith("@"))return xe(e,t,n.slice(1));let c=N(n);if(c!==-1){let{selector:u,all:d}=b(n),h=n.slice(c+1),A=u?e.find(t,u,r):[t];return d&&r.allMatches?A.map(a=>xe(e,a,h)):A.length===0?null:xe(e,A[0],h)}if(n===".")return e.text(t);let{selector:l,all:s}=b(n),f=e.find(t,l,r);return s&&r.allMatches?f.map(u=>e.text(u)):f.length===0?null:e.text(f[0])}function _t(e,t,{selector:n,codec:i},r){let o=n?e.find(t,n,r):[t];return o.length===0?null:i.read(e,o[0],{query:r.query,view:r.view,region:r.region})}function ze(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(i){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,i)}}function xe(e,t,n){if(k(n))return v(e.attr(t,"style"),n);if(oe.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let i=e.attr(t,n);return i??null}function Je(e,t,n,i){let r=e.length,o=t.length,c=new Array(r).fill(-1);if(i){let p=new Set;for(let y=0;y<r;y++){let w=i[y];!(w>=0&&w<o)||p.has(w)||(c[y]=w,p.add(w))}}if(r===0||o===0)return c;let l=e.map(p=>Fe(p,n)),s=t.map(p=>Fe(p,n)),f=new Array(o).fill(!1);for(let p of c)p>=0&&(f[p]=!0);let u=new Map;s.forEach((p,y)=>{f[y]||u.set(p,u.has(p)?-1:y)});let d=new Map;l.forEach((p,y)=>{c[y]>=0||d.set(p,(d.get(p)||0)+1)}),l.forEach((p,y)=>{if(c[y]>=0||d.get(p)!==1)return;let w=u.get(p);w===void 0||w===-1||f[w]||(c[y]=w,f[w]=!0)});let h=[];for(let p=0;p<r;p++)c[p]<0&&h.push(p);let A=[];for(let p=0;p<o;p++)f[p]||A.push(p);if(h.length===0||A.length===0)return c;let a=r*o+1,m=$t(e,t,n),g=(p,y)=>m(p,y)*a+Math.abs(p-y);for(let[p,y]of jt(h,A,g))c[p]=y;return c}var Xe=e=>typeof e=="object"&&e!==null;function Fe(e,t){if(!Xe(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(i=>{let r=JSON.stringify(e?.[i]);return r===void 0?" undef":r}))}function $t(e,t,n){if(!Xe(n))return(l,s)=>e[l]===t[s]?0:1;let i=Object.keys(n),r=l=>i.map(s=>JSON.stringify(l?.[s])),o=e.map(r),c=t.map(r);return(l,s)=>{let f=o[l],u=c[s],d=0;for(let h=0;h<i.length;h++)f[h]!==u[h]&&d++;return d}}function jt(e,t,n){return e.length<=t.length?Ke(e,t,n,!1):Ke(t,e,(i,r)=>n(r,i),!0)}function Ke(e,t,n,i){let r=e.length,o=t.length,c=[];for(let d=0;d<=r;d++)c.push(new Float64Array(o+1).fill(1/0));let l=[];for(let d=0;d<=r;d++)l.push(new Uint8Array(o+1));for(let d=0;d<=o;d++)c[r][d]=0;for(let d=r-1;d>=0;d--)for(let h=o-1;h>=0;h--){let A=n(e[d],t[h])+c[d+1][h+1],a=c[d][h+1];A<=a?(c[d][h]=A,l[d][h]=1):c[d][h]=a}let s=[],f=0,u=0;for(;f<r&&u<o;)l[f][u]&&(s.push(i?[t[u],e[f]]:[e[f],t[u]]),f++),u++;return s}function Ce(e,t,n,i,r,o,c,l={}){let s=e.find(t,n,l);if(r.length===0){s.forEach(E=>e.remove(E)),Re(l,"onRowsApplied",o.path,[]);return}let f=r.length>s.length,u=s[0]||null;if(f&&!u&&(u=qt(e,t,n,l),!u))throw new P(o.path);let d=s.map(E=>Wt(e,E,i,l)),h=null;if(f&&u){h=e.clone(u);let E=l.templateAttr&&e.attr(u,l.templateAttr)!=null;l.templateAttr&&e.removeAttr(h,l.templateAttr),E&&e.removeAttr(h,"hidden");let O=e.stripIds(h);O>0&&console.warn(`[hyper-html-api] stripped ${O} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let A=Je(r,d,i,Dt(e,s,r,o,l)),a=s.length>0?e.parent(s[0]):Ut(e,t,n,u,o,l),m=s.length>0?et(e,a,s[0]):0,g=Kt(e,s),p=new Set,y=[],w=r.map((E,O)=>{let S=A[O];if(S>=0)return p.add(S),y.push(!1),s[S];y.push(!0);let T=e.clone(h);return e.stripIds(T),T});s.forEach((E,O)=>{p.has(O)||e.remove(E)}),g?Ft(e,a,m,w,y):Jt(e,w,y,a,m),vt(e,w,i,r,o,c,l),Re(l,"onRowsApplied",o.path,w)}function Re(e,t,n,i){if(typeof e[t]=="function")try{return e[t](n.slice(),i)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function Dt(e,t,n,i,r){let o=Re(r,"identifyRows",i.path,n);if(!Array.isArray(o))return null;let c=new Array(n.length).fill(-1),l=new Set,s=new Map(t.map((f,u)=>[e.identity(f),u]));for(let f=0;f<n.length;f++){if(!o[f])continue;let u=s.get(e.identity(o[f]));u===void 0||l.has(u)||(c[f]=u,l.add(u))}return c}function vt(e,t,n,i,r,o,c){t.forEach((l,s)=>{if(n===null){let f=i[s],u=f==null?"":String(f);e.text(l)!==u&&e.text(l,u)}else{let f=o(e,l,n,i[s],{depth:r.depth+1,path:[...r.path,s]},c);f&&f!==l&&(t[s]=f)}})}function Wt(e,t,n,i){return n===null?e.text(t):L(e,t,n,i.onRowsRead?{...i,onRowsRead:void 0}:i)}function et(e,t,n){let i=e.children(t);for(let r=0;r<i.length;r++)if(e.sameNode(i[r],n))return r;return-1}function qt(e,t,n,i){if(!i.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),o=new RegExp(":not\\(\\["+i.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),c=n.replace(/^\s*:scope\s*>\s*/,"").replace(o,""),l=r?Vt(c):0,s=Ae(c),f=t;for(;f;){let u=e.find(f,c,{includeRulesTag:!1,templateAttr:null});for(let d of u)if(e.attr(d,i.templateAttr)!=null&&!(r&&!Ht(e,t,d,l))&&!(s&&!e.matches(e.parent(d),s)))return d;f=e.parent(f)}return null}function Vt(e){let t=0,n=null,i=1;for(let r=0;r<e.length;r++){let o=e[r];if(o==="\\")r++;else if(n)o===n&&(n=null);else if(o==='"'||o==="'")n=o;else if(o==="["||o==="(")t++;else if(o==="]"||o===")")t>0&&t--;else if(t===0&&o===">")i++;else{if(t===0&&(o==="+"||o==="~"))return null;if(t===0&&/\s/.test(o)){if(!Bt(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return i}function Bt(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let i=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return Ye(i)||Ye(r)}function Ye(e){return e===">"||e==="+"||e==="~"}function Ht(e,t,n,i){if(i===null)return!0;let r=n;for(let s=0;s<i;s++)if(r=e.parent(r),!r)return!1;let o=e.prop(t,"tagName");if(!o)return!0;let c=e.prop(r,"tagName");if(!c||String(c).toLowerCase()!==String(o).toLowerCase())return!1;let l=new Set(Ge(e,r));return Ge(e,t).every(s=>l.has(s))}function Ge(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function Ut(e,t,n,i,r,o){let c=e.parent(i);if(c&&zt(e,t,c)&&!Qe(e,c,o))return c;let l=Ae(n);if(!l)throw new P(r.path,`the list selector "${n}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let f=(l===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,l,o)).filter(u=>!Qe(e,u,o));if(f.length===0)throw new P(r.path,`no container matching "${l}" inside this context to hold the new rows`);if(f.length>1)throw new P(r.path,`"${l}" matches ${f.length} containers inside this context, so the new rows have no single destination`);return f[0]}function zt(e,t,n){let i=n;for(;i;){if(e.sameNode(i,t))return!0;i=e.parent(i)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(r=>e.sameNode(r,n))}var Ze=["no-data","editor-ui"];function Qe(e,t,n){let i=t;for(;i;){if(n.templateAttr&&e.attr(i,n.templateAttr)!=null||Ze.some(o=>e.attr(i,o)!=null))return!0;let r=e.attr(i,"clay");if(r&&r.split(/\s+/).some(o=>Ze.includes(o)))return!0;i=e.parent(i)}return!1}function Ft(e,t,n,i,r){let o=e.children(t),c=o.map(s=>e.identity(s)),l=!1;i.forEach((s,f)=>{let u=e.identity(s),d=n+f;if(c[d]===u)return;if(!r[f]){let A=c.indexOf(u);A!==-1&&(c.splice(A,1),o.splice(A,1))}let h=Math.min(d,o.length);h<o.length?e.insertBefore(o[h],s):o.length?l?e.insertAfter(o[o.length-1],s):(e.insertAt(t,s,d),l=!0):e.insertAt(t,s,0),c.splice(h,0,u),o.splice(h,0,s)})}function Kt(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let i=new Map(e.children(n).map((o,c)=>[e.identity(o),c])),r=[];for(let o of t){let c=i.get(e.identity(o));if(c===void 0)return!1;r.push(c)}return r.sort((o,c)=>o-c),r[r.length-1]-r[0]===r.length-1}function Jt(e,t,n,i,r){let o=null,c=r;for(let l=0;l<t.length;l++){if(!n[l]){o=t[l];continue}let s=o?e.parent(o):i;if(!s)continue;let f=o?et(e,s,o)+1:c++;e.insertAt(s,t[l],f),o=t[l]}}function D(e,t,n,i,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");j(n,r);let o=[];if(Ne(n,i,[],o),o.length)throw new U(o);fe(e,t,n,i,{depth:0,path:[]},r)}function fe(e,t,n,i,r,o={}){if(r.depth>M)throw new _(r.path);if(i===void 0)return t;if(typeof n=="string")return Xt(e,t,n,i,r,o);if(Array.isArray(n)){let[c,l]=n;return Ce(e,t,c,l,i,r,fe,o),t}if(typeof n=="object"&&n!==null){for(let[c,l]of Object.entries(n)){let s=fe(e,t,l,i==null?i:i[c],{depth:r.depth+1,path:[...r.path,c]},o);s&&s!==t&&(t=s)}return t}return t}function Xt(e,t,n,i,r,o){if(n.endsWith("[]")){let d=n.slice(0,-2);return Ce(e,t,d,null,i,r,fe,o),t}let c=le(n,o);if(c){let d=c.selector?e.find(t,c.selector,o):[t];return d.length&&c.codec.write(e,d[0],i,{query:o.query}),t}if(n.startsWith("@"))return nt(e,t,n.slice(1),i);let l=N(n);if(l!==-1){let{selector:d,all:h}=b(n),A=n.slice(l+1),a=d?e.find(t,d,o):[t];for(let m of h?a:a.slice(0,1))nt(e,m,A,i);return t}if(n===".")return tt(e,t,i),t;let{selector:s,all:f}=b(n),u=e.find(t,s,o);for(let d of f?u:u.slice(0,1))tt(e,d,i);return t}function tt(e,t,n){let i=n==null?"":String(n);e.text(t)!==i&&e.text(t,i)}function Yt(e,t,n,i){if(e.styleVar){e.styleVar(t,n,i);return}ce(e,t,n,i)}function nt(e,t,n,i){if(k(n))return Yt(e,t,n,i==null?"":String(i).trim()),t;if(B.has(n)){let r=e.prop(t,n);if(r===i||r!=null&&i!=null&&String(r)===String(i))return t;throw new z(n)}if(n==="outerHTML"){let r=i==null?"":String(i);return e.replaceWith(t,r)}if(pe.has(n)){let r=me(n,i);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(i==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(i);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function Ne(e,t,n,i){if(t!==void 0){if(typeof e=="string"){if($(e))return;if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,o)=>{typeof r=="object"&&r!==null&&i.push({path:X([...n,o]),expected:"scalar",got:J(r)})}):i.push({path:X(n),expected:"array",got:J(t)});return}t!==null&&typeof t=="object"&&i.push({path:X(n),expected:"scalar",got:J(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){i.push({path:X(n),expected:"array",got:J(t)});return}let r=e[1];t.forEach((o,c)=>Ne(r,o,[...n,c],i));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){i.push({path:X(n),expected:"object",got:J(t)});return}for(let[r,o]of Object.entries(e))Ne(o,t[r],[...n,r],i)}}}function J(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function X(e){return e.join(".")}function Pe(e){try{return JSON.parse(e)}catch(t){throw new C(`Invalid strict JSON: ${t.message}`,t)}}function Y(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function n(r){let o=[],c=0;for(;c<r.length;){let l=r[c];if(/\s/.test(l)){c++;continue}if("{}".includes(l)){o.push({type:l,value:l}),c++;continue}if(l==="["){let d=!1,h=c+1;for(;h<r.length&&/\s/.test(r[h]);)h++;if(h<r.length&&/[a-zA-Z_]/.test(r[h])&&(d=!0),!d){o.push({type:l,value:l}),c++;continue}}if(l==="]"){o.push({type:l,value:l}),c++;continue}if(l===":"){o.push({type:t.COLON,value:l}),c++;continue}if(l===","){o.push({type:t.COMMA,value:l}),c++;continue}if(l==='"'||l==="'"){let d=l,h=c+1;for(;h<r.length&&r[h]!==d;)r[h]==="\\"&&h++,h++;o.push({type:t.STRING,value:r.substring(c+1,h),quoted:!0,sourceQuote:d}),c=h+1;continue}let s=c,f;for(;s<r.length&&!/[{},]/.test(r[s]);)if(r[s]===":"){let d=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],h=!1;for(let A of d){let a=A.substring(1);if(r.substring(s+1,s+1+a.length)===a){h=!0,s+=a.length;break}}if(!h)break}else if(r[s]==="["){for(s++;s<r.length&&r[s]!=="]";){if(r[s]==='"'||r[s]==="'"){let d=r[s];for(s++;s<r.length&&r[s]!==d;)r[s]==="\\"&&s++,s++}s++}s<r.length&&r[s]==="]"&&s++}else s++;f=r.substring(c,s);let u=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(f)?u=t.NUMBER:f==="true"||f==="false"||f==="null"?u=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(f)&&(u=t.SELECTOR),o.push({type:u,value:f,quoted:!1}),c=s}return o}function i(r){let o="";for(let c=0;c<r.length;c++){let l=r[c];if("{}".includes(l.type)||"[]".includes(l.type)){o+=l.value;continue}if(l.type===t.COLON){o+=l.value;continue}if(l.type===t.COMMA){let s=r[c+1];if(s&&(s.type==="}"||s.type==="]"))continue;o+=l.value;continue}if(l.type===t.STRING&&l.quoted){let s=l.value;l.sourceQuote==="'"&&(s=s.replace(/\\'/g,"'"),s=s.replace(/(\\*)"/g,(f,u)=>u.length%2===0?u+'\\"':f)),o+=`"${s}"`;continue}if(l.type===t.NUMBER||l.type===t.BOOLEAN){o+=l.value;continue}if(l.type===t.SELECTOR||l.type===t.IDENTIFIER){o+=`"${l.value}"`;continue}o+=`"${l.value}"`}return o}try{let r=n(e),o=i(r);return JSON.parse(o)}catch(r){throw new C("Invalid extraction rules syntax: "+r.message,r)}}var it=["1","2"],rt=/^[a-zA-Z0-9_-]+$/;function W(e,t,n){let i;if(n===void 0)i="script[data-rules-name]";else{if(typeof n!="string"||!rt.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${rt})`);i=`script[data-rules-name~="${n}"]`}let r=e.find(t,i,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let o=r[0],c=e.attr(o,"data-rules-version");if(!it.includes(c))throw new H(c);return{rules:Y(e.text(o)),tagNode:o,version:c}}var ue=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),Gt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),ot=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function G(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function Me(e,t){if(G(e,t))return!0;for(let[n,i]of Object.entries(Gt))if(i.includes(t)&&G(e,n))return!0;return!1}function Z(e){let t=ue[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Zt(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let i=ue[t];if(!i)throw new Error(`Unknown region capability: ${t}`);if(i.tokens.some(r=>Me(n,r))||i.bundles.some(r=>G(n,r)))return n;n=n.parentElement}return null}function st(e,t){return!!Zt(e,t)}var ae=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...ot],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})}),Qt=new Set(["textContent","innerText"]);function ct(e){let n=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return n?n[1].toLowerCase():null}var en=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function lt(e,t,n=ae){if(!en.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let i=String(e).toLowerCase();if(n.refusedAttributePrefixes.some(r=>i.startsWith(r)))return`attribute "${i}" can run script`;if(n.refusedAttributes.includes(i))return`attribute "${i}" is not content`;if(n.urlAttributes.includes(i)&&t!=null){let r=i==="srcset"?String(t).split(",").map(o=>o.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let o of r){let c=ct(o);if(c&&n.refusedSchemes.includes(c))return`"${c}:" URLs are not allowed in "${i}"`}}return null}function ke(e,t){let n=e.prop(t,"tagName");return n?String(n).toLowerCase():""}function tn(e,t){let n=ke(e,t)||"node",i=e.attr(t,"id");return i?`<${n}#${i}>`:`<${n}>`}function nn(e,t,n){let i=t;for(;i;){let r=ke(e,i);if(r&&n.refusedTargets.includes(r))return r;i=e.parent(i)}return null}function ft(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function rn(e,t){return ke(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:ft(e,t)}function on(e){if(/[\u0000-\u001f\u007f]/.test(e))return"control characters are not allowed in a custom property value";let t=[],n=null;for(let i=0;i<e.length;i++){let r=e[i];if(n){r===n&&(n=null);continue}if(r==='"'||r==="'")n=r;else{if(r==="/"&&e[i+1]==="*")return"comments are not allowed in a custom property value";if(r==="(")t.push(")");else if(r==="[")t.push("]");else if((r===")"||r==="]")&&t.pop()!==r)return`"${r}" does not close anything in this custom property value`}}return n?"a custom property value must close its quotes":t.length?"a custom property value must close its brackets":null}function ut(e,t=ae){let n=t.customPropertyValues,i=String(e);if(i.length>n.maxLength)return`custom property values are limited to ${n.maxLength} characters`;let r=n.refusedCharacters.find(s=>i.includes(s));if(r)return`${JSON.stringify(r)} is not allowed in a custom property value`;let o=on(i);if(o)return o;let c=i.toLowerCase(),l=n.refusedFunctions.find(s=>new RegExp(`(^|[^a-z0-9_-])${s.replace(/[-]/g,"\\-")}\\s*\\(`).test(c));return l?`"${l}()" is not allowed in a custom property value`:null}function de(e,t=ae){let n=[],i=(s,f)=>(n.push({target:tn(e,s),reason:f}),!1),r=s=>{let f=nn(e,s,t);return f?i(s,`inside <${f}>, which is not content`):!0},o=s=>r(s)?ft(e,s)?i(s,"a text write here would delete the data rules tag"):!0:!1,c=(s,f,u)=>{if(!r(s))return!1;let d=lt(f,u,t);return d?i(s,d):!0};return{...e,text(s,f){if(f===void 0)return e.text(s);o(s)&&e.text(s,f)},attr(s,f,u){if(u===void 0)return e.attr(s,f);c(s,f,u)&&e.attr(s,f,u)},removeAttr(s,f){c(s,f,null)&&e.removeAttr(s,f)},styleVar(s,f,u){if((v(e.attr(s,"style"),f)??"")!==u&&r(s)){if(!k(f))return i(s,`"${f}" is not a custom property`);if(u!==""){let d=ut(u,t);if(d)return i(s,d)}ce(e,s,f,u)}},prop(s,f,u){if(u===void 0)return e.prop(s,f);if(t.refusedRuleForms.includes(f))return i(s,`"@${f}" writes HTML, only text is allowed`);if(Qt.has(f)){o(s)&&e.prop(s,f,u);return}c(s,f==="className"?"class":f,u)&&e.prop(s,f,u)},remove(s){if(rn(e,s)){i(s,"removing this would delete the data rules tag");return}e.remove(s)},replaceWith(s,f){return f===e.prop(s,"outerHTML")||i(s,'"@outerHTML" writes HTML, only text is allowed'),s},refusals:n,assertClean(){if(n.length)throw new F(n.slice())}}}function Q(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function at(e){return e.reduce((t,n)=>typeof n=="number"?`${t}[${n}]`:t?`${t}.${n}`:n,"")}function Le(e,t,n,i,r={}){j(n,r);let o=[],c=[];function l(f,u,d){if(Array.isArray(f)){let[,h]=f;if(!Array.isArray(u)||!Q(h))return;u.forEach((A,a)=>l(h,A,[...d,a]));return}if(!(!Q(f)||!Q(u)))for(let h of Object.keys(u))Object.prototype.hasOwnProperty.call(f,h)?l(f[h],u[h],[...d,h]):o.push(at([...d,h]))}function s(f,u,d,h){if(d!==void 0){if(typeof u=="string"){if(u.endsWith("[]")||u==="."||u.startsWith("@"))return;let{selector:A}=b(u);if(!A)return;e.find(f,A,r).length===0&&c.push({path:at(h),selector:A});return}if(!Array.isArray(u)&&Q(u)&&Q(d))for(let[A,a]of Object.entries(u))s(f,a,d[A],[...h,A])}}return l(n,i,[]),s(t,n,i,[]),{unknownKeys:o,unmatched:c}}function Ie(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null,version:"1"};if(typeof n=="string"){let i=t&&t.ownerDocument?t.ownerDocument:t;return W(e,i,n)}return null}var cn=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function ln(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function dt(e,t,n,i){if(i)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function ht(e,t,n,i,r,o){return(o?st(e,t):dt(e,n,r,!1))||!!(i&&(o&&e!==r?e.matches(i):dt(e,i,r,o)))}function fn(e,t){let n=ue[t];return n.tokens.some(i=>Me(e,i))||n.bundles.some(i=>G(e,i))}var un=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function pt(e,t,n,i){if(e.nodeType===1&&i(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,o=t;if(e.nodeType===1){if(un.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,o=t.content,n.cloneToLive.set(o,r),n.liveToClone.set(r,o)}}else if(e.nodeType!==11)return;let c=o.firstChild;for(let l=r.firstChild;l&&c;l=l.nextSibling)pt(l,c,n,i),c=c.nextSibling}function ee(e,{capability:t="data",exclude:n=null,inherit:i=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let o=e.nodeType===9?e:e.ownerDocument;if(!o?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let c=o.implementation.createHTMLDocument(""),l=r||new WeakMap,s=new WeakMap,f=e.nodeType===9?e.documentElement:e;n&&c.documentElement.matches(n);let u=Z(t),d=i?a=>fn(a,t)||!!(n&&a.matches(n)):a=>ht(a,t,u,n,f,!1),h=null;if(f.nodeType!==1||!ht(f,t,u,n,f,i)){h=c.importNode(f,!0);let a={cloneToLive:l,liveToClone:s,dropped:[],controls:[]};pt(f,h,a,d);for(let m of a.dropped)m.remove();for(let m=0;m<a.controls.length;m+=2)ln(a.controls[m],a.controls[m+1])}e.nodeType===9&&h&&(c.replaceChild(h,c.documentElement),s.set(e,c),l.set(c,e));let A=a=>{if(cn.test(a))throw new Error(`Filtered content queries do not support stateful selector: ${a}`)};return{root:h,document:c,capability:t,selector:Z(t),cloneToLive:l,liveToClone:s,original(a){return l.get(a)||null},cloneOf(a){return s.get(a)||null},query(a,m=h){return A(a),Array.from(m.querySelectorAll(a),g=>l.get(g)||g)},text(a=h){return(a===h?h:s.get(a))?.textContent||""},html(a=h){return(a===h?h:s.get(a))?.innerHTML??""},clone(a=h){let m=a===h?h:s.get(a);return m?c.importNode(m,!0):null}}}function yt(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function an(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function mt(e,t,n){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=n===null?"":n:t==="checked"&&e.tagName==="INPUT"?e.checked=n!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=n!==null))}function gt(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function wt(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let i=n.type;i!=="file"&&i!=="checkbox"&&i!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var x={semanticExclude:!0,find(e,t,n={}){let i=an(e);if(!i||!i.querySelectorAll)return[];let r=Array.from(i.querySelectorAll(t));n.includeRulesTag||(r=r.filter(l=>!yt(l)));let o=[];n.skip&&o.push(n.skip);let c=n.templateAttr===null?null:n.templateAttr||"cms-template";if(c&&o.push("["+c+"]"),o.length){let l=o.join(", ");r=r.filter(s=>!s.closest||!s.closest(l))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,gt(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),mt(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),mt(e,t,null)},prop(e,t,n){if(n===void 0){let i=e?e[t]:void 0;return i!==void 0?i:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return wt(t),t},insertAt(e,t,n){let i=e.children[n]||null;e.insertBefore(t,i)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let i=e.ownerDocument.createElement("template");i.innerHTML=t;let r=i.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(i=>{i.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function I(e,t={}){if(t.exclude===null)return x;let n=[Z("data"),t.exclude].filter(Boolean).join(", "),i=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!i?.querySelector?.(n))return x;let o=e.nodeType===9||!e.isConnected?e:e.ownerDocument,c=e.nodeType===9?e:e.ownerDocument,l=null,s=()=>l||(l=ee(o,{capability:"data",exclude:t.exclude||null})),f=a=>{let m=s();return a===e?m.cloneOf(e):m.cloneOf(a)||a},u=a=>l?.original(a)||a,d=(a,m)=>{s().liveToClone.set(a,m),s().cloneToLive.set(m,a);let g=a.childNodes||[],p=m.childNodes||[];for(let y=0;y<Math.min(g.length,p.length);y++)d(g[y],p[y])},h=(a,m,g,p)=>{let y=Array.from(a.childNodes).filter(T=>l.cloneOf(T)),E=y[0];for(;E&&y.includes(E);)E=E.nextSibling;for(let T of y)T.remove();if(g==="innerHTML"){let T=c.createElement("template");T.innerHTML=p;for(let V of Array.from(T.content.childNodes))a.insertBefore(V,E||null)}else a.insertBefore(c.createTextNode(p),E||null),gt(a,p);let O=ee(a,{capability:"data",exclude:t.exclude||null});m.replaceChildren(...Array.from(O.root?.childNodes||[]));let S=T=>{let V=O.original(T);V&&(l.liveToClone.set(V,T),l.cloneToLive.set(T,V));for(let Et of Array.from(T.childNodes||[]))S(Et)};for(let T of Array.from(m.childNodes))S(T)},A={...x,find(a,m,g={}){let p=f(a);if(!p?.querySelectorAll)return[];let y=s().query(m,p);g.includeRulesTag||(y=y.filter(O=>!yt(O)));let w=[];g.skip&&w.push(g.skip);let E=g.templateAttr===null?null:g.templateAttr||"cms-template";if(E&&w.push(`[${E}]`),w.length){let O=w.join(", ");y=y.filter(S=>!S.closest?.(O))}return y},parent(a){let m=f(a)?.parentElement;return m?u(m):null},children(a){return Array.from(f(a)?.children||[],u)},text(a,m){if(m===void 0){let y=u(a);return!y?.matches?.(n)&&!y?.querySelector?.(n)?x.text(y):(f(a)?.textContent||"").trim()}let g=u(a);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!l){x.text(g,m);return}let p=s().cloneOf(g);p?h(g,p,"textContent",m):x.text(g,m)},attr(a,m,g){let p=u(a);if(g===void 0)return x.attr(p,m);x.attr(p,m,g);let y=l?.cloneOf(p);y&&(x.attr(y,m,g),ee(p,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),l.liveToClone.delete(p),l.cloneToLive.delete(y)))},removeAttr(a,m){let g=u(a);x.removeAttr(g,m);let p=l?.cloneOf(g);p&&x.removeAttr(p,m)},prop(a,m,g){let p=u(a);if(g===void 0)return m==="innerHTML"||m==="outerHTML"||m==="textContent"||m==="innerText"?x.prop(f(p),m):x.prop(p,m);let y=m==="innerHTML"||m==="textContent"||m==="innerText",w=y?s().cloneOf(p):l?.cloneOf(p);w&&y?h(p,w,m,g):(x.prop(p,m,g),w&&x.prop(w,m,g))},clone(a){let m=f(a);if(m===a)return x.clone(a);let g=c.importNode(m,!0);return wt(g),g},insertAt(a,m,g){let p=u(a),w=A.children(p)[g]||(()=>{for(let S=p.children.length-1;S>=0;S--){let T=p.children[S];if(s().cloneOf(T))return T.nextElementSibling}return p.firstElementChild})(),E=u(m);p.insertBefore(E,w||null);let O=s().cloneOf(p);if(O){let S=s().cloneOf(E);S||(S=c.importNode(E,!0),d(E,S));let T=Array.from(O.children);O.insertBefore(S,T[g]||null)}},insertBefore(a,m){let g=u(a),p=u(m);g.parentNode.insertBefore(p,g);let y=s().cloneOf(g.parentNode);if(y){let w=s().cloneOf(p);w||(w=c.importNode(p,!0),d(p,w));let E=s().cloneOf(g);E?E.before(w):y.appendChild(w)}},insertAfter(a,m){let g=u(a),p=u(m);g.parentNode.insertBefore(p,g.nextSibling);let y=s().cloneOf(g.parentNode);if(y){let w=s().cloneOf(p);w||(w=c.importNode(p,!0),d(p,w));let E=s().cloneOf(g);E?E.after(w):y.appendChild(w)}},identity(a){return u(a)||null},remove(a){let m=u(a),g=s().cloneOf(m);x.remove(m),g&&x.remove(g)},replaceWith(a,m){let g=u(a),p=s().cloneOf(g),y=x.replaceWith(g,m);if(p){let w=ee(y,{capability:"data",exclude:t.exclude||null});if(!w.root)p.remove();else{p.replaceWith(w.root);let E=O=>{let S=w.original(O);S&&(l.liveToClone.set(S,O),l.cloneToLive.set(O,S));for(let T of Array.from(O.childNodes||[]))E(T)};E(w.root)}}return y}};return A}var te=x;var ne=e=>({codecs:Se(),...e}),re={extract:(e,t,n={})=>L(I(e,n),e,t,ne(n)),apply:(e,t,n,i={})=>D(I(e,{...i,_write:!0}),e,t,n,ne(i)),findRulesIn:(e,t)=>W(te,e,t),findRules:(e,t)=>Ie(te,e,t),bind:(e,t,n={})=>{let i=Ie(te,e,t);if(!i){let o=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${o}`)}let r=ne({version:i.version,...n});return{...i,get:()=>L(I(e,n),e,i.rules,r),set:o=>D(I(e,{...n,_write:!0}),e,i.rules,o,r)}},codecs:{register:Te,get:Oe},parseStrict:Pe,parseRelaxed:Y,ruleAttrIndex:N,splitRule:b,errors:R,DOM_PROPERTIES:ie},_e=e=>!!e&&typeof e.nodeType=="number";function At(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=W(te,t,"api");if(!n)throw new R.NoRulesTag("api");return{rules:n.rules,version:n.version}}function dn(e){if(e.nodeType===9)return e;let t=e.ownerDocument?.documentElement;if(t?.contains(e))return t;let n=e;for(;n.parentNode;)n=n.parentNode;return n}function hn(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let t=e.ownerDocument.createDocumentFragment();for(let n of e.childNodes)t.appendChild(n.cloneNode(!0));return t}function pn(e,t){let n=[];for(;t!==e;){let i=t.parentNode;n.push(Array.prototype.indexOf.call(i.childNodes,t)),t=i}return n.reverse()}function mn(e,t){return t.reduce((n,i)=>n.childNodes[i],e)}function q(e,t){let n=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&n.unshift(e),n}function yn(e,t){let n=q(e,"option"),i=q(t,"option");n.forEach((s,f)=>i[f].selected=s.selected);let r=q(e,"input"),o=q(t,"input");r.forEach((s,f)=>{let u=s.type.toLowerCase();u!=="file"&&(o[f].value=s.value),(u==="checkbox"||u==="radio")&&(o[f].checked=s.checked)});let c=q(e,"textarea"),l=q(t,"textarea");c.forEach((s,f)=>l[f].value=s.value)}function $e(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let n=e.startsWith("@")?0:N(e);if(n===-1)return;let i=e.slice(n+1);if(B.has(i))throw new R.RuleTargetReadOnly(i);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(n=>$e(e[1],n));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[n,i]of Object.entries(e))$e(i,t[n])}}function gn(e,t,n,i){let r=ne({templateAttr:"cms-template",version:i}),o=dn(e),c=pn(o,e),l=hn(o);yn(o,l);let s=mn(l,c),f=I(l,{...r,_write:!0}),u=Le(f,s,t,n,r);if(u.unknownKeys.length||u.unmatched.length)throw new R.WriteRejected(u.unknownKeys,u.unmatched);let d=de(f);D(d,s,t,n,r),d.assertClean(),$e(t,n);let h=de(I(o,{...r,_write:!0}));D(h,e,t,n,r),h.assertClean()}function wn(e){if(!(e instanceof Error))return e;let n=e instanceof R.UnknownCodec||e instanceof R.CodecRefused?e.code:e.name||"Error";try{e.code=n}catch{Object.defineProperty(e,"code",{value:n,configurable:!0,enumerable:!0})}return e instanceof R.WriteRefused?e.details=e.refusals:e instanceof R.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof R.ShapeMismatch?e.details=e.mismatches:Array.isArray(e.path)?e.details={path:e.path}:typeof e.target=="string"?e.details={target:e.target}:e.token!==void 0?e.details={token:e.token}:e.version!==void 0?e.details={version:e.version}:e.details={},e}function je(e,t){let n=_e(e)?e:document,i=_e(e)?t:e;if(i===void 0){let{rules:r,version:o}=At(n);return L(I(n),n,r,ne({version:o}))}return re.bind(n,i).get()}function De(e,t,n){try{if(!_e(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let{rules:i,version:r}=n===void 0?At(e):re.bind(e,n);gn(e,i,t,r)}catch(i){throw wn(i)}return e}var An={engine:re,extractData:je,applyData:De},En=An;return bt(Tn);})();
6
6
  window.clay = window.clay || {};
7
7
  window.clay.extractData = hyperHtmlApiData.extractData;
8
8
  window.clay.applyData = function (values, optionsOrSource, source) {