@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
|
@@ -2,4 +2,4 @@ var As=Object.defineProperty,xs=(t,e,r)=>e in t?As(t,e,{enumerable:!0,configurab
|
|
|
2
2
|
`)}},Me=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[Dt]?on(t,e):ut(t)?Xe(t,r=>qe(e,n=>Me(r,n))):pi(t)?Tt(t,(r,n)=>Me(r,e[n])):!1,I=class{extends(t){let[e,r]=[this.shape,t.shape];return this.constructor._dilutes&&([r,e]=[e,r]),Me(e,r)}equals(t){return this.constructor===t.constructor&&Bt(this.shape,t.shape)}[Vi](){return!0}[Dt](t){return this.equals(t)}validate(t){return this.check(t)}check(t,e){P()}get nullable(){return mt(this,de)}get optional(){return new pn(this)}cast(t){return Lr(t,this),t}expect(t){return Lr(t,this),t}};Ge(I,"_dilutes",!1);var sr=class extends I{constructor(t,e){super(),this.shape=t,this._c=e}check(t,e=void 0){let r=t?.constructor===this.shape&&(this._c==null||this._c(t));return!r&&e?.extend(null,this.shape.name,t?.constructor.name,t?.constructor!==this.shape?"Constructor match failed":"Check failed"),r}},S=(t,e=null)=>new sr(t,e),oc=S(sr),ir=class extends I{constructor(t){super(),this.shape=t}check(t,e){let r=this.shape(t);return!r&&e?.extend(null,"custom prop",t?.constructor.name,"failed to check custom prop"),r}},D=t=>new ir(t),cc=S(ir),ce=class extends I{constructor(t){super(),this.shape=t}check(t,e){let r=this.shape.some(n=>n===t);return!r&&e?.extend(null,this.shape.join(" | "),t.toString()),r}},ae=(...t)=>new ce(t),gn=S(ce),Pi=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),fn=t=>{if(ft.check(t))return[Pi(t)];if(gn.check(t))return t.shape.map(e=>e+"");if(xn.check(t))return["[+-]?\\d+.?\\d*"];if(In.check(t))return[".*"];if(Xt.check(t))return t.shape.map(fn).flat(1);O()},ji=class extends I{constructor(t){super(),this.shape=t,this._r=new RegExp("^"+t.map(fn).map(e=>`(${e.join("|")})`).join("")+"$")}check(t,e){let r=this._r.exec(t)!=null;return!r&&e?.extend(null,this._r.toString(),t.toString(),"String doesn't match string template."),r}},ac=S(ji),zi=Symbol("optional"),pn=class extends I{constructor(t){super(),this.shape=t}check(t,e){let r=t===void 0||this.shape.check(t);return!r&&e?.extend(null,"undefined (optional)","()"),r}get[zi](){return!0}},Ji=S(pn),wn=class extends I{check(t,e){return e?.extend(null,"never",typeof t),!1}},hc=new wn,uc=S(wn),mn=class kn extends I{constructor(e,r=!1){super(),this.shape=e,this._isPartial=r}get partial(){return new kn(this.shape,!0)}check(e,r){return e==null?(r?.extend(null,"object","null"),!1):Tt(this.shape,(n,s)=>{let i=this._isPartial&&!er(e,s)||n.check(e[s],r);return!i&&r?.extend(s.toString(),n.toString(),typeof e[s],"Object property does not match"),i})}};Ge(mn,"_dilutes",!0);var yn=mn,$i=t=>new yn(t),Bi=S(yn),Wi=D(t=>t!=null&&(t.constructor===Object||t.constructor==null)),bn=class extends I{constructor(t,e){super(),this.shape={keys:t,values:e}}check(t,e){return t!=null&&Tt(t,(r,n)=>{let s=this.shape.keys.check(n,e);return!s&&e?.extend(n+"","Record",typeof t,s?"Key doesn't match schema":"Value doesn't match value"),s&&this.shape.values.check(r,e)})}},_n=(t,e)=>new bn(t,e),Yi=S(bn),vn=class extends I{constructor(t){super(),this.shape=t}check(t,e){return t!=null&&Tt(this.shape,(r,n)=>{let s=r.check(t[n],e);return!s&&e?.extend(n.toString(),"Tuple",typeof r),s})}},Ki=(...t)=>new vn(t),dc=S(vn),Sn=class extends I{constructor(t){super(),this.shape=t.length===1?t[0]:new he(t)}check(t,e){let r=ut(t)&&Xe(t,n=>this.shape.check(n));return!r&&e?.extend(null,"Array",""),r}},En=(...t)=>new Sn(t),Hi=S(Sn),Gi=D(t=>ut(t)),Cn=class extends I{constructor(t,e){super(),this.shape=t,this._c=e}check(t,e){let r=t instanceof this.shape&&(this._c==null||this._c(t));return!r&&e?.extend(null,this.shape.name,t?.constructor.name),r}},Xi=(t,e=null)=>new Cn(t,e),gc=S(Cn),qi=Xi(I),Qi=class extends I{constructor(t){super(),this.len=t.length-1,this.args=Ki(...t.slice(-1)),this.res=t[this.len]}check(t,e){let r=t.constructor===Function&&t.length<=this.len;return!r&&e?.extend(null,"function",typeof t),r}},Zi=S(Qi),tl=D(t=>typeof t=="function"),el=class extends I{constructor(t){super(),this.shape=t}check(t,e){let r=Xe(this.shape,n=>n.check(t,e));return!r&&e?.extend(null,"Intersectinon",typeof t),r}},fc=S(el,t=>t.shape.length>0),he=class extends I{constructor(t){super(),this.shape=t}check(t,e){let r=qe(this.shape,n=>n.check(t,e));return e?.extend(null,"Union",typeof t),r}};Ge(he,"_dilutes",!0);var mt=(...t)=>t.findIndex(e=>Xt.check(e))>=0?mt(...t.map(e=>At(e)).map(e=>Xt.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new he(t),Xt=S(he),Dn=()=>!0,qt=D(Dn),rl=S(ir,t=>t.shape===Dn),lr=D(t=>typeof t=="bigint"),nl=D(t=>t===lr),An=D(t=>typeof t=="symbol"),pc=D(t=>t===An),ot=D(t=>typeof t=="number"),xn=D(t=>t===ot),ft=D(t=>typeof t=="string"),In=D(t=>t===ft),ue=D(t=>typeof t=="boolean"),sl=D(t=>t===ue),Un=ae(void 0),wc=S(ce,t=>t.shape.length===1&&t.shape[0]===void 0),mc=ae(void 0),de=ae(null),il=S(ce,t=>t.shape.length===1&&t.shape[0]===null),kc=S(Uint8Array),yc=S(sr,t=>t.shape===Uint8Array),ll=mt(ot,ft,de,Un,lr,ue,An),bc=(()=>{let t=En(qt),e=_n(ft,qt),r=mt(ot,ft,de,ue,t,e);return t.shape=r,e.shape.values=r,r})(),At=t=>{if(qi.check(t))return t;if(Wi.check(t)){let e={};for(let r in t)e[r]=At(t[r]);return $i(e)}else{if(Gi.check(t))return mt(...t.map(At));if(ll.check(t))return ae(t);if(tl.check(t))return S(t)}O()},Lr=Di?()=>{}:(t,e)=>{let r=new Fi;if(!e.check(t,r))throw J(`Expected value to be of type ${e.constructor.name}.
|
|
3
3
|
${r.toString()}`)},ol=class{constructor(t){this.patterns=[],this.$state=t}if(t,e){return this.patterns.push({if:At(t),h:e}),this}else(t){return this.if(qt,t)}done(){return(t,e)=>{for(let r=0;r<this.patterns.length;r++){let n=this.patterns[r];if(n.if.check(t))return n.h(t,e)}throw J("Unhandled pattern")}}},cl=t=>new ol(t),On=cl(qt).if(xn,(t,e)=>Ee(e,Cr,Kt)).if(In,(t,e)=>Ri(e)).if(sl,(t,e)=>Nr(e)).if(nl,(t,e)=>BigInt(Ee(e,Cr,Kt))).if(Xt,(t,e)=>it(e,Ce(e,t.shape))).if(Bi,(t,e)=>{let r={};for(let n in t.shape){let s=t.shape[n];if(Ji.check(s)){if(Nr(e))continue;s=s.shape}r[n]=On(s,e)}return r}).if(Hi,(t,e)=>{let r=[],n=dn(e,0,42);for(let s=0;s<n;s++)r.push(it(e,t.shape));return r}).if(gn,(t,e)=>Ce(e,t.shape)).if(il,(t,e)=>null).if(Zi,(t,e)=>{let r=it(e,t.res);return()=>r}).if(rl,(t,e)=>it(e,Ce(e,[ot,ft,de,Un,lr,ue,En(ot),_n(mt("a","b","c"),ot)]))).if(Yi,(t,e)=>{let r={},n=Ee(e,0,3);for(let s=0;s<n;s++){let i=it(e,t.shape.keys),l=it(e,t.shape.values);r[i]=l}return r}).done(),it=(t,e)=>On(At(e),t),st=typeof document<"u"?document:{},_c=D(t=>t.nodeType===gl),vc=typeof DOMParser<"u"?new DOMParser:null,Sc=D(t=>t.nodeType===hl),Ec=D(t=>t.nodeType===ul),al=t=>Is(t,(e,r)=>`${r}:${e};`).join(""),hl=st.ELEMENT_NODE,ul=st.TEXT_NODE,Cc=st.CDATA_SECTION_NODE,Dc=st.COMMENT_NODE,dl=st.DOCUMENT_NODE,Ac=st.DOCUMENT_TYPE_NODE,gl=st.DOCUMENT_FRAGMENT_NODE,xc=D(t=>t.nodeType===dl),Y=Symbol,Mn=Y(),Tn=Y(),fl=Y(),pl=Y(),wl=Y(),Nn=Y(),ml=Y(),or=Y(),kl=Y(),yl=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());let e=[],r=[],n=0;for(;n<t.length;n++){let s=t[n];if(s===void 0)break;if(s.constructor===String||s.constructor===Number)e.push(s);else if(s.constructor===Object)break}for(n>0&&r.push(e.join(""));n<t.length;n++){let s=t[n];s instanceof Symbol||r.push(s)}return r},Ic=sn(),bl={[Mn]:B("font-weight","bold"),[Tn]:B("font-weight","normal"),[fl]:B("color","blue"),[wl]:B("color","green"),[pl]:B("color","grey"),[Nn]:B("color","red"),[ml]:B("color","purple"),[or]:B("color","orange"),[kl]:B("color","black")},_l=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());let e=[],r=[],n=F(),s=[],i=0;for(;i<t.length;i++){let l=t[i],o=bl[l];if(o!==void 0)n.set(o.left,o.right);else{if(l===void 0)break;if(l.constructor===String||l.constructor===Number){let c=al(n);i>0||c.length>0?(e.push("%c"+l),r.push(c)):e.push(l)}else break}}for(i>0&&(s=r,s.unshift(e.join("")));i<t.length;i++){let l=t[i];l instanceof Symbol||s.push(l)}return s},Ln=xi?_l:yl,vl=(...t)=>{console.log(...Ln(t)),Vn.forEach(e=>e.print(t))},Rn=(...t)=>{console.warn(...Ln(t)),t.unshift(or),Vn.forEach(e=>e.print(t))},Vn=ht(),Fn=t=>({[Symbol.iterator](){return this},next:t}),Sl=(t,e)=>Fn(()=>{let r;do r=t.next();while(!r.done&&!e(r.value));return r}),De=(t,e)=>Fn(()=>{let{done:r,value:n}=t.next();return{done:r,value:r?void 0:e(n)}});var cr=class{constructor(t,e){this.clock=t,this.len=e}},kt=class{constructor(){this.clients=new Map}},pt=(t,e,r)=>e.clients.forEach((n,s)=>{let i=t.doc.store.clients.get(s);if(i!=null){let l=i[i.length-1],o=l.id.clock+l.length;for(let c=0,u=n[c];c<n.length&&u.clock<o;u=n[++c])qn(t,i,u.clock,u.len,r)}}),El=(t,e)=>{let r=0,n=t.length-1;for(;r<=n;){let s=z((r+n)/2),i=t[s],l=i.clock;if(l<=e){if(e<l+i.len)return s;r=s+1}else n=s-1}return null},Nt=(t,e)=>{let r=t.clients.get(e.client);return r!==void 0&&El(r,e.clock)!==null},ar=t=>{t.clients.forEach(e=>{e.sort((s,i)=>s.clock-i.clock);let r,n;for(r=1,n=1;r<e.length;r++){let s=e[n-1],i=e[r];s.clock+s.len>=i.clock?s.len=nt(s.len,i.clock+i.len-s.clock):(n<r&&(e[n]=i),n++)}e.length=n})},Te=t=>{let e=new kt;for(let r=0;r<t.length;r++)t[r].clients.forEach((n,s)=>{if(!e.clients.has(s)){let i=n.slice();for(let l=r+1;l<t.length;l++)Os(i,t[l].clients.get(s)||[]);e.clients.set(s,i)}});return ar(e),e},xt=(t,e,r,n)=>{q(t.clients,e,()=>[]).push(new cr(r,n))},Pn=()=>new kt,Cl=t=>{let e=Pn();return t.clients.forEach((r,n)=>{let s=[];for(let i=0;i<r.length;i++){let l=r[i];if(l.deleted){let o=l.id.clock,c=l.length;if(i+1<r.length)for(let u=r[i+1];i+1<r.length&&u.deleted;u=r[++i+1])c+=u.length;s.push(new cr(o,c))}}s.length>0&&e.clients.set(n,s)}),e},yt=(t,e)=>{p(t.restEncoder,e.clients.size),G(e.clients.entries()).sort((r,n)=>n[0]-r[0]).forEach(([r,n])=>{t.resetDsCurVal(),p(t.restEncoder,r);let s=n.length;p(t.restEncoder,s);for(let i=0;i<s;i++){let l=n[i];t.writeDsClock(l.clock),t.writeDsLen(l.len)}})},ge=t=>{let e=new kt,r=w(t.restDecoder);for(let n=0;n<r;n++){t.resetDsCurVal();let s=w(t.restDecoder),i=w(t.restDecoder);if(i>0){let l=q(e.clients,s,()=>[]);for(let o=0;o<i;o++)l.push(new cr(t.readDsClock(),t.readDsLen()))}}return e},Rr=(t,e,r)=>{let n=new kt,s=w(t.restDecoder);for(let i=0;i<s;i++){t.resetDsCurVal();let l=w(t.restDecoder),o=w(t.restDecoder),c=r.clients.get(l)||[],u=_(r,l);for(let a=0;a<o;a++){let h=t.readDsClock(),d=h+t.readDsLen();if(h<u){u<d&&xt(n,l,u,d-u);let g=$(c,h),f=c[g];for(!f.deleted&&f.id.clock<h&&(c.splice(g+1,0,ne(e,f,h-f.id.clock)),g++);g<c.length&&(f=c[g++],f.id.clock<d);)f.deleted||(d<f.id.clock+f.length&&c.splice(g,0,ne(e,f,d-f.id.clock)),f.delete(e))}else xt(n,l,h,d-h)}}if(n.clients.size>0){let i=new et;return p(i.restEncoder,0),yt(i,n),i.toUint8Array()}return null},Uc=(t,e)=>{if(t.clients.size!==e.clients.size)return!1;for(let[r,n]of t.clients.entries()){let s=e.clients.get(r);if(s===void 0||n.length!==s.length)return!1;for(let i=0;i<n.length;i++){let l=n[i],o=s[i];if(l.clock!==o.clock||l.len!==o.len)return!1}}return!0},jn=nn,fe=class zn extends Qr{constructor({guid:e=ui(),collectionid:r=null,gc:n=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:l=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=s,this.clientID=jn(),this.guid=e,this.collectionid=r,this.share=new Map,this.store=new Gn,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=l,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Mr(u=>{this.on("load",()=>{this.isLoaded=!0,u(this)})});let c=()=>Mr(u=>{let a=h=>{(h===void 0||h===!0)&&(this.off("sync",a),u())};this.on("sync",a)});this.on("sync",u=>{u===!1&&this.isSynced&&(this.whenSynced=c()),this.isSynced=u===void 0||u===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=c()}load(){let e=this._item;e!==null&&!this.shouldLoad&&y(e.parent.doc,r=>{r.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(G(this.subdocs).map(e=>e.guid))}transact(e,r=null){return y(this,e,r)}get(e,r=C){let n=q(this.share,e,()=>{let i=new r;return i._integrate(this,null),i}),s=n.constructor;if(r!==C&&s!==r)if(s===C){let i=new r;i._map=n._map,n._map.forEach(l=>{for(;l!==null;l=l.left)l.parent=i}),i._start=n._start;for(let l=i._start;l!==null;l=l.right)l.parent=i;return i._length=n._length,this.share.set(e,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=""){return this.get(e,us)}getText(e=""){return this.get(e,kr)}getMap(e=""){return this.get(e,mr)}getXmlElement(e=""){return this.get(e,yr)}getXmlFragment(e=""){return this.get(e,be)}toJSON(){let e={};return this.share.forEach((r,n)=>{e[n]=r.toJSON()}),e}destroy(){this.isDestroyed=!0,G(this.subdocs).forEach(r=>r.destroy());let e=this._item;if(e!==null){this._item=null;let r=e.content;r.doc=new zn({guid:this.guid,...r.opts,shouldLoad:!1}),r.doc._item=e,y(e.parent.doc,n=>{let s=r.doc;e.deleted||n.subdocsAdded.add(s),n.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}},Jn=class{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return w(this.restDecoder)}readDsLen(){return w(this.restDecoder)}},Dl=class extends Jn{readLeftID(){return m(w(this.restDecoder),w(this.restDecoder))}readRightID(){return m(w(this.restDecoder),w(this.restDecoder))}readClient(){return w(this.restDecoder)}readInfo(){return dt(this.restDecoder)}readString(){return tt(this.restDecoder)}readParentInfo(){return w(this.restDecoder)===1}readTypeRef(){return w(this.restDecoder)}readLen(){return w(this.restDecoder)}readAny(){return Ct(this.restDecoder)}readBuf(){return Ti(T(this.restDecoder))}readJSON(){return JSON.parse(tt(this.restDecoder))}readKey(){return tt(this.restDecoder)}},Al=class{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=w(this.restDecoder),this.dsCurrVal}readDsLen(){let t=w(this.restDecoder)+1;return this.dsCurrVal+=t,t}},X=class extends Al{constructor(t){super(t),this.keys=[],w(t),this.keyClockDecoder=new Se(T(t)),this.clientDecoder=new $t(T(t)),this.leftClockDecoder=new Se(T(t)),this.rightClockDecoder=new Se(T(t)),this.infoDecoder=new Or(T(t),dt),this.stringDecoder=new ci(T(t)),this.parentInfoDecoder=new Or(T(t),dt),this.typeRefDecoder=new $t(T(t)),this.lenDecoder=new $t(T(t))}readLeftID(){return new ct(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ct(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Ct(this.restDecoder)}readBuf(){return T(this.restDecoder)}readJSON(){return Ct(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},$n=class{constructor(){this.restEncoder=wt()}toUint8Array(){return R(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){p(this.restEncoder,t)}writeDsLen(t){p(this.restEncoder,t)}},pe=class extends $n{writeLeftID(t){p(this.restEncoder,t.client),p(this.restEncoder,t.clock)}writeRightID(t){p(this.restEncoder,t.client),p(this.restEncoder,t.clock)}writeClient(t){p(this.restEncoder,t)}writeInfo(t){St(this.restEncoder,t)}writeString(t){Z(this.restEncoder,t)}writeParentInfo(t){p(this.restEncoder,t?1:0)}writeTypeRef(t){p(this.restEncoder,t)}writeLen(t){p(this.restEncoder,t)}writeAny(t){Et(this.restEncoder,t)}writeBuf(t){M(this.restEncoder,t)}writeJSON(t){Z(this.restEncoder,JSON.stringify(t))}writeKey(t){Z(this.restEncoder,t)}},hr=class{constructor(){this.restEncoder=wt(),this.dsCurrVal=0}toUint8Array(){return R(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let e=t-this.dsCurrVal;this.dsCurrVal=t,p(this.restEncoder,e)}writeDsLen(t){t===0&&O(),p(this.restEncoder,t-1),this.dsCurrVal+=t}},et=class extends hr{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new ve,this.clientEncoder=new Jt,this.leftClockEncoder=new ve,this.rightClockEncoder=new ve,this.infoEncoder=new xr(St),this.stringEncoder=new Qs,this.parentInfoEncoder=new xr(St),this.typeRefEncoder=new Jt,this.lenEncoder=new Jt}toUint8Array(){let t=wt();return p(t,0),M(t,this.keyClockEncoder.toUint8Array()),M(t,this.clientEncoder.toUint8Array()),M(t,this.leftClockEncoder.toUint8Array()),M(t,this.rightClockEncoder.toUint8Array()),M(t,R(this.infoEncoder)),M(t,this.stringEncoder.toUint8Array()),M(t,R(this.parentInfoEncoder)),M(t,this.typeRefEncoder.toUint8Array()),M(t,this.lenEncoder.toUint8Array()),Mt(t,R(this.restEncoder)),R(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){Et(this.restEncoder,t)}writeBuf(t){M(this.restEncoder,t)}writeJSON(t){Et(this.restEncoder,t)}writeKey(t){let e=this.keyMap.get(t);e===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(e)}},xl=(t,e,r,n)=>{n=nt(n,e[0].id.clock);let s=$(e,n);p(t.restEncoder,e.length-s),t.writeClient(r),p(t.restEncoder,n);let i=e[s];i.write(t,n-i.id.clock);for(let l=s+1;l<e.length;l++)e[l].write(t,0)},ur=(t,e,r)=>{let n=new Map;r.forEach((s,i)=>{_(e,i)>s&&n.set(i,s)}),we(e).forEach((s,i)=>{r.has(i)||n.set(i,0)}),p(t.restEncoder,n.size),G(n.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{xl(t,e.clients.get(s),s,i)})},Il=(t,e)=>{let r=F(),n=w(t.restDecoder);for(let s=0;s<n;s++){let i=w(t.restDecoder),l=new Array(i),o=t.readClient(),c=w(t.restDecoder);r.set(o,{i:0,refs:l});for(let u=0;u<i;u++){let a=t.readInfo();switch(31&a){case 0:{let h=t.readLen();l[u]=new L(m(o,c),h),c+=h;break}case 10:{let h=w(t.restDecoder);l[u]=new N(m(o,c),h),c+=h;break}default:{let h=(a&192)===0,d=new b(m(o,c),null,(a&128)===128?t.readLeftID():null,null,(a&64)===64?t.readRightID():null,h?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,h&&(a&32)===32?t.readString():null,Es(t,a));l[u]=d,c+=d.length}}}}return r},Ul=(t,e,r)=>{let n=[],s=G(r.keys()).sort((g,f)=>g-f);if(s.length===0)return null;let i=()=>{if(s.length===0)return null;let g=r.get(s[s.length-1]);for(;g.refs.length===g.i;)if(s.pop(),s.length>0)g=r.get(s[s.length-1]);else return null;return g},l=i();if(l===null)return null;let o=new Gn,c=new Map,u=(g,f)=>{let k=c.get(g);(k==null||k>f)&&c.set(g,f)},a=l.refs[l.i++],h=new Map,d=()=>{for(let g of n){let f=g.id.client,k=r.get(f);k?(k.i--,o.clients.set(f,k.refs.slice(k.i)),r.delete(f),k.i=0,k.refs=[]):o.clients.set(f,[g]),s=s.filter(V=>V!==f)}n.length=0};for(;;){if(a.constructor!==N){let g=q(h,a.id.client,()=>_(e,a.id.client))-a.id.clock;if(g<0)n.push(a),u(a.id.client,a.id.clock-1),d();else{let f=a.getMissing(t,e);if(f!==null){n.push(a);let k=r.get(f)||{refs:[],i:0};if(k.refs.length===k.i)u(f,_(e,f)),d();else{a=k.refs[k.i++];continue}}else(g===0||g<a.length)&&(a.integrate(t,g),h.set(a.id.client,a.id.clock+a.length))}}if(n.length>0)a=n.pop();else if(l!==null&&l.i<l.refs.length)a=l.refs[l.i++];else{if(l=i(),l===null)break;a=l.refs[l.i++]}}if(o.clients.size>0){let g=new et;return ur(g,o,new Map),p(g.restEncoder,0),{missing:c,update:g.toUint8Array()}}return null},Ol=(t,e)=>ur(t,e.doc.store,e.beforeState),Ml=(t,e,r,n=new X(t))=>y(e,s=>{s.local=!1;let i=!1,l=s.doc,o=l.store,c=Il(n,l),u=Ul(s,o,c),a=o.pendingStructs;if(a){for(let[d,g]of a.missing)if(g<_(o,d)){i=!0;break}if(u){for(let[d,g]of u.missing){let f=a.missing.get(d);(f==null||f>g)&&a.missing.set(d,g)}a.update=Zt([a.update,u.update])}}else o.pendingStructs=u;let h=Rr(n,s,o);if(o.pendingDs){let d=new X(W(o.pendingDs));w(d.restDecoder);let g=Rr(d,s,o);h&&g?o.pendingDs=Zt([h,g]):o.pendingDs=h||g}else o.pendingDs=h;if(i){let d=o.pendingStructs.update;o.pendingStructs=null,Tl(s.doc,d)}},r,!1);var Tl=(t,e,r,n=X)=>{let s=W(e);Ml(s,t,r,new n(s))};var Nl=(t,e,r=new Map)=>{ur(t,e.store,r),yt(t,Cl(e.store))},Oc=(t,e=new Uint8Array([0]),r=new et)=>{let n=Bn(e);Nl(r,t,n);let s=[r.toUint8Array()];if(t.store.pendingDs&&s.push(t.store.pendingDs),t.store.pendingStructs&&s.push(eo(t.store.pendingStructs.update,e)),s.length>1){if(r.constructor===pe)return Zl(s.map((i,l)=>l===0?i:no(i)));if(r.constructor===et)return Zt(s)}return s[0]};var Ll=t=>{let e=new Map,r=w(t.restDecoder);for(let n=0;n<r;n++){let s=w(t.restDecoder),i=w(t.restDecoder);e.set(s,i)}return e},Bn=t=>Ll(new Jn(W(t))),Wn=(t,e)=>(p(t.restEncoder,e.size),G(e.entries()).sort((r,n)=>n[0]-r[0]).forEach(([r,n])=>{p(t.restEncoder,r),p(t.restEncoder,n)}),t),Rl=(t,e)=>Wn(t,we(e.store)),Vl=(t,e=new hr)=>(t instanceof Map?Wn(e,t):Rl(e,t),e.toUint8Array()),Mc=t=>Vl(t,new $n),Fl=class{constructor(){this.l=[]}},Vr=()=>new Fl,Fr=(t,e)=>t.l.push(e),Pr=(t,e)=>{let r=t.l,n=r.length;t.l=r.filter(s=>e!==s),n===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},Yn=(t,e,r)=>rr(t.l,[e,r]),ct=class{constructor(t,e){this.client=t,this.clock=e}},Vt=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,m=(t,e)=>new ct(t,e),jr=(t,e)=>{p(t,e.client),p(t,e.clock)},zr=t=>m(w(t),w(t)),Kn=t=>{for(let[e,r]of t.doc.share.entries())if(r===t)return e;throw O()},Qt=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};var Hn=class{constructor(t,e,r,n=0){this.type=t,this.tname=e,this.item=r,this.assoc=n}};var Pl=class{constructor(t,e,r=0){this.type=t,this.index=e,this.assoc=r}},jl=(t,e,r=0)=>new Pl(t,e,r),Ft=(t,e,r)=>{let n=null,s=null;return t._item===null?s=Kn(t):n=m(t._item.id.client,t._item.id.clock),new Hn(n,s,e,r)},Tc=(t,e,r=0)=>{let n=t._start;if(r<0){if(e===0)return Ft(t,null,r);e--}for(;n!==null;){if(!n.deleted&&n.countable){if(n.length>e)return Ft(t,m(n.id.client,n.id.clock+e),r);e-=n.length}if(n.right===null&&r<0)return Ft(t,n.lastId,r);n=n.right}return Ft(t,null,r)},zl=(t,e)=>{let{type:r,tname:n,item:s,assoc:i}=e;if(s!==null)p(t,0),jr(t,s);else if(n!==null)St(t,1),Z(t,n);else if(r!==null)St(t,2),jr(t,r);else throw O();return se(t,i),t},Nc=t=>{let e=wt();return zl(e,t),R(e)},Jl=t=>{let e=null,r=null,n=null;switch(w(t)){case 0:n=zr(t);break;case 1:r=tt(t);break;case 2:e=zr(t)}let s=rn(t)?oe(t):0;return new Hn(e,r,n,s)},Lc=t=>Jl(W(t)),$l=(t,e)=>{let r=at(t,e),n=e.clock-r.id.clock;return{item:r,diff:n}},Rc=(t,e,r=!0)=>{let n=e.store,s=t.item,i=t.type,l=t.tname,o=t.assoc,c=null,u=0;if(s!==null){if(_(n,s.client)<=s.clock)return null;let a=r?Ke(n,s):$l(n,s),h=a.item;if(!(h instanceof b))return null;if(c=h.parent,c._item===null||!c._item.deleted){u=h.deleted||!h.countable?0:a.diff+(o>=0?0:1);let d=h.left;for(;d!==null;)!d.deleted&&d.countable&&(u+=d.length),d=d.left}}else{if(l!==null)c=e.get(l);else if(i!==null){if(_(n,i.client)<=i.clock)return null;let{item:a}=r?Ke(n,i):{item:at(n,i)};if(a instanceof b&&a.content instanceof Q)c=a.content.type;else return null}else throw O();o>=0?u=c._length:u=0}return jl(c,u,t.assoc)};var Bl=class{constructor(t,e){this.ds=t,this.sv=e}};var Wl=(t,e)=>new Bl(t,e),Vc=Wl(Pn(),new Map);var lt=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Nt(e.ds,t.id),Ne=(t,e)=>{let r=q(t.meta,Ne,ht),n=t.doc.store;r.has(e)||(e.sv.forEach((s,i)=>{s<_(n,i)&&U(t,m(i,s))}),pt(t,e.ds,s=>{}),r.add(e))};var Gn=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},we=t=>{let e=new Map;return t.clients.forEach((r,n)=>{let s=r[r.length-1];e.set(n,s.id.clock+s.length)}),e},_=(t,e)=>{let r=t.clients.get(e);if(r===void 0)return 0;let n=r[r.length-1];return n.id.clock+n.length},Xn=(t,e)=>{let r=t.clients.get(e.id.client);if(r===void 0)r=[],t.clients.set(e.id.client,r);else{let n=r[r.length-1];if(n.id.clock+n.length!==e.id.clock)throw O()}r.push(e)},$=(t,e)=>{let r=0,n=t.length-1,s=t[n],i=s.id.clock;if(i===e)return n;let l=z(e/(i+s.length-1)*n);for(;r<=n;){if(s=t[l],i=s.id.clock,i<=e){if(e<i+s.length)return l;r=l+1}else n=l-1;l=z((r+n)/2)}throw O()},Yl=(t,e)=>{let r=t.clients.get(e.client);return r[$(r,e.clock)]},at=Yl,Le=(t,e,r)=>{let n=$(e,r),s=e[n];return s.id.clock<r&&s instanceof b?(e.splice(n+1,0,ne(t,s,r-s.id.clock)),n+1):n},U=(t,e)=>{let r=t.doc.store.clients.get(e.client);return r[Le(t,r,e.clock)]},Jr=(t,e,r)=>{let n=e.clients.get(r.client),s=$(n,r.clock),i=n[s];return r.clock!==i.id.clock+i.length-1&&i.constructor!==L&&n.splice(s+1,0,ne(t,i,r.clock-i.id.clock+1)),i},Kl=(t,e,r)=>{let n=t.clients.get(e.id.client);n[$(n,e.id.clock)]=r},qn=(t,e,r,n,s)=>{if(n===0)return;let i=r+n,l=Le(t,e,r),o;do o=e[l++],i<o.id.clock+o.length&&Le(t,e,i),s(o);while(l<e.length&&e[l].id.clock<i)},Hl=class{constructor(t,e,r){this.doc=t,this.deleteSet=new kt,this.beforeState=we(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=e,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},$r=(t,e)=>e.deleteSet.clients.size===0&&!Us(e.afterState,(r,n)=>e.beforeState.get(n)!==r)?!1:(ar(e.deleteSet),Ol(t,e),yt(t,e.deleteSet),!0),Br=(t,e,r)=>{let n=e._item;(n===null||n.id.clock<(t.beforeState.get(n.id.client)||0)&&!n.deleted)&&q(t.changed,e,ht).add(r)},Wt=(t,e)=>{let r=t[e],n=t[e-1],s=e;for(;s>0;r=n,n=t[--s-1]){if(n.deleted===r.deleted&&n.constructor===r.constructor&&n.mergeWith(r)){r instanceof b&&r.parentSub!==null&&r.parent._map.get(r.parentSub)===r&&r.parent._map.set(r.parentSub,n);continue}break}let i=e-s;return i&&t.splice(e+1-i,i),i},Gl=(t,e,r)=>{for(let[n,s]of t.clients.entries()){let i=e.clients.get(n);for(let l=s.length-1;l>=0;l--){let o=s[l],c=o.clock+o.len;for(let u=$(i,o.clock),a=i[u];u<i.length&&a.id.clock<c;a=i[++u]){let h=i[u];if(o.clock+o.len<=h.id.clock)break;h instanceof b&&h.deleted&&!h.keep&&r(h)&&h.gc(e,!1)}}}},Xl=(t,e)=>{t.clients.forEach((r,n)=>{let s=e.clients.get(n);for(let i=r.length-1;i>=0;i--){let l=r[i],o=Zr(s.length-1,1+$(s,l.clock+l.len-1));for(let c=o,u=s[c];c>0&&u.id.clock>=l.clock;u=s[c])c-=1+Wt(s,c)}})};var Qn=(t,e)=>{if(e<t.length){let r=t[e],n=r.doc,s=n.store,i=r.deleteSet,l=r._mergeStructs;try{ar(i),r.afterState=we(r.doc.store),n.emit("beforeObserverCalls",[r,n]);let o=[];r.changed.forEach((c,u)=>o.push(()=>{(u._item===null||!u._item.deleted)&&u._callObserver(r,c)})),o.push(()=>{r.changedParentTypes.forEach((c,u)=>{u._dEH.l.length>0&&(u._item===null||!u._item.deleted)&&(c=c.filter(a=>a.target._item===null||!a.target._item.deleted),c.forEach(a=>{a.currentTarget=u,a._path=null}),c.sort((a,h)=>a.path.length-h.path.length),Yn(u._dEH,c,r))})}),o.push(()=>n.emit("afterTransaction",[r,n])),rr(o,[]),r._needFormattingCleanup&&ko(r)}finally{n.gc&&Gl(i,s,n.gcFilter),Xl(i,s),r.afterState.forEach((a,h)=>{let d=r.beforeState.get(h)||0;if(d!==a){let g=s.clients.get(h),f=nt($(g,d),1);for(let k=g.length-1;k>=f;)k-=1+Wt(g,k)}});for(let a=l.length-1;a>=0;a--){let{client:h,clock:d}=l[a].id,g=s.clients.get(h),f=$(g,d);f+1<g.length&&Wt(g,f+1)>1||f>0&&Wt(g,f)}if(!r.local&&r.afterState.get(n.clientID)!==r.beforeState.get(n.clientID)&&(vl(or,Mn,"[yjs] ",Tn,Nn,"Changed the client-id because another client seems to be using it."),n.clientID=jn()),n.emit("afterTransactionCleanup",[r,n]),n._observers.has("update")){let a=new pe;$r(a,r)&&n.emit("update",[a.toUint8Array(),r.origin,n,r])}if(n._observers.has("updateV2")){let a=new et;$r(a,r)&&n.emit("updateV2",[a.toUint8Array(),r.origin,n,r])}let{subdocsAdded:o,subdocsLoaded:c,subdocsRemoved:u}=r;(o.size>0||u.size>0||c.size>0)&&(o.forEach(a=>{a.clientID=n.clientID,a.collectionid==null&&(a.collectionid=n.collectionid),n.subdocs.add(a)}),u.forEach(a=>n.subdocs.delete(a)),n.emit("subdocs",[{loaded:c,added:o,removed:u},n,r]),u.forEach(a=>a.destroy())),t.length<=e+1?(n._transactionCleanups=[],n.emit("afterAllTransactions",[n,t])):Qn(t,e+1)}}},y=(t,e,r=null,n=!0)=>{let s=t._transactionCleanups,i=!1,l=null;t._transaction===null&&(i=!0,t._transaction=new Hl(t,r,n),s.push(t._transaction),s.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{l=e(t._transaction)}finally{if(i){let o=t._transaction===s[0];t._transaction=null,o&&Qn(s,0)}}return l},ql=class{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}},Wr=(t,e,r)=>{pt(t,r.deletions,n=>{n instanceof b&&e.scope.some(s=>s===t.doc||Qt(s,n))&&Sr(n,!1)})},Yr=(t,e,r)=>{let n=null,s=t.doc,i=t.scope;y(s,o=>{for(;e.length>0&&t.currStackItem===null;){let c=s.store,u=e.pop(),a=new Set,h=[],d=!1;pt(o,u.insertions,g=>{if(g instanceof b){if(g.redone!==null){let{item:f,diff:k}=Ke(c,g.id);k>0&&(f=U(o,m(f.id.client,f.id.clock+k))),g=f}!g.deleted&&i.some(f=>f===o.doc||Qt(f,g))&&h.push(g)}}),pt(o,u.deletions,g=>{g instanceof b&&i.some(f=>f===o.doc||Qt(f,g))&&!Nt(u.insertions,g.id)&&a.add(g)}),a.forEach(g=>{d=Ss(o,g,a,u.insertions,t.ignoreRemoteMapChanges,t)!==null||d});for(let g=h.length-1;g>=0;g--){let f=h[g];t.deleteFilter(f)&&(f.delete(o),d=!0)}t.currStackItem=d?u:null}o.changed.forEach((c,u)=>{c.has(null)&&u._searchMarker&&(u._searchMarker.length=0)}),n=o},t);let l=t.currStackItem;if(l!=null){let o=n.changedParentTypes;t.emit("stack-item-popped",[{stackItem:l,type:r,changedParentTypes:o,origin:t},t]),t.currStackItem=null}return l},Fc=class extends Qr{constructor(t,{captureTimeout:e=500,captureTransaction:r=o=>!0,deleteFilter:n=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:i=!1,doc:l=ut(t)?t[0].doc:t instanceof fe?t:t.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(t),this.deleteFilter=n,s.add(this),this.trackedOrigins=s,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=i,this.captureTimeout=e,this.afterTransactionHandler=o=>{if(!this.captureTransaction(o)||!this.scope.some(k=>o.changedParentTypes.has(k)||k===this.doc)||!this.trackedOrigins.has(o.origin)&&(!o.origin||!this.trackedOrigins.has(o.origin.constructor)))return;let c=this.undoing,u=this.redoing,a=c?this.redoStack:this.undoStack;c?this.stopCapturing():u||this.clear(!1,!0);let h=new kt;o.afterState.forEach((k,V)=>{let v=o.beforeState.get(V)||0,Er=k-v;Er>0&&xt(h,V,v,Er)});let d=sn(),g=!1;if(this.lastChange>0&&d-this.lastChange<this.captureTimeout&&a.length>0&&!c&&!u){let k=a[a.length-1];k.deletions=Te([k.deletions,o.deleteSet]),k.insertions=Te([k.insertions,h])}else a.push(new ql(o.deleteSet,h)),g=!0;!c&&!u&&(this.lastChange=d),pt(o,o.deleteSet,k=>{k instanceof b&&this.scope.some(V=>V===o.doc||Qt(V,k))&&Sr(k,!0)});let f=[{stackItem:a[a.length-1],origin:o.origin,type:c?"redo":"undo",changedParentTypes:o.changedParentTypes},this];g?this.emit("stack-item-added",f):this.emit("stack-item-updated",f)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(t){let e=new Set(this.scope);t=ut(t)?t:[t],t.forEach(r=>{e.has(r)||(e.add(r),(r instanceof C?r.doc!==this.doc:r!==this.doc)&&Rn("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,e=!0){(t&&this.canUndo()||e&&this.canRedo())&&this.doc.transact(r=>{t&&(this.undoStack.forEach(n=>Wr(r,this,n)),this.undoStack=[]),e&&(this.redoStack.forEach(n=>Wr(r,this,n)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=Yr(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=Yr(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}};function*Ql(t){let e=w(t.restDecoder);for(let r=0;r<e;r++){let n=w(t.restDecoder),s=t.readClient(),i=w(t.restDecoder);for(let l=0;l<n;l++){let o=t.readInfo();if(o===10){let c=w(t.restDecoder);yield new N(m(s,i),c),i+=c}else if((31&o)!==0){let c=(o&192)===0,u=new b(m(s,i),null,(o&128)===128?t.readLeftID():null,null,(o&64)===64?t.readRightID():null,c?t.readParentInfo()?t.readString():t.readLeftID():null,c&&(o&32)===32?t.readString():null,Es(t,o));yield u,i+=u.length}else{let c=t.readLen();yield new L(m(s,i),c),i+=c}}}}var Lt=class{constructor(t,e){this.gen=Ql(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===N);return this.curr}};var Pc=(t,e=X)=>{let r=[],n=new e(W(t)),s=new Lt(n,!1);for(let i=s.curr;i!==null;i=s.next())r.push(i);return{structs:r,ds:ge(n)}},dr=class{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}},Zl=t=>Zt(t,Dl,pe),jc=(t,e=hr,r=X)=>{let n=new e,s=new Lt(new r(W(t)),!1),i=s.curr;if(i!==null){let l=0,o=i.id.client,c=i.id.clock!==0,u=c?0:i.id.clock+i.length;for(;i!==null;i=s.next())o!==i.id.client&&(u!==0&&(l++,p(n.restEncoder,o),p(n.restEncoder,u)),o=i.id.client,u=0,c=i.id.clock!==0),i.constructor===N&&(c=!0),c||(u=i.id.clock+i.length);u!==0&&(l++,p(n.restEncoder,o),p(n.restEncoder,u));let a=wt();return p(a,l),Ks(a,n.restEncoder),n.restEncoder=a,n.toUint8Array()}else return p(n.restEncoder,0),n.toUint8Array()};var to=(t,e)=>{if(t.constructor===L){let{client:r,clock:n}=t.id;return new L(m(r,n+e),t.length-e)}else if(t.constructor===N){let{client:r,clock:n}=t.id;return new N(m(r,n+e),t.length-e)}else{let r=t,{client:n,clock:s}=r.id;return new b(m(n,s+e),null,m(n,s+e-1),null,r.rightOrigin,r.parent,r.parentSub,r.content.splice(e))}},Zt=(t,e=X,r=et)=>{if(t.length===1)return t[0];let n=t.map(a=>new e(W(a))),s=n.map(a=>new Lt(a,!0)),i=null,l=new r,o=new dr(l);for(;s=s.filter(a=>a.curr!==null),s.sort((a,h)=>{if(a.curr.id.client===h.curr.id.client){let d=a.curr.id.clock-h.curr.id.clock;return d===0?a.curr.constructor===h.curr.constructor?0:a.curr.constructor===N?1:-1:d}else return h.curr.id.client-a.curr.id.client}),s.length!==0;){let a=s[0],h=a.curr.id.client;if(i!==null){let d=a.curr,g=!1;for(;d!==null&&d.id.clock+d.length<=i.struct.id.clock+i.struct.length&&d.id.client>=i.struct.id.client;)d=a.next(),g=!0;if(d===null||d.id.client!==h||g&&d.id.clock>i.struct.id.clock+i.struct.length)continue;if(h!==i.struct.id.client)K(o,i.struct,i.offset),i={struct:d,offset:0},a.next();else if(i.struct.id.clock+i.struct.length<d.id.clock)if(i.struct.constructor===N)i.struct.length=d.id.clock+d.length-i.struct.id.clock;else{K(o,i.struct,i.offset);let f=d.id.clock-i.struct.id.clock-i.struct.length;i={struct:new N(m(h,i.struct.id.clock+i.struct.length),f),offset:0}}else{let f=i.struct.id.clock+i.struct.length-d.id.clock;f>0&&(i.struct.constructor===N?i.struct.length-=f:d=to(d,f)),i.struct.mergeWith(d)||(K(o,i.struct,i.offset),i={struct:d,offset:0},a.next())}}else i={struct:a.curr,offset:0},a.next();for(let d=a.curr;d!==null&&d.id.client===h&&d.id.clock===i.struct.id.clock+i.struct.length&&d.constructor!==N;d=a.next())K(o,i.struct,i.offset),i={struct:d,offset:0}}i!==null&&(K(o,i.struct,i.offset),i=null),gr(o);let c=n.map(a=>ge(a)),u=Te(c);return yt(l,u),l.toUint8Array()},eo=(t,e,r=X,n=et)=>{let s=Bn(e),i=new n,l=new dr(i),o=new r(W(t)),c=new Lt(o,!1);for(;c.curr;){let a=c.curr,h=a.id.client,d=s.get(h)||0;if(c.curr.constructor===N){c.next();continue}if(a.id.clock+a.length>d)for(K(l,a,nt(d-a.id.clock,0)),c.next();c.curr&&c.curr.id.client===h;)K(l,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===h&&c.curr.id.clock+c.curr.length<=d;)c.next()}gr(l);let u=ge(o);return yt(i,u),i.toUint8Array()};var Zn=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:R(t.encoder.restEncoder)}),t.encoder.restEncoder=wt(),t.written=0)},K=(t,e,r)=>{t.written>0&&t.currClient!==e.id.client&&Zn(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),p(t.encoder.restEncoder,e.id.clock+r)),e.write(t.encoder,r),t.written++},gr=t=>{Zn(t);let e=t.encoder.restEncoder;p(e,t.clientStructs.length);for(let r=0;r<t.clientStructs.length;r++){let n=t.clientStructs[r];p(e,n.written),Mt(e,n.restEncoder)}},ro=(t,e,r,n)=>{let s=new r(W(t)),i=new Lt(s,!1),l=new n,o=new dr(l);for(let u=i.curr;u!==null;u=i.next())K(o,e(u),0);gr(o);let c=ge(s);return yt(l,c),l.toUint8Array()};var no=t=>ro(t,vi,X,pe),Kr="You must not compute changes after the event-handler fired.",me=class{constructor(t,e){this.target=t,this.currentTarget=t,this.transaction=e,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=so(this.currentTarget,this.target))}deletes(t){return Nt(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw J(Kr);let t=new Map,e=this.target;this.transaction.changed.get(e).forEach(r=>{if(r!==null){let n=e._map.get(r),s,i;if(this.adds(n)){let l=n.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(n))if(l!==null&&this.deletes(l))s="delete",i=_e(l.content.getContent());else return;else l!==null&&this.deletes(l)?(s="update",i=_e(l.content.getContent())):(s="add",i=void 0)}else if(this.deletes(n))s="delete",i=_e(n.content.getContent());else return;t.set(r,{action:s,oldValue:i})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw J(Kr);let e=this.target,r=ht(),n=ht(),s=[];if(t={added:r,deleted:n,delta:s,keys:this.keys},this.transaction.changed.get(e).has(null)){let i=null,l=()=>{i&&s.push(i)};for(let o=e._start;o!==null;o=o.right)o.deleted?this.deletes(o)&&!this.adds(o)&&((i===null||i.delete===void 0)&&(l(),i={delete:0}),i.delete+=o.length,n.add(o)):this.adds(o)?((i===null||i.insert===void 0)&&(l(),i={insert:[]}),i.insert=i.insert.concat(o.content.getContent()),r.add(o)):((i===null||i.retain===void 0)&&(l(),i={retain:0}),i.retain+=o.length);i!==null&&i.retain===void 0&&l()}this._changes=t}return t}},so=(t,e)=>{let r=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)r.unshift(e._item.parentSub);else{let n=0,s=e._item.parent._start;for(;s!==e._item&&s!==null;)!s.deleted&&s.countable&&(n+=s.length),s=s.right;r.unshift(n)}e=e._item.parent}return r},x=()=>{Rn("Invalid access: Add Yjs type to a document before reading data.")},ts=80,fr=0,io=class{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=fr++}},lo=t=>{t.timestamp=fr++},es=(t,e,r)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=r,t.timestamp=fr++},oo=(t,e,r)=>{if(t.length>=ts){let n=t.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return es(n,e,r),n}else{let n=new io(e,r);return t.push(n),n}},ke=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;let r=t._searchMarker.length===0?null:t._searchMarker.reduce((i,l)=>zt(e-i.index)<zt(e-l.index)?i:l),n=t._start,s=0;for(r!==null&&(n=r.p,s=r.index,lo(r));n.right!==null&&s<e;){if(!n.deleted&&n.countable){if(e<s+n.length)break;s+=n.length}n=n.right}for(;n.left!==null&&s>e;)n=n.left,!n.deleted&&n.countable&&(s-=n.length);for(;n.left!==null&&n.left.id.client===n.id.client&&n.left.id.clock+n.left.length===n.id.clock;)n=n.left,!n.deleted&&n.countable&&(s-=n.length);return r!==null&&zt(r.index-s)<n.parent.length/ts?(es(r,n,s),r):oo(t._searchMarker,n,s)},It=(t,e,r)=>{for(let n=t.length-1;n>=0;n--){let s=t[n];if(r>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){t.splice(n,1);continue}s.p=i,i.marker=!0}(e<s.index||r>0&&e===s.index)&&(s.index=nt(e,s.index+r))}};var ye=(t,e,r)=>{let n=t,s=e.changedParentTypes;for(;q(s,t,()=>[]).push(r),t._item!==null;)t=t._item.parent;Yn(n._eH,r,e)},C=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Vr(),this._dEH=Vr(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw P()}clone(){throw P()}_write(t){}get _first(){let t=this._start;for(;t!==null&&t.deleted;)t=t.right;return t}_callObserver(t,e){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){Fr(this._eH,t)}observeDeep(t){Fr(this._dEH,t)}unobserve(t){Pr(this._eH,t)}unobserveDeep(t){Pr(this._dEH,t)}toJSON(){}},rs=(t,e,r)=>{t.doc??x(),e<0&&(e=t._length+e),r<0&&(r=t._length+r);let n=r-e,s=[],i=t._start;for(;i!==null&&n>0;){if(i.countable&&!i.deleted){let l=i.content.getContent();if(l.length<=e)e-=l.length;else{for(let o=e;o<l.length&&n>0;o++)s.push(l[o]),n--;e=0}}i=i.right}return s},ns=t=>{t.doc??x();let e=[],r=t._start;for(;r!==null;){if(r.countable&&!r.deleted){let n=r.content.getContent();for(let s=0;s<n.length;s++)e.push(n[s])}r=r.right}return e};var Ut=(t,e)=>{let r=0,n=t._start;for(t.doc??x();n!==null;){if(n.countable&&!n.deleted){let s=n.content.getContent();for(let i=0;i<s.length;i++)e(s[i],r++,t)}n=n.right}},ss=(t,e)=>{let r=[];return Ut(t,(n,s)=>{r.push(e(n,s,t))}),r},co=t=>{let e=t._start,r=null,n=0;return{[Symbol.iterator](){return this},next:()=>{if(r===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};r=e.content.getContent(),n=0,e=e.right}let s=r[n++];return r.length<=n&&(r=null),{done:!1,value:s}}}},is=(t,e)=>{t.doc??x();let r=ke(t,e),n=t._start;for(r!==null&&(n=r.p,e-=r.index);n!==null;n=n.right)if(!n.deleted&&n.countable){if(e<n.length)return n.content.getContent()[e];e-=n.length}},te=(t,e,r,n)=>{let s=r,i=t.doc,l=i.clientID,o=i.store,c=r===null?e._start:r.right,u=[],a=()=>{u.length>0&&(s=new b(m(l,_(o,l)),s,s&&s.lastId,c,c&&c.id,e,null,new re(u)),s.integrate(t,0),u=[])};n.forEach(h=>{if(h===null)u.push(h);else switch(h.constructor){case Number:case Object:case Boolean:case Array:case String:u.push(h);break;default:switch(a(),h.constructor){case Uint8Array:case ArrayBuffer:s=new b(m(l,_(o,l)),s,s&&s.lastId,c,c&&c.id,e,null,new _r(new Uint8Array(h))),s.integrate(t,0);break;case fe:s=new b(m(l,_(o,l)),s,s&&s.lastId,c,c&&c.id,e,null,new vr(h)),s.integrate(t,0);break;default:if(h instanceof C)s=new b(m(l,_(o,l)),s,s&&s.lastId,c,c&&c.id,e,null,new Q(h)),s.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),a()},ls=()=>J("Length exceeded!"),os=(t,e,r,n)=>{if(r>e._length)throw ls();if(r===0)return e._searchMarker&&It(e._searchMarker,r,n.length),te(t,e,null,n);let s=r,i=ke(e,r),l=e._start;for(i!==null&&(l=i.p,r-=i.index,r===0&&(l=l.prev,r+=l&&l.countable&&!l.deleted?l.length:0));l!==null;l=l.right)if(!l.deleted&&l.countable){if(r<=l.length){r<l.length&&U(t,m(l.id.client,l.id.clock+r));break}r-=l.length}return e._searchMarker&&It(e._searchMarker,s,n.length),te(t,e,l,n)},ao=(t,e,r)=>{let n=(e._searchMarker||[]).reduce((s,i)=>i.index>s.index?i:s,{index:0,p:e._start}).p;if(n)for(;n.right;)n=n.right;return te(t,e,n,r)},cs=(t,e,r,n)=>{if(n===0)return;let s=r,i=n,l=ke(e,r),o=e._start;for(l!==null&&(o=l.p,r-=l.index);o!==null&&r>0;o=o.right)!o.deleted&&o.countable&&(r<o.length&&U(t,m(o.id.client,o.id.clock+r)),r-=o.length);for(;n>0&&o!==null;)o.deleted||(n<o.length&&U(t,m(o.id.client,o.id.clock+n)),o.delete(t),n-=o.length),o=o.right;if(n>0)throw ls();e._searchMarker&&It(e._searchMarker,s,-i+n)},ee=(t,e,r)=>{let n=e._map.get(r);n!==void 0&&n.delete(t)},pr=(t,e,r,n)=>{let s=e._map.get(r)||null,i=t.doc,l=i.clientID,o;if(n==null)o=new re([n]);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:o=new re([n]);break;case Uint8Array:o=new _r(n);break;case fe:o=new vr(n);break;default:if(n instanceof C)o=new Q(n);else throw new Error("Unexpected content type")}new b(m(l,_(i.store,l)),s,s&&s.lastId,null,null,e,r,o).integrate(t,0)},wr=(t,e)=>{t.doc??x();let r=t._map.get(e);return r!==void 0&&!r.deleted?r.content.getContent()[r.length-1]:void 0},as=t=>{let e={};return t.doc??x(),t._map.forEach((r,n)=>{r.deleted||(e[n]=r.content.getContent()[r.length-1])}),e},hs=(t,e)=>{t.doc??x();let r=t._map.get(e);return r!==void 0&&!r.deleted};var ho=(t,e)=>{let r={};return t._map.forEach((n,s)=>{let i=n;for(;i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;i!==null&<(i,e)&&(r[s]=i.content.getContent()[i.length-1])}),r},Pt=t=>(t.doc??x(),Sl(t._map.entries(),e=>!e[1].deleted)),uo=class extends me{},us=class Yt extends C{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){let r=new Yt;return r.push(e),r}_integrate(e,r){super._integrate(e,r),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Yt}clone(){let e=new Yt;return e.insert(0,this.toArray().map(r=>r instanceof C?r.clone():r)),e}get length(){return this.doc??x(),this._length}_callObserver(e,r){super._callObserver(e,r),ye(this,e,new uo(this,e))}insert(e,r){this.doc!==null?y(this.doc,n=>{os(n,this,e,r)}):this._prelimContent.splice(e,0,...r)}push(e){this.doc!==null?y(this.doc,r=>{ao(r,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,r=1){this.doc!==null?y(this.doc,n=>{cs(n,this,e,r)}):this._prelimContent.splice(e,r)}get(e){return is(this,e)}toArray(){return ns(this)}slice(e=0,r=this.length){return rs(this,e,r)}toJSON(){return this.map(e=>e instanceof C?e.toJSON():e)}map(e){return ss(this,e)}forEach(e){Ut(this,e)}[Symbol.iterator](){return co(this)}_write(e){e.writeTypeRef(jo)}},go=t=>new us,fo=class extends me{constructor(t,e,r){super(t,e),this.keysChanged=r}},mr=class Re extends C{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,r){super._integrate(e,r),this._prelimContent.forEach((n,s)=>{this.set(s,n)}),this._prelimContent=null}_copy(){return new Re}clone(){let e=new Re;return this.forEach((r,n)=>{e.set(n,r instanceof C?r.clone():r)}),e}_callObserver(e,r){ye(this,e,new fo(this,e,r))}toJSON(){this.doc??x();let e={};return this._map.forEach((r,n)=>{if(!r.deleted){let s=r.content.getContent()[r.length-1];e[n]=s instanceof C?s.toJSON():s}}),e}get size(){return[...Pt(this)].length}keys(){return De(Pt(this),e=>e[0])}values(){return De(Pt(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return De(Pt(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??x(),this._map.forEach((r,n)=>{r.deleted||e(r.content.getContent()[r.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?y(this.doc,r=>{ee(r,this,e)}):this._prelimContent.delete(e)}set(e,r){return this.doc!==null?y(this.doc,n=>{pr(n,this,e,r)}):this._prelimContent.set(e,r),r}get(e){return wr(this,e)}has(e){return hs(this,e)}clear(){this.doc!==null?y(this.doc,e=>{this.forEach(function(r,n,s){ee(e,s,n)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(zo)}},po=t=>new mr,H=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&bi(t,e),Ve=class{constructor(t,e,r,n){this.left=t,this.right=e,this.index=r,this.currentAttributes=n}forward(){this.right===null&&O(),this.right.content.constructor===A?this.right.deleted||bt(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}},Hr=(t,e,r)=>{for(;e.right!==null&&r>0;)e.right.content.constructor===A?e.right.deleted||bt(e.currentAttributes,e.right.content):e.right.deleted||(r<e.right.length&&U(t,m(e.right.id.client,e.right.id.clock+r)),e.index+=e.right.length,r-=e.right.length),e.left=e.right,e.right=e.right.right;return e},jt=(t,e,r,n)=>{let s=new Map,i=n?ke(e,r):null;if(i){let l=new Ve(i.p.left,i.p,i.index,s);return Hr(t,l,r-i.index)}else{let l=new Ve(null,e._start,0,s);return Hr(t,l,r)}},ds=(t,e,r,n)=>{for(;r.right!==null&&(r.right.deleted===!0||r.right.content.constructor===A&&H(n.get(r.right.content.key),r.right.content.value));)r.right.deleted||n.delete(r.right.content.key),r.forward();let s=t.doc,i=s.clientID;n.forEach((l,o)=>{let c=r.left,u=r.right,a=new b(m(i,_(s.store,i)),c,c&&c.lastId,u,u&&u.id,e,null,new A(o,l));a.integrate(t,0),r.right=a,r.forward()})},bt=(t,e)=>{let{key:r,value:n}=e;n===null?t.delete(r):t.set(r,n)},gs=(t,e)=>{for(;t.right!==null&&(t.right.deleted||t.right.content.constructor===A&&H(e[t.right.content.key]??null,t.right.content.value));)t.forward()},fs=(t,e,r,n)=>{let s=t.doc,i=s.clientID,l=new Map;for(let o in n){let c=n[o],u=r.currentAttributes.get(o)??null;if(!H(u,c)){l.set(o,u);let{left:a,right:h}=r;r.right=new b(m(i,_(s.store,i)),a,a&&a.lastId,h,h&&h.id,e,null,new A(o,c)),r.right.integrate(t,0),r.forward()}}return l},Ae=(t,e,r,n,s)=>{r.currentAttributes.forEach((d,g)=>{s[g]===void 0&&(s[g]=null)});let i=t.doc,l=i.clientID;gs(r,s);let o=fs(t,e,r,s),c=n.constructor===String?new rt(n):n instanceof C?new Q(n):new Rt(n),{left:u,right:a,index:h}=r;e._searchMarker&&It(e._searchMarker,r.index,c.getLength()),a=new b(m(l,_(i.store,l)),u,u&&u.lastId,a,a&&a.id,e,null,c),a.integrate(t,0),r.right=a,r.index=h,r.forward(),ds(t,e,r,o)},Gr=(t,e,r,n,s)=>{let i=t.doc,l=i.clientID;gs(r,s);let o=fs(t,e,r,s);t:for(;r.right!==null&&(n>0||o.size>0&&(r.right.deleted||r.right.content.constructor===A));){if(!r.right.deleted)switch(r.right.content.constructor){case A:{let{key:c,value:u}=r.right.content,a=s[c];if(a!==void 0){if(H(a,u))o.delete(c);else{if(n===0)break t;o.set(c,u)}r.right.delete(t)}else r.currentAttributes.set(c,u);break}default:n<r.right.length&&U(t,m(r.right.id.client,r.right.id.clock+n)),n-=r.right.length;break}r.forward()}if(n>0){let c="";for(;n>0;n--)c+=`
|
|
4
4
|
`;r.right=new b(m(l,_(i.store,l)),r.left,r.left&&r.left.lastId,r.right,r.right&&r.right.id,e,null,new rt(c)),r.right.integrate(t,0),r.forward()}ds(t,e,r,o)},ps=(t,e,r,n,s)=>{let i=e,l=F();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===A){let u=i.content;l.set(u.key,u)}i=i.right}let o=0,c=!1;for(;e!==i;){if(r===e&&(c=!0),!e.deleted){let u=e.content;if(u.constructor===A){let{key:a,value:h}=u,d=n.get(a)??null;(l.get(a)!==u||d===h)&&(e.delete(t),o++,!c&&(s.get(a)??null)===h&&d!==h&&(d===null?s.delete(a):s.set(a,d))),!c&&!e.deleted&&bt(s,u)}}e=e.right}return o},wo=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;let r=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===A){let n=e.content.key;r.has(n)?e.delete(t):r.add(n)}e=e.left}},mo=t=>{let e=0;return y(t.doc,r=>{let n=t._start,s=t._start,i=F(),l=Ie(i);for(;s;)s.deleted===!1&&(s.content.constructor===A?bt(l,s.content):(e+=ps(r,n,s,i,l),i=Ie(l),n=s)),s=s.right}),e},ko=t=>{let e=new Set,r=t.doc;for(let[n,s]of t.afterState.entries()){let i=t.beforeState.get(n)||0;s!==i&&qn(t,r.store.clients.get(n),i,s,l=>{!l.deleted&&l.content.constructor===A&&l.constructor!==L&&e.add(l.parent)})}y(r,n=>{pt(t,t.deleteSet,s=>{if(s instanceof L||!s.parent._hasFormatting||e.has(s.parent))return;let i=s.parent;s.content.constructor===A?e.add(i):wo(n,s)});for(let s of e)mo(s)})},Xr=(t,e,r)=>{let n=r,s=Ie(e.currentAttributes),i=e.right;for(;r>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Q:case Rt:case rt:r<e.right.length&&U(t,m(e.right.id.client,e.right.id.clock+r)),r-=e.right.length,e.right.delete(t);break}e.forward()}i&&ps(t,i,e.right,s,e.currentAttributes);let l=(e.left||e.right).parent;return l._searchMarker&&It(l._searchMarker,e.index,-n+r),e},yo=class extends me{constructor(t,e,r){super(t,e),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(n=>{n===null?this.childListChanged=!0:this.keysChanged.add(n)})}get changes(){if(this._changes===null){let t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){let t=this.target.doc,e=[];y(t,r=>{let n=new Map,s=new Map,i=this.target._start,l=null,o={},c="",u=0,a=0,h=()=>{if(l!==null){let d=null;switch(l){case"delete":a>0&&(d={delete:a}),a=0;break;case"insert":(typeof c=="object"||c.length>0)&&(d={insert:c},n.size>0&&(d.attributes={},n.forEach((g,f)=>{g!==null&&(d.attributes[f]=g)}))),c="";break;case"retain":u>0&&(d={retain:u},yi(o)||(d.attributes=wi({},o))),u=0;break}d&&e.push(d),l=null}};for(;i!==null;){switch(i.content.constructor){case Q:case Rt:this.adds(i)?this.deletes(i)||(h(),l="insert",c=i.content.getContent()[0],h()):this.deletes(i)?(l!=="delete"&&(h(),l="delete"),a+=1):i.deleted||(l!=="retain"&&(h(),l="retain"),u+=1);break;case rt:this.adds(i)?this.deletes(i)||(l!=="insert"&&(h(),l="insert"),c+=i.content.str):this.deletes(i)?(l!=="delete"&&(h(),l="delete"),a+=i.length):i.deleted||(l!=="retain"&&(h(),l="retain"),u+=i.length);break;case A:{let{key:d,value:g}=i.content;if(this.adds(i)){if(!this.deletes(i)){let f=n.get(d)??null;H(f,g)?g!==null&&i.delete(r):(l==="retain"&&h(),H(g,s.get(d)??null)?delete o[d]:o[d]=g)}}else if(this.deletes(i)){s.set(d,g);let f=n.get(d)??null;H(f,g)||(l==="retain"&&h(),o[d]=f)}else if(!i.deleted){s.set(d,g);let f=o[d];f!==void 0&&(H(f,g)?f!==null&&i.delete(r):(l==="retain"&&h(),g===null?delete o[d]:o[d]=g))}i.deleted||(l==="insert"&&h(),bt(n,i.content));break}}i=i.right}for(h();e.length>0;){let d=e[e.length-1];if(d.retain!==void 0&&d.attributes===void 0)e.pop();else break}}),this._delta=e}return this._delta}},kr=class Fe extends C{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??x(),this._length}_integrate(e,r){super._integrate(e,r);try{this._pending.forEach(n=>n())}catch(n){console.error(n)}this._pending=null}_copy(){return new Fe}clone(){let e=new Fe;return e.applyDelta(this.toDelta()),e}_callObserver(e,r){super._callObserver(e,r);let n=new yo(this,e,r);ye(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??x();let e="",r=this._start;for(;r!==null;)!r.deleted&&r.countable&&r.content.constructor===rt&&(e+=r.content.str),r=r.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:r=!0}={}){this.doc!==null?y(this.doc,n=>{let s=new Ve(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let l=e[i];if(l.insert!==void 0){let o=!r&&typeof l.insert=="string"&&i===e.length-1&&s.right===null&&l.insert.slice(-1)===`
|
|
5
|
-
`?l.insert.slice(0,-1):l.insert;(typeof o!="string"||o.length>0)&&Ae(n,this,s,o,l.attributes||{})}else l.retain!==void 0?Gr(n,this,s,l.retain,l.attributes||{}):l.delete!==void 0&&Xr(n,s,l.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,r,n){this.doc??x();let s=[],i=new Map,l=this.doc,o="",c=this._start;function u(){if(o.length>0){let h={},d=!1;i.forEach((f,k)=>{d=!0,h[k]=f});let g={insert:o};d&&(g.attributes=h),s.push(g),o=""}}let a=()=>{for(;c!==null;){if(lt(c,e)||r!==void 0&<(c,r))switch(c.content.constructor){case rt:{let h=i.get("ychange");e!==void 0&&!lt(c,e)?(h===void 0||h.user!==c.id.client||h.type!=="removed")&&(u(),i.set("ychange",n?n("removed",c.id):{type:"removed"})):r!==void 0&&!lt(c,r)?(h===void 0||h.user!==c.id.client||h.type!=="added")&&(u(),i.set("ychange",n?n("added",c.id):{type:"added"})):h!==void 0&&(u(),i.delete("ychange")),o+=c.content.str;break}case Q:case Rt:{u();let h={insert:c.content.getContent()[0]};if(i.size>0){let d={};h.attributes=d,i.forEach((g,f)=>{d[f]=g})}s.push(h);break}case A:lt(c,e)&&(u(),bt(i,c.content));break}c=c.right}u()};return e||r?y(l,h=>{e&&Ne(h,e),r&&Ne(h,r),a()},"cleanup"):a(),s}insert(e,r,n){if(r.length<=0)return;let s=this.doc;s!==null?y(s,i=>{let l=jt(i,this,e,!n);n||(n={},l.currentAttributes.forEach((o,c)=>{n[c]=o})),Ae(i,this,l,r,n)}):this._pending.push(()=>this.insert(e,r,n))}insertEmbed(e,r,n){let s=this.doc;s!==null?y(s,i=>{let l=jt(i,this,e,!n);Ae(i,this,l,r,n||{})}):this._pending.push(()=>this.insertEmbed(e,r,n||{}))}delete(e,r){if(r===0)return;let n=this.doc;n!==null?y(n,s=>{Xr(s,jt(s,this,e,!0),r)}):this._pending.push(()=>this.delete(e,r))}format(e,r,n){if(r===0)return;let s=this.doc;s!==null?y(s,i=>{let l=jt(i,this,e,!1);l.right!==null&&Gr(i,this,l,r,n)}):this._pending.push(()=>this.format(e,r,n))}removeAttribute(e){this.doc!==null?y(this.doc,r=>{ee(r,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,r){this.doc!==null?y(this.doc,n=>{pr(n,this,e,r)}):this._pending.push(()=>this.setAttribute(e,r))}getAttribute(e){return wr(this,e)}getAttributes(){return as(this)}_write(e){e.writeTypeRef(Jo)}},bo=t=>new kr,xe=class{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??x()}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(e)))do if(e=t.content.type,!t.deleted&&(e.constructor===yr||e.constructor===be)&&e._start!==null)t=e._start;else for(;t!==null;){let r=t.next;if(r!==null){t=r;break}else t.parent===this._root?t=null:t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,t===null?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}},be=class Pe extends C{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,r){super._integrate(e,r),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Pe}clone(){let e=new Pe;return e.insert(0,this.toArray().map(r=>r instanceof C?r.clone():r)),e}get length(){return this.doc??x(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new xe(this,e)}querySelector(e){e=e.toUpperCase();let r=new xe(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),G(new xe(this,r=>r.nodeName&&r.nodeName.toUpperCase()===e))}_callObserver(e,r){ye(this,e,new So(this,r,e))}toString(){return ss(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,r={},n){let s=e.createDocumentFragment();return n!==void 0&&n._createAssociation(s,this),Ut(this,i=>{s.insertBefore(i.toDOM(e,r,n),null)}),s}insert(e,r){this.doc!==null?y(this.doc,n=>{os(n,this,e,r)}):this._prelimContent.splice(e,0,...r)}insertAfter(e,r){if(this.doc!==null)y(this.doc,n=>{let s=e&&e instanceof C?e._item:e;te(n,this,s,r)});else{let n=this._prelimContent,s=e===null?0:n.findIndex(i=>i===e)+1;if(s===0&&e!==null)throw J("Reference item not found");n.splice(s,0,...r)}}delete(e,r=1){this.doc!==null?y(this.doc,n=>{cs(n,this,e,r)}):this._prelimContent.splice(e,r)}toArray(){return ns(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return is(this,e)}slice(e=0,r=this.length){return rs(this,e,r)}forEach(e){Ut(this,e)}_write(e){e.writeTypeRef(Bo)}},_o=t=>new be,yr=class je extends be{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,r){super._integrate(e,r),this._prelimAttrs.forEach((n,s)=>{this.setAttribute(s,n)}),this._prelimAttrs=null}_copy(){return new je(this.nodeName)}clone(){let e=new je(this.nodeName),r=this.getAttributes();return ki(r,(n,s)=>{typeof n=="string"&&e.setAttribute(s,n)}),e.insert(0,this.toArray().map(n=>n instanceof C?n.clone():n)),e}toString(){let e=this.getAttributes(),r=[],n=[];for(let o in e)n.push(o);n.sort();let s=n.length;for(let o=0;o<s;o++){let c=n[o];r.push(c+'="'+e[c]+'"')}let i=this.nodeName.toLocaleLowerCase(),l=r.length>0?" "+r.join(" "):"";return`<${i}${l}>${super.toString()}</${i}>`}removeAttribute(e){this.doc!==null?y(this.doc,r=>{ee(r,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,r){this.doc!==null?y(this.doc,n=>{pr(n,this,e,r)}):this._prelimAttrs.set(e,r)}getAttribute(e){return wr(this,e)}hasAttribute(e){return hs(this,e)}getAttributes(e){return e?ho(this,e):as(this)}toDOM(e=document,r={},n){let s=e.createElement(this.nodeName),i=this.getAttributes();for(let l in i){let o=i[l];typeof o=="string"&&s.setAttribute(l,o)}return Ut(this,l=>{s.appendChild(l.toDOM(e,r,n))}),n!==void 0&&n._createAssociation(s,this),s}_write(e){e.writeTypeRef($o),e.writeKey(this.nodeName)}},vo=t=>new yr(t.readKey()),So=class extends me{constructor(t,e,r){super(t,r),this.childListChanged=!1,this.attributesChanged=new Set,e.forEach(n=>{n===null?this.childListChanged=!0:this.attributesChanged.add(n)})}},Eo=class ze extends mr{constructor(e){super(),this.hookName=e}_copy(){return new ze(this.hookName)}clone(){let e=new ze(this.hookName);return this.forEach((r,n)=>{e.set(n,r)}),e}toDOM(e=document,r={},n){let s=r[this.hookName],i;return s!==void 0?i=s.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(Wo),e.writeKey(this.hookName)}},Co=t=>new Eo(t.readKey()),Do=class Je extends kr{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new Je}clone(){let e=new Je;return e.applyDelta(this.toDelta()),e}toDOM(e=document,r,n){let s=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(s,this),s}toString(){return this.toDelta().map(e=>{let r=[];for(let s in e.attributes){let i=[];for(let l in e.attributes[s])i.push({key:l,value:e.attributes[s][l]});i.sort((l,o)=>l.key<o.key?-1:1),r.push({nodeName:s,attrs:i})}r.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let n="";for(let s=0;s<r.length;s++){let i=r[s];n+=`<${i.nodeName}`;for(let l=0;l<i.attrs.length;l++){let o=i.attrs[l];n+=` ${o.key}="${o.value}"`}n+=">"}n+=e.insert;for(let s=r.length-1;s>=0;s--)n+=`</${r[s].nodeName}>`;return n}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(Yo)}},Ao=t=>new Do,br=class{constructor(t,e){this.id=t,this.length=e}get deleted(){throw P()}mergeWith(t){return!1}write(t,e,r){throw P()}integrate(t,e){throw P()}},xo=0,L=class extends br{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,e){e>0&&(this.id.clock+=e,this.length-=e),Xn(t.doc.store,this)}write(t,e){t.writeInfo(xo),t.writeLen(this.length-e)}getMissing(t,e){return null}},_r=class ws{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new ws(this.content)}splice(e){throw P()}mergeWith(e){return!1}integrate(e,r){}delete(e){}gc(e){}write(e,r){e.writeBuf(this.content)}getRef(){return 3}},Io=t=>new _r(t.readBuf()),ms=class $e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new $e(this.len)}splice(e){let r=new $e(this.len-e);return this.len=e,r}mergeWith(e){return this.len+=e.len,!0}integrate(e,r){xt(e.deleteSet,r.id.client,r.id.clock,this.len),r.markDeleted()}delete(e){}gc(e){}write(e,r){e.writeLen(this.len-r)}getRef(){return 1}},Uo=t=>new ms(t.readLen()),ks=(t,e)=>new fe({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1}),vr=class ys{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;let r={};this.opts=r,e.gc||(r.gc=!1),e.autoLoad&&(r.autoLoad=!0),e.meta!==null&&(r.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new ys(ks(this.doc.guid,this.opts))}splice(e){throw P()}mergeWith(e){return!1}integrate(e,r){this.doc._item=r,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,r){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},Oo=t=>new vr(ks(t.readString(),t.readAny())),Rt=class bs{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new bs(this.embed)}splice(e){throw P()}mergeWith(e){return!1}integrate(e,r){}delete(e){}gc(e){}write(e,r){e.writeJSON(this.embed)}getRef(){return 5}},Mo=t=>new Rt(t.readJSON()),A=class _s{constructor(e,r){this.key=e,this.value=r}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new _s(this.key,this.value)}splice(e){throw P()}mergeWith(e){return!1}integrate(e,r){let n=r.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,r){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},To=t=>new A(t.readKey(),t.readJSON()),No=class Be{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Be(this.arr)}splice(e){let r=new Be(this.arr.slice(e));return this.arr=this.arr.slice(0,e),r}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,r){}delete(e){}gc(e){}write(e,r){let n=this.arr.length;e.writeLen(n-r);for(let s=r;s<n;s++){let i=this.arr[s];e.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}},Lo=t=>{let e=t.readLen(),r=[];for(let n=0;n<e;n++){let s=t.readString();s==="undefined"?r.push(void 0):r.push(JSON.parse(s))}return new No(r)},Ro=Gt("node_env")==="development",re=class We{constructor(e){this.arr=e,Ro&&cn(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new We(this.arr)}splice(e){let r=new We(this.arr.slice(e));return this.arr=this.arr.slice(0,e),r}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,r){}delete(e){}gc(e){}write(e,r){let n=this.arr.length;e.writeLen(n-r);for(let s=r;s<n;s++){let i=this.arr[s];e.writeAny(i)}}getRef(){return 8}},Vo=t=>{let e=t.readLen(),r=[];for(let n=0;n<e;n++)r.push(t.readAny());return new re(r)},rt=class Ye{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Ye(this.str)}splice(e){let r=new Ye(this.str.slice(e));this.str=this.str.slice(0,e);let n=this.str.charCodeAt(e-1);return n>=55296&&n<=56319&&(this.str=this.str.slice(0,e-1)+"\uFFFD",r.str="\uFFFD"+r.str.slice(1)),r}mergeWith(e){return this.str+=e.str,!0}integrate(e,r){}delete(e){}gc(e){}write(e,r){e.writeString(r===0?this.str:this.str.slice(r))}getRef(){return 4}},Fo=t=>new rt(t.readString()),Po=[go,po,bo,vo,_o,Co,Ao],jo=0,zo=1,Jo=2,$o=3,Bo=4,Wo=5,Yo=6,Q=class vs{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new vs(this.type._copy())}splice(e){throw P()}mergeWith(e){return!1}integrate(e,r){this.type._integrate(e.doc,r)}delete(e){let r=this.type._start;for(;r!==null;)r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e),r=r.right;this.type._map.forEach(n=>{n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e)}),e.changed.delete(this.type)}gc(e){let r=this.type._start;for(;r!==null;)r.gc(e,!0),r=r.right;this.type._start=null,this.type._map.forEach(n=>{for(;n!==null;)n.gc(e,!0),n=n.left}),this.type._map=new Map}write(e,r){this.type._write(e)}getRef(){return 7}},Ko=t=>new Q(Po[t.readTypeRef()](t)),Ke=(t,e)=>{let r=e,n=0,s;do n>0&&(r=m(r.client,r.clock+n)),s=at(t,r),n=r.clock-s.id.clock,r=s.redone;while(r!==null&&s instanceof b);return{item:s,diff:n}},Sr=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},ne=(t,e,r)=>{let{client:n,clock:s}=e.id,i=new b(m(n,s+r),e,m(n,s+r-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(r));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),e.redone!==null&&(i.redone=m(e.redone.client,e.redone.clock+r)),e.right=i,i.right!==null&&(i.right.left=i),t._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),e.length=r,i},qr=(t,e)=>qe(t,r=>Nt(r.deletions,e)),Ss=(t,e,r,n,s,i)=>{let l=t.doc,o=l.store,c=l.clientID,u=e.redone;if(u!==null)return U(t,u);let a=e.parent._item,h=null,d;if(a!==null&&a.deleted===!0){if(a.redone===null&&(!r.has(a)||Ss(t,a,r,n,s,i)===null))return null;for(;a.redone!==null;)a=U(t,a.redone)}let g=a===null?e.parent:a.content.type;if(e.parentSub===null){for(h=e.left,d=e;h!==null;){let v=h;for(;v!==null&&v.parent._item!==a;)v=v.redone===null?null:U(t,v.redone);if(v!==null&&v.parent._item===a){h=v;break}h=h.left}for(;d!==null;){let v=d;for(;v!==null&&v.parent._item!==a;)v=v.redone===null?null:U(t,v.redone);if(v!==null&&v.parent._item===a){d=v;break}d=d.right}}else if(d=null,e.right&&!s){for(h=e;h!==null&&h.right!==null&&(h.right.redone||Nt(n,h.right.id)||qr(i.undoStack,h.right.id)||qr(i.redoStack,h.right.id));)for(h=h.right;h.redone;)h=U(t,h.redone);if(h&&h.right!==null)return null}else h=g._map.get(e.parentSub)||null;let f=_(o,c),k=m(c,f),V=new b(k,h,h&&h.lastId,d,d&&d.id,g,e.parentSub,e.content.copy());return e.redone=k,Sr(V,!0),V.integrate(t,0),V},b=class He extends br{constructor(e,r,n,s,i,l,o,c){super(e,c.getLength()),this.origin=n,this.left=r,this.right=s,this.rightOrigin=i,this.parent=l,this.parentSub=o,this.redone=null,this.content=c,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(e,r){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=_(r,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=_(r,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ct&&this.id.client!==this.parent.client&&this.parent.clock>=_(r,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Jr(e,r,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=U(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===L||this.right&&this.right.constructor===L)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===He?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===He&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===ct){let n=at(r,this.parent);n.constructor===L?this.parent=null:this.parent=n.content.type}return null}integrate(e,r){if(r>0&&(this.id.clock+=r,this.left=Jr(e,e.doc.store,m(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(r),this.length-=r),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let n=this.left,s;if(n!==null)s=n.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;let i=new Set,l=new Set;for(;s!==null&&s!==this.right;){if(l.add(s),i.add(s),Vt(this.origin,s.origin)){if(s.id.client<this.id.client)n=s,i.clear();else if(Vt(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&l.has(at(e.doc.store,s.origin)))i.has(at(e.doc.store,s.origin))||(n=s,i.clear());else break;s=s.right}this.left=n}if(this.left!==null){let n=this.left.right;this.right=n,this.left.right=this}else{let n;if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start,this.parent._start=this;this.right=n}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Xn(e.doc.store,this),this.content.integrate(e,this),Br(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new L(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:m(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Vt(e.origin,this.lastId)&&this.right===e&&Vt(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let r=this.parent._searchMarker;return r&&r.forEach(n=>{n.p===e&&(n.p=this,!this.deleted&&this.countable&&(n.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let r=this.parent;this.countable&&this.parentSub===null&&(r._length-=this.length),this.markDeleted(),xt(e.deleteSet,this.id.client,this.id.clock,this.length),Br(e,r,this.parentSub),this.content.delete(e)}}gc(e,r){if(!this.deleted)throw O();this.content.gc(e),r?Kl(e,this,new L(this.id,this.length)):this.content=new ms(this.length)}write(e,r){let n=r>0?m(this.id.client,this.id.clock+r-1):this.origin,s=this.rightOrigin,i=this.parentSub,l=this.content.getRef()&31|(n===null?0:128)|(s===null?0:64)|(i===null?0:32);if(e.writeInfo(l),n!==null&&e.writeLeftID(n),s!==null&&e.writeRightID(s),n===null&&s===null){let o=this.parent;if(o._item!==void 0){let c=o._item;if(c===null){let u=Kn(o);e.writeParentInfo(!0),e.writeString(u)}else e.writeParentInfo(!1),e.writeLeftID(c.id)}else o.constructor===String?(e.writeParentInfo(!0),e.writeString(o)):o.constructor===ct?(e.writeParentInfo(!1),e.writeLeftID(o)):O();i!==null&&e.writeString(i)}this.content.write(e,r)}},Es=(t,e)=>Ho[e&31](t),Ho=[()=>{O()},Uo,Lo,Io,Fo,Mo,To,Ko,Vo,Oo,()=>{O()}],Go=10,N=class extends br{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,e){O()}write(t,e){t.writeInfo(Go),p(t.restEncoder,this.length-e)}getMissing(t,e){return null}},Cs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Ds="__ $YJS$ __";Cs[Ds]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Cs[Ds]=!0;export{ic as a,lc as b,pt as c,Cl as d,Uc as e,fe as f,Tl as g,Oc as h,Bn as i,Mc as j,Tc as k,Nc as l,Lc as m,Rc as n,at as o,Fc as p,Pc as q,jc as r,Zt as s,C as t,mr as u,Rt as v,A as w,rt as x,b as y,N as z};
|
|
5
|
+
`?l.insert.slice(0,-1):l.insert;(typeof o!="string"||o.length>0)&&Ae(n,this,s,o,l.attributes||{})}else l.retain!==void 0?Gr(n,this,s,l.retain,l.attributes||{}):l.delete!==void 0&&Xr(n,s,l.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,r,n){this.doc??x();let s=[],i=new Map,l=this.doc,o="",c=this._start;function u(){if(o.length>0){let h={},d=!1;i.forEach((f,k)=>{d=!0,h[k]=f});let g={insert:o};d&&(g.attributes=h),s.push(g),o=""}}let a=()=>{for(;c!==null;){if(lt(c,e)||r!==void 0&<(c,r))switch(c.content.constructor){case rt:{let h=i.get("ychange");e!==void 0&&!lt(c,e)?(h===void 0||h.user!==c.id.client||h.type!=="removed")&&(u(),i.set("ychange",n?n("removed",c.id):{type:"removed"})):r!==void 0&&!lt(c,r)?(h===void 0||h.user!==c.id.client||h.type!=="added")&&(u(),i.set("ychange",n?n("added",c.id):{type:"added"})):h!==void 0&&(u(),i.delete("ychange")),o+=c.content.str;break}case Q:case Rt:{u();let h={insert:c.content.getContent()[0]};if(i.size>0){let d={};h.attributes=d,i.forEach((g,f)=>{d[f]=g})}s.push(h);break}case A:lt(c,e)&&(u(),bt(i,c.content));break}c=c.right}u()};return e||r?y(l,h=>{e&&Ne(h,e),r&&Ne(h,r),a()},"cleanup"):a(),s}insert(e,r,n){if(r.length<=0)return;let s=this.doc;s!==null?y(s,i=>{let l=jt(i,this,e,!n);n||(n={},l.currentAttributes.forEach((o,c)=>{n[c]=o})),Ae(i,this,l,r,n)}):this._pending.push(()=>this.insert(e,r,n))}insertEmbed(e,r,n){let s=this.doc;s!==null?y(s,i=>{let l=jt(i,this,e,!n);Ae(i,this,l,r,n||{})}):this._pending.push(()=>this.insertEmbed(e,r,n||{}))}delete(e,r){if(r===0)return;let n=this.doc;n!==null?y(n,s=>{Xr(s,jt(s,this,e,!0),r)}):this._pending.push(()=>this.delete(e,r))}format(e,r,n){if(r===0)return;let s=this.doc;s!==null?y(s,i=>{let l=jt(i,this,e,!1);l.right!==null&&Gr(i,this,l,r,n)}):this._pending.push(()=>this.format(e,r,n))}removeAttribute(e){this.doc!==null?y(this.doc,r=>{ee(r,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,r){this.doc!==null?y(this.doc,n=>{pr(n,this,e,r)}):this._pending.push(()=>this.setAttribute(e,r))}getAttribute(e){return wr(this,e)}getAttributes(){return as(this)}_write(e){e.writeTypeRef(Jo)}},bo=t=>new kr,xe=class{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??x()}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(e)))do if(e=t.content.type,!t.deleted&&(e.constructor===yr||e.constructor===be)&&e._start!==null)t=e._start;else for(;t!==null;){let r=t.next;if(r!==null){t=r;break}else t.parent===this._root?t=null:t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,t===null?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}},be=class Pe extends C{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,r){super._integrate(e,r),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Pe}clone(){let e=new Pe;return e.insert(0,this.toArray().map(r=>r instanceof C?r.clone():r)),e}get length(){return this.doc??x(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new xe(this,e)}querySelector(e){e=e.toUpperCase();let r=new xe(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),G(new xe(this,r=>r.nodeName&&r.nodeName.toUpperCase()===e))}_callObserver(e,r){ye(this,e,new So(this,r,e))}toString(){return ss(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,r={},n){let s=e.createDocumentFragment();return n!==void 0&&n._createAssociation(s,this),Ut(this,i=>{s.insertBefore(i.toDOM(e,r,n),null)}),s}insert(e,r){this.doc!==null?y(this.doc,n=>{os(n,this,e,r)}):this._prelimContent.splice(e,0,...r)}insertAfter(e,r){if(this.doc!==null)y(this.doc,n=>{let s=e&&e instanceof C?e._item:e;te(n,this,s,r)});else{let n=this._prelimContent,s=e===null?0:n.findIndex(i=>i===e)+1;if(s===0&&e!==null)throw J("Reference item not found");n.splice(s,0,...r)}}delete(e,r=1){this.doc!==null?y(this.doc,n=>{cs(n,this,e,r)}):this._prelimContent.splice(e,r)}toArray(){return ns(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return is(this,e)}slice(e=0,r=this.length){return rs(this,e,r)}forEach(e){Ut(this,e)}_write(e){e.writeTypeRef(Bo)}},_o=t=>new be,yr=class je extends be{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,r){super._integrate(e,r),this._prelimAttrs.forEach((n,s)=>{this.setAttribute(s,n)}),this._prelimAttrs=null}_copy(){return new je(this.nodeName)}clone(){let e=new je(this.nodeName),r=this.getAttributes();return ki(r,(n,s)=>{typeof n=="string"&&e.setAttribute(s,n)}),e.insert(0,this.toArray().map(n=>n instanceof C?n.clone():n)),e}toString(){let e=this.getAttributes(),r=[],n=[];for(let o in e)n.push(o);n.sort();let s=n.length;for(let o=0;o<s;o++){let c=n[o];r.push(c+'="'+e[c]+'"')}let i=this.nodeName.toLocaleLowerCase(),l=r.length>0?" "+r.join(" "):"";return`<${i}${l}>${super.toString()}</${i}>`}removeAttribute(e){this.doc!==null?y(this.doc,r=>{ee(r,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,r){this.doc!==null?y(this.doc,n=>{pr(n,this,e,r)}):this._prelimAttrs.set(e,r)}getAttribute(e){return wr(this,e)}hasAttribute(e){return hs(this,e)}getAttributes(e){return e?ho(this,e):as(this)}toDOM(e=document,r={},n){let s=e.createElement(this.nodeName),i=this.getAttributes();for(let l in i){let o=i[l];typeof o=="string"&&s.setAttribute(l,o)}return Ut(this,l=>{s.appendChild(l.toDOM(e,r,n))}),n!==void 0&&n._createAssociation(s,this),s}_write(e){e.writeTypeRef($o),e.writeKey(this.nodeName)}},vo=t=>new yr(t.readKey()),So=class extends me{constructor(t,e,r){super(t,r),this.childListChanged=!1,this.attributesChanged=new Set,e.forEach(n=>{n===null?this.childListChanged=!0:this.attributesChanged.add(n)})}},Eo=class ze extends mr{constructor(e){super(),this.hookName=e}_copy(){return new ze(this.hookName)}clone(){let e=new ze(this.hookName);return this.forEach((r,n)=>{e.set(n,r)}),e}toDOM(e=document,r={},n){let s=r[this.hookName],i;return s!==void 0?i=s.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(Wo),e.writeKey(this.hookName)}},Co=t=>new Eo(t.readKey()),Do=class Je extends kr{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new Je}clone(){let e=new Je;return e.applyDelta(this.toDelta()),e}toDOM(e=document,r,n){let s=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(s,this),s}toString(){return this.toDelta().map(e=>{let r=[];for(let s in e.attributes){let i=[];for(let l in e.attributes[s])i.push({key:l,value:e.attributes[s][l]});i.sort((l,o)=>l.key<o.key?-1:1),r.push({nodeName:s,attrs:i})}r.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let n="";for(let s=0;s<r.length;s++){let i=r[s];n+=`<${i.nodeName}`;for(let l=0;l<i.attrs.length;l++){let o=i.attrs[l];n+=` ${o.key}="${o.value}"`}n+=">"}n+=e.insert;for(let s=r.length-1;s>=0;s--)n+=`</${r[s].nodeName}>`;return n}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(Yo)}},Ao=t=>new Do,br=class{constructor(t,e){this.id=t,this.length=e}get deleted(){throw P()}mergeWith(t){return!1}write(t,e,r){throw P()}integrate(t,e){throw P()}},xo=0,L=class extends br{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,e){e>0&&(this.id.clock+=e,this.length-=e),Xn(t.doc.store,this)}write(t,e){t.writeInfo(xo),t.writeLen(this.length-e)}getMissing(t,e){return null}},_r=class ws{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new ws(this.content)}splice(e){throw P()}mergeWith(e){return!1}integrate(e,r){}delete(e){}gc(e){}write(e,r){e.writeBuf(this.content)}getRef(){return 3}},Io=t=>new _r(t.readBuf()),ms=class $e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new $e(this.len)}splice(e){let r=new $e(this.len-e);return this.len=e,r}mergeWith(e){return this.len+=e.len,!0}integrate(e,r){xt(e.deleteSet,r.id.client,r.id.clock,this.len),r.markDeleted()}delete(e){}gc(e){}write(e,r){e.writeLen(this.len-r)}getRef(){return 1}},Uo=t=>new ms(t.readLen()),ks=(t,e)=>new fe({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1}),vr=class ys{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;let r={};this.opts=r,e.gc||(r.gc=!1),e.autoLoad&&(r.autoLoad=!0),e.meta!==null&&(r.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new ys(ks(this.doc.guid,this.opts))}splice(e){throw P()}mergeWith(e){return!1}integrate(e,r){this.doc._item=r,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,r){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},Oo=t=>new vr(ks(t.readString(),t.readAny())),Rt=class bs{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new bs(this.embed)}splice(e){throw P()}mergeWith(e){return!1}integrate(e,r){}delete(e){}gc(e){}write(e,r){e.writeJSON(this.embed)}getRef(){return 5}},Mo=t=>new Rt(t.readJSON()),A=class _s{constructor(e,r){this.key=e,this.value=r}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new _s(this.key,this.value)}splice(e){throw P()}mergeWith(e){return!1}integrate(e,r){let n=r.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,r){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},To=t=>new A(t.readKey(),t.readJSON()),No=class Be{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Be(this.arr)}splice(e){let r=new Be(this.arr.slice(e));return this.arr=this.arr.slice(0,e),r}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,r){}delete(e){}gc(e){}write(e,r){let n=this.arr.length;e.writeLen(n-r);for(let s=r;s<n;s++){let i=this.arr[s];e.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}},Lo=t=>{let e=t.readLen(),r=[];for(let n=0;n<e;n++){let s=t.readString();s==="undefined"?r.push(void 0):r.push(JSON.parse(s))}return new No(r)},Ro=Gt("node_env")==="development",re=class We{constructor(e){this.arr=e,Ro&&cn(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new We(this.arr)}splice(e){let r=new We(this.arr.slice(e));return this.arr=this.arr.slice(0,e),r}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,r){}delete(e){}gc(e){}write(e,r){let n=this.arr.length;e.writeLen(n-r);for(let s=r;s<n;s++){let i=this.arr[s];e.writeAny(i)}}getRef(){return 8}},Vo=t=>{let e=t.readLen(),r=[];for(let n=0;n<e;n++)r.push(t.readAny());return new re(r)},rt=class Ye{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Ye(this.str)}splice(e){let r=new Ye(this.str.slice(e));this.str=this.str.slice(0,e);let n=this.str.charCodeAt(e-1);return n>=55296&&n<=56319&&(this.str=this.str.slice(0,e-1)+"\uFFFD",r.str="\uFFFD"+r.str.slice(1)),r}mergeWith(e){return this.str+=e.str,!0}integrate(e,r){}delete(e){}gc(e){}write(e,r){e.writeString(r===0?this.str:this.str.slice(r))}getRef(){return 4}},Fo=t=>new rt(t.readString()),Po=[go,po,bo,vo,_o,Co,Ao],jo=0,zo=1,Jo=2,$o=3,Bo=4,Wo=5,Yo=6,Q=class vs{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new vs(this.type._copy())}splice(e){throw P()}mergeWith(e){return!1}integrate(e,r){this.type._integrate(e.doc,r)}delete(e){let r=this.type._start;for(;r!==null;)r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e),r=r.right;this.type._map.forEach(n=>{n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e)}),e.changed.delete(this.type)}gc(e){let r=this.type._start;for(;r!==null;)r.gc(e,!0),r=r.right;this.type._start=null,this.type._map.forEach(n=>{for(;n!==null;)n.gc(e,!0),n=n.left}),this.type._map=new Map}write(e,r){this.type._write(e)}getRef(){return 7}},Ko=t=>new Q(Po[t.readTypeRef()](t)),Ke=(t,e)=>{let r=e,n=0,s;do n>0&&(r=m(r.client,r.clock+n)),s=at(t,r),n=r.clock-s.id.clock,r=s.redone;while(r!==null&&s instanceof b);return{item:s,diff:n}},Sr=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},ne=(t,e,r)=>{let{client:n,clock:s}=e.id,i=new b(m(n,s+r),e,m(n,s+r-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(r));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),e.redone!==null&&(i.redone=m(e.redone.client,e.redone.clock+r)),e.right=i,i.right!==null&&(i.right.left=i),t._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),e.length=r,i},qr=(t,e)=>qe(t,r=>Nt(r.deletions,e)),Ss=(t,e,r,n,s,i)=>{let l=t.doc,o=l.store,c=l.clientID,u=e.redone;if(u!==null)return U(t,u);let a=e.parent._item,h=null,d;if(a!==null&&a.deleted===!0){if(a.redone===null&&(!r.has(a)||Ss(t,a,r,n,s,i)===null))return null;for(;a.redone!==null;)a=U(t,a.redone)}let g=a===null?e.parent:a.content.type;if(e.parentSub===null){for(h=e.left,d=e;h!==null;){let v=h;for(;v!==null&&v.parent._item!==a;)v=v.redone===null?null:U(t,v.redone);if(v!==null&&v.parent._item===a){h=v;break}h=h.left}for(;d!==null;){let v=d;for(;v!==null&&v.parent._item!==a;)v=v.redone===null?null:U(t,v.redone);if(v!==null&&v.parent._item===a){d=v;break}d=d.right}}else if(d=null,e.right&&!s){for(h=e;h!==null&&h.right!==null&&(h.right.redone||Nt(n,h.right.id)||qr(i.undoStack,h.right.id)||qr(i.redoStack,h.right.id));)for(h=h.right;h.redone;)h=U(t,h.redone);if(h&&h.right!==null)return null}else h=g._map.get(e.parentSub)||null;let f=_(o,c),k=m(c,f),V=new b(k,h,h&&h.lastId,d,d&&d.id,g,e.parentSub,e.content.copy());return e.redone=k,Sr(V,!0),V.integrate(t,0),V},b=class He extends br{constructor(e,r,n,s,i,l,o,c){super(e,c.getLength()),this.origin=n,this.left=r,this.right=s,this.rightOrigin=i,this.parent=l,this.parentSub=o,this.redone=null,this.content=c,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(e,r){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=_(r,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=_(r,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ct&&this.id.client!==this.parent.client&&this.parent.clock>=_(r,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Jr(e,r,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=U(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===L||this.right&&this.right.constructor===L)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===He?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===He&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===ct){let n=at(r,this.parent);n.constructor===L?this.parent=null:this.parent=n.content.type}return null}integrate(e,r){if(r>0&&(this.id.clock+=r,this.left=Jr(e,e.doc.store,m(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(r),this.length-=r),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let n=this.left,s;if(n!==null)s=n.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;let i=new Set,l=new Set;for(;s!==null&&s!==this.right;){if(l.add(s),i.add(s),Vt(this.origin,s.origin)){if(s.id.client<this.id.client)n=s,i.clear();else if(Vt(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&l.has(at(e.doc.store,s.origin)))i.has(at(e.doc.store,s.origin))||(n=s,i.clear());else break;s=s.right}this.left=n}if(this.left!==null){let n=this.left.right;this.right=n,this.left.right=this}else{let n;if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start,this.parent._start=this;this.right=n}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Xn(e.doc.store,this),this.content.integrate(e,this),Br(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new L(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:m(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Vt(e.origin,this.lastId)&&this.right===e&&Vt(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let r=this.parent._searchMarker;return r&&r.forEach(n=>{n.p===e&&(n.p=this,!this.deleted&&this.countable&&(n.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let r=this.parent;this.countable&&this.parentSub===null&&(r._length-=this.length),this.markDeleted(),xt(e.deleteSet,this.id.client,this.id.clock,this.length),Br(e,r,this.parentSub),this.content.delete(e)}}gc(e,r){if(!this.deleted)throw O();this.content.gc(e),r?Kl(e,this,new L(this.id,this.length)):this.content=new ms(this.length)}write(e,r){let n=r>0?m(this.id.client,this.id.clock+r-1):this.origin,s=this.rightOrigin,i=this.parentSub,l=this.content.getRef()&31|(n===null?0:128)|(s===null?0:64)|(i===null?0:32);if(e.writeInfo(l),n!==null&&e.writeLeftID(n),s!==null&&e.writeRightID(s),n===null&&s===null){let o=this.parent;if(o._item!==void 0){let c=o._item;if(c===null){let u=Kn(o);e.writeParentInfo(!0),e.writeString(u)}else e.writeParentInfo(!1),e.writeLeftID(c.id)}else o.constructor===String?(e.writeParentInfo(!0),e.writeString(o)):o.constructor===ct?(e.writeParentInfo(!1),e.writeLeftID(o)):O();i!==null&&e.writeString(i)}this.content.write(e,r)}},Es=(t,e)=>Ho[e&31](t),Ho=[()=>{O()},Uo,Lo,Io,Fo,Mo,To,Ko,Vo,Oo,()=>{O()}],Go=10,N=class extends br{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,e){O()}write(t,e){t.writeInfo(Go),p(t.restEncoder,this.length-e)}getMissing(t,e){return null}},Cs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Ds="__ $YJS$ __";Cs[Ds]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Cs[Ds]=!0;export{ic as a,lc as b,pt as c,Nt as d,Te as e,Pn as f,Cl as g,Uc as h,fe as i,Tl as j,Oc as k,Bn as l,Mc as m,Tc as n,Nc as o,Lc as p,Rc as q,_ as r,at as s,Fc as t,Pc as u,jc as v,Zt as w,C as x,mr as y,Rt as z,A,rt as B,b as C,N as D};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as o}from"./c-VKEDWYDF.js";import{f as r}from"./c-C7SUMNMI.js";import{r as c}from"./c-UW6MMZ4V.js";var s="[editmode\\:resource]:is(style, link, script)",u='[editmode\\:resource]:is(style, link, script)[type^="inert/"]',n="inert/";function l(e){let t=e.getAttribute("type");return t&&t.startsWith(n)?!1:(e.setAttribute("type",n+(t||"")),!0)}function a(e){let t=e.getAttribute("type").slice(n.length);t==="javascript"?e.setAttribute("type","text/javascript"):t?e.setAttribute("type",t):e.removeAttribute("type")}function p(){c(e=>{e.querySelectorAll(s).forEach(l)},{required:!0})}function d(){r&&o(()=>{f()})}function f(e=document){let t=(e.ownerDocument||e)===document;e.querySelectorAll(u).forEach(i=>{a(i),t&&i.replaceWith(i.cloneNode(!0))})}function b(){document.querySelectorAll(s).forEach(e=>{l(e)&&e.replaceWith(e.cloneNode(!0))})}function R(){p(),d()}export{s as a,f as b,b as c,R as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as d}from"./c-VO6RSFCO.js";import"./c-WN3MXOLT.js";import{b as f,c as m}from"./c-RVMWGXEJ.js";import{b as n,c as r}from"./c-NUHP2XDB.js";import{e as c}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-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var x=30,g=6,e=null,u=null;function O(){return u??=Promise.all([import("./c-
|
|
1
|
+
import{f as d}from"./c-VO6RSFCO.js";import"./c-WN3MXOLT.js";import{b as f,c as m}from"./c-RVMWGXEJ.js";import{b as n,c as r}from"./c-NUHP2XDB.js";import{e as c}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-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var x=30,g=6,e=null,u=null;function O(){return u??=Promise.all([import("./c-33SS5A4Y.js"),import("./c-46LJAZZJ.js")]).then(([o,t])=>e={pageScheme:o.pageScheme,paintLook:o.paintLook,RUNTIME_ONLY:o.RUNTIME_ONLY,TOKENS:t.TOKENS,SHADOW:t.SHADOW,FONT:`600 11px/1 ${t.FONT_MONO}`,LABEL_FONT:`500 11px/1.4 ${t.FONT_MONO}`}).catch(o=>{throw u=null,o}),u}var N=()=>O().then(()=>!0,()=>!1),a=["all:initial","color-scheme:inherit","direction:ltr","unicode-bidi:isolate"],T="#FFFCF6";function l(o){return o.setAttribute("clay",e.RUNTIME_ONLY),o}function E(o){return{people:o.people.map(i=>({id:i.id,name:i.name,you:i.you})),anonymous:o.anonymous}}var h=class{constructor(){this.roster={people:[],anonymous:0},this.root=null,this.stack=null,this.count=null,this.tip=null,this._gate=null}supported(){return this._gate||(this._gate=Promise.all([c("presence"),c("record-awareness-v1"),c("blockeditor-awareness-v1")]).then(([t,i,s])=>(d.setCapabilities({supported:t,recordAwareness:i,pageAwareness:s}),t===!0),()=>!1)),this._gate}async update(t){let i=E(d.receive(t)),s=this.root&&JSON.stringify(i)===JSON.stringify(this.roster);if(this.roster=i,!!await this.supported()){if(s){e.paintLook(this.root);return}await this.render()}}clear(){d.clear(),this.roster={people:[],anonymous:0},this.root&&(this.root.remove(),this.root=null,this.stack=null,this.count=null,this.tip=null)}async render(){let{people:t,anonymous:i}=this.roster;if(t.length+i<=1||window.clay?.menu){this.hide();return}if(await N()&&this.build()){this.hideTip(),this.stack.textContent="";for(let s of t)this.stack.appendChild(this.avatar(s));this.stack.firstElementChild&&n(this.stack.firstElementChild,"margin-left","0"),i>0?(this.count.textContent=`+${i} viewing`,n(this.count,"display","inline-block")):(this.count.textContent="",n(this.count,"display","none")),n(this.root,"display","flex"),e.paintLook(this.root)}}hide(){this.root&&(this.hideTip(),this.stack.textContent="",this.count.textContent="",n(this.root,"display","none"))}build(){return this.root?!0:typeof document>"u"||!document.body?!1:(this.root=l(r("div",[...a,`color-scheme:${e.pageScheme()}`,"position:fixed","top:calc(12px + env(safe-area-inset-top,0px))","right:calc(12px + env(safe-area-inset-right,0px))","z-index:2147483000","display:flex","align-items:center","gap:8px","max-width:calc(100vw - 24px)",`font:${e.LABEL_FONT}`,`color:${e.TOKENS.ink}`,"pointer-events:none"])),this.root.setAttribute("data-clay-presence",""),this.count=l(r("span",[...a,"box-sizing:border-box","flex:none","white-space:nowrap","padding:3px 8px","border-radius:0",`background:${e.TOKENS.surface}`,`color:${e.TOKENS.muted}`,`border:1px solid ${e.TOKENS["line-2"]}`,`font:${e.LABEL_FONT}`,"letter-spacing:.02em",`box-shadow:${e.SHADOW}`,"display:none","pointer-events:none"])),this.count.setAttribute("data-clay-presence-count",""),this.stack=l(r("div",[...a,"display:flex","align-items:center","flex:none","pointer-events:none"])),this.tip=l(r("span",[...a,"position:absolute","top:100%","right:0","margin-top:6px","box-sizing:border-box","white-space:nowrap","pointer-events:none","padding:5px 9px","border-radius:0",`background:${e.TOKENS.ink}`,`color:${e.TOKENS.ground}`,`font:${e.LABEL_FONT}`,"letter-spacing:.02em",`box-shadow:${e.SHADOW}`,"display:none"])),this.tip.setAttribute("data-clay-presence-tip",""),this.root.append(this.stack,this.count,this.tip),document.body.appendChild(this.root),!0)}avatar(t){let i=f(t.id),s=[`background-color:${T}`,`color:${i}`,`border-color:${i}`],p=l(r("div",[...a,"box-sizing:border-box","flex:none",`width:${x}px`,`height:${x}px`,"border-radius:0","display:flex","align-items:center","justify-content:center",`font:${e.FONT}`,"letter-spacing:.02em",`margin-left:-${g}px`,"border-width:2px","border-style:solid","background-image:none",`box-shadow:${e.SHADOW}`,"user-select:none","cursor:default","pointer-events:auto",...s],m(t.name)));p.setAttribute("data-clay-presence-avatar","");let b=t.you?`${t.name} (you)`:t.name;return p.addEventListener("mouseenter",()=>this.showTip(b)),p.addEventListener("mouseleave",()=>this.hideTip()),p}showTip(t){this.tip&&(this.tip.textContent=t,n(this.tip,"display","block"))}hideTip(){this.tip&&(this.tip.textContent="",n(this.tip,"display","none"))}},y=new h;typeof document<"u"&&document.addEventListener("clay:menu-ready",()=>y.render());var v=y;export{h as Presence,v as default,y as presence};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as K}from"./c-
|
|
1
|
+
import{b as K}from"./c-SYOA4T7V.js";import{d as h}from"./c-3XGLJAS7.js";import{d as w,z as C}from"./c-OH2FPYSY.js";import{c as O}from"./c-FSQXFG5T.js";import"./c-RETTCOWO.js";import"./c-VHNSBD2M.js";var z=`
|
|
2
2
|
:where(article[data-blockeditor], .blockeditor-shell) { --blockeditor-board-lane: 274px; --blockeditor-board-gap: 14px; --blockeditor-board-radius: 8px; --blockeditor-board-panel: 360px; }
|
|
3
3
|
.blockeditor-editor .blockeditor-board { margin-block: 1.1em 1.5em; font-size: 15px; line-height: 1.4; white-space: normal; }
|
|
4
4
|
:is(.blockeditor-board, .blockeditor-board-panel) .i { flex: none; width: 16px; height: 16px; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as ae}from"./c-7WZSUTYP.js";import{i as re,j as se}from"./c-WHMZCRQD.js";import"./c-LAKBBJOU.js";import"./c-EIUKME3W.js";import"./c-DZT6W2NG.js";import"./c-SYOA4T7V.js";import"./c-ND3W7D5U.js";import"./c-WHQUZM2V.js";import{C as ce}from"./c-3XGLJAS7.js";import{A as _,F as te,a as W,b as Y,d as V,ea as oe,ia as ne,o as Z,r as U,y as N,z as ee}from"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import{b as Q}from"./c-RETTCOWO.js";import"./c-JC4RZW4E.js";import"./c-57XDY6HC.js";import{a as G}from"./c-I2SCCUEW.js";import"./c-PGSBXHUE.js";import"./c-VHNSBD2M.js";var ye="iframe, frame, frameset, object, embed, applet, meta, base, link, form, style, animate, set, animateMotion, animateTransform, portal",we=/^(srcdoc|data|formaction|codebase|archive|ping|background|poster|lowsrc|dynsrc)$/i,xe=/^\s*(javascript|vbscript|data):/i;function Me(o,a){let c=a.createElement("template");c.innerHTML=o;for(let d of c.content.querySelectorAll(ye))d.remove();for(let d of c.content.querySelectorAll("*"))for(let{name:h,value:m}of[...d.attributes])(we.test(h)||xe.test(m.replace(/[\u0000-\u0020]/g,"")))&&d.removeAttribute(h);return c.innerHTML}var H=2*1024*1024,le=32,ie=1e4,I=class extends Error{constructor(a,c){super(c),this.name="MarkdownImportError",this.code=a}},pe="\uFFFC",ue={type:"hard_break"},fe=new Set(["paragraph","heading","list","blockquote","code","table","hr","html","def","space"]),Se=new TextEncoder,de=V.marks,me=o=>o.slice().sort((a,c)=>a.type.rank-c.type.rank);function R(o,a,c){return o.some(d=>d.type===de[a])?o:me([...o,de[a].create(c)])}var he=/^(?![a-z][a-z0-9+.-]*:|[/#?])\S/i;function Ee(o,a){let c=typeof a=="function"?a(o):null;return typeof c=="string"&&c?W(c):he.test(o.trim())?null:W(o)}function Te(o,{images:a=!0,refused:c=[],unsupported:d=[],resolveLink:h=null}={}){let m=[],O="",v=[],q=()=>{O&&m.push({c:O,m:v}),O="",v=[]},M=($,k)=>{let u=String($??"");if(!u)return;let P=Z(me(k));O+=u;for(let b=0;b<u.length;b++)v.push(P)},S=$=>{O+=pe,v.push("@"+JSON.stringify($))},E=($,k)=>{for(let u of $??[]){let P=u?.type;if(typeof P!="string")throw new I("malformed-input","A Markdown token has no type.");switch(P){case"text":Array.isArray(u.tokens)?E(u.tokens.filter(b=>typeof b?.type=="string"&&!fe.has(b.type)),k):M(u.text,k);break;case"escape":M(u.text,k);break;case"strong":E(u.tokens,R(k,"strong"));break;case"em":E(u.tokens,R(k,"em"));break;case"del":case"strike":E(u.tokens,R(k,"strike"));break;case"codespan":M(u.text,R(k,"code"));break;case"br":S(ue);break;case"link":{let b=Ee(String(u.href??""),h);b?E(u.tokens,R(k,"link",{href:b})):(c.push({type:"link",href:String(u.href??"")}),E(u.tokens,k));break}case"image":{let b={src:String(u.href??""),alt:String(u.text??""),title:u.title??""};if(!a){M(b.alt,k);break}q(),m.push({image:b});break}case"html":M(u.text??u.raw,k);break;case"checkbox":break;default:d.push({type:P,text:String(u.raw??u.text??"")}),M(u.raw??u.text,k);break}}};return E(o,[]),q(),{parts:m}}function ke(o,{document:a=globalThis.document,resolveImage:c=null,resolveLink:d=null}={}){if(!Array.isArray(o))throw new I("malformed-input","Markdown import needs the lexer's token list.");let h=0;for(let n of o){if(!n||typeof n!="object"||typeof n.type!="string")throw new I("malformed-input","A Markdown token has no type.");h+=Se.encode(String(n.raw??"")).length}if(h>H)throw new I("input-too-large",`Markdown import is limited to ${H} bytes; this file is ${h}.`);let m=[],O=[],v=[],q=new Set,M=n=>{let r=_(n);for(;q.has(r);)r=_(n);return q.add(r),r},S=n=>{if(m.length+1>ie)throw new I("too-many-blocks",`Markdown import is limited to ${ie} blocks.`);m.push(n)},E=n=>{let r=n.depth+1;if(r>le)throw new I("nesting-too-deep",`Markdown import is limited to ${le} levels of nesting.`);return r},$=(n,r,{c:t,m:p})=>{let s={t:n,...r,c:t};return p.some(Boolean)&&(s.m=U(p)),s},k=n=>{let r=typeof c=="function"?c(n.src):null,t=typeof r=="string"&&r?r:null,p=t?Y(t):he.test(String(n.src).trim())?null:Y(n.src);return p?{t:"image",src:p,...n.alt?{alt:n.alt}:{},...n.title?{caption:n.title}:{}}:(v.push({type:"image",href:n.src}),n.alt?$("paragraph",{},{c:n.alt,m:[]}):null)},u=(n,r,t)=>{for(let p of t.parts){if(!p.image){S($(n,r,p));continue}let s=k(p.image);s&&S(s)}},P=(n,r)=>u(r.quote?"quote":"paragraph",{},n),b=(n,r={})=>Te(n,{refused:v,unsupported:O,resolveLink:d,...r}),K=n=>{let r=String(n.raw??n.text??"");O.push({type:n.type,text:r}),S({t:"code_block",lang:"markdown",c:r})},e=(n,r)=>{for(let t of n??[]){let p=t?.type;if(typeof p!="string")throw new I("malformed-input","A Markdown token has no type.");switch(p){case"space":break;case"heading":{let s=Math.min(6,Math.max(1,Number.parseInt(t.depth,10)||1));u("heading",s===2?{}:{level:s},b(t.tokens,{images:!1}));break}case"paragraph":case"text":P(b(t.tokens??[t]),r);break;case"hr":S({t:"divider"});break;case"code":S({t:"code_block",...t.lang?{lang:String(t.lang)}:{},c:String(t.text??"")});break;case"html":{let s=String(t.text??t.raw??"");O.push({type:"HTML block cleaned",text:s}),S({t:"preserved",html:Me(ne(a).fallback(s),a)});break}case"blockquote":{let s=E(r);e(t.tokens,{...r,depth:s,quote:!0});break}case"list":{let s=E(r),y=r.indent??0,f=t.ordered?"ordered":"bullet";for(let w of t.items??[]){let A={c:"",m:[]},C=[];for(let x of w?.tokens??[]){let g=x?.type;if(!(g==="checkbox"||g==="space"))if(g==="text"||g==="paragraph"){A.c&&(A={c:A.c+pe,m:[...A.m,"@"+JSON.stringify(ue)]});let j=g==="paragraph"?x.tokens??[]:[x];for(let T of b(j,{images:!1}).parts)A={c:A.c+T.c,m:[...A.m,...T.m]};C.push(...(x.tokens??[]).filter(T=>typeof T?.type=="string"&&fe.has(T.type)&&T.type!=="space"))}else C.push(x)}let D=w?.task?"check":f,B={...D==="bullet"?{}:{kind:D},...y?{indent:y}:{},...w?.task&&w.checked?{checked:!0}:{}};S($("list_item",B,A)),C.length&&e(C,{...r,depth:s,indent:y+1,quote:!1})}break}case"table":{let s=t.header??[];if(!s.length){K(t);break}let y=x=>b(x,{images:!1}).parts[0]??{c:"",m:[]},f=s.map(()=>M("c")),w=N(null,null,s.length),A=Object.fromEntries(f.map((x,g)=>[x,{pos:w[g],name:y(s[g]?.tokens).c}])),C=t.rows?.length?t.rows:[[]],D=N(null,null,C.length),B=C.map(x=>Object.fromEntries(f.map((g,j)=>{let T=y(x?.[j]?.tokens);return[g,T.m.some(Boolean)?{c:T.c,m:U(T.m)}:T.c]})));S({t:"table",cols:A,rows:Object.fromEntries(B.map((x,g)=>[M("r"),{pos:D[g],cells:x}]))});break}default:K(t);break}}};e(o,{depth:0,indent:0,quote:!1});let l=N(null,null,m.length),i={};return m.forEach((n,r)=>{i[M("b")]={...n,pos:l[r]}}),{blocks:i,unsupported:O,refused:v}}var Ae="markdown-import-preview",ze=new TextEncoder,Oe=o=>{let a=String(o??"").replace(/\s+/g," ").trim();return a.length>60?`${a.slice(0,60)}\u2026`:a},$e=o=>typeof o.text=="function"?o.text():new Promise((a,c)=>{let d=new FileReader;d.onload=()=>a(d.result),d.onerror=()=>c(d.error),d.readAsText(o)}),Ce=()=>globalThis.clay?.assets?.load?.("marked")??import("./c-XN6MBKI6.js"),ve=(o,a)=>{let c=-1;return o.forEach((d,h,m)=>{c<0&&d.attrs.id===a&&(c=m)}),c};function Pe(o){let a=o.selection.$from;if(a.depth>=1)return{node:a.node(1),at:a.before(1),textblock:a.parent.isTextblock};let c=Math.min(a.index(0),Math.max(0,o.doc.childCount-1)),d=0;for(let h=0;h<c;h++)d+=o.doc.child(h).nodeSize;return{node:o.doc.child(c),at:d,textblock:!1}}function Be(o){let{node:a,at:c,textblock:d}=Pe(o),h=o.selection,m=d?Math.max(0,h.from-c-1):0;return{id:a.attrs.id,textblock:d,size:a.isTextblock?a.content.size:0,fromOff:m,toOff:d?Math.max(m,h.to-c-1):0}}var Ie=o=>{try{return ae(oe(o))>0}catch{return!0}},qe=o=>o?.code==="blockeditor-format-upgrade-required"?"This document needs a newer page format before Markdown can be added. The preview stays open.":o?.code==="blockeditor-format-unsupported"?"This host cannot record the newer page format this file needs. The preview stays open.":o?.code==="stale-target"?"The place this import was started from changed. The preview stays open.":o?.code==="empty-import"?"This file holds nothing that can be inserted.":"The Markdown could not be inserted. The preview stays open.";function Qe({view:o=null,load:a=Ce}={}){if(!o)return{run:()=>Promise.resolve({ok:!1,code:"not-editing"}),dispose(){}};let c=o.dom.ownerDocument,d=null,h=null,m=!1,O=G({id:Ae,isPending:()=>d!==null}),v=()=>h??=Promise.resolve().then(a).catch(e=>{throw h=null,e});function q(){try{let e=o.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},l=o.coordsAtPos(Math.min(o.state.selection.from,o.state.doc.content.size));return{x:Math.max(8,l.left-e.left),y:l.bottom+6-e.top}}catch{return null}}function M(){let e=d;if(!e)return!1;d=null;for(let[l,i,n,r]of e.listen)l.removeEventListener(i,n,r);return e.panel.remove(),!0}function S(){return M()?(o.focus?.(),{ok:!0,cancelled:!0}):{ok:!1,code:"cancelled"}}function E(e){let l=[],i=(s,y)=>{let f=c.createElement("div");return f.className=s,f.textContent=y,f};if(l.push(i("blockeditor-menu-title",e.error?"Couldn't read that Markdown":`Import ${e.name}`)),!e.error){let s=[`${e.count} block${e.count===1?"":"s"}`];e.unsupported.length&&s.push(`${e.unsupported.length} kept as written`),e.refused.length&&s.push(`${e.refused.length} address${e.refused.length===1?"":"es"} left out`),l.push(i("blockeditor-menu-title blockeditor-import-summary",s.join(" \xB7 ")))}let n=(s,y)=>{let f=c.createElement("div");return f.className=s,f.replaceChildren(...y.map(w=>i("blockeditor-import-row",w))),f};e.unsupported.length&&l.push(n("blockeditor-import-unsupported",e.unsupported.map(s=>`${s.type}: ${Oe(s.text)}`))),e.refused.length&&l.push(n("blockeditor-import-refused",e.refused.map(s=>`${s.type}: ${s.href}`)));let r=e.error??e.notice??null;if(r){let s=c.createElement("p");s.className="blockeditor-import-error",s.setAttribute("role","alert"),s.textContent=r,l.push(s)}let t=(s,y)=>{let f=c.createElement("button");return f.type="button",f.className="blockeditor-menu-item",f.dataset.import=s,f.textContent=y,f.addEventListener("mousedown",w=>w.preventDefault()),f.addEventListener("click",()=>s==="insert"?k():S()),f},p=t("insert","Insert at the selection");p.disabled=!!e.error,l.push(p,t("cancel","Cancel")),e.panel.replaceChildren(...l)}function $(e,l){let i=o.state,n=i.doc,r=ve(n,e.id);if(r<0)return{ok:!1,code:"stale-target"};let t=n.child(r);if(e.textblock?!t.isTextblock||t.content.size!==e.size:t.isTextblock)return{ok:!1,code:"stale-target"};let p=ee(l).map(z=>te(V,z,{...l[z],pos:null,parent:null}));if(!p.length)return{ok:!1,code:"empty-import"};let s=0;for(let z=0;z<r;z++)s+=n.child(z).nodeSize;let y=n.maybeChild(r+1),f=t.type.name==="toggle",w=e.textblock&&!f&&t.content.size>0,A=w||e.textblock&&!f&&t.content.size===0,C=w?Math.min(e.fromOff,t.content.size):0,D=w?Math.min(Math.max(C,e.toOff),t.content.size):0,B=w&&C>0?t.type.create({...t.attrs},t.content.cut(0,C)):null,x=w?t.content.cut(D):null,g=x&&x.size?t.type.create({...t.attrs,id:_(),pos:null},x):null,j=w&&!B?r>0?n.child(r-1).attrs.pos:null:t.attrs.pos,T=N(j,y?.attrs.pos??null,p.length+(g?1:0)),be=f?t.attrs.id:t.attrs.parent??null,F=p.map((z,ge)=>z.type.create({...z.attrs,pos:T[ge],parent:be},z.content,z.marks)),X=g?g.type.create({...g.attrs,pos:T[p.length]},g.content,g.marks):null,L=i.tr;A?L.replaceWith(s,s+t.nodeSize,[...B?[B]:[],...F,...X?[X]:[]]):L.insert(s+t.nodeSize,F),f&&!t.attrs.open&&F.length>0&&L.setNodeMarkup(s,null,{...t.attrs,open:!0});let J=s+(A?B?B.nodeSize:0:t.nodeSize);for(let z of F)J+=z.nodeSize;return L.setSelection(Q.TextSelection.near(L.doc.resolve(X?J:Math.max(0,J-1)),X?1:-1)),o.dispatch(ce(L).scrollIntoView()),o.focus?.(),{ok:!0,blocks:F.length}}async function k(){let e=d;if(!e||e.error)return e?{ok:!1,code:"no-import"}:{ok:!1,code:"not-editing"};e.notice&&(e.notice=null,E(e));let l=()=>$(e.target,e.blocks),i=e.floor?await re(o,l):l();return i?.ok?(M(),i):(d===e&&(e.notice=qe(i),E(e)),i??{ok:!1,code:"import-failed"})}function u(e){!d||se(e,o)||(e.key==="Escape"?(e.preventDefault(),e.stopPropagation(),S()):e.key==="Enter"&&!e.target?.closest?.("[data-import]")&&(e.preventDefault(),e.stopPropagation(),k()))}function P(){return new Promise(e=>{let l=c.createElement("input");l.type="file",l.accept=".md,.markdown,text/markdown,text/plain",l.hidden=!0,l.className="blockeditor-markdown-input";let i=n=>{l.remove(),e(n)};l.addEventListener("change",()=>i(l.files?.[0]??null)),l.addEventListener("cancel",()=>i(null)),(o.dom.parentElement??c.body).appendChild(l),l.click()})}async function b(e,l=null){e.error=l;let i=c.createElement("div");i.className="blockeditor-menu blockeditor-import-preview",i.setAttribute("role","dialog"),i.setAttribute("aria-label","Import Markdown"),e.panel=i,d=e;let n=(p,s,y,f)=>{p.addEventListener(s,y,f),e.listen.push([p,s,y,f])};n(c,"keydown",p=>u(p),!0),n(c,"mousedown",p=>{e.panel.contains(p.target)||S()},!0),(o.dom.parentElement??c.body).appendChild(i),E(e);let r=q();r&&(i.style.setProperty("--blockeditor-pop-x",`${r.x}px`),i.style.setProperty("--blockeditor-pop-y",`${r.y}px`));let t=i.querySelector('[data-import="insert"]');return t&&!t.disabled&&t.focus?.(),{ok:!0,preview:!0}}async function K(e={}){if(m||o.isDestroyed)return{ok:!1,code:"not-editing"};M();let l=Be(o.state),i=e?.file??await P();if(!i)return{ok:!1,code:"cancelled"};if(typeof i.size=="number"&&i.size>H)return{ok:!1,code:"input-too-large"};let n;try{n=await $e(i)}catch(p){return{ok:!1,code:"unreadable",error:p}}if(m||o.isDestroyed)return{ok:!1,code:"not-editing"};if(ze.encode(n).length>H)return{ok:!1,code:"input-too-large"};let r={target:l,name:String(i.name??"Markdown"),blocks:{},count:0,unsupported:[],refused:[],floor:0,panel:null,error:null,notice:null,listen:[]},t;try{let p=await v();t=ke(new p.Marked().lexer(n))}catch(p){return m||o.isDestroyed?{ok:!1,code:"not-editing"}:b(r,String(p?.message??"The Markdown could not be read."))}return m||o.isDestroyed?{ok:!1,code:"not-editing"}:(r.blocks=t.blocks,r.count=Object.keys(t.blocks).length,r.unsupported=t.unsupported,r.refused=t.refused,r.floor=Ie(t.blocks)?1:0,b(r))}return{async run(e){return K(e)},dispose(){m=!0,M(),O.dispose()}}}export{Qe as createFeature};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as m}from"./c-PZ4XEPUP.js";import{a as c}from"./c-SFKI6OLM.js";import{a as p,b as y}from"./c-RHMPKZZ7.js";import{L as f,M as d}from"./c-
|
|
1
|
+
import{b as m}from"./c-PZ4XEPUP.js";import{a as c}from"./c-SFKI6OLM.js";import{a as p,b as y}from"./c-RHMPKZZ7.js";import{L as f,M as d}from"./c-UW6MMZ4V.js";function g(e=new Date){let t=r=>String(r).padStart(2,"0");return`${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}-${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}`}function h(e,t){let n=`<script type="application/json" id="clay-lost-edits" clay="no-save">${JSON.stringify(t).replace(/</g,"\\u003c")}<\/script>`,s=e.lastIndexOf("</body>");return s>=0?e.slice(0,s)+n+e.slice(s):e+n}function j(e,{refused:t=!1}={}){let r=window.clay?.conflicts||null,n=[],s=new Set;for(let o of e){let a=r?.recoveryOf(o.id);a&&!s.has(a.id)&&(s.add(a.id),n.push(a))}n.sort((o,a)=>(o.ticket||0)-(a.ticket||0));let u=o=>c(f(o.recoveryRoot??o.root,{prepared:o.domain==="save"})),i,l;t||!n.length?(i=c(d()),l=n):(i=u(n[n.length-1]),l=n.slice(0,-1));let w=e.map(o=>{if(o.kind==="apply-incomplete")return{id:o.id,kind:"apply-incomplete",name:"Sync update that did not finish",error:o.error??null};let{id:a,name:$,kind:S,yours:O,now:b,sentence:k}=m(o);return{id:a,name:$,kind:S,yours:O,now:b,sentence:k}}),v={format:"clay-lost-edits",version:1,savedAt:new Date().toISOString(),page:location.href,refused:!!t,edits:w,earlierPages:l.map(o=>({applyId:o.id,source:o.source,html:u(o)}))};return{html:h(i,v),name:`${p()}-${t?"my-version":"my-copy"}-${g()}.html`}}async function I({html:e=null,edits:t=[]}={}){try{let r=c(typeof e=="string"?e:d()),n={format:"clay-lost-edits",version:1,savedAt:new Date().toISOString(),page:location.href,refused:!1,edits:Array.isArray(t)?t:[],earlierPages:[]};return await y({html:h(r,n),name:`${p()}-my-copy-${g()}.html`})}catch(r){return console.error("clayjs: could not build the download",r),!1}}async function C(e,{refused:t=!1}={}){try{let{html:r,name:n}=j(e,{refused:t});return await y({html:r,name:n})}catch(r){return console.error("clayjs: could not build the download",r),!1}}export{I as a,C as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./c-
|
|
1
|
+
import{a}from"./c-755ZOHOM.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";export{a as replace};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var Ze=Object.defineProperty,Ge=(e,t)=>{for(var r in t)Ze(e,r,{get:t[r],enumerable:!0})},Oe=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],Qe=new Set(Oe),Ye=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Ne=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),ue=new Set(["checked","selected","disabled","readOnly","paused"]);function et(e,t){return t==null?ue.has(e)?!1:"":ue.has(e)?t==="false"?!1:!!t:t}var O={};Ge(O,{CodecRefused:()=>ot,EmptyListInsert:()=>M,MAX_RULE_DEPTH:()=>W,MaxRuleDepthExceeded:()=>Z,NoRulesTag:()=>nt,RuleTargetReadOnly:()=>Re,RulesParseError:()=>R,ShapeMismatch:()=>$e,UnknownCodec:()=>ke,UnknownRulesVersion:()=>Se,WriteNotRoundTripped:()=>rt,WriteRefused:()=>Ce,WriteRejected:()=>lt});var R=class extends Error{constructor(e,t){super(e),this.name="RulesParseError",this.cause=t}},Se=class extends Error{constructor(e){super(`unknown rules version: ${e}. Library supports "1" and "2".`),this.name="UnknownRulesVersion",this.version=e}},W=20,Z=class extends Error{constructor(e){super(`rule depth exceeded ${W} at path: ${e.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=e}},$e=class extends Error{constructor(e){super(`shape mismatch: ${e.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=e}},M=class extends Error{constructor(e,t){super(t?`cannot add items to empty list at "${e.join(".")}" \u2014 ${t}`:`cannot add items to empty list at "${e.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=e}},Re=class extends Error{constructor(e){super(`cannot write to read-only DOM property "${e}"`),this.name="RuleTargetReadOnly",this.target=e}},Ce=class extends Error{constructor(e){super(`write refused: ${e.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=e}};function tt(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t?`${t}.${r}`:String(r),"")||"(root)"}var rt=class extends Error{constructor(e){super(`write did not round-trip at "${tt(e)}"`),this.name="WriteNotRoundTripped",this.path=e}},nt=class extends Error{constructor(e){super(`no <script data-rules-name~="${e}"> rules tag in this document`),this.name="NoRulesTag",this.token=e}},lt=class extends Error{constructor(e,t){super(`write rejected: ${e.length} unknown key(s), ${t.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=e,this.unmatched=t}},ke=class extends Error{constructor(e){super(`unknown codec "${e}": no codec by that name is given to this call`),this.name="UnknownCodec",this.code="unknown-codec",this.codec=e}},ot=class extends Error{constructor(e,t){super(t),this.name="CodecRefused",this.code=e}};function C(e){let t=0,r=null,l=-1;for(let n=0;n<e.length;n++){let o=e[n];o==="\\"?n++:r?o===r&&(r=null):o==='"'||o==="'"?r=o:o==="["||o==="("?t++:o==="]"||o===")"?t>0&&t--:o==="@"&&t===0&&(l=n)}return l}var ae="[*]";function S(e){let t=C(e),r=t===-1?e:e.slice(0,t),l=r.endsWith(ae),n={selector:l?r.slice(0,-ae.length):r,prop:t===-1?null:e.slice(t+1)||null};return l&&(n.all=!0),n}function je(e){let t=0,r=null,l=-1,n=!1;for(let o=0;o<e.length;o++){let a=e[o];a==="\\"?o++:r?a===r&&(r=null):a==='"'||a==="'"?r=a:a==="["||a==="("?t++:a==="]"||a===")"?t>0&&t--:t===0&&a===">"?l=o:t===0&&a===","&&(n=!0)}return n||l===-1||!it(e,l+1)?null:e.slice(0,l).trim()||null}function it(e,t){let r=t,l=e.replace(/\s+$/,"").length;for(;r<l&&/\s/.test(e[r]);)r++;let n=0,o=null;for(;r<l;r++){let a=e[r];if(a==="\\")r++;else if(o)a===o&&(o=null);else if(a==='"'||a==="'")o=a;else if(a==="["||a==="(")n++;else if(a==="]"||a===")")n>0&&n--;else if(n===0&&(a==="+"||a==="~"||/\s/.test(a)))return!1}return!0}var ut=/^codec\(([a-z][a-z0-9-]*)\)$/;function G(e){if(typeof e!="string")return null;let t=C(e);if(t===-1)return null;let r=ut.exec(e.slice(t+1));if(!r)return null;let{selector:l,all:n}=S(e);if(n)throw new R("A @codec(name) rule cannot use [*].");return{selector:l,name:r[1]}}var at=/^--[A-Za-z0-9_-]+$/;function Q(e){return typeof e=="string"&&at.test(e)}function Le(e){let t=[],r=[],l=null,n=0;for(let o=0;o<e.length;o++){let a=e[o];if(l){a==="\\"?o++:a===l&&(l=null);continue}if(a==="/"&&e[o+1]==="*"){let i=e.indexOf("*/",o+2);o=i===-1?e.length:i+1;continue}a==='"'||a==="'"?l=a:a==="("?r.push(")"):a==="["?r.push("]"):a==="{"?r.push("}"):(a===")"||a==="]"||a==="}")&&r[r.length-1]===a?r.pop():a===";"&&r.length===0&&(t.push(e.slice(n,o)),n=o+1)}return t.push(e.slice(n)),t}function st(e){let t="",r=null;for(let l=0;l<e.length;l++){let n=e[l];if(r){t+=n,n==="\\"&&l+1<e.length?t+=e[++l]:n===r&&(r=null);continue}if(n==="/"&&e[l+1]==="*"){let o=e.indexOf("*/",l+2);l=o===-1?e.length:o+1,t+=" ";continue}(n==='"'||n==="'")&&(r=n),t+=n}return t}function Me(e){e=st(e);let t=e.indexOf(":");if(t===-1)return null;let r=e.slice(0,t).trim(),l=e.slice(t+1).trim(),n=/!\s*important\s*$/i.exec(l);return n&&(l=l.slice(0,n.index).trim()),{name:r,value:l,important:!!n}}function Y(e,t){if(e==null)return null;let r=null;for(let l of Le(String(e))){let n=Me(l);!n||n.name!==t||(!r||n.important||!r.important)&&(r=n)}return r?r.value:null}function ct(e,t,r){let l=e==null?"":String(e),n=r==null||r==="",o=Le(l),a=o.map(Me),i=a.some(d=>d&&d.name===t&&d.important),u=[],s=!1;o.forEach((d,p)=>{let v=a[p];if(!v||v.name!==t){u.push(d);return}if(n||s)return;let f=/^\s*/.exec(d)[0];u.push(`${f}${t}: ${r}${i?" !important":""}`),s=!0});let c=u.join(";");if(!n&&!s){let d=c.trimEnd();c=d===""?`${t}: ${r}`:`${d}${d.endsWith(";")?" ":"; "}${t}: ${r}`}return c.trim()===""?null:c}function Ie(e,t,r,l){let n=e.attr(t,"style");if((Y(n,r)??"")===l)return;let o=ct(n,r,l);o==null?e.removeAttr(t,"style"):e.attr(t,"style",o)}var se=/^[a-z][a-z0-9-]*$/,ee=new Map;function ft(e,t){if(typeof e!="string"||!se.test(e))throw new Error(`hyper-html-api: invalid codec name ${JSON.stringify(e)} (must match ${se})`);if(!t||typeof t.read!="function"||typeof t.write!="function"||typeof t.same!="function")throw new Error(`hyper-html-api: codec "${e}" needs read, write and same functions`);ee.set(e,t)}function dt(e){return ee.get(e)??null}function pt(){return Object.fromEntries(ee)}var ht='The @codec(name) rule form needs a rules tag with data-rules-version="2".',mt="A @codec(name) rule must be the value of a top level key.";function We(e,t){let r=G(e);return r?{...r,codec:t.codecs[r.name]}:null}function te(e,t={}){let r=t.version??"1",l=t.codecs??{};n(e,0);function n(o,a){if(!(a>W)){if(typeof o=="string"){let i=G(o);if(!i)return;if(r!=="2")throw new R(ht);if(a!==1)throw new R(mt);if(!Object.prototype.hasOwnProperty.call(l,i.name))throw new ke(i.name);return}if(Array.isArray(o)){n(o[1],a+1);return}if(o&&typeof o=="object")for(let i of Object.values(o))n(i,a+1)}}}function q(e,t,r,l={}){if(Object.prototype.hasOwnProperty.call(l,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return te(r,l),_(e,t,r,{depth:0,path:[]},l)}function _(e,t,r,l,n){if(l.depth>W)throw new Z(l.path);if(typeof r=="string")return yt(e,t,r,l,n);if(Array.isArray(r)){let[o,a]=r,i=e.find(t,o,n);return De(n,l,i),i.map((u,s)=>_(e,u,a,{depth:l.depth+1,path:[...l.path,s]},n))}if(typeof r=="object"&&r!==null){let o={};for(let[a,i]of Object.entries(r))o[a]=_(e,t,i,{depth:l.depth+1,path:[...l.path,a]},n);return o}return null}function yt(e,t,r,l,n){if(r.endsWith("[]")){let c=r.slice(0,-2),d=e.find(t,c,n);return De(n,l,d),d.map(p=>e.text(p))}let o=We(r,n);if(o)return gt(e,t,o,n);if(r.startsWith("@"))return z(e,t,r.slice(1));let a=C(r);if(a!==-1){let{selector:c,all:d}=S(r),p=r.slice(a+1),v=c?e.find(t,c,n):[t];return d&&n.allMatches?v.map(f=>z(e,f,p)):v.length===0?null:z(e,v[0],p)}if(r===".")return e.text(t);let{selector:i,all:u}=S(r),s=e.find(t,i,n);return u&&n.allMatches?s.map(c=>e.text(c)):s.length===0?null:e.text(s[0])}function gt(e,t,{selector:r,codec:l},n){let o=r?e.find(t,r,n):[t];return o.length===0?null:l.read(e,o[0],{query:n.query,view:n.view,region:n.region})}function De(e,t,r){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),r)}catch(l){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,l)}}function z(e,t,r){if(Q(r))return Y(e.attr(t,"style"),r);if(Qe.has(r)){let n=e.prop(t,r);return n==null?null:String(n)}return e.attr(t,r)??null}function wt(e,t,r,l){let n=e.length,o=t.length,a=new Array(n).fill(-1);if(l){let h=new Set;for(let y=0;y<n;y++){let w=l[y];!(w>=0&&w<o)||h.has(w)||(a[y]=w,h.add(w))}}if(n===0||o===0)return a;let i=e.map(h=>ce(h,r)),u=t.map(h=>ce(h,r)),s=new Array(o).fill(!1);for(let h of a)h>=0&&(s[h]=!0);let c=new Map;u.forEach((h,y)=>{s[y]||c.set(h,c.has(h)?-1:y)});let d=new Map;i.forEach((h,y)=>{a[y]>=0||d.set(h,(d.get(h)||0)+1)}),i.forEach((h,y)=>{if(a[y]>=0||d.get(h)!==1)return;let w=c.get(h);w===void 0||w===-1||s[w]||(a[y]=w,s[w]=!0)});let p=[];for(let h=0;h<n;h++)a[h]<0&&p.push(h);let v=[];for(let h=0;h<o;h++)s[h]||v.push(h);if(p.length===0||v.length===0)return a;let f=n*o+1,m=vt(e,t,r),g=(h,y)=>m(h,y)*f+Math.abs(h-y);for(let[h,y]of At(p,v,g))a[h]=y;return a}var Pe=e=>typeof e=="object"&&e!==null;function ce(e,t){if(!Pe(t))return e==null?" null":String(e);let r=Object.keys(t);return JSON.stringify(r.map(l=>{let n=JSON.stringify(e?.[l]);return n===void 0?" undef":n}))}function vt(e,t,r){if(!Pe(r))return(i,u)=>e[i]===t[u]?0:1;let l=Object.keys(r),n=i=>l.map(u=>JSON.stringify(i?.[u])),o=e.map(n),a=t.map(n);return(i,u)=>{let s=o[i],c=a[u],d=0;for(let p=0;p<l.length;p++)s[p]!==c[p]&&d++;return d}}function At(e,t,r){return e.length<=t.length?fe(e,t,r,!1):fe(t,e,(l,n)=>r(n,l),!0)}function fe(e,t,r,l){let n=e.length,o=t.length,a=[];for(let d=0;d<=n;d++)a.push(new Float64Array(o+1).fill(1/0));let i=[];for(let d=0;d<=n;d++)i.push(new Uint8Array(o+1));for(let d=0;d<=o;d++)a[n][d]=0;for(let d=n-1;d>=0;d--)for(let p=o-1;p>=0;p--){let v=r(e[d],t[p])+a[d+1][p+1],f=a[d][p+1];v<=f?(a[d][p]=v,i[d][p]=1):a[d][p]=f}let u=[],s=0,c=0;for(;s<n&&c<o;)i[s][c]&&(u.push(l?[t[c],e[s]]:[e[s],t[c]]),s++),c++;return u}function qe(e,t,r,l,n,o,a,i={}){let u=e.find(t,r,i);if(n.length===0){u.forEach(b=>e.remove(b)),V(i,"onRowsApplied",o.path,[]);return}let s=n.length>u.length,c=u[0]||null;if(s&&!c&&(c=xt(e,t,r,i),!c))throw new M(o.path);let d=u.map(b=>Et(e,b,l,i)),p=null;if(s&&c){p=e.clone(c);let b=i.templateAttr&&e.attr(c,i.templateAttr)!=null;i.templateAttr&&e.removeAttr(p,i.templateAttr),b&&e.removeAttr(p,"hidden");let T=e.stripIds(p);T>0&&console.warn(`[hyper-html-api] stripped ${T} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let v=wt(n,d,l,bt(e,u,n,o,i)),f=u.length>0?e.parent(u[0]):$t(e,t,r,c,o,i),m=u.length>0?Be(e,f,u[0]):0,g=kt(e,u),h=new Set,y=[],w=n.map((b,T)=>{let A=v[T];if(A>=0)return h.add(A),y.push(!1),u[A];y.push(!0);let x=e.clone(p);return e.stripIds(x),x});u.forEach((b,T)=>{h.has(T)||e.remove(b)}),g?Ct(e,f,m,w,y):jt(e,w,y,f,m),Tt(e,w,l,n,o,a,i),V(i,"onRowsApplied",o.path,w)}function V(e,t,r,l){if(typeof e[t]=="function")try{return e[t](r.slice(),l)}catch(n){console.warn(`[hyper-html-api] ${t} threw at "${r.join(".")||"(root)"}"`,n);return}}function bt(e,t,r,l,n){let o=V(n,"identifyRows",l.path,r);if(!Array.isArray(o))return null;let a=new Array(r.length).fill(-1),i=new Set,u=new Map(t.map((s,c)=>[e.identity(s),c]));for(let s=0;s<r.length;s++){if(!o[s])continue;let c=u.get(e.identity(o[s]));c===void 0||i.has(c)||(a[s]=c,i.add(c))}return a}function Tt(e,t,r,l,n,o,a){t.forEach((i,u)=>{if(r===null){let s=l[u],c=s==null?"":String(s);e.text(i)!==c&&e.text(i,c)}else{let s=o(e,i,r,l[u],{depth:n.depth+1,path:[...n.path,u]},a);s&&s!==i&&(t[u]=s)}})}function Et(e,t,r,l){return r===null?e.text(t):q(e,t,r,l.onRowsRead?{...l,onRowsRead:void 0}:l)}function Be(e,t,r){let l=e.children(t);for(let n=0;n<l.length;n++)if(e.sameNode(l[n],r))return n;return-1}function xt(e,t,r,l){if(!l.templateAttr)return null;let n=/^\s*:scope\s*>\s*/.test(r),o=new RegExp(":not\\(\\["+l.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),a=r.replace(/^\s*:scope\s*>\s*/,"").replace(o,""),i=n?Ot(a):0,u=je(a),s=t;for(;s;){let c=e.find(s,a,{includeRulesTag:!1,templateAttr:null});for(let d of c)if(e.attr(d,l.templateAttr)!=null&&!(n&&!St(e,t,d,i))&&!(u&&!e.matches(e.parent(d),u)))return d;s=e.parent(s)}return null}function Ot(e){let t=0,r=null,l=1;for(let n=0;n<e.length;n++){let o=e[n];if(o==="\\")n++;else if(r)o===r&&(r=null);else if(o==='"'||o==="'")r=o;else if(o==="["||o==="(")t++;else if(o==="]"||o===")")t>0&&t--;else if(t===0&&o===">")l++;else{if(t===0&&(o==="+"||o==="~"))return null;if(t===0&&/\s/.test(o)){if(!Nt(e,n))return null;for(;n+1<e.length&&/\s/.test(e[n+1]);)n++}}}return l}function Nt(e,t){let r=t;for(;r<e.length&&/\s/.test(e[r]);)r++;let l=t>0?e[t-1]:"",n=r<e.length?e[r]:"";return de(l)||de(n)}function de(e){return e===">"||e==="+"||e==="~"}function St(e,t,r,l){if(l===null)return!0;let n=r;for(let u=0;u<l;u++)if(n=e.parent(n),!n)return!1;let o=e.prop(t,"tagName");if(!o)return!0;let a=e.prop(n,"tagName");if(!a||String(a).toLowerCase()!==String(o).toLowerCase())return!1;let i=new Set(pe(e,n));return pe(e,t).every(u=>i.has(u))}function pe(e,t){let r=e.attr(t,"class");return r?String(r).split(/\s+/).filter(Boolean):[]}function $t(e,t,r,l,n,o){let a=e.parent(l);if(a&&Rt(e,t,a)&&!me(e,a,o))return a;let i=je(r);if(!i)throw new M(n.path,`the list selector "${r}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let u=(i===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,i,o)).filter(s=>!me(e,s,o));if(u.length===0)throw new M(n.path,`no container matching "${i}" inside this context to hold the new rows`);if(u.length>1)throw new M(n.path,`"${i}" matches ${u.length} containers inside this context, so the new rows have no single destination`);return u[0]}function Rt(e,t,r){let l=r;for(;l;){if(e.sameNode(l,t))return!0;l=e.parent(l)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(n=>e.sameNode(n,r))}var he=["no-data","editor-ui"];function me(e,t,r){let l=t;for(;l;){if(r.templateAttr&&e.attr(l,r.templateAttr)!=null||he.some(o=>e.attr(l,o)!=null))return!0;let n=e.attr(l,"clay");if(n&&n.split(/\s+/).some(o=>he.includes(o)))return!0;l=e.parent(l)}return!1}function Ct(e,t,r,l,n){let o=e.children(t),a=o.map(u=>e.identity(u)),i=!1;l.forEach((u,s)=>{let c=e.identity(u),d=r+s;if(a[d]===c)return;if(!n[s]){let v=a.indexOf(c);v!==-1&&(a.splice(v,1),o.splice(v,1))}let p=Math.min(d,o.length);p<o.length?e.insertBefore(o[p],u):o.length?i?e.insertAfter(o[o.length-1],u):(e.insertAt(t,u,d),i=!0):e.insertAt(t,u,0),a.splice(p,0,c),o.splice(p,0,u)})}function kt(e,t){if(t.length<=1)return!0;let r=e.parent(t[0]);if(!r)return!1;let l=new Map(e.children(r).map((o,a)=>[e.identity(o),a])),n=[];for(let o of t){let a=l.get(e.identity(o));if(a===void 0)return!1;n.push(a)}return n.sort((o,a)=>o-a),n[n.length-1]-n[0]===n.length-1}function jt(e,t,r,l,n){let o=null,a=n;for(let i=0;i<t.length;i++){if(!r[i]){o=t[i];continue}let u=o?e.parent(o):l;if(!u)continue;let s=o?Be(e,u,o)+1:a++;e.insertAt(u,t[i],s),o=t[i]}}function B(e,t,r,l,n={}){if(Object.prototype.hasOwnProperty.call(n,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");te(r,n);let o=[];if(F(r,l,[],o),o.length)throw new $e(o);H(e,t,r,l,{depth:0,path:[]},n)}function H(e,t,r,l,n,o={}){if(n.depth>W)throw new Z(n.path);if(l===void 0)return t;if(typeof r=="string")return Lt(e,t,r,l,n,o);if(Array.isArray(r)){let[a,i]=r;return qe(e,t,a,i,l,n,H,o),t}if(typeof r=="object"&&r!==null){for(let[a,i]of Object.entries(r)){let u=H(e,t,i,l==null?l:l[a],{depth:n.depth+1,path:[...n.path,a]},o);u&&u!==t&&(t=u)}return t}return t}function Lt(e,t,r,l,n,o){if(r.endsWith("[]")){let d=r.slice(0,-2);return qe(e,t,d,null,l,n,H,o),t}let a=We(r,o);if(a){let d=a.selector?e.find(t,a.selector,o):[t];return d.length&&a.codec.write(e,d[0],l,{query:o.query}),t}if(r.startsWith("@"))return ge(e,t,r.slice(1),l);let i=C(r);if(i!==-1){let{selector:d,all:p}=S(r),v=r.slice(i+1),f=d?e.find(t,d,o):[t];for(let m of p?f:f.slice(0,1))ge(e,m,v,l);return t}if(r===".")return ye(e,t,l),t;let{selector:u,all:s}=S(r),c=e.find(t,u,o);for(let d of s?c:c.slice(0,1))ye(e,d,l);return t}function ye(e,t,r){let l=r==null?"":String(r);e.text(t)!==l&&e.text(t,l)}function Mt(e,t,r,l){if(e.styleVar){e.styleVar(t,r,l);return}Ie(e,t,r,l)}function ge(e,t,r,l){if(Q(r))return Mt(e,t,r,l==null?"":String(l).trim()),t;if(Ne.has(r)){let n=e.prop(t,r);if(n===l||n!=null&&l!=null&&String(n)===String(l))return t;throw new Re(r)}if(r==="outerHTML"){let n=l==null?"":String(l);return e.replaceWith(t,n)}if(Ye.has(r)){let n=et(r,l);return e.prop(t,r)!==n&&e.prop(t,r,n),t}if(l==null)e.attr(t,r)!=null&&e.removeAttr(t,r);else{let n=String(l);e.attr(t,r)!==n&&e.attr(t,r,n)}return t}function F(e,t,r,l){if(t!==void 0){if(typeof e=="string"){if(G(e))return;if(e.endsWith("[]")){Array.isArray(t)?t.forEach((n,o)=>{typeof n=="object"&&n!==null&&l.push({path:j([...r,o]),expected:"scalar",got:k(n)})}):l.push({path:j(r),expected:"array",got:k(t)});return}t!==null&&typeof t=="object"&&l.push({path:j(r),expected:"scalar",got:k(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){l.push({path:j(r),expected:"array",got:k(t)});return}let n=e[1];t.forEach((o,a)=>F(n,o,[...r,a],l));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){l.push({path:j(r),expected:"object",got:k(t)});return}for(let[n,o]of Object.entries(e))F(o,t[n],[...r,n],l)}}}function k(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function j(e){return e.join(".")}function It(e){try{return JSON.parse(e)}catch(t){throw new R(`Invalid strict JSON: ${t.message}`,t)}}function He(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function r(n){let o=[],a=0;for(;a<n.length;){let i=n[a];if(/\s/.test(i)){a++;continue}if("{}".includes(i)){o.push({type:i,value:i}),a++;continue}if(i==="["){let d=!1,p=a+1;for(;p<n.length&&/\s/.test(n[p]);)p++;if(p<n.length&&/[a-zA-Z_]/.test(n[p])&&(d=!0),!d){o.push({type:i,value:i}),a++;continue}}if(i==="]"){o.push({type:i,value:i}),a++;continue}if(i===":"){o.push({type:t.COLON,value:i}),a++;continue}if(i===","){o.push({type:t.COMMA,value:i}),a++;continue}if(i==='"'||i==="'"){let d=i,p=a+1;for(;p<n.length&&n[p]!==d;)n[p]==="\\"&&p++,p++;o.push({type:t.STRING,value:n.substring(a+1,p),quoted:!0,sourceQuote:d}),a=p+1;continue}let u=a,s;for(;u<n.length&&!/[{},]/.test(n[u]);)if(n[u]===":"){let d=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],p=!1;for(let v of d){let f=v.substring(1);if(n.substring(u+1,u+1+f.length)===f){p=!0,u+=f.length;break}}if(!p)break}else if(n[u]==="["){for(u++;u<n.length&&n[u]!=="]";){if(n[u]==='"'||n[u]==="'"){let d=n[u];for(u++;u<n.length&&n[u]!==d;)n[u]==="\\"&&u++,u++}u++}u<n.length&&n[u]==="]"&&u++}else u++;s=n.substring(a,u);let c=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(s)?c=t.NUMBER:s==="true"||s==="false"||s==="null"?c=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(s)&&(c=t.SELECTOR),o.push({type:c,value:s,quoted:!1}),a=u}return o}function l(n){let o="";for(let a=0;a<n.length;a++){let i=n[a];if("{}".includes(i.type)||"[]".includes(i.type)){o+=i.value;continue}if(i.type===t.COLON){o+=i.value;continue}if(i.type===t.COMMA){let u=n[a+1];if(u&&(u.type==="}"||u.type==="]"))continue;o+=i.value;continue}if(i.type===t.STRING&&i.quoted){let u=i.value;i.sourceQuote==="'"&&(u=u.replace(/\\'/g,"'"),u=u.replace(/(\\*)"/g,(s,c)=>c.length%2===0?c+'\\"':s)),o+=`"${u}"`;continue}if(i.type===t.NUMBER||i.type===t.BOOLEAN){o+=i.value;continue}if(i.type===t.SELECTOR||i.type===t.IDENTIFIER){o+=`"${i.value}"`;continue}o+=`"${i.value}"`}return o}try{let n=r(e),o=l(n);return JSON.parse(o)}catch(n){throw new R("Invalid extraction rules syntax: "+n.message,n)}}var Wt=["1","2"],we=/^[a-zA-Z0-9_-]+$/;function re(e,t,r){let l;if(r===void 0)l="script[data-rules-name]";else{if(typeof r!="string"||!we.test(r))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(r)} (must match ${we})`);l=`script[data-rules-name~="${r}"]`}let n=e.find(t,l,{includeRulesTag:!0});if(n.length===0)return null;r!==void 0&&n.length>1&&console.warn(`hyper-html-api: ${n.length} rules tags match data-rules-name~="${r}"; using the first.`);let o=n[0],a=e.attr(o,"data-rules-version");if(!Wt.includes(a))throw new Se(a);return{rules:He(e.text(o)),tagNode:o,version:a}}var ne=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),Dt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Pt=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function U(e,t){if(!e||e.nodeType!==1)return!1;let r=e.getAttribute?.("clay");return!!(r&&r.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function Ue(e,t){if(U(e,t))return!0;for(let[r,l]of Object.entries(Dt))if(l.includes(t)&&U(e,r))return!0;return!1}function J(e){let t=ne[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(r=>[`[clay~="${r}"]`,`[${r}]`]).join(", ")}function qt(e,t){let r=e&&e.nodeType===1?e:e?.parentElement;for(;r&&r.nodeType===1;){let l=ne[t];if(!l)throw new Error(`Unknown region capability: ${t}`);if(l.tokens.some(n=>Ue(r,n))||l.bundles.some(n=>U(r,n)))return r;r=r.parentElement}return null}function Bt(e,t){return!!qt(e,t)}var le=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...Pt],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})}),Ht=new Set(["textContent","innerText"]);function Ut(e){let t=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return t?t[1].toLowerCase():null}var zt=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function _t(e,t,r=le){if(!zt.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let l=String(e).toLowerCase();if(r.refusedAttributePrefixes.some(n=>l.startsWith(n)))return`attribute "${l}" can run script`;if(r.refusedAttributes.includes(l))return`attribute "${l}" is not content`;if(r.urlAttributes.includes(l)&&t!=null){let n=l==="srcset"?String(t).split(",").map(o=>o.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let o of n){let a=Ut(o);if(a&&r.refusedSchemes.includes(a))return`"${a}:" URLs are not allowed in "${l}"`}}return null}function oe(e,t){let r=e.prop(t,"tagName");return r?String(r).toLowerCase():""}function Vt(e,t){let r=oe(e,t)||"node",l=e.attr(t,"id");return l?`<${r}#${l}>`:`<${r}>`}function Ft(e,t,r){let l=t;for(;l;){let n=oe(e,l);if(n&&r.refusedTargets.includes(n))return n;l=e.parent(l)}return null}function ze(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function Jt(e,t){return oe(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:ze(e,t)}function Kt(e){if(/[\u0000-\u001f\u007f]/.test(e))return"control characters are not allowed in a custom property value";let t=[],r=null;for(let l=0;l<e.length;l++){let n=e[l];if(r){n===r&&(r=null);continue}if(n==='"'||n==="'")r=n;else{if(n==="/"&&e[l+1]==="*")return"comments are not allowed in a custom property value";if(n==="(")t.push(")");else if(n==="[")t.push("]");else if((n===")"||n==="]")&&t.pop()!==n)return`"${n}" does not close anything in this custom property value`}}return r?"a custom property value must close its quotes":t.length?"a custom property value must close its brackets":null}function Xt(e,t=le){let r=t.customPropertyValues,l=String(e);if(l.length>r.maxLength)return`custom property values are limited to ${r.maxLength} characters`;let n=r.refusedCharacters.find(u=>l.includes(u));if(n)return`${JSON.stringify(n)} is not allowed in a custom property value`;let o=Kt(l);if(o)return o;let a=l.toLowerCase(),i=r.refusedFunctions.find(u=>new RegExp(`(^|[^a-z0-9_-])${u.replace(/[-]/g,"\\-")}\\s*\\(`).test(a));return i?`"${i}()" is not allowed in a custom property value`:null}function ve(e,t=le){let r=[],l=(i,u)=>(r.push({target:Vt(e,i),reason:u}),!1),n=i=>{let u=Ft(e,i,t);return u?l(i,`inside <${u}>, which is not content`):!0},o=i=>n(i)?ze(e,i)?l(i,"a text write here would delete the data rules tag"):!0:!1,a=(i,u,s)=>{if(!n(i))return!1;let c=_t(u,s,t);return c?l(i,c):!0};return{...e,text(i,u){if(u===void 0)return e.text(i);o(i)&&e.text(i,u)},attr(i,u,s){if(s===void 0)return e.attr(i,u);a(i,u,s)&&e.attr(i,u,s)},removeAttr(i,u){a(i,u,null)&&e.removeAttr(i,u)},styleVar(i,u,s){if((Y(e.attr(i,"style"),u)??"")!==s&&n(i)){if(!Q(u))return l(i,`"${u}" is not a custom property`);if(s!==""){let c=Xt(s,t);if(c)return l(i,c)}Ie(e,i,u,s)}},prop(i,u,s){if(s===void 0)return e.prop(i,u);if(t.refusedRuleForms.includes(u))return l(i,`"@${u}" writes HTML, only text is allowed`);if(Ht.has(u)){o(i)&&e.prop(i,u,s);return}a(i,u==="className"?"class":u,s)&&e.prop(i,u,s)},remove(i){if(Jt(e,i)){l(i,"removing this would delete the data rules tag");return}e.remove(i)},replaceWith(i,u){return u===e.prop(i,"outerHTML")||l(i,'"@outerHTML" writes HTML, only text is allowed'),i},refusals:r,assertClean(){if(r.length)throw new Ce(r.slice())}}}function L(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ae(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t?`${t}.${r}`:r,"")}function Zt(e,t,r,l,n={}){te(r,n);let o=[],a=[];function i(s,c,d){if(Array.isArray(s)){let[,p]=s;if(!Array.isArray(c)||!L(p))return;c.forEach((v,f)=>i(p,v,[...d,f]));return}if(!(!L(s)||!L(c)))for(let p of Object.keys(c))Object.prototype.hasOwnProperty.call(s,p)?i(s[p],c[p],[...d,p]):o.push(Ae([...d,p]))}function u(s,c,d,p){if(d!==void 0){if(typeof c=="string"){if(c.endsWith("[]")||c==="."||c.startsWith("@"))return;let{selector:v}=S(c);if(!v)return;e.find(s,v,n).length===0&&a.push({path:Ae(p),selector:v});return}if(!Array.isArray(c)&&L(c)&&L(d))for(let[v,f]of Object.entries(c))u(s,f,d[v],[...p,v])}}return i(r,l,[]),u(t,r,l,[]),{unknownKeys:o,unmatched:a}}function be(e,t,r){if(r&&typeof r=="object")return{rules:r,tagNode:null,version:"1"};if(typeof r=="string"){let l=t&&t.ownerDocument?t.ownerDocument:t;return re(e,l,r)}return null}var Gt=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Qt(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let r=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&r!=="checkbox"&&r!=="radio"&&r!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(r==="checkbox"||r==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function Te(e,t,r,l){if(l)return!!e.closest?.(t);let n=e;for(;n?.nodeType===1;){if(n.matches(t))return!0;if(n===r)break;n=n.parentElement}return!1}function Ee(e,t,r,l,n,o){return(o?Bt(e,t):Te(e,r,n,!1))||!!(l&&(o&&e!==n?e.matches(l):Te(e,l,n,o)))}function Yt(e,t){let r=ne[t];return r.tokens.some(l=>Ue(e,l))||r.bundles.some(l=>U(e,l))}var er=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function _e(e,t,r,l){if(e.nodeType===1&&l(e)){r.dropped.push(t);return}r.cloneToLive.set(t,e),r.liveToClone.set(e,t);let n=e,o=t;if(e.nodeType===1){if(er.has(e.tagName)&&r.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);n=e.content,o=t.content,r.cloneToLive.set(o,n),r.liveToClone.set(n,o)}}else if(e.nodeType!==11)return;let a=o.firstChild;for(let i=n.firstChild;i&&a;i=i.nextSibling)_e(i,a,r,l),a=a.nextSibling}function D(e,{capability:t="data",exclude:r=null,inherit:l=!0,provenance:n=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let o=e.nodeType===9?e:e.ownerDocument;if(!o?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let a=o.implementation.createHTMLDocument(""),i=n||new WeakMap,u=new WeakMap,s=e.nodeType===9?e.documentElement:e;r&&a.documentElement.matches(r);let c=J(t),d=l?f=>Yt(f,t)||!!(r&&f.matches(r)):f=>Ee(f,t,c,r,s,!1),p=null;if(s.nodeType!==1||!Ee(s,t,c,r,s,l)){p=a.importNode(s,!0);let f={cloneToLive:i,liveToClone:u,dropped:[],controls:[]};_e(s,p,f,d);for(let m of f.dropped)m.remove();for(let m=0;m<f.controls.length;m+=2)Qt(f.controls[m],f.controls[m+1])}e.nodeType===9&&p&&(a.replaceChild(p,a.documentElement),u.set(e,a),i.set(a,e));let v=f=>{if(Gt.test(f))throw new Error(`Filtered content queries do not support stateful selector: ${f}`)};return{root:p,document:a,capability:t,selector:J(t),cloneToLive:i,liveToClone:u,original(f){return i.get(f)||null},cloneOf(f){return u.get(f)||null},query(f,m=p){return v(f),Array.from(m.querySelectorAll(f),g=>i.get(g)||g)},text(f=p){return(f===p?p:u.get(f))?.textContent||""},html(f=p){return(f===p?p:u.get(f))?.innerHTML??""},clone(f=p){let m=f===p?p:u.get(f);return m?a.importNode(m,!0):null}}}function Ve(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function tr(e){return e?(e.nodeType===9||e.nodeType,e):null}function xe(e,t,r){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=r===null?"":r:t==="checked"&&e.tagName==="INPUT"?e.checked=r!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=r!==null))}function Fe(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function Je(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let r of t)if(r.tagName==="TEXTAREA")r.value=r.defaultValue;else if(r.tagName==="INPUT"){let l=r.type;l!=="file"&&l!=="checkbox"&&l!=="radio"&&(r.value=r.defaultValue),r.checked=r.defaultChecked}else r.tagName==="OPTION"&&(r.selected=r.defaultSelected)}var E={semanticExclude:!0,find(e,t,r={}){let l=tr(e);if(!l||!l.querySelectorAll)return[];let n=Array.from(l.querySelectorAll(t));r.includeRulesTag||(n=n.filter(i=>!Ve(i)));let o=[];r.skip&&o.push(r.skip);let a=r.templateAttr===null?null:r.templateAttr||"cms-template";if(a&&o.push("["+a+"]"),o.length){let i=o.join(", ");n=n.filter(u=>!u.closest||!u.closest(i))}return n},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,Fe(e,t)},attr(e,t,r){if(r===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,r),xe(e,t,r)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),xe(e,t,null)},prop(e,t,r){if(r===void 0){let l=e?e[t]:void 0;return l!==void 0?l:null}e[t]=r},clone(e){let t=e.cloneNode(!0);return Je(t),t},insertAt(e,t,r){let l=e.children[r]||null;e.insertBefore(t,l)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let r=e.ownerDocument.createElement("template");r.innerHTML=t;let l=r.content.firstElementChild;if(!l)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(l,e),l},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(r=>{r.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function N(e,t={}){if(t.exclude===null)return E;let r=[J("data"),t.exclude].filter(Boolean).join(", "),l=e.nodeType===9?e:e.ownerDocument||e,n=e.nodeType===9?e.documentElement:e;if(!t._write&&!n?.matches?.(r)&&!n?.querySelector?.(r)&&!l?.querySelector?.(r))return E;let o=e.nodeType===9||!e.isConnected?e:e.ownerDocument,a=e.nodeType===9?e:e.ownerDocument,i=null,u=()=>i||(i=D(o,{capability:"data",exclude:t.exclude||null})),s=f=>{let m=u();return f===e?m.cloneOf(e):m.cloneOf(f)||f},c=f=>i?.original(f)||f,d=(f,m)=>{u().liveToClone.set(f,m),u().cloneToLive.set(m,f);let g=f.childNodes||[],h=m.childNodes||[];for(let y=0;y<Math.min(g.length,h.length);y++)d(g[y],h[y])},p=(f,m,g,h)=>{let y=Array.from(f.childNodes).filter(A=>i.cloneOf(A)),w=y[0];for(;w&&y.includes(w);)w=w.nextSibling;for(let A of y)A.remove();if(g==="innerHTML"){let A=a.createElement("template");A.innerHTML=h;for(let x of Array.from(A.content.childNodes))f.insertBefore(x,w||null)}else f.insertBefore(a.createTextNode(h),w||null),Fe(f,h);let b=D(f,{capability:"data",exclude:t.exclude||null});m.replaceChildren(...Array.from(b.root?.childNodes||[]));let T=A=>{let x=b.original(A);x&&(i.liveToClone.set(x,A),i.cloneToLive.set(A,x));for(let Xe of Array.from(A.childNodes||[]))T(Xe)};for(let A of Array.from(m.childNodes))T(A)},v={...E,find(f,m,g={}){let h=s(f);if(!h?.querySelectorAll)return[];let y=u().query(m,h);g.includeRulesTag||(y=y.filter(T=>!Ve(T)));let w=[];g.skip&&w.push(g.skip);let b=g.templateAttr===null?null:g.templateAttr||"cms-template";if(b&&w.push(`[${b}]`),w.length){let T=w.join(", ");y=y.filter(A=>!A.closest?.(T))}return y},parent(f){let m=s(f)?.parentElement;return m?c(m):null},children(f){return Array.from(s(f)?.children||[],c)},text(f,m){if(m===void 0){let y=c(f);return!y?.matches?.(r)&&!y?.querySelector?.(r)?E.text(y):(s(f)?.textContent||"").trim()}let g=c(f);if(!g?.matches?.(r)&&!g?.querySelector?.(r)&&!i){E.text(g,m);return}let h=u().cloneOf(g);h?p(g,h,"textContent",m):E.text(g,m)},attr(f,m,g){let h=c(f);if(g===void 0)return E.attr(h,m);E.attr(h,m,g);let y=i?.cloneOf(h);y&&(E.attr(y,m,g),D(h,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),i.liveToClone.delete(h),i.cloneToLive.delete(y)))},removeAttr(f,m){let g=c(f);E.removeAttr(g,m);let h=i?.cloneOf(g);h&&E.removeAttr(h,m)},prop(f,m,g){let h=c(f);if(g===void 0)return m==="innerHTML"||m==="outerHTML"||m==="textContent"||m==="innerText"?E.prop(s(h),m):E.prop(h,m);let y=m==="innerHTML"||m==="textContent"||m==="innerText",w=y?u().cloneOf(h):i?.cloneOf(h);w&&y?p(h,w,m,g):(E.prop(h,m,g),w&&E.prop(w,m,g))},clone(f){let m=s(f);if(m===f)return E.clone(f);let g=a.importNode(m,!0);return Je(g),g},insertAt(f,m,g){let h=c(f),y=v.children(h)[g]||(()=>{for(let T=h.children.length-1;T>=0;T--){let A=h.children[T];if(u().cloneOf(A))return A.nextElementSibling}return h.firstElementChild})(),w=c(m);h.insertBefore(w,y||null);let b=u().cloneOf(h);if(b){let T=u().cloneOf(w);T||(T=a.importNode(w,!0),d(w,T));let A=Array.from(b.children);b.insertBefore(T,A[g]||null)}},insertBefore(f,m){let g=c(f),h=c(m);g.parentNode.insertBefore(h,g);let y=u().cloneOf(g.parentNode);if(y){let w=u().cloneOf(h);w||(w=a.importNode(h,!0),d(h,w));let b=u().cloneOf(g);b?b.before(w):y.appendChild(w)}},insertAfter(f,m){let g=c(f),h=c(m);g.parentNode.insertBefore(h,g.nextSibling);let y=u().cloneOf(g.parentNode);if(y){let w=u().cloneOf(h);w||(w=a.importNode(h,!0),d(h,w));let b=u().cloneOf(g);b?b.after(w):y.appendChild(w)}},identity(f){return c(f)||null},remove(f){let m=c(f),g=u().cloneOf(m);E.remove(m),g&&E.remove(g)},replaceWith(f,m){let g=c(f),h=u().cloneOf(g),y=E.replaceWith(g,m);if(h){let w=D(y,{capability:"data",exclude:t.exclude||null});if(!w.root)h.remove();else{h.replaceWith(w.root);let b=T=>{let A=w.original(T);A&&(i.liveToClone.set(A,T),i.cloneToLive.set(T,A));for(let x of Array.from(T.childNodes||[]))b(x)};b(w.root)}}return y}};return v}var P=E,I=e=>({codecs:pt(),...e}),ie={extract:(e,t,r={})=>q(N(e,r),e,t,I(r)),apply:(e,t,r,l={})=>B(N(e,{...l,_write:!0}),e,t,r,I(l)),findRulesIn:(e,t)=>re(P,e,t),findRules:(e,t)=>be(P,e,t),bind:(e,t,r={})=>{let l=be(P,e,t);if(!l){let o=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${o}`)}let n=I({version:l.version,...r});return{...l,get:()=>q(N(e,r),e,l.rules,n),set:o=>B(N(e,{...r,_write:!0}),e,l.rules,o,n)}},codecs:{register:ft,get:dt},parseStrict:It,parseRelaxed:He,ruleAttrIndex:C,splitRule:S,errors:O,DOM_PROPERTIES:Oe},K=e=>!!e&&typeof e.nodeType=="number";function Ke(e){let t=e&&e.ownerDocument?e.ownerDocument:e,r=re(P,t,"api");if(!r)throw new O.NoRulesTag("api");return{rules:r.rules,version:r.version}}function rr(e){if(e.nodeType===9)return e;let t=e.ownerDocument?.documentElement;if(t?.contains(e))return t;let r=e;for(;r.parentNode;)r=r.parentNode;return r}function nr(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let t=e.ownerDocument.createDocumentFragment();for(let r of e.childNodes)t.appendChild(r.cloneNode(!0));return t}function lr(e,t){let r=[];for(;t!==e;){let l=t.parentNode;r.push(Array.prototype.indexOf.call(l.childNodes,t)),t=l}return r.reverse()}function or(e,t){return t.reduce((r,l)=>r.childNodes[l],e)}function $(e,t){let r=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&r.unshift(e),r}function ir(e,t){let r=$(e,"option"),l=$(t,"option");r.forEach((u,s)=>l[s].selected=u.selected);let n=$(e,"input"),o=$(t,"input");n.forEach((u,s)=>{let c=u.type.toLowerCase();c!=="file"&&(o[s].value=u.value),(c==="checkbox"||c==="radio")&&(o[s].checked=u.checked)});let a=$(e,"textarea"),i=$(t,"textarea");a.forEach((u,s)=>i[s].value=u.value)}function X(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let r=e.startsWith("@")?0:C(e);if(r===-1)return;let l=e.slice(r+1);if(Ne.has(l))throw new O.RuleTargetReadOnly(l);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(r=>X(e[1],r));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[r,l]of Object.entries(e))X(l,t[r])}}function ur(e,t,r,l){let n=I({templateAttr:"cms-template",version:l}),o=rr(e),a=lr(o,e),i=nr(o);ir(o,i);let u=or(i,a),s=N(i,{...n,_write:!0}),c=Zt(s,u,t,r,n);if(c.unknownKeys.length||c.unmatched.length)throw new O.WriteRejected(c.unknownKeys,c.unmatched);let d=ve(s);B(d,u,t,r,n),d.assertClean(),X(t,r);let p=ve(N(o,{...n,_write:!0}));B(p,e,t,r,n),p.assertClean()}function ar(e){if(!(e instanceof Error))return e;let t=e instanceof O.UnknownCodec||e instanceof O.CodecRefused?e.code:e.name||"Error";try{e.code=t}catch{Object.defineProperty(e,"code",{value:t,configurable:!0,enumerable:!0})}return e instanceof O.WriteRefused?e.details=e.refusals:e instanceof O.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof O.ShapeMismatch?e.details=e.mismatches:Array.isArray(e.path)?e.details={path:e.path}:typeof e.target=="string"?e.details={target:e.target}:e.token!==void 0?e.details={token:e.token}:e.version!==void 0?e.details={version:e.version}:e.details={},e}function sr(e,t){let r=K(e)?e:document,l=K(e)?t:e;if(l===void 0){let{rules:n,version:o}=Ke(r);return q(N(r),r,n,I({version:o}))}return ie.bind(r,l).get()}function cr(e,t,r){try{if(!K(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let{rules:l,version:n}=r===void 0?Ke(e):ie.bind(e,r);ur(e,l,t,n)}catch(l){throw ar(l)}return e}var fr={engine:ie,extractData:sr,applyData:cr},dr=fr;export{ie as a,sr as b,cr as c,dr as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as p,p as f,s as i,v as y}from"./c-
|
|
1
|
+
import{n as p,p as f,s as i,v as y}from"./c-UW6MMZ4V.js";import{i as m}from"./c-HA6INT6J.js";var S="http://www.w3.org/1999/xhtml",C=64*1024,g=256;function E(e){return e.namespaceURI===S&&e.localName!=="template"&&e.getElementsByTagName("*").length>=g}function*d(e,t,l,o){for(let n of e.childNodes){if(n.nodeType===1&&E(n)){yield*T(n,l,o);continue}let r;n.nodeType===1?r=n.outerHTML:(t.replaceChildren(n.cloneNode(!1)),r=t.innerHTML),l.push(r),o.bytes+=r.length,o.bytes>=C&&(o.bytes=0,yield)}}function*T(e,t,l){let o=i(e,!1),n=o.outerHTML,r=`</${o.localName}>`;t.push(n.slice(0,n.length-r.length)),yield*d(e,o,t,l),t.push(r)}function*h(e){let t=["<!DOCTYPE html>"];return yield*T(e,t,{bytes:0}),t.join("")}function*k(e){let t=p(e);if(!t.length)return yield*h(e);let l=f(t),o;try{o=yield*h(e)}finally{for(let[n,r]of t)n.replaceChildren(...r)}for(let[n,r]of l)o=o.split(n).join(r);return o}function*M(e){return y(e),yield*h(e)}function*b(e){let t=i(e,!1);for(let s of m)t.removeAttribute(s);let l=t.outerHTML,o=`</${t.localName}>`,n=["<!DOCTYPE html>",l.slice(0,l.length-o.length)],r=p(e),u=r.length?f(r):[];try{yield*d(e,i(e,!1),n,{bytes:0})}finally{for(let[s,a]of r)s.replaceChildren(...a)}n.push(o);let c=n.join("");for(let[s,a]of u)c=c.split(s).join(a);return c}export{h as a,k as b,M as c,b as d};
|