@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
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as ee}from"./c-4Q6QIODW.js";import{b as Q}from"./c-3G2DGZUP.js";import{p as K,q as Z}from"./c-MFB74XVN.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import{a as B,h as X}from"./c-KU3PX7LL.js";import"./c-EQ5NBOGA.js";import"./c-IJUK2GPW.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-PNZIJFG7.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var We=Object.defineProperty,Ve=(e,t)=>{for(var r in t)We(e,r,{get:t[r],enumerable:!0})},Fe=["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"],ze=new Set(Fe),_e=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),he=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),te=new Set(["checked","selected","disabled","readOnly","paused"]);function Je(e,t){return t==null?te.has(e)?!1:"":te.has(e)?t==="false"?!1:!!t:t}var Ye={};Ve(Ye,{CodecRefused:()=>et,EmptyListInsert:()=>R,MAX_RULE_DEPTH:()=>L,MaxRuleDepthExceeded:()=>G,NoRulesTag:()=>Ze,RuleTargetReadOnly:()=>ge,RulesParseError:()=>$,ShapeMismatch:()=>ye,UnknownCodec:()=>we,UnknownRulesVersion:()=>me,WriteNotRoundTripped:()=>Ke,WriteRefused:()=>Ge,WriteRejected:()=>Qe});var $=class extends Error{constructor(e,t){super(e),this.name="RulesParseError",this.cause=t}},me=class extends Error{constructor(e){super(`unknown rules version: ${e}. Library supports "1" and "2".`),this.name="UnknownRulesVersion",this.version=e}},L=20,G=class extends Error{constructor(e){super(`rule depth exceeded ${L} at path: ${e.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=e}},ye=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}},ge=class extends Error{constructor(e){super(`cannot write to read-only DOM property "${e}"`),this.name="RuleTargetReadOnly",this.target=e}},Ge=class extends Error{constructor(e){super(`write refused: ${e.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=e}};function Xe(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t?`${t}.${r}`:String(r),"")||"(root)"}var Ke=class extends Error{constructor(e){super(`write did not round-trip at "${Xe(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}},Qe=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}},we=class extends Error{constructor(e){super(`unknown codec "${e}": no codec by that name is given to this call`),this.name="UnknownCodec",this.code="unknown-codec",this.codec=e}},et=class extends Error{constructor(e,t){super(t),this.name="CodecRefused",this.code=e}};function M(e){let t=0,r=null,o=-1;for(let n=0;n<e.length;n++){let l=e[n];l==="\\"?n++:r?l===r&&(r=null):l==='"'||l==="'"?r=l:l==="["||l==="("?t++:l==="]"||l===")"?t>0&&t--:l==="@"&&t===0&&(o=n)}return o}var re="[*]";function j(e){let t=M(e),r=t===-1?e:e.slice(0,t),o=r.endsWith(re),n={selector:o?r.slice(0,-re.length):r,prop:t===-1?null:e.slice(t+1)||null};return o&&(n.all=!0),n}function ve(e){let t=0,r=null,o=-1,n=!1;for(let l=0;l<e.length;l++){let i=e[l];i==="\\"?l++:r?i===r&&(r=null):i==='"'||i==="'"?r=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:t===0&&i===">"?o=l:t===0&&i===","&&(n=!0)}return n||o===-1||!tt(e,o+1)?null:e.slice(0,o).trim()||null}function tt(e,t){let r=t,o=e.replace(/\s+$/,"").length;for(;r<o&&/\s/.test(e[r]);)r++;let n=0,l=null;for(;r<o;r++){let i=e[r];if(i==="\\")r++;else if(l)i===l&&(l=null);else if(i==='"'||i==="'")l=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 rt=/^codec\(([a-z][a-z0-9-]*)\)$/;function P(e){if(typeof e!="string")return null;let t=M(e);if(t===-1)return null;let r=rt.exec(e.slice(t+1));if(!r)return null;let{selector:o,all:n}=j(e);if(n)throw new $("A @codec(name) rule cannot use [*].");return{selector:o,name:r[1]}}var nt=/^--[A-Za-z0-9_-]+$/;function be(e){return typeof e=="string"&&nt.test(e)}function xe(e){let t=[],r=[],o=null,n=0;for(let l=0;l<e.length;l++){let i=e[l];if(o){i==="\\"?l++:i===o&&(o=null);continue}if(i==="/"&&e[l+1]==="*"){let a=e.indexOf("*/",l+2);l=a===-1?e.length:a+1;continue}i==='"'||i==="'"?o=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,l)),n=l+1)}return t.push(e.slice(n)),t}function ot(e){let t="",r=null;for(let o=0;o<e.length;o++){let n=e[o];if(r){t+=n,n==="\\"&&o+1<e.length?t+=e[++o]:n===r&&(r=null);continue}if(n==="/"&&e[o+1]==="*"){let l=e.indexOf("*/",o+2);o=l===-1?e.length:l+1,t+=" ";continue}(n==='"'||n==="'")&&(r=n),t+=n}return t}function Ae(e){e=ot(e);let t=e.indexOf(":");if(t===-1)return null;let r=e.slice(0,t).trim(),o=e.slice(t+1).trim(),n=/!\s*important\s*$/i.exec(o);return n&&(o=o.slice(0,n.index).trim()),{name:r,value:o,important:!!n}}function Te(e,t){if(e==null)return null;let r=null;for(let o of xe(String(e))){let n=Ae(o);!n||n.name!==t||(!r||n.important||!r.important)&&(r=n)}return r?r.value:null}function lt(e,t,r){let o=e==null?"":String(e),n=r==null||r==="",l=xe(o),i=l.map(Ae),a=i.some(u=>u&&u.name===t&&u.important),s=[],c=!1;l.forEach((u,d)=>{let m=i[d];if(!m||m.name!==t){s.push(u);return}if(n||c)return;let p=/^\s*/.exec(u)[0];s.push(`${p}${t}: ${r}${a?" !important":""}`),c=!0});let f=s.join(";");if(!n&&!c){let u=f.trimEnd();f=u===""?`${t}: ${r}`:`${u}${u.endsWith(";")?" ":"; "}${t}: ${r}`}return f.trim()===""?null:f}function it(e,t,r,o){let n=e.attr(t,"style");if((Te(n,r)??"")===o)return;let l=lt(n,r,o);l==null?e.removeAttr(t,"style"):e.attr(t,"style",l)}var at='The @codec(name) rule form needs a rules tag with data-rules-version="2".',st="A @codec(name) rule must be the value of a top level key.";function Oe(e,t){let r=P(e);return r?{...r,codec:t.codecs[r.name]}:null}function Ee(e,t={}){let r=t.version??"1",o=t.codecs??{};n(e,0);function n(l,i){if(!(i>L)){if(typeof l=="string"){let a=P(l);if(!a)return;if(r!=="2")throw new $(at);if(i!==1)throw new $(st);if(!Object.prototype.hasOwnProperty.call(o,a.name))throw new we(a.name);return}if(Array.isArray(l)){n(l[1],i+1);return}if(l&&typeof l=="object")for(let a of Object.values(l))n(a,i+1)}}}function ke(e,t,r,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return Ee(r,o),V(e,t,r,{depth:0,path:[]},o)}function V(e,t,r,o,n){if(o.depth>L)throw new G(o.path);if(typeof r=="string")return ut(e,t,r,o,n);if(Array.isArray(r)){let[l,i]=r,a=e.find(t,l,n);return Ne(n,o,a),a.map((s,c)=>V(e,s,i,{depth:o.depth+1,path:[...o.path,c]},n))}if(typeof r=="object"&&r!==null){let l={};for(let[i,a]of Object.entries(r))l[i]=V(e,t,a,{depth:o.depth+1,path:[...o.path,i]},n);return l}return null}function ut(e,t,r,o,n){if(r.endsWith("[]")){let f=r.slice(0,-2),u=e.find(t,f,n);return Ne(n,o,u),u.map(d=>e.text(d))}let l=Oe(r,n);if(l)return ct(e,t,l,n);if(r.startsWith("@"))return W(e,t,r.slice(1));let i=M(r);if(i!==-1){let{selector:f,all:u}=j(r),d=r.slice(i+1),m=f?e.find(t,f,n):[t];return u&&n.allMatches?m.map(p=>W(e,p,d)):m.length===0?null:W(e,m[0],d)}if(r===".")return e.text(t);let{selector:a,all:s}=j(r),c=e.find(t,a,n);return s&&n.allMatches?c.map(f=>e.text(f)):c.length===0?null:e.text(c[0])}function ct(e,t,{selector:r,codec:o},n){let l=r?e.find(t,r,n):[t];return l.length===0?null:o.read(e,l[0],{query:n.query,view:n.view,region:n.region})}function Ne(e,t,r){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),r)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function W(e,t,r){if(be(r))return Te(e.attr(t,"style"),r);if(ze.has(r)){let n=e.prop(t,r);return n==null?null:String(n)}return e.attr(t,r)??null}function ft(e,t,r,o){let n=e.length,l=t.length,i=new Array(n).fill(-1);if(o){let h=new Set;for(let y=0;y<n;y++){let g=o[y];!(g>=0&&g<l)||h.has(g)||(i[y]=g,h.add(g))}}if(n===0||l===0)return i;let a=e.map(h=>ne(h,r)),s=t.map(h=>ne(h,r)),c=new Array(l).fill(!1);for(let h of i)h>=0&&(c[h]=!0);let f=new Map;s.forEach((h,y)=>{c[y]||f.set(h,f.has(h)?-1:y)});let u=new Map;a.forEach((h,y)=>{i[y]>=0||u.set(h,(u.get(h)||0)+1)}),a.forEach((h,y)=>{if(i[y]>=0||u.get(h)!==1)return;let g=f.get(h);g===void 0||g===-1||c[g]||(i[y]=g,c[g]=!0)});let d=[];for(let h=0;h<n;h++)i[h]<0&&d.push(h);let m=[];for(let h=0;h<l;h++)c[h]||m.push(h);if(d.length===0||m.length===0)return i;let p=n*l+1,w=dt(e,t,r),v=(h,y)=>w(h,y)*p+Math.abs(h-y);for(let[h,y]of pt(d,m,v))i[h]=y;return i}var Se=e=>typeof e=="object"&&e!==null;function ne(e,t){if(!Se(t))return e==null?" null":String(e);let r=Object.keys(t);return JSON.stringify(r.map(o=>{let n=JSON.stringify(e?.[o]);return n===void 0?" undef":n}))}function dt(e,t,r){if(!Se(r))return(a,s)=>e[a]===t[s]?0:1;let o=Object.keys(r),n=a=>o.map(s=>JSON.stringify(a?.[s])),l=e.map(n),i=t.map(n);return(a,s)=>{let c=l[a],f=i[s],u=0;for(let d=0;d<o.length;d++)c[d]!==f[d]&&u++;return u}}function pt(e,t,r){return e.length<=t.length?oe(e,t,r,!1):oe(t,e,(o,n)=>r(n,o),!0)}function oe(e,t,r,o){let n=e.length,l=t.length,i=[];for(let u=0;u<=n;u++)i.push(new Float64Array(l+1).fill(1/0));let a=[];for(let u=0;u<=n;u++)a.push(new Uint8Array(l+1));for(let u=0;u<=l;u++)i[n][u]=0;for(let u=n-1;u>=0;u--)for(let d=l-1;d>=0;d--){let m=r(e[u],t[d])+i[u+1][d+1],p=i[u][d+1];m<=p?(i[u][d]=m,a[u][d]=1):i[u][d]=p}let s=[],c=0,f=0;for(;c<n&&f<l;)a[c][f]&&(s.push(o?[t[f],e[c]]:[e[c],t[f]]),c++),f++;return s}function Re(e,t,r,o,n,l,i,a={}){let s=e.find(t,r,a);if(n.length===0){s.forEach(b=>e.remove(b)),F(a,"onRowsApplied",l.path,[]);return}let c=n.length>s.length,f=s[0]||null;if(c&&!f&&(f=gt(e,t,r,a),!f))throw new R(l.path);let u=s.map(b=>yt(e,b,o,a)),d=null;if(c&&f){d=e.clone(f),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 "${l.path.join(".")||"(root)"}"`)}let m=ft(n,u,o,ht(e,s,n,l,a)),p=s.length>0?e.parent(s[0]):xt(e,t,r,f,l,a),w=s.length>0?$e(e,p,s[0]):0,v=Ot(e,s),h=new Set,y=[],g=n.map((b,E)=>{let k=m[E];if(k>=0)return h.add(k),y.push(!1),s[k];y.push(!0);let T=e.clone(d);return e.stripIds(T),T});s.forEach((b,E)=>{h.has(E)||e.remove(b)}),v?Tt(e,p,w,g,y):Et(e,g,y,p,w),mt(e,g,o,n,l,i,a),F(a,"onRowsApplied",l.path,g)}function F(e,t,r,o){if(typeof e[t]=="function")try{return e[t](r.slice(),o)}catch(n){console.warn(`[hyper-html-api] ${t} threw at "${r.join(".")||"(root)"}"`,n);return}}function ht(e,t,r,o,n){let l=F(n,"identifyRows",o.path,r);if(!Array.isArray(l))return null;let i=new Array(r.length).fill(-1),a=new Set,s=new Map(t.map((c,f)=>[e.identity(c),f]));for(let c=0;c<r.length;c++){if(!l[c])continue;let f=s.get(e.identity(l[c]));f===void 0||a.has(f)||(i[c]=f,a.add(f))}return i}function mt(e,t,r,o,n,l,i){t.forEach((a,s)=>{if(r===null){let c=o[s],f=c==null?"":String(c);e.text(a)!==f&&e.text(a,f)}else{let c=l(e,a,r,o[s],{depth:n.depth+1,path:[...n.path,s]},i);c&&c!==a&&(t[s]=c)}})}function yt(e,t,r,o){return r===null?e.text(t):ke(e,t,r,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function $e(e,t,r){let o=e.children(t);for(let n=0;n<o.length;n++)if(e.sameNode(o[n],r))return n;return-1}function gt(e,t,r,o){if(!o.templateAttr)return null;let n=/^\s*:scope\s*>\s*/.test(r),l=new RegExp(":not\\(\\["+o.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),i=r.replace(/^\s*:scope\s*>\s*/,"").replace(l,""),a=n?wt(i):0,s=ve(i),c=t;for(;c;){let f=e.find(c,i,{includeRulesTag:!1,templateAttr:null});for(let u of f)if(e.attr(u,o.templateAttr)!=null&&!(n&&!bt(e,t,u,a))&&!(s&&!e.matches(e.parent(u),s)))return u;c=e.parent(c)}return null}function wt(e){let t=0,r=null,o=1;for(let n=0;n<e.length;n++){let l=e[n];if(l==="\\")n++;else if(r)l===r&&(r=null);else if(l==='"'||l==="'")r=l;else if(l==="["||l==="(")t++;else if(l==="]"||l===")")t>0&&t--;else if(t===0&&l===">")o++;else{if(t===0&&(l==="+"||l==="~"))return null;if(t===0&&/\s/.test(l)){if(!vt(e,n))return null;for(;n+1<e.length&&/\s/.test(e[n+1]);)n++}}}return o}function vt(e,t){let r=t;for(;r<e.length&&/\s/.test(e[r]);)r++;let o=t>0?e[t-1]:"",n=r<e.length?e[r]:"";return le(o)||le(n)}function le(e){return e===">"||e==="+"||e==="~"}function bt(e,t,r,o){if(o===null)return!0;let n=r;for(let s=0;s<o;s++)if(n=e.parent(n),!n)return!1;let l=e.prop(t,"tagName");if(!l)return!0;let i=e.prop(n,"tagName");if(!i||String(i).toLowerCase()!==String(l).toLowerCase())return!1;let a=new Set(ie(e,n));return ie(e,t).every(s=>a.has(s))}function ie(e,t){let r=e.attr(t,"class");return r?String(r).split(/\s+/).filter(Boolean):[]}function xt(e,t,r,o,n,l){let i=e.parent(o);if(i&&At(e,t,i)&&!se(e,i,l))return i;let a=ve(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,l)).filter(c=>!se(e,c,l));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 At(e,t,r){let o=r;for(;o;){if(e.sameNode(o,t))return!0;o=e.parent(o)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(n=>e.sameNode(n,r))}var ae=["no-data","editor-ui"];function se(e,t,r){let o=t;for(;o;){if(r.templateAttr&&e.attr(o,r.templateAttr)!=null||ae.some(l=>e.attr(o,l)!=null))return!0;let n=e.attr(o,"clay");if(n&&n.split(/\s+/).some(l=>ae.includes(l)))return!0;o=e.parent(o)}return!1}function Tt(e,t,r,o,n){let l=e.children(t),i=l.map(s=>e.identity(s)),a=!1;o.forEach((s,c)=>{let f=e.identity(s),u=r+c;if(i[u]===f)return;if(!n[c]){let m=i.indexOf(f);m!==-1&&(i.splice(m,1),l.splice(m,1))}let d=Math.min(u,l.length);d<l.length?e.insertBefore(l[d],s):l.length?a?e.insertAfter(l[l.length-1],s):(e.insertAt(t,s,u),a=!0):e.insertAt(t,s,0),i.splice(d,0,f),l.splice(d,0,s)})}function Ot(e,t){if(t.length<=1)return!0;let r=e.parent(t[0]);if(!r)return!1;let o=new Map(e.children(r).map((l,i)=>[e.identity(l),i])),n=[];for(let l of t){let i=o.get(e.identity(l));if(i===void 0)return!1;n.push(i)}return n.sort((l,i)=>l-i),n[n.length-1]-n[0]===n.length-1}function Et(e,t,r,o,n){let l=null,i=n;for(let a=0;a<t.length;a++){if(!r[a]){l=t[a];continue}let s=l?e.parent(l):o;if(!s)continue;let c=l?$e(e,s,l)+1:i++;e.insertAt(s,t[a],c),l=t[a]}}function kt(e,t,r,o,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.");Ee(r,n);let l=[];if(z(r,o,[],l),l.length)throw new ye(l);I(e,t,r,o,{depth:0,path:[]},n)}function I(e,t,r,o,n,l={}){if(n.depth>L)throw new G(n.path);if(o===void 0)return t;if(typeof r=="string")return Nt(e,t,r,o,n,l);if(Array.isArray(r)){let[i,a]=r;return Re(e,t,i,a,o,n,I,l),t}if(typeof r=="object"&&r!==null){for(let[i,a]of Object.entries(r)){let s=I(e,t,a,o==null?o:o[i],{depth:n.depth+1,path:[...n.path,i]},l);s&&s!==t&&(t=s)}return t}return t}function Nt(e,t,r,o,n,l){if(r.endsWith("[]")){let u=r.slice(0,-2);return Re(e,t,u,null,o,n,I,l),t}let i=Oe(r,l);if(i){let u=i.selector?e.find(t,i.selector,l):[t];return u.length&&i.codec.write(e,u[0],o,{query:l.query}),t}if(r.startsWith("@"))return ce(e,t,r.slice(1),o);let a=M(r);if(a!==-1){let{selector:u,all:d}=j(r),m=r.slice(a+1),p=u?e.find(t,u,l):[t];for(let w of d?p:p.slice(0,1))ce(e,w,m,o);return t}if(r===".")return ue(e,t,o),t;let{selector:s,all:c}=j(r),f=e.find(t,s,l);for(let u of c?f:f.slice(0,1))ue(e,u,o);return t}function ue(e,t,r){let o=r==null?"":String(r);e.text(t)!==o&&e.text(t,o)}function St(e,t,r,o){if(e.styleVar){e.styleVar(t,r,o);return}it(e,t,r,o)}function ce(e,t,r,o){if(be(r))return St(e,t,r,o==null?"":String(o).trim()),t;if(he.has(r)){let n=e.prop(t,r);if(n===o||n!=null&&o!=null&&String(n)===String(o))return t;throw new ge(r)}if(r==="outerHTML"){let n=o==null?"":String(o);return e.replaceWith(t,n)}if(_e.has(r)){let n=Je(r,o);return e.prop(t,r)!==n&&e.prop(t,r,n),t}if(o==null)e.attr(t,r)!=null&&e.removeAttr(t,r);else{let n=String(o);e.attr(t,r)!==n&&e.attr(t,r,n)}return t}function z(e,t,r,o){if(t!==void 0){if(typeof e=="string"){if(P(e))return;if(e.endsWith("[]")){Array.isArray(t)?t.forEach((n,l)=>{typeof n=="object"&&n!==null&&o.push({path:S([...r,l]),expected:"scalar",got:N(n)})}):o.push({path:S(r),expected:"array",got:N(t)});return}t!==null&&typeof t=="object"&&o.push({path:S(r),expected:"scalar",got:N(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:S(r),expected:"array",got:N(t)});return}let n=e[1];t.forEach((l,i)=>z(n,l,[...r,i],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:S(r),expected:"object",got:N(t)});return}for(let[n,l]of Object.entries(e))z(l,t[n],[...r,n],o)}}}function N(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function S(e){return e.join(".")}function Rt(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 l=[],i=0;for(;i<n.length;){let a=n[i];if(/\s/.test(a)){i++;continue}if("{}".includes(a)){l.push({type:a,value:a}),i++;continue}if(a==="["){let u=!1,d=i+1;for(;d<n.length&&/\s/.test(n[d]);)d++;if(d<n.length&&/[a-zA-Z_]/.test(n[d])&&(u=!0),!u){l.push({type:a,value:a}),i++;continue}}if(a==="]"){l.push({type:a,value:a}),i++;continue}if(a===":"){l.push({type:t.COLON,value:a}),i++;continue}if(a===","){l.push({type:t.COMMA,value:a}),i++;continue}if(a==='"'||a==="'"){let u=a,d=i+1;for(;d<n.length&&n[d]!==u;)n[d]==="\\"&&d++,d++;l.push({type:t.STRING,value:n.substring(i+1,d),quoted:!0,sourceQuote:u}),i=d+1;continue}let s=i,c;for(;s<n.length&&!/[{},]/.test(n[s]);)if(n[s]===":"){let u=[":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 u){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 u=n[s];for(s++;s<n.length&&n[s]!==u;)n[s]==="\\"&&s++,s++}s++}s<n.length&&n[s]==="]"&&s++}else s++;c=n.substring(i,s);let f=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(c)?f=t.NUMBER:c==="true"||c==="false"||c==="null"?f=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(c)&&(f=t.SELECTOR),l.push({type:f,value:c,quoted:!1}),i=s}return l}function o(n){let l="";for(let i=0;i<n.length;i++){let a=n[i];if("{}".includes(a.type)||"[]".includes(a.type)){l+=a.value;continue}if(a.type===t.COLON){l+=a.value;continue}if(a.type===t.COMMA){let s=n[i+1];if(s&&(s.type==="}"||s.type==="]"))continue;l+=a.value;continue}if(a.type===t.STRING&&a.quoted){let s=a.value;a.sourceQuote==="'"&&(s=s.replace(/\\'/g,"'"),s=s.replace(/(\\*)"/g,(c,f)=>f.length%2===0?f+'\\"':c)),l+=`"${s}"`;continue}if(a.type===t.NUMBER||a.type===t.BOOLEAN){l+=a.value;continue}if(a.type===t.SELECTOR||a.type===t.IDENTIFIER){l+=`"${a.value}"`;continue}l+=`"${a.value}"`}return l}try{let n=r(e),l=o(n);return JSON.parse(l)}catch(n){throw new $("Invalid extraction rules syntax: "+n.message,n)}}var $t=["1","2"];var Ar=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"]})}),Tr=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),jt=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);var Or=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",...jt],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 Ct(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Lt(e){return e?(e.nodeType===9||e.nodeType,e):null}function fe(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 Mt(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function Ut(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 o=r.type;o!=="file"&&o!=="checkbox"&&o!=="radio"&&(r.value=r.defaultValue),r.checked=r.defaultChecked}else r.tagName==="OPTION"&&(r.selected=r.defaultSelected)}var It={semanticExclude:!0,find(e,t,r={}){let o=Lt(e);if(!o||!o.querySelectorAll)return[];let n=Array.from(o.querySelectorAll(t));r.includeRulesTag||(n=n.filter(a=>!Ct(a)));let l=[];r.skip&&l.push(r.skip);let i=r.templateAttr===null?null:r.templateAttr||"cms-template";if(i&&l.push("["+i+"]"),l.length){let a=l.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,Mt(e,t)},attr(e,t,r){if(r===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,r),fe(e,t,r)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),fe(e,t,null)},prop(e,t,r){if(r===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=r},clone(e){let t=e.cloneNode(!0);return Ut(t),t},insertAt(e,t,r){let o=e.children[r]||null;e.insertBefore(t,o)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let r=e.ownerDocument.createElement("template");r.innerHTML=t;let o=r.content.firstElementChild;if(!o)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(o,e),o},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 U=It;var Pt="hha:upgrade-check:";function x(e,t){let r=e.querySelector(`meta[name="${t}"]`),o=r?r.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function de(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function Dt(e,t){let r=de(e),o=de(t);if(!r||!o)return!1;let n=Math.max(r.length,o.length);for(let l=0;l<n;l++){let i=r[l]||0,a=o[l]||0;if(i!==a)return i>a}return!1}function qt(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function Ht(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function Bt({force:e=!1,doc:t,loc:r,fetchFn:o,now:n,ttlMs:l=864e5}={}){if(t=t||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),o=o||(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 c=`${Pt}${s.href}:${a||"none"}`,f,u=e?null:qt(c);if(u&&typeof u.checkedAt=="number"&&n-u.checkedAt<l)f=u.sourceVersion;else{try{let d=await o(s.href);if(!d.ok)throw new Error(`HTTP ${d.status}`);let m=await d.text(),p=new DOMParser().parseFromString(m,"text/html");f=x(p,"hyper-version")}catch{f=null}Ht(c,{checkedAt:n,sourceVersion:f})}return f?{available:Dt(f,a||"0.0.0"),currentVersion:a,sourceVersion:f,sourceUrl:s.href}:null}var Wt="script[data-rules-name]";function Vt(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function je(e,t){let r=e.find(t,Wt,{includeRulesTag:!0}),o=new Set,n=[];for(let l of r){let i=Vt(e.attr(l,"data-rules-name"));if(!i)continue;if(o.has(i)){console.warn(`hyper-html-api: duplicate rules tag name "${i}"; using the first.`);continue}let a=e.attr(l,"data-rules-version");if(!$t.includes(a))throw new me(a);o.add(i),n.push({name:i,rules:Rt(e.text(l)),version:a})}return n}function Ce(e,t){if(t!=="2"||!e||typeof e!="object"||Array.isArray(e))return{rules:e,carried:[]};let r={},o=[];for(let[n,l]of Object.entries(e)){let i=P(l);i?o.push({key:n,selector:i.selector}):r[n]=l}return{rules:r,carried:o}}function Le(e,t,r){return e.find(t,r)[0]||null}function Me(e,t){let r={};for(let{name:o,rules:n,version:l}of je(e,t)){let{rules:i,carried:a}=Ce(n,l),s=ke(e,t,i,{version:l});for(let{key:c,selector:f}of a){let u=Le(e,t,f);s[c]=u?e.prop(u,"innerHTML"):null}r[o]=s}return r}function Ft(e){let t=e||document,r=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:Me(U,t),version:x(r,"hyper-version")}}var pe=class extends Error{constructor(e,t){super(`could not fetch upgrade source: ${e}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=e,this.cause=t}},zt=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}},_=class extends Error{constructor(e,t){super(e),this.name="UpgradeTransformInvalid",this.cause=t}},_t=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}},Jt="text/hyper-upgrade";function Yt(e,t){let r=e.find(t,`script[type="${Jt}"]`);if(r.length===0)return null;if(r.length>1)throw new _t(r.length);return e.text(r[0])||null}var Gt=new Function("url","return import(url)");async function Xt(e){let t=new Blob([e],{type:"text/javascript"}),r=URL.createObjectURL(t),o;try{o=await Gt(r)}catch(n){throw new _(`transform failed to load: ${n&&n.message?n.message:n}`,n)}finally{URL.revokeObjectURL(r)}if(typeof o.default!="function")throw new _("transform must `export default` a function");return o.default}function Ue(e,t){let r={carriedOver:0,discarded:0,listItems:0},o=J(t,e,r);return Y(t,e,r),{data:o,summary:r}}function J(e,t,r,o=!1){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(r.listItems+=t.length,r.carriedOver+=t.length,t):o?[]:void 0:t==null||typeof t=="object"?o&&!Kt(e)?null:void 0:(r.carriedOver++,t);if(Array.isArray(e)){let[,n]=e;return Array.isArray(t)?(r.listItems+=t.length,t.map(l=>J(n,l,r,!0))):o?[]:void 0}if(typeof e=="object"&&e!==null){let n={};for(let[l,i]of Object.entries(e)){let a=J(i,t?.[l],r,o);a!==void 0&&(n[l]=a)}return n}}function Kt(e){let t=M(e);return t!==-1&&he.has(e.slice(t+1))}function Y(e,t,r){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let o=new Set(Object.keys(e));for(let n of Object.keys(t))o.has(n)?Y(e[n],t[n],r):r.discarded+=C(t[n]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(n=>Y(o,n,r));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(r.discarded+=C(t))}}function C(e){return e==null?0:Array.isArray(e)?e.reduce((t,r)=>t+C(r),0):typeof e=="object"?Object.values(e).reduce((t,r)=>t+C(r),0):1}function Zt(e,t,r){let o=je(e,t),n={carriedOver:0,discarded:0,listItems:0},l={},i=new Set;for(let{name:a,rules:s,version:c}of o){if(i.add(a),!Object.prototype.hasOwnProperty.call(r,a)){l[a]={carriedOver:0,discarded:0,listItems:0};continue}let{rules:f,carried:u}=Ce(s,c),d=r[a],{data:m,summary:p}=Ue(Qt(d,u),f);kt(e,t,f,m,{templateAttr:"cms-template"});for(let{key:w,selector:v}of u){let h=Ie(d)?d[w]:void 0;if(h==null)continue;let y=Le(e,t,v);typeof h=="string"&&y?(e.prop(y,"innerHTML",h),p.carriedOver+=1):p.discarded+=1}l[a]=p,n.carriedOver+=p.carriedOver,n.discarded+=p.discarded,n.listItems+=p.listItems}for(let a of Object.keys(r))i.has(a)||(n.discarded+=C(r[a]));return{totals:n,byName:l,rulesTagCount:o.length}}function Ie(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Qt(e,t){if(!t.length||!Ie(e))return e;let r={...e};for(let{key:o}of t)delete r[o];return r}async function er({sourceUrl:e,dataByName:t,fromVersion:r,doc:o,loc:n,fetchFn:l}={}){if(o=o||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),l=l||(h=>fetch(h)),!o)throw new Error("upgrade.run requires a document context");if(e=e||x(o,"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(o,"hyper-version"),t=t||Me(U,o);let a;try{a=await l(i.href)}catch(h){throw new pe(i.href,h)}if(!a.ok)throw new pe(i.href,new Error(`HTTP ${a.status}`));let s=await a.text(),c=new DOMParser().parseFromString(s,"text/html"),f=x(c,"hyper-version"),u=t,d=!1,m=Yt(U,c);if(m){let h=await(await Xt(m))(u,{fromVersion:r,toVersion:f});if(!h||typeof h!="object"||Array.isArray(h))throw new _("transform must return a plain object map of { rulesName: data }");u=h,d=!0}let{totals:p,byName:w,rulesTagCount:v}=Zt(U,c,u);if(v===0&&Object.keys(u).length>0)throw new zt(i.href);return{html:rr(c),fromVersion:r,toVersion:f,summary:{transformApplied:d,totals:p,byName:w}}}function tr(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 o=r.findIndex(n=>n.hasAttribute("selected"));if(t.selectedIndex===o||o===-1&&t.selectedIndex<=0)continue}for(let o of r)o.selected!==o.hasAttribute("selected")&&o.toggleAttribute("selected",o.selected)}}function rr(e){return tr(e),`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
2
|
+
`+e.documentElement.outerHTML}var D={checkForUpdate:Bt,run:er,extractAll:Ft,shapeMatch:Ue};var A="The new version could not be downloaded. Nothing was changed.",q="The upgrade could not be saved. Nothing was changed.",qe="This document changed somewhere else. Reload and try again.",nr="Something else is changing this document. Nothing was changed.",or="This document does not say which parts are its data, so it cannot be upgraded safely. Nothing was changed.",lr="The new version has no place for this page's content. Nothing was changed.";async function ir(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(o=>o.toString(16).padStart(2,"0")).join("")}async function Pe(e,t){try{let r=await e(t,{credentials:"omit"});return!r||!r.ok?null:r}catch{return null}}function ar(e,t,r){if(e&&typeof e.latestUrl=="string"&&e.latestUrl)return e.latestUrl;let o=x(t,"hyper-source");if(!o)return null;try{let n=new URL(o,r?r.href:void 0);return n.pathname=n.pathname.replace(/\.html$/,".json"),n.href}catch{return null}}function sr(e){let t=x(e,"clay-template");if(!t)return null;let[r,o]=t.split(/\s+/);return r&&o?{id:r,variant:o}:null}function H(e,t="",r=[]){if(Array.isArray(e)){for(let o of e)H(o,`${t}[]`,r);return r}if(e&&typeof e=="object"){for(let[o,n]of Object.entries(e))H(n,t?`${t}.${o}`:o,r);return r}return e!=null&&r.push({path:t,value:e}),r}function ur(e,t){let r=[e];for(let o of String(t).split(".")){let n=o.endsWith("[]"),l=n?o.slice(0,-2):o,i=[];for(let a of r){let s=l?a?.[l]:a;n?Array.isArray(s)&&i.push(...s):i.push(s)}r=i}return r}function cr(e,t,r={}){let o=new Map;for(let{path:l,value:i}of H(t)){let a=`${l}\0${String(i)}`;o.set(a,(o.get(a)||0)+1)}let n=[];for(let{path:l,value:i}of H(e)){let a=`${l}\0${String(i)}`;if(o.get(a)>0){o.set(a,o.get(a)-1);continue}let s=r[l];typeof s=="string"&&ur(t,s).some(c=>c===i)||n.push({path:l,value:i})}return n}async function fr(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 dr(e){let r=new DOMParser().parseFromString(e,"text/html").querySelector('script[type="text/hyper-upgrade"]');if(!r)return{};let o=await fr(r.textContent||"");return o&&o.renames&&typeof o.renames=="object"?o.renames:{}}var De='script[clay~="live"][merge]';function pr(e,t,r){let o=t.querySelector("article[data-blockeditor]");if(!o)return null;o.replaceWith(t.importNode(r,!0));for(let l of e.querySelectorAll(De)){let i=l.getAttribute("merge");if(i!=="blockeditor"&&!i.startsWith("blockeditor."))continue;let a=t.importNode(l,!0),s=[...t.querySelectorAll(De)].find(c=>c.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 He(e,{doc:t=document,loc:r=location,fetchFn:o=(n,l)=>fetch(n,l)}={}){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 l=ar(e,t,r);if(!l)return{ok:!1,code:"unavailable",message:A};let i=await Pe(o,l);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=sr(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 c=x(t,"hyper-version");if(!c||typeof a.version!="string"||!Q(a.version,c))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 f;try{f=new URL(a.html,l).href}catch{return{ok:!1,code:"unavailable",message:A}}if(!/^https:\/\/hyperclay\.com\/templates\//.test(f))return{ok:!1,code:"source",message:"This upgrade is not from the template host."};let u=await Pe(o,f);if(!u)return{ok:!1,code:"unavailable",message:A};let d;try{d=await u.text()}catch{return{ok:!1,code:"unavailable",message:A}}let m=await ir(new TextEncoder().encode(d));if(!m||m!==String(a.sha256||"").toLowerCase())return{ok:!1,code:"unavailable",message:A};let p,w;try{w=await dr(d),p=await D.run({sourceUrl:f,doc:t,loc:r,fromVersion:c,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=D.extractAll(t).dataByName,y=t.querySelector("article[data-blockeditor]");if(!y&&!Object.keys(h||{}).length)return{ok:!1,code:"undeclared",message:or};let g=p.html;if(y){let T=pr(t,v,y);if(!T)return{ok:!1,code:"lost",lost:[],discarded:0,message:lr};g=T}let b=D.extractAll(v).dataByName,E=cr(h,b,w),k=p.summary&&p.summary.totals&&p.summary.totals.discarded||0;return E.length||k>0?{ok:!1,code:"lost",lost:E,discarded:k,message:hr(E,k)}:{ok:!0,html:g,version:p.toVersion||a.version}}function hr(e,t){let r=e.slice(0,5).map(({path:n})=>n),o=e.length>r.length?` and ${e.length-r.length} more`:"";return r.length?`This upgrade would lose data: ${r.join(", ")}${o}. Nothing was changed.`:`This upgrade would lose ${t} value${t===1?"":"s"}. Nothing was changed.`}function mr(e){let t=e&&e.state;if(t==="conflict")return{ok:!1,code:"conflict",message:qe};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 Be(e,{doc:t=document,loc:r=location,fetchFn:o=(s,c)=>fetch(s,c),clay:n=typeof window<"u"?window.clay:null,reload:l=()=>window.location.reload(),replace:i=null,etag:a}={}){if((n||{}).isDraftMode)return{ok:!1,code:"draft"};let c=K("upgrade");if(!c)return{ok:!1,code:"busy",message:nr};try{return await yr(e,{doc:t,loc:r,fetchFn:o,clay:n,reload:l,replace:i,etag:a})}finally{Z(c)}}async function yr(e,{doc:t,loc:r,fetchFn:o,clay:n,reload:l,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 mr(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 X()}catch{}let c=a!==void 0?a:B(),f=t;if(s.isEditMode&&typeof s.getHTML=="function")try{f=new DOMParser().parseFromString(await s.getHTML(),"text/html")}catch{return{ok:!1,code:"failed",message:q}}else f=new DOMParser().parseFromString(`<!DOCTYPE html>
|
|
4
|
+
`+t.documentElement.outerHTML,"text/html");let u=await He(e,{doc:f,loc:r,fetchFn:o});if(!u.ok)return u;let d=typeof i=="function"?i:s.save&&typeof s.save.replace=="function"?s.save.replace:ee,m;try{m=await d(u.html,{etag:c})}catch{return{ok:!1,code:"failed",message:q}}if(!m||!m.ok){let p=m&&m.code?m.code:"failed";return p==="conflict"?{ok:!1,code:p,message:qe}: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:q}}return l(),{ok:!0,html:u.html,version:u.version,etag:m.etag}}function O(e,t,r={}){let o=e.createElement(t);o.setAttribute("clay","editor-ui");for(let[n,l]of Object.entries(r))n==="style"?o.setAttribute("style",l):n==="text"?o.textContent=l:o.setAttribute(n,l);return o}function gr(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 wr(e,{loc:t=location,fetchFn:r=(o,n)=>fetch(o,n)}={}){if(typeof e.getHTML=="function")return e.getHTML();let o=await r(t.href,{cache:"no-store",credentials:"same-origin"});if(!o.ok)throw new Error(`copy fetch ${o.status}`);return o.text()}async function vr({clay:e,doc:t=document,loc:r=location,fetchFn:o}={}){if(typeof URL>"u"||typeof URL.createObjectURL!="function")return!1;try{let n=await wr(e,{loc:r,fetchFn:o});if(typeof n=="string"&&/clay|data-paid-only/i.test(n)){let{stripCopyContent:a}=await import("./c-C4IIQZGJ.js");n=a(n)}let l=URL.createObjectURL(new Blob([n],{type:"text/html"})),i=t.createElement("a");return i.setAttribute("clay","editor-ui"),i.href=l,i.download=gr(r),i.style.setProperty("display","none","important"),t.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(l),4e4),!0}catch{return!1}}async function br(e){let t=e&&e.host;if(!t||!t.versions)return!1;try{return await t.versions===!0}catch{return!1}}async function xr(e,t={}){let r=t.doc||document,o=t.clay||(typeof window<"u"?window.clay:null)||{};if(o.isDraftMode||!e||typeof e.version!="string")return null;let n=await br(o),l=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;"}),c=O(r,"p",{role:"status",style:"margin:0 0 12px;min-height:1.5em;"}),f=O(r,"div",{style:"display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end;"}),u="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:u}),m=n?null:O(r,"button",{type:"button",text:"Download a copy first",style:u}),p=O(r,"button",{type:"button",text:"Upgrade",style:`${u}border-color:transparent;background:#2f6fed;color:#fff;font-weight:600;`});n||(p.disabled=!0),m&&f.append(m),f.append(d,p),i.append(a,s,c,f),l.append(i),r.body.appendChild(l);let w=!1,v=()=>{w||(w=!0,l.remove())};m&&m.addEventListener("click",async()=>{await vr({clay:o,doc:r,loc:t.loc,fetchFn:t.fetchFn})?(p.disabled=!1,c.textContent="Your copy was downloaded."):c.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),c.textContent=`Upgrading to version ${e.version}\u2026`;let g=await Be(e,t);if(g.ok){v(),h(g);return}c.textContent=g.message||q,p.disabled=!1,m&&(m.disabled=!1),h(g)}),{root:l,title:a,body:s,status:c,cancel:d,download:m,upgrade:p,close:v,done:y}}export{Be as apply,He as prepare,xr as start};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./c-VHNSBD2M.js";var l=(e,n)=>Object.assign(new Error(`clayjs: ${e}`),{code:n}),u=(e,n)=>!e||n.seq===null||e.seq===null||n.seq>e.seq?n:e;function a({stream:e,apply:n,retire:f,yieldArticle:i=()=>!1,reclaimArticle:s=()=>!1}){let t=null,r=!1;e.adopt({onSnapshot:o=>(t=u(t,o),!0)});let d=()=>{let o=t;return t=null,o};return{get represented(){return e.represented},get held(){return t??e.represented},yieldArticle(){return r||!i()?!1:(r=!0,!0)},reclaimArticle(){return!r||!s()?!1:(r=!1,!0)},reconcile(){let o=d();return o&&!n(o)?Promise.reject(l("the switch could not apply the saved file","load-failed")):Promise.resolve()},resume(){e.adopt({onSnapshot:n});let o=d();o&&n(o)},commit(){if(!r){let o=d();if(o&&!n(o))return!1}return e.represented.bytes===null?!1:(e.stop(),f())}}}async function c({stream:e,options:n,apply:f,retire:i,yieldArticle:s=()=>!1,reclaimArticle:t=()=>!1}){if(e)return a({stream:e,apply:f,retire:i,yieldArticle:s,reclaimArticle:t});let r=await import("./sync/live-sync-
|
|
1
|
+
import"./c-VHNSBD2M.js";var l=(e,n)=>Object.assign(new Error(`clayjs: ${e}`),{code:n}),u=(e,n)=>!e||n.seq===null||e.seq===null||n.seq>e.seq?n:e;function a({stream:e,apply:n,retire:f,yieldArticle:i=()=>!1,reclaimArticle:s=()=>!1}){let t=null,r=!1;e.adopt({onSnapshot:o=>(t=u(t,o),!0)});let d=()=>{let o=t;return t=null,o};return{get represented(){return e.represented},get held(){return t??e.represented},yieldArticle(){return r||!i()?!1:(r=!0,!0)},reclaimArticle(){return!r||!s()?!1:(r=!1,!0)},reconcile(){let o=d();return o&&!n(o)?Promise.reject(l("the switch could not apply the saved file","load-failed")):Promise.resolve()},resume(){e.adopt({onSnapshot:n});let o=d();o&&n(o)},commit(){if(!r){let o=d();if(o&&!n(o))return!1}return e.represented.bytes===null?!1:(e.stop(),f())}}}async function c({stream:e,options:n,apply:f,retire:i,yieldArticle:s=()=>!1,reclaimArticle:t=()=>!1}){if(e)return a({stream:e,apply:f,retire:i,yieldArticle:s,reclaimArticle:t});let r=await import("./sync/live-sync-XMXXZS3G.js").then(({liveSync:d})=>d.prepareHandoff(n));return{get represented(){return r.represented},get held(){return r.held},yieldArticle:s,reclaimArticle:t,reconcile:()=>r.reconcile(),resume:()=>r.resume(),commit:()=>r.commit()&&i()}}async function p(e,{signal:n,deadline:f=15e3}={}){let i=Date.now()+f;for(;e._morphInFlight;){if(n?.aborted)throw e._handoffHeld=!1,l("the switch was cancelled","aborted");if(Date.now()>=i)throw e._handoffHeld=!1,l("the apply did not settle","timeout");await new Promise(t=>setTimeout(t,1))}let s=()=>e._pendingHtml!=null||e._pendingExternal!=null;return{get represented(){return e._represented},get held(){let t=e._represented;return e._pendingHtml!=null&&(t=u(t,{bytes:e._pendingHtml,etag:e._pendingEtag??null,seq:e._pendingSeq??null})),e._pendingExternal&&(t=u(t,{bytes:e._pendingExternal.html,etag:e._pendingExternal.etag??null,seq:e._pendingExternal.seq??null})),t},async reconcile(){if(!(!e._handoff||e.isDestroyed)){for(let t=0;t<8;t++){if(e._morphInFlight){await new Promise(r=>setTimeout(r,1));continue}if(!s())return;await e._runPending()}if(s())throw l("the held frame could not be applied","load-failed")}},resume(){e._handoff&&(e._handoff=null,e._handoffHeld=!1,e._scheduleNextFrame())},commit(){return e._represented.bytes?(e._handoff=null,e._handoffHeld=!1,e.stop(),!0):!1}}}export{p as engineHandoff,c as readerHandoff};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as h,d as f,h as x}from"./c-
|
|
1
|
+
import{C as h,d as f,h as x}from"./c-AI3H6ETU.js";import{A as g,c as I,d as $}from"./c-OH2FPYSY.js";import{b as E}from"./c-RETTCOWO.js";var{Plugin:B,PluginKey:j}=E,k=$.nodes,m=new j("blockeditor-media"),L=1.5*1024*1024,u=new WeakMap,C=new WeakMap,U=(t,o)=>{let s=t.resolve(Math.max(0,Math.min(o,t.content.size)));return s.depth===0?s.pos:s.after(1)};function b(t,o){let s=x(t.doc),e=s[Math.min(o,s.length-1)],a=e.node.type===k.paragraph&&e.node.content.size===0;return{hostId:e.node.attrs.id,at:a?e.at:s[e.subEnd].end,parent:e.node.attrs.parent??null,replaceId:a?e.node.attrs.id:null}}var O={init:()=>({items:[],placed:{},picker:null}),apply(t,o){let{items:s,placed:e,picker:a}=o;if(t.docChanged&&(s=s.map(r=>({...r,pos:U(t.doc,t.mapping.map(r.pos,-1))}))),a&&t.docChanged&&(a={...a,place:{...a.place,at:U(t.doc,t.mapping.map(a.place.at,-1))}},a.remove)){let r=t.mapping.map(a.remove.from,1),c=t.mapping.map(a.remove.to,-1);a=r<=c&&t.doc.textBetween(r,c)===a.remove.text?{...a,remove:{...a.remove,from:r,to:c}}:null}let n=t.getMeta(m);if(n?.picker!==void 0&&(a=n.picker),n?.add&&(s=[...s,...n.add]),n?.update&&(s=s.map(r=>r.id===n.update.id?{...r,...n.update}:r)),n?.placed){let{id:r,at:c,size:d,blockId:p}=n.placed,i=o.items.find(l=>l.id===r);s=s.filter(l=>l.id!==r).map(l=>i&&l.pos===c&&l.group===i.group&&l.order>i.order?{...l,pos:l.pos+d}:l),i&&(e={...e,[i.group]:[...e[i.group]||[],p]})}n?.remove&&(s=s.filter(r=>r.id!==n.remove));for(let r of Object.keys(e))s.some(c=>c.group===r)||(e={...e},delete e[r]);return{items:s,placed:e,picker:a}}};function R(t,o,s){if(!o)return;let e=null,a=null;t.doc.forEach((n,r)=>{n.attrs.id===o&&e&&s.includes(e.attrs.id)&&(a={n,off:r}),e=n}),a&&a.n.type===k.paragraph&&a.n.content.size===0&&t.delete(a.off,a.off+a.n.nodeSize)}function P(t,o,s){let{items:e,placed:a}=m.getState(t),n=e.find(i=>i.id===o);if(!n)return null;let r=U(t.doc,n.pos),c=g(),d=(n.kind==="image"?k.image:k.file).create({...s,id:c,pos:null,parent:n.parent}),p=t.tr.insert(r,d);return e.some(i=>i.group===n.group&&i.id!==o)||R(p,n.replaceId,[...a[n.group]||[],c]),h(p).setMeta(m,{placed:{id:o,at:r,size:d.nodeSize,blockId:c}})}function F(t,o){let{items:s,placed:e}=m.getState(t),a=s.find(r=>r.id===o);if(!a)return null;let n=t.tr;return s.some(r=>r.group===a.group&&r.id!==o)||R(n,a.replaceId,e[a.group]||[]),n.docChanged&&h(n),n.setMeta(m,{remove:o})}function y(t,o,s=b(t.state,t.state.selection.$head.index(0))){if(o=[...o].filter(Boolean),!o.length)return!1;let e=g("g"),a=o.map((n,r)=>{let c=/^image\//.test(n.type||"")?"image":"file";return{id:g("u"),pos:s.at,group:e,order:r,file:n,kind:c,name:n.name||(c==="image"?"image":"file"),parent:s.parent,replaceId:s.replaceId,state:"uploading",percent:0,preview:c==="image"&&globalThis.URL?.createObjectURL?URL.createObjectURL(n):null}});t.dispatch(t.state.tr.setMeta(m,{add:a}));for(let n of a)H(t,n);return f(t,o.length===1?`Uploading ${a[0].name}`:`Uploading ${o.length} files`),!0}var z=(t,o)=>m.getState(t.state).items.find(s=>s.id===o),M=(t,o,s)=>t.dispatch(t.state.tr.setMeta(m,{update:{id:o,...s}})),A=(t,o)=>t.kind==="image"?{src:o,alt:"",caption:""}:{src:o,name:t.name,size:t.file.size??null,mime:t.file.type||null};function T(t,o,s){t.preview&&URL.revokeObjectURL?.(t.preview),s&&o.dispatch(s)}async function H(t,o){let s=u.get(t),e=new AbortController;s.aborts.set(o.id,e);let a=-5,n=({percent:d})=>{d-a<5&&d!==100||(a=d,u.has(t)&&z(t,o.id)&&M(t,o.id,{percent:d}))},r;try{r=await s.upload(o.file,{onProgress:n,signal:e.signal})}catch{r={code:"network",msg:"Upload failed"}}if(s.aborts.delete(o.id),!u.has(t)||!z(t,o.id))return;if(r?.ok){let d=I(r.uploads?.[0]?.url);if(d){T(o,t,P(t.state,o.id,A(o,d))),f(t,`${o.name} added`);return}r={code:"bad-response",msg:"The upload returned an invalid address"}}if((!r||typeof r!="object")&&(r={code:"bad-response",msg:"The upload returned an invalid response"}),r.code==="aborted")return T(o,t,F(t.state,o.id));if(r.code==="unsupported"){let d=/^image\/(png|jpeg|gif|webp)$/i.test(o.file.type)&&o.file.size<=L,p=d?"This host doesn't store files. You can keep this image inside the document, which makes the document larger.":o.kind==="image"&&o.file.size>L?"This host doesn't store files, and this image is over 1.5 MB, too large to keep inside the document.":"This host doesn't store files.";M(t,o.id,{state:d?"embed-choice":"error",code:r.code,message:p}),f(t,`${o.name}: ${p}`);return}let c=r.code==="timeout"?"The upload timed out. It may have arrived; trying again is safe.":r.msg||"Upload failed";M(t,o.id,{state:"error",code:r.code,message:c}),f(t,`${o.name}: ${c}`)}var Y=t=>t.replace(/<(meta|style|img)\b[^>]*>/gi,"").replace(/<[^>]+>/g,"").trim()!=="";function Q({upload:t,features:o=null}){let s=e=>{!o||o.has("media")||!u.has(e)||o.ensure("media").catch(()=>{})};return new B({key:m,state:O,view(e){let n=e.dom.ownerDocument.createElement("input");n.type="file",n.multiple=!0,n.hidden=!0,n.className="blockeditor-file-input",e.dom.parentElement.append(n),u.set(e,{upload:t,aborts:new Map,input:n}),n.addEventListener("change",()=>{let c=[...n.files??[]],d=m.getState(e.state).picker;if(e.dispatch(e.state.tr.setMeta(m,{picker:null})),c.length&&d){let{remove:p}=d;p&&e.state.doc.textBetween(p.from,p.to)===p.text&&e.dispatch(h(e.state.tr.delete(p.from,p.to)));let i=_(e.state.doc,d.place.hostId);(!d.place.hostId||i>=0)&&(y(e,c,i>=0?b(e.state,i):d.place),s(e))}n.value="",e.focus()}),n.addEventListener("cancel",()=>e.dispatch(e.state.tr.setMeta(m,{picker:null})));let r=c=>{let d=c.target.closest?.(".blockeditor-upload-btn");if(!d)return;c.preventDefault();let p=C.get(e),i=d.dataset.upload;d.dataset.act==="retry"?p?.retryUpload(e,i):d.dataset.act==="embed"?p?.embedUpload(e,i):p?.cancelUpload(e,i)};return e.dom.addEventListener("click",r),{destroy(){e.dom.removeEventListener("click",r);let c=u.get(e);u.delete(e);for(let d of m.getState(e.state).items)d.preview&&URL.revokeObjectURL?.(d.preview);for(let d of c.aborts.values())d.abort();n.remove()}}},props:{handlePaste(e,a){let n=a.clipboardData,r=[...n?.files??[]];if(!r.length||e.state.selection.$from.parent.type.spec.code||Y(n.getData("text/html")||""))return!1;let c=b(e.state,e.state.selection.$head.index(0));return a.preventDefault(),y(e,r,c),s(e),!0},handleDrop(e,a,n,r){let c=[...a.dataTransfer?.files??[]];if(r||!c.length)return!1;let d=e.posAtCoords({left:a.clientX,top:a.clientY});if(!d)return!1;let p=x(e.state.doc),i=Math.min(e.state.doc.resolve(d.pos).index(0),p.length-1),l=e.nodeDOM(p[i].at)?.getBoundingClientRect?.(),D=l&&a.clientY<l.top+l.height/2;a.preventDefault();let S={at:D?p[i].at:p[p[i].subEnd].end,parent:p[i].node.attrs.parent??null,replaceId:null};return y(e,c,S),s(e),!0}}})}var _=(t,o)=>{let s=-1;return t.forEach((e,a,n)=>{e.attrs.id===o&&(s=n)}),s};function V(t,o,s=b(t.state,t.state.selection.$head.index(0)),e=null){let a=u.get(t);if(!a)return!1;let n={place:s,remove:e&&{...e,text:t.state.doc.textBetween(e.from,e.to)}};return t.dispatch(t.state.tr.setMeta(m,{picker:n})),a.input.accept=o,a.input.click(),!0}export{m as a,L as b,u as c,C as d,U as e,b as f,P as g,F as h,z as i,M as j,A as k,T as l,H as m,Q as n,V as o};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as R}from"./c-I2SCCUEW.js";import{a as C,d as P}from"./c-
|
|
1
|
+
import{a as R}from"./c-I2SCCUEW.js";import{a as C,d as P}from"./c-EQ5NBOGA.js";import{c as v}from"./c-BPF2NSPV.js";var q="/_/upload",F=12e4,O={document:["document"],local:["local"],"document-or-local":["document","local"]},H=new Set(["network","timeout","error","bad-response","aborted"]);function j(e){return e?e.state==="cancelled"?!0:e.state!=="failed"?!1:H.has(e.result?.code??null):!1}var _=new Set,D=()=>[..._].some(e=>e.state==="uploading");async function B(){let e=[..._].filter(t=>t.state==="uploading").map(t=>t.result);return e.length?(await Promise.allSettled(e),{ok:!D()}):{ok:!0}}var S=R({id:"upload",isPending:D,flush:B}),E=null,M=()=>E?.admitted!==!1,$=0;function z(){return $+=1,`upload-${$}`}function d(e,t,s,g,m=[]){return{ok:e,msg:t,msgType:s,code:g,uploads:m}}function x(e,t){typeof document>"u"||document.dispatchEvent(new CustomEvent(`clay:upload-${e}`,{detail:t}))}function L(e){if(e==null)return null;let t=O[e];if(!t)throw new TypeError(`Unknown requiredAccess: ${String(e)}. Use one of ${Object.keys(O).join(", ")}.`);return t}async function Y(e,{onProgress:t,signal:s,requiredAccess:g,taskId:m=z(),attempt:b=1}={}){let i=L(g);if(!e)return d(!1,"No file to upload","error","bad-request");let l=()=>d(!1,"Upload cancelled","error","aborted");if(!M())return l();let a;try{a=await P(b>1?{fresh:!0}:void 0)}catch{a={extensions:[],document:null}}if(s?.aborted)return l();if(C(a)==="failed")return d(!1,"Couldn't reach the host to upload","error","network");if(!a.extensions.includes("upload"))return d(!1,"This host does not store uploaded files","skipped","unsupported");if(s?.aborted)return l();if(!a.document?.upload)return d(!1,"You can't add files to this document","error","forbidden");if(s?.aborted)return l();if(i){let k=a.document.upload.access;if(!i.includes(k))return d(!1,"This host does not keep uploaded files private to this document","error","privacy-unsupported")}if(s?.aborted)return l();let f=a.document?.upload?.maxBytes;return typeof f=="number"&&f>0&&e.size>f?d(!1,`That file is larger than this host accepts (${f} bytes)`,"error","too-large"):N(e,{onProgress:t,signal:s,taskId:m,attempt:b,requiredAccess:i})}function J(e,t){if(!t||!e.ok)return e;let s=e.uploads||[];return s.every(m=>t.includes(m?.access))?e:d(!1,"The host stored the file without the access it promised","error","privacy-unsupported",s)}function N(e,{onProgress:t,signal:s,taskId:g,attempt:m,requiredAccess:b}={}){let i=Array.isArray(b)?b:L(b);return new Promise(l=>{let a={taskId:g,attempt:m},f=v(),k=f?`${q}/${f}`:q,A=new URL(k,window.location.origin).href,n=null,y=!1,p=null;function w(r,c,o){return y?!1:(y=!0,p!==null&&clearTimeout(p),s&&s.removeEventListener("abort",T),c&&x(c,{...o,...a}),l(r),!0)}function h(r,c,o){return w(d(!1,r,c,o),"error",{msg:r,code:o})}function U(){let r=d(!1,"Upload timed out","unknown","timeout");w(r,"error",{msg:r.msg,code:r.code})&&n.abort()}function T(){w(d(!1,"Upload cancelled","skipped","aborted"))&&n?.abort()}try{n=new XMLHttpRequest}catch{return h("This browser could not start the upload","error","error")}if(p=setTimeout(U,F),s){if(s.aborted)return T();s.addEventListener("abort",T)}n.upload.addEventListener("progress",r=>{if(y||!r.lengthComputable)return;let c={loaded:r.loaded,total:r.total,percent:Math.round(r.loaded/r.total*100)};if(x("progress",{...c,...a}),t)try{t(c)}catch{}}),n.addEventListener("load",()=>{if(y)return;let r={};try{r=JSON.parse(n.responseText||"{}")}catch{r={}}if(n.status>=200&&n.status<300){let o=Array.isArray(r.uploads)?r.uploads:[];if(!o.length||typeof o[0]?.url!="string")return h("The host accepted the file but did not say where it put it","error","bad-response");let u=J(d(!0,r.msg??"Uploaded",r.msgType||"success",r.code??null,o),i);return u.ok?w(u,"done",{uploads:o}):w(u,"error",{msg:u.msg,code:u.code,uploads:o})}let c=r.code||Q[n.status]||"error";return h(r.msg||`Upload failed (${n.status})`,"error",c)}),n.addEventListener("error",()=>h("Upload failed","error","network")),n.addEventListener("abort",()=>w(d(!1,"Upload cancelled","skipped","aborted")));try{n.open("POST",A,!0),n.withCredentials=!1,n.setRequestHeader("Document-URL",window.location.href);let r=new FormData;r.append("file",e,e.name||"upload"),x("start",{name:e.name||null,size:e.size??null,...a}),n.send(r)}catch{h("The upload could not be sent","error","error")}})}function V(e,t={}){if(!e)throw new TypeError("clay.upload.start needs a file");L(t.requiredAccess);let s=z(),g=t.requiredAccess??null,m=t.onProgress||null,b=e,i=0,l="uploading",a=0,f=null,k=null,A=null,n=null,y=null,p=!1,w=0,h=new Set;function U(){return{id:s,attempt:i,state:l,loaded:a,total:f,percent:k,result:A}}function T(){if(!h.size)return;let o=U();for(let u of[...h])try{u(o)}catch{}}function r(){i+=1;let o=i;return n=new AbortController,l="uploading",a=0,f=null,k=null,A=null,y=Y(b,{requiredAccess:g,signal:n.signal,taskId:s,attempt:o,onProgress:u=>{if(!(p||o!==i)&&(a=u.loaded,f=u.total,k=u.percent,T(),m))try{m(u)}catch{}}}).then(u=>(!p&&o===i&&o!==w&&(A=u,l=u.ok?"succeeded":u.code==="aborted"?"cancelled":"failed",T()),S.changed(),u)),T(),S.changed(),y}let c={id:s,get attempt(){return i},get state(){return l},get file(){return b},get result(){return y},snapshot:U,subscribe(o){if(typeof o!="function")throw new TypeError("subscribe needs a function");if(p)return()=>{};h.add(o);try{o(U())}catch{}return()=>h.delete(o)},cancel(){p||(l==="uploading"&&(w=i,l="cancelled",A=d(!1,"Upload cancelled","error","aborted"),T(),S.changed()),n?.abort())},retry(){return p||!M()||!j(U())?y:r()},dispose(){p||(p=!0,n?.abort(),h.clear(),b=null,_.delete(c),S.changed())}};return _.add(c),r(),c}function W(){return{id:"clay:upload",order:340,prepare(e={}){let t={admitted:e.initial===!0};return E=t,{enable(){E===t&&(t.admitted=!0)},quiesce(){E===t&&(t.admitted=!1)},resume(){E===t&&(t.admitted=!0)},dispose(){E===t&&(t.admitted=!1)}}}}}var Q={402:"payment-required",413:"too-large",415:"unsupported-type",401:"unauthorized",403:"forbidden",404:"not-found"};export{j as a,L as b,Y as c,V as d,W as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b}from"./c-
|
|
1
|
+
import{b}from"./c-C7SUMNMI.js";import{c as x}from"./c-BPF2NSPV.js";var y="/_/meta",v=6e3,A=new WeakMap,S=new WeakMap,O=new WeakMap,_=0;function f(t,e=s(),n=null,o=null){return A.set(e,t),n!==null&&S.set(e,n),o!==null&&O.set(e,o),e}function g(t){return A.get(t)??"none"}function R(t){return S.get(t)}function $(t){return O.get(t)??0}function s(){return{spec:null,extensions:[],document:null}}var h=null,m=null;function d({fresh:t=!1}={}){if(b)return Promise.resolve(s());if(!t)return h||(h=T().catch(s)),h;if(!m){let e=h;m=T().catch(s).finally(()=>{m=null}),h=m.then(async n=>{if(g(n)==="ok"||!e)return n;let o=await e;return g(o)==="ok"?o:n})}return m}async function P(t){return(await d()).extensions.includes(t)}async function D(){return(await d()).extensions.includes("blockeditor-format-v1")?1:0}async function C(){let t=await d();return t.extensions.includes("blockeditor-recovery-v1")&&t.document?.blockeditorState?.href||null}async function H(){return(await d()).document?.versions===!0}var E=["codeEditor","versions","duplicate","reveal","export"];function M(t){if(typeof t!="string"||!t)return null;try{let e=new URL(t,location.href);return e.protocol==="http:"||e.protocol==="https:"?e:null}catch{return null}}async function N(){let e=(await d()).document?.actions,n={};if(!e||typeof e!="object")return n;for(let o of E){let i=M(e[o]?.href);if(i){n[o]={href:i.href};continue}let l=M(e[o]?.post);l&&l.origin===location.origin&&(n[o]={post:l.href})}return n}function W(){h=null,m=null}async function F({saveId:t,requestHash:e,signal:n}={}){if(b||typeof t!="string"||!t||typeof e!="string"||!e||!/^https?:$/.test(window.location.protocol)||n?.aborted)return null;let o=new AbortController,i=()=>o.abort(),l=setTimeout(i,v);n?.addEventListener("abort",i);try{let u=await d();if(g(u)!=="ok"||!u.extensions.includes("save-history")||o.signal.aborted)return null;let p=x(),r=p?`${y}/${p}`:y,w=await fetch(new URL(r,window.location.origin).href,{method:"GET",credentials:p?"omit":"same-origin",headers:{"Document-URL":window.location.href,"Save-ID":t,"Save-Request-Hash":e},cache:"no-store",redirect:"manual",signal:o.signal});if(!w.ok)return null;let k=await w.text();if(!k)return null;let c;try{c=JSON.parse(k)}catch{return null}if(!c||typeof c!="object"||typeof c.spec!="number"||!Array.isArray(c.extensions)||!c.extensions.includes("save-history"))return null;let a=c.document&&typeof c.document=="object"?c.document.saveOutcome:null;return!a||typeof a!="object"||a.saveId!==t||a.requestHash!==e||a.status!=="applied"&&a.status!=="unknown"?null:{saveId:t,requestHash:e,status:a.status}}catch{return null}finally{clearTimeout(l),n?.removeEventListener("abort",i)}}async function T(){let t=location.pathname,e=++_;if(!/^https?:$/.test(window.location.protocol))return f("none",s(),t,e);let n=x(),o=n?`${y}/${n}`:y,i=new AbortController,l=setTimeout(()=>i.abort(),v);try{let u=await fetch(new URL(o,window.location.origin).href,{method:"GET",credentials:n?"omit":"same-origin",headers:{"Document-URL":window.location.href},cache:"no-store",redirect:"manual",signal:i.signal});if(!u.ok)return f(u.status>=500?"failed":"none",s(),t,e);let p=await u.text();if(!p)return f("none",s(),t,e);let r;try{r=JSON.parse(p)}catch{return f("none",s(),t,e)}return!r||typeof r!="object"||typeof r.spec!="number"?f("none",s(),t,e):f("ok",{spec:r.spec,extensions:Array.isArray(r.extensions)?r.extensions:[],document:r.document&&typeof r.document=="object"?r.document:null},t,e)}catch{return f("failed",s(),t,e)}finally{clearTimeout(l)}}export{g as a,R as b,$ as c,d,P as e,D as f,C as g,H as h,N as i,W as j,F as k};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as ee,D as oe,G as te,H as re,I as ne,i as J}from"./c-TGIMBAWE.js";import"./c-WNOLMHI2.js";import"./c-LS7IVQVW.js";import"./c-NEQRFC4O.js";import{a as X}from"./c-
|
|
1
|
+
import{A as ee,D as oe,G as te,H as re,I as ne,i as J}from"./c-TGIMBAWE.js";import"./c-WNOLMHI2.js";import"./c-LS7IVQVW.js";import"./c-NEQRFC4O.js";import{a as X}from"./c-HGG7M2S3.js";import"./c-PZ4XEPUP.js";import"./c-JRKY44DK.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{A as Q,F as Z,d as z,y as K}from"./c-OH2FPYSY.js";import"./c-SFKI6OLM.js";import"./c-Q3XOWZEV.js";import{b as Y}from"./c-QY7F6EN6.js";import{a as G,b as H}from"./c-RETTCOWO.js";import"./c-RHMPKZZ7.js";import"./c-57XDY6HC.js";import"./c-I2SCCUEW.js";import"./c-PNZIJFG7.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var le="Work from an earlier session could not be put back. Read it, download it, or recover it as a copy.",pe=`
|
|
2
2
|
:host { font: inherit !important; color: inherit !important; }
|
|
3
3
|
.blockeditor-recovery-root { display: contents; }
|
|
4
4
|
.blockeditor-recovery { position: fixed; right: 16px; bottom: 16px; z-index: 20; min-height: 36px; padding: 0 14px; font: inherit; font-size: 14px; color: var(--blockeditor-ink); background: var(--blockeditor-pop-bg); border: 1px solid var(--blockeditor-chrome-line-rest); border-radius: 999px; cursor: pointer; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d,b as c,c as o,d as n}from"./c-
|
|
1
|
+
import{a as d,b as c,c as o,d as n}from"./c-QCDVDZIR.js";import{a as u}from"./c-VKEDWYDF.js";import{f as a}from"./c-C7SUMNMI.js";import{b as l,r as b}from"./c-PNZIJFG7.js";var r="[editmode\\:contenteditable]";function m(){b(e=>{e.querySelectorAll(r).forEach(t=>{n(t),o(t,l(t)??t)})})}function s(){a&&u(()=>{p()})}function p(e=document){e.querySelectorAll(r).forEach(t=>{d(t);let i=t.getAttribute("inert-contenteditable")??t.getAttribute("contenteditable")??c(t,"inert-contenteditable")??"true",f=i.toLowerCase();t.setAttribute("contenteditable",["","true","false","plaintext-only"].includes(f)?i:"true"),t.removeAttribute("inert-contenteditable")})}function y(){document.querySelectorAll(r).forEach(e=>{n(e),o(e)})}function S(){m(),s()}export{r as a,p as b,y as c,S as d};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as u}from"./c-7NCWENHV.js";import{C as M}from"./c-
|
|
1
|
+
import{a as u}from"./c-7NCWENHV.js";import{C as M}from"./c-AI3H6ETU.js";import{d as v}from"./c-OH2FPYSY.js";import{b as S,d as x}from"./c-RETTCOWO.js";import"./c-VHNSBD2M.js";var{Plugin:R}=S,{Decoration:D}=x;var O=[["","Plain text"],["javascript","JavaScript"],["typescript","TypeScript"],["jsx","JSX"],["tsx","TSX"],["json","JSON"],["html","HTML"],["css","CSS"],["python","Python"],["shellscript","Shell"],["sql","SQL"],["go","Go"],["rust","Rust"],["java","Java"],["c","C"],["cpp","C++"],["csharp","C#"],["ruby","Ruby"],["php","PHP"],["yaml","YAML"],["markdown","Markdown"],["diff","Diff"],["swift","Swift"],["kotlin","Kotlin"],["xml","XML"]],L=new Set(O.map(([s])=>s)),T={js:"javascript",mjs:"javascript",ts:"typescript",py:"python",sh:"shellscript",bash:"shellscript",shell:"shellscript",zsh:"shellscript",rb:"ruby",yml:"yaml",md:"markdown",htm:"html",golang:"go",rs:"rust","c++":"cpp",cs:"csharp","c#":"csharp",kt:"kotlin"},m=s=>{let t=String(s??"").trim().toLowerCase(),e=T[t]??t;return L.has(e)?e:""},n=s=>({color:s}),C={name:"page",appearance:"light",cssVariables:{prefix:"--blockeditor-code-token-"},style:{syntax:{comment:n("comment"),keyword:n("keyword"),operator:n("keyword"),preproc:n("keyword"),"punctuation.special":n("keyword"),string:n("string-expression"),"string.escape":n("constant"),"string.regex":n("constant"),"string.special":n("constant"),number:n("constant"),boolean:n("constant"),constant:n("constant"),type:n("constant"),property:n("constant"),enum:n("constant"),variant:n("constant"),namespace:n("constant"),label:n("constant"),function:n("function"),constructor:n("function"),selector:n("function"),attribute:n("function"),"variable.parameter":n("parameter"),tag:n("string-expression"),link_uri:n("link"),link_text:n("link"),"diff.plus":n("string-expression"),"diff.minus":n("keyword"),title:{font_weight:700},emphasis:{font_style:"italic"},"emphasis.strong":{font_weight:700}}}},E=null;async function P(s,t){E??=import("./c-3OWDMNJR.js");let{codeToTokens:e}=await E;return e(s,{lang:t,theme:C}).tokens}var _="var(--blockeditor-code-token-foreground)",A=s=>{let t=[];return s.color&&s.color!==_&&t.push(`color: ${s.color}`),s.fontStyle&1&&t.push("font-style: italic"),s.fontStyle&2&&t.push("font-weight: 600"),s.fontStyle&4&&t.push("text-decoration: underline"),t.join("; ")},H=200,y=class{constructor(t,e,i){this.view=t,this.run=e,this.delay=i,this.cache=new Map,this.pending=new Set,this.visible=new Set,this.targets=new Map,this.timer=0;let c=t.dom.ownerDocument.defaultView.IntersectionObserver;this.io=c?new c(a=>{for(let o of a){let r=o.target.dataset.id;this.targets.get(r)===o.target&&this.visible[o.isIntersecting?"add":"delete"](r)}this.schedule(0)},{rootMargin:"200px 0px"}):null,this.schedule(0)}update(t,e){(!e||t.state.doc!==e.doc)&&this.schedule(this.delay)}schedule(t){clearTimeout(this.timer),this.timer=setTimeout(()=>this.pass(),t)}pass(){let{view:t}=this;if(t.isDestroyed)return;let e=[],i=new Map,c=u.getState(t.state);t.state.doc.forEach((o,r)=>{if(o.type!==v.nodes.code_block)return;let d=o.attrs.id,p=t.nodeDOM(r);p&&i.set(d,p);let g=m(o.attrs.lang);if(!g)return;let k=o.textContent,h=`${g}
|
|
2
2
|
${k}`,b=this.cache.get(h);if(b)for(let l of b){let w=A(l);w&&l.content&&e.push(D.inline(r+1+l.offset,r+1+l.offset+l.content.length,{style:w}))}else{if(e.push(...c.find(r,r+o.nodeSize)),this.io&&!this.visible.has(d)||this.pending.has(h))return;this.pending.add(h),this.run(k,g).then(l=>l.flat(),()=>[]).then(l=>{this.pending.delete(h),this.cache.set(h,l),this.cache.size>H&&this.cache.delete(this.cache.keys().next().value),this.schedule(0)})}}),this.track(i);let a=o=>o.map(r=>`${r.from}:${r.to}:${r.type.attrs.style}`).join("|");a(e)!==a(u.getState(t.state).find())&&t.dispatch(t.state.tr.setMeta(u,e).setMeta("addToHistory",!1))}track(t){if(this.io){for(let[e,i]of this.targets)t.get(e)!==i&&(this.io.unobserve(i),this.targets.delete(e),this.visible.delete(e));for(let[e,i]of t)this.targets.get(e)!==i&&(this.targets.set(e,i),this.io.observe(i))}}destroy(){clearTimeout(this.timer),this.io?.disconnect()}};function j(s,{tokenize:t=P,delay:e=300}={}){let i=new y(s,t,e),c=s.dispatch.bind(s),a=s.state.doc,o=d=>{if(c(d),s.state.doc===a)return;let p={doc:a};a=s.state.doc,i.update(s,p)};s.dispatch=o;let r=i.destroy.bind(i);return i.destroy=()=>{s.dispatch===o&&(s.dispatch=c),r()},i}var f=class{constructor(t,e,i){this.node=t,this.view=e,this.getPos=i;let c=e.dom.ownerDocument;this.dom=c.createElement("pre"),this.contentDOM=c.createElement("code"),this.select=c.createElement("select"),this.select.className="blockeditor-code-lang",this.select.contentEditable="false",this.select.setAttribute("aria-label","Code language");for(let[a,o]of O)this.select.append(new Option(o,a));this.select.addEventListener("change",()=>this.setLang(this.select.value)),this.dom.append(this.select,this.contentDOM),this.render(t)}render(t){this.node=t,this.dom.dataset.id=t.attrs.id??"";let e=m(t.attrs.lang);e?this.dom.dataset.lang=e:delete this.dom.dataset.lang,this.select.value=e}setLang(t){let e=this.getPos();e==null||t===m(this.node.attrs.lang)||(this.view.dispatch(M(this.view.state.tr.setNodeMarkup(e,null,{...this.node.attrs,lang:t}))),this.view.focus())}update(t){return t.type!==this.node.type?!1:(this.render(t),!0)}stopEvent(t){return this.select.contains(t.target)}ignoreMutation(t){return t.type!=="selection"&&this.select.contains(t.target)}};function X({view:s=null,highlight:t={}}={}){let e=s?j(s,t):null;return{id:"code",nodeViews:{code_block:(i,c,a)=>new f(i,c,a)},css:null,dispose(){e?.destroy()}}}export{X as createFeature};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as j}from"./c-MJ7GVE46.js";import{b as S,c as A,f as C,i as l,j as P,l as L,n as B}from"./c-
|
|
1
|
+
import{a as j}from"./c-MJ7GVE46.js";import{b as S,c as A,f as C,i as l,j as P,l as L,n as B}from"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var y=0,x=[],b=[],d=null,I=!1,E=!1,v=null,M=null,$=15e3,u=()=>P().mode,p=(e,t)=>Object.assign(new Error(`clay.modeLifecycle: ${e}`),{code:t});function U(){document.dispatchEvent(new Event("clay:modechange"))}function h(e,t="idle",o={}){return l({phase:t,reason:e}),{ok:!1,mode:u(),code:e,...o}}function k(e){for(let t of[...e].reverse())try{t.dispose?.()}catch{}}function D(e){try{e?.reclaimArticle?.()}catch{}try{e?.resume?.()}catch{}}function O(e){document.documentElement.setAttribute("editmode",e?"true":"false")}function G(){try{let e=new URL(window.location.href);if(!e.searchParams.has("editmode"))return;e.searchParams.delete("editmode"),window.history.replaceState(window.history.state,"",`${e.pathname}${e.search}${e.hash}`)}catch(e){console.warn("clayjs: the URL could not be rewritten after the mode switch",e)}}var N=e=>[...e?.edit?.core??[],...e?.edit?.plugins??[],...e?.edit?.late??[]];function X(e){let t=[];for(let o of N(e)){let n=j(o);if(n!=="export"&&typeof n!="function")continue;let r=e.loaded?.[o];r&&t.push(typeof n=="function"?n(r):r.modeParticipant?.())}return t}async function _(e){let t=new Set(b.map(({id:n})=>n)),o=n=>{if(typeof n?.id!="string"||typeof n.prepare!="function")throw p("a participant needs an id and a prepare()","unsupported-plugin");t.has(n.id)||(t.add(n.id),b.push(n))};if(e)for(let n of X(e))o(await n);for(let n of B())o(await n);return[...b].sort((n,r)=>(n.order??0)-(r.order??0))}function z(e){let t=b.findIndex(o=>o.id===e);t!==-1&&b.splice(t,1)}L(z);function H(e,t){if(!e||e.bytes===null)return!1;let o=t??{};return typeof e.seq=="number"&&typeof o.seq=="number"&&e.seq!==o.seq?e.seq>o.seq:(e.etag??null)!==(o.etag??null)}async function V(e=null){let t=u(),o=C,n=new AbortController,r={generation:++y,destination:P().destination,signal:n.signal,represented:null,reader:null,initial:!1,isCurrent:()=>r.generation===y&&!n.signal.aborted};l({phase:"entering",generation:r.generation,reason:null}),e||(I=!0,E=!1,v=null);let s=[],c=[],f=null,i=null,w=!1,m=(async()=>{try{if(e){let a=await import("./c-WVCT3ITX.js");i=await a.prepareReader(e,r),c.push(...await a.importPlan(e,e.edit,{signal:n.signal})),await i?.reconcile(),r.represented=i?i.represented:null,r.reader=i,M=r.represented}f=e?.loaded?.["core/save.js"]??await import("./core/save-K6Q47J2X.js");for(let a of await _(e)){w=!0;let g=await a.prepare(r);if(g){if(s.push(g),!r.isCurrent())throw p(`"${a.id}" prepared for a stale generation`,"stale-document");if(g.ready&&await g.ready,!r.isCurrent())throw p(`"${a.id}" became ready for a stale generation`,"stale-document")}}if(e||!o){let a=f.adoptEntryBaseline({represented:r.represented});if(a&&a.ok===!1)throw Object.assign(p("the page moved since the last session",a.code||"pending-input"),a);if(H(i?.held??i?.represented,r.represented))throw p("the reader holds a newer file than the session was built from","stale-document")}return!0}catch(a){throw k(s),a}})(),q=null,W=new Promise(a=>{q=setTimeout(()=>{n.abort(),a(!1)},$)}),T;try{T=await Promise.race([m,W])}catch(a){return clearTimeout(q),n.abort(),w?(D(i),h(a?.code||"load-failed","blocked",{message:a?.message})):(D(i),l({phase:"idle",reason:null}),null)}if(clearTimeout(q),!T)return m.catch(()=>{}),k(s.splice(0)),D(i),h("timeout");i?.commit(),l({mode:S?"draft":"edit",isEditMode:!0}),e&&G(),O(!0),f?.setSaveGeneration(r.generation);try{for(let a of s)a.enable()}catch(a){return l({mode:t,isEditMode:o}),O(!1),k(s),n.abort(),e&&(await import("./c-WVCT3ITX.js").catch(()=>null))?.startReader(e,M),h(a?.code||"load-failed","blocked",{message:a?.message})}x=s,l({phase:"idle",reason:null}),U();for(let a of c)e?.announce?.(a);return{ok:!0,mode:u(),changed:t!==u()}}async function J(e){if(!e)return[];let t=[];for(let r of N(e)){let s=j(r);if(s!=="export"&&typeof s!="function")continue;let c=e.loaded?.[r];if(!c)continue;let f=await(typeof s=="function"?s(c):c.modeParticipant?.());if(typeof f?.id!="string"||typeof f.prepare!="function")return null;t.push(f)}t.sort((r,s)=>(r.order??0)-(s.order??0));let o=[],n={generation:y,destination:P().destination,signal:void 0,represented:null,reader:null,initial:!0,isCurrent:()=>!0};for(let r of t){let s=null;try{s=await r.prepare(n)}catch{return null}s&&o.push(s)}return o}async function K(e){return(e?.loaded?.["core/save.js"]??await import("./core/save-K6Q47J2X.js").catch(()=>null))?.acceptedReceipt?.(y)??null}var R=Symbol("the exit deadline passed");function Q(){let e=null,t=Date.now()+$;return{expired:new Promise(n=>{e=setTimeout(()=>n(R),$)}),remaining:()=>Math.max(0,t-Date.now()),clear:()=>clearTimeout(e)}}async function Y(e,t){if(!e)return;let n=(await import("./c-WVCT3ITX.js")).importPlan(e,e.view);n.catch(()=>{});let r=await Promise.race([n.then(()=>null,s=>s),t]);if(r&&r!==R)throw r}async function Z(e=null){let t=Q();try{return await ee(e,t)}finally{t.clear()}}async function ee(e,t){let o=I;l({phase:"leaving"});let n=await import("./c-UD4VDBGJ.js").catch(()=>null);if(!n)return h("load-failed");let r=x;if(o&&!E){v??=J(e);let i=await Promise.race([v,t.expired]);if(i===R)return h("timeout");if(!i)return v=null,l({phase:"idle",reason:null}),null;E=!0,r=[...i,...r],x=r}try{await Y(e,t.expired)}catch(i){return h(i?.code||"load-failed","idle",{message:i?.message})}let s=[],c=null;try{if(c=n.claimOperation("mode"),!c)throw p("another document operation is in progress","busy");for(let w of[...r].reverse()){s.push(w);let m=await Promise.race([Promise.resolve(w.quiesce?.()),t.expired]);if(m===R)throw p("the exit deadline passed while a lease quiesced","timeout");if(m&&m.ok===!1)throw Object.assign(p("a lease refused the exit",m.code||"pending-input"),m)}let i=await n.runSaveBarrier({operation:c,timeoutMs:t.remaining()});if(!i.ok)throw Object.assign(p("the exit barrier refused",i.code||"save-failed"),i)}catch(i){for(let w of[...s].reverse())try{w.resume?.()}catch{}return l({phase:"idle",reason:i?.code||"save-failed"}),{ok:!1,mode:u(),code:i?.code||"save-failed",state:i?.state,pending:i?.pending}}finally{c&&n.releaseOperation(c)}k(r),x=[],I=!1,E=!1,v=null;let f=await K(e)??M;return M=null,e&&(await import("./c-WVCT3ITX.js").catch(()=>null))?.startReader(e,f),y++,O(!1),l({mode:"view",isEditMode:!1,phase:"idle",generation:y,reason:null}),G(),U(),{ok:!0,mode:"view",changed:!0}}function F(e,t=null){if(e!=="edit"&&e!=="view")throw new TypeError(`clay.modeLifecycle: unknown mode "${e}"`);if(d)return d.target===e?d.promise:{ok:!1,mode:u(),code:"busy"};if(e===u())return{ok:!0,mode:u(),changed:!1};if(S||e==="edit"&&!A)return{ok:!1,mode:u(),code:"not-allowed"};let o=(e==="edit"?V(t):Z(t)).finally(()=>{d=null});return d={target:e,promise:o},o}async function re(e,t){let o=await import("./c-WVCT3ITX.js").catch(()=>null);return!o||!o.liveAllowed(t)?null:(d||e===u()||e==="edit"&&o.openResources(),F(e,t))}async function oe(){if(u()==="view")return{ok:!0,mode:"view",changed:!1};if(d)return d.promise;let e=V().finally(()=>{d=null});return d={target:"edit",promise:e},e}export{oe as activateInitial,z as forgetParticipant,F as requestMode,re as switchMode};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as h}from"./c-Q6BG3ZLO.js";import{i as k,j as y}from"./c-
|
|
1
|
+
import{c as h}from"./c-Q6BG3ZLO.js";import{i as k,j as y}from"./c-JWW6BHWD.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-DT7E76Z2.js";import"./c-C6YZNU6E.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{C as g}from"./c-AI3H6ETU.js";import{d}from"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import{b as m}from"./c-RETTCOWO.js";import"./c-WCG6AKA7.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var b=e=>String(e).padStart(2,"0");function A(e){if(typeof e!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;let s=new Date(`${e}T12:00:00Z`);return Number.isFinite(s.valueOf())&&s.toISOString().slice(0,10)===e}var $=(e=new Date)=>`${e.getFullYear()}-${b(e.getMonth()+1)}-${b(e.getDate())}`,E=(e,s)=>{let a=new Date(`${e}T12:00:00Z`);return a.setUTCDate(a.getUTCDate()+s),a.toISOString().slice(0,10)},I=e=>{let s=E(e,1);return[{id:"today",name:`Today (${e})`,date:e},{id:"tomorrow",name:`Tomorrow (${s})`,date:s}]};function L({view:e=null}={}){if(!e)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let s=e.dom.ownerDocument,a=null;function l(t){let o=e.state;if(!o.selection.empty||o.selection.from!==t.from||t.from<0||t.from>o.doc.content.size)return null;let r=o.doc.resolve(t.from);return!r.parent.isTextblock||r.parent.type.spec.code||!r.parent.type.allowsMarkType(d.marks.date)?null:t.from}function D(t){try{let o=e.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=e.coordsAtPos(t.from);return{x:Math.max(8,r.left-o.left),y:r.bottom+6-o.top}}catch{return null}}function u(t){let o=t.picker.activeId();o?e.dom.setAttribute("aria-activedescendant",o):e.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&e.dom.removeAttribute("aria-activedescendant")}function c(){let t=a;if(t){a=null;for(let[o,r,n,i]of t.listen)o.removeEventListener(r,n,i);e.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&e.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function x(t,o){let r=String(o),n=e.state.tr.insertText(r,t,t);return n.addMark(t,t+r.length,d.marks.date.create({date:r})),n.insertText(" ",t+r.length),n.setSelection(m.TextSelection.create(n.doc,t+r.length+1)),e.dispatch(g(n)),e.focus(),{ok:!0,date:r}}async function f(t){let o=a;if(!o)return{ok:!1,code:"not-editing"};let r=o.picker.personAt(t),n=l(o);return n===null||!r||!A(r.date)?(c(),r?n===null?{ok:!1,code:"stale-target"}:{ok:!1,code:"invalid-date"}:{ok:!1,code:"no-date"}):(c(),k(e,()=>{let i=l(o);return i===null?{ok:!1,code:"stale-target"}:x(i,r.date)}))}function S(t){let o=a;if(!o||y(t,e))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),o.picker.move(t.key==="ArrowDown"?1:-1),u(o)):t.key==="Enter"?(r(),f(o.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),c())}function T(){c();let t={from:e.state.selection.from,days:I($()),picker:null,listen:[]};t.picker=h({document:s,label:"Insert a date",empty:"No date to insert",onPick:r=>f(r)}),a=t;let o=(r,n,i,p)=>{r.addEventListener(n,i,p),t.listen.push([r,n,i,p])};return o(s,"keydown",r=>S(r),!0),o(e.dom,"input",()=>c()),o(s,"mousedown",r=>{t.picker.el.contains(r.target)||c()},!0),(e.dom.parentElement??s.body).appendChild(t.picker.el),l(t)===null?(c(),{ok:!1,code:"stale-target"}):(t.picker.show(t.days,D(t)),u(t),{ok:!0,picker:!0})}return{async run(){return T()},dispose(){c()}}}export{L as createFeature,I as earlyDays,A as isISODate,$ as localISODate};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as S}from"./c-BULK5J4M.js";import{a as ne,b as F,c as re,d as oe}from"./c-N326R2JD.js";import{a as H}from"./c-JAX2667S.js";import{b as le,c as ae}from"./c-YINHPF4V.js";import"./c-P5NKFRL4.js";import"./c-LZJPNR2W.js";import{b as ce,g as ie}from"./c-SNVDWMM3.js";import{b as Z}from"./c-FZRZPIFS.js";import{b as se}from"./c-RTSRGGTP.js";import"./c-QTTJYJMA.js";import"./c-TWCXBWS3.js";import"./c-VKEDWYDF.js";import{E as te}from"./c-2YIJ6ZA6.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import{g as ee}from"./c-LO4C4J77.js";import"./c-FV46ZKGX.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import{a as J}from"./c-LA2BW7UY.js";import"./c-HSNGLIFB.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-RXTPKCMC.js";import"./c-RBPZNU2D.js";import{f as X}from"./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{h as Q}from"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var T="This spot changed again. Review the latest edit or download your copy.",ue="\uFFFC",C="",M=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),ge=new Set(["BR","WBR","IMG"]),L=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" ")),ke=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" ")),we=new Set("P H1 H2 H3 H4 H5 H6 SUMMARY".split(" ")),Ne=/[\u001E]/,ve={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0},k=e=>!!e&&e.nodeType===1,W=e=>k(e)&&M.has(e.tagName),B=e=>e.matches(le),z=e=>e.matches(ae),y=e=>e.localName==="template"&&e.content?e.content:e,w=e=>Array.prototype.indexOf.call(e.parentNode.childNodes,e),x=e=>e.getAttribute("data-id")||e.getAttribute("id")||null;function Ce(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function ye(e){if(e.nodeType===3)return!0;if(!k(e))return!1;if(B(e)||ge.has(e.tagName))return!0;if(!M.has(e.tagName))return!L.has(e.tagName);if(z(e))return!1;for(let n of e.childNodes)if(!ye(n))return!1;return!0}function Y(e){if(!ke.has(e.tagName)||B(e)||z(e))return!1;for(let n of e.childNodes)if(n.nodeType===8||!ye(n))return!1;return!0}function xe(e,n=document){for(let t of n.querySelectorAll("template")){if(t.content===e)return t;let r=xe(e,t.content);if(r)return r}return null}function m(e,n){for(let t=e;t;t=t.nodeType===11?xe(t):t.parentNode)if(t===n)return!0;return!1}var h=e=>m(e,document);function Ae(e,n){let t=e;for(let r of n)if(t=r==="content"?t.content:t.childNodes[r],!t)return null;return t}function D(e,n=new Set){if(k(e)){let t=x(e);t&&n.add(t)}if(e.nodeType===1||e.nodeType===11)for(let t of y(e).childNodes)D(t,n);return n}function Re(e){let n=document.createElement("template");return n.innerHTML=e,n.content}var Ie=e=>[...e.querySelectorAll("*")].some(n=>L.has(n.tagName));function Se(e){let n=[];for(let t=e;t.childNodes.length===1&&k(t.firstChild);t=t.firstChild)n.push(t.firstChild);return n}function De(e,n){let t=e.lastIndexOf("content");if(t<0)return document;let r=$(e.slice(0,t),n);return r&&r.content?r.content:null}function $(e,n){let t=Ae(n.root,e);if(!k(t))return null;let r=x(t),o=r?De(e,n):null;if(!o)return null;let s=[...o.querySelectorAll(t.localName)].filter(i=>i.namespaceURI===t.namespaceURI&&x(i)===r);return s.length===1?s[0]:null}function Me(e){let n=x(e);if(!n)return null;let t=[...document.querySelectorAll(e.localName)].filter(r=>r.namespaceURI===e.namespaceURI&&x(r)===n);return t.length===1?t[0]:null}function b(e,n,t=e?e.nodeType:1){if(!e)return null;for(let o of e.live)if(o.nodeType===t&&h(o))return o;if(t!==1)return null;if(e.local.length)return $(e.local[0],n);let r=e.live.find(k);return r?Me(r):null}function Pe(e){let n=e.live.find(k),t=n?x(n):null;return!!t&&![...document.querySelectorAll(n.localName)].some(r=>x(r)===t)}function _(e){let n=y(e),t={root:e,container:n,text:"",nodes:[],atoms:[],blocks:[]},r=s=>{for(let i of s){if(i.nodeType===3){if(!i.data)continue;t.nodes.push({node:i,s:t.text.length,e:t.text.length+i.data.length}),t.text+=i.data;continue}if(!k(i)||B(i))continue;if(Y(i)){t.text.length&&t.text[t.text.length-1]!==C&&(t.text+=C);let l={el:i,from:t.text.length,to:-1};t.blocks.push(l),r(i.childNodes),t.text+=C,l.to=t.text.length;continue}let c=M.has(i.tagName)&&Ce(i);if(ge.has(i.tagName)||!M.has(i.tagName)||z(i)||c){t.atoms.push({i:t.text.length,el:i}),t.text+=ue;continue}r(i.childNodes)}};if(r(n.childNodes),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&!t.blocks.length&&t.text.replace(ue,"").trim()===""){let s=t.atoms[0].i;t.text=t.text.slice(0,s)+t.text.slice(s+1),t.atoms=[];for(let i of t.nodes)i.s>s&&(i.s--,i.e--)}return t}function fe(e,n,t){for(let s of e.nodes)if(t==="start"?s.s<=n&&n<s.e:s.s<n&&n<=s.e)return[s.node,n-s.s];let r=t==="start"?n:n-1,o=e.atoms.find(s=>s.i===r);if(o)return[o.el.parentNode,w(o.el)+(t==="start"?0:1)];if(e.text[r]===C){let s=e.blocks.find(c=>c.to===r+1);if(s)return t==="start"?[s.el,s.el.childNodes.length]:[s.el.parentNode,w(s.el)+1];let i=e.blocks.find(c=>c.from===r+1);if(i)return t==="start"?[i.el,0]:[i.el.parentNode,w(i.el)]}for(let s of e.nodes)if(s.s===n||s.e===n)return[s.node,n-s.s];return[e.container,n===0?0:e.container.childNodes.length]}function j(e,n){let t=document.createRange();return t.setStart(e,n),t.setEnd(e,n),t}function K(e,n,t){if(n.nodeType===3){let i=e.nodes.find(c=>c.node===n);return i?i.s+t:null}if(n!==e.container&&!m(n,e.root))return null;let r=j(n,t),o=e.text.length,s=(i,c)=>{try{return r.comparePoint(i,c)>=0}catch{return!1}};for(let i of e.nodes)s(i.node,0)&&(o=Math.min(o,i.s));for(let i of e.atoms)s(i.el.parentNode,w(i.el))&&(o=Math.min(o,i.i));return o}function Le(e,n){let t=e.slice(n.bs,n.be),r=0;for(;r<t.length&&r<n.text.length&&t[r]===n.text[r];)r++;let o=0;for(;o<t.length-r&&o<n.text.length-r&&t[t.length-1-o]===n.text[n.text.length-1-o];)o++;return{bs:n.bs+r,be:n.be-o,text:n.text.slice(r,n.text.length-o)}}function G(e,n,t,r){if(e===n)return{s:t,e:r};let o=0,s=0,i=H.diff(e,n).map(c=>Le(e,c)).sort((c,l)=>c.bs-l.bs);for(let c of i){if(c.bs===c.be&&!c.text)continue;let l=c.text.length-(c.be-c.bs);if(c.be<=t)o+=l;else{if(c.bs>=r)continue;if(c.bs>=t&&c.be<=r){if(Ne.test(e.slice(c.bs,c.be)+c.text))return null;s+=l}else return null}}return{s:t+o,e:r+o+s}}function Be(e,n,t){let r=e.liveScope;if(r&&r.startContainer&&m(r.startContainer,n)&&m(r.endContainer,n)){let s=K(t,r.startContainer,r.startOffset);if(s!==null)return s}if(Y(n))return 0;let o=e.merged.text?t.text.indexOf(e.merged.text):-1;return o>=0&&t.text.indexOf(e.merged.text,o+1)<0?o:null}function Te(e,n){let t=e.commonAncestorContainer;for(t.nodeType===3&&(t=t.parentNode);t&&t!==n;t=t.parentNode)if(k(t)&&Y(t))return t;return n}var Oe=(e,n)=>e.tagName===n.tagName&&e.attributes.length===n.attributes.length&&[...e.attributes].every(t=>n.getAttribute(t.name)===t.value);function de(e,n){let t=[];for(let r=k(e)?e:e.parentNode;r&&r!==n&&W(r);r=r.parentNode)t.unshift(r);return t}function Ue(e,n,t){let[r,o]=e;if(r.nodeType===3){if(o!==0&&o!==r.data.length)return e;[r,o]=[r.parentNode,w(r)+(o===0?0:1)]}let s=!1;for(;r!==n&&W(r)&&(o===0||o===r.childNodes.length)&&!t.some(i=>Oe(i,r));)[r,o]=[r.parentNode,w(r)+(o===0?0:1)],s=!0;return s?[r,o]:e}function He(e,n,t){let r=de(n.startContainer,t),o=de(n.endContainer,t);return r.length!==o.length||r.some((s,i)=>s!==o[i])||r.length>e.wrappers.length||r.some((s,i)=>!Oe(s,e.wrappers[i]))?!1:(e.peel=r.length,!e.wrappers.slice(e.peel).some(s=>r.some(i=>i.tagName===s.tagName)))}function Fe(e,n,t,r){let o=e.childNodes.length===1&&k(e.firstChild)?e.firstChild:null;if(!o||!L.has(o.tagName))return;let s=document.createRange();s.setStart(...n),s.setEnd(...t);let i=Te(s,r);i===r||i.tagName!==o.tagName||i.namespaceURI!==o.namespaceURI||x(i)!==x(o)||o.replaceWith(...o.childNodes)}function Ge(e){if(!e.parsed)return e.fragment;let n=e.parsed.childNodes;return n.length?n.length===1&&n[0].nodeType===3?n[0].data:null:""}function Ve(e,n){let t=e.recovery.text,r=e.recovery.subject,o=b(r,n,r.nodeType);if(!o)return null;let s=o.nodeType===3&&o.parentNode?.localName==="textarea"?o.parentNode:o,i=t.local.text.slice(t.local.start,t.local.end);if(Ne.test(t.merged.text.slice(t.merged.start,t.merged.end))||i.includes(C))return null;let c={kind:"text",id:e.id,ticket:n.ticket,key:r.key,fragment:t.local.fragment,encoding:t.encoding,local:i,ids:new Set,range:document.createRange()};if(o.nodeType===8){let g=G(t.merged.text,o.data,t.merged.start,t.merged.end);return g?(c.range.setStart(o,g.s),c.range.setEnd(o,g.e),{...c,root:o,owner:o,scope:o,s:g.s,e:g.e,before:o.data,bs:g.s,be:g.e}):null}if(s.localName==="textarea"){if(c.encoding!=="plain")return null;let g=G(t.merged.text,s.value,t.merged.start,t.merged.end);return g?(c.range.selectNodeContents(s),{...c,root:s,field:s,scope:s,f:{text:s.value},s:g.s,e:g.e,before:s.value,bs:g.s,be:g.e}):null}let l=_(o),u=Be(t,o,l);if(u===null)return null;let d=G(t.merged.text,l.text.slice(u),t.merged.start,t.merged.end);if(!d)return null;let N=u+d.s,v=u+d.e,A=fe(l,N,"start"),a=N===v?A:fe(l,v,"end");if(c.parsed=c.encoding==="html"?Re(c.fragment):null,c.parsed&&Fe(c.parsed,A,a,o),c.parsed&&Ie(c.parsed)||(c.wrappers=c.parsed?Se(c.parsed):[],c.parsed&&D(c.parsed,c.ids),c.plain=Ge(c),N===v&&(A=a=Ue(A,o,c.wrappers)),c.range.setStart(...A),c.range.setEnd(...a),!He(c,c.range,o)))return null;let f=Te(c.range,o),p=f===o?l:_(f),E=K(p,...A),U=N===v?E:K(p,...a);return E===null||U===null||p.text.slice(E,U)!==l.text.slice(N,v)?null:{...c,root:o,f:l,s:N,e:v,scope:f,before:p.text,bs:E,be:U}}function qe(e){if(e.owner){let o=e.owner.data;e.owner.data=o.slice(0,e.s)+e.fragment+o.slice(e.e),e.check=()=>e.owner.data.slice(e.s,e.s+e.fragment.length)===e.fragment&&h(e.owner);return}if(e.field){let o=e.field,s=o.value.slice(0,e.s)+e.fragment+o.value.slice(e.e);o.textContent=s,o.value!==s&&(o.value=s,e.wroteProperty=!0),o.hasAttribute("data-value")&&o.setAttribute("data-value",s),e.check=()=>h(o)&&o.value===s&&o.textContent===s;return}let n=e.range,t=n.startContainer;if(e.plain!==null&&t.nodeType===3&&n.endContainer===t){let o=n.startOffset;t.replaceData(o,n.endOffset-o,e.plain),e.check=()=>h(t)&&t.data.slice(o,o+e.plain.length)===e.plain;return}n.deleteContents();let r=[];if(e.fragment)if(e.parsed){let o=document.importNode(e.parsed,!0),s=Se(o);for(let i=0;i<e.peel;i++)s[i].replaceWith(...s[i].childNodes);r=[...o.childNodes],n.insertNode(o)}else r=[document.createTextNode(e.fragment)],n.insertNode(r[0]);e.check=()=>r.every(h)&&(e.parsed||!r.length||r[0].data===e.fragment)}function _e(e,n){let t=b(e.recovery.subject,n,1);if(!t)return null;let r=e.recovery.attribute,o={kind:"attr",id:e.id,ticket:n.ticket,key:e.recovery.subject.key,el:t,ns:r.namespaceURI,name:r.qualifiedName,local:r.localName,value:e.local??null,ids:new Set};try{o.ns===null?document.createAttribute(o.name):document.createAttributeNS(o.ns,o.name)}catch{return null}return o}var je=new Set(["hidden","submit","image","reset","button","checkbox","radio","file"]);function Ke(e,n){let t=document.createElement("input");return t.type=e.type,t.value=n,t.value}function We(e){let n=e.el;return e.ns!==null||n.namespaceURI!=="http://www.w3.org/1999/xhtml"?null:n.localName==="input"&&e.name==="checked"&&(n.type==="checkbox"||n.type==="radio")?["checked",e.value!==null]:n.localName==="input"&&e.name==="value"&&!je.has(n.type)?["value",Ke(n,e.value??"")]:n.localName==="option"&&e.name==="selected"?["selected",e.value!==null]:null}function ze(e){e.ns===null?e.value===null?e.el.removeAttribute(e.name):e.el.setAttribute(e.name,e.value):e.value===null?e.el.removeAttributeNS(e.ns,e.local):e.el.setAttributeNS(e.ns,e.name,e.value);let n=We(e);n&&e.el[n[0]]!==n[1]&&(e.el[n[0]]=n[1],e.wroteProperty=!0);let t=()=>e.ns===null?e.el.getAttribute(e.name):e.el.getAttributeNS(e.ns,e.local);e.check=()=>h(e.el)&&t()===e.value&&(!n||e.el[n[0]]===n[1])}function Ye(e,n){let t=e.recovery.structure,r=e.recovery.subject,o=b(r,n,r.nodeType),s={id:e.id,ticket:n.ticket,key:r.key,apply:n,ids:new Set},i=c=>c?b(c.parent,n,1):null;if(t.localAction==="deleted")return o?{...s,kind:"remove",node:o}:Pe(r)?{...s,kind:"done",check:()=>!0}:null;if(t.localAction==="moved"){let c=i(t.localPlacement);return!o||!c||o===c||m(c,o)?null:{...s,kind:"move",node:o,parent:c,placement:t.localPlacement}}if(t.localAction==="reordered"){if(!o||!t.localOrder)return null;let c=y(o),l=t.localOrder.map(u=>b(u,n,u.nodeType)).filter(u=>u&&u.parentNode===c);return l.length<2?null:{...s,kind:"reorder",parent:o,order:l}}if(t.localAction==="inserted"){let c=i(t.localPlacement);if(!c||o&&o.parentNode!==y(c))return null;if(t.fragmentKind!=="element")return typeof t.localFragment!="string"?null:{...s,kind:"run",node:o,parent:c,placement:t.localPlacement,text:t.localFragment,nodeType:r.nodeType};let l=r.local.length?Ae(n.root,r.local[0]):null;if(!k(l))return null;let u=o?o.tagName===l.tagName&&o.namespaceURI===l.namespaceURI?"morph":"replace":"place";return{...s,kind:"realize",node:o,parent:c,placement:t.localPlacement,src:l,mode:u,ids:D(l)}}return null}function V(e,n,t,r){let o=y(n),s=l=>{for(let u of l){let d=b(u,r,u.nodeType);if(d&&d!==e&&d.parentNode===o)return d}return null},i=s(t.before);if(i)return o.insertBefore(e,i);let c=s(t.after);return c?o.insertBefore(e,c.nextSibling):t.before.length?o.insertBefore(e,o.firstChild):o.appendChild(e)}function $e(e){let n=document.importNode(e.src,!0),t=document.createDocumentFragment();return t.append(n),e.apply.domain==="save"&&(se(t),ce(t),ie(t),Z(t)),n}function Qe(e,n){let t=e.filter(r=>r.kind==="move");for(let r of t)n.append(r.node);for(let r of e){if(r.kind==="run"){r.node?r.node.data=r.text:r.node=V(r.nodeType===8?document.createComment(r.text):document.createTextNode(r.text),r.parent,r.placement,r.apply),r.check=()=>h(r.node)&&r.node.parentNode===y(r.parent)&&r.node.data===r.text;continue}if(r.kind!=="realize")continue;let o=$e(r);r.mode==="morph"?H.morphElement(r.node,o,{ignore:B,scripts:{execute:!1}}):r.mode==="replace"?(r.node.replaceWith(o),r.node=o):r.node=V(o,r.parent,r.placement,r.apply),r.check=()=>h(r.node)&&r.node.parentNode===y(r.parent)}for(let r of t)V(r.node,r.parent,r.placement,r.apply),r.check=()=>r.node.parentNode===y(r.parent)&&h(r.node);for(let r of e){if(r.kind!=="reorder")continue;let o=y(r.parent),s=r.order.filter(u=>u.parentNode===o),i=s.slice(),c=[...o.childNodes].map(u=>s.includes(u)?i.shift():u),l=null;for(let u=c.length-1;u>=0;u--){let d=c[u];s.includes(d)&&d.nextSibling!==l&&o.insertBefore(d,l),l=d}r.check=()=>{let u=[...o.childNodes].filter(d=>s.includes(d));return u.length===s.length&&u.every((d,N)=>d===s[N])}}for(let r of e)r.kind==="remove"&&(r.node.remove(),r.check=()=>!h(r.node))}function O(e){return e.kind==="move"||e.kind==="remove"?[e.node]:e.kind==="realize"||e.kind==="run"?e.node?[e.node]:[]:[]}function R(e){return e.kind==="text"?[e.scope]:e.kind==="move"||e.kind==="reorder"?[e.parent]:(e.kind==="realize"||e.kind==="run")&&!e.node?[e.parent]:[]}var be=e=>e.kind==="attr"?[e.el]:[...O(e),...R(e)];function Xe(e,n){try{let t=j(e.startContainer,e.startOffset),r=j(n.startContainer,n.startOffset);return e.collapsed&&n.collapsed?t.comparePoint(n.startContainer,n.startOffset)===0:t.comparePoint(n.endContainer,n.endOffset)>0&&r.comparePoint(e.endContainer,e.endOffset)>0}catch{return!1}}function Je(e,n){try{return e.comparePoint(n.startContainer,n.startOffset)===0&&e.comparePoint(n.endContainer,n.endOffset)===0}catch{return!1}}function Ze(e,n){try{return e.intersectsNode(n)&&!m(e.commonAncestorContainer,n)}catch{return!1}}function I(e,n){if(!e.ids.size&&!n.ids.size)return!1;let t=s=>{let i=new Set;for(let c of be(s))D(c,i);return i},r=e.ids.size?null:t(e),o=t(n);return[...e.ids].some(s=>n.ids.has(s)||o.has(s))||[...n.ids].some(s=>(r||t(e)).has(s))}function me(e,n){return n.kind==="text"?Ze(n.range,e.el):O(n).some(t=>m(e.el,t))||n.ids.has(x(e.el))}function pe(e,n){return n.kind==="reorder"?m(n.parent,e.scope)||I(e,n):O(n).some(t=>m(t,e.scope)||m(e.scope,t))||R(n).some(t=>m(t,e.scope))?!0:I(e,n)}function he(e,n){return O(n).some(t=>e.order.includes(t)||m(e.parent,t))||R(n).includes(e.parent)?!0:I(e,n)}function q(e,n){if(e.kind==="done"||n.kind==="done")return!1;if(e.kind==="text"&&n.kind==="text")return Xe(e.range,n.range);if(e.kind==="attr"&&n.kind==="attr")return e.el===n.el&&e.ns===n.ns&&e.local===n.local;if(e.kind==="attr")return me(e,n);if(n.kind==="attr")return me(n,e);if(e.kind==="text")return pe(e,n);if(n.kind==="text")return pe(n,e);if(e.kind==="reorder"&&n.kind==="reorder")return e.parent===n.parent||I(e,n);if(e.kind==="reorder")return he(e,n);if(n.kind==="reorder")return he(n,e);for(let t of O(e))for(let r of O(n))if(m(t,r)||m(r,t))return!0;for(let t of O(e))for(let r of R(n))if(m(r,t))return!0;for(let t of O(n))for(let r of R(e))if(m(r,t))return!0;return I(e,n)}function et(e,n){return e.kind==="done"?!1:e.kind==="attr"?m(e.el,n.node):be(e).some(t=>m(t,n.node)||m(n.node,t))?!0:e.ids.size?(n.ids||(n.ids=D(n.node)),[...e.ids].some(t=>n.ids.has(t))):!1}function tt(e,n){return e.kind==="text"&&n.kind==="text"&&!e.field&&e.root===n.root&&Je(e.range,n.range)}function nt(e,n){let t=oe(e);return t?t.nodes:[rt(e,n)]}function rt(e,n){let t=e.recovery,r=t.subject;for(let c of t.text?[t.text.liveSpan,t.text.liveScope]:[])if(c&&c.startContainer&&h(c.startContainer)&&h(c.endContainer))return st(ot(c));let o=r?b(r,n,r.nodeType):null;if(o)return o;let s=t.structure&&t.structure.localPlacement?b(t.structure.localPlacement.parent,n,1):null;if(s)return s;let i=r&&r.local.length?r.local[0]:[];for(let c=i.length-1;c>0;c--){if(i[c-1]==="content")continue;let l=$(i.slice(0,c),n);if(l)return l}return document.documentElement}function ot(e){let n=new Set;for(let r=e.startContainer;r;r=r.parentNode)n.add(r);let t=e.endContainer;for(;t&&!n.has(t);)t=t.parentNode;return t.nodeType===1||t.nodeType===11?t:t.parentNode}function st(e){for(let n=e;n;n=n.parentNode)if(k(n)&&ke.has(n.tagName))return n;return e}function ct(e,n){let t=e.recovery;return t.applied===!1||t.unavailable?null:t.structure?Ye(e,n):t.text?Ve(e,n):t.attribute?_e(e,n):null}var P=()=>`${re()}|${S.hasPendingApply()?1:0}|${S.list().map(e=>e.id).join(",")}`;function Ee(){let e={ids:new Map,nested:new Set},n=r=>{for(let o of["id","data-id"]){let s=r.getAttribute(o);s&&e.ids.set(`${o} ${s}`,(e.ids.get(`${o} ${s}`)||0)+1)}},t=(r,o)=>{for(let s of y(r).children)n(s),o&&L.has(s.tagName)&&e.nested.add(s),t(s,o||W(s)||we.has(s.tagName))};return n(document.documentElement),t(document.documentElement,!1),e}function it(e){let n=Ee();for(let[r,o]of n.ids)if(o>1&&(e.before.ids.get(r)||0)<=1)return!1;for(let r of n.nested)if(!e.before.nested.has(r))return!1;let t=new Map;for(let r of e.ops)r.kind==="text"&&t.set(r.scope,[...t.get(r.scope)||[],r]);for(let[r,o]of t){let s=o[0].before;for(let c of[...o].sort((l,u)=>u.bs-l.bs))s=s.slice(0,c.bs)+c.local+s.slice(c.be);if((o[0].owner?r.data:o[0].field?r.value:_(r).text)!==s)return!1}return!0}function lt(){let e=new Map,n=c=>{for(let l of c.querySelectorAll("*"))e.set(l,[...l.attributes].map(u=>[u,u.value])),l.localName==="template"&&l.content&&n(l.content)};n(document);let t=[];for(let c of document.querySelectorAll("input, textarea"))t.push([c,"value",c.value]);for(let c of document.querySelectorAll("input"))t.push([c,"checked",c.checked]);for(let c of document.querySelectorAll("option"))t.push([c,"selected",c.selected]);let r=document.activeElement,o=null;try{r&&typeof r.selectionStart=="number"&&(o=[r.selectionStart,r.selectionEnd,r.selectionDirection])}catch{}let s=document.getSelection(),i=s&&s.rangeCount?[s.anchorNode,s.anchorOffset,s.focusNode,s.focusOffset]:null;return{attrs:e,controls:t,active:r,caret:o,selection:i}}function at(e,n){let t=e.attributes;return t.length===n.length&&n.every(([r,o],s)=>t[s]===r&&r.value===o)}function ut(e,n){let t=new Set;for(let s=e.length-1;s>=0;s--){let i=e[s];if(i.type==="characterData")i.target.data=i.oldValue;else if(i.type==="attributes")t.add(i.target);else{for(let c of i.addedNodes)c.parentNode===i.target&&i.target.removeChild(c);for(let c of i.removedNodes)i.target.insertBefore(c,i.nextSibling)}}for(let s of t){let i=n.attrs.get(s);if(!(!i||at(s,i))){for(let c of[...s.attributes])s.removeAttributeNode(c);for(let[c,l]of i)c.value=l,s.setAttributeNode(c)}}for(let[s,i,c]of n.controls)if(s[i]!==c)try{s[i]=c}catch{}let r=document.getSelection();r&&n.selection?h(n.selection[0])&&h(n.selection[2])&&r.setBaseAndExtent(...n.selection):r&&r.rangeCount&&r.removeAllRanges();let o=n.active;if(o&&o!==document.activeElement&&o!==document.body&&h(o)&&o.focus&&o.focus({preventScroll:!0}),n.caret&&document.activeElement===o)try{o.setSelectionRange(...n.caret)}catch{}}function ft(e){let n=t=>{e.observe(t,ve);for(let r of t.querySelectorAll("template"))r.content&&n(r.content)};n(document)}function dt(e){let n=new Set;for(let t of e)if(t.type==="characterData"){if(n.has(t.target))return!1;n.add(t.target)}return!0}function mt(e){let n=P(),t=new Map,r=new Map,o=[],s=new Set;for(let a of e){if(s.has(a))continue;s.add(a);let f=S.get(a);f&&(f.claimedBy||f.kind==="apply-incomplete"||f.kind==="json"||!f.recovery?t.set(a,T):o.push(f))}if(S.hasPendingApply()){for(let a of o)t.set(a.id,T);return{ops:[],covered:r,blocked:t,revision:n,before:null}}let i=[],c=a=>{let f=S.recoveryOf(a.id),p=f?ct(a,f):null;if(!p&&f)for(let E of nt(a,f))i.push({ticket:f.ticket,node:E});return p},l=[];for(let a of o){let f=c(a);f?l.push(f):t.set(a.id,T)}let u=[];for(let a of S.list())if(!s.has(a.id)){if(a.kind==="apply-incomplete")i.push({ticket:a.ticket,node:document.documentElement});else if(a.recovery){let f=c(a);f&&u.push(f)}}l.sort((a,f)=>f.ticket-a.ticket);let d=[],N=[],v=a=>{t.set(a.id,T),N.push(a)};for(let a of l){if(i.some(p=>p.ticket>a.ticket&&et(a,p))||u.some(p=>p.ticket>a.ticket&&q(p,a))||N.some(p=>q(p,a))){v(a);continue}let f=d.find(p=>q(p,a));if(!f){d.push(a);continue}if(tt(f,a)){r.set(a.id,f.id);continue}v(a),f.ticket===a.ticket&&(d.splice(d.indexOf(f),1),v(f))}let A=ne(i.filter(a=>d.some(f=>a.ticket>f.ticket)).map(a=>a.node));return{ops:d,covered:r,blocked:t,revision:P(),protectedWitnesses:A,before:Ee()}}function pt(e){if(e.revision!==P()||!F(e.protectedWitnesses||[])){for(let c of e.ops)e.blocked.set(c.id,T);for(let c of e.covered.keys())e.blocked.set(c,T);return[]}let n=lt(),t=window.clay?.undo;t?.pause?.();let r=new MutationObserver(()=>{}),o=document.createDocumentFragment(),s=[],i=!1;try{ft(r),r.observe(o,ve);let c=e.ops.filter(l=>l.kind==="text").sort((l,u)=>l.root===u.root?u.s-l.s||u.e-l.e:0);for(let l of c)qe(l);for(let l of e.ops)l.kind==="attr"&&ze(l);Qe(e.ops.filter(l=>l.kind!=="text"&&l.kind!=="attr"),o),s=r.takeRecords(),i=e.ops.every(l=>l.check())&&it(e)&&e.revision===P()&&F(e.protectedWitnesses||[])}catch(c){console.error("[clay] Revert to mine failed while writing and was undone",c)}finally{s=s.concat(r.takeRecords()),r.disconnect()}if(i)return dt(s)&&!e.ops.some(c=>c.wroteProperty)?t?.commitCaptured?.("Revert to mine"):t?.discardCaptured?.(),t?.resume?.(),[...e.ops.map(c=>c.id),...e.covered.keys()];try{ut(s,n)}finally{J.dropQueued(),t?.discardCaptured?.(),t?.resume?.()}for(let c of e.ops)e.blocked.set(c.id,T);for(let c of e.covered.keys())e.blocked.set(c,T);return[]}async function wt(e){await Promise.resolve();let n=mt(e),t=pt(n);Q();let r=null;return t.length&&(ee(),S.acknowledge(t,{reason:"reverted"}),X(),await Promise.resolve(),r=await te()),{revertedIds:t,blockedIds:[...n.blocked.keys()],saveResult:r}}export{T as BLOCKED,pt as applyRevert,mt as prepareRevert,wt as revertConflicts};
|
|
1
|
+
import{f as S}from"./c-RWJ3OSCP.js";import{a as ne,b as F,c as re,d as oe}from"./c-N326R2JD.js";import{a as H}from"./c-JAX2667S.js";import{b as le,c as ae}from"./c-QWB53KRW.js";import"./c-QDVG4NAZ.js";import"./c-LZJPNR2W.js";import{b as ce,g as ie}from"./c-IJHF4IO6.js";import{b as Z}from"./c-U65PREMC.js";import{b as se}from"./c-FJDTDGDA.js";import"./c-QTTJYJMA.js";import"./c-QCDVDZIR.js";import"./c-VKEDWYDF.js";import{E as te}from"./c-VMXCX52Q.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import{g as ee}from"./c-P73XPAOA.js";import"./c-ZPI7M5U5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import{a as J}from"./c-MZCOGNZL.js";import"./c-MFB74XVN.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-KU3PX7LL.js";import"./c-EQ5NBOGA.js";import{f as X}from"./c-IJUK2GPW.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-PNZIJFG7.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import{h as Q}from"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var T="This spot changed again. Review the latest edit or download your copy.",ue="\uFFFC",C="",M=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),ge=new Set(["BR","WBR","IMG"]),L=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" ")),ke=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" ")),we=new Set("P H1 H2 H3 H4 H5 H6 SUMMARY".split(" ")),Ne=/[\u001E]/,ve={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0},k=e=>!!e&&e.nodeType===1,W=e=>k(e)&&M.has(e.tagName),B=e=>e.matches(le),z=e=>e.matches(ae),y=e=>e.localName==="template"&&e.content?e.content:e,w=e=>Array.prototype.indexOf.call(e.parentNode.childNodes,e),x=e=>e.getAttribute("data-id")||e.getAttribute("id")||null;function Ce(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function ye(e){if(e.nodeType===3)return!0;if(!k(e))return!1;if(B(e)||ge.has(e.tagName))return!0;if(!M.has(e.tagName))return!L.has(e.tagName);if(z(e))return!1;for(let n of e.childNodes)if(!ye(n))return!1;return!0}function Y(e){if(!ke.has(e.tagName)||B(e)||z(e))return!1;for(let n of e.childNodes)if(n.nodeType===8||!ye(n))return!1;return!0}function xe(e,n=document){for(let t of n.querySelectorAll("template")){if(t.content===e)return t;let r=xe(e,t.content);if(r)return r}return null}function m(e,n){for(let t=e;t;t=t.nodeType===11?xe(t):t.parentNode)if(t===n)return!0;return!1}var h=e=>m(e,document);function Ae(e,n){let t=e;for(let r of n)if(t=r==="content"?t.content:t.childNodes[r],!t)return null;return t}function D(e,n=new Set){if(k(e)){let t=x(e);t&&n.add(t)}if(e.nodeType===1||e.nodeType===11)for(let t of y(e).childNodes)D(t,n);return n}function Re(e){let n=document.createElement("template");return n.innerHTML=e,n.content}var Ie=e=>[...e.querySelectorAll("*")].some(n=>L.has(n.tagName));function Se(e){let n=[];for(let t=e;t.childNodes.length===1&&k(t.firstChild);t=t.firstChild)n.push(t.firstChild);return n}function De(e,n){let t=e.lastIndexOf("content");if(t<0)return document;let r=$(e.slice(0,t),n);return r&&r.content?r.content:null}function $(e,n){let t=Ae(n.root,e);if(!k(t))return null;let r=x(t),o=r?De(e,n):null;if(!o)return null;let s=[...o.querySelectorAll(t.localName)].filter(i=>i.namespaceURI===t.namespaceURI&&x(i)===r);return s.length===1?s[0]:null}function Me(e){let n=x(e);if(!n)return null;let t=[...document.querySelectorAll(e.localName)].filter(r=>r.namespaceURI===e.namespaceURI&&x(r)===n);return t.length===1?t[0]:null}function b(e,n,t=e?e.nodeType:1){if(!e)return null;for(let o of e.live)if(o.nodeType===t&&h(o))return o;if(t!==1)return null;if(e.local.length)return $(e.local[0],n);let r=e.live.find(k);return r?Me(r):null}function Pe(e){let n=e.live.find(k),t=n?x(n):null;return!!t&&![...document.querySelectorAll(n.localName)].some(r=>x(r)===t)}function _(e){let n=y(e),t={root:e,container:n,text:"",nodes:[],atoms:[],blocks:[]},r=s=>{for(let i of s){if(i.nodeType===3){if(!i.data)continue;t.nodes.push({node:i,s:t.text.length,e:t.text.length+i.data.length}),t.text+=i.data;continue}if(!k(i)||B(i))continue;if(Y(i)){t.text.length&&t.text[t.text.length-1]!==C&&(t.text+=C);let l={el:i,from:t.text.length,to:-1};t.blocks.push(l),r(i.childNodes),t.text+=C,l.to=t.text.length;continue}let c=M.has(i.tagName)&&Ce(i);if(ge.has(i.tagName)||!M.has(i.tagName)||z(i)||c){t.atoms.push({i:t.text.length,el:i}),t.text+=ue;continue}r(i.childNodes)}};if(r(n.childNodes),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&!t.blocks.length&&t.text.replace(ue,"").trim()===""){let s=t.atoms[0].i;t.text=t.text.slice(0,s)+t.text.slice(s+1),t.atoms=[];for(let i of t.nodes)i.s>s&&(i.s--,i.e--)}return t}function fe(e,n,t){for(let s of e.nodes)if(t==="start"?s.s<=n&&n<s.e:s.s<n&&n<=s.e)return[s.node,n-s.s];let r=t==="start"?n:n-1,o=e.atoms.find(s=>s.i===r);if(o)return[o.el.parentNode,w(o.el)+(t==="start"?0:1)];if(e.text[r]===C){let s=e.blocks.find(c=>c.to===r+1);if(s)return t==="start"?[s.el,s.el.childNodes.length]:[s.el.parentNode,w(s.el)+1];let i=e.blocks.find(c=>c.from===r+1);if(i)return t==="start"?[i.el,0]:[i.el.parentNode,w(i.el)]}for(let s of e.nodes)if(s.s===n||s.e===n)return[s.node,n-s.s];return[e.container,n===0?0:e.container.childNodes.length]}function j(e,n){let t=document.createRange();return t.setStart(e,n),t.setEnd(e,n),t}function K(e,n,t){if(n.nodeType===3){let i=e.nodes.find(c=>c.node===n);return i?i.s+t:null}if(n!==e.container&&!m(n,e.root))return null;let r=j(n,t),o=e.text.length,s=(i,c)=>{try{return r.comparePoint(i,c)>=0}catch{return!1}};for(let i of e.nodes)s(i.node,0)&&(o=Math.min(o,i.s));for(let i of e.atoms)s(i.el.parentNode,w(i.el))&&(o=Math.min(o,i.i));return o}function Le(e,n){let t=e.slice(n.bs,n.be),r=0;for(;r<t.length&&r<n.text.length&&t[r]===n.text[r];)r++;let o=0;for(;o<t.length-r&&o<n.text.length-r&&t[t.length-1-o]===n.text[n.text.length-1-o];)o++;return{bs:n.bs+r,be:n.be-o,text:n.text.slice(r,n.text.length-o)}}function G(e,n,t,r){if(e===n)return{s:t,e:r};let o=0,s=0,i=H.diff(e,n).map(c=>Le(e,c)).sort((c,l)=>c.bs-l.bs);for(let c of i){if(c.bs===c.be&&!c.text)continue;let l=c.text.length-(c.be-c.bs);if(c.be<=t)o+=l;else{if(c.bs>=r)continue;if(c.bs>=t&&c.be<=r){if(Ne.test(e.slice(c.bs,c.be)+c.text))return null;s+=l}else return null}}return{s:t+o,e:r+o+s}}function Be(e,n,t){let r=e.liveScope;if(r&&r.startContainer&&m(r.startContainer,n)&&m(r.endContainer,n)){let s=K(t,r.startContainer,r.startOffset);if(s!==null)return s}if(Y(n))return 0;let o=e.merged.text?t.text.indexOf(e.merged.text):-1;return o>=0&&t.text.indexOf(e.merged.text,o+1)<0?o:null}function Te(e,n){let t=e.commonAncestorContainer;for(t.nodeType===3&&(t=t.parentNode);t&&t!==n;t=t.parentNode)if(k(t)&&Y(t))return t;return n}var Oe=(e,n)=>e.tagName===n.tagName&&e.attributes.length===n.attributes.length&&[...e.attributes].every(t=>n.getAttribute(t.name)===t.value);function de(e,n){let t=[];for(let r=k(e)?e:e.parentNode;r&&r!==n&&W(r);r=r.parentNode)t.unshift(r);return t}function Ue(e,n,t){let[r,o]=e;if(r.nodeType===3){if(o!==0&&o!==r.data.length)return e;[r,o]=[r.parentNode,w(r)+(o===0?0:1)]}let s=!1;for(;r!==n&&W(r)&&(o===0||o===r.childNodes.length)&&!t.some(i=>Oe(i,r));)[r,o]=[r.parentNode,w(r)+(o===0?0:1)],s=!0;return s?[r,o]:e}function He(e,n,t){let r=de(n.startContainer,t),o=de(n.endContainer,t);return r.length!==o.length||r.some((s,i)=>s!==o[i])||r.length>e.wrappers.length||r.some((s,i)=>!Oe(s,e.wrappers[i]))?!1:(e.peel=r.length,!e.wrappers.slice(e.peel).some(s=>r.some(i=>i.tagName===s.tagName)))}function Fe(e,n,t,r){let o=e.childNodes.length===1&&k(e.firstChild)?e.firstChild:null;if(!o||!L.has(o.tagName))return;let s=document.createRange();s.setStart(...n),s.setEnd(...t);let i=Te(s,r);i===r||i.tagName!==o.tagName||i.namespaceURI!==o.namespaceURI||x(i)!==x(o)||o.replaceWith(...o.childNodes)}function Ge(e){if(!e.parsed)return e.fragment;let n=e.parsed.childNodes;return n.length?n.length===1&&n[0].nodeType===3?n[0].data:null:""}function Ve(e,n){let t=e.recovery.text,r=e.recovery.subject,o=b(r,n,r.nodeType);if(!o)return null;let s=o.nodeType===3&&o.parentNode?.localName==="textarea"?o.parentNode:o,i=t.local.text.slice(t.local.start,t.local.end);if(Ne.test(t.merged.text.slice(t.merged.start,t.merged.end))||i.includes(C))return null;let c={kind:"text",id:e.id,ticket:n.ticket,key:r.key,fragment:t.local.fragment,encoding:t.encoding,local:i,ids:new Set,range:document.createRange()};if(o.nodeType===8){let g=G(t.merged.text,o.data,t.merged.start,t.merged.end);return g?(c.range.setStart(o,g.s),c.range.setEnd(o,g.e),{...c,root:o,owner:o,scope:o,s:g.s,e:g.e,before:o.data,bs:g.s,be:g.e}):null}if(s.localName==="textarea"){if(c.encoding!=="plain")return null;let g=G(t.merged.text,s.value,t.merged.start,t.merged.end);return g?(c.range.selectNodeContents(s),{...c,root:s,field:s,scope:s,f:{text:s.value},s:g.s,e:g.e,before:s.value,bs:g.s,be:g.e}):null}let l=_(o),u=Be(t,o,l);if(u===null)return null;let d=G(t.merged.text,l.text.slice(u),t.merged.start,t.merged.end);if(!d)return null;let N=u+d.s,v=u+d.e,A=fe(l,N,"start"),a=N===v?A:fe(l,v,"end");if(c.parsed=c.encoding==="html"?Re(c.fragment):null,c.parsed&&Fe(c.parsed,A,a,o),c.parsed&&Ie(c.parsed)||(c.wrappers=c.parsed?Se(c.parsed):[],c.parsed&&D(c.parsed,c.ids),c.plain=Ge(c),N===v&&(A=a=Ue(A,o,c.wrappers)),c.range.setStart(...A),c.range.setEnd(...a),!He(c,c.range,o)))return null;let f=Te(c.range,o),p=f===o?l:_(f),E=K(p,...A),U=N===v?E:K(p,...a);return E===null||U===null||p.text.slice(E,U)!==l.text.slice(N,v)?null:{...c,root:o,f:l,s:N,e:v,scope:f,before:p.text,bs:E,be:U}}function qe(e){if(e.owner){let o=e.owner.data;e.owner.data=o.slice(0,e.s)+e.fragment+o.slice(e.e),e.check=()=>e.owner.data.slice(e.s,e.s+e.fragment.length)===e.fragment&&h(e.owner);return}if(e.field){let o=e.field,s=o.value.slice(0,e.s)+e.fragment+o.value.slice(e.e);o.textContent=s,o.value!==s&&(o.value=s,e.wroteProperty=!0),o.hasAttribute("data-value")&&o.setAttribute("data-value",s),e.check=()=>h(o)&&o.value===s&&o.textContent===s;return}let n=e.range,t=n.startContainer;if(e.plain!==null&&t.nodeType===3&&n.endContainer===t){let o=n.startOffset;t.replaceData(o,n.endOffset-o,e.plain),e.check=()=>h(t)&&t.data.slice(o,o+e.plain.length)===e.plain;return}n.deleteContents();let r=[];if(e.fragment)if(e.parsed){let o=document.importNode(e.parsed,!0),s=Se(o);for(let i=0;i<e.peel;i++)s[i].replaceWith(...s[i].childNodes);r=[...o.childNodes],n.insertNode(o)}else r=[document.createTextNode(e.fragment)],n.insertNode(r[0]);e.check=()=>r.every(h)&&(e.parsed||!r.length||r[0].data===e.fragment)}function _e(e,n){let t=b(e.recovery.subject,n,1);if(!t)return null;let r=e.recovery.attribute,o={kind:"attr",id:e.id,ticket:n.ticket,key:e.recovery.subject.key,el:t,ns:r.namespaceURI,name:r.qualifiedName,local:r.localName,value:e.local??null,ids:new Set};try{o.ns===null?document.createAttribute(o.name):document.createAttributeNS(o.ns,o.name)}catch{return null}return o}var je=new Set(["hidden","submit","image","reset","button","checkbox","radio","file"]);function Ke(e,n){let t=document.createElement("input");return t.type=e.type,t.value=n,t.value}function We(e){let n=e.el;return e.ns!==null||n.namespaceURI!=="http://www.w3.org/1999/xhtml"?null:n.localName==="input"&&e.name==="checked"&&(n.type==="checkbox"||n.type==="radio")?["checked",e.value!==null]:n.localName==="input"&&e.name==="value"&&!je.has(n.type)?["value",Ke(n,e.value??"")]:n.localName==="option"&&e.name==="selected"?["selected",e.value!==null]:null}function ze(e){e.ns===null?e.value===null?e.el.removeAttribute(e.name):e.el.setAttribute(e.name,e.value):e.value===null?e.el.removeAttributeNS(e.ns,e.local):e.el.setAttributeNS(e.ns,e.name,e.value);let n=We(e);n&&e.el[n[0]]!==n[1]&&(e.el[n[0]]=n[1],e.wroteProperty=!0);let t=()=>e.ns===null?e.el.getAttribute(e.name):e.el.getAttributeNS(e.ns,e.local);e.check=()=>h(e.el)&&t()===e.value&&(!n||e.el[n[0]]===n[1])}function Ye(e,n){let t=e.recovery.structure,r=e.recovery.subject,o=b(r,n,r.nodeType),s={id:e.id,ticket:n.ticket,key:r.key,apply:n,ids:new Set},i=c=>c?b(c.parent,n,1):null;if(t.localAction==="deleted")return o?{...s,kind:"remove",node:o}:Pe(r)?{...s,kind:"done",check:()=>!0}:null;if(t.localAction==="moved"){let c=i(t.localPlacement);return!o||!c||o===c||m(c,o)?null:{...s,kind:"move",node:o,parent:c,placement:t.localPlacement}}if(t.localAction==="reordered"){if(!o||!t.localOrder)return null;let c=y(o),l=t.localOrder.map(u=>b(u,n,u.nodeType)).filter(u=>u&&u.parentNode===c);return l.length<2?null:{...s,kind:"reorder",parent:o,order:l}}if(t.localAction==="inserted"){let c=i(t.localPlacement);if(!c||o&&o.parentNode!==y(c))return null;if(t.fragmentKind!=="element")return typeof t.localFragment!="string"?null:{...s,kind:"run",node:o,parent:c,placement:t.localPlacement,text:t.localFragment,nodeType:r.nodeType};let l=r.local.length?Ae(n.root,r.local[0]):null;if(!k(l))return null;let u=o?o.tagName===l.tagName&&o.namespaceURI===l.namespaceURI?"morph":"replace":"place";return{...s,kind:"realize",node:o,parent:c,placement:t.localPlacement,src:l,mode:u,ids:D(l)}}return null}function V(e,n,t,r){let o=y(n),s=l=>{for(let u of l){let d=b(u,r,u.nodeType);if(d&&d!==e&&d.parentNode===o)return d}return null},i=s(t.before);if(i)return o.insertBefore(e,i);let c=s(t.after);return c?o.insertBefore(e,c.nextSibling):t.before.length?o.insertBefore(e,o.firstChild):o.appendChild(e)}function $e(e){let n=document.importNode(e.src,!0),t=document.createDocumentFragment();return t.append(n),e.apply.domain==="save"&&(se(t),ce(t),ie(t),Z(t)),n}function Qe(e,n){let t=e.filter(r=>r.kind==="move");for(let r of t)n.append(r.node);for(let r of e){if(r.kind==="run"){r.node?r.node.data=r.text:r.node=V(r.nodeType===8?document.createComment(r.text):document.createTextNode(r.text),r.parent,r.placement,r.apply),r.check=()=>h(r.node)&&r.node.parentNode===y(r.parent)&&r.node.data===r.text;continue}if(r.kind!=="realize")continue;let o=$e(r);r.mode==="morph"?H.morphElement(r.node,o,{ignore:B,scripts:{execute:!1}}):r.mode==="replace"?(r.node.replaceWith(o),r.node=o):r.node=V(o,r.parent,r.placement,r.apply),r.check=()=>h(r.node)&&r.node.parentNode===y(r.parent)}for(let r of t)V(r.node,r.parent,r.placement,r.apply),r.check=()=>r.node.parentNode===y(r.parent)&&h(r.node);for(let r of e){if(r.kind!=="reorder")continue;let o=y(r.parent),s=r.order.filter(u=>u.parentNode===o),i=s.slice(),c=[...o.childNodes].map(u=>s.includes(u)?i.shift():u),l=null;for(let u=c.length-1;u>=0;u--){let d=c[u];s.includes(d)&&d.nextSibling!==l&&o.insertBefore(d,l),l=d}r.check=()=>{let u=[...o.childNodes].filter(d=>s.includes(d));return u.length===s.length&&u.every((d,N)=>d===s[N])}}for(let r of e)r.kind==="remove"&&(r.node.remove(),r.check=()=>!h(r.node))}function O(e){return e.kind==="move"||e.kind==="remove"?[e.node]:e.kind==="realize"||e.kind==="run"?e.node?[e.node]:[]:[]}function R(e){return e.kind==="text"?[e.scope]:e.kind==="move"||e.kind==="reorder"?[e.parent]:(e.kind==="realize"||e.kind==="run")&&!e.node?[e.parent]:[]}var be=e=>e.kind==="attr"?[e.el]:[...O(e),...R(e)];function Xe(e,n){try{let t=j(e.startContainer,e.startOffset),r=j(n.startContainer,n.startOffset);return e.collapsed&&n.collapsed?t.comparePoint(n.startContainer,n.startOffset)===0:t.comparePoint(n.endContainer,n.endOffset)>0&&r.comparePoint(e.endContainer,e.endOffset)>0}catch{return!1}}function Je(e,n){try{return e.comparePoint(n.startContainer,n.startOffset)===0&&e.comparePoint(n.endContainer,n.endOffset)===0}catch{return!1}}function Ze(e,n){try{return e.intersectsNode(n)&&!m(e.commonAncestorContainer,n)}catch{return!1}}function I(e,n){if(!e.ids.size&&!n.ids.size)return!1;let t=s=>{let i=new Set;for(let c of be(s))D(c,i);return i},r=e.ids.size?null:t(e),o=t(n);return[...e.ids].some(s=>n.ids.has(s)||o.has(s))||[...n.ids].some(s=>(r||t(e)).has(s))}function me(e,n){return n.kind==="text"?Ze(n.range,e.el):O(n).some(t=>m(e.el,t))||n.ids.has(x(e.el))}function pe(e,n){return n.kind==="reorder"?m(n.parent,e.scope)||I(e,n):O(n).some(t=>m(t,e.scope)||m(e.scope,t))||R(n).some(t=>m(t,e.scope))?!0:I(e,n)}function he(e,n){return O(n).some(t=>e.order.includes(t)||m(e.parent,t))||R(n).includes(e.parent)?!0:I(e,n)}function q(e,n){if(e.kind==="done"||n.kind==="done")return!1;if(e.kind==="text"&&n.kind==="text")return Xe(e.range,n.range);if(e.kind==="attr"&&n.kind==="attr")return e.el===n.el&&e.ns===n.ns&&e.local===n.local;if(e.kind==="attr")return me(e,n);if(n.kind==="attr")return me(n,e);if(e.kind==="text")return pe(e,n);if(n.kind==="text")return pe(n,e);if(e.kind==="reorder"&&n.kind==="reorder")return e.parent===n.parent||I(e,n);if(e.kind==="reorder")return he(e,n);if(n.kind==="reorder")return he(n,e);for(let t of O(e))for(let r of O(n))if(m(t,r)||m(r,t))return!0;for(let t of O(e))for(let r of R(n))if(m(r,t))return!0;for(let t of O(n))for(let r of R(e))if(m(r,t))return!0;return I(e,n)}function et(e,n){return e.kind==="done"?!1:e.kind==="attr"?m(e.el,n.node):be(e).some(t=>m(t,n.node)||m(n.node,t))?!0:e.ids.size?(n.ids||(n.ids=D(n.node)),[...e.ids].some(t=>n.ids.has(t))):!1}function tt(e,n){return e.kind==="text"&&n.kind==="text"&&!e.field&&e.root===n.root&&Je(e.range,n.range)}function nt(e,n){let t=oe(e);return t?t.nodes:[rt(e,n)]}function rt(e,n){let t=e.recovery,r=t.subject;for(let c of t.text?[t.text.liveSpan,t.text.liveScope]:[])if(c&&c.startContainer&&h(c.startContainer)&&h(c.endContainer))return st(ot(c));let o=r?b(r,n,r.nodeType):null;if(o)return o;let s=t.structure&&t.structure.localPlacement?b(t.structure.localPlacement.parent,n,1):null;if(s)return s;let i=r&&r.local.length?r.local[0]:[];for(let c=i.length-1;c>0;c--){if(i[c-1]==="content")continue;let l=$(i.slice(0,c),n);if(l)return l}return document.documentElement}function ot(e){let n=new Set;for(let r=e.startContainer;r;r=r.parentNode)n.add(r);let t=e.endContainer;for(;t&&!n.has(t);)t=t.parentNode;return t.nodeType===1||t.nodeType===11?t:t.parentNode}function st(e){for(let n=e;n;n=n.parentNode)if(k(n)&&ke.has(n.tagName))return n;return e}function ct(e,n){let t=e.recovery;return t.applied===!1||t.unavailable?null:t.structure?Ye(e,n):t.text?Ve(e,n):t.attribute?_e(e,n):null}var P=()=>`${re()}|${S.hasPendingApply()?1:0}|${S.list().map(e=>e.id).join(",")}`;function Ee(){let e={ids:new Map,nested:new Set},n=r=>{for(let o of["id","data-id"]){let s=r.getAttribute(o);s&&e.ids.set(`${o} ${s}`,(e.ids.get(`${o} ${s}`)||0)+1)}},t=(r,o)=>{for(let s of y(r).children)n(s),o&&L.has(s.tagName)&&e.nested.add(s),t(s,o||W(s)||we.has(s.tagName))};return n(document.documentElement),t(document.documentElement,!1),e}function it(e){let n=Ee();for(let[r,o]of n.ids)if(o>1&&(e.before.ids.get(r)||0)<=1)return!1;for(let r of n.nested)if(!e.before.nested.has(r))return!1;let t=new Map;for(let r of e.ops)r.kind==="text"&&t.set(r.scope,[...t.get(r.scope)||[],r]);for(let[r,o]of t){let s=o[0].before;for(let c of[...o].sort((l,u)=>u.bs-l.bs))s=s.slice(0,c.bs)+c.local+s.slice(c.be);if((o[0].owner?r.data:o[0].field?r.value:_(r).text)!==s)return!1}return!0}function lt(){let e=new Map,n=c=>{for(let l of c.querySelectorAll("*"))e.set(l,[...l.attributes].map(u=>[u,u.value])),l.localName==="template"&&l.content&&n(l.content)};n(document);let t=[];for(let c of document.querySelectorAll("input, textarea"))t.push([c,"value",c.value]);for(let c of document.querySelectorAll("input"))t.push([c,"checked",c.checked]);for(let c of document.querySelectorAll("option"))t.push([c,"selected",c.selected]);let r=document.activeElement,o=null;try{r&&typeof r.selectionStart=="number"&&(o=[r.selectionStart,r.selectionEnd,r.selectionDirection])}catch{}let s=document.getSelection(),i=s&&s.rangeCount?[s.anchorNode,s.anchorOffset,s.focusNode,s.focusOffset]:null;return{attrs:e,controls:t,active:r,caret:o,selection:i}}function at(e,n){let t=e.attributes;return t.length===n.length&&n.every(([r,o],s)=>t[s]===r&&r.value===o)}function ut(e,n){let t=new Set;for(let s=e.length-1;s>=0;s--){let i=e[s];if(i.type==="characterData")i.target.data=i.oldValue;else if(i.type==="attributes")t.add(i.target);else{for(let c of i.addedNodes)c.parentNode===i.target&&i.target.removeChild(c);for(let c of i.removedNodes)i.target.insertBefore(c,i.nextSibling)}}for(let s of t){let i=n.attrs.get(s);if(!(!i||at(s,i))){for(let c of[...s.attributes])s.removeAttributeNode(c);for(let[c,l]of i)c.value=l,s.setAttributeNode(c)}}for(let[s,i,c]of n.controls)if(s[i]!==c)try{s[i]=c}catch{}let r=document.getSelection();r&&n.selection?h(n.selection[0])&&h(n.selection[2])&&r.setBaseAndExtent(...n.selection):r&&r.rangeCount&&r.removeAllRanges();let o=n.active;if(o&&o!==document.activeElement&&o!==document.body&&h(o)&&o.focus&&o.focus({preventScroll:!0}),n.caret&&document.activeElement===o)try{o.setSelectionRange(...n.caret)}catch{}}function ft(e){let n=t=>{e.observe(t,ve);for(let r of t.querySelectorAll("template"))r.content&&n(r.content)};n(document)}function dt(e){let n=new Set;for(let t of e)if(t.type==="characterData"){if(n.has(t.target))return!1;n.add(t.target)}return!0}function mt(e){let n=P(),t=new Map,r=new Map,o=[],s=new Set;for(let a of e){if(s.has(a))continue;s.add(a);let f=S.get(a);f&&(f.claimedBy||f.kind==="apply-incomplete"||f.kind==="json"||!f.recovery?t.set(a,T):o.push(f))}if(S.hasPendingApply()){for(let a of o)t.set(a.id,T);return{ops:[],covered:r,blocked:t,revision:n,before:null}}let i=[],c=a=>{let f=S.recoveryOf(a.id),p=f?ct(a,f):null;if(!p&&f)for(let E of nt(a,f))i.push({ticket:f.ticket,node:E});return p},l=[];for(let a of o){let f=c(a);f?l.push(f):t.set(a.id,T)}let u=[];for(let a of S.list())if(!s.has(a.id)){if(a.kind==="apply-incomplete")i.push({ticket:a.ticket,node:document.documentElement});else if(a.recovery){let f=c(a);f&&u.push(f)}}l.sort((a,f)=>f.ticket-a.ticket);let d=[],N=[],v=a=>{t.set(a.id,T),N.push(a)};for(let a of l){if(i.some(p=>p.ticket>a.ticket&&et(a,p))||u.some(p=>p.ticket>a.ticket&&q(p,a))||N.some(p=>q(p,a))){v(a);continue}let f=d.find(p=>q(p,a));if(!f){d.push(a);continue}if(tt(f,a)){r.set(a.id,f.id);continue}v(a),f.ticket===a.ticket&&(d.splice(d.indexOf(f),1),v(f))}let A=ne(i.filter(a=>d.some(f=>a.ticket>f.ticket)).map(a=>a.node));return{ops:d,covered:r,blocked:t,revision:P(),protectedWitnesses:A,before:Ee()}}function pt(e){if(e.revision!==P()||!F(e.protectedWitnesses||[])){for(let c of e.ops)e.blocked.set(c.id,T);for(let c of e.covered.keys())e.blocked.set(c,T);return[]}let n=lt(),t=window.clay?.undo;t?.pause?.();let r=new MutationObserver(()=>{}),o=document.createDocumentFragment(),s=[],i=!1;try{ft(r),r.observe(o,ve);let c=e.ops.filter(l=>l.kind==="text").sort((l,u)=>l.root===u.root?u.s-l.s||u.e-l.e:0);for(let l of c)qe(l);for(let l of e.ops)l.kind==="attr"&&ze(l);Qe(e.ops.filter(l=>l.kind!=="text"&&l.kind!=="attr"),o),s=r.takeRecords(),i=e.ops.every(l=>l.check())&&it(e)&&e.revision===P()&&F(e.protectedWitnesses||[])}catch(c){console.error("[clay] Revert to mine failed while writing and was undone",c)}finally{s=s.concat(r.takeRecords()),r.disconnect()}if(i)return dt(s)&&!e.ops.some(c=>c.wroteProperty)?t?.commitCaptured?.("Revert to mine"):t?.discardCaptured?.(),t?.resume?.(),[...e.ops.map(c=>c.id),...e.covered.keys()];try{ut(s,n)}finally{J.dropQueued(),t?.discardCaptured?.(),t?.resume?.()}for(let c of e.ops)e.blocked.set(c.id,T);for(let c of e.covered.keys())e.blocked.set(c,T);return[]}async function wt(e){await Promise.resolve();let n=mt(e),t=pt(n);Q();let r=null;return t.length&&(ee(),S.acknowledge(t,{reason:"reverted"}),X(),await Promise.resolve(),r=await te()),{revertedIds:t,blockedIds:[...n.blocked.keys()],saveResult:r}}export{T as BLOCKED,pt as applyRevert,mt as prepareRevert,wt as revertConflicts};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as m}from"./c-PZ4XEPUP.js";import{a as c}from"./c-SFKI6OLM.js";import{a as p,b as y}from"./c-RHMPKZZ7.js";import{L as f,M as d}from"./c-
|
|
1
|
+
import{b as m}from"./c-PZ4XEPUP.js";import{a as c}from"./c-SFKI6OLM.js";import{a as p,b as y}from"./c-RHMPKZZ7.js";import{L as f,M as d}from"./c-PNZIJFG7.js";function g(e=new Date){let t=r=>String(r).padStart(2,"0");return`${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}-${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}`}function h(e,t){let n=`<script type="application/json" id="clay-lost-edits" clay="no-save">${JSON.stringify(t).replace(/</g,"\\u003c")}<\/script>`,s=e.lastIndexOf("</body>");return s>=0?e.slice(0,s)+n+e.slice(s):e+n}function j(e,{refused:t=!1}={}){let r=window.clay?.conflicts||null,n=[],s=new Set;for(let o of e){let a=r?.recoveryOf(o.id);a&&!s.has(a.id)&&(s.add(a.id),n.push(a))}n.sort((o,a)=>(o.ticket||0)-(a.ticket||0));let u=o=>c(f(o.recoveryRoot??o.root,{prepared:o.domain==="save"})),i,l;t||!n.length?(i=c(d()),l=n):(i=u(n[n.length-1]),l=n.slice(0,-1));let w=e.map(o=>{if(o.kind==="apply-incomplete")return{id:o.id,kind:"apply-incomplete",name:"Sync update that did not finish",error:o.error??null};let{id:a,name:$,kind:S,yours:O,now:b,sentence:k}=m(o);return{id:a,name:$,kind:S,yours:O,now:b,sentence:k}}),v={format:"clay-lost-edits",version:1,savedAt:new Date().toISOString(),page:location.href,refused:!!t,edits:w,earlierPages:l.map(o=>({applyId:o.id,source:o.source,html:u(o)}))};return{html:h(i,v),name:`${p()}-${t?"my-version":"my-copy"}-${g()}.html`}}async function I({html:e=null,edits:t=[]}={}){try{let r=c(typeof e=="string"?e:d()),n={format:"clay-lost-edits",version:1,savedAt:new Date().toISOString(),page:location.href,refused:!1,edits:Array.isArray(t)?t:[],earlierPages:[]};return await y({html:h(r,n),name:`${p()}-my-copy-${g()}.html`})}catch(r){return console.error("clayjs: could not build the download",r),!1}}async function C(e,{refused:t=!1}={}){try{let{html:r,name:n}=j(e,{refused:t});return await y({html:r,name:n})}catch(r){return console.error("clayjs: could not build the download",r),!1}}export{I as a,C as b};
|