hyper-html-api 0.13.0 → 0.15.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 -1
- package/conformance/MANIFEST.json +2 -2
- package/conformance/cases/all-matches-read-quoted.expected.json +3 -0
- package/conformance/cases/all-matches-read-quoted.html +5 -0
- package/conformance/cases/all-matches-read-quoted.meta +7 -0
- package/conformance/cases/all-matches-read-quoted.parsed.json +3 -0
- package/conformance/cases/all-matches-read.expected.json +3 -0
- package/conformance/cases/all-matches-read.html +6 -0
- package/conformance/cases/all-matches-read.meta +7 -0
- package/conformance/cases/all-matches-read.parsed.json +3 -0
- package/conformance/cases/codec-form-nested.error.json +5 -0
- package/conformance/cases/codec-form-nested.html +4 -0
- package/conformance/cases/codec-form-nested.meta +6 -0
- package/conformance/cases/codec-form-nested.parsed.json +5 -0
- package/conformance/cases/codec-form-star.error.json +5 -0
- package/conformance/cases/codec-form-star.html +4 -0
- package/conformance/cases/codec-form-star.meta +6 -0
- package/conformance/cases/codec-form-star.parsed.json +3 -0
- package/conformance/cases/codec-form-under-v1.error.json +5 -0
- package/conformance/cases/codec-form-under-v1.html +4 -0
- package/conformance/cases/codec-form-under-v1.meta +6 -0
- package/conformance/cases/codec-form-under-v1.parsed.json +3 -0
- package/conformance/cases/codec-unknown-name.error.json +5 -0
- package/conformance/cases/codec-unknown-name.html +4 -0
- package/conformance/cases/codec-unknown-name.meta +6 -0
- package/conformance/cases/codec-unknown-name.parsed.json +3 -0
- package/conformance/cases/tag-version-2-plain.expected.json +7 -0
- package/conformance/cases/tag-version-2-plain.html +5 -0
- package/conformance/cases/tag-version-2-plain.meta +6 -0
- package/conformance/cases/tag-version-2-plain.parsed.json +4 -0
- package/conformance/cases/tag-wrong-version.error.json +1 -1
- package/conformance/cases/tag-wrong-version.html +1 -1
- package/conformance/cases/write-all-matches-attr.after.html +1 -0
- package/conformance/cases/write-all-matches-attr.after.json +3 -0
- package/conformance/cases/write-all-matches-attr.data.json +1 -0
- package/conformance/cases/write-all-matches-attr.html +1 -0
- package/conformance/cases/write-all-matches-attr.meta +6 -0
- package/conformance/cases/write-all-matches-attr.write.json +4 -0
- package/conformance/cases/write-all-matches-group.after.html +1 -0
- package/conformance/cases/write-all-matches-group.after.json +3 -0
- package/conformance/cases/write-all-matches-group.data.json +1 -0
- package/conformance/cases/write-all-matches-group.html +1 -0
- package/conformance/cases/write-all-matches-group.meta +6 -0
- package/conformance/cases/write-all-matches-group.write.json +4 -0
- package/conformance/cases/write-all-matches-text.after.html +1 -0
- package/conformance/cases/write-all-matches-text.after.json +3 -0
- package/conformance/cases/write-all-matches-text.data.json +1 -0
- package/conformance/cases/write-all-matches-text.html +1 -0
- package/conformance/cases/write-all-matches-text.meta +6 -0
- package/conformance/cases/write-all-matches-text.write.json +4 -0
- package/conformance/cases/write-all-matches-unmatched.data.json +1 -0
- package/conformance/cases/write-all-matches-unmatched.error.json +14 -0
- package/conformance/cases/write-all-matches-unmatched.html +1 -0
- package/conformance/cases/write-all-matches-unmatched.meta +6 -0
- package/conformance/sheet/body-data-write.body.json +3 -0
- package/conformance/sheet/body-data-write.data.json +3 -0
- package/conformance/sheet/body-data-write.html +25 -0
- package/conformance/sheet/body-data-write.meta +5 -0
- package/conformance/sheet/body-patch-key-in-rules.body.json +3 -0
- package/conformance/sheet/body-patch-key-in-rules.data.json +13 -0
- package/conformance/sheet/body-patch-key-in-rules.html +18 -0
- package/conformance/sheet/body-patch-key-in-rules.meta +5 -0
- package/conformance/sheet/body-patch-not-array.body.json +3 -0
- package/conformance/sheet/body-patch-not-array.data.json +3 -0
- package/conformance/sheet/body-patch-not-array.html +25 -0
- package/conformance/sheet/body-patch-not-array.meta +5 -0
- package/conformance/sheet/body-patch-on-sheet.body.json +3 -0
- package/conformance/sheet/body-patch-on-sheet.data.json +14 -0
- package/conformance/sheet/body-patch-on-sheet.html +25 -0
- package/conformance/sheet/body-patch-on-sheet.meta +5 -0
- package/conformance/sheet/body-patch-version-1.body.json +3 -0
- package/conformance/sheet/body-patch-version-1.data.json +13 -0
- package/conformance/sheet/body-patch-version-1.html +4 -0
- package/conformance/sheet/body-patch-version-1.meta +5 -0
- package/conformance/sheet/body-patch-with-other-key.body.json +3 -0
- package/conformance/sheet/body-patch-with-other-key.data.json +14 -0
- package/conformance/sheet/body-patch-with-other-key.html +25 -0
- package/conformance/sheet/body-patch-with-other-key.meta +5 -0
- package/conformance/sheet/body-patch-without-operation-id.body.json +3 -0
- package/conformance/sheet/body-patch-without-operation-id.data.json +13 -0
- package/conformance/sheet/body-patch-without-operation-id.html +25 -0
- package/conformance/sheet/body-patch-without-operation-id.meta +5 -0
- package/conformance/sheet/params-bad-range.error.json +6 -0
- package/conformance/sheet/params-bad-range.html +25 -0
- package/conformance/sheet/params-bad-range.meta +6 -0
- package/conformance/sheet/params-bad-render.error.json +6 -0
- package/conformance/sheet/params-bad-render.html +25 -0
- package/conformance/sheet/params-bad-render.meta +6 -0
- package/conformance/sheet/params-bad-shape.error.json +6 -0
- package/conformance/sheet/params-bad-shape.html +25 -0
- package/conformance/sheet/params-bad-shape.meta +6 -0
- package/conformance/sheet/params-cache-buster.expected.json +128 -0
- package/conformance/sheet/params-cache-buster.html +25 -0
- package/conformance/sheet/params-cache-buster.meta +6 -0
- package/conformance/sheet/params-data-alone.expected.json +128 -0
- package/conformance/sheet/params-data-alone.html +25 -0
- package/conformance/sheet/params-data-alone.meta +6 -0
- package/conformance/sheet/params-empty.error.json +6 -0
- package/conformance/sheet/params-empty.html +25 -0
- package/conformance/sheet/params-empty.meta +6 -0
- package/conformance/sheet/params-index.expected.json +19 -0
- package/conformance/sheet/params-index.html +25 -0
- package/conformance/sheet/params-index.meta +6 -0
- package/conformance/sheet/params-none.expected.json +128 -0
- package/conformance/sheet/params-none.html +25 -0
- package/conformance/sheet/params-none.meta +6 -0
- package/conformance/sheet/params-range.expected.json +17 -0
- package/conformance/sheet/params-range.html +25 -0
- package/conformance/sheet/params-range.meta +6 -0
- package/conformance/sheet/params-render-without-range.error.json +6 -0
- package/conformance/sheet/params-render-without-range.html +25 -0
- package/conformance/sheet/params-render-without-range.meta +6 -0
- package/conformance/sheet/params-repeated.error.json +6 -0
- package/conformance/sheet/params-repeated.html +25 -0
- package/conformance/sheet/params-repeated.meta +6 -0
- package/conformance/sheet/params-unknown-sheet.error.json +6 -0
- package/conformance/sheet/params-unknown-sheet.html +25 -0
- package/conformance/sheet/params-unknown-sheet.meta +6 -0
- package/conformance/sheet/params-with-data.error.json +6 -0
- package/conformance/sheet/params-with-data.html +25 -0
- package/conformance/sheet/params-with-data.meta +6 -0
- package/conformance/sheet/sheet-contract-cells.expected.json +57 -0
- package/conformance/sheet/sheet-contract-cells.html +10 -0
- package/conformance/sheet/sheet-contract-cells.meta +6 -0
- package/conformance/sheet/sheet-contract-formulas.expected.json +29 -0
- package/conformance/sheet/sheet-contract-formulas.html +10 -0
- package/conformance/sheet/sheet-contract-formulas.meta +6 -0
- package/conformance/sheet/sheet-contract-values.expected.json +29 -0
- package/conformance/sheet/sheet-contract-values.html +10 -0
- package/conformance/sheet/sheet-contract-values.meta +6 -0
- package/conformance/sheet/sheet-contract-whole.expected.json +59 -0
- package/conformance/sheet/sheet-contract-whole.html +10 -0
- package/conformance/sheet/sheet-contract-whole.meta +5 -0
- package/conformance/sheet/sheet-hostile-01.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-01.html +6 -0
- package/conformance/sheet/sheet-hostile-01.meta +5 -0
- package/conformance/sheet/sheet-hostile-02.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-02.html +6 -0
- package/conformance/sheet/sheet-hostile-02.meta +5 -0
- package/conformance/sheet/sheet-hostile-03.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-03.html +6 -0
- package/conformance/sheet/sheet-hostile-03.meta +5 -0
- package/conformance/sheet/sheet-hostile-04.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-04.html +6 -0
- package/conformance/sheet/sheet-hostile-04.meta +5 -0
- package/conformance/sheet/sheet-hostile-05.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-05.html +6 -0
- package/conformance/sheet/sheet-hostile-05.meta +5 -0
- package/conformance/sheet/sheet-hostile-06.expected.json +21 -0
- package/conformance/sheet/sheet-hostile-06.html +6 -0
- package/conformance/sheet/sheet-hostile-06.meta +5 -0
- package/conformance/sheet/sheet-hostile-07.expected.json +21 -0
- package/conformance/sheet/sheet-hostile-07.html +6 -0
- package/conformance/sheet/sheet-hostile-07.meta +5 -0
- package/conformance/sheet/sheet-hostile-08.expected.json +21 -0
- package/conformance/sheet/sheet-hostile-08.html +6 -0
- package/conformance/sheet/sheet-hostile-08.meta +5 -0
- package/conformance/sheet/sheet-hostile-09.expected.json +21 -0
- package/conformance/sheet/sheet-hostile-09.html +6 -0
- package/conformance/sheet/sheet-hostile-09.meta +5 -0
- package/conformance/sheet/sheet-hostile-10.expected.json +21 -0
- package/conformance/sheet/sheet-hostile-10.html +6 -0
- package/conformance/sheet/sheet-hostile-10.meta +5 -0
- package/conformance/sheet/sheet-hostile-11.expected.json +22 -0
- package/conformance/sheet/sheet-hostile-11.html +6 -0
- package/conformance/sheet/sheet-hostile-11.meta +5 -0
- package/conformance/sheet/sheet-hostile-12.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-12.html +6 -0
- package/conformance/sheet/sheet-hostile-12.meta +5 -0
- package/conformance/sheet/sheet-hostile-13.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-13.html +6 -0
- package/conformance/sheet/sheet-hostile-13.meta +5 -0
- package/conformance/sheet/sheet-hostile-14.expected.json +21 -0
- package/conformance/sheet/sheet-hostile-14.html +6 -0
- package/conformance/sheet/sheet-hostile-14.meta +5 -0
- package/conformance/sheet/sheet-hostile-15.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-15.html +0 -0
- package/conformance/sheet/sheet-hostile-15.meta +5 -0
- package/conformance/sheet/sheet-hostile-16.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-16.html +6 -0
- package/conformance/sheet/sheet-hostile-16.meta +5 -0
- package/conformance/sheet/sheet-hostile-17.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-17.html +6 -0
- package/conformance/sheet/sheet-hostile-17.meta +5 -0
- package/conformance/sheet/sheet-hostile-18.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-18.html +6 -0
- package/conformance/sheet/sheet-hostile-18.meta +5 -0
- package/conformance/sheet/sheet-hostile-19.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-19.html +6 -0
- package/conformance/sheet/sheet-hostile-19.meta +5 -0
- package/conformance/sheet/sheet-hostile-20.expected.json +16 -0
- package/conformance/sheet/sheet-hostile-20.html +6 -0
- package/conformance/sheet/sheet-hostile-20.meta +5 -0
- package/conformance/sheet/sheet-hostile-21.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-21.html +6 -0
- package/conformance/sheet/sheet-hostile-21.meta +5 -0
- package/conformance/sheet/sheet-hostile-22.expected.json +21 -0
- package/conformance/sheet/sheet-hostile-22.html +6 -0
- package/conformance/sheet/sheet-hostile-22.meta +5 -0
- package/conformance/sheet/sheet-hostile-23.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-23.html +6 -0
- package/conformance/sheet/sheet-hostile-23.meta +5 -0
- package/conformance/sheet/sheet-hostile-24.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-24.html +6 -0
- package/conformance/sheet/sheet-hostile-24.meta +5 -0
- package/conformance/sheet/sheet-hostile-25.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-25.html +6 -0
- package/conformance/sheet/sheet-hostile-25.meta +5 -0
- package/conformance/sheet/sheet-hostile-26.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-26.html +6 -0
- package/conformance/sheet/sheet-hostile-26.meta +5 -0
- package/conformance/sheet/sheet-hostile-27.expected.json +24 -0
- package/conformance/sheet/sheet-hostile-27.html +7 -0
- package/conformance/sheet/sheet-hostile-27.meta +5 -0
- package/conformance/sheet/sheet-hostile-28.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-28.html +6 -0
- package/conformance/sheet/sheet-hostile-28.meta +5 -0
- package/conformance/sheet/sheet-hostile-29.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-29.html +6 -0
- package/conformance/sheet/sheet-hostile-29.meta +5 -0
- package/conformance/sheet/sheet-hostile-30.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-30.html +6 -0
- package/conformance/sheet/sheet-hostile-30.meta +5 -0
- package/conformance/sheet/sheet-hostile-31.expected.json +19 -0
- package/conformance/sheet/sheet-hostile-31.html +6 -0
- package/conformance/sheet/sheet-hostile-31.meta +5 -0
- package/conformance/sheet/sheet-hostile-32.expected.json +24 -0
- package/conformance/sheet/sheet-hostile-32.html +6 -0
- package/conformance/sheet/sheet-hostile-32.meta +5 -0
- package/conformance/sheet/sheet-hostile-33.expected.json +18 -0
- package/conformance/sheet/sheet-hostile-33.html +6 -0
- package/conformance/sheet/sheet-hostile-33.meta +5 -0
- package/conformance/sheet/sheet-hostile-34.expected.json +24 -0
- package/conformance/sheet/sheet-hostile-34.html +8 -0
- package/conformance/sheet/sheet-hostile-34.meta +5 -0
- package/conformance/sheet/sheet-hostile-35.expected.json +24 -0
- package/conformance/sheet/sheet-hostile-35.html +8 -0
- package/conformance/sheet/sheet-hostile-35.meta +5 -0
- package/conformance/sheet/sheet-patch-append.after.html +27 -0
- package/conformance/sheet/sheet-patch-append.after.json +143 -0
- package/conformance/sheet/sheet-patch-append.data.json +15 -0
- package/conformance/sheet/sheet-patch-append.html +25 -0
- package/conformance/sheet/sheet-patch-append.meta +5 -0
- package/conformance/sheet/sheet-patch-append.write.json +7 -0
- package/conformance/sheet/sheet-patch-bad-range.data.json +11 -0
- package/conformance/sheet/sheet-patch-bad-range.error.json +6 -0
- package/conformance/sheet/sheet-patch-bad-range.html +25 -0
- package/conformance/sheet/sheet-patch-bad-range.meta +5 -0
- package/conformance/sheet/sheet-patch-bad-value.data.json +13 -0
- package/conformance/sheet/sheet-patch-bad-value.error.json +6 -0
- package/conformance/sheet/sheet-patch-bad-value.html +25 -0
- package/conformance/sheet/sheet-patch-bad-value.meta +5 -0
- package/conformance/sheet/sheet-patch-clean-tab-beside-edited.after.html +25 -0
- package/conformance/sheet/sheet-patch-clean-tab-beside-edited.after.json +129 -0
- package/conformance/sheet/sheet-patch-clean-tab-beside-edited.data.json +11 -0
- package/conformance/sheet/sheet-patch-clean-tab-beside-edited.html +25 -0
- package/conformance/sheet/sheet-patch-clean-tab-beside-edited.meta +5 -0
- package/conformance/sheet/sheet-patch-clean-tab-beside-edited.write.json +7 -0
- package/conformance/sheet/sheet-patch-covered-cell.data.json +10 -0
- package/conformance/sheet/sheet-patch-covered-cell.error.json +6 -0
- package/conformance/sheet/sheet-patch-covered-cell.html +10 -0
- package/conformance/sheet/sheet-patch-covered-cell.meta +5 -0
- package/conformance/sheet/sheet-patch-empty.data.json +1 -0
- package/conformance/sheet/sheet-patch-empty.error.json +6 -0
- package/conformance/sheet/sheet-patch-empty.html +25 -0
- package/conformance/sheet/sheet-patch-empty.meta +5 -0
- package/conformance/sheet/sheet-patch-fallback-route.after.html +24 -0
- package/conformance/sheet/sheet-patch-fallback-route.after.json +86 -0
- package/conformance/sheet/sheet-patch-fallback-route.data.json +10 -0
- package/conformance/sheet/sheet-patch-fallback-route.html +24 -0
- package/conformance/sheet/sheet-patch-fallback-route.meta +5 -0
- package/conformance/sheet/sheet-patch-fallback-route.write.json +7 -0
- package/conformance/sheet/sheet-patch-first-tab.after.html +25 -0
- package/conformance/sheet/sheet-patch-first-tab.after.json +129 -0
- package/conformance/sheet/sheet-patch-first-tab.data.json +10 -0
- package/conformance/sheet/sheet-patch-first-tab.html +25 -0
- package/conformance/sheet/sheet-patch-first-tab.meta +5 -0
- package/conformance/sheet/sheet-patch-first-tab.write.json +7 -0
- package/conformance/sheet/sheet-patch-formula.after.html +25 -0
- package/conformance/sheet/sheet-patch-formula.after.json +128 -0
- package/conformance/sheet/sheet-patch-formula.data.json +11 -0
- package/conformance/sheet/sheet-patch-formula.html +25 -0
- package/conformance/sheet/sheet-patch-formula.meta +5 -0
- package/conformance/sheet/sheet-patch-formula.write.json +7 -0
- package/conformance/sheet/sheet-patch-no-sheet-rule.data.json +10 -0
- package/conformance/sheet/sheet-patch-no-sheet-rule.error.json +6 -0
- package/conformance/sheet/sheet-patch-no-sheet-rule.html +18 -0
- package/conformance/sheet/sheet-patch-no-sheet-rule.meta +5 -0
- package/conformance/sheet/sheet-patch-no-values.data.json +6 -0
- package/conformance/sheet/sheet-patch-no-values.error.json +6 -0
- package/conformance/sheet/sheet-patch-no-values.html +25 -0
- package/conformance/sheet/sheet-patch-no-values.meta +5 -0
- package/conformance/sheet/sheet-patch-not-canonical.data.json +11 -0
- package/conformance/sheet/sheet-patch-not-canonical.error.json +6 -0
- package/conformance/sheet/sheet-patch-not-canonical.html +25 -0
- package/conformance/sheet/sheet-patch-not-canonical.meta +5 -0
- package/conformance/sheet/sheet-patch-outside-sheet.data.json +11 -0
- package/conformance/sheet/sheet-patch-outside-sheet.error.json +6 -0
- package/conformance/sheet/sheet-patch-outside-sheet.html +25 -0
- package/conformance/sheet/sheet-patch-outside-sheet.meta +5 -0
- package/conformance/sheet/sheet-patch-range.after.html +25 -0
- package/conformance/sheet/sheet-patch-range.after.json +126 -0
- package/conformance/sheet/sheet-patch-range.data.json +11 -0
- package/conformance/sheet/sheet-patch-range.html +25 -0
- package/conformance/sheet/sheet-patch-range.meta +5 -0
- package/conformance/sheet/sheet-patch-range.write.json +7 -0
- package/conformance/sheet/sheet-patch-two-tabs.after.html +25 -0
- package/conformance/sheet/sheet-patch-two-tabs.after.json +130 -0
- package/conformance/sheet/sheet-patch-two-tabs.data.json +20 -0
- package/conformance/sheet/sheet-patch-two-tabs.html +25 -0
- package/conformance/sheet/sheet-patch-two-tabs.meta +5 -0
- package/conformance/sheet/sheet-patch-two-tabs.write.json +7 -0
- package/conformance/sheet/sheet-patch-typed.after.html +25 -0
- package/conformance/sheet/sheet-patch-typed.after.json +121 -0
- package/conformance/sheet/sheet-patch-typed.data.json +13 -0
- package/conformance/sheet/sheet-patch-typed.html +25 -0
- package/conformance/sheet/sheet-patch-typed.meta +5 -0
- package/conformance/sheet/sheet-patch-typed.write.json +7 -0
- package/conformance/sheet/sheet-patch-unknown-sheet.data.json +11 -0
- package/conformance/sheet/sheet-patch-unknown-sheet.error.json +6 -0
- package/conformance/sheet/sheet-patch-unknown-sheet.html +25 -0
- package/conformance/sheet/sheet-patch-unknown-sheet.meta +5 -0
- package/conformance/sheet/sheet-read-bad-range.error.json +6 -0
- package/conformance/sheet/sheet-read-bad-range.html +25 -0
- package/conformance/sheet/sheet-read-bad-range.meta +6 -0
- package/conformance/sheet/sheet-read-bad-render.error.json +6 -0
- package/conformance/sheet/sheet-read-bad-render.html +25 -0
- package/conformance/sheet/sheet-read-bad-render.meta +6 -0
- package/conformance/sheet/sheet-read-digest.expected.json +91 -0
- package/conformance/sheet/sheet-read-digest.html +25 -0
- package/conformance/sheet/sheet-read-digest.meta +6 -0
- package/conformance/sheet/sheet-read-empty.expected.json +11 -0
- package/conformance/sheet/sheet-read-empty.html +6 -0
- package/conformance/sheet/sheet-read-empty.meta +5 -0
- package/conformance/sheet/sheet-read-escapes.expected.json +108 -0
- package/conformance/sheet/sheet-read-escapes.html +22 -0
- package/conformance/sheet/sheet-read-escapes.meta +5 -0
- package/conformance/sheet/sheet-read-formulas-formatted.expected.json +298 -0
- package/conformance/sheet/sheet-read-formulas-formatted.html +16 -0
- package/conformance/sheet/sheet-read-formulas-formatted.meta +5 -0
- package/conformance/sheet/sheet-read-grid-in-comment.expected.json +85 -0
- package/conformance/sheet/sheet-read-grid-in-comment.html +24 -0
- package/conformance/sheet/sheet-read-grid-in-comment.meta +5 -0
- package/conformance/sheet/sheet-read-grid-in-script.expected.json +85 -0
- package/conformance/sheet/sheet-read-grid-in-script.html +24 -0
- package/conformance/sheet/sheet-read-grid-in-script.meta +5 -0
- package/conformance/sheet/sheet-read-grid-in-template.expected.json +85 -0
- package/conformance/sheet/sheet-read-grid-in-template.html +24 -0
- package/conformance/sheet/sheet-read-grid-in-template.meta +5 -0
- package/conformance/sheet/sheet-read-grid-in-textarea.expected.json +85 -0
- package/conformance/sheet/sheet-read-grid-in-textarea.html +24 -0
- package/conformance/sheet/sheet-read-grid-in-textarea.meta +5 -0
- package/conformance/sheet/sheet-read-grid-outside-read-by-rule.expected.json +94 -0
- package/conformance/sheet/sheet-read-grid-outside-read-by-rule.html +24 -0
- package/conformance/sheet/sheet-read-grid-outside-read-by-rule.meta +5 -0
- package/conformance/sheet/sheet-read-grid-outside-sheet.expected.json +85 -0
- package/conformance/sheet/sheet-read-grid-outside-sheet.html +24 -0
- package/conformance/sheet/sheet-read-grid-outside-sheet.meta +5 -0
- package/conformance/sheet/sheet-read-hand-edited.expected.json +85 -0
- package/conformance/sheet/sheet-read-hand-edited.html +18 -0
- package/conformance/sheet/sheet-read-hand-edited.meta +5 -0
- package/conformance/sheet/sheet-read-index.expected.json +19 -0
- package/conformance/sheet/sheet-read-index.html +25 -0
- package/conformance/sheet/sheet-read-index.meta +6 -0
- package/conformance/sheet/sheet-read-merged.expected.json +59 -0
- package/conformance/sheet/sheet-read-merged.html +10 -0
- package/conformance/sheet/sheet-read-merged.meta +5 -0
- package/conformance/sheet/sheet-read-no-tag.error.json +5 -0
- package/conformance/sheet/sheet-read-no-tag.html +18 -0
- package/conformance/sheet/sheet-read-no-tag.meta +5 -0
- package/conformance/sheet/sheet-read-padded-name-index.expected.json +19 -0
- package/conformance/sheet/sheet-read-padded-name-index.html +25 -0
- package/conformance/sheet/sheet-read-padded-name-index.meta +6 -0
- package/conformance/sheet/sheet-read-padded-name-lookup.expected.json +83 -0
- package/conformance/sheet/sheet-read-padded-name-lookup.html +25 -0
- package/conformance/sheet/sheet-read-padded-name-lookup.meta +6 -0
- package/conformance/sheet/sheet-read-padded-name-trimmed-lookup.error.json +6 -0
- package/conformance/sheet/sheet-read-padded-name-trimmed-lookup.html +25 -0
- package/conformance/sheet/sheet-read-padded-name-trimmed-lookup.meta +6 -0
- package/conformance/sheet/sheet-read-padded-name.expected.json +128 -0
- package/conformance/sheet/sheet-read-padded-name.html +25 -0
- package/conformance/sheet/sheet-read-padded-name.meta +5 -0
- package/conformance/sheet/sheet-read-range-cells.expected.json +55 -0
- package/conformance/sheet/sheet-read-range-cells.html +25 -0
- package/conformance/sheet/sheet-read-range-cells.meta +6 -0
- package/conformance/sheet/sheet-read-range-first-tab.expected.json +12 -0
- package/conformance/sheet/sheet-read-range-first-tab.html +25 -0
- package/conformance/sheet/sheet-read-range-first-tab.meta +6 -0
- package/conformance/sheet/sheet-read-range-formulas.expected.json +24 -0
- package/conformance/sheet/sheet-read-range-formulas.html +25 -0
- package/conformance/sheet/sheet-read-range-formulas.meta +6 -0
- package/conformance/sheet/sheet-read-range-values.expected.json +24 -0
- package/conformance/sheet/sheet-read-range-values.html +25 -0
- package/conformance/sheet/sheet-read-range-values.meta +6 -0
- package/conformance/sheet/sheet-read-sheet-by-id.expected.json +46 -0
- package/conformance/sheet/sheet-read-sheet-by-id.html +25 -0
- package/conformance/sheet/sheet-read-sheet-by-id.meta +6 -0
- package/conformance/sheet/sheet-read-sheet-by-name.expected.json +46 -0
- package/conformance/sheet/sheet-read-sheet-by-name.html +25 -0
- package/conformance/sheet/sheet-read-sheet-by-name.meta +6 -0
- package/conformance/sheet/sheet-read-styled.expected.json +48 -0
- package/conformance/sheet/sheet-read-styled.html +10 -0
- package/conformance/sheet/sheet-read-styled.meta +5 -0
- package/conformance/sheet/sheet-read-tiny.expected.json +85 -0
- package/conformance/sheet/sheet-read-tiny.html +18 -0
- package/conformance/sheet/sheet-read-tiny.meta +5 -0
- package/conformance/sheet/sheet-read-two-tabs.expected.json +128 -0
- package/conformance/sheet/sheet-read-two-tabs.html +25 -0
- package/conformance/sheet/sheet-read-two-tabs.meta +5 -0
- package/conformance/sheet/sheet-read-unknown-sheet.error.json +6 -0
- package/conformance/sheet/sheet-read-unknown-sheet.html +25 -0
- package/conformance/sheet/sheet-read-unknown-sheet.meta +6 -0
- package/conformance/sheet/sheet-read-version-1-codec.error.json +5 -0
- package/conformance/sheet/sheet-read-version-1-codec.html +25 -0
- package/conformance/sheet/sheet-read-version-1-codec.meta +5 -0
- package/conformance/sheet/sheet-write-whole-refused.data.json +3 -0
- package/conformance/sheet/sheet-write-whole-refused.error.json +7 -0
- package/conformance/sheet/sheet-write-whole-refused.html +25 -0
- package/conformance/sheet/sheet-write-whole-refused.meta +5 -0
- package/conformance/sheet-guard-extraction.json +616 -0
- package/conformance/sheet-guard.json +32362 -0
- package/conformance/sheet-read-shapes.json +1 -0
- package/dist/hyper-html-api.engine.esm.js +1 -1
- package/dist/hyper-html-api.engine.min.js +1 -1
- package/dist/hyper-html-api.min.js +8 -8
- package/dist/hyper-html-api.upgrade.min.js +2 -2
- package/package.json +6 -3
- package/src/codecs/sheet.js +127 -0
- package/src/codecs/sheet.vendor.js +887 -0
- package/src/dom-api.js +20 -11
- package/src/engine/apply.js +17 -7
- package/src/engine/codecs.js +80 -0
- package/src/engine/errors.js +20 -1
- package/src/engine/extract.js +17 -3
- package/src/engine/index.js +9 -5
- package/src/engine/round-trip.js +24 -10
- package/src/engine/rule-syntax.js +29 -3
- package/src/engine/rules-tag.js +3 -2
- package/src/engine/write-plan.js +4 -3
- package/src/page.js +15 -5
- package/src/patch-document.js +122 -0
- package/src/read.js +163 -0
- package/src/site.js +164 -0
- package/src/upgrade/codec-carry.js +23 -0
- package/src/upgrade/extract-all.js +12 -3
- package/src/upgrade/migrate.js +31 -3
- package/src/upgrade/rules-tags.js +4 -4
- package/src/upgrade/shape-match.js +32 -13
- package/src/write.js +44 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"tiny":{"tab":{"cols":["ca","cb","cc"],"rows":[{"id":"r1","cells":[{"v":"Item","style":"font-weight:bold"},"Cost","Share"]},{"id":"r2","cells":["Rent",{"v":1200,"text":"$1,200.00"},{"f":"=B2/B$5","v":0.8,"text":"80%"}]},{"id":"r3","cells":["Food",{"v":300,"text":"$300.00"},{"f":"=B3/B$5","v":0.2,"text":"20%"}]},{"id":"r4","cells":[]},{"id":"r5","cells":[{"v":"Total","style":"font-weight:bold"},{"f":"=SUM(B2:B3)","v":1500,"text":"$1,500.00"}]},{"id":"r6","cells":[{"v":"Prices as of November","style":"text-align:center","colspan":3}]}]},"index":{"rows":6,"cols":3,"frozenRows":1},"values":{"values":[["Item","Cost","Share"],["Rent",1200,0.8],["Food",300,0.2]]},"formulas":{"values":[[1200,"=B2/B$5"],[300,"=B3/B$5"],[null,null],["=SUM(B2:B3)",null],[null,null]]},"cells":{"cols":["ca","cb","cc"],"rows":[{"id":"r5","cells":[{"v":"Total","style":"font-weight:bold"},{"f":"=SUM(B2:B3)","v":1500,"text":"$1,500.00"}]},{"id":"r6","cells":[{"v":"Prices as of November","style":"text-align:center","colspan":3}]}]}},"merged":{"tab":{"cols":["m-c0","m-c1","m-c2","m-c3"],"rows":[{"id":"m-r1","cells":[{"v":"Title","colspan":3},null,null,"D1"]},{"id":"m-r2","cells":[{"v":"Tall","rowspan":2},"B2","C2"]},{"id":"m-r3","cells":[null,"B3",null,"D3"]},{"id":"m-r4","cells":[{"v":"Box","colspan":2,"rowspan":2}]}]},"index":{"rows":4,"cols":4,"frozenRows":0},"values":{"values":[["Title",null,null],["Tall","B2","C2"],[null,"B3",null]]},"formulas":{"values":[["B2","C2",null],["B3",null,"D3"],[null,null,null]]},"cells":{"cols":["m-c0","m-c1","m-c2"],"rows":[]}},"formulas-formatted":{"tab":{"cols":["ff-c0","ff-c1","ff-c2","ff-c3","ff-c4"],"rows":[{"id":"ff-r1","cells":[7,{"f":"=A1*1.5","v":10.5,"text":"$10.50","fmt":"$#,##0.00"},{"f":"=A1/70","v":0.1,"text":"10%","fmt":"0%"},{"f":"=DATE(2026,1,1)","v":46023,"text":"Jan 1, 2026","fmt":"mmm d, yyyy"},{"f":"=A1>35","v":false}]},{"id":"ff-r2","cells":[14,{"f":"=A2*1.5","v":21,"text":"$21.00","fmt":"$#,##0.00"},{"f":"=A2/70","v":0.2,"text":"20%","fmt":"0%"},{"f":"=DATE(2026,1,2)","v":46024,"text":"Jan 2, 2026","fmt":"mmm d, yyyy"},{"f":"=A2>35","v":false}]},{"id":"ff-r3","cells":[21,{"f":"=A3*1.5","v":31.5,"text":"$31.50","fmt":"$#,##0.00"},{"f":"=A3/70","v":0.3,"text":"30%","fmt":"0%"},{"f":"=DATE(2026,1,3)","v":46025,"text":"Jan 3, 2026","fmt":"mmm d, yyyy"},{"f":"=A3>35","v":false}]},{"id":"ff-r4","cells":[28,{"f":"=A4*1.5","v":42,"text":"$42.00","fmt":"$#,##0.00"},{"f":"=A4/70","v":0.4,"text":"40%","fmt":"0%"},{"f":"=DATE(2026,1,4)","v":46026,"text":"Jan 4, 2026","fmt":"mmm d, yyyy"},{"f":"=A4>35","v":false}]},{"id":"ff-r5","cells":[35,{"f":"=A5*1.5","v":52.5,"text":"$52.50","fmt":"$#,##0.00"},{"f":"=A5/70","v":0.5,"text":"50%","fmt":"0%"},{"f":"=DATE(2026,1,5)","v":46027,"text":"Jan 5, 2026","fmt":"mmm d, yyyy"},{"f":"=A5>35","v":false}]},{"id":"ff-r6","cells":[42,{"f":"=A6*1.5","v":63,"text":"$63.00","fmt":"$#,##0.00"},{"f":"=A6/70","v":0.6,"text":"60%","fmt":"0%"},{"f":"=DATE(2026,1,6)","v":46028,"text":"Jan 6, 2026","fmt":"mmm d, yyyy"},{"f":"=A6>35","v":true}]},{"id":"ff-r7","cells":[49,{"f":"=A7*1.5","v":73.5,"text":"$73.50","fmt":"$#,##0.00"},{"f":"=A7/70","v":0.7,"text":"70%","fmt":"0%"},{"f":"=DATE(2026,1,7)","v":46029,"text":"Jan 7, 2026","fmt":"mmm d, yyyy"},{"f":"=A7>35","v":true}]},{"id":"ff-r8","cells":[56,{"f":"=A8*1.5","v":84,"text":"$84.00","fmt":"$#,##0.00"},{"f":"=A8/70","v":0.8,"text":"80%","fmt":"0%"},{"f":"=DATE(2026,1,8)","v":46030,"text":"Jan 8, 2026","fmt":"mmm d, yyyy"},{"f":"=A8>35","v":true}]},{"id":"ff-r9","cells":[63,{"f":"=A9*1.5","v":94.5,"text":"$94.50","fmt":"$#,##0.00"},{"f":"=A9/70","v":0.9,"text":"90%","fmt":"0%"},{"f":"=DATE(2026,1,9)","v":46031,"text":"Jan 9, 2026","fmt":"mmm d, yyyy"},{"f":"=A9>35","v":true}]},{"id":"ff-r10","cells":[70,{"f":"=A10*1.5","v":105,"text":"$105.00","fmt":"$#,##0.00"},{"f":"=A10/70","v":1,"text":"100%","fmt":"0%"},{"f":"=DATE(2026,1,10)","v":46032,"text":"Jan 10, 2026","fmt":"mmm d, yyyy"},{"f":"=A10>35","v":true}]}]},"index":{"rows":10,"cols":5,"frozenRows":0},"values":{"values":[[7,10.5,0.1],[14,21,0.2],[21,31.5,0.3]]},"formulas":{"values":[["=A2*1.5","=A2/70","=DATE(2026,1,2)"],["=A3*1.5","=A3/70","=DATE(2026,1,3)"],["=A4*1.5","=A4/70","=DATE(2026,1,4)"],["=A5*1.5","=A5/70","=DATE(2026,1,5)"],["=A6*1.5","=A6/70","=DATE(2026,1,6)"],["=A7*1.5","=A7/70","=DATE(2026,1,7)"],["=A8*1.5","=A8/70","=DATE(2026,1,8)"],["=A9*1.5","=A9/70","=DATE(2026,1,9)"]]},"cells":{"cols":["ff-c0","ff-c1","ff-c2"],"rows":[{"id":"ff-r5","cells":[35,{"f":"=A5*1.5","v":52.5,"text":"$52.50","fmt":"$#,##0.00"},{"f":"=A5/70","v":0.5,"text":"50%","fmt":"0%"}]},{"id":"ff-r6","cells":[42,{"f":"=A6*1.5","v":63,"text":"$63.00","fmt":"$#,##0.00"},{"f":"=A6/70","v":0.6,"text":"60%","fmt":"0%"}]}]}},"refusals":[["A0",null,"bad_range","range \"A0\" is not an A1 cell or rectangle such as B2 or A1:C3"],["B2:A1",null,"bad_range","range \"B2:A1\" is reversed: write the top left cell first"],["A1:B2:C3",null,"bad_range","range \"A1:B2:C3\" has more than one colon"],["XFE1",null,"bad_range","range \"XFE1\" is not an A1 cell or rectangle such as B2 or A1:C3"],["",null,"bad_range","range \"\" is not an A1 cell or rectangle such as B2 or A1:C3"],["a1",null,"bad_range","range \"a1\" is not an A1 cell or rectangle such as B2 or A1:C3"],["A1","html","bad_render","render must be one of values, formulas, cells"],[12,null,"bad_range","range must be text such as A1:C3"]]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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};
|
|
1
|
+
var At=Object.defineProperty;var Et=(e,t)=>{for(var n in t)At(e,n,{get:t[n],enumerable:!0})};var re=["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"],ie=new Set(re),he=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),B=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),$e=new Set(["checked","selected","disabled","readOnly","paused"]);function pe(e,t){return t==null?$e.has(e)?!1:"":$e.has(e)?t==="false"?!1:!!t:t}var R={};Et(R,{CodecRefused:()=>ge,EmptyListInsert:()=>P,MAX_RULE_DEPTH:()=>M,MaxRuleDepthExceeded:()=>_,NoRulesTag:()=>me,RuleTargetReadOnly:()=>z,RulesParseError:()=>C,ShapeMismatch:()=>U,UnknownCodec:()=>K,UnknownRulesVersion:()=>H,WriteNotRoundTripped:()=>oe,WriteRefused:()=>F,WriteRejected:()=>ye});var C=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},H=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1" and "2".`),this.name="UnknownRulesVersion",this.version=t}},M=20,_=class extends Error{constructor(t){super(`rule depth exceeded ${M} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},U=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},P=class extends Error{constructor(t,n){super(n?`cannot add items to empty list at "${t.join(".")}" \u2014 ${n}`:`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},z=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},F=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function Tt(e){return e.reduce((n,i)=>typeof i=="number"?`${n}[${i}]`:n?`${n}.${i}`:String(i),"")||"(root)"}var oe=class extends Error{constructor(t){super(`write did not round-trip at "${Tt(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},me=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},ye=class extends Error{constructor(t,n){super(`write rejected: ${t.length} unknown key(s), ${n.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=t,this.unmatched=n}},K=class extends Error{constructor(t){super(`unknown codec "${t}": no codec by that name is given to this call`),this.name="UnknownCodec",this.code="unknown-codec",this.codec=t}},ge=class extends Error{constructor(t,n){super(n),this.name="CodecRefused",this.code=t}};function N(e){let t=0,n=null,i=-1;for(let r=0;r<e.length;r++){let o=e[r];o==="\\"?r++:n?o===n&&(n=null):o==='"'||o==="'"?n=o:o==="["||o==="("?t++:o==="]"||o===")"?t>0&&t--:o==="@"&&t===0&&(i=r)}return i}var je="[*]";function b(e){let t=N(e),n=t===-1?e:e.slice(0,t),i=n.endsWith(je),r={selector:i?n.slice(0,-je.length):n,prop:t===-1?null:e.slice(t+1)||null};return i&&(r.all=!0),r}function we(e){let t=0,n=null,i=-1,r=!1;for(let o=0;o<e.length;o++){let c=e[o];c==="\\"?o++:n?c===n&&(n=null):c==='"'||c==="'"?n=c:c==="["||c==="("?t++:c==="]"||c===")"?t>0&&t--:t===0&&c===">"?i=o:t===0&&c===","&&(r=!0)}return r||i===-1||!Ot(e,i+1)?null:e.slice(0,i).trim()||null}function Ot(e,t){let n=t,i=e.replace(/\s+$/,"").length;for(;n<i&&/\s/.test(e[n]);)n++;let r=0,o=null;for(;n<i;n++){let c=e[n];if(c==="\\")n++;else if(o)c===o&&(o=null);else if(c==='"'||c==="'")o=c;else if(c==="["||c==="(")r++;else if(c==="]"||c===")")r>0&&r--;else if(r===0&&(c==="+"||c==="~"||/\s/.test(c)))return!1}return!0}var St=/^codec\(([a-z][a-z0-9-]*)\)$/;function $(e){if(typeof e!="string")return null;let t=N(e);if(t===-1)return null;let n=St.exec(e.slice(t+1));if(!n)return null;let{selector:i,all:r}=b(e);if(r)throw new C("A @codec(name) rule cannot use [*].");return{selector:i,name:n[1]}}var xt=/^--[A-Za-z0-9_-]+$/;function k(e){return typeof e=="string"&&xt.test(e)}function De(e){let t=[],n=[],i=null,r=0;for(let o=0;o<e.length;o++){let c=e[o];if(i){c==="\\"?o++:c===i&&(i=null);continue}if(c==="/"&&e[o+1]==="*"){let l=e.indexOf("*/",o+2);o=l===-1?e.length:l+1;continue}c==='"'||c==="'"?i=c:c==="("?n.push(")"):c==="["?n.push("]"):c==="{"?n.push("}"):(c===")"||c==="]"||c==="}")&&n[n.length-1]===c?n.pop():c===";"&&n.length===0&&(t.push(e.slice(r,o)),r=o+1)}return t.push(e.slice(r)),t}function bt(e){let t="",n=null;for(let i=0;i<e.length;i++){let r=e[i];if(n){t+=r,r==="\\"&&i+1<e.length?t+=e[++i]:r===n&&(n=null);continue}if(r==="/"&&e[i+1]==="*"){let o=e.indexOf("*/",i+2);i=o===-1?e.length:o+1,t+=" ";continue}(r==='"'||r==="'")&&(n=r),t+=r}return t}function ve(e){e=bt(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),i=e.slice(t+1).trim(),r=/!\s*important\s*$/i.exec(i);return r&&(i=i.slice(0,r.index).trim()),{name:n,value:i,important:!!r}}function v(e,t){if(e==null)return null;let n=null;for(let i of De(String(e))){let r=ve(i);!r||r.name!==t||(!n||r.important||!n.important)&&(n=r)}return n?n.value:null}function We(e,t,n){let i=e==null?"":String(e),r=n==null||n==="",o=De(i),c=o.map(ve),l=c.some(d=>d&&d.name===t&&d.important),s=[],f=!1;o.forEach((d,h)=>{let A=c[h];if(!A||A.name!==t){s.push(d);return}if(r||f)return;let a=/^\s*/.exec(d)[0];s.push(`${a}${t}: ${n}${l?" !important":""}`),f=!0});let u=s.join(";");if(!r&&!f){let d=u.trimEnd();u=d===""?`${t}: ${n}`:`${d}${d.endsWith(";")?" ":"; "}${t}: ${n}`}return u.trim()===""?null:u}function se(e,t,n,i){let r=e.attr(t,"style");if((v(r,n)??"")===i)return;let o=We(r,n,i);o==null?e.removeAttr(t,"style"):e.attr(t,"style",o)}var qe=/^[a-z][a-z0-9-]*$/,Ae=new Map;function Ee(e,t){if(typeof e!="string"||!qe.test(e))throw new Error(`hyper-html-api: invalid codec name ${JSON.stringify(e)} (must match ${qe})`);if(!t||typeof t.read!="function"||typeof t.write!="function"||typeof t.same!="function")throw new Error(`hyper-html-api: codec "${e}" needs read, write and same functions`);Ae.set(e,t)}function Te(e){return Ae.get(e)??null}function Oe(){return Object.fromEntries(Ae)}var Rt='The @codec(name) rule form needs a rules tag with data-rules-version="2".',Ct="A @codec(name) rule must be the value of a top level key.";function ce(e,t){let n=$(e);return n?{...n,codec:t.codecs[n.name]}:null}function j(e,t={}){let n=t.version??"1",i=t.codecs??{};r(e,0);function r(o,c){if(!(c>M)){if(typeof o=="string"){let l=$(o);if(!l)return;if(n!=="2")throw new C(Rt);if(c!==1)throw new C(Ct);if(!Object.prototype.hasOwnProperty.call(i,l.name))throw new K(l.name);return}if(Array.isArray(o)){r(o[1],c+1);return}if(o&&typeof o=="object")for(let l of Object.values(o))r(l,c+1)}}}function L(e,t,n,i={}){if(Object.prototype.hasOwnProperty.call(i,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return j(n,i),xe(e,t,n,{depth:0,path:[]},i)}function xe(e,t,n,i,r){if(i.depth>M)throw new _(i.path);if(typeof n=="string")return Nt(e,t,n,i,r);if(Array.isArray(n)){let[o,c]=n,l=e.find(t,o,r);return Ve(r,i,l),l.map((s,f)=>xe(e,s,c,{depth:i.depth+1,path:[...i.path,f]},r))}if(typeof n=="object"&&n!==null){let o={};for(let[c,l]of Object.entries(n))o[c]=xe(e,t,l,{depth:i.depth+1,path:[...i.path,c]},r);return o}return null}function Nt(e,t,n,i,r){if(n.endsWith("[]")){let u=n.slice(0,-2),d=e.find(t,u,r);return Ve(r,i,d),d.map(h=>e.text(h))}let o=ce(n,r);if(o)return Pt(e,t,o,r);if(n.startsWith("@"))return Se(e,t,n.slice(1));let c=N(n);if(c!==-1){let{selector:u,all:d}=b(n),h=n.slice(c+1),A=u?e.find(t,u,r):[t];return d&&r.allMatches?A.map(a=>Se(e,a,h)):A.length===0?null:Se(e,A[0],h)}if(n===".")return e.text(t);let{selector:l,all:s}=b(n),f=e.find(t,l,r);return s&&r.allMatches?f.map(u=>e.text(u)):f.length===0?null:e.text(f[0])}function Pt(e,t,{selector:n,codec:i},r){let o=n?e.find(t,n,r):[t];return o.length===0?null:i.read(e,o[0],{query:r.query,view:r.view,region:r.region})}function Ve(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(i){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,i)}}function Se(e,t,n){if(k(n))return v(e.attr(t,"style"),n);if(ie.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let i=e.attr(t,n);return i??null}function Ue(e,t,n,i){let r=e.length,o=t.length,c=new Array(r).fill(-1);if(i){let p=new Set;for(let y=0;y<r;y++){let w=i[y];!(w>=0&&w<o)||p.has(w)||(c[y]=w,p.add(w))}}if(r===0||o===0)return c;let l=e.map(p=>Be(p,n)),s=t.map(p=>Be(p,n)),f=new Array(o).fill(!1);for(let p of c)p>=0&&(f[p]=!0);let u=new Map;s.forEach((p,y)=>{f[y]||u.set(p,u.has(p)?-1:y)});let d=new Map;l.forEach((p,y)=>{c[y]>=0||d.set(p,(d.get(p)||0)+1)}),l.forEach((p,y)=>{if(c[y]>=0||d.get(p)!==1)return;let w=u.get(p);w===void 0||w===-1||f[w]||(c[y]=w,f[w]=!0)});let h=[];for(let p=0;p<r;p++)c[p]<0&&h.push(p);let A=[];for(let p=0;p<o;p++)f[p]||A.push(p);if(h.length===0||A.length===0)return c;let a=r*o+1,m=Mt(e,t,n),g=(p,y)=>m(p,y)*a+Math.abs(p-y);for(let[p,y]of kt(h,A,g))c[p]=y;return c}var ze=e=>typeof e=="object"&&e!==null;function Be(e,t){if(!ze(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(i=>{let r=JSON.stringify(e?.[i]);return r===void 0?" undef":r}))}function Mt(e,t,n){if(!ze(n))return(l,s)=>e[l]===t[s]?0:1;let i=Object.keys(n),r=l=>i.map(s=>JSON.stringify(l?.[s])),o=e.map(r),c=t.map(r);return(l,s)=>{let f=o[l],u=c[s],d=0;for(let h=0;h<i.length;h++)f[h]!==u[h]&&d++;return d}}function kt(e,t,n){return e.length<=t.length?He(e,t,n,!1):He(t,e,(i,r)=>n(r,i),!0)}function He(e,t,n,i){let r=e.length,o=t.length,c=[];for(let d=0;d<=r;d++)c.push(new Float64Array(o+1).fill(1/0));let l=[];for(let d=0;d<=r;d++)l.push(new Uint8Array(o+1));for(let d=0;d<=o;d++)c[r][d]=0;for(let d=r-1;d>=0;d--)for(let h=o-1;h>=0;h--){let A=n(e[d],t[h])+c[d+1][h+1],a=c[d][h+1];A<=a?(c[d][h]=A,l[d][h]=1):c[d][h]=a}let s=[],f=0,u=0;for(;f<r&&u<o;)l[f][u]&&(s.push(i?[t[u],e[f]]:[e[f],t[u]]),f++),u++;return s}function Re(e,t,n,i,r,o,c,l={}){let s=e.find(t,n,l);if(r.length===0){s.forEach(E=>e.remove(E)),be(l,"onRowsApplied",o.path,[]);return}let f=r.length>s.length,u=s[0]||null;if(f&&!u&&(u=$t(e,t,n,l),!u))throw new P(o.path);let d=s.map(E=>_t(e,E,i,l)),h=null;if(f&&u){h=e.clone(u),l.templateAttr&&e.removeAttr(h,l.templateAttr);let E=e.stripIds(h);E>0&&console.warn(`[hyper-html-api] stripped ${E} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let A=Ue(r,d,i,Lt(e,s,r,o,l)),a=s.length>0?e.parent(s[0]):Wt(e,t,n,u,o,l),m=s.length>0?Ye(e,a,s[0]):0,g=Bt(e,s),p=new Set,y=[],w=r.map((E,x)=>{let O=A[x];if(O>=0)return p.add(O),y.push(!1),s[O];y.push(!0);let T=e.clone(h);return e.stripIds(T),T});s.forEach((E,x)=>{p.has(x)||e.remove(E)}),g?Vt(e,a,m,w,y):Ht(e,w,y,a,m),It(e,w,i,r,o,c,l),be(l,"onRowsApplied",o.path,w)}function be(e,t,n,i){if(typeof e[t]=="function")try{return e[t](n.slice(),i)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function Lt(e,t,n,i,r){let o=be(r,"identifyRows",i.path,n);if(!Array.isArray(o))return null;let c=new Array(n.length).fill(-1),l=new Set,s=new Map(t.map((f,u)=>[e.identity(f),u]));for(let f=0;f<n.length;f++){if(!o[f])continue;let u=s.get(e.identity(o[f]));u===void 0||l.has(u)||(c[f]=u,l.add(u))}return c}function It(e,t,n,i,r,o,c){t.forEach((l,s)=>{if(n===null){let f=i[s],u=f==null?"":String(f);e.text(l)!==u&&e.text(l,u)}else{let f=o(e,l,n,i[s],{depth:r.depth+1,path:[...r.path,s]},c);f&&f!==l&&(t[s]=f)}})}function _t(e,t,n,i){return n===null?e.text(t):L(e,t,n,i.onRowsRead?{...i,onRowsRead:void 0}:i)}function Ye(e,t,n){let i=e.children(t);for(let r=0;r<i.length;r++)if(e.sameNode(i[r],n))return r;return-1}function $t(e,t,n,i){if(!i.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),o=new RegExp(":not\\(\\["+i.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),c=n.replace(/^\s*:scope\s*>\s*/,"").replace(o,""),l=r?jt(c):0,s=we(c),f=t;for(;f;){let u=e.find(f,c,{includeRulesTag:!1,templateAttr:null});for(let d of u)if(e.attr(d,i.templateAttr)!=null&&!(r&&!vt(e,t,d,l))&&!(s&&!e.matches(e.parent(d),s)))return d;f=e.parent(f)}return null}function jt(e){let t=0,n=null,i=1;for(let r=0;r<e.length;r++){let o=e[r];if(o==="\\")r++;else if(n)o===n&&(n=null);else if(o==='"'||o==="'")n=o;else if(o==="["||o==="(")t++;else if(o==="]"||o===")")t>0&&t--;else if(t===0&&o===">")i++;else{if(t===0&&(o==="+"||o==="~"))return null;if(t===0&&/\s/.test(o)){if(!Dt(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return i}function Dt(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let i=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return Fe(i)||Fe(r)}function Fe(e){return e===">"||e==="+"||e==="~"}function vt(e,t,n,i){if(i===null)return!0;let r=n;for(let s=0;s<i;s++)if(r=e.parent(r),!r)return!1;let o=e.prop(t,"tagName");if(!o)return!0;let c=e.prop(r,"tagName");if(!c||String(c).toLowerCase()!==String(o).toLowerCase())return!1;let l=new Set(Ke(e,r));return Ke(e,t).every(s=>l.has(s))}function Ke(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function Wt(e,t,n,i,r,o){let c=e.parent(i);if(c&&qt(e,t,c)&&!Xe(e,c,o))return c;let l=we(n);if(!l)throw new P(r.path,`the list selector "${n}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let f=(l===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,l,o)).filter(u=>!Xe(e,u,o));if(f.length===0)throw new P(r.path,`no container matching "${l}" inside this context to hold the new rows`);if(f.length>1)throw new P(r.path,`"${l}" matches ${f.length} containers inside this context, so the new rows have no single destination`);return f[0]}function qt(e,t,n){let i=n;for(;i;){if(e.sameNode(i,t))return!0;i=e.parent(i)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(r=>e.sameNode(r,n))}var Je=["no-data","editor-ui"];function Xe(e,t,n){let i=t;for(;i;){if(n.templateAttr&&e.attr(i,n.templateAttr)!=null||Je.some(o=>e.attr(i,o)!=null))return!0;let r=e.attr(i,"clay");if(r&&r.split(/\s+/).some(o=>Je.includes(o)))return!0;i=e.parent(i)}return!1}function Vt(e,t,n,i,r){let o=e.children(t),c=o.map(s=>e.identity(s)),l=!1;i.forEach((s,f)=>{let u=e.identity(s),d=n+f;if(c[d]===u)return;if(!r[f]){let A=c.indexOf(u);A!==-1&&(c.splice(A,1),o.splice(A,1))}let h=Math.min(d,o.length);h<o.length?e.insertBefore(o[h],s):o.length?l?e.insertAfter(o[o.length-1],s):(e.insertAt(t,s,d),l=!0):e.insertAt(t,s,0),c.splice(h,0,u),o.splice(h,0,s)})}function Bt(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let i=new Map(e.children(n).map((o,c)=>[e.identity(o),c])),r=[];for(let o of t){let c=i.get(e.identity(o));if(c===void 0)return!1;r.push(c)}return r.sort((o,c)=>o-c),r[r.length-1]-r[0]===r.length-1}function Ht(e,t,n,i,r){let o=null,c=r;for(let l=0;l<t.length;l++){if(!n[l]){o=t[l];continue}let s=o?e.parent(o):i;if(!s)continue;let f=o?Ye(e,s,o)+1:c++;e.insertAt(s,t[l],f),o=t[l]}}function D(e,t,n,i,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");j(n,r);let o=[];if(Ce(n,i,[],o),o.length)throw new U(o);le(e,t,n,i,{depth:0,path:[]},r)}function le(e,t,n,i,r,o={}){if(r.depth>M)throw new _(r.path);if(i===void 0)return t;if(typeof n=="string")return Ut(e,t,n,i,r,o);if(Array.isArray(n)){let[c,l]=n;return Re(e,t,c,l,i,r,le,o),t}if(typeof n=="object"&&n!==null){for(let[c,l]of Object.entries(n)){let s=le(e,t,l,i==null?i:i[c],{depth:r.depth+1,path:[...r.path,c]},o);s&&s!==t&&(t=s)}return t}return t}function Ut(e,t,n,i,r,o){if(n.endsWith("[]")){let d=n.slice(0,-2);return Re(e,t,d,null,i,r,le,o),t}let c=ce(n,o);if(c){let d=c.selector?e.find(t,c.selector,o):[t];return d.length&&c.codec.write(e,d[0],i,{query:o.query}),t}if(n.startsWith("@"))return Ze(e,t,n.slice(1),i);let l=N(n);if(l!==-1){let{selector:d,all:h}=b(n),A=n.slice(l+1),a=d?e.find(t,d,o):[t];for(let m of h?a:a.slice(0,1))Ze(e,m,A,i);return t}if(n===".")return Ge(e,t,i),t;let{selector:s,all:f}=b(n),u=e.find(t,s,o);for(let d of f?u:u.slice(0,1))Ge(e,d,i);return t}function Ge(e,t,n){let i=n==null?"":String(n);e.text(t)!==i&&e.text(t,i)}function zt(e,t,n,i){if(e.styleVar){e.styleVar(t,n,i);return}se(e,t,n,i)}function Ze(e,t,n,i){if(k(n))return zt(e,t,n,i==null?"":String(i).trim()),t;if(B.has(n)){let r=e.prop(t,n);if(r===i||r!=null&&i!=null&&String(r)===String(i))return t;throw new z(n)}if(n==="outerHTML"){let r=i==null?"":String(i);return e.replaceWith(t,r)}if(he.has(n)){let r=pe(n,i);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(i==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(i);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function Ce(e,t,n,i){if(t!==void 0){if(typeof e=="string"){if($(e))return;if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,o)=>{typeof r=="object"&&r!==null&&i.push({path:X([...n,o]),expected:"scalar",got:J(r)})}):i.push({path:X(n),expected:"array",got:J(t)});return}t!==null&&typeof t=="object"&&i.push({path:X(n),expected:"scalar",got:J(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){i.push({path:X(n),expected:"array",got:J(t)});return}let r=e[1];t.forEach((o,c)=>Ce(r,o,[...n,c],i));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){i.push({path:X(n),expected:"object",got:J(t)});return}for(let[r,o]of Object.entries(e))Ce(o,t[r],[...n,r],i)}}}function J(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function X(e){return e.join(".")}function Ne(e){try{return JSON.parse(e)}catch(t){throw new C(`Invalid strict JSON: ${t.message}`,t)}}function Y(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function n(r){let o=[],c=0;for(;c<r.length;){let l=r[c];if(/\s/.test(l)){c++;continue}if("{}".includes(l)){o.push({type:l,value:l}),c++;continue}if(l==="["){let d=!1,h=c+1;for(;h<r.length&&/\s/.test(r[h]);)h++;if(h<r.length&&/[a-zA-Z_]/.test(r[h])&&(d=!0),!d){o.push({type:l,value:l}),c++;continue}}if(l==="]"){o.push({type:l,value:l}),c++;continue}if(l===":"){o.push({type:t.COLON,value:l}),c++;continue}if(l===","){o.push({type:t.COMMA,value:l}),c++;continue}if(l==='"'||l==="'"){let d=l,h=c+1;for(;h<r.length&&r[h]!==d;)r[h]==="\\"&&h++,h++;o.push({type:t.STRING,value:r.substring(c+1,h),quoted:!0,sourceQuote:d}),c=h+1;continue}let s=c,f;for(;s<r.length&&!/[{},]/.test(r[s]);)if(r[s]===":"){let d=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],h=!1;for(let A of d){let a=A.substring(1);if(r.substring(s+1,s+1+a.length)===a){h=!0,s+=a.length;break}}if(!h)break}else if(r[s]==="["){for(s++;s<r.length&&r[s]!=="]";){if(r[s]==='"'||r[s]==="'"){let d=r[s];for(s++;s<r.length&&r[s]!==d;)r[s]==="\\"&&s++,s++}s++}s<r.length&&r[s]==="]"&&s++}else s++;f=r.substring(c,s);let u=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(f)?u=t.NUMBER:f==="true"||f==="false"||f==="null"?u=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(f)&&(u=t.SELECTOR),o.push({type:u,value:f,quoted:!1}),c=s}return o}function i(r){let o="";for(let c=0;c<r.length;c++){let l=r[c];if("{}".includes(l.type)||"[]".includes(l.type)){o+=l.value;continue}if(l.type===t.COLON){o+=l.value;continue}if(l.type===t.COMMA){let s=r[c+1];if(s&&(s.type==="}"||s.type==="]"))continue;o+=l.value;continue}if(l.type===t.STRING&&l.quoted){let s=l.value;l.sourceQuote==="'"&&(s=s.replace(/\\'/g,"'"),s=s.replace(/(\\*)"/g,(f,u)=>u.length%2===0?u+'\\"':f)),o+=`"${s}"`;continue}if(l.type===t.NUMBER||l.type===t.BOOLEAN){o+=l.value;continue}if(l.type===t.SELECTOR||l.type===t.IDENTIFIER){o+=`"${l.value}"`;continue}o+=`"${l.value}"`}return o}try{let r=n(e),o=i(r);return JSON.parse(o)}catch(r){throw new C("Invalid extraction rules syntax: "+r.message,r)}}var et=["1","2"],Qe=/^[a-zA-Z0-9_-]+$/;function W(e,t,n){let i;if(n===void 0)i="script[data-rules-name]";else{if(typeof n!="string"||!Qe.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${Qe})`);i=`script[data-rules-name~="${n}"]`}let r=e.find(t,i,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let o=r[0],c=e.attr(o,"data-rules-version");if(!et.includes(c))throw new H(c);return{rules:Y(e.text(o)),tagNode:o,version:c}}var fe=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"]})}),Ft=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),tt=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function G(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function Pe(e,t){if(G(e,t))return!0;for(let[n,i]of Object.entries(Ft))if(i.includes(t)&&G(e,n))return!0;return!1}function Z(e){let t=fe[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 i=fe[t];if(!i)throw new Error(`Unknown region capability: ${t}`);if(i.tokens.some(r=>Pe(n,r))||i.bundles.some(r=>G(n,r)))return n;n=n.parentElement}return null}function nt(e,t){return!!Kt(e,t)}var ue=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",...tt],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"]})}),Jt=new Set(["textContent","innerText"]);function rt(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 it(e,t,n=ue){if(!Xt.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let i=String(e).toLowerCase();if(n.refusedAttributePrefixes.some(r=>i.startsWith(r)))return`attribute "${i}" can run script`;if(n.refusedAttributes.includes(i))return`attribute "${i}" is not content`;if(n.urlAttributes.includes(i)&&t!=null){let r=i==="srcset"?String(t).split(",").map(o=>o.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let o of r){let c=rt(o);if(c&&n.refusedSchemes.includes(c))return`"${c}:" URLs are not allowed in "${i}"`}}return null}function Me(e,t){let n=e.prop(t,"tagName");return n?String(n).toLowerCase():""}function Yt(e,t){let n=Me(e,t)||"node",i=e.attr(t,"id");return i?`<${n}#${i}>`:`<${n}>`}function Gt(e,t,n){let i=t;for(;i;){let r=Me(e,i);if(r&&n.refusedTargets.includes(r))return r;i=e.parent(i)}return null}function ot(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function Zt(e,t){return Me(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:ot(e,t)}function Qt(e){if(/[\u0000-\u001f\u007f]/.test(e))return"control characters are not allowed in a custom property value";let t=[],n=null;for(let i=0;i<e.length;i++){let r=e[i];if(n){r===n&&(n=null);continue}if(r==='"'||r==="'")n=r;else{if(r==="/"&&e[i+1]==="*")return"comments are not allowed in a custom property value";if(r==="(")t.push(")");else if(r==="[")t.push("]");else if((r===")"||r==="]")&&t.pop()!==r)return`"${r}" does not close anything in this custom property value`}}return n?"a custom property value must close its quotes":t.length?"a custom property value must close its brackets":null}function st(e,t=ue){let n=t.customPropertyValues,i=String(e);if(i.length>n.maxLength)return`custom property values are limited to ${n.maxLength} characters`;let r=n.refusedCharacters.find(s=>i.includes(s));if(r)return`${JSON.stringify(r)} is not allowed in a custom property value`;let o=Qt(i);if(o)return o;let c=i.toLowerCase(),l=n.refusedFunctions.find(s=>new RegExp(`(^|[^a-z0-9_-])${s.replace(/[-]/g,"\\-")}\\s*\\(`).test(c));return l?`"${l}()" is not allowed in a custom property value`:null}function ae(e,t=ue){let n=[],i=(s,f)=>(n.push({target:Yt(e,s),reason:f}),!1),r=s=>{let f=Gt(e,s,t);return f?i(s,`inside <${f}>, which is not content`):!0},o=s=>r(s)?ot(e,s)?i(s,"a text write here would delete the data rules tag"):!0:!1,c=(s,f,u)=>{if(!r(s))return!1;let d=it(f,u,t);return d?i(s,d):!0};return{...e,text(s,f){if(f===void 0)return e.text(s);o(s)&&e.text(s,f)},attr(s,f,u){if(u===void 0)return e.attr(s,f);c(s,f,u)&&e.attr(s,f,u)},removeAttr(s,f){c(s,f,null)&&e.removeAttr(s,f)},styleVar(s,f,u){if((v(e.attr(s,"style"),f)??"")!==u&&r(s)){if(!k(f))return i(s,`"${f}" is not a custom property`);if(u!==""){let d=st(u,t);if(d)return i(s,d)}se(e,s,f,u)}},prop(s,f,u){if(u===void 0)return e.prop(s,f);if(t.refusedRuleForms.includes(f))return i(s,`"@${f}" writes HTML, only text is allowed`);if(Jt.has(f)){o(s)&&e.prop(s,f,u);return}c(s,f==="className"?"class":f,u)&&e.prop(s,f,u)},remove(s){if(Zt(e,s)){i(s,"removing this would delete the data rules tag");return}e.remove(s)},replaceWith(s,f){return f===e.prop(s,"outerHTML")||i(s,'"@outerHTML" writes HTML, only text is allowed'),s},refusals:n,assertClean(){if(n.length)throw new F(n.slice())}}}function Q(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ct(e){return e.reduce((t,n)=>typeof n=="number"?`${t}[${n}]`:t?`${t}.${n}`:n,"")}function ke(e,t,n,i,r={}){j(n,r);let o=[],c=[];function l(f,u,d){if(Array.isArray(f)){let[,h]=f;if(!Array.isArray(u)||!Q(h))return;u.forEach((A,a)=>l(h,A,[...d,a]));return}if(!(!Q(f)||!Q(u)))for(let h of Object.keys(u))Object.prototype.hasOwnProperty.call(f,h)?l(f[h],u[h],[...d,h]):o.push(ct([...d,h]))}function s(f,u,d,h){if(d!==void 0){if(typeof u=="string"){if(u.endsWith("[]")||u==="."||u.startsWith("@"))return;let{selector:A}=b(u);if(!A)return;e.find(f,A,r).length===0&&c.push({path:ct(h),selector:A});return}if(!Array.isArray(u)&&Q(u)&&Q(d))for(let[A,a]of Object.entries(u))s(f,a,d[A],[...h,A])}}return l(n,i,[]),s(t,n,i,[]),{unknownKeys:o,unmatched:c}}function Le(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null,version:"1"};if(typeof n=="string"){let i=t&&t.ownerDocument?t.ownerDocument:t;return W(e,i,n)}return null}var tn=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function nn(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 lt(e,t,n,i){if(i)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function ft(e,t,n,i,r,o){return(o?nt(e,t):lt(e,n,r,!1))||!!(i&&(o&&e!==r?e.matches(i):lt(e,i,r,o)))}function rn(e,t){let n=fe[t];return n.tokens.some(i=>Pe(e,i))||n.bundles.some(i=>G(e,i))}var on=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function ut(e,t,n,i){if(e.nodeType===1&&i(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,o=t;if(e.nodeType===1){if(on.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,o=t.content,n.cloneToLive.set(o,r),n.liveToClone.set(r,o)}}else if(e.nodeType!==11)return;let c=o.firstChild;for(let l=r.firstChild;l&&c;l=l.nextSibling)ut(l,c,n,i),c=c.nextSibling}function ee(e,{capability:t="data",exclude:n=null,inherit:i=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let o=e.nodeType===9?e:e.ownerDocument;if(!o?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let c=o.implementation.createHTMLDocument(""),l=r||new WeakMap,s=new WeakMap,f=e.nodeType===9?e.documentElement:e;n&&c.documentElement.matches(n);let u=Z(t),d=i?a=>rn(a,t)||!!(n&&a.matches(n)):a=>ft(a,t,u,n,f,!1),h=null;if(f.nodeType!==1||!ft(f,t,u,n,f,i)){h=c.importNode(f,!0);let a={cloneToLive:l,liveToClone:s,dropped:[],controls:[]};ut(f,h,a,d);for(let m of a.dropped)m.remove();for(let m=0;m<a.controls.length;m+=2)nn(a.controls[m],a.controls[m+1])}e.nodeType===9&&h&&(c.replaceChild(h,c.documentElement),s.set(e,c),l.set(c,e));let A=a=>{if(tn.test(a))throw new Error(`Filtered content queries do not support stateful selector: ${a}`)};return{root:h,document:c,capability:t,selector:Z(t),cloneToLive:l,liveToClone:s,original(a){return l.get(a)||null},cloneOf(a){return s.get(a)||null},query(a,m=h){return A(a),Array.from(m.querySelectorAll(a),g=>l.get(g)||g)},text(a=h){return(a===h?h:s.get(a))?.textContent||""},html(a=h){return(a===h?h:s.get(a))?.innerHTML??""},clone(a=h){let m=a===h?h:s.get(a);return m?c.importNode(m,!0):null}}}function dt(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function sn(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function at(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 ht(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function pt(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let i=n.type;i!=="file"&&i!=="checkbox"&&i!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var S={semanticExclude:!0,find(e,t,n={}){let i=sn(e);if(!i||!i.querySelectorAll)return[];let r=Array.from(i.querySelectorAll(t));n.includeRulesTag||(r=r.filter(l=>!dt(l)));let o=[];n.skip&&o.push(n.skip);let c=n.templateAttr===null?null:n.templateAttr||"cms-template";if(c&&o.push("["+c+"]"),o.length){let l=o.join(", ");r=r.filter(s=>!s.closest||!s.closest(l))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,ht(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),at(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),at(e,t,null)},prop(e,t,n){if(n===void 0){let i=e?e[t]:void 0;return i!==void 0?i:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return pt(t),t},insertAt(e,t,n){let i=e.children[n]||null;e.insertBefore(t,i)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let i=e.ownerDocument.createElement("template");i.innerHTML=t;let r=i.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(i=>{i.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function I(e,t={}){if(t.exclude===null)return S;let n=[Z("data"),t.exclude].filter(Boolean).join(", "),i=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!i?.querySelector?.(n))return S;let o=e.nodeType===9||!e.isConnected?e:e.ownerDocument,c=e.nodeType===9?e:e.ownerDocument,l=null,s=()=>l||(l=ee(o,{capability:"data",exclude:t.exclude||null})),f=a=>{let m=s();return a===e?m.cloneOf(e):m.cloneOf(a)||a},u=a=>l?.original(a)||a,d=(a,m)=>{s().liveToClone.set(a,m),s().cloneToLive.set(m,a);let g=a.childNodes||[],p=m.childNodes||[];for(let y=0;y<Math.min(g.length,p.length);y++)d(g[y],p[y])},h=(a,m,g,p)=>{let y=Array.from(a.childNodes).filter(T=>l.cloneOf(T)),E=y[0];for(;E&&y.includes(E);)E=E.nextSibling;for(let T of y)T.remove();if(g==="innerHTML"){let T=c.createElement("template");T.innerHTML=p;for(let V of Array.from(T.content.childNodes))a.insertBefore(V,E||null)}else a.insertBefore(c.createTextNode(p),E||null),ht(a,p);let x=ee(a,{capability:"data",exclude:t.exclude||null});m.replaceChildren(...Array.from(x.root?.childNodes||[]));let O=T=>{let V=x.original(T);V&&(l.liveToClone.set(V,T),l.cloneToLive.set(T,V));for(let wt of Array.from(T.childNodes||[]))O(wt)};for(let T of Array.from(m.childNodes))O(T)},A={...S,find(a,m,g={}){let p=f(a);if(!p?.querySelectorAll)return[];let y=s().query(m,p);g.includeRulesTag||(y=y.filter(x=>!dt(x)));let w=[];g.skip&&w.push(g.skip);let E=g.templateAttr===null?null:g.templateAttr||"cms-template";if(E&&w.push(`[${E}]`),w.length){let x=w.join(", ");y=y.filter(O=>!O.closest?.(x))}return y},parent(a){let m=f(a)?.parentElement;return m?u(m):null},children(a){return Array.from(f(a)?.children||[],u)},text(a,m){if(m===void 0){let y=u(a);return!y?.matches?.(n)&&!y?.querySelector?.(n)?S.text(y):(f(a)?.textContent||"").trim()}let g=u(a);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!l){S.text(g,m);return}let p=s().cloneOf(g);p?h(g,p,"textContent",m):S.text(g,m)},attr(a,m,g){let p=u(a);if(g===void 0)return S.attr(p,m);S.attr(p,m,g);let y=l?.cloneOf(p);y&&(S.attr(y,m,g),ee(p,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),l.liveToClone.delete(p),l.cloneToLive.delete(y)))},removeAttr(a,m){let g=u(a);S.removeAttr(g,m);let p=l?.cloneOf(g);p&&S.removeAttr(p,m)},prop(a,m,g){let p=u(a);if(g===void 0)return m==="innerHTML"||m==="outerHTML"||m==="textContent"||m==="innerText"?S.prop(f(p),m):S.prop(p,m);let y=m==="innerHTML"||m==="textContent"||m==="innerText",w=y?s().cloneOf(p):l?.cloneOf(p);w&&y?h(p,w,m,g):(S.prop(p,m,g),w&&S.prop(w,m,g))},clone(a){let m=f(a);if(m===a)return S.clone(a);let g=c.importNode(m,!0);return pt(g),g},insertAt(a,m,g){let p=u(a),w=A.children(p)[g]||(()=>{for(let O=p.children.length-1;O>=0;O--){let T=p.children[O];if(s().cloneOf(T))return T.nextElementSibling}return p.firstElementChild})(),E=u(m);p.insertBefore(E,w||null);let x=s().cloneOf(p);if(x){let O=s().cloneOf(E);O||(O=c.importNode(E,!0),d(E,O));let T=Array.from(x.children);x.insertBefore(O,T[g]||null)}},insertBefore(a,m){let g=u(a),p=u(m);g.parentNode.insertBefore(p,g);let y=s().cloneOf(g.parentNode);if(y){let w=s().cloneOf(p);w||(w=c.importNode(p,!0),d(p,w));let E=s().cloneOf(g);E?E.before(w):y.appendChild(w)}},insertAfter(a,m){let g=u(a),p=u(m);g.parentNode.insertBefore(p,g.nextSibling);let y=s().cloneOf(g.parentNode);if(y){let w=s().cloneOf(p);w||(w=c.importNode(p,!0),d(p,w));let E=s().cloneOf(g);E?E.after(w):y.appendChild(w)}},identity(a){return u(a)||null},remove(a){let m=u(a),g=s().cloneOf(m);S.remove(m),g&&S.remove(g)},replaceWith(a,m){let g=u(a),p=s().cloneOf(g),y=S.replaceWith(g,m);if(p){let w=ee(y,{capability:"data",exclude:t.exclude||null});if(!w.root)p.remove();else{p.replaceWith(w.root);let E=x=>{let O=w.original(x);O&&(l.liveToClone.set(O,x),l.cloneToLive.set(x,O));for(let T of Array.from(x.childNodes||[]))E(T)};E(w.root)}}return y}};return A}var te=S;var ne=e=>({codecs:Oe(),...e}),de={extract:(e,t,n={})=>L(I(e,n),e,t,ne(n)),apply:(e,t,n,i={})=>D(I(e,{...i,_write:!0}),e,t,n,ne(i)),findRulesIn:(e,t)=>W(te,e,t),findRules:(e,t)=>Le(te,e,t),bind:(e,t,n={})=>{let i=Le(te,e,t);if(!i){let o=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${o}`)}let r=ne({version:i.version,...n});return{...i,get:()=>L(I(e,n),e,i.rules,r),set:o=>D(I(e,{...n,_write:!0}),e,i.rules,o,r)}},codecs:{register:Ee,get:Te},parseStrict:Ne,parseRelaxed:Y,ruleAttrIndex:N,splitRule:b,errors:R,DOM_PROPERTIES:re},Ie=e=>!!e&&typeof e.nodeType=="number";function mt(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=W(te,t,"api");if(!n)throw new R.NoRulesTag("api");return{rules:n.rules,version:n.version}}function cn(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 ln(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 fn(e,t){let n=[];for(;t!==e;){let i=t.parentNode;n.push(Array.prototype.indexOf.call(i.childNodes,t)),t=i}return n.reverse()}function un(e,t){return t.reduce((n,i)=>n.childNodes[i],e)}function q(e,t){let n=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&n.unshift(e),n}function an(e,t){let n=q(e,"option"),i=q(t,"option");n.forEach((s,f)=>i[f].selected=s.selected);let r=q(e,"input"),o=q(t,"input");r.forEach((s,f)=>{let u=s.type.toLowerCase();u!=="file"&&(o[f].value=s.value),(u==="checkbox"||u==="radio")&&(o[f].checked=s.checked)});let c=q(e,"textarea"),l=q(t,"textarea");c.forEach((s,f)=>l[f].value=s.value)}function _e(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let n=e.startsWith("@")?0:N(e);if(n===-1)return;let i=e.slice(n+1);if(B.has(i))throw new R.RuleTargetReadOnly(i);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(n=>_e(e[1],n));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[n,i]of Object.entries(e))_e(i,t[n])}}function dn(e,t,n,i){let r=ne({templateAttr:"cms-template",version:i}),o=cn(e),c=fn(o,e),l=ln(o);an(o,l);let s=un(l,c),f=I(l,{...r,_write:!0}),u=ke(f,s,t,n,r);if(u.unknownKeys.length||u.unmatched.length)throw new R.WriteRejected(u.unknownKeys,u.unmatched);let d=ae(f);D(d,s,t,n,r),d.assertClean(),_e(t,n);let h=ae(I(o,{...r,_write:!0}));D(h,e,t,n,r),h.assertClean()}function hn(e){if(!(e instanceof Error))return e;let n=e instanceof R.UnknownCodec||e instanceof R.CodecRefused?e.code:e.name||"Error";try{e.code=n}catch{Object.defineProperty(e,"code",{value:n,configurable:!0,enumerable:!0})}return e instanceof R.WriteRefused?e.details=e.refusals:e instanceof R.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof R.ShapeMismatch?e.details=e.mismatches:Array.isArray(e.path)?e.details={path:e.path}:typeof e.target=="string"?e.details={target:e.target}:e.token!==void 0?e.details={token:e.token}:e.version!==void 0?e.details={version:e.version}:e.details={},e}function yt(e,t){let n=Ie(e)?e:document,i=Ie(e)?t:e;if(i===void 0){let{rules:r,version:o}=mt(n);return L(I(n),n,r,ne({version:o}))}return de.bind(n,i).get()}function gt(e,t,n){try{if(!Ie(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let{rules:i,version:r}=n===void 0?mt(e):de.bind(e,n);dn(e,i,t,r)}catch(i){throw hn(i)}return e}var pn={engine:de,extractData:yt,applyData:gt},$r=pn;export{gt as applyData,$r as default,de as engine,yt as extractData};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var hyperHtmlApiData=(()=>{var le=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var ft=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var Ne=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},at=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ft(t))!ut.call(e,r)&&r!==n&&le(e,r,{get:()=>t[r],enumerable:!(i=ct(t,r))||i.enumerable});return e};var ht=e=>at(le({},"__esModule",{value:!0}),e);var on={};Ne(on,{applyData:()=>Re,default:()=>rn,engine:()=>Z,extractData:()=>be});var Q=["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"],ee=new Set(Q),ce=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"]),Ce=new Set(["checked","selected","disabled","readOnly","paused"]);function fe(e,t){return t==null?Ce.has(e)?!1:"":Ce.has(e)?t==="false"?!1:!!t:t}var R={};Ne(R,{EmptyListInsert:()=>N,MAX_RULE_DEPTH:()=>j,MaxRuleDepthExceeded:()=>k,NoRulesTag:()=>ue,RuleTargetReadOnly:()=>q,RulesParseError:()=>I,ShapeMismatch:()=>H,UnknownRulesVersion:()=>B,WriteNotRoundTripped:()=>te,WriteRefused:()=>V,WriteRejected:()=>ae});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 dt(e){return e.reduce((n,i)=>typeof i=="number"?`${n}[${i}]`:n?`${n}.${i}`:String(i),"")||"(root)"}var te=class extends Error{constructor(t){super(`write did not round-trip at "${dt(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},ue=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},ae=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,i=-1;for(let r=0;r<e.length;r++){let o=e[r];o==="\\"?r++:n?o===n&&(n=null):o==='"'||o==="'"?n=o:o==="["||o==="("?t++:o==="]"||o===")"?t>0&&t--:o==="@"&&t===0&&(i=r)}return i}function he(e){let t=b(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function de(e){let t=0,n=null,i=-1,r=!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===">"?i=o:t===0&&l===","&&(r=!0)}return r||i===-1||!pt(e,i+1)?null:e.slice(0,i).trim()||null}function pt(e,t){let n=t,i=e.replace(/\s+$/,"").length;for(;n<i&&/\s/.test(e[n]);)n++;let r=0,o=null;for(;n<i;n++){let l=e[n];if(l==="\\")n++;else if(o)l===o&&(o=null);else if(l==='"'||l==="'")o=l;else if(l==="["||l==="(")r++;else if(l==="]"||l===")")r>0&&r--;else if(r===0&&(l==="+"||l==="~"||/\s/.test(l)))return!1}return!0}var mt=/^--[A-Za-z0-9_-]+$/;function C(e){return typeof e=="string"&&mt.test(e)}function Pe(e){let t=[],n=[],i=null,r=0;for(let o=0;o<e.length;o++){let l=e[o];if(i){l==="\\"?o++:l===i&&(i=null);continue}if(l==="/"&&e[o+1]==="*"){let c=e.indexOf("*/",o+2);o=c===-1?e.length:c+1;continue}l==='"'||l==="'"?i=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(r,o)),r=o+1)}return t.push(e.slice(r)),t}function yt(e){let t="",n=null;for(let i=0;i<e.length;i++){let r=e[i];if(n){t+=r,r==="\\"&&i+1<e.length?t+=e[++i]:r===n&&(n=null);continue}if(r==="/"&&e[i+1]==="*"){let o=e.indexOf("*/",i+2);i=o===-1?e.length:o+1,t+=" ";continue}(r==='"'||r==="'")&&(n=r),t+=r}return t}function Me(e){e=yt(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),i=e.slice(t+1).trim(),r=/!\s*important\s*$/i.exec(i);return r&&(i=i.slice(0,r.index).trim()),{name:n,value:i,important:!!r}}function $(e,t){if(e==null)return null;let n=null;for(let i of Pe(String(e))){let r=Me(i);!r||r.name!==t||(!n||r.important||!n.important)&&(n=r)}return n?n.value:null}function ke(e,t,n){let i=e==null?"":String(e),r=n==null||n==="",o=Pe(i),l=o.map(Me),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(r||f)return;let a=/^\s*/.exec(d)[0];s.push(`${a}${t}: ${n}${c?" !important":""}`),f=!0});let u=s.join(";");if(!r&&!f){let d=u.trimEnd();u=d===""?`${t}: ${n}`:`${d}${d.endsWith(";")?" ":"; "}${t}: ${n}`}return u.trim()===""?null:u}function ne(e,t,n,i){let r=e.attr(t,"style");if(($(r,n)??"")===i)return;let o=ke(r,n,i);o==null?e.removeAttr(t,"style"):e.attr(t,"style",o)}function P(e,t,n,i={}){if(Object.prototype.hasOwnProperty.call(i,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return pe(e,t,n,{depth:0,path:[]},i)}function pe(e,t,n,i,r){if(i.depth>j)throw new k(i.path);if(typeof n=="string")return gt(e,t,n,i,r);if(Array.isArray(n)){let[o,l]=n,c=e.find(t,o,r);return Ie(r,i,c),c.map((s,f)=>pe(e,s,l,{depth:i.depth+1,path:[...i.path,f]},r))}if(typeof n=="object"&&n!==null){let o={};for(let[l,c]of Object.entries(n))o[l]=pe(e,t,c,{depth:i.depth+1,path:[...i.path,l]},r);return o}return null}function gt(e,t,n,i,r){if(n.endsWith("[]")){let c=n.slice(0,-2),s=e.find(t,c,r);return Ie(r,i,s),s.map(f=>e.text(f))}if(n.startsWith("@"))return Le(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,r):[t];return f.length===0?null:Le(e,f[0],s)}if(n===".")return e.text(t);let l=e.find(t,n,r);return l.length===0?null:e.text(l[0])}function Ie(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(i){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,i)}}function Le(e,t,n){if(C(n))return $(e.attr(t,"style"),n);if(ee.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let i=e.attr(t,n);return i??null}function _e(e,t,n,i){let r=e.length,o=t.length,l=new Array(r).fill(-1);if(i){let h=new Set;for(let y=0;y<r;y++){let A=i[y];!(A>=0&&A<o)||h.has(A)||(l[y]=A,h.add(A))}}if(r===0||o===0)return l;let c=e.map(h=>je(h,n)),s=t.map(h=>je(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<r;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=r*o+1,m=At(e,t,n),g=(h,y)=>m(h,y)*a+Math.abs(h-y);for(let[h,y]of Tt(p,w,g))l[h]=y;return l}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(i=>{let r=JSON.stringify(e?.[i]);return r===void 0?" undef":r}))}function At(e,t,n){if(!De(n))return(c,s)=>e[c]===t[s]?0:1;let i=Object.keys(n),r=c=>i.map(s=>JSON.stringify(c?.[s])),o=e.map(r),l=t.map(r);return(c,s)=>{let f=o[c],u=l[s],d=0;for(let p=0;p<i.length;p++)f[p]!==u[p]&&d++;return d}}function Tt(e,t,n){return e.length<=t.length?$e(e,t,n,!1):$e(t,e,(i,r)=>n(r,i),!0)}function $e(e,t,n,i){let r=e.length,o=t.length,l=[];for(let d=0;d<=r;d++)l.push(new Float64Array(o+1).fill(1/0));let c=[];for(let d=0;d<=r;d++)c.push(new Uint8Array(o+1));for(let d=0;d<=o;d++)l[r][d]=0;for(let d=r-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<r&&u<o;)c[f][u]&&(s.push(i?[t[u],e[f]]:[e[f],t[u]]),f++),u++;return s}function ye(e,t,n,i,r,o,l,c={}){let s=e.find(t,n,c);if(r.length===0){s.forEach(T=>e.remove(T)),me(c,"onRowsApplied",o.path,[]);return}let f=r.length>s.length,u=s[0]||null;if(f&&!u&&(u=St(e,t,n,c),!u))throw new N(o.path);let d=s.map(T=>Ot(e,T,i,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=_e(r,d,i,wt(e,s,r,o,c)),a=s.length>0?e.parent(s[0]):Nt(e,t,n,u,o,c),m=s.length>0?qe(e,a,s[0]):0,g=Mt(e,s),h=new Set,y=[],A=r.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?Pt(e,a,m,A,y):kt(e,A,y,a,m),Et(e,A,i,r,o,l,c),me(c,"onRowsApplied",o.path,A)}function me(e,t,n,i){if(typeof e[t]=="function")try{return e[t](n.slice(),i)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function wt(e,t,n,i,r){let o=me(r,"identifyRows",i.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 Et(e,t,n,i,r,o,l){t.forEach((c,s)=>{if(n===null){let f=i[s],u=f==null?"":String(f);e.text(c)!==u&&e.text(c,u)}else{let f=o(e,c,n,i[s],{depth:r.depth+1,path:[...r.path,s]},l);f&&f!==c&&(t[s]=f)}})}function Ot(e,t,n,i){return n===null?e.text(t):P(e,t,n,i.onRowsRead?{...i,onRowsRead:void 0}:i)}function qe(e,t,n){let i=e.children(t);for(let r=0;r<i.length;r++)if(e.sameNode(i[r],n))return r;return-1}function St(e,t,n,i){if(!i.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),o=new RegExp(":not\\(\\["+i.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),l=n.replace(/^\s*:scope\s*>\s*/,"").replace(o,""),c=r?xt(l):0,s=de(l),f=t;for(;f;){let u=e.find(f,l,{includeRulesTag:!1,templateAttr:null});for(let d of u)if(e.attr(d,i.templateAttr)!=null&&!(r&&!Rt(e,t,d,c))&&!(s&&!e.matches(e.parent(d),s)))return d;f=e.parent(f)}return null}function xt(e){let t=0,n=null,i=1;for(let r=0;r<e.length;r++){let o=e[r];if(o==="\\")r++;else if(n)o===n&&(n=null);else if(o==='"'||o==="'")n=o;else if(o==="["||o==="(")t++;else if(o==="]"||o===")")t>0&&t--;else if(t===0&&o===">")i++;else{if(t===0&&(o==="+"||o==="~"))return null;if(t===0&&/\s/.test(o)){if(!bt(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return i}function bt(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let i=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return We(i)||We(r)}function We(e){return e===">"||e==="+"||e==="~"}function Rt(e,t,n,i){if(i===null)return!0;let r=n;for(let s=0;s<i;s++)if(r=e.parent(r),!r)return!1;let o=e.prop(t,"tagName");if(!o)return!0;let l=e.prop(r,"tagName");if(!l||String(l).toLowerCase()!==String(o).toLowerCase())return!1;let c=new Set(ve(e,r));return ve(e,t).every(s=>c.has(s))}function ve(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function Nt(e,t,n,i,r,o){let l=e.parent(i);if(l&&Ct(e,t,l)&&!He(e,l,o))return l;let c=de(n);if(!c)throw new N(r.path,`the list selector "${n}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let f=(c===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,c,o)).filter(u=>!He(e,u,o));if(f.length===0)throw new N(r.path,`no container matching "${c}" inside this context to hold the new rows`);if(f.length>1)throw new N(r.path,`"${c}" matches ${f.length} containers inside this context, so the new rows have no single destination`);return f[0]}function Ct(e,t,n){let i=n;for(;i;){if(e.sameNode(i,t))return!0;i=e.parent(i)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(r=>e.sameNode(r,n))}var Be=["no-data","editor-ui"];function He(e,t,n){let i=t;for(;i;){if(n.templateAttr&&e.attr(i,n.templateAttr)!=null||Be.some(o=>e.attr(i,o)!=null))return!0;let r=e.attr(i,"clay");if(r&&r.split(/\s+/).some(o=>Be.includes(o)))return!0;i=e.parent(i)}return!1}function Pt(e,t,n,i,r){let o=e.children(t),l=o.map(s=>e.identity(s)),c=!1;i.forEach((s,f)=>{let u=e.identity(s),d=n+f;if(l[d]===u)return;if(!r[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 Mt(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let i=new Map(e.children(n).map((o,l)=>[e.identity(o),l])),r=[];for(let o of t){let l=i.get(e.identity(o));if(l===void 0)return!1;r.push(l)}return r.sort((o,l)=>o-l),r[r.length-1]-r[0]===r.length-1}function kt(e,t,n,i,r){let o=null,l=r;for(let c=0;c<t.length;c++){if(!n[c]){o=t[c];continue}let s=o?e.parent(o):i;if(!s)continue;let f=o?qe(e,s,o)+1:l++;e.insertAt(s,t[c],f),o=t[c]}}function L(e,t,n,i,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let o=[];if(ge(n,i,[],o),o.length)throw new H(o);re(e,t,n,i,{depth:0,path:[]},r)}function re(e,t,n,i,r,o={}){if(r.depth>j)throw new k(r.path);if(i===void 0)return t;if(typeof n=="string")return Lt(e,t,n,i,r,o);if(Array.isArray(n)){let[l,c]=n;return ye(e,t,l,c,i,r,re,o),t}if(typeof n=="object"&&n!==null){for(let[l,c]of Object.entries(n)){let s=re(e,t,c,i==null?i:i[l],{depth:r.depth+1,path:[...r.path,l]},o);s&&s!==t&&(t=s)}return t}return t}function Lt(e,t,n,i,r,o){if(n.endsWith("[]")){let s=n.slice(0,-2);return ye(e,t,s,null,i,r,re,o),t}if(n.startsWith("@"))return Ue(e,t,n.slice(1),i);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||Ue(e,u[0],f,i),t}if(n===".")return Ve(e,t,i),t;let c=e.find(t,n,o);return c.length===0||Ve(e,c[0],i),t}function Ve(e,t,n){let i=n==null?"":String(n);e.text(t)!==i&&e.text(t,i)}function It(e,t,n,i){if(e.styleVar){e.styleVar(t,n,i);return}ne(e,t,n,i)}function Ue(e,t,n,i){if(C(n))return It(e,t,n,i==null?"":String(i).trim()),t;if(v.has(n)){let r=e.prop(t,n);if(r===i||r!=null&&i!=null&&String(r)===String(i))return t;throw new q(n)}if(n==="outerHTML"){let r=i==null?"":String(i);return e.replaceWith(t,r)}if(ce.has(n)){let r=fe(n,i);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(i==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(i);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function ge(e,t,n,i){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,o)=>{typeof r=="object"&&r!==null&&i.push({path:z([...n,o]),expected:"scalar",got:U(r)})}):i.push({path:z(n),expected:"array",got:U(t)});return}t!==null&&typeof t=="object"&&i.push({path:z(n),expected:"scalar",got:U(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){i.push({path:z(n),expected:"array",got:U(t)});return}let r=e[1];t.forEach((o,l)=>ge(r,o,[...n,l],i));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){i.push({path:z(n),expected:"object",got:U(t)});return}for(let[r,o]of Object.entries(e))ge(o,t[r],[...n,r],i)}}}function U(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function z(e){return e.join(".")}function Ae(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(r){let o=[],l=0;for(;l<r.length;){let c=r[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<r.length&&/\s/.test(r[p]);)p++;if(p<r.length&&/[a-zA-Z_]/.test(r[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<r.length&&r[p]!==d;)r[p]==="\\"&&p++,p++;o.push({type:t.STRING,value:r.substring(l+1,p),quoted:!0,sourceQuote:d}),l=p+1;continue}let s=l,f;for(;s<r.length&&!/[{},]/.test(r[s]);)if(r[s]===":"){let d=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],p=!1;for(let w of d){let a=w.substring(1);if(r.substring(s+1,s+1+a.length)===a){p=!0,s+=a.length;break}}if(!p)break}else if(r[s]==="["){for(s++;s<r.length&&r[s]!=="]";){if(r[s]==='"'||r[s]==="'"){let d=r[s];for(s++;s<r.length&&r[s]!==d;)r[s]==="\\"&&s++,s++}s++}s<r.length&&r[s]==="]"&&s++}else s++;f=r.substring(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 i(r){let o="";for(let l=0;l<r.length;l++){let c=r[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=r[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 r=n(e),o=i(r);return JSON.parse(o)}catch(r){throw new I("Invalid extraction rules syntax: "+r.message,r)}}var jt="1",ze=/^[a-zA-Z0-9_-]+$/;function _(e,t,n){let i;if(n===void 0)i="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})`);i=`script[data-rules-name~="${n}"]`}let r=e.find(t,i,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let o=r[0],l=e.attr(o,"data-rules-version");if(l!==jt)throw new B(l);return{rules:F(e.text(o)),tagNode:o}}var ie=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"]})}),$t=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 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 Te(e,t){if(K(e,t))return!0;for(let[n,i]of Object.entries($t))if(i.includes(t)&&K(e,n))return!0;return!1}function J(e){let t=ie[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function _t(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let i=ie[t];if(!i)throw new Error(`Unknown region capability: ${t}`);if(i.tokens.some(r=>Te(n,r))||i.bundles.some(r=>K(n,r)))return n;n=n.parentElement}return null}function Ke(e,t){return!!_t(e,t)}var oe=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"]})}),Dt=new Set(["textContent","innerText"]);function Je(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 Wt=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function Xe(e,t,n=oe){if(!Wt.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let i=String(e).toLowerCase();if(n.refusedAttributePrefixes.some(r=>i.startsWith(r)))return`attribute "${i}" can run script`;if(n.refusedAttributes.includes(i))return`attribute "${i}" is not content`;if(n.urlAttributes.includes(i)&&t!=null){let r=i==="srcset"?String(t).split(",").map(o=>o.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let o of r){let l=Je(o);if(l&&n.refusedSchemes.includes(l))return`"${l}:" URLs are not allowed in "${i}"`}}return null}function we(e,t){let n=e.prop(t,"tagName");return n?String(n).toLowerCase():""}function vt(e,t){let n=we(e,t)||"node",i=e.attr(t,"id");return i?`<${n}#${i}>`:`<${n}>`}function Bt(e,t,n){let i=t;for(;i;){let r=we(e,i);if(r&&n.refusedTargets.includes(r))return r;i=e.parent(i)}return null}function Ye(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function Ht(e,t){return we(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:Ye(e,t)}function qt(e){if(/[\u0000-\u001f\u007f]/.test(e))return"control characters are not allowed in a custom property value";let t=[],n=null;for(let i=0;i<e.length;i++){let r=e[i];if(n){r===n&&(n=null);continue}if(r==='"'||r==="'")n=r;else{if(r==="/"&&e[i+1]==="*")return"comments are not allowed in a custom property value";if(r==="(")t.push(")");else if(r==="[")t.push("]");else if((r===")"||r==="]")&&t.pop()!==r)return`"${r}" does not close anything in this custom property value`}}return n?"a custom property value must close its quotes":t.length?"a custom property value must close its brackets":null}function Ge(e,t=oe){let n=t.customPropertyValues,i=String(e);if(i.length>n.maxLength)return`custom property values are limited to ${n.maxLength} characters`;let r=n.refusedCharacters.find(s=>i.includes(s));if(r)return`${JSON.stringify(r)} is not allowed in a custom property value`;let o=qt(i);if(o)return o;let l=i.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 se(e,t=oe){let n=[],i=(s,f)=>(n.push({target:vt(e,s),reason:f}),!1),r=s=>{let f=Bt(e,s,t);return f?i(s,`inside <${f}>, which is not content`):!0},o=s=>r(s)?Ye(e,s)?i(s,"a text write here would delete the data rules tag"):!0:!1,l=(s,f,u)=>{if(!r(s))return!1;let d=Xe(f,u,t);return d?i(s,d):!0};return{...e,text(s,f){if(f===void 0)return e.text(s);o(s)&&e.text(s,f)},attr(s,f,u){if(u===void 0)return e.attr(s,f);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&&r(s)){if(!C(f))return i(s,`"${f}" is not a custom property`);if(u!==""){let d=Ge(u,t);if(d)return i(s,d)}ne(e,s,f,u)}},prop(s,f,u){if(u===void 0)return e.prop(s,f);if(t.refusedRuleForms.includes(f))return i(s,`"@${f}" writes HTML, only text is allowed`);if(Dt.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(Ht(e,s)){i(s,"removing this would delete the data rules tag");return}e.remove(s)},replaceWith(s,f){return f===e.prop(s,"outerHTML")||i(s,'"@outerHTML" writes HTML, only text is allowed'),s},refusals:n,assertClean(){if(n.length)throw new V(n.slice())}}}function X(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ze(e){return e.reduce((t,n)=>typeof n=="number"?`${t}[${n}]`:t?`${t}.${n}`:n,"")}function Ee(e,t,n,i,r={}){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(Ze([...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,r).length===0&&l.push({path:Ze(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,i,[]),s(t,n,i,[]),{unknownKeys:o,unmatched:l}}function Oe(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let i=t&&t.ownerDocument?t.ownerDocument:t;return _(e,i,n)}return null}var Ut=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function zt(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,i){if(i)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function et(e,t,n,i,r,o){return(o?Ke(e,t):Qe(e,n,r,!1))||!!(i&&(o&&e!==r?e.matches(i):Qe(e,i,r,o)))}function Ft(e,t){let n=ie[t];return n.tokens.some(i=>Te(e,i))||n.bundles.some(i=>K(e,i))}var Kt=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function tt(e,t,n,i){if(e.nodeType===1&&i(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,o=t;if(e.nodeType===1){if(Kt.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,o=t.content,n.cloneToLive.set(o,r),n.liveToClone.set(r,o)}}else if(e.nodeType!==11)return;let l=o.firstChild;for(let c=r.firstChild;c&&l;c=c.nextSibling)tt(c,l,n,i),l=l.nextSibling}function Y(e,{capability:t="data",exclude:n=null,inherit:i=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let o=e.nodeType===9?e:e.ownerDocument;if(!o?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let l=o.implementation.createHTMLDocument(""),c=r||new WeakMap,s=new WeakMap,f=e.nodeType===9?e.documentElement:e;n&&l.documentElement.matches(n);let u=J(t),d=i?a=>Ft(a,t)||!!(n&&a.matches(n)):a=>et(a,t,u,n,f,!1),p=null;if(f.nodeType!==1||!et(f,t,u,n,f,i)){p=l.importNode(f,!0);let a={cloneToLive:c,liveToClone:s,dropped:[],controls:[]};tt(f,p,a,d);for(let m of a.dropped)m.remove();for(let m=0;m<a.controls.length;m+=2)zt(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(Ut.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 rt(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Jt(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function nt(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 it(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function ot(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let i=n.type;i!=="file"&&i!=="checkbox"&&i!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var S={semanticExclude:!0,find(e,t,n={}){let i=Jt(e);if(!i||!i.querySelectorAll)return[];let r=Array.from(i.querySelectorAll(t));n.includeRulesTag||(r=r.filter(c=>!rt(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(", ");r=r.filter(s=>!s.closest||!s.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,it(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),nt(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),nt(e,t,null)},prop(e,t,n){if(n===void 0){let i=e?e[t]:void 0;return i!==void 0?i:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return ot(t),t},insertAt(e,t,n){let i=e.children[n]||null;e.insertBefore(t,i)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let i=e.ownerDocument.createElement("template");i.innerHTML=t;let r=i.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(i=>{i.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function M(e,t={}){if(t.exclude===null)return S;let n=[J("data"),t.exclude].filter(Boolean).join(", "),i=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!i?.querySelector?.(n))return S;let o=e.nodeType===9||!e.isConnected?e:e.ownerDocument,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),it(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 lt of Array.from(E.childNodes||[]))O(lt)};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=>!rt(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 ot(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 Z={extract:(e,t,n={})=>P(M(e,n),e,t,n),apply:(e,t,n,i={})=>L(M(e,{...i,_write:!0}),e,t,n,i),findRulesIn:(e,t)=>_(G,e,t),findRules:(e,t)=>Oe(G,e,t),bind:(e,t,n={})=>{let i=Oe(G,e,t);if(!i){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{...i,get:()=>P(M(e,n),e,i.rules,n),set:r=>L(M(e,{...n,_write:!0}),e,i.rules,r,n)}},parseStrict:Ae,parseRelaxed:F,ruleAttrIndex:b,splitRule:he,errors:R,DOM_PROPERTIES:Q},Se=e=>!!e&&typeof e.nodeType=="number";function st(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=_(G,t,"api");if(!n)throw new R.NoRulesTag("api");return n.rules}function Xt(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 Yt(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 Gt(e,t){let n=[];for(;t!==e;){let i=t.parentNode;n.push(Array.prototype.indexOf.call(i.childNodes,t)),t=i}return n.reverse()}function Zt(e,t){return t.reduce((n,i)=>n.childNodes[i],e)}function D(e,t){let n=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&n.unshift(e),n}function Qt(e,t){let n=D(e,"option"),i=D(t,"option");n.forEach((s,f)=>i[f].selected=s.selected);let r=D(e,"input"),o=D(t,"input");r.forEach((s,f)=>{let u=s.type.toLowerCase();u!=="file"&&(o[f].value=s.value),(u==="checkbox"||u==="radio")&&(o[f].checked=s.checked)});let l=D(e,"textarea"),c=D(t,"textarea");l.forEach((s,f)=>c[f].value=s.value)}function xe(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 i=e.slice(n+1);if(v.has(i))throw new R.RuleTargetReadOnly(i);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(n=>xe(e[1],n));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[n,i]of Object.entries(e))xe(i,t[n])}}function en(e,t,n){let i={templateAttr:"cms-template"},r=Xt(e),o=Gt(r,e),l=Yt(r);Qt(r,l);let c=Zt(l,o),s=M(l,{...i,_write:!0}),f=Ee(s,c,t,n,i);if(f.unknownKeys.length||f.unmatched.length)throw new R.WriteRejected(f.unknownKeys,f.unmatched);let u=se(s);L(u,c,t,n,i),u.assertClean(),xe(t,n);let d=se(M(r,{...i,_write:!0}));L(d,e,t,n,i),d.assertClean()}function tn(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 be(e,t){let n=Se(e)?e:document,i=Se(e)?t:e;return i===void 0?P(M(n),n,st(n)):Z.bind(n,i).get()}function Re(e,t,n){try{if(!Se(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let i=n===void 0?st(e):Z.bind(e,n).rules;en(e,i,t)}catch(i){throw tn(i)}return e}var nn={engine:Z,extractData:be,applyData:Re},rn=nn;return ht(on);})();
|
|
1
|
+
var hyperHtmlApiData=(()=>{var he=Object.defineProperty;var Tt=Object.getOwnPropertyDescriptor;var Ot=Object.getOwnPropertyNames;var St=Object.prototype.hasOwnProperty;var ve=(e,t)=>{for(var n in t)he(e,n,{get:t[n],enumerable:!0})},xt=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ot(t))!St.call(e,r)&&r!==n&&he(e,r,{get:()=>t[r],enumerable:!(i=Tt(t,r))||i.enumerable});return e};var bt=e=>xt(he({},"__esModule",{value:!0}),e);var Tn={};ve(Tn,{applyData:()=>De,default:()=>En,engine:()=>re,extractData:()=>je});var ie=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],oe=new Set(ie),pe=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),B=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),We=new Set(["checked","selected","disabled","readOnly","paused"]);function me(e,t){return t==null?We.has(e)?!1:"":We.has(e)?t==="false"?!1:!!t:t}var R={};ve(R,{CodecRefused:()=>we,EmptyListInsert:()=>P,MAX_RULE_DEPTH:()=>M,MaxRuleDepthExceeded:()=>_,NoRulesTag:()=>ye,RuleTargetReadOnly:()=>z,RulesParseError:()=>C,ShapeMismatch:()=>U,UnknownCodec:()=>K,UnknownRulesVersion:()=>H,WriteNotRoundTripped:()=>se,WriteRefused:()=>F,WriteRejected:()=>ge});var C=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},H=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1" and "2".`),this.name="UnknownRulesVersion",this.version=t}},M=20,_=class extends Error{constructor(t){super(`rule depth exceeded ${M} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},U=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},P=class extends Error{constructor(t,n){super(n?`cannot add items to empty list at "${t.join(".")}" \u2014 ${n}`:`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},z=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},F=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function Rt(e){return e.reduce((n,i)=>typeof i=="number"?`${n}[${i}]`:n?`${n}.${i}`:String(i),"")||"(root)"}var se=class extends Error{constructor(t){super(`write did not round-trip at "${Rt(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},ye=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},ge=class extends Error{constructor(t,n){super(`write rejected: ${t.length} unknown key(s), ${n.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=t,this.unmatched=n}},K=class extends Error{constructor(t){super(`unknown codec "${t}": no codec by that name is given to this call`),this.name="UnknownCodec",this.code="unknown-codec",this.codec=t}},we=class extends Error{constructor(t,n){super(n),this.name="CodecRefused",this.code=t}};function N(e){let t=0,n=null,i=-1;for(let r=0;r<e.length;r++){let o=e[r];o==="\\"?r++:n?o===n&&(n=null):o==='"'||o==="'"?n=o:o==="["||o==="("?t++:o==="]"||o===")"?t>0&&t--:o==="@"&&t===0&&(i=r)}return i}var qe="[*]";function b(e){let t=N(e),n=t===-1?e:e.slice(0,t),i=n.endsWith(qe),r={selector:i?n.slice(0,-qe.length):n,prop:t===-1?null:e.slice(t+1)||null};return i&&(r.all=!0),r}function Ae(e){let t=0,n=null,i=-1,r=!1;for(let o=0;o<e.length;o++){let c=e[o];c==="\\"?o++:n?c===n&&(n=null):c==='"'||c==="'"?n=c:c==="["||c==="("?t++:c==="]"||c===")"?t>0&&t--:t===0&&c===">"?i=o:t===0&&c===","&&(r=!0)}return r||i===-1||!Ct(e,i+1)?null:e.slice(0,i).trim()||null}function Ct(e,t){let n=t,i=e.replace(/\s+$/,"").length;for(;n<i&&/\s/.test(e[n]);)n++;let r=0,o=null;for(;n<i;n++){let c=e[n];if(c==="\\")n++;else if(o)c===o&&(o=null);else if(c==='"'||c==="'")o=c;else if(c==="["||c==="(")r++;else if(c==="]"||c===")")r>0&&r--;else if(r===0&&(c==="+"||c==="~"||/\s/.test(c)))return!1}return!0}var Nt=/^codec\(([a-z][a-z0-9-]*)\)$/;function $(e){if(typeof e!="string")return null;let t=N(e);if(t===-1)return null;let n=Nt.exec(e.slice(t+1));if(!n)return null;let{selector:i,all:r}=b(e);if(r)throw new C("A @codec(name) rule cannot use [*].");return{selector:i,name:n[1]}}var Pt=/^--[A-Za-z0-9_-]+$/;function k(e){return typeof e=="string"&&Pt.test(e)}function Ve(e){let t=[],n=[],i=null,r=0;for(let o=0;o<e.length;o++){let c=e[o];if(i){c==="\\"?o++:c===i&&(i=null);continue}if(c==="/"&&e[o+1]==="*"){let l=e.indexOf("*/",o+2);o=l===-1?e.length:l+1;continue}c==='"'||c==="'"?i=c:c==="("?n.push(")"):c==="["?n.push("]"):c==="{"?n.push("}"):(c===")"||c==="]"||c==="}")&&n[n.length-1]===c?n.pop():c===";"&&n.length===0&&(t.push(e.slice(r,o)),r=o+1)}return t.push(e.slice(r)),t}function Mt(e){let t="",n=null;for(let i=0;i<e.length;i++){let r=e[i];if(n){t+=r,r==="\\"&&i+1<e.length?t+=e[++i]:r===n&&(n=null);continue}if(r==="/"&&e[i+1]==="*"){let o=e.indexOf("*/",i+2);i=o===-1?e.length:o+1,t+=" ";continue}(r==='"'||r==="'")&&(n=r),t+=r}return t}function Be(e){e=Mt(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),i=e.slice(t+1).trim(),r=/!\s*important\s*$/i.exec(i);return r&&(i=i.slice(0,r.index).trim()),{name:n,value:i,important:!!r}}function v(e,t){if(e==null)return null;let n=null;for(let i of Ve(String(e))){let r=Be(i);!r||r.name!==t||(!n||r.important||!n.important)&&(n=r)}return n?n.value:null}function He(e,t,n){let i=e==null?"":String(e),r=n==null||n==="",o=Ve(i),c=o.map(Be),l=c.some(d=>d&&d.name===t&&d.important),s=[],f=!1;o.forEach((d,h)=>{let A=c[h];if(!A||A.name!==t){s.push(d);return}if(r||f)return;let a=/^\s*/.exec(d)[0];s.push(`${a}${t}: ${n}${l?" !important":""}`),f=!0});let u=s.join(";");if(!r&&!f){let d=u.trimEnd();u=d===""?`${t}: ${n}`:`${d}${d.endsWith(";")?" ":"; "}${t}: ${n}`}return u.trim()===""?null:u}function ce(e,t,n,i){let r=e.attr(t,"style");if((v(r,n)??"")===i)return;let o=He(r,n,i);o==null?e.removeAttr(t,"style"):e.attr(t,"style",o)}var Ue=/^[a-z][a-z0-9-]*$/,Ee=new Map;function Te(e,t){if(typeof e!="string"||!Ue.test(e))throw new Error(`hyper-html-api: invalid codec name ${JSON.stringify(e)} (must match ${Ue})`);if(!t||typeof t.read!="function"||typeof t.write!="function"||typeof t.same!="function")throw new Error(`hyper-html-api: codec "${e}" needs read, write and same functions`);Ee.set(e,t)}function Oe(e){return Ee.get(e)??null}function Se(){return Object.fromEntries(Ee)}var kt='The @codec(name) rule form needs a rules tag with data-rules-version="2".',Lt="A @codec(name) rule must be the value of a top level key.";function le(e,t){let n=$(e);return n?{...n,codec:t.codecs[n.name]}:null}function j(e,t={}){let n=t.version??"1",i=t.codecs??{};r(e,0);function r(o,c){if(!(c>M)){if(typeof o=="string"){let l=$(o);if(!l)return;if(n!=="2")throw new C(kt);if(c!==1)throw new C(Lt);if(!Object.prototype.hasOwnProperty.call(i,l.name))throw new K(l.name);return}if(Array.isArray(o)){r(o[1],c+1);return}if(o&&typeof o=="object")for(let l of Object.values(o))r(l,c+1)}}}function L(e,t,n,i={}){if(Object.prototype.hasOwnProperty.call(i,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return j(n,i),be(e,t,n,{depth:0,path:[]},i)}function be(e,t,n,i,r){if(i.depth>M)throw new _(i.path);if(typeof n=="string")return It(e,t,n,i,r);if(Array.isArray(n)){let[o,c]=n,l=e.find(t,o,r);return ze(r,i,l),l.map((s,f)=>be(e,s,c,{depth:i.depth+1,path:[...i.path,f]},r))}if(typeof n=="object"&&n!==null){let o={};for(let[c,l]of Object.entries(n))o[c]=be(e,t,l,{depth:i.depth+1,path:[...i.path,c]},r);return o}return null}function It(e,t,n,i,r){if(n.endsWith("[]")){let u=n.slice(0,-2),d=e.find(t,u,r);return ze(r,i,d),d.map(h=>e.text(h))}let o=le(n,r);if(o)return _t(e,t,o,r);if(n.startsWith("@"))return xe(e,t,n.slice(1));let c=N(n);if(c!==-1){let{selector:u,all:d}=b(n),h=n.slice(c+1),A=u?e.find(t,u,r):[t];return d&&r.allMatches?A.map(a=>xe(e,a,h)):A.length===0?null:xe(e,A[0],h)}if(n===".")return e.text(t);let{selector:l,all:s}=b(n),f=e.find(t,l,r);return s&&r.allMatches?f.map(u=>e.text(u)):f.length===0?null:e.text(f[0])}function _t(e,t,{selector:n,codec:i},r){let o=n?e.find(t,n,r):[t];return o.length===0?null:i.read(e,o[0],{query:r.query,view:r.view,region:r.region})}function ze(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(i){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,i)}}function xe(e,t,n){if(k(n))return v(e.attr(t,"style"),n);if(oe.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let i=e.attr(t,n);return i??null}function Je(e,t,n,i){let r=e.length,o=t.length,c=new Array(r).fill(-1);if(i){let p=new Set;for(let y=0;y<r;y++){let w=i[y];!(w>=0&&w<o)||p.has(w)||(c[y]=w,p.add(w))}}if(r===0||o===0)return c;let l=e.map(p=>Fe(p,n)),s=t.map(p=>Fe(p,n)),f=new Array(o).fill(!1);for(let p of c)p>=0&&(f[p]=!0);let u=new Map;s.forEach((p,y)=>{f[y]||u.set(p,u.has(p)?-1:y)});let d=new Map;l.forEach((p,y)=>{c[y]>=0||d.set(p,(d.get(p)||0)+1)}),l.forEach((p,y)=>{if(c[y]>=0||d.get(p)!==1)return;let w=u.get(p);w===void 0||w===-1||f[w]||(c[y]=w,f[w]=!0)});let h=[];for(let p=0;p<r;p++)c[p]<0&&h.push(p);let A=[];for(let p=0;p<o;p++)f[p]||A.push(p);if(h.length===0||A.length===0)return c;let a=r*o+1,m=$t(e,t,n),g=(p,y)=>m(p,y)*a+Math.abs(p-y);for(let[p,y]of jt(h,A,g))c[p]=y;return c}var Xe=e=>typeof e=="object"&&e!==null;function Fe(e,t){if(!Xe(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(i=>{let r=JSON.stringify(e?.[i]);return r===void 0?" undef":r}))}function $t(e,t,n){if(!Xe(n))return(l,s)=>e[l]===t[s]?0:1;let i=Object.keys(n),r=l=>i.map(s=>JSON.stringify(l?.[s])),o=e.map(r),c=t.map(r);return(l,s)=>{let f=o[l],u=c[s],d=0;for(let h=0;h<i.length;h++)f[h]!==u[h]&&d++;return d}}function jt(e,t,n){return e.length<=t.length?Ke(e,t,n,!1):Ke(t,e,(i,r)=>n(r,i),!0)}function Ke(e,t,n,i){let r=e.length,o=t.length,c=[];for(let d=0;d<=r;d++)c.push(new Float64Array(o+1).fill(1/0));let l=[];for(let d=0;d<=r;d++)l.push(new Uint8Array(o+1));for(let d=0;d<=o;d++)c[r][d]=0;for(let d=r-1;d>=0;d--)for(let h=o-1;h>=0;h--){let A=n(e[d],t[h])+c[d+1][h+1],a=c[d][h+1];A<=a?(c[d][h]=A,l[d][h]=1):c[d][h]=a}let s=[],f=0,u=0;for(;f<r&&u<o;)l[f][u]&&(s.push(i?[t[u],e[f]]:[e[f],t[u]]),f++),u++;return s}function Ce(e,t,n,i,r,o,c,l={}){let s=e.find(t,n,l);if(r.length===0){s.forEach(E=>e.remove(E)),Re(l,"onRowsApplied",o.path,[]);return}let f=r.length>s.length,u=s[0]||null;if(f&&!u&&(u=qt(e,t,n,l),!u))throw new P(o.path);let d=s.map(E=>Wt(e,E,i,l)),h=null;if(f&&u){h=e.clone(u),l.templateAttr&&e.removeAttr(h,l.templateAttr);let E=e.stripIds(h);E>0&&console.warn(`[hyper-html-api] stripped ${E} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let A=Je(r,d,i,Dt(e,s,r,o,l)),a=s.length>0?e.parent(s[0]):Ut(e,t,n,u,o,l),m=s.length>0?et(e,a,s[0]):0,g=Kt(e,s),p=new Set,y=[],w=r.map((E,x)=>{let O=A[x];if(O>=0)return p.add(O),y.push(!1),s[O];y.push(!0);let T=e.clone(h);return e.stripIds(T),T});s.forEach((E,x)=>{p.has(x)||e.remove(E)}),g?Ft(e,a,m,w,y):Jt(e,w,y,a,m),vt(e,w,i,r,o,c,l),Re(l,"onRowsApplied",o.path,w)}function Re(e,t,n,i){if(typeof e[t]=="function")try{return e[t](n.slice(),i)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function Dt(e,t,n,i,r){let o=Re(r,"identifyRows",i.path,n);if(!Array.isArray(o))return null;let c=new Array(n.length).fill(-1),l=new Set,s=new Map(t.map((f,u)=>[e.identity(f),u]));for(let f=0;f<n.length;f++){if(!o[f])continue;let u=s.get(e.identity(o[f]));u===void 0||l.has(u)||(c[f]=u,l.add(u))}return c}function vt(e,t,n,i,r,o,c){t.forEach((l,s)=>{if(n===null){let f=i[s],u=f==null?"":String(f);e.text(l)!==u&&e.text(l,u)}else{let f=o(e,l,n,i[s],{depth:r.depth+1,path:[...r.path,s]},c);f&&f!==l&&(t[s]=f)}})}function Wt(e,t,n,i){return n===null?e.text(t):L(e,t,n,i.onRowsRead?{...i,onRowsRead:void 0}:i)}function et(e,t,n){let i=e.children(t);for(let r=0;r<i.length;r++)if(e.sameNode(i[r],n))return r;return-1}function qt(e,t,n,i){if(!i.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),o=new RegExp(":not\\(\\["+i.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),c=n.replace(/^\s*:scope\s*>\s*/,"").replace(o,""),l=r?Vt(c):0,s=Ae(c),f=t;for(;f;){let u=e.find(f,c,{includeRulesTag:!1,templateAttr:null});for(let d of u)if(e.attr(d,i.templateAttr)!=null&&!(r&&!Ht(e,t,d,l))&&!(s&&!e.matches(e.parent(d),s)))return d;f=e.parent(f)}return null}function Vt(e){let t=0,n=null,i=1;for(let r=0;r<e.length;r++){let o=e[r];if(o==="\\")r++;else if(n)o===n&&(n=null);else if(o==='"'||o==="'")n=o;else if(o==="["||o==="(")t++;else if(o==="]"||o===")")t>0&&t--;else if(t===0&&o===">")i++;else{if(t===0&&(o==="+"||o==="~"))return null;if(t===0&&/\s/.test(o)){if(!Bt(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return i}function Bt(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let i=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return Ye(i)||Ye(r)}function Ye(e){return e===">"||e==="+"||e==="~"}function Ht(e,t,n,i){if(i===null)return!0;let r=n;for(let s=0;s<i;s++)if(r=e.parent(r),!r)return!1;let o=e.prop(t,"tagName");if(!o)return!0;let c=e.prop(r,"tagName");if(!c||String(c).toLowerCase()!==String(o).toLowerCase())return!1;let l=new Set(Ge(e,r));return Ge(e,t).every(s=>l.has(s))}function Ge(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function Ut(e,t,n,i,r,o){let c=e.parent(i);if(c&&zt(e,t,c)&&!Qe(e,c,o))return c;let l=Ae(n);if(!l)throw new P(r.path,`the list selector "${n}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let f=(l===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,l,o)).filter(u=>!Qe(e,u,o));if(f.length===0)throw new P(r.path,`no container matching "${l}" inside this context to hold the new rows`);if(f.length>1)throw new P(r.path,`"${l}" matches ${f.length} containers inside this context, so the new rows have no single destination`);return f[0]}function zt(e,t,n){let i=n;for(;i;){if(e.sameNode(i,t))return!0;i=e.parent(i)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(r=>e.sameNode(r,n))}var Ze=["no-data","editor-ui"];function Qe(e,t,n){let i=t;for(;i;){if(n.templateAttr&&e.attr(i,n.templateAttr)!=null||Ze.some(o=>e.attr(i,o)!=null))return!0;let r=e.attr(i,"clay");if(r&&r.split(/\s+/).some(o=>Ze.includes(o)))return!0;i=e.parent(i)}return!1}function Ft(e,t,n,i,r){let o=e.children(t),c=o.map(s=>e.identity(s)),l=!1;i.forEach((s,f)=>{let u=e.identity(s),d=n+f;if(c[d]===u)return;if(!r[f]){let A=c.indexOf(u);A!==-1&&(c.splice(A,1),o.splice(A,1))}let h=Math.min(d,o.length);h<o.length?e.insertBefore(o[h],s):o.length?l?e.insertAfter(o[o.length-1],s):(e.insertAt(t,s,d),l=!0):e.insertAt(t,s,0),c.splice(h,0,u),o.splice(h,0,s)})}function Kt(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let i=new Map(e.children(n).map((o,c)=>[e.identity(o),c])),r=[];for(let o of t){let c=i.get(e.identity(o));if(c===void 0)return!1;r.push(c)}return r.sort((o,c)=>o-c),r[r.length-1]-r[0]===r.length-1}function Jt(e,t,n,i,r){let o=null,c=r;for(let l=0;l<t.length;l++){if(!n[l]){o=t[l];continue}let s=o?e.parent(o):i;if(!s)continue;let f=o?et(e,s,o)+1:c++;e.insertAt(s,t[l],f),o=t[l]}}function D(e,t,n,i,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");j(n,r);let o=[];if(Ne(n,i,[],o),o.length)throw new U(o);fe(e,t,n,i,{depth:0,path:[]},r)}function fe(e,t,n,i,r,o={}){if(r.depth>M)throw new _(r.path);if(i===void 0)return t;if(typeof n=="string")return Xt(e,t,n,i,r,o);if(Array.isArray(n)){let[c,l]=n;return Ce(e,t,c,l,i,r,fe,o),t}if(typeof n=="object"&&n!==null){for(let[c,l]of Object.entries(n)){let s=fe(e,t,l,i==null?i:i[c],{depth:r.depth+1,path:[...r.path,c]},o);s&&s!==t&&(t=s)}return t}return t}function Xt(e,t,n,i,r,o){if(n.endsWith("[]")){let d=n.slice(0,-2);return Ce(e,t,d,null,i,r,fe,o),t}let c=le(n,o);if(c){let d=c.selector?e.find(t,c.selector,o):[t];return d.length&&c.codec.write(e,d[0],i,{query:o.query}),t}if(n.startsWith("@"))return nt(e,t,n.slice(1),i);let l=N(n);if(l!==-1){let{selector:d,all:h}=b(n),A=n.slice(l+1),a=d?e.find(t,d,o):[t];for(let m of h?a:a.slice(0,1))nt(e,m,A,i);return t}if(n===".")return tt(e,t,i),t;let{selector:s,all:f}=b(n),u=e.find(t,s,o);for(let d of f?u:u.slice(0,1))tt(e,d,i);return t}function tt(e,t,n){let i=n==null?"":String(n);e.text(t)!==i&&e.text(t,i)}function Yt(e,t,n,i){if(e.styleVar){e.styleVar(t,n,i);return}ce(e,t,n,i)}function nt(e,t,n,i){if(k(n))return Yt(e,t,n,i==null?"":String(i).trim()),t;if(B.has(n)){let r=e.prop(t,n);if(r===i||r!=null&&i!=null&&String(r)===String(i))return t;throw new z(n)}if(n==="outerHTML"){let r=i==null?"":String(i);return e.replaceWith(t,r)}if(pe.has(n)){let r=me(n,i);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(i==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(i);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function Ne(e,t,n,i){if(t!==void 0){if(typeof e=="string"){if($(e))return;if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,o)=>{typeof r=="object"&&r!==null&&i.push({path:X([...n,o]),expected:"scalar",got:J(r)})}):i.push({path:X(n),expected:"array",got:J(t)});return}t!==null&&typeof t=="object"&&i.push({path:X(n),expected:"scalar",got:J(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){i.push({path:X(n),expected:"array",got:J(t)});return}let r=e[1];t.forEach((o,c)=>Ne(r,o,[...n,c],i));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){i.push({path:X(n),expected:"object",got:J(t)});return}for(let[r,o]of Object.entries(e))Ne(o,t[r],[...n,r],i)}}}function J(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function X(e){return e.join(".")}function Pe(e){try{return JSON.parse(e)}catch(t){throw new C(`Invalid strict JSON: ${t.message}`,t)}}function Y(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function n(r){let o=[],c=0;for(;c<r.length;){let l=r[c];if(/\s/.test(l)){c++;continue}if("{}".includes(l)){o.push({type:l,value:l}),c++;continue}if(l==="["){let d=!1,h=c+1;for(;h<r.length&&/\s/.test(r[h]);)h++;if(h<r.length&&/[a-zA-Z_]/.test(r[h])&&(d=!0),!d){o.push({type:l,value:l}),c++;continue}}if(l==="]"){o.push({type:l,value:l}),c++;continue}if(l===":"){o.push({type:t.COLON,value:l}),c++;continue}if(l===","){o.push({type:t.COMMA,value:l}),c++;continue}if(l==='"'||l==="'"){let d=l,h=c+1;for(;h<r.length&&r[h]!==d;)r[h]==="\\"&&h++,h++;o.push({type:t.STRING,value:r.substring(c+1,h),quoted:!0,sourceQuote:d}),c=h+1;continue}let s=c,f;for(;s<r.length&&!/[{},]/.test(r[s]);)if(r[s]===":"){let d=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],h=!1;for(let A of d){let a=A.substring(1);if(r.substring(s+1,s+1+a.length)===a){h=!0,s+=a.length;break}}if(!h)break}else if(r[s]==="["){for(s++;s<r.length&&r[s]!=="]";){if(r[s]==='"'||r[s]==="'"){let d=r[s];for(s++;s<r.length&&r[s]!==d;)r[s]==="\\"&&s++,s++}s++}s<r.length&&r[s]==="]"&&s++}else s++;f=r.substring(c,s);let u=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(f)?u=t.NUMBER:f==="true"||f==="false"||f==="null"?u=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(f)&&(u=t.SELECTOR),o.push({type:u,value:f,quoted:!1}),c=s}return o}function i(r){let o="";for(let c=0;c<r.length;c++){let l=r[c];if("{}".includes(l.type)||"[]".includes(l.type)){o+=l.value;continue}if(l.type===t.COLON){o+=l.value;continue}if(l.type===t.COMMA){let s=r[c+1];if(s&&(s.type==="}"||s.type==="]"))continue;o+=l.value;continue}if(l.type===t.STRING&&l.quoted){let s=l.value;l.sourceQuote==="'"&&(s=s.replace(/\\'/g,"'"),s=s.replace(/(\\*)"/g,(f,u)=>u.length%2===0?u+'\\"':f)),o+=`"${s}"`;continue}if(l.type===t.NUMBER||l.type===t.BOOLEAN){o+=l.value;continue}if(l.type===t.SELECTOR||l.type===t.IDENTIFIER){o+=`"${l.value}"`;continue}o+=`"${l.value}"`}return o}try{let r=n(e),o=i(r);return JSON.parse(o)}catch(r){throw new C("Invalid extraction rules syntax: "+r.message,r)}}var it=["1","2"],rt=/^[a-zA-Z0-9_-]+$/;function W(e,t,n){let i;if(n===void 0)i="script[data-rules-name]";else{if(typeof n!="string"||!rt.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${rt})`);i=`script[data-rules-name~="${n}"]`}let r=e.find(t,i,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let o=r[0],c=e.attr(o,"data-rules-version");if(!it.includes(c))throw new H(c);return{rules:Y(e.text(o)),tagNode:o,version:c}}var ue=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),Gt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),ot=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function G(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function Me(e,t){if(G(e,t))return!0;for(let[n,i]of Object.entries(Gt))if(i.includes(t)&&G(e,n))return!0;return!1}function Z(e){let t=ue[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Zt(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let i=ue[t];if(!i)throw new Error(`Unknown region capability: ${t}`);if(i.tokens.some(r=>Me(n,r))||i.bundles.some(r=>G(n,r)))return n;n=n.parentElement}return null}function st(e,t){return!!Zt(e,t)}var ae=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...ot],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})}),Qt=new Set(["textContent","innerText"]);function ct(e){let n=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return n?n[1].toLowerCase():null}var en=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function lt(e,t,n=ae){if(!en.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let i=String(e).toLowerCase();if(n.refusedAttributePrefixes.some(r=>i.startsWith(r)))return`attribute "${i}" can run script`;if(n.refusedAttributes.includes(i))return`attribute "${i}" is not content`;if(n.urlAttributes.includes(i)&&t!=null){let r=i==="srcset"?String(t).split(",").map(o=>o.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let o of r){let c=ct(o);if(c&&n.refusedSchemes.includes(c))return`"${c}:" URLs are not allowed in "${i}"`}}return null}function ke(e,t){let n=e.prop(t,"tagName");return n?String(n).toLowerCase():""}function tn(e,t){let n=ke(e,t)||"node",i=e.attr(t,"id");return i?`<${n}#${i}>`:`<${n}>`}function nn(e,t,n){let i=t;for(;i;){let r=ke(e,i);if(r&&n.refusedTargets.includes(r))return r;i=e.parent(i)}return null}function ft(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function rn(e,t){return ke(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:ft(e,t)}function on(e){if(/[\u0000-\u001f\u007f]/.test(e))return"control characters are not allowed in a custom property value";let t=[],n=null;for(let i=0;i<e.length;i++){let r=e[i];if(n){r===n&&(n=null);continue}if(r==='"'||r==="'")n=r;else{if(r==="/"&&e[i+1]==="*")return"comments are not allowed in a custom property value";if(r==="(")t.push(")");else if(r==="[")t.push("]");else if((r===")"||r==="]")&&t.pop()!==r)return`"${r}" does not close anything in this custom property value`}}return n?"a custom property value must close its quotes":t.length?"a custom property value must close its brackets":null}function ut(e,t=ae){let n=t.customPropertyValues,i=String(e);if(i.length>n.maxLength)return`custom property values are limited to ${n.maxLength} characters`;let r=n.refusedCharacters.find(s=>i.includes(s));if(r)return`${JSON.stringify(r)} is not allowed in a custom property value`;let o=on(i);if(o)return o;let c=i.toLowerCase(),l=n.refusedFunctions.find(s=>new RegExp(`(^|[^a-z0-9_-])${s.replace(/[-]/g,"\\-")}\\s*\\(`).test(c));return l?`"${l}()" is not allowed in a custom property value`:null}function de(e,t=ae){let n=[],i=(s,f)=>(n.push({target:tn(e,s),reason:f}),!1),r=s=>{let f=nn(e,s,t);return f?i(s,`inside <${f}>, which is not content`):!0},o=s=>r(s)?ft(e,s)?i(s,"a text write here would delete the data rules tag"):!0:!1,c=(s,f,u)=>{if(!r(s))return!1;let d=lt(f,u,t);return d?i(s,d):!0};return{...e,text(s,f){if(f===void 0)return e.text(s);o(s)&&e.text(s,f)},attr(s,f,u){if(u===void 0)return e.attr(s,f);c(s,f,u)&&e.attr(s,f,u)},removeAttr(s,f){c(s,f,null)&&e.removeAttr(s,f)},styleVar(s,f,u){if((v(e.attr(s,"style"),f)??"")!==u&&r(s)){if(!k(f))return i(s,`"${f}" is not a custom property`);if(u!==""){let d=ut(u,t);if(d)return i(s,d)}ce(e,s,f,u)}},prop(s,f,u){if(u===void 0)return e.prop(s,f);if(t.refusedRuleForms.includes(f))return i(s,`"@${f}" writes HTML, only text is allowed`);if(Qt.has(f)){o(s)&&e.prop(s,f,u);return}c(s,f==="className"?"class":f,u)&&e.prop(s,f,u)},remove(s){if(rn(e,s)){i(s,"removing this would delete the data rules tag");return}e.remove(s)},replaceWith(s,f){return f===e.prop(s,"outerHTML")||i(s,'"@outerHTML" writes HTML, only text is allowed'),s},refusals:n,assertClean(){if(n.length)throw new F(n.slice())}}}function Q(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function at(e){return e.reduce((t,n)=>typeof n=="number"?`${t}[${n}]`:t?`${t}.${n}`:n,"")}function Le(e,t,n,i,r={}){j(n,r);let o=[],c=[];function l(f,u,d){if(Array.isArray(f)){let[,h]=f;if(!Array.isArray(u)||!Q(h))return;u.forEach((A,a)=>l(h,A,[...d,a]));return}if(!(!Q(f)||!Q(u)))for(let h of Object.keys(u))Object.prototype.hasOwnProperty.call(f,h)?l(f[h],u[h],[...d,h]):o.push(at([...d,h]))}function s(f,u,d,h){if(d!==void 0){if(typeof u=="string"){if(u.endsWith("[]")||u==="."||u.startsWith("@"))return;let{selector:A}=b(u);if(!A)return;e.find(f,A,r).length===0&&c.push({path:at(h),selector:A});return}if(!Array.isArray(u)&&Q(u)&&Q(d))for(let[A,a]of Object.entries(u))s(f,a,d[A],[...h,A])}}return l(n,i,[]),s(t,n,i,[]),{unknownKeys:o,unmatched:c}}function Ie(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null,version:"1"};if(typeof n=="string"){let i=t&&t.ownerDocument?t.ownerDocument:t;return W(e,i,n)}return null}var cn=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function ln(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function dt(e,t,n,i){if(i)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function ht(e,t,n,i,r,o){return(o?st(e,t):dt(e,n,r,!1))||!!(i&&(o&&e!==r?e.matches(i):dt(e,i,r,o)))}function fn(e,t){let n=ue[t];return n.tokens.some(i=>Me(e,i))||n.bundles.some(i=>G(e,i))}var un=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function pt(e,t,n,i){if(e.nodeType===1&&i(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,o=t;if(e.nodeType===1){if(un.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,o=t.content,n.cloneToLive.set(o,r),n.liveToClone.set(r,o)}}else if(e.nodeType!==11)return;let c=o.firstChild;for(let l=r.firstChild;l&&c;l=l.nextSibling)pt(l,c,n,i),c=c.nextSibling}function ee(e,{capability:t="data",exclude:n=null,inherit:i=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let o=e.nodeType===9?e:e.ownerDocument;if(!o?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let c=o.implementation.createHTMLDocument(""),l=r||new WeakMap,s=new WeakMap,f=e.nodeType===9?e.documentElement:e;n&&c.documentElement.matches(n);let u=Z(t),d=i?a=>fn(a,t)||!!(n&&a.matches(n)):a=>ht(a,t,u,n,f,!1),h=null;if(f.nodeType!==1||!ht(f,t,u,n,f,i)){h=c.importNode(f,!0);let a={cloneToLive:l,liveToClone:s,dropped:[],controls:[]};pt(f,h,a,d);for(let m of a.dropped)m.remove();for(let m=0;m<a.controls.length;m+=2)ln(a.controls[m],a.controls[m+1])}e.nodeType===9&&h&&(c.replaceChild(h,c.documentElement),s.set(e,c),l.set(c,e));let A=a=>{if(cn.test(a))throw new Error(`Filtered content queries do not support stateful selector: ${a}`)};return{root:h,document:c,capability:t,selector:Z(t),cloneToLive:l,liveToClone:s,original(a){return l.get(a)||null},cloneOf(a){return s.get(a)||null},query(a,m=h){return A(a),Array.from(m.querySelectorAll(a),g=>l.get(g)||g)},text(a=h){return(a===h?h:s.get(a))?.textContent||""},html(a=h){return(a===h?h:s.get(a))?.innerHTML??""},clone(a=h){let m=a===h?h:s.get(a);return m?c.importNode(m,!0):null}}}function yt(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function an(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function mt(e,t,n){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=n===null?"":n:t==="checked"&&e.tagName==="INPUT"?e.checked=n!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=n!==null))}function gt(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function wt(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let i=n.type;i!=="file"&&i!=="checkbox"&&i!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var S={semanticExclude:!0,find(e,t,n={}){let i=an(e);if(!i||!i.querySelectorAll)return[];let r=Array.from(i.querySelectorAll(t));n.includeRulesTag||(r=r.filter(l=>!yt(l)));let o=[];n.skip&&o.push(n.skip);let c=n.templateAttr===null?null:n.templateAttr||"cms-template";if(c&&o.push("["+c+"]"),o.length){let l=o.join(", ");r=r.filter(s=>!s.closest||!s.closest(l))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,gt(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),mt(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),mt(e,t,null)},prop(e,t,n){if(n===void 0){let i=e?e[t]:void 0;return i!==void 0?i:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return wt(t),t},insertAt(e,t,n){let i=e.children[n]||null;e.insertBefore(t,i)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let i=e.ownerDocument.createElement("template");i.innerHTML=t;let r=i.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(i=>{i.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function I(e,t={}){if(t.exclude===null)return S;let n=[Z("data"),t.exclude].filter(Boolean).join(", "),i=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!i?.querySelector?.(n))return S;let o=e.nodeType===9||!e.isConnected?e:e.ownerDocument,c=e.nodeType===9?e:e.ownerDocument,l=null,s=()=>l||(l=ee(o,{capability:"data",exclude:t.exclude||null})),f=a=>{let m=s();return a===e?m.cloneOf(e):m.cloneOf(a)||a},u=a=>l?.original(a)||a,d=(a,m)=>{s().liveToClone.set(a,m),s().cloneToLive.set(m,a);let g=a.childNodes||[],p=m.childNodes||[];for(let y=0;y<Math.min(g.length,p.length);y++)d(g[y],p[y])},h=(a,m,g,p)=>{let y=Array.from(a.childNodes).filter(T=>l.cloneOf(T)),E=y[0];for(;E&&y.includes(E);)E=E.nextSibling;for(let T of y)T.remove();if(g==="innerHTML"){let T=c.createElement("template");T.innerHTML=p;for(let V of Array.from(T.content.childNodes))a.insertBefore(V,E||null)}else a.insertBefore(c.createTextNode(p),E||null),gt(a,p);let x=ee(a,{capability:"data",exclude:t.exclude||null});m.replaceChildren(...Array.from(x.root?.childNodes||[]));let O=T=>{let V=x.original(T);V&&(l.liveToClone.set(V,T),l.cloneToLive.set(T,V));for(let Et of Array.from(T.childNodes||[]))O(Et)};for(let T of Array.from(m.childNodes))O(T)},A={...S,find(a,m,g={}){let p=f(a);if(!p?.querySelectorAll)return[];let y=s().query(m,p);g.includeRulesTag||(y=y.filter(x=>!yt(x)));let w=[];g.skip&&w.push(g.skip);let E=g.templateAttr===null?null:g.templateAttr||"cms-template";if(E&&w.push(`[${E}]`),w.length){let x=w.join(", ");y=y.filter(O=>!O.closest?.(x))}return y},parent(a){let m=f(a)?.parentElement;return m?u(m):null},children(a){return Array.from(f(a)?.children||[],u)},text(a,m){if(m===void 0){let y=u(a);return!y?.matches?.(n)&&!y?.querySelector?.(n)?S.text(y):(f(a)?.textContent||"").trim()}let g=u(a);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!l){S.text(g,m);return}let p=s().cloneOf(g);p?h(g,p,"textContent",m):S.text(g,m)},attr(a,m,g){let p=u(a);if(g===void 0)return S.attr(p,m);S.attr(p,m,g);let y=l?.cloneOf(p);y&&(S.attr(y,m,g),ee(p,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),l.liveToClone.delete(p),l.cloneToLive.delete(y)))},removeAttr(a,m){let g=u(a);S.removeAttr(g,m);let p=l?.cloneOf(g);p&&S.removeAttr(p,m)},prop(a,m,g){let p=u(a);if(g===void 0)return m==="innerHTML"||m==="outerHTML"||m==="textContent"||m==="innerText"?S.prop(f(p),m):S.prop(p,m);let y=m==="innerHTML"||m==="textContent"||m==="innerText",w=y?s().cloneOf(p):l?.cloneOf(p);w&&y?h(p,w,m,g):(S.prop(p,m,g),w&&S.prop(w,m,g))},clone(a){let m=f(a);if(m===a)return S.clone(a);let g=c.importNode(m,!0);return wt(g),g},insertAt(a,m,g){let p=u(a),w=A.children(p)[g]||(()=>{for(let O=p.children.length-1;O>=0;O--){let T=p.children[O];if(s().cloneOf(T))return T.nextElementSibling}return p.firstElementChild})(),E=u(m);p.insertBefore(E,w||null);let x=s().cloneOf(p);if(x){let O=s().cloneOf(E);O||(O=c.importNode(E,!0),d(E,O));let T=Array.from(x.children);x.insertBefore(O,T[g]||null)}},insertBefore(a,m){let g=u(a),p=u(m);g.parentNode.insertBefore(p,g);let y=s().cloneOf(g.parentNode);if(y){let w=s().cloneOf(p);w||(w=c.importNode(p,!0),d(p,w));let E=s().cloneOf(g);E?E.before(w):y.appendChild(w)}},insertAfter(a,m){let g=u(a),p=u(m);g.parentNode.insertBefore(p,g.nextSibling);let y=s().cloneOf(g.parentNode);if(y){let w=s().cloneOf(p);w||(w=c.importNode(p,!0),d(p,w));let E=s().cloneOf(g);E?E.after(w):y.appendChild(w)}},identity(a){return u(a)||null},remove(a){let m=u(a),g=s().cloneOf(m);S.remove(m),g&&S.remove(g)},replaceWith(a,m){let g=u(a),p=s().cloneOf(g),y=S.replaceWith(g,m);if(p){let w=ee(y,{capability:"data",exclude:t.exclude||null});if(!w.root)p.remove();else{p.replaceWith(w.root);let E=x=>{let O=w.original(x);O&&(l.liveToClone.set(O,x),l.cloneToLive.set(x,O));for(let T of Array.from(x.childNodes||[]))E(T)};E(w.root)}}return y}};return A}var te=S;var ne=e=>({codecs:Se(),...e}),re={extract:(e,t,n={})=>L(I(e,n),e,t,ne(n)),apply:(e,t,n,i={})=>D(I(e,{...i,_write:!0}),e,t,n,ne(i)),findRulesIn:(e,t)=>W(te,e,t),findRules:(e,t)=>Ie(te,e,t),bind:(e,t,n={})=>{let i=Ie(te,e,t);if(!i){let o=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${o}`)}let r=ne({version:i.version,...n});return{...i,get:()=>L(I(e,n),e,i.rules,r),set:o=>D(I(e,{...n,_write:!0}),e,i.rules,o,r)}},codecs:{register:Te,get:Oe},parseStrict:Pe,parseRelaxed:Y,ruleAttrIndex:N,splitRule:b,errors:R,DOM_PROPERTIES:ie},_e=e=>!!e&&typeof e.nodeType=="number";function At(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=W(te,t,"api");if(!n)throw new R.NoRulesTag("api");return{rules:n.rules,version:n.version}}function dn(e){if(e.nodeType===9)return e;let t=e.ownerDocument?.documentElement;if(t?.contains(e))return t;let n=e;for(;n.parentNode;)n=n.parentNode;return n}function hn(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let t=e.ownerDocument.createDocumentFragment();for(let n of e.childNodes)t.appendChild(n.cloneNode(!0));return t}function pn(e,t){let n=[];for(;t!==e;){let i=t.parentNode;n.push(Array.prototype.indexOf.call(i.childNodes,t)),t=i}return n.reverse()}function mn(e,t){return t.reduce((n,i)=>n.childNodes[i],e)}function q(e,t){let n=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&n.unshift(e),n}function yn(e,t){let n=q(e,"option"),i=q(t,"option");n.forEach((s,f)=>i[f].selected=s.selected);let r=q(e,"input"),o=q(t,"input");r.forEach((s,f)=>{let u=s.type.toLowerCase();u!=="file"&&(o[f].value=s.value),(u==="checkbox"||u==="radio")&&(o[f].checked=s.checked)});let c=q(e,"textarea"),l=q(t,"textarea");c.forEach((s,f)=>l[f].value=s.value)}function $e(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let n=e.startsWith("@")?0:N(e);if(n===-1)return;let i=e.slice(n+1);if(B.has(i))throw new R.RuleTargetReadOnly(i);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(n=>$e(e[1],n));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[n,i]of Object.entries(e))$e(i,t[n])}}function gn(e,t,n,i){let r=ne({templateAttr:"cms-template",version:i}),o=dn(e),c=pn(o,e),l=hn(o);yn(o,l);let s=mn(l,c),f=I(l,{...r,_write:!0}),u=Le(f,s,t,n,r);if(u.unknownKeys.length||u.unmatched.length)throw new R.WriteRejected(u.unknownKeys,u.unmatched);let d=de(f);D(d,s,t,n,r),d.assertClean(),$e(t,n);let h=de(I(o,{...r,_write:!0}));D(h,e,t,n,r),h.assertClean()}function wn(e){if(!(e instanceof Error))return e;let n=e instanceof R.UnknownCodec||e instanceof R.CodecRefused?e.code:e.name||"Error";try{e.code=n}catch{Object.defineProperty(e,"code",{value:n,configurable:!0,enumerable:!0})}return e instanceof R.WriteRefused?e.details=e.refusals:e instanceof R.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof R.ShapeMismatch?e.details=e.mismatches:Array.isArray(e.path)?e.details={path:e.path}:typeof e.target=="string"?e.details={target:e.target}:e.token!==void 0?e.details={token:e.token}:e.version!==void 0?e.details={version:e.version}:e.details={},e}function je(e,t){let n=_e(e)?e:document,i=_e(e)?t:e;if(i===void 0){let{rules:r,version:o}=At(n);return L(I(n),n,r,ne({version:o}))}return re.bind(n,i).get()}function De(e,t,n){try{if(!_e(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let{rules:i,version:r}=n===void 0?At(e):re.bind(e,n);gn(e,i,t,r)}catch(i){throw wn(i)}return e}var An={engine:re,extractData:je,applyData:De},En=An;return bt(Tn);})();
|