@panphora/clayjs 1.15.1 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -5
- package/THIRD-PARTY-NOTICES.md +16 -0
- package/compat/highlight-11.9.0.min.js +1213 -0
- package/compat/highlight-LICENSE +29 -0
- package/compat/journal-assets.lock.json +22 -0
- package/compat/overtype-2.6.1.min.js +116 -0
- package/compat/overtype-LICENSE +21 -0
- package/dist/all.js +90 -0
- package/dist/clay-dom.js +84 -0
- package/dist/clay-events.js +103 -0
- package/dist/clay-internals.js +85 -0
- package/dist/clay-options.js +93 -0
- package/dist/clay-router.js +98 -0
- package/dist/clay-ui.js +95 -0
- package/dist/clay-utils.js +84 -0
- package/dist/clay.js +146 -0
- package/dist/clay.standalone.js +83090 -58706
- package/dist/m/attrs/add-from-T5LJXFFI.js +1 -0
- package/dist/m/attrs/onaftersave-OKSWEJQF.js +1 -0
- package/dist/m/attrs/refetch-on-save-NWPPXOCZ.js +1 -0
- package/dist/m/attrs/save-freeze-FUP4Q4X3.js +1 -0
- package/dist/m/c-2AZDZWCK.js +1 -0
- package/dist/m/c-2JL6E75N.js +1 -0
- package/dist/m/c-2M73252O.js +1 -0
- package/dist/m/c-2SPVQSHC.js +1 -0
- package/dist/m/c-33HUYEDI.js +1 -0
- package/dist/m/c-33JJ6CBX.js +2 -0
- package/dist/m/c-35NBGMZB.js +1 -0
- package/dist/m/c-3GJ4SDE2.js +1 -0
- package/dist/m/c-3IQRECYS.js +1 -0
- package/dist/m/c-3OWDMNJR.js +2 -0
- package/dist/m/c-46XYM55L.js +1 -0
- package/dist/m/c-4B6H4G5V.js +1 -0
- package/dist/m/c-4DRMS4QG.js +9 -0
- package/dist/m/c-4FFHZM32.js +1 -0
- package/dist/m/c-4JZDZFF6.js +1 -0
- package/dist/m/c-4L3BTFRK.js +1 -0
- package/dist/m/c-4Q2XTQ2N.js +2 -0
- package/dist/m/c-4WKFKEKF.js +1 -0
- package/dist/m/c-4YSCRICO.js +1 -0
- package/dist/m/c-54RCDCBU.js +1 -0
- package/dist/m/c-5M4YEKCX.js +4 -0
- package/dist/m/c-5R4PTRG2.js +1 -0
- package/dist/m/c-5V3MOVJT.js +1 -0
- package/dist/m/c-5VYOWDTI.js +1 -0
- package/dist/m/c-5Y6TNX5W.js +34 -0
- package/dist/m/c-5YIHJ3TJ.js +1 -0
- package/dist/m/c-66O32MV3.js +28 -0
- package/dist/m/c-6HMB24EV.js +1 -0
- package/dist/m/c-7DJDKPGL.js +1 -0
- package/dist/m/c-7O6AFR65.js +1 -0
- package/dist/m/c-7SWMYKAI.js +1 -0
- package/dist/m/c-7VGZ7RU5.js +1 -0
- package/dist/m/c-A7LS5UZW.js +1 -0
- package/dist/m/c-ANQTJ3B5.js +2 -0
- package/dist/m/c-AQLFEATB.js +1 -0
- package/dist/m/c-AYVOREBE.js +1 -0
- package/dist/m/c-B2ZXPOS3.js +3 -0
- package/dist/m/c-BBVGTQG7.js +1 -0
- package/dist/m/c-BMIZKMPV.js +1 -0
- package/dist/m/c-BTDI4Y23.js +1 -0
- package/dist/m/c-BWFVSBDF.js +1 -0
- package/dist/m/c-BYTKL6UX.js +1 -0
- package/dist/m/c-CFHW5AMY.js +6 -0
- package/dist/m/c-CJZSLMVQ.js +1 -0
- package/dist/m/c-CYWLPPUS.js +1 -0
- package/dist/m/c-CZUSOB7V.js +1 -0
- package/dist/m/c-DBE6ORSI.js +1 -0
- package/dist/m/c-DCFSEJZG.js +1 -0
- package/dist/m/c-DNZ5IFM6.js +1 -0
- package/dist/m/c-EDHUR4MX.js +1 -0
- package/dist/m/c-EJTGYSLN.js +1 -0
- package/dist/m/c-EY6UOM54.js +1 -0
- package/dist/m/c-F3CKJTJS.js +1 -0
- package/dist/m/c-F7Y6FLPY.js +1 -0
- package/dist/m/c-FA4DZVTC.js +1 -0
- package/dist/m/c-FILLTJA7.js +1 -0
- package/dist/m/c-G2BUZITR.js +1 -0
- package/dist/m/c-GB3JTV6E.js +1 -0
- package/dist/m/c-GBGWXTX4.js +1 -0
- package/dist/m/c-GHBCCVG4.js +1 -0
- package/dist/m/c-GJAEGGXY.js +1 -0
- package/dist/m/c-GOWBDM6J.js +1 -0
- package/dist/m/c-GQ6F6IDK.js +1 -0
- package/dist/m/c-H4LG442Q.js +1 -0
- package/dist/m/c-HA6INT6J.js +1 -0
- package/dist/m/c-HPURYVZS.js +2 -0
- package/dist/m/c-HRDCD3WN.js +67 -0
- package/dist/m/c-HT33EQRN.js +1 -0
- package/dist/m/c-HVYXIS72.js +1 -0
- package/dist/m/c-IB52R237.js +1 -0
- package/dist/m/c-IJUK2GPW.js +1 -0
- package/dist/m/c-IKWNE4R4.js +1 -0
- package/dist/m/c-IU3IYEU6.js +1 -0
- package/dist/m/c-IZ2EBRAJ.js +1 -0
- package/dist/m/c-J7CA54IP.js +1 -0
- package/dist/m/c-JAX2667S.js +6 -0
- package/dist/m/c-KI7M4AY3.js +1 -0
- package/dist/m/c-KIPQJX4B.js +1 -0
- package/dist/m/c-KKWLDOPM.js +1 -0
- package/dist/m/c-KR4UW4KW.js +1 -0
- package/dist/m/c-KY3VJGUA.js +8 -0
- package/dist/m/c-L4WQSC27.js +1 -0
- package/dist/m/c-LFPHCXY3.js +1 -0
- package/dist/m/c-LR4CGEPT.js +91 -0
- package/dist/m/c-LRPUO2MX.js +1 -0
- package/dist/m/c-LTGMXXKO.js +1 -0
- package/dist/m/c-LXENEBV7.js +1 -0
- package/dist/m/c-LZJPNR2W.js +1 -0
- package/dist/m/c-MMUIUUZG.js +2 -0
- package/dist/m/c-MTQHWQC3.js +1 -0
- package/dist/m/c-N326R2JD.js +1 -0
- package/dist/m/c-N7JPUPGC.js +1 -0
- package/dist/m/c-NMJRXKPC.js +8 -0
- package/dist/m/c-NRPJEVJS.js +1 -0
- package/dist/m/c-NUHP2XDB.js +1 -0
- package/dist/m/c-NZMNXVF6.js +1 -0
- package/dist/m/c-OCSZ4QGN.js +1 -0
- package/dist/m/c-OIBUTDXI.js +1 -0
- package/dist/m/c-OIDRZKAF.js +1 -0
- package/dist/m/c-OYTFP5QN.js +1 -0
- package/dist/m/c-P7KNDG34.js +1 -0
- package/dist/m/c-PPOSCAQD.js +1 -0
- package/dist/m/c-PQ5LK6QE.js +993 -0
- package/dist/m/c-PZ4XEPUP.js +2 -0
- package/dist/m/c-QHIWXHRO.js +1 -0
- package/dist/m/c-QHWJ5ZIJ.js +1 -0
- package/dist/m/c-QIX5BJYN.js +1 -0
- package/dist/m/c-QNKREOL6.js +1 -0
- package/dist/m/c-QQHEX6HA.js +1 -0
- package/dist/m/c-R7RMANJI.js +9 -0
- package/dist/m/c-RI4NT75Y.js +1 -0
- package/dist/m/c-RM7J7BV2.js +1 -0
- package/dist/m/c-RUJKSUQW.js +1 -0
- package/dist/m/c-RVMWGXEJ.js +1 -0
- package/dist/m/c-S7H2DRCB.js +1 -0
- package/dist/m/c-S7LK4KUE.js +1 -0
- package/dist/m/c-SGCCC4FW.js +25 -0
- package/dist/m/c-SGIA4IEQ.js +188 -0
- package/dist/m/c-SWRJFCNN.js +1 -0
- package/dist/m/c-T4VO4OCB.js +1 -0
- package/dist/m/c-TCCA5BZN.js +2 -0
- package/dist/m/c-TQEMVJCS.js +1 -0
- package/dist/m/c-TQZ2JYHD.js +1 -0
- package/dist/m/c-TR6RMDQ7.js +3 -0
- package/dist/m/c-TRS6TM6O.js +1 -0
- package/dist/m/c-UGHH4MB3.js +1 -0
- package/dist/m/c-UKHTLWUW.js +1 -0
- package/dist/m/c-UL2YUY52.js +1 -0
- package/dist/m/c-UNN7LWCT.js +1 -0
- package/dist/m/c-UXBMRDZB.js +235 -0
- package/dist/m/c-V7PZZRG7.js +1 -0
- package/dist/m/c-VAK7SG37.js +1 -0
- package/dist/m/c-VDSS4K3Z.js +1 -0
- package/dist/m/c-VFX45IZQ.js +1 -0
- package/dist/m/c-VHNSBD2M.js +1 -0
- package/dist/m/c-VKEDWYDF.js +1 -0
- package/dist/m/c-VL52ADDR.js +1 -0
- package/dist/m/c-WN5AY3OZ.js +1 -0
- package/dist/m/c-WNYBLIOZ.js +1 -0
- package/dist/m/c-WRBKEJD4.js +1 -0
- package/dist/m/c-WWDBYXLK.js +1 -0
- package/dist/m/c-WYFDLITL.js +1 -0
- package/dist/m/c-XN6MBKI6.js +67 -0
- package/dist/m/c-XNNW2CWK.js +1 -0
- package/dist/m/c-XPELB6E5.js +1 -0
- package/dist/m/c-XQXZAO7N.js +1 -0
- package/dist/m/c-Y6USGTS5.js +5 -0
- package/dist/m/c-YDH7Q3NY.js +1 -0
- package/dist/m/c-YG2NJYS6.js +135 -0
- package/dist/m/c-Z36J63PP.js +1 -0
- package/dist/m/c-Z4VRC7GU.js +7 -0
- package/dist/m/c-Z6K52OLP.js +19 -0
- package/dist/m/c-ZDY2MDAA.js +21 -0
- package/dist/m/c-ZE46QDIH.js +1 -0
- package/dist/m/c-ZUCOKOHT.js +1 -0
- package/dist/m/core/admin-attrs-VGNLAUDK.js +1 -0
- package/dist/m/core/autosave-E4PEFPZ6.js +1 -0
- package/dist/m/core/conflict-notice-VQ6Y64PH.js +1 -0
- package/dist/m/core/draft-mode-WSQAT67S.js +1 -0
- package/dist/m/core/host-permission-XN3K2IW3.js +1 -0
- package/dist/m/core/is-edit-mode-JXHDVGUL.js +1 -0
- package/dist/m/core/persist-HKHA66IY.js +3 -0
- package/dist/m/core/recovery-TBBSICE2.js +1 -0
- package/dist/m/core/save-WUCHTQBE.js +1 -0
- package/dist/m/core/save-core-FJVHT5M3.js +1 -0
- package/dist/m/core/snapshot-F3SWDZMM.js +1 -0
- package/dist/m/core/unsaved-warning-STKBHE6G.js +1 -0
- package/dist/m/dom/all-APS5ZSKP.js +1 -0
- package/dist/m/dom/dom-helpers-L7OSR6S4.js +1 -0
- package/dist/m/events/index-23DPTUT4.js +1 -0
- package/dist/m/internals/index-WOVAP3RU.js +1 -0
- package/dist/m/lib/cache-bust-CGWT6ZJI.js +1 -0
- package/dist/m/lib/region-policy-SB2AWVG5.js +1 -0
- package/dist/m/loader-HXX6YNH5.js +1 -0
- package/dist/m/manifest-F22DEDAC.js +1 -0
- package/dist/m/manifest-edit-C3C7376B.js +1 -0
- package/dist/m/manifest.json +3491 -0
- package/dist/m/options/options-2LH76JQ3.js +1 -0
- package/dist/m/page/editor-XUTB2HB2.js +189 -0
- package/dist/m/plugins/ai-edit-ZQ4CGWIP.js +6 -0
- package/dist/m/plugins/bind-text-NX46N5UV.js +1 -0
- package/dist/m/plugins/cms-HP3LSTPN.js +2293 -0
- package/dist/m/plugins/demo-ZIBFAA3R.js +1 -0
- package/dist/m/plugins/derive-UAAA4V4S.js +1 -0
- package/dist/m/plugins/indicator-PV4YW2ID.js +1 -0
- package/dist/m/plugins/live-NUTTXSBS.js +1 -0
- package/dist/m/plugins/menu-HCKO3DSP.js +138 -0
- package/dist/m/plugins/message-LQ6EDH4V.js +1 -0
- package/dist/m/plugins/page-KSUH7G6J.js +2 -0
- package/dist/m/plugins/page-view-W73OW7WI.js +1 -0
- package/dist/m/plugins/people-AJJ32YCG.js +1 -0
- package/dist/m/plugins/quickcrop-QNY3PKLD.js +26 -0
- package/dist/m/plugins/quickcrop-QNY3PKLD.js.LEGAL.txt +7 -0
- package/dist/m/plugins/richclay-RC3L2F6X.js +517 -0
- package/dist/m/plugins/richclay-RC3L2F6X.js.LEGAL.txt +1 -0
- package/dist/m/plugins/sortable-YRMQX3ZU.js +1 -0
- package/dist/m/plugins/source-KHK5UUSK.js +1 -0
- package/dist/m/plugins/undo-OF2L3CXU.js +1 -0
- package/dist/m/plugins/unsent-HJFLQJ2O.js +1 -0
- package/dist/m/plugins/upgrade-ZNYODP5Y.js +1 -0
- package/dist/m/plugins/upload-XSGNILUY.js +1 -0
- package/dist/m/plugins/visitor-drafts-XK5GW55Q.js +21 -0
- package/dist/m/plugins/visitor-drafts-owner-KSSH75EV.js +1 -0
- package/dist/m/plugins/wire-ZWVWKF76.js +1 -0
- package/dist/m/reader-core-ILWLXVMP.js +68 -0
- package/dist/m/route/route-KOCZSEGN.js +1 -0
- package/dist/m/sync/live-sync-4AUVXVJU.js +1 -0
- package/dist/m/ui/index-EVHKMKBL.js +1 -0
- package/dist/m/utils/index-4TJCVLT7.js +1 -0
- package/dist/m/vendor/Sortable.vendor-A755ITLN.js +3 -0
- package/dist/m/vendor/Sortable.vendor-A755ITLN.js.LEGAL.txt +1 -0
- package/dist/m/vendor/sap-core.vendor-A7BMUYZT.js +6 -0
- package/dist/offline-manifest.json +3800 -0
- package/dist/page/themes/light-1.css +406 -0
- package/dist/server/core.cjs +23662 -22860
- package/dist/server/offline-runtime.cjs +4954 -0
- package/dist/server/offline-runtime.mjs +4923 -0
- package/dist/server/rooms.mjs +9 -0
- package/docs/guide.md +1078 -669
- package/entries/all.js +2 -0
- package/entries/clay-data.js +1 -1
- package/entries/clay-dom.js +2 -0
- package/entries/clay-events.js +2 -0
- package/entries/clay-internals.js +2 -0
- package/entries/clay-options.js +2 -0
- package/entries/clay-router.js +2 -0
- package/entries/clay-ui.js +2 -0
- package/entries/clay-utils.js +2 -0
- package/entries/clay.js +2 -0
- package/entries/sap.js +6 -6
- package/fonts/ibm-plex-mono-LICENSE +93 -0
- package/fonts/ibm-plex-mono-latin-300-normal.woff2 +0 -0
- package/fonts/ibm-plex-mono-latin-400-italic.woff2 +0 -0
- package/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
- package/fonts/ibm-plex-mono-latin-500-normal.woff2 +0 -0
- package/fonts/ibm-plex-mono-latin-600-normal.woff2 +0 -0
- package/fonts/ibm-plex-sans-LICENSE +93 -0
- package/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
- package/fonts/ibm-plex-sans-latin-500-normal.woff2 +0 -0
- package/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
- package/fonts/ibm-plex.css +71 -0
- package/fonts/inter-LICENSE +93 -0
- package/fonts/inter-cyrillic-ext-wght-normal.woff2 +0 -0
- package/fonts/inter-cyrillic-wght-normal.woff2 +0 -0
- package/fonts/inter-greek-ext-wght-normal.woff2 +0 -0
- package/fonts/inter-greek-wght-normal.woff2 +0 -0
- package/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
- package/fonts/inter-latin-wght-normal.woff2 +0 -0
- package/fonts/inter-vietnamese-wght-normal.woff2 +0 -0
- package/fonts/inter.css +62 -0
- package/fonts/newsreader-LICENSE +93 -0
- package/fonts/newsreader-latin-ext-opsz-normal.woff2 +0 -0
- package/fonts/newsreader-latin-opsz-normal.woff2 +0 -0
- package/fonts/newsreader-vietnamese-opsz-normal.woff2 +0 -0
- package/fonts/newsreader.css +26 -0
- package/fonts/work-sans-LICENSE +93 -0
- package/fonts/work-sans-latin-wght-normal.woff2 +0 -0
- package/fonts/work-sans.css +8 -0
- package/package.json +20 -3
- package/packed-contract.json +1 -0
- package/src/attrs/add-from.js +27 -4
- package/src/attrs/save-freeze.js +7 -52
- package/src/core/admin-attrs.js +119 -12
- package/src/core/admin-contenteditable.js +12 -10
- package/src/core/admin-inputs.js +14 -15
- package/src/core/admin-onclick.js +2 -0
- package/src/core/autosave.js +74 -21
- package/src/core/conflict-download.js +22 -0
- package/src/core/conflict-notice-ui.js +1173 -0
- package/src/core/conflict-notice.js +140 -697
- package/src/core/edit-mode.js +147 -14
- package/src/core/etag.js +30 -12
- package/src/core/host-meta.js +72 -8
- package/src/core/host-permission.js +29 -0
- package/src/core/is-edit-mode.js +145 -12
- package/src/core/mode-key.js +125 -0
- package/src/core/mode-lifecycle.js +544 -0
- package/src/core/mode-receipt.js +30 -0
- package/src/core/mode-refusal.js +13 -0
- package/src/core/mode-resources.js +52 -0
- package/src/core/mode-support.js +82 -0
- package/src/core/mode-switch.js +259 -0
- package/src/core/mode-transition.js +112 -0
- package/src/core/page-data-write.js +305 -0
- package/src/core/page-data.js +26 -227
- package/src/core/page-format-wire.js +4 -0
- package/src/core/page-format.js +58 -0
- package/src/core/persist.js +37 -9
- package/src/core/preserve-authored.js +114 -0
- package/src/core/recovery.js +772 -0
- package/src/core/runtime-url.js +105 -0
- package/src/core/save-core.js +109 -12
- package/src/core/save-replace.js +72 -0
- package/src/core/save-size-notice.js +134 -0
- package/src/core/save-size.js +140 -0
- package/src/core/save.js +805 -118
- package/src/core/snapshot.js +121 -11
- package/src/core/source-map.js +157 -9
- package/src/core/unsaved-warning.js +14 -4
- package/src/core/upgrade-run.js +408 -0
- package/src/core/version.js +18 -0
- package/src/lib/assets.js +30 -0
- package/src/lib/autosave-debug-gate.js +50 -0
- package/src/lib/autosave-scheduler.js +141 -0
- package/src/lib/boot-imports.js +8 -0
- package/src/lib/derived.js +3 -1
- package/src/lib/dirty-gate.js +15 -0
- package/src/lib/doc-storage.js +33 -0
- package/src/lib/effect.js +9 -4
- package/src/lib/mutation.js +4 -2
- package/src/lib/offline-runtime.js +226 -0
- package/src/lib/preload.js +48 -0
- package/src/lib/root-attrs.js +1 -1
- package/src/lib/trash.js +18 -0
- package/src/lib/undo/capture-move.js +152 -0
- package/src/live/local-channel.js +61 -0
- package/src/live/local-lane.js +60 -9
- package/src/live/server-lane.js +6 -3
- package/src/loader-logic.js +76 -15
- package/src/loader.js +218 -30
- package/src/page/adopt-boot.js +76 -22
- package/src/page/adopt.js +25 -4
- package/src/page/awareness.js +230 -0
- package/src/page/blocks.js +79 -5
- package/src/page/blocksel.js +20 -4
- package/src/page/board-face.js +13 -0
- package/src/page/board-panel.js +5 -17
- package/src/page/board-style.js +2 -13
- package/src/page/board-view.js +1 -11
- package/src/page/board-views.js +17 -0
- package/src/page/board.js +2 -2
- package/src/page/boot-pack.js +26 -0
- package/src/page/boot.js +237 -0
- package/src/page/checklist.js +1 -1
- package/src/page/chrome.js +411 -61
- package/src/page/csv-import.js +17 -2
- package/src/page/document-title-dom.js +40 -0
- package/src/page/document-title-runtime.js +76 -0
- package/src/page/document-title.js +9 -0
- package/src/page/drag.js +48 -13
- package/src/page/drop.js +2 -1
- package/src/page/editor.js +330 -86
- package/src/page/feature-loader.js +72 -0
- package/src/page/features/board.js +12 -0
- package/src/page/features/code.js +13 -0
- package/src/page/features/media.js +290 -0
- package/src/page/features/registry.js +23 -0
- package/src/page/features/table.js +383 -0
- package/src/page/{tool-view.js → features/tool.js} +33 -2
- package/src/page/format-codec.js +215 -0
- package/src/page/format-gate.js +179 -0
- package/src/page/format-level.js +157 -0
- package/src/page/highlight-slot.js +23 -0
- package/src/page/highlight.js +30 -16
- package/src/page/history-intent.js +78 -0
- package/src/page/inline.js +18 -25
- package/src/page/items.js +52 -11
- package/src/page/link.js +1 -0
- package/src/page/markdown.js +86 -1
- package/src/page/media-views.js +3 -0
- package/src/page/media.js +33 -245
- package/src/page/outline-cache.js +11 -0
- package/src/page/placeholder.js +27 -7
- package/src/page/projection.js +196 -50
- package/src/page/reader-patch.js +306 -0
- package/src/page/recover.js +1 -1
- package/src/page/rich/page-tool.js +1 -4
- package/src/page/runtime-owner.js +27 -0
- package/src/page/save-projection.js +7 -4
- package/src/page/schema.js +14 -0
- package/src/page/table-rect-key.js +3 -0
- package/src/page/table-select.js +4 -3
- package/src/page/table-style.js +1 -1
- package/src/page/table-views.js +3 -0
- package/src/page/table.js +8 -293
- package/src/page/themes/light-1.css +139 -2
- package/src/page/themes/light-1.source.css +269 -0
- package/src/page/tool-capability.js +3 -0
- package/src/page/tool-views.js +3 -0
- package/src/page/view.js +390 -107
- package/src/page/ybind/awareness.js +172 -0
- package/src/page/ybind/binding.js +9 -1
- package/src/page/ybind/bridge.js +50 -47
- package/src/page/ybind/decode.js +52 -19
- package/src/page/ybind/doc.js +27 -2
- package/src/page/ybind/group.js +12 -3
- package/src/page/ybind/index.js +2 -0
- package/src/page/ybind/lineage.js +71 -0
- package/src/page/ybind/marks.js +25 -1
- package/src/page/ybind/migrate.js +48 -13
- package/src/page/ybind/moves.js +32 -21
- package/src/page/ybind/positions.js +50 -0
- package/src/page/ybind/provider.js +84 -22
- package/src/page/ybind/recovery-proof.js +191 -0
- package/src/page/ybind/recovery-replay.js +130 -0
- package/src/page/ybind/tokens.js +15 -6
- package/src/page/ybind/walk.js +10 -3
- package/src/page/ybind/writer.js +48 -4
- package/src/plugins/ai-edit.js +167 -32
- package/src/plugins/bind-text.js +218 -0
- package/src/plugins/cms.js +93 -0
- package/src/plugins/indicator.js +57 -5
- package/src/plugins/live.js +282 -34
- package/src/plugins/menu/claygoo.svg.js +1 -0
- package/src/plugins/menu/seo-head.js +323 -0
- package/src/plugins/menu/seo.js +849 -0
- package/src/plugins/menu.js +425 -0
- package/src/plugins/page-view.js +131 -0
- package/src/plugins/page.js +1022 -275
- package/src/plugins/people.js +158 -31
- package/src/plugins/richclay.js +119 -9
- package/src/plugins/sortable.js +370 -60
- package/src/plugins/source.js +189 -366
- package/src/plugins/undo.js +289 -19
- package/src/plugins/unsent.js +132 -0
- package/src/plugins/upgrade-run.js +1 -0
- package/src/plugins/upgrade.js +210 -0
- package/src/plugins/upload-task.js +571 -0
- package/src/plugins/upload-ui.js +265 -0
- package/src/plugins/upload.js +34 -153
- package/src/plugins/visitor-drafts/inert.js +32 -0
- package/src/plugins/visitor-drafts/owner-chip.js +3 -0
- package/src/plugins/visitor-drafts/prompt.js +2 -2
- package/src/plugins/visitor-drafts-owner.js +85 -0
- package/src/plugins/visitor-drafts.js +31 -42
- package/src/plugins/wire.js +82 -1
- package/src/reader-core.js +26 -0
- package/src/recovery/conflicts.js +287 -0
- package/src/recovery/identity.js +154 -0
- package/src/recovery/store.js +792 -0
- package/src/recovery/undo.js +257 -0
- package/src/server/checkpoint/index.js +68 -4
- package/src/server/offline-runtime/index.js +214 -0
- package/src/server/rooms/index.js +2 -1
- package/src/server/rooms/live-data-rooms.js +2 -2
- package/src/server/rooms/page-admission.js +33 -0
- package/src/server/rooms/page-lineage.js +56 -0
- package/src/server/rooms/page-rebase.js +11 -5
- package/src/server/rooms/page-state.js +2 -0
- package/src/server/rooms/page-write-admission.js +9 -3
- package/src/source/session.js +705 -0
- package/src/sync/conflict-revert.js +5 -4
- package/src/sync/conflicts-edit.js +119 -0
- package/src/sync/conflicts-facade.js +49 -0
- package/src/sync/conflicts.js +99 -1
- package/src/sync/editing-marker.js +37 -6
- package/src/sync/editing-sender.js +8 -1
- package/src/sync/live-sync-edit.js +63 -0
- package/src/sync/live-sync.js +364 -119
- package/src/sync/local-presence.js +187 -0
- package/src/sync/merge-declarations.js +10 -0
- package/src/sync/merge-engine.js +12 -0
- package/src/sync/presence-store.js +412 -0
- package/src/sync/presence-target.js +243 -0
- package/src/sync/presence.js +72 -41
- package/src/sync/saved-handoff.js +200 -0
- package/src/sync/saved-stream.js +535 -0
- package/src/sync/version-guard.js +92 -0
- package/src/sync/wire-profile.js +81 -0
- package/src/ui/bevel-controls.js +2 -8
- package/src/ui/page-scheme.js +7 -0
- package/src/ui/skins/cms.js +1 -1
- package/src/ui/theme-config.js +150 -0
- package/src/ui/theme.js +6 -138
- package/src/ui/toast-lazy.js +11 -0
- package/src/vendor/LICENSES-optional.md +253 -0
- package/src/vendor/highlight.vendor.js +3 -0
- package/src/vendor/hljs-bash.vendor.js +2 -0
- package/src/vendor/hljs-css.vendor.js +2 -0
- package/src/vendor/hljs-javascript.vendor.js +2 -0
- package/src/vendor/hljs-json.vendor.js +2 -0
- package/src/vendor/hljs-python.vendor.js +2 -0
- package/src/vendor/hljs-xml.vendor.js +2 -0
- package/src/vendor/hyper-html-api-data.vendor.js +1 -1
- package/src/vendor/hyper-html-api-upgrade.vendor.js +5 -0
- package/src/vendor/hyper-morph-identity.vendor.js +2 -0
- package/src/vendor/hyper-morph-json.vendor.js +3 -0
- package/src/vendor/hyper-morph.vendor.js +6 -6
- package/src/vendor/hyper-undo.vendor.js +1 -1
- package/src/vendor/hypercms.vendor.js +169 -84
- package/src/vendor/marked.vendor.js +68 -0
- package/src/vendor/overtype.vendor.js +994 -0
- package/src/vendor/richclay.vendor.js +17 -17
- package/src/vendor/sap-core.vendor.js +5 -5
- package/src/vendor/sap-ownership.vendor.js +11 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// GENERATED — do not edit. Vendored from
|
|
2
2
|
// hyper-html-api/dist/hyper-html-api.engine.esm.js via hyper-html-api
|
|
3
3
|
// `npm run copy-to-clayjs`. Edit the hyper-html-api source and re-run.
|
|
4
|
-
var Qe=Object.defineProperty;var et=(e,t)=>{for(var n in t)Qe(e,n,{get:t[n],enumerable:!0})};var G=["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"],Y=new Set(G),re=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),$=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),Ee=new Set(["checked","selected","disabled","readOnly","paused"]);function ie(e,t){return t==null?Ee.has(e)?!1:"":Ee.has(e)?t==="false"?!1:!!t:t}var R={};et(R,{EmptyListInsert:()=>N,MAX_RULE_DEPTH:()=>L,MaxRuleDepthExceeded:()=>P,NoRulesTag:()=>oe,RuleTargetReadOnly:()=>B,RulesParseError:()=>k,ShapeMismatch:()=>v,UnknownRulesVersion:()=>W,WriteNotRoundTripped:()=>Z,WriteRefused:()=>H,WriteRejected:()=>se});var k=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},W=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},L=20,P=class extends Error{constructor(t){super(`rule depth exceeded ${L} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},v=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},N=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}},B=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},H=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function tt(e){return e.reduce((n,r)=>typeof r=="number"?`${n}[${r}]`:n?`${n}.${r}`:String(r),"")||"(root)"}var Z=class extends Error{constructor(t){super(`write did not round-trip at "${tt(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},oe=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},se=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}};function b(e){let t=0,n=null,r=-1;for(let i=0;i<e.length;i++){let s=e[i];s==="\\"?i++:n?s===n&&(n=null):s==='"'||s==="'"?n=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:s==="@"&&t===0&&(r=i)}return r}function le(e){let t=b(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function ce(e){let t=0,n=null,r=-1,i=!1;for(let s=0;s<e.length;s++){let l=e[s];l==="\\"?s++:n?l===n&&(n=null):l==='"'||l==="'"?n=l:l==="["||l==="("?t++:l==="]"||l===")"?t>0&&t--:t===0&&l===">"?r=s:t===0&&l===","&&(i=!0)}return i||r===-1||!nt(e,r+1)?null:e.slice(0,r).trim()||null}function nt(e,t){let n=t,r=e.replace(/\s+$/,"").length;for(;n<r&&/\s/.test(e[n]);)n++;let i=0,s=null;for(;n<r;n++){let l=e[n];if(l==="\\")n++;else if(s)l===s&&(s=null);else if(l==='"'||l==="'")s=l;else if(l==="["||l==="(")i++;else if(l==="]"||l===")")i>0&&i--;else if(i===0&&(l==="+"||l==="~"||/\s/.test(l)))return!1}return!0}function C(e,t,n,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.");return fe(e,t,n,{depth:0,path:[]},r)}function fe(e,t,n,r,i){if(r.depth>L)throw new P(r.path);if(typeof n=="string")return rt(e,t,n,r,i);if(Array.isArray(n)){let[s,l]=n,c=e.find(t,s,i);return xe(i,r,c),c.map((o,f)=>fe(e,o,l,{depth:r.depth+1,path:[...r.path,f]},i))}if(typeof n=="object"&&n!==null){let s={};for(let[l,c]of Object.entries(n))s[l]=fe(e,t,c,{depth:r.depth+1,path:[...r.path,l]},i);return s}return null}function rt(e,t,n,r,i){if(n.endsWith("[]")){let c=n.slice(0,-2),o=e.find(t,c,i);return xe(i,r,o),o.map(f=>e.text(f))}if(n.startsWith("@"))return Oe(e,t,n.slice(1));let s=b(n);if(s!==-1){let c=n.slice(0,s),o=n.slice(s+1),f=c?e.find(t,c,i):[t];return f.length===0?null:Oe(e,f[0],o)}if(n===".")return e.text(t);let l=e.find(t,n,i);return l.length===0?null:e.text(l[0])}function xe(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(r){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,r)}}function Oe(e,t,n){if(Y.has(n)){let i=e.prop(t,n);return i==null?null:String(i)}let r=e.attr(t,n);return r??null}function Re(e,t,n,r){let i=e.length,s=t.length,l=new Array(i).fill(-1);if(r){let h=new Set;for(let y=0;y<i;y++){let A=r[y];!(A>=0&&A<s)||h.has(A)||(l[y]=A,h.add(A))}}if(i===0||s===0)return l;let c=e.map(h=>Se(h,n)),o=t.map(h=>Se(h,n)),f=new Array(s).fill(!1);for(let h of l)h>=0&&(f[h]=!0);let u=new Map;o.forEach((h,y)=>{f[y]||u.set(h,u.has(h)?-1:y)});let m=new Map;c.forEach((h,y)=>{l[y]>=0||m.set(h,(m.get(h)||0)+1)}),c.forEach((h,y)=>{if(l[y]>=0||m.get(h)!==1)return;let A=u.get(h);A===void 0||A===-1||f[A]||(l[y]=A,f[A]=!0)});let d=[];for(let h=0;h<i;h++)l[h]<0&&d.push(h);let w=[];for(let h=0;h<s;h++)f[h]||w.push(h);if(d.length===0||w.length===0)return l;let a=i*s+1,p=it(e,t,n),g=(h,y)=>p(h,y)*a+Math.abs(h-y);for(let[h,y]of ot(d,w,g))l[h]=y;return l}var Ne=e=>typeof e=="object"&&e!==null;function Se(e,t){if(!Ne(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(r=>{let i=JSON.stringify(e?.[r]);return i===void 0?" undef":i}))}function it(e,t,n){if(!Ne(n))return(c,o)=>e[c]===t[o]?0:1;let r=Object.keys(n),i=c=>r.map(o=>JSON.stringify(c?.[o])),s=e.map(i),l=t.map(i);return(c,o)=>{let f=s[c],u=l[o],m=0;for(let d=0;d<r.length;d++)f[d]!==u[d]&&m++;return m}}function ot(e,t,n){return e.length<=t.length?be(e,t,n,!1):be(t,e,(r,i)=>n(i,r),!0)}function be(e,t,n,r){let i=e.length,s=t.length,l=[];for(let m=0;m<=i;m++)l.push(new Float64Array(s+1).fill(1/0));let c=[];for(let m=0;m<=i;m++)c.push(new Uint8Array(s+1));for(let m=0;m<=s;m++)l[i][m]=0;for(let m=i-1;m>=0;m--)for(let d=s-1;d>=0;d--){let w=n(e[m],t[d])+l[m+1][d+1],a=l[m][d+1];w<=a?(l[m][d]=w,c[m][d]=1):l[m][d]=a}let o=[],f=0,u=0;for(;f<i&&u<s;)c[f][u]&&(o.push(r?[t[u],e[f]]:[e[f],t[u]]),f++),u++;return o}function ae(e,t,n,r,i,s,l,c={}){let o=e.find(t,n,c);if(i.length===0){o.forEach(T=>e.remove(T)),ue(c,"onRowsApplied",s.path,[]);return}let f=i.length>o.length,u=o[0]||null;if(f&&!u&&(u=ft(e,t,n,c),!u))throw new N(s.path);let m=o.map(T=>ct(e,T,r,c)),d=null;if(f&&u){d=e.clone(u),c.templateAttr&&e.removeAttr(d,c.templateAttr);let T=e.stripIds(d);T>0&&console.warn(`[hyper-html-api] stripped ${T} id attribute(s) from cloned template at "${s.path.join(".")||"(root)"}"`)}let w=Re(i,m,r,st(e,o,i,s,c)),a=o.length>0?e.parent(o[0]):dt(e,t,n,u,s,c),p=o.length>0?ke(e,a,o[0]):0,g=yt(e,o),h=new Set,y=[],A=i.map((T,S)=>{let O=w[S];if(O>=0)return h.add(O),y.push(!1),o[O];y.push(!0);let E=e.clone(d);return e.stripIds(E),E});o.forEach((T,S)=>{h.has(S)||e.remove(T)}),g?mt(e,a,p,A,y):gt(e,A,y,a,p),lt(e,A,r,i,s,l,c),ue(c,"onRowsApplied",s.path,A)}function ue(e,t,n,r){if(typeof e[t]=="function")try{return e[t](n.slice(),r)}catch(i){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,i);return}}function st(e,t,n,r,i){let s=ue(i,"identifyRows",r.path,n);if(!Array.isArray(s))return null;let l=new Array(n.length).fill(-1),c=new Set,o=new Map(t.map((f,u)=>[e.identity(f),u]));for(let f=0;f<n.length;f++){if(!s[f])continue;let u=o.get(e.identity(s[f]));u===void 0||c.has(u)||(l[f]=u,c.add(u))}return l}function lt(e,t,n,r,i,s,l){t.forEach((c,o)=>{if(n===null){let f=r[o],u=f==null?"":String(f);e.text(c)!==u&&e.text(c,u)}else{let f=s(e,c,n,r[o],{depth:i.depth+1,path:[...i.path,o]},l);f&&f!==c&&(t[o]=f)}})}function ct(e,t,n,r){return n===null?e.text(t):C(e,t,n,r.onRowsRead?{...r,onRowsRead:void 0}:r)}function ke(e,t,n){let r=e.children(t);for(let i=0;i<r.length;i++)if(e.sameNode(r[i],n))return i;return-1}function ft(e,t,n,r){if(!r.templateAttr)return null;let i=/^\s*:scope\s*>\s*/.test(n),s=new RegExp(":not\\(\\["+r.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),l=n.replace(/^\s*:scope\s*>\s*/,"").replace(s,""),c=i?ut(l):0,o=ce(l),f=t;for(;f;){let u=e.find(f,l,{includeRulesTag:!1,templateAttr:null});for(let m of u)if(e.attr(m,r.templateAttr)!=null&&!(i&&!ht(e,t,m,c))&&!(o&&!e.matches(e.parent(m),o)))return m;f=e.parent(f)}return null}function ut(e){let t=0,n=null,r=1;for(let i=0;i<e.length;i++){let s=e[i];if(s==="\\")i++;else if(n)s===n&&(n=null);else if(s==='"'||s==="'")n=s;else if(s==="["||s==="(")t++;else if(s==="]"||s===")")t>0&&t--;else if(t===0&&s===">")r++;else{if(t===0&&(s==="+"||s==="~"))return null;if(t===0&&/\s/.test(s)){if(!at(e,i))return null;for(;i+1<e.length&&/\s/.test(e[i+1]);)i++}}}return r}function at(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let r=t>0?e[t-1]:"",i=n<e.length?e[n]:"";return Ce(r)||Ce(i)}function Ce(e){return e===">"||e==="+"||e==="~"}function ht(e,t,n,r){if(r===null)return!0;let i=n;for(let o=0;o<r;o++)if(i=e.parent(i),!i)return!1;let s=e.prop(t,"tagName");if(!s)return!0;let l=e.prop(i,"tagName");if(!l||String(l).toLowerCase()!==String(s).toLowerCase())return!1;let c=new Set(Me(e,i));return Me(e,t).every(o=>c.has(o))}function Me(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function dt(e,t,n,r,i,s){let l=e.parent(r);if(l&&pt(e,t,l)&&!Ie(e,l,s))return l;let c=ce(n);if(!c)throw new N(i.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=(c===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,c,s)).filter(u=>!Ie(e,u,s));if(f.length===0)throw new N(i.path,`no container matching "${c}" inside this context to hold the new rows`);if(f.length>1)throw new N(i.path,`"${c}" matches ${f.length} containers inside this context, so the new rows have no single destination`);return f[0]}function pt(e,t,n){let r=n;for(;r;){if(e.sameNode(r,t))return!0;r=e.parent(r)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(i=>e.sameNode(i,n))}var Pe=["no-data","editor-ui"];function Ie(e,t,n){let r=t;for(;r;){if(n.templateAttr&&e.attr(r,n.templateAttr)!=null||Pe.some(s=>e.attr(r,s)!=null))return!0;let i=e.attr(r,"clay");if(i&&i.split(/\s+/).some(s=>Pe.includes(s)))return!0;r=e.parent(r)}return!1}function mt(e,t,n,r,i){let s=e.children(t),l=s.map(o=>e.identity(o)),c=!1;r.forEach((o,f)=>{let u=e.identity(o),m=n+f;if(l[m]===u)return;if(!i[f]){let w=l.indexOf(u);w!==-1&&(l.splice(w,1),s.splice(w,1))}let d=Math.min(m,s.length);d<s.length?e.insertBefore(s[d],o):s.length?c?e.insertAfter(s[s.length-1],o):(e.insertAt(t,o,m),c=!0):e.insertAt(t,o,0),l.splice(d,0,u),s.splice(d,0,o)})}function yt(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let r=new Map(e.children(n).map((s,l)=>[e.identity(s),l])),i=[];for(let s of t){let l=r.get(e.identity(s));if(l===void 0)return!1;i.push(l)}return i.sort((s,l)=>s-l),i[i.length-1]-i[0]===i.length-1}function gt(e,t,n,r,i){let s=null,l=i;for(let c=0;c<t.length;c++){if(!n[c]){s=t[c];continue}let o=s?e.parent(s):r;if(!o)continue;let f=s?ke(e,o,s)+1:l++;e.insertAt(o,t[c],f),s=t[c]}}function I(e,t,n,r,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.");let s=[];if(he(n,r,[],s),s.length)throw new v(s);Q(e,t,n,r,{depth:0,path:[]},i)}function Q(e,t,n,r,i,s={}){if(i.depth>L)throw new P(i.path);if(r===void 0)return t;if(typeof n=="string")return At(e,t,n,r,i,s);if(Array.isArray(n)){let[l,c]=n;return ae(e,t,l,c,r,i,Q,s),t}if(typeof n=="object"&&n!==null){for(let[l,c]of Object.entries(n)){let o=Q(e,t,c,r==null?r:r[l],{depth:i.depth+1,path:[...i.path,l]},s);o&&o!==t&&(t=o)}return t}return t}function At(e,t,n,r,i,s){if(n.endsWith("[]")){let o=n.slice(0,-2);return ae(e,t,o,null,r,i,Q,s),t}if(n.startsWith("@"))return je(e,t,n.slice(1),r);let l=b(n);if(l!==-1){let o=n.slice(0,l),f=n.slice(l+1),u=o?e.find(t,o,s):[t];return u.length===0||je(e,u[0],f,r),t}if(n===".")return Le(e,t,r),t;let c=e.find(t,n,s);return c.length===0||Le(e,c[0],r),t}function Le(e,t,n){let r=n==null?"":String(n);e.text(t)!==r&&e.text(t,r)}function je(e,t,n,r){if($.has(n)){let i=e.prop(t,n);if(i===r||i!=null&&r!=null&&String(i)===String(r))return t;throw new B(n)}if(n==="outerHTML"){let i=r==null?"":String(r);return e.replaceWith(t,i)}if(re.has(n)){let i=ie(n,r);return e.prop(t,n)!==i&&e.prop(t,n,i),t}if(r==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let i=String(r);e.attr(t,n)!==i&&e.attr(t,n,i)}return t}function he(e,t,n,r){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((i,s)=>{typeof i=="object"&&i!==null&&r.push({path:U([...n,s]),expected:"scalar",got:q(i)})}):r.push({path:U(n),expected:"array",got:q(t)});return}t!==null&&typeof t=="object"&&r.push({path:U(n),expected:"scalar",got:q(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){r.push({path:U(n),expected:"array",got:q(t)});return}let i=e[1];t.forEach((s,l)=>he(i,s,[...n,l],r));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){r.push({path:U(n),expected:"object",got:q(t)});return}for(let[i,s]of Object.entries(e))he(s,t[i],[...n,i],r)}}}function q(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function U(e){return e.join(".")}function de(e){try{return JSON.parse(e)}catch(t){throw new k(`Invalid strict JSON: ${t.message}`,t)}}function z(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(i){let s=[],l=0;for(;l<i.length;){let c=i[l];if(/\s/.test(c)){l++;continue}if("{}".includes(c)){s.push({type:c,value:c}),l++;continue}if(c==="["){let m=!1,d=l+1;for(;d<i.length&&/\s/.test(i[d]);)d++;if(d<i.length&&/[a-zA-Z_]/.test(i[d])&&(m=!0),!m){s.push({type:c,value:c}),l++;continue}}if(c==="]"){s.push({type:c,value:c}),l++;continue}if(c===":"){s.push({type:t.COLON,value:c}),l++;continue}if(c===","){s.push({type:t.COMMA,value:c}),l++;continue}if(c==='"'||c==="'"){let m=c,d=l+1;for(;d<i.length&&i[d]!==m;)i[d]==="\\"&&d++,d++;s.push({type:t.STRING,value:i.substring(l+1,d),quoted:!0,sourceQuote:m}),l=d+1;continue}let o=l,f;for(;o<i.length&&!/[{},]/.test(i[o]);)if(i[o]===":"){let m=[":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"],d=!1;for(let w of m){let a=w.substring(1);if(i.substring(o+1,o+1+a.length)===a){d=!0,o+=a.length;break}}if(!d)break}else if(i[o]==="["){for(o++;o<i.length&&i[o]!=="]";){if(i[o]==='"'||i[o]==="'"){let m=i[o];for(o++;o<i.length&&i[o]!==m;)i[o]==="\\"&&o++,o++}o++}o<i.length&&i[o]==="]"&&o++}else o++;f=i.substring(l,o);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),s.push({type:u,value:f,quoted:!1}),l=o}return s}function r(i){let s="";for(let l=0;l<i.length;l++){let c=i[l];if("{}".includes(c.type)||"[]".includes(c.type)){s+=c.value;continue}if(c.type===t.COLON){s+=c.value;continue}if(c.type===t.COMMA){let o=i[l+1];if(o&&(o.type==="}"||o.type==="]"))continue;s+=c.value;continue}if(c.type===t.STRING&&c.quoted){let o=c.value;c.sourceQuote==="'"&&(o=o.replace(/\\'/g,"'"),o=o.replace(/(\\*)"/g,(f,u)=>u.length%2===0?u+'\\"':f)),s+=`"${o}"`;continue}if(c.type===t.NUMBER||c.type===t.BOOLEAN){s+=c.value;continue}if(c.type===t.SELECTOR||c.type===t.IDENTIFIER){s+=`"${c.value}"`;continue}s+=`"${c.value}"`}return s}try{let i=n(e),s=r(i);return JSON.parse(s)}catch(i){throw new k("Invalid extraction rules syntax: "+i.message,i)}}var Tt="1",_e=/^[a-zA-Z0-9_-]+$/;function j(e,t,n){let r;if(n===void 0)r="script[data-rules-name]";else{if(typeof n!="string"||!_e.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${_e})`);r=`script[data-rules-name~="${n}"]`}let i=e.find(t,r,{includeRulesTag:!0});if(i.length===0)return null;n!==void 0&&i.length>1&&console.warn(`hyper-html-api: ${i.length} rules tags match data-rules-name~="${n}"; using the first.`);let s=i[0],l=e.attr(s,"data-rules-version");if(l!==Tt)throw new W(l);return{rules:z(e.text(s)),tagNode:s}}var ee=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"]})}),wt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),De=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function K(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 pe(e,t){if(K(e,t))return!0;for(let[n,r]of Object.entries(wt))if(r.includes(t)&&K(e,n))return!0;return!1}function F(e){let t=ee[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Et(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let r=ee[t];if(!r)throw new Error(`Unknown region capability: ${t}`);if(r.tokens.some(i=>pe(n,i))||r.bundles.some(i=>K(n,i)))return n;n=n.parentElement}return null}function $e(e,t){return!!Et(e,t)}var me=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",...De],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"]}),Ot=new Set(["textContent","innerText"]);function We(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 xt=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function ve(e,t,n=me){if(!xt.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let r=String(e).toLowerCase();if(n.refusedAttributePrefixes.some(i=>r.startsWith(i)))return`attribute "${r}" can run script`;if(n.refusedAttributes.includes(r))return`attribute "${r}" is not content`;if(n.urlAttributes.includes(r)&&t!=null){let i=r==="srcset"?String(t).split(",").map(s=>s.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let s of i){let l=We(s);if(l&&n.refusedSchemes.includes(l))return`"${l}:" URLs are not allowed in "${r}"`}}return null}function ye(e,t){let n=e.prop(t,"tagName");return n?String(n).toLowerCase():""}function St(e,t){let n=ye(e,t)||"node",r=e.attr(t,"id");return r?`<${n}#${r}>`:`<${n}>`}function bt(e,t,n){let r=t;for(;r;){let i=ye(e,r);if(i&&n.refusedTargets.includes(i))return i;r=e.parent(r)}return null}function Be(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function Rt(e,t){return ye(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:Be(e,t)}function te(e,t=me){let n=[],r=(o,f)=>(n.push({target:St(e,o),reason:f}),!1),i=o=>{let f=bt(e,o,t);return f?r(o,`inside <${f}>, which is not content`):!0},s=o=>i(o)?Be(e,o)?r(o,"a text write here would delete the data rules tag"):!0:!1,l=(o,f,u)=>{if(!i(o))return!1;let m=ve(f,u,t);return m?r(o,m):!0};return{...e,text(o,f){if(f===void 0)return e.text(o);s(o)&&e.text(o,f)},attr(o,f,u){if(u===void 0)return e.attr(o,f);l(o,f,u)&&e.attr(o,f,u)},removeAttr(o,f){l(o,f,null)&&e.removeAttr(o,f)},prop(o,f,u){if(u===void 0)return e.prop(o,f);if(t.refusedRuleForms.includes(f))return r(o,`"@${f}" writes HTML, only text is allowed`);if(Ot.has(f)){s(o)&&e.prop(o,f,u);return}l(o,f==="className"?"class":f,u)&&e.prop(o,f,u)},remove(o){if(Rt(e,o)){r(o,"removing this would delete the data rules tag");return}e.remove(o)},replaceWith(o,f){return f===e.prop(o,"outerHTML")||r(o,'"@outerHTML" writes HTML, only text is allowed'),o},refusals:n,assertClean(){if(n.length)throw new H(n.slice())}}}function V(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function He(e){return e.reduce((t,n)=>typeof n=="number"?`${t}[${n}]`:t?`${t}.${n}`:n,"")}function ge(e,t,n,r,i={}){let s=[],l=[];function c(f,u,m){if(Array.isArray(f)){let[,d]=f;if(!Array.isArray(u)||!V(d))return;u.forEach((w,a)=>c(d,w,[...m,a]));return}if(!(!V(f)||!V(u)))for(let d of Object.keys(u))Object.prototype.hasOwnProperty.call(f,d)?c(f[d],u[d],[...m,d]):s.push(He([...m,d]))}function o(f,u,m,d){if(m!==void 0){if(typeof u=="string"){if(u.endsWith("[]")||u==="."||u.startsWith("@"))return;let w=b(u),a=w===-1?u:u.slice(0,w);if(!a)return;e.find(f,a,i).length===0&&l.push({path:He(d),selector:a});return}if(!Array.isArray(u)&&V(u)&&V(m))for(let[w,a]of Object.entries(u))o(f,a,m[w],[...d,w])}}return c(n,r,[]),o(t,n,r,[]),{unknownKeys:s,unmatched:l}}function Ae(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let r=t&&t.ownerDocument?t.ownerDocument:t;return j(e,r,n)}return null}var Ct=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Mt(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 qe(e,t,n,r){if(r)return!!e.closest?.(t);let i=e;for(;i?.nodeType===1;){if(i.matches(t))return!0;if(i===n)break;i=i.parentElement}return!1}function Ue(e,t,n,r,i,s){return(s?$e(e,t):qe(e,n,i,!1))||!!(r&&(s&&e!==i?e.matches(r):qe(e,r,i,s)))}function Pt(e,t){let n=ee[t];return n.tokens.some(r=>pe(e,r))||n.bundles.some(r=>K(e,r))}var It=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function ze(e,t,n,r){if(e.nodeType===1&&r(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let i=e,s=t;if(e.nodeType===1){if(It.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);i=e.content,s=t.content,n.cloneToLive.set(s,i),n.liveToClone.set(i,s)}}else if(e.nodeType!==11)return;let l=s.firstChild;for(let c=i.firstChild;c&&l;c=c.nextSibling)ze(c,l,n,r),l=l.nextSibling}function J(e,{capability:t="data",exclude:n=null,inherit:r=!0,provenance:i=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let s=e.nodeType===9?e:e.ownerDocument;if(!s?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let l=s.implementation.createHTMLDocument(""),c=i||new WeakMap,o=new WeakMap,f=e.nodeType===9?e.documentElement:e;n&&l.documentElement.matches(n);let u=F(t),m=r?a=>Pt(a,t)||!!(n&&a.matches(n)):a=>Ue(a,t,u,n,f,!1),d=null;if(f.nodeType!==1||!Ue(f,t,u,n,f,r)){d=l.importNode(f,!0);let a={cloneToLive:c,liveToClone:o,dropped:[],controls:[]};ze(f,d,a,m);for(let p of a.dropped)p.remove();for(let p=0;p<a.controls.length;p+=2)Mt(a.controls[p],a.controls[p+1])}e.nodeType===9&&d&&(l.replaceChild(d,l.documentElement),o.set(e,l),c.set(l,e));let w=a=>{if(Ct.test(a))throw new Error(`Filtered content queries do not support stateful selector: ${a}`)};return{root:d,document:l,capability:t,selector:F(t),cloneToLive:c,liveToClone:o,original(a){return c.get(a)||null},cloneOf(a){return o.get(a)||null},query(a,p=d){return w(a),Array.from(p.querySelectorAll(a),g=>c.get(g)||g)},text(a=d){return(a===d?d:o.get(a))?.textContent||""},html(a=d){return(a===d?d:o.get(a))?.innerHTML??""},clone(a=d){let p=a===d?d:o.get(a);return p?l.importNode(p,!0):null}}}function Fe(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function kt(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function Ke(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 Ve(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function Je(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 r=n.type;r!=="file"&&r!=="checkbox"&&r!=="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 r=kt(e);if(!r||!r.querySelectorAll)return[];let i=Array.from(r.querySelectorAll(t));n.includeRulesTag||(i=i.filter(c=>!Fe(c)));let s=[];n.skip&&s.push(n.skip);let l=n.templateAttr===null?null:n.templateAttr||"cms-template";if(l&&s.push("["+l+"]"),s.length){let c=s.join(", ");i=i.filter(o=>!o.closest||!o.closest(c))}return i},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,Ve(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),Ke(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),Ke(e,t,null)},prop(e,t,n){if(n===void 0){let r=e?e[t]:void 0;return r!==void 0?r:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return Je(t),t},insertAt(e,t,n){let r=e.children[n]||null;e.insertBefore(t,r)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let r=e.ownerDocument.createElement("template");r.innerHTML=t;let i=r.content.firstElementChild;if(!i)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(i,e),i},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(r=>{r.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function M(e,t={}){if(t.exclude===null)return x;let n=[F("data"),t.exclude].filter(Boolean).join(", "),r=e.nodeType===9?e:e.ownerDocument||e,i=e.nodeType===9?e.documentElement:e;if(!t._write&&!i?.matches?.(n)&&!i?.querySelector?.(n)&&!r?.querySelector?.(n))return x;let s=e.nodeType===9||!e.isConnected?e:e.ownerDocument,l=e.nodeType===9?e:e.ownerDocument,c=null,o=()=>c||(c=J(s,{capability:"data",exclude:t.exclude||null})),f=a=>{let p=o();return a===e?p.cloneOf(e):p.cloneOf(a)||a},u=a=>c?.original(a)||a,m=(a,p)=>{o().liveToClone.set(a,p),o().cloneToLive.set(p,a);let g=a.childNodes||[],h=p.childNodes||[];for(let y=0;y<Math.min(g.length,h.length);y++)m(g[y],h[y])},d=(a,p,g,h)=>{let y=Array.from(a.childNodes).filter(E=>c.cloneOf(E)),T=y[0];for(;T&&y.includes(T);)T=T.nextSibling;for(let E of y)E.remove();if(g==="innerHTML"){let E=l.createElement("template");E.innerHTML=h;for(let D of Array.from(E.content.childNodes))a.insertBefore(D,T||null)}else a.insertBefore(l.createTextNode(h),T||null),Ve(a,h);let S=J(a,{capability:"data",exclude:t.exclude||null});p.replaceChildren(...Array.from(S.root?.childNodes||[]));let O=E=>{let D=S.original(E);D&&(c.liveToClone.set(D,E),c.cloneToLive.set(E,D));for(let Ze of Array.from(E.childNodes||[]))O(Ze)};for(let E of Array.from(p.childNodes))O(E)},w={...x,find(a,p,g={}){let h=f(a);if(!h?.querySelectorAll)return[];let y=o().query(p,h);g.includeRulesTag||(y=y.filter(S=>!Fe(S)));let A=[];g.skip&&A.push(g.skip);let T=g.templateAttr===null?null:g.templateAttr||"cms-template";if(T&&A.push(`[${T}]`),A.length){let S=A.join(", ");y=y.filter(O=>!O.closest?.(S))}return y},parent(a){let p=f(a)?.parentElement;return p?u(p):null},children(a){return Array.from(f(a)?.children||[],u)},text(a,p){if(p===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)&&!c){x.text(g,p);return}let h=o().cloneOf(g);h?d(g,h,"textContent",p):x.text(g,p)},attr(a,p,g){let h=u(a);if(g===void 0)return x.attr(h,p);x.attr(h,p,g);let y=c?.cloneOf(h);y&&(x.attr(y,p,g),J(h,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),c.liveToClone.delete(h),c.cloneToLive.delete(y)))},removeAttr(a,p){let g=u(a);x.removeAttr(g,p);let h=c?.cloneOf(g);h&&x.removeAttr(h,p)},prop(a,p,g){let h=u(a);if(g===void 0)return p==="innerHTML"||p==="outerHTML"||p==="textContent"||p==="innerText"?x.prop(f(h),p):x.prop(h,p);let y=p==="innerHTML"||p==="textContent"||p==="innerText",A=y?o().cloneOf(h):c?.cloneOf(h);A&&y?d(h,A,p,g):(x.prop(h,p,g),A&&x.prop(A,p,g))},clone(a){let p=f(a);if(p===a)return x.clone(a);let g=l.importNode(p,!0);return Je(g),g},insertAt(a,p,g){let h=u(a),A=w.children(h)[g]||(()=>{for(let O=h.children.length-1;O>=0;O--){let E=h.children[O];if(o().cloneOf(E))return E.nextElementSibling}return h.firstElementChild})(),T=u(p);h.insertBefore(T,A||null);let S=o().cloneOf(h);if(S){let O=o().cloneOf(T);O||(O=l.importNode(T,!0),m(T,O));let E=Array.from(S.children);S.insertBefore(O,E[g]||null)}},insertBefore(a,p){let g=u(a),h=u(p);g.parentNode.insertBefore(h,g);let y=o().cloneOf(g.parentNode);if(y){let A=o().cloneOf(h);A||(A=l.importNode(h,!0),m(h,A));let T=o().cloneOf(g);T?T.before(A):y.appendChild(A)}},insertAfter(a,p){let g=u(a),h=u(p);g.parentNode.insertBefore(h,g.nextSibling);let y=o().cloneOf(g.parentNode);if(y){let A=o().cloneOf(h);A||(A=l.importNode(h,!0),m(h,A));let T=o().cloneOf(g);T?T.after(A):y.appendChild(A)}},identity(a){return u(a)||null},remove(a){let p=u(a),g=o().cloneOf(p);x.remove(p),g&&x.remove(g)},replaceWith(a,p){let g=u(a),h=o().cloneOf(g),y=x.replaceWith(g,p);if(h){let A=J(y,{capability:"data",exclude:t.exclude||null});if(!A.root)h.remove();else{h.replaceWith(A.root);let T=S=>{let O=A.original(S);O&&(c.liveToClone.set(O,S),c.cloneToLive.set(S,O));for(let E of Array.from(S.childNodes||[]))T(E)};T(A.root)}}return y}};return w}var X=x;var ne={extract:(e,t,n={})=>C(M(e,n),e,t,n),apply:(e,t,n,r={})=>I(M(e,{...r,_write:!0}),e,t,n,r),findRulesIn:(e,t)=>j(X,e,t),findRules:(e,t)=>Ae(X,e,t),bind:(e,t,n={})=>{let r=Ae(X,e,t);if(!r){let i=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${i}`)}return{...r,get:()=>C(M(e,n),e,r.rules,n),set:i=>I(M(e,{...n,_write:!0}),e,r.rules,i,n)}},parseStrict:de,parseRelaxed:z,ruleAttrIndex:b,splitRule:le,errors:R,DOM_PROPERTIES:G},Te=e=>!!e&&typeof e.nodeType=="number";function Xe(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=j(X,t,"api");if(!n)throw new R.NoRulesTag("api");return n.rules}function Lt(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 jt(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 _t(e,t){let n=[];for(;t!==e;){let r=t.parentNode;n.push(Array.prototype.indexOf.call(r.childNodes,t)),t=r}return n.reverse()}function Dt(e,t){return t.reduce((n,r)=>n.childNodes[r],e)}function _(e,t){let n=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&n.unshift(e),n}function $t(e,t){let n=_(e,"option"),r=_(t,"option");n.forEach((o,f)=>r[f].selected=o.selected);let i=_(e,"input"),s=_(t,"input");i.forEach((o,f)=>{let u=o.type.toLowerCase();u!=="file"&&(s[f].value=o.value),(u==="checkbox"||u==="radio")&&(s[f].checked=o.checked)});let l=_(e,"textarea"),c=_(t,"textarea");l.forEach((o,f)=>c[f].value=o.value)}function we(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let n=e.startsWith("@")?0:b(e);if(n===-1)return;let r=e.slice(n+1);if($.has(r))throw new R.RuleTargetReadOnly(r);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(n=>we(e[1],n));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[n,r]of Object.entries(e))we(r,t[n])}}function Wt(e,t,n){let r={templateAttr:"cms-template"},i=Lt(e),s=_t(i,e),l=jt(i);$t(i,l);let c=Dt(l,s),o=M(l,{...r,_write:!0}),f=ge(o,c,t,n,r);if(f.unknownKeys.length||f.unmatched.length)throw new R.WriteRejected(f.unknownKeys,f.unmatched);let u=te(o);I(u,c,t,n,r),u.assertClean(),we(t,n);let m=te(M(i,{...r,_write:!0}));I(m,e,t,n,r),m.assertClean()}function vt(e){if(!(e instanceof Error))return e;let t=e.name||"Error";try{e.code=t}catch{Object.defineProperty(e,"code",{value:t,configurable:!0,enumerable:!0})}return e instanceof 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 Ge(e,t){let n=Te(e)?e:document,r=Te(e)?t:e;return r===void 0?C(M(n),n,Xe(n)):ne.bind(n,r).get()}function Ye(e,t,n){try{if(!Te(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let r=n===void 0?Xe(e):ne.bind(e,n).rules;Wt(e,r,t)}catch(r){throw vt(r)}return e}var Bt={engine:ne,extractData:Ge,applyData:Ye},Fn=Bt;export{Ye as applyData,Fn as default,ne as engine,Ge as extractData};
|
|
4
|
+
var st=Object.defineProperty;var lt=(e,t)=>{for(var n in t)st(e,n,{get:t[n],enumerable:!0})};var Z=["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"],Q=new Set(Z),le=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),v=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),xe=new Set(["checked","selected","disabled","readOnly","paused"]);function ce(e,t){return t==null?xe.has(e)?!1:"":xe.has(e)?t==="false"?!1:!!t:t}var R={};lt(R,{EmptyListInsert:()=>N,MAX_RULE_DEPTH:()=>j,MaxRuleDepthExceeded:()=>k,NoRulesTag:()=>fe,RuleTargetReadOnly:()=>q,RulesParseError:()=>I,ShapeMismatch:()=>H,UnknownRulesVersion:()=>B,WriteNotRoundTripped:()=>ee,WriteRefused:()=>V,WriteRejected:()=>ue});var I=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},B=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},j=20,k=class extends Error{constructor(t){super(`rule depth exceeded ${j} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},H=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},N=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}},q=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},V=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function ct(e){return e.reduce((n,r)=>typeof r=="number"?`${n}[${r}]`:n?`${n}.${r}`:String(r),"")||"(root)"}var ee=class extends Error{constructor(t){super(`write did not round-trip at "${ct(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},fe=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},ue=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}};function b(e){let t=0,n=null,r=-1;for(let i=0;i<e.length;i++){let o=e[i];o==="\\"?i++:n?o===n&&(n=null):o==='"'||o==="'"?n=o:o==="["||o==="("?t++:o==="]"||o===")"?t>0&&t--:o==="@"&&t===0&&(r=i)}return r}function ae(e){let t=b(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function he(e){let t=0,n=null,r=-1,i=!1;for(let o=0;o<e.length;o++){let l=e[o];l==="\\"?o++:n?l===n&&(n=null):l==='"'||l==="'"?n=l:l==="["||l==="("?t++:l==="]"||l===")"?t>0&&t--:t===0&&l===">"?r=o:t===0&&l===","&&(i=!0)}return i||r===-1||!ft(e,r+1)?null:e.slice(0,r).trim()||null}function ft(e,t){let n=t,r=e.replace(/\s+$/,"").length;for(;n<r&&/\s/.test(e[n]);)n++;let i=0,o=null;for(;n<r;n++){let l=e[n];if(l==="\\")n++;else if(o)l===o&&(o=null);else if(l==='"'||l==="'")o=l;else if(l==="["||l==="(")i++;else if(l==="]"||l===")")i>0&&i--;else if(i===0&&(l==="+"||l==="~"||/\s/.test(l)))return!1}return!0}var ut=/^--[A-Za-z0-9_-]+$/;function C(e){return typeof e=="string"&&ut.test(e)}function be(e){let t=[],n=[],r=null,i=0;for(let o=0;o<e.length;o++){let l=e[o];if(r){l==="\\"?o++:l===r&&(r=null);continue}if(l==="/"&&e[o+1]==="*"){let c=e.indexOf("*/",o+2);o=c===-1?e.length:c+1;continue}l==='"'||l==="'"?r=l:l==="("?n.push(")"):l==="["?n.push("]"):l==="{"?n.push("}"):(l===")"||l==="]"||l==="}")&&n[n.length-1]===l?n.pop():l===";"&&n.length===0&&(t.push(e.slice(i,o)),i=o+1)}return t.push(e.slice(i)),t}function at(e){let t="",n=null;for(let r=0;r<e.length;r++){let i=e[r];if(n){t+=i,i==="\\"&&r+1<e.length?t+=e[++r]:i===n&&(n=null);continue}if(i==="/"&&e[r+1]==="*"){let o=e.indexOf("*/",r+2);r=o===-1?e.length:o+1,t+=" ";continue}(i==='"'||i==="'")&&(n=i),t+=i}return t}function Re(e){e=at(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),r=e.slice(t+1).trim(),i=/!\s*important\s*$/i.exec(r);return i&&(r=r.slice(0,i.index).trim()),{name:n,value:r,important:!!i}}function $(e,t){if(e==null)return null;let n=null;for(let r of be(String(e))){let i=Re(r);!i||i.name!==t||(!n||i.important||!n.important)&&(n=i)}return n?n.value:null}function Ne(e,t,n){let r=e==null?"":String(e),i=n==null||n==="",o=be(r),l=o.map(Re),c=l.some(d=>d&&d.name===t&&d.important),s=[],f=!1;o.forEach((d,p)=>{let w=l[p];if(!w||w.name!==t){s.push(d);return}if(i||f)return;let a=/^\s*/.exec(d)[0];s.push(`${a}${t}: ${n}${c?" !important":""}`),f=!0});let u=s.join(";");if(!i&&!f){let d=u.trimEnd();u=d===""?`${t}: ${n}`:`${d}${d.endsWith(";")?" ":"; "}${t}: ${n}`}return u.trim()===""?null:u}function te(e,t,n,r){let i=e.attr(t,"style");if(($(i,n)??"")===r)return;let o=Ne(i,n,r);o==null?e.removeAttr(t,"style"):e.attr(t,"style",o)}function P(e,t,n,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.");return de(e,t,n,{depth:0,path:[]},r)}function de(e,t,n,r,i){if(r.depth>j)throw new k(r.path);if(typeof n=="string")return ht(e,t,n,r,i);if(Array.isArray(n)){let[o,l]=n,c=e.find(t,o,i);return Pe(i,r,c),c.map((s,f)=>de(e,s,l,{depth:r.depth+1,path:[...r.path,f]},i))}if(typeof n=="object"&&n!==null){let o={};for(let[l,c]of Object.entries(n))o[l]=de(e,t,c,{depth:r.depth+1,path:[...r.path,l]},i);return o}return null}function ht(e,t,n,r,i){if(n.endsWith("[]")){let c=n.slice(0,-2),s=e.find(t,c,i);return Pe(i,r,s),s.map(f=>e.text(f))}if(n.startsWith("@"))return Ce(e,t,n.slice(1));let o=b(n);if(o!==-1){let c=n.slice(0,o),s=n.slice(o+1),f=c?e.find(t,c,i):[t];return f.length===0?null:Ce(e,f[0],s)}if(n===".")return e.text(t);let l=e.find(t,n,i);return l.length===0?null:e.text(l[0])}function Pe(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(r){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,r)}}function Ce(e,t,n){if(C(n))return $(e.attr(t,"style"),n);if(Q.has(n)){let i=e.prop(t,n);return i==null?null:String(i)}let r=e.attr(t,n);return r??null}function Le(e,t,n,r){let i=e.length,o=t.length,l=new Array(i).fill(-1);if(r){let h=new Set;for(let y=0;y<i;y++){let A=r[y];!(A>=0&&A<o)||h.has(A)||(l[y]=A,h.add(A))}}if(i===0||o===0)return l;let c=e.map(h=>Me(h,n)),s=t.map(h=>Me(h,n)),f=new Array(o).fill(!1);for(let h of l)h>=0&&(f[h]=!0);let u=new Map;s.forEach((h,y)=>{f[y]||u.set(h,u.has(h)?-1:y)});let d=new Map;c.forEach((h,y)=>{l[y]>=0||d.set(h,(d.get(h)||0)+1)}),c.forEach((h,y)=>{if(l[y]>=0||d.get(h)!==1)return;let A=u.get(h);A===void 0||A===-1||f[A]||(l[y]=A,f[A]=!0)});let p=[];for(let h=0;h<i;h++)l[h]<0&&p.push(h);let w=[];for(let h=0;h<o;h++)f[h]||w.push(h);if(p.length===0||w.length===0)return l;let a=i*o+1,m=dt(e,t,n),g=(h,y)=>m(h,y)*a+Math.abs(h-y);for(let[h,y]of pt(p,w,g))l[h]=y;return l}var Ie=e=>typeof e=="object"&&e!==null;function Me(e,t){if(!Ie(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(r=>{let i=JSON.stringify(e?.[r]);return i===void 0?" undef":i}))}function dt(e,t,n){if(!Ie(n))return(c,s)=>e[c]===t[s]?0:1;let r=Object.keys(n),i=c=>r.map(s=>JSON.stringify(c?.[s])),o=e.map(i),l=t.map(i);return(c,s)=>{let f=o[c],u=l[s],d=0;for(let p=0;p<r.length;p++)f[p]!==u[p]&&d++;return d}}function pt(e,t,n){return e.length<=t.length?ke(e,t,n,!1):ke(t,e,(r,i)=>n(i,r),!0)}function ke(e,t,n,r){let i=e.length,o=t.length,l=[];for(let d=0;d<=i;d++)l.push(new Float64Array(o+1).fill(1/0));let c=[];for(let d=0;d<=i;d++)c.push(new Uint8Array(o+1));for(let d=0;d<=o;d++)l[i][d]=0;for(let d=i-1;d>=0;d--)for(let p=o-1;p>=0;p--){let w=n(e[d],t[p])+l[d+1][p+1],a=l[d][p+1];w<=a?(l[d][p]=w,c[d][p]=1):l[d][p]=a}let s=[],f=0,u=0;for(;f<i&&u<o;)c[f][u]&&(s.push(r?[t[u],e[f]]:[e[f],t[u]]),f++),u++;return s}function me(e,t,n,r,i,o,l,c={}){let s=e.find(t,n,c);if(i.length===0){s.forEach(T=>e.remove(T)),pe(c,"onRowsApplied",o.path,[]);return}let f=i.length>s.length,u=s[0]||null;if(f&&!u&&(u=At(e,t,n,c),!u))throw new N(o.path);let d=s.map(T=>gt(e,T,r,c)),p=null;if(f&&u){p=e.clone(u),c.templateAttr&&e.removeAttr(p,c.templateAttr);let T=e.stripIds(p);T>0&&console.warn(`[hyper-html-api] stripped ${T} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let w=Le(i,d,r,mt(e,s,i,o,c)),a=s.length>0?e.parent(s[0]):Ot(e,t,n,u,o,c),m=s.length>0?We(e,a,s[0]):0,g=bt(e,s),h=new Set,y=[],A=i.map((T,x)=>{let O=w[x];if(O>=0)return h.add(O),y.push(!1),s[O];y.push(!0);let E=e.clone(p);return e.stripIds(E),E});s.forEach((T,x)=>{h.has(x)||e.remove(T)}),g?xt(e,a,m,A,y):Rt(e,A,y,a,m),yt(e,A,r,i,o,l,c),pe(c,"onRowsApplied",o.path,A)}function pe(e,t,n,r){if(typeof e[t]=="function")try{return e[t](n.slice(),r)}catch(i){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,i);return}}function mt(e,t,n,r,i){let o=pe(i,"identifyRows",r.path,n);if(!Array.isArray(o))return null;let l=new Array(n.length).fill(-1),c=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||c.has(u)||(l[f]=u,c.add(u))}return l}function yt(e,t,n,r,i,o,l){t.forEach((c,s)=>{if(n===null){let f=r[s],u=f==null?"":String(f);e.text(c)!==u&&e.text(c,u)}else{let f=o(e,c,n,r[s],{depth:i.depth+1,path:[...i.path,s]},l);f&&f!==c&&(t[s]=f)}})}function gt(e,t,n,r){return n===null?e.text(t):P(e,t,n,r.onRowsRead?{...r,onRowsRead:void 0}:r)}function We(e,t,n){let r=e.children(t);for(let i=0;i<r.length;i++)if(e.sameNode(r[i],n))return i;return-1}function At(e,t,n,r){if(!r.templateAttr)return null;let i=/^\s*:scope\s*>\s*/.test(n),o=new RegExp(":not\\(\\["+r.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),l=n.replace(/^\s*:scope\s*>\s*/,"").replace(o,""),c=i?Tt(l):0,s=he(l),f=t;for(;f;){let u=e.find(f,l,{includeRulesTag:!1,templateAttr:null});for(let d of u)if(e.attr(d,r.templateAttr)!=null&&!(i&&!Et(e,t,d,c))&&!(s&&!e.matches(e.parent(d),s)))return d;f=e.parent(f)}return null}function Tt(e){let t=0,n=null,r=1;for(let i=0;i<e.length;i++){let o=e[i];if(o==="\\")i++;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===">")r++;else{if(t===0&&(o==="+"||o==="~"))return null;if(t===0&&/\s/.test(o)){if(!wt(e,i))return null;for(;i+1<e.length&&/\s/.test(e[i+1]);)i++}}}return r}function wt(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let r=t>0?e[t-1]:"",i=n<e.length?e[n]:"";return je(r)||je(i)}function je(e){return e===">"||e==="+"||e==="~"}function Et(e,t,n,r){if(r===null)return!0;let i=n;for(let s=0;s<r;s++)if(i=e.parent(i),!i)return!1;let o=e.prop(t,"tagName");if(!o)return!0;let l=e.prop(i,"tagName");if(!l||String(l).toLowerCase()!==String(o).toLowerCase())return!1;let c=new Set($e(e,i));return $e(e,t).every(s=>c.has(s))}function $e(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function Ot(e,t,n,r,i,o){let l=e.parent(r);if(l&&St(e,t,l)&&!De(e,l,o))return l;let c=he(n);if(!c)throw new N(i.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=(c===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,c,o)).filter(u=>!De(e,u,o));if(f.length===0)throw new N(i.path,`no container matching "${c}" inside this context to hold the new rows`);if(f.length>1)throw new N(i.path,`"${c}" matches ${f.length} containers inside this context, so the new rows have no single destination`);return f[0]}function St(e,t,n){let r=n;for(;r;){if(e.sameNode(r,t))return!0;r=e.parent(r)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(i=>e.sameNode(i,n))}var _e=["no-data","editor-ui"];function De(e,t,n){let r=t;for(;r;){if(n.templateAttr&&e.attr(r,n.templateAttr)!=null||_e.some(o=>e.attr(r,o)!=null))return!0;let i=e.attr(r,"clay");if(i&&i.split(/\s+/).some(o=>_e.includes(o)))return!0;r=e.parent(r)}return!1}function xt(e,t,n,r,i){let o=e.children(t),l=o.map(s=>e.identity(s)),c=!1;r.forEach((s,f)=>{let u=e.identity(s),d=n+f;if(l[d]===u)return;if(!i[f]){let w=l.indexOf(u);w!==-1&&(l.splice(w,1),o.splice(w,1))}let p=Math.min(d,o.length);p<o.length?e.insertBefore(o[p],s):o.length?c?e.insertAfter(o[o.length-1],s):(e.insertAt(t,s,d),c=!0):e.insertAt(t,s,0),l.splice(p,0,u),o.splice(p,0,s)})}function bt(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let r=new Map(e.children(n).map((o,l)=>[e.identity(o),l])),i=[];for(let o of t){let l=r.get(e.identity(o));if(l===void 0)return!1;i.push(l)}return i.sort((o,l)=>o-l),i[i.length-1]-i[0]===i.length-1}function Rt(e,t,n,r,i){let o=null,l=i;for(let c=0;c<t.length;c++){if(!n[c]){o=t[c];continue}let s=o?e.parent(o):r;if(!s)continue;let f=o?We(e,s,o)+1:l++;e.insertAt(s,t[c],f),o=t[c]}}function L(e,t,n,r,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.");let o=[];if(ye(n,r,[],o),o.length)throw new H(o);ne(e,t,n,r,{depth:0,path:[]},i)}function ne(e,t,n,r,i,o={}){if(i.depth>j)throw new k(i.path);if(r===void 0)return t;if(typeof n=="string")return Nt(e,t,n,r,i,o);if(Array.isArray(n)){let[l,c]=n;return me(e,t,l,c,r,i,ne,o),t}if(typeof n=="object"&&n!==null){for(let[l,c]of Object.entries(n)){let s=ne(e,t,c,r==null?r:r[l],{depth:i.depth+1,path:[...i.path,l]},o);s&&s!==t&&(t=s)}return t}return t}function Nt(e,t,n,r,i,o){if(n.endsWith("[]")){let s=n.slice(0,-2);return me(e,t,s,null,r,i,ne,o),t}if(n.startsWith("@"))return Be(e,t,n.slice(1),r);let l=b(n);if(l!==-1){let s=n.slice(0,l),f=n.slice(l+1),u=s?e.find(t,s,o):[t];return u.length===0||Be(e,u[0],f,r),t}if(n===".")return ve(e,t,r),t;let c=e.find(t,n,o);return c.length===0||ve(e,c[0],r),t}function ve(e,t,n){let r=n==null?"":String(n);e.text(t)!==r&&e.text(t,r)}function Ct(e,t,n,r){if(e.styleVar){e.styleVar(t,n,r);return}te(e,t,n,r)}function Be(e,t,n,r){if(C(n))return Ct(e,t,n,r==null?"":String(r).trim()),t;if(v.has(n)){let i=e.prop(t,n);if(i===r||i!=null&&r!=null&&String(i)===String(r))return t;throw new q(n)}if(n==="outerHTML"){let i=r==null?"":String(r);return e.replaceWith(t,i)}if(le.has(n)){let i=ce(n,r);return e.prop(t,n)!==i&&e.prop(t,n,i),t}if(r==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let i=String(r);e.attr(t,n)!==i&&e.attr(t,n,i)}return t}function ye(e,t,n,r){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((i,o)=>{typeof i=="object"&&i!==null&&r.push({path:z([...n,o]),expected:"scalar",got:U(i)})}):r.push({path:z(n),expected:"array",got:U(t)});return}t!==null&&typeof t=="object"&&r.push({path:z(n),expected:"scalar",got:U(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){r.push({path:z(n),expected:"array",got:U(t)});return}let i=e[1];t.forEach((o,l)=>ye(i,o,[...n,l],r));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){r.push({path:z(n),expected:"object",got:U(t)});return}for(let[i,o]of Object.entries(e))ye(o,t[i],[...n,i],r)}}}function U(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function z(e){return e.join(".")}function ge(e){try{return JSON.parse(e)}catch(t){throw new I(`Invalid strict JSON: ${t.message}`,t)}}function F(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(i){let o=[],l=0;for(;l<i.length;){let c=i[l];if(/\s/.test(c)){l++;continue}if("{}".includes(c)){o.push({type:c,value:c}),l++;continue}if(c==="["){let d=!1,p=l+1;for(;p<i.length&&/\s/.test(i[p]);)p++;if(p<i.length&&/[a-zA-Z_]/.test(i[p])&&(d=!0),!d){o.push({type:c,value:c}),l++;continue}}if(c==="]"){o.push({type:c,value:c}),l++;continue}if(c===":"){o.push({type:t.COLON,value:c}),l++;continue}if(c===","){o.push({type:t.COMMA,value:c}),l++;continue}if(c==='"'||c==="'"){let d=c,p=l+1;for(;p<i.length&&i[p]!==d;)i[p]==="\\"&&p++,p++;o.push({type:t.STRING,value:i.substring(l+1,p),quoted:!0,sourceQuote:d}),l=p+1;continue}let s=l,f;for(;s<i.length&&!/[{},]/.test(i[s]);)if(i[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"],p=!1;for(let w of d){let a=w.substring(1);if(i.substring(s+1,s+1+a.length)===a){p=!0,s+=a.length;break}}if(!p)break}else if(i[s]==="["){for(s++;s<i.length&&i[s]!=="]";){if(i[s]==='"'||i[s]==="'"){let d=i[s];for(s++;s<i.length&&i[s]!==d;)i[s]==="\\"&&s++,s++}s++}s<i.length&&i[s]==="]"&&s++}else s++;f=i.substring(l,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}),l=s}return o}function r(i){let o="";for(let l=0;l<i.length;l++){let c=i[l];if("{}".includes(c.type)||"[]".includes(c.type)){o+=c.value;continue}if(c.type===t.COLON){o+=c.value;continue}if(c.type===t.COMMA){let s=i[l+1];if(s&&(s.type==="}"||s.type==="]"))continue;o+=c.value;continue}if(c.type===t.STRING&&c.quoted){let s=c.value;c.sourceQuote==="'"&&(s=s.replace(/\\'/g,"'"),s=s.replace(/(\\*)"/g,(f,u)=>u.length%2===0?u+'\\"':f)),o+=`"${s}"`;continue}if(c.type===t.NUMBER||c.type===t.BOOLEAN){o+=c.value;continue}if(c.type===t.SELECTOR||c.type===t.IDENTIFIER){o+=`"${c.value}"`;continue}o+=`"${c.value}"`}return o}try{let i=n(e),o=r(i);return JSON.parse(o)}catch(i){throw new I("Invalid extraction rules syntax: "+i.message,i)}}var Pt="1",He=/^[a-zA-Z0-9_-]+$/;function _(e,t,n){let r;if(n===void 0)r="script[data-rules-name]";else{if(typeof n!="string"||!He.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${He})`);r=`script[data-rules-name~="${n}"]`}let i=e.find(t,r,{includeRulesTag:!0});if(i.length===0)return null;n!==void 0&&i.length>1&&console.warn(`hyper-html-api: ${i.length} rules tags match data-rules-name~="${n}"; using the first.`);let o=i[0],l=e.attr(o,"data-rules-version");if(l!==Pt)throw new B(l);return{rules:F(e.text(o)),tagNode:o}}var re=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"]})}),Mt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),qe=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function K(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 Ae(e,t){if(K(e,t))return!0;for(let[n,r]of Object.entries(Mt))if(r.includes(t)&&K(e,n))return!0;return!1}function J(e){let t=re[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function kt(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let r=re[t];if(!r)throw new Error(`Unknown region capability: ${t}`);if(r.tokens.some(i=>Ae(n,i))||r.bundles.some(i=>K(n,i)))return n;n=n.parentElement}return null}function Ve(e,t){return!!kt(e,t)}var ie=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",...qe],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"]})}),Lt=new Set(["textContent","innerText"]);function Ue(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 It=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function ze(e,t,n=ie){if(!It.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let r=String(e).toLowerCase();if(n.refusedAttributePrefixes.some(i=>r.startsWith(i)))return`attribute "${r}" can run script`;if(n.refusedAttributes.includes(r))return`attribute "${r}" is not content`;if(n.urlAttributes.includes(r)&&t!=null){let i=r==="srcset"?String(t).split(",").map(o=>o.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let o of i){let l=Ue(o);if(l&&n.refusedSchemes.includes(l))return`"${l}:" URLs are not allowed in "${r}"`}}return null}function Te(e,t){let n=e.prop(t,"tagName");return n?String(n).toLowerCase():""}function jt(e,t){let n=Te(e,t)||"node",r=e.attr(t,"id");return r?`<${n}#${r}>`:`<${n}>`}function $t(e,t,n){let r=t;for(;r;){let i=Te(e,r);if(i&&n.refusedTargets.includes(i))return i;r=e.parent(r)}return null}function Fe(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function _t(e,t){return Te(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:Fe(e,t)}function Dt(e){if(/[\u0000-\u001f\u007f]/.test(e))return"control characters are not allowed in a custom property value";let t=[],n=null;for(let r=0;r<e.length;r++){let i=e[r];if(n){i===n&&(n=null);continue}if(i==='"'||i==="'")n=i;else{if(i==="/"&&e[r+1]==="*")return"comments are not allowed in a custom property value";if(i==="(")t.push(")");else if(i==="[")t.push("]");else if((i===")"||i==="]")&&t.pop()!==i)return`"${i}" 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 Ke(e,t=ie){let n=t.customPropertyValues,r=String(e);if(r.length>n.maxLength)return`custom property values are limited to ${n.maxLength} characters`;let i=n.refusedCharacters.find(s=>r.includes(s));if(i)return`${JSON.stringify(i)} is not allowed in a custom property value`;let o=Dt(r);if(o)return o;let l=r.toLowerCase(),c=n.refusedFunctions.find(s=>new RegExp(`(^|[^a-z0-9_-])${s.replace(/[-]/g,"\\-")}\\s*\\(`).test(l));return c?`"${c}()" is not allowed in a custom property value`:null}function oe(e,t=ie){let n=[],r=(s,f)=>(n.push({target:jt(e,s),reason:f}),!1),i=s=>{let f=$t(e,s,t);return f?r(s,`inside <${f}>, which is not content`):!0},o=s=>i(s)?Fe(e,s)?r(s,"a text write here would delete the data rules tag"):!0:!1,l=(s,f,u)=>{if(!i(s))return!1;let d=ze(f,u,t);return d?r(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);l(s,f,u)&&e.attr(s,f,u)},removeAttr(s,f){l(s,f,null)&&e.removeAttr(s,f)},styleVar(s,f,u){if(($(e.attr(s,"style"),f)??"")!==u&&i(s)){if(!C(f))return r(s,`"${f}" is not a custom property`);if(u!==""){let d=Ke(u,t);if(d)return r(s,d)}te(e,s,f,u)}},prop(s,f,u){if(u===void 0)return e.prop(s,f);if(t.refusedRuleForms.includes(f))return r(s,`"@${f}" writes HTML, only text is allowed`);if(Lt.has(f)){o(s)&&e.prop(s,f,u);return}l(s,f==="className"?"class":f,u)&&e.prop(s,f,u)},remove(s){if(_t(e,s)){r(s,"removing this would delete the data rules tag");return}e.remove(s)},replaceWith(s,f){return f===e.prop(s,"outerHTML")||r(s,'"@outerHTML" writes HTML, only text is allowed'),s},refusals:n,assertClean(){if(n.length)throw new V(n.slice())}}}function X(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Je(e){return e.reduce((t,n)=>typeof n=="number"?`${t}[${n}]`:t?`${t}.${n}`:n,"")}function we(e,t,n,r,i={}){let o=[],l=[];function c(f,u,d){if(Array.isArray(f)){let[,p]=f;if(!Array.isArray(u)||!X(p))return;u.forEach((w,a)=>c(p,w,[...d,a]));return}if(!(!X(f)||!X(u)))for(let p of Object.keys(u))Object.prototype.hasOwnProperty.call(f,p)?c(f[p],u[p],[...d,p]):o.push(Je([...d,p]))}function s(f,u,d,p){if(d!==void 0){if(typeof u=="string"){if(u.endsWith("[]")||u==="."||u.startsWith("@"))return;let w=b(u),a=w===-1?u:u.slice(0,w);if(!a)return;e.find(f,a,i).length===0&&l.push({path:Je(p),selector:a});return}if(!Array.isArray(u)&&X(u)&&X(d))for(let[w,a]of Object.entries(u))s(f,a,d[w],[...p,w])}}return c(n,r,[]),s(t,n,r,[]),{unknownKeys:o,unmatched:l}}function Ee(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let r=t&&t.ownerDocument?t.ownerDocument:t;return _(e,r,n)}return null}var vt=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Bt(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 Xe(e,t,n,r){if(r)return!!e.closest?.(t);let i=e;for(;i?.nodeType===1;){if(i.matches(t))return!0;if(i===n)break;i=i.parentElement}return!1}function Ye(e,t,n,r,i,o){return(o?Ve(e,t):Xe(e,n,i,!1))||!!(r&&(o&&e!==i?e.matches(r):Xe(e,r,i,o)))}function Ht(e,t){let n=re[t];return n.tokens.some(r=>Ae(e,r))||n.bundles.some(r=>K(e,r))}var qt=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function Ge(e,t,n,r){if(e.nodeType===1&&r(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let i=e,o=t;if(e.nodeType===1){if(qt.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);i=e.content,o=t.content,n.cloneToLive.set(o,i),n.liveToClone.set(i,o)}}else if(e.nodeType!==11)return;let l=o.firstChild;for(let c=i.firstChild;c&&l;c=c.nextSibling)Ge(c,l,n,r),l=l.nextSibling}function Y(e,{capability:t="data",exclude:n=null,inherit:r=!0,provenance:i=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 l=o.implementation.createHTMLDocument(""),c=i||new WeakMap,s=new WeakMap,f=e.nodeType===9?e.documentElement:e;n&&l.documentElement.matches(n);let u=J(t),d=r?a=>Ht(a,t)||!!(n&&a.matches(n)):a=>Ye(a,t,u,n,f,!1),p=null;if(f.nodeType!==1||!Ye(f,t,u,n,f,r)){p=l.importNode(f,!0);let a={cloneToLive:c,liveToClone:s,dropped:[],controls:[]};Ge(f,p,a,d);for(let m of a.dropped)m.remove();for(let m=0;m<a.controls.length;m+=2)Bt(a.controls[m],a.controls[m+1])}e.nodeType===9&&p&&(l.replaceChild(p,l.documentElement),s.set(e,l),c.set(l,e));let w=a=>{if(vt.test(a))throw new Error(`Filtered content queries do not support stateful selector: ${a}`)};return{root:p,document:l,capability:t,selector:J(t),cloneToLive:c,liveToClone:s,original(a){return c.get(a)||null},cloneOf(a){return s.get(a)||null},query(a,m=p){return w(a),Array.from(m.querySelectorAll(a),g=>c.get(g)||g)},text(a=p){return(a===p?p:s.get(a))?.textContent||""},html(a=p){return(a===p?p:s.get(a))?.innerHTML??""},clone(a=p){let m=a===p?p:s.get(a);return m?l.importNode(m,!0):null}}}function Qe(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Vt(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function Ze(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 et(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function tt(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 r=n.type;r!=="file"&&r!=="checkbox"&&r!=="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 r=Vt(e);if(!r||!r.querySelectorAll)return[];let i=Array.from(r.querySelectorAll(t));n.includeRulesTag||(i=i.filter(c=>!Qe(c)));let o=[];n.skip&&o.push(n.skip);let l=n.templateAttr===null?null:n.templateAttr||"cms-template";if(l&&o.push("["+l+"]"),o.length){let c=o.join(", ");i=i.filter(s=>!s.closest||!s.closest(c))}return i},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,et(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),Ze(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),Ze(e,t,null)},prop(e,t,n){if(n===void 0){let r=e?e[t]:void 0;return r!==void 0?r:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return tt(t),t},insertAt(e,t,n){let r=e.children[n]||null;e.insertBefore(t,r)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let r=e.ownerDocument.createElement("template");r.innerHTML=t;let i=r.content.firstElementChild;if(!i)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(i,e),i},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(r=>{r.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function M(e,t={}){if(t.exclude===null)return S;let n=[J("data"),t.exclude].filter(Boolean).join(", "),r=e.nodeType===9?e:e.ownerDocument||e,i=e.nodeType===9?e.documentElement:e;if(!t._write&&!i?.matches?.(n)&&!i?.querySelector?.(n)&&!r?.querySelector?.(n))return S;let o=e.nodeType===9||!e.isConnected?e:e.ownerDocument,l=e.nodeType===9?e:e.ownerDocument,c=null,s=()=>c||(c=Y(o,{capability:"data",exclude:t.exclude||null})),f=a=>{let m=s();return a===e?m.cloneOf(e):m.cloneOf(a)||a},u=a=>c?.original(a)||a,d=(a,m)=>{s().liveToClone.set(a,m),s().cloneToLive.set(m,a);let g=a.childNodes||[],h=m.childNodes||[];for(let y=0;y<Math.min(g.length,h.length);y++)d(g[y],h[y])},p=(a,m,g,h)=>{let y=Array.from(a.childNodes).filter(E=>c.cloneOf(E)),T=y[0];for(;T&&y.includes(T);)T=T.nextSibling;for(let E of y)E.remove();if(g==="innerHTML"){let E=l.createElement("template");E.innerHTML=h;for(let W of Array.from(E.content.childNodes))a.insertBefore(W,T||null)}else a.insertBefore(l.createTextNode(h),T||null),et(a,h);let x=Y(a,{capability:"data",exclude:t.exclude||null});m.replaceChildren(...Array.from(x.root?.childNodes||[]));let O=E=>{let W=x.original(E);W&&(c.liveToClone.set(W,E),c.cloneToLive.set(E,W));for(let ot of Array.from(E.childNodes||[]))O(ot)};for(let E of Array.from(m.childNodes))O(E)},w={...S,find(a,m,g={}){let h=f(a);if(!h?.querySelectorAll)return[];let y=s().query(m,h);g.includeRulesTag||(y=y.filter(x=>!Qe(x)));let A=[];g.skip&&A.push(g.skip);let T=g.templateAttr===null?null:g.templateAttr||"cms-template";if(T&&A.push(`[${T}]`),A.length){let x=A.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)&&!c){S.text(g,m);return}let h=s().cloneOf(g);h?p(g,h,"textContent",m):S.text(g,m)},attr(a,m,g){let h=u(a);if(g===void 0)return S.attr(h,m);S.attr(h,m,g);let y=c?.cloneOf(h);y&&(S.attr(y,m,g),Y(h,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),c.liveToClone.delete(h),c.cloneToLive.delete(y)))},removeAttr(a,m){let g=u(a);S.removeAttr(g,m);let h=c?.cloneOf(g);h&&S.removeAttr(h,m)},prop(a,m,g){let h=u(a);if(g===void 0)return m==="innerHTML"||m==="outerHTML"||m==="textContent"||m==="innerText"?S.prop(f(h),m):S.prop(h,m);let y=m==="innerHTML"||m==="textContent"||m==="innerText",A=y?s().cloneOf(h):c?.cloneOf(h);A&&y?p(h,A,m,g):(S.prop(h,m,g),A&&S.prop(A,m,g))},clone(a){let m=f(a);if(m===a)return S.clone(a);let g=l.importNode(m,!0);return tt(g),g},insertAt(a,m,g){let h=u(a),A=w.children(h)[g]||(()=>{for(let O=h.children.length-1;O>=0;O--){let E=h.children[O];if(s().cloneOf(E))return E.nextElementSibling}return h.firstElementChild})(),T=u(m);h.insertBefore(T,A||null);let x=s().cloneOf(h);if(x){let O=s().cloneOf(T);O||(O=l.importNode(T,!0),d(T,O));let E=Array.from(x.children);x.insertBefore(O,E[g]||null)}},insertBefore(a,m){let g=u(a),h=u(m);g.parentNode.insertBefore(h,g);let y=s().cloneOf(g.parentNode);if(y){let A=s().cloneOf(h);A||(A=l.importNode(h,!0),d(h,A));let T=s().cloneOf(g);T?T.before(A):y.appendChild(A)}},insertAfter(a,m){let g=u(a),h=u(m);g.parentNode.insertBefore(h,g.nextSibling);let y=s().cloneOf(g.parentNode);if(y){let A=s().cloneOf(h);A||(A=l.importNode(h,!0),d(h,A));let T=s().cloneOf(g);T?T.after(A):y.appendChild(A)}},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),h=s().cloneOf(g),y=S.replaceWith(g,m);if(h){let A=Y(y,{capability:"data",exclude:t.exclude||null});if(!A.root)h.remove();else{h.replaceWith(A.root);let T=x=>{let O=A.original(x);O&&(c.liveToClone.set(O,x),c.cloneToLive.set(x,O));for(let E of Array.from(x.childNodes||[]))T(E)};T(A.root)}}return y}};return w}var G=S;var se={extract:(e,t,n={})=>P(M(e,n),e,t,n),apply:(e,t,n,r={})=>L(M(e,{...r,_write:!0}),e,t,n,r),findRulesIn:(e,t)=>_(G,e,t),findRules:(e,t)=>Ee(G,e,t),bind:(e,t,n={})=>{let r=Ee(G,e,t);if(!r){let i=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${i}`)}return{...r,get:()=>P(M(e,n),e,r.rules,n),set:i=>L(M(e,{...n,_write:!0}),e,r.rules,i,n)}},parseStrict:ge,parseRelaxed:F,ruleAttrIndex:b,splitRule:ae,errors:R,DOM_PROPERTIES:Z},Oe=e=>!!e&&typeof e.nodeType=="number";function nt(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=_(G,t,"api");if(!n)throw new R.NoRulesTag("api");return n.rules}function Ut(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 zt(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 Ft(e,t){let n=[];for(;t!==e;){let r=t.parentNode;n.push(Array.prototype.indexOf.call(r.childNodes,t)),t=r}return n.reverse()}function Kt(e,t){return t.reduce((n,r)=>n.childNodes[r],e)}function D(e,t){let n=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&n.unshift(e),n}function Jt(e,t){let n=D(e,"option"),r=D(t,"option");n.forEach((s,f)=>r[f].selected=s.selected);let i=D(e,"input"),o=D(t,"input");i.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 l=D(e,"textarea"),c=D(t,"textarea");l.forEach((s,f)=>c[f].value=s.value)}function Se(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let n=e.startsWith("@")?0:b(e);if(n===-1)return;let r=e.slice(n+1);if(v.has(r))throw new R.RuleTargetReadOnly(r);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(n=>Se(e[1],n));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[n,r]of Object.entries(e))Se(r,t[n])}}function Xt(e,t,n){let r={templateAttr:"cms-template"},i=Ut(e),o=Ft(i,e),l=zt(i);Jt(i,l);let c=Kt(l,o),s=M(l,{...r,_write:!0}),f=we(s,c,t,n,r);if(f.unknownKeys.length||f.unmatched.length)throw new R.WriteRejected(f.unknownKeys,f.unmatched);let u=oe(s);L(u,c,t,n,r),u.assertClean(),Se(t,n);let d=oe(M(i,{...r,_write:!0}));L(d,e,t,n,r),d.assertClean()}function Yt(e){if(!(e instanceof Error))return e;let t=e.name||"Error";try{e.code=t}catch{Object.defineProperty(e,"code",{value:t,configurable:!0,enumerable:!0})}return e instanceof 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 rt(e,t){let n=Oe(e)?e:document,r=Oe(e)?t:e;return r===void 0?P(M(n),n,nt(n)):se.bind(n,r).get()}function it(e,t,n){try{if(!Oe(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let r=n===void 0?nt(e):se.bind(e,n).rules;Xt(e,r,t)}catch(r){throw Yt(r)}return e}var Gt={engine:se,extractData:rt,applyData:it},fr=Gt;export{it as applyData,fr as default,se as engine,rt as extractData};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// GENERATED — do not edit. Vendored from
|
|
2
|
+
// hyper-html-api/src/upgrade.js via hyper-html-api
|
|
3
|
+
// `npm run copy-to-clayjs`. Edit the hyper-html-api source and re-run.
|
|
4
|
+
var ut=Object.defineProperty;var at=(e,t)=>{for(var n in t)ut(e,n,{get:t[n],enumerable:!0})};var G=["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"],Z=new Set(G),fe=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Q=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),Ce=new Set(["checked","selected","disabled","readOnly","paused"]);function ue(e,t){return t==null?Ce.has(e)?!1:"":Ce.has(e)?t==="false"?!1:!!t:t}var ne={};at(ne,{EmptyListInsert:()=>M,MAX_RULE_DEPTH:()=>D,MaxRuleDepthExceeded:()=>k,NoRulesTag:()=>ae,RuleTargetReadOnly:()=>H,RulesParseError:()=>_,ShapeMismatch:()=>v,UnknownRulesVersion:()=>P,WriteNotRoundTripped:()=>te,WriteRefused:()=>ee,WriteRejected:()=>de});var _=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},P=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},D=20,k=class extends Error{constructor(t){super(`rule depth exceeded ${D} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},v=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},M=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}},H=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},ee=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function dt(e){return e.reduce((n,o)=>typeof o=="number"?`${n}[${o}]`:n?`${n}.${o}`:String(o),"")||"(root)"}var te=class extends Error{constructor(t){super(`write did not round-trip at "${dt(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},ae=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},de=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}};function b(e){let t=0,n=null,o=-1;for(let r=0;r<e.length;r++){let i=e[r];i==="\\"?r++:n?i===n&&(n=null):i==='"'||i==="'"?n=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:i==="@"&&t===0&&(o=r)}return o}function pe(e){let t=b(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function he(e){let t=0,n=null,o=-1,r=!1;for(let i=0;i<e.length;i++){let s=e[i];s==="\\"?i++:n?s===n&&(n=null):s==='"'||s==="'"?n=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:t===0&&s===">"?o=i:t===0&&s===","&&(r=!0)}return r||o===-1||!pt(e,o+1)?null:e.slice(0,o).trim()||null}function pt(e,t){let n=t,o=e.replace(/\s+$/,"").length;for(;n<o&&/\s/.test(e[n]);)n++;let r=0,i=null;for(;n<o;n++){let s=e[n];if(s==="\\")n++;else if(i)s===i&&(i=null);else if(s==='"'||s==="'")i=s;else if(s==="["||s==="(")r++;else if(s==="]"||s===")")r>0&&r--;else if(r===0&&(s==="+"||s==="~"||/\s/.test(s)))return!1}return!0}var ht=/^--[A-Za-z0-9_-]+$/;function I(e){return typeof e=="string"&&ht.test(e)}function Me(e){let t=[],n=[],o=null,r=0;for(let i=0;i<e.length;i++){let s=e[i];if(o){s==="\\"?i++:s===o&&(o=null);continue}if(s==="/"&&e[i+1]==="*"){let c=e.indexOf("*/",i+2);i=c===-1?e.length:c+1;continue}s==='"'||s==="'"?o=s:s==="("?n.push(")"):s==="["?n.push("]"):s==="{"?n.push("}"):(s===")"||s==="]"||s==="}")&&n[n.length-1]===s?n.pop():s===";"&&n.length===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t}function mt(e){let t="",n=null;for(let o=0;o<e.length;o++){let r=e[o];if(n){t+=r,r==="\\"&&o+1<e.length?t+=e[++o]:r===n&&(n=null);continue}if(r==="/"&&e[o+1]==="*"){let i=e.indexOf("*/",o+2);o=i===-1?e.length:i+1,t+=" ";continue}(r==='"'||r==="'")&&(n=r),t+=r}return t}function Pe(e){e=mt(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),o=e.slice(t+1).trim(),r=/!\s*important\s*$/i.exec(o);return r&&(o=o.slice(0,r.index).trim()),{name:n,value:o,important:!!r}}function V(e,t){if(e==null)return null;let n=null;for(let o of Me(String(e))){let r=Pe(o);!r||r.name!==t||(!n||r.important||!n.important)&&(n=r)}return n?n.value:null}function ke(e,t,n){let o=e==null?"":String(e),r=n==null||n==="",i=Me(o),s=i.map(Pe),c=s.some(h=>h&&h.name===t&&h.important),l=[],u=!1;i.forEach((h,m)=>{let T=s[m];if(!T||T.name!==t){l.push(h);return}if(r||u)return;let f=/^\s*/.exec(h)[0];l.push(`${f}${t}: ${n}${c?" !important":""}`),u=!0});let d=l.join(";");if(!r&&!u){let h=d.trimEnd();d=h===""?`${t}: ${n}`:`${h}${h.endsWith(";")?" ":"; "}${t}: ${n}`}return d.trim()===""?null:d}function me(e,t,n,o){let r=e.attr(t,"style");if((V(r,n)??"")===o)return;let i=ke(r,n,o);i==null?e.removeAttr(t,"style"):e.attr(t,"style",i)}function C(e,t,n,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return ye(e,t,n,{depth:0,path:[]},o)}function ye(e,t,n,o,r){if(o.depth>D)throw new k(o.path);if(typeof n=="string")return yt(e,t,n,o,r);if(Array.isArray(n)){let[i,s]=n,c=e.find(t,i,r);return Le(r,o,c),c.map((l,u)=>ye(e,l,s,{depth:o.depth+1,path:[...o.path,u]},r))}if(typeof n=="object"&&n!==null){let i={};for(let[s,c]of Object.entries(n))i[s]=ye(e,t,c,{depth:o.depth+1,path:[...o.path,s]},r);return i}return null}function yt(e,t,n,o,r){if(n.endsWith("[]")){let c=n.slice(0,-2),l=e.find(t,c,r);return Le(r,o,l),l.map(u=>e.text(u))}if(n.startsWith("@"))return Ie(e,t,n.slice(1));let i=b(n);if(i!==-1){let c=n.slice(0,i),l=n.slice(i+1),u=c?e.find(t,c,r):[t];return u.length===0?null:Ie(e,u[0],l)}if(n===".")return e.text(t);let s=e.find(t,n,r);return s.length===0?null:e.text(s[0])}function Le(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function Ie(e,t,n){if(I(n))return V(e.attr(t,"style"),n);if(Z.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o??null}function _e(e,t,n,o){let r=e.length,i=t.length,s=new Array(r).fill(-1);if(o){let a=new Set;for(let y=0;y<r;y++){let w=o[y];!(w>=0&&w<i)||a.has(w)||(s[y]=w,a.add(w))}}if(r===0||i===0)return s;let c=e.map(a=>je(a,n)),l=t.map(a=>je(a,n)),u=new Array(i).fill(!1);for(let a of s)a>=0&&(u[a]=!0);let d=new Map;l.forEach((a,y)=>{u[y]||d.set(a,d.has(a)?-1:y)});let h=new Map;c.forEach((a,y)=>{s[y]>=0||h.set(a,(h.get(a)||0)+1)}),c.forEach((a,y)=>{if(s[y]>=0||h.get(a)!==1)return;let w=d.get(a);w===void 0||w===-1||u[w]||(s[y]=w,u[w]=!0)});let m=[];for(let a=0;a<r;a++)s[a]<0&&m.push(a);let T=[];for(let a=0;a<i;a++)u[a]||T.push(a);if(m.length===0||T.length===0)return s;let f=r*i+1,p=gt(e,t,n),g=(a,y)=>p(a,y)*f+Math.abs(a-y);for(let[a,y]of wt(m,T,g))s[a]=y;return s}var De=e=>typeof e=="object"&&e!==null;function je(e,t){if(!De(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(o=>{let r=JSON.stringify(e?.[o]);return r===void 0?" undef":r}))}function gt(e,t,n){if(!De(n))return(c,l)=>e[c]===t[l]?0:1;let o=Object.keys(n),r=c=>o.map(l=>JSON.stringify(c?.[l])),i=e.map(r),s=t.map(r);return(c,l)=>{let u=i[c],d=s[l],h=0;for(let m=0;m<o.length;m++)u[m]!==d[m]&&h++;return h}}function wt(e,t,n){return e.length<=t.length?$e(e,t,n,!1):$e(t,e,(o,r)=>n(r,o),!0)}function $e(e,t,n,o){let r=e.length,i=t.length,s=[];for(let h=0;h<=r;h++)s.push(new Float64Array(i+1).fill(1/0));let c=[];for(let h=0;h<=r;h++)c.push(new Uint8Array(i+1));for(let h=0;h<=i;h++)s[r][h]=0;for(let h=r-1;h>=0;h--)for(let m=i-1;m>=0;m--){let T=n(e[h],t[m])+s[h+1][m+1],f=s[h][m+1];T<=f?(s[h][m]=T,c[h][m]=1):s[h][m]=f}let l=[],u=0,d=0;for(;u<r&&d<i;)c[u][d]&&(l.push(o?[t[d],e[u]]:[e[u],t[d]]),u++),d++;return l}function we(e,t,n,o,r,i,s,c={}){let l=e.find(t,n,c);if(r.length===0){l.forEach(A=>e.remove(A)),ge(c,"onRowsApplied",i.path,[]);return}let u=r.length>l.length,d=l[0]||null;if(u&&!d&&(d=Ot(e,t,n,c),!d))throw new M(i.path);let h=l.map(A=>xt(e,A,o,c)),m=null;if(u&&d){m=e.clone(d),c.templateAttr&&e.removeAttr(m,c.templateAttr);let A=e.stripIds(m);A>0&&console.warn(`[hyper-html-api] stripped ${A} id attribute(s) from cloned template at "${i.path.join(".")||"(root)"}"`)}let T=_e(r,h,o,At(e,l,r,i,c)),f=l.length>0?e.parent(l[0]):Rt(e,t,n,d,i,c),p=l.length>0?Ve(e,f,l[0]):0,g=Mt(e,l),a=new Set,y=[],w=r.map((A,S)=>{let O=T[S];if(O>=0)return a.add(O),y.push(!1),l[O];y.push(!0);let x=e.clone(m);return e.stripIds(x),x});l.forEach((A,S)=>{a.has(S)||e.remove(A)}),g?Ct(e,f,p,w,y):Pt(e,w,y,f,p),Tt(e,w,o,r,i,s,c),ge(c,"onRowsApplied",i.path,w)}function ge(e,t,n,o){if(typeof e[t]=="function")try{return e[t](n.slice(),o)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function At(e,t,n,o,r){let i=ge(r,"identifyRows",o.path,n);if(!Array.isArray(i))return null;let s=new Array(n.length).fill(-1),c=new Set,l=new Map(t.map((u,d)=>[e.identity(u),d]));for(let u=0;u<n.length;u++){if(!i[u])continue;let d=l.get(e.identity(i[u]));d===void 0||c.has(d)||(s[u]=d,c.add(d))}return s}function Tt(e,t,n,o,r,i,s){t.forEach((c,l)=>{if(n===null){let u=o[l],d=u==null?"":String(u);e.text(c)!==d&&e.text(c,d)}else{let u=i(e,c,n,o[l],{depth:r.depth+1,path:[...r.path,l]},s);u&&u!==c&&(t[l]=u)}})}function xt(e,t,n,o){return n===null?e.text(t):C(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function Ve(e,t,n){let o=e.children(t);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],n))return r;return-1}function Ot(e,t,n,o){if(!o.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),i=new RegExp(":not\\(\\["+o.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),s=n.replace(/^\s*:scope\s*>\s*/,"").replace(i,""),c=r?Et(s):0,l=he(s),u=t;for(;u;){let d=e.find(u,s,{includeRulesTag:!1,templateAttr:null});for(let h of d)if(e.attr(h,o.templateAttr)!=null&&!(r&&!bt(e,t,h,c))&&!(l&&!e.matches(e.parent(h),l)))return h;u=e.parent(u)}return null}function Et(e){let t=0,n=null,o=1;for(let r=0;r<e.length;r++){let i=e[r];if(i==="\\")r++;else if(n)i===n&&(n=null);else if(i==='"'||i==="'")n=i;else if(i==="["||i==="(")t++;else if(i==="]"||i===")")t>0&&t--;else if(t===0&&i===">")o++;else{if(t===0&&(i==="+"||i==="~"))return null;if(t===0&&/\s/.test(i)){if(!St(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return o}function St(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let o=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return We(o)||We(r)}function We(e){return e===">"||e==="+"||e==="~"}function bt(e,t,n,o){if(o===null)return!0;let r=n;for(let l=0;l<o;l++)if(r=e.parent(r),!r)return!1;let i=e.prop(t,"tagName");if(!i)return!0;let s=e.prop(r,"tagName");if(!s||String(s).toLowerCase()!==String(i).toLowerCase())return!1;let c=new Set(Ue(e,r));return Ue(e,t).every(l=>c.has(l))}function Ue(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function Rt(e,t,n,o,r,i){let s=e.parent(o);if(s&&Nt(e,t,s)&&!He(e,s,i))return s;let c=he(n);if(!c)throw new M(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 u=(c===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,c,i)).filter(d=>!He(e,d,i));if(u.length===0)throw new M(r.path,`no container matching "${c}" inside this context to hold the new rows`);if(u.length>1)throw new M(r.path,`"${c}" matches ${u.length} containers inside this context, so the new rows have no single destination`);return u[0]}function Nt(e,t,n){let o=n;for(;o;){if(e.sameNode(o,t))return!0;o=e.parent(o)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(r=>e.sameNode(r,n))}var ve=["no-data","editor-ui"];function He(e,t,n){let o=t;for(;o;){if(n.templateAttr&&e.attr(o,n.templateAttr)!=null||ve.some(i=>e.attr(o,i)!=null))return!0;let r=e.attr(o,"clay");if(r&&r.split(/\s+/).some(i=>ve.includes(i)))return!0;o=e.parent(o)}return!1}function Ct(e,t,n,o,r){let i=e.children(t),s=i.map(l=>e.identity(l)),c=!1;o.forEach((l,u)=>{let d=e.identity(l),h=n+u;if(s[h]===d)return;if(!r[u]){let T=s.indexOf(d);T!==-1&&(s.splice(T,1),i.splice(T,1))}let m=Math.min(h,i.length);m<i.length?e.insertBefore(i[m],l):i.length?c?e.insertAfter(i[i.length-1],l):(e.insertAt(t,l,h),c=!0):e.insertAt(t,l,0),s.splice(m,0,d),i.splice(m,0,l)})}function Mt(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=new Map(e.children(n).map((i,s)=>[e.identity(i),s])),r=[];for(let i of t){let s=o.get(e.identity(i));if(s===void 0)return!1;r.push(s)}return r.sort((i,s)=>i-s),r[r.length-1]-r[0]===r.length-1}function Pt(e,t,n,o,r){let i=null,s=r;for(let c=0;c<t.length;c++){if(!n[c]){i=t[c];continue}let l=i?e.parent(i):o;if(!l)continue;let u=i?Ve(e,l,i)+1:s++;e.insertAt(l,t[c],u),i=t[c]}}function L(e,t,n,o,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.");let i=[];if(Ae(n,o,[],i),i.length)throw new v(i);re(e,t,n,o,{depth:0,path:[]},r)}function re(e,t,n,o,r,i={}){if(r.depth>D)throw new k(r.path);if(o===void 0)return t;if(typeof n=="string")return kt(e,t,n,o,r,i);if(Array.isArray(n)){let[s,c]=n;return we(e,t,s,c,o,r,re,i),t}if(typeof n=="object"&&n!==null){for(let[s,c]of Object.entries(n)){let l=re(e,t,c,o==null?o:o[s],{depth:r.depth+1,path:[...r.path,s]},i);l&&l!==t&&(t=l)}return t}return t}function kt(e,t,n,o,r,i){if(n.endsWith("[]")){let l=n.slice(0,-2);return we(e,t,l,null,o,r,re,i),t}if(n.startsWith("@"))return Be(e,t,n.slice(1),o);let s=b(n);if(s!==-1){let l=n.slice(0,s),u=n.slice(s+1),d=l?e.find(t,l,i):[t];return d.length===0||Be(e,d[0],u,o),t}if(n===".")return qe(e,t,o),t;let c=e.find(t,n,i);return c.length===0||qe(e,c[0],o),t}function qe(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function It(e,t,n,o){if(e.styleVar){e.styleVar(t,n,o);return}me(e,t,n,o)}function Be(e,t,n,o){if(I(n))return It(e,t,n,o==null?"":String(o).trim()),t;if(Q.has(n)){let r=e.prop(t,n);if(r===o||r!=null&&o!=null&&String(r)===String(o))return t;throw new H(n)}if(n==="outerHTML"){let r=o==null?"":String(o);return e.replaceWith(t,r)}if(fe.has(n)){let r=ue(n,o);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(o==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(o);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function Ae(e,t,n,o){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,i)=>{typeof r=="object"&&r!==null&&o.push({path:B([...n,i]),expected:"scalar",got:q(r)})}):o.push({path:B(n),expected:"array",got:q(t)});return}t!==null&&typeof t=="object"&&o.push({path:B(n),expected:"scalar",got:q(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:B(n),expected:"array",got:q(t)});return}let r=e[1];t.forEach((i,s)=>Ae(r,i,[...n,s],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:B(n),expected:"object",got:q(t)});return}for(let[r,i]of Object.entries(e))Ae(i,t[r],[...n,r],o)}}}function q(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function B(e){return e.join(".")}function Te(e){try{return JSON.parse(e)}catch(t){throw new _(`Invalid strict JSON: ${t.message}`,t)}}function j(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 i=[],s=0;for(;s<r.length;){let c=r[s];if(/\s/.test(c)){s++;continue}if("{}".includes(c)){i.push({type:c,value:c}),s++;continue}if(c==="["){let h=!1,m=s+1;for(;m<r.length&&/\s/.test(r[m]);)m++;if(m<r.length&&/[a-zA-Z_]/.test(r[m])&&(h=!0),!h){i.push({type:c,value:c}),s++;continue}}if(c==="]"){i.push({type:c,value:c}),s++;continue}if(c===":"){i.push({type:t.COLON,value:c}),s++;continue}if(c===","){i.push({type:t.COMMA,value:c}),s++;continue}if(c==='"'||c==="'"){let h=c,m=s+1;for(;m<r.length&&r[m]!==h;)r[m]==="\\"&&m++,m++;i.push({type:t.STRING,value:r.substring(s+1,m),quoted:!0,sourceQuote:h}),s=m+1;continue}let l=s,u;for(;l<r.length&&!/[{},]/.test(r[l]);)if(r[l]===":"){let h=[":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"],m=!1;for(let T of h){let f=T.substring(1);if(r.substring(l+1,l+1+f.length)===f){m=!0,l+=f.length;break}}if(!m)break}else if(r[l]==="["){for(l++;l<r.length&&r[l]!=="]";){if(r[l]==='"'||r[l]==="'"){let h=r[l];for(l++;l<r.length&&r[l]!==h;)r[l]==="\\"&&l++,l++}l++}l<r.length&&r[l]==="]"&&l++}else l++;u=r.substring(s,l);let d=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?d=t.NUMBER:u==="true"||u==="false"||u==="null"?d=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(d=t.SELECTOR),i.push({type:d,value:u,quoted:!1}),s=l}return i}function o(r){let i="";for(let s=0;s<r.length;s++){let c=r[s];if("{}".includes(c.type)||"[]".includes(c.type)){i+=c.value;continue}if(c.type===t.COLON){i+=c.value;continue}if(c.type===t.COMMA){let l=r[s+1];if(l&&(l.type==="}"||l.type==="]"))continue;i+=c.value;continue}if(c.type===t.STRING&&c.quoted){let l=c.value;c.sourceQuote==="'"&&(l=l.replace(/\\'/g,"'"),l=l.replace(/(\\*)"/g,(u,d)=>d.length%2===0?d+'\\"':u)),i+=`"${l}"`;continue}if(c.type===t.NUMBER||c.type===t.BOOLEAN){i+=c.value;continue}if(c.type===t.SELECTOR||c.type===t.IDENTIFIER){i+=`"${c.value}"`;continue}i+=`"${c.value}"`}return i}try{let r=n(e),i=o(r);return JSON.parse(i)}catch(r){throw new _("Invalid extraction rules syntax: "+r.message,r)}}var xe="1",ze=/^[a-zA-Z0-9_-]+$/;function z(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!ze.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${ze})`);o=`script[data-rules-name~="${n}"]`}let r=e.find(t,o,{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 i=r[0],s=e.attr(i,"data-rules-version");if(s!==xe)throw new P(s);return{rules:j(e.text(i)),tagNode:i}}var oe=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),Lt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Fe=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function F(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 Oe(e,t){if(F(e,t))return!0;for(let[n,o]of Object.entries(Lt))if(o.includes(t)&&F(e,n))return!0;return!1}function K(e){let t=oe[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function jt(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=oe[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>Oe(n,r))||o.bundles.some(r=>F(n,r)))return n;n=n.parentElement}return null}function Ke(e,t){return!!jt(e,t)}var $t=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",...Fe],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"]})});function Ee(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return z(e,o,n)}return null}var Ut=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function vt(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 Je(e,t,n,o){if(o)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 Ye(e,t,n,o,r,i){return(i?Ke(e,t):Je(e,n,r,!1))||!!(o&&(i&&e!==r?e.matches(o):Je(e,o,r,i)))}function Ht(e,t){let n=oe[t];return n.tokens.some(o=>Oe(e,o))||n.bundles.some(o=>F(e,o))}var Vt=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function Xe(e,t,n,o){if(e.nodeType===1&&o(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,i=t;if(e.nodeType===1){if(Vt.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,i=t.content,n.cloneToLive.set(i,r),n.liveToClone.set(r,i)}}else if(e.nodeType!==11)return;let s=i.firstChild;for(let c=r.firstChild;c&&s;c=c.nextSibling)Xe(c,s,n,o),s=s.nextSibling}function J(e,{capability:t="data",exclude:n=null,inherit:o=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let i=e.nodeType===9?e:e.ownerDocument;if(!i?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=i.implementation.createHTMLDocument(""),c=r||new WeakMap,l=new WeakMap,u=e.nodeType===9?e.documentElement:e;n&&s.documentElement.matches(n);let d=K(t),h=o?f=>Ht(f,t)||!!(n&&f.matches(n)):f=>Ye(f,t,d,n,u,!1),m=null;if(u.nodeType!==1||!Ye(u,t,d,n,u,o)){m=s.importNode(u,!0);let f={cloneToLive:c,liveToClone:l,dropped:[],controls:[]};Xe(u,m,f,h);for(let p of f.dropped)p.remove();for(let p=0;p<f.controls.length;p+=2)vt(f.controls[p],f.controls[p+1])}e.nodeType===9&&m&&(s.replaceChild(m,s.documentElement),l.set(e,s),c.set(s,e));let T=f=>{if(Ut.test(f))throw new Error(`Filtered content queries do not support stateful selector: ${f}`)};return{root:m,document:s,capability:t,selector:K(t),cloneToLive:c,liveToClone:l,original(f){return c.get(f)||null},cloneOf(f){return l.get(f)||null},query(f,p=m){return T(f),Array.from(p.querySelectorAll(f),g=>c.get(g)||g)},text(f=m){return(f===m?m:l.get(f))?.textContent||""},html(f=m){return(f===m?m:l.get(f))?.innerHTML??""},clone(f=m){let p=f===m?m:l.get(f);return p?s.importNode(p,!0):null}}}function Ze(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function qt(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function Ge(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 Qe(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function et(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 o=n.type;o!=="file"&&o!=="checkbox"&&o!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var E={semanticExclude:!0,find(e,t,n={}){let o=qt(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(c=>!Ze(c)));let i=[];n.skip&&i.push(n.skip);let s=n.templateAttr===null?null:n.templateAttr||"cms-template";if(s&&i.push("["+s+"]"),i.length){let c=i.join(", ");r=r.filter(l=>!l.closest||!l.closest(c))}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,Qe(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),Ge(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),Ge(e,t,null)},prop(e,t,n){if(n===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return et(t),t},insertAt(e,t,n){let o=e.children[n]||null;e.insertBefore(t,o)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let o=e.ownerDocument.createElement("template");o.innerHTML=t;let r=o.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(o=>{o.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function Y(e,t={}){if(t.exclude===null)return E;let n=[K("data"),t.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!o?.querySelector?.(n))return E;let i=e.nodeType===9||!e.isConnected?e:e.ownerDocument,s=e.nodeType===9?e:e.ownerDocument,c=null,l=()=>c||(c=J(i,{capability:"data",exclude:t.exclude||null})),u=f=>{let p=l();return f===e?p.cloneOf(e):p.cloneOf(f)||f},d=f=>c?.original(f)||f,h=(f,p)=>{l().liveToClone.set(f,p),l().cloneToLive.set(p,f);let g=f.childNodes||[],a=p.childNodes||[];for(let y=0;y<Math.min(g.length,a.length);y++)h(g[y],a[y])},m=(f,p,g,a)=>{let y=Array.from(f.childNodes).filter(x=>c.cloneOf(x)),A=y[0];for(;A&&y.includes(A);)A=A.nextSibling;for(let x of y)x.remove();if(g==="innerHTML"){let x=s.createElement("template");x.innerHTML=a;for(let U of Array.from(x.content.childNodes))f.insertBefore(U,A||null)}else f.insertBefore(s.createTextNode(a),A||null),Qe(f,a);let S=J(f,{capability:"data",exclude:t.exclude||null});p.replaceChildren(...Array.from(S.root?.childNodes||[]));let O=x=>{let U=S.original(x);U&&(c.liveToClone.set(U,x),c.cloneToLive.set(x,U));for(let ft of Array.from(x.childNodes||[]))O(ft)};for(let x of Array.from(p.childNodes))O(x)},T={...E,find(f,p,g={}){let a=u(f);if(!a?.querySelectorAll)return[];let y=l().query(p,a);g.includeRulesTag||(y=y.filter(S=>!Ze(S)));let w=[];g.skip&&w.push(g.skip);let A=g.templateAttr===null?null:g.templateAttr||"cms-template";if(A&&w.push(`[${A}]`),w.length){let S=w.join(", ");y=y.filter(O=>!O.closest?.(S))}return y},parent(f){let p=u(f)?.parentElement;return p?d(p):null},children(f){return Array.from(u(f)?.children||[],d)},text(f,p){if(p===void 0){let y=d(f);return!y?.matches?.(n)&&!y?.querySelector?.(n)?E.text(y):(u(f)?.textContent||"").trim()}let g=d(f);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!c){E.text(g,p);return}let a=l().cloneOf(g);a?m(g,a,"textContent",p):E.text(g,p)},attr(f,p,g){let a=d(f);if(g===void 0)return E.attr(a,p);E.attr(a,p,g);let y=c?.cloneOf(a);y&&(E.attr(y,p,g),J(a,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),c.liveToClone.delete(a),c.cloneToLive.delete(y)))},removeAttr(f,p){let g=d(f);E.removeAttr(g,p);let a=c?.cloneOf(g);a&&E.removeAttr(a,p)},prop(f,p,g){let a=d(f);if(g===void 0)return p==="innerHTML"||p==="outerHTML"||p==="textContent"||p==="innerText"?E.prop(u(a),p):E.prop(a,p);let y=p==="innerHTML"||p==="textContent"||p==="innerText",w=y?l().cloneOf(a):c?.cloneOf(a);w&&y?m(a,w,p,g):(E.prop(a,p,g),w&&E.prop(w,p,g))},clone(f){let p=u(f);if(p===f)return E.clone(f);let g=s.importNode(p,!0);return et(g),g},insertAt(f,p,g){let a=d(f),w=T.children(a)[g]||(()=>{for(let O=a.children.length-1;O>=0;O--){let x=a.children[O];if(l().cloneOf(x))return x.nextElementSibling}return a.firstElementChild})(),A=d(p);a.insertBefore(A,w||null);let S=l().cloneOf(a);if(S){let O=l().cloneOf(A);O||(O=s.importNode(A,!0),h(A,O));let x=Array.from(S.children);S.insertBefore(O,x[g]||null)}},insertBefore(f,p){let g=d(f),a=d(p);g.parentNode.insertBefore(a,g);let y=l().cloneOf(g.parentNode);if(y){let w=l().cloneOf(a);w||(w=s.importNode(a,!0),h(a,w));let A=l().cloneOf(g);A?A.before(w):y.appendChild(w)}},insertAfter(f,p){let g=d(f),a=d(p);g.parentNode.insertBefore(a,g.nextSibling);let y=l().cloneOf(g.parentNode);if(y){let w=l().cloneOf(a);w||(w=s.importNode(a,!0),h(a,w));let A=l().cloneOf(g);A?A.after(w):y.appendChild(w)}},identity(f){return d(f)||null},remove(f){let p=d(f),g=l().cloneOf(p);E.remove(p),g&&E.remove(g)},replaceWith(f,p){let g=d(f),a=l().cloneOf(g),y=E.replaceWith(g,p);if(a){let w=J(y,{capability:"data",exclude:t.exclude||null});if(!w.root)a.remove();else{a.replaceWith(w.root);let A=S=>{let O=w.original(S);O&&(c.liveToClone.set(O,S),c.cloneToLive.set(S,O));for(let x of Array.from(S.childNodes||[]))A(x)};A(w.root)}}return y}};return T}var R=E;var tt={extract:(e,t,n={})=>C(Y(e,n),e,t,n),apply:(e,t,n,o={})=>L(Y(e,{...o,_write:!0}),e,t,n,o),findRulesIn:(e,t)=>z(R,e,t),findRules:(e,t)=>Ee(R,e,t),bind:(e,t,n={})=>{let o=Ee(R,e,t);if(!o){let r=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${r}`)}return{...o,get:()=>C(Y(e,n),e,o.rules,n),set:r=>L(Y(e,{...n,_write:!0}),e,o.rules,r,n)}},parseStrict:Te,parseRelaxed:j,ruleAttrIndex:b,splitRule:pe,errors:ne,DOM_PROPERTIES:G};var Bt="hha:upgrade-check:";function N(e,t){let n=e.querySelector(`meta[name="${t}"]`),o=n?n.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function Se(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function nt(e,t){let n=Se(e),o=Se(t);if(!n||!o)return!1;let r=Math.max(n.length,o.length);for(let i=0;i<r;i++){let s=n[i]||0,c=o[i]||0;if(s!==c)return s>c}return!1}function zt(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function Ft(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function rt({force:e=!1,doc:t,loc:n,fetchFn:o,now:r,ttlMs:i=864e5}={}){if(t=t||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(m=>fetch(m)),r=r??Date.now(),!t)return null;let s=N(t,"hyper-source");if(!s)return null;let c=N(t,"hyper-version"),l;try{l=new URL(s,n?n.href:void 0)}catch{return null}if(n&&l.origin===n.origin&&l.pathname===n.pathname)return null;let u=`${Bt}${l.href}:${c||"none"}`,d,h=e?null:zt(u);if(h&&typeof h.checkedAt=="number"&&r-h.checkedAt<i)d=h.sourceVersion;else{try{let m=await o(l.href);if(!m.ok)throw new Error(`HTTP ${m.status}`);let T=await m.text(),f=new DOMParser().parseFromString(T,"text/html");d=N(f,"hyper-version")}catch{d=null}Ft(u,{checkedAt:r,sourceVersion:d})}return d?{available:nt(d,c||"0.0.0"),currentVersion:c,sourceVersion:d,sourceUrl:l.href}:null}var Kt="script[data-rules-name]";function Jt(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function ie(e,t){let n=e.find(t,Kt,{includeRulesTag:!0}),o=new Set,r=[];for(let i of n){let s=Jt(e.attr(i,"data-rules-name"));if(!s)continue;if(o.has(s)){console.warn(`hyper-html-api: duplicate rules tag name "${s}"; using the first.`);continue}let c=e.attr(i,"data-rules-version");if(c!==xe)throw new P(c);o.add(s),r.push({name:s,rules:j(e.text(i))})}return r}function be(e,t){let n={};for(let{name:o,rules:r}of ie(e,t))n[o]=C(e,t,r);return n}function ot(e){let t=e||document,n=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:be(R,t),version:N(n,"hyper-version")}}var X=class extends Error{constructor(t,n){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=n}},se=class extends Error{constructor(t){super(`upgrade source has no rules tags; refusing to drop all existing data: ${t}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=t}},$=class extends Error{constructor(t,n){super(t),this.name="UpgradeTransformInvalid",this.cause=n}},ce=class extends Error{constructor(t){super(`found ${t} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=t}};var Yt="text/hyper-upgrade";function it(e,t){let n=e.find(t,`script[type="${Yt}"]`);if(n.length===0)return null;if(n.length>1)throw new ce(n.length);return e.text(n[0])||null}var Xt=new Function("url","return import(url)");async function st(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o;try{o=await Xt(n)}catch(r){throw new $(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(n)}if(typeof o.default!="function")throw new $("transform must `export default` a function");return o.default}function le(e,t){let n={carriedOver:0,discarded:0,listItems:0},o=Re(t,e,n);return Ne(t,e,n),{data:o,summary:n}}function Re(e,t,n){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(n.listItems+=t.length,n.carriedOver+=t.length,t):void 0:t==null||typeof t=="object"?void 0:(n.carriedOver++,t);if(Array.isArray(e)){let[,o]=e;return Array.isArray(t)?(n.listItems+=t.length,t.map(r=>Re(o,r,n))):void 0}if(typeof e=="object"&&e!==null){let o={};for(let[r,i]of Object.entries(e)){let s=Re(i,t?.[r],n);s!==void 0&&(o[r]=s)}return o}}function Ne(e,t,n){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let o=new Set(Object.keys(e));for(let r of Object.keys(t))o.has(r)?Ne(e[r],t[r],n):n.discarded+=W(t[r]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(r=>Ne(o,r,n));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(n.discarded+=W(t))}}function W(e){return e==null?0:Array.isArray(e)?e.reduce((t,n)=>t+W(n),0):typeof e=="object"?Object.values(e).reduce((t,n)=>t+W(n),0):1}function ct(e,t,n){let o=ie(e,t),r={carriedOver:0,discarded:0,listItems:0},i={},s=new Set;for(let{name:c,rules:l}of o){if(s.add(c),!Object.prototype.hasOwnProperty.call(n,c)){i[c]={carriedOver:0,discarded:0,listItems:0};continue}let{data:u,summary:d}=le(n[c],l);L(e,t,l,u),i[c]=d,r.carriedOver+=d.carriedOver,r.discarded+=d.discarded,r.listItems+=d.listItems}for(let c of Object.keys(n))s.has(c)||(r.discarded+=W(n[c]));return{totals:r,byName:i,rulesTagCount:o.length}}async function lt({sourceUrl:e,dataByName:t,fromVersion:n,doc:o,loc:r,fetchFn:i}={}){if(o=o||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),i=i||(a=>fetch(a)),!o)throw new Error("upgrade.run requires a document context");if(e=e||N(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let s=new URL(e,r?r.href:void 0);n=n!==void 0?n:N(o,"hyper-version"),t=t||be(R,o);let c;try{c=await i(s.href)}catch(a){throw new X(s.href,a)}if(!c.ok)throw new X(s.href,new Error(`HTTP ${c.status}`));let l=await c.text(),u=new DOMParser().parseFromString(l,"text/html"),d=N(u,"hyper-version"),h=t,m=!1,T=it(R,u);if(T){let y=await(await st(T))(h,{fromVersion:n,toVersion:d});if(!y||typeof y!="object"||Array.isArray(y))throw new $("transform must return a plain object map of { rulesName: data }");h=y,m=!0}let{totals:f,byName:p,rulesTagCount:g}=ct(R,u,h);if(g===0&&Object.keys(h).length>0)throw new se(s.href);return{html:Gt(u),fromVersion:n,toVersion:d,summary:{transformApplied:m,totals:f,byName:p}}}function Gt(e){return`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
5
|
+
`+e.documentElement.outerHTML}var Zt={checkForUpdate:rt,run:lt,extractAll:ot,shapeMatch:le};var Qt={engine:tt,upgrade:Zt},en=Qt;export{en as default,tt as engine,nt as isNewerVersion,Se as parseVersion,N as readMeta,Zt as upgrade};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* hyper-morph identity (src/identity.js), version 1.7.0. Generated; do not edit. */
|
|
2
|
+
var w="~",T="^";function m(e){let r=new WeakMap,l=0,u=i=>r.get(i)||null,c=i=>{let t=r.get(i);return t||(t=`${e}:${++l}`,r.set(i,t)),t};return{idOf:u,ensure:c,adopt:(i,t)=>{i&&typeof t=="string"&&t&&r.set(i,t)},exportMap:(i,t)=>{let n={},s=[],o=[],d=(a,A)=>{let f=t(a);f&&(n[A]=c(f));let y=a.children;s.push(y.length),o.push(a.tagName.toLowerCase());for(let p=0;p<y.length;p++)d(y[p],A===""?String(p):`${A}.${p}`)};return d(i,""),n["~"]=s.join(","),n["^"]=o.join(","),n}}}function M(e,r){let l=new WeakMap;if(!e||!r||typeof r!="object"||Array.isArray(r))return l;let u=r["~"],c=typeof u=="string"?u.split(",").map(Number):null,g=c&&typeof r["^"]=="string"?r["^"].split(","):null,h=o=>Number.isInteger(o)&&o>=0,i=0,t=!1,n=o=>{let d=o;for(;d>0;){let a=c[i++];if(i>c.length||!h(a))return!1;d+=a-1}return!0},s=(o,d)=>{if(t)return;if(c){let f=i++,y=c[f];if(f>=c.length||!h(y)){t=!0;return}let p=!g||g[f]===o.tagName.toLowerCase();if(!p||y!==o.children.length){let E=p&&r[d];typeof E=="string"&&E&&l.set(o,E),n(y)||(t=!0);return}}let a=r[d];typeof a=="string"&&a&&l.set(o,a);let A=o.children;for(let f=0;f<A.length;f++)s(A[f],d===""?String(f):`${d}.${f}`)};return s(e,""),l}function S(e){return r=>{for(let l of e){let u=l(r);if(typeof u=="string"&&u!=="")return u}return null}}var b=S([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function k(e,r,l,u=null,c=null){let g=new Map,h=new Set,i=t=>{if(l(t))return;let n=r(t);n&&(g.has(n)?h.add(n):g.set(n,t))};if(u){let t=n=>{for(let s of n.querySelectorAll(u))i(s);for(let s of n.querySelectorAll("template"))s.content&&t(s.content)};i(e),t(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let t=n=>{i(n);let s=n.tagName==="TEMPLATE"&&n.content?n.content.children:n.children;for(let o=0;o<s.length;o++)t(s[o])};t(e)}for(let t of h)g.delete(t),c&&c.add(t),x(t);return g}function x(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}export{w as SHAPE_KEY,T as TAGS_KEY,m as createIdentityStore,b as defaultIdentity,M as importMap,k as indexByIdentity,S as tieredIdentity,x as warnDuplicate};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* hyper-morph json (src/hyper-morph-json-parse.js), version 1.7.0. Generated; do not edit. */
|
|
2
|
+
function O(n,o){for(;;){for(;o<n.length&&/\s/.test(n[o]);)o++;if(n[o]==="/"&&n[o+1]==="/"){for(;o<n.length&&n[o]!==`
|
|
3
|
+
`;)o++;continue}if(n[o]==="/"&&n[o+1]==="*"){let r=n.indexOf("*/",o+2);if(r===-1)return n.length;o=r+2;continue}return o}}function g(n){return n.replace(/\\'/g,"'").replace(/(\\*)"/g,(o,r)=>r.length%2===0?r+'\\"':o)}var N=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,y=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function v(n){try{return JSON.parse(n)}catch{return JSON.parse(R(n))}}function R(n){let o="",r=0,h=(e,c)=>{throw new Error(`Invalid relaxed JSON: ${e} at position ${c}`)};for(;r<n.length&&(r=O(n,r),!(r>=n.length));){let e=n[r];if("{}[]:".includes(e)){o+=e,r++;continue}if(e===","){let t=O(n,r+1);if(n[t]==="}"||n[t]==="]"){r++;continue}o+=e,r++;continue}if(e==='"'||e==="'"){let t=r+1;for(;t<n.length&&n[t]!==e;)n[t]==="\\"&&t++,t++;t>=n.length&&h("unterminated string",r);let l=n.slice(r+1,t);e==="'"&&(l=g(l)),o+='"'+l+'"',r=t+1;continue}let c=r;for(;c<n.length&&/[A-Za-z0-9_$.+\-]/.test(n[c]);)c++;c===r&&h("unexpected character "+JSON.stringify(e),r);let s=n.slice(r,c);if(s==="true"||s==="false"||s==="null"||N.test(s)){o+=s,r=c;continue}if(y.test(s)){if(n[O(n,c)]===":"){o+='"'+s+'"',r=c;continue}h("unquoted value "+JSON.stringify(s),r)}h("invalid token "+JSON.stringify(s),r)}return o}function I(n){try{return JSON.parse(n)}catch{}let o={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function r(e){let c=[],s=0;for(;s<e.length;){let t=e[s];if(/\s/.test(t)){s++;continue}if("{}".includes(t)){c.push({type:t,value:t}),s++;continue}if(t==="["){let a=!1,f=s+1;for(;f<e.length&&/\s/.test(e[f]);)f++;if(f<e.length&&/[a-zA-Z_]/.test(e[f])&&(a=!0),!a){c.push({type:t,value:t}),s++;continue}}if(t==="]"){c.push({type:t,value:t}),s++;continue}if(t===":"){c.push({type:o.COLON,value:t}),s++;continue}if(t===","){c.push({type:o.COMMA,value:t}),s++;continue}if(t==='"'||t==="'"){let a=t,f=s+1;for(;f<e.length&&e[f]!==a;)e[f]==="\\"&&f++,f++;c.push({type:o.STRING,value:e.substring(s+1,f),quoted:!0,sourceQuote:a}),s=f+1;continue}let l=s,i;for(;l<e.length&&!/[{},]/.test(e[l]);)if(e[l]===":"){let a=[":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"],f=!1;for(let E of a){let d=E.substring(1);if(e.substring(l+1,l+1+d.length)===d){f=!0,l+=d.length;break}}if(!f)break}else if(e[l]==="["){for(l++;l<e.length&&e[l]!=="]";){if(e[l]==='"'||e[l]==="'"){let a=e[l];for(l++;l<e.length&&e[l]!==a;)e[l]==="\\"&&l++,l++}l++}l<e.length&&e[l]==="]"&&l++}else l++;i=e.substring(s,l);let u=o.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(i)?u=o.NUMBER:i==="true"||i==="false"||i==="null"?u=o.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(i)&&(u=o.SELECTOR),c.push({type:u,value:i,quoted:!1}),s=l}return c}function h(e){let c="";for(let s=0;s<e.length;s++){let t=e[s];if("{}".includes(t.type)||"[]".includes(t.type)){c+=t.value;continue}if(t.type===o.COLON){c+=t.value;continue}if(t.type===o.COMMA){let l=e[s+1];if(l&&(l.type==="}"||l.type==="]"))continue;c+=t.value;continue}if(t.type===o.STRING){let l=t.value;t.sourceQuote==="'"&&(l=g(l)),c+=`"${l}"`;continue}if(t.type===o.NUMBER||t.type===o.BOOLEAN){c+=t.value;continue}c+=`"${t.value}"`}return c}try{let e=r(n),c=h(e);return JSON.parse(c)}catch(e){throw new Error("Invalid extraction rules syntax: "+e.message)}}export{v as parseJsonRelaxed,I as parseRulesRelaxed};
|