@panphora/clayjs 1.25.0 → 1.26.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 +5570 -4173
- package/dist/m/attrs/{save-freeze-MH3AOD56.js → save-freeze-PUYX32AK.js} +1 -1
- package/dist/m/{c-BOMQIQ3V.js → c-2EFMJYGJ.js} +1 -1
- package/dist/m/c-2EPHRF47.js +1 -0
- package/dist/m/{c-JD2VFAYG.js → c-2SUFMUZX.js} +2 -2
- package/dist/m/{c-CITLTVQ4.js → c-2TJCFPX4.js} +1 -1
- package/dist/m/c-33SS5A4Y.js +1 -0
- package/dist/m/{c-V2FPBRO6.js → c-34J5HC7N.js} +1 -1
- package/dist/m/c-3F3AADKG.js +1 -0
- package/dist/m/{c-TCFVG3I4.js → c-3S3647J6.js} +1 -1
- package/dist/m/{c-GY4BREDT.js → c-3S5TNRZA.js} +1 -1
- package/dist/m/{c-GDNZEOOZ.js → c-3WX5FABT.js} +1 -1
- package/dist/m/{c-AI3H6ETU.js → c-3XGLJAS7.js} +2 -2
- package/dist/m/c-42WBOKFM.js +1 -0
- package/dist/m/c-47M4QHCK.js +1 -0
- package/dist/m/{c-UOUUI265.js → c-4M2T676V.js} +1 -1
- package/dist/m/{c-GEAG5XAK.js → c-4TP3UXBT.js} +1 -1
- package/dist/m/{c-IESDKFO6.js → c-5ELELG2F.js} +1 -1
- package/dist/m/{c-X3V4RWMA.js → c-5ZYLTN3Q.js} +1 -1
- package/dist/m/{c-5PZYDWTW.js → c-67TBU56I.js} +1 -1
- package/dist/m/{c-WNOLMHI2.js → c-6BGJAJ67.js} +1 -1
- package/dist/m/{c-4Q6QIODW.js → c-755ZOHOM.js} +1 -1
- package/dist/m/c-7Q4XYDF4.js +1 -0
- package/dist/m/c-7RHOMAMR.js +1 -0
- package/dist/m/c-A5LASUEZ.js +1 -0
- package/dist/m/{c-IL5IVTOG.js → c-ABOBD7F3.js} +1 -1
- package/dist/m/c-AQVQKFKB.js +1 -0
- package/dist/m/{c-QDVG4NAZ.js → c-ARO6CPMA.js} +1 -1
- package/dist/m/{c-ORLPQFNU.js → c-AZM34SPO.js} +1 -1
- package/dist/m/{c-XUZMRQ7O.js → c-BCS3AZQZ.js} +1 -1
- package/dist/m/c-BOS7GONO.js +1 -0
- package/dist/m/{c-SUAC5RSG.js → c-C5UGNOC2.js} +1 -1
- package/dist/m/c-C6DXZIXD.js +1 -0
- package/dist/m/{c-WSTUCBHV.js → c-CPRGR2II.js} +1 -1
- package/dist/m/{c-NICICT4P.js → c-DEYHCYJB.js} +1 -1
- package/dist/m/{c-WGQVSKKC.js → c-DYTBSJBI.js} +1 -1
- package/dist/m/{c-DT7E76Z2.js → c-DZT6W2NG.js} +1 -1
- package/dist/m/{c-O2QZDVZ2.js → c-EEWPNUM2.js} +1 -1
- package/dist/m/{c-MFB74XVN.js → c-EHAR4RJJ.js} +2 -2
- package/dist/m/c-EHJWIGWN.js +1 -0
- package/dist/m/c-EIDZHQHZ.js +1 -0
- package/dist/m/{c-V2V5FKXX.js → c-EIUKME3W.js} +1 -1
- package/dist/m/c-ELXMSEN5.js +1 -0
- package/dist/m/c-EXZOA6XY.js +7 -0
- package/dist/m/{c-FKTALXNV.js → c-EYFMAR3M.js} +1 -1
- package/dist/m/c-FC5RUFPR.js +1 -0
- package/dist/m/{c-FBOO2UY3.js → c-FUN6AKFE.js} +1 -1
- package/dist/m/{c-V4B3RUWB.js → c-GFASNR55.js} +1 -1
- package/dist/m/{c-XMIDHEKF.js → c-GY36NO7C.js} +1 -1
- package/dist/m/{c-UD4VDBGJ.js → c-H3M6UDNV.js} +1 -1
- package/dist/m/{c-SFZRY6RT.js → c-H47C6PJZ.js} +1 -1
- package/dist/m/{c-MUM53J5J.js → c-H4M2T4A6.js} +1 -1
- package/dist/m/{c-U7F66I64.js → c-HYNM5U6B.js} +1 -1
- package/dist/m/c-J2YYLEVM.js +1 -0
- package/dist/m/c-J2ZW4HMR.js +1 -0
- package/dist/m/{c-WCG6AKA7.js → c-JC4RZW4E.js} +1 -1
- package/dist/m/c-K2ZHQMPF.js +1 -0
- package/dist/m/c-KD2ME5UN.js +2 -0
- package/dist/m/{c-Z2OZFX3N.js → c-L6KVXPBO.js} +1 -1
- package/dist/m/{c-GO635CRU.js → c-LAKBBJOU.js} +2 -2
- package/dist/m/{c-4AE2A2LK.js → c-LETPPG2F.js} +1 -1
- package/dist/m/{c-SFYTKRU7.js → c-MKAUC6DB.js} +1 -1
- package/dist/m/{c-WDFQ7PBU.js → c-MMEVDN6D.js} +1 -1
- package/dist/m/{c-LS7IVQVW.js → c-MMV5JULA.js} +1 -1
- package/dist/m/{c-NEQRFC4O.js → c-MVVEIJUU.js} +1 -1
- package/dist/m/{c-SXZYVXD6.js → c-N362HNGO.js} +1 -1
- package/dist/m/{c-7K4SCQB7.js → c-ND3W7D5U.js} +1 -1
- package/dist/m/{c-3E2IK5HU.js → c-NNHNXD6M.js} +1 -1
- package/dist/m/{c-D62HRSZK.js → c-NYJ577NL.js} +1 -1
- package/dist/m/{c-YFO6ZJLQ.js → c-O3DPFZCE.js} +1 -1
- package/dist/m/c-OZOACVUD.js +1 -0
- package/dist/m/{c-MV7TEUTD.js → c-OZVK3TFI.js} +1 -1
- package/dist/m/{c-ZEA3DCG3.js → c-PWILUN4T.js} +1 -1
- package/dist/m/{c-BCWYEG6P.js → c-QA3Q3MDI.js} +1 -1
- package/dist/m/{c-XHZIKRCV.js → c-QKOKMQXA.js} +1 -1
- package/dist/m/{c-TGIMBAWE.js → c-RBWVF4N5.js} +1 -1
- package/dist/m/c-RES2S5Q3.js +1 -0
- package/dist/m/c-RFGELYEU.js +2 -0
- package/dist/m/c-RGFPLQGV.js +1 -0
- package/dist/m/{c-RGAALCDU.js → c-SPOEDIMP.js} +1 -1
- package/dist/m/{c-YX2MC7YL.js → c-SRW5OBCF.js} +1 -1
- package/dist/m/{c-C6YZNU6E.js → c-SYOA4T7V.js} +1 -1
- package/dist/m/c-SYVF6ZMF.js +1 -0
- package/dist/m/{c-NADLYVAH.js → c-TJ5PFOJ2.js} +1 -1
- package/dist/m/{c-KYTVZT4D.js → c-TKV273YU.js} +1 -1
- package/dist/m/c-U35T5NAY.js +1 -0
- package/dist/m/{c-PRZNJUYZ.js → c-UEKJWXCB.js} +2 -2
- package/dist/m/c-UW6MMZ4V.js +1 -0
- package/dist/m/{c-XQTERKQA.js → c-V4DBV5ZV.js} +1 -1
- package/dist/m/c-VGG3UR7I.js +1 -0
- package/dist/m/c-VU4WEWPH.js +4 -0
- package/dist/m/{c-5Q5XBN56.js → c-W7LWCJHD.js} +1 -1
- package/dist/m/c-WHMZCRQD.js +6 -0
- package/dist/m/{c-WMRJKQ2V.js → c-WHQUZM2V.js} +1 -1
- package/dist/m/c-WOJ2RTV4.js +1 -0
- package/dist/m/{c-ZJG6C2WL.js → c-WOWGGNCJ.js} +1 -1
- package/dist/m/{c-ZORVIXUR.js → c-XHD7XJTE.js} +1 -1
- package/dist/m/c-XONFK3WC.js +1 -0
- package/dist/m/{c-HGG7M2S3.js → c-Y3J5LDKB.js} +1 -1
- package/dist/m/{c-JB5YU57S.js → c-Y3MPVURA.js} +1 -1
- package/dist/m/c-Y6HH7LTM.js +1 -0
- package/dist/m/{c-52OC3OH3.js → c-YRDKVEGR.js} +1 -1
- package/dist/m/c-YYIN4NAF.js +30 -0
- package/dist/m/{c-WVCT3ITX.js → c-YZGWSCMT.js} +1 -1
- package/dist/m/c-ZFAPQQIB.js +1 -0
- package/dist/m/core/{admin-attrs-ZI6K6UGM.js → admin-attrs-43JBA6JB.js} +1 -1
- package/dist/m/core/{autosave-BSM2ABJL.js → autosave-HD7Y7UNV.js} +1 -1
- package/dist/m/core/{conflict-notice-7EQLDYPA.js → conflict-notice-UNDOD4BL.js} +1 -1
- package/dist/m/core/{persist-2SZO3PCE.js → persist-MX3VYVBN.js} +1 -1
- package/dist/m/core/{save-K6Q47J2X.js → save-JZ7R4ET2.js} +1 -1
- package/dist/m/core/{save-core-U3Z44XBO.js → save-core-I4N6S4ED.js} +1 -1
- package/dist/m/core/site-edits-C22O53GS.js +1 -0
- package/dist/m/core/{snapshot-PWCHYFL6.js → snapshot-N5MKDGNI.js} +1 -1
- package/dist/m/core/{unsaved-warning-2WRZLJH5.js → unsaved-warning-BP6ZY3PG.js} +1 -1
- package/dist/m/internals/{index-FSLC4M7J.js → index-3LAVREAU.js} +1 -1
- package/dist/m/loader-DCKCZKY6.js +1 -0
- package/dist/m/manifest-7954CBE3.js +1 -0
- package/dist/m/manifest-edit-93AA79D7.js +1 -0
- package/dist/m/manifest.json +1240 -1179
- package/dist/m/page/{editor-PKSPJ2XJ.js → editor-UF3CIA6V.js} +5 -5
- package/dist/m/plugins/{ai-edit-3LG6MGS3.js → ai-edit-WDV2GLDU.js} +2 -2
- package/dist/m/plugins/{cms-T2HLI7JG.js → cms-KG6TCTR3.js} +9 -9
- package/dist/m/plugins/{derive-7DR5TUDH.js → derive-R4USHZ7P.js} +1 -1
- package/dist/m/plugins/{indicator-CTKX4EY7.js → indicator-OLPZ4WFI.js} +1 -1
- package/dist/m/plugins/{live-IFLL6YN5.js → live-DF5YS5AH.js} +1 -1
- package/dist/m/plugins/{menu-YJZ3JWBC.js → menu-ESEFQARM.js} +1 -1
- package/dist/m/plugins/page-GZSU77JS.js +2 -0
- package/dist/m/plugins/{page-view-NMCCU6MF.js → page-view-7MM3FEAR.js} +1 -1
- package/dist/m/plugins/{people-6WIWCZEG.js → people-EBWE337I.js} +1 -1
- package/dist/m/plugins/quickcrop-UHURKA2F.js +26 -0
- package/dist/m/plugins/richclay-MXH2GFAZ.js +549 -0
- package/dist/m/plugins/sortable-BAG3MSWS.js +1 -0
- package/dist/m/plugins/{source-7LSGOV46.js → source-OYHDXKTB.js} +1 -1
- package/dist/m/plugins/undo-KLHAGV75.js +1 -0
- package/dist/m/plugins/{upgrade-MMPZUCDM.js → upgrade-SZQJYEQQ.js} +1 -1
- package/dist/m/plugins/{visitor-drafts-V5YB7XDH.js → visitor-drafts-ZE6PCAFP.js} +2 -2
- package/dist/m/plugins/{visitor-menu-QDV2MYJN.js → visitor-menu-5XY57JQA.js} +1 -1
- package/dist/m/plugins/{wire-3YGUO3GE.js → wire-S5ATC4QI.js} +1 -1
- package/dist/m/reader-core-AHOAP5DH.js +77 -0
- package/dist/m/sync/{live-sync-XMXXZS3G.js → live-sync-RZQSDMZW.js} +1 -1
- package/dist/m/ui/index-G7ZJXNMG.js +1 -0
- package/dist/m/vendor/{sap-core.vendor-JANUQULT.js → sap-core.vendor-5TWOJYVM.js} +4 -4
- package/dist/offline-manifest.json +780 -750
- package/dist/server/core.cjs +4245 -2614
- package/dist/server/markdown.cjs +1 -0
- package/dist/server/markdown.mjs +7 -0
- package/docs/guide.md +26 -37
- package/entries/clay-data.js +1 -1
- package/entries/sap.js +5 -5
- package/package.json +6 -2
- package/packed-contract.json +3 -0
- package/src/attrs/save-freeze.js +1 -1
- package/src/core/admin-contenteditable.js +1 -1
- package/src/core/admin-inputs.js +1 -1
- package/src/core/admin-onclick.js +1 -1
- package/src/core/admin-resources.js +5 -2
- package/src/core/conflict-notice-ui.js +59 -34
- package/src/core/save.js +9 -9
- package/src/core/site-edits.js +1 -1
- package/src/core/snapshot.js +56 -43
- package/src/core/stale-host-notice.js +20 -7
- package/src/loader-logic.js +0 -13
- package/src/page/boot-pack.js +1 -0
- package/src/page/editor.js +10 -4
- package/src/page/history-intent.js +111 -4
- package/src/page/import-markdown.js +22 -8
- package/src/page/save-projection.js +1 -1
- package/src/page/ybind/bridge.js +14 -7
- package/src/page/ybind/moves.js +437 -3
- package/src/page/ybind/origins.js +1 -1
- package/src/page/ybind/recovery.js +1 -1
- package/src/plugins/page.js +48 -4
- package/src/plugins/quickcrop.js +128 -69
- package/src/plugins/richclay.js +136 -0
- package/src/plugins/sortable.js +25 -9
- package/src/plugins/undo.js +169 -7
- package/src/recovery/undo.js +14 -7
- package/src/server/markdown/index.js +23 -0
- package/src/sync/conflicts.js +3 -1
- package/src/sync/data-guard-notice.js +137 -18
- package/src/sync/live-sync.js +24 -0
- package/src/ui/bevel-controls.js +4 -1
- package/src/ui/dialogs.js +11 -7
- package/src/ui/modal.js +9 -7
- package/src/ui/toast.js +67 -32
- package/src/ui/vendor-skin.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/hyper-undo.vendor.js +1 -1
- package/src/vendor/hypercms.vendor.js +7 -7
- package/src/vendor/richclay.vendor.js +16 -16
- package/src/vendor/sap-core.vendor.js +4 -4
- package/tool-generation/context.md +69 -0
- package/tool-generation/system.md +1 -1
- package/dist/m/c-277QP5ET.js +0 -1
- package/dist/m/c-5SZ6KFR5.js +0 -1
- package/dist/m/c-CU33V6RW.js +0 -4
- package/dist/m/c-CVSWLX3X.js +0 -1
- package/dist/m/c-DXPOFLEJ.js +0 -1
- package/dist/m/c-EODTTNVA.js +0 -1
- package/dist/m/c-ESK4S67I.js +0 -1
- package/dist/m/c-FDWR3FL7.js +0 -1
- package/dist/m/c-FJDTDGDA.js +0 -1
- package/dist/m/c-FYDKYW6E.js +0 -1
- package/dist/m/c-HKSLOVU4.js +0 -1
- package/dist/m/c-IJHF4IO6.js +0 -1
- package/dist/m/c-IUL7PU4P.js +0 -1
- package/dist/m/c-JWW6BHWD.js +0 -6
- package/dist/m/c-K4M76VPM.js +0 -7
- package/dist/m/c-M7ITYKMF.js +0 -1
- package/dist/m/c-MR75YPRT.js +0 -1
- package/dist/m/c-NFQFV7OP.js +0 -2
- package/dist/m/c-NHXOBD6A.js +0 -1
- package/dist/m/c-NVU3DORS.js +0 -1
- package/dist/m/c-PNZIJFG7.js +0 -1
- package/dist/m/c-QWB53KRW.js +0 -1
- package/dist/m/c-RHPHMTF2.js +0 -2
- package/dist/m/c-RWJ3OSCP.js +0 -1
- package/dist/m/c-SEVOS4UE.js +0 -1
- package/dist/m/c-SGG6MUXW.js +0 -1
- package/dist/m/c-SXNSSHPP.js +0 -1
- package/dist/m/c-TFLRT5JX.js +0 -1
- package/dist/m/c-TLQINES7.js +0 -30
- package/dist/m/c-U65PREMC.js +0 -1
- package/dist/m/c-V5L6HWVL.js +0 -1
- package/dist/m/c-VMXCX52Q.js +0 -1
- package/dist/m/c-YYGUHSZR.js +0 -1
- package/dist/m/core/site-edits-CFMF6GHD.js +0 -1
- package/dist/m/loader-RC54UV7H.js +0 -1
- package/dist/m/manifest-3B84C829.js +0 -1
- package/dist/m/manifest-edit-1CB79AD4.js +0 -1
- package/dist/m/plugins/page-GTDPYGE4.js +0 -2
- package/dist/m/plugins/quickcrop-X5MRIBAP.js +0 -26
- package/dist/m/plugins/richclay-L3BZMX4I.js +0 -549
- package/dist/m/plugins/sortable-365SRRL3.js +0 -1
- package/dist/m/plugins/undo-UES4KS7B.js +0 -1
- package/dist/m/reader-core-VR7EL4WV.js +0 -77
- package/dist/m/ui/index-MGTWOW2C.js +0 -1
- /package/dist/m/{c-QTTJYJMA.js → c-FILLTJA7.js} +0 -0
- /package/dist/m/plugins/{quickcrop-X5MRIBAP.js.LEGAL.txt → quickcrop-UHURKA2F.js.LEGAL.txt} +0 -0
- /package/dist/m/plugins/{richclay-L3BZMX4I.js.LEGAL.txt → richclay-MXH2GFAZ.js.LEGAL.txt} +0 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{b as U}from"./c-LD6UVV5R.js";import{a as se,g as ae,h as C}from"./c-PGSBXHUE.js";import{a as oe,b as ie,c as j}from"./c-KU3PX7LL.js";import{d as A}from"./c-EQ5NBOGA.js";import{c as Z,e as Q,g as ee}from"./c-IJUK2GPW.js";import{b as k,f as D}from"./c-C7SUMNMI.js";import{c as V}from"./c-BPF2NSPV.js";import{i as q}from"./c-U4TWEIKZ.js";import{a as M,g as te,h as ne,i as re}from"./c-
|
|
1
|
+
import{b as U}from"./c-LD6UVV5R.js";import{a as se,g as ae,h as C}from"./c-PGSBXHUE.js";import{a as oe,b as ie,c as j}from"./c-KU3PX7LL.js";import{d as A}from"./c-EQ5NBOGA.js";import{c as Z,e as Q,g as ee}from"./c-IJUK2GPW.js";import{b as k,f as D}from"./c-C7SUMNMI.js";import{c as V}from"./c-BPF2NSPV.js";import{i as q}from"./c-U4TWEIKZ.js";import{a as M,g as te,h as ne,i as re}from"./c-UW6MMZ4V.js";var F=null,ue=null,T=null;function Te(e){let t=e?.document?.maxBytes;return Number.isSafeInteger(t)&&t>0?t:null}function le(e){return F=Te(e),ue=e?.document?.maxBytesMeasures==="file"?"file":null,F}var be=/<script\b[^>]*\bmerge=(["'])blockeditor\1[^>]*>[\s\S]*?<\/script\s*>/i;function B(e,t=ue){if(t!=="file"||typeof e!="string")return e;let n=be.exec(e);if(!n)return e;let o=n.index,s=o+n[0].length,r=e.lastIndexOf(`
|
|
2
2
|
`,o-1)+1,a=e.indexOf(`
|
|
3
|
-
`,s),c=a===-1?e.length:a+1;return!/\S/.test(e.slice(r,o))&&!/\S/.test(e.slice(s,c))&&(o=r,s=c),e.slice(0,o)+e.slice(s)}function H(e,t){let n=new TextEncoder().encode(e).byteLength,o=Number.isSafeInteger(t)&&t>0;return{bytes:n,maxBytes:o?t:null,state:o?n>t?"over":n>=Math.ceil(t*.8)?"near":"ok":"unknown"}}function ce(){return F}function L({fresh:e=!1}={}){return e?(T=A({fresh:!0}).then(le),T):(T||(T=A().then(le)),T)}function St({fresh:e=!1}={}){return L({fresh:e}).then(t=>({maxBytes:t}))}async function xt(e){let t=await L();return H(B(e),t)}function fe(e){let t=new CustomEvent("clay:save-size",{detail:e});document.dispatchEvent(t),(e.state==="near"||e.state==="over")&&import("./c-M7ITYKMF.js").then(n=>n.start(t),()=>{})}var P="/_/clayjs/",Oe=/[\u0000-\u001F\u007F]/,Ee=/^[\t\n\f\r ]|[\t\n\f\r ]$/,$e=/^https:\/\/clayjs\.com\/v(\d+)\/([\s\S]*)$/,Re=/^https:\/\/clayjs\.com\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,de=/^\/_\/clayjs\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,ke=/%2e|%2f|%5c/i;function Me(e){if(typeof e!="string")return null;let t=/^(\d+)\.\d+\.\d+$/.exec(e);return t?t[1]:null}function je(e){if(typeof e!="string"||e==="")return null;try{return new URL(e).origin}catch{return null}}function Le(e){let t=e.indexOf("#"),n=t<0?"":e.slice(t),o=t<0?e:e.slice(0,t),s=o.indexOf("?"),r=s<0?"":o.slice(s);return{head:s<0?o:o.slice(0,s),search:r,hash:n}}function Pe(e){if(e===""||e.includes("\\")||ke.test(e))return null;let t=e.split("/"),n=[];for(let o of t){if(o===""||o==="."||o==="..")return null;let s;try{s=decodeURIComponent(o)}catch{return null}if(s.includes("/")||s.includes("\\")||s==="."||s==="..")return null;n.push(s)}return n.join("/")}function b(e,{documentURL:t}={}){if(typeof e!="string"||e===""||Ee.test(e)||Oe.test(e))return null;let{head:n,search:o,hash:s}=Le(e),r=null,a=null,c=null,l=null,i=$e.exec(n);if(i&&(r="rolling",c=i[1],l=i[2]),r||(i=Re.exec(n),i&&(r="exact",a=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],l=i[4])),r||(i=de.exec(n),i&&(r="local",a=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],l=i[4])),!r){let f=je(t);f&&n.startsWith(`${f}/`)&&(i=de.exec(n.slice(f.length)),i&&(r="local",a=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],l=i[4]))}if(!r)return null;let u=Pe(l);return u===null?null:{kind:r,major:c,version:a,rawPath:l,path:u,search:o,hash:s}}function Ie(e,t){let n=e&&typeof e=="object"?e[t]:null;return n&&typeof n.files=="object"&&n.files?n.files:null}function _e(e){return!e||typeof e!="object"?[]:Array.isArray(e.entries)?e.entries.filter(t=>t&&typeof t=="object"):[]}function Ne(e,t,n){if(!n)return!0;let o=Ie(n,t);return!!(o&&Object.hasOwn(o,e.path))}function he(e,{descriptor:t,releases:n,documentURL:o,aliases:s}={}){let r=b(e,{documentURL:o});if(!r||r.kind!=="local")return e;let a=_e(t),c=Me(r.version);for(let l of a){if(l.local!==e||typeof l.original!="string")continue;let i=n?.[r.version]?.aliases??s;if(i&&typeof i=="object"&&!r.search&&!r.hash&&Object.hasOwn(i,l.original)&&i[l.original]===r.path)return l.original;let u=b(l.original);if(u&&!(u.kind!=="rolling"&&u.kind!=="exact")&&u.rawPath===r.rawPath&&u.search===r.search&&u.hash===r.hash&&!(u.kind==="rolling"?u.major!==c:u.version!==r.version)&&Ne(r,r.version,n))return u.kind==="exact"?l.original:`https://clayjs.com/v${u.major}/${r.rawPath}${r.search}${r.hash}`}for(let l of a){if(typeof l.original!="string")continue;let i=b(l.original);if(i&&!(i.kind!=="rolling"&&i.kind!=="exact")&&i.rawPath===r.rawPath&&!(i.kind==="rolling"?i.major!==c:i.version!==r.version))return i.kind==="rolling"?`https://clayjs.com/v${i.major}/${r.rawPath}${r.search}${r.hash}`:`https://clayjs.com/${i.version}/${r.rawPath}${r.search}${r.hash}`}return`https://clayjs.com/${r.version}/${r.rawPath}${r.search}${r.hash}`}var De=Object.freeze({"https://cdn.jsdelivr.net/npm/overtype@2.6.1/dist/overtype.min.js":"compat/overtype-2.6.1.min.js","https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js":"compat/highlight-11.9.0.min.js","https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;0,600;1,400;1,500&family=IBM+Plex+Sans:wght@400;500;600&display=swap":"fonts/ibm-plex.css"}),z="clay-runtime-map",Ue=new Set(["stylesheet","preload","modulepreload"]),pe=null,J=null;function Ce(e){let t;try{t=JSON.parse(e)}catch{return null}return!t||typeof t!="object"||t.schema!==1?null:t}function Fe(){if(typeof document>"u")return null;let e=document.getElementById(z);if(!e)return null;let t=e.textContent??"";return t===pe||(pe=t,J=Ce(t)),J}var Be=`script[src*="${P}"], link[href*="${P}"], #${z}`;function me(e){if(e.querySelector(Be))return!0;for(let t of e.querySelectorAll("template"))if(me(t.content))return!0;return!1}function He(e){let t=[],n=[e];for(;n.length;){let o=n.pop();for(let s of o.children??[])t.push(s),n.push(s),s.content&&n.push(s.content)}return t}function Je(e){return e.tagName==="SCRIPT"&&e.hasAttribute("src")?"src":e.tagName!=="LINK"||!e.hasAttribute("href")?null:(e.getAttribute("rel")??"").toLowerCase().split(/\s+/).some(n=>Ue.has(n))?"href":null}function ze(e){if(!e||!me(e))return;let t=[],n=!1;for(let r of He(e)){if(r.getAttribute("id")===z){r.remove();continue}let a=Je(r);a&&(t.push({element:r,name:a}),!n&&(r.getAttribute(a)??"").includes(P)&&(n=!0))}if(!n)return;let o=location.href,s=Fe();for(let{element:r,name:a}of t){let c=r.getAttribute(a),l=b(c,{documentURL:o});!l||l.kind!=="local"||r.setAttribute(a,he(c,{descriptor:s,documentURL:o,aliases:De}))}}re(ze);var x=!1,$=null,ge="/_/save",Ke=12e3,ve=6e4,We=1024*1024,we="text/plain;charset=UTF-8",I=null,R=!1,K=new Map;function Ht(e,t){t==null?K.delete(e):K.set(e,String(t))}var W=new Set;function Jt(e){return W.add(e),()=>W.delete(e)}async function zt(e,t){R=!!e;try{return await t()}finally{R=!1}}function Gt(){return x}function Kt(){return x?null:(x=!0,$={reserved:!0},$)}function Wt(e){!e||$!==e||($=null,x=!1)}function Xt(){return R}var _=[],N=[];function Yt(e){return _.push(e),()=>{let t=_.indexOf(e);t>=0&&_.splice(t,1)}}function Vt(e){return N.push(e),()=>{let t=N.indexOf(e);t>=0&&N.splice(t,1)}}function Xe(e){for(let t of _)try{t(e)}catch(n){console.error("clayjs: onSaveAttempt hook failed:",n)}}function Ye(e){for(let t of N)try{t(e)}catch(n){console.error("clayjs: onSaveOutcome hook failed:",n)}}function ye(e){return{ok:!0,msg:e.msg??"Saved",msgType:e.msgType||"success",code:e.code??null,etag:e.etag??null,...e.siteData?{siteData:e.siteData}:{}}}var O=[],Ve=8,y=null;function qt(){return y!==null}function Se(){let e=window.crypto?.randomUUID?.();if(e)return e;if(window.crypto?.getRandomValues){let n=new Uint8Array(16);return window.crypto.getRandomValues(n),Array.from(n,o=>o.toString(16).padStart(2,"0")).join("")}let t=()=>Math.random().toString(36).slice(2,12).padEnd(10,"0");return`${Date.now().toString(36)}-${t()}${t()}${t()}`}function qe(e){O.push(e),O.length>Ve&&O.shift()}function Ze(e){return typeof e=="string"&&e!==""&&O.includes(e)}function Zt(){O.length=0,y=null}function X(e){let t=e.name==="AbortError",n=!t&&e.status===412,o=!t&&!n&&e.code==="save-already-applied";return{ok:!1,msg:t?"Server not responding":e.message||"Save failed",msgType:t||o?"unknown":n?"conflict":"error",code:t?"timeout":n?"conflict":e.code??null,changedBy:n?e.changedBy??null:null,afterTimeout:n&&y!==null,conflictEtag:n?e.etag??null:null,status:Number.isInteger(e.status)?e.status:null,hadTimeout:t||e.hadTimeout===!0,reason:e.reason??null,retryAfter:e.retryAfter??null,saveOutcome:e.saveOutcome??null,etag:null}}function E(e){return{ok:!1,msg:e,msgType:"skipped",code:null,etag:null}}function Qe(e){let t=new Error(`This document is ${e.bytes} bytes; this host saves at most ${e.maxBytes}`);return t.code="save-too-large",{...X(t),sent:!1,size:e}}var w=null;function et(e){return w?null:(w={kind:e},w)}function tt(e){w===e&&(w=null)}function nt(){return w?w.kind:null}function rt(){return{ok:!1,msg:"Invalid page conversion metadata",msgType:"error",code:"invalid-header",etag:null}}var ot=3,it=/^(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT|(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), \d{2}-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{2} \d{2}:\d{2}:\d{2} GMT|(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?: \d|\d{2}) \d{2}:\d{2}:\d{2} \d{4})$/;function st(e){if(e==null)return null;let t=String(e).trim();if(!t)return null;if(/^-?\d+$/.test(t))return Math.max(0,Math.min(3600,Number(t)));if(!it.test(t))return null;let n=Date.parse(t);return Number.isNaN(n)?null:Math.max(0,Math.min(3600,Math.round((n-Date.now())/1e3)))}var at=/^[0-9a-f]{64}$/,lt=/^[A-Za-z0-9-]{1,64}$/;function ut(e){if(e==null)return{header:null};if(typeof e!="object")return{invalid:!0};let{source:t,base:n,epoch:o}=e;return typeof n!="string"||!at.test(n)?{invalid:!0}:t==="file"?o!=null?{invalid:!0}:{header:`v1; source=file; base=${n}`}:t==="room"?typeof o!="string"||!lt.test(o)?{invalid:!0}:{header:`v1; source=room; base=${n}; epoch=${o}`}:{invalid:!0}}function ct(e,t,n,o,s,r=!1,a=null,c=!0){let l=V(),i=l?`${ge}/${l}`:ge,u={method:"POST",credentials:l?"omit":"same-origin",signal:n,headers:{"Document-URL":window.location.href,"Page-URL":window.location.href,"Save-Trigger":t?"user":"auto","Save-ID":o,[se]:String(1)},body:ft(e)};for(let[f,h]of K)u.headers[f]=h;if(c)for(let f of W){let h=null;try{h=f(e)}catch(p){console.error("clayjs: a save header source failed:",p)}if(h)for(let[p,S]of Object.entries(h))u.headers[p]=String(S)}return typeof u.body!="string"&&(u.headers["Content-Type"]=we),a&&(u.headers["Blockeditor-Conversion"]=a),s&&(u.headers["If-Match"]=s),r&&e.length<ve&&new Blob([e]).size<ve&&(u.keepalive=!0),{url:dt(i),options:u}}function ft(e){if(e.length<We)return e;if(I&&I.content===e)return I.blob;let t=new Blob([e],{type:we});return I={content:e,blob:t},t}function xe(){let e=oe();return ie()&&e?e:null}function dt(e){let t=window.location.origin;return!t||t==="null"?e:new URL(e,t).href}function G(e,t){let n=JSON.stringify(t);return{ok:e>=200&&e<300,status:e,statusText:e===200?"OK":"Insufficient Storage",text:()=>Promise.resolve(n)}}function ht(e,t){let n=q();return n?Promise.resolve().then(()=>n(e,t)).then(()=>G(200,{msg:"Saved in this browser",msgType:"success"}),o=>G(507,{msg:"Couldn't save in this browser. Storage is full or turned off.",msgType:"error",code:o?.code||"draft-storage"})):Promise.resolve(G(503,{msg:"Saving in this browser is not ready yet",msgType:"error",code:"draft-not-ready"}))}function pt(e,t,n,{captureId:o=null,conversionHeader:s=null,attempts:r=[],gateToken:a=null}={}){let c=new AbortController,l=setTimeout(()=>c.abort(),Ke),i=Q(),u=ee(),f=i||u,h=R;R=!1;let{url:p,options:S}=ct(e,f,c.signal,t,n,h,s);return qe(t),k||(r.some(d=>d.saveId===t&&d.etag===(n??null))||r.push({saveId:t,etag:n??null}),Xe({captureId:o,saveId:t,html:e,etag:n??null})),(k?ht(e,a):fetch(p,S)).then(d=>d.text().then(g=>{let m={};if(g)try{m=JSON.parse(g)}catch{if(d.ok)throw new Error("Server sent a response that was not JSON")}if(!d.ok){let v=new Error(m.msg||m.error||`HTTP ${d.status}: ${d.statusText}`);throw v.code=d.status===413?"save-too-large":m.code??null,v.status=d.status,v.changedBy=m.changedBy??null,v.etag=m.etag??null,v.saveId=m.saveId??null,v.reason=typeof m.reason=="string"?m.reason:null,v.saveOutcome=m.saveOutcome??null,v.retryAfter=st(d.headers?.get?.("Retry-After")),v}return j(m.etag??null),y=null,m})).catch(d=>{throw console.error("Failed to save page:",d),d.name==="AbortError"&&(y={saveId:t,etag:n}),f&&Z(),d}).finally(()=>{clearTimeout(l)})}async function mt(){let e=y;if(!e)return{landed:null,resend:!1};let n=(await A({fresh:!0})).document,o=typeof n?.etag=="string"&&n.etag?n.etag:null;return o?n.saveId&&n.saveId===e.saveId?(j(o),y=null,{landed:{msg:"Saved",msgType:"success",etag:o},resend:!1}):(n.saveId&&(y=null),{landed:null,resend:!!e.etag,etag:e.etag}):{landed:null,resend:!1}}async function gt(e,{captureId:t=null,conversionHeader:n=null,attempts:o=[],gateToken:s=null}={}){let r=Se(),a=xe(),c=!1,l=!1,i=0,u=t??M();for(;;)try{return await pt(e,r,a,{captureId:t,conversionHeader:n,attempts:o,gateToken:s})}catch(f){if(c&&(f.hadTimeout=!0),f.name==="AbortError"){if(c)throw f;let{landed:h,resend:p,etag:S}=await mt();if(h)return h;if(!p)throw f;a=S,c=!0;continue}if(f.status===412&&!l&&Ze(f.saveId)){j(f.etag??null),y=null,r=Se(),a=xe(),l=!0;continue}if(f.code==="blockeditor-converting"&&i<ot){if(M()!==u||(i+=1,await new Promise(h=>setTimeout(h,Math.max(0,f.retryAfter??1)*1e3)),M()!==u))throw f;continue}throw f}}function Y(e,t,n,o,s=null,r=0,a=null,c=null){return e=ae(e,Math.max(C(),r)),new Promise(l=>{let i=[],u=te(s),f=()=>a!==null&&$===a,h=()=>{f()||(x=!1)},p=(g,m=!1)=>{m&&U(e,t??null,u),ne(s),Ye({captureId:t??null,result:g,attempts:i,sent:i.length>0}),typeof n=="function"&&n(g),l(g)};if(!D&&!window.clay?.testMode)return p(E("Not in edit mode"));if(x&&!f())return p(E("Save already in progress"));let S=ut(o);if(S.invalid)return p(rt());if(x=!0,window.clay?.testMode){setTimeout(()=>{h(),p(ye({msg:"Test mode: save skipped"}))},0);return}L();let d=H(B(e),ce());if(fe(d),d.state==="over")return h(),p(Qe(d));gt(e,{captureId:t,conversionHeader:S.header,attempts:i,gateToken:c}).then(ye,X).then(g=>{h(),g.code==="save-too-large"&&!g.size&&(g.size=d),g.ok&&U(e,t??null,u,g.siteData??null),p(g)})})}function vt(e,t=()=>{}){return Y(e,null,t,null)}function Qt(e,t,n=()=>{},{conversion:o,capture:s=null,blockeditorFormatFloor:r,lane:a=null,gateToken:c=null}={}){return Y(e,t,n,o,s,r,a,c)}function en({html:e,captureId:t,conversion:n}){return Y(e,t??null,void 0,n)}function tn(e,t=()=>{}){return new Promise(n=>{let o=null,s=r=>{tt(o),typeof t=="function"&&t(r),n(r)};if(!D)return s(E("Not in edit mode"));if(nt())return s(E("Another document operation is in progress"));if(x)return s(E("Save already in progress"));if(k)return s(!1);o=et("replace"),fetch(new URL(e,window.location.href).href).then(r=>{if(!r.ok)throw new Error(`Template fetch failed: HTTP ${r.status} ${r.statusText}`);return r.text()}).then(r=>vt(r)).then(s).catch(r=>{console.error("Failed to fetch template:",r),s(X(r))})})}var Ae=null;function nn(e){Ae=e}function rn(){return Ae}export{L as a,St as b,xt as c,Ht as d,Jt as e,zt as f,Gt as g,Kt as h,Wt as i,Xt as j,Yt as k,Vt as l,qt as m,Se as n,Zt as o,et as p,tt as q,nt as r,ct as s,vt as t,Qt as u,en as v,tn as w,nn as x,rn as y};
|
|
3
|
+
`,s),c=a===-1?e.length:a+1;return!/\S/.test(e.slice(r,o))&&!/\S/.test(e.slice(s,c))&&(o=r,s=c),e.slice(0,o)+e.slice(s)}function H(e,t){let n=new TextEncoder().encode(e).byteLength,o=Number.isSafeInteger(t)&&t>0;return{bytes:n,maxBytes:o?t:null,state:o?n>t?"over":n>=Math.ceil(t*.8)?"near":"ok":"unknown"}}function ce(){return F}function L({fresh:e=!1}={}){return e?(T=A({fresh:!0}).then(le),T):(T||(T=A().then(le)),T)}function St({fresh:e=!1}={}){return L({fresh:e}).then(t=>({maxBytes:t}))}async function xt(e){let t=await L();return H(B(e),t)}function fe(e){let t=new CustomEvent("clay:save-size",{detail:e});document.dispatchEvent(t),(e.state==="near"||e.state==="over")&&import("./c-3F3AADKG.js").then(n=>n.start(t),()=>{})}var P="/_/clayjs/",Oe=/[\u0000-\u001F\u007F]/,Ee=/^[\t\n\f\r ]|[\t\n\f\r ]$/,$e=/^https:\/\/clayjs\.com\/v(\d+)\/([\s\S]*)$/,Re=/^https:\/\/clayjs\.com\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,de=/^\/_\/clayjs\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,ke=/%2e|%2f|%5c/i;function Me(e){if(typeof e!="string")return null;let t=/^(\d+)\.\d+\.\d+$/.exec(e);return t?t[1]:null}function je(e){if(typeof e!="string"||e==="")return null;try{return new URL(e).origin}catch{return null}}function Le(e){let t=e.indexOf("#"),n=t<0?"":e.slice(t),o=t<0?e:e.slice(0,t),s=o.indexOf("?"),r=s<0?"":o.slice(s);return{head:s<0?o:o.slice(0,s),search:r,hash:n}}function Pe(e){if(e===""||e.includes("\\")||ke.test(e))return null;let t=e.split("/"),n=[];for(let o of t){if(o===""||o==="."||o==="..")return null;let s;try{s=decodeURIComponent(o)}catch{return null}if(s.includes("/")||s.includes("\\")||s==="."||s==="..")return null;n.push(s)}return n.join("/")}function b(e,{documentURL:t}={}){if(typeof e!="string"||e===""||Ee.test(e)||Oe.test(e))return null;let{head:n,search:o,hash:s}=Le(e),r=null,a=null,c=null,l=null,i=$e.exec(n);if(i&&(r="rolling",c=i[1],l=i[2]),r||(i=Re.exec(n),i&&(r="exact",a=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],l=i[4])),r||(i=de.exec(n),i&&(r="local",a=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],l=i[4])),!r){let f=je(t);f&&n.startsWith(`${f}/`)&&(i=de.exec(n.slice(f.length)),i&&(r="local",a=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],l=i[4]))}if(!r)return null;let u=Pe(l);return u===null?null:{kind:r,major:c,version:a,rawPath:l,path:u,search:o,hash:s}}function Ie(e,t){let n=e&&typeof e=="object"?e[t]:null;return n&&typeof n.files=="object"&&n.files?n.files:null}function _e(e){return!e||typeof e!="object"?[]:Array.isArray(e.entries)?e.entries.filter(t=>t&&typeof t=="object"):[]}function Ne(e,t,n){if(!n)return!0;let o=Ie(n,t);return!!(o&&Object.hasOwn(o,e.path))}function he(e,{descriptor:t,releases:n,documentURL:o,aliases:s}={}){let r=b(e,{documentURL:o});if(!r||r.kind!=="local")return e;let a=_e(t),c=Me(r.version);for(let l of a){if(l.local!==e||typeof l.original!="string")continue;let i=n?.[r.version]?.aliases??s;if(i&&typeof i=="object"&&!r.search&&!r.hash&&Object.hasOwn(i,l.original)&&i[l.original]===r.path)return l.original;let u=b(l.original);if(u&&!(u.kind!=="rolling"&&u.kind!=="exact")&&u.rawPath===r.rawPath&&u.search===r.search&&u.hash===r.hash&&!(u.kind==="rolling"?u.major!==c:u.version!==r.version)&&Ne(r,r.version,n))return u.kind==="exact"?l.original:`https://clayjs.com/v${u.major}/${r.rawPath}${r.search}${r.hash}`}for(let l of a){if(typeof l.original!="string")continue;let i=b(l.original);if(i&&!(i.kind!=="rolling"&&i.kind!=="exact")&&i.rawPath===r.rawPath&&!(i.kind==="rolling"?i.major!==c:i.version!==r.version))return i.kind==="rolling"?`https://clayjs.com/v${i.major}/${r.rawPath}${r.search}${r.hash}`:`https://clayjs.com/${i.version}/${r.rawPath}${r.search}${r.hash}`}return`https://clayjs.com/${r.version}/${r.rawPath}${r.search}${r.hash}`}var De=Object.freeze({"https://cdn.jsdelivr.net/npm/overtype@2.6.1/dist/overtype.min.js":"compat/overtype-2.6.1.min.js","https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js":"compat/highlight-11.9.0.min.js","https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;0,600;1,400;1,500&family=IBM+Plex+Sans:wght@400;500;600&display=swap":"fonts/ibm-plex.css"}),z="clay-runtime-map",Ue=new Set(["stylesheet","preload","modulepreload"]),pe=null,J=null;function Ce(e){let t;try{t=JSON.parse(e)}catch{return null}return!t||typeof t!="object"||t.schema!==1?null:t}function Fe(){if(typeof document>"u")return null;let e=document.getElementById(z);if(!e)return null;let t=e.textContent??"";return t===pe||(pe=t,J=Ce(t)),J}var Be=`script[src*="${P}"], link[href*="${P}"], #${z}`;function me(e){if(e.querySelector(Be))return!0;for(let t of e.querySelectorAll("template"))if(me(t.content))return!0;return!1}function He(e){let t=[],n=[e];for(;n.length;){let o=n.pop();for(let s of o.children??[])t.push(s),n.push(s),s.content&&n.push(s.content)}return t}function Je(e){return e.tagName==="SCRIPT"&&e.hasAttribute("src")?"src":e.tagName!=="LINK"||!e.hasAttribute("href")?null:(e.getAttribute("rel")??"").toLowerCase().split(/\s+/).some(n=>Ue.has(n))?"href":null}function ze(e){if(!e||!me(e))return;let t=[],n=!1;for(let r of He(e)){if(r.getAttribute("id")===z){r.remove();continue}let a=Je(r);a&&(t.push({element:r,name:a}),!n&&(r.getAttribute(a)??"").includes(P)&&(n=!0))}if(!n)return;let o=location.href,s=Fe();for(let{element:r,name:a}of t){let c=r.getAttribute(a),l=b(c,{documentURL:o});!l||l.kind!=="local"||r.setAttribute(a,he(c,{descriptor:s,documentURL:o,aliases:De}))}}re(ze);var x=!1,$=null,ge="/_/save",Ke=12e3,ve=6e4,We=1024*1024,we="text/plain;charset=UTF-8",I=null,R=!1,K=new Map;function Ht(e,t){t==null?K.delete(e):K.set(e,String(t))}var W=new Set;function Jt(e){return W.add(e),()=>W.delete(e)}async function zt(e,t){R=!!e;try{return await t()}finally{R=!1}}function Gt(){return x}function Kt(){return x?null:(x=!0,$={reserved:!0},$)}function Wt(e){!e||$!==e||($=null,x=!1)}function Xt(){return R}var _=[],N=[];function Yt(e){return _.push(e),()=>{let t=_.indexOf(e);t>=0&&_.splice(t,1)}}function Vt(e){return N.push(e),()=>{let t=N.indexOf(e);t>=0&&N.splice(t,1)}}function Xe(e){for(let t of _)try{t(e)}catch(n){console.error("clayjs: onSaveAttempt hook failed:",n)}}function Ye(e){for(let t of N)try{t(e)}catch(n){console.error("clayjs: onSaveOutcome hook failed:",n)}}function ye(e){return{ok:!0,msg:e.msg??"Saved",msgType:e.msgType||"success",code:e.code??null,etag:e.etag??null,...e.siteData?{siteData:e.siteData}:{}}}var O=[],Ve=8,y=null;function qt(){return y!==null}function Se(){let e=window.crypto?.randomUUID?.();if(e)return e;if(window.crypto?.getRandomValues){let n=new Uint8Array(16);return window.crypto.getRandomValues(n),Array.from(n,o=>o.toString(16).padStart(2,"0")).join("")}let t=()=>Math.random().toString(36).slice(2,12).padEnd(10,"0");return`${Date.now().toString(36)}-${t()}${t()}${t()}`}function qe(e){O.push(e),O.length>Ve&&O.shift()}function Ze(e){return typeof e=="string"&&e!==""&&O.includes(e)}function Zt(){O.length=0,y=null}function X(e){let t=e.name==="AbortError",n=!t&&e.status===412,o=!t&&!n&&e.code==="save-already-applied";return{ok:!1,msg:t?"Server not responding":e.message||"Save failed",msgType:t||o?"unknown":n?"conflict":"error",code:t?"timeout":n?"conflict":e.code??null,changedBy:n?e.changedBy??null:null,afterTimeout:n&&y!==null,conflictEtag:n?e.etag??null:null,status:Number.isInteger(e.status)?e.status:null,hadTimeout:t||e.hadTimeout===!0,reason:e.reason??null,retryAfter:e.retryAfter??null,saveOutcome:e.saveOutcome??null,etag:null}}function E(e){return{ok:!1,msg:e,msgType:"skipped",code:null,etag:null}}function Qe(e){let t=new Error(`This document is ${e.bytes} bytes; this host saves at most ${e.maxBytes}`);return t.code="save-too-large",{...X(t),sent:!1,size:e}}var w=null;function et(e){return w?null:(w={kind:e},w)}function tt(e){w===e&&(w=null)}function nt(){return w?w.kind:null}function rt(){return{ok:!1,msg:"Invalid page conversion metadata",msgType:"error",code:"invalid-header",etag:null}}var ot=3,it=/^(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT|(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), \d{2}-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{2} \d{2}:\d{2}:\d{2} GMT|(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?: \d|\d{2}) \d{2}:\d{2}:\d{2} \d{4})$/;function st(e){if(e==null)return null;let t=String(e).trim();if(!t)return null;if(/^-?\d+$/.test(t))return Math.max(0,Math.min(3600,Number(t)));if(!it.test(t))return null;let n=Date.parse(t);return Number.isNaN(n)?null:Math.max(0,Math.min(3600,Math.round((n-Date.now())/1e3)))}var at=/^[0-9a-f]{64}$/,lt=/^[A-Za-z0-9-]{1,64}$/;function ut(e){if(e==null)return{header:null};if(typeof e!="object")return{invalid:!0};let{source:t,base:n,epoch:o}=e;return typeof n!="string"||!at.test(n)?{invalid:!0}:t==="file"?o!=null?{invalid:!0}:{header:`v1; source=file; base=${n}`}:t==="room"?typeof o!="string"||!lt.test(o)?{invalid:!0}:{header:`v1; source=room; base=${n}; epoch=${o}`}:{invalid:!0}}function ct(e,t,n,o,s,r=!1,a=null,c=!0){let l=V(),i=l?`${ge}/${l}`:ge,u={method:"POST",credentials:l?"omit":"same-origin",signal:n,headers:{"Document-URL":window.location.href,"Page-URL":window.location.href,"Save-Trigger":t?"user":"auto","Save-ID":o,[se]:String(1)},body:ft(e)};for(let[f,h]of K)u.headers[f]=h;if(c)for(let f of W){let h=null;try{h=f(e)}catch(p){console.error("clayjs: a save header source failed:",p)}if(h)for(let[p,S]of Object.entries(h))u.headers[p]=String(S)}return typeof u.body!="string"&&(u.headers["Content-Type"]=we),a&&(u.headers["Blockeditor-Conversion"]=a),s&&(u.headers["If-Match"]=s),r&&e.length<ve&&new Blob([e]).size<ve&&(u.keepalive=!0),{url:dt(i),options:u}}function ft(e){if(e.length<We)return e;if(I&&I.content===e)return I.blob;let t=new Blob([e],{type:we});return I={content:e,blob:t},t}function xe(){let e=oe();return ie()&&e?e:null}function dt(e){let t=window.location.origin;return!t||t==="null"?e:new URL(e,t).href}function G(e,t){let n=JSON.stringify(t);return{ok:e>=200&&e<300,status:e,statusText:e===200?"OK":"Insufficient Storage",text:()=>Promise.resolve(n)}}function ht(e,t){let n=q();return n?Promise.resolve().then(()=>n(e,t)).then(()=>G(200,{msg:"Saved in this browser",msgType:"success"}),o=>G(507,{msg:"Couldn't save in this browser. Storage is full or turned off.",msgType:"error",code:o?.code||"draft-storage"})):Promise.resolve(G(503,{msg:"Saving in this browser is not ready yet",msgType:"error",code:"draft-not-ready"}))}function pt(e,t,n,{captureId:o=null,conversionHeader:s=null,attempts:r=[],gateToken:a=null}={}){let c=new AbortController,l=setTimeout(()=>c.abort(),Ke),i=Q(),u=ee(),f=i||u,h=R;R=!1;let{url:p,options:S}=ct(e,f,c.signal,t,n,h,s);return qe(t),k||(r.some(d=>d.saveId===t&&d.etag===(n??null))||r.push({saveId:t,etag:n??null}),Xe({captureId:o,saveId:t,html:e,etag:n??null})),(k?ht(e,a):fetch(p,S)).then(d=>d.text().then(g=>{let m={};if(g)try{m=JSON.parse(g)}catch{if(d.ok)throw new Error("Server sent a response that was not JSON")}if(!d.ok){let v=new Error(m.msg||m.error||`HTTP ${d.status}: ${d.statusText}`);throw v.code=d.status===413?"save-too-large":m.code??null,v.status=d.status,v.changedBy=m.changedBy??null,v.etag=m.etag??null,v.saveId=m.saveId??null,v.reason=typeof m.reason=="string"?m.reason:null,v.saveOutcome=m.saveOutcome??null,v.retryAfter=st(d.headers?.get?.("Retry-After")),v}return j(m.etag??null),y=null,m})).catch(d=>{throw console.error("Failed to save page:",d),d.name==="AbortError"&&(y={saveId:t,etag:n}),f&&Z(),d}).finally(()=>{clearTimeout(l)})}async function mt(){let e=y;if(!e)return{landed:null,resend:!1};let n=(await A({fresh:!0})).document,o=typeof n?.etag=="string"&&n.etag?n.etag:null;return o?n.saveId&&n.saveId===e.saveId?(j(o),y=null,{landed:{msg:"Saved",msgType:"success",etag:o},resend:!1}):(n.saveId&&(y=null),{landed:null,resend:!!e.etag,etag:e.etag}):{landed:null,resend:!1}}async function gt(e,{captureId:t=null,conversionHeader:n=null,attempts:o=[],gateToken:s=null}={}){let r=Se(),a=xe(),c=!1,l=!1,i=0,u=t??M();for(;;)try{return await pt(e,r,a,{captureId:t,conversionHeader:n,attempts:o,gateToken:s})}catch(f){if(c&&(f.hadTimeout=!0),f.name==="AbortError"){if(c)throw f;let{landed:h,resend:p,etag:S}=await mt();if(h)return h;if(!p)throw f;a=S,c=!0;continue}if(f.status===412&&!l&&Ze(f.saveId)){j(f.etag??null),y=null,r=Se(),a=xe(),l=!0;continue}if(f.code==="blockeditor-converting"&&i<ot){if(M()!==u||(i+=1,await new Promise(h=>setTimeout(h,Math.max(0,f.retryAfter??1)*1e3)),M()!==u))throw f;continue}throw f}}function Y(e,t,n,o,s=null,r=0,a=null,c=null){return e=ae(e,Math.max(C(),r)),new Promise(l=>{let i=[],u=te(s),f=()=>a!==null&&$===a,h=()=>{f()||(x=!1)},p=(g,m=!1)=>{m&&U(e,t??null,u),ne(s),Ye({captureId:t??null,result:g,attempts:i,sent:i.length>0}),typeof n=="function"&&n(g),l(g)};if(!D&&!window.clay?.testMode)return p(E("Not in edit mode"));if(x&&!f())return p(E("Save already in progress"));let S=ut(o);if(S.invalid)return p(rt());if(x=!0,window.clay?.testMode){setTimeout(()=>{h(),p(ye({msg:"Test mode: save skipped"}))},0);return}L();let d=H(B(e),ce());if(fe(d),d.state==="over")return h(),p(Qe(d));gt(e,{captureId:t,conversionHeader:S.header,attempts:i,gateToken:c}).then(ye,X).then(g=>{h(),g.code==="save-too-large"&&!g.size&&(g.size=d),g.ok&&U(e,t??null,u,g.siteData??null),p(g)})})}function vt(e,t=()=>{}){return Y(e,null,t,null)}function Qt(e,t,n=()=>{},{conversion:o,capture:s=null,blockeditorFormatFloor:r,lane:a=null,gateToken:c=null}={}){return Y(e,t,n,o,s,r,a,c)}function en({html:e,captureId:t,conversion:n}){return Y(e,t??null,void 0,n)}function tn(e,t=()=>{}){return new Promise(n=>{let o=null,s=r=>{tt(o),typeof t=="function"&&t(r),n(r)};if(!D)return s(E("Not in edit mode"));if(nt())return s(E("Another document operation is in progress"));if(x)return s(E("Save already in progress"));if(k)return s(!1);o=et("replace"),fetch(new URL(e,window.location.href).href).then(r=>{if(!r.ok)throw new Error(`Template fetch failed: HTTP ${r.status} ${r.statusText}`);return r.text()}).then(r=>vt(r)).then(s).catch(r=>{console.error("Failed to fetch template:",r),s(X(r))})})}var Ae=null;function nn(e){Ae=e}function rn(){return Ae}export{L as a,St as b,xt as c,Ht as d,Jt as e,zt as f,Gt as g,Kt as h,Wt as i,Xt as j,Yt as k,Vt as l,qt as m,Se as n,Zt as o,et as p,tt as q,nt as r,ct as s,vt as t,Qt as u,en as v,tn as w,nn as x,rn as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as v,e as m}from"./c-LETPPG2F.js";import"./c-MVVEIJUU.js";import"./c-IW6GGOU2.js";import"./c-HAWFNBYG.js";import{f as h,g as p,h as g,i as k}from"./c-LAKBBJOU.js";import"./c-EIUKME3W.js";import"./c-ND3W7D5U.js";import"./c-WHQUZM2V.js";import"./c-OH2FPYSY.js";import"./c-RETTCOWO.js";import"./c-TCCA5BZN.js";import"./c-57XDY6HC.js";import"./c-OZVK3TFI.js";import"./c-QCDVDZIR.js";import"./c-MZCOGNZL.js";import"./c-IJUK2GPW.js";import{c as b}from"./c-BPF2NSPV.js";import{e as T}from"./c-UW6MMZ4V.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";T(v);var x=1,y=class extends Error{constructor(o,n){super(n),this.name="PageCheckpointError",this.code=o}},w=(e,o)=>{throw new y(e,o)},t=(e,o)=>({ok:!1,code:e,message:o}),A=/^[0-9a-f]{64}$/,j=/^[0-9a-f]{32}$/,E=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function I(e){return{v:e.v,g:e.g,y:{...e.y??{}}}}function H(e){let o;try{o=JSON.parse(e)}catch{w("invalid-state","The page state is not JSON")}return(!E(o)||o.v!==1)&&w("invalid-state","Expected a version 1 Yjs page value"),{state:I(o),bytes:p(o)}}var S=e=>e==null?"":String(e);async function N({href:e,etag:o,fetch:n=globalThis.fetch,signal:i=null}={}){if(typeof o!="string"||!o)return t("missing-etag","A conditional read needs the accepted ETag");if(typeof e!="string"||!e)return t("no-blockeditor-state","This host names no blockeditor-state resource");if(typeof n!="function")return t("unavailable","This tab cannot read the page state");let s=globalThis.location?.href??"http://localhost/",d;try{d=new URL(e,s).href}catch{return t("no-blockeditor-state","The blockeditor-state resource is not a URL")}let c=b(),a;try{a=await n(d,{method:"GET",credentials:c?"omit":"same-origin",headers:{"If-Match":o,"Document-URL":globalThis.location?.href??s},cache:"no-store",redirect:"manual",signal:i})}catch{return t("unavailable","The blockeditor-state request did not complete")}if(!a||typeof a.status!="number")return t("unavailable","The blockeditor-state request did not answer");if(a.status===412)return t("etag-mismatch","Another version of this document is stored");if(a.status===428)return t("etag-required","The host needs a condition this read cannot send");if(a.status===404)return t("no-blockeditor-state","This host keeps no page state");if(!a.ok)return t("unavailable",`The host answered ${a.status}`);let r;try{r=JSON.parse(await a.text())}catch{return t("invalid-state","The blockeditor-state answer is not JSON")}return!E(r)||r.version!==x?t("unsupported-version","Unknown blockeditor-state version"):typeof r.tag!="string"||!r.tag?t("invalid-state","The blockeditor-state answer carries no page tag"):typeof r.stateHash!="string"||!A.test(r.stateHash)?t("invalid-state","The blockeditor-state answer carries no state digest"):typeof r.generation!="string"||!j.test(r.generation)?t("invalid-state","The blockeditor-state answer carries no generation"):typeof r.etag!="string"||!r.etag?t("invalid-state","The blockeditor-state answer carries no ETag"):Object.hasOwn(r,"documentId")?{ok:!0,version:r.version,documentId:r.documentId,generation:r.generation,etag:r.etag,stateHash:r.stateHash,tag:r.tag}:t("invalid-state","The blockeditor-state answer carries no document identity")}async function _(e,{accepted:o,article:n,etag:i}={}){if(!e||e.ok!==!0)return t(e?.code??"unavailable",e?.message??"The page state was not read");let s=o?.authority;if(!(s?.scope==="path"&&e.documentId==null)&&S(e.documentId)!==S(s?.documentId))return t("foreign-document","The page state belongs to another document");if(typeof o?.lineage?.generation!="string"||e.generation!==o.lineage.generation)return t("foreign-generation","The page state belongs to another generation");if(e.etag!==i)return t("etag-mismatch","The page state belongs to another version of this document");let c,a;try{({state:a,bytes:c}=H(e.tag))}catch(u){return t(u?.code??"invalid-state",u?.message??"The page state does not decode")}if(await h(c)!==e.stateHash)return t("state-digest-mismatch","The page state is not the one the host hashed");if(typeof n!="string")return t("missing-article","A proof names the final outgoing article");let r;try{r=m(a)}catch(u){return t("invalid-state",u?.message??"The page state does not project")}return r!==n?t("article-mismatch","The page state does not project to the accepted article"):{ok:!0,state:a,receipt:{file:e.etag,blockeditorState:e.stateHash}}}async function O(e,o){let n=(o||[]).map(({id:i,revision:s})=>({id:i,revision:s}));try{return{ok:!0,proof:e,covered:await k(e,n)}}catch(i){return t(i?.code??"invalid-proof",i?.message??"The proof does not validate")}}async function R({capture:e,records:o=[],accepted:n,article:i,state:s=null,etag:d=null}={}){if(!s)return t("no-capture-state","No page state was pinned to this capture");if(typeof d!="string"||!d)return t("missing-etag","An accepted save with no ETag proves no stored pair");if(typeof i!="string")return t("missing-article","The accepted bytes hold no article");let c,a;try{c=m(s),a=p(s)}catch(u){return t(u?.code??"invalid-state",u?.message??"The pinned page state does not decode")}if(c!==i)return t("article-mismatch","The pinned page state does not project to the accepted article");let r;try{r=await g({capture:e,records:o,accepted:n,article:i,state:s,receipt:{file:d,blockeditorState:await h(a)}})}catch(u){return t(u?.code??"invalid-proof",u?.message??"The proof could not be built")}return O(r,o)}async function B({read:e,capture:o,records:n=[],accepted:i,article:s,etag:d=null}={}){let c=await _(e,{accepted:i,article:s,etag:d});if(!c.ok)return c;let a;try{a=await g({capture:o,records:n,accepted:i,article:s,state:c.state,receipt:c.receipt})}catch(r){return t(r?.code??"invalid-proof",r?.message??"The proof could not be built")}return O(a,n)}async function G({channel:e,records:o=[],capture:n,accepted:i,article:s,state:d=null,etag:c=null,href:a=null,read:r=N,fetch:u}={}){if(!e||typeof e.checkpoint!="function")return{ok:!1,code:"no-channel",retired:[],proof:null};let l=await R({capture:n,records:o,accepted:i,article:s,state:d,etag:c});if(!l.ok){let P=await r({href:a,etag:c,fetch:u});l=await B({read:P,capture:n,records:o,accepted:i,article:s,etag:c})}if(!l.ok)return{ok:!1,code:l.code,retired:[],proof:null};let f=await e.checkpoint({records:l.covered,proof:l.proof});return!f||f.ok!==!0?{ok:!1,code:f?.code??"checkpoint-failed",retired:[],proof:l.proof}:{ok:!0,retired:f.retired??[],proof:l.proof}}export{x as PAGE_STATE_VERSION,y as PageCheckpointError,R as captureProof,G as checkpointAccepted,N as readPageState,B as refetchedProof,_ as verifyPageState};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as B}from"./c-QY7F6EN6.js";import{d as T}from"./c-QHWJ5ZIJ.js";import{b as E,c as I,f as x,g as $,h as N,j as y}from"./c-J2ZW4HMR.js";import{a as g,d as S,e as b,f as w}from"./c-A5LASUEZ.js";import{e as d,f,g as m}from"./c-5RZNFTWD.js";import{b as C}from"./c-PKCCHJ5X.js";import{a as L,b as c}from"./c-NUHP2XDB.js";var h={success:{edge:d.teal,icon:f.toastSuccess},error:{edge:d.ox,icon:f.toastWarning},warning:{edge:d.brass,icon:f.toastWarning},info:{edge:d.brass,icon:f.toastInfo}},R=f.toastClose,_=["opacity:0","transform:translateX(24px)"],P=24,q=10;function U(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches?"none":"opacity .5s ease-in-out, transform .5s ease-in-out"}function X(e){let n=document.querySelector('clay-editor-ui[data-clay-ui="toasts"]')?.shadowRoot.querySelector("[data-clay-toasts]");if(n)return n;let s=x("div",["position:fixed","top:18px","right:18px","z-index:9999","display:flex","flex-direction:column","align-items:flex-end","gap:10px","width:min(330px, calc(100vw - 36px))","pointer-events:none"],{theme:e,parts:["toast.stack"]});return s.setAttribute("data-clay-toasts",""),s.setAttribute("aria-live","polite"),B({name:"toasts",content:s}),s}function A(e,n,{detail:s="",actions:t=[]}={},i){let l=h[n],o=N("div",["display:flex","align-items:flex-start",...m.toast,"width:100%",`border-inline-start:3px solid ${l.edge}`,"cursor:pointer","pointer-events:auto",..._,`transition:${U()}`],{theme:i,parts:["toast.panel"]});g(i)&&L(o,[`border-inline-start-color:${l.edge}`,...b(i,["toast.panel"],{})]),o.setAttribute("data-clay-toast",n);let a=x("div",["flex:1 1 auto","min-width:0","display:flex","flex-direction:column","gap:8px"],{theme:i}),r=x("div",["display:flex","align-items:flex-start","gap:8px"],{theme:i}),p=y("span",["display:inline-grid","flex:none","padding-top:1px",`color:${l.edge}`],void 0,{theme:i,parts:["toast.icon"],role:null});p.innerHTML=l.icon,E(p.firstElementChild,16);let O=y("span",["flex:1 1 auto","min-width:120px",...m.toastTitle,"overflow-wrap:anywhere"],e,{theme:i,parts:["toast.text"]});if(r.append(p,O),a.append(r),s&&a.append(y("span",["display:block",`padding-inline-start:${P}px`,`color:${d.muted}`,"overflow-wrap:anywhere"],s,{theme:i,parts:["toast.text"],role:"mutedText"})),t.length){let k=x("div",["display:flex","flex-wrap:wrap","gap:8px",`padding-inline-start:${P-q}px`],{theme:i});for(let{label:D,onClick:H}of t)k.append(I(D,{small:!0,variant:"quiet",onClick:H,extra:["padding:4px 8px"],theme:i}));a.append(k)}return o.append(a),o}function W(e,n){let s=["flex:none","display:inline-grid","place-items:center",...m.toastClose,"cursor:pointer"],t=x("button",s);if(t.type="button",t.setAttribute("aria-label","Dismiss"),t.title="Dismiss",t.innerHTML=R,!g(n)){E(t.firstElementChild,14);let r=p=>{c(t,"color",p?d.ink:d.muted),c(t,"background",p?d.sunk:"transparent")};return t.addEventListener("pointerenter",()=>r(!0)),t.addEventListener("pointerleave",()=>r(!1)),t.addEventListener("focus",()=>{r(!0),c(t,"outline",`2px solid ${d.brass}`),c(t,"outline-offset","1px")}),t.addEventListener("blur",()=>{r(!1),c(t,"outline","none")}),t.addEventListener("click",e),t}let i=["close","toast.close"],l=["icon","toast.closeIcon"];w(t,n,i),w(t.firstElementChild,n,l);let o={hover:!1,focus:!1,pressed:!1},a=()=>{let r={hover:o.hover,active:o.pressed,focus:o.focus},p=t.firstElementChild;p.style.cssText="",E(p,14),L(p,b(n,l,r)),$(t,[...s,...S(n,"close",r),...b(n,i,r)])};return t.addEventListener("pointerenter",()=>{o.hover=!0,a()}),t.addEventListener("pointerleave",()=>{o.hover=!1,o.pressed=!1,a()}),t.addEventListener("pointerdown",r=>{r.button!==void 0&&r.button!==0||(o.pressed=!0,a())}),t.addEventListener("pointerup",()=>{o.pressed=!1,a()}),t.addEventListener("focus",()=>{o.focus=!0,a()}),t.addEventListener("blur",()=>{o.focus=!1,o.pressed=!1,a()}),t.addEventListener("click",e),a(),t}function M(e,n){X(n).append(e),g(n)?c(e,"color-scheme",n.scheme==="light dark"?"light":n.scheme):C(e,{background:d.surface}),setTimeout(()=>{c(e,"opacity","1"),c(e,"transform","none")},10)}function v(e,n){c(e,"opacity","0"),c(e,"transform","translateX(24px)"),setTimeout(()=>{e.remove(),n?.()},500)}function z(e,n="success"){let s=T(),t=A(e,h[n]?n:"success",{},s);t.addEventListener("click",()=>v(t)),M(t,s),setTimeout(()=>v(t),6600)}var u=new Map;function Q(e,n="warning",{detail:s="",actions:t=[]}={}){let i=u.get(e);i&&(v(i),u.delete(e));let l=T(),o=A(e,h[n]?n:"warning",{detail:s,actions:t},l);c(o,"cursor","default");let a=W(r=>{r.stopPropagation(),v(o,()=>{u.get(e)===o&&u.delete(e)})},l);o.append(a),u.set(e,o),M(o,l)}function V(e,{now:n=!1}={}){let s=u.get(e);if(s){if(u.delete(e),n){s.remove();return}v(s)}}var Z=z;export{Q as a,V as b,Z as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{i as S}from"./c-WHQUZM2V.js";import{d as k,g as A,h as j,i as E,j as M,k as w,m as $,v as N}from"./c-OH2FPYSY.js";var G="blockeditor-local",U="blockeditor-net",V="blockeditor-seed",B=N,Q=Symbol("blockeditor-history"),X=Object.freeze(["flow","attrs","gone","boardFields","tableFields","origins"]),Y=new Set(["id","pos"]),F=new WeakMap,Z=t=>{let s=F.get(t);return s||F.set(t,s=Object.freeze([...Object.keys(t.spec.attrs||{}).filter(r=>!Y.has(r)),...t.name==="table"?["rows"]:[]])),s},v=(t,s)=>t.name==="table"&&s==="rows"?{}:t.spec.attrs[s].default,tt=(t,s)=>t===s||JSON.stringify(t)===JSON.stringify(s),et=t=>`${t.client}.${t.clock}`,st=t=>{let s=t.indexOf(".");return{client:+t.slice(0,s),clock:+t.slice(s+1)}},ot=t=>t>=55296&&t<=56319,nt=t=>t>=56320&&t<=57343,_=0,rt=t=>`${t.ydoc.clientID.toString(36)}-${(_++).toString(36)}`,q=0,it=t=>`b${t.ydoc.clientID.toString(36)}${(q++).toString(36)}`;function at(t=new S){return{ydoc:t,flow:t.getText("flow"),attrs:t.getMap("attrs"),gone:t.getMap("gone"),boardFields:t.getMap("boardFields"),tableFields:t.getMap("tableFields"),origins:t.getMap("origins")}}var W=t=>t.split("!")[0].split("~")[0],L=t=>t.includes("!"),dt=t=>{let s={};for(let r of t)s[r.type.name]=r.attrs&&Object.keys(r.attrs).length?{...r.attrs}:!0;return s},ht=t=>{let s={};for(let r of t){if(A(r)){for(let[c,i]of Object.entries(E(r.attrs.entries)))s[c]=JSON.parse(JSON.stringify(i));continue}s[r.type.name]=r.attrs&&Object.keys(r.attrs).length?{...r.attrs}:!0}return s},ut=t=>t.map(s=>s.type.name+(s.attrs&&Object.keys(s.attrs).length?JSON.stringify(s.attrs):"")).sort().join("|");function gt(t,s){if(s==="code_block")return[];let r=new Map,c=new Set;for(let o of Object.keys(t))L(o)&&t[o]&&c.add(o.split("!")[0]);for(let o of Object.keys(t).sort()){let a=t[o];a==null||L(o)||c.has(o)||r.set(W(o),a)}let i=[],l=null;for(let[o,a]of r)k.marks[o]&&(!w.has(o)||$(o,a===!0?{}:a))?i.push(k.marks[o].create(a===!0?null:a)):(l??={})[o]=a;if(l){let o=M(l);o.length&&i.push(j(o))}return i}var h=t=>Number.isSafeInteger(t)&&t>=0,p=t=>{throw new RangeError(t)},T=t=>(t!=="before"&&t!=="after"&&p(`Unknown affinity: ${t}`),t),I=(t,s,r)=>{let c=0,i=t.length;for(;c<i;){let l=c+i>>1;s(t[l])<=r?c=l+1:i=l}return c};function bt(t,s){(!t||typeof t!="object"||!h(t.tokens))&&p("A projection map needs a walk result with a token count"),h(s)||p("A projection map needs a nonnegative physical length");let r=t.holes===void 0?[]:t.holes;Array.isArray(r)||p("A projection map needs the walk holes");let c=[],i=[],l=[0],o=0,a=0,b=-1,m=e=>{c.push({logicalStart:o,logicalLength:e,physicalStart:a,physicalLength:e,kind:"visible"}),o+=e,a+=e},J=e=>{let n=i[i.length-1];n&&n.at===o?(n.length+=e,n.end+=e,c[c.length-1].physicalLength+=e,l[l.length-1]+=e):(i.push({at:o,start:a,end:a+e,length:e}),c.push({logicalStart:o,logicalLength:0,physicalStart:a,physicalLength:e,kind:"hidden"}),l.push(l[l.length-1]+e)),a+=e};for(let e of r)(!e||typeof e!="object"||!h(e.at)||!h(e.len))&&p("Malformed walk hole"),e.at<b&&p("Walk holes are out of order"),e.at>t.tokens&&p("A walk hole sits past the logical length"),b=e.at,e.at>o&&m(e.at-o),e.len&&J(e.len);o<t.tokens&&m(t.tokens-o),a!==s&&p("Walk holes do not account for the physical length");let x=e=>I(i,n=>n.at,e),O=e=>I(i,n=>n.end,e),g=e=>e+l[x(e)],K=e=>{let n=i[x(e)-1];return n&&n.at===e?n:null},P=e=>{let n=i[O(e)];return n&&n.start<=e?n:null},R=(e,n)=>{let f=T(n);(!h(e)||e>t.tokens)&&p(`Logical position ${e} is outside the map`);let d=K(e);return d?f==="before"?d.start:d.end:g(e)},C=(e,n)=>{T(n),(!h(e)||e>s)&&p(`Physical position ${e} is outside the flow`);let f=P(e);return f?f.at:e-l[O(e)]},D=(e,n)=>{(!h(e)||!h(n)||e>t.tokens||n>t.tokens)&&p(`Logical range ${e}..${n} is outside the map`);let f=[];if(n<=e)return f;let d=g(e);for(let u of i)if(!(u.at<=e)){if(u.at>n)break;u.start>d&&f.push([d,u.start]),d=u.end}let y=g(n);return y>d&&f.push([d,y]),f};return{segments:c,logicalLength:t.tokens,physicalLength:s,toPhysical:R,toLogical:C,physicalRanges:D}}export{G as a,U as b,V as c,B as d,Q as e,X as f,Z as g,v as h,tt as i,et as j,st as k,ot as l,nt as m,rt as n,it as o,at as p,W as q,L as r,dt as s,ht as t,ut as u,gt as v,bt as w};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h}from"./c-A5LASUEZ.js";import"./c-VHNSBD2M.js";export{g as floorRules,h as heightFloor,f as markParts,e as partRules,b as stateList,a as themed,c as tokenRules,d as tokenRulesFor};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{d as De,h as Je,i as et}from"./c-TRS6TM6O.js";import{a as Ue,b as We}from"./c-Y3J5LDKB.js";import{a as He,b as Ke}from"./c-PZ4XEPUP.js";import"./c-SFKI6OLM.js";import"./c-Q3XOWZEV.js";import"./c-RHMPKZZ7.js";import{d as Ze}from"./c-QHWJ5ZIJ.js";import{a as Se,b as je,c as V,d as Qe,h as pe,i as Le,j as u}from"./c-J2ZW4HMR.js";import{a as te,e as ce,f as de}from"./c-A5LASUEZ.js";import"./c-4JZDZFF6.js";import{b as W,c as ee,e as l,f as qe}from"./c-5RZNFTWD.js";import{b as Ge}from"./c-PKCCHJ5X.js";import"./c-46XYM55L.js";import{a as se,b as T,c as Ve}from"./c-NUHP2XDB.js";import{a as Xe,r as q}from"./c-FC5RUFPR.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import{f as Re}from"./c-P73XPAOA.js";import"./c-ZPI7M5U5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-MZCOGNZL.js";import"./c-EHAR4RJJ.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-KU3PX7LL.js";import"./c-EQ5NBOGA.js";import"./c-IJUK2GPW.js";import{f as Ye}from"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-UW6MMZ4V.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 I="light-dark(#D08A1E, #E3A33F)",ht=5e3,gt=4e3,mt=500,wt={"another-tab":"in another tab","another-person":"by someone else","an-agent":"by an agent"},yt='<svg viewBox="0 0 12 12" width="12" height="12" aria-hidden="true"><path d="M2.5 9.5h7" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="square"/></svg>',H=(e,t)=>`${e} ${t}${e===1?"":"s"}`,xt="This spot changed again. Review the latest edit or download your copy.",vt="A data value can't be put back from here. Download your copy to keep yours.",w="hidden",Y=!1,L=[],ne=new Set,B=new Set,m=null,Me=0,O=null,b=null,fe=null,h=null,R=!1,K=!1,Ce=!1,Q=new Map,he=0,ue=!1,ie=!1,k=null,X=null,D=null,Be=0,z=!1,ge=0,me=null,re=null,$=[],v=[],ae=!1,we=null,ye=null,c=null,a=null,P=null,G=new Map,M=()=>window.clay?.conflicts||null,ot=()=>$.reduce((e,t)=>e+t.conflicts.length,0)+v.length,_e=()=>{let e=window.clay?.undo;return e&&typeof e.kept=="function"?e:null},xe=()=>M()?.list().filter(e=>!e.claimedBy&&e.kind!=="apply-incomplete")??[],Ie=()=>M()?.list().filter(e=>!e.claimedBy&&e.kind==="apply-incomplete")??[];function Oe(){return O?"upgraded":m?"refused":xe().length?"replaced":Ie().length?"failed":$.length||v.length?"recovered":null}function g(e,t,n){let o=Ve(e,t,n);return t[0]==="all:initial"&&T(o,"color-scheme","inherit"),o.setAttribute("clay",Se),o}function _(e,t){return G.set(t,e),e}function j(e,t){return te(a)&&(de(e,a,t),se(e,ce(a,t,{}))),e}function le(){if(!c)return;let e=window.visualViewport,t=e?Math.max(0,window.innerHeight-e.height-e.offsetTop):0;T(c,"bottom",`calc(${16+t}px + env(safe-area-inset-bottom,0px))`),re&&T(re,"max-height",`${Math.max(160,(e?.height||window.innerHeight)-32)}px`)}function bt(){c=g("div",["all:initial","position:fixed","left:50%","transform:translateX(-50%)","z-index:2147483001","display:none","flex-direction:column","align-items:center","max-width:calc(100vw - 24px)",`font:14px/1.5 ${W}`,`color:${l.ink}`,"text-align:left"]),c.setAttribute("data-clay-conflict",""),document.body.appendChild(c),window.visualViewport?.addEventListener("resize",le),window.visualViewport?.addEventListener("scroll",le)}function d(){if(ue)return;ue=!0;let e=()=>{ue=!1,y()};typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16)}function y(){a=Ze(),ie&&(ie=!1,m&&!q()&&(m=null));let e=Oe();if(e?w==="hidden"&&(w="bar"):(w="hidden",Y=!1,ne.clear(),B.clear(),L=[],x(),me=null,z=!1),!c){if(w==="hidden"&&!k||!document.body)return;bt()}!c.isConnected&&document.body&&document.body.appendChild(c);let t=document.activeElement,n=null;for(let[s,r]of G)r===t&&(n=s);let o=P?P.scrollTop:0;G=new Map,P=null,re=null,c.replaceChildren(),k?c.append(Tt(k)):w==="bar"?c.append(At(e)):w==="panel"&&c.append(Ct(e)),T(c,"display",k||w!=="hidden"?"flex":"none"),P&&(P.scrollTop=o);let i=D||n;i&&G.has(i)&&G.get(i).focus({preventScroll:!0}),k||(D=null),le(),te(a)?(de(c,a,["conflict.root"]),se(c,ce(a,["conflict.root"],{})),T(c,"color-scheme",a.scheme==="light dark"?"light":a.scheme)):(c.removeAttribute("data-clay-part"),Ge(c))}function it(){return j(g("span",["all:initial","display:inline-block","flex:none","width:8px","height:8px","border-radius:50%",`background:${I}`]),["conflict.dot"])}function rt(){return wt[m?.changedBy]||null}function kt(e,t){if(e==="upgraded")return O;if(e==="refused"){let n=rt();return!n&&m.afterTimeout?"This page changed elsewhere, possibly by your own save that timed out. Your edits here are safe.":`This page changed ${n||"elsewhere"}. Your edits here are safe.`}return e==="failed"?"A sync update did not finish. Your edits here are safe.":e==="recovered"?`${H(t,"change")} replaced before this page loaded ${t===1?"is":"are"} still here.`:`Another edit replaced ${H(t,"change")}.`}function $t(e,t){return e==="upgraded"?O:e==="refused"?`This page changed ${rt()||"elsewhere"}`:e==="failed"?"A sync update did not finish":e==="recovered"?`${H(t,"change")} kept from before this page loaded`:`Another edit replaced ${H(t,"change")}`}function Tt(e){let t=pe("div",["display:block",`background:${l["teal-soft"]}`,"padding:10px 14px","width:max-content","max-width:calc(100vw - 24px)"],{theme:a,parts:["conflict.panel"]});return te(a)&&se(t,[`background:${l["teal-soft"]}`]),t.setAttribute("role","status"),t.textContent=e,t}function At(e){let t=e==="failed"?Ie().length:e==="recovered"?ot():xe().length,n=pe("div",["display:flex","flex-wrap:wrap","align-items:center","gap:10px 12px","padding:8px 8px 8px 14px","width:max-content","max-width:calc(100vw - 24px)"],{theme:a,parts:["conflict.panel"]}),o=kt(e,t);return o!==me&&(n.setAttribute("role",e==="refused"?"alert":"status"),me=o),n.append(it(),u("span",[],o,{theme:a,parts:["conflict.text"]})),e==="upgraded"?(n.append(_(V("Reload",{variant:"primary",onClick:()=>window.location.reload(),theme:a,parts:["conflict.button"],labelParts:["conflict.buttonLabel"]}),"reload")),n):(n.append(_(V("Review",{onClick:Ot,theme:a,parts:["conflict.button"],labelParts:["conflict.buttonLabel"]}),"review")),n)}function A(e,t,{variant:n="default",onClick:o,push:i=!1}={}){let r=window.innerWidth<480?["flex:1 1 100%",...n==="primary"?["order:-1"]:[]]:i?["margin-left:auto"]:[];return _(V(e,{variant:n,onClick:o,extra:r,theme:a,parts:["conflict.button"],labelParts:["conflict.buttonLabel"]}),t)}function E(e){return u("div",["display:block","padding:0 16px 12px",`color:${l["ink-2"]}`,"font-size:13.5px"],e,{theme:a,parts:["conflict.text"]})}function Ct(e){let t=e==="replaced"?xe():e==="failed"?Ie():[],n=e==="refused"?xe():t,o=e==="recovered"?ot():t.length;if(ne.size)for(let p of t)ne.has(p.id)||B.add(p.id);for(let p of[...B])t.some(F=>F.id===p)||B.delete(p);let i=$t(e,o),s=Math.max(160,(window.visualViewport?.height||window.innerHeight)-32),r=pe("div",["display:flex","flex-direction:column","width:520px","max-width:calc(100vw - 24px)",`max-height:${s}px`],{theme:a,parts:["conflict.panel"]});re=r,r.setAttribute("role","dialog"),r.setAttribute("aria-label",i);let f=j(g("div",["all:initial","display:flex","align-items:center","gap:8px","padding:12px 12px 8px 16px",`font:14px/1.5 ${W}`,`color:${l.ink}`]),["conflict.header"]),C=_(u("b",["font-weight:600","font-size:14.5px","outline:none"],i,{theme:a,parts:["conflict.title"]}),"title");C.setAttribute("tabindex","-1"),f.append(it(),C),e==="replaced"&&B.size&&f.append(u("span",[`font:600 10.5px/1 ${ee}`,"letter-spacing:.12em","text-transform:uppercase","padding:3px 6px",`color:color-mix(in srgb, ${l.brass} 80%, ${l.ink})`,`background:${l["brass-soft"]}`],`${B.size} new`));let J=g("span",["all:initial","display:inline-flex","margin-left:auto"]),Fe=_(Qe(yt,{label:"Minimize",onClick:at,theme:a,parts:["close","conflict.close"]}),"minimize");if(Fe.title="Minimize to the bar. Nothing is accepted until you choose.",J.append(Fe),f.append(J),r.append(f),e==="recovered")return Bt(r),r;if(e==="refused"){if(r.append(E("Your edits here are safe and not saved yet; nothing will be overwritten until you choose. Their version is not on this page, so there is no list of edits to compare. Keep yours, which saves over theirs, or accept theirs, which reloads the page and drops your unsaved edits.")),n.length&&r.append(E(`${H(n.length,"earlier replaced edit")} ${n.length===1?"is":"are"} also held in this tab. Download my copy includes them.`)),R&&r.append(E("That did not save either. Your edits here are still here.")),z&&r.append(E("Something changed on the page after your first press, so nothing was dropped. Press Accept theirs again if you still want their version.")),b){let p=j(g("div",["all:initial","display:block","margin:0 16px 12px","padding:8px 10px",`background:color-mix(in srgb, ${I} 14%, transparent)`,`color:${l.ink}`,`font:13px/1.5 ${W}`]),["conflict.warning"]);p.append(g("b",["all:initial","font:inherit","font-weight:700","color:inherit"],"This drops your unsaved edits."),document.createTextNode(" Download your copy first if you might want them. Press again to confirm.")),r.append(p)}}else e==="upgraded"?r.append(E("Its layout and code changed with it, so this page stops here. Reload to see the new version.")):e==="failed"?r.append(E("Part of an update from elsewhere could not be applied, so this page may be missing some of it. Your edits here are safe. Download a copy of the page as you had it, or accept to keep the page as it is.")):r.append(E("The page is showing the other edit. This stays until you choose. You can also save a copy of the page as you had it."));let N=j(g("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","padding:0 16px 14px"]),["conflict.actions"]);if(e==="upgraded")return N.append(A("Reload","reload",{variant:"primary",onClick:()=>window.location.reload(),push:!0})),r.append(N),L=[],r;let ft=A(Ce?"Try again":K?"Downloaded":"Download my copy","download",{onClick:Yt});if(N.append(ft),e==="refused"){let p=A(h==="overwrite"?"Saving\u2026":R?"Try again":"Keep mine","keep",{onClick:Vt});p.setDisabled(h==="overwrite"),N.append(p,A(b?"Yes, drop my edits":"Accept theirs","accept",{variant:"primary",onClick:qt,push:!0}))}else{if(e==="replaced"){let p=M().hasPendingApply(),F=A(p?"Finishing the incoming edit\u2026":h==="revert"?"Putting back\u2026":"Revert to mine","revert",{onClick:Ft});F.setDisabled(p||h==="revert"),N.append(F)}N.append(A("Accept theirs","accept",{variant:"primary",onClick:Nt,push:!0}))}if(r.append(N),e==="replaced")if(Y)r.append(Et(t));else{let p=g("div",["all:initial","display:flex","align-items:center","gap:8px",`border-top:1px solid ${l.line}`,"padding:8px 10px 8px 16px",`color:${l.muted}`,`font:13px/1.5 ${W}`]),F=g("span",["all:initial","display:inline-flex","margin-left:auto"]);F.append(_(V("See the edits",{small:!0,onClick:lt,theme:a,parts:["conflict.button"],labelParts:["conflict.buttonLabel"]}),"list")),p.append(g("span",["all:initial","font:inherit","color:inherit"],H(t.length,"edit")),F),r.append(p)}L=n.map(p=>p.id);for(let p of t)ne.add(p.id);return r}function Et(e){let t=Le(["flex:1 1 auto","margin:0 16px 12px","min-height:0","overflow:auto",`background:${l.sunk}`,`border:1px solid ${l["line-2"]}`],{theme:a,parts:["conflict.well","conflict.list"]}),n=g("div",["all:initial","position:sticky","top:0","z-index:1","display:flex","align-items:center","gap:8px","padding:8px 12px",`background:${l.sunk}`,`border-bottom:1px solid ${l["line-2"]}`,`color:${l.muted}`,`font:600 10.5px/1 ${ee}`,"letter-spacing:.12em","text-transform:uppercase"]),o=g("span",["all:initial","display:inline-flex","margin-left:auto"]);return o.append(_(V("Hide",{small:!0,variant:"quiet",onClick:lt,theme:a,parts:["conflict.button"],labelParts:["conflict.buttonLabel"]}),"list")),n.append(g("span",["all:initial","font:inherit","color:inherit","letter-spacing:inherit","text-transform:inherit"],"Replaced edits"),o),t.append(n),e.forEach((i,s)=>t.append(Pt(i,s))),P=t,t}function Ne(e){let t=e.context?.label||e.name||(e.context?.kind==="entry"?"Entry":"Edit");return e.context?.field?`${t} \xB7 ${e.context.field}`:t}var St={"content-changed":"the page changed there","structure-changed":"the structure changed there","target-detached":"that part of the page is gone","duplicate-id":"another part of the page now has the same id",protected:"that region keeps its own history",unsupported:"this kind of step cannot be put back"},Lt=e=>St[e]||"the page changed there";function Rt(e,t){let n=Array.isArray(e)?e:[];for(let o of n){if(!o||o.kind!=="text"&&o.kind!=="value")continue;let i=t==="redo"?o.after:o.before;if(typeof i=="string"&&i)return{text:i,id:o.target?.id??null}}for(let o of n){if(!o||o.kind!=="add"&&o.kind!=="remove")continue;let i=Array.isArray(o.nodes)?o.nodes.find(s=>typeof s?.html=="string"&&s.html):null;if(i)return{text:He(i.html).replace(/\s+/g," ").trim(),id:o.parent?.id??null}}for(let o of n){if(!o)continue;let i=t==="redo"?o.after:o.before;if(typeof i=="string"&&i)return{text:i,id:o.target?.id??null}}return{text:"",id:null}}function Dt(e){if(e==null||typeof document>"u")return"";let t=window.CSS?.escape?window.CSS.escape(String(e)):String(e).replace(/["\\]/g,"\\$&"),n=null;try{n=document.querySelector(`[data-id="${t}"]`)}catch{return""}if(!n)return"";let o=n.matches?.("input, textarea, select")?n.value:null;return(typeof o=="string"?o:n.textContent??"").replace(/\s+/g," ").trim()}function zt(e){let t=e?.payload&&typeof e.payload=="object"?e.payload:{},n=String(e?.key??""),o={id:e?.id,revision:e?.revision,record:e,kind:e?.kind??"conflict"};if(n.startsWith("app:"))return{...o,name:typeof t.label=="string"&&t.label?t.label:n.slice(4),sentence:"",yours:typeof t.text=="string"?t.text:"",now:""};let i=t.direction==="redo"?"redo":"undo",f=((Array.isArray(t.context)?t.context:[]).find(J=>typeof J?.label=="string"&&J.label)??null)?.label||typeof t.label=="string"&&t.label||"Edit",C=Rt(t.steps,i);return{...o,name:f,sentence:`The ${i} of "${f}" was not applied because ${Lt(t.code)}.`,yours:C.text,now:C.id==null?"":Dt(C.id)}}function Mt(e){let t=_e();if(!e.record||typeof t?.reviewActionsFor!="function")return[];try{return(t.reviewActionsFor(e.record)||[]).filter(n=>n&&typeof n.run=="function"&&n.label)}catch{return[]}}var tt=e=>({before:"",hit:e,after:"",cutBefore:!1,cutAfter:!1});function nt(e){let t=u("div",["display:block","padding:8px 12px 10px"],void 0,{theme:a,parts:["conflict.row"],role:null}),n=u("div",["display:flex","align-items:center","gap:8px","font-size:12.5px","font-weight:600",`color:${l["ink-2"]}`,"margin-bottom:4px"],void 0,{theme:a,parts:["conflict.location"],role:null});if(n.append(u("span",[],Ne(e))),t.append(n),e.sentence&&t.append(u("div",["display:block","font-size:13px",`color:${l["ink-2"]}`],e.sentence)),e.yours){let i=u("div",["display:grid","grid-template-columns:44px 1fr","gap:3px 10px","align-items:start",`font:12.5px/1.5 ${ee}`,...e.sentence?["margin-top:4px"]:[]]);i.append(...ve("Yours",tt(e.yours),{mine:!0})),e.now&&i.append(...ve("Now",tt(e.now),{mine:!1})),t.append(i)}let o=g("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","margin-top:8px"]);return Mt(e).forEach((i,s)=>{let r=A(i.label,`run:${e.id}:${s}`,{onClick:()=>Wt(e,i,r)});o.append(r)}),o.append(A(we===e.id?"Copied":"Copy",`copy:${e.id}`,{onClick:()=>Kt(e)})),o.append(A("Dismiss",`dismiss:${e.id}`,{onClick:()=>st(e)})),t.append(o),t}function Bt(e){e.append(E($.length?"These copies were replaced before this page loaded. The page never puts them back on its own. Copy or download the ones you want; dismiss one when you no longer need it.":"These copies were kept because an undo could not be put back or the page set them aside. The page never puts them back on its own. Copy or download the ones you want; dismiss one when you no longer need it.")),ae&&e.append(E("That action did not run. The copy is still here."));let t=Le(["flex:1 1 auto","margin:0 16px 12px","min-height:0","overflow:auto",`background:${l.sunk}`,`border:1px solid ${l["line-2"]}`],{theme:a,parts:["conflict.well","conflict.list"]});for(let o of $)for(let i of o.conflicts)t.append(nt(i));for(let o of v)t.append(nt(o));P=t,e.append(t);let n=j(g("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","padding:0 16px 14px"]),["conflict.actions"]);($.some(o=>o.root)||v.length)&&n.append(A(K?"Downloaded":"Download my copy","download",{onClick:Ut})),e.append(n),L=[]}function ve(e,t,{mine:n}){let o=[u("span",[`color:${l.faint}`,`font-family:${W}`],e,{theme:a,parts:["conflict.valueLabel"],role:null})],i=u("span",["display:-webkit-box","-webkit-line-clamp:2","-webkit-box-orient:vertical","overflow:hidden","overflow-wrap:anywhere",...n?[`color:${l.ink}`]:[`color:${l.muted}`]],void 0,{theme:a,parts:[n?"conflict.mine":"conflict.theirs","conflict.value"],role:null}),s=(t.cutBefore?"\u2026":"")+t.before+t.hit+t.after+(t.cutAfter?"\u2026":"");i.title=s,t.before&&i.append(u("span",[`color:${l.faint}`],(t.cutBefore?"\u2026":"")+t.before,{theme:a,parts:["conflict.before"],role:null}));let r=u("span",n?[`background:color-mix(in srgb, ${I} 18%, transparent)`,"padding:0 4px"]:t.before||t.after?["text-decoration:underline",`text-decoration-color:color-mix(in srgb, ${I} 70%, transparent)`,"text-underline-offset:3px"]:[],t.hit||"(empty)",{theme:a,parts:["conflict.value"],role:null});return i.append(r),t.after&&i.append(u("span",[`color:${l.faint}`],t.after+(t.cutAfter?"\u2026":""),{theme:a,parts:["conflict.after"],role:null})),o.push(i),o}function Pt(e,t){let n=Ke(e),o=u("div",["display:block","padding:8px 12px 10px",...t?[`border-top:1px solid ${l.line}`]:[]],void 0,{theme:a,parts:["conflict.row"],role:null}),i=u("div",["display:flex","align-items:center","gap:4px","font-size:12.5px","font-weight:600",`color:${l["ink-2"]}`,"margin-bottom:4px"],void 0,{theme:a,parts:["conflict.location"],role:null});if(i.append(u("span",[],n.name)),n.target&&n.target.isConnected&&i.append(_(_t(n),`eye:${e.id}`)),o.append(i),n.sentence&&o.append(u("div",["display:block","font-size:13px",`color:${l["ink-2"]}`],n.sentence)),Q.has(e.id)&&o.append(u("div",["display:block","font-size:13px","margin-top:4px",`color:${I}`],Q.get(e.id))),n.yours){let s=u("div",["display:grid","grid-template-columns:44px 1fr","gap:3px 10px","align-items:start",`font:12.5px/1.5 ${ee}`,...n.sentence?["margin-top:4px"]:[]]);s.append(...ve("Yours",n.yours,{mine:!0})),n.now&&s.append(...ve("Now",n.now,{mine:!1})),o.append(s)}return o}function _t(e){let t=["all:initial","color-scheme:inherit","box-sizing:border-box","cursor:pointer","display:inline-grid","place-items:center","width:22px","height:20px",`color:${l.ink}`],n=g("button",t);n.type="button",n.innerHTML=qe.conflictEye,je(n.firstElementChild,16),n.setAttribute("aria-label",`Show ${e.name} on page`),n.title="Show on page";let o=["button","conflict.button"];de(n,a,o);let i=s=>{n.style.cssText="";let r=te(a)?[...t,...ce(a,o,{}),...s]:[...t,...s];for(let f of r){let C=f.indexOf(":");n.style.setProperty(f.slice(0,C),f.slice(C+1),"important")}};return n.addEventListener("pointerenter",()=>i([`background:color-mix(in srgb, ${I} 16%, transparent)`])),n.addEventListener("pointerleave",()=>i([])),n.addEventListener("focus",()=>i([`outline:2px solid ${l.brass}`,"outline-offset:1px"])),n.addEventListener("blur",()=>i([])),n.addEventListener("click",()=>It(e.target)),n}var S=null,be=null,ke=null;function $e(){clearTimeout(be),window.removeEventListener("scroll",oe,!0),window.removeEventListener("resize",oe),S?.remove(),S=null,ke=null}function oe(){if(!S||!ke)return;let e=ke.getBoundingClientRect();T(S,"left",`${e.left}px`),T(S,"top",`${e.top}px`),T(S,"width",`${e.width}px`),T(S,"height",`${e.height}px`)}function It(e){if($e(),!e||!e.isConnected)return;let n=!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches?"instant":"smooth",o=c?.getBoundingClientRect().top??0,i=c&&o>0?Math.max(0,window.innerHeight-o):0;if(!i)e.scrollIntoView?.({block:"center",behavior:n});else{e.scrollIntoView?.({block:"center",behavior:"instant"});let s=e.getBoundingClientRect(),r=window.innerHeight-i,f=s.height>r-24?s.top-12:s.top+s.height/2-r/2;window.scrollBy?.({top:f,behavior:n})}ke=e,S=j(g("div",["all:initial","color-scheme:inherit","position:fixed","pointer-events:none","z-index:2147483001",`outline:2px solid ${I}`,"outline-offset:3px",`background:color-mix(in srgb, ${I} 14%, transparent)`]),["conflict.previewRing"]),document.body.appendChild(S),oe(),window.addEventListener("scroll",oe,!0),window.addEventListener("resize",oe),be=setTimeout($e,2500)}function Ot(){O||(w="panel",D="title",y())}function at(){$e(),w="bar",x(),D="review",y()}function lt(){Y=!Y,Y&&B.clear(),y()}function Nt(){let e=M(),t=L.filter(n=>{let o=e?.get(n);return o&&!o.claimedBy});e&&t.length&&e.acknowledge(t,{reason:"accepted"}),w=Oe()?"bar":"hidden",D="review",d()}async function Ft(){let e=M();if(h||!e||e.hasPendingApply())return;let t=L.filter(r=>{let f=e.get(r);return f&&!f.claimedBy});if(!t.length)return;h="revert",y();let n=!0,o=r=>{n=!!c?.contains(r.target)};document.addEventListener("focus",o,!0);let i;try{let{revertConflicts:r}=await import("./c-3S5TNRZA.js");i=await r(t)}catch(r){console.error("[clay] Revert to mine did not finish",r),i={revertedIds:[],blockedIds:t,saveResult:null}}finally{document.removeEventListener("focus",o,!0)}h=null;for(let r of i.blockedIds)Q.set(r,M()?.get(r)?.kind==="json"?vt:xt);w=Oe()?"bar":"hidden",D=n?"review":null;let s=i.saveResult&&(i.saveResult.ok||i.saveResult.msg==="Save already in progress");i.revertedIds.length&&s?Ee(`Put back ${H(i.revertedIds.length,"change")}. Saving.`):y()}var Z=null;async function Yt(){let e=M(),t=m?e?.list()??[]:L.map(o=>e?.get(o)).filter(Boolean),n=await We(t,{refused:!!m});Ce=!n,K=n,clearTimeout(Z),n&&(Z=setTimeout(()=>{K=!1,d()},1200)),y()}async function U(){let e=null;if(De())try{e=await Je()}catch{e=null}let t=_e(),n=null;if(t)try{n=await t.kept()}catch{n=null}let o=!1;if(e?.ok?($=e.records,o=!0):!De()&&$.length&&($=[],o=!0),n?.ok){let i=(Array.isArray(n.records)?n.records:[]).filter(r=>r&&r.supported!==!1).map(zt);i.length===v.length&&i.every((r,f)=>r.id===v[f].id&&r.revision===v[f].revision)||(o=!0),v=i}else n&&v.length&&(v=[],o=!0);o&&d()}async function Ht(e){try{return await navigator.clipboard.writeText(e),!0}catch{}let t=document.createElement("textarea");t.value=e,t.setAttribute("clay",Se),t.style.setProperty("position","fixed","important"),t.style.setProperty("opacity","0","important"),document.body?.append(t),t.select();let n=!1;try{n=document.execCommand?.("copy")===!0}catch{}return t.remove(),n}async function Kt(e){let t=e.record?e.yours:`${Ne(e)}
|
|
2
|
+
|
|
3
|
+
Yours:
|
|
4
|
+
${e.yours}
|
|
5
|
+
|
|
6
|
+
Now:
|
|
7
|
+
${e.now}`;if(!await Ht(t)){Ee("Could not copy. Select the text instead.");return}we=e.id,clearTimeout(ye),ye=setTimeout(()=>{we=null,d()},1200),y()}async function Ut(){let e=$.find(o=>o.root),t=[];for(let o of $)for(let i of o.conflicts)t.push({id:i.id,kind:i.kind,name:Ne(i),yours:i.yours,now:i.now,sentence:i.sentence});for(let o of v)t.push({id:o.id,kind:o.kind,name:o.name,yours:o.yours,now:o.now,sentence:o.sentence});let n=await Ue({html:e?.root??null,edits:t});Ce=!n,K=n,clearTimeout(Z),n&&(Z=setTimeout(()=>{K=!1,d()},1200)),y()}async function st(e){let t;try{t=e.record?await _e()?.dismissKept(e.id,{revision:e.revision}):await et([e.id]),t||={ok:!1}}catch{t={ok:!1}}t.ok||Ee("That copy could not be dismissed."),await U(),d()}var ze=new Set;async function Wt(e,t,n=null){if(!ze.has(t)){ze.add(t),n&&(n.disabled=!0,n.setAttribute("aria-busy","true")),ae=!1;try{let o=null;try{o=await t.run(e.record)}catch{o=null}if(o?.ok===!0&&o?.dismiss===!0){await st(e);return}ae=o?.ok!==!0,await U(),d()}finally{ze.delete(t),n&&n.isConnected&&(n.disabled=!1,n.removeAttribute("aria-busy"))}}}function ct(e){e?.detail?.ok===!0&&(ae=!1,U(),d())}function x(){clearTimeout(fe),fe=null,b=null}async function Vt(){if(h)return;let e=++ge;h="overwrite",R=!1,x(),y();let t;try{t=await window.clay?.save?.overwrite?.()}catch{t={ok:!1}}e!==ge||h!=="overwrite"||(!t?.ok&&q()&&(h=null,R=!0),d())}function qt(){if(!b){b={refusalGeneration:Me,ledgerRevision:he,dirtyGeneration:Re().gen},Be=Date.now(),z=!1,clearTimeout(fe),fe=setTimeout(()=>{x(),d()},ht),y();return}if(Date.now()-Be<mt)return;let e=b;Xe({isCurrent:()=>b===e&&e.refusalGeneration===Me&&e.ledgerRevision===he&&e.dirtyGeneration===Re().gen,reload:()=>window.location.reload()})||(x(),z=!0,y())}function Ee(e){k=e,clearTimeout(X),X=setTimeout(()=>{k=null,d()},gt),y()}function Gt(){U(),d()}function dt(){he++,b&&x();for(let e of[...Q.keys()])M()?.get(e)||Q.delete(e);U(),d()}function pt(e){O=e?.detail&&e.detail.message||"This document was upgraded.",k=null,clearTimeout(X),x(),h=null,R=!1,z=!1,w="bar",d()}function ut(e){let t=e?.detail||{};m={generation:++Me,changedBy:t.changedBy,afterTimeout:!!t.afterTimeout,etag:t.etag??null},k=null,clearTimeout(X),x(),h=null,R=!1,ge++,z=!1,d()}function Pe(e){if(q()){e.type==="clay:save-saved"&&queueMicrotask(()=>{q()||Pe(e)});return}let t=h==="overwrite"&&e.type==="clay:save-saved";(m||h)&&(m=null,h=null,R=!1,z=!1,x()),t?Ee("Saved your version over theirs."):d()}function jt(){m&&(ie=!0,d())}function Qt(){!m||q()||(m=null,h=null,R=!1,z=!1,x(),d())}function Xt(e){if(e.key!=="Escape")return;if(b){e.preventDefault(),x(),y();return}if(w!=="panel")return;let t=document.activeElement;t&&t!==document.body&&!c?.contains(t)||(e.preventDefault(),at())}function Zt(e){!b||c?.contains(e.target)||(x(),d())}function Jt(e){k&&D&&!c?.contains(e.target)&&(D=null)}function en(){Ae=new AbortController;let{signal:e}=Ae;document.addEventListener("clay:document-upgraded",pt,{signal:e}),Ye&&(document.addEventListener("clay:sync-conflicts-changed",dt,{signal:e}),document.addEventListener("clay:unsaved-state-changed",d,{signal:e}),document.addEventListener("clay:save-conflict",ut,{signal:e}),document.addEventListener("clay:save-saved",Pe,{signal:e}),document.addEventListener("clay:save-conflict-resolved",Pe,{signal:e}),document.addEventListener("clay:sync-applied",jt,{signal:e}),document.addEventListener("clay:save-conflict-released",Qt,{signal:e}),document.addEventListener("keydown",Xt,{signal:e}),document.addEventListener("input",Zt,{capture:!0,signal:e}),document.addEventListener("focus",Jt,{capture:!0,signal:e}),document.addEventListener("clay:conflict-store-changed",Gt,{signal:e}),document.addEventListener("clay:undo-kept",ct,{signal:e}),M()?.size&&d(),U(),Promise.resolve(window.clay?.ready).catch(()=>{}).then(()=>{e.aborted||U()}))}var tn={"clay:sync-conflicts-changed":dt,"clay:save-conflict":ut,"clay:document-upgraded":pt,"clay:undo-kept":ct},Te=!1,Ae=null;function gn(e){Te||(Te=!0,en());let t=e&&tn[e.type];t&&t(e),m&&(ie=!0,d())}function mn(){Te&&(Te=!1,Ae?.abort(),Ae=null,x(),clearTimeout(X),X=null,clearTimeout(Z),Z=null,clearTimeout(ye),ye=null,clearTimeout(be),be=null,$e(),window.visualViewport?.removeEventListener("resize",le),window.visualViewport?.removeEventListener("scroll",le),c?.remove(),c=null,G=new Map,P=null,re=null,w="hidden",Y=!1,L=[],ne.clear(),B.clear(),Q.clear(),k=null,m=null,O=null,h=null,R=!1,ge++,b=null,Be=0,z=!1,$=[],v=[],ae=!1,ue=!1,ie=!1,D=null,me=null,K=!1,Ce=!1,we=null)}var wn={state:()=>({view:w,listOpen:Y,renderedIds:L.slice(),refused:m,armed:b,busy:h,ledgerRevision:he,upgraded:O}),render:y,resetUpgrade:()=>{O=null}};export{I as WARN,wn as _test,d as schedule,gn as start,mn as stop,Ee as toast};
|
|
@@ -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-3XGLJAS7.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Qt}from"./c-4ASQPRQL.js";import{a as Ot}from"./c-GQ6F6IDK.js";import{c as F}from"./c-I2SCCUEW.js";import{b as We}from"./c-5VYOWDTI.js";import{a as Vt,d as $,e as Ge,f as R,h as N}from"./c-P73XPAOA.js";import{a as Ke,b as Yt,c as jt,d as zt}from"./c-ZPI7M5U5.js";import{a as $t}from"./c-UGHH4MB3.js";import{a as kt}from"./c-MZCOGNZL.js";import{a as Rt,f as Ft,g as P,h as Ut,i as qt,j as Bt,m as Ht,u as Gt,w as Wt,x as Kt}from"./c-EHAR4RJJ.js";import{b as Nt,h as He}from"./c-PGSBXHUE.js";import{a as qe,c as It,g as bt,h as Be}from"./c-KU3PX7LL.js";import{a as be,f as Re,h as Q}from"./c-IJUK2GPW.js";import{b as K,e as Pt,f as A}from"./c-C7SUMNMI.js";import{k as Ct,m as Mt,o as xt}from"./c-U4TWEIKZ.js";import{E as Ue,h as Ne,r as Fe,u as Lt,y as V,z as me}from"./c-UW6MMZ4V.js";import{d as Dt}from"./c-MOP5KBWZ.js";import{a as pe}from"./c-2YYDMLNZ.js";import{d as Et,e as wt,g as At,h as Tt}from"./c-HA6INT6J.js";import{k as _t}from"./c-ICMAOOGK.js";var An="clay:debug:autosave";function ve(){try{return localStorage.getItem(An)==="true"}catch{return!1}}function ge(){return import("./c-CFHW5AMY.js").catch(e=>(console.warn("[autosave-debug] Failed to load the debug logger:",e),null))}function he(e,t){ve()&&ge().then(n=>n?.logSaveCheck(e,t))}function re(e,t=""){ve()&&ge().then(n=>n?.logBaseline(e,t))}function Xt(e,t){ve()&&ge().then(n=>n?.logUnloadDiffSync(e,t))}function Jt(){ve()&&ge().then(e=>e?.preloadIfEnabled())}var U=Number.NEGATIVE_INFINITY;function Tn({firstDirtyAt:e=U,lastActivityAt:t=U,finishedAt:n=U,costMs:o=0}={}){let r=e??U,i=t??U,a=n??U,f=Math.min(3e4,Math.max(1200,4*o)),u=Math.max(i,a)+1500,m=Math.max(r+1e4,a+f);return Math.max(a+1200,Math.min(u,m))}function Zt({now:e=()=>Date.now(),setTimer:t=(r,i)=>setTimeout(r,i),clearTimer:n=r=>clearTimeout(r),run:o=()=>{}}={}){let r=null,i=null,a=U,f=0,u=null,m=null,c=!1,p=!1;function S(){return Tn({firstDirtyAt:r,lastActivityAt:i,finishedAt:a,costMs:f})}function y(){if(!c||p)return;let E=S();if(u!==null){if(m===E)return;n(u)}m=E,u=t(d,Math.max(0,E-e()))}function d(){if(u=null,m=null,!(!c||p)){if(e()<S()){y();return}g()}}function g(){c=!1,p=!0,r=null,i=null;let E;try{E=o()}catch{l();return}Promise.resolve(E).then(l,l)}function l(){p=!1,a=e(),c&&y()}function s({at:E=e()}={}){r===null&&(r=E),i=E,c=!0,y()}function v(){c=!0,y()}function M(E){E>0&&(f=Math.max(E,f*.8))}return{noteActivity:s,request:v,noteCost:M,dueAt:S,costEstimate:()=>f,pending:()=>c||p,running:()=>p}}Fe(e=>{for(let t of Tt)e.removeAttribute(t)},{required:!0});Fe(e=>{for(let t of[...Et,...wt,...At])e.removeAttribute(t)},{required:!0});var x=null;function w(e,t="",n="",o=null){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus",e);let r=new CustomEvent(`clay:save-${e}`,{detail:{msg:t,msgType:n,timestamp:Date.now(),...o||{}}});document.dispatchEvent(r),Mn(e,r.detail)}var an=Symbol.for("clay.saveFailureClaimed"),Br=e=>{e?.detail&&(e.detail[an]=!0)},Ee=null,un=()=>(Ee??=import("./c-2EFMJYGJ.js").catch(e=>{throw Ee=null,e}),Ee),Cn=()=>{un().then(e=>e.warm(),()=>{})};for(let e of["beforeinput","keydown","pointerdown"])document.addEventListener(e,Cn,{once:!0,capture:!0});function Mn(e,t){if(e==="saved"){Ee?.then(n=>n.clearFailures(),()=>{});return}e!=="error"&&e!=="offline"||t?.[an]||un().then(n=>n.reportFailure(e),n=>{console.error("clayjs: a save failed and the notice for it could not be downloaded",n)})}function ot(){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus","offline")}function xn(){x=setTimeout(()=>{w("saving")},500)}window.addEventListener("offline",()=>{ot()});window.addEventListener("online",()=>{document.documentElement.getAttribute("savestatus")==="offline"&&I().then(e=>{e.msgType==="skipped"&&document.documentElement.getAttribute("savestatus")==="offline"&&document.documentElement.setAttribute("savestatus","saved")})});var q=!1,L="",C="",ie=0,we=new Set,D=!1,k=!1,Ae=!1,B=0,je=!1;function Pn(){B++}function ln(){B!==0&&(B--,!(B>0)&&(fe&&(fe=!1,Z=setTimeout(mt,0)),je&&(je=!1,Oe())))}function _n(){return B>0}var Y=0,ne=!1,ae=!1,Te=!1;function de(e=null){return Y===0||dn(e)}function st(){return ne}function Dn(){if(ne)return!0;try{let e=V({flushUndo:!1});return St(e)?!1:e!==C}catch{return!0}}function kn(){let e="idle",t=0;return{get phase(){return e},get open(){return e==="open"},changedWhileClosed(){return e==="quiesced"&&Ge()!==t},start(){e==="idle"&&(e="open")},quiesce(){e==="open"&&(e="quiesced",t=Ge(),Y++)},resume(){e==="quiesced"&&(e="open",Y--,!(Y>0)&&(zn(),on()))},stop(){if(e==="stopped")return;let n=e==="quiesced";(n||e==="open")&&Dn()&&(Te=!0),e="stopped",n&&(Y--,Y===0&&on())}}}var en=!1,oe=null,ze=null,Xe=!1;function Hr(e=b){if(!oe||oe.generation!==e)return null;let{bytes:t,etag:n}=oe;return{bytes:t,etag:n}}function Gr({represented:e}={}){let t=R(),{forComparison:n,forDirty:o}=me(),r=typeof e?.etag=="string"&&e.etag?e.etag:null;return!(Xe&&r!==null&&r!==ze)&&Te&&(n!==L||o!==C)?{ok:!1,code:"pending-input"}:(Te=!1,ue(n,o),W=n,ee=!1,vt=!0,ze=r,Xe=!0,N(t),document.documentElement.setAttribute("savestatus","saved"),document.dispatchEvent(new CustomEvent("clay:baseline-settled")),{ok:!0})}var it=Promise.resolve(!1),Ce=!1,Ln=()=>(Ce=!0,bt().catch(()=>!1).then(e=>(Ce=!1,e)));function Wr(){return{id:"clay:save",order:10,prepare(e={}){let t=kn();return e.initial===!0&&t.start(),{enable(){it=Ln();let n=e.represented?.etag;typeof n=="string"&&n&&It(n),e.initial!==!0&&(On(),t.start())},quiesce:()=>t.quiesce(),resume:()=>t.resume(),dispose:()=>t.stop()}}}}function On(){en||(en=!0,Vt(),be(),En(),wn())}var O=0,Je=!1,Me=!1,at="Waiting for the AI edit to be kept or reverted",j=new Map;function Kr(e=at){O++,j.set(e,(j.get(e)||0)+1)}function Qr({replay:e=!0,reason:t=at}={}){let n=j.get(t)||0;if(n===0||(n===1?j.delete(t):j.set(t,n-1),O--,O>0))return;let o=Je,r=Me;Je=!1,Me=!1,e&&(o?I():r&&Oe())}function Vr(){return O>0}function ut(){return O===0?null:j.keys().next().value||at}function fn(e,t){if(O===0)return!1;Je=!0,Q();let n=h(ut());return e(n),t(n),n}var H=!1,se=null;function In(e){se=e??null,!H&&(H=!0,Pn())}function bn(){H&&(H=!1,se=null,ln())}function Ze(){return H}function $r(e){if(!H||se&&e!==se)return;H=!1,se=null,!We()&&$()||(document.documentElement.getAttribute("savestatus")==="conflict"&&document.documentElement.setAttribute("savestatus","saved"),document.dispatchEvent(new CustomEvent("clay:save-conflict-resolved",{detail:{timestamp:Date.now()}}))),document.dispatchEvent(new CustomEvent("clay:save-conflict-released",{detail:{etag:e??null}})),ln()}function h(e){return{ok:!1,msg:e,msgType:"skipped",code:null,etag:null}}function lt(e){return($()||F())&&(ne=!0),h(e)}function cn(){return{ok:!1,msg:"You are not allowed to save this document.",msgType:"forbidden",code:"forbidden",status:403,sent:!1,etag:null}}function ft(){return Pt()===!1}var ct=new Set,b=0;function Yr(){return b}function jr(e){typeof e=="number"&&(b=e)}function Rn(e=b){let t=Object.freeze({generation:e});return ct.add(t),t}function Nn(e){ct.delete(e)}function dn(e){return!!e&&ct.has(e)&&e.generation===b}function z(e,t){e!=null&&zt({captureId:e,ok:t.ok===!0,etag:t.etag??null})}function Fn(e,t,n,o,r,i=null,a=null,f=!1){if(z(a,e),e.ok)ne=!1,ue(t,n),xe=i,oe={bytes:i,etag:qe(),generation:b},ze=oe.etag,Xe=!0,Te=!1,q=!1,N(r),w("saved",e.msg||"Saved",e.msgType,{etag:e.etag??null,captureId:a}),re(o,`${L.length} chars`),bn();else if(e.msgType==="conflict"){if(f){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus","saved");return}In(e.conflictEtag),w("conflict",e.msg,e.msgType,{hadTimeout:e.hadTimeout===!0,changedBy:e.changedBy??null,afterTimeout:e.afterTimeout===!0,etag:e.conflictEtag??null,code:e.code??null,reason:e.reason??null,retryAfter:e.retryAfter??null,captureId:a})}else if(e.msgType!=="skipped"){let u={status:e.status??null,hadTimeout:e.hadTimeout===!0,code:e.code??null,reason:e.reason??null,retryAfter:e.retryAfter??null,captureId:a};navigator.onLine?w("error",e.msg,e.msgType||"error",u):w("offline",e.msg,e.msgType||"error",u)}}function pn(){if(!(!D&&!k)&&!Ht()){if(D){D=!1,k=!1,I();return}k=!1,nt.request()}}function zr(){return q}function Xr(e){q=e}function Jr(){return L}function dt(){return C}var xe=null;function Zr(){return xe}function ue(e,t){L=e,C=t,ie++}function eo(e){ue(e,e)}var G=()=>typeof performance<"u"&&performance.now?performance.now():Date.now();var Un=4,tn="Save cancelled: the page changed while it prepared",X=null,le=null,Qe=null,mn=!1;function vn(){return Qe||(Qe=import("./c-DYTBSJBI.js").then(e=>(le=e,e),e=>(mn=!0,console.info("clayjs: sliced save off ("+(e&&e.message?e.message:e)+"); saves prepare in one task"),null))),Qe}function qn(){try{return performance.getEntriesByType("navigation")[0]?.decodedBodySize||0}catch{return 0}}var Bn=()=>typeof xe=="string"?xe.length:qn();function Pe(){return mn||document.hidden||Bt()?!1:Bn()>=307200}function nn(e,t,n){return n?"morph":b!==t.generation||!A?"mode":de(e.permit)?ft()?"refused":ie!==t.baselines?"newer save":Math.max(He(),e.blockeditorFormatFloor)>t.floor?"floor":null:"session"}function Hn(e=150,t=2e3){return new Promise(n=>{let o=G(),r=null,i=()=>{document.removeEventListener("clay:sync-applied",a),n()},a=()=>{clearTimeout(r),r=setTimeout(i,Math.max(0,Math.min(e,t-(G()-o))))};document.addEventListener("clay:sync-applied",a),a()})}async function pt({explicit:e,forced:t=!1,forSave:n,forComparison:o,forDirty:r,captureId:i,gateToken:a,costMs:f,blockeditorFormatFloor:u=0,quietConflict:m=!1,laneHeld:c=!1,lane:p=null,capture:S,noteRecovery:y,release:d,callback:g}){if(y(),e&&!t){if(q=r!==C,he("savePage dirty check",!q),!q){Q(),N(a),d();let s=h("No changes to save");return z(i,s),typeof g=="function"&&g(s),{result:s,dispatched:!1}}}else if(!e){let s=!ee||o!==W,v=o!==L;if(he("throttled vs baseline",!s),he("throttled vs lastSave",!v),!(s&&v)){let M=!1;try{M=!v&&(!document.querySelector(_t)||$()&&r===C)}catch(yt){console.error("savePageThrottled: dirty domain check failed",yt)}M&&N(a),nt.noteCost(f),d();let E=h("No changes to save");return z(i,E),typeof g=="function"&&g(E),{result:E,dispatched:!1}}if(q=!0,!c&&P()){D=!0,d();let M=h("Save already in progress");return z(i,M),typeof g=="function"&&g(M),{result:M,dispatched:!1}}}xn();let l={forComparison:o,forDirty:r};return we.add(l),Ae=!0,new Promise(s=>{Gt(n,i,v=>{Ae=!1,we.delete(l);let M=G();Fn(v,l.forComparison,l.forDirty,t?"updated after force save":"updated after save",a,n,i,m),e||nt.noteCost(f+(G()-M)),typeof g=="function"&&g(v),s({result:v,dispatched:!0}),c||pn()},{capture:S,blockeditorFormatFloor:u,lane:p,gateToken:a})})}async function Gn(e,t){let n={over:!1},o=()=>{n.over=!0};document.addEventListener("clay:sync-applied",o);try{for(let i=0;i<2;i++){let a=R(),f={generation:b,baselines:ie,floor:Math.max(He(),e.blockeditorFormatFloor)},u=le.beginSaveCapture({requestRefresh:!0,forRequest:!0,pageFormatMarker:f.floor?{name:Nt,content:String(f.floor)}:null});Yt(u.captureId);let m=null,c={get aborted(){let d=nn(e,f,n.over);return d&&(m=d),!!d}},p;try{p=await le.runPreparedSteps(u.steps(),{budgetMs:Un,signal:c})}catch(d){console.error(`${e.explicit?"savePage":"savePageThrottled"}: preparing the save failed`,d),u.drop();let g={msg:d&&d.message?d.message:"Save failed",msgType:"error",code:d?.code??null,etag:null};return w("error",g.msg,"",{sent:!1,code:g.code}),z(u.captureId,g),typeof e.callback=="function"&&e.callback(g),{result:g,dispatched:!1}}let S=p.aborted?m:nn(e,f,n.over);if(!S){let d=p.result;return await pt({explicit:e.explicit,forced:e.forced,forSave:d.forSave,forComparison:d.forComparison,forDirty:d.forDirty,captureId:d.captureId,gateToken:a,costMs:p.activeMs,blockeditorFormatFloor:e.blockeditorFormatFloor,quietConflict:e.quietConflict,laneHeld:!0,lane:t,capture:d,noteRecovery:()=>jt(d.captureId,d.forSave),release:()=>u.drop(),callback:e.callback})}u.drop();let y=h(tn);if(S==="session"&&(ae=!0),z(u.captureId,y),!(S==="floor"&&i===0)){if(S==="morph"&&e.explicit&&i===0){await Hn(),n.over=!1;continue}return typeof e.callback=="function"&&e.callback(y),{result:y,dispatched:!1}}}let r=h(tn);return typeof e.callback=="function"&&e.callback(r),{result:r,dispatched:!1}}finally{document.removeEventListener("clay:sync-applied",o),qt(t)}}function gn(e){let t=Ut();if(!t)return!1;let n=Gn(e,t).catch(o=>{console.error("save: preparing the save failed",o);let r={msg:o&&o.message?o.message:"Save failed",msgType:"error",code:o?.code??null,etag:null};return w("error",r.msg,"",{sent:!1,code:r.code}),typeof e.callback=="function"&&e.callback(r),{result:r,dispatched:!1}});return X=n,n.then(o=>{X===n&&(X=null),e.resolve(o.result),e.settleSoonQueued(o.result),(o.dispatched||D||k||ke.length)&&pn()}),!0}function Le(e,t=()=>{}){return Ce?it.then(()=>Le(e,t)):te?ce.then(()=>De(e,t)):De(e,t)}function _e(e,t){let n=!1,o=setTimeout(()=>{n=!0,w("saving")},500);return e.then(()=>(clearTimeout(o),t())).then(r=>(n&&!P()&&!$()&&document.documentElement.getAttribute("savestatus")==="saving"&&(document.documentElement.setAttribute("savestatus","saved"),document.dispatchEvent(new CustomEvent("clay:save-status",{detail:{state:"saved"}}))),r))}function De({kind:e,permit:t=null},n=()=>{}){let o=e==="explicit";return new Promise(r=>{if(!A&&!window.clay?.testMode){o&&Q();let s=h("Not in edit mode");return T().forEach(v=>v(s)),n(s),r(s)}if(!de(t)){ae=!0;let s=lt("Save session is quiesced");return o&&T().forEach(v=>v(s)),n(s),r(s)}if(ft()){o&&Q();let s=cn();return w("error",s.msg,"",{code:s.code,status:s.status,sent:!1}),T().forEach(v=>v(s)),n(s),r(s)}if(o){let s=fn(n,r);if(s){T().forEach(v=>v(s));return}if(P()){D=!0;let v=h("Save already in progress");return n(v),r(v)}}else{if(O>0){Me=!0;let s=h(ut());return n(s),r(s)}if(P()&&!ee&&Ae){k=!0;let s=h("Save already in progress");return n(s),r(s)}if(X){k=!0;let s=h("Save already in progress");return n(s),r(s)}if(!ee&&!$()){let s=h("No changes to save");return n(s),r(s)}}let i=window.clay?.source?.ensureForSave?.();if(i)return r(_e(i,()=>De({kind:e,permit:t},n)));if(Pe()&&!le){r(_e(vn(),()=>De({kind:e,permit:t},n)));return}let a=o?T():[],f=s=>a.forEach(v=>v(s));if(!navigator.onLine&&ot(),Pe()&&gn({explicit:o,forced:!1,permit:t,blockeditorFormatFloor:0,quietConflict:!1,settleSoonQueued:f,callback:n,resolve:r}))return;let m=G(),c,p,S,y,d,g=R();try{c=Ue({requestRefresh:!0,forRequest:!0}),{forSave:p,forComparison:S,forDirty:y,captureId:d}=c}catch(s){console.error(`${o?"savePage":"savePageThrottled"}: captureForSaveAndComparison failed`,s),o?(Q(),w("error",s.message,"error",{sent:!1,code:s.code??null})):w("error",s.message,"error");let v={ok:!1,msg:s.message,msgType:"error",code:o?s.code??null:null,etag:null};typeof n=="function"&&n(v),r(v),f(v);return}let l=G()-m;pt({explicit:o,forSave:p,forComparison:S,forDirty:y,captureId:d,gateToken:g,costMs:l,capture:c,noteRecovery:()=>Ke({captureId:d,html:p}),release:()=>Ne(c),callback:n}).then(s=>{r(s.result),f(s.result)})})}function I(e=()=>{}){return Le({kind:"explicit"},e)}function Wn(e,t=()=>{}){return Le({kind:"explicit",permit:e},t)}function J(e=()=>{},{quietConflict:t=!1,blockeditorFormatFloor:n=0,permit:o=null}={}){return Ce?it.then(()=>J(e,{quietConflict:t,blockeditorFormatFloor:n,permit:o})):new Promise(r=>{if(!A&&!window.clay?.testMode){let l=h("Not in edit mode");return T().forEach(s=>s(l)),e(l),r(l)}if(!de(o)||o&&!dn(o)){let l=lt("Save session is quiesced");return T().forEach(s=>s(l)),e(l),r(l)}if(ft()){let l=cn();return w("error",l.msg,"",{code:l.code,status:l.status,sent:!1}),T().forEach(s=>s(l)),e(l),r(l)}let i=fn(e,r);if(i){T().forEach(l=>l(i));return}if(P()){D=!0;let l=h("Save already in progress");return T().forEach(s=>s(l)),e(l),r(l)}let a=window.clay?.source?.ensureForSave?.();if(a)return r(_e(a,()=>J(e,{quietConflict:t,blockeditorFormatFloor:n,permit:o})));if(!navigator.onLine&&ot(),Pe()&&!le){r(_e(vn(),()=>J(e,{quietConflict:t,blockeditorFormatFloor:n,permit:o})));return}let u=T(),m=l=>u.forEach(s=>s(l));if(Pe()&&gn({explicit:!0,forced:!0,permit:o,blockeditorFormatFloor:n,quietConflict:t,settleSoonQueued:m,callback:e,resolve:r}))return;let c,p,S,y,d,g=R();try{c=Ue({requestRefresh:!0,forRequest:!0}),{forSave:p,forComparison:S,forDirty:y,captureId:d}=c}catch(l){console.error("savePageForce: captureForSaveAndComparison failed",l),w("error",l.message,"error",{sent:!1,code:l.code??null});let s={ok:!1,msg:l.message,msgType:"error",code:l.code??null,etag:null};typeof e=="function"&&e(s),r(s),m(s);return}pt({explicit:!0,forced:!0,forSave:p,forComparison:S,forDirty:y,captureId:d,gateToken:g,costMs:0,blockeditorFormatFloor:n,quietConflict:t,capture:c,noteRecovery:()=>Ke({captureId:d,html:p}),release:()=>Ne(c),callback:e}).then(l=>{r(l.result),m(l.result)})})}Kt(e=>J(()=>{},{permit:e}));function Kn(e){let t=["clay:save-saved","clay:save-error","clay:save-offline","clay:save-conflict"];return new Promise((n,o)=>{let r=null,i=()=>{clearTimeout(r);for(let u of t)document.removeEventListener(u,a)},a=()=>{i(),n()},f=e-Date.now();if(f<=0){o(Object.assign(new Error("Save timed out."),{state:"failed"}));return}r=setTimeout(()=>{i(),o(Object.assign(new Error("Save timed out."),{state:"failed"}))},f);for(let u of t)document.addEventListener(u,a)})}function _(e,t){return Object.assign(new Error(e),{state:t})}function Qn(e,t){return new Promise((n,o)=>{let r=t-Date.now();if(r<=0)return o(_("Save timed out.","failed"));let i=setTimeout(()=>{document.removeEventListener(e,a),o(_("Save timed out.","failed"))},r),a=()=>{clearTimeout(i),n()};document.addEventListener(e,a,{once:!0})})}async function to({keepalive:e=!1,timeoutMs:t=15e3,permit:n=null}={}){if(!A)return{state:"view",etag:null};let o=Date.now()+t,r=n||Rn(),i={over:!1},a=null,f=new Promise((u,m)=>{a=setTimeout(()=>m(Object.assign(_("Save timed out.","failed"),{timedOut:!0})),Math.max(0,t))});try{return await Promise.race([Vn(e,o,r,i),f])}catch(u){throw u&&typeof u.state=="string"?u:_(u?.message||"Save failed","failed")}finally{i.over=!0,clearTimeout(a),n||Nn(r)}}async function Vn(e,t,n,o={over:!1}){if(hn()||await Qn("clay:baseline-settled",t),o.over)return null;let r=!1,i=null;for(let a=0;a<4;a++){if(X&&(await X,o.over)||P()&&(await Kn(t),o.over))return null;if(Ze())throw _("This document has a conflict to resolve.","conflict");let f=R();if(!rt()){if(N(f),F())throw _("This document has unsaved work a save cannot write.","blocked");return ne=!1,{state:r?"saved":"clean",etag:i??qe()}}if(o.over)return null;let u=await Ft(e,()=>Wn(n));if(u.msgType!=="skipped"){if(!u.ok)throw _(u.msg||"Save failed",u.msgType==="conflict"||Ze()?"conflict":"failed");r=!0,i=u.etag??null}}throw _("The document kept changing while saving.","failed")}async function no(e=()=>{}){return await Be({fresh:!0}),J(e)}function ro(e){!A||K||Wt(e,t=>{t.ok?window.location.reload():t.msgType==="skipped"?w("error",t.msg||"Template not saved"):w("error",t.msg||"Failed to save template")})}var $n=Ot(e=>Le({kind:"automatic"},e),1200),Yn=250,jn=1e3,Z=null,rn=0,et=[],ke=[],fe=!1,T=()=>{let e=ke;return ke=[],e};function mt(){if(Z=null,B>0||!de()){fe=!0;return}let e=et;if(et=[],P()){ke.push(...e),I();return}I().then(t=>e.forEach(n=>n(t)))}function oo(){let e=Date.now();return Z===null?rn=e:clearTimeout(Z),new Promise(t=>{et.push(t),Z=setTimeout(mt,Math.max(0,Math.min(Yn,rn+jn-e)))})}function zn(){ae&&(ae=!1,Oe())}function on(){fe&&(fe=!1,Z=setTimeout(mt,0))}var W="",ee=!0,vt=!1;function hn(){return vt}var Ve=!1,Xn=250,Jn=1250,$e=null,Sn="clay:paint-heal:"+location.pathname;function yn(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)|0;return String(t>>>0)}function Zn(e){try{return localStorage.getItem(Sn)===yn(e)}catch{return!1}}function er(e){try{localStorage.setItem(Sn,yn(e))}catch{}}function tr(){return Dt(Lt({flushUndo:!1}))}function so(e){!A||K||(clearTimeout($e),$e=setTimeout(async()=>{$e=null,te&&await ce;let t=typeof e=="function"?e():e;t==null||!We()||!hn()||Ze()||_n()||V({flushUndo:!1})===C&&t!==tr()&&(Zn(t)||(er(t),J(()=>{},{quietConflict:!0})))},Xn+Math.random()*Jn))}var Se=null,Ye=null,te=0,ce=Promise.resolve(),gt=!1,ht=[];function nr(){return Ye??=import("./c-KNPDOMDY.js").catch(e=>(Ye=null,console.error("style-comparisons failed to load",e),null)),Ye}async function rr(e){try{if(Se||(Se=(await nr())?.styleComparisonStripper??null),!Se)return;let t=Se(e);L=t(L),C=t(C),W=t(W);for(let n of we)n.forComparison=t(n.forComparison),n.forDirty=t(n.forDirty)}catch(t){console.error("style adoption failed",t)}finally{te--,ht.shift()}}var ye=e=>e.replace(/&/g,"&").replace(/"/g,""");function or(e){if(e.name!==void 0){let n=[`data-name="${ye(e.name)}"`];return e.legacyId!==void 0&&n.push(`id="${ye(e.legacyId)}"`),n}let t=[ye(e.href)];try{let{pathname:n}=new URL(e.href);n&&t.push(ye(n))}catch{}return t}function sr(e){let t=[L,C,W];for(let n of we)t.push(n.forComparison,n.forDirty);return t.some(n=>n&&e.some(o=>o&&n.includes(o)))}function ir(e,t){let n=[];for(let{markers:i,tag:a}of t)for(let f of i)for(let u=e.indexOf(f);u>=0;u=e.indexOf(f,u+f.length)){let m=e.lastIndexOf("<",u);if(m<0||e.slice(m+1,m+1+a.length).toLowerCase()!==a)continue;let c=a==="style"?e.indexOf("</style",u):u;if(c<0)continue;let p=e.indexOf(">",c);p>=0&&n.push([m,p+1])}n.sort((i,a)=>i[0]-a[0]);let o="",r=0;for(let[i,a]of n)i<r||(o+=e.slice(r,i),r=a);return o+e.slice(r)}$t(e=>{let t=or(e);sr(t)&&(te||(gt=!1),te++,ht.push({markers:t,tag:e.name!==void 0?"style":"link"}),ce=ce.then(()=>rr(e)))});function io(){return ce}function St(e){return!te||gt||F()||P()||D||k||ne||typeof e!="string"?!1:e===ir(C,ht)}var ar=500,ur=3e3,lr=1e4,tt=null;function fr(){pe.holdSettle=!1,tt&&tt()}function sn(){if(!A)return;let e=!1,t=null,{forComparison:n,forDirty:o}=me();ue(n,o);let r=ie;W=n,re("immediate capture",`${n.length} chars`);let i=["keydown","pointerdown","drop","input","change","paste"],a=new Set(["Shift","Control","Alt","Meta"]),f=c=>{c.type==="keydown"&&a.has(c.key)||(gt=!0,e||(Ve=!0))};i.forEach(c=>document.addEventListener(c,f,!0));let u=()=>{if(!e){if(e=!0,t&&t(),!Ve&&ie===r){let c=R(),{forComparison:p,forDirty:S}=me();ue(p,S),W=p,N(c),re("settled capture",`${p.length} chars`)}else re("settled skipped",Ve?"user edited":"save occurred during settle");ee=!1,document.documentElement.setAttribute("savestatus","saved"),vt=!0,document.dispatchEvent(new CustomEvent("clay:baseline-settled"))}};tt=u;let m=()=>{pe.holdSettle||u()};t=kt.onAnyChange({debounce:ar,omitChangeDetails:!0,require:"autosave"},m),setTimeout(()=>{e||m()},ur),setTimeout(()=>{!e&&pe.holdSettle&&fr()},lr)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",sn):sn();function Oe(e=()=>{}){if(!A){let t=h("Not in edit mode");return e(t),Promise.resolve(t)}if(O>0){Me=!0;let t=h(ut());return e(t),Promise.resolve(t)}if(!de()){ae=!0;let t=lt("Save session is quiesced");return e(t),Promise.resolve(t)}if(B>0){je=!0;let t=h("Autosave suspended");return e(t),Promise.resolve(t)}if(!ee&&Ae){k=!0;let t=h("Save already in progress");return e(t),Promise.resolve(t)}return $n(e).catch(t=>{let n={ok:!1,msg:t?.message||"Save failed",msgType:"error",code:null,etag:null};return w("error",n.msg),n})}var nt=Zt({now:G,run:()=>Oe()});function En(){document.addEventListener("keydown",function(e){if((window.navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)&&e.keyCode==83){if(!A)return;e.preventDefault(),e.isTrusted&&Re(),I()}})}function wn(){document.addEventListener("click",e=>{e.target.closest("[trigger-save]")&&(e.isTrusted&&Re(),I())})}function cr(){A&&(Be(),Rt(),be(),En(),wn())}cr();var ao=I;var Ie=!1;function go({isCurrent:e,reload:t}){return e()?(Ie=!0,setTimeout(()=>{Ie=!1},1e3),t(),!0):!1}Jt();function dr(){return st()?!0:A?F()?!0:K?Mt()||xt():window.clay?.demo?!1:rt():!1}function rt(){if(!A)return!1;try{let e=V();return St(e)?!1:e!==dt()}catch{return!0}}window.addEventListener("beforeunload",e=>{if(!A&&!st())return;if(Ie){Ie=!1;return}if(!((!K||Ct())&&!dr())&&(e.preventDefault(),e.returnValue="",!window.clay?.demo&&!F()))try{let n=V(),o=dt();n!==o&&Xt(n,o)}catch{}});export{go as a,dr as b,rt as c,Br as d,Pn as e,ln as f,_n as g,de as h,st as i,kn as j,Hr as k,Gr as l,Wr as m,Kr as n,Qr as o,Vr as p,ut as q,Ze as r,$r as s,Yr as t,jr as u,Rn as v,Nn as w,zr as x,Xr as y,Jr as z,dt as A,Zr as B,ue as C,eo as D,I as E,J as F,to as G,no as H,ro as I,oo as J,hn as K,tr as L,so as M,io as N,St as O,fr as P,Oe as Q,nt as R,En as S,wn as T,cr as U,ao as V};
|
|
@@ -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-
|
|
1
|
+
import{A as ee,D as oe,G as te,H as re,I as ne,i as J}from"./c-RBWVF4N5.js";import"./c-6BGJAJ67.js";import"./c-MMV5JULA.js";import"./c-MVVEIJUU.js";import{a as X}from"./c-Y3J5LDKB.js";import"./c-PZ4XEPUP.js";import"./c-JRKY44DK.js";import"./c-LAKBBJOU.js";import"./c-EIUKME3W.js";import"./c-ND3W7D5U.js";import"./c-WHQUZM2V.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-UW6MMZ4V.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"./c-7WZSUTYP.js";import{b as s,d as n,f as l,h as m}from"./c-PGSBXHUE.js";import{f as i}from"./c-EQ5NBOGA.js";import"./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 p="blockeditor-format-activation-failed";function u(){let e=document.querySelector(`meta[name="${s}"]`);return e?l(e.outerHTML):0}var F=async e=>(await import("./core/save-
|
|
1
|
+
import"./c-7WZSUTYP.js";import{b as s,d as n,f as l,h as m}from"./c-PGSBXHUE.js";import{f as i}from"./c-EQ5NBOGA.js";import"./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 p="blockeditor-format-activation-failed";function u(){let e=document.querySelector(`meta[name="${s}"]`);return e?l(e.outerHTML):0}var F=async e=>(await import("./core/save-JZ7R4ET2.js")).savePageForce(()=>{},e),P=4,f=1e4,w=e=>e?.ok===!1&&e?.msgType==="skipped"&&/in progress/i.test(e?.msg??""),A=async()=>{let{isSaveInProgress:e}=await import("./core/save-core-I4N6S4ED.js"),a=Date.now()+f;for(;e()&&Date.now()<a;)await new Promise(c=>setTimeout(c,50))};function k({save:e=F,settles:a=A,supported:c=()=>i().then(o=>o===1)}={}){return{read(){return{floor:Math.max(m(),u()),revision:null}},capabilities(){return[]},supported:c,async activate({floor:o=1}={}){let t;try{t=await e({blockeditorFormatFloor:o});for(let r=1;r<P&&w(t);r+=1)await a(),t=await e({blockeditorFormatFloor:o})}catch(r){return{accepted:!1,code:r?.code??p}}return t?.ok?{accepted:!0,revision:null,receipt:t.receipt??t.etag??null}:t?.code===n?{accepted:!1,code:n}:{accepted:!1,code:t?.code??p}}}}export{k as createFormatHost};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A,B,C,D,E,F,G,H,I,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./c-
|
|
1
|
+
import{A,B,C,D,E,F,G,H,I,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./c-RBWVF4N5.js";import"./c-6BGJAJ67.js";import"./c-MMV5JULA.js";import"./c-MVVEIJUU.js";import"./c-JRKY44DK.js";import"./c-LAKBBJOU.js";import"./c-EIUKME3W.js";import"./c-ND3W7D5U.js";import"./c-WHQUZM2V.js";import"./c-OH2FPYSY.js";import"./c-RETTCOWO.js";import"./c-57XDY6HC.js";import"./c-I2SCCUEW.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{c as COMPACT_BATCHES,d as COMPACT_BYTES,y as COPY_CHANNEL,z as COPY_VERSION,E as IME_CHANNEL,F as IME_VERSION,a as PAGE_CHANNEL,b as PAGE_CHANNEL_VERSION,f as PageReplayError,g as accumulateCapsule,j as admitCapsule,l as applyCapsule,k as capsulesOf,C as copyState,x as coversText,r as createPageJournal,w as describeReview,I as imeEntries,p as journalBase,B as markerFor,e as mergePageUpdates,H as openImeShadow,s as openPageJournal,o as pageAuthority,q as pageChannel,A as pageCopyChannel,G as pageImeChannel,n as pageJournalContext,i as reconstructPage,v as reconstructText,D as recoverAsCopy,u as replayInto,m as replayJournals,h as replayPageValue,t as watchJournal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{G as x,c as b,r as f,t as m,v as h,w as k}from"./c-
|
|
1
|
+
import{G as x,c as b,r as f,t as m,v as h,w as k}from"./c-FC5RUFPR.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import{b as c,d as S}from"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-P73XPAOA.js";import"./c-ZPI7M5U5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-MZCOGNZL.js";import{m as s,p as D,q as y,r as E}from"./c-EHAR4RJJ.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./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-UW6MMZ4V.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 O=15e3,M=Symbol("the barrier deadline passed"),A=2,e=(i,r={})=>({ok:!1,code:i,...r});async function I(i,r){let u=null,l=new Promise(a=>{u=setTimeout(()=>a(M),Math.max(0,r-Date.now()))});try{return await Promise.race([Promise.resolve(i),l])}finally{clearTimeout(u)}}async function _({generation:i=m(),keepalive:r=!1,timeoutMs:u=O,operation:l=null}={}){let a=l?null:D("mode");if(!l&&!a)return e("busy");let n=Date.now()+u,d=h(i),g=new AbortController;try{for(let w=0;;w++){if(i!==m())return e("stale-document");if(Date.now()>=n)return e("timeout");let P={permit:d,deadline:n,keepalive:r,signal:g.signal,timeoutMs:Math.max(0,n-Date.now())},t=await I(S(P),n);if(t===M)return e("timeout",{pending:c()});if(!t.ok)return f()?e("conflict",{pending:t.pending}):s()?e("save-unknown",{pending:t.pending}):e("pending-input",{pending:t.pending});if(t.pending.length)return e("pending-input",{pending:t.pending});if(f())return e("conflict");if(s())return e("save-unknown");let o;try{o=await x({keepalive:r,timeoutMs:Math.max(0,n-Date.now()),permit:d})}catch(p){return p?.state==="conflict"?e("conflict"):p?.state==="blocked"?e("pending-input",{pending:c()}):s()?e("save-unknown"):p?.timedOut||Date.now()>=n?e("timeout"):e("save-failed")}if(o.state!=="clean"&&o.state!=="saved")return e("save-failed");if(f())return e("conflict");if(s())return e("save-unknown");let v=c();if(v.length)return e("pending-input",{pending:v});if(b()){if(w+1<A&&Date.now()<n)continue;return e("pending-input")}return{ok:!0,state:o.state,etag:o.etag??null}}}finally{g.abort(),k(d),a&&y(a)}}export{D as claimOperation,E as operationKind,y as releaseOperation,_ as runSaveBarrier};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as E,d as A,e as M,f as I}from"./c-
|
|
1
|
+
import{b as E,d as A,e as M,f as I}from"./c-MMV5JULA.js";import"./c-MVVEIJUU.js";import"./c-LAKBBJOU.js";import"./c-EIUKME3W.js";import"./c-ND3W7D5U.js";import"./c-WHQUZM2V.js";import{C as B}from"./c-3XGLJAS7.js";import{E as m,fa as S,ia as L,ja as O,la as Y,ma as x}from"./c-OH2FPYSY.js";import"./c-RETTCOWO.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var Q="This element holds blocks from a document editor. Reply with the same outer div. Inside it use p, h1, h2, h3, ul, ol, li, blockquote, pre with code, details with summary, hr, table with thead, tbody, tr, th, td, and the inline tags strong, em, s, u, code, a. You may also keep any tag already in the element. Keep each data-id on the block it belongs to, and give a new block no data-id. An hr with data-clay-keep stands for something you cannot see: keep it where it belongs unless the request says to remove it. Keep each checkbox on a list item unless the request says to remove it. No classes, no style attributes, no scripts.",U=new Set(["image","file","chart","board","toc","tool","preserved"]),$=new Set(["paragraph","heading","list_item","quote","callout","code_block","toggle","divider","table"]),p=(r,t)=>({status:"refused",code:r,message:t}),H=({id:r,parent:t,...i})=>({...i,parent:t??null}),F=(r,t)=>S(H(r))===S(H(t)),K=()=>globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,P=["owner","due","pageIcon","pageCoverSrc","pageCoverAlt","pageCoverX","pageCoverY"],G=(r,t)=>{let i={...t};for(let d of P)(i[d]===void 0||i[d]===null)&&r[d]!==void 0&&(i[d]=r[d]);return i},V=(r,t)=>{let i=new Set(r.cols.map(o=>o.id).filter(Boolean)),d=r.cols.map((o,l)=>{if(o.id)return o;let n=t.cols[l];return!n?.id||i.has(n.id)?o:(i.add(n.id),{...o,id:n.id})}).map(o=>{let l=o.id?t.cols.find(h=>h.id===o.id):null;if(!l)return o;let n={...o};return n.kind===void 0&&l.kind!==void 0&&(n.kind=l.kind),n.width===void 0&&l.width!==void 0&&(n.width=l.width),n});return{...r,cols:d}};function Z(r,t,{dom:i=document}={}){let d=m(r);if(t.some(s=>d[s]?.t==="opaque_block"))return p("opaque","This area holds a block this editor cannot rewrite.");let o=I(A(d),i),l=new Set(t),n=o.filter(s=>l.has(s.id));if(n.length!==t.length)return p("not-found","Some of these blocks are no longer in the document.");let h=new Map,a=new Map,g=n.map(s=>{let w=d[s.id]?.t??s.t;return U.has(w)?(h.set(s.id,s),a.set(s.id,w),{id:s.id,t:"divider",parent:s.parent}):s});if(n.every(s=>h.has(s.id)))return p("no-text","This area holds nothing that can be rewritten.");let b=i.createElement("template");b.innerHTML=O(g,{clean:L(i)});for(let s of b.content.querySelectorAll("hr[data-id]")){let w=s.getAttribute("data-id");h.has(w)&&s.setAttribute("data-clay-keep",a.get(w))}let f=o.indexOf(n[0]),y=o.indexOf(n[n.length-1]);return y-f+1!==n.length?p("not-found","These blocks are not next to each other."):{status:"ok",capture:{ids:n.map(s=>s.id),blocks:d,baseItems:o,before:o.slice(0,f),span:n,after:o.slice(y+1),parent:n[0].parent??null,held:h,html:`<div data-clay-area>${b.innerHTML}</div>`}}}function N(r,t,i=document){let d=I(A(m(r)),i),o=new Map(d.map(a=>[a.id,a])),l=t.span.filter(a=>!o.has(a.id)||!F(a,o.get(a.id))).map(a=>a.id);if(l.length)return l;let n=d.findIndex(a=>a.id===t.ids[0]);return t.ids.every((a,g)=>d[n+g]?.id===a)?[]:[...t.ids]}function ee(r,t,i,{seed:d="",dom:o=document}={}){if(N(r.doc,t,o).length)return p("stale","These blocks changed while AI was working, so nothing was changed.");let n=o.createElement("template");n.innerHTML=i??"";let h=[...n.content.children],a=h.length===1?h[0]:null,g=a&&a.tagName==="DIV"&&(a.hasAttribute("data-clay-area")||!a.hasAttribute("data-id"))?a:null,b=o.createElement("article");b.append(...g?g.childNodes:n.content.childNodes);let f=Y(b);if(!f.length)return p("empty","AI did not write any blocks. Try again.");let y=new Set(t.ids);if(f=f.map(e=>e.id&&!y.has(e.id)?{...e,id:null}:e),f.some(e=>!(e.id&&t.held.has(e.id))&&!$.has(e.t)))return p("active","AI used formatting this editor cannot put in a document. Try again.");let s=new Map(t.span.map(e=>[e.id,e])),w=new Set(f.map(e=>e.id).filter(Boolean)),v=0,q=f.map(e=>{if(e.id){let R=t.ids.indexOf(e.id);return R>=0&&(v=R+1),e}let c=t.ids[v],D=c?s.get(c):null;return!c||w.has(c)||!D||D.t!==e.t?e:(w.add(c),v++,{...e,id:c})}).map(e=>{let c=e.id?s.get(e.id):null;return c?.t==="table"&&e.t==="table"&&Array.isArray(e.cols)&&Array.isArray(c.cols)?V(e,c):e}),k=new Set(t.baseItems.filter(e=>!s.has(e.id)).map(e=>e.id)),u=x(q,{seed:d,known:s,taken:k});for(let e=0;e<4&&u.some(c=>k.has(c.id));e++)u=x(q,{seed:K(),known:s,taken:k});if(u.some(e=>k.has(e.id)))return p("active","The new blocks from AI could not be added to the document. Try again.");u=u.map(e=>e.id&&t.held.has(e.id)?{...t.held.get(e.id)}:e),u=u.map(e=>{let c=e.id?s.get(e.id):null;return c&&c.t===e.t?G(c,e):e}),t.parent!==null&&(u=u.map(e=>e.parent?e:{...e,parent:t.parent}));let T=E(t.blocks,[...t.before,...u,...t.after],t.baseItems);if(!T)return p("no-change","AI did not change anything.");let C=M(r,T);if(!C)return p("no-change","AI did not change anything.");let _=new Map;return C.doc.forEach(e=>_.set(e.attrs.id,e)),{status:"ready",plan:T,reply:u,nodes:u.map(e=>_.get(e.id)).filter(Boolean)}}function te(r,t,i,d=document){let o=N(r.doc,t,d);if(o.length)return{status:"stale",ids:o};let l=A(m(r.doc)),n=I(l,d),h=n.findIndex(f=>f.id===t.ids[0]);if(h<0)return{status:"stale",ids:[...t.ids]};let a=h+t.ids.length-1,g=E(l,[...n.slice(0,h),...i.reply,...n.slice(a+1)],n);if(!g)return{status:"stale",ids:[]};let b=M(r,g);return b?{status:"ok",tr:B(b)}:{status:"stale",ids:[]}}export{Q as AREA_GUIDE,Z as captureArea,te as keepAreaTransaction,ee as proposeArea,N as staleIds};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as j,c as re}from"./c-6DNRCPNM.js";import{a as Re}from"./c-Q3XOWZEV.js";import{a as Le}from"./c-4ASQPRQL.js";import{j as Me}from"./c-
|
|
1
|
+
import{a as j,c as re}from"./c-6DNRCPNM.js";import{a as Re}from"./c-Q3XOWZEV.js";import{a as Le}from"./c-4ASQPRQL.js";import{j as Me}from"./c-EHAR4RJJ.js";import{a as Ce}from"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import{a as Ae}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{b as Y,c as Oe,d as Ie,l as ce,u as fe}from"./c-UW6MMZ4V.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 Et=16384;function Ot(e){let t=new Map,n=e?.onParseError;return{parser:new Re({...e,onParseError:s=>{t.set(s.code,(t.get(s.code)||0)+1),n?.(s)}}),errors:t}}function It(e,t,n,r){let s=Math.min(n+r,t.length);return e.tokenizer.write(t.slice(n,s),s>=t.length),s}function*de(e,t,{chunk:n=Et}={}){let{parser:r,errors:s}=Ot(t),o=0;do o=It(r,e,o,n),o<e.length&&(yield);while(o<e.length);return{document:r.document,errors:s}}var ge=new Set(["script","style","xmp","iframe","noembed","noframes","plaintext","noscript"]),Je=new Set(["textarea","title"]),be=e=>ge.has(e)?"raw":Je.has(e)?"rcdata":"normal",pe=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),$e="http://www.w3.org/1999/xhtml",K=1500,Ct=e=>e.replace(/&/g,"&").replace(/ /g," ").replace(/</g,"<").replace(/>/g,">"),Fe=e=>e.replace(/&/g,"&").replace(/ /g," ").replace(/"/g,""");function Qe(e){return j(ie(e))}function*ie(e){let{document:t,errors:n}=yield*de(e,{sourceCodeLocationInfo:!0});return We(e,t,n)}function We(e,t,n){let r=t.childNodes.find(l=>l.nodeName==="html"),s=t.childNodes.filter(l=>l!==r).map(l=>l.nodeName==="#documentType"?{kind:"doctype",name:l.name||"",publicId:l.publicId||"",systemId:l.systemId||""}:{kind:l.nodeName==="#comment"?"comment":l.nodeName,value:l.data}),o=r?ze(r,null,e):null;return o&&Ve(o,e),{src:e,doc:t,outside:s,root:o,parseErrors:n,relocated:o?me(o):null,movedIn:o?me(o,"movedIn"):null,tailOwner:o?He(o):null}}function ze(e,t,n){let r=e.sourceCodeLocation||null,s=e.nodeName==="#text"?"text":e.nodeName==="#comment"?"comment":"element",o={node:e,parent:t,live:null,kind:s,children:[],from:r?r.startOffset:-1,to:r?r.endOffset:-1};if(s==="text")return o.value=e.value,o;if(s==="comment")return o.value=e.data,o;o.tag=e.tagName,o.located=!!(r&&r.startTag),o.openFrom=o.located?r.startTag.startOffset:-1,o.openTo=o.located?r.startTag.endOffset:-1,o.closeFrom=r&&r.endTag?r.endTag.startOffset:o.located?o.to:-1,o.closeTo=r&&r.endTag?r.endTag.endOffset:o.located?o.to:-1,o.endTagged=!!(r&&r.endTag),o.located&&(o.to<o.openTo&&(o.to=o.openTo),o.closeFrom<o.openTo&&(o.closeFrom=o.closeTo=o.openTo)),o.attrs=[];let l=o.located&&r.startTag.attrs||r&&r.attrs||{};for(let a of e.attrs){let g=a.prefix?a.prefix+":"+a.name:a.name,c=l[g.toLowerCase()];o.attrs.push({name:g,key:g.toLowerCase(),value:a.value,from:c?c.startOffset:-1,to:c?c.endOffset:-1})}let d=e.nodeName==="template"&&e.content?e.content.childNodes:e.childNodes;for(let a of d)a.nodeName!=="#documentType"&&o.children.push(ze(a,o,n));if(!o.located){let a=o.children.filter(p=>p.from>=0),g=a.length?Math.min(...a.map(p=>p.from)):-1,c=a.length?Math.max(...a.map(p=>p.to)):-1;o.openFrom=o.openTo=g,o.closeFrom=o.closeTo=c,o.from=g,o.to=c}return o}function Ve(e,t,n=1/0){if(e.kind!=="element")return;for(let o of e.children){if(o.from>=n&&!(o.kind==="text"&&!/\S/.test(o.value))&&(e.movedIn=!0),o.from>=0&&e.located){let l=Math.max(e.openTo,Math.min(o.to,e.closeFrom)),d=Math.min(Math.max(o.from,e.openTo),l);if(d!==o.from||l!==o.to){if(o.kind==="text"&&!ge.has(e.tag)&&!Je.has(e.tag)){let a=t.slice(l,o.to).replace(/<!--[\s\S]*?-->|<[^>]*>/g,"").replace(/\r\n?/g,`
|
|
2
2
|
`);a&&!/\S/.test(a)&&o.value.endsWith(a)&&(o.outsideTail=a)}o.clamped=!0,o.from=d,o.to=l}}o.kind==="element"&&o.located&&!o.endTagged&&o.closeFrom>o.to&&(o.closeFrom=o.closeTo=o.to)}let r=e.located?e.openTo:-1;for(let o of e.children)if(!(o.from<0)){if(o.from<r){e.outOfOrder=!0;break}r=o.to}let s=e.located&&e.endTagged?Math.min(n,e.closeTo):n;for(let o of e.children)Ve(o,t,s)}function me(e,t="outOfOrder"){if(e[t])return e.tag;for(let n of e.children){if(n.kind!=="element")continue;let r=me(n,t);if(r)return r}return null}function He(e){if(e.outsideTail)return e;for(let t of e.children||[]){let n=He(t);if(n)return n}return null}function Z(e,t){if(!e.root)return"source has no <html> element";if(e.root.openFrom<0)return"source has no content inside <html>";if(e.relocated)return"the parser moved content out of <"+e.relocated+">, so source order and tree order disagree";if(e.movedIn)return"the parser moved content written after the end of <"+e.movedIn+"> back inside it, so source order and tree order disagree";let n=Rt(t),r=e.outside.map(At);if(n.length!==r.length)return"outside <html>: "+JSON.stringify(r)+" vs live "+JSON.stringify(n);for(let s=0;s<n.length;s++)if(n[s]!==r[s])return"outside <html>: "+r[s]+" vs live "+n[s];return null}function At(e){return e.kind==="doctype"?"doctype:"+e.name+"|"+e.publicId+"|"+e.systemId:e.kind+":"+e.value}function Rt(e){let t=[];for(let n of e.childNodes)n.nodeType===10?t.push("doctype:"+n.name+"|"+n.publicId+"|"+n.systemId):n.nodeType===8?t.push("comment:"+n.data):n.nodeType!==1&&t.push("#"+n.nodeType+":"+(n.data||""));return t}var ae="\0",Ge={align:0,hashKey:0};function Pe(e,t){for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function J(e){Ge.hashKey++;let t=2166136261,n=5381;for(let r of e)t=Pe(t,r),n=(Math.imul(n,33)^Pe(t^2654435769,r))>>>0;return t.toString(36)+"."+n.toString(36)}function q(e){let t=e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content.childNodes:e.childNodes,n=[];for(let r of t)(r.nodeType===1||r.nodeType===3||r.nodeType===8)&&n.push(r);return n}var ye=e=>Array.from(e.attributes,t=>t.name.toLowerCase()+"="+t.value).sort().join(ae),Xe=e=>e.attrs.map(t=>t.key+"="+t.value).sort().join(ae);function Ye(e,t){let n;if(e.nodeType===3)n={tag:"#text",shallow:"t:"+e.data,content:"t:"+e.data,deep:"t:"+e.data};else if(e.nodeType===8)n={tag:"#comment",shallow:"c:"+e.data,content:"c:"+e.data,deep:"c:"+e.data};else{let r=q(e).map(o=>Ye(o,t)),s="e:"+e.localName+"|"+ye(e);n={tag:e.localName,shallow:s,content:"e:"+e.localName+"|"+J(r.map(o=>o.content)),deep:s+"|"+J(r.map(o=>o.deep))}}return t.set(e,n),n}function*Ke(e,t,n){++n.n%K===0&&(yield);let r;if(e.nodeType===3)r={tag:"#text",shallow:"t:"+e.data,content:"t:"+e.data,deep:"t:"+e.data};else if(e.nodeType===8)r={tag:"#comment",shallow:"c:"+e.data,content:"c:"+e.data,deep:"c:"+e.data};else{let s=[];for(let l of q(e))s.push(yield*Ke(l,t,n));let o="e:"+e.localName+"|"+ye(e);r={tag:e.localName,shallow:o,content:"e:"+e.localName+"|"+J(s.map(l=>l.content)),deep:o+"|"+J(s.map(l=>l.deep))}}return t.set(e,r),r}function*Ze(e,t){if(++t.n%K===0&&(yield),e.kind==="text")return e.keys={tag:"#text",shallow:"t:"+e.value,content:"t:"+e.value,deep:"t:"+e.value};if(e.kind==="comment")return e.keys={tag:"#comment",shallow:"c:"+e.value,content:"c:"+e.value,deep:"c:"+e.value};let n=[];for(let s of e.children)n.push(yield*Ze(s,t));let r="e:"+e.tag+"|"+Xe(e);return e.keys={tag:e.tag,shallow:r,content:"e:"+e.tag+"|"+J(n.map(s=>s.content)),deep:r+"|"+J(n.map(s=>s.deep))}}var De=["deep","content","shallow","tag"],Mt=4096;function Lt(e,t){Ge.align++;let n=[],r=e.map((p,y)=>y),s=t.map((p,y)=>y);g(r,s,0);let o=new Set(n.map(p=>p[0])),l=new Set(n.map(p=>p[1])),d=r.filter(p=>!o.has(p)),a=s.filter(p=>!l.has(p));return d.length&&a.length&&g(d,a,0),n.sort((p,y)=>p[0]-y[0]),n;function g(p,y,S){let w=0,h=p.length,v=0,N=y.length;if(w>=h||v>=N)return;if(S>=De.length)return c(p,y);let b=De[S];for(;w<h&&v<N&&e[p[w]][b]===t[y[v]][b];)n.push([p[w],y[v]]),w++,v++;for(;w<h&&v<N&&e[p[h-1]][b]===t[y[N-1]][b];)h--,N--,n.push([p[h],y[N]]);if(w>=h||v>=N)return;let P=new Map,Q=new Map;for(let I=w;I<h;I++){let A=e[p[I]][b];P.set(A,P.has(A)?-1:I)}for(let I=v;I<N;I++){let A=t[y[I]][b];Q.set(A,Q.has(A)?-1:I)}let ne=[];for(let I=w;I<h;I++){let A=e[p[I]][b];if(P.get(A)===I){let D=Q.get(A);D!==void 0&&D>=0&&ne.push([I,D])}}let W=bt(ne);if(!W.length){if((h-w)*(N-v)<=Mt){let I=Ft(e,t,p,y,w,h,v,N,b);if(I.length){let A=w,D=v;for(let[H,G]of I)n.push([p[H],y[G]]),g(p.slice(A,H),y.slice(D,G),S+1),A=H+1,D=G+1;g(p.slice(A,h),y.slice(D,N),S+1);return}}return g(p.slice(w,h),y.slice(v,N),S+1)}let z=w,V=v;for(let[I,A]of W)n.push([p[I],y[A]]),g(p.slice(z,I),y.slice(V,A),S),z=I+1,V=A+1;g(p.slice(z,h),y.slice(V,N),S)}function c(p,y){let S=new Map,w=new Map;for(let h of p){let v=e[h].tag;S.has(v)||S.set(v,[]),S.get(v).push(h)}for(let h of y){let v=t[h].tag;w.has(v)||w.set(v,[]),w.get(v).push(h)}for(let[h,v]of S){let N=w.get(h);N&&N.length===v.length&&h!=="#text"&&h!=="#comment"&&v.forEach((b,P)=>n.push([b,N[P]]))}}}function bt(e){let t=[],n=[],r=new Array(e.length).fill(-1);for(let l=0;l<e.length;l++){let d=e[l][1],a=0,g=t.length;for(;a<g;){let c=a+g>>1;t[c]<d?a=c+1:g=c}t[a]=d,n[a]=l,r[l]=a>0?n[a-1]:-1}let s=[],o=n.length?n[n.length-1]:-1;for(;o>=0;)s.push(e[o]),o=r[o];return s.reverse()}function Ft(e,t,n,r,s,o,l,d,a){let g=o-s,c=d-l,p=(v,N)=>e[n[s+v]][a]===t[r[l+N]][a],y=Array.from({length:g+1},()=>new Uint16Array(c+1));for(let v=g-1;v>=0;v--)for(let N=c-1;N>=0;N--)y[v][N]=p(v,N)?y[v+1][N+1]+1:Math.max(y[v+1][N],y[v][N+1]);let S=[],w=0,h=0;for(;w<g&&h<c;)p(w,h)?(S.push([s+w,l+h]),w++,h++):y[w+1][h]>=y[w][h+1]?w++:h++;return S}function Be(e){return e.nodeType===3?"#text "+JSON.stringify(e.data.slice(0,40)):e.nodeType===8?"#comment":"<"+e.localName+Array.from(e.attributes,t=>" "+t.name+'="'+t.value.slice(0,30)+'"').join("")+">"}function je(e){return e.kind==="text"?"#text "+JSON.stringify(e.value.slice(0,40)):e.kind==="comment"?"#comment":"<"+e.tag+e.attrs.map(t=>" "+t.name+'="'+t.value.slice(0,30)+'"').join("")+">"}function et(e,t,n=r=>r){return j(we(e,t,n))}function*we(e,t,n=r=>r){let r=new WeakMap,s=new Map,o={n:0};yield*Ke(e,s,o),yield*Ze(t.root,o);let l={paired:0,unmatchedLive:[],unmatchedSource:[],attrDiffs:[],textDiffs:0,unresolved:0},d={};return t.gen=d,yield*tt(e,t.root,r,s,l,"html",n,d,o),{map:r,stats:l}}function*tt(e,t,n,r,s,o,l,d,a){++a.n%K===0&&(yield);let g=l(e);if(g?(n.set(g,t),t.gen=d,s.paired++):s.unresolved++,t.kind!=="element"){e.data!==t.value&&s.textDiffs++;return}ye(e)!==Xe(t)&&s.attrDiffs.push({path:o,live:Be(e),source:je(t)});let c=q(e),p=t.children,y=Lt(c.map(h=>r.get(h)),p.map(h=>h.keys)),S=new Set,w=new Set;for(let[h,v]of y)S.add(h),w.add(v),yield*tt(c[h],p[v],n,r,s,o+">"+(c[h].nodeType===1?c[h].localName:"#")+"["+h+"]",l,d,a);for(let h=0;h<c.length;h++)S.has(h)||s.unmatchedLive.push({path:o,node:Be(c[h])});for(let h=0;h<p.length;h++)w.has(h)||s.unmatchedSource.push({path:o,node:je(p[h])})}function*nt(e,t,n=r=>r){if(!t.root)return null;let r=[],s=yield*rt(e,t.root,n,r,{n:0});if(s<0)return null;let o=new WeakMap,l={};t.gen=l;let d=0;for(let[a,g]of r)a&&(o.set(a,g),g.gen=l,d++);return{map:o,stats:{paired:d,unmatchedLive:[],unmatchedSource:[],attrDiffs:[],textDiffs:0,unresolved:s}}}function*rt(e,t,n,r,s){if(++s.n%K===0&&(yield),t.kind==="text"){if(e.nodeType!==3||e.data!==t.value)return-1}else if(t.kind==="comment"){if(e.nodeType!==8||e.data!==t.value)return-1}else if(e.nodeType!==1||e.localName!==t.tag||e.namespaceURI!==t.node.namespaceURI||Pt(e)!==Dt(t.node))return-1;let o=n(e);r.push([o,t]);let l=o?0:1;if(t.kind!=="element")return l;let d=Bt(e),a=t.children;if(d.length!==a.length)return-1;for(let g=0;g<d.length;g++){let c=yield*rt(d[g],a[g],n,r,s);if(c<0)return-1;l+=c}return l}var ot=e=>JSON.stringify(e),Pt=e=>Array.from(e.attributes,t=>ot([t.namespaceURI||"",t.name,t.value])).sort().join(ae),Dt=e=>e.attrs.map(t=>ot([t.namespace||"",t.prefix?t.prefix+":"+t.name:t.name,t.value])).sort().join(ae);function Bt(e){let t=e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content.childNodes:e.childNodes,n=[];for(let r of t)(r.nodeType===1||r.nodeType===3||r.nodeType===8)&&n.push(r);return n}function st(e,t,n){let r=t.get(e);if(!r||r.gen!==n.gen||r.from<0||r.to<0||r.kind==="element"&&r.located&&n.src.slice(r.openFrom,r.openFrom+r.tag.length+1).toLowerCase()!=="<"+r.tag.toLowerCase())return null;let s=jt(n),o=Ut(s,r.from);return{from:r.from,to:r.to,line:o+1,column:r.from-s[o]+1}}function jt(e){if(!e.lineStarts){let t=[0];for(let n=0;n<e.src.length;n++)e.src.charCodeAt(n)===10&&t.push(n+1);e.lineStarts=t}return e.lineStarts}function Ut(e,t){let n=0,r=e.length-1;for(;n<r;){let s=n+r+1>>1;e[s]<=t?n=s:r=s-1}return n}function it(e,t,n,r,s={}){let o=()=>typeof performance<"u"?performance.now():Date.now(),l=o(),d=n.src,a=[],g=0,c=(u,m)=>{if(!(u>=0&&m>u))return;let f=a.length>g?a[a.length-1]:null;f&&f.text===void 0&&f.to===u?f.to=m:a.push({from:u,to:m})},p=u=>{u&&a.push({text:u})},y=0,S=u=>{if(y)return null;let m=r(u),f=m?t.get(m):null;return f&&f.gen===n.gen?f:null},w=null,h=-1,v=!1,N=n.root;if(c(0,N.openFrom),I(e,N),c(N.closeTo,d.length),n.tailOwner&&h>=0&&!v){for(let u=h;u<a.length;u++)a[u]={text:Q(P(a[u]))};w&&w.tail&&a.splice(w.at,0,{text:w.tail})}return{text:a.map(P).join(""),ms:o()-l};function P(u){return u.text!==void 0?u.text:d.slice(u.from,u.to)}function Q(u){return u.split(/(<!--[\s\S]*?-->|<[^>]*>)/).map((m,f)=>f%2?m:m.replace(/[\t\n\f\r ]+/g,"")).join("")}function ne(){h=a.length,g=a.length,v=!!w&&w.whole&&/^(?:<\/[^>]*>)*$/.test(a.slice(w.at).map(P).join(""))}function W(u,m){if(u.nodeType===3)return V(u,m);if(u.nodeType===8)return z(u);if(u.nodeType===1){if(s.print&&s.print.has(u)){y++;try{I(u,null)}finally{y--}}else I(u,S(u));u.localName==="body"&&u.parentNode===e&&ne()}}function z(u){let m=S(u);m&&m.kind==="comment"&&m.value===u.data&&m.from>=0&&!s.breakText?c(m.from,m.to):p("<!--"+u.data+"-->")}function V(u,m){let f=S(u),x=u.data;s.corrupt==="drop-first-text"&&!s.corrupted&&x.trim()&&(s.corrupted=!0,x=x.slice(1));let T=f&&f.parent&&be(f.parent.tag)===be(m);if(f&&f.kind==="text"&&f.value===x&&f.from>=0&&!s.breakText&&T){c(f.from,f.to),s.doubleCopied!==void 0&&x===s.doubleCopied&&c(f.from,f.to),f.outsideTail&&(w={at:a.length,tail:f.outsideTail,whole:!0},g=a.length);return}let M=null;if(f&&f.kind==="text"&&f.outsideTail){let R=x.endsWith(f.outsideTail);R&&(x=x.slice(0,x.length-f.outsideTail.length)),M={tail:R?f.outsideTail:"",whole:R}}p(ge.has(m)?x:Ct(x)),M&&(w={at:a.length,...M},g=a.length)}function I(u,m){let f=u.localName,x=pe.has(f)&&u.namespaceURI===$e,T=m&&m.kind==="element"&&!s.breakTags?m:null;if(T&&!T.located){if(u.attributes.length===0){if(T.openFrom>=0){X(u,T,f);return}q(u).length&&X(u,null,f);return}if(p(A(u)),x)return;X(u,T.openFrom>=0?T:null,f),p("</"+f+">");return}if(!T){if(p(A(u)),x)return;X(u,null,f),p("</"+f+">");return}H(u,T),!x&&(X(u,T,f),c(T.closeFrom,T.closeTo))}function A(u){let m="<"+u.localName;for(let f of u.attributes)m+=" "+f.name+(f.value===""?"":'="'+Fe(f.value)+'"');return m+">"}function D(u,m){let f=u.attributes;if(f.length!==m.attrs.length)return!1;for(let x=0;x<f.length;x++){let T=m.attrs[x];if(T.from<0||f[x].value!==T.value||f[x].name.toLowerCase()!==T.key)return!1}return!0}function H(u,m){if(D(u,m)){c(m.openFrom,m.openTo);return}let f=new Map;for(let O of u.attributes)f.set(O.name.toLowerCase(),O);let x=new Set,T=m.openFrom;for(let O of m.attrs){if(O.from<0){let _=f.get(O.key);_&&_.value===O.value&&x.add(O.key);continue}let L=f.get(O.key);if(x.add(O.key),!L){c(T,G(T,O.from)),T=O.to;continue}if(L.value===O.value){c(T,O.to),T=O.to;continue}c(T,O.from),p(xt(d.slice(O.from,O.to),L.value)),T=O.to}let M=m.openTo-1,R=m.attrs.reduce((O,L)=>L.to>O?L.to:O,m.openFrom);d[M-1]==="/"&&M-1>=R&&M--,c(T,M);for(let O of u.attributes)x.has(O.name.toLowerCase())||p(" "+O.name+(O.value===""?"":'="'+Fe(O.value)+'"'));c(M,m.openTo)}function G(u,m){let f=m;for(;f>u&&/[ \t\n\r\f]/.test(d[f-1]);)f--;return f}function xt(u,m){let f=u.indexOf("="),x=(f<0?u:u.slice(0,f)).trimEnd(),T=f<0?"":u.slice(f+1).trim(),M=T[0]==="'"?"'":T[0]==='"'?'"':"",R=m.replace(/&/g,"&").replace(/ /g," ");return M==="'"&&!m.includes("'")?x+"='"+R+"'":M===""&&T!==""&&m!==""&&!/[\s"'=<>`]/.test(m)?x+"="+R:x+'="'+R.replace(/"/g,""")+'"'}function St(u){if(u.nodeType!==1||y||s.print&&s.print.has(u))return null;let m=S(u);return m&&m.kind==="element"&&m.located&&!m.endTagged&&!pe.has(m.tag)&&!s.breakTags?m:null}function ue(u){let m=St(u);if(!m)return null;let f=q(u);return((f.length?ue(f[f.length-1]):null)||[]).concat(m.tag)}function X(u,m,f){let x=q(u),T=null,M=(C,k)=>{T&&!(k>=0&&T.j>=0&&k===T.j+1)&&p(T.tags.map(E=>"</"+E+">").join("")),T=null};if(!m){for(let C of x){M(-1,-1),W(C,f);let k=ue(C);k&&(T={tags:k,j:-1})}return}let R=m.children,O=new Map(R.map((C,k)=>[C,k])),L=x.map(C=>{let k=S(C);return k&&k.parent===m&&k.from>=0?O.get(k):-1}),_=new Set;if(!s.breakText&&!s.breakTags){let C=new Set(L),k=new Map;R.forEach((E,F)=>{C.has(F)||E.from<0||!E.keys||(k.has(E.keys.deep)||k.set(E.keys.deep,[]),k.get(E.keys.deep).push(F))}),k.size&&x.forEach((E,F)=>{if(L[F]>=0||S(E))return;let B=k.get(Ye(E,new Map).deep);B&&B.length&&(L[F]=B.shift(),_.add(F))})}let Se=(C,k)=>{if(!_.has(k))return W(C,f);let E=R[L[k]];c(E.from,E.to),E.outsideTail&&(w={at:a.length,tail:E.outsideTail,whole:!0},g=a.length)},kt=(C,k)=>{if(!_.has(k))return ue(C);let E=R[L[k]];return E.kind==="element"&&E.located&&!E.endTagged&&!pe.has(E.tag)?[E.tag]:null},Nt=new Set(_t(L)),U=m.openTo,ke=-1,Ne=C=>{for(let k=ke+1;k<C;k++){let E=R[k];E.from<0||(c(U,E.from),U=Math.max(U,E.to))}};for(let C=0;C<x.length;C++){let k=x[C],E=kt(k,C);if(Nt.has(C)){let B=L[C],Ee=R[B];M(C,B),Ne(B),c(U,Ee.from),Se(k,C),U=Math.max(U,Ee.to),ke=B,T=E?{tags:E,j:B}:null;continue}let F=S(k);M(C,F&&F.parent===m?O.get(F):-1),Se(k,C),T=E?{tags:E,j:-1}:null}Ne(R.length),c(U,m.closeFrom)}}function _t(e){let t=[],n=[],r=new Array(e.length).fill(-1);for(let l=0;l<e.length;l++){let d=e[l];if(d<0)continue;let a=0,g=t.length;for(;a<g;){let c=a+g>>1;t[c]<d?a=c+1:g=c}t[a]=d,n[a]=l,r[l]=a>0?n[a-1]:-1}let s=[],o=n.length?n[n.length-1]:-1;for(;o>=0;)s.push(o),o=r[o];return s.reverse()}function*at(e,t,n,r=null,s=null){return yield*ve(e,t,n,r,s,!0)}function*ve(e,t,n,r,s,o){let l=new DOMParser,d=l.parseFromString(e,"text/html"),a=qe(d),g=qe(n);if(a.join(`
|
|
3
3
|
`)!==g.join(`
|
|
4
4
|
`))return{ok:!1,diff:"document: outside <html> "+JSON.stringify(a)+" vs live "+JSON.stringify(g)};let c=null,p=null;if(r&&(c=[],p=yield*se(d.documentElement,r,"html",c),!p)){let h=yield*Ue(e,s,o);return h.diff?{ok:!1,diff:h.diff}:o?_e({ok:!0,diff:null,oracle:"clone"},h,e,n):{ok:!0,diff:null,oracle:"clone"}}let y=l.parseFromString(t,"text/html"),S=yield*se(d.documentElement,y.documentElement,"html"),w=S?null:yield*Ue(e,s,o);return S?r?{ok:!1,diff:S,at:c}:{ok:!1,diff:S}:w.diff?{ok:!1,diff:w.diff}:o?_e({ok:!0,diff:null,oracle:"today"},w,e,n):{ok:!0,diff:null,oracle:"today"}}function lt(e,t){let n=e;for(let r of t){let s=he(n);if(r>=s.length)return null;n=s[r]}return n}function*Ue(e,t,n){if(!t)return{diff:null};let{document:r,errors:s}=yield*de(e,n?{sourceCodeLocationInfo:!0}:{});for(let[o,l]of s){let d=t.get(o)||0;if(l>d)return{diff:`the render introduced parse errors the source does not have: ${o} ${d} -> ${l}`}}return n?{diff:null,doc:r,parseErrors:s}:{diff:null}}function _e(e,t,n,r){if(!t.doc)return e;let s=We(n,t.doc,t.parseErrors);return Z(s,r)||(e.model=s),e}function qe(e){let t=[];for(let n of e.childNodes)n.nodeType===10?t.push("doctype "+n.name+"|"+n.publicId+"|"+n.systemId):n.nodeType===8?t.push("comment "+n.data):n.nodeType!==1&&t.push("node"+n.nodeType+" "+(n.data||""));return t}function*qt(e,t,n,r){let s=new DOMParser,o=l=>{let d=Array.from(l.childNodes);return d.length&&d.every(a=>a.nodeType===3)?d.map(a=>a.data).join(""):l.innerHTML};return yield*se(s.parseFromString(e.innerHTML,"text/html").body,s.parseFromString(o(t),"text/html").body,n+">#noscript",[],r)}function he(e){let t=e.localName==="template"&&e.content?e.content.childNodes:e.childNodes,n=[];for(let r=0;r<t.length;r++){let s=t[r];(s.nodeType===1||s.nodeType===3||s.nodeType===8)&&n.push(s)}return n}var oe=e=>Array.from(e.attributes,t=>(t.namespaceURI||"")+" "+t.name+"="+JSON.stringify(t.value)).sort().join("; ");function Jt(e,t){let n=e.attributes,r=t.attributes;if(n.length!==r.length)return!1;for(let s=0;s<n.length;s++){let o=n[s],l=r[s];if(o.name!==l.name||o.value!==l.value||o.namespaceURI!==l.namespaceURI)return!1}return!0}function*se(e,t,n,r=[],s={n:0}){if(++s.n%K===0&&(yield),e.nodeType!==t.nodeType)return n+": node type "+e.nodeType+" vs "+t.nodeType;if(e.nodeType===3||e.nodeType===8)return e.data===t.data?null:n+": text "+JSON.stringify(e.data.slice(0,60))+" vs "+JSON.stringify(t.data.slice(0,60));if(e.localName!==t.localName||e.namespaceURI!==t.namespaceURI)return n+": tag "+e.localName+" vs "+t.localName;if(!Jt(e,t)&&oe(e)!==oe(t))return n+": attrs "+oe(e)+" vs "+oe(t);if(e.localName==="noscript"&&e.namespaceURI===$e)return yield*qt(e,t,n,s);let o=he(e),l=he(t);if(o.length!==l.length)return n+": "+o.length+" vs "+l.length+" children";for(let d=0;d<o.length;d++){r.push(d);let a=yield*se(o[d],l[d],n+">"+(o[d].localName||"#")+"["+d+"]",r,s);if(a)return a;r.pop()}return null}var i={installed:!1,refused:null,session:0,model:null,map:null,stats:null,saves:0,reprints:0,lastReprint:null,partialReprints:0,lastPartialReprint:null,lastOutcome:null,lastRenderMs:null,lastBytes:null,timing:{fetch:null,model:null,pair:null,refresh:null},refreshes:0,repairs:0,refreshQueued:!1,pendingBytes:null,refetch:!1,adoptions:0},$t=2,$=()=>typeof performance<"u"?performance.now():Date.now(),dt=4,le=Object.freeze({superseded:!0});function pt(e){return document.hidden||Me()?!1:e>=307200}var mt='<script type="application/json" id="clay-runtime-map"',ht=e=>e.includes(mt)||e.includes("/_/clayjs/");async function gt(e){let t=await fetch(e,{cache:"no-store",redirect:"manual",credentials:"same-origin",headers:{"Clay-Source":"1"}});if(!t.ok)throw new Error(`source fetch: status ${t.status}`);if(t.redirected||t.type==="opaqueredirect")throw new Error("source fetch: redirected");let n=(t.headers.get("content-type")||"").toLowerCase();if(!n.startsWith("text/html"))throw new Error(`source fetch: content-type ${n||"missing"}`);let r=await t.text();if(r.includes(mt))throw new Error("source fetch: projected response");return r}function yt(e){let t=fe({flushUndo:!1,authored:!1});return et(t,e,Y)}function*Qt(e){let t=fe({flushUndo:!1,authored:!1});return yield*we(t,e,Y)}function Wt(e){let t=e.doc&&e.doc.childNodes.find(r=>r.nodeName==="html"),n=t&&Array.isArray(t.attrs)?t.attrs.find(r=>r.name==="documentetag"):null;return n&&n.value?n.value:null}function zt(e){let t=e&&e.represented&&e.represented.etag;if(t)return t;let n=Ae();return n||e===null&&document.documentElement.getAttribute("documentetag")||null}function Vt(e,t){let n=Wt(e),r=zt(t);return!n||!r||n===r?null:`source refused: the fetch answered version ${n} while this page holds ${r}`}async function wt(e,t=null,n=0,r=!0,s=null){let o=i.session,l=$(),d=i.adoptions;i.refused=null;let a=s?s():null,g=a&&typeof a.bytes=="string"&&!ht(a.bytes)?a.bytes:null;try{let c=g!==null?g:await gt(e);if(o!==i.session)return null;let p=$(),y=await Ht({src:c,context:t,render:r,session:o,generation:d,t0:l,t1:p});if(y!==le)return y;if(n<$t)return wt(e,t,n+1,r,s);throw new Error("source refused: a save replaced the file while the fetch was in flight")}catch(c){return o!==i.session||(i.refused=String(c&&c.message?c.message:c),console.info(`clayjs: source map off (${i.refused}); saves use the full serialization`)),null}}function*ut(e){let t=yield*ie(e.src),n=Z(t,document);if(n)throw new Error(`source refused: ${n}`);let r=Vt(t,e.context);if(r)throw new Error(r);if(i.adoptions!==e.generation)return le;let s=$();if(yield,i.session!==e.session)return null;if(i.adoptions!==e.generation)return le;let{map:o,stats:l}=yield*Qt(t);if(i.session!==e.session)return null;if(i.adoptions!==e.generation)return le;let d=$();return i.model=t,i.map=o,i.stats=l,i.timing={fetch:e.t1-e.t0,model:s-e.t1,pair:d-s,refresh:null},i.installed=!0,e.render&&ce(Gt,{steps:vt}),Tt()}async function Ht(e){if(!pt(e.src.length))return j(ut(e));let t={get aborted(){return i.session!==e.session}},n=await re(ut(e),{budgetMs:dt,signal:t});return n&&n.aborted===!0?null:n}function Gt(e,t,n={}){return j(vt(e,t,n))}function*vt(e,t,n={}){if(!i.installed)return t;yield*xe();let r=i.session,s=i.repairs,o=Oe(),l=!!o&&!o.authoredHandlers,d=new Set,a=null;for(let g=0;g<=Yt;g++){let c;try{c=it(e,i.map,i.model,Y,{...n,print:d})}catch(y){return ee("render threw: "+(y&&y.message?y.message:y),t)}let p=l?yield*at(c.text,t,document,e,i.model.parseErrors):yield*ve(c.text,t,document,e,i.model.parseErrors,!1);if(p.ok){let y=ct(r,s);if(y)return ee(y,t);let S=d.size?{text:c.text,scope:"partial",reason:a,printed:d.size}:{text:c.text,scope:null},w=p.model?yield*nt(e,p.model,Y):null,h=ct(r,s);return h?ee(h,t):(i.lastRenderMs=c.ms,i.lastBytes=c.text.length,i.lastOutcome=S,p.model&&Xt(p.model,c.text,o,w),c.text)}if(a===null&&(a=p.diff),!p.at||!Kt(e,lt(e,p.at),d))return ee(a,t)}return ee(a,t)}function ct(e,t){return i.session!==e?"render refused: the session ended while this render ran":i.installed?i.repairs!==t?"render refused: the map was re-paired while this render ran":null:"render refused: the source map was uninstalled while this render ran"}function Xt(e,t,n,r){r&&Ie({captureId:n.captureId,html:t,source:{model:e,map:r.map,stats:r.stats,repairGeneration:i.repairs,outcome:i.lastOutcome}})}var Yt=8;function Kt(e,t,n){let r=t&&t.nodeType===1?t:t&&t.parentNode;for(let s=r;s&&s!==e;s=s.parentNode)if(n.has(s)){n.delete(s),r=s.parentNode;break}return!r||r.nodeType!==1||r===e?!1:(n.add(r),!0)}function ee(e,t){return i.lastOutcome={text:t,scope:"full",reason:e},t}function Zt(e){i.reprints++,i.lastReprint=e,console.warn("clayjs: source map did not verify, saving the full serialization instead:",e),document.dispatchEvent(new CustomEvent("clay:save-reprinted",{detail:{reason:e,scope:"full"}}))}function en(e,t){i.partialReprints++,i.lastPartialReprint=e,console.info(`clayjs: source map printed ${t} element(s) in full to match the page:`,e),document.dispatchEvent(new CustomEvent("clay:save-reprinted",{detail:{reason:e,scope:"partial",printed:t}}))}function tn(e,t){i.adoptions++,i.installed&&(rn(e,t&&t.artifact?t.artifact.source.outcome:null),!nn(e,t)&&(i.pendingBytes=e,Te()))}function nn(e,t){let n=t&&t.artifact;return!n||!n.source||n.html!==e||t.captureId===null||t.captureId===void 0||n.captureId!==t.captureId||n.source.repairGeneration!==i.repairs||i.refreshQueued||i.pendingBytes!==null?!1:(i.model=n.source.model,i.map=n.source.map,i.stats=n.source.stats,!0)}function rn(e,t=null){let n=i.lastOutcome&&i.lastOutcome.text===e?i.lastOutcome:t;!n||n.text!==e||(i.lastOutcome===n&&(i.lastOutcome=null),i.saves++,n.scope==="full"?Zt(n.reason):n.scope==="partial"&&en(n.reason,n.printed))}function on(e){let t=e&&e.detail;t&&t.source==="disk"&&typeof t.html=="string"&&i.adoptions++,i.installed&&(t&&t.source==="disk"&&typeof t.html=="string"&&(ht(t.html)?i.refetch=!0:i.pendingBytes=t.html),Te())}function Te(){i.refreshQueued||(i.refreshQueued=!0,typeof requestIdleCallback=="function"?requestIdleCallback(ft,{timeout:2e3}):setTimeout(ft,0))}function ft(){if(!pt(sn())){te();return}an()}function sn(){return typeof i.pendingBytes=="string"?i.pendingBytes.length:i.model?i.model.src.length:0}async function an(){let e=i.session,t={get aborted(){return i.session!==e}};try{await re(xe(),{budgetMs:dt,signal:t})}catch(n){console.warn("clayjs: source map could not run the queued repair:",n)}!i.refreshQueued||!i.installed||i.session!==e||(i.refreshQueued=!1,Te())}function te(){j(xe())}function*xe(){if(!i.refreshQueued)return;if(!i.installed){i.refreshQueued=!1;return}let e=i.session,t=i.repairs,n=i.adoptions,r=i.pendingBytes,s=i.refetch&&r===null,o=$(),l=i.model;if(r!==null)try{let a=yield*ie(r),g=Z(a,document);if(g)throw new Error(g);l=a}catch(a){console.warn("clayjs: source map kept the previous model, the accepted bytes did not model:",a)}if(yield,!ln(e,t,n))return;let d=null;try{d=yt(l)}catch(a){console.warn("clayjs: source map could not re-pair, continuing on the previous map:",a)}i.refreshQueued=!1,i.pendingBytes=null,s&&(i.refetch=!1),i.repairs++,d&&(i.model=l,i.map=d.map,i.stats=d.stats,i.refreshes++,i.timing.refresh=$()-o),s&&un()}function ln(e,t,n){return i.session===e&&i.installed&&i.repairs===t&&i.adoptions===n}function un(){let e=i.repairs,t=i.adoptions;gt(window.location.href).then(n=>{let r=Qe(n),s=Z(r,document);if(s)throw new Error(s);return r}).then(n=>{if(!(i.repairs!==e||i.adoptions!==t))try{i.repairs++,i.adoptions++;let{map:r,stats:s}=yt(n);i.model=n,i.map=r,i.stats=s,i.refreshes++}catch(r){console.warn("clayjs: source map could not re-pair, continuing on the previous map:",r)}}).catch(n=>{console.warn("clayjs: source map kept the previous model, the accepted bytes did not model:",n)})}function Tt(){let e=i.stats;return{installed:i.installed,refused:i.refused,sourceBytes:i.model?i.model.src.length:null,paired:e?e.paired:0,unresolved:e?e.unresolved:0,unmatchedLive:e?e.unmatchedLive.length:0,unmatchedSource:e?e.unmatchedSource.length:0,attrDiffs:e?e.attrDiffs.length:0,saves:i.saves,reprints:i.reprints,lastReprint:i.lastReprint,partialReprints:i.partialReprints,lastPartialReprint:i.lastPartialReprint,lastRenderMs:i.lastRenderMs,lastBytes:i.lastBytes,refreshes:i.refreshes,timing:i.timing}}function kn(){return te(),i.model?i.model.src:null}function Nn(e){return te(),i.installed&&e?st(e,i.map,i.model):null}function En(){return te(),i.stats?{live:i.stats.unmatchedLive.slice(0,50),source:i.stats.unmatchedSource.slice(0,50)}:null}function On(){return te(),Tt()}var In=()=>i.installed,Cn=()=>i.repairs;function An(){cn()}function cn(){i.session++,i.installed=!1,i.refreshQueued=!1,i.pendingBytes=null,i.refetch=!1,ce(null)}function Rn({context:e=null,latest:t=null}={}){return wt(window.location.href,e,0,!0,t)}Ce(tn);document.addEventListener("clay:sync-applied",on);export{tn as adoptAccepted,In as installed,Nn as locateLive,xe as refreshNowSteps,An as release,Gt as renderSave,vt as renderSaveSteps,Cn as repairGeneration,Rn as start,On as stats,kn as text,En as unpaired};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{f as n}from"./c-VO6RSFCO.js";import{b as h,c as a}from"./c-WN3MXOLT.js";import{a as u}from"./c-7RHOMAMR.js";import"./c-N326R2JD.js";import{b as T,g as _}from"./c-U35T5NAY.js";import{b as p}from"./c-WOJ2RTV4.js";import{b}from"./c-RGFPLQGV.js";import"./c-QCDVDZIR.js";import"./c-VKEDWYDF.js";import{B as v,C as g,K as k,M as E,Q as w,r as f,s as m,y}from"./c-FC5RUFPR.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-P73XPAOA.js";import"./c-ZPI7M5U5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-MZCOGNZL.js";import"./c-EHAR4RJJ.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./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-UW6MMZ4V.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 x=250,A=2e3,c=["focusin","focusout","selectionchange","clay:sync-applied","clay:workspace-background","clay:workspace-foreground"],S=t=>n.setGeneric(t),o=class{constructor({send:e=S,now:i=()=>Date.now()}){this.send=e,this.now=i,this.others=!1,this.background=!1,this.sent=null,this.lastAt=-1/0,this.timer=null,this.poked=null,this.inflight=!1,this.retry=null,this.stopped=!1,this._onEvent=s=>{s.type==="clay:workspace-background"&&(this.background=!0),s.type==="clay:workspace-foreground"&&(this.background=!1),this.poke()}}start(){this.stopped=!1;for(let e of c)document.addEventListener(e,this._onEvent)}resume(){this.stopped&&(this.start(),this.sent=null,this.schedule())}stop(){this.stopped=!0;for(let e of c)document.removeEventListener(e,this._onEvent);clearTimeout(this.timer),clearTimeout(this.poked),clearTimeout(this.retry),this.timer=null,this.poked=null,this.retry=null}roster(e){let s=(e&&Array.isArray(e.people)?e.people:[]).some(r=>r&&r.you!==!0);s!==this.others&&(this.others=s,this.schedule())}reconnected(){this.sent=null,this.schedule()}wanted(){return!this.others||this.background?null:a(h(document.activeElement))}poke(){this.poked===null&&(this.poked=setTimeout(()=>{this.poked=null,this.schedule()},0))}schedule(){if(this.stopped||this.timer!==null||this.inflight||this.wanted()===this.sent)return;let e=Math.max(0,this.lastAt+x-this.now());this.timer=setTimeout(()=>{this.timer=null,this.flush()},e)}flush(){if(this.inflight)return;let e=this.wanted();if(e===this.sent)return;this.sent=e,this.lastAt=this.now(),this.inflight=!0;let i=s=>{if(this.inflight=!1,!this.stopped){if(s)clearTimeout(this.retry),this.retry=null;else if(this.sent===e){this.sent=void 0,this.retry===null&&(this.retry=setTimeout(()=>{this.retry=null,this.schedule()},A));return}this.schedule()}};Promise.resolve(this.send(e)).then(s=>i(!!s),()=>i(!1))}};function P(t){let e=()=>(t._presenceQuiesced=!0,t._editing?.stop(),n.setGeneric(null),n.releaseTarget(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-quiesce")),t.lane==="live"&&t._morphInFlight?{ok:!1,code:"pending-input"}:{ok:!0}),i=()=>{t._presenceQuiesced=!1,t._editing?.resume(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))},s=()=>{t._presenceQuiesced=!1,t.stop(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))};return{id:"clay:sync",order:50,async prepare(r){if(await u(),r?.initial)return{quiesce:e,resume:i,dispose:s};let l=!1;return{quiesce:e,resume:i,enable(){let d=t.currentFile;t.stop(),t.start(d,{lane:"live"}),l=!0},dispose:()=>{t._presenceQuiesced=!1,l&&t.stop(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))}}}}}export{o as EditingSender,k as baselineSettled,m as conflictResolvedBySync,_ as enableAdminInputs,p as enableAdminResources,b as enableContentEditable,T as enableOnClick,v as getLastSavedBytes,f as isSaveConflicted,w as savePageThrottled,E as schedulePaintHeal,g as setLastSavedBaselines,y as setUnsavedChanges,P as syncParticipant};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./c-4M2T676V.js";import"./c-OZOACVUD.js";import"./c-QHWJ5ZIJ.js";import"./c-J2ZW4HMR.js";import"./c-A5LASUEZ.js";import"./c-4JZDZFF6.js";import"./c-5RZNFTWD.js";import"./c-PKCCHJ5X.js";import"./c-46XYM55L.js";import"./c-NUHP2XDB.js";import"./c-VHNSBD2M.js";export{a as SURFACE_THEME,b as default};
|