@panphora/clayjs 1.24.0 → 1.25.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/dist/all.js +1 -1
- package/dist/clay-dom.js +1 -1
- package/dist/clay-events.js +1 -1
- package/dist/clay-internals.js +1 -1
- package/dist/clay-options.js +1 -1
- package/dist/clay-router.js +1 -1
- package/dist/clay-ui.js +1 -1
- package/dist/clay-utils.js +1 -1
- package/dist/clay.js +1 -1
- package/dist/clay.standalone.js +16610 -14400
- package/dist/m/attrs/{refetch-on-save-DPGJJMGN.js → refetch-on-save-5CBFUJUF.js} +1 -1
- package/dist/m/attrs/save-freeze-MH3AOD56.js +1 -0
- package/dist/m/c-277QP5ET.js +1 -0
- package/dist/m/{c-SXGEWPFC.js → c-3E2IK5HU.js} +1 -1
- package/dist/m/{c-A4L7APIU.js → c-4AE2A2LK.js} +1 -1
- package/dist/m/{c-DZPO22O3.js → c-4Q6QIODW.js} +1 -1
- package/dist/m/{c-RO73MKKR.js → c-52OC3OH3.js} +1 -1
- package/dist/m/{c-VNAYHV2J.js → c-5PZYDWTW.js} +1 -1
- package/dist/m/c-5Q5XBN56.js +1 -0
- package/dist/m/c-5SZ6KFR5.js +1 -0
- package/dist/m/{c-ZRGEN6QQ.js → c-AI3H6ETU.js} +2 -2
- package/dist/m/{c-7V6MGMX2.js → c-BCWYEG6P.js} +1 -1
- package/dist/m/{c-A7N5TNSL.js → c-BJ2RRQBQ.js} +1 -1
- package/dist/m/{c-CTGRDT6E.js → c-C6YZNU6E.js} +1 -1
- package/dist/m/{c-DLBX4JCJ.js → c-C7SUMNMI.js} +1 -1
- package/dist/m/c-CITLTVQ4.js +4 -0
- package/dist/m/{c-TWOXQQKV.js → c-CL5LSATX.js} +1 -1
- package/dist/m/c-CU33V6RW.js +4 -0
- package/dist/m/{c-2R4OBWIP.js → c-D62HRSZK.js} +1 -1
- package/dist/m/{c-DD26VXAP.js → c-DT7E76Z2.js} +1 -1
- package/dist/m/{c-54ZZZYUN.js → c-EAV7A6BT.js} +1 -1
- package/dist/m/{c-RBPZNU2D.js → c-EQ5NBOGA.js} +1 -1
- package/dist/m/{c-KQKKIVLW.js → c-FBOO2UY3.js} +1 -1
- package/dist/m/{c-RTSRGGTP.js → c-FJDTDGDA.js} +1 -1
- package/dist/m/{c-MQKSKQHG.js → c-FKTALXNV.js} +1 -1
- package/dist/m/{c-GNIVHLEJ.js → c-GDNZEOOZ.js} +1 -1
- package/dist/m/{c-SUXHUL7U.js → c-GEAG5XAK.js} +1 -1
- package/dist/m/{c-UM7VZDTW.js → c-GY4BREDT.js} +1 -1
- package/dist/m/{c-4PO3YGDC.js → c-HGG7M2S3.js} +1 -1
- package/dist/m/c-HKSLOVU4.js +1 -0
- package/dist/m/{c-KJHVB2KG.js → c-HXGNH6GY.js} +1 -1
- package/dist/m/{c-FLEIU6CG.js → c-IESDKFO6.js} +1 -1
- package/dist/m/{c-SNVDWMM3.js → c-IJHF4IO6.js} +1 -1
- package/dist/m/{c-SGGGCIVD.js → c-IL5IVTOG.js} +1 -1
- package/dist/m/c-JB5YU57S.js +1 -0
- package/dist/m/{c-MP6S4AZU.js → c-JD2VFAYG.js} +2 -2
- package/dist/m/{c-CV4T65JE.js → c-JWW6BHWD.js} +3 -3
- package/dist/m/{c-GM7OA6EJ.js → c-K4M76VPM.js} +1 -1
- package/dist/m/{c-RXTPKCMC.js → c-KU3PX7LL.js} +1 -1
- package/dist/m/{c-2PVGJFI5.js → c-KYTVZT4D.js} +1 -1
- package/dist/m/{c-RJKKRWHW.js → c-M7ITYKMF.js} +1 -1
- package/dist/m/c-MFB74XVN.js +3 -0
- package/dist/m/c-MOP5KBWZ.js +1 -0
- package/dist/m/{c-YB3CDTDZ.js → c-MUM53J5J.js} +1 -1
- package/dist/m/{c-YK2L436K.js → c-MV7TEUTD.js} +1 -1
- package/dist/m/{c-LA2BW7UY.js → c-MZCOGNZL.js} +1 -1
- package/dist/m/{c-YGGO2G2L.js → c-N4GEJMXW.js} +1 -1
- package/dist/m/{c-NQAPWM7O.js → c-NADLYVAH.js} +1 -1
- package/dist/m/{c-RS77ODLY.js → c-NL4I4KNG.js} +1 -1
- package/dist/m/{c-6UPEKW6O.js → c-O2QZDVZ2.js} +1 -1
- package/dist/m/{c-LTSPHVAK.js → c-OBMZASYQ.js} +1 -1
- package/dist/m/{c-LUXAB2XI.js → c-ORLPQFNU.js} +1 -1
- package/dist/m/c-P73XPAOA.js +1 -0
- package/dist/m/{c-PWJSJEJU.js → c-PNZIJFG7.js} +1 -1
- package/dist/m/{c-ZKKAF4UT.js → c-PRZNJUYZ.js} +2 -2
- package/dist/m/{c-Q6VNQDJE.js → c-Q2CB57UG.js} +1 -1
- package/dist/m/{c-TWCXBWS3.js → c-QCDVDZIR.js} +1 -1
- package/dist/m/{c-P5NKFRL4.js → c-QDVG4NAZ.js} +1 -1
- package/dist/m/c-QWB53KRW.js +1 -0
- package/dist/m/{c-GNI7WHKF.js → c-RGAALCDU.js} +1 -1
- package/dist/m/c-RHPHMTF2.js +2 -0
- package/dist/m/{c-BULK5J4M.js → c-RWJ3OSCP.js} +1 -1
- package/dist/m/{c-5FXEKU4Y.js → c-SEVOS4UE.js} +1 -1
- package/dist/m/{c-PMRRMT72.js → c-SFYTKRU7.js} +1 -1
- package/dist/m/{c-47IBJGPQ.js → c-SFZRY6RT.js} +1 -1
- package/dist/m/{c-QENKN7QI.js → c-SGG6MUXW.js} +1 -1
- package/dist/m/c-SMLAJASY.js +1 -0
- package/dist/m/{c-VSEUFJAO.js → c-SUAC5RSG.js} +1 -1
- package/dist/m/{c-6RGEQNVV.js → c-SXZYVXD6.js} +1 -1
- package/dist/m/{c-ZFO5RW6G.js → c-TCFVG3I4.js} +1 -1
- package/dist/m/{c-PZRWZZRO.js → c-TLQINES7.js} +2 -2
- package/dist/m/c-U4TWEIKZ.js +1 -0
- package/dist/m/{c-FZRZPIFS.js → c-U65PREMC.js} +1 -1
- package/dist/m/{c-7YETSAVY.js → c-U7F66I64.js} +1 -1
- package/dist/m/{c-WOELSNWS.js → c-UD4VDBGJ.js} +1 -1
- package/dist/m/{c-VI3BJHCM.js → c-V2FPBRO6.js} +1 -1
- package/dist/m/{c-2OIKXOY6.js → c-V4B3RUWB.js} +1 -1
- package/dist/m/{c-O5ARALMJ.js → c-V5L6HWVL.js} +1 -1
- package/dist/m/c-VMXCX52Q.js +1 -0
- package/dist/m/{c-PVJMJL3P.js → c-VO6RSFCO.js} +1 -1
- package/dist/m/c-WDFQ7PBU.js +1 -0
- package/dist/m/{c-OG6GFSUX.js → c-WGQVSKKC.js} +1 -1
- package/dist/m/c-WSTUCBHV.js +1 -0
- package/dist/m/{c-EY5KDUZF.js → c-WVCT3ITX.js} +1 -1
- package/dist/m/{c-SE3SIY7Y.js → c-X3V4RWMA.js} +1 -1
- package/dist/m/{c-HIX5H5L7.js → c-XHZIKRCV.js} +1 -1
- package/dist/m/{c-2BLVA6IN.js → c-XQTERKQA.js} +1 -1
- package/dist/m/{c-A5ZBFICF.js → c-YFO6ZJLQ.js} +1 -1
- package/dist/m/{c-PD5AKHY3.js → c-YX2MC7YL.js} +1 -1
- package/dist/m/{c-OYHI67B6.js → c-YYGUHSZR.js} +1 -1
- package/dist/m/{c-YYMZWQLR.js → c-Z2OZFX3N.js} +1 -1
- package/dist/m/{c-AT7GLQGV.js → c-ZEA3DCG3.js} +1 -1
- package/dist/m/{c-75N3KG35.js → c-ZJG6C2WL.js} +1 -1
- package/dist/m/{c-FVPNX2GO.js → c-ZORVIXUR.js} +1 -1
- package/dist/m/{c-FV46ZKGX.js → c-ZPI7M5U5.js} +1 -1
- package/dist/m/core/{admin-attrs-5UGMYCKW.js → admin-attrs-ZI6K6UGM.js} +1 -1
- package/dist/m/core/{autosave-4P66VXX7.js → autosave-BSM2ABJL.js} +1 -1
- package/dist/m/core/{conflict-notice-BAR23OWH.js → conflict-notice-7EQLDYPA.js} +1 -1
- package/dist/m/core/draft-mode-M5XNYBMY.js +1 -0
- package/dist/m/core/{host-permission-3HE4CFD6.js → host-permission-5BYP24GC.js} +1 -1
- package/dist/m/core/{is-edit-mode-GK7IFFMT.js → is-edit-mode-73OXKK5H.js} +1 -1
- package/dist/m/core/{persist-AIJGTKKI.js → persist-2SZO3PCE.js} +1 -1
- package/dist/m/core/{recovery-LPB6X72P.js → recovery-VZF7RJZF.js} +1 -1
- package/dist/m/core/{save-FV4ZCKBI.js → save-K6Q47J2X.js} +1 -1
- package/dist/m/core/{save-core-K7XFAWQ4.js → save-core-U3Z44XBO.js} +1 -1
- package/dist/m/core/{site-edits-TEQORBJU.js → site-edits-CFMF6GHD.js} +1 -1
- package/dist/m/core/{snapshot-FJP5IJL3.js → snapshot-PWCHYFL6.js} +1 -1
- package/dist/m/core/unsaved-warning-2WRZLJH5.js +1 -0
- package/dist/m/events/{index-B6TGDYMG.js → index-YKQIBZE5.js} +1 -1
- package/dist/m/internals/index-FSLC4M7J.js +1 -0
- package/dist/m/lib/{cache-bust-NH7VBWHO.js → cache-bust-BL4KUQAJ.js} +1 -1
- package/dist/m/loader-RC54UV7H.js +1 -0
- package/dist/m/manifest-3B84C829.js +1 -0
- package/dist/m/manifest-edit-1CB79AD4.js +1 -0
- package/dist/m/manifest.json +1215 -1129
- package/dist/m/options/{options-55LQHSJ4.js → options-LKIZ7YTG.js} +1 -1
- package/dist/m/page/{editor-KAZDJNND.js → editor-PKSPJ2XJ.js} +2 -2
- package/dist/m/plugins/{ai-edit-CUKQQWJX.js → ai-edit-3LG6MGS3.js} +1 -1
- package/dist/m/plugins/{cms-JANMGPHM.js → cms-T2HLI7JG.js} +16 -16
- package/dist/m/plugins/{demo-JIR7DXJA.js → demo-LMCMBILC.js} +1 -1
- package/dist/m/plugins/{derive-QVI3LI3A.js → derive-7DR5TUDH.js} +1 -1
- package/dist/m/plugins/{indicator-DAKZGAWI.js → indicator-CTKX4EY7.js} +1 -1
- package/dist/m/plugins/{live-UAJGWRNP.js → live-IFLL6YN5.js} +1 -1
- package/dist/m/plugins/{menu-BFJ644YX.js → menu-YJZ3JWBC.js} +1 -1
- package/dist/m/plugins/page-GTDPYGE4.js +2 -0
- package/dist/m/plugins/{page-view-OYN7Z5TS.js → page-view-NMCCU6MF.js} +1 -1
- package/dist/m/plugins/{people-VBDR5Y22.js → people-6WIWCZEG.js} +1 -1
- package/dist/m/plugins/{richclay-CBLZRFB4.js → richclay-L3BZMX4I.js} +3 -3
- package/dist/m/plugins/sortable-365SRRL3.js +1 -0
- package/dist/m/plugins/{source-ZXDD7F6X.js → source-7LSGOV46.js} +1 -1
- package/dist/m/plugins/{undo-5JI5G7CQ.js → undo-UES4KS7B.js} +1 -1
- package/dist/m/plugins/{upgrade-6B6QS3NR.js → upgrade-MMPZUCDM.js} +1 -1
- package/dist/m/plugins/{upload-DNJNW6H3.js → upload-NZET3DNQ.js} +1 -1
- package/dist/m/plugins/visitor-drafts-V5YB7XDH.js +20 -0
- package/dist/m/plugins/{visitor-drafts-owner-VIAZC3CF.js → visitor-drafts-owner-TLECTYWS.js} +1 -1
- package/dist/m/plugins/{visitor-menu-ZHKWIKKY.js → visitor-menu-QDV2MYJN.js} +1 -1
- package/dist/m/plugins/wire-3YGUO3GE.js +1 -0
- package/dist/m/{reader-core-F6RY3V64.js → reader-core-VR7EL4WV.js} +2 -2
- package/dist/m/sync/live-sync-XMXXZS3G.js +1 -0
- package/dist/m/vendor/sap-core.vendor-JANUQULT.js +7 -0
- package/dist/offline-manifest.json +724 -664
- package/docs/guide.md +1 -0
- package/entries/clay-data.js +1 -1
- package/entries/sap.js +6 -5
- package/package.json +2 -2
- package/src/core/draft-mode.js +11 -0
- package/src/core/save-core.js +16 -17
- package/src/core/save.js +1 -1
- package/src/core/unsaved-warning.js +2 -2
- package/src/lib/dirty-gate.js +19 -0
- package/src/lib/idb-error-code.js +20 -0
- package/src/loader.js +2 -0
- package/src/plugins/menu/visitor.js +33 -1
- package/src/plugins/page.js +19 -5
- package/src/plugins/sortable.js +7 -0
- package/src/plugins/visitor-drafts/commit.js +350 -0
- package/src/plugins/visitor-drafts/idb.js +227 -0
- package/src/plugins/visitor-drafts/prompt.js +23 -3
- package/src/plugins/visitor-drafts/recovery-menu.js +118 -0
- package/src/plugins/visitor-drafts/recovery.js +64 -0
- package/src/plugins/visitor-drafts/session.js +393 -0
- package/src/plugins/visitor-drafts/store.js +247 -27
- package/src/plugins/visitor-drafts.js +177 -28
- package/src/sync/live-sync.js +1 -1
- package/src/sync/wire-profile.js +9 -4
- package/src/vendor/hyper-html-api-data.vendor.js +1 -1
- package/src/vendor/hyper-html-api-upgrade.vendor.js +2 -2
- package/src/vendor/hypercms.vendor.js +16 -16
- package/src/vendor/richclay.vendor.js +1 -1
- package/src/vendor/sap-core.vendor.js +6 -5
- package/src/vendor/sap-ownership.vendor.js +181 -11
- package/tool-generation/system.md +1 -1
- package/dist/m/attrs/save-freeze-JZHKRQLR.js +0 -1
- package/dist/m/c-234RSEIW.js +0 -1
- package/dist/m/c-2YIJ6ZA6.js +0 -1
- package/dist/m/c-H2H7TI6O.js +0 -1
- package/dist/m/c-HSNGLIFB.js +0 -3
- package/dist/m/c-JMDKPBMC.js +0 -4
- package/dist/m/c-LO4C4J77.js +0 -1
- package/dist/m/c-N7JPUPGC.js +0 -1
- package/dist/m/c-NEXFVJIT.js +0 -1
- package/dist/m/c-R23UHMXG.js +0 -1
- package/dist/m/c-T527QHOB.js +0 -1
- package/dist/m/c-V2U3F4QX.js +0 -1
- package/dist/m/c-VG5XIN4T.js +0 -1
- package/dist/m/c-YINHPF4V.js +0 -1
- package/dist/m/core/draft-mode-WSQAT67S.js +0 -1
- package/dist/m/core/unsaved-warning-FF63QGKI.js +0 -1
- package/dist/m/internals/index-AX4CG7B2.js +0 -1
- package/dist/m/loader-5IA5OJ3J.js +0 -1
- package/dist/m/manifest-98258645.js +0 -1
- package/dist/m/manifest-edit-ABF56000.js +0 -1
- package/dist/m/plugins/page-ZBIYHGK4.js +0 -2
- package/dist/m/plugins/sortable-HDOQ6GAC.js +0 -1
- package/dist/m/plugins/visitor-drafts-A5FDQ2G7.js +0 -20
- package/dist/m/plugins/wire-XOT7XKJL.js +0 -1
- package/dist/m/sync/live-sync-M2PP2IWY.js +0 -1
- package/dist/m/vendor/sap-core.vendor-OA5SKL7Q.js +0 -6
- /package/dist/m/plugins/{richclay-CBLZRFB4.js.LEGAL.txt → richclay-L3BZMX4I.js.LEGAL.txt} +0 -0
package/dist/m/c-234RSEIW.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var ze=Object.defineProperty,_e=(e,t)=>{for(var r in t)ze(e,r,{get:t[r],enumerable:!0})},Ae=["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"],Ve=new Set(Ae),Fe=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Te=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),ne=new Set(["checked","selected","disabled","readOnly","paused"]);function Je(e,t){return t==null?ne.has(e)?!1:"":ne.has(e)?t==="false"?!1:!!t:t}var O={};_e(O,{EmptyListInsert:()=>L,MAX_RULE_DEPTH:()=>H,MaxRuleDepthExceeded:()=>X,NoRulesTag:()=>Ze,RuleTargetReadOnly:()=>Ee,RulesParseError:()=>K,ShapeMismatch:()=>xe,UnknownRulesVersion:()=>be,WriteNotRoundTripped:()=>Xe,WriteRefused:()=>Oe,WriteRejected:()=>Ge});var K=class extends Error{constructor(e,t){super(e),this.name="RulesParseError",this.cause=t}},be=class extends Error{constructor(e){super(`unknown rules version: ${e}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=e}},H=20,X=class extends Error{constructor(e){super(`rule depth exceeded ${H} at path: ${e.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=e}},xe=class extends Error{constructor(e){super(`shape mismatch: ${e.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=e}},L=class extends Error{constructor(e,t){super(t?`cannot add items to empty list at "${e.join(".")}" \u2014 ${t}`:`cannot add items to empty list at "${e.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=e}},Ee=class extends Error{constructor(e){super(`cannot write to read-only DOM property "${e}"`),this.name="RuleTargetReadOnly",this.target=e}},Oe=class extends Error{constructor(e){super(`write refused: ${e.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=e}};function Ke(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t?`${t}.${r}`:String(r),"")||"(root)"}var Xe=class extends Error{constructor(e){super(`write did not round-trip at "${Ke(e)}"`),this.name="WriteNotRoundTripped",this.path=e}},Ze=class extends Error{constructor(e){super(`no <script data-rules-name~="${e}"> rules tag in this document`),this.name="NoRulesTag",this.token=e}},Ge=class extends Error{constructor(e,t){super(`write rejected: ${e.length} unknown key(s), ${t.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=e,this.unmatched=t}};function j(e){let t=0,r=null,l=-1;for(let n=0;n<e.length;n++){let o=e[n];o==="\\"?n++:r?o===r&&(r=null):o==='"'||o==="'"?r=o:o==="["||o==="("?t++:o==="]"||o===")"?t>0&&t--:o==="@"&&t===0&&(l=n)}return l}var le="[*]";function R(e){let t=j(e),r=t===-1?e:e.slice(0,t),l=r.endsWith(le),n={selector:l?r.slice(0,-le.length):r,prop:t===-1?null:e.slice(t+1)||null};return l&&(n.all=!0),n}function Ne(e){let t=0,r=null,l=-1,n=!1;for(let o=0;o<e.length;o++){let a=e[o];a==="\\"?o++:r?a===r&&(r=null):a==='"'||a==="'"?r=a:a==="["||a==="("?t++:a==="]"||a===")"?t>0&&t--:t===0&&a===">"?l=o:t===0&&a===","&&(n=!0)}return n||l===-1||!Qe(e,l+1)?null:e.slice(0,l).trim()||null}function Qe(e,t){let r=t,l=e.replace(/\s+$/,"").length;for(;r<l&&/\s/.test(e[r]);)r++;let n=0,o=null;for(;r<l;r++){let a=e[r];if(a==="\\")r++;else if(o)a===o&&(o=null);else if(a==='"'||a==="'")o=a;else if(a==="["||a==="(")n++;else if(a==="]"||a===")")n>0&&n--;else if(n===0&&(a==="+"||a==="~"||/\s/.test(a)))return!1}return!0}var Ye=/^--[A-Za-z0-9_-]+$/;function Z(e){return typeof e=="string"&&Ye.test(e)}function Se(e){let t=[],r=[],l=null,n=0;for(let o=0;o<e.length;o++){let a=e[o];if(l){a==="\\"?o++:a===l&&(l=null);continue}if(a==="/"&&e[o+1]==="*"){let i=e.indexOf("*/",o+2);o=i===-1?e.length:i+1;continue}a==='"'||a==="'"?l=a:a==="("?r.push(")"):a==="["?r.push("]"):a==="{"?r.push("}"):(a===")"||a==="]"||a==="}")&&r[r.length-1]===a?r.pop():a===";"&&r.length===0&&(t.push(e.slice(n,o)),n=o+1)}return t.push(e.slice(n)),t}function et(e){let t="",r=null;for(let l=0;l<e.length;l++){let n=e[l];if(r){t+=n,n==="\\"&&l+1<e.length?t+=e[++l]:n===r&&(r=null);continue}if(n==="/"&&e[l+1]==="*"){let o=e.indexOf("*/",l+2);l=o===-1?e.length:o+1,t+=" ";continue}(n==='"'||n==="'")&&(r=n),t+=n}return t}function Re(e){e=et(e);let t=e.indexOf(":");if(t===-1)return null;let r=e.slice(0,t).trim(),l=e.slice(t+1).trim(),n=/!\s*important\s*$/i.exec(l);return n&&(l=l.slice(0,n.index).trim()),{name:r,value:l,important:!!n}}function G(e,t){if(e==null)return null;let r=null;for(let l of Se(String(e))){let n=Re(l);!n||n.name!==t||(!r||n.important||!r.important)&&(r=n)}return r?r.value:null}function tt(e,t,r){let l=e==null?"":String(e),n=r==null||r==="",o=Se(l),a=o.map(Re),i=a.some(h=>h&&h.name===t&&h.important),u=[],s=!1;o.forEach((h,p)=>{let v=a[p];if(!v||v.name!==t){u.push(h);return}if(n||s)return;let f=/^\s*/.exec(h)[0];u.push(`${f}${t}: ${r}${i?" !important":""}`),s=!0});let c=u.join(";");if(!n&&!s){let h=c.trimEnd();c=h===""?`${t}: ${r}`:`${h}${h.endsWith(";")?" ":"; "}${t}: ${r}`}return c.trim()===""?null:c}function $e(e,t,r,l){let n=e.attr(t,"style");if((G(n,r)??"")===l)return;let o=tt(n,r,l);o==null?e.removeAttr(t,"style"):e.attr(t,"style",o)}function W(e,t,r,l={}){if(Object.prototype.hasOwnProperty.call(l,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return U(e,t,r,{depth:0,path:[]},l)}function U(e,t,r,l,n){if(l.depth>H)throw new X(l.path);if(typeof r=="string")return rt(e,t,r,l,n);if(Array.isArray(r)){let[o,a]=r,i=e.find(t,o,n);return Ce(n,l,i),i.map((u,s)=>U(e,u,a,{depth:l.depth+1,path:[...l.path,s]},n))}if(typeof r=="object"&&r!==null){let o={};for(let[a,i]of Object.entries(r))o[a]=U(e,t,i,{depth:l.depth+1,path:[...l.path,a]},n);return o}return null}function rt(e,t,r,l,n){if(r.endsWith("[]")){let s=r.slice(0,-2),c=e.find(t,s,n);return Ce(n,l,c),c.map(h=>e.text(h))}if(r.startsWith("@"))return q(e,t,r.slice(1));let o=j(r);if(o!==-1){let{selector:s,all:c}=R(r),h=r.slice(o+1),p=s?e.find(t,s,n):[t];return c&&n.allMatches?p.map(v=>q(e,v,h)):p.length===0?null:q(e,p[0],h)}if(r===".")return e.text(t);let{selector:a,all:i}=R(r),u=e.find(t,a,n);return i&&n.allMatches?u.map(s=>e.text(s)):u.length===0?null:e.text(u[0])}function Ce(e,t,r){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),r)}catch(l){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,l)}}function q(e,t,r){if(Z(r))return G(e.attr(t,"style"),r);if(Ve.has(r)){let n=e.prop(t,r);return n==null?null:String(n)}return e.attr(t,r)??null}function nt(e,t,r,l){let n=e.length,o=t.length,a=new Array(n).fill(-1);if(l){let d=new Set;for(let y=0;y<n;y++){let w=l[y];!(w>=0&&w<o)||d.has(w)||(a[y]=w,d.add(w))}}if(n===0||o===0)return a;let i=e.map(d=>oe(d,r)),u=t.map(d=>oe(d,r)),s=new Array(o).fill(!1);for(let d of a)d>=0&&(s[d]=!0);let c=new Map;u.forEach((d,y)=>{s[y]||c.set(d,c.has(d)?-1:y)});let h=new Map;i.forEach((d,y)=>{a[y]>=0||h.set(d,(h.get(d)||0)+1)}),i.forEach((d,y)=>{if(a[y]>=0||h.get(d)!==1)return;let w=c.get(d);w===void 0||w===-1||s[w]||(a[y]=w,s[w]=!0)});let p=[];for(let d=0;d<n;d++)a[d]<0&&p.push(d);let v=[];for(let d=0;d<o;d++)s[d]||v.push(d);if(p.length===0||v.length===0)return a;let f=n*o+1,m=lt(e,t,r),g=(d,y)=>m(d,y)*f+Math.abs(d-y);for(let[d,y]of ot(p,v,g))a[d]=y;return a}var ke=e=>typeof e=="object"&&e!==null;function oe(e,t){if(!ke(t))return e==null?" null":String(e);let r=Object.keys(t);return JSON.stringify(r.map(l=>{let n=JSON.stringify(e?.[l]);return n===void 0?" undef":n}))}function lt(e,t,r){if(!ke(r))return(i,u)=>e[i]===t[u]?0:1;let l=Object.keys(r),n=i=>l.map(u=>JSON.stringify(i?.[u])),o=e.map(n),a=t.map(n);return(i,u)=>{let s=o[i],c=a[u],h=0;for(let p=0;p<l.length;p++)s[p]!==c[p]&&h++;return h}}function ot(e,t,r){return e.length<=t.length?ie(e,t,r,!1):ie(t,e,(l,n)=>r(n,l),!0)}function ie(e,t,r,l){let n=e.length,o=t.length,a=[];for(let h=0;h<=n;h++)a.push(new Float64Array(o+1).fill(1/0));let i=[];for(let h=0;h<=n;h++)i.push(new Uint8Array(o+1));for(let h=0;h<=o;h++)a[n][h]=0;for(let h=n-1;h>=0;h--)for(let p=o-1;p>=0;p--){let v=r(e[h],t[p])+a[h+1][p+1],f=a[h][p+1];v<=f?(a[h][p]=v,i[h][p]=1):a[h][p]=f}let u=[],s=0,c=0;for(;s<n&&c<o;)i[s][c]&&(u.push(l?[t[c],e[s]]:[e[s],t[c]]),s++),c++;return u}function Le(e,t,r,l,n,o,a,i={}){let u=e.find(t,r,i);if(n.length===0){u.forEach(A=>e.remove(A)),z(i,"onRowsApplied",o.path,[]);return}let s=n.length>u.length,c=u[0]||null;if(s&&!c&&(c=st(e,t,r,i),!c))throw new L(o.path);let h=u.map(A=>at(e,A,l,i)),p=null;if(s&&c){p=e.clone(c),i.templateAttr&&e.removeAttr(p,i.templateAttr);let A=e.stripIds(p);A>0&&console.warn(`[hyper-html-api] stripped ${A} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let v=nt(n,h,l,it(e,u,n,o,i)),f=u.length>0?e.parent(u[0]):pt(e,t,r,c,o,i),m=u.length>0?je(e,f,u[0]):0,g=yt(e,u),d=new Set,y=[],w=n.map((A,b)=>{let T=v[b];if(T>=0)return d.add(T),y.push(!1),u[T];y.push(!0);let E=e.clone(p);return e.stripIds(E),E});u.forEach((A,b)=>{d.has(b)||e.remove(A)}),g?mt(e,f,m,w,y):gt(e,w,y,f,m),ut(e,w,l,n,o,a,i),z(i,"onRowsApplied",o.path,w)}function z(e,t,r,l){if(typeof e[t]=="function")try{return e[t](r.slice(),l)}catch(n){console.warn(`[hyper-html-api] ${t} threw at "${r.join(".")||"(root)"}"`,n);return}}function it(e,t,r,l,n){let o=z(n,"identifyRows",l.path,r);if(!Array.isArray(o))return null;let a=new Array(r.length).fill(-1),i=new Set,u=new Map(t.map((s,c)=>[e.identity(s),c]));for(let s=0;s<r.length;s++){if(!o[s])continue;let c=u.get(e.identity(o[s]));c===void 0||i.has(c)||(a[s]=c,i.add(c))}return a}function ut(e,t,r,l,n,o,a){t.forEach((i,u)=>{if(r===null){let s=l[u],c=s==null?"":String(s);e.text(i)!==c&&e.text(i,c)}else{let s=o(e,i,r,l[u],{depth:n.depth+1,path:[...n.path,u]},a);s&&s!==i&&(t[u]=s)}})}function at(e,t,r,l){return r===null?e.text(t):W(e,t,r,l.onRowsRead?{...l,onRowsRead:void 0}:l)}function je(e,t,r){let l=e.children(t);for(let n=0;n<l.length;n++)if(e.sameNode(l[n],r))return n;return-1}function st(e,t,r,l){if(!l.templateAttr)return null;let n=/^\s*:scope\s*>\s*/.test(r),o=new RegExp(":not\\(\\["+l.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),a=r.replace(/^\s*:scope\s*>\s*/,"").replace(o,""),i=n?ct(a):0,u=Ne(a),s=t;for(;s;){let c=e.find(s,a,{includeRulesTag:!1,templateAttr:null});for(let h of c)if(e.attr(h,l.templateAttr)!=null&&!(n&&!dt(e,t,h,i))&&!(u&&!e.matches(e.parent(h),u)))return h;s=e.parent(s)}return null}function ct(e){let t=0,r=null,l=1;for(let n=0;n<e.length;n++){let o=e[n];if(o==="\\")n++;else if(r)o===r&&(r=null);else if(o==='"'||o==="'")r=o;else if(o==="["||o==="(")t++;else if(o==="]"||o===")")t>0&&t--;else if(t===0&&o===">")l++;else{if(t===0&&(o==="+"||o==="~"))return null;if(t===0&&/\s/.test(o)){if(!ft(e,n))return null;for(;n+1<e.length&&/\s/.test(e[n+1]);)n++}}}return l}function ft(e,t){let r=t;for(;r<e.length&&/\s/.test(e[r]);)r++;let l=t>0?e[t-1]:"",n=r<e.length?e[r]:"";return ue(l)||ue(n)}function ue(e){return e===">"||e==="+"||e==="~"}function dt(e,t,r,l){if(l===null)return!0;let n=r;for(let u=0;u<l;u++)if(n=e.parent(n),!n)return!1;let o=e.prop(t,"tagName");if(!o)return!0;let a=e.prop(n,"tagName");if(!a||String(a).toLowerCase()!==String(o).toLowerCase())return!1;let i=new Set(ae(e,n));return ae(e,t).every(u=>i.has(u))}function ae(e,t){let r=e.attr(t,"class");return r?String(r).split(/\s+/).filter(Boolean):[]}function pt(e,t,r,l,n,o){let a=e.parent(l);if(a&&ht(e,t,a)&&!ce(e,a,o))return a;let i=Ne(r);if(!i)throw new L(n.path,`the list selector "${r}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let u=(i===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,i,o)).filter(s=>!ce(e,s,o));if(u.length===0)throw new L(n.path,`no container matching "${i}" inside this context to hold the new rows`);if(u.length>1)throw new L(n.path,`"${i}" matches ${u.length} containers inside this context, so the new rows have no single destination`);return u[0]}function ht(e,t,r){let l=r;for(;l;){if(e.sameNode(l,t))return!0;l=e.parent(l)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(n=>e.sameNode(n,r))}var se=["no-data","editor-ui"];function ce(e,t,r){let l=t;for(;l;){if(r.templateAttr&&e.attr(l,r.templateAttr)!=null||se.some(o=>e.attr(l,o)!=null))return!0;let n=e.attr(l,"clay");if(n&&n.split(/\s+/).some(o=>se.includes(o)))return!0;l=e.parent(l)}return!1}function mt(e,t,r,l,n){let o=e.children(t),a=o.map(u=>e.identity(u)),i=!1;l.forEach((u,s)=>{let c=e.identity(u),h=r+s;if(a[h]===c)return;if(!n[s]){let v=a.indexOf(c);v!==-1&&(a.splice(v,1),o.splice(v,1))}let p=Math.min(h,o.length);p<o.length?e.insertBefore(o[p],u):o.length?i?e.insertAfter(o[o.length-1],u):(e.insertAt(t,u,h),i=!0):e.insertAt(t,u,0),a.splice(p,0,c),o.splice(p,0,u)})}function yt(e,t){if(t.length<=1)return!0;let r=e.parent(t[0]);if(!r)return!1;let l=new Map(e.children(r).map((o,a)=>[e.identity(o),a])),n=[];for(let o of t){let a=l.get(e.identity(o));if(a===void 0)return!1;n.push(a)}return n.sort((o,a)=>o-a),n[n.length-1]-n[0]===n.length-1}function gt(e,t,r,l,n){let o=null,a=n;for(let i=0;i<t.length;i++){if(!r[i]){o=t[i];continue}let u=o?e.parent(o):l;if(!u)continue;let s=o?je(e,u,o)+1:a++;e.insertAt(u,t[i],s),o=t[i]}}function D(e,t,r,l,n={}){if(Object.prototype.hasOwnProperty.call(n,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let o=[];if(_(r,l,[],o),o.length)throw new xe(o);P(e,t,r,l,{depth:0,path:[]},n)}function P(e,t,r,l,n,o={}){if(n.depth>H)throw new X(n.path);if(l===void 0)return t;if(typeof r=="string")return wt(e,t,r,l,n,o);if(Array.isArray(r)){let[a,i]=r;return Le(e,t,a,i,l,n,P,o),t}if(typeof r=="object"&&r!==null){for(let[a,i]of Object.entries(r)){let u=P(e,t,i,l==null?l:l[a],{depth:n.depth+1,path:[...n.path,a]},o);u&&u!==t&&(t=u)}return t}return t}function wt(e,t,r,l,n,o){if(r.endsWith("[]")){let c=r.slice(0,-2);return Le(e,t,c,null,l,n,P,o),t}if(r.startsWith("@"))return de(e,t,r.slice(1),l);let a=j(r);if(a!==-1){let{selector:c,all:h}=R(r),p=r.slice(a+1),v=c?e.find(t,c,o):[t];for(let f of h?v:v.slice(0,1))de(e,f,p,l);return t}if(r===".")return fe(e,t,l),t;let{selector:i,all:u}=R(r),s=e.find(t,i,o);for(let c of u?s:s.slice(0,1))fe(e,c,l);return t}function fe(e,t,r){let l=r==null?"":String(r);e.text(t)!==l&&e.text(t,l)}function vt(e,t,r,l){if(e.styleVar){e.styleVar(t,r,l);return}$e(e,t,r,l)}function de(e,t,r,l){if(Z(r))return vt(e,t,r,l==null?"":String(l).trim()),t;if(Te.has(r)){let n=e.prop(t,r);if(n===l||n!=null&&l!=null&&String(n)===String(l))return t;throw new Ee(r)}if(r==="outerHTML"){let n=l==null?"":String(l);return e.replaceWith(t,n)}if(Fe.has(r)){let n=Je(r,l);return e.prop(t,r)!==n&&e.prop(t,r,n),t}if(l==null)e.attr(t,r)!=null&&e.removeAttr(t,r);else{let n=String(l);e.attr(t,r)!==n&&e.attr(t,r,n)}return t}function _(e,t,r,l){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((n,o)=>{typeof n=="object"&&n!==null&&l.push({path:C([...r,o]),expected:"scalar",got:$(n)})}):l.push({path:C(r),expected:"array",got:$(t)});return}t!==null&&typeof t=="object"&&l.push({path:C(r),expected:"scalar",got:$(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){l.push({path:C(r),expected:"array",got:$(t)});return}let n=e[1];t.forEach((o,a)=>_(n,o,[...r,a],l));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){l.push({path:C(r),expected:"object",got:$(t)});return}for(let[n,o]of Object.entries(e))_(o,t[n],[...r,n],l)}}}function $(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function C(e){return e.join(".")}function At(e){try{return JSON.parse(e)}catch(t){throw new K(`Invalid strict JSON: ${t.message}`,t)}}function Me(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function r(n){let o=[],a=0;for(;a<n.length;){let i=n[a];if(/\s/.test(i)){a++;continue}if("{}".includes(i)){o.push({type:i,value:i}),a++;continue}if(i==="["){let h=!1,p=a+1;for(;p<n.length&&/\s/.test(n[p]);)p++;if(p<n.length&&/[a-zA-Z_]/.test(n[p])&&(h=!0),!h){o.push({type:i,value:i}),a++;continue}}if(i==="]"){o.push({type:i,value:i}),a++;continue}if(i===":"){o.push({type:t.COLON,value:i}),a++;continue}if(i===","){o.push({type:t.COMMA,value:i}),a++;continue}if(i==='"'||i==="'"){let h=i,p=a+1;for(;p<n.length&&n[p]!==h;)n[p]==="\\"&&p++,p++;o.push({type:t.STRING,value:n.substring(a+1,p),quoted:!0,sourceQuote:h}),a=p+1;continue}let u=a,s;for(;u<n.length&&!/[{},]/.test(n[u]);)if(n[u]===":"){let h=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],p=!1;for(let v of h){let f=v.substring(1);if(n.substring(u+1,u+1+f.length)===f){p=!0,u+=f.length;break}}if(!p)break}else if(n[u]==="["){for(u++;u<n.length&&n[u]!=="]";){if(n[u]==='"'||n[u]==="'"){let h=n[u];for(u++;u<n.length&&n[u]!==h;)n[u]==="\\"&&u++,u++}u++}u<n.length&&n[u]==="]"&&u++}else u++;s=n.substring(a,u);let c=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(s)?c=t.NUMBER:s==="true"||s==="false"||s==="null"?c=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(s)&&(c=t.SELECTOR),o.push({type:c,value:s,quoted:!1}),a=u}return o}function l(n){let o="";for(let a=0;a<n.length;a++){let i=n[a];if("{}".includes(i.type)||"[]".includes(i.type)){o+=i.value;continue}if(i.type===t.COLON){o+=i.value;continue}if(i.type===t.COMMA){let u=n[a+1];if(u&&(u.type==="}"||u.type==="]"))continue;o+=i.value;continue}if(i.type===t.STRING&&i.quoted){let u=i.value;i.sourceQuote==="'"&&(u=u.replace(/\\'/g,"'"),u=u.replace(/(\\*)"/g,(s,c)=>c.length%2===0?c+'\\"':s)),o+=`"${u}"`;continue}if(i.type===t.NUMBER||i.type===t.BOOLEAN){o+=i.value;continue}if(i.type===t.SELECTOR||i.type===t.IDENTIFIER){o+=`"${i.value}"`;continue}o+=`"${i.value}"`}return o}try{let n=r(e),o=l(n);return JSON.parse(o)}catch(n){throw new K("Invalid extraction rules syntax: "+n.message,n)}}var Tt="1",pe=/^[a-zA-Z0-9_-]+$/;function Q(e,t,r){let l;if(r===void 0)l="script[data-rules-name]";else{if(typeof r!="string"||!pe.test(r))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(r)} (must match ${pe})`);l=`script[data-rules-name~="${r}"]`}let n=e.find(t,l,{includeRulesTag:!0});if(n.length===0)return null;r!==void 0&&n.length>1&&console.warn(`hyper-html-api: ${n.length} rules tags match data-rules-name~="${r}"; using the first.`);let o=n[0],a=e.attr(o,"data-rules-version");if(a!==Tt)throw new be(a);return{rules:Me(e.text(o)),tagNode:o}}var Y=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"]})}),bt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),xt=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function B(e,t){if(!e||e.nodeType!==1)return!1;let r=e.getAttribute?.("clay");return!!(r&&r.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function Ie(e,t){if(B(e,t))return!0;for(let[r,l]of Object.entries(bt))if(l.includes(t)&&B(e,r))return!0;return!1}function V(e){let t=Y[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(r=>[`[clay~="${r}"]`,`[${r}]`]).join(", ")}function Et(e,t){let r=e&&e.nodeType===1?e:e?.parentElement;for(;r&&r.nodeType===1;){let l=Y[t];if(!l)throw new Error(`Unknown region capability: ${t}`);if(l.tokens.some(n=>Ie(r,n))||l.bundles.some(n=>B(r,n)))return r;r=r.parentElement}return null}function Ot(e,t){return!!Et(e,t)}var ee=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",...xt],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"]})}),Nt=new Set(["textContent","innerText"]);function St(e){let t=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return t?t[1].toLowerCase():null}var Rt=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function $t(e,t,r=ee){if(!Rt.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let l=String(e).toLowerCase();if(r.refusedAttributePrefixes.some(n=>l.startsWith(n)))return`attribute "${l}" can run script`;if(r.refusedAttributes.includes(l))return`attribute "${l}" is not content`;if(r.urlAttributes.includes(l)&&t!=null){let n=l==="srcset"?String(t).split(",").map(o=>o.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let o of n){let a=St(o);if(a&&r.refusedSchemes.includes(a))return`"${a}:" URLs are not allowed in "${l}"`}}return null}function te(e,t){let r=e.prop(t,"tagName");return r?String(r).toLowerCase():""}function Ct(e,t){let r=te(e,t)||"node",l=e.attr(t,"id");return l?`<${r}#${l}>`:`<${r}>`}function kt(e,t,r){let l=t;for(;l;){let n=te(e,l);if(n&&r.refusedTargets.includes(n))return n;l=e.parent(l)}return null}function We(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function Lt(e,t){return te(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:We(e,t)}function jt(e){if(/[\u0000-\u001f\u007f]/.test(e))return"control characters are not allowed in a custom property value";let t=[],r=null;for(let l=0;l<e.length;l++){let n=e[l];if(r){n===r&&(r=null);continue}if(n==='"'||n==="'")r=n;else{if(n==="/"&&e[l+1]==="*")return"comments are not allowed in a custom property value";if(n==="(")t.push(")");else if(n==="[")t.push("]");else if((n===")"||n==="]")&&t.pop()!==n)return`"${n}" does not close anything in this custom property value`}}return r?"a custom property value must close its quotes":t.length?"a custom property value must close its brackets":null}function Mt(e,t=ee){let r=t.customPropertyValues,l=String(e);if(l.length>r.maxLength)return`custom property values are limited to ${r.maxLength} characters`;let n=r.refusedCharacters.find(u=>l.includes(u));if(n)return`${JSON.stringify(n)} is not allowed in a custom property value`;let o=jt(l);if(o)return o;let a=l.toLowerCase(),i=r.refusedFunctions.find(u=>new RegExp(`(^|[^a-z0-9_-])${u.replace(/[-]/g,"\\-")}\\s*\\(`).test(a));return i?`"${i}()" is not allowed in a custom property value`:null}function he(e,t=ee){let r=[],l=(i,u)=>(r.push({target:Ct(e,i),reason:u}),!1),n=i=>{let u=kt(e,i,t);return u?l(i,`inside <${u}>, which is not content`):!0},o=i=>n(i)?We(e,i)?l(i,"a text write here would delete the data rules tag"):!0:!1,a=(i,u,s)=>{if(!n(i))return!1;let c=$t(u,s,t);return c?l(i,c):!0};return{...e,text(i,u){if(u===void 0)return e.text(i);o(i)&&e.text(i,u)},attr(i,u,s){if(s===void 0)return e.attr(i,u);a(i,u,s)&&e.attr(i,u,s)},removeAttr(i,u){a(i,u,null)&&e.removeAttr(i,u)},styleVar(i,u,s){if((G(e.attr(i,"style"),u)??"")!==s&&n(i)){if(!Z(u))return l(i,`"${u}" is not a custom property`);if(s!==""){let c=Mt(s,t);if(c)return l(i,c)}$e(e,i,u,s)}},prop(i,u,s){if(s===void 0)return e.prop(i,u);if(t.refusedRuleForms.includes(u))return l(i,`"@${u}" writes HTML, only text is allowed`);if(Nt.has(u)){o(i)&&e.prop(i,u,s);return}a(i,u==="className"?"class":u,s)&&e.prop(i,u,s)},remove(i){if(Lt(e,i)){l(i,"removing this would delete the data rules tag");return}e.remove(i)},replaceWith(i,u){return u===e.prop(i,"outerHTML")||l(i,'"@outerHTML" writes HTML, only text is allowed'),i},refusals:r,assertClean(){if(r.length)throw new Oe(r.slice())}}}function k(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function me(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t?`${t}.${r}`:r,"")}function It(e,t,r,l,n={}){let o=[],a=[];function i(s,c,h){if(Array.isArray(s)){let[,p]=s;if(!Array.isArray(c)||!k(p))return;c.forEach((v,f)=>i(p,v,[...h,f]));return}if(!(!k(s)||!k(c)))for(let p of Object.keys(c))Object.prototype.hasOwnProperty.call(s,p)?i(s[p],c[p],[...h,p]):o.push(me([...h,p]))}function u(s,c,h,p){if(h!==void 0){if(typeof c=="string"){if(c.endsWith("[]")||c==="."||c.startsWith("@"))return;let{selector:v}=R(c);if(!v)return;e.find(s,v,n).length===0&&a.push({path:me(p),selector:v});return}if(!Array.isArray(c)&&k(c)&&k(h))for(let[v,f]of Object.entries(c))u(s,f,h[v],[...p,v])}}return i(r,l,[]),u(t,r,l,[]),{unknownKeys:o,unmatched:a}}function ye(e,t,r){if(r&&typeof r=="object")return{rules:r,tagNode:null};if(typeof r=="string"){let l=t&&t.ownerDocument?t.ownerDocument:t;return Q(e,l,r)}return null}var Wt=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Dt(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let r=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&r!=="checkbox"&&r!=="radio"&&r!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(r==="checkbox"||r==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function ge(e,t,r,l){if(l)return!!e.closest?.(t);let n=e;for(;n?.nodeType===1;){if(n.matches(t))return!0;if(n===r)break;n=n.parentElement}return!1}function we(e,t,r,l,n,o){return(o?Ot(e,t):ge(e,r,n,!1))||!!(l&&(o&&e!==n?e.matches(l):ge(e,l,n,o)))}function Pt(e,t){let r=Y[t];return r.tokens.some(l=>Ie(e,l))||r.bundles.some(l=>B(e,l))}var Bt=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function De(e,t,r,l){if(e.nodeType===1&&l(e)){r.dropped.push(t);return}r.cloneToLive.set(t,e),r.liveToClone.set(e,t);let n=e,o=t;if(e.nodeType===1){if(Bt.has(e.tagName)&&r.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);n=e.content,o=t.content,r.cloneToLive.set(o,n),r.liveToClone.set(n,o)}}else if(e.nodeType!==11)return;let a=o.firstChild;for(let i=n.firstChild;i&&a;i=i.nextSibling)De(i,a,r,l),a=a.nextSibling}function M(e,{capability:t="data",exclude:r=null,inherit:l=!0,provenance:n=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 a=o.implementation.createHTMLDocument(""),i=n||new WeakMap,u=new WeakMap,s=e.nodeType===9?e.documentElement:e;r&&a.documentElement.matches(r);let c=V(t),h=l?f=>Pt(f,t)||!!(r&&f.matches(r)):f=>we(f,t,c,r,s,!1),p=null;if(s.nodeType!==1||!we(s,t,c,r,s,l)){p=a.importNode(s,!0);let f={cloneToLive:i,liveToClone:u,dropped:[],controls:[]};De(s,p,f,h);for(let m of f.dropped)m.remove();for(let m=0;m<f.controls.length;m+=2)Dt(f.controls[m],f.controls[m+1])}e.nodeType===9&&p&&(a.replaceChild(p,a.documentElement),u.set(e,a),i.set(a,e));let v=f=>{if(Wt.test(f))throw new Error(`Filtered content queries do not support stateful selector: ${f}`)};return{root:p,document:a,capability:t,selector:V(t),cloneToLive:i,liveToClone:u,original(f){return i.get(f)||null},cloneOf(f){return u.get(f)||null},query(f,m=p){return v(f),Array.from(m.querySelectorAll(f),g=>i.get(g)||g)},text(f=p){return(f===p?p:u.get(f))?.textContent||""},html(f=p){return(f===p?p:u.get(f))?.innerHTML??""},clone(f=p){let m=f===p?p:u.get(f);return m?a.importNode(m,!0):null}}}function Pe(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Ht(e){return e?(e.nodeType===9||e.nodeType,e):null}function ve(e,t,r){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=r===null?"":r:t==="checked"&&e.tagName==="INPUT"?e.checked=r!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=r!==null))}function Be(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function He(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let r of t)if(r.tagName==="TEXTAREA")r.value=r.defaultValue;else if(r.tagName==="INPUT"){let l=r.type;l!=="file"&&l!=="checkbox"&&l!=="radio"&&(r.value=r.defaultValue),r.checked=r.defaultChecked}else r.tagName==="OPTION"&&(r.selected=r.defaultSelected)}var x={semanticExclude:!0,find(e,t,r={}){let l=Ht(e);if(!l||!l.querySelectorAll)return[];let n=Array.from(l.querySelectorAll(t));r.includeRulesTag||(n=n.filter(i=>!Pe(i)));let o=[];r.skip&&o.push(r.skip);let a=r.templateAttr===null?null:r.templateAttr||"cms-template";if(a&&o.push("["+a+"]"),o.length){let i=o.join(", ");n=n.filter(u=>!u.closest||!u.closest(i))}return n},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,Be(e,t)},attr(e,t,r){if(r===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,r),ve(e,t,r)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),ve(e,t,null)},prop(e,t,r){if(r===void 0){let l=e?e[t]:void 0;return l!==void 0?l:null}e[t]=r},clone(e){let t=e.cloneNode(!0);return He(t),t},insertAt(e,t,r){let l=e.children[r]||null;e.insertBefore(t,l)},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 l=r.content.firstElementChild;if(!l)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(l,e),l},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 N(e,t={}){if(t.exclude===null)return x;let r=[V("data"),t.exclude].filter(Boolean).join(", "),l=e.nodeType===9?e:e.ownerDocument||e,n=e.nodeType===9?e.documentElement:e;if(!t._write&&!n?.matches?.(r)&&!n?.querySelector?.(r)&&!l?.querySelector?.(r))return x;let o=e.nodeType===9||!e.isConnected?e:e.ownerDocument,a=e.nodeType===9?e:e.ownerDocument,i=null,u=()=>i||(i=M(o,{capability:"data",exclude:t.exclude||null})),s=f=>{let m=u();return f===e?m.cloneOf(e):m.cloneOf(f)||f},c=f=>i?.original(f)||f,h=(f,m)=>{u().liveToClone.set(f,m),u().cloneToLive.set(m,f);let g=f.childNodes||[],d=m.childNodes||[];for(let y=0;y<Math.min(g.length,d.length);y++)h(g[y],d[y])},p=(f,m,g,d)=>{let y=Array.from(f.childNodes).filter(T=>i.cloneOf(T)),w=y[0];for(;w&&y.includes(w);)w=w.nextSibling;for(let T of y)T.remove();if(g==="innerHTML"){let T=a.createElement("template");T.innerHTML=d;for(let E of Array.from(T.content.childNodes))f.insertBefore(E,w||null)}else f.insertBefore(a.createTextNode(d),w||null),Be(f,d);let A=M(f,{capability:"data",exclude:t.exclude||null});m.replaceChildren(...Array.from(A.root?.childNodes||[]));let b=T=>{let E=A.original(T);E&&(i.liveToClone.set(E,T),i.cloneToLive.set(T,E));for(let Ue of Array.from(T.childNodes||[]))b(Ue)};for(let T of Array.from(m.childNodes))b(T)},v={...x,find(f,m,g={}){let d=s(f);if(!d?.querySelectorAll)return[];let y=u().query(m,d);g.includeRulesTag||(y=y.filter(b=>!Pe(b)));let w=[];g.skip&&w.push(g.skip);let A=g.templateAttr===null?null:g.templateAttr||"cms-template";if(A&&w.push(`[${A}]`),w.length){let b=w.join(", ");y=y.filter(T=>!T.closest?.(b))}return y},parent(f){let m=s(f)?.parentElement;return m?c(m):null},children(f){return Array.from(s(f)?.children||[],c)},text(f,m){if(m===void 0){let y=c(f);return!y?.matches?.(r)&&!y?.querySelector?.(r)?x.text(y):(s(f)?.textContent||"").trim()}let g=c(f);if(!g?.matches?.(r)&&!g?.querySelector?.(r)&&!i){x.text(g,m);return}let d=u().cloneOf(g);d?p(g,d,"textContent",m):x.text(g,m)},attr(f,m,g){let d=c(f);if(g===void 0)return x.attr(d,m);x.attr(d,m,g);let y=i?.cloneOf(d);y&&(x.attr(y,m,g),M(d,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),i.liveToClone.delete(d),i.cloneToLive.delete(y)))},removeAttr(f,m){let g=c(f);x.removeAttr(g,m);let d=i?.cloneOf(g);d&&x.removeAttr(d,m)},prop(f,m,g){let d=c(f);if(g===void 0)return m==="innerHTML"||m==="outerHTML"||m==="textContent"||m==="innerText"?x.prop(s(d),m):x.prop(d,m);let y=m==="innerHTML"||m==="textContent"||m==="innerText",w=y?u().cloneOf(d):i?.cloneOf(d);w&&y?p(d,w,m,g):(x.prop(d,m,g),w&&x.prop(w,m,g))},clone(f){let m=s(f);if(m===f)return x.clone(f);let g=a.importNode(m,!0);return He(g),g},insertAt(f,m,g){let d=c(f),y=v.children(d)[g]||(()=>{for(let b=d.children.length-1;b>=0;b--){let T=d.children[b];if(u().cloneOf(T))return T.nextElementSibling}return d.firstElementChild})(),w=c(m);d.insertBefore(w,y||null);let A=u().cloneOf(d);if(A){let b=u().cloneOf(w);b||(b=a.importNode(w,!0),h(w,b));let T=Array.from(A.children);A.insertBefore(b,T[g]||null)}},insertBefore(f,m){let g=c(f),d=c(m);g.parentNode.insertBefore(d,g);let y=u().cloneOf(g.parentNode);if(y){let w=u().cloneOf(d);w||(w=a.importNode(d,!0),h(d,w));let A=u().cloneOf(g);A?A.before(w):y.appendChild(w)}},insertAfter(f,m){let g=c(f),d=c(m);g.parentNode.insertBefore(d,g.nextSibling);let y=u().cloneOf(g.parentNode);if(y){let w=u().cloneOf(d);w||(w=a.importNode(d,!0),h(d,w));let A=u().cloneOf(g);A?A.after(w):y.appendChild(w)}},identity(f){return c(f)||null},remove(f){let m=c(f),g=u().cloneOf(m);x.remove(m),g&&x.remove(g)},replaceWith(f,m){let g=c(f),d=u().cloneOf(g),y=x.replaceWith(g,m);if(d){let w=M(y,{capability:"data",exclude:t.exclude||null});if(!w.root)d.remove();else{d.replaceWith(w.root);let A=b=>{let T=w.original(b);T&&(i.liveToClone.set(T,b),i.cloneToLive.set(b,T));for(let E of Array.from(b.childNodes||[]))A(E)};A(w.root)}}return y}};return v}var I=x,re={extract:(e,t,r={})=>W(N(e,r),e,t,r),apply:(e,t,r,l={})=>D(N(e,{...l,_write:!0}),e,t,r,l),findRulesIn:(e,t)=>Q(I,e,t),findRules:(e,t)=>ye(I,e,t),bind:(e,t,r={})=>{let l=ye(I,e,t);if(!l){let n=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${n}`)}return{...l,get:()=>W(N(e,r),e,l.rules,r),set:n=>D(N(e,{...r,_write:!0}),e,l.rules,n,r)}},parseStrict:At,parseRelaxed:Me,ruleAttrIndex:j,splitRule:R,errors:O,DOM_PROPERTIES:Ae},F=e=>!!e&&typeof e.nodeType=="number";function qe(e){let t=e&&e.ownerDocument?e.ownerDocument:e,r=Q(I,t,"api");if(!r)throw new O.NoRulesTag("api");return r.rules}function qt(e){if(e.nodeType===9)return e;let t=e.ownerDocument?.documentElement;if(t?.contains(e))return t;let r=e;for(;r.parentNode;)r=r.parentNode;return r}function Ut(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let t=e.ownerDocument.createDocumentFragment();for(let r of e.childNodes)t.appendChild(r.cloneNode(!0));return t}function zt(e,t){let r=[];for(;t!==e;){let l=t.parentNode;r.push(Array.prototype.indexOf.call(l.childNodes,t)),t=l}return r.reverse()}function _t(e,t){return t.reduce((r,l)=>r.childNodes[l],e)}function S(e,t){let r=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&r.unshift(e),r}function Vt(e,t){let r=S(e,"option"),l=S(t,"option");r.forEach((u,s)=>l[s].selected=u.selected);let n=S(e,"input"),o=S(t,"input");n.forEach((u,s)=>{let c=u.type.toLowerCase();c!=="file"&&(o[s].value=u.value),(c==="checkbox"||c==="radio")&&(o[s].checked=u.checked)});let a=S(e,"textarea"),i=S(t,"textarea");a.forEach((u,s)=>i[s].value=u.value)}function J(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let r=e.startsWith("@")?0:j(e);if(r===-1)return;let l=e.slice(r+1);if(Te.has(l))throw new O.RuleTargetReadOnly(l);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(r=>J(e[1],r));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[r,l]of Object.entries(e))J(l,t[r])}}function Ft(e,t,r){let l={templateAttr:"cms-template"},n=qt(e),o=zt(n,e),a=Ut(n);Vt(n,a);let i=_t(a,o),u=N(a,{...l,_write:!0}),s=It(u,i,t,r,l);if(s.unknownKeys.length||s.unmatched.length)throw new O.WriteRejected(s.unknownKeys,s.unmatched);let c=he(u);D(c,i,t,r,l),c.assertClean(),J(t,r);let h=he(N(n,{...l,_write:!0}));D(h,e,t,r,l),h.assertClean()}function Jt(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 O.WriteRefused?e.details=e.refusals:e instanceof O.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof O.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 Kt(e,t){let r=F(e)?e:document,l=F(e)?t:e;return l===void 0?W(N(r),r,qe(r)):re.bind(r,l).get()}function Xt(e,t,r){try{if(!F(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let l=r===void 0?qe(e):re.bind(e,r).rules;Ft(e,l,t)}catch(l){throw Jt(l)}return e}var Zt={engine:re,extractData:Kt,applyData:Xt},Gt=Zt;export{re as a,Kt as b,Xt as c,Gt as d};
|
package/dist/m/c-2YIJ6ZA6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as Kt}from"./c-4ASQPRQL.js";import{a as kt}from"./c-GQ6F6IDK.js";import{c as F}from"./c-I2SCCUEW.js";import{b as We}from"./c-5VYOWDTI.js";import{a as Qt,d as $,e as Ge,f as R,h as N}from"./c-LO4C4J77.js";import{a as Ke,b as $t,c as Yt,d as jt}from"./c-FV46ZKGX.js";import{a as Vt}from"./c-UGHH4MB3.js";import{a as Dt}from"./c-LA2BW7UY.js";import{a as bt,f as Nt,g as P,h as Ft,i as Ut,j as qt,m as Bt,u as Ht,w as Gt,x as Wt}from"./c-HSNGLIFB.js";import{b as Rt,h as He}from"./c-PGSBXHUE.js";import{a as qe,c as Ot,g as It,h as Be}from"./c-RXTPKCMC.js";import{a as be,f as Re,h as Q}from"./c-IJUK2GPW.js";import{b as K,e as xt,f as A}from"./c-DLBX4JCJ.js";import{i as Ct,k as Mt}from"./c-N7JPUPGC.js";import{E as Ue,h as Ne,r as Fe,u as Lt,y as V,z as me}from"./c-PWJSJEJU.js";import{d as _t}from"./c-VG5XIN4T.js";import{a as pe}from"./c-2YYDMLNZ.js";import{d as Et,e as wt,g as At,h as Tt}from"./c-HA6INT6J.js";import{k as Pt}from"./c-ICMAOOGK.js";var wn="clay:debug:autosave";function ve(){try{return localStorage.getItem(wn)==="true"}catch{return!1}}function ge(){return import("./c-CFHW5AMY.js").catch(e=>(console.warn("[autosave-debug] Failed to load the debug logger:",e),null))}function he(e,t){ve()&&ge().then(n=>n?.logSaveCheck(e,t))}function re(e,t=""){ve()&&ge().then(n=>n?.logBaseline(e,t))}function zt(e,t){ve()&&ge().then(n=>n?.logUnloadDiffSync(e,t))}function Xt(){ve()&&ge().then(e=>e?.preloadIfEnabled())}var U=Number.NEGATIVE_INFINITY;function An({firstDirtyAt:e=U,lastActivityAt:t=U,finishedAt:n=U,costMs:o=0}={}){let r=e??U,i=t??U,a=n??U,f=Math.min(3e4,Math.max(1200,4*o)),u=Math.max(i,a)+1500,m=Math.max(r+1e4,a+f);return Math.max(a+1200,Math.min(u,m))}function Jt({now:e=()=>Date.now(),setTimer:t=(r,i)=>setTimeout(r,i),clearTimer:n=r=>clearTimeout(r),run:o=()=>{}}={}){let r=null,i=null,a=U,f=0,u=null,m=null,c=!1,p=!1;function S(){return An({firstDirtyAt:r,lastActivityAt:i,finishedAt:a,costMs:f})}function y(){if(!c||p)return;let E=S();if(u!==null){if(m===E)return;n(u)}m=E,u=t(d,Math.max(0,E-e()))}function d(){if(u=null,m=null,!(!c||p)){if(e()<S()){y();return}g()}}function g(){c=!1,p=!0,r=null,i=null;let E;try{E=o()}catch{l();return}Promise.resolve(E).then(l,l)}function l(){p=!1,a=e(),c&&y()}function s({at:E=e()}={}){r===null&&(r=E),i=E,c=!0,y()}function v(){c=!0,y()}function M(E){E>0&&(f=Math.max(E,f*.8))}return{noteActivity:s,request:v,noteCost:M,dueAt:S,costEstimate:()=>f,pending:()=>c||p,running:()=>p}}Fe(e=>{for(let t of Tt)e.removeAttribute(t)});Fe(e=>{for(let t of[...Et,...wt,...At])e.removeAttribute(t)});var x=null;function w(e,t="",n="",o=null){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus",e);let r=new CustomEvent(`clay:save-${e}`,{detail:{msg:t,msgType:n,timestamp:Date.now(),...o||{}}});document.dispatchEvent(r),Cn(e,r.detail)}var sn=Symbol.for("clay.saveFailureClaimed"),qr=e=>{e?.detail&&(e.detail[sn]=!0)},Ee=null,an=()=>(Ee??=import("./c-BOMQIQ3V.js").catch(e=>{throw Ee=null,e}),Ee),Tn=()=>{an().then(e=>e.warm(),()=>{})};for(let e of["beforeinput","keydown","pointerdown"])document.addEventListener(e,Tn,{once:!0,capture:!0});function Cn(e,t){if(e==="saved"){Ee?.then(n=>n.clearFailures(),()=>{});return}e!=="error"&&e!=="offline"||t?.[sn]||an().then(n=>n.reportFailure(e),n=>{console.error("clayjs: a save failed and the notice for it could not be downloaded",n)})}function ot(){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus","offline")}function Mn(){x=setTimeout(()=>{w("saving")},500)}window.addEventListener("offline",()=>{ot()});window.addEventListener("online",()=>{document.documentElement.getAttribute("savestatus")==="offline"&&I().then(e=>{e.msgType==="skipped"&&document.documentElement.getAttribute("savestatus")==="offline"&&document.documentElement.setAttribute("savestatus","saved")})});var q=!1,k="",C="",ie=0,we=new Set,D=!1,L=!1,Ae=!1,B=0,je=!1;function xn(){B++}function un(){B!==0&&(B--,!(B>0)&&(fe&&(fe=!1,Z=setTimeout(mt,0)),je&&(je=!1,Oe())))}function Pn(){return B>0}var Y=0,ne=!1,ae=!1,Te=!1;function de(e=null){return Y===0||cn(e)}function st(){return ne}function _n(){if(ne)return!0;try{let e=V({flushUndo:!1});return St(e)?!1:e!==C}catch{return!0}}function Dn(){let e="idle",t=0;return{get phase(){return e},get open(){return e==="open"},changedWhileClosed(){return e==="quiesced"&&Ge()!==t},start(){e==="idle"&&(e="open")},quiesce(){e==="open"&&(e="quiesced",t=Ge(),Y++)},resume(){e==="quiesced"&&(e="open",Y--,!(Y>0)&&(jn(),rn()))},stop(){if(e==="stopped")return;let n=e==="quiesced";(n||e==="open")&&_n()&&(Te=!0),e="stopped",n&&(Y--,Y===0&&rn())}}}var Zt=!1,oe=null,ze=null,Xe=!1;function Br(e=b){if(!oe||oe.generation!==e)return null;let{bytes:t,etag:n}=oe;return{bytes:t,etag:n}}function Hr({represented:e}={}){let t=R(),{forComparison:n,forDirty:o}=me(),r=typeof e?.etag=="string"&&e.etag?e.etag:null;return!(Xe&&r!==null&&r!==ze)&&Te&&(n!==k||o!==C)?{ok:!1,code:"pending-input"}:(Te=!1,ue(n,o),W=n,ee=!1,vt=!0,ze=r,Xe=!0,N(t),document.documentElement.setAttribute("savestatus","saved"),document.dispatchEvent(new CustomEvent("clay:baseline-settled")),{ok:!0})}var it=Promise.resolve(!1),Ce=!1,Ln=()=>(Ce=!0,It().catch(()=>!1).then(e=>(Ce=!1,e)));function Gr(){return{id:"clay:save",order:10,prepare(e={}){let t=Dn();return e.initial===!0&&t.start(),{enable(){it=Ln();let n=e.represented?.etag;typeof n=="string"&&n&&Ot(n),e.initial!==!0&&(kn(),t.start())},quiesce:()=>t.quiesce(),resume:()=>t.resume(),dispose:()=>t.stop()}}}}function kn(){Zt||(Zt=!0,Qt(),be(),yn(),En())}var O=0,Je=!1,Me=!1,at="Waiting for the AI edit to be kept or reverted",j=new Map;function Wr(e=at){O++,j.set(e,(j.get(e)||0)+1)}function Kr({replay:e=!0,reason:t=at}={}){let n=j.get(t)||0;if(n===0||(n===1?j.delete(t):j.set(t,n-1),O--,O>0))return;let o=Je,r=Me;Je=!1,Me=!1,e&&(o?I():r&&Oe())}function Qr(){return O>0}function ut(){return O===0?null:j.keys().next().value||at}function ln(e,t){if(O===0)return!1;Je=!0,Q();let n=h(ut());return e(n),t(n),n}var H=!1,se=null;function On(e){se=e??null,!H&&(H=!0,xn())}function In(){H&&(H=!1,se=null,un())}function Ze(){return H}function Vr(e){if(!H||se&&e!==se)return;H=!1,se=null,!We()&&$()||(document.documentElement.getAttribute("savestatus")==="conflict"&&document.documentElement.setAttribute("savestatus","saved"),document.dispatchEvent(new CustomEvent("clay:save-conflict-resolved",{detail:{timestamp:Date.now()}}))),document.dispatchEvent(new CustomEvent("clay:save-conflict-released",{detail:{etag:e??null}})),un()}function h(e){return{ok:!1,msg:e,msgType:"skipped",code:null,etag:null}}function lt(e){return($()||F())&&(ne=!0),h(e)}function fn(){return{ok:!1,msg:"You are not allowed to save this document.",msgType:"forbidden",code:"forbidden",status:403,sent:!1,etag:null}}function ft(){return xt()===!1}var ct=new Set,b=0;function $r(){return b}function Yr(e){typeof e=="number"&&(b=e)}function bn(e=b){let t=Object.freeze({generation:e});return ct.add(t),t}function Rn(e){ct.delete(e)}function cn(e){return!!e&&ct.has(e)&&e.generation===b}function z(e,t){e!=null&&jt({captureId:e,ok:t.ok===!0,etag:t.etag??null})}function Nn(e,t,n,o,r,i=null,a=null,f=!1){if(z(a,e),e.ok)ne=!1,ue(t,n),xe=i,oe={bytes:i,etag:qe(),generation:b},ze=oe.etag,Xe=!0,Te=!1,q=!1,N(r),w("saved",e.msg||"Saved",e.msgType,{etag:e.etag??null,captureId:a}),re(o,`${k.length} chars`),In();else if(e.msgType==="conflict"){if(f){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus","saved");return}On(e.conflictEtag),w("conflict",e.msg,e.msgType,{hadTimeout:e.hadTimeout===!0,changedBy:e.changedBy??null,afterTimeout:e.afterTimeout===!0,etag:e.conflictEtag??null,code:e.code??null,reason:e.reason??null,retryAfter:e.retryAfter??null,captureId:a})}else if(e.msgType!=="skipped"){let u={status:e.status??null,hadTimeout:e.hadTimeout===!0,code:e.code??null,reason:e.reason??null,retryAfter:e.retryAfter??null,captureId:a};navigator.onLine?w("error",e.msg,"",u):w("offline",e.msg,"",u)}}function dn(){if(!(!D&&!L)&&!Bt()){if(D){D=!1,L=!1,I();return}L=!1,nt.request()}}function jr(){return q}function zr(e){q=e}function Xr(){return k}function dt(){return C}var xe=null;function Jr(){return xe}function ue(e,t){k=e,C=t,ie++}function Zr(e){ue(e,e)}var G=()=>typeof performance<"u"&&performance.now?performance.now():Date.now();var Fn=4,en="Save cancelled: the page changed while it prepared",X=null,le=null,Qe=null,pn=!1;function mn(){return Qe||(Qe=import("./c-OG6GFSUX.js").then(e=>(le=e,e),e=>(pn=!0,console.info("clayjs: sliced save off ("+(e&&e.message?e.message:e)+"); saves prepare in one task"),null))),Qe}function Un(){try{return performance.getEntriesByType("navigation")[0]?.decodedBodySize||0}catch{return 0}}var qn=()=>typeof xe=="string"?xe.length:Un();function Pe(){return pn||document.hidden||qt()?!1:qn()>=307200}function tn(e,t,n){return n?"morph":b!==t.generation||!A?"mode":de(e.permit)?ft()?"refused":ie!==t.baselines?"newer save":Math.max(He(),e.blockeditorFormatFloor)>t.floor?"floor":null:"session"}function Bn(e=150,t=2e3){return new Promise(n=>{let o=G(),r=null,i=()=>{document.removeEventListener("clay:sync-applied",a),n()},a=()=>{clearTimeout(r),r=setTimeout(i,Math.max(0,Math.min(e,t-(G()-o))))};document.addEventListener("clay:sync-applied",a),a()})}async function pt({explicit:e,forced:t=!1,forSave:n,forComparison:o,forDirty:r,captureId:i,gateToken:a,costMs:f,blockeditorFormatFloor:u=0,quietConflict:m=!1,laneHeld:c=!1,lane:p=null,capture:S,noteRecovery:y,release:d,callback:g}){if(y(),e&&!t){if(q=r!==C,he("savePage dirty check",!q),!q){Q(),N(a),d();let s=h("No changes to save");return z(i,s),typeof g=="function"&&g(s),{result:s,dispatched:!1}}}else if(!e){let s=!ee||o!==W,v=o!==k;if(he("throttled vs baseline",!s),he("throttled vs lastSave",!v),!(s&&v)){let M=!1;try{M=!v&&(!document.querySelector(Pt)||$()&&r===C)}catch(yt){console.error("savePageThrottled: dirty domain check failed",yt)}M&&N(a),nt.noteCost(f),d();let E=h("No changes to save");return z(i,E),typeof g=="function"&&g(E),{result:E,dispatched:!1}}if(q=!0,!c&&P()){D=!0,d();let M=h("Save already in progress");return z(i,M),typeof g=="function"&&g(M),{result:M,dispatched:!1}}}Mn();let l={forComparison:o,forDirty:r};return we.add(l),Ae=!0,new Promise(s=>{Ht(n,i,v=>{Ae=!1,we.delete(l);let M=G();Nn(v,l.forComparison,l.forDirty,t?"updated after force save":"updated after save",a,n,i,m),e||nt.noteCost(f+(G()-M)),typeof g=="function"&&g(v),s({result:v,dispatched:!0}),c||dn()},{capture:S,blockeditorFormatFloor:u,lane:p})})}async function Hn(e,t){let n={over:!1},o=()=>{n.over=!0};document.addEventListener("clay:sync-applied",o);try{for(let i=0;i<2;i++){let a=R(),f={generation:b,baselines:ie,floor:Math.max(He(),e.blockeditorFormatFloor)},u=le.beginSaveCapture({requestRefresh:!0,forRequest:!0,pageFormatMarker:f.floor?{name:Rt,content:String(f.floor)}:null});$t(u.captureId);let m=null,c={get aborted(){let d=tn(e,f,n.over);return d&&(m=d),!!d}},p;try{p=await le.runPreparedSteps(u.steps(),{budgetMs:Fn,signal:c})}catch(d){console.error(`${e.explicit?"savePage":"savePageThrottled"}: preparing the save failed`,d),u.drop();let g={msg:d&&d.message?d.message:"Save failed",msgType:"error",code:d?.code??null,etag:null};return w("error",g.msg,"",{sent:!1,code:g.code}),z(u.captureId,g),typeof e.callback=="function"&&e.callback(g),{result:g,dispatched:!1}}let S=p.aborted?m:tn(e,f,n.over);if(!S){let d=p.result;return await pt({explicit:e.explicit,forced:e.forced,forSave:d.forSave,forComparison:d.forComparison,forDirty:d.forDirty,captureId:d.captureId,gateToken:a,costMs:p.activeMs,blockeditorFormatFloor:e.blockeditorFormatFloor,quietConflict:e.quietConflict,laneHeld:!0,lane:t,capture:d,noteRecovery:()=>Yt(d.captureId,d.forSave),release:()=>u.drop(),callback:e.callback})}u.drop();let y=h(en);if(S==="session"&&(ae=!0),z(u.captureId,y),!(S==="floor"&&i===0)){if(S==="morph"&&e.explicit&&i===0){await Bn(),n.over=!1;continue}return typeof e.callback=="function"&&e.callback(y),{result:y,dispatched:!1}}}let r=h(en);return typeof e.callback=="function"&&e.callback(r),{result:r,dispatched:!1}}finally{document.removeEventListener("clay:sync-applied",o),Ut(t)}}function vn(e){let t=Ft();if(!t)return!1;let n=Hn(e,t).catch(o=>{console.error("save: preparing the save failed",o);let r={msg:o&&o.message?o.message:"Save failed",msgType:"error",code:o?.code??null,etag:null};return w("error",r.msg,"",{sent:!1,code:r.code}),typeof e.callback=="function"&&e.callback(r),{result:r,dispatched:!1}});return X=n,n.then(o=>{X===n&&(X=null),e.resolve(o.result),e.settleSoonQueued(o.result),(o.dispatched||D||L||Le.length)&&dn()}),!0}function ke(e,t=()=>{}){return Ce?it.then(()=>ke(e,t)):te?ce.then(()=>De(e,t)):De(e,t)}function _e(e,t){let n=!1,o=setTimeout(()=>{n=!0,w("saving")},500);return e.then(()=>(clearTimeout(o),t())).then(r=>(n&&!P()&&!$()&&document.documentElement.getAttribute("savestatus")==="saving"&&(document.documentElement.setAttribute("savestatus","saved"),document.dispatchEvent(new CustomEvent("clay:save-status",{detail:{state:"saved"}}))),r))}function De({kind:e,permit:t=null},n=()=>{}){let o=e==="explicit";return new Promise(r=>{if(!A&&!window.clay?.testMode){o&&Q();let s=h("Not in edit mode");return T().forEach(v=>v(s)),n(s),r(s)}if(!de(t)){ae=!0;let s=lt("Save session is quiesced");return o&&T().forEach(v=>v(s)),n(s),r(s)}if(ft()){o&&Q();let s=fn();return w("error",s.msg,"",{code:s.code,status:s.status,sent:!1}),T().forEach(v=>v(s)),n(s),r(s)}if(o){let s=ln(n,r);if(s){T().forEach(v=>v(s));return}if(P()){D=!0;let v=h("Save already in progress");return n(v),r(v)}}else{if(O>0){Me=!0;let s=h(ut());return n(s),r(s)}if(P()&&!ee&&Ae){L=!0;let s=h("Save already in progress");return n(s),r(s)}if(X){L=!0;let s=h("Save already in progress");return n(s),r(s)}if(!ee&&!$()){let s=h("No changes to save");return n(s),r(s)}}let i=window.clay?.source?.ensureForSave?.();if(i)return r(_e(i,()=>De({kind:e,permit:t},n)));if(Pe()&&!le){r(_e(mn(),()=>De({kind:e,permit:t},n)));return}let a=o?T():[],f=s=>a.forEach(v=>v(s));if(!navigator.onLine&&ot(),Pe()&&vn({explicit:o,forced:!1,permit:t,blockeditorFormatFloor:0,quietConflict:!1,settleSoonQueued:f,callback:n,resolve:r}))return;let m=G(),c,p,S,y,d,g=R();try{c=Ue({requestRefresh:!0,forRequest:!0}),{forSave:p,forComparison:S,forDirty:y,captureId:d}=c}catch(s){console.error(`${o?"savePage":"savePageThrottled"}: captureForSaveAndComparison failed`,s),o?(Q(),w("error",s.message,"",{sent:!1,code:s.code??null})):w("error",s.message);let v={msg:s.message,msgType:"error",code:o?s.code??null:null,etag:null};typeof n=="function"&&n(v),r(v),f(v);return}let l=G()-m;pt({explicit:o,forSave:p,forComparison:S,forDirty:y,captureId:d,gateToken:g,costMs:l,capture:c,noteRecovery:()=>Ke({captureId:d,html:p}),release:()=>Ne(c),callback:n}).then(s=>{r(s.result),f(s.result)})})}function I(e=()=>{}){return ke({kind:"explicit"},e)}function Gn(e,t=()=>{}){return ke({kind:"explicit",permit:e},t)}function J(e=()=>{},{quietConflict:t=!1,blockeditorFormatFloor:n=0,permit:o=null}={}){return Ce?it.then(()=>J(e,{quietConflict:t,blockeditorFormatFloor:n,permit:o})):new Promise(r=>{if(!A&&!window.clay?.testMode){let l=h("Not in edit mode");return T().forEach(s=>s(l)),e(l),r(l)}if(!de(o)||o&&!cn(o)){let l=lt("Save session is quiesced");return T().forEach(s=>s(l)),e(l),r(l)}if(ft()){let l=fn();return w("error",l.msg,"",{code:l.code,status:l.status,sent:!1}),T().forEach(s=>s(l)),e(l),r(l)}let i=ln(e,r);if(i){T().forEach(l=>l(i));return}if(P()){D=!0;let l=h("Save already in progress");return T().forEach(s=>s(l)),e(l),r(l)}let a=window.clay?.source?.ensureForSave?.();if(a)return r(_e(a,()=>J(e,{quietConflict:t,blockeditorFormatFloor:n,permit:o})));if(!navigator.onLine&&ot(),Pe()&&!le){r(_e(mn(),()=>J(e,{quietConflict:t,blockeditorFormatFloor:n,permit:o})));return}let u=T(),m=l=>u.forEach(s=>s(l));if(Pe()&&vn({explicit:!0,forced:!0,permit:o,blockeditorFormatFloor:n,quietConflict:t,settleSoonQueued:m,callback:e,resolve:r}))return;let c,p,S,y,d,g=R();try{c=Ue({requestRefresh:!0,forRequest:!0}),{forSave:p,forComparison:S,forDirty:y,captureId:d}=c}catch(l){console.error("savePageForce: captureForSaveAndComparison failed",l),w("error",l.message,"",{sent:!1,code:l.code??null});let s={msg:l.message,msgType:"error",code:l.code??null,etag:null};typeof e=="function"&&e(s),r(s),m(s);return}pt({explicit:!0,forced:!0,forSave:p,forComparison:S,forDirty:y,captureId:d,gateToken:g,costMs:0,blockeditorFormatFloor:n,quietConflict:t,capture:c,noteRecovery:()=>Ke({captureId:d,html:p}),release:()=>Ne(c),callback:e}).then(l=>{r(l.result),m(l.result)})})}Wt(e=>J(()=>{},{permit:e}));function Wn(e){let t=["clay:save-saved","clay:save-error","clay:save-offline","clay:save-conflict"];return new Promise((n,o)=>{let r=null,i=()=>{clearTimeout(r);for(let u of t)document.removeEventListener(u,a)},a=()=>{i(),n()},f=e-Date.now();if(f<=0){o(Object.assign(new Error("Save timed out."),{state:"failed"}));return}r=setTimeout(()=>{i(),o(Object.assign(new Error("Save timed out."),{state:"failed"}))},f);for(let u of t)document.addEventListener(u,a)})}function _(e,t){return Object.assign(new Error(e),{state:t})}function Kn(e,t){return new Promise((n,o)=>{let r=t-Date.now();if(r<=0)return o(_("Save timed out.","failed"));let i=setTimeout(()=>{document.removeEventListener(e,a),o(_("Save timed out.","failed"))},r),a=()=>{clearTimeout(i),n()};document.addEventListener(e,a,{once:!0})})}async function eo({keepalive:e=!1,timeoutMs:t=15e3,permit:n=null}={}){if(!A)return{state:"view",etag:null};let o=Date.now()+t,r=n||bn(),i={over:!1},a=null,f=new Promise((u,m)=>{a=setTimeout(()=>m(Object.assign(_("Save timed out.","failed"),{timedOut:!0})),Math.max(0,t))});try{return await Promise.race([Qn(e,o,r,i),f])}catch(u){throw u&&typeof u.state=="string"?u:_(u?.message||"Save failed","failed")}finally{i.over=!0,clearTimeout(a),n||Rn(r)}}async function Qn(e,t,n,o={over:!1}){if(gn()||await Kn("clay:baseline-settled",t),o.over)return null;let r=!1,i=null;for(let a=0;a<4;a++){if(X&&(await X,o.over)||P()&&(await Wn(t),o.over))return null;if(Ze())throw _("This document has a conflict to resolve.","conflict");let f=R();if(!rt()){if(N(f),F())throw _("This document has unsaved work a save cannot write.","blocked");return ne=!1,{state:r?"saved":"clean",etag:i??qe()}}if(o.over)return null;let u=await Nt(e,()=>Gn(n));if(u.msgType!=="skipped"){if(!u.ok)throw _(u.msg||"Save failed",u.msgType==="conflict"||Ze()?"conflict":"failed");r=!0,i=u.etag??null}}throw _("The document kept changing while saving.","failed")}async function to(e=()=>{}){return await Be({fresh:!0}),J(e)}function no(e){!A||K||Gt(e,t=>{t.ok?window.location.reload():t.msgType==="skipped"?w("error",t.msg||"Template not saved"):w("error",t.msg||"Failed to save template")})}var Vn=kt(e=>ke({kind:"automatic"},e),1200),$n=250,Yn=1e3,Z=null,nn=0,et=[],Le=[],fe=!1,T=()=>{let e=Le;return Le=[],e};function mt(){if(Z=null,B>0||!de()){fe=!0;return}let e=et;if(et=[],P()){Le.push(...e),I();return}I().then(t=>e.forEach(n=>n(t)))}function ro(){let e=Date.now();return Z===null?nn=e:clearTimeout(Z),new Promise(t=>{et.push(t),Z=setTimeout(mt,Math.max(0,Math.min($n,nn+Yn-e)))})}function jn(){ae&&(ae=!1,Oe())}function rn(){fe&&(fe=!1,Z=setTimeout(mt,0))}var W="",ee=!0,vt=!1;function gn(){return vt}var Ve=!1,zn=250,Xn=1250,$e=null,hn="clay:paint-heal:"+location.pathname;function Sn(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)|0;return String(t>>>0)}function Jn(e){try{return localStorage.getItem(hn)===Sn(e)}catch{return!1}}function Zn(e){try{localStorage.setItem(hn,Sn(e))}catch{}}function er(){return _t(Lt({flushUndo:!1}))}function oo(e){!A||K||(clearTimeout($e),$e=setTimeout(async()=>{$e=null,te&&await ce;let t=typeof e=="function"?e():e;t==null||!We()||!gn()||Ze()||Pn()||V({flushUndo:!1})===C&&t!==er()&&(Jn(t)||(Zn(t),J(()=>{},{quietConflict:!0})))},zn+Math.random()*Xn))}var Se=null,Ye=null,te=0,ce=Promise.resolve(),gt=!1,ht=[];function tr(){return Ye??=import("./c-KNPDOMDY.js").catch(e=>(Ye=null,console.error("style-comparisons failed to load",e),null)),Ye}async function nr(e){try{if(Se||(Se=(await tr())?.styleComparisonStripper??null),!Se)return;let t=Se(e);k=t(k),C=t(C),W=t(W);for(let n of we)n.forComparison=t(n.forComparison),n.forDirty=t(n.forDirty)}catch(t){console.error("style adoption failed",t)}finally{te--,ht.shift()}}var ye=e=>e.replace(/&/g,"&").replace(/"/g,""");function rr(e){if(e.name!==void 0){let n=[`data-name="${ye(e.name)}"`];return e.legacyId!==void 0&&n.push(`id="${ye(e.legacyId)}"`),n}let t=[ye(e.href)];try{let{pathname:n}=new URL(e.href);n&&t.push(ye(n))}catch{}return t}function or(e){let t=[k,C,W];for(let n of we)t.push(n.forComparison,n.forDirty);return t.some(n=>n&&e.some(o=>o&&n.includes(o)))}function sr(e,t){let n=[];for(let{markers:i,tag:a}of t)for(let f of i)for(let u=e.indexOf(f);u>=0;u=e.indexOf(f,u+f.length)){let m=e.lastIndexOf("<",u);if(m<0||e.slice(m+1,m+1+a.length).toLowerCase()!==a)continue;let c=a==="style"?e.indexOf("</style",u):u;if(c<0)continue;let p=e.indexOf(">",c);p>=0&&n.push([m,p+1])}n.sort((i,a)=>i[0]-a[0]);let o="",r=0;for(let[i,a]of n)i<r||(o+=e.slice(r,i),r=a);return o+e.slice(r)}Vt(e=>{let t=rr(e);or(t)&&(te||(gt=!1),te++,ht.push({markers:t,tag:e.name!==void 0?"style":"link"}),ce=ce.then(()=>nr(e)))});function so(){return ce}function St(e){return!te||gt||F()||P()||D||L||ne||typeof e!="string"?!1:e===sr(C,ht)}var ir=500,ar=3e3,ur=1e4,tt=null;function lr(){pe.holdSettle=!1,tt&&tt()}function on(){if(!A)return;let e=!1,t=null,{forComparison:n,forDirty:o}=me();ue(n,o);let r=ie;W=n,re("immediate capture",`${n.length} chars`);let i=["keydown","pointerdown","drop","input","change","paste"],a=new Set(["Shift","Control","Alt","Meta"]),f=c=>{c.type==="keydown"&&a.has(c.key)||(gt=!0,e||(Ve=!0))};i.forEach(c=>document.addEventListener(c,f,!0));let u=()=>{if(!e){if(e=!0,t&&t(),!Ve&&ie===r){let c=R(),{forComparison:p,forDirty:S}=me();ue(p,S),W=p,N(c),re("settled capture",`${p.length} chars`)}else re("settled skipped",Ve?"user edited":"save occurred during settle");ee=!1,document.documentElement.setAttribute("savestatus","saved"),vt=!0,document.dispatchEvent(new CustomEvent("clay:baseline-settled"))}};tt=u;let m=()=>{pe.holdSettle||u()};t=Dt.onAnyChange({debounce:ir,omitChangeDetails:!0,require:"autosave"},m),setTimeout(()=>{e||m()},ar),setTimeout(()=>{!e&&pe.holdSettle&&lr()},ur)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",on):on();function Oe(e=()=>{}){if(!A){let t=h("Not in edit mode");return e(t),Promise.resolve(t)}if(O>0){Me=!0;let t=h(ut());return e(t),Promise.resolve(t)}if(!de()){ae=!0;let t=lt("Save session is quiesced");return e(t),Promise.resolve(t)}if(B>0){je=!0;let t=h("Autosave suspended");return e(t),Promise.resolve(t)}if(!ee&&Ae){L=!0;let t=h("Save already in progress");return e(t),Promise.resolve(t)}return Vn(e).catch(t=>{let n={ok:!1,msg:t?.message||"Save failed",msgType:"error",code:null,etag:null};return w("error",n.msg),n})}var nt=Jt({now:G,run:()=>Oe()});function yn(){document.addEventListener("keydown",function(e){if((window.navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)&&e.keyCode==83){if(!A)return;e.preventDefault(),e.isTrusted&&Re(),I()}})}function En(){document.addEventListener("click",e=>{e.target.closest("[trigger-save]")&&(e.isTrusted&&Re(),I())})}function fr(){A&&(Be(),bt(),be(),yn(),En())}fr();var io=I;var Ie=!1;function vo({isCurrent:e,reload:t}){return e()?(Ie=!0,setTimeout(()=>{Ie=!1},1e3),t(),!0):!1}Xt();function cr(){return st()?!0:A?F()?!0:K?Mt():window.clay?.demo?!1:rt():!1}function rt(){if(!A)return!1;try{let e=V();return St(e)?!1:e!==dt()}catch{return!0}}window.addEventListener("beforeunload",e=>{if(!A&&!st())return;if(Ie){Ie=!1;return}if(!((!K||Ct())&&!cr())&&(e.preventDefault(),e.returnValue="",!window.clay?.demo&&!F()))try{let n=V(),o=dt();n!==o&&zt(n,o)}catch{}});export{vo as a,cr as b,rt as c,qr as d,xn as e,un as f,Pn as g,de as h,st as i,Dn as j,Br as k,Hr as l,Gr as m,Wr as n,Kr as o,Qr as p,ut as q,Ze as r,Vr as s,$r as t,Yr as u,bn as v,Rn as w,jr as x,zr as y,Xr as z,dt as A,Jr as B,ue as C,Zr as D,I as E,J as F,eo as G,to as H,no as I,ro as J,gn as K,er as L,oo as M,so as N,St as O,lr as P,Oe as Q,nt as R,yn as S,En as T,fr as U,io as V};
|
package/dist/m/c-H2H7TI6O.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d}from"./c-234RSEIW.js";import"./c-VHNSBD2M.js";export{c as applyData,d as default,a as engine,b as extractData};
|
package/dist/m/c-HSNGLIFB.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{b as D}from"./c-LD6UVV5R.js";import{a as ie,g as se,h as U}from"./c-PGSBXHUE.js";import{a as re,b as oe,c as M}from"./c-RXTPKCMC.js";import{d as w}from"./c-RBPZNU2D.js";import{c as q,e as Z,g as Q}from"./c-IJUK2GPW.js";import{b as R,f as N}from"./c-DLBX4JCJ.js";import{c as Y}from"./c-BPF2NSPV.js";import{g as V}from"./c-N7JPUPGC.js";import{a as k,g as ee,h as te,i as ne}from"./c-PWJSJEJU.js";var C=null,le=null,A=null;function Ae(e){let t=e?.document?.maxBytes;return Number.isSafeInteger(t)&&t>0?t:null}function ae(e){return C=Ae(e),le=e?.document?.maxBytesMeasures==="file"?"file":null,C}var Te=/<script\b[^>]*\bmerge=(["'])blockeditor\1[^>]*>[\s\S]*?<\/script\s*>/i;function F(e,t=le){if(t!=="file"||typeof e!="string")return e;let n=Te.exec(e);if(!n)return e;let o=n.index,s=o+n[0].length,r=e.lastIndexOf(`
|
|
2
|
-
`,o-1)+1,l=e.indexOf(`
|
|
3
|
-
`,s),c=l===-1?e.length:l+1;return!/\S/.test(e.slice(r,o))&&!/\S/.test(e.slice(s,c))&&(o=r,s=c),e.slice(0,o)+e.slice(s)}function B(e,t){let n=new TextEncoder().encode(e).byteLength,o=Number.isSafeInteger(t)&&t>0;return{bytes:n,maxBytes:o?t:null,state:o?n>t?"over":n>=Math.ceil(t*.8)?"near":"ok":"unknown"}}function ue(){return C}function j({fresh:e=!1}={}){return e?(A=w({fresh:!0}).then(ae),A):(A||(A=w().then(ae)),A)}function yt({fresh:e=!1}={}){return j({fresh:e}).then(t=>({maxBytes:t}))}async function St(e){let t=await j();return B(F(e),t)}function ce(e){let t=new CustomEvent("clay:save-size",{detail:e});document.dispatchEvent(t),(e.state==="near"||e.state==="over")&&import("./c-RJKKRWHW.js").then(n=>n.start(t),()=>{})}var L="/_/clayjs/",be=/[\u0000-\u001F\u007F]/,Oe=/^[\t\n\f\r ]|[\t\n\f\r ]$/,Ee=/^https:\/\/clayjs\.com\/v(\d+)\/([\s\S]*)$/,$e=/^https:\/\/clayjs\.com\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,fe=/^\/_\/clayjs\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,Re=/%2e|%2f|%5c/i;function ke(e){if(typeof e!="string")return null;let t=/^(\d+)\.\d+\.\d+$/.exec(e);return t?t[1]:null}function Me(e){if(typeof e!="string"||e==="")return null;try{return new URL(e).origin}catch{return null}}function je(e){let t=e.indexOf("#"),n=t<0?"":e.slice(t),o=t<0?e:e.slice(0,t),s=o.indexOf("?"),r=s<0?"":o.slice(s);return{head:s<0?o:o.slice(0,s),search:r,hash:n}}function Le(e){if(e===""||e.includes("\\")||Re.test(e))return null;let t=e.split("/"),n=[];for(let o of t){if(o===""||o==="."||o==="..")return null;let s;try{s=decodeURIComponent(o)}catch{return null}if(s.includes("/")||s.includes("\\")||s==="."||s==="..")return null;n.push(s)}return n.join("/")}function T(e,{documentURL:t}={}){if(typeof e!="string"||e===""||Oe.test(e)||be.test(e))return null;let{head:n,search:o,hash:s}=je(e),r=null,l=null,c=null,u=null,i=Ee.exec(n);if(i&&(r="rolling",c=i[1],u=i[2]),r||(i=$e.exec(n),i&&(r="exact",l=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],u=i[4])),r||(i=fe.exec(n),i&&(r="local",l=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],u=i[4])),!r){let d=Me(t);d&&n.startsWith(`${d}/`)&&(i=fe.exec(n.slice(d.length)),i&&(r="local",l=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],u=i[4]))}if(!r)return null;let a=Le(u);return a===null?null:{kind:r,major:c,version:l,rawPath:u,path:a,search:o,hash:s}}function Pe(e,t){let n=e&&typeof e=="object"?e[t]:null;return n&&typeof n.files=="object"&&n.files?n.files:null}function Ie(e){return!e||typeof e!="object"?[]:Array.isArray(e.entries)?e.entries.filter(t=>t&&typeof t=="object"):[]}function _e(e,t,n){if(!n)return!0;let o=Pe(n,t);return!!(o&&Object.hasOwn(o,e.path))}function de(e,{descriptor:t,releases:n,documentURL:o,aliases:s}={}){let r=T(e,{documentURL:o});if(!r||r.kind!=="local")return e;let l=Ie(t),c=ke(r.version);for(let u of l){if(u.local!==e||typeof u.original!="string")continue;let i=n?.[r.version]?.aliases??s;if(i&&typeof i=="object"&&!r.search&&!r.hash&&Object.hasOwn(i,u.original)&&i[u.original]===r.path)return u.original;let a=T(u.original);if(a&&!(a.kind!=="rolling"&&a.kind!=="exact")&&a.rawPath===r.rawPath&&a.search===r.search&&a.hash===r.hash&&!(a.kind==="rolling"?a.major!==c:a.version!==r.version)&&_e(r,r.version,n))return a.kind==="exact"?u.original:`https://clayjs.com/v${a.major}/${r.rawPath}${r.search}${r.hash}`}for(let u of l){if(typeof u.original!="string")continue;let i=T(u.original);if(i&&!(i.kind!=="rolling"&&i.kind!=="exact")&&i.rawPath===r.rawPath&&!(i.kind==="rolling"?i.major!==c:i.version!==r.version))return i.kind==="rolling"?`https://clayjs.com/v${i.major}/${r.rawPath}${r.search}${r.hash}`:`https://clayjs.com/${i.version}/${r.rawPath}${r.search}${r.hash}`}return`https://clayjs.com/${r.version}/${r.rawPath}${r.search}${r.hash}`}var Ne=Object.freeze({"https://cdn.jsdelivr.net/npm/overtype@2.6.1/dist/overtype.min.js":"compat/overtype-2.6.1.min.js","https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js":"compat/highlight-11.9.0.min.js","https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;0,600;1,400;1,500&family=IBM+Plex+Sans:wght@400;500;600&display=swap":"fonts/ibm-plex.css"}),J="clay-runtime-map",De=new Set(["stylesheet","preload","modulepreload"]),he=null,H=null;function Ue(e){let t;try{t=JSON.parse(e)}catch{return null}return!t||typeof t!="object"||t.schema!==1?null:t}function Ce(){if(typeof document>"u")return null;let e=document.getElementById(J);if(!e)return null;let t=e.textContent??"";return t===he||(he=t,H=Ue(t)),H}var Fe=`script[src*="${L}"], link[href*="${L}"], #${J}`;function pe(e){if(e.querySelector(Fe))return!0;for(let t of e.querySelectorAll("template"))if(pe(t.content))return!0;return!1}function Be(e){let t=[],n=[e];for(;n.length;){let o=n.pop();for(let s of o.children??[])t.push(s),n.push(s),s.content&&n.push(s.content)}return t}function He(e){return e.tagName==="SCRIPT"&&e.hasAttribute("src")?"src":e.tagName!=="LINK"||!e.hasAttribute("href")?null:(e.getAttribute("rel")??"").toLowerCase().split(/\s+/).some(n=>De.has(n))?"href":null}function Je(e){if(!e||!pe(e))return;let t=[],n=!1;for(let r of Be(e)){if(r.getAttribute("id")===J){r.remove();continue}let l=He(r);l&&(t.push({element:r,name:l}),!n&&(r.getAttribute(l)??"").includes(L)&&(n=!0))}if(!n)return;let o=location.href,s=Ce();for(let{element:r,name:l}of t){let c=r.getAttribute(l),u=T(c,{documentURL:o});!u||u.kind!=="local"||r.setAttribute(l,de(c,{descriptor:s,documentURL:o,aliases:Ne}))}}ne(Je);var S=!1,E=null,me="/_/save",Ge=12e3,ge=6e4,Ke=1024*1024,xe="text/plain;charset=UTF-8",P=null,$=!1,G=new Map;function Bt(e,t){t==null?G.delete(e):G.set(e,String(t))}var K=new Set;function Ht(e){return K.add(e),()=>K.delete(e)}async function Jt(e,t){$=!!e;try{return await t()}finally{$=!1}}function zt(){return S}function Gt(){return S?null:(S=!0,E={reserved:!0},E)}function Kt(e){!e||E!==e||(E=null,S=!1)}function Wt(){return $}var I=[],_=[];function Xt(e){return I.push(e),()=>{let t=I.indexOf(e);t>=0&&I.splice(t,1)}}function Yt(e){return _.push(e),()=>{let t=_.indexOf(e);t>=0&&_.splice(t,1)}}function We(e){for(let t of I)try{t(e)}catch(n){console.error("clayjs: onSaveAttempt hook failed:",n)}}function Xe(e){for(let t of _)try{t(e)}catch(n){console.error("clayjs: onSaveOutcome hook failed:",n)}}function ve(e){return{ok:!0,msg:e.msg??"Saved",msgType:e.msgType||"success",code:e.code??null,etag:e.etag??null,...e.siteData?{siteData:e.siteData}:{}}}var b=[],Ye=8,y=null;function Vt(){return y!==null}function ye(){let e=window.crypto?.randomUUID?.();if(e)return e;if(window.crypto?.getRandomValues){let n=new Uint8Array(16);return window.crypto.getRandomValues(n),Array.from(n,o=>o.toString(16).padStart(2,"0")).join("")}let t=()=>Math.random().toString(36).slice(2,12).padEnd(10,"0");return`${Date.now().toString(36)}-${t()}${t()}${t()}`}function Ve(e){b.push(e),b.length>Ye&&b.shift()}function qe(e){return typeof e=="string"&&e!==""&&b.includes(e)}function qt(){b.length=0,y=null}function W(e){let t=e.name==="AbortError",n=!t&&e.status===412,o=!t&&!n&&e.code==="save-already-applied";return{ok:!1,msg:t?"Server not responding":e.message||"Save failed",msgType:t||o?"unknown":n?"conflict":"error",code:t?"timeout":n?"conflict":e.code??null,changedBy:n?e.changedBy??null:null,afterTimeout:n&&y!==null,conflictEtag:n?e.etag??null:null,status:Number.isInteger(e.status)?e.status:null,hadTimeout:t||e.hadTimeout===!0,reason:e.reason??null,retryAfter:e.retryAfter??null,saveOutcome:e.saveOutcome??null,etag:null}}function O(e){return{ok:!1,msg:e,msgType:"skipped",code:null,etag:null}}function Ze(e){let t=new Error(`This document is ${e.bytes} bytes; this host saves at most ${e.maxBytes}`);return t.code="save-too-large",{...W(t),sent:!1,size:e}}var x=null;function Qe(e){return x?null:(x={kind:e},x)}function et(e){x===e&&(x=null)}function tt(){return x?x.kind:null}function nt(){return{ok:!1,msg:"Invalid page conversion metadata",msgType:"error",code:"invalid-header",etag:null}}var rt=3,ot=/^(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT|(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), \d{2}-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{2} \d{2}:\d{2}:\d{2} GMT|(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?: \d|\d{2}) \d{2}:\d{2}:\d{2} \d{4})$/;function it(e){if(e==null)return null;let t=String(e).trim();if(!t)return null;if(/^-?\d+$/.test(t))return Math.max(0,Math.min(3600,Number(t)));if(!ot.test(t))return null;let n=Date.parse(t);return Number.isNaN(n)?null:Math.max(0,Math.min(3600,Math.round((n-Date.now())/1e3)))}var st=/^[0-9a-f]{64}$/,at=/^[A-Za-z0-9-]{1,64}$/;function lt(e){if(e==null)return{header:null};if(typeof e!="object")return{invalid:!0};let{source:t,base:n,epoch:o}=e;return typeof n!="string"||!st.test(n)?{invalid:!0}:t==="file"?o!=null?{invalid:!0}:{header:`v1; source=file; base=${n}`}:t==="room"?typeof o!="string"||!at.test(o)?{invalid:!0}:{header:`v1; source=room; base=${n}; epoch=${o}`}:{invalid:!0}}function ut(e,t,n,o,s,r=!1,l=null,c=!0){let u=Y(),i=u?`${me}/${u}`:me,a={method:"POST",credentials:u?"omit":"same-origin",signal:n,headers:{"Document-URL":window.location.href,"Page-URL":window.location.href,"Save-Trigger":t?"user":"auto","Save-ID":o,[ie]:String(1)},body:ct(e)};for(let[d,h]of G)a.headers[d]=h;if(c)for(let d of K){let h=null;try{h=d(e)}catch(g){console.error("clayjs: a save header source failed:",g)}if(h)for(let[g,f]of Object.entries(h))a.headers[g]=String(f)}return typeof a.body!="string"&&(a.headers["Content-Type"]=xe),l&&(a.headers["Blockeditor-Conversion"]=l),s&&(a.headers["If-Match"]=s),r&&e.length<ge&&new Blob([e]).size<ge&&(a.keepalive=!0),{url:ft(i),options:a}}function ct(e){if(e.length<Ke)return e;if(P&&P.content===e)return P.blob;let t=new Blob([e],{type:xe});return P={content:e,blob:t},t}function Se(){let e=re();return oe()&&e?e:null}function ft(e){let t=window.location.origin;return!t||t==="null"?e:new URL(e,t).href}function z(e,t){let n=JSON.stringify(t);return{ok:e>=200&&e<300,status:e,statusText:e===200?"OK":"Insufficient Storage",text:()=>Promise.resolve(n)}}function dt(e){let t=V();return t?Promise.resolve().then(()=>{try{return t(e),z(200,{msg:"Saved in this browser",msgType:"success"})}catch(n){return z(507,{msg:"Couldn't save in this browser. Storage is full or turned off.",msgType:"error",code:n.code||"draft-storage"})}}):Promise.resolve(z(503,{msg:"Saving in this browser is not ready yet",msgType:"error",code:"draft-not-ready"}))}function ht(e,t,n,{captureId:o=null,conversionHeader:s=null,attempts:r=[]}={}){let l=new AbortController,c=setTimeout(()=>l.abort(),Ge),u=Z(),i=Q(),a=u||i,d=$;$=!1;let{url:h,options:g}=ut(e,a,l.signal,t,n,d,s);return Ve(t),R||(r.some(f=>f.saveId===t&&f.etag===(n??null))||r.push({saveId:t,etag:n??null}),We({captureId:o,saveId:t,html:e,etag:n??null})),(R?dt(e):fetch(h,g)).then(f=>f.text().then(m=>{let p={};if(m)try{p=JSON.parse(m)}catch{if(f.ok)throw new Error("Server sent a response that was not JSON")}if(!f.ok){let v=new Error(p.msg||p.error||`HTTP ${f.status}: ${f.statusText}`);throw v.code=f.status===413?"save-too-large":p.code??null,v.status=f.status,v.changedBy=p.changedBy??null,v.etag=p.etag??null,v.saveId=p.saveId??null,v.reason=typeof p.reason=="string"?p.reason:null,v.saveOutcome=p.saveOutcome??null,v.retryAfter=it(f.headers?.get?.("Retry-After")),v}return M(p.etag??null),y=null,p})).catch(f=>{throw console.error("Failed to save page:",f),f.name==="AbortError"&&(y={saveId:t,etag:n}),a&&q(),f}).finally(()=>{clearTimeout(c)})}async function pt(){let e=y;if(!e)return{landed:null,resend:!1};let n=(await w({fresh:!0})).document,o=typeof n?.etag=="string"&&n.etag?n.etag:null;return o?n.saveId&&n.saveId===e.saveId?(M(o),y=null,{landed:{msg:"Saved",msgType:"success",etag:o},resend:!1}):(n.saveId&&(y=null),{landed:null,resend:!!e.etag,etag:e.etag}):{landed:null,resend:!1}}async function mt(e,{captureId:t=null,conversionHeader:n=null,attempts:o=[]}={}){let s=ye(),r=Se(),l=!1,c=!1,u=0,i=t??k();for(;;)try{return await ht(e,s,r,{captureId:t,conversionHeader:n,attempts:o})}catch(a){if(l&&(a.hadTimeout=!0),a.name==="AbortError"){if(l)throw a;let{landed:d,resend:h,etag:g}=await pt();if(d)return d;if(!h)throw a;r=g,l=!0;continue}if(a.status===412&&!c&&qe(a.saveId)){M(a.etag??null),y=null,s=ye(),r=Se(),c=!0;continue}if(a.code==="blockeditor-converting"&&u<rt){if(k()!==i||(u+=1,await new Promise(d=>setTimeout(d,Math.max(0,a.retryAfter??1)*1e3)),k()!==i))throw a;continue}throw a}}function X(e,t,n,o,s=null,r=0,l=null){return e=se(e,Math.max(U(),r)),new Promise(c=>{let u=[],i=ee(s),a=()=>l!==null&&E===l,d=()=>{a()||(S=!1)},h=(m,p=!1)=>{p&&D(e,t??null,i),te(s),Xe({captureId:t??null,result:m,attempts:u,sent:u.length>0}),typeof n=="function"&&n(m),c(m)};if(!N&&!window.clay?.testMode)return h(O("Not in edit mode"));if(S&&!a())return h(O("Save already in progress"));let g=lt(o);if(g.invalid)return h(nt());if(S=!0,window.clay?.testMode){setTimeout(()=>{d(),h(ve({msg:"Test mode: save skipped"}))},0);return}j();let f=B(F(e),ue());if(ce(f),f.state==="over")return d(),h(Ze(f));mt(e,{captureId:t,conversionHeader:g.header,attempts:u}).then(ve,W).then(m=>{d(),m.code==="save-too-large"&&!m.size&&(m.size=f),m.ok&&D(e,t??null,i,m.siteData??null),h(m)})})}function gt(e,t=()=>{}){return X(e,null,t,null)}function Zt(e,t,n=()=>{},{conversion:o,capture:s=null,blockeditorFormatFloor:r,lane:l=null}={}){return X(e,t,n,o,s,r,l)}function Qt({html:e,captureId:t,conversion:n}){return X(e,t??null,void 0,n)}function en(e,t=()=>{}){return new Promise(n=>{let o=null,s=r=>{et(o),typeof t=="function"&&t(r),n(r)};if(!N)return s(O("Not in edit mode"));if(tt())return s(O("Another document operation is in progress"));if(S)return s(O("Save already in progress"));if(R)return s(!1);o=Qe("replace"),fetch(new URL(e,window.location.href).href).then(r=>{if(!r.ok)throw new Error(`Template fetch failed: HTTP ${r.status} ${r.statusText}`);return r.text()}).then(r=>gt(r)).then(s).catch(r=>{console.error("Failed to fetch template:",r),s(W(r))})})}var we=null;function tn(e){we=e}function nn(){return we}export{j as a,yt as b,St as c,Bt as d,Ht as e,Jt as f,zt as g,Gt as h,Kt as i,Wt as j,Xt as k,Yt as l,Vt as m,ye as n,qt as o,Qe as p,et as q,tt as r,ut as s,gt as t,Zt as u,Qt as v,en as w,tn as x,nn as y};
|
package/dist/m/c-JMDKPBMC.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{a as Z}from"./c-DZPO22O3.js";import{b as K}from"./c-3G2DGZUP.js";import{p as G,q as X}from"./c-HSNGLIFB.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import{a as B,h as Y}from"./c-RXTPKCMC.js";import"./c-RBPZNU2D.js";import"./c-IJUK2GPW.js";import"./c-DLBX4JCJ.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-PWJSJEJU.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var Ue=Object.defineProperty,Ie=(e,t)=>{for(var r in t)Ue(e,r,{get:t[r],enumerable:!0})},Pe=["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"],De=new Set(Pe),Be=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),de=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),Q=new Set(["checked","selected","disabled","readOnly","paused"]);function He(e,t){return t==null?Q.has(e)?!1:"":Q.has(e)?t==="false"?!1:!!t:t}var qe={};Ie(qe,{EmptyListInsert:()=>R,MAX_RULE_DEPTH:()=>M,MaxRuleDepthExceeded:()=>J,NoRulesTag:()=>ze,RuleTargetReadOnly:()=>ye,RulesParseError:()=>pe,ShapeMismatch:()=>me,UnknownRulesVersion:()=>he,WriteNotRoundTripped:()=>Fe,WriteRefused:()=>We,WriteRejected:()=>_e});var pe=class extends Error{constructor(e,t){super(e),this.name="RulesParseError",this.cause=t}},he=class extends Error{constructor(e){super(`unknown rules version: ${e}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=e}},M=20,J=class extends Error{constructor(e){super(`rule depth exceeded ${M} at path: ${e.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=e}},me=class extends Error{constructor(e){super(`shape mismatch: ${e.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=e}},R=class extends Error{constructor(e,t){super(t?`cannot add items to empty list at "${e.join(".")}" \u2014 ${t}`:`cannot add items to empty list at "${e.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=e}},ye=class extends Error{constructor(e){super(`cannot write to read-only DOM property "${e}"`),this.name="RuleTargetReadOnly",this.target=e}},We=class extends Error{constructor(e){super(`write refused: ${e.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=e}};function Ve(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t?`${t}.${r}`:String(r),"")||"(root)"}var Fe=class extends Error{constructor(e){super(`write did not round-trip at "${Ve(e)}"`),this.name="WriteNotRoundTripped",this.path=e}},ze=class extends Error{constructor(e){super(`no <script data-rules-name~="${e}"> rules tag in this document`),this.name="NoRulesTag",this.token=e}},_e=class extends Error{constructor(e,t){super(`write rejected: ${e.length} unknown key(s), ${t.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=e,this.unmatched=t}};function U(e){let t=0,r=null,l=-1;for(let n=0;n<e.length;n++){let o=e[n];o==="\\"?n++:r?o===r&&(r=null):o==='"'||o==="'"?r=o:o==="["||o==="("?t++:o==="]"||o===")"?t>0&&t--:o==="@"&&t===0&&(l=n)}return l}var ee="[*]";function L(e){let t=U(e),r=t===-1?e:e.slice(0,t),l=r.endsWith(ee),n={selector:l?r.slice(0,-ee.length):r,prop:t===-1?null:e.slice(t+1)||null};return l&&(n.all=!0),n}function ge(e){let t=0,r=null,l=-1,n=!1;for(let o=0;o<e.length;o++){let i=e[o];i==="\\"?o++:r?i===r&&(r=null):i==='"'||i==="'"?r=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:t===0&&i===">"?l=o:t===0&&i===","&&(n=!0)}return n||l===-1||!Je(e,l+1)?null:e.slice(0,l).trim()||null}function Je(e,t){let r=t,l=e.replace(/\s+$/,"").length;for(;r<l&&/\s/.test(e[r]);)r++;let n=0,o=null;for(;r<l;r++){let i=e[r];if(i==="\\")r++;else if(o)i===o&&(o=null);else if(i==='"'||i==="'")o=i;else if(i==="["||i==="(")n++;else if(i==="]"||i===")")n>0&&n--;else if(n===0&&(i==="+"||i==="~"||/\s/.test(i)))return!1}return!0}var Ye=/^--[A-Za-z0-9_-]+$/;function we(e){return typeof e=="string"&&Ye.test(e)}function ve(e){let t=[],r=[],l=null,n=0;for(let o=0;o<e.length;o++){let i=e[o];if(l){i==="\\"?o++:i===l&&(l=null);continue}if(i==="/"&&e[o+1]==="*"){let a=e.indexOf("*/",o+2);o=a===-1?e.length:a+1;continue}i==='"'||i==="'"?l=i:i==="("?r.push(")"):i==="["?r.push("]"):i==="{"?r.push("}"):(i===")"||i==="]"||i==="}")&&r[r.length-1]===i?r.pop():i===";"&&r.length===0&&(t.push(e.slice(n,o)),n=o+1)}return t.push(e.slice(n)),t}function Ge(e){let t="",r=null;for(let l=0;l<e.length;l++){let n=e[l];if(r){t+=n,n==="\\"&&l+1<e.length?t+=e[++l]:n===r&&(r=null);continue}if(n==="/"&&e[l+1]==="*"){let o=e.indexOf("*/",l+2);l=o===-1?e.length:o+1,t+=" ";continue}(n==='"'||n==="'")&&(r=n),t+=n}return t}function be(e){e=Ge(e);let t=e.indexOf(":");if(t===-1)return null;let r=e.slice(0,t).trim(),l=e.slice(t+1).trim(),n=/!\s*important\s*$/i.exec(l);return n&&(l=l.slice(0,n.index).trim()),{name:r,value:l,important:!!n}}function xe(e,t){if(e==null)return null;let r=null;for(let l of ve(String(e))){let n=be(l);!n||n.name!==t||(!r||n.important||!r.important)&&(r=n)}return r?r.value:null}function Xe(e,t,r){let l=e==null?"":String(e),n=r==null||r==="",o=ve(l),i=o.map(be),a=i.some(f=>f&&f.name===t&&f.important),s=[],u=!1;o.forEach((f,d)=>{let m=i[d];if(!m||m.name!==t){s.push(f);return}if(n||u)return;let p=/^\s*/.exec(f)[0];s.push(`${p}${t}: ${r}${a?" !important":""}`),u=!0});let c=s.join(";");if(!n&&!u){let f=c.trimEnd();c=f===""?`${t}: ${r}`:`${f}${f.endsWith(";")?" ":"; "}${t}: ${r}`}return c.trim()===""?null:c}function Ke(e,t,r,l){let n=e.attr(t,"style");if((xe(n,r)??"")===l)return;let o=Xe(n,r,l);o==null?e.removeAttr(t,"style"):e.attr(t,"style",o)}function Ae(e,t,r,l={}){if(Object.prototype.hasOwnProperty.call(l,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return q(e,t,r,{depth:0,path:[]},l)}function q(e,t,r,l,n){if(l.depth>M)throw new J(l.path);if(typeof r=="string")return Ze(e,t,r,l,n);if(Array.isArray(r)){let[o,i]=r,a=e.find(t,o,n);return Te(n,l,a),a.map((s,u)=>q(e,s,i,{depth:l.depth+1,path:[...l.path,u]},n))}if(typeof r=="object"&&r!==null){let o={};for(let[i,a]of Object.entries(r))o[i]=q(e,t,a,{depth:l.depth+1,path:[...l.path,i]},n);return o}return null}function Ze(e,t,r,l,n){if(r.endsWith("[]")){let u=r.slice(0,-2),c=e.find(t,u,n);return Te(n,l,c),c.map(f=>e.text(f))}if(r.startsWith("@"))return H(e,t,r.slice(1));let o=U(r);if(o!==-1){let{selector:u,all:c}=L(r),f=r.slice(o+1),d=u?e.find(t,u,n):[t];return c&&n.allMatches?d.map(m=>H(e,m,f)):d.length===0?null:H(e,d[0],f)}if(r===".")return e.text(t);let{selector:i,all:a}=L(r),s=e.find(t,i,n);return a&&n.allMatches?s.map(u=>e.text(u)):s.length===0?null:e.text(s[0])}function Te(e,t,r){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),r)}catch(l){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,l)}}function H(e,t,r){if(we(r))return xe(e.attr(t,"style"),r);if(De.has(r)){let n=e.prop(t,r);return n==null?null:String(n)}return e.attr(t,r)??null}function Qe(e,t,r,l){let n=e.length,o=t.length,i=new Array(n).fill(-1);if(l){let h=new Set;for(let y=0;y<n;y++){let g=l[y];!(g>=0&&g<o)||h.has(g)||(i[y]=g,h.add(g))}}if(n===0||o===0)return i;let a=e.map(h=>te(h,r)),s=t.map(h=>te(h,r)),u=new Array(o).fill(!1);for(let h of i)h>=0&&(u[h]=!0);let c=new Map;s.forEach((h,y)=>{u[y]||c.set(h,c.has(h)?-1:y)});let f=new Map;a.forEach((h,y)=>{i[y]>=0||f.set(h,(f.get(h)||0)+1)}),a.forEach((h,y)=>{if(i[y]>=0||f.get(h)!==1)return;let g=c.get(h);g===void 0||g===-1||u[g]||(i[y]=g,u[g]=!0)});let d=[];for(let h=0;h<n;h++)i[h]<0&&d.push(h);let m=[];for(let h=0;h<o;h++)u[h]||m.push(h);if(d.length===0||m.length===0)return i;let p=n*o+1,w=et(e,t,r),v=(h,y)=>w(h,y)*p+Math.abs(h-y);for(let[h,y]of tt(d,m,v))i[h]=y;return i}var Oe=e=>typeof e=="object"&&e!==null;function te(e,t){if(!Oe(t))return e==null?" null":String(e);let r=Object.keys(t);return JSON.stringify(r.map(l=>{let n=JSON.stringify(e?.[l]);return n===void 0?" undef":n}))}function et(e,t,r){if(!Oe(r))return(a,s)=>e[a]===t[s]?0:1;let l=Object.keys(r),n=a=>l.map(s=>JSON.stringify(a?.[s])),o=e.map(n),i=t.map(n);return(a,s)=>{let u=o[a],c=i[s],f=0;for(let d=0;d<l.length;d++)u[d]!==c[d]&&f++;return f}}function tt(e,t,r){return e.length<=t.length?re(e,t,r,!1):re(t,e,(l,n)=>r(n,l),!0)}function re(e,t,r,l){let n=e.length,o=t.length,i=[];for(let f=0;f<=n;f++)i.push(new Float64Array(o+1).fill(1/0));let a=[];for(let f=0;f<=n;f++)a.push(new Uint8Array(o+1));for(let f=0;f<=o;f++)i[n][f]=0;for(let f=n-1;f>=0;f--)for(let d=o-1;d>=0;d--){let m=r(e[f],t[d])+i[f+1][d+1],p=i[f][d+1];m<=p?(i[f][d]=m,a[f][d]=1):i[f][d]=p}let s=[],u=0,c=0;for(;u<n&&c<o;)a[u][c]&&(s.push(l?[t[c],e[u]]:[e[u],t[c]]),u++),c++;return s}function Ee(e,t,r,l,n,o,i,a={}){let s=e.find(t,r,a);if(n.length===0){s.forEach(b=>e.remove(b)),W(a,"onRowsApplied",o.path,[]);return}let u=n.length>s.length,c=s[0]||null;if(u&&!c&&(c=ot(e,t,r,a),!c))throw new R(o.path);let f=s.map(b=>lt(e,b,l,a)),d=null;if(u&&c){d=e.clone(c),a.templateAttr&&e.removeAttr(d,a.templateAttr);let b=e.stripIds(d);b>0&&console.warn(`[hyper-html-api] stripped ${b} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let m=Qe(n,f,l,rt(e,s,n,o,a)),p=s.length>0?e.parent(s[0]):ut(e,t,r,c,o,a),w=s.length>0?Ne(e,p,s[0]):0,v=dt(e,s),h=new Set,y=[],g=n.map((b,E)=>{let N=m[E];if(N>=0)return h.add(N),y.push(!1),s[N];y.push(!0);let T=e.clone(d);return e.stripIds(T),T});s.forEach((b,E)=>{h.has(E)||e.remove(b)}),v?ft(e,p,w,g,y):pt(e,g,y,p,w),nt(e,g,l,n,o,i,a),W(a,"onRowsApplied",o.path,g)}function W(e,t,r,l){if(typeof e[t]=="function")try{return e[t](r.slice(),l)}catch(n){console.warn(`[hyper-html-api] ${t} threw at "${r.join(".")||"(root)"}"`,n);return}}function rt(e,t,r,l,n){let o=W(n,"identifyRows",l.path,r);if(!Array.isArray(o))return null;let i=new Array(r.length).fill(-1),a=new Set,s=new Map(t.map((u,c)=>[e.identity(u),c]));for(let u=0;u<r.length;u++){if(!o[u])continue;let c=s.get(e.identity(o[u]));c===void 0||a.has(c)||(i[u]=c,a.add(c))}return i}function nt(e,t,r,l,n,o,i){t.forEach((a,s)=>{if(r===null){let u=l[s],c=u==null?"":String(u);e.text(a)!==c&&e.text(a,c)}else{let u=o(e,a,r,l[s],{depth:n.depth+1,path:[...n.path,s]},i);u&&u!==a&&(t[s]=u)}})}function lt(e,t,r,l){return r===null?e.text(t):Ae(e,t,r,l.onRowsRead?{...l,onRowsRead:void 0}:l)}function Ne(e,t,r){let l=e.children(t);for(let n=0;n<l.length;n++)if(e.sameNode(l[n],r))return n;return-1}function ot(e,t,r,l){if(!l.templateAttr)return null;let n=/^\s*:scope\s*>\s*/.test(r),o=new RegExp(":not\\(\\["+l.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),i=r.replace(/^\s*:scope\s*>\s*/,"").replace(o,""),a=n?it(i):0,s=ge(i),u=t;for(;u;){let c=e.find(u,i,{includeRulesTag:!1,templateAttr:null});for(let f of c)if(e.attr(f,l.templateAttr)!=null&&!(n&&!st(e,t,f,a))&&!(s&&!e.matches(e.parent(f),s)))return f;u=e.parent(u)}return null}function it(e){let t=0,r=null,l=1;for(let n=0;n<e.length;n++){let o=e[n];if(o==="\\")n++;else if(r)o===r&&(r=null);else if(o==='"'||o==="'")r=o;else if(o==="["||o==="(")t++;else if(o==="]"||o===")")t>0&&t--;else if(t===0&&o===">")l++;else{if(t===0&&(o==="+"||o==="~"))return null;if(t===0&&/\s/.test(o)){if(!at(e,n))return null;for(;n+1<e.length&&/\s/.test(e[n+1]);)n++}}}return l}function at(e,t){let r=t;for(;r<e.length&&/\s/.test(e[r]);)r++;let l=t>0?e[t-1]:"",n=r<e.length?e[r]:"";return ne(l)||ne(n)}function ne(e){return e===">"||e==="+"||e==="~"}function st(e,t,r,l){if(l===null)return!0;let n=r;for(let s=0;s<l;s++)if(n=e.parent(n),!n)return!1;let o=e.prop(t,"tagName");if(!o)return!0;let i=e.prop(n,"tagName");if(!i||String(i).toLowerCase()!==String(o).toLowerCase())return!1;let a=new Set(le(e,n));return le(e,t).every(s=>a.has(s))}function le(e,t){let r=e.attr(t,"class");return r?String(r).split(/\s+/).filter(Boolean):[]}function ut(e,t,r,l,n,o){let i=e.parent(l);if(i&&ct(e,t,i)&&!ie(e,i,o))return i;let a=ge(r);if(!a)throw new R(n.path,`the list selector "${r}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let s=(a===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,a,o)).filter(u=>!ie(e,u,o));if(s.length===0)throw new R(n.path,`no container matching "${a}" inside this context to hold the new rows`);if(s.length>1)throw new R(n.path,`"${a}" matches ${s.length} containers inside this context, so the new rows have no single destination`);return s[0]}function ct(e,t,r){let l=r;for(;l;){if(e.sameNode(l,t))return!0;l=e.parent(l)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(n=>e.sameNode(n,r))}var oe=["no-data","editor-ui"];function ie(e,t,r){let l=t;for(;l;){if(r.templateAttr&&e.attr(l,r.templateAttr)!=null||oe.some(o=>e.attr(l,o)!=null))return!0;let n=e.attr(l,"clay");if(n&&n.split(/\s+/).some(o=>oe.includes(o)))return!0;l=e.parent(l)}return!1}function ft(e,t,r,l,n){let o=e.children(t),i=o.map(s=>e.identity(s)),a=!1;l.forEach((s,u)=>{let c=e.identity(s),f=r+u;if(i[f]===c)return;if(!n[u]){let m=i.indexOf(c);m!==-1&&(i.splice(m,1),o.splice(m,1))}let d=Math.min(f,o.length);d<o.length?e.insertBefore(o[d],s):o.length?a?e.insertAfter(o[o.length-1],s):(e.insertAt(t,s,f),a=!0):e.insertAt(t,s,0),i.splice(d,0,c),o.splice(d,0,s)})}function dt(e,t){if(t.length<=1)return!0;let r=e.parent(t[0]);if(!r)return!1;let l=new Map(e.children(r).map((o,i)=>[e.identity(o),i])),n=[];for(let o of t){let i=l.get(e.identity(o));if(i===void 0)return!1;n.push(i)}return n.sort((o,i)=>o-i),n[n.length-1]-n[0]===n.length-1}function pt(e,t,r,l,n){let o=null,i=n;for(let a=0;a<t.length;a++){if(!r[a]){o=t[a];continue}let s=o?e.parent(o):l;if(!s)continue;let u=o?Ne(e,s,o)+1:i++;e.insertAt(s,t[a],u),o=t[a]}}function ht(e,t,r,l,n={}){if(Object.prototype.hasOwnProperty.call(n,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let o=[];if(V(r,l,[],o),o.length)throw new me(o);j(e,t,r,l,{depth:0,path:[]},n)}function j(e,t,r,l,n,o={}){if(n.depth>M)throw new J(n.path);if(l===void 0)return t;if(typeof r=="string")return mt(e,t,r,l,n,o);if(Array.isArray(r)){let[i,a]=r;return Ee(e,t,i,a,l,n,j,o),t}if(typeof r=="object"&&r!==null){for(let[i,a]of Object.entries(r)){let s=j(e,t,a,l==null?l:l[i],{depth:n.depth+1,path:[...n.path,i]},o);s&&s!==t&&(t=s)}return t}return t}function mt(e,t,r,l,n,o){if(r.endsWith("[]")){let c=r.slice(0,-2);return Ee(e,t,c,null,l,n,j,o),t}if(r.startsWith("@"))return se(e,t,r.slice(1),l);let i=U(r);if(i!==-1){let{selector:c,all:f}=L(r),d=r.slice(i+1),m=c?e.find(t,c,o):[t];for(let p of f?m:m.slice(0,1))se(e,p,d,l);return t}if(r===".")return ae(e,t,l),t;let{selector:a,all:s}=L(r),u=e.find(t,a,o);for(let c of s?u:u.slice(0,1))ae(e,c,l);return t}function ae(e,t,r){let l=r==null?"":String(r);e.text(t)!==l&&e.text(t,l)}function yt(e,t,r,l){if(e.styleVar){e.styleVar(t,r,l);return}Ke(e,t,r,l)}function se(e,t,r,l){if(we(r))return yt(e,t,r,l==null?"":String(l).trim()),t;if(de.has(r)){let n=e.prop(t,r);if(n===l||n!=null&&l!=null&&String(n)===String(l))return t;throw new ye(r)}if(r==="outerHTML"){let n=l==null?"":String(l);return e.replaceWith(t,n)}if(Be.has(r)){let n=He(r,l);return e.prop(t,r)!==n&&e.prop(t,r,n),t}if(l==null)e.attr(t,r)!=null&&e.removeAttr(t,r);else{let n=String(l);e.attr(t,r)!==n&&e.attr(t,r,n)}return t}function V(e,t,r,l){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((n,o)=>{typeof n=="object"&&n!==null&&l.push({path:S([...r,o]),expected:"scalar",got:k(n)})}):l.push({path:S(r),expected:"array",got:k(t)});return}t!==null&&typeof t=="object"&&l.push({path:S(r),expected:"scalar",got:k(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){l.push({path:S(r),expected:"array",got:k(t)});return}let n=e[1];t.forEach((o,i)=>V(n,o,[...r,i],l));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){l.push({path:S(r),expected:"object",got:k(t)});return}for(let[n,o]of Object.entries(e))V(o,t[n],[...r,n],l)}}}function k(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function S(e){return e.join(".")}function gt(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function r(n){let o=[],i=0;for(;i<n.length;){let a=n[i];if(/\s/.test(a)){i++;continue}if("{}".includes(a)){o.push({type:a,value:a}),i++;continue}if(a==="["){let f=!1,d=i+1;for(;d<n.length&&/\s/.test(n[d]);)d++;if(d<n.length&&/[a-zA-Z_]/.test(n[d])&&(f=!0),!f){o.push({type:a,value:a}),i++;continue}}if(a==="]"){o.push({type:a,value:a}),i++;continue}if(a===":"){o.push({type:t.COLON,value:a}),i++;continue}if(a===","){o.push({type:t.COMMA,value:a}),i++;continue}if(a==='"'||a==="'"){let f=a,d=i+1;for(;d<n.length&&n[d]!==f;)n[d]==="\\"&&d++,d++;o.push({type:t.STRING,value:n.substring(i+1,d),quoted:!0,sourceQuote:f}),i=d+1;continue}let s=i,u;for(;s<n.length&&!/[{},]/.test(n[s]);)if(n[s]===":"){let f=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],d=!1;for(let m of f){let p=m.substring(1);if(n.substring(s+1,s+1+p.length)===p){d=!0,s+=p.length;break}}if(!d)break}else if(n[s]==="["){for(s++;s<n.length&&n[s]!=="]";){if(n[s]==='"'||n[s]==="'"){let f=n[s];for(s++;s<n.length&&n[s]!==f;)n[s]==="\\"&&s++,s++}s++}s<n.length&&n[s]==="]"&&s++}else s++;u=n.substring(i,s);let c=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?c=t.NUMBER:u==="true"||u==="false"||u==="null"?c=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(c=t.SELECTOR),o.push({type:c,value:u,quoted:!1}),i=s}return o}function l(n){let o="";for(let i=0;i<n.length;i++){let a=n[i];if("{}".includes(a.type)||"[]".includes(a.type)){o+=a.value;continue}if(a.type===t.COLON){o+=a.value;continue}if(a.type===t.COMMA){let s=n[i+1];if(s&&(s.type==="}"||s.type==="]"))continue;o+=a.value;continue}if(a.type===t.STRING&&a.quoted){let s=a.value;a.sourceQuote==="'"&&(s=s.replace(/\\'/g,"'"),s=s.replace(/(\\*)"/g,(u,c)=>c.length%2===0?c+'\\"':u)),o+=`"${s}"`;continue}if(a.type===t.NUMBER||a.type===t.BOOLEAN){o+=a.value;continue}if(a.type===t.SELECTOR||a.type===t.IDENTIFIER){o+=`"${a.value}"`;continue}o+=`"${a.value}"`}return o}try{let n=r(e),o=l(n);return JSON.parse(o)}catch(n){throw new pe("Invalid extraction rules syntax: "+n.message,n)}}var wt="1";var ur=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"]})}),cr=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),vt=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);var fr=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",...vt],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})});function bt(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function xt(e){return e?(e.nodeType===9||e.nodeType,e):null}function ue(e,t,r){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=r===null?"":r:t==="checked"&&e.tagName==="INPUT"?e.checked=r!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=r!==null))}function At(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 r of t)if(r.tagName==="TEXTAREA")r.value=r.defaultValue;else if(r.tagName==="INPUT"){let l=r.type;l!=="file"&&l!=="checkbox"&&l!=="radio"&&(r.value=r.defaultValue),r.checked=r.defaultChecked}else r.tagName==="OPTION"&&(r.selected=r.defaultSelected)}var Ot={semanticExclude:!0,find(e,t,r={}){let l=xt(e);if(!l||!l.querySelectorAll)return[];let n=Array.from(l.querySelectorAll(t));r.includeRulesTag||(n=n.filter(a=>!bt(a)));let o=[];r.skip&&o.push(r.skip);let i=r.templateAttr===null?null:r.templateAttr||"cms-template";if(i&&o.push("["+i+"]"),o.length){let a=o.join(", ");n=n.filter(s=>!s.closest||!s.closest(a))}return n},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,At(e,t)},attr(e,t,r){if(r===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,r),ue(e,t,r)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),ue(e,t,null)},prop(e,t,r){if(r===void 0){let l=e?e[t]:void 0;return l!==void 0?l:null}e[t]=r},clone(e){let t=e.cloneNode(!0);return Tt(t),t},insertAt(e,t,r){let l=e.children[r]||null;e.insertBefore(t,l)},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 l=r.content.firstElementChild;if(!l)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(l,e),l},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}};var C=Ot;var Et="hha:upgrade-check:";function x(e,t){let r=e.querySelector(`meta[name="${t}"]`),l=r?r.getAttribute("content"):null;return l&&l.trim()?l.trim():null}function ce(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function Nt(e,t){let r=ce(e),l=ce(t);if(!r||!l)return!1;let n=Math.max(r.length,l.length);for(let o=0;o<n;o++){let i=r[o]||0,a=l[o]||0;if(i!==a)return i>a}return!1}function kt(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function St(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function Rt({force:e=!1,doc:t,loc:r,fetchFn:l,now:n,ttlMs:o=864e5}={}){if(t=t||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),l=l||(d=>fetch(d)),n=n??Date.now(),!t)return null;let i=x(t,"hyper-source");if(!i)return null;let a=x(t,"hyper-version"),s;try{s=new URL(i,r?r.href:void 0)}catch{return null}if(r&&s.origin===r.origin&&s.pathname===r.pathname)return null;let u=`${Et}${s.href}:${a||"none"}`,c,f=e?null:kt(u);if(f&&typeof f.checkedAt=="number"&&n-f.checkedAt<o)c=f.sourceVersion;else{try{let d=await l(s.href);if(!d.ok)throw new Error(`HTTP ${d.status}`);let m=await d.text(),p=new DOMParser().parseFromString(m,"text/html");c=x(p,"hyper-version")}catch{c=null}St(u,{checkedAt:n,sourceVersion:c})}return c?{available:Nt(c,a||"0.0.0"),currentVersion:a,sourceVersion:c,sourceUrl:s.href}:null}var $t="script[data-rules-name]";function Ct(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function ke(e,t){let r=e.find(t,$t,{includeRulesTag:!0}),l=new Set,n=[];for(let o of r){let i=Ct(e.attr(o,"data-rules-name"));if(!i)continue;if(l.has(i)){console.warn(`hyper-html-api: duplicate rules tag name "${i}"; using the first.`);continue}let a=e.attr(o,"data-rules-version");if(a!==wt)throw new he(a);l.add(i),n.push({name:i,rules:gt(e.text(o))})}return n}function Se(e,t){let r={};for(let{name:l,rules:n}of ke(e,t))r[l]=Ae(e,t,n);return r}function Lt(e){let t=e||document,r=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:Se(C,t),version:x(r,"hyper-version")}}var fe=class extends Error{constructor(e,t){super(`could not fetch upgrade source: ${e}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=e,this.cause=t}},jt=class extends Error{constructor(e){super(`upgrade source has no rules tags; refusing to drop all existing data: ${e}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=e}},F=class extends Error{constructor(e,t){super(e),this.name="UpgradeTransformInvalid",this.cause=t}},Mt=class extends Error{constructor(e){super(`found ${e} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=e}},Ut="text/hyper-upgrade";function It(e,t){let r=e.find(t,`script[type="${Ut}"]`);if(r.length===0)return null;if(r.length>1)throw new Mt(r.length);return e.text(r[0])||null}var Pt=new Function("url","return import(url)");async function Dt(e){let t=new Blob([e],{type:"text/javascript"}),r=URL.createObjectURL(t),l;try{l=await Pt(r)}catch(n){throw new F(`transform failed to load: ${n&&n.message?n.message:n}`,n)}finally{URL.revokeObjectURL(r)}if(typeof l.default!="function")throw new F("transform must `export default` a function");return l.default}function Re(e,t){let r={carriedOver:0,discarded:0,listItems:0},l=z(t,e,r);return _(t,e,r),{data:l,summary:r}}function z(e,t,r,l=!1){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(r.listItems+=t.length,r.carriedOver+=t.length,t):l?[]:void 0:t==null||typeof t=="object"?l&&!Bt(e)?null:void 0:(r.carriedOver++,t);if(Array.isArray(e)){let[,n]=e;return Array.isArray(t)?(r.listItems+=t.length,t.map(o=>z(n,o,r,!0))):l?[]:void 0}if(typeof e=="object"&&e!==null){let n={};for(let[o,i]of Object.entries(e)){let a=z(i,t?.[o],r,l);a!==void 0&&(n[o]=a)}return n}}function Bt(e){let t=U(e);return t!==-1&&de.has(e.slice(t+1))}function _(e,t,r){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let l=new Set(Object.keys(e));for(let n of Object.keys(t))l.has(n)?_(e[n],t[n],r):r.discarded+=$(t[n]);return}if(Array.isArray(e)&&Array.isArray(t)){let l=e[1];t.forEach(n=>_(l,n,r));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(r.discarded+=$(t))}}function $(e){return e==null?0:Array.isArray(e)?e.reduce((t,r)=>t+$(r),0):typeof e=="object"?Object.values(e).reduce((t,r)=>t+$(r),0):1}function Ht(e,t,r){let l=ke(e,t),n={carriedOver:0,discarded:0,listItems:0},o={},i=new Set;for(let{name:a,rules:s}of l){if(i.add(a),!Object.prototype.hasOwnProperty.call(r,a)){o[a]={carriedOver:0,discarded:0,listItems:0};continue}let{data:u,summary:c}=Re(r[a],s);ht(e,t,s,u,{templateAttr:"cms-template"}),o[a]=c,n.carriedOver+=c.carriedOver,n.discarded+=c.discarded,n.listItems+=c.listItems}for(let a of Object.keys(r))i.has(a)||(n.discarded+=$(r[a]));return{totals:n,byName:o,rulesTagCount:l.length}}async function qt({sourceUrl:e,dataByName:t,fromVersion:r,doc:l,loc:n,fetchFn:o}={}){if(l=l||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(h=>fetch(h)),!l)throw new Error("upgrade.run requires a document context");if(e=e||x(l,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let i=new URL(e,n?n.href:void 0);r=r!==void 0?r:x(l,"hyper-version"),t=t||Se(C,l);let a;try{a=await o(i.href)}catch(h){throw new fe(i.href,h)}if(!a.ok)throw new fe(i.href,new Error(`HTTP ${a.status}`));let s=await a.text(),u=new DOMParser().parseFromString(s,"text/html"),c=x(u,"hyper-version"),f=t,d=!1,m=It(C,u);if(m){let h=await(await Dt(m))(f,{fromVersion:r,toVersion:c});if(!h||typeof h!="object"||Array.isArray(h))throw new F("transform must return a plain object map of { rulesName: data }");f=h,d=!0}let{totals:p,byName:w,rulesTagCount:v}=Ht(C,u,f);if(v===0&&Object.keys(f).length>0)throw new jt(i.href);return{html:Vt(u),fromVersion:r,toVersion:c,summary:{transformApplied:d,totals:p,byName:w}}}function Wt(e){for(let t of e.querySelectorAll("input")){let r=(t.getAttribute("type")||"").toLowerCase();r!=="file"&&(r==="checkbox"||r==="radio"?t.checked!==t.hasAttribute("checked")&&t.toggleAttribute("checked",t.checked):t.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",t.value))}for(let t of e.querySelectorAll("textarea"))t.value!==t.textContent&&(t.textContent=t.value);for(let t of e.querySelectorAll("select")){let r=[...t.options];if(!t.multiple){let l=r.findIndex(n=>n.hasAttribute("selected"));if(t.selectedIndex===l||l===-1&&t.selectedIndex<=0)continue}for(let l of r)l.selected!==l.hasAttribute("selected")&&l.toggleAttribute("selected",l.selected)}}function Vt(e){return Wt(e),`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
2
|
-
`+e.documentElement.outerHTML}var I={checkForUpdate:Rt,run:qt,extractAll:Lt,shapeMatch:Re};var A="The new version could not be downloaded. Nothing was changed.",P="The upgrade could not be saved. Nothing was changed.",Le="This document changed somewhere else. Reload and try again.",Ft="Something else is changing this document. Nothing was changed.",zt="This document does not say which parts are its data, so it cannot be upgraded safely. Nothing was changed.",_t="The new version has no place for this page's content. Nothing was changed.";async function Jt(e){let t=globalThis.crypto&&globalThis.crypto.subtle;if(!t)return null;let r=await t.digest("SHA-256",e);return[...new Uint8Array(r)].map(l=>l.toString(16).padStart(2,"0")).join("")}async function $e(e,t){try{let r=await e(t,{credentials:"omit"});return!r||!r.ok?null:r}catch{return null}}function Yt(e,t,r){if(e&&typeof e.latestUrl=="string"&&e.latestUrl)return e.latestUrl;let l=x(t,"hyper-source");if(!l)return null;try{let n=new URL(l,r?r.href:void 0);return n.pathname=n.pathname.replace(/\.html$/,".json"),n.href}catch{return null}}function Gt(e){let t=x(e,"clay-template");if(!t)return null;let[r,l]=t.split(/\s+/);return r&&l?{id:r,variant:l}:null}function D(e,t="",r=[]){if(Array.isArray(e)){for(let l of e)D(l,`${t}[]`,r);return r}if(e&&typeof e=="object"){for(let[l,n]of Object.entries(e))D(n,t?`${t}.${l}`:l,r);return r}return e!=null&&r.push({path:t,value:e}),r}function Xt(e,t){let r=[e];for(let l of String(t).split(".")){let n=l.endsWith("[]"),o=n?l.slice(0,-2):l,i=[];for(let a of r){let s=o?a?.[o]:a;n?Array.isArray(s)&&i.push(...s):i.push(s)}r=i}return r}function Kt(e,t,r={}){let l=new Map;for(let{path:o,value:i}of D(t)){let a=`${o}\0${String(i)}`;l.set(a,(l.get(a)||0)+1)}let n=[];for(let{path:o,value:i}of D(e)){let a=`${o}\0${String(i)}`;if(l.get(a)>0){l.set(a,l.get(a)-1);continue}let s=r[o];typeof s=="string"&&Xt(t,s).some(u=>u===i)||n.push({path:o,value:i})}return n}async function Zt(e){let t=new Blob([e],{type:"text/javascript"}),r=URL.createObjectURL(t);try{return await new Function("url","return import(url)")(r)}finally{URL.revokeObjectURL(r)}}async function Qt(e){let r=new DOMParser().parseFromString(e,"text/html").querySelector('script[type="text/hyper-upgrade"]');if(!r)return{};let l=await Zt(r.textContent||"");return l&&l.renames&&typeof l.renames=="object"?l.renames:{}}var Ce='script[clay~="live"][merge]';function er(e,t,r){let l=t.querySelector("article[data-blockeditor]");if(!l)return null;l.replaceWith(t.importNode(r,!0));for(let o of e.querySelectorAll(Ce)){let i=o.getAttribute("merge");if(i!=="blockeditor"&&!i.startsWith("blockeditor."))continue;let a=t.importNode(o,!0),s=[...t.querySelectorAll(Ce)].find(u=>u.getAttribute("merge")===i);s?s.replaceWith(a):t.querySelector("article[data-blockeditor]").after(a)}return(t.doctype?`<!DOCTYPE ${t.doctype.name}>
|
|
3
|
-
`:"")+t.documentElement.outerHTML}async function je(e,{doc:t=document,loc:r=location,fetchFn:l=(n,o)=>fetch(n,o)}={}){if((typeof window<"u"&&window.clay||{}).isDraftMode)return{ok:!1,code:"draft"};if(!e||typeof e.version!="string")return{ok:!1,code:"unavailable",message:A};let o=Yt(e,t,r);if(!o)return{ok:!1,code:"unavailable",message:A};let i=await $e(l,o);if(!i)return{ok:!1,code:"unavailable",message:A};let a;try{a=await i.json()}catch{return{ok:!1,code:"unavailable",message:A}}if(!a||typeof a!="object")return{ok:!1,code:"unavailable",message:A};let s=Gt(t);if(!s||a.id!==s.id||a.variant!==s.variant)return{ok:!1,code:"template",message:"This upgrade is for a different document."};let u=x(t,"hyper-version");if(!u||typeof a.version!="string"||!K(a.version,u))return{ok:!1,code:"not-newer",message:"There is no newer version to install."};if(typeof a.html!="string"||!a.html)return{ok:!1,code:"unavailable",message:A};let c;try{c=new URL(a.html,o).href}catch{return{ok:!1,code:"unavailable",message:A}}if(!/^https:\/\/hyperclay\.com\/templates\//.test(c))return{ok:!1,code:"source",message:"This upgrade is not from the template host."};let f=await $e(l,c);if(!f)return{ok:!1,code:"unavailable",message:A};let d;try{d=await f.text()}catch{return{ok:!1,code:"unavailable",message:A}}let m=await Jt(new TextEncoder().encode(d));if(!m||m!==String(a.sha256||"").toLowerCase())return{ok:!1,code:"unavailable",message:A};let p,w;try{w=await Qt(d),p=await I.run({sourceUrl:c,doc:t,loc:r,fromVersion:u,fetchFn:async()=>({ok:!0,status:200,text:async()=>d})})}catch(T){return{ok:!1,code:"transform",message:T&&T.message?T.message:A}}let v=new DOMParser().parseFromString(p.html,"text/html"),h=I.extractAll(t).dataByName,y=t.querySelector("article[data-blockeditor]");if(!y&&!Object.keys(h||{}).length)return{ok:!1,code:"undeclared",message:zt};let g=p.html;if(y){let T=er(t,v,y);if(!T)return{ok:!1,code:"lost",lost:[],discarded:0,message:_t};g=T}let b=I.extractAll(v).dataByName,E=Kt(h,b,w),N=p.summary&&p.summary.totals&&p.summary.totals.discarded||0;return E.length||N>0?{ok:!1,code:"lost",lost:E,discarded:N,message:tr(E,N)}:{ok:!0,html:g,version:p.toVersion||a.version}}function tr(e,t){let r=e.slice(0,5).map(({path:n})=>n),l=e.length>r.length?` and ${e.length-r.length} more`:"";return r.length?`This upgrade would lose data: ${r.join(", ")}${l}. Nothing was changed.`:`This upgrade would lose ${t} value${t===1?"":"s"}. Nothing was changed.`}function rr(e){let t=e&&e.state;if(t==="conflict")return{ok:!1,code:"conflict",message:Le};let r=e&&e.message?e.message:"The document could not be saved.";return{ok:!1,code:"flush",state:t||"failed",message:r}}async function Me(e,{doc:t=document,loc:r=location,fetchFn:l=(s,u)=>fetch(s,u),clay:n=typeof window<"u"?window.clay:null,reload:o=()=>window.location.reload(),replace:i=null,etag:a}={}){if((n||{}).isDraftMode)return{ok:!1,code:"draft"};let u=G("upgrade");if(!u)return{ok:!1,code:"busy",message:Ft};try{return await nr(e,{doc:t,loc:r,fetchFn:l,clay:n,reload:o,replace:i,etag:a})}finally{X(u)}}async function nr(e,{doc:t,loc:r,fetchFn:l,clay:n,reload:o,replace:i,etag:a}){let s=n||{};if(s.isEditMode&&s.save&&typeof s.save.flush=="function"){let p;try{p=await s.save.flush()}catch(w){return rr(w)}if(p&&typeof p.state=="string"&&p.state!=="saved"&&p.state!=="clean"&&p.state!=="view")return{ok:!1,code:"flush",state:p.state,message:"This document has changes that could not be saved. Nothing was changed."}}if(a===void 0&&!B())try{await Y()}catch{}let u=a!==void 0?a:B(),c=t;if(s.isEditMode&&typeof s.getHTML=="function")try{c=new DOMParser().parseFromString(await s.getHTML(),"text/html")}catch{return{ok:!1,code:"failed",message:P}}else c=new DOMParser().parseFromString(`<!DOCTYPE html>
|
|
4
|
-
`+t.documentElement.outerHTML,"text/html");let f=await je(e,{doc:c,loc:r,fetchFn:l});if(!f.ok)return f;let d=typeof i=="function"?i:s.save&&typeof s.save.replace=="function"?s.save.replace:Z,m;try{m=await d(f.html,{etag:u})}catch{return{ok:!1,code:"failed",message:P}}if(!m||!m.ok){let p=m&&m.code?m.code:"failed";return p==="conflict"?{ok:!1,code:p,message:Le}:p==="forbidden"?{ok:!1,code:p,message:"You are not allowed to save this document."}:p==="unsupported"?{ok:!1,code:p,message:"This host cannot save the upgrade."}:{ok:!1,code:p,message:P}}return o(),{ok:!0,html:f.html,version:f.version,etag:m.etag}}function O(e,t,r={}){let l=e.createElement(t);l.setAttribute("clay","editor-ui");for(let[n,o]of Object.entries(r))n==="style"?l.setAttribute("style",o):n==="text"?l.textContent=o:l.setAttribute(n,o);return l}function lr(e){let r=(e&&e.pathname?e.pathname:"/").split("/").filter(Boolean).pop()||"page.html";try{r=decodeURIComponent(r)}catch{}return/\.html?$/i.test(r)?r:`${r}.html`}async function or(e,{loc:t=location,fetchFn:r=(l,n)=>fetch(l,n)}={}){if(typeof e.getHTML=="function")return e.getHTML();let l=await r(t.href,{cache:"no-store",credentials:"same-origin"});if(!l.ok)throw new Error(`copy fetch ${l.status}`);return l.text()}async function ir({clay:e,doc:t=document,loc:r=location,fetchFn:l}={}){if(typeof URL>"u"||typeof URL.createObjectURL!="function")return!1;try{let n=await or(e,{loc:r,fetchFn:l});if(typeof n=="string"&&/clay|data-paid-only/i.test(n)){let{stripCopyContent:a}=await import("./c-C4IIQZGJ.js");n=a(n)}let o=URL.createObjectURL(new Blob([n],{type:"text/html"})),i=t.createElement("a");return i.setAttribute("clay","editor-ui"),i.href=o,i.download=lr(r),i.style.setProperty("display","none","important"),t.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(o),4e4),!0}catch{return!1}}async function ar(e){let t=e&&e.host;if(!t||!t.versions)return!1;try{return await t.versions===!0}catch{return!1}}async function sr(e,t={}){let r=t.doc||document,l=t.clay||(typeof window<"u"?window.clay:null)||{};if(l.isDraftMode||!e||typeof e.version!="string")return null;let n=await ar(l),o=O(r,"div",{role:"dialog","aria-modal":"true","data-clay-upgrade":"",style:"position:fixed;inset:0;z-index:2147483000;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(15,17,21,.42);font-family:system-ui,-apple-system,'Segoe UI',sans-serif;"}),i=O(r,"div",{style:"width:min(460px,100%);padding:20px;border-radius:14px;background:var(--clay-ui-bg,#fff);color:var(--clay-ui-fg,#1f2328);box-shadow:0 18px 48px -16px rgba(0,0,0,.55);font-size:14px;line-height:1.5;"}),a=O(r,"h2",{text:`Upgrade to version ${e.version}`,style:"margin:0 0 8px;font-size:16px;"}),s=O(r,"p",{text:`Your data moves into version ${e.version}. The page's layout and code are replaced; your current version stays in this document's history.`,style:"margin:0 0 16px;"}),u=O(r,"p",{role:"status",style:"margin:0 0 12px;min-height:1.5em;"}),c=O(r,"div",{style:"display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end;"}),f="padding:7px 12px;border-radius:8px;border:1px solid rgba(23,28,36,.2);background:transparent;color:inherit;font:inherit;cursor:pointer;",d=O(r,"button",{type:"button",text:"Cancel",style:f}),m=n?null:O(r,"button",{type:"button",text:"Download a copy first",style:f}),p=O(r,"button",{type:"button",text:"Upgrade",style:`${f}border-color:transparent;background:#2f6fed;color:#fff;font-weight:600;`});n||(p.disabled=!0),m&&c.append(m),c.append(d,p),i.append(a,s,u,c),o.append(i),r.body.appendChild(o);let w=!1,v=()=>{w||(w=!0,o.remove())};m&&m.addEventListener("click",async()=>{await ir({clay:l,doc:r,loc:t.loc,fetchFn:t.fetchFn})?(p.disabled=!1,u.textContent="Your copy was downloaded."):u.textContent="The copy could not be downloaded. Nothing was changed."}),d.addEventListener("click",v);let h,y=new Promise(g=>{h=g});return p.addEventListener("click",async()=>{p.disabled=!0,m&&(m.disabled=!0),u.textContent=`Upgrading to version ${e.version}\u2026`;let g=await Me(e,t);if(g.ok){v(),h(g);return}u.textContent=g.message||P,p.disabled=!1,m&&(m.disabled=!1),h(g)}),{root:o,title:a,body:s,status:u,cancel:d,download:m,upgrade:p,close:v,done:y}}export{Me as apply,je as prepare,sr as start};
|
package/dist/m/c-LO4C4J77.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as r}from"./c-WYFDLITL.js";import{a as p}from"./c-LA2BW7UY.js";import{f as u}from"./c-DLBX4JCJ.js";import{n as d,o as l}from"./c-ICMAOOGK.js";var n=0,g=0,c=!1,m=!1,y=!1,i=!1;function o(){!u||i||(i=!0,queueMicrotask(()=>{if(i=!1,typeof document>"u")return;let e=C();if(e===y)return;y=e;let t=document.documentElement;e?t.setAttribute("unsaved","true"):t.removeAttribute("unsaved"),document.dispatchEvent(new CustomEvent(e?"clay:dirty":"clay:clean"))}))}var T=`input${r}, textarea${r}, select${r}`,h=`${d}, ${l}`,a=new WeakMap;function v(){let e=[];for(let t of document.querySelectorAll(T))t.closest(h)||e.push(t);return e}function E(e){let t=e.target;!t||t.nodeType!==1||(t.matches("input, textarea, select")||t.isContentEditable)&&(t.closest(h)||(n++,o()))}function x(){m||(m=!0,p.onAnyChange({omitChangeDetails:!0,require:"dirty"},()=>{c||(n++,o())}),document.addEventListener("input",E,!0),document.addEventListener("change",E,!0))}function L(){c=!0}function k(){c=!1}function f(e){return e instanceof HTMLSelectElement?Array.from(e.selectedOptions,t=>t.value).join("\0"):e instanceof HTMLInputElement&&(e.type==="checkbox"||e.type==="radio")?e.checked?"1":"0":e.value}function M(e){return e instanceof HTMLSelectElement?Array.from(e.options).every(t=>t.selected===t.defaultSelected):e instanceof HTMLInputElement?e.type==="checkbox"||e.type==="radio"?e.checked===e.defaultChecked:e.value===e.defaultValue:e instanceof HTMLTextAreaElement?e.hasAttribute("data-value")?e.value===e.getAttribute("data-value"):e.value===e.defaultValue:!0}function S(){for(let e of v()){let t=f(e);if(a.get(e)!==t){if(M(e)){a.set(e,t);continue}return!0}}return!1}function C(){return n>g||S()}function D(){return n}function O(){let e=[];for(let t of v())e.push([t,f(t)]);return{gen:n,probe:e}}function b(){n++,o()}function H(e){if(e){n===e.gen&&(g=e.gen);for(let[t,s]of e.probe)f(t)===s&&a.set(t,s);o()}}typeof document<"u"&&u&&x();typeof window<"u"&&(window.clay=window.clay||{},window.clay.markDirty=b);export{x as a,L as b,k as c,C as d,D as e,O as f,b as g,H as h};
|
package/dist/m/c-N7JPUPGC.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var f=/^[A-Za-z0-9._-]{1,100}$/,c="visitor-drafts",d="visitor-drafts",l=!1,u=null,i=!1,s=(t,e)=>(t?.get?.(e)||"").split(",").map(r=>r.trim()).includes(d);function h(t){l=s(t,"plugins")&&!s(t,"exclude")}function p(t=document){let e=t.documentElement.getAttribute(c);return e&&f.test(e)?e:null}var a=!1;function x(t){let e=t.querySelector('script[data-rules-name~="api"]');if(!e)return!1;let r=e.getAttribute("data-rules-version"),n=null;if(r!=="1")n=`the api rules tag says data-rules-version="${r??""}" and this version reads version 1`;else try{JSON.parse(e.textContent)}catch{n="the api rules tag does not hold readable JSON"}return n?(a||(a=!0,console.warn(`visitor-drafts: this page keeps no draft (${n})`)),!1):!0}function g(t=document,e=window.location){return l&&(e.protocol==="https:"||e.protocol==="http:")&&p(t)!==null&&x(t)}function v(t){u=t}function m(){return u}var o=null;function S(t){o=t}function T(){if(!o)return!0;try{return o()!==!1}catch{return!1}}function A(t){i=!!t}function D(){return i}export{c as a,d as b,h as c,p as d,g as e,v as f,m as g,S as h,T as i,A as j,D as k};
|
package/dist/m/c-NEXFVJIT.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as a,f as b,g as c}from"./c-PVJMJL3P.js";import"./c-WN3MXOLT.js";import"./c-RBPZNU2D.js";import"./c-DLBX4JCJ.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{a as PresenceStore,c as default,b as presence};
|
package/dist/m/c-R23UHMXG.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as b,b as c,c as d,d as e,e as f}from"./c-2PVGJFI5.js";import{g as a}from"./c-CV4T65JE.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-DD26VXAP.js";import"./c-CTGRDT6E.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-ZRGEN6QQ.js";import"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import"./c-RETTCOWO.js";import"./c-WCG6AKA7.js";import"./c-57XDY6HC.js";import"./c-I2SCCUEW.js";import"./c-VHNSBD2M.js";export{e as ChartView,d as chartFromSlash,a as chartTables,b as insertChartAfterTable,f as refreshCharts,c as tableLabel};
|
package/dist/m/c-T527QHOB.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a}from"./c-DZPO22O3.js";import"./c-HSNGLIFB.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-RXTPKCMC.js";import"./c-RBPZNU2D.js";import"./c-IJUK2GPW.js";import"./c-DLBX4JCJ.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-PWJSJEJU.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{a as replace};
|
package/dist/m/c-V2U3F4QX.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as y}from"./c-QTEUO2K6.js";import{a as i,e as s,f as h,g as u,h as m,k as v}from"./c-DIKR7H57.js";import{b as r,c,d as p,e as d,f}from"./c-CUMXGHVD.js";import"./c-QY7F6EN6.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";function g(){let t=()=>{let o=d()&&c(d());document.dispatchEvent(new CustomEvent("clay:variant-change",{detail:{active:o,shown:o}}))},e=o=>r().some(n=>c(n)===o)?(document.documentElement.setAttribute("look",o),f(o),window.clay?.save?.soon?.(),t(),{ok:!0}):{ok:!1,code:"unknown-variant"};r().length>=2&&(window.clay.variants={list:()=>r().map(o=>({name:c(o),label:p(o),active:o===d()})),get active(){return d()&&c(d())},get shown(){return d()&&c(d())},preview:e,choose:e,keep:()=>Promise.resolve({ok:!1,code:"not-editing"})},document.addEventListener("clay:drafts-restored",()=>{t()}))}var L='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round" aria-hidden="true"><path d="M12 9a3 3 0 1 1 0 6 3 3 0 0 1 0-6M10 3h4l1.5 3 3.5-.5 2 4-2 2.5 2 2.5-2 4-3.5-.5-1.5 3h-4l-1.5-3-3.5.5-2-4 2-2.5-2-2.5 2-4 3.5.5Z"/></svg>',w=()=>window.clay?.blockeditor?.history??window.clay?.undo??null;function S({addItem:t,beforeOpen:e}){let o=null,n=()=>{let a=w();if(!a)return;let l=o??{canUndo:!!a.canUndo,canRedo:!!a.canRedo};t({id:"clay.undo",pair:[{id:"clay.undo.undo",label:"Undo",keys:y("\u2318Z","Ctrl+Z"),disabled:!l.canUndo,run:()=>w()?.undo()},{id:"clay.undo.redo",label:"Redo",keys:y("\u2318\u21E7Z","Ctrl+Shift+Z"),disabled:!l.canRedo,run:()=>w()?.redo()}]})};document.addEventListener("clay:undo-change",a=>{o={canUndo:!!a.detail?.canUndo,canRedo:!!a.detail?.canRedo},n()}),n(),e.push(n)}function R(t=window.location){let e=t.pathname.replace(/\/+$/,"")||"/";return`/_/copy${e==="/"?"":e}`}function N(){if(document.querySelector('clay-editor-ui[data-clay-ui="menu"]'))return;let t=v({sections:[["clay.undo"],null],icon:L,label:"Settings"}),{embedded:e,skin:o,addItem:n,removeItem:a,open:l,close:k,note:b,goo:E,beforeOpen:U}=t;t.mount(e?[i,s,o??u,m]:[i,s,h,u,m]),g(),S({addItem:n,beforeOpen:U}),n({id:"clay.download",label:"Download copy",run:()=>window.clay.visitorDrafts.download()}),n({id:"clay.copy",label:"Make your own copy",href:R()}),window.clay.menu={addItem:n,removeItem:a,open:l,close:k,note:b,embedded:e,button:E},document.dispatchEvent(new CustomEvent("clay:menu-ready"))}export{N as start};
|
package/dist/m/c-VG5XIN4T.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as h}from"./c-2YYDMLNZ.js";var p="sap-error",S=/^(show-when|hide-when|option|option-not):/,m=new Set(["id","data-id","class","style","sap","scope","items","item","bind","state","template","cms-template","sap-ignore"]),v=new Set(["value","checked","selected"]);function b(t){return t.hasAttribute("bind")||t.hasAttribute("persist")||!!t.closest("select[bind]")}function g(t){return t.localName==="template"||t.hasAttribute("template")||t.hasAttribute("cms-template")||t.hasAttribute("sap-ignore")}function a(t,e=null){let s=null;for(let r=t;r&&r.nodeType===1;r=r.parentElement){if(g(r))return null;if(r.hasAttribute("sap"))return r;s=r}return e&&s&&!s.isConnected?a(e):null}function A(t,e){let s=t.getAttribute("state");if(!s)return!1;for(let r of s.trim().split(/\s+/))if(r.split("=")[0].split(":")[0]===e)return!0;return!1}function y(t){if(t.hasAttribute("show"))return!0;for(let e of t.attributes)if(S.test(e.name))return!0;return!1}function x(t,e,s=null){return!t||t.nodeType!==1||!e?!1:e===p?!!a(t,s):m.has(e)||v.has(e)&&b(t)?!1:e==="hidden"?y(t)&&!!a(t,s):t.hasAttribute("attr:"+e)&&!A(t,e)&&!!a(t,s)}function f(t){if(!t||t.nodeType!==1||!a(t))return null;let e=null,s=(r,n)=>(e||(e={attrs:[],classes:[],vars:[],text:!1}))[r].push(n);for(let r of t.attributes){let n=r.name;if(n==="text"||n.startsWith("text:"))t.hasAttribute("bind")||((e||(e={attrs:[],classes:[],vars:[],text:!1})).text=!0);else if(n.startsWith("attr:")){let i=n.slice(5);i&&!m.has(i)&&!(v.has(i)&&b(t))&&!A(t,i)&&s("attrs",i)}else n.startsWith("class:")?s("classes",n.slice(6)):n.startsWith("css:")&&s("vars","--"+n.slice(4))}return y(t)&&s("attrs","hidden"),t.hasAttribute(p)&&s("attrs",p),e}function d(t,e){if(!t||t.nodeType!==1&&t.nodeType!==9)return;let s=t.nodeType===1&&t.hasAttribute("sap")?[t]:[...t.querySelectorAll("[sap]")].filter(r=>!r.parentElement||!r.parentElement.closest("[sap]"));for(let r of s)for(let n of[r,...r.querySelectorAll("*")]){let i=f(n);i&&e(n,i)}}function w(t){d(t,(e,s)=>{for(let r of s.attrs)e.hasAttribute(r)&&e.removeAttribute(r);for(let r of s.classes)e.classList.contains(r)&&e.classList.remove(r);!e.getAttribute("class")&&e.hasAttribute("class")&&s.classes.length&&e.removeAttribute("class");for(let r of s.vars)e.style.getPropertyValue(r)!==""&&e.style.removeProperty(r);s.vars.length&&e.hasAttribute("style")&&!e.getAttribute("style").trim()&&e.removeAttribute("style"),s.text&&e.firstChild&&e.replaceChildren()})}var P=(t,e,s=null)=>x(t,e,s),O=t=>!!t&&t.nodeType===1&&!!f(t)?.text,V=t=>w(t);function D(t){let e=[];return d(t,(s,r)=>{e.push(s.localName);for(let n of r.attrs)n!=="sap-error"&&e.push(n+"="+(s.getAttribute(n)??"\0"));for(let n of r.classes)e.push("."+n+"="+s.classList.contains(n));for(let n of r.vars)e.push(n+"="+s.style.getPropertyValue(n));r.text&&e.push("#"+s.textContent)}),e.join("")}function j(t){return D(new DOMParser().parseFromString(t,"text/html"))}function T(t,e,s,r,n){return s(t||"").map(i=>i.trim()).filter(i=>i&&!e.includes(n(i))).sort().join(r)}function E(t,e,s,r){let n=f(t);if(!n)return!1;if(e==="class"){if(!n.classes.length)return!1;let u=o=>T(o,n.classes,l=>l.split(/\s+/)," ",l=>l);return u(s)===u(r)}if(!n.vars.length)return!1;let i=u=>T(u,n.vars,o=>o.split(";"),";",o=>o.split(":")[0].trim());return i(s)===i(r)}function q(t){if(t.__derived!==void 0)return t.__derived;let e=t.element,s=!1;if(e&&e.nodeType===1)if(t.type==="attribute"){let r=t.attribute;s=P(e,r)||(r==="class"||r==="style")&&E(e,r,t.oldValue,t.newValue)}else t.type==="characterData"&&(s=O(e));return t.__derived=s,s}var c=new Set,_=!1;function F(){return c.size>0||h.holdSettle}var C=[];function H(){for(let t of[...c])try{t()}catch(e){console.error("clayjs: a derived repaint failed:",e)}}var L={register(t){return c.add(t),()=>c.delete(t)},mounted(){_=!0;for(let t of C.splice(0))t()}};export{P as a,O as b,V as c,D as d,j as e,q as f,F as g,H as h,L as i};
|
package/dist/m/c-YINHPF4V.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as ce,b as Qe,c as ue,e as fe,f as pe,g as nt}from"./c-P5NKFRL4.js";import{a as Ze,b as et,c as de,d as tt}from"./c-LZJPNR2W.js";import{a as A,b as J}from"./c-QTTJYJMA.js";import{b as Ke}from"./c-5VYOWDTI.js";import{b as oe,c as ae,d as x,f as he,g as Ve,h as Xe}from"./c-LO4C4J77.js";import{a as q}from"./c-LA2BW7UY.js";import{a as Ge}from"./c-LD6UVV5R.js";import{a as ze,f as We,g as Ye,h as Je}from"./c-PGSBXHUE.js";import{a as se,b as $e,c as P,d as re,e as le,h as je}from"./c-RXTPKCMC.js";import{e as Ue}from"./c-RBPZNU2D.js";import{d as Pe}from"./c-IJUK2GPW.js";import{f as $,j as te}from"./c-DLBX4JCJ.js";import{a as Le}from"./c-BPF2NSPV.js";import{E as Y,F as Ne,H as T,I as Oe,b as D,j as ie,o as W,t as M,z as Be}from"./c-PWJSJEJU.js";import{a as Re,b as qe,c as Me,e as j,g as z,h as ne}from"./c-VG5XIN4T.js";import{m as Ie,n as Te}from"./c-HA6INT6J.js";import{a as He,b as Fe,l as Ce,m as Ae}from"./c-ICMAOOGK.js";function it(s){let e=new WeakMap,t=0,i=r=>e.get(r)||null,n=r=>{let l=e.get(r);return l||(l=`${s}:${++t}`,e.set(r,l)),l};return{idOf:i,ensure:n,adopt:(r,l)=>{r&&typeof l=="string"&&l&&e.set(r,l)},exportMap:(r,l)=>{let o={},a=[],h=[],c=(d,_)=>{let g=l(d);g&&(o[_]=n(g));let E=d.children;a.push(E.length),h.push(d.tagName.toLowerCase());for(let f=0;f<E.length;f++)c(E[f],_===""?String(f):`${_}.${f}`)};return c(r,""),o["~"]=a.join(","),o["^"]=h.join(","),o}}}function st(s,e){let t=new WeakMap;if(!s||!e||typeof e!="object"||Array.isArray(e))return t;let i=e["~"],n=typeof i=="string"?i.split(",").map(Number):null,r=n&&typeof e["^"]=="string"?e["^"].split(","):null,l=d=>Number.isInteger(d)&&d>=0,o=0,a=!1,h=d=>{let _=d;for(;_>0;){let g=n[o++];if(o>n.length||!l(g))return!1;_+=g-1}return!0},c=(d,_)=>{if(a)return;if(n){let f=o++,u=n[f];if(f>=n.length||!l(u)){a=!0;return}let S=!r||r[f]===d.tagName.toLowerCase();if(!S||u!==d.children.length){let w=S&&e[_];typeof w=="string"&&w&&t.set(d,w),h(u)||(a=!0);return}}let g=e[_];typeof g=="string"&&g&&t.set(d,g);let E=d.children;for(let f=0;f<E.length;f++)c(E[f],_===""?String(f):`${_}.${f}`)};return c(s,""),t}function vt(s){return e=>{for(let t of s){let i=t(e);if(typeof i=="string"&&i!=="")return i}return null}}var Bt=vt([s=>s.getAttribute("data-id"),s=>s.getAttribute("id")]);var St=/^blockeditor(\.[0-9]+)?$/,rt=s=>[...s.querySelectorAll('script[merge][clay~="live"]')].filter(e=>St.test(e.getAttribute("merge")));function lt(s,e,t){if(!s.html.includes("data-blockeditor"))return s;let i=u=>W(new DOMParser().parseFromString(u,"text/html")),n=i(s.html),r=n.querySelector("article[data-blockeditor]");if(!r)return s;let l=i(e),o=l.querySelector("article[data-blockeditor]");if(!o)return null;let a=st(n.documentElement,s.identityMap),h=(u,S)=>{let w=n.importNode(S,!0),b=a.get(u);return b&&a.set(w,b),u.replaceWith(w),w},c=h(r,o),d=new Map(rt(n).map(u=>[u.getAttribute("merge"),u]));for(let u of rt(l)){let S=u.getAttribute("merge"),w=d.get(S);w?h(w,u):c.before(n.importNode(u,!0)),d.delete(S)}for(let u of d.values())u.remove();let _=n.querySelector("head > title"),g=l.querySelector("head > title");_&&g?h(_,g):g?n.head.append(n.importNode(g,!0)):_?.remove();let E=n.documentElement,f=t.exportMap(E,u=>{let S=a.get(u);return S?(t.adopt(u,S),u):null});return{...s,html:T(E),identityMap:f}}var Et={"merge-tokens":"tokens","merge-max":"max"};function ot(s,e){if(!e.startsWith("data-")||e==="data-id"||!s?.closest)return null;for(let[t,i]of Object.entries(Et)){let n=s.closest(`[${t}]`);if(n&&n.getAttribute(t).split(/\s+/).includes(e))return i}return null}var m=null,at=null,B=new Map;function V(){return at??=Promise.all([import("./c-A5ZBFICF.js"),import("./c-EJTGYSLN.js")]).then(([s,e])=>{m={...s,beginLineageCapture:e.beginLineageCapture};for(let t of[...B.keys()])B.set(t,s.registerContext(t));return m}),at}var ht=()=>m,I={get size(){return m?m.conflicts.size:0},list(){return m?m.conflicts.list():[]},get(s){return m?m.conflicts.get(s):null},acknowledge(s,e={}){if(m)return m.conflicts.acknowledge(s,e);if(!Array.isArray(s))throw new TypeError("clay.conflicts.acknowledge needs an array of ids");return{removedIds:[],remainingIds:[]}},claim(s,e={}){if(m)return m.conflicts.claim(s,e);if(!e.owner)throw new TypeError("clay.conflicts.claim needs an owner");return{release(){}}},registerContext(s){if(m)return m.conflicts.registerContext(s);if(typeof s!="function")throw new TypeError("clay.conflicts.registerContext needs a resolver function");return B.set(s,null),()=>{let e=B.get(s);B.delete(s),e&&e()}},contextFor(s,e){return m?m.conflicts.contextFor(s,e):null},recoveryOf(s){return m?m.conflicts.recoveryOf(s):null},hasPendingApply(){return m?m.conflicts.hasPendingApply():!1}};var y=null,_e=null;function R(){return _e??=new Promise(s=>setTimeout(s,0)).then(()=>import("./c-7YETSAVY.js")).then(s=>y=s).catch(s=>{throw _e=null,s}),_e}var ve=null,ge=null;function kt(){return ge??=import("./c-NEXFVJIT.js").then(s=>ve=s.presence).catch(s=>{throw ge=null,s}),ge}var ut=te().phase==="entering";$&&!ut&&R().catch(()=>{});$&&V().catch(()=>{});var L=null,ye=null,Q=[];function ft(s){L.presence.update(s),L.editingMarker.update(s)}function xt(){return ye??=Promise.all([import("./c-75N3KG35.js"),import("./c-6UPEKW6O.js")]).then(([s,e])=>{L={presence:s.presence,editingMarker:e.editingMarker};let t=Q;Q=[];for(let i of t)ft(i);return L}).catch(s=>{throw ye=null,s}),ye}function bt(s){if(L){ft(s);return}Q.push(s),xt().catch(()=>{})}var ct=Object.freeze({bytes:null,etag:null,seq:null}),Dt=()=>({msg:"Not in edit mode",msgType:"skipped",code:null,etag:null}),pt=["[editor-ui]",'[clay~="editor-ui"]',"[save-ignore]","[snapshot-remove]","[no-snapshot]","[no-save]","[save-remove]","[freeze] *","[save-freeze] *",'[clay~="no-save"]','[clay~="no-snapshot"]','[clay~="freeze"] *',Ce,He].join(","),_t='[clay~="freeze"], [freeze], [save-freeze]';function X(s){for(let e of s.querySelectorAll(_t))e.replaceChildren();return z()&&Me(s),s}function dt(s){if(s==null)return s;let e=typeof s=="string"?new DOMParser().parseFromString(s,"text/html"):s;return ie(e),W(e),X(e),e}var It=[Ae,'[clay~="no-watch"]',"[no-watch]","[mutations-ignore]"].join(","),Tt=(s,e,t)=>Ie(s,e,t)||Fe.test(e.toLowerCase()),gt=s=>s.getAttribute("data-id")||s.getAttribute("id")||null;function Lt(s){let e=new Map,t=n=>{if(n.matches(pt))return;let r=gt(n);r&&e.set(r,(e.get(r)||0)+1);let l=n.localName==="template"&&n.content?n.content.children:n.children;for(let o of l)t(o)},i=s.nodeType===9?[s.documentElement]:s.nodeType===11?s.children:[s];for(let n of i)n&&n.nodeType===1&&t(n);return e}var Ht=s=>e=>{let t=gt(e);if(!t)return null;let i=e.getRootNode(),n=s.get(i);return n||s.set(i,n=Lt(i)),n.get(t)===1?t:null},me=s=>!!s&&typeof s=="object"&&!Array.isArray(s);function Ft(s){return typeof s!="string"||s===""?null:new DOMParser().parseFromString(s,"text/html").documentElement?.getAttribute("documentetag")||null}function Ct(s,e){e!=="live"||!s||!y||(y.enableContentEditable(s),y.enableOnClick(s),y.enableAdminInputs(s),y.enableAdminResources(s))}function At(){let{forComparison:s,forDirty:e}=Be({flushUndo:!1});return[s,e]}var Rt=1024*1024;function qt(s,e,t,i,n){let r={sender:t,identityMap:i,...n?{etag:n}:{}};return e.length<Rt?JSON.stringify({[s.snapshotKey]:e,...r}):new Blob([`{${JSON.stringify(s.snapshotKey)}:`,JSON.stringify(e),`,${JSON.stringify(r).slice(1)}`],{type:"application/json"})}var Se=class{constructor(){this.sse=null,this.currentFile=null,this.lastHtml=null,this._diskBase=null,this._diskBaseTicket=0,this._agreeSeq=0,this._saveTicket=0,this._peerBaseTicket=0,this._acceptedSaveTicket=0,this._morphTicket=0,this.clientId=this.generateClientId(),this.resumeId=null,this._savedSnapshot?.abort?.abort(),this._savedSnapshot=null,this._sendInFlight=!1,this._queuedSend=null,this._profile=null,this._profilePromise=null,this._sharedData=!1,this._sharedSync=!1,this._workerFeatures=["live-data"],this._liveData=!1,this._editing=null,this._presenceLease=null,this._presenceQuiesced=!1,this._ready=null,this._startGen=0,this.isPaused=!1,this.isDestroyed=!1,this.debug=!1,this._lane=$?"live":"saved",this._laneChosen=!1,this._snapshotHandler=null,this._hiddenHandler=null,this.lastSeenSeq=0,this._pendingHtml=null,this._pendingSeq=null,this._pendingIdentityMap=null,this._pendingEtag=null,this._pendingBy=null,this._morphInFlight=!1,this._rafHandle=null,this._represented=ct,this._handoff=null,this._handoffHeld=!1,this._pendingExternal=null,this._lastExternalSeq=0,this._saveEpoch=0,this._saveSavedHandler=null,this._saveConflictHandler=null,this._settledHandler=null,this._lastIdentityMap=null,this._applyGen=0,this._holdRetryPeer=null,this._holdRetryExt=null,this._servedFetchId=0,this._startupRetry=null,this._engineRetry=null,this._heldLive=!1,this._heldExt=!1,this.identity=it(this.clientId),this.onConnect=null,this.onDisconnect=null,this.onUpdate=null,this.onError=null,this.onNotification=null}get unresolvedConflicts(){return I.list().filter(e=>e.kind!=="apply-incomplete")}_log(e,t=null){if(!this.debug)return;let i=`[LiveSync ${new Date().toISOString()}]`;t!==null?console.log(i,e,t):console.log(i,e)}generateClientId(){return Math.random().toString(36).slice(2,11)+Date.now().toString(36)}generateResumeId(){try{let e=new Uint8Array(16);return(globalThis.crypto||window.crypto).getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}catch{return Math.random().toString(36).slice(2)+Date.now().toString(36)}}_seedBases(){if(x())return;let e=M({flushUndo:!1});this._setPeerBase(T(e),this.identity.exportMap(e,D),this._ticket()),this._setDiskBase(Y({emitForSync:!1}).forSave,this._ticket())}get lane(){return this._lane}set lane(e){this._lane=e,this._laneChosen=!0}start(e=null,{lane:t,represented:i}={}){if(this.isDestroyed=!1,(this.sse||this._snapshotHandler)&&this.cleanup(),this.currentFile=e||this.detectCurrentFile(),!this.currentFile){console.warn("[LiveSync] No file detected");return}let n=te().mode==="edit"?"live":"saved",r=this.lane==="live";this._lane=t||(this._laneChosen?this._lane:n),this.lastHtml=null,this._lastIdentityMap=null,this._peerBaseTicket=this._ticket(),this._diskBase=null,this._diskBaseTicket=this._ticket(),this._saveTicket=0,this._savedSnapshot?.abort?.abort(),this._savedSnapshot=null,this._applyGen++,this.lastSeenSeq=0,this._lastExternalSeq=0,this._represented=i?Object.freeze({bytes:i.bytes??null,etag:i.etag??null,seq:i.seq??null}):ct,this._acquireEmptySaved=r&&this.lane==="saved"&&this._represented.bytes===null,this._pendingExternal=null,this.resumeId=this.generateResumeId(),this.lane==="live"&&this._seedBases(),this.lane==="live"&&V().catch(()=>{}),console.log(`[LiveSync] Starting for: ${this.currentFile} (lane=${this.lane})`);let l=++this._startGen;if(this.lane==="live"&&!(y&&y.baselineSettled())){let o=this._applyGen,a=this._morphTicket,h=this._saveEpoch,c=this.lastHtml,d=this._diskBaseTicket,_=this._diskBase!==null;this._settledHandler=()=>{if(this._settledHandler=null,!(this.isDestroyed||this._startGen!==l)&&!Pe()&&!x()&&this._saveTicket===0&&this._morphTicket===a){if(c!==null&&this._applyGen===o&&this._saveEpoch===h&&this.lastHtml===c){let g=M({flushUndo:!1});this._setPeerBase(T(g),this.identity.exportMap(g,D),this._ticket())}_&&this._diskBaseTicket===d&&this._setDiskBase(Y({emitForSync:!1}).forSave,this._ticket())}},document.addEventListener("clay:baseline-settled",this._settledHandler,{once:!0})}this._ready=Promise.all([this.lane==="live"?R():null,this._resolveProfile()]).then(()=>{this.isDestroyed||this._startGen!==l||this.connect()}),this.lane==="live"&&(this.listenForSnapshots(),kt().then(o=>this._startPresence(o,l),()=>{}),this._saveSavedHandler=o=>{this._saveEpoch++;let a=this._saveTicket||this._ticket();this._saveTicket=0,a>this._acceptedSaveTicket&&(this._acceptedSaveTicket=a);let h=y?y.getLastSavedBytes():null;h!=null&&this._setDiskBase(h,a),this._relayCommit(o?.detail?.captureId,h)},document.addEventListener("clay:save-saved",this._saveSavedHandler),this._saveConflictHandler=o=>{let a=o.detail&&o.detail.etag;a&&queueMicrotask(()=>{this.isDestroyed||a===se()&&(y?.conflictResolvedBySync(a),this._saveAfterMerge(x(),!1))})},document.addEventListener("clay:save-conflict",this._saveConflictHandler))}cleanup(){if(this.sse&&(this.sse.close(),this.sse=null),de(),Q=[],L&&(L.presence.clear(),L.editingMarker.clear()),this._editing&&(this._editing.stop(),this._editing=null),this._presenceLease){let e=this._presenceLease;this._presenceLease=null,typeof e.stop=="function"?e.stop():e.detach()}this._lastRoster=null,this._snapshotHandler&&(document.removeEventListener("clay:snapshot-ready",this._snapshotHandler),this._snapshotHandler=null),this._saveSavedHandler&&(document.removeEventListener("clay:save-saved",this._saveSavedHandler),this._saveSavedHandler=null),this._saveConflictHandler&&(document.removeEventListener("clay:save-conflict",this._saveConflictHandler),this._saveConflictHandler=null),this._settledHandler&&(document.removeEventListener("clay:baseline-settled",this._settledHandler),this._settledHandler=null),this._hiddenHandler&&(document.removeEventListener("visibilitychange",this._hiddenHandler),document.removeEventListener("clay:workspace-background",this._hiddenHandler),this._hiddenHandler=null),this._queuedSend=null,this._rafHandle!=null&&(this._cancelFrame(this._rafHandle),this._rafHandle=null),this._pendingHtml=null,this._pendingSeq=null,this._pendingIdentityMap=null,this._pendingBy=null,this._pendingExternal=null,this._handoff=null,this._handoffHeld=!1,clearTimeout(this._holdRetryPeer),clearTimeout(this._holdRetryExt),this._holdRetryPeer=null,this._holdRetryExt=null,clearTimeout(this._startupRetry),this._startupRetry=null,clearTimeout(this._engineRetry),this._engineRetry=null,this._servedFetchId++}detectCurrentFile(){let e=window.location.pathname;if(e==="/")return"index.html";e=e.replace(/^\//,"");let t=e.match(/^(.*?\.html(?:clay)?)/);return t?t[1]:e}_resolveProfile(){return this._profilePromise||(this._profilePromise=nt().then(e=>(this._sharedData=e.sharedData,this._sharedSync=e.sharedSync,this._liveData=e.liveData,this._workerFeatures=e.workerFeatures,this._profile=e.profile,this._log(`Wire profile: ${e.profile.name}`),e.profile))),this._profilePromise}_setHeld(e,t,i){let n=e==="live"?"_heldLive":"_heldExt";this[n]!==t&&(this[n]=t,!t&&!this._heldLive&&!this._heldExt&&je({fresh:!0,clearIfMissing:!1}),document.dispatchEvent(new CustomEvent(t?"clay:sync-held":"clay:sync-resumed",{detail:{lane:e,el:i||null}})))}_applyEtagFrame(e){return typeof e.etag!="string"||typeof e.html=="string"?!1:(this._log("Dropping a stamp that arrived with no document: nothing proves this tab holds those bytes"),!0)}connect(){if(this.isDestroyed)return;let t=(this._profile||pe.legacy).streamPath(window.location.href,this.lane,this.resumeId,this.clientId);this._hiddenHandler||(this._hiddenHandler=()=>{this._rafHandle==null||!ce()||(this._cancelFrame(this._rafHandle),this._rafHandle=null,this._scheduleNextFrame())},document.addEventListener("visibilitychange",this._hiddenHandler),document.addEventListener("clay:workspace-background",this._hiddenHandler)),this.sse=new Qe(new URL(t,window.location.origin).href,{shared:this._sharedSync,sharedData:this._sharedData,workerFeatures:this._workerFeatures,documentURL:window.location.href,lane:this.lane,clientId:this.clientId,keepAliveWhenHidden:this.lane!=="live"?!1:this._liveData?!0:"shared",startupCheck:!!Le}),this._acquireEmptySaved&&(this._acquireEmptySaved=!1,this._fetchServedDocument(void 0,{repair:!0})),this.sse.onopen=()=>{console.log("[LiveSync] Connected"),this._editing&&this._editing.reconnected(),ve&&ve.reconnect(),this.onConnect&&this.onConnect()},this.sse.addEventListener("open",()=>et({clientId:this.clientId,lane:this.lane})),this.sse.addEventListener("error",()=>de());for(let i of Ze)this.sse.addEventListener(i,n=>{let r;try{r=JSON.parse(n.data)}catch{return}tt(i,r)});this.sse.addEventListener("cursor",i=>{let n;try{n=JSON.parse(i.data)}catch{return}if(!n||n.resync!==!0&&n.startup!==!0)return;let r=n.resync===!0,l=n.startup===!0&&!r;console.log(r?"[LiveSync] Server could not replay everything; refetching the document":"[LiveSync] Checking the served document against the version this tab was served"),this._fetchServedDocument(typeof n.seq=="number"?n.seq:void 0,{repair:r,startup:l})}),this.sse.addEventListener("presence",i=>{let n;try{n=JSON.parse(i.data)}catch{return}bt(n),this._lastRoster=n,this._editing&&this._editing.roster(n)}),this.sse.onmessage=i=>{let n=JSON.parse(i.data),{seq:r}=n;if(typeof r=="number"&&r<=this.lastSeenSeq){this._log(`Dropping stale message: seq=${r}, lastSeen=${this.lastSeenSeq}`);return}if(typeof r=="number"&&(this.lastSeenSeq=r),n.type==="notification"){if(this._maybeAcceptExternalChange(n))return;this.handleNotification(n);return}if(n.error){console.error("[LiveSync] Server error:",n.error),this.onError&&this.onError(new Error(n.error));return}if(this._applyEtagFrame(n))return;let{html:l,sender:o,identityMap:a}=n;if(o===this.clientId){this._log("Ignoring own message (sender matches clientId)");return}if(typeof l!="string"){console.error("[LiveSync] Received invalid html, ignoring");return}let h=typeof n.etag=="string"&&n.etag?n.etag:null;if(this.lane==="live"&&!h&&$e()){this._log(`Dropping an unstamped live frame on a stamping host (seq=${r})`);return}if(this.lane==="saved"&&l===this._represented.bytes){this._represented=Object.freeze({bytes:l,etag:h||null,seq:r??null}),P(h);return}if(h&&l===this.lastHtml){this._log(`Taking the stamp from a peer save of content already applied (seq=${r})`),P(h),y&&y.isSaveConflicted()&&(y.conflictResolvedBySync(h),this._saveAfterMerge(x(),!1));return}this._log(`Received update from: ${o} (my clientId: ${this.clientId}, seq=${r})`),this.applyUpdate(l,r,a,h,n.by),this.onUpdate&&this.onUpdate({html:l,sender:o,seq:r,identityMap:a,etag:h})},this.sse.onerror=()=>{this.sse.readyState===EventSource.CONNECTING?console.log("[LiveSync] Reconnecting..."):this.sse.readyState===EventSource.CLOSED&&(console.log("[LiveSync] Connection closed"),this.onError&&this.onError(new Error("Connection closed"))),this.onDisconnect&&this.onDisconnect()}}listenForSnapshots(){this._snapshotHandler=e=>{if(!e.detail||e.detail.forSave!==!0)return;this._saveTicket=this._ticket();let{documentElement:t}=e.detail;if(!t)return;this._log("snapshot-ready received, preparing to send");let i=this.identity.exportMap(t,D);this._savedSnapshot?.abort?.abort();let n={html:null,steps:null,copy:null,abort:null,identityMap:i,ticket:this._saveTicket,captureId:e.detail.captureId??null};if(e.detail.sliced){n.copy=Oe(t),n.abort=new AbortController;let{signal:r}=n.abort;Promise.all([import("./c-YYMZWQLR.js"),import("./c-ZWBI4HYK.js")]).then(([{serializeForSyncSteps:l},{runSliced:o}])=>{if(r.aborted||typeof n.html=="string")return;let a=(function*(){let h=yield*l(n.copy);n.html=h,n.steps=null})();return n.steps=a,o(a,{signal:r})}).catch(()=>{})}else n.html=T(t);this._savedSnapshot=n},document.addEventListener("clay:snapshot-ready",this._snapshotHandler)}_enqueueSend(e,t,i=null){if(!this._profile){this._queuedSend={html:e,identityMap:t,etag:i},this._resolveProfile().then(()=>this._flushQueuedSend());return}if(this._sendInFlight){this._queuedSend={html:e,identityMap:t,etag:i};return}this._postUpdate(e,t,i)}_flushQueuedSend(){if(this.isDestroyed||this._sendInFlight)return;let e=this._queuedSend;e&&(this._queuedSend=null,this._postUpdate(e.html,e.identityMap,e.etag))}_relayCommit(e=null,t=null){if(this.isDestroyed)return;let i=se(),n=this._savedSnapshot;if(n&&(n.captureId??null)!==(e??null)){this._log("Skipping send - snapshot belongs to a different capture");return}let r=n;if(this._savedSnapshot=null,r?.copy&&typeof r.html!="string")if(r.abort?.abort(),r.steps)for(let c=r.steps.next();!c.done;c=r.steps.next());else r.html=T(r.copy);if(!r||typeof r.html!="string")return;let l=r;if(typeof t=="string"){try{l=lt(r,t,this.identity)}catch(c){this._log(`Skipping send - page relay failed: ${c&&c.message}`);return}if(!l){this._log("Skipping send - accepted capture has no page article");return}}let o=Mt(e)??t,a=typeof o=="string"?We(o):0;l={...l,html:Pt(Ye(l.html,Math.max(Je(),a)),o)};let h=!i&&l.html===this.lastHtml;if(this._setPeerBase(l.html,l.identityMap,l.ticket),h){this._log("Skipping send - HTML unchanged");return}this._enqueueSend(l.html,l.identityMap,i||null)}_postUpdate(e,t,i=null,n=0){this._log(`Sending update (HTML length: ${e.length})`),this._sendInFlight=!0;let r=!1,l=this._profile||pe.legacy;fetch(new URL(l.relayPath,window.location.origin).href,{method:"POST",headers:{"Content-Type":"application/json",[l.documentHeader]:window.location.href,[ze]:String(1)},body:qt(l,e,this.clientId,t,i)}).then(o=>{o.ok||(console.warn("[LiveSync] Save returned status:",o.status),r=o.status>=500||o.status===408||o.status===429)}).catch(o=>{console.error("[LiveSync] Save failed:",o),this.onError&&this.onError(o),r=!0}).finally(()=>{this._sendInFlight=!1;let o=this._queuedSend;if(this._queuedSend=null,o){this._postUpdate(o.html,o.identityMap,o.etag);return}!r||!i||n>=3||this.isDestroyed||(this._sendInFlight=!0,setTimeout(()=>{if(this._sendInFlight=!1,this.isDestroyed)return;let a=this._queuedSend;this._queuedSend=null,a?this._postUpdate(a.html,a.identityMap,a.etag):this._postUpdate(e,t,i,n+1)},500*2**n))})}_startPresence(e,t){return this.isDestroyed||this._startGen!==t||this._presenceLease?null:e.connect({send:i=>this._postPresence(i)}).then(i=>this.isDestroyed||this._startGen!==t?(typeof i?.stop=="function"?i.stop():i?.detach(),null):(this._presenceLease=i||null,Ue("presence-editing")),()=>!1).then(i=>{if(!(!i||this.isDestroyed||this._startGen!==t||this._editing))return R().then(n=>{this.isDestroyed||this._startGen!==t||this._editing||(this._editing=new n.EditingSender({}),this._presenceQuiesced?this._editing.stop():(this._editing.start(),this._editing.roster(this._lastRoster)))})})}_postPresence(e){let t=new URL("/_/presence",window.location.origin);return t.searchParams.set("client-id",this.clientId),fetch(t.href,{method:"POST",headers:{"Content-Type":"application/json","Document-URL":window.location.href},body:JSON.stringify(e)}).then(i=>i.ok,()=>!1)}_maybeAcceptExternalChange(e){if(this.lane!=="live")return!1;let t=e.data;return t&&t.kind==="external-change"?(typeof t.html=="string"?this._enqueueExternal(t.html,e.seq,t.etag,t.by):this._fetchExternalChange(e.seq),!0):typeof e.msg=="string"&&e.msg.endsWith("changed on disk outside this tab")?(this._fetchExternalChange(e.seq),!0):!1}_enqueueExternal(e,t,i,n){if(typeof t=="number"){if(t<=this._lastExternalSeq){this._log(`Dropping replayed external change: seq=${t}`);return}this._lastExternalSeq=t}this._pendingExternal={html:e,seq:t,saveEpoch:this._saveEpoch,etag:typeof i=="string"&&i?i:null,by:n??null},this._scheduleNextFrame()}_fetchExternalChange(e){if(typeof e=="number"){if(e<=this._lastExternalSeq)return;this._lastExternalSeq=e}this._fetchServedDocument(e)}_fetchServedDocument(e,{attempt:t=0,repair:i=!1,startup:n=!1}={}){if(n&&(this._morphInFlight||this._pendingHtml!=null||this._pendingExternal!=null)){this._retryStartup(t);return}let r=this._saveEpoch,l=this._startGen,o=this.lastSeenSeq,a=this._applyGen,h=++this._servedFetchId;i&&typeof e!="number"&&(e=this._lastExternalSeq),fetch(new URL(window.location.href),{cache:"no-store"}).then(c=>c.ok?c.text():null).then(c=>{if(this.isDestroyed||c==null||this._startGen!==l)return;let d=Ft(c),_=n||i&&!!d;if(_){if(h!==this._servedFetchId){i&&this._retryStartup(t+1,{repair:i,startup:n},typeof e=="number"?Math.max(e,this._lastExternalSeq):e);return}if(r!==this._saveEpoch||o!==this.lastSeenSeq||a!==this._applyGen||this._morphInFlight||this._pendingHtml!=null||this._pendingExternal!=null){this._retryStartup(t+1,{repair:i,startup:n},e);return}if(d){if(d===re()){(i||n)&&this.lane==="saved"&&(this._represented=Object.freeze({bytes:c,etag:d,seq:e??null}));return}}else if(!i)return}else if(typeof e=="number"&&e<this._lastExternalSeq){i&&t<3&&this._fetchServedDocument(this._lastExternalSeq,{attempt:t+1,repair:i,startup:n});return}else if(this._saveEpoch>r){t<3&&(console.log("[LiveSync] Refetching external change: own save landed mid-fetch"),this._fetchServedDocument(e,{attempt:t+1,repair:i,startup:n}));return}this._pendingExternal={html:c,seq:e,saveEpoch:r,etag:d,by:null,fetchOptions:{repair:i,startup:n,attempt:t,versionCheck:_},startGen:l,seenSeq:o,applyGen:a,fetchId:h},this._scheduleNextFrame()}).catch(c=>{this._log("External-change fetch failed",c),typeof e=="number"&&this._lastExternalSeq===e&&(this._lastExternalSeq=e-1)})}_retryStartup(e=0,t={startup:!0},i){this.isDestroyed||e>3||(clearTimeout(this._startupRetry),this._startupRetry=setTimeout(()=>{if(this._startupRetry=null,!this.isDestroyed){if(this._morphInFlight||this._pendingHtml!=null||this._pendingExternal!=null){this._retryStartup(e,t,i);return}this._fetchServedDocument(i,{...t,attempt:e})}},16))}applyUpdate(e,t,i,n,r){this.isDestroyed||(this._pendingHtml=e,this._pendingSeq=t,this._pendingIdentityMap=i,this._pendingEtag=n??null,this._pendingBy=r??null,this._scheduleNextFrame())}prepareHandoff(e={}){return this._handoff?Promise.resolve(this._handoff):this.isDestroyed?Promise.reject(new Error("LiveSync: stopped")):(this._handoffHeld=!0,this._rafHandle!=null&&(this._cancelFrame(this._rafHandle),this._rafHandle=null),import("./c-2R4OBWIP.js").then(({engineHandoff:t})=>t(this,e)).then(t=>this._handoff=t))}_scheduleNextFrame(){this.isDestroyed||this._handoffHeld||this._rafHandle==null&&(this._morphInFlight||(this._rafHandle=this._requestFrame(()=>this._runPending())))}async _runPending(){if(this._rafHandle=null,this.isDestroyed)return;if(!A()){this._morphInFlight=!0;try{await J()}catch(r){this._log("Merge engine failed to load",r),this._engineRetry=setTimeout(()=>this._scheduleNextFrame(),2e3);return}finally{this._morphInFlight=!1}if(this.isDestroyed)return}let e=this._pendingExternal,t=e?.fetchOptions||null,i=!!(t?.startup||t?.versionCheck),n=!1;if(e!=null&&(i&&this._pendingHtml!=null?n=!1:this._pendingHtml==null?n=!0:n=!(typeof e.seq=="number"&&typeof this._pendingSeq=="number"&&this._pendingSeq<e.seq)),n)if(this._pendingExternal=null,typeof e.seq=="number"&&e.seq<this._lastExternalSeq)i&&t?.repair?this._retryStartup((t.attempt||0)+1,t,this._lastExternalSeq):this._log("Dropping superseded external change at drain");else if(i&&e.startGen!==this._startGen)this._log("Dropping superseded startup check at drain");else if(i&&e.fetchId!==this._servedFetchId)t?.repair?this._retryStartup((t.attempt||0)+1,t,this._lastExternalSeq):this._log("Dropping superseded startup check at drain");else if(i&&(e.saveEpoch!==this._saveEpoch||e.seenSeq!==this.lastSeenSeq||e.applyGen!==this._applyGen))this._retryStartup((t.attempt||0)+1,t,e.seq);else if(i&&e.etag!=null&&e.etag===re())this._log("Startup check found the same version: nothing to apply");else if(!i&&e.saveEpoch!==this._saveEpoch)console.log("[LiveSync] Refetching external change: own save landed after queue"),this._fetchServedDocument(e.seq,t||{});else{this._morphInFlight=!0;try{await this._doApplyExternal(e.html,e.seq,e.etag,e.by,t)}catch(r){console.error("[LiveSync] applyExternal failed:",r)}finally{this._morphInFlight=!1}}else{let r=this._pendingHtml,l=this._pendingSeq,o=this._pendingIdentityMap,a=this._pendingEtag,h=this._pendingBy;if(this._pendingHtml=null,this._pendingSeq=null,this._pendingIdentityMap=null,this._pendingEtag=null,this._pendingBy=null,r==null)return;this._morphInFlight=!0;try{await this._doApplyUpdate(r,l,o,a,h)}catch(c){console.error("[LiveSync] applyUpdate failed:",c)}finally{this._morphInFlight=!1}}!this.isDestroyed&&(this._pendingHtml!=null||this._pendingExternal!=null)&&this._scheduleNextFrame()}_ticket(){return++this._agreeSeq}_setDiskBase(e,t){t<=this._diskBaseTicket||(this._diskBase=e,this._diskBaseTicket=t)}_setPeerBase(e,t,i){return i<this._peerBaseTicket?!1:(this._peerBaseTicket=i,this.lastHtml=e,this._lastIdentityMap=t&&typeof t=="object"&&!Array.isArray(t)?t:null,!0)}_requestFrame(e){if(ce()){if(typeof MessageChannel=="function"){let n=new MessageChannel,r=!0;return n.port1.onmessage=()=>{n.port1.close(),r&&e()},n.port2.postMessage(null),{cancel:()=>{r=!1,n.port1.close()}}}let i=setTimeout(e,0);return{cancel:()=>clearTimeout(i)}}if(typeof window<"u"&&typeof window.requestAnimationFrame=="function"){let i=window.requestAnimationFrame(e);return{cancel:()=>window.cancelAnimationFrame?.(i)}}let t=setTimeout(e,16);return{cancel:()=>clearTimeout(t)}}_cancelFrame(e){e?.cancel?.()}async _mergeIncoming(e,t,{base:i,baseIdentityMap:n=null,captureLocal:r,synthetic:l,source:o="peer",seq:a=null,etag:h=null,extra:c={}}){A()||await J();let{beginApply:d,completeApply:_,failApply:g,beginLineageCapture:E}=ht()||await V(),f,u=p=>{f=E(I.list());try{let v=A().HyperMorph.mergeDocument({...p,lineage:f.lineage});return f.returned(),v}catch(v){throw f.invalidate(I.list()),f.finish(I.list()),v}},S=this.identity,w=Te,b=Ht(new WeakMap),N=p=>me(p)?{first:b,map:p,then:b}:b,O=l?p=>b(p)||S.idOf(D(p)||p)||null:b,H=e,we=new Map;if(me(t)){H=new DOMParser().parseFromString(e,"text/html"),ie(H);let p=A().HyperMorph.importMap(H.documentElement,t);for(let v of H.querySelectorAll("[data-id], [id]")){let k=b(v),De=k&&p.get(v);De&&we.set(k,De)}}H=dt(H);let Z={live:document,remote:H,ignore:p=>p.matches(pt),opaque:p=>p.matches(_t)||z()&&qe(p),remoteWins:p=>p.matches(It),ignoreAttribute:(p,v,k)=>Tt(p,v,k)||z()&&Re(k||p,v),attributeMerge:ot,protectFocusedValue:!0,restoreFocus:document.activeElement?.localName!=="clay-editor-ui",keepLiveOnly:o==="peer",scripts:{mergeTags:A().mergeTagRecognizers},hooks:{beforeAttributeUpdated:w},...c},ke=this.lane==="live"&&x(),xe=he(),G,ee=null,C=null;if(i==null)G=u({...Z,base:null,local:{root:X(r()),toLive:D},identity:{local:O,remote:N(t)}});else if(ke){let p=r(),v=p.cloneNode(!0);ee=X(p),C=d({source:o,seq:a,etag:h,root:ee,recoveryRoot:v,domain:o==="disk"?"save":"sync"});try{G=u({...Z,base:dt(i),local:{root:ee,toLive:D},identity:{base:N(n),local:O,remote:N(t)}})}catch(k){throw g(C,k),k}}else{let p=X(r()),v=p.ownerDocument;v.documentElement!==p&&v.replaceChild(p,v.documentElement),G=u({...Z,base:v,local:{root:p,toLive:D},fastPath:!0,identity:{base:O,local:O,remote:N(t)}})}let U=this._ticket();this._morphTicket=U;let F;try{F=await G}catch(p){f.invalidate(I.list());try{C&&g(C,p,{ticket:U})}finally{f.finish(I.list())}throw p}let yt=he().gen!==xe.gen,be;try{f.prepareComplete(F,I.list()),be=C?_(C,F.conflicts,{ticket:U}):[]}finally{f.finish(I.list())}this.lane==="live"&&F.localDiverged?Ve():ke&&!F.localDiverged&&Xe(xe);let mt=new Set(me(t)?Object.values(t):[]);for(let[p,v]of F.identities){let k=mt.has(v)?v:we.get(v);k&&S.adopt(p,k)}return{report:F,ticket:U,typedDuringWait:yt,conflictIds:be}}_saveAfterMerge(e,t){(e||t)&&Ke()&&(y?y.savePageThrottled():Dt())}async _doApplyUpdate(e,t,i,n,r=null){if(ue(e)){await fe();return}this.lane==="live"&&!y&&await R(),this._log("applyUpdate - pausing mutations and morphing"),this.isPaused=!0;let l=window.scrollX,o=window.scrollY;q.pause(),oe();let a=!1,h=!1,c=!1;try{if(this.lane==="live"&&x()&&this.lastHtml===null){console.log("[LiveSync] Holding incoming update: unsaved local edits and no baseline to merge against"),this._setHeld("live",!0,null);let f=this._saveEpoch,u=this.lastSeenSeq;clearTimeout(this._holdRetryPeer),this._holdRetryPeer=setTimeout(()=>{this._holdRetryPeer=null,!(this.isDestroyed||this._pendingHtml!=null)&&this._saveEpoch===f&&this.lastSeenSeq===u&&(this._pendingHtml=e,this._pendingSeq=t,this._pendingIdentityMap=i,this._pendingBy=r,this._scheduleNextFrame())},3e3);return}this._setHeld("live",!1);let{report:d,ticket:_,typedDuringWait:g,conflictIds:E}=await this._mergeIncoming(e,i,{base:this.lastHtml,baseIdentityMap:this._lastIdentityMap,captureLocal:()=>M({flushUndo:!1}),synthetic:!0,source:"peer",seq:t,etag:n});if(a=d.localDiverged,h=g,ne(),window.scrollTo(l,o),this._setPeerBase(e,i,_),this._applyGen++,this._acceptedSaveTicket>_||(typeof n=="string"&&n?(P(n),c=!0):le()),this.lane==="live"&&!a&&!x()){let{forSave:f,forComparison:u,forDirty:S}=Y({emitForSync:!1,flushUndo:!1});y.setLastSavedBaselines(u,S),this._setDiskBase(f,this._ticket())}this.lane==="saved"&&(this._represented=Object.freeze({bytes:e,etag:n||null,seq:t??null})),document.dispatchEvent(new CustomEvent("clay:sync-applied",{detail:{seq:t,source:this.lane==="saved"?"disk":"peer",lane:this.lane,by:r||null,html:e,report:d,unresolved:this.unresolvedConflicts,conflictIds:E}}))}finally{this._log("applyUpdate - morph complete, resuming mutations"),q.resume(),ae(),await new Promise(d=>setTimeout(d,0)),this.isPaused=!1}c&&y?.conflictResolvedBySync(n),this._saveAfterMerge(a,h)}async _doApplyExternal(e,t,i=null,n=null,r=null){if(ue(e)){await fe();return}this.lane==="live"&&!y&&await R();let l=this._diskBase;this._log(`applyExternal - external disk change (seq=${t})`),this.isPaused=!0;let o=window.scrollX,a=window.scrollY;q.pause(),oe();let h=!1,c=!1,d=!1;try{if(this.lane==="live"&&x()&&this._diskBase===null){if(console.log("[LiveSync] Holding external change: unsaved local edits and no baseline to merge against"),this._setHeld("external",!0,null),r?.startup||r?.versionCheck){clearTimeout(this._holdRetryExt),this._holdRetryExt=setTimeout(()=>{if(this._holdRetryExt=null,this.isDestroyed)return;let S=typeof t=="number"?Math.max(t,this._lastExternalSeq):t;this._retryStartup(0,r,S)},3e3);return}let u=this._saveEpoch;clearTimeout(this._holdRetryExt),this._holdRetryExt=setTimeout(()=>{this._holdRetryExt=null,!(this.isDestroyed||this._pendingExternal!=null)&&(this._pendingExternal={html:e,seq:t,saveEpoch:u,etag:i,by:n},this._scheduleNextFrame())},3e3);return}this._setHeld("external",!1);let{report:_,ticket:g,typedDuringWait:E,conflictIds:f}=await this._mergeIncoming(e,null,{base:this._diskBase,captureLocal:()=>Ne().saveClone,synthetic:!1,source:"disk",seq:t,etag:i,extra:{beforeApply:u=>Ct(u.documentElement,this.lane)}});if(h=_.localDiverged,c=E,ne(),this._setDiskBase(e,g),window.scrollTo(o,a),this._acceptedSaveTicket>g||(typeof i=="string"&&i?(P(i),d=!0):le()),this.lane==="live"&&!h&&!x()){y.setLastSavedBaselines(...At()),y.setUnsavedChanges(!1);let u=M({flushUndo:!1});this._setPeerBase(T(u),this.identity.exportMap(u,D),g),this._applyGen++}this.lane==="saved"&&(this._represented=Object.freeze({bytes:e,etag:i||null,seq:t??null})),document.dispatchEvent(new CustomEvent("clay:sync-applied",{detail:{seq:t,source:"disk",etag:typeof i=="string"&&i?i:null,by:n||null,html:e,report:_,conflictIds:f,unresolved:this.unresolvedConflicts}}))}finally{this._log("applyExternal - morph complete, resuming mutations"),q.resume(),ae(),await new Promise(_=>setTimeout(_,0)),this.isPaused=!1}d&&y?.conflictResolvedBySync(i),this._saveAfterMerge(h,c),l!=null&&j(l)===j(e)&&y&&y.schedulePaintHeal(()=>this._diskBase==null?null:j(this._diskBase))}handleNotification({msgType:e,msg:t,action:i,persistent:n,data:r}){this._log(`Notification received: ${e} - ${t}`),e==="data-loss"||(n&&window.toastPersistent?window.toastPersistent(t,e):window.toast?window.toast(t,e):console.log(`[LiveSync] Notification: ${t}`)),document.dispatchEvent(new CustomEvent("clay:notification",{detail:{msgType:e,msg:t,action:i,persistent:n,data:r}})),this.onNotification&&this.onNotification({msgType:e,msg:t,action:i,persistent:n,data:r})}stop(){this.cleanup(),this.isDestroyed=!0,console.log("[LiveSync] Stopped")}editParticipant(){return R().then(e=>e.syncParticipant(this))}},K=null;Ge((s,e)=>{K=typeof s=="string"?{html:s,captureId:e?.captureId??null}:null});var Mt=s=>K&&(K.captureId??null)===(s??null)?K.html:null;function Pt(s,e){if(typeof e!="string"||e===s)return s;let t=i=>new DOMParser().parseFromString(i,"text/html").documentElement;return t(s).isEqualNode(t(e))?e:s}var Ee=new Se;typeof window<"u"&&!ut&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>Ee.start()):Ee.start());var yn=(s,e,t)=>J().then(({morph:i})=>i(s,e,t));var mn=Ee;export{I as a,pt as b,It as c,Se as d,Ee as e,yn as f,mn as g};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k}from"../c-N7JPUPGC.js";import"../c-VHNSBD2M.js";export{a as DRAFT_ATTR,b as DRAFT_PLUGIN,e as draftEligible,d as draftSlot,k as draftStoreFailed,g as draftTransport,i as flushDraft,c as noteBootParams,h as setDraftFlush,j as setDraftStoreFailed,f as setDraftTransport};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c}from"../c-2YIJ6ZA6.js";import"../c-4ASQPRQL.js";import"../c-GQ6F6IDK.js";import"../c-I2SCCUEW.js";import"../c-5VYOWDTI.js";import"../c-LO4C4J77.js";import"../c-FV46ZKGX.js";import"../c-WYFDLITL.js";import"../c-UGHH4MB3.js";import"../c-LA2BW7UY.js";import"../c-HSNGLIFB.js";import"../c-LD6UVV5R.js";import"../c-PGSBXHUE.js";import"../c-RXTPKCMC.js";import"../c-RBPZNU2D.js";import"../c-IJUK2GPW.js";import"../c-DLBX4JCJ.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-N7JPUPGC.js";import"../c-PWJSJEJU.js";import"../c-XQXZAO7N.js";import"../c-S7LK4KUE.js";import"../c-VG5XIN4T.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";export{c as bytesUnsaved,b as hasUnsavedChanges,a as reloadAfterDiscard};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{g as t,t as n,w as i}from"../c-HSNGLIFB.js";import"../c-LD6UVV5R.js";import"../c-PGSBXHUE.js";import"../c-RXTPKCMC.js";import"../c-RBPZNU2D.js";import"../c-IJUK2GPW.js";import"../c-DLBX4JCJ.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-N7JPUPGC.js";import{G as o,r as a,t as e}from"../c-PWJSJEJU.js";import"../c-XQXZAO7N.js";import"../c-S7LK4KUE.js";import"../c-VG5XIN4T.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import{w as r}from"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var s=window.clay=window.clay||{};s.internals={captureSnapshot:e,captureForSave:o,addDocumentTransform:a,region:r,save:{saveHtml:n,replacePageWith:i,isSaveInProgress:t}};var l=s.internals;export{l as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as X}from"./c-RS77ODLY.js";import"./c-7SWMYKAI.js";import{f as J}from"./c-46XYM55L.js";import{b as V}from"./c-QTTJYJMA.js";import{a as F}from"./c-VKEDWYDF.js";import"./c-UGHH4MB3.js";import"./c-LA2BW7UY.js";import"./c-IJUK2GPW.js";import{b as G}from"./c-CYWLPPUS.js";import{i as z}from"./c-VG5XIN4T.js";import{a as W}from"./c-2YYDMLNZ.js";import{c as H,l as $}from"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var K={always:["lib/mutation.js","core/preserve-authored.js","core/edit-mode.js","core/mode-key.js","core/stale-host-notice.js","core/page-data.js"],editOnly:["core/snapshot.js","core/persist.js","core/admin-attrs.js","core/save-core.js","core/save.js","core/conflict-notice.js","core/recovery.js","core/unsaved-warning.js","core/autosave.js","attrs/save-freeze.js","attrs/onaftersave.js","attrs/refetch-on-save.js","attrs/add-from.js","lib/cache-bust.js"]},b={richclay:{path:"plugins/richclay.js",editOnly:!0,default:!0},indicator:{path:"plugins/indicator.js",editOnly:!0,default:!1},sync:{path:"sync/live-sync.js",editOnly:!1,default:!1},live:{path:"plugins/live.js",editOnly:!1,default:!1},blockeditor:{path:"plugins/page.js",editOnly:!0,default:!1},"blockeditor-view":{path:"plugins/page-view.js",editOnly:!1,default:!1,internal:!0},sortable:{path:"plugins/sortable.js",editOnly:!0,default:!1},undo:{path:"plugins/undo.js",editOnly:!0,default:!1},unsent:{path:"plugins/unsent.js",editOnly:!0,default:!1},cms:{path:"plugins/cms.js",editOnly:!1,default:!1},quickcrop:{path:"plugins/quickcrop.js",editOnly:!1,default:!1},upload:{path:"plugins/upload.js",editOnly:!0,default:!1},people:{path:"plugins/people.js",editOnly:!1,default:!1},menu:{path:"plugins/menu.js",editOnly:!1,default:!1},wire:{path:"plugins/wire.js",editOnly:!1,default:!1},message:{path:"plugins/message.js",editOnly:!1,default:!1},like:{path:"plugins/like.js",editOnly:!1,default:!1},"ai-edit":{path:"plugins/ai-edit.js",editOnly:!0,default:!1},demo:{path:"plugins/demo.js",editOnly:!1,default:!1},source:{path:"plugins/source.js",editOnly:!0,default:!0},"visitor-drafts":{path:"plugins/visitor-drafts.js",ownerPath:"plugins/visitor-drafts-owner.js",editOnly:!1,default:!1},"visitor-menu":{path:"plugins/visitor-menu.js",editOnly:!0,draft:!0},"bind-text":{path:"plugins/bind-text.js",editOnly:!0,default:!1},derive:{path:"plugins/derive.js",editOnly:!1,default:!1},upgrade:{path:"plugins/upgrade.js",editOnly:!1,default:!1}},O={"core/is-edit-mode.js":()=>import("./core/is-edit-mode-GK7IFFMT.js"),"core/draft-mode.js":()=>import("./core/draft-mode-WSQAT67S.js"),"lib/region-policy.js":()=>import("./lib/region-policy-KWBPROWF.js"),"lib/mutation.js":()=>import("./reader-core-F6RY3V64.js").then(t=>t.core["lib/mutation.js"]),"core/edit-mode.js":()=>import("./reader-core-F6RY3V64.js").then(t=>t.core["core/edit-mode.js"]),"core/mode-key.js":()=>import("./reader-core-F6RY3V64.js").then(t=>t.core["core/mode-key.js"]),"core/stale-host-notice.js":()=>import("./reader-core-F6RY3V64.js").then(t=>t.core["core/stale-host-notice.js"]),"core/page-data.js":()=>import("./reader-core-F6RY3V64.js").then(t=>t.core["core/page-data.js"]),"core/preserve-authored.js":()=>import("./reader-core-F6RY3V64.js").then(t=>t.core["core/preserve-authored.js"]),"core/snapshot.js":()=>import("./core/snapshot-FJP5IJL3.js"),"core/save-core.js":()=>import("./core/save-core-K7XFAWQ4.js"),"core/save.js":()=>import("./core/save-FV4ZCKBI.js"),"core/site-edits.js":()=>import("./core/site-edits-TEQORBJU.js"),"core/conflict-notice.js":()=>import("./core/conflict-notice-BAR23OWH.js"),"core/recovery.js":()=>import("./core/recovery-LPB6X72P.js"),"core/unsaved-warning.js":()=>import("./core/unsaved-warning-FF63QGKI.js"),"core/persist.js":()=>import("./core/persist-AIJGTKKI.js"),"core/admin-attrs.js":()=>import("./core/admin-attrs-5UGMYCKW.js"),"core/autosave.js":()=>import("./core/autosave-4P66VXX7.js"),"attrs/save-freeze.js":()=>import("./attrs/save-freeze-JZHKRQLR.js"),"attrs/onaftersave.js":()=>import("./attrs/onaftersave-OKSWEJQF.js"),"attrs/refetch-on-save.js":()=>import("./attrs/refetch-on-save-DPGJJMGN.js"),"attrs/add-from.js":()=>import("./attrs/add-from-T5LJXFFI.js"),"lib/cache-bust.js":()=>import("./lib/cache-bust-NH7VBWHO.js"),"plugins/richclay.js":()=>import("./plugins/richclay-CBLZRFB4.js"),"plugins/indicator.js":()=>import("./plugins/indicator-DAKZGAWI.js"),"sync/live-sync.js":()=>import("./sync/live-sync-M2PP2IWY.js"),"plugins/live.js":()=>import("./plugins/live-UAJGWRNP.js"),"plugins/page.js":()=>import("./plugins/page-ZBIYHGK4.js"),"plugins/page-view.js":()=>import("./plugins/page-view-OYN7Z5TS.js"),"plugins/sortable.js":()=>import("./plugins/sortable-HDOQ6GAC.js"),"plugins/undo.js":()=>import("./plugins/undo-5JI5G7CQ.js"),"plugins/unsent.js":()=>import("./plugins/unsent-OA4RGBUT.js"),"plugins/cms.js":()=>import("./plugins/cms-JANMGPHM.js"),"plugins/quickcrop.js":()=>import("./plugins/quickcrop-X5MRIBAP.js"),"plugins/upload.js":()=>import("./plugins/upload-DNJNW6H3.js"),"plugins/people.js":()=>import("./plugins/people-VBDR5Y22.js"),"plugins/menu.js":()=>import("./plugins/menu-BFJ644YX.js"),"plugins/wire.js":()=>import("./plugins/wire-XOT7XKJL.js"),"plugins/message.js":()=>import("./plugins/message-LQ6EDH4V.js"),"plugins/like.js":()=>import("./plugins/like-EV7MTZ56.js"),"plugins/ai-edit.js":()=>import("./plugins/ai-edit-CUKQQWJX.js"),"plugins/demo.js":()=>import("./plugins/demo-JIR7DXJA.js"),"plugins/visitor-drafts.js":()=>import("./plugins/visitor-drafts-A5FDQ2G7.js"),"plugins/visitor-drafts-owner.js":()=>import("./plugins/visitor-drafts-owner-VIAZC3CF.js"),"plugins/visitor-menu.js":()=>import("./plugins/visitor-menu-ZHKWIKKY.js"),"plugins/bind-text.js":()=>import("./plugins/bind-text-NX46N5UV.js"),"plugins/source.js":()=>import("./plugins/source-ZXDD7F6X.js"),"plugins/derive.js":()=>import("./plugins/derive-QVI3LI3A.js"),"plugins/upgrade.js":()=>import("./plugins/upgrade-6B6QS3NR.js")},re=["visitor-drafts","visitor-menu","richclay","indicator","sortable","undo","unsent","quickcrop","upload","people","menu","upgrade","cms","blockeditor-view","sync","live","blockeditor","message","like","wire","ai-edit","demo","derive","bind-text","source"],ae={cms:["quickcrop","upload","menu"],"ai-edit":["wire"],blockeditor:["live","sync","upload","wire","ai-edit"]},ce={blockeditor:["richclay"]},le={blockeditor:["undo"]},ue=new Set(["source","sortable","menu","upgrade"]),de=new Set(["wire","ai-edit"]);function Q(t,e,o,s){let l=t.get(e);if(l)for(let i of l.split(",")){let a=i.trim();if(a){if(!b[a]||b[a].internal){console.warn(`clayjs: unknown plugin "${a}"`);continue}s(o,a)}}}var pe=["sync","live","blockeditor","upload","quickcrop","cms","people","menu","upgrade","wire","ai-edit","demo","source"],fe="core/site-edits.js",me=["attrs/refetch-on-save.js","core/conflict-notice.js"],ge="https://hyperclay.com/templates/";function P(t,e,{isDraftMode:o=!1,hasSap:s=!1,hasVariants:l=!1,hasSite:i=!1,canEdit:a=!1,templateSource:h=null}={}){let u=[...K.always];e&&u.push(...K.editOnly),e&&!o&&i&&u.splice(u.indexOf("core/save.js")+1,0,fe);let d=new Set;Q(t,"plugins",d,(r,c)=>r.add(c));let j=new Set;Q(t,"exclude",j,(r,c)=>r.add(c));let n=new Set(d);for(let[r,c]of Object.entries(b))c.default&&n.add(r);s&&n.add("derive"),l&&(e||a)&&n.add("menu"),!e&&!o&&n.has("blockeditor")&&n.add("blockeditor-view");for(let r of[...n])if(!j.has(r)&&!(b[r].editOnly&&!e))for(let c of ae[r]||[])n.add(c);j.has("wire")&&n.delete("ai-edit");for(let r of j)n.delete(r);if(o){let r=n.has("blockeditor");for(let c of pe)r&&(c==="blockeditor"||c==="live")||n.delete(c);for(let c of me){let y=u.indexOf(c);y>-1&&u.splice(y,1)}n.add("visitor-drafts")}!o&&a&&!j.has("upgrade")&&h&&h.startsWith(ge)&&n.add("upgrade");for(let[r,c]of Object.entries(ce))if(n.has(r))for(let y of c)d.has(y)||n.delete(y);for(let[r,c]of Object.entries(le))if(n.has(r))for(let y of c)n.has(y)&&(n.delete(y),console.warn(`clayjs: plugin "${y}" cannot run with "${r}" and was left out`));let g=[],w=[];for(let r of re){if(!n.has(r))continue;let c=b[r];if(c.editOnly&&!e||c.draft&&!o)continue;(ue.has(r)||de.has(r)&&n.has("blockeditor")?w:g).push(c.ownerPath&&!o?c.ownerPath:c.path)}return{core:u,plugins:g,late:w}}var _="data-deleted-at",I=(t,e)=>window.clay?.undo?.commit?window.clay.undo.commit(t,e):e(),Y=(t,e)=>t.dispatchEvent(new CustomEvent(e,{bubbles:!0})),R=Object.assign((t,{at:e=new Date().toISOString()}={})=>(I("Move to Trash",()=>t.setAttribute(_,e)),Y(t,"clay:trashed"),{undo:()=>R.restore(t)}),{is:t=>!!t.getAttribute(_),restore(t){I("Restore",()=>t.removeAttribute(_)),Y(t,"clay:restored")},purge(t){I("Delete forever",()=>t.remove())}});var Z=50,he=1e3,ye='[clay~="no-snapshot"], [no-snapshot], [snapshot-remove]',L=0,je=t=>{let e=t.nodeType===1?t:t.parentElement;if(!e)return"a detached node";let o=e.localName;return e.id?o+="#"+e.id:e.classList.length&&(o+="."+[...e.classList].slice(0,2).join(".")),"<"+o+">"};function ve(t){let e=window.clay?.region?.resolveRegionPolicy;if(!e)return null;let o=s=>!!s&&!s.closest(ye)&&e(s).dirtyTracked;for(let s of t){if(s.type==="attributes"&&$(s.attributeName,s.target))continue;let l=s.target.nodeType===1?s.target:s.target.parentElement;if(o(l)&&!(s.type==="childList"&&![...s.addedNodes,...s.removedNodes].some(i=>i.nodeType!==1||o(i))))return s.target}return null}function q(t){let e=window.clay,o=e.Mutation,s=new Set,l=(m,p)=>{s.has(m)||(s.add(m),console.warn("clay.effect: "+p))},i=!1,a=!1,h=0,u=0;L&&e.isEditMode&&console.warn("clay.effect: an effect was created inside another effect, so a new one starts on every run. Create effects once, in clay.start.");let d=()=>{let m=Date.now();m-h>he&&(h=m,u=0),++u>Z&&l("loop",`this effect ran more than ${Z} times in a second. Something keeps changing the document, often a timer or async callback the effect started.`)},j=()=>{if(i=!1,a)return;let m=null;o.pause(),L++;try{e.isEditMode===!0&&(d(),s.has("saved")||(m=new MutationObserver(()=>{}),m.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0})));let p=t();p&&typeof p.then=="function"&&(y(),console.error("clay.effect: fn returned a promise. It must be synchronous, so this effect was stopped."))}catch(p){console.error("clay.effect:",p)}finally{L--,o.resume();let p=m?m.takeRecords():[];if(m?.disconnect(),p.length){let S=ve(p);S&&l("saved",`this effect changed ${je(S)}, which is saved with the file. Effect writes never mark the page unsaved, so a merge can leave it dirty with no save scheduled. Draw derived values inside clay="no-dirty" or clay="editor-ui".`)}}},n=()=>{i||a||(i=!0,queueMicrotask(j))},g=["undo","redo"],w=()=>{for(let m of g)e.undo?.on?.(m,n)},r=m=>{m.detail?.applied?.length&&n()},c=o.onAnyChange({debounce:0,require:"observed"},n);document.addEventListener("clay:sync-applied",n),document.addEventListener("clay:site-data",r),document.addEventListener("clay:modechange",w),w();let y=()=>{a=!0,c(),document.removeEventListener("clay:sync-applied",n),document.removeEventListener("clay:site-data",r),document.removeEventListener("clay:modechange",w);for(let m of g)e.undo?.off?.(m,n)};return n(),y}Object.defineProperty(q,"running",{get:()=>L>0});var we={overtype:()=>import("./c-PQ5LK6QE.js"),marked:()=>import("./c-XN6MBKI6.js"),highlight:()=>import("./c-33JJ6CBX.js"),"highlight/bash":()=>import("./c-KI7M4AY3.js"),"highlight/css":()=>import("./c-H4LG442Q.js"),"highlight/javascript":()=>import("./c-VDSS4K3Z.js"),"highlight/json":()=>import("./c-NRPJEVJS.js"),"highlight/python":()=>import("./c-5YIHJ3TJ.js"),"highlight/xml":()=>import("./c-WN5AY3OZ.js"),uimotion:()=>import("./c-B5CS55WR.js")};function be(t){let e=new Map;function o(s){return Object.hasOwn(t,s)?(e.has(s)||e.set(s,t[s]().catch(l=>{throw e.delete(s),l})),e.get(s)):Promise.reject(new Error(`clay.assets: no asset named "${s}"`))}return{load:o,names:()=>Object.keys(t)}}var ee=be(we);function T(t,e){if(!t||!e)return t;let o={...e,...t};for(let s of["entries","imports","bootImports"])o[s]={...e[s],...t[s]};return o}var Oe="plugins/page.js";function M(t,e,{isEditMode:o=!1,isDraftMode:s=!1,hasSapJs:l=!1}={},i=document){if(!t?.entries)return 0;let a=[...e];for(let n of e)for(let g of t.bootImports?.[n]??[])l&&g==="vendor/sap-core.vendor.js"||a.push(g);o&&!s&&a.push(...t.editBootImports??[]),o&&!s&&e.includes(Oe)&&a.push(...t.editorBootImports??[]);let h=new Set,u=n=>{if(!(!n||h.has(n))){h.add(n);for(let g of t.imports?.[n]??[])u(g)}};for(let n of a)u(t.entries[n]);let d=new Set([...i.querySelectorAll('link[rel="modulepreload"]')].map(n=>n.href)),j=0;for(let n of h){let g=new URL(n,t.base).href;if(d.has(g))continue;let w=i.createElement("link");w.rel="modulepreload",w.href=g,w.setAttribute("clay","no-save"),i.head.append(w),j++}return j}var k=Object.fromEntries(Object.entries(b).flatMap(([t,e])=>e.ownerPath?[[e.path,t],[e.ownerPath,t]]:[[e.path,t]])),v={},te=new Set;function oe(t){te.has(t)||(te.add(t),document.dispatchEvent(new CustomEvent("clay:plugin-ready",{detail:{plugin:k[t]}})))}var Se=(t,e,o,s)=>()=>t().then(l=>(M(T(e,l),[...o.core,...o.plugins,...o.late],{isEditMode:!0,hasSapJs:s}),l));function Ee(){return new Promise(t=>F(t))}function A(){let t=document.querySelector('meta[name="hyper-source"]');return t?t.getAttribute("content"):null}async function Je(t,e,o,s=null,l=null,i=null){J(),(await O["core/draft-mode.js"]()).noteBootParams(e),await Ee();let h=await O["core/is-edit-mode.js"](),{isEditMode:u,isDraftMode:d,isOwner:j,siteVisibility:n,canEdit:g}=h;u&&!d&&import("./core/host-permission-3HE4CFD6.js").then(f=>f.checkHostPermission()).catch(()=>{}),window.__hyperclayEditMode=u;let w=await O["lib/region-policy.js"](),r=!!document.querySelector("[sap]"),c=document.querySelectorAll("head style[clay-variant]").length>=2,y=/(?:^|[{,])\s*["']?site["']?\s*:/.test(document.querySelector('script[data-rules-name~="api"]')?.textContent??""),m=!!document.querySelector('script[src*="sap.js"]');W.holdSettle=r&&u;let p=P(e,u,{isDraftMode:d,hasSap:r,hasVariants:c,hasSite:y,canEdit:g,templateSource:A()});p.plugins.includes("plugins/demo.js")&&h.commitModeFacts({destination:"demo"}),M(T(s,l),[...p.core,...p.plugins],{isEditMode:u,isDraftMode:d,hasSapJs:m}),(u||d)&&!l&&i&&i().then(f=>M(T(s,f),[...p.core,...p.plugins],{isEditMode:u,isDraftMode:d,hasSapJs:m})).catch(()=>{});let S,ne=new Promise(f=>{S=f}),ie={sync:p.plugins.includes("sync/live-sync.js")};for(let f of p.core)v[f]=await O[f](),v[f].install?.();if(Le(v,{isDraftMode:d,isOwner:j,siteVisibility:n},w),se(v),document.documentElement.getAttribute("clay-mode-switch")==="live"){let f=P(e,!0,{isDraftMode:d,hasSap:r,hasVariants:c,hasSite:y,canEdit:g,templateSource:A()});v["core/edit-mode.js"].noteLiveSwitch({edit:f,view:P(e,!1,{isDraftMode:d,hasSap:r,hasVariants:c,hasSite:y,canEdit:g,templateSource:A()}),loaded:v,modules:O,attach:(E,x)=>{U(E,x);let D=k[E],C=window.clay.plugins;D&&Array.isArray(C)&&!C.includes(D)&&(window.clay.plugins=Object.freeze([...C,D]))},attachEditCore:se,announce:oe,loadEditHints:i?Se(i,s,f,m):null,late:ne})}await v["core/edit-mode.js"].activateInitialMode(),window.clay.plugins=Object.freeze([...p.plugins,...p.late].map(f=>k[f]));let B=u?p:P(e,!0,{isDraftMode:d,hasSap:r,hasVariants:c,hasSite:y,canEdit:g,templateSource:A()});window.clay.editPlugins=Object.freeze([...B.plugins,...B.late].map(f=>k[f]));for(let f of p.plugins){let E;try{E=await O[f]()}catch(x){console.error(`clayjs: plugin "${f}" failed to load, continuing without it:`,x);continue}v[f]=E,f==="plugins/page-view.js"&&E.start(ie),U(f,E,v)}await Promise.allSettled(p.plugins.map(f=>v[f]?.ready).filter(Boolean)),r&&Pe(v),Te(h),o(window.clay),document.dispatchEvent(new CustomEvent("clay:ready",{detail:{clay:window.clay}})),p.late.length?ke(p.late,h).then(S,S):S()}var N=(t,e)=>b[k[t]]?.editOnly&&!e.startsAtImport();async function ke(t,e){try{await window.clay.blockeditor?.ready}catch{}for(let o of t)if(!N(o,e))try{let s=await O[o]();if(N(o,e)||(v[o]=s,U(o,s,v),await s.ready,N(o,e)))continue;oe(o)}catch(s){console.error(`clayjs: plugin "${o}" failed to load, continuing without it:`,s),document.dispatchEvent(new CustomEvent("clay:plugin-failed",{detail:{plugin:k[o]}}))}}function Pe(t){let e=t["core/save.js"],o=null;try{o=e?e.currentPaintSignature():null}catch(s){console.error("clayjs: could not read the page's painted values:",s)}try{window.Sap&&typeof window.Sap.mount=="function"&&window.Sap.mount()}catch(s){console.error("clayjs: the derive engine failed to mount:",s)}finally{e?.releaseBootSettle()}e&&o!=null&&e.schedulePaintHeal(o)}function Le(t,{isDraftMode:e,isOwner:o,siteVisibility:s},l){let i=window.clay,a=t["lib/mutation.js"],h=t["core/edit-mode.js"];Object.assign(i,{toggleEditMode:h.toggleEditMode,setMode:h.setMode,modeLifecycle:h.modeLifecycle,isDraftMode:e,isOwner:o,siteVisibility:s,Mutation:a.default,region:l.windowRegionShape});for(let d of["mode","isEditMode","canEdit"])Object.defineProperty(i,d,{get:()=>h[d],enumerable:!0,configurable:!0});i.assets=ee;let u=t["core/page-data.js"];i.readData=u.readData,i.writeData=u.writeData,i.ephemeral=H,i.storage=G,i.host={get versions(){return import("./c-Q6VNQDJE.js").then(d=>d.hostVersions())}},i.trash=R,i.derived=z,i.effect=q,i.style=X,i.morph=(d,j,n)=>V().then(({morph:g})=>g(d,j,n))}function se(t){let e=window.clay,o=t["core/save.js"];if(o){let a=o.savePage||o.default;a.force=o.savePageForce,a.overwrite=o.saveOverwritingConflict,a.flush=o.flushSave,a.soon=o.savePageSoon,a.limits=o.saveLimits,a.inspect=o.inspectSaveSize,e.save!==a&&typeof e.save?.replace=="function"&&(a.replace=e.save.replace),e.save!==a&&(e.save=a)}e.hasUnsavedChanges=t["core/unsaved-warning.js"]?.hasUnsavedChanges??e.hasUnsavedChanges??(()=>!1);let s=t["core/snapshot.js"];s&&(e.getHTML||(e.getHTML=s.getPageContents),e.addDocumentTransform||(e.addDocumentTransform=s.addDocumentTransform),e.onSnapshot||(e.onSnapshot=s.onSnapshot));let l=t["lib/cache-bust.js"];l&&!e.cacheBust&&(e.cacheBust=l.default);let i=t["core/recovery.js"];i&&!e.recovery&&(e.recovery=i.recovery)}function U(t,e,o=v){let s=window.clay;t==="plugins/undo.js"?s.undo=e.undo||e.default:t==="plugins/unsent.js"?s.unsent=e.unsent:t==="sync/live-sync.js"?(s.morph=e.morph,s.conflicts=e.conflicts,o["core/page-data.js"].setPageDataLiveSync(e.liveSync)):t==="plugins/live.js"?s.live=e.live:t==="plugins/page.js"?s.blockeditor=e.page:t==="plugins/upgrade.js"?(s.save=s.save||{},s.save.replace=e.replace):t==="plugins/cms.js"?s.cms=e.cms||e.default:t==="plugins/upload.js"?s.upload=e.upload||e.default:t==="plugins/people.js"?(s.people=e.people,s.author=e.author,Object.defineProperty(s,"me",{get:e.currentMe,configurable:!0,enumerable:!0})):t==="plugins/message.js"?s.message=e.message:t==="plugins/like.js"?s.like=e.like:t==="plugins/wire.js"?s.wire=e.wire||e.default:t==="plugins/ai-edit.js"?s.aiEdit=e.aiEdit||e.default:t==="plugins/demo.js"?s.demo=e.demo:t==="plugins/richclay.js"?s.RichClay=e.RichClay||e.default:t==="plugins/quickcrop.js"?s.quickcrop=e.quickcrop||e.default:t==="plugins/sortable.js"?s.sortable=e.sortable:t==="plugins/source.js"?s.source=e.source||e.default:t==="plugins/visitor-drafts.js"||t==="plugins/visitor-drafts-owner.js"?s.visitorDrafts=e.visitorDrafts:t==="plugins/bind-text.js"&&(s.bindText=e.bindText)}function Te(t){t.isEditMode||document.addEventListener("click",e=>{e.target.closest?.("[trigger-save]")&&(t.isEditMode||(console.info("clayjs: you're not the owner of this page; changes stay local"),document.dispatchEvent(new CustomEvent("clay:view-save-attempt"))))})}export{Je as boot,Pe as mountDerivedEngine};
|