@panphora/clayjs 1.25.0 → 1.25.1
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 +4432 -3831
- package/dist/m/attrs/{save-freeze-MH3AOD56.js → save-freeze-PUYX32AK.js} +1 -1
- package/dist/m/{c-XHZIKRCV.js → c-2A2ATCIH.js} +1 -1
- package/dist/m/{c-BOMQIQ3V.js → c-2EFMJYGJ.js} +1 -1
- package/dist/m/{c-JD2VFAYG.js → c-2GB34XL4.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-ZEA3DCG3.js → c-3AAQJAKJ.js} +1 -1
- package/dist/m/c-3F3AADKG.js +1 -0
- package/dist/m/{c-GDNZEOOZ.js → c-3WX5FABT.js} +1 -1
- package/dist/m/{c-QWB53KRW.js → c-3XNTQQEJ.js} +1 -1
- package/dist/m/{c-AI3H6ETU.js → c-3Y234AUB.js} +2 -2
- package/dist/m/{c-GEAG5XAK.js → c-42RLKGEY.js} +1 -1
- package/dist/m/{c-XQTERKQA.js → c-44WITKWQ.js} +1 -1
- package/dist/m/c-47M4QHCK.js +1 -0
- package/dist/m/{c-UOUUI265.js → c-4M2T676V.js} +1 -1
- package/dist/m/{c-3E2IK5HU.js → c-4NAYDOWH.js} +1 -1
- package/dist/m/{c-TLQINES7.js → c-4OZZ7ENT.js} +2 -2
- package/dist/m/{c-QDVG4NAZ.js → c-5IIEOPIV.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-BCWYEG6P.js → c-7Z2625LX.js} +1 -1
- package/dist/m/{c-C6YZNU6E.js → c-A3OKSYRI.js} +1 -1
- package/dist/m/{c-RGAALCDU.js → c-A5IYL7JI.js} +1 -1
- package/dist/m/c-A5LASUEZ.js +1 -0
- package/dist/m/c-AQVQKFKB.js +1 -0
- package/dist/m/{c-IESDKFO6.js → c-ASGHHLFX.js} +1 -1
- package/dist/m/c-ASMLERFA.js +7 -0
- package/dist/m/{c-ORLPQFNU.js → c-AZM34SPO.js} +1 -1
- package/dist/m/{c-TCFVG3I4.js → c-BHLYQGTA.js} +1 -1
- package/dist/m/{c-ZORVIXUR.js → c-C27EVUQ6.js} +1 -1
- 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-NFQFV7OP.js → c-D2OPWOWO.js} +1 -1
- package/dist/m/{c-PRZNJUYZ.js → c-D4N4UJCQ.js} +2 -2
- package/dist/m/{c-D62HRSZK.js → c-DAUQ6JZ3.js} +1 -1
- package/dist/m/{c-5PZYDWTW.js → c-DDCYVLGG.js} +1 -1
- package/dist/m/{c-FBOO2UY3.js → c-DVMDYRAE.js} +1 -1
- package/dist/m/{c-WGQVSKKC.js → c-DYTBSJBI.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-EIDZHQHZ.js +1 -0
- package/dist/m/c-ELXMSEN5.js +1 -0
- package/dist/m/c-FC5RUFPR.js +1 -0
- package/dist/m/{c-V4B3RUWB.js → c-GFASNR55.js} +1 -1
- package/dist/m/{c-4AE2A2LK.js → c-GNFDX6SU.js} +1 -1
- package/dist/m/{c-UD4VDBGJ.js → c-H3M6UDNV.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-Z2OZFX3N.js → c-L6KVXPBO.js} +1 -1
- package/dist/m/{c-JWW6BHWD.js → c-LUBZU4AZ.js} +4 -4
- package/dist/m/{c-SEVOS4UE.js → c-LYNLY3MR.js} +1 -1
- package/dist/m/{c-NADLYVAH.js → c-MHTO3QAD.js} +1 -1
- package/dist/m/{c-SFYTKRU7.js → c-MKAUC6DB.js} +1 -1
- package/dist/m/c-MLMJUNRV.js +1 -0
- package/dist/m/{c-WDFQ7PBU.js → c-MMEVDN6D.js} +1 -1
- package/dist/m/{c-KYTVZT4D.js → c-NW4ZFKCY.js} +1 -1
- package/dist/m/{c-YFO6ZJLQ.js → c-O3DPFZCE.js} +1 -1
- package/dist/m/c-O4YIDULY.js +1 -0
- package/dist/m/c-OZOACVUD.js +1 -0
- package/dist/m/{c-MV7TEUTD.js → c-OZVK3TFI.js} +1 -1
- package/dist/m/c-PP3CUF3U.js +1 -0
- package/dist/m/{c-GY4BREDT.js → c-QL4NYM2L.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-FKTALXNV.js → c-STAPQ2X6.js} +1 -1
- package/dist/m/c-SYVF6ZMF.js +1 -0
- package/dist/m/{c-X3V4RWMA.js → c-T5IWJOMW.js} +1 -1
- package/dist/m/{c-DT7E76Z2.js → c-T7LOTEWO.js} +1 -1
- package/dist/m/{c-SFZRY6RT.js → c-TWB5ZQU4.js} +1 -1
- package/dist/m/c-U35T5NAY.js +1 -0
- package/dist/m/c-UW6MMZ4V.js +1 -0
- 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-WOJ2RTV4.js +1 -0
- package/dist/m/{c-ZJG6C2WL.js → c-WOWGGNCJ.js} +1 -1
- package/dist/m/{c-SXZYVXD6.js → c-XCOQNISP.js} +1 -1
- package/dist/m/{c-IL5IVTOG.js → c-XS7G6U3Z.js} +1 -1
- 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-WVCT3ITX.js → c-YZGWSCMT.js} +1 -1
- package/dist/m/{c-YX2MC7YL.js → c-ZJ7726FO.js} +1 -1
- 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-Y2NTMDGJ.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-CFMF6GHD.js → site-edits-TIJDPG6H.js} +1 -1
- 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-RC54UV7H.js → loader-7ORQVRCK.js} +1 -1
- package/dist/m/manifest-A27A4278.js +1 -0
- package/dist/m/manifest-edit-E8A61EB4.js +1 -0
- package/dist/m/manifest.json +1099 -1039
- package/dist/m/page/{editor-PKSPJ2XJ.js → editor-HS2CAV3W.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-4KET6RZT.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-CO4VJS46.js} +1 -1
- package/dist/m/plugins/{menu-YJZ3JWBC.js → menu-ESEFQARM.js} +1 -1
- package/dist/m/plugins/{page-GTDPYGE4.js → page-L3VKIQU2.js} +2 -2
- package/dist/m/plugins/{page-view-NMCCU6MF.js → page-view-6KNTXABH.js} +1 -1
- package/dist/m/plugins/{people-6WIWCZEG.js → people-EBWE337I.js} +1 -1
- package/dist/m/plugins/quickcrop-VNRXGRPC.js +26 -0
- package/dist/m/plugins/{richclay-L3BZMX4I.js → richclay-V6WKJTUF.js} +17 -17
- 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-WUK2NLBA.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-DX4K5GDB.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 +707 -677
- 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/snapshot.js +56 -43
- package/src/core/stale-host-notice.js +20 -7
- package/src/page/editor.js +10 -4
- package/src/page/import-markdown.js +22 -8
- package/src/page/save-projection.js +1 -1
- package/src/plugins/quickcrop.js +128 -69
- package/src/plugins/sortable.js +25 -9
- 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/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/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-K4M76VPM.js +0 -7
- package/dist/m/c-M7ITYKMF.js +0 -1
- package/dist/m/c-MR75YPRT.js +0 -1
- 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-RHPHMTF2.js +0 -2
- package/dist/m/c-RWJ3OSCP.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-U65PREMC.js +0 -1
- package/dist/m/c-VMXCX52Q.js +0 -1
- package/dist/m/c-YYGUHSZR.js +0 -1
- package/dist/m/manifest-3B84C829.js +0 -1
- package/dist/m/manifest-edit-1CB79AD4.js +0 -1
- package/dist/m/plugins/quickcrop-X5MRIBAP.js +0 -26
- 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-VNRXGRPC.js.LEGAL.txt} +0 -0
- /package/dist/m/plugins/{richclay-L3BZMX4I.js.LEGAL.txt → richclay-V6WKJTUF.js.LEGAL.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as h}from"./c-Q6BG3ZLO.js";import{i as k,j as y}from"./c-
|
|
1
|
+
import{c as h}from"./c-Q6BG3ZLO.js";import{i as k,j as y}from"./c-LUBZU4AZ.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-T7LOTEWO.js";import"./c-A3OKSYRI.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{C as g}from"./c-3Y234AUB.js";import{d}from"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import{b as m}from"./c-RETTCOWO.js";import"./c-JC4RZW4E.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var b=e=>String(e).padStart(2,"0");function A(e){if(typeof e!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;let s=new Date(`${e}T12:00:00Z`);return Number.isFinite(s.valueOf())&&s.toISOString().slice(0,10)===e}var $=(e=new Date)=>`${e.getFullYear()}-${b(e.getMonth()+1)}-${b(e.getDate())}`,E=(e,s)=>{let a=new Date(`${e}T12:00:00Z`);return a.setUTCDate(a.getUTCDate()+s),a.toISOString().slice(0,10)},I=e=>{let s=E(e,1);return[{id:"today",name:`Today (${e})`,date:e},{id:"tomorrow",name:`Tomorrow (${s})`,date:s}]};function L({view:e=null}={}){if(!e)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let s=e.dom.ownerDocument,a=null;function l(t){let o=e.state;if(!o.selection.empty||o.selection.from!==t.from||t.from<0||t.from>o.doc.content.size)return null;let r=o.doc.resolve(t.from);return!r.parent.isTextblock||r.parent.type.spec.code||!r.parent.type.allowsMarkType(d.marks.date)?null:t.from}function D(t){try{let o=e.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=e.coordsAtPos(t.from);return{x:Math.max(8,r.left-o.left),y:r.bottom+6-o.top}}catch{return null}}function u(t){let o=t.picker.activeId();o?e.dom.setAttribute("aria-activedescendant",o):e.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&e.dom.removeAttribute("aria-activedescendant")}function c(){let t=a;if(t){a=null;for(let[o,r,n,i]of t.listen)o.removeEventListener(r,n,i);e.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&e.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function x(t,o){let r=String(o),n=e.state.tr.insertText(r,t,t);return n.addMark(t,t+r.length,d.marks.date.create({date:r})),n.insertText(" ",t+r.length),n.setSelection(m.TextSelection.create(n.doc,t+r.length+1)),e.dispatch(g(n)),e.focus(),{ok:!0,date:r}}async function f(t){let o=a;if(!o)return{ok:!1,code:"not-editing"};let r=o.picker.personAt(t),n=l(o);return n===null||!r||!A(r.date)?(c(),r?n===null?{ok:!1,code:"stale-target"}:{ok:!1,code:"invalid-date"}:{ok:!1,code:"no-date"}):(c(),k(e,()=>{let i=l(o);return i===null?{ok:!1,code:"stale-target"}:x(i,r.date)}))}function S(t){let o=a;if(!o||y(t,e))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),o.picker.move(t.key==="ArrowDown"?1:-1),u(o)):t.key==="Enter"?(r(),f(o.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),c())}function T(){c();let t={from:e.state.selection.from,days:I($()),picker:null,listen:[]};t.picker=h({document:s,label:"Insert a date",empty:"No date to insert",onPick:r=>f(r)}),a=t;let o=(r,n,i,p)=>{r.addEventListener(n,i,p),t.listen.push([r,n,i,p])};return o(s,"keydown",r=>S(r),!0),o(e.dom,"input",()=>c()),o(s,"mousedown",r=>{t.picker.el.contains(r.target)||c()},!0),(e.dom.parentElement??s.body).appendChild(t.picker.el),l(t)===null?(c(),{ok:!1,code:"stale-target"}):(t.picker.show(t.days,D(t)),u(t),{ok:!0,picker:!0})}return{async run(){return T()},dispose(){c()}}}export{L as createFeature,I as earlyDays,A as isISODate,$ as localISODate};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as p}from"./c-H3FNLBHN.js";import{w as u}from"./c-
|
|
1
|
+
import{c as p}from"./c-H3FNLBHN.js";import{w as u}from"./c-LUBZU4AZ.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-T7LOTEWO.js";import"./c-A3OKSYRI.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-3Y234AUB.js";import{d as h}from"./c-OH2FPYSY.js";import{a as n,b as r}from"./c-Q26XHBLQ.js";import"./c-FSQXFG5T.js";import"./c-RETTCOWO.js";import"./c-JC4RZW4E.js";import"./c-3LDGIBMN.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var m=`
|
|
2
2
|
.blockeditor-tool-block { position: relative; min-height: 48px; border: 1px solid var(--blockeditor-rule); border-radius: 8px; padding: 12px; }
|
|
3
3
|
.blockeditor-tool-settings { position: absolute; top: 4px; inset-inline-end: 4px; border: 0; border-radius: 5px; background: var(--blockeditor-pop-bg); color: var(--blockeditor-ink-soft); font: 12px var(--blockeditor-font); padding: 5px 8px; cursor: pointer; opacity: 0; }
|
|
4
4
|
.blockeditor-tool-block:hover .blockeditor-tool-settings, .blockeditor-tool-block:focus-within .blockeditor-tool-settings { opacity: 1; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e}from"./c-K2ZHQMPF.js";import"./c-4M2T676V.js";import"./c-EIDZHQHZ.js";import"./c-UL2YUY52.js";import"./c-QY7F6EN6.js";import"./c-OZOACVUD.js";import"./c-QHWJ5ZIJ.js";import"./c-J2ZW4HMR.js";import"./c-A5LASUEZ.js";import"./c-4JZDZFF6.js";import"./c-5RZNFTWD.js";import"./c-PKCCHJ5X.js";import"./c-46XYM55L.js";import"./c-NUHP2XDB.js";import"./c-VKEDWYDF.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{a as ask,b as consent,e as init,d as snippet,c as tell};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as R,c as z}from"./c-OZOACVUD.js";import{d as j}from"./c-QHWJ5ZIJ.js";import{c as q,m as k}from"./c-J2ZW4HMR.js";import{b as Y}from"./c-NUHP2XDB.js";var $=Symbol("clay.surfaceTheme"),L=(()=>{"use strict";let r=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'];class u{constructor({targetModal:e,triggers:t=[],onShow:n=()=>{},onClose:f=()=>{},openTrigger:o="data-micromodal-trigger",closeTrigger:x="data-micromodal-close",openClass:F="is-open",disableScroll:v=!1,disableFocus:M=!1,awaitCloseAnimation:C=!1,awaitOpenAnimation:c=!1,debugMode:p=!1}){this.modal=typeof e=="string"?document.getElementById(e):e,this.config={debugMode:p,disableScroll:v,openTrigger:o,closeTrigger:x,openClass:F,onShow:n,onClose:f,awaitCloseAnimation:C,awaitOpenAnimation:c,disableFocus:M},t.length>0&&this.registerTriggers(...t),this.onClick=this.onClick.bind(this),this.onKeydown=this.onKeydown.bind(this)}registerTriggers(...e){e.filter(Boolean).forEach(t=>{t.addEventListener("click",n=>this.showModal(n))})}showModal(e=null){if(this.activeElement=document.activeElement,this.modal.setAttribute("aria-hidden","false"),this.scrollBehaviour("disable"),this.addEventListeners(),this.config.awaitOpenAnimation){let t=()=>{this.modal.removeEventListener("animationend",t,!1),this.setFocusToFirstNode()};this.modal.addEventListener("animationend",t,!1)}else this.setFocusToFirstNode();this.config.onShow(this.modal,this.activeElement,e)}closeModal(e=null){this.modal.setAttribute("aria-hidden","true"),this.removeEventListeners(),this.scrollBehaviour("enable"),this.config.onClose(this.modal,this.activeElement,e)}scrollBehaviour(e){if(!this.config.disableScroll)return;let t=document.querySelector("body");switch(e){case"enable":Object.assign(t.style,{overflow:""});break;case"disable":Object.assign(t.style,{overflow:"hidden"});break;default:}}addEventListeners(){this.modal.addEventListener("touchstart",this.onClick),this.modal.addEventListener("click",this.onClick),document.addEventListener("keydown",this.onKeydown)}removeEventListeners(){this.modal&&(this.modal.removeEventListener("touchstart",this.onClick),this.modal.removeEventListener("click",this.onClick)),document.removeEventListener("keydown",this.onKeydown)}onClick(e){(e.target.hasAttribute(this.config.closeTrigger)||e.target.parentNode.hasAttribute(this.config.closeTrigger))&&(e.preventDefault(),e.stopPropagation(),this.closeModal(e))}onKeydown(e){e.keyCode===27&&this.closeModal(e),e.keyCode===9&&this.retainFocus(e)}getFocusableNodes(){let e=this.modal.querySelectorAll(r);return Array(...e)}setFocusToFirstNode(){if(this.config.disableFocus)return;let e=this.getFocusableNodes();if(e.length===0)return;let t=e.filter(n=>!n.hasAttribute(this.config.closeTrigger));t.length>0&&t[0].focus(),t.length===0&&e[0].focus()}retainFocus(e){let t=this.getFocusableNodes();if(t.length!==0)if(t=t.filter(n=>n.offsetParent!==null),!this.modal.contains(document.activeElement))t[0].focus();else{let n=t.indexOf(document.activeElement);e.shiftKey&&n===0&&(t[t.length-1].focus(),e.preventDefault()),!e.shiftKey&&t.length>0&&n===t.length-1&&(t[0].focus(),e.preventDefault())}}}let l=null,g=(i,e)=>{let t=[];return i.forEach(n=>{let f=n.attributes[e].value;t[f]===void 0&&(t[f]=[]),t[f].push(n)}),t},h=i=>{if(!document.getElementById(i))return console.warn(`MicroModal: \u2757Seems like you have missed %c'${i}'`,"background-color: #f8f9fa;color: #50596c;font-weight: bold;","ID somewhere in your code. Refer example below to resolve it."),console.warn("%cExample:","background-color: #f8f9fa;color: #50596c;font-weight: bold;",`<div class="modal" id="${i}"></div>`),!1},a=i=>{if(i.length<=0)return console.warn("MicroModal: \u2757Please specify at least one %c'micromodal-trigger'","background-color: #f8f9fa;color: #50596c;font-weight: bold;","data attribute."),console.warn("%cExample:","background-color: #f8f9fa;color: #50596c;font-weight: bold;",'<a href="#" data-micromodal-trigger="my-modal"></a>'),!1},m=(i,e)=>{if(a(i),!e)return!0;for(let t in e)h(t);return!0};return{init:i=>{let e=Object.assign({},{openTrigger:"data-micromodal-trigger"},i),t=[...document.querySelectorAll(`[${e.openTrigger}]`)],n=g(t,e.openTrigger);if(!(e.debugMode===!0&&m(t,n)===!1))for(let f in n){let o=n[f];e.targetModal=f,e.triggers=[...o],l=new u(e)}},show:(i,e)=>{let t=e||{};t.targetModal=i,!(t.debugMode===!0&&h(i)===!1)&&(l&&l.removeEventListeners(),l=new u(t),l.showModal())},close:()=>{l&&(l.closeModal(),l=null)}}})(),G=(()=>{let r="",u="",l="",g="100",h="",a="",m="",b,T=!0,E=!0,i=!1,e=[],t=[],n=[];return{isShowing:!1,open(){let o=e,x=t,F=n;e=[],t=[],n=[];let v=!1,M=()=>{v||(v=!0,x.forEach(s=>s()))};(this.isShowing||document.querySelector("[data-clay-modal]"))&&(this._dismiss?.(),this._cleanupListeners?.(),document.querySelectorAll("[data-clay-modal]").forEach(s=>{R.get(s)?.(),s.remove()}),this.isShowing=!1,document.body.style.overflow=""),this._dismiss=M;let C=b===void 0?j():b,c=z({zIndex:g,closable:!!h,titled:!!a,...m?{width:m}:{},theme:C}),p=c.root,D=c.overlay,N=c.panel,O=c.body,A=c.footer,U=c.close,H={theme:C,parts:["dialog.button"],labelParts:["dialog.buttonLabel"]},y=q("",H),w=q("",{variant:"primary",...H});w.type="submit",A.append(y,w);let S=(s,d,P=!1)=>{d instanceof Node?s.append(d):P?s.innerHTML=d:s.textContent=d};S(O,r,!0),S(w.firstChild,u),S(y.firstChild,l),a&&S(c.heading,a),a&&N.setAttribute("aria-label",c.heading.textContent.trim()),k(O,!(r===""||r==null),"block"),(r===""||r==null)&&a&&Y(A,"border-top","0"),document.body.prepend(p);let B=!1;function I(s){B=D.contains(s.target)&&!N.contains(s.target)}function _(s){(y.contains(s.target)||U?.contains(s.target)||T&&B&&!N.contains(s.target)&&D.contains(s.target))&&L.close(),B=!1}function K(s){if(p.contains(s.target)){s.preventDefault();let d=!0;for(let P of o)try{if(P()===!1){d=!1;break}}catch{d=!1;break}d&&(v=!0,L.close())}}document.addEventListener("mousedown",I),document.addEventListener("click",_),document.addEventListener("submit",K),this._cleanupListeners=()=>{document.removeEventListener("mousedown",I),document.removeEventListener("click",_),document.removeEventListener("submit",K)};function V(){k(A,!!(u||l),"flex"),k(w,!!u,"inline-flex"),k(y,!!l,"inline-flex")}if(V(),L.show(p,{disableScroll:E,disableFocus:!0,onClose:s=>{M(),p.remove(),r="",u="",l="",g="100",h="",a="",m="",b=void 0,T=!0,E=!0,i=!1,this.isShowing=!1,document.removeEventListener("mousedown",I),document.removeEventListener("click",_),document.removeEventListener("submit",K),this._cleanupListeners=null,this._dismiss=null}}),this.isShowing=!0,F.forEach(s=>s()),!i){let s=O.querySelector(":is(input,textarea,button):not([hidden])")||[w,y].find(d=>!d.hidden);s?.focus(),s?.setSelectionRange?.(-1,-1)}},close(){L.close()},get html(){return r},set html(o){r=o},get closeHtml(){return h},set closeHtml(o){h=o},get title(){return a},set title(o){a=o},get width(){return m},set width(o){m=o},get[$](){return b},set[$](o){b=o},get yes(){return u},set yes(o){u=o},get no(){return l},set no(o){l=o},get zIndex(){return g},set zIndex(o){g=o},get disableFocus(){return i},set disableFocus(o){i=o},get disableScroll(){return E},set disableScroll(o){E=o},get onYes(){return o=>{e.push(o)}},set onYes(o){e=[o]},get onNo(){return o=>{t.push(o)}},set onNo(o){t=[o]},get onOpen(){return o=>{n.push(o)}},set onOpen(o){n=[o]}}})(),ee=G;export{$ as a,ee as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as F,c as M}from"./c-
|
|
1
|
+
import{b as F,c as M}from"./c-T7LOTEWO.js";import{C as N,d as $}from"./c-3Y234AUB.js";import{A,b as X,c as Y,d as w,x as U}from"./c-OH2FPYSY.js";import{b as P}from"./c-QY7F6EN6.js";import"./c-RETTCOWO.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var y=5;function v(n){let u=0;for(let i=0;i<n.childCount;i++){let s=n.child(i);if(s.type===w.nodes.heading&&s.attrs.level===1&&s.attrs.parent==null)return{index:i,at:u,node:s};u+=s.nodeSize}return null}var O=`
|
|
2
2
|
:host{font:inherit !important;color:inherit !important}
|
|
3
3
|
.blockeditor-cover-panel{display:flex;align-items:center;gap:8px;margin:8px 0;padding:6px 10px;border:1px solid var(--blockeditor-pop-line);border-radius:8px;background:var(--blockeditor-pop-bg);color:var(--blockeditor-pop-ink);box-shadow:var(--blockeditor-pop-shadow);font-size:.88em}
|
|
4
4
|
.blockeditor-cover-msg{max-width:34ch}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Et,b as Jn,c as Ro,f as Yo}from"./c-4AE2A2LK.js";import{a as $o}from"./c-WNOLMHI2.js";import{a as Bn,b as Dn,e as zn,f as it,g as Mt}from"./c-LS7IVQVW.js";import{a as Po}from"./c-NEQRFC4O.js";import{a as Ct,b as It,c as At,d as ze,e as Ye,f as Kn,g as Tt,h as Hn,i as qn,j as Pt,l as Rt}from"./c-NICICT4P.js";import{b as Co,c as Io}from"./c-OBMZASYQ.js";import"./c-IW6GGOU2.js";import"./c-HAWFNBYG.js";import{a as Re,b as _n,p as Nn,q as Fn,u as Ao,v as To}from"./c-JWW6BHWD.js";import{A as An,B as Be,C as ot,D as Tn,E as Pn,F as De,G as Rn,H as Pe,I as rt,J as Yn,K as St,L as $n,M as st,N as jn,O as ue,a as Le,b as kt,c as wn,d as xn,f as Sn,j as On,m as Eo,p as Mn,q as En,r as Cn,s as In,t as vt,v as wt,x as xt,z as Oe}from"./c-GO635CRU.js";import{a as me,b as hn,d as Me,e as _e,g as xe,h as Ne,i as ye,j as Ee,k as gn,l as Fe,m as nt,n as be,o as bn,p as kn,q as Se,r as Ce,u as yn,v as vn,w as yt}from"./c-V2V5FKXX.js";import"./c-DT7E76Z2.js";import"./c-C6YZNU6E.js";import"./c-7K4SCQB7.js";import{f as tn,g as nn,i as Qe,j as Ze,k as dt,n as pt,o as et,p as on,s as mt,t as rn,u as Ae,v as de,w as Te,x as ht,y as sn}from"./c-WMRJKQ2V.js";import{g as Ln,p as Ot}from"./c-AI3H6ETU.js";import{E as gt,H as bt,I as dn,d as fe,fa as je,g as an,i as fn,ia as pn,ja as mn,na as tt,w as un}from"./c-OH2FPYSY.js";import{b as Vt}from"./c-QY7F6EN6.js";import"./c-FSQXFG5T.js";import{b as pe,c as ln,e as cn}from"./c-RETTCOWO.js";import{a as Wt,b as Ut,d as ft}from"./c-WCG6AKA7.js";import{a as Zt}from"./c-TCCA5BZN.js";import"./c-3LDGIBMN.js";import{c as en}from"./c-57XDY6HC.js";import"./c-MV7TEUTD.js";import{a as Qt,b as ut}from"./c-QTTJYJMA.js";import"./c-QCDVDZIR.js";import{e as Gt,f as Xt}from"./c-VMXCX52Q.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-P73XPAOA.js";import"./c-ZPI7M5U5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-MZCOGNZL.js";import"./c-MFB74XVN.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-PNZIJFG7.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var Yt=new Set(["paragraph","heading","list_item","callout","quote","code_block","toggle"]),Je=(e,o)=>je(e)===je(o);function $t(e,o){let n=o.createElement("article");return n.setAttribute("data-blockeditor",""),n.innerHTML=mn([{id:e.id,t:"paragraph",c:e.c??"",...e.m?{m:e.m}:{}}],{clean:pn(o)}),n}function jo(e,o){let n=new Map(e.map((f,u)=>[f.id,u])),r=new Set(o.map(f=>f.id)),t=new Map,s=0;return o.map(f=>{let u=n.get(f.id);if(u!==void 0)return s=u+1,f;let p={c:f.c??"",m:f.m??null};for(let b=s;b<e.length;b++){let C=e[b];if(!(r.has(C.id)||C.t!==f.t||!Je({c:C.c??"",m:C.m??null},p)))return r.add(C.id),s=b+1,t.set(f.id,C.id),{...f,id:C.id}}return f}).map(f=>t.has(f.parent)?{...f,parent:t.get(f.parent)}:f)}function jt(e,o,n,{doc:r,merge3:t,mergeJson:s}){let a=[],f=jo(e,n),u=new Map(e.map(c=>[c.id,c])),p=new Map(o.map(c=>[c.id,c])),b=new Map(f.map(c=>[c.id,c])),C=o.map(c=>({...c})),M=f.map(c=>({...c})),h=new Map(C.map(c=>[c.id,c])),w=new Map(M.map(c=>[c.id,c]));for(let[c,E]of u){let i=p.get(c),g=b.get(c);if(!i||!g||!Yt.has(E.t)||!Yt.has(i.t)||!Yt.has(g.t))continue;let A={c:E.c??"",m:E.m??null},z={c:i.c??"",m:i.m??null},W={c:g.c??"",m:g.m??null};if(Je(z,A)||Je(W,A)||Je(z,W))continue;if(E.t==="code_block"){for(let P of[h.get(c),w.get(c)])P.c=g.c??"",g.m?P.m=g.m:delete P.m;a.push({id:c,kind:"text",local:i.c??"",remote:g.c??""});continue}let T=t($t(E,r),$t(i,r),$t(g,r));for(let P of T.conflicts)a.push({id:c,kind:"text",local:P.local?.textContent??null,remote:P.remote?.textContent??null});let[U]=tt(T.root,{seed:"",known:new Map});for(let P of[h.get(c),w.get(c)])P.c=U.c,U.m?P.m=U.m:delete P.m}let y=o.map(c=>c.id);for(let[c,E]of u){let i=h.get(c);if(!i||b.has(c)||Je(p.get(c),E))continue;let g=y.indexOf(c)-1;for(;g>=0&&!w.has(y[g]);)g--;let A=g<0?0:M.findIndex(z=>z.id===y[g])+1;M.splice(A,0,{...i}),w.set(c,M[A]),a.push({id:c,kind:"kept-edit"})}let N=s(e,C,M,{onConflict:c=>a.push({kind:"field",path:c.path,local:c.local,remote:c.remote,resolved:c.resolved})}),B=new Set(N.map(c=>c.id)),v=c=>(p.get(c)??u.get(c)??b.get(c))?.parent??null,L=N.map(c=>{let E=c.parent??null;for(;E&&!B.has(E);)E=v(E);return E===(c.parent??null)?c:{...c,parent:E}}),Y=new Map(L.map(c=>[c.id,c.parent??null])),$=c=>{let E=new Set([c]);for(let i=Y.get(c);i;i=Y.get(i)){if(E.has(i))return!0;E.add(i)}return!1};for(let c of L)if($(c.id)){for(let E of[p.get(c.id)?.parent,u.get(c.id)?.parent,null])if(Y.set(c.id,E&&B.has(E)?E:null),!$(c.id))break}return{items:L.map(c=>(c.parent??null)===Y.get(c.id)?c:{...c,parent:Y.get(c.id)}),conflicts:a}}var _o=e=>{try{return Zt(e)}catch{return null}},$e={ok:!0,outcome:"unchanged"},Ke={ok:!1,outcome:"disposed",reason:"adoption-disposed"},He={ok:!1,outcome:"refused",reason:"adoption-refused"},No={ok:!1,outcome:"refused",reason:"adoption-timeout"},Fo={ok:!1,outcome:"error",reason:"adoption-error"},Lo={ok:!0,outcome:"writer-adopts"},Vn=e=>({ok:!0,outcome:"adopted",counts:e}),Wn=1e4;function Bo(e){let o=e.querySelector(Et);return o?{article:o.cloneNode(!0),tags:Jn(e).map(n=>_o(n.textContent))}:null}function Un(e){return new Promise(o=>{if(!e.composing)return o();e.dom.addEventListener("compositionend",()=>setTimeout(()=>o(Un(e)),0),{once:!0})})}function Do({view:e,source:o=null,ready:n=Promise.resolve(),isAdopter:r=()=>!0,idle:t=()=>Un(e),requestCheckpoint:s=()=>{},notice:a=()=>{},snapshot:f=()=>null,mergeTagless:u=!1,seeded:p=!1,writerReady:b=()=>Promise.resolve(),adopted:C=()=>{},hold:M=Gt,release:h=Xt,holdMs:w=Wn,doc:y=document}){let N=o?o.article.innerHTML:null,B=o?o.article:null,v=new Map,L=P=>{let I=P.getAttribute("data-rev");if(!I)return;let K=v.get(I)??[];v.delete(I),v.set(I,K),K.push(P),K.length>10&&K.shift(),v.size>20&&v.delete(v.keys().next().value)};B&&L(B);let Y=Promise.resolve(),$=!1,x,c=new Promise(P=>x=P);async function E(){let P,I=new Promise(K=>{P=setTimeout(()=>K("timeout"),w)});try{return await Promise.race([Promise.resolve(n).then(()=>t()).then(()=>"ready"),c.then(()=>"disposed"),I])}finally{clearTimeout(P)}}function i(P,I,K,j){let{HyperMorph:Q}=Qt(),le=jt(K,I,j,{doc:y,merge3:Q.merge3,mergeJson:Q.mergeJson}),ee=le.conflicts.filter(D=>D.kind==="text"||D.kind==="field"),m=ee.length?f():null,l=Dn(P,le.items,I),k=l&&zn(e.state,l);if(!k)return null;e.dispatch(k),e.dispatch(cn.closeHistory(e.state.tr));let F={edited:l.edited.size,created:l.created.size,deleted:l.deleted.length,moved:l.reordered},{displaced:R}=k.getMeta(Bn);return Object.keys(R).length&&(F.displaced=R),ee.length&&(F.conflicts=ee),m&&(F.copy=m),F}async function g(P){if(u&&!P.tags.length)return A(P);let I=Mt(P.article,P.tags);if(I.kind==="unbased"&&console.warn("page: the article and its data changed together; kept the data"),I.kind!=="adopt")return $e;if(!r())return Lo;M();try{if(await ut(),$)return Ke;if(!r())return He;let K=await E();if(K==="timeout"&&console.warn("page: gave up waiting for the editor; the hand edit was not adopted"),K==="disposed"||$)return Ke;if(K!=="ready")return No;if(!r())return He;let j=gt(e.state.doc),Q=i(j,it(j,y),I.baseItems,I.parsed);return Q?(C(I.A),Vn(Q)):$e}finally{h()}}async function A(P){let I=P.article.getAttribute("data-rev"),K=I&&v.get(I)||[],j=K.at(-1)??B;if(K.slice(0,-1).some(Q=>Q.innerHTML===P.article.innerHTML)||(L(P.article),B=P.article,!j)||j.outerHTML===P.article.outerHTML)return $e;M();try{if(await ut(),$)return Ke;if(!r())return He;if(await b(),$)return Ke;if(!r())return He;if(await E()==="disposed"||$)return Ke;if(!r())return He;let le=gt(e.state.doc),ee=it(le,y),m=new Map(ee.map(F=>[F.id,F])),l=F=>tt(F,{seed:F.getAttribute("data-rev")??"",known:m}),k=i(le,ee,l(j),l(P.article));return k?Vn(k):$e}finally{h()}}async function z(P){try{return await g(P)}catch(I){return console.error("page: adoption failed",I),Fo}}let W=null;function T(P,I=!1){return Y=Y.then(()=>z(P)).then(K=>(I&&(W=K),!K.ok||K.outcome!=="adopted"||(s(),a(K.counts),y.dispatchEvent(new CustomEvent("clay:blockeditor-adopted",{detail:K.counts}))),K)),Y}function U(P){let I=P.detail?.html;if($||typeof I!="string")return;let K=Bo(new DOMParser().parseFromString(I,"text/html"));!K||K.article.innerHTML===N||(N=K.article.innerHTML,T(K))}return y.addEventListener("clay:sync-applied",U),o&&!p&&T(o,!0),{idle:async()=>(await Y,W),saved(P){if(!u||typeof P!="string")return;let I=new DOMParser().parseFromString(P,"text/html").querySelector(Et);I&&(L(I),B=I)},dispose(){$=!0,x(),y.removeEventListener("clay:sync-applied",U)}}}var Gn='["text-delete",',Xn=(e,o)=>o instanceof rn&&o._item&&o._item.parent===e.attrs&&typeof o._item.parentSub=="string"?o._item.parentSub:null,Qn=e=>e==="t"||e==="parent",_t=e=>e.content instanceof de&&e.content.embed.b!==void 0,zo=e=>e.content instanceof ht||e.content instanceof Te||e.content instanceof de&&e.content.embed.b===void 0,eo=e=>{let o=new Map;for(let n of e.stops)(o.get(n.client)??o.set(n.client,[]).get(n.client)).push(n);return o},to=(e,o)=>{let n=o.get(e.id.client);if(!n)return!1;let r=e.id.clock,t=r+e.length;return n.some(s=>s.clock<t&&r<s.clock+s.len)},Jo=(e,o)=>{for(let n=e.left;n;n=n.left){if(n.deleted){if(to(n,o))return null;continue}if(_t(n))return n}return null};function no(e,o,n){let r=eo(n),t=new Set,s=new Set,a=o.changed.get(e.tableFields)??new Set;for(let[h,w]of o.changed){if(h===e.flow)continue;if(h===e.attrs){if(!o.local)return null;for(let N of w){let B=e.attrs.get(N);if(!(B instanceof Ae)||B._item.left||B._item.id.clock<(o.beforeState.get(B._item.id.client)??0))return null;s.add(N)}if(s.size>1)return null;continue}if(h===e.tableFields){for(let N of w){let B=e.tableFields.has(N)?En(N,e.tableFields.get(N)):null;if(B===null)return null;t.add(B)}continue}let y=Xn(e,h);if(y!==null){for(let N of w)if(Qn(N))return null;t.add(y);continue}if(h!==e.gone)return null;for(let N of w)if(typeof N!="string"||!N.startsWith(Gn))return null}let f=e.ydoc.store,u=null,p=null,b=!1,C=h=>{if(!(h instanceof sn))return!1;if(h.parent===e.gone)return typeof h.parentSub=="string"&&h.parentSub.startsWith(Gn);if(h.parent===e.tableFields)return a.has(h.parentSub);if(h.parent===e.attrs)return s.has(h.parentSub);if(h.parent!==e.flow){let y=Xn(e,h.parent);return y!==null&&(s.has(y)||t.has(y)&&!Qn(h.parentSub))}if(_t(h)){if(h.deleted||!s.has(h.content.embed.b))return!1;p=h}else if(!zo(h))return!1;let w=Jo(h,r);return!w||u&&w!==u?!1:(u=w,h.content instanceof Te&&(b=!0),!0)};for(let[h,w]of o.afterState)for(let y=o.beforeState.get(h)??0;y<w;){let N=et(f,{client:h,clock:y});if(!C(N))return null;y=N.id.clock+N.length}let M=!1;for(let[h,w]of o.deleteSet.clients)for(let{clock:y,len:N}of w)for(let B=y;B<y+N;){let v=et(f,{client:h,clock:B});if(!C(v))return null;M=!0,B=v.id.clock+v.length}return s.size&&!p?null:u||t.size?{marker:u,split:p,deleted:M,formats:b,fields:t,remote:!o.local}:null}var Ko=e=>{for(let o in e)return{...e};return null};function oo(e,o,n,r=null){let t=r?.formats??!0,s=r?.split??null,a=o.visible,f=-1,u=0;for(let i=0;i<a.length;i++){let g=a[i];if(g.brk&&g.brk.client===n.id.client&&g.brk.clock===n.id.clock){f=i;break}u+=g.len}if(f<0)return null;let p=a[f];if(p.implicit||p.atom||p.opaque||p.recovered||p.hide)return null;let b=p.runs.findIndex(i=>i.hole!==void 0);if(b>=0&&t||p.items&&o.copies.has(p.baseId))return null;let C=eo(o),M={...p.fmtIn??{}},h=null,w={...p,runs:[],len:1};p.items&&(w.items=[]);let y=w,N=!1,B=Ye(o.holes,u),v=B+1;for(let i=n.right;i;i=i.right){if(i.deleted){if(to(i,C))return null;continue}if(_t(i)&&(i!==s||y!==w)){N=!0;break}let g=v;i.countable&&(v+=i.length);let A=i.content;if(i===s){let z=A.embed.b,W=e.attrs.get(z)?.get("t")||"paragraph";if(!Object.hasOwn(fe.nodes,W)||!fe.nodes[W].isTextblock)return null;let T=Ko(M);w.fmtOut=T,y={kind:"b",id:z,baseId:z,brk:{client:i.id.client,clock:i.id.clock},implicit:!1,runs:[],len:1,atom:!1,items:null,fmtIn:T,fmtOut:null,t:W,opaque:!1},h=null;continue}if(A instanceof Te){A.value===null?delete M[A.key]:M[A.key]=A.value,h=null;continue}if(A instanceof de){y.runs.push({br:!0}),y.items&&y.items.push({at:g,id:Ee(i.id),client:i.id.client,clock:i.id.clock,length:i.length,kind:"br",text:null,blockId:null,raw:{...M}}),y.len+=1;continue}if(A instanceof ht){if(!h){let z=vn(M,y.t);h={marks:z,mk:yn(z)}}y.runs.push({text:A.str,marks:h.marks,mk:h.mk}),y.items&&y.items.push({at:g,id:Ee(i.id),client:i.id.client,clock:i.id.clock,length:i.length,kind:"text",text:A.str,blockId:null,raw:{...M}}),y.len+=A.str.length}else if(i.countable)return null}let L=p.len;if(b<0){if(!ye(M,p.fmtOut??{}))return null}else{if(!N||y.t!==p.t)return null;L=1;for(let i=0;i<b;i++)L+=p.runs[i].br?1:p.runs[i].text.length}let Y=y===w?[w]:[w,y],$=Y.reduce((i,g)=>i+g.len,0)-L,x=B+L,c=i=>i.at>=x?{...i,at:i.at+$}:i;y.fmtOut=p.fmtOut,b>=0&&(y.runs=y.runs.concat(p.runs.slice(b)),y.len+=p.len-L,y.items&&(y.items=y.items.concat(p.items.filter(i=>i.at>=x).map(c))));let E={...o,visible:a.slice(),tokens:o.tokens+$};if(E.visible.splice(f,1,...Y),$){let i=u+L;E.holes=o.holes.map(g=>g.at>=i?{at:g.at+$,len:g.len}:g),E.hidden=o.hidden.map(g=>g.at>=x?{...g,at:g.at+$,items:g.items.map(c)}:g);for(let g=f+Y.length;g<E.visible.length;g+=1){let A=E.visible[g];A.items?.length&&(E.visible[g]={...A,items:A.items.map(c)})}}return E}var Ho=e=>e.br?`
|
|
1
|
+
import{a as Ct,b as It,c as At,d as ze,e as Ye,f as Kn,g as Tt,h as Hn,i as qn,j as Pt,l as Rt}from"./c-NICICT4P.js";import{a as Et,b as Jn,c as Ro,f as Yo}from"./c-GNFDX6SU.js";import{a as $o}from"./c-WNOLMHI2.js";import{a as Bn,b as Dn,e as zn,f as it,g as Mt}from"./c-LS7IVQVW.js";import{a as Po}from"./c-NEQRFC4O.js";import{b as Co,c as Io}from"./c-OBMZASYQ.js";import"./c-IW6GGOU2.js";import"./c-HAWFNBYG.js";import{a as Re,b as _n,p as Nn,q as Fn,u as Ao,v as To}from"./c-LUBZU4AZ.js";import{A as An,B as Be,C as ot,D as Tn,E as Pn,F as De,G as Rn,H as Pe,I as rt,J as Yn,K as St,L as $n,M as st,N as jn,O as ue,a as Le,b as kt,c as wn,d as xn,f as Sn,j as On,m as Eo,p as Mn,q as En,r as Cn,s as In,t as vt,v as wt,x as xt,z as Oe}from"./c-GO635CRU.js";import{a as me,b as hn,d as Me,e as _e,g as xe,h as Ne,i as ye,j as Ee,k as gn,l as Fe,m as nt,n as be,o as bn,p as kn,q as Se,r as Ce,u as yn,v as vn,w as yt}from"./c-V2V5FKXX.js";import"./c-T7LOTEWO.js";import"./c-A3OKSYRI.js";import"./c-7K4SCQB7.js";import{f as tn,g as nn,i as Qe,j as Ze,k as dt,n as pt,o as et,p as on,s as mt,t as rn,u as Ae,v as de,w as Te,x as ht,y as sn}from"./c-WMRJKQ2V.js";import{g as Ln,p as Ot}from"./c-3Y234AUB.js";import{E as gt,H as bt,I as dn,d as fe,fa as je,g as an,i as fn,ia as pn,ja as mn,na as tt,w as un}from"./c-OH2FPYSY.js";import{b as Vt}from"./c-QY7F6EN6.js";import"./c-FSQXFG5T.js";import{b as pe,c as ln,e as cn}from"./c-RETTCOWO.js";import{a as Wt,b as Ut,d as ft}from"./c-JC4RZW4E.js";import{a as Zt}from"./c-TCCA5BZN.js";import"./c-3LDGIBMN.js";import{c as en}from"./c-57XDY6HC.js";import"./c-OZVK3TFI.js";import{a as Qt,b as ut}from"./c-FILLTJA7.js";import"./c-QCDVDZIR.js";import{e as Gt,f as Xt}from"./c-FC5RUFPR.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-P73XPAOA.js";import"./c-ZPI7M5U5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-MZCOGNZL.js";import"./c-EHAR4RJJ.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-KU3PX7LL.js";import"./c-EQ5NBOGA.js";import"./c-IJUK2GPW.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-UW6MMZ4V.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var Yt=new Set(["paragraph","heading","list_item","callout","quote","code_block","toggle"]),Je=(e,o)=>je(e)===je(o);function $t(e,o){let n=o.createElement("article");return n.setAttribute("data-blockeditor",""),n.innerHTML=mn([{id:e.id,t:"paragraph",c:e.c??"",...e.m?{m:e.m}:{}}],{clean:pn(o)}),n}function jo(e,o){let n=new Map(e.map((f,u)=>[f.id,u])),r=new Set(o.map(f=>f.id)),t=new Map,s=0;return o.map(f=>{let u=n.get(f.id);if(u!==void 0)return s=u+1,f;let p={c:f.c??"",m:f.m??null};for(let b=s;b<e.length;b++){let C=e[b];if(!(r.has(C.id)||C.t!==f.t||!Je({c:C.c??"",m:C.m??null},p)))return r.add(C.id),s=b+1,t.set(f.id,C.id),{...f,id:C.id}}return f}).map(f=>t.has(f.parent)?{...f,parent:t.get(f.parent)}:f)}function jt(e,o,n,{doc:r,merge3:t,mergeJson:s}){let a=[],f=jo(e,n),u=new Map(e.map(c=>[c.id,c])),p=new Map(o.map(c=>[c.id,c])),b=new Map(f.map(c=>[c.id,c])),C=o.map(c=>({...c})),M=f.map(c=>({...c})),h=new Map(C.map(c=>[c.id,c])),w=new Map(M.map(c=>[c.id,c]));for(let[c,E]of u){let i=p.get(c),g=b.get(c);if(!i||!g||!Yt.has(E.t)||!Yt.has(i.t)||!Yt.has(g.t))continue;let A={c:E.c??"",m:E.m??null},z={c:i.c??"",m:i.m??null},W={c:g.c??"",m:g.m??null};if(Je(z,A)||Je(W,A)||Je(z,W))continue;if(E.t==="code_block"){for(let P of[h.get(c),w.get(c)])P.c=g.c??"",g.m?P.m=g.m:delete P.m;a.push({id:c,kind:"text",local:i.c??"",remote:g.c??""});continue}let T=t($t(E,r),$t(i,r),$t(g,r));for(let P of T.conflicts)a.push({id:c,kind:"text",local:P.local?.textContent??null,remote:P.remote?.textContent??null});let[U]=tt(T.root,{seed:"",known:new Map});for(let P of[h.get(c),w.get(c)])P.c=U.c,U.m?P.m=U.m:delete P.m}let y=o.map(c=>c.id);for(let[c,E]of u){let i=h.get(c);if(!i||b.has(c)||Je(p.get(c),E))continue;let g=y.indexOf(c)-1;for(;g>=0&&!w.has(y[g]);)g--;let A=g<0?0:M.findIndex(z=>z.id===y[g])+1;M.splice(A,0,{...i}),w.set(c,M[A]),a.push({id:c,kind:"kept-edit"})}let N=s(e,C,M,{onConflict:c=>a.push({kind:"field",path:c.path,local:c.local,remote:c.remote,resolved:c.resolved})}),B=new Set(N.map(c=>c.id)),v=c=>(p.get(c)??u.get(c)??b.get(c))?.parent??null,L=N.map(c=>{let E=c.parent??null;for(;E&&!B.has(E);)E=v(E);return E===(c.parent??null)?c:{...c,parent:E}}),Y=new Map(L.map(c=>[c.id,c.parent??null])),$=c=>{let E=new Set([c]);for(let i=Y.get(c);i;i=Y.get(i)){if(E.has(i))return!0;E.add(i)}return!1};for(let c of L)if($(c.id)){for(let E of[p.get(c.id)?.parent,u.get(c.id)?.parent,null])if(Y.set(c.id,E&&B.has(E)?E:null),!$(c.id))break}return{items:L.map(c=>(c.parent??null)===Y.get(c.id)?c:{...c,parent:Y.get(c.id)}),conflicts:a}}var _o=e=>{try{return Zt(e)}catch{return null}},$e={ok:!0,outcome:"unchanged"},Ke={ok:!1,outcome:"disposed",reason:"adoption-disposed"},He={ok:!1,outcome:"refused",reason:"adoption-refused"},No={ok:!1,outcome:"refused",reason:"adoption-timeout"},Fo={ok:!1,outcome:"error",reason:"adoption-error"},Lo={ok:!0,outcome:"writer-adopts"},Vn=e=>({ok:!0,outcome:"adopted",counts:e}),Wn=1e4;function Bo(e){let o=e.querySelector(Et);return o?{article:o.cloneNode(!0),tags:Jn(e).map(n=>_o(n.textContent))}:null}function Un(e){return new Promise(o=>{if(!e.composing)return o();e.dom.addEventListener("compositionend",()=>setTimeout(()=>o(Un(e)),0),{once:!0})})}function Do({view:e,source:o=null,ready:n=Promise.resolve(),isAdopter:r=()=>!0,idle:t=()=>Un(e),requestCheckpoint:s=()=>{},notice:a=()=>{},snapshot:f=()=>null,mergeTagless:u=!1,seeded:p=!1,writerReady:b=()=>Promise.resolve(),adopted:C=()=>{},hold:M=Gt,release:h=Xt,holdMs:w=Wn,doc:y=document}){let N=o?o.article.innerHTML:null,B=o?o.article:null,v=new Map,L=P=>{let I=P.getAttribute("data-rev");if(!I)return;let K=v.get(I)??[];v.delete(I),v.set(I,K),K.push(P),K.length>10&&K.shift(),v.size>20&&v.delete(v.keys().next().value)};B&&L(B);let Y=Promise.resolve(),$=!1,x,c=new Promise(P=>x=P);async function E(){let P,I=new Promise(K=>{P=setTimeout(()=>K("timeout"),w)});try{return await Promise.race([Promise.resolve(n).then(()=>t()).then(()=>"ready"),c.then(()=>"disposed"),I])}finally{clearTimeout(P)}}function i(P,I,K,j){let{HyperMorph:Q}=Qt(),le=jt(K,I,j,{doc:y,merge3:Q.merge3,mergeJson:Q.mergeJson}),ee=le.conflicts.filter(D=>D.kind==="text"||D.kind==="field"),m=ee.length?f():null,l=Dn(P,le.items,I),k=l&&zn(e.state,l);if(!k)return null;e.dispatch(k),e.dispatch(cn.closeHistory(e.state.tr));let F={edited:l.edited.size,created:l.created.size,deleted:l.deleted.length,moved:l.reordered},{displaced:R}=k.getMeta(Bn);return Object.keys(R).length&&(F.displaced=R),ee.length&&(F.conflicts=ee),m&&(F.copy=m),F}async function g(P){if(u&&!P.tags.length)return A(P);let I=Mt(P.article,P.tags);if(I.kind==="unbased"&&console.warn("page: the article and its data changed together; kept the data"),I.kind!=="adopt")return $e;if(!r())return Lo;M();try{if(await ut(),$)return Ke;if(!r())return He;let K=await E();if(K==="timeout"&&console.warn("page: gave up waiting for the editor; the hand edit was not adopted"),K==="disposed"||$)return Ke;if(K!=="ready")return No;if(!r())return He;let j=gt(e.state.doc),Q=i(j,it(j,y),I.baseItems,I.parsed);return Q?(C(I.A),Vn(Q)):$e}finally{h()}}async function A(P){let I=P.article.getAttribute("data-rev"),K=I&&v.get(I)||[],j=K.at(-1)??B;if(K.slice(0,-1).some(Q=>Q.innerHTML===P.article.innerHTML)||(L(P.article),B=P.article,!j)||j.outerHTML===P.article.outerHTML)return $e;M();try{if(await ut(),$)return Ke;if(!r())return He;if(await b(),$)return Ke;if(!r())return He;if(await E()==="disposed"||$)return Ke;if(!r())return He;let le=gt(e.state.doc),ee=it(le,y),m=new Map(ee.map(F=>[F.id,F])),l=F=>tt(F,{seed:F.getAttribute("data-rev")??"",known:m}),k=i(le,ee,l(j),l(P.article));return k?Vn(k):$e}finally{h()}}async function z(P){try{return await g(P)}catch(I){return console.error("page: adoption failed",I),Fo}}let W=null;function T(P,I=!1){return Y=Y.then(()=>z(P)).then(K=>(I&&(W=K),!K.ok||K.outcome!=="adopted"||(s(),a(K.counts),y.dispatchEvent(new CustomEvent("clay:blockeditor-adopted",{detail:K.counts}))),K)),Y}function U(P){let I=P.detail?.html;if($||typeof I!="string")return;let K=Bo(new DOMParser().parseFromString(I,"text/html"));!K||K.article.innerHTML===N||(N=K.article.innerHTML,T(K))}return y.addEventListener("clay:sync-applied",U),o&&!p&&T(o,!0),{idle:async()=>(await Y,W),saved(P){if(!u||typeof P!="string")return;let I=new DOMParser().parseFromString(P,"text/html").querySelector(Et);I&&(L(I),B=I)},dispose(){$=!0,x(),y.removeEventListener("clay:sync-applied",U)}}}var Gn='["text-delete",',Xn=(e,o)=>o instanceof rn&&o._item&&o._item.parent===e.attrs&&typeof o._item.parentSub=="string"?o._item.parentSub:null,Qn=e=>e==="t"||e==="parent",_t=e=>e.content instanceof de&&e.content.embed.b!==void 0,zo=e=>e.content instanceof ht||e.content instanceof Te||e.content instanceof de&&e.content.embed.b===void 0,eo=e=>{let o=new Map;for(let n of e.stops)(o.get(n.client)??o.set(n.client,[]).get(n.client)).push(n);return o},to=(e,o)=>{let n=o.get(e.id.client);if(!n)return!1;let r=e.id.clock,t=r+e.length;return n.some(s=>s.clock<t&&r<s.clock+s.len)},Jo=(e,o)=>{for(let n=e.left;n;n=n.left){if(n.deleted){if(to(n,o))return null;continue}if(_t(n))return n}return null};function no(e,o,n){let r=eo(n),t=new Set,s=new Set,a=o.changed.get(e.tableFields)??new Set;for(let[h,w]of o.changed){if(h===e.flow)continue;if(h===e.attrs){if(!o.local)return null;for(let N of w){let B=e.attrs.get(N);if(!(B instanceof Ae)||B._item.left||B._item.id.clock<(o.beforeState.get(B._item.id.client)??0))return null;s.add(N)}if(s.size>1)return null;continue}if(h===e.tableFields){for(let N of w){let B=e.tableFields.has(N)?En(N,e.tableFields.get(N)):null;if(B===null)return null;t.add(B)}continue}let y=Xn(e,h);if(y!==null){for(let N of w)if(Qn(N))return null;t.add(y);continue}if(h!==e.gone)return null;for(let N of w)if(typeof N!="string"||!N.startsWith(Gn))return null}let f=e.ydoc.store,u=null,p=null,b=!1,C=h=>{if(!(h instanceof sn))return!1;if(h.parent===e.gone)return typeof h.parentSub=="string"&&h.parentSub.startsWith(Gn);if(h.parent===e.tableFields)return a.has(h.parentSub);if(h.parent===e.attrs)return s.has(h.parentSub);if(h.parent!==e.flow){let y=Xn(e,h.parent);return y!==null&&(s.has(y)||t.has(y)&&!Qn(h.parentSub))}if(_t(h)){if(h.deleted||!s.has(h.content.embed.b))return!1;p=h}else if(!zo(h))return!1;let w=Jo(h,r);return!w||u&&w!==u?!1:(u=w,h.content instanceof Te&&(b=!0),!0)};for(let[h,w]of o.afterState)for(let y=o.beforeState.get(h)??0;y<w;){let N=et(f,{client:h,clock:y});if(!C(N))return null;y=N.id.clock+N.length}let M=!1;for(let[h,w]of o.deleteSet.clients)for(let{clock:y,len:N}of w)for(let B=y;B<y+N;){let v=et(f,{client:h,clock:B});if(!C(v))return null;M=!0,B=v.id.clock+v.length}return s.size&&!p?null:u||t.size?{marker:u,split:p,deleted:M,formats:b,fields:t,remote:!o.local}:null}var Ko=e=>{for(let o in e)return{...e};return null};function oo(e,o,n,r=null){let t=r?.formats??!0,s=r?.split??null,a=o.visible,f=-1,u=0;for(let i=0;i<a.length;i++){let g=a[i];if(g.brk&&g.brk.client===n.id.client&&g.brk.clock===n.id.clock){f=i;break}u+=g.len}if(f<0)return null;let p=a[f];if(p.implicit||p.atom||p.opaque||p.recovered||p.hide)return null;let b=p.runs.findIndex(i=>i.hole!==void 0);if(b>=0&&t||p.items&&o.copies.has(p.baseId))return null;let C=eo(o),M={...p.fmtIn??{}},h=null,w={...p,runs:[],len:1};p.items&&(w.items=[]);let y=w,N=!1,B=Ye(o.holes,u),v=B+1;for(let i=n.right;i;i=i.right){if(i.deleted){if(to(i,C))return null;continue}if(_t(i)&&(i!==s||y!==w)){N=!0;break}let g=v;i.countable&&(v+=i.length);let A=i.content;if(i===s){let z=A.embed.b,W=e.attrs.get(z)?.get("t")||"paragraph";if(!Object.hasOwn(fe.nodes,W)||!fe.nodes[W].isTextblock)return null;let T=Ko(M);w.fmtOut=T,y={kind:"b",id:z,baseId:z,brk:{client:i.id.client,clock:i.id.clock},implicit:!1,runs:[],len:1,atom:!1,items:null,fmtIn:T,fmtOut:null,t:W,opaque:!1},h=null;continue}if(A instanceof Te){A.value===null?delete M[A.key]:M[A.key]=A.value,h=null;continue}if(A instanceof de){y.runs.push({br:!0}),y.items&&y.items.push({at:g,id:Ee(i.id),client:i.id.client,clock:i.id.clock,length:i.length,kind:"br",text:null,blockId:null,raw:{...M}}),y.len+=1;continue}if(A instanceof ht){if(!h){let z=vn(M,y.t);h={marks:z,mk:yn(z)}}y.runs.push({text:A.str,marks:h.marks,mk:h.mk}),y.items&&y.items.push({at:g,id:Ee(i.id),client:i.id.client,clock:i.id.clock,length:i.length,kind:"text",text:A.str,blockId:null,raw:{...M}}),y.len+=A.str.length}else if(i.countable)return null}let L=p.len;if(b<0){if(!ye(M,p.fmtOut??{}))return null}else{if(!N||y.t!==p.t)return null;L=1;for(let i=0;i<b;i++)L+=p.runs[i].br?1:p.runs[i].text.length}let Y=y===w?[w]:[w,y],$=Y.reduce((i,g)=>i+g.len,0)-L,x=B+L,c=i=>i.at>=x?{...i,at:i.at+$}:i;y.fmtOut=p.fmtOut,b>=0&&(y.runs=y.runs.concat(p.runs.slice(b)),y.len+=p.len-L,y.items&&(y.items=y.items.concat(p.items.filter(i=>i.at>=x).map(c))));let E={...o,visible:a.slice(),tokens:o.tokens+$};if(E.visible.splice(f,1,...Y),$){let i=u+L;E.holes=o.holes.map(g=>g.at>=i?{at:g.at+$,len:g.len}:g),E.hidden=o.hidden.map(g=>g.at>=x?{...g,at:g.at+$,items:g.items.map(c)}:g);for(let g=f+Y.length;g<E.visible.length;g+=1){let A=E.visible[g];A.items?.length&&(E.visible[g]={...A,items:A.items.map(c)})}}return E}var Ho=e=>e.br?`
|
|
2
2
|
`:e.hole!==void 0?{hole:e.hole}:{text:e.text,mk:e.mk},qo=e=>{let o=[];for(let n of e.map(Ho)){let r=o[o.length-1];r&&typeof r=="object"&&typeof n=="object"&&r.text!==void 0&&n.text!==void 0&&r.mk===n.mk?o[o.length-1]={text:r.text+n.text,mk:n.mk}:o.push(n)}return o},Zn=(e,o)=>{let n=et(e.ydoc.store,{client:o.client,clock:o.clock});return{client:n.id.client,clock:n.id.clock,len:n.length}},Ve=(e,o)=>rt({...o,copies:[...o.copies],fences:o.fences.map(n=>Zn(e,n)),stops:o.stops.map(n=>Zn(e,n)),visible:o.visible.map(n=>({...n,runs:qo(n.runs)}))});var ro=e=>e===!0?{}:e,so=(e,o)=>ye(ro(e),ro(o));function co(e,o,n,r){let t=e.attrs.get(o);t||(t=new Ae,e.attrs.set(o,t));let s=fe.nodes[n];if(!s){t.get("t")!==n&&t.set("t",n);for(let[p,b]of Object.entries(r??{}))p==="t"||p==="pos"||ye(t.has(p)?t.get(p):void 0,b)||t.set(p,b);return}let a=n==="table"&&t.get("t")==="table"&&!St(o),f=n==="board"&&!St(o),u=a?Cn(e.tableFields,o,In(e,o)):f?wt(e.boardFields,o):null;t.get("t")!==n&&t.set("t",n);for(let p of xe(s)){if(a&&(p==="rows"||p==="cols")||f&&(p==="columns"||p==="cards"))continue;let b=t.has(p)?t.get(p):Ne(s,p);ye(b,r[p])||t.set(p,r[p])}a&&vt(e,o,u,r),f&&xt(e,o,u,r)}function io(e,o){let n=new Map,r=o;for(let t=e.flow._start;t&&r>0;t=t.right){if(t.deleted)continue;let s=t.content;s instanceof Te?s.value===null?n.delete(s.key):n.set(s.key,s.value):t.countable&&(r-=t.length)}return n}function Vo(e){let o=new Set;for(let[r,t]of e)Ce(r)&&t&&o.add(r.split("!")[0]);let n=[];for(let[r,t]of e)!Ce(r)&&t!==null&&t!==void 0&&!o.has(r)&&fe.marks[Se(r)]&&n.push([r,t]);return n}function ao(e){let o=new Set;for(let[r,t]of e)Ce(r)&&t&&o.add(r.split("!")[0]);let n=[];for(let[r,t]of e)!Ce(r)&&t!==null&&t!==void 0&&!o.has(r)&&!fe.marks[Se(r)]&&n.push([r,t]);return n}function fo(e,o={}){let n={},r=!1;for(let[t,s]of e)(Ce(t)||fe.marks[Se(t)])&&(n[t]=s);for(let[t,s]of ao(e))r=!0,o[Se(t)]!==void 0&&(n[t]=s);return{attrs:n,opaque:r}}function Wo(e,o,n){let r=be(e),t={},s=Vo(o),a=new Set;for(let[u,p]of s){let b=Se(u),C=n[b];C!==void 0&&so(C,p)?a.add(b):t[`${u}!${r}`]=!0}for(let[u,p]of ao(o)){let b=Se(u);n[b]!==void 0&&so(n[b],p)&&a.add(b)}for(let[u,p]of Object.entries(n))a.has(u)||(t[`${u}~${be(e)}`]=p);let f=fo(o,n);if(!(!Object.keys(t).length&&!f.opaque))return{...f.attrs,...t}}var Nt=2e3;function Uo(e){let o=[],n=[],r=0;for(let t=0;t<e.length;t++)if(n.push(e[t]),r+=1,r>=Nt&&t+1<e.length){let s=e[t];if(s.k==="c"&&Fe(s.ch.charCodeAt(0)))continue;o.push(n),n=[],r=0}return n.length&&o.push(n),o}function lt(e,o,n,r=s=>s(),t=null){let s=o;for(let a of Uo(n))r(()=>{s+=Xo(e,s,a,t)});return s-o}var Go=(e,o,n)=>{if(!n||!n.length)return null;let r=o,t=e.flow._start;for(;t&&r>0;){if(!t.deleted&&t.countable){if(r<t.length)return null;r-=t.length}t=t.right}for(;t&&(t.deleted||!t.countable);t=t.right)if(t.deleted&&n.some(s=>s.client===t.id.client&&s.clock>=t.id.clock&&s.clock<t.id.clock+t.length))return t;return null},We=(e,o,n,r)=>{let t=Go(e,o,n);if(!t)return r();t.deleted=!1;try{return r()}finally{t.deleted=!0,e.flow._searchMarker&&(e.flow._searchMarker.length=0)}};function Xo(e,o,n,r=null){let t=o,s="",a=null,f=null,u=()=>{if(!s)return;let b=Wo(e,io(e,t),f??{});We(e,t,r,()=>e.flow.insert(t,s,b)),t+=s.length,s=""},p=b=>{let C=fo(io(e,t)).attrs;We(e,t,r,()=>e.flow.insertEmbed(t,b,C)),t+=1};for(let b of n)b.k==="c"?(a!==null&&b.mk!==a&&u(),a=b.mk,f=b.ma,s+=b.ch):b.k==="h"?(u(),a=null,p({br:1})):(u(),a=null,p({b:b.id}),co(e,b.id,b.t,b.attrs));return u(),t-o}var Qo=(e,o,n,r)=>{let t=0;for(let s=e.flow._start;s&&t<r;s=s.right){if(s.deleted||!s.countable)continue;let a=t;if(t+=s.length,t<=n||s.content instanceof de&&s.content.embed?.b!==void 0)continue;let f=Math.max(0,n-a),u=Math.min(s.length,r-a);u<=f||e.gone.set(Pn(s.id.client,s.id.clock+f,o.operationId),{length:u-f,actor:e.ydoc.clientID,sv:o.sv})}};function lo(e,o,n,r=null){for(let t=n.length-1;t>=0;t--){let[s,a]=n[t];if(a<=s)continue;let f=o.physicalRanges(s,a);for(let u=f.length-1;u>=0;u--){let[p,b]=f[u];b<=p||(r&&Qo(e,r,p,b),e.flow.delete(p,b-p))}}}function Zo(e,o,n){let r=!1;for(let t=e.flow._start;t;t=t.right){let s=Ee(t.id);if(s===o){r=!0;continue}if(!r)continue;let a=t.content instanceof de?t.content.embed:null;if(a&&a.b!==void 0&&a.b!==n)return s}return null}function Ft(e,o,n,r,t=null){let{pd:s,map:a,bt:f}=e,u=i=>t===null||t[i],p=0;for(;p<n.length&&p<r.length&&ze(n[p],r[p])&&u(p);)p++;let b=0;for(;b<n.length-p&&b<r.length-p&&ze(n[n.length-1-b],r[r.length-1-b])&&u(n.length-1-b);)b++;let C=i=>i&&i.k==="c"?i.ch.charCodeAt(0):-1;p>0&&Fe(C(n[p-1]))&&(nt(C(n[p]))||nt(C(r[p])))&&p--,b>0&&nt(C(n[n.length-b]))&&(Fe(C(n[n.length-b-1]))||Fe(C(r[r.length-b-1])))&&b--;let M=n.slice(p,n.length-b),h=r.slice(p,r.length-b),w=o+p,y=w+M.length,N=M.filter(i=>i.k==="b").map(i=>i.id).join(",");if(!(M.some(i=>i.k==="b")&&N===h.filter(i=>i.k==="b").map(i=>i.id).join(","))){let i=Le(s.origins);try{for(let T of M){if(T.k!=="b"||!T.brk)continue;let U=i.resolve(T.brk);i.boundaryOf(U)||e.tx(()=>i.recordBoundary(U,{blockId:T.id,kind:"removed"}))}}finally{i.dispose()}let g=new Set;M.forEach((T,U)=>{if(T.k!=="b"||!T.brk)return;let P=w+U,I=P+1;for(;I<f.length&&f[I].k!=="b";)I++;let K=I<=y&&I!==P+1,j=I<f.length?f[I].brk:null;K&&(e.tx(()=>s.gone.set(Be(Ee(T.brk),e.operationId),{blockId:T.id,end:j?Ee(j):null,sv:e.sv})),g.add(P))});let A=[],z=w;for(let T=w;T<y;T++)g.has(T)&&(T>z&&A.push([z,T]),z=T+1);y>z&&A.push([z,y]),e.tx(()=>lo(s,a,A,M.some(T=>T.k==="b")?null:e));let W=new Set(h.filter(T=>T.k==="b").map(T=>T.id));for(let T of M)if(!(T.k!=="b"||!T.brk||W.has(T.id)))for(let U of e.copies.get(T.id)??[]){let P=Be(U,e.operationId);s.gone.has(P)||e.tx(()=>s.gone.set(P,{blockId:T.id,end:Zo(s,U,T.id),sv:e.sv}))}h.length&<(s,a.toPhysical(w,"before"),h,e.tx,e.fences);return}let v=[],L=[],Y=[],$=w,x=0,c=0;for(;x<M.length||c<h.length;){let i=x;for(;i<M.length&&M[i].k!=="b";)i++;let g=c;for(;g<h.length&&h[g].k!=="b";)g++;let A=M.slice(x,i),z=h.slice(c,g);if(A.length&&v.push([$,$+A.length]),z.length&&L.push({at:$,toks:z}),$+=A.length,i<M.length&&(Y.push([M[i],h[g]]),$+=1),x=i+(i<M.length?1:0),c=g+(g<h.length?1:0),i>=M.length&&g>=h.length)break}let E=[...v.map(i=>({at:i[0],d:i})),...L.map(i=>({at:i.at,i}))].sort((i,g)=>g.at-i.at||(i.d?-1:1));for(let i of E)i.d?e.tx(()=>lo(s,a,[i.d],e)):lt(s,a.toPhysical(i.at,"before"),i.i.toks,e.tx,e.fences);for(let[i,g]of Y)e.tx(()=>{if(!fe.nodes[g.t])return;let A=e.recovered.get(i.id);if(A){i.t!==g.t&&s.gone.set(De(A,"t"),g.t);for(let T of xe(fe.nodes[g.t]))ye(i.attrs[T],g.attrs[T])||s.gone.set(De(A,T),g.attrs[T]);return}let z=i.id,W=s.attrs.get(z);if(W){let T=i.t==="table"&&g.t==="table"&&W.get("t")==="table",U=g.t==="board",P=U?i.t==="board"&&W.get("t")==="board"?i.attrs:wt(s.boardFields,z):null;i.t!==g.t&&W.set("t",g.t);for(let I of xe(fe.nodes[g.t])){if(T&&(I==="rows"||I==="cols")||U&&(I==="columns"||I==="cards"))continue;let K=W.has(I)?W.get(I):Ne(fe.nodes[g.t],I);ye(K,g.attrs[I])||W.set(I,g.attrs[I])}T&&vt(s,z,i.attrs,g.attrs),U&&xt(s,z,P,g.attrs)}else co(s,z,g.t,g.attrs)})}function Lt(e,o,n,r,t,s){let{pd:a,map:f}=e,u=`${r}~${be(a)}`,p=be(a),b=o;for(;b<n;){if(s[b].k!=="c"){b++;continue}let C=b;for(;C<n&&s[C].k==="c";)C++;let M=f.physicalRanges(b,C);if(t!==null)for(let[h,w]of M)a.flow.format(h,w-h,{[u]:t});else{let h=0;for(let w of a.flow.toDelta()){let y=typeof w.insert=="string"?w.insert.length:1;for(let[N,B]of M){if(h>=B)break;let v=Math.max(h,N),L=Math.min(h+y,B);if(L>v&&w.attributes){let Y={};for(let[$,x]of Object.entries(w.attributes))Se($)===r&&!Ce($)&&x!==null&&(Y[`${$}!${p}`]=!0);Object.keys(Y).length&&a.flow.format(v,L-v,Y)}}h+=y}}b=C}}var{AddMarkStep:uo,RemoveMarkStep:er,AttrStep:tr,ReplaceStep:nr,Mapping:ct}=ln,po=(e,o,n)=>{let r=e.resolve(o),t=e.resolve(n);return[r.depth&&r.node(1).type.name==="table"?r.before(1):o,t.depth&&t.node(1).type.name==="table"?t.after(1):n]},or=(e,o,n)=>{let r=!1;return e.nodesBetween(o,n,t=>(t.type.name==="table"&&(r=!0),!r&&t.type.name!=="table")),r};function mo(e,o,n,r,t=null,s=!0,a=null,{join:f=!1,open:u=!1}={}){let p=()=>{if(a){let l=a;a=null,l()}},b=[],C=[],M=[];for(let l of o)l.steps.forEach((k,F)=>{b.push(k),C.push(l.docs[F]),M.push(k.getMap())});if(!b.length)return;let h=new ct(M),w=[...Qe(Ze(e.ydoc)).entries()].sort((l,k)=>l[0]-k[0]),y=be(e),N=C[0],B=o[o.length-1].doc,v=n.visible.length===0&&N.childCount===1&&N.firstChild.type.name==="paragraph"?[{id:N.firstChild.attrs.id,implicit:!0,t:"paragraph",len:0}]:n.visible,L=new Map,Y=[];{let l=0;v.forEach(k=>{k.implicit&&Y.push({tok:l,id:k.id,t:k.t}),l+=k.len})}Y.sort((l,k)=>k.tok-l.tok);for(let l of Y)l.alias=bn(e),L.set(l.id,l.alias);let $=L.size?n.holes.map(l=>({at:l.at+Y.filter(k=>k.tok<l.at).length,len:l.len})):n.holes,x=Tt(n.tokens+L.size,$,e.flow.length+L.size),c=[],E=[];b.forEach((l,k)=>{let F=l instanceof uo||l instanceof er;if(F&&!or(C[k],l.from,l.to)){E.push({i:k,step:l});return}let R=new ct(M.slice(0,k)).invert(),D=new ct(M.slice(k+1)),q=[];l instanceof tr?q.push([l.pos,l.pos+1,l.pos,l.pos+1]):F?q.push([l.from,l.to,l.from,l.to]):l.getMap().forEach((O,te,X,G)=>q.push([O,te,X,G]));for(let[O,te,X,G]of q){let[Z,oe]=po(N,R.map(O,-1),R.map(te,1)),[ne,Ge]=po(B,D.map(X,-1),D.map(G,1));c.push({oa:Z,ob:oe,na:ne,nb:Ge})}}),c.sort((l,k)=>l.oa-k.oa||l.na-k.na);let i=[];for(let l of c){let k=i[i.length-1];k&&(l.oa<=k.ob||l.na<=k.nb)?(k.ob=Math.max(k.ob,l.ob),k.nb=Math.max(k.nb,l.nb)):i.push({...l})}let g=!Y.length&&!E.length&&b.every(l=>l instanceof nr)&&o.every(dn),A=g?null:It(N,L,v),z=g?null:It(B,L,v),W=g?[]:Ct(N,L,v),T=g?[]:Ct(B,L,v),U=g?i.map(l=>({r:l,old:At(N,l.oa,l.ob),next:At(B,l.na,l.nb)})):null,P=g?U.reduce((l,k)=>l+k.next.end-k.next.start,0):i.reduce((l,k)=>l+(z[k.nb]-z[k.na]),0),I=P>Nt,K=I?l=>e.ydoc.transact(k=>{k.meta.set(_e,s),p(),l()},me):l=>l(),j={pd:e,map:x,bt:W,tx:K,copies:n.copies,fences:n.fences,sv:w,operationId:y,recovered:new Map(n.visible.filter(l=>l.recovered).map(l=>[l.id,l.sourceKey]))},Q=l=>l.filter(k=>k.k==="b").map(k=>`${k.id}|${k.t}|${JSON.stringify(k.attrs)}`).join(`
|
|
3
3
|
`),le=!g&&(E.length>0||Q(W)!==Q(T)),ee=()=>{for(let F of Y)lt(e,Ye(n.holes,F.tok),[{k:"b",id:F.alias,t:F.t,attrs:Object.fromEntries(xe(fe.nodes[F.t]).map(R=>[R,Ne(fe.nodes[F.t],R)]))}],K);for(let F=i.length-1;F>=0;F--)if(g){let{r:R,old:D,next:q}=U[F],O=D.tokens.map((te,X)=>{let G=h.mapResult(R.oa+X,1),Z=h.mapResult(R.oa+X+1,-1),oe=G.pos-R.na;return!G.deleted&&!Z.deleted&&Z.pos===G.pos+1&&oe>=0&&oe<q.tokens.length&&ze(te,q.tokens[oe])});Ft(j,D.start,D.tokens,q.tokens,O)}else{let R=i[F],D=A[R.oa],q=A[R.ob];Ft(j,D,W.slice(D,q),T.slice(z[R.na],z[R.nb]))}let l=E.length?ue(e):null,k=l?{...j,map:Tt(l.tokens,l.holes,e.flow.length)}:null;for(let{i:F,step:R}of E){let D=new ct(M.slice(F+1)),q=z[D.map(R.from,1)],O=z[D.map(R.to,-1)];if(O<=q)continue;let te=R.mark.type.name,X=R instanceof uo?R.mark.attrs&&Object.keys(R.mark.attrs).length?{...R.mark.attrs}:!0:null;if(an(R.mark)){if(X===null)continue;let G=fn(R.mark.attrs.entries);K(()=>{for(let[Z,oe]of Object.entries(G))Lt(k,q,O,Z,oe,T)});continue}K(()=>Lt(k,q,O,te,X,T))}};f||t?.stopCapturing();let m=t?.captureTimeout;t&&(t.captureTimeout=1/0);try{I?ee():e.ydoc.transact(l=>{l.meta.set(_e,s),p(),ee()},me)}finally{t&&(t.captureTimeout=m),u||t?.stopCapturing()}r.groups++,r.lastGroup={chunked:I,structural:le,regional:g,span:P}}var ke=e=>({status:"refused",code:e}),ho=e=>{if(!e)return"";let o=[];for(let n of Object.keys(e).sort())o.push(`${n}=${JSON.stringify(e[n])}`);return o.join(`
|
|
4
4
|
`)},rr=(e,o,n)=>{let r=n?n.state.doc:null,s=r&&r.childCount===o.visible.length&&o.visible.every((f,u)=>r.child(u).attrs.id===f.id)?r:Re(e,o),a=[];return s.forEach(f=>{f.attrs.id===null||f.attrs.id===void 0||a.push({id:f.attrs.id,parent:f.attrs.parent??null,t:f.type.name})}),a},sr=(e,o)=>{let n=[],r=e.get(o)?.parent??null,t=0;for(;r!=null&&t++<=e.size;)n.push(r),r=e.get(r)?.parent??null;return n},bo=(e,o,n)=>sr(e,n).includes(o),Bt=(e,o,n)=>o===n||bo(e,n,o),Dt=(e,o,n,r,t)=>{if(o?.recovered){let a=De(o.sourceKey,r);(e.gone.has(a)?e.gone.get(a):o.fields?.[r]??null)!==t&&e.gone.set(a,t);return}let s=e.attrs.get(n);s||(s=new Ae,e.attrs.set(n,s)),s.get(r)!==t&&s.set(r,t)},at=(e,o,n,r)=>Dt(e,o,n,"parent",r),ir=8,go={indent:(e,o)=>o.t==="list_item"&&Number.isInteger(e)&&e>=0&&e<=ir,open:(e,o)=>o.t==="toggle"&&typeof e=="boolean",parent:(e,o,n)=>e===null||typeof e=="string"&&n.get(e)?.t==="toggle"&&!Bt(n,e,o.id)},lr=(e,o)=>{if(e?.attrs===void 0)return[];if(!e.attrs||typeof e.attrs!="object"||Array.isArray(e.attrs))return null;let n=[];for(let[r,t]of Object.entries(e.attrs)){let s=o.get(r);if(!s||!t||typeof t!="object"||Array.isArray(t))return null;for(let[a,f]of Object.entries(t)){if(!go[a]||!go[a](f,s,o))return null;n.push({id:r,field:a,value:f})}}return n},cr=(e,o)=>{let n=kt(e.flow,0,e.flow.length),r=[],t=0;for(let s of e.flow.toDelta()){let a=s.attributes;if(typeof s.insert=="string")for(let f=0;f<s.insert.length;f++)r.push({ch:s.insert[f],attrs:a,source:o.resolve(n[t++])});else r.push({embed:s.insert,attrs:a,source:o.resolve(n[t++])})}if(t!==n.length)throw new Error(`The flow delta has ${t} units but the document has ${n.length}`);return r},ar=(e,o,n)=>{let r=new Map;for(let s of o.visible)n.has(s.id)&&s.brk&&r.set(Oe(s.brk),s.id);for(let s of n)for(let a of o.copies.get(s)??[])r.set(a,s);let t=[];for(let s=e.flow._start;s;s=s.right){if(s.deleted||!(s.content instanceof de))continue;let a=s.content.embed?.b;if(a===void 0||r.get(Oe(s.id))!==a)continue;let f=null;for(let u=s.right;u;u=u.right){if(u.deleted||!(u.content instanceof de))continue;let p=u.content.embed?.b;if(!(p===void 0||p===a)){f=Oe(u.id);break}}t.push({key:Oe(s.id),blockId:a,end:f})}return t};function zt({pd:e,view:o,um:n,origins:r,render:t,walked:s=null},a={}){let f=Array.isArray(a?.ids)?[...new Set(a.ids)]:[],u=a?.afterId===void 0?null:a.afterId,p=a?.parent!==void 0,b=s??ue(e,r),C=new Set(b.visible.filter(m=>m.opaque).map(m=>m.id)),M=rr(e,b,o),h=new Map(M.map(m=>[m.id,m])),w=M.map(m=>m.id);if(!f.length)return ke("missing-source");for(let m of f)if(!h.has(m))return ke("missing-source");let y=lr(a,h);if(!y)return ke("invalid-attrs");let N=y.filter(m=>m.field==="parent"),B=new Set(f.filter(m=>!f.some(l=>l!==m&&bo(h,l,m)))),v=M.filter(m=>f.some(l=>Bt(h,m.id,l))),L=new Set(v.map(m=>m.id));if(v.some(m=>C.has(m.id))||y.some(m=>C.has(m.id)))return ke("unsupported-format");let Y=new Map(b.visible.map(m=>[m.id,m]));for(let m of v){let l=Y.get(m.id);if(!l||l.implicit||!l.brk)return ke("missing-source")}let $;if(p)$=a.parent??null;else{let m=new Set(v.filter(l=>B.has(l.id)).map(l=>l.parent));if(m.size!==1)return ke("invalid-parent");$=[...m][0]}if(p&&$!==null){let m=h.get($);if(!m||m.t!=="toggle")return ke("invalid-parent");if(L.has($))return ke("cycle")}if(u!==null){if(typeof u!="string"||!h.has(u))return ke("missing-destination");if(L.has(u))return ke("cycle");if(h.get(u).parent!==$)return ke("missing-destination")}let x=M.filter(m=>!L.has(m.id)),c=0;if(u===null){if($!==null){let m=x.findIndex(k=>k.parent===$),l=x.findIndex(k=>k.id===$);c=m>=0?m:l<0?0:l+1}}else for(c=x.findIndex(m=>m.id===u)+1;c<x.length&&Bt(h,x[c].id,u);)c++;let E=[...x.slice(0,c),...v,...x.slice(c)],i=E.length===w.length&&E.every((m,l)=>m.id===w[l]),g=v.filter(m=>B.has(m.id)&&m.parent!==$),A=v.map(m=>m.id);if(i&&!g.length&&!y.length)return{status:"unchanged"};let z=(()=>{let m=o?.state.selection;if(!(m instanceof pe.TextSelection))return null;let l=R=>{let D=o.state.doc.resolve(R);return D.depth?{id:D.node(1).attrs.id,offset:D.parentOffset}:null},k=l(m.anchor),F=l(m.head);return k&&F&&(L.has(k.id)||L.has(F.id))?{anchor:k,head:F}:null})(),W=()=>{if(!z||!o)return;let m=({id:F,offset:R})=>{let D=null;return o.state.doc.forEach((q,O)=>{D===null&&q.attrs.id===F&&(D=O+1+Math.min(R,q.content.size))}),D},l=m(z.anchor),k=m(z.head);l!==null&&k!==null&&o.dispatch(o.state.tr.setSelection(pe.TextSelection.create(o.state.doc,l,k)).setMeta(Me,!0).setMeta("addToHistory",!1))};if(i)return n?.stopCapturing(),e.ydoc.transact(()=>{if(N.length)for(let m of N)at(e,Y.get(m.id),m.id,m.value);else for(let m of g)at(e,Y.get(m.id),m.id,$);for(let m of y)m.field!=="parent"&&Dt(e,Y.get(m.id),m.id,m.field,m.value)},me),n?.stopCapturing(),t(),W(),{status:"moved",ids:A};let T=[...Qe(Ze(e.ydoc)).entries()].sort((m,l)=>m[0]-l[0]),U=be(e),P=cr(e,r),I=yt(b,e.flow.length),K=[],j=0;for(let m of b.visible){if(L.has(m.id)){let l=[];for(let[k,F]of I.physicalRanges(j,j+m.len))for(let R=k;R<F;R++)l.push(P[R]);K.push({seg:m,units:l})}j+=m.len}for(let m=0;m<K.length;m++){let l=K[m];if(l.seg.id!==A[m])throw new Error(`Captured ${l.seg.id} where ${A[m]} was expected`);if(!l.units.length||l.units[0].embed===void 0||l.units[0].embed.b!==l.seg.id)throw new Error(`The selected block ${l.seg.id} has no physical marker to copy`)}let Q=ar(e,b,L),le=Pe(e.gone),ee=new Map;for(let m of v){let l=Y.get(m.id);if(!l.recovered)continue;let k=b.removals.filter(D=>D.sourceKey===l.sourceKey),F=$n(l.sourceKey,k,le),R=le.restores.find(D=>D.key===F?.key)?.baseline??{type:l.t,attrs:l.fields??{}};ee.set(l.sourceKey,{covers:k.map(D=>D.key),baseline:JSON.parse(JSON.stringify(R))})}if(!Q.length)throw new Error("The selected blocks have no live physical markers to retire");return n?.stopCapturing(),e.ydoc.transact(()=>{for(let O of Q)e.gone.set(Be(O.key,U),{blockId:O.blockId,end:O.end,sv:T});let m=ue(e,r),l=yt(m,e.flow.length),k=m.visible.map(O=>O.id),F=0;if(c>0){let O=k.indexOf(x[c-1].id);F=O<0?0:O+1}let R=0;for(let O=0;O<F;O++)R+=m.visible[O].len;let D=l.toPhysical(R,"before"),q=[];for(let O of K){let te=D,X=null,G=null,Z=()=>{X!==null&&(We(e,D,m.fences,()=>e.flow.insert(D,X,G??void 0)),D+=X.length,X=null)};for(let ne of O.units)ne.ch!==void 0?(X!==null&&ho(ne.attrs)!==ho(G)&&Z(),X===null&&(X="",G=ne.attrs),X+=ne.ch):(Z(),We(e,D,m.fences,()=>e.flow.insertEmbed(D,ne.embed,ne.attrs)),D+=1);Z();let oe=kt(e.flow,te,D);if(oe.length!==O.units.length)throw new Error(`Copied ${O.seg.id} as ${oe.length} units instead of ${O.units.length}`);for(let ne=1;ne<O.units.length;ne++)q.push({dest:oe[ne],source:O.units[ne].source});r.recordBoundary(oe[0],O.seg.recovered?{blockId:O.seg.id,kind:"copy",recoveryOf:O.seg.sourceKey}:{blockId:O.seg.id,kind:"copy"}),O.seg.recovered&&e.gone.set(ot(O.seg.sourceKey,U),ee.get(O.seg.sourceKey)),e.gone.set(Tn(Oe(oe[0])),!0)}if(q.length&&r.recordSpans(q),N.length)for(let O of N)at(e,Y.get(O.id),O.id,O.value);else for(let O of g)at(e,Y.get(O.id),O.id,$);for(let O of y)O.field!=="parent"&&Dt(e,Y.get(O.id),O.id,O.field,O.value)},me),n?.stopCapturing(),t(),W(),{status:"moved",ids:A}}var Jt=e=>{let o=[];return e.forEach(n=>o.push([n.type.name,JSON.stringify(Object.fromEntries(xe(n.type).map(r=>[r,n.attrs[r]]))),n.isTextblock||n.type.name==="table"?JSON.stringify(n.content.toJSON()):null])),JSON.stringify(o)};function fr(e,o){if(e.childCount!==o.childCount)return!1;for(let n=0;n<e.childCount;n++){let r=e.child(n),t=o.child(n);if(r!==t&&(r.type!==t.type||xe(r.type).some(s=>!ye(r.attrs[s],t.attrs[s]))||(r.isTextblock||r.type.name==="table")&&!r.content.eq(t.content)))return!1}return!0}var ur=e=>{let o=[];return e.forEach((n,r)=>{n.type.name==="opaque_block"&&o.push([r,r+n.nodeSize])}),o},dr=(e,o)=>{let n=typeof e.from=="number"?e.from:typeof e.pos=="number"?e.pos:null;if(n===null)return!1;let r=typeof e.to=="number"?e.to:n+1;return o.some(([t,s])=>n<s&&r>t)},Ue=(e,o)=>{let n=e.resolve(o);return n.depth&&n.node(1).type.name==="table"?[n.before(1),n.after(1)]:null};function ko(e,o){let n=e.content.findDiffStart(o.content);if(n===null)return null;let{a:r,b:t}=e.content.findDiffEnd(o.content),s=n-Math.min(r,t);s>0&&(r+=s,t+=s);let a=(f,u)=>{let p=f.resolve(n);return p.parent.isTextblock&&p.sameParent(f.resolve(u))};return(Ue(e,n)||Ue(e,r))&&!(a(e,r)&&a(o,t))?(n=Ue(e,n)?.[0]??n,r=Ue(e,r)?.[1]??r,t=Ue(o,t)?.[1]??t,{start:n,endA:r,endB:t,tables:!0}):{start:n,endA:r,endB:t}}function Kt(e,o=null){let n=new Map;o?.forEach(u=>{u.attrs.id&&n.set(u.attrs.id,u)});let r=[];e.forEach(u=>r.push(u));let t=r.map(u=>({id:u.attrs.id,pos:n.get(u.attrs.id)?.attrs.pos??u.attrs.pos})),s=bt(t,"b"),a=!1,f=r.map((u,p)=>{let b=s[p]?.pos??t[p].pos,C=u.content;if(u.type.name==="table"){let w=[];u.forEach(v=>w.push(v));let y=w.map(v=>({id:v.attrs.id,pos:v.attrs.pos})),N=bt(y,"r"),B=w.map((v,L)=>{let Y=N[L]?.pos??y[L].pos;return Y===v.attrs.pos?v:v.type.create({...v.attrs,pos:Y},v.content,v.marks)});B.some((v,L)=>v!==w[L])&&(C=B)}if(b===u.attrs.pos&&C===u.content)return u;a=!0;let M={...u.attrs,pos:b},h=n.get(u.attrs.id);return h&&C===u.content&&h.hasMarkup(u.type,M,u.marks)&&h.content.eq(C)?h:u.type.create(M,C,u.marks)});return a?e.type.create(e.attrs,f):e}var yo=e=>{let o=new Set,n=null;for(let r=0;r<e.childCount;r++){let{id:t,pos:s}=e.child(r).attrs;if(!t||o.has(t)||!un(s)||n!==null&&n>=s)return!1;o.add(t),n=s}return!0},pr=(e,o)=>{for(let n in e.attrs)if(n!=="pos"&&e.attrs[n]!==o.attrs[n])return!1;return!0};function mr(e,o){if(e.childCount!==o.childCount||!yo(e))return!1;for(let n=0;n<e.childCount;n++){let r=e.child(n),t=o.child(n);if(r===t)continue;if(!(r.type===t.type&&r.marks===t.marks&&pr(r,t))&&!r.hasMarkup(t.type,{...t.attrs,pos:r.attrs.pos},t.marks)||!r.content.eq(t.content)||r.type.name==="table"&&!yo(r))return!1}return!0}var wo=e=>{if(e&&typeof e=="object"){for(let o of Object.keys(e))wo(e[o]);Object.freeze(e)}return e},vo=e=>wo(JSON.parse(JSON.stringify(e))),hr=(e,o)=>{let n=gn(o),r=0;for(let t=e.flow._start;t;t=t.right){if(t.id.client===n.client&&t.id.clock===n.clock)return t.deleted?r:r+t.length;!t.deleted&&t.countable&&(r+=t.length)}return r},gr=(e,o)=>{let n=null;for(let r=e.flow._start;r;r=r.right)r.id.client!==e.ydoc.clientID||!(r.content instanceof de)||r.content.embed?.b!==o||(!n||r.id.clock>n.clock)&&(n=r.id);return n};function xo({pd:e,onNotice:o=()=>{},ownedTokens:n=[],authorToken:r=null,stats:t={groups:0,mismatch:0,renders:0,first:null},captureTimeout:s=500}){let a=null,f=null,u=0,p=-1,b=null,C=0,M=new WeakMap,h=Le(e.origins);f=ue(e,h);let w=new on([e.flow,e.attrs,e.gone,e.tableFields,e.boardFields],{trackedOrigins:new Set([me]),captureTimeout:s,captureTransaction:d=>d.meta.get(_e)!==!1,deleteFilter:d=>{if(d.parent!==e.flow||!(d.content instanceof de))return!0;let S=h.resolve(d.id);return S.client!==d.id.client||S.clock!==d.id.clock||h.boundaryOf(d.id)?.kind!=="copy"}}),y=wn(e,w,h,d=>Pe(d).textDeletes),N=new Set,B=new Set(r?[...n,r]:n),v=r?()=>{let d=An(e.ydoc.clientID);e.origins.get(d)!==r&&e.origins.set(d,r)}:null,L=new Set,Y=new Set,$=0,x=null,c=null,E=d=>{let S=new Set;for(let J of d.blocks)for(let V of J.runs){if(!V.displaced)continue;let H=Rn(V.source)?.client===e.ydoc.clientID;V.author&&(H||B.has(V.author))?S.add(V.author):H&&S.add(null)}if(!S.size)return null;let _=[...S].filter(Boolean).sort();return{kind:"recovered-change",source:d.source,revision:d.revision,blockId:d.blockId,author:_[0]??null,authors:_}},i=d=>{let S=d.list.filter(J=>J.recoverable).map(J=>vo(J)),_=vo(S.map(J=>E(J)).filter(J=>J&&!L.has(`${J.source}\0${J.revision}`)));return Object.freeze({recoverable:Object.freeze(S),notices:Object.freeze(_)})},g=(d,S)=>{if(JSON.stringify(i(st(e,{index:h,walked:S})))===JSON.stringify(d)){t.provedRecoveries=(t.provedRecoveries??0)+1;return}throw t.walkMismatch=(t.walkMismatch??0)+1,new Error("Recovery snapshot built from the displacing sources diverged from a full reduction")},A=()=>{if(x&&x.version===$)return x.snapshot;let d=p===u?f:void 0,S=i(jn(e,{index:h,walked:d}));return t.proveWalks&&g(S,d),x={version:$,snapshot:S},S},z=d=>rt({recoverable:d.recoverable.map(S=>[S.source,S.revision]),notices:d.notices}),W=()=>{$++;let d=A();for(let _ of d.notices){let J=`${_.source}\0${_.revision}`;N.has(J)||(N.add(J),o(_))}if(!Y.size){c=null;return}let S=z(d);if(S!==c){c=S;for(let _ of[...Y])_(d)}},T=d=>{f=d,p=u,b=null,C=0},U=()=>p===u?f:null,P=d=>{let S=Ve(e,d),_=Ve(e,ue(e));if(S===_){t.provedWalks=(t.provedWalks??0)+1;return}throw t.walkMismatch=(t.walkMismatch??0)+1,new Error(`Incremental walk diverged from the full walk:
|
|
@@ -27,4 +27,4 @@ ${_}`)},Q=()=>{if(JSON.stringify(i(st(e,{index:h,walked:f})))!==JSON.stringify(A
|
|
|
27
27
|
.blockeditor-recover-row button, .blockeditor-recover-head button { min-height: 44px; }
|
|
28
28
|
}
|
|
29
29
|
`,yr={heading:"Heading",list_item:"List item",toggle:"Toggle",quote:"Quote",code_block:"Code",callout:"Callout",table:"Table",image:"Image"},qt=280,ve=(e,o,n,r={})=>{let t=e.createElement(o);n&&(t.className=n);for(let[s,a]of Object.entries(r))t.setAttribute(s,a);return t};function vr(e,o){let n=ve(e,"div","blockeditor-recover-text"),r=0;for(let t of o.blocks){for(let s of t.runs){if(s.kind!=="text"||r>=qt)continue;let a=s.text.slice(0,qt-r);r+=a.length,n.append(s.displaced?Object.assign(e.createElement("mark"),{textContent:a}):e.createTextNode(a))}r<qt&&t!==o.blocks[o.blocks.length-1]&&n.append(e.createTextNode(" / "))}return n.textContent||(n.textContent="(no text)"),n}function wr(e){let o=new Set;for(let n of e.blocks)for(let r of n.runs)r.displaced&&o.add(r.author??null);return[...o]}function xr(e,o){let n=null;return e.state.doc.forEach((r,t)=>{n===null&&r.attrs.id===o&&(n=r.isTextblock?t+1:t)}),n===null?!1:(e.dispatch(e.state.tr.setSelection(pe.Selection.near(e.state.doc.resolve(n))).scrollIntoView()),e.focus(),!0)}function Sr({binding:e,mount:o,ownTokens:n=[],onRestored:r=()=>{},onStale:t=()=>{}}){let s=o.ownerDocument,a=new Set(n.filter(Boolean)),f=ve(s,"button","blockeditor-recover",{type:"button","aria-haspopup":"dialog","aria-expanded":"false"}),u=ve(s,"div","blockeditor-recover-panel",{role:"dialog","aria-label":"Recover changes"});f.hidden=!0,u.hidden=!0;let p=ve(s,"div","blockeditor-recover-root");p.append(f,u);let b=Vt({name:"blockeditor-recover",content:p,css:[kr],parent:o}),C={recoverable:[],notices:[]},M=null,h="",w=x=>x.some(c=>a.has(c))?x.length>1?"You and others":"You":x.some(c=>c!==null)?"Another editor":"An earlier edit",y=()=>{u.hidden=!0,M=null,f.setAttribute("aria-expanded","false")},N=x=>{let c;try{c=e.restore(x.source,x.revision)}catch(E){return console.error("[clay] Restore failed:",E),Wt("This change could not be restored.","error"),{status:"failed"}}return c.status==="restored"||c.status==="resolved"?r(c.id):c.status==="stale"&&t(c),c},B=()=>{u.replaceChildren();let x=ve(s,"div","blockeditor-recover-head");x.append(s.createTextNode("Recover changes"));let c=ve(s,"button","",{type:"button"});c.textContent="Close",c.addEventListener("click",()=>{y(),f.focus()}),x.append(c);let E=ve(s,"p","blockeditor-recover-note");E.textContent="Text typed while its block was moved or removed. Restore puts it back as a new block.",u.append(x,E);for(let i of C.recoverable){let g=ve(s,"div","blockeditor-recover-row",{"data-source":i.source});i.source===M&&g.classList.add("is-target");let A=ve(s,"div","blockeditor-recover-meta");A.textContent=`${yr[i.type]??"Paragraph"} \xB7 ${w(wr(i))}`;let z=ve(s,"button","",{type:"button"});z.textContent="Restore",z.addEventListener("click",()=>N(i)),g.append(A,vr(s,i),z),u.append(g)}},v=(x=null)=>{if(!C.recoverable.length)return;M=x,u.hidden=!1,f.setAttribute("aria-expanded","true"),B();let c=[...u.querySelectorAll(".blockeditor-recover-row")];(c.find(i=>i.dataset.source===x)??c[0])?.querySelector("button")?.focus()},L=x=>{let c=x.map(E=>`${E.source}\0${E.revision}`).join(`
|
|
30
|
-
`);if(c!==h){if(h=c,!x.length){ft(Ht);return}Ut(Ht,"warning",{actions:[{label:"Review",onClick:()=>v(x[0].source)},{label:"Dismiss",onClick:()=>{for(let E of x)e.dismiss(E.source,E.revision)}}]})}},Y=x=>{C=x;let c=x.recoverable.length;f.hidden=c===0,f.textContent=`Recover changes (${c})`,c?u.hidden||B():y(),L(x.notices)};f.addEventListener("click",()=>u.hidden?v():y()),u.addEventListener("keydown",x=>{x.key==="Escape"&&(x.stopPropagation(),y(),f.focus())});let $=e.subscribeRecovery(Y);return{open:v,close:y,restore:N,get count(){return C.recoverable.length},destroy(){$(),ft(Ht),b.remove()}}}import("./page/editor-
|
|
30
|
+
`);if(c!==h){if(h=c,!x.length){ft(Ht);return}Ut(Ht,"warning",{actions:[{label:"Review",onClick:()=>v(x[0].source)},{label:"Dismiss",onClick:()=>{for(let E of x)e.dismiss(E.source,E.revision)}}]})}},Y=x=>{C=x;let c=x.recoverable.length;f.hidden=c===0,f.textContent=`Recover changes (${c})`,c?u.hidden||B():y(),L(x.notices)};f.addEventListener("click",()=>u.hidden?v():y()),u.addEventListener("keydown",x=>{x.key==="Escape"&&(x.stopPropagation(),y(),f.focus())});let $=e.subscribeRecovery(Y);return{open:v,close:y,restore:N,get count(){return C.recoverable.length},destroy(){$(),ft(Ht),b.remove()}}}import("./page/editor-HS2CAV3W.js").catch(()=>null);export{Wn as ADOPTION_TIMEOUT_MS,Yo as acceptedPageState,Po as blocksFromYValue,je as canon,Mt as classifyFile,Io as createFeatureLoader,Sr as createRecoverList,br as createYPageBinding,xr as focusBlock,To as heldSlashRange,Ao as holdSlashRange,Do as installAdoption,jt as mergePageModels,Co as observeDocumentTitle,it as readBack,Ro as renderFromTags,$o as seedPageFromArticle,Eo as yValueOf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as m}from"./c-EQ5NBOGA.js";import{f as l}from"./c-C7SUMNMI.js";var _=window.__clayWorkspaceBackground===!0;document.addEventListener("clay:workspace-background",()=>{_=!0});document.addEventListener("clay:workspace-foreground",()=>{_=!1});var c=()=>document.hidden||_,y=class extends EventTarget{constructor(e,{shared:s=!1,sharedData:r=!1,documentURL:n,lane:o,clientId:h,startupCheck:t=!1,keepAliveWhenHidden:a=!1,workerFeatures:d=["live-data"]}={}){super(),this.url=e,this.readyState=0,this.onopen=null,this.onmessage=null,this.onerror=null,this._shared=s&&typeof SharedWorker=="function"&&(!r||o==="live"),this._sharedData=r,this._documentURL=n,this._lane=o,this._clientId=h,this._keepAliveWhenHidden=a,this._workerFeatures=d,this._since=0,this._closed=!1,this._suspended=!1,this._repair=!1,this._startup=t,this._worker=null,this._source=null,this._visibility=()=>{clearTimeout(this._hiddenTimer),c()?(this._worker&&this._postWorker(this._worker,"hidden"),this._keepHidden()||(this._hiddenTimer=setTimeout(()=>this._suspend(),5e3))):this._suspended?this._resume():this._worker&&this._postWorker(this._worker,"visible")},this._pagehide=()=>this._suspend(!0),this._pageshow=()=>{(!c()||this._keepHidden())&&this._resume()},document.addEventListener("visibilitychange",this._visibility),document.addEventListener("clay:workspace-background",this._visibility),document.addEventListener("clay:workspace-foreground",this._visibility),window.addEventListener("pagehide",this._pagehide),window.addEventListener("pageshow",this._pageshow),this._open(),c()&&this._visibility()}_emit(e,s){if(this._closed)return;let r=s===void 0?new Event(e):new MessageEvent(e,{data:s});this.dispatchEvent(r),this[`on${e}`]?.(r)}_postWorker(e,s,r={}){e.port.postMessage({v:this._sharedData?2:1,type:s,...r})}_open(){if(!(this._closed||this._suspended)){if(this.readyState=0,!this._shared)return this._openDirect();try{let e=new SharedWorker(new URL(this._sharedData?"/_/sync/data-worker.js":"/_/sync/worker.js",window.location.origin).href,this._sharedData?"clay-sync-data":"clay-sync");this._worker=e;let s=Date.now(),r=!1;e.onerror=()=>{this._worker===e&&(this._shared=!1,this._repair=!0,this._reopen(),c()&&this._visibility())},this._startTimer=setTimeout(e.onerror,5e3),e.port.onmessage=({data:t})=>{if(!(this._worker!==e||t?.v!==(this._sharedData?2:1))){if(this._sharedData){if(t.type==="unsupported"||t.type==="capacity"){e.onerror();return}if(t.type==="gone"){this.readyState=2,this._emit("error"),this.close();return}if(!r){if(t.type!=="hello")return;if(!Array.isArray(t.features)||!this._workerFeatures.every(a=>t.features.includes(a))){e.onerror();return}r=!0,clearTimeout(this._startTimer),s=Date.now();return}if(t.type==="hello")return}if(s=Date.now(),!this._sharedData&&["status","pong","cursor","frame","gone"].includes(t.type)&&clearTimeout(this._startTimer),t.type==="status")t.state==="open"?(!this._sharedData||this.readyState!==1)&&(this.readyState=1,this._emit("open")):t.state==="connecting"&&(this.readyState=0,this._emit("error"));else if(t.type==="cursor"){clearTimeout(this._startTimer),Number.isSafeInteger(t.seq)&&(this._since=Math.max(this._since,t.seq));let a=t.resync===!0||this._repair,d=this._startup;this._repair=!1,this._startup=!1,this._emit("cursor",JSON.stringify({...t,resync:a,startup:d}))}else if(t.type==="frame"&&typeof t.data=="string")this._remember(t.data),this._emit("message",t.data);else if(this._sharedData&&t.type==="event"&&["data","data-state","data-writer","presence"].includes(t.event)&&t.data!==null&&typeof t.data=="object"&&!Array.isArray(t.data))try{this._emit(t.event,JSON.stringify(t.data))}catch{}else t.type==="gone"&&(this.readyState=2,this._emit("error"),this.close())}},e.port.start(),this._postWorker(e,c()?"hidden":"visible");let n={document:this._documentURL,lane:this._lane,since:this._since};this._sharedData&&this._lane==="live"&&(n.clientId=this._clientId),this._postWorker(e,"subscribe",n);let o=0,h=Date.now();this._pingTimer=setInterval(()=>{if(this._worker!==e)return;let t=Date.now(),a=t-h>15e3*6;if(h=t,s>=o&&(o=0),a||o&&t-o>=15e3*3){this._repair=!0,this._reopen();return}o||(o=t),this._postWorker(e,"ping")},15e3)}catch{this._shared=!1,this._reopen(),c()&&this._visibility()}}}_openDirect(){let e=new EventSource(this.url);this._source=e;let s=!1,r=!1;e.onopen=()=>{if(this._source===e&&(s&&!r&&(this._repair=!0),s=!0,this.readyState=1,this._emit("open"),this._repair||this._startup)){let n=this._repair,o=this._startup;this._repair=!1,this._startup=!1,this._emit("cursor",JSON.stringify({resync:n,startup:o}))}},e.onerror=()=>{this._source===e&&(this.readyState=e.readyState,this._emit("error"))},e.onmessage=n=>{this._source===e&&(this._remember(n.data),this._emit("message",n.data))};for(let n of["cursor","presence","data","data-state","data-writer"])e.addEventListener(n,o=>{this._source===e&&(n==="cursor"&&(r=!0),this._emit(n,o.data))})}_remember(e){try{let{seq:s}=JSON.parse(e);Number.isSafeInteger(s)&&(this._since=Math.max(this._since,s))}catch{}}_disconnect(){if(clearTimeout(this._startTimer),clearInterval(this._pingTimer),this._worker){let e=this._worker;this._worker=null,e.onerror=null,e.port.onmessage=null;try{this._postWorker(e,"unsubscribe")}catch{}e.port.close()}this._source&&(this._source.close(),this._source=null)}_keepHidden(){return this._keepAliveWhenHidden===!0||this._keepAliveWhenHidden==="shared"&&this._shared}_reopen(){let e=(this._sharedData||this._keepAliveWhenHidden===!0)&&this.readyState===1;this.readyState=0,e&&this._emit("error"),this._disconnect(),this._open()}_suspend(e=!1){clearTimeout(this._hiddenTimer),!(this._closed||this._suspended)&&(this._suspended=!0,this._repair=!0,this.readyState=0,e&&this._keepAliveWhenHidden===!0&&this._emit("error"),this._disconnect())}_resume(){clearTimeout(this._hiddenTimer),!(this._closed||!this._suspended)&&(this._suspended=!1,this._open())}close(){this._closed=!0,this.readyState=2,clearTimeout(this._hiddenTimer),this._disconnect(),document.removeEventListener("visibilitychange",this._visibility),document.removeEventListener("clay:workspace-background",this._visibility),document.removeEventListener("clay:workspace-foreground",this._visibility),window.removeEventListener("pagehide",this._pagehide),window.removeEventListener("pageshow",this._pageshow)}};var v="This document was upgraded.",u=!1;function p(i,e){let s=i.querySelector(`meta[name="${e}"]`),r=s?s.getAttribute("content"):null;return r&&r.trim()?r.trim():null}function k(i=document){return p(i,"hyper-version")}function T(i){return typeof i!="string"||!i.includes("hyper-version")?null:p(new DOMParser().parseFromString(i,"text/html"),"hyper-version")}function w(i){let e=k();return!!e&&!!i&&i!==e}function D(i){return u?!0:w(T(i))}function b(i){return u?!0:!i||typeof i.querySelector!="function"?!1:w(p(i,"hyper-version"))}function L(){if(u)return Promise.resolve();u=!0;let i=l?import("./core/save-
|
|
1
|
+
import{d as m}from"./c-EQ5NBOGA.js";import{f as l}from"./c-C7SUMNMI.js";var _=window.__clayWorkspaceBackground===!0;document.addEventListener("clay:workspace-background",()=>{_=!0});document.addEventListener("clay:workspace-foreground",()=>{_=!1});var c=()=>document.hidden||_,y=class extends EventTarget{constructor(e,{shared:s=!1,sharedData:r=!1,documentURL:n,lane:o,clientId:h,startupCheck:t=!1,keepAliveWhenHidden:a=!1,workerFeatures:d=["live-data"]}={}){super(),this.url=e,this.readyState=0,this.onopen=null,this.onmessage=null,this.onerror=null,this._shared=s&&typeof SharedWorker=="function"&&(!r||o==="live"),this._sharedData=r,this._documentURL=n,this._lane=o,this._clientId=h,this._keepAliveWhenHidden=a,this._workerFeatures=d,this._since=0,this._closed=!1,this._suspended=!1,this._repair=!1,this._startup=t,this._worker=null,this._source=null,this._visibility=()=>{clearTimeout(this._hiddenTimer),c()?(this._worker&&this._postWorker(this._worker,"hidden"),this._keepHidden()||(this._hiddenTimer=setTimeout(()=>this._suspend(),5e3))):this._suspended?this._resume():this._worker&&this._postWorker(this._worker,"visible")},this._pagehide=()=>this._suspend(!0),this._pageshow=()=>{(!c()||this._keepHidden())&&this._resume()},document.addEventListener("visibilitychange",this._visibility),document.addEventListener("clay:workspace-background",this._visibility),document.addEventListener("clay:workspace-foreground",this._visibility),window.addEventListener("pagehide",this._pagehide),window.addEventListener("pageshow",this._pageshow),this._open(),c()&&this._visibility()}_emit(e,s){if(this._closed)return;let r=s===void 0?new Event(e):new MessageEvent(e,{data:s});this.dispatchEvent(r),this[`on${e}`]?.(r)}_postWorker(e,s,r={}){e.port.postMessage({v:this._sharedData?2:1,type:s,...r})}_open(){if(!(this._closed||this._suspended)){if(this.readyState=0,!this._shared)return this._openDirect();try{let e=new SharedWorker(new URL(this._sharedData?"/_/sync/data-worker.js":"/_/sync/worker.js",window.location.origin).href,this._sharedData?"clay-sync-data":"clay-sync");this._worker=e;let s=Date.now(),r=!1;e.onerror=()=>{this._worker===e&&(this._shared=!1,this._repair=!0,this._reopen(),c()&&this._visibility())},this._startTimer=setTimeout(e.onerror,5e3),e.port.onmessage=({data:t})=>{if(!(this._worker!==e||t?.v!==(this._sharedData?2:1))){if(this._sharedData){if(t.type==="unsupported"||t.type==="capacity"){e.onerror();return}if(t.type==="gone"){this.readyState=2,this._emit("error"),this.close();return}if(!r){if(t.type!=="hello")return;if(!Array.isArray(t.features)||!this._workerFeatures.every(a=>t.features.includes(a))){e.onerror();return}r=!0,clearTimeout(this._startTimer),s=Date.now();return}if(t.type==="hello")return}if(s=Date.now(),!this._sharedData&&["status","pong","cursor","frame","gone"].includes(t.type)&&clearTimeout(this._startTimer),t.type==="status")t.state==="open"?(!this._sharedData||this.readyState!==1)&&(this.readyState=1,this._emit("open")):t.state==="connecting"&&(this.readyState=0,this._emit("error"));else if(t.type==="cursor"){clearTimeout(this._startTimer),Number.isSafeInteger(t.seq)&&(this._since=Math.max(this._since,t.seq));let a=t.resync===!0||this._repair,d=this._startup;this._repair=!1,this._startup=!1,this._emit("cursor",JSON.stringify({...t,resync:a,startup:d}))}else if(t.type==="frame"&&typeof t.data=="string")this._remember(t.data),this._emit("message",t.data);else if(this._sharedData&&t.type==="event"&&["data","data-state","data-writer","presence"].includes(t.event)&&t.data!==null&&typeof t.data=="object"&&!Array.isArray(t.data))try{this._emit(t.event,JSON.stringify(t.data))}catch{}else t.type==="gone"&&(this.readyState=2,this._emit("error"),this.close())}},e.port.start(),this._postWorker(e,c()?"hidden":"visible");let n={document:this._documentURL,lane:this._lane,since:this._since};this._sharedData&&this._lane==="live"&&(n.clientId=this._clientId),this._postWorker(e,"subscribe",n);let o=0,h=Date.now();this._pingTimer=setInterval(()=>{if(this._worker!==e)return;let t=Date.now(),a=t-h>15e3*6;if(h=t,s>=o&&(o=0),a||o&&t-o>=15e3*3){this._repair=!0,this._reopen();return}o||(o=t),this._postWorker(e,"ping")},15e3)}catch{this._shared=!1,this._reopen(),c()&&this._visibility()}}}_openDirect(){let e=new EventSource(this.url);this._source=e;let s=!1,r=!1;e.onopen=()=>{if(this._source===e&&(s&&!r&&(this._repair=!0),s=!0,this.readyState=1,this._emit("open"),this._repair||this._startup)){let n=this._repair,o=this._startup;this._repair=!1,this._startup=!1,this._emit("cursor",JSON.stringify({resync:n,startup:o}))}},e.onerror=()=>{this._source===e&&(this.readyState=e.readyState,this._emit("error"))},e.onmessage=n=>{this._source===e&&(this._remember(n.data),this._emit("message",n.data))};for(let n of["cursor","presence","data","data-state","data-writer"])e.addEventListener(n,o=>{this._source===e&&(n==="cursor"&&(r=!0),this._emit(n,o.data))})}_remember(e){try{let{seq:s}=JSON.parse(e);Number.isSafeInteger(s)&&(this._since=Math.max(this._since,s))}catch{}}_disconnect(){if(clearTimeout(this._startTimer),clearInterval(this._pingTimer),this._worker){let e=this._worker;this._worker=null,e.onerror=null,e.port.onmessage=null;try{this._postWorker(e,"unsubscribe")}catch{}e.port.close()}this._source&&(this._source.close(),this._source=null)}_keepHidden(){return this._keepAliveWhenHidden===!0||this._keepAliveWhenHidden==="shared"&&this._shared}_reopen(){let e=(this._sharedData||this._keepAliveWhenHidden===!0)&&this.readyState===1;this.readyState=0,e&&this._emit("error"),this._disconnect(),this._open()}_suspend(e=!1){clearTimeout(this._hiddenTimer),!(this._closed||this._suspended)&&(this._suspended=!0,this._repair=!0,this.readyState=0,e&&this._keepAliveWhenHidden===!0&&this._emit("error"),this._disconnect())}_resume(){clearTimeout(this._hiddenTimer),!(this._closed||!this._suspended)&&(this._suspended=!1,this._open())}close(){this._closed=!0,this.readyState=2,clearTimeout(this._hiddenTimer),this._disconnect(),document.removeEventListener("visibilitychange",this._visibility),document.removeEventListener("clay:workspace-background",this._visibility),document.removeEventListener("clay:workspace-foreground",this._visibility),window.removeEventListener("pagehide",this._pagehide),window.removeEventListener("pageshow",this._pageshow)}};var v="This document was upgraded.",u=!1;function p(i,e){let s=i.querySelector(`meta[name="${e}"]`),r=s?s.getAttribute("content"):null;return r&&r.trim()?r.trim():null}function k(i=document){return p(i,"hyper-version")}function T(i){return typeof i!="string"||!i.includes("hyper-version")?null:p(new DOMParser().parseFromString(i,"text/html"),"hyper-version")}function w(i){let e=k();return!!e&&!!i&&i!==e}function D(i){return u?!0:w(T(i))}function b(i){return u?!0:!i||typeof i.querySelector!="function"?!1:w(p(i,"hyper-version"))}function L(){if(u)return Promise.resolve();u=!0;let i=l?import("./core/save-JZ7R4ET2.js").then(r=>r.holdAllSaves(v),()=>{}):Promise.resolve(),e=new CustomEvent("clay:document-upgraded",{detail:{message:v}}),s=l?Promise.resolve():import("./c-ASMLERFA.js").then(r=>r.start(e),()=>{});return document.dispatchEvent(e),Promise.all([i,s]).then(()=>{})}var g=i=>i==null?"":`&blockeditor-format=${i}`,f={spec:{name:"spec",relayPath:"/_/sync",documentHeader:"Document-URL",snapshotKey:"snapshot",streamPath:(i,e,s,r,n)=>`/_/sync?document-url=${encodeURIComponent(i)}&lane=${e}&resume-id=${s}&client-id=${encodeURIComponent(r)}${g(n)}`},legacy:{name:"legacy",relayPath:"/_/live-sync/save",documentHeader:"Page-URL",snapshotKey:"html",streamPath:(i,e,s,r,n)=>`/_/live-sync/stream?page-url=${encodeURIComponent(i)}&lane=${e}&resume-id=${s}&client-id=${encodeURIComponent(r)}${g(n)}`}};function R(){return m().then(i=>{let e=i?.extensions||[],s=e.includes("sync"),r=e.includes("live-data"),n=e.includes("presence"),o=s&&r&&e.includes("sync-worker-data"),h=s&&(o||e.includes("sync-worker")&&!r&&!n);return{profile:s?f.spec:f.legacy,sharedSync:h,sharedData:o,liveData:r,workerFeatures:n?["live-data","presence"]:["live-data"]}}).catch(()=>({profile:f.legacy,sharedSync:!1,sharedData:!1,liveData:!1,workerFeatures:["live-data"]}))}export{c as a,y as b,D as c,b as d,L as e,f,R as g};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as g,s as k}from"./c-
|
|
1
|
+
import{n as g,s as k}from"./c-EHAR4RJJ.js";import{a as u,b as r,c as d,h as p}from"./c-KU3PX7LL.js";var v=3e4;function a(){return{ok:!1,code:"failed"}}async function x(n,{etag:o}={}){if(typeof n!="string"||n==="")return a();let m=o!==void 0,y=typeof o=="string"&&o?o:null;if(r()||await p(),!r())return{ok:!1,code:"unsupported"};let s=m?y:u();if(!s)return{ok:!1,code:"conflict"};let i=new AbortController,S=setTimeout(()=>i.abort(),v);try{let{url:c,options:b}=k(n,!0,i.signal,g(),s,!1,null,!1),t=await fetch(c,b),f=await t.text(),e={};if(f)try{e=JSON.parse(f)}catch{e={}}if(!t.ok)return t.status===412?{ok:!1,code:"conflict"}:t.status===401||t.status===403?{ok:!1,code:"forbidden"}:a();let l=typeof e.etag=="string"&&e.etag?e.etag:null;return d(l),{ok:!0,etag:l}}catch{return a()}finally{clearTimeout(S)}}export{x as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as y,f as L,h as $,j as B,m}from"./c-J2ZW4HMR.js";import"./c-A5LASUEZ.js";import{a as _}from"./c-4JZDZFF6.js";import{b as R,c as T,d as N,e as S}from"./c-5RZNFTWD.js";import{b as F}from"./c-PKCCHJ5X.js";import{b}from"./c-NUHP2XDB.js";import{h as P}from"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var D="p,h1,h2,h3,h4,h5,h6,li,dt,dd,blockquote,pre,figcaption,td,th",K="section,article,aside,header,footer,nav,main,div,ul,ol,dl,table,figure,form",v=4,C=()=>typeof matchMedia=="function"&&!!matchMedia("(pointer: coarse)").matches;function w(l,d,f){return l.setAttribute(d,f),l}function H(l=document){let d=n=>n instanceof l.defaultView.Element&&n!==l.body&&n!==l.documentElement&&!n.closest("[data-clay-ai-edit]")&&!n.closest(P),f=n=>{if(!n||!d(n))return null;let r=n.closest(D)||n.closest(K);return r&&r!==l.body?r:null};return{targetAt(n,r){let a=typeof l.elementsFromPoint=="function"?l.elementsFromPoint(n,r):[];for(let s of a||[]){let t=f(s);if(t)return t}return null},between(n,r){if(!n)return r||null;if(!r||n===r)return n;let a=n.compareDocumentPosition(r)&4?n:r,s=a===n?r:n,t=a;for(;t&&!t.contains(s);)t=t.parentElement;return t?t===l.body||t.matches(D)||t.matches(K)?t:f(t)||t:null},rectOf(n){return n.getBoundingClientRect()}}}function U({coarse:l}){let d=`color-scheme:${_()}`,f=(u,i)=>w(u,"data-clay-ai-edit-part",i),n=w(L("div",["position:fixed","inset:0","z-index:99997","background:transparent","touch-action:pan-y","cursor:crosshair",d]),"data-clay-ai-edit","picker"),r=w(L("div",["box-sizing:content-box","position:fixed","z-index:99998","pointer-events:none",`border:2px solid ${S.brass}`,"border-radius:0",d]),"data-clay-ai-edit","picker-ring");m(r,!1);let a=w($("div",["position:fixed","left:50%","bottom:16px","transform:translateX(-50%)","z-index:99999","width:min(35rem, calc(100vw - 32px))","padding:8px 10px","border-radius:12px","gap:8px","align-items:center",`box-shadow:${N}`,`font:13px/1.5 ${R}`,d]),"data-clay-ai-edit","picker-bar");m(a,!1,"flex");let s=f(B("div",["display:block","flex:1","min-width:0","overflow:hidden","text-overflow:ellipsis","white-space:nowrap",`color:${S.muted}`,`font:12.5px/1.5 ${T}`]),"picker-hint");s.textContent="Click or drag blocks";let t=f(y("Whole page",{extra:["flex:none"]}),"picker-whole"),h=f(y("Cancel",{variant:"quiet",extra:["flex:none"]}),"picker-cancel"),c=l?f(y("Continue",{variant:"primary",extra:["flex:none"]}),"picker-continue"):null;c&&m(c,!1,"inline-flex"),a.append(s,t,...c?[c]:[],h),document.body.append(n,r,a);for(let u of[n,r,a])F(u);return{overlay:n,ring:r,bar:a,hint:s,whole:t,more:c,cancel:h}}function ee({surface:l,onPicked:d,onWholePage:f,onCancel:n,build:r}={}){let a=document,s=l||H(a),t=null,h=null,c=!1,u=null,i=null,M=e=>e&&(typeof s.rectOf=="function"?s.rectOf(e):e.getBoundingClientRect())||null,k=e=>s.targetAt(e.clientX,e.clientY)||null;function E(e){if(!t)return;let o=M(e);if(!o){m(t.ring,!1);return}b(t.ring,"left",o.left-5+"px"),b(t.ring,"top",o.top-5+"px"),b(t.ring,"width",o.width+6+"px"),b(t.ring,"height",o.height+6+"px"),m(t.ring,!0)}function X(e,o){if(!e)return;let p=u&&(o||C())&&s.between(u,e)||e;u=p,E(p),t.more&&m(t.more,!0,"inline-flex"),!C()&&d?.(p)}function z(e){!c||e.button>0||(e.preventDefault(),i={x:e.clientX,y:e.clientY,from:k(e),moved:!1,shift:!!e.shiftKey})}function Y(e){if(!c)return;let o=k(e);if(i){let p=e.clientX-i.x,x=e.clientY-i.y;if(!i.moved&&p*p+x*x>v*v&&(i.moved=!0),i.moved){E(i.from&&o?s.between(i.from,o)||o:o||i.from);return}}E(o)}function q(e){if(!c||!i)return;let o=i;i=null;let p=e.clientX-o.x,x=e.clientY-o.y,G=o.moved||p*p+x*x>v*v,g=k(e),A=G&&o.from&&g?s.between(o.from,g)||g:g||o.from;A&&X(A,!!(o.shift||e.shiftKey))}function I(e){!c||e.key!=="Escape"||(O(),n?.())}function V(){if(c)return;c=!0,u=null,i=null,t=(r||U)({coarse:C()}),h=new AbortController;let{signal:e}=h,{overlay:o}=t;o.addEventListener("pointerdown",z,{signal:e}),o.addEventListener("pointermove",Y,{signal:e}),o.addEventListener("pointerup",q,{signal:e}),o.addEventListener("pointercancel",()=>{i=null},{signal:e}),t.whole.addEventListener("click",()=>{c&&f?.()},{signal:e}),t.more?.addEventListener("click",()=>{c&&u&&d?.(u)},{signal:e}),t.cancel.addEventListener("click",()=>{O(),n?.()},{signal:e}),a.addEventListener("keydown",I,{signal:e}),m(t.bar,!0,"flex"),t.whole.focus({preventScroll:!0})}function O(){if(!(!c&&!t)){if(c=!1,u=null,i=null,h?.abort(),h=null,t)for(let e of[t.overlay,t.ring,t.bar])e.remove();t=null}}function W(e){return!t||!e?!1:t.overlay.contains(e)||t.bar.contains(e)}return{open:V,close:O,contains:W,get picking(){return c}}}export{ee as createPicker,H as genericSurface};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as k}from"./c-N326R2JD.js";import{a as w}from"./c-I2SCCUEW.js";import{f as v}from"./c-C7SUMNMI.js";var j=new Set(["accepted","reverted","reconciled"]),T=Math.random().toString(36).slice(2,8),z=0,l=new Map,f=new Map,p=new Set,h=new Set,x=null,O=20,y=null,b=null,u=[];function E(){b??=import("./c-AZM34SPO.js").then(e=>{for(y=e;u.length;)y.keep(u.shift())},e=>{b=null,console.error("clayjs: the conflict recovery module could not be downloaded; conflicts stay in this tab only",e)})}v&&E();function S(e=""){return`${T}:${e}${++z}`}function m(){return x||=w({id:"live-sync-conflicts",isPending:()=>l.size>0||p.size>0}),x}function g(e){m().changed(),document.dispatchEvent(new CustomEvent("clay:sync-conflicts-changed",{detail:{open:[...l.keys()],added:[],removedIds:[],updatedIds:[],...e}}))}function $(e){if(e.kind==="structure"&&e.detail==="remote-wins")return!1;let t=e.recovery;return t?t.applied===!1&&t.unavailable==="hook-veto"?!1:t.localLost!==!1:!0}var C=["kind","id","label","field"];function I(e){if(!e||typeof e!="object")return null;let t={};for(let n of C){let o=e[n];typeof o=="string"&&o?t[n]=o:typeof o=="number"&&Number.isFinite(o)&&(t[n]=String(o))}return Object.keys(t).length?t:null}function F(e){let t=I(e);return t?(typeof e.open=="function"&&(t.open=e.open),t):null}function A(e,t){for(let n of[...h].reverse()){let o;try{o=n(e,t)}catch(r){console.error("clayjs: a conflict context resolver threw; the conflict stays generic",r);continue}let i=F(o);if(i)return i}return null}function L(e){if(typeof e!="function")throw new TypeError("clay.conflicts.registerContext needs a resolver function");return h.add(e),()=>h.delete(e)}function B(e,t){let n=S(),o=Object.assign(t[0],{id:n,applyId:e.id,source:e.source,ticket:e.ticket,rawReports:t,claimedBy:null});return o.context=A(o,e),l.set(n,o),e.ids.add(n),n}function D({source:e,seq:t=null,etag:n=null,domain:o,root:i,recoveryRoot:r=null}){let c=S("a");return f.set(c,{id:c,source:e,seq:t,etag:n,ticket:0,domain:o,root:i,recoveryRoot:r,ids:new Set}),p.add(c),m().changed(),c}function N(e){if(!e.every(n=>n.kind==="structure"&&n.detail==="insert-collision"&&n.recovery?.applied===!0&&!n.recovery.unavailable&&n.recovery.structure?.localAction==="inserted"&&n.recovery.structure.fragmentKind==="element"))return null;let t=e[0].recovery.subject;return t?.local?.length!==1||t.merged?.length!==1||t.live?.length!==1?null:{local:t.local[0],merged:t.merged[0],live:t.live[0]}}function P(e){let t=new Map(e.map(r=>[r,N(r)])),n=(r,c)=>r.length<c.length&&r.every((s,d)=>s===c[d]),o=(r,c)=>c.reduce((s,d)=>d==="content"?s?.content:s?.childNodes[d],r),i=new Map;for(let r of e){let c=t.get(r),s=r;if(c)for(let d of e){let a=t.get(d);a&&a.local.length<t.get(s).local.length&&n(a.local,c.local)&&n(a.merged,c.merged)&&(a.live.contains(c.live)||o(a.live,c.merged.slice(a.merged.length))===c.live)&&(s=d)}i.has(s)||i.set(s,[...s]),r!==s&&i.get(s).push(...r)}return[...i.values()]}function M(e,t){let n=t.map(i=>l.get(i)).filter(Boolean);if(!n.length)return;let o={apply:e,records:n.map(i=>({rec:i,context:I(i.context)}))};if(y)return y.keep(o);u.push(o),u.length>O&&u.shift(),E()}function Q(e,t,{ticket:n}){let o=f.get(e);if(!o)return[];o.ticket=n;let i=new Map;for(let c of t){if(!$(c))continue;let s=c.recovery?.key??Symbol();i.has(s)||i.set(s,[]),i.get(s).push(c)}let r=P([...i.values()]).map(c=>B(o,c));return r.length&&M(o,r),p.delete(e),r.length||f.delete(e),r.length?g({added:r.map(c=>l.get(c))}):m().changed(),r}function X(e,t,{ticket:n=0}={}){let o=f.get(e);if(!o)return[];o.ticket=n,p.delete(e);let i=B(o,[{kind:"apply-incomplete",detail:null,error:String(t)}]);return l.get(i).rawReports=[],M(o,[i]),g({added:[l.get(i)]}),[i]}var q={get size(){return l.size},list(){return[...l.values()]},get(e){return l.get(e)||null},acknowledge(e,{reason:t}={}){if(!Array.isArray(e))throw new TypeError("clay.conflicts.acknowledge needs an array of ids");if(!j.has(t))throw new TypeError(`clay.conflicts.acknowledge: unknown reason "${t}"`);let n=[];for(let o of e){let i=l.get(o);if(!i)continue;k(i),l.delete(o),n.push(o);let r=f.get(i.applyId);r&&(r.ids.delete(o),r.ids.size||f.delete(i.applyId))}return n.length&&(g({removedIds:n,reason:t}),import("./c-AZM34SPO.js").then(o=>o.dismiss(n),()=>{})),{removedIds:n,remainingIds:[...l.keys()]}},claim(e,{owner:t}){if(!t)throw new TypeError("clay.conflicts.claim needs an owner");for(let i of e){let r=l.get(i);if(r&&r.claimedBy&&r.claimedBy!==t)throw new Error(`conflict ${i} is already claimed by ${r.claimedBy}`)}let n=[];for(let i of e){let r=l.get(i);r&&!r.claimedBy&&(r.claimedBy=t,n.push(i))}n.length&&g({updatedIds:n,reason:"claimed"});let o=!1;return{release(){if(o)return;o=!0;let i=n.filter(r=>l.get(r)?.claimedBy===t);for(let r of i)l.get(r).claimedBy=null;i.length&&g({updatedIds:i,reason:"released"})}}},registerContext:L,contextFor:A,recoveryOf(e){let t=l.get(e);return t&&f.get(t.applyId)||null},hasPendingApply(){return p.size>0}};export{E as a,L as b,D as c,Q as d,X as e,q as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as J}from"./c-AI3H6ETU.js";import{d as F}from"./c-OH2FPYSY.js";import{c as z}from"./c-FSQXFG5T.js";import{d as _}from"./c-RETTCOWO.js";import"./c-VHNSBD2M.js";var{Decoration:tt,DecorationSet:et}=_,a=(e,o,n,t={},r=null)=>{let l=e.createElement(o);n&&(l.className=n);for(let[s,i]of Object.entries(t))i!=null&&i!==!1&&l.setAttribute(s,i===!0?"":String(i));return r!==null&&(l.textContent=r),l},ot=(e,o)=>a(e,"span","blockeditor-board-face",{"aria-hidden":"true"},([...String(o).trim()][0]??"?").toUpperCase());function I(e,o){let n=null;return e.state.doc.forEach((t,r)=>{t.attrs.id===o&&t.type===F.nodes.list_item&&t.attrs.kind==="check"&&(n={node:t,pos:r})}),n}function X(e,o,n,t){let r=I(e,o);r&&e.dispatch(J(e.state.tr.setNodeMarkup(r.pos,null,{...r.node.attrs,[n]:t||null})))}var L={person:'<circle cx="8" cy="5.4" r="2.3"/><path d="M3.6 13.2c.6-2.1 2.2-3.3 4.4-3.3s3.8 1.2 4.4 3.3"/>',calendar:'<rect x="2.5" y="3.5" width="11" height="10"/><path d="M2.5 6.8h11M5.5 2v2.4M10.5 2v2.4"/>',clock:'<circle cx="8" cy="8" r="5.5"/><path d="M8 4.8v3.4l2.3 1.4"/>',tick:'<path d="M3.5 8.3l3 3 6-6.2"/>',plus:'<path d="M8 3.5v9M3.5 8h9"/>',clear:'<path d="M4.8 4.8l6.4 6.4M11.2 4.8l-6.4 6.4"/>',"chevron-left":'<path d="M9.8 3.6L5.4 8l4.4 4.4"/>',"chevron-right":'<path d="M6.2 3.6L10.6 8l-4.4 4.4"/>'};function q(e,o){let n=e.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("viewBox","0 0 16 16"),n.setAttribute("width","14"),n.setAttribute("height","14"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.5"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.setAttribute("aria-hidden","true"),n.innerHTML=o,n}var Z=e=>String(e).padStart(2,"0"),B=/^\d{4}-\d{2}-\d{2}$/,S=(e=new Date)=>`${e.getFullYear()}-${Z(e.getMonth()+1)}-${Z(e.getDate())}`,nt=e=>{let o=new Date(`${e}T00:00:00Z`);return o.setUTCDate(o.getUTCDate()+1),o.toISOString().slice(0,10)};function rt(e,o){if(!e)return"No date";if(!B.test(e))return e;if(e===o)return"Today";if(e===nt(o))return"Tomorrow";let n=e.slice(0,4)===o.slice(0,4);return new Date(`${e}T00:00:00Z`).toLocaleDateString("en-US",{month:"short",day:"numeric",...n?{}:{year:"numeric"},timeZone:"UTC"})}function j(e,{name:o,paths:n,label:t,aria:r,filled:l,overdue:s=!1}){let i=a(e,"button","blockeditor-check-chip",{type:"button","data-check":o,"data-filled":String(l),"data-overdue":s?"true":null,"aria-expanded":"false","aria-label":r});return i.append(q(e,n),a(e,"span","blockeditor-check-chip-label",{},t)),i}var N=null;function G(e,o,{className:n,label:t,check:r,onKey:l=null}){let s=o.ownerDocument,i=s.defaultView;N&&N.close();for(let d of s.querySelectorAll(".blockeditor-check-popup"))d.remove();let y=e.dom.parentNode,h=["relative","absolute","fixed","sticky"].includes(i?.getComputedStyle?.(y)?.position??""),k=y&&h?y:s.body,f=a(s,"div",`blockeditor-check-popup ${n}`,{role:"dialog","aria-label":t,"data-check":r}),A=!1,E=()=>{let d=o.getBoundingClientRect(),c=k===s.body?{top:-(i?.scrollY??0),left:-(i?.scrollX??0)}:k.getBoundingClientRect(),p=f.getBoundingClientRect(),u=p.width||Math.min(264,(i?.innerWidth||292)-28),b=(i?.innerHeight??0)-d.bottom-2,g=p.height>0&&b<p.height;f.style.left=`${Math.round(d.right-u-c.left)}px`,f.style.top=`${Math.round((g?d.top-p.height-2:d.bottom+2)-c.top)}px`},C=d=>{if(!f.isConnected)return w();f.contains(d.target)||o.contains(d.target)||w()},w=({focusAnchor:d=!1}={})=>{if(A)return;A=!0,s.removeEventListener("mousedown",C,!0),i?.removeEventListener("resize",E),i?.removeEventListener("scroll",E,!0),N?.panel===f&&(N=null),f.remove(),o.setAttribute("aria-expanded","false");let c=o.dataset.fromKeys==="true";delete o.dataset.fromKeys,d&&c?e.focus():d&&o.focus()};return f.addEventListener("keydown",d=>{if(d.stopPropagation(),d.key==="Escape"){d.preventDefault(),w({focusAnchor:!0});return}l?.(d,f)}),k.append(f),o.setAttribute("aria-expanded","true"),N={panel:f,close:()=>w()},s.addEventListener("mousedown",C,!0),i?.addEventListener("resize",E),i?.addEventListener("scroll",E,!0),{panel:f,close:w,place:E}}function ct(e,o){let n=new Map;e.state.doc.forEach(t=>{if(t.type!==F.nodes.list_item||t.attrs.kind!=="check")return;let r=String(t.attrs.owner??"").trim();if(!r)return;let l=r.toLowerCase(),s=n.get(l)??{name:r,count:0};s.count+=1,n.set(l,s)});for(let t of o??[]){let r=String((typeof t=="string"?t:t?.name)??"").trim();r&&!n.has(r.toLowerCase())&&n.set(r.toLowerCase(),{name:r,count:0})}return[...n.values()].sort((t,r)=>t.name.localeCompare(r.name))}function at(e,o,n){let t=n.ownerDocument,r=I(e,o)?.node.attrs.owner||"",{panel:l,close:s,place:i}=G(e,n,{className:"blockeditor-check-owner",label:"Assignee",check:"owner-panel",onKey:(c,p)=>{if(c.key!=="ArrowDown"&&c.key!=="ArrowUp")return;c.preventDefault();let u=[...p.querySelectorAll("input, button:not([disabled])")],b=u.indexOf(t.activeElement),g=c.key==="ArrowDown"?1:-1;(b<0?g>0?u[0]:u[u.length-1]:u[(b+g+u.length)%u.length])?.focus()}}),y=a(t,"input","blockeditor-check-search",{type:"text",placeholder:"Find or type a name","aria-label":"Find or type a name"}),h=a(t,"div","blockeditor-check-people"),k=a(t,"button","blockeditor-check-person blockeditor-check-danger",{type:"button","data-check":"clear-owner"});k.append(q(t,L.clear),a(t,"span","blockeditor-check-person-name",{},"Remove assignee")),k.disabled=!r,k.addEventListener("click",()=>A(null)),l.append(y,a(t,"div","blockeditor-check-subhead",{},"People in this document"),h,a(t,"div","blockeditor-check-divider"),k);let f=[],A=c=>{s(),X(e,o,"owner",c)},E=(c,p)=>{let u=c.toLowerCase()===String(r).toLowerCase(),b=a(t,"button","blockeditor-check-person",{type:"button","data-check":"owner-option","data-name":c,"aria-pressed":String(u)});return b.append(ot(t,c),a(t,"span","blockeditor-check-person-name",{},c),a(t,"span","blockeditor-check-person-meta",{},`${p} ${p===1?"item":"items"}`)),u&&b.append(q(t,L.tick)),b.addEventListener("click",()=>A(c)),b},C=c=>{let p=a(t,"button","blockeditor-check-person",{type:"button","data-check":"owner-new","data-name":c}),u=a(t,"span","blockeditor-check-person-name",{},"Assign to ");return u.append(a(t,"strong",null,{},c)),p.append(q(t,L.plus),u,a(t,"span","blockeditor-check-person-meta",{},"New")),p.addEventListener("click",()=>A(c)),p},w=()=>{let c=y.value.trim(),p=c.toLowerCase(),u=ct(e,f),b=[];c&&!u.some(g=>g.name.toLowerCase()===p)&&b.push(C(c));for(let g of u)p&&!g.name.toLowerCase().includes(p)||b.push(E(g.name,g.count));h.replaceChildren(...b)};y.addEventListener("keydown",c=>{if(c.stopPropagation(),c.key==="Escape"){c.preventDefault(),s({focusAnchor:!0});return}c.key==="Enter"&&(c.preventDefault(),h.querySelector("button[data-check]")?.click())}),y.addEventListener("input",w),w(),i(),y.focus();let d=globalThis.clay?.people?.available;d&&Promise.resolve().then(()=>d()).then(c=>{!N||N.panel!==l||(f=Array.isArray(c)?c:[],w())}).catch(()=>{})}var st=["January","February","March","April","May","June","July","August","September","October","November","December"],$=(e,o,n)=>new Date(e,o,n),it=e=>e.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"}),lt=e=>e.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"}),W=e=>{if(!e||!B.test(e))return null;let[o,n,t]=e.split("-").map(Number);return $(o,n-1,t)};function dt(e,o,n){let t=n.ownerDocument,r=I(e,o)?.node.attrs.due||null,l=S(),s=new Date,i=$(s.getFullYear(),s.getMonth(),s.getDate()),y=W(r)??i,h=y.getFullYear(),k=y.getMonth(),{panel:f,close:A,place:E}=G(e,n,{className:"blockeditor-check-date",label:"Due date",check:"date-panel",onKey:(m,D)=>Q(m,D)}),C=m=>{A(),X(e,o,"due",m)},w=a(t,"div","blockeditor-check-quick"),d=(m,D)=>{let M=$(i.getFullYear(),i.getMonth(),i.getDate()+D),x=a(t,"button","blockeditor-check-quick-row",{type:"button","data-check":"date-quick","data-date":S(M)});return x.append(q(t,L.calendar),a(t,"span","blockeditor-check-quick-label",{},m),a(t,"span","blockeditor-check-quick-meta",{},it(M))),x.addEventListener("click",()=>C(S(M))),x};w.append(d("Today",0),d("Tomorrow",1),d("Next week",7));let c=a(t,"div","blockeditor-check-cal"),p=a(t,"div","blockeditor-check-cal-head"),u=a(t,"span","blockeditor-check-cal-month"),b=a(t,"span","blockeditor-check-cal-nav"),g=m=>{let D=$(h,k+m,1);h=D.getFullYear(),k=D.getMonth(),H()},U=a(t,"button","blockeditor-check-cal-btn",{type:"button","aria-label":"Previous month"}),O=a(t,"button","blockeditor-check-cal-btn",{type:"button","aria-label":"Next month"});U.append(q(t,L["chevron-left"])),O.append(q(t,L["chevron-right"])),U.addEventListener("click",()=>g(-1)),O.addEventListener("click",()=>g(1)),b.append(U,O),p.append(u,b);let Y=a(t,"div","blockeditor-check-cal-grid");c.append(p,Y);let H=()=>{u.replaceChildren(a(t,"span",null,{},`${st[k]} `),a(t,"span","blockeditor-check-cal-year",{},String(h)));let m=$(h,k,1),D=$(h,k+1,0).getDate(),M=Math.ceil((m.getDay()+D)/7)*7,x=["S","M","T","W","T","F","S"].map(v=>a(t,"span","blockeditor-check-cal-dow",{},v)),T=[];for(let v=0;v<M;v+=1){let P=$(h,k,1-m.getDay()+v),R=S(P),V=a(t,"button","blockeditor-check-cal-day",{type:"button","data-check":"date-day","data-date":R,"data-outside":String(P.getMonth()!==k),"data-today":String(R===l),"aria-pressed":String(R===r),"aria-label":lt(P)},String(P.getDate()));V.addEventListener("click",()=>C(R)),T.push(V)}Y.replaceChildren(...x,...T)},Q=(m,D)=>{let M=t.activeElement?.closest?.('[data-check="date-day"]');if(!M)return;if(m.key==="Enter"||m.key===" "){m.preventDefault(),M.click();return}let x={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7}[m.key];if(!x)return;m.preventDefault();let T=W(M.dataset.date),v=$(T.getFullYear(),T.getMonth(),T.getDate()+x);(v.getMonth()!==k||v.getFullYear()!==h)&&(h=v.getFullYear(),k=v.getMonth(),H()),D.querySelector(`[data-check="date-day"][data-date="${S(v)}"]`)?.focus()},K=a(t,"button","blockeditor-check-quick-row blockeditor-check-danger",{type:"button","data-check":"clear-date"});K.append(q(t,L.clear),a(t,"span","blockeditor-check-quick-label",{},"Clear date")),K.disabled=!r,K.addEventListener("click",()=>C(null)),f.append(w,c,a(t,"div","blockeditor-check-divider"),K),H(),E(),(Y.querySelector('[data-check="date-day"][aria-pressed="true"]')??Y.querySelector('[data-check="date-day"][data-today="true"]'))?.focus()}function ut(e,o){let n=e.dom.ownerDocument,t=n.createElement("span");t.className="blockeditor-check-controls",t.contentEditable="false",t.dataset.empty=String(!o.attrs.owner&&!o.attrs.due);let r=S(),l=o.attrs.owner||"Unassigned",s=j(n,{name:"owner",paths:L.person,label:l,aria:`Assignee: ${l}`,filled:!!o.attrs.owner}),i=rt(o.attrs.due,r),y=!!o.attrs.due&&!o.attrs.checked&&B.test(o.attrs.due)&&o.attrs.due<r,h=j(n,{name:"date",paths:y?L.clock:L.calendar,label:i,aria:`Due date: ${i}`,filled:!!o.attrs.due,overdue:y});return s.addEventListener("click",()=>at(e,o.attrs.id,s)),h.addEventListener("click",()=>dt(e,o.attrs.id,h)),t.append(s,h),t}function pt(e,o){let n=e.state.selection.$head;if(n.depth!==1||n.parent.type!==F.nodes.list_item||n.parent.attrs.kind!=="check")return!1;let t=n.parent.attrs.id,l=[...e.dom.querySelectorAll(".blockeditor-check-controls")].find(s=>s.dataset.item===t)?.querySelector(`[data-check="${o}"]`);return l?(l.dataset.fromKeys="true",l.click(),!0):!1}function ht(e){let o=[],n=S();return e.doc.forEach((t,r)=>{t.type!==F.nodes.list_item||t.attrs.kind!=="check"||o.push(tt.widget(r+t.nodeSize-1,l=>{let s=ut(l,t);return s.dataset.item=t.attrs.id,s},{key:`${t.attrs.id}:${t.attrs.owner}:${t.attrs.due}:${t.attrs.checked}:${n}`,side:-1,stopEvent:l=>!!l.target.closest?.(".blockeditor-check-chip, .blockeditor-check-popup"),ignoreSelection:!0}))}),et.create(e.doc,o)}function kt(e){let o=S(),n=()=>{e.isDestroyed||S()===o||(o=S(),e.dispatch(e.state.tr.setMeta("addToHistory",!1)))},t=e.dom.ownerDocument.defaultView,r=t.setInterval(n,6e4);return t.document.addEventListener("visibilitychange",n),()=>{t.clearInterval(r),t.document.removeEventListener("visibilitychange",n)}}function gt({view:e=null}={}){let o=e?z(e,{decorations:ht,focusControl:pt}):()=>{},n=e?kt(e):()=>{};return e&&!e.isDestroyed&&e.dispatch(e.state.tr.setMeta("addToHistory",!1)),{id:"checklist",dispose(){o(),n()}}}export{gt as createFeature,ht as decorations,pt as focusControl};
|
|
1
|
+
import{C as J}from"./c-3Y234AUB.js";import{d as F}from"./c-OH2FPYSY.js";import{c as z}from"./c-FSQXFG5T.js";import{d as _}from"./c-RETTCOWO.js";import"./c-VHNSBD2M.js";var{Decoration:tt,DecorationSet:et}=_,a=(e,o,n,t={},r=null)=>{let l=e.createElement(o);n&&(l.className=n);for(let[s,i]of Object.entries(t))i!=null&&i!==!1&&l.setAttribute(s,i===!0?"":String(i));return r!==null&&(l.textContent=r),l},ot=(e,o)=>a(e,"span","blockeditor-board-face",{"aria-hidden":"true"},([...String(o).trim()][0]??"?").toUpperCase());function I(e,o){let n=null;return e.state.doc.forEach((t,r)=>{t.attrs.id===o&&t.type===F.nodes.list_item&&t.attrs.kind==="check"&&(n={node:t,pos:r})}),n}function X(e,o,n,t){let r=I(e,o);r&&e.dispatch(J(e.state.tr.setNodeMarkup(r.pos,null,{...r.node.attrs,[n]:t||null})))}var L={person:'<circle cx="8" cy="5.4" r="2.3"/><path d="M3.6 13.2c.6-2.1 2.2-3.3 4.4-3.3s3.8 1.2 4.4 3.3"/>',calendar:'<rect x="2.5" y="3.5" width="11" height="10"/><path d="M2.5 6.8h11M5.5 2v2.4M10.5 2v2.4"/>',clock:'<circle cx="8" cy="8" r="5.5"/><path d="M8 4.8v3.4l2.3 1.4"/>',tick:'<path d="M3.5 8.3l3 3 6-6.2"/>',plus:'<path d="M8 3.5v9M3.5 8h9"/>',clear:'<path d="M4.8 4.8l6.4 6.4M11.2 4.8l-6.4 6.4"/>',"chevron-left":'<path d="M9.8 3.6L5.4 8l4.4 4.4"/>',"chevron-right":'<path d="M6.2 3.6L10.6 8l-4.4 4.4"/>'};function q(e,o){let n=e.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("viewBox","0 0 16 16"),n.setAttribute("width","14"),n.setAttribute("height","14"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.5"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.setAttribute("aria-hidden","true"),n.innerHTML=o,n}var Z=e=>String(e).padStart(2,"0"),B=/^\d{4}-\d{2}-\d{2}$/,S=(e=new Date)=>`${e.getFullYear()}-${Z(e.getMonth()+1)}-${Z(e.getDate())}`,nt=e=>{let o=new Date(`${e}T00:00:00Z`);return o.setUTCDate(o.getUTCDate()+1),o.toISOString().slice(0,10)};function rt(e,o){if(!e)return"No date";if(!B.test(e))return e;if(e===o)return"Today";if(e===nt(o))return"Tomorrow";let n=e.slice(0,4)===o.slice(0,4);return new Date(`${e}T00:00:00Z`).toLocaleDateString("en-US",{month:"short",day:"numeric",...n?{}:{year:"numeric"},timeZone:"UTC"})}function j(e,{name:o,paths:n,label:t,aria:r,filled:l,overdue:s=!1}){let i=a(e,"button","blockeditor-check-chip",{type:"button","data-check":o,"data-filled":String(l),"data-overdue":s?"true":null,"aria-expanded":"false","aria-label":r});return i.append(q(e,n),a(e,"span","blockeditor-check-chip-label",{},t)),i}var N=null;function G(e,o,{className:n,label:t,check:r,onKey:l=null}){let s=o.ownerDocument,i=s.defaultView;N&&N.close();for(let d of s.querySelectorAll(".blockeditor-check-popup"))d.remove();let y=e.dom.parentNode,h=["relative","absolute","fixed","sticky"].includes(i?.getComputedStyle?.(y)?.position??""),k=y&&h?y:s.body,f=a(s,"div",`blockeditor-check-popup ${n}`,{role:"dialog","aria-label":t,"data-check":r}),A=!1,E=()=>{let d=o.getBoundingClientRect(),c=k===s.body?{top:-(i?.scrollY??0),left:-(i?.scrollX??0)}:k.getBoundingClientRect(),p=f.getBoundingClientRect(),u=p.width||Math.min(264,(i?.innerWidth||292)-28),b=(i?.innerHeight??0)-d.bottom-2,g=p.height>0&&b<p.height;f.style.left=`${Math.round(d.right-u-c.left)}px`,f.style.top=`${Math.round((g?d.top-p.height-2:d.bottom+2)-c.top)}px`},C=d=>{if(!f.isConnected)return w();f.contains(d.target)||o.contains(d.target)||w()},w=({focusAnchor:d=!1}={})=>{if(A)return;A=!0,s.removeEventListener("mousedown",C,!0),i?.removeEventListener("resize",E),i?.removeEventListener("scroll",E,!0),N?.panel===f&&(N=null),f.remove(),o.setAttribute("aria-expanded","false");let c=o.dataset.fromKeys==="true";delete o.dataset.fromKeys,d&&c?e.focus():d&&o.focus()};return f.addEventListener("keydown",d=>{if(d.stopPropagation(),d.key==="Escape"){d.preventDefault(),w({focusAnchor:!0});return}l?.(d,f)}),k.append(f),o.setAttribute("aria-expanded","true"),N={panel:f,close:()=>w()},s.addEventListener("mousedown",C,!0),i?.addEventListener("resize",E),i?.addEventListener("scroll",E,!0),{panel:f,close:w,place:E}}function ct(e,o){let n=new Map;e.state.doc.forEach(t=>{if(t.type!==F.nodes.list_item||t.attrs.kind!=="check")return;let r=String(t.attrs.owner??"").trim();if(!r)return;let l=r.toLowerCase(),s=n.get(l)??{name:r,count:0};s.count+=1,n.set(l,s)});for(let t of o??[]){let r=String((typeof t=="string"?t:t?.name)??"").trim();r&&!n.has(r.toLowerCase())&&n.set(r.toLowerCase(),{name:r,count:0})}return[...n.values()].sort((t,r)=>t.name.localeCompare(r.name))}function at(e,o,n){let t=n.ownerDocument,r=I(e,o)?.node.attrs.owner||"",{panel:l,close:s,place:i}=G(e,n,{className:"blockeditor-check-owner",label:"Assignee",check:"owner-panel",onKey:(c,p)=>{if(c.key!=="ArrowDown"&&c.key!=="ArrowUp")return;c.preventDefault();let u=[...p.querySelectorAll("input, button:not([disabled])")],b=u.indexOf(t.activeElement),g=c.key==="ArrowDown"?1:-1;(b<0?g>0?u[0]:u[u.length-1]:u[(b+g+u.length)%u.length])?.focus()}}),y=a(t,"input","blockeditor-check-search",{type:"text",placeholder:"Find or type a name","aria-label":"Find or type a name"}),h=a(t,"div","blockeditor-check-people"),k=a(t,"button","blockeditor-check-person blockeditor-check-danger",{type:"button","data-check":"clear-owner"});k.append(q(t,L.clear),a(t,"span","blockeditor-check-person-name",{},"Remove assignee")),k.disabled=!r,k.addEventListener("click",()=>A(null)),l.append(y,a(t,"div","blockeditor-check-subhead",{},"People in this document"),h,a(t,"div","blockeditor-check-divider"),k);let f=[],A=c=>{s(),X(e,o,"owner",c)},E=(c,p)=>{let u=c.toLowerCase()===String(r).toLowerCase(),b=a(t,"button","blockeditor-check-person",{type:"button","data-check":"owner-option","data-name":c,"aria-pressed":String(u)});return b.append(ot(t,c),a(t,"span","blockeditor-check-person-name",{},c),a(t,"span","blockeditor-check-person-meta",{},`${p} ${p===1?"item":"items"}`)),u&&b.append(q(t,L.tick)),b.addEventListener("click",()=>A(c)),b},C=c=>{let p=a(t,"button","blockeditor-check-person",{type:"button","data-check":"owner-new","data-name":c}),u=a(t,"span","blockeditor-check-person-name",{},"Assign to ");return u.append(a(t,"strong",null,{},c)),p.append(q(t,L.plus),u,a(t,"span","blockeditor-check-person-meta",{},"New")),p.addEventListener("click",()=>A(c)),p},w=()=>{let c=y.value.trim(),p=c.toLowerCase(),u=ct(e,f),b=[];c&&!u.some(g=>g.name.toLowerCase()===p)&&b.push(C(c));for(let g of u)p&&!g.name.toLowerCase().includes(p)||b.push(E(g.name,g.count));h.replaceChildren(...b)};y.addEventListener("keydown",c=>{if(c.stopPropagation(),c.key==="Escape"){c.preventDefault(),s({focusAnchor:!0});return}c.key==="Enter"&&(c.preventDefault(),h.querySelector("button[data-check]")?.click())}),y.addEventListener("input",w),w(),i(),y.focus();let d=globalThis.clay?.people?.available;d&&Promise.resolve().then(()=>d()).then(c=>{!N||N.panel!==l||(f=Array.isArray(c)?c:[],w())}).catch(()=>{})}var st=["January","February","March","April","May","June","July","August","September","October","November","December"],$=(e,o,n)=>new Date(e,o,n),it=e=>e.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"}),lt=e=>e.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"}),W=e=>{if(!e||!B.test(e))return null;let[o,n,t]=e.split("-").map(Number);return $(o,n-1,t)};function dt(e,o,n){let t=n.ownerDocument,r=I(e,o)?.node.attrs.due||null,l=S(),s=new Date,i=$(s.getFullYear(),s.getMonth(),s.getDate()),y=W(r)??i,h=y.getFullYear(),k=y.getMonth(),{panel:f,close:A,place:E}=G(e,n,{className:"blockeditor-check-date",label:"Due date",check:"date-panel",onKey:(m,D)=>Q(m,D)}),C=m=>{A(),X(e,o,"due",m)},w=a(t,"div","blockeditor-check-quick"),d=(m,D)=>{let M=$(i.getFullYear(),i.getMonth(),i.getDate()+D),x=a(t,"button","blockeditor-check-quick-row",{type:"button","data-check":"date-quick","data-date":S(M)});return x.append(q(t,L.calendar),a(t,"span","blockeditor-check-quick-label",{},m),a(t,"span","blockeditor-check-quick-meta",{},it(M))),x.addEventListener("click",()=>C(S(M))),x};w.append(d("Today",0),d("Tomorrow",1),d("Next week",7));let c=a(t,"div","blockeditor-check-cal"),p=a(t,"div","blockeditor-check-cal-head"),u=a(t,"span","blockeditor-check-cal-month"),b=a(t,"span","blockeditor-check-cal-nav"),g=m=>{let D=$(h,k+m,1);h=D.getFullYear(),k=D.getMonth(),H()},U=a(t,"button","blockeditor-check-cal-btn",{type:"button","aria-label":"Previous month"}),O=a(t,"button","blockeditor-check-cal-btn",{type:"button","aria-label":"Next month"});U.append(q(t,L["chevron-left"])),O.append(q(t,L["chevron-right"])),U.addEventListener("click",()=>g(-1)),O.addEventListener("click",()=>g(1)),b.append(U,O),p.append(u,b);let Y=a(t,"div","blockeditor-check-cal-grid");c.append(p,Y);let H=()=>{u.replaceChildren(a(t,"span",null,{},`${st[k]} `),a(t,"span","blockeditor-check-cal-year",{},String(h)));let m=$(h,k,1),D=$(h,k+1,0).getDate(),M=Math.ceil((m.getDay()+D)/7)*7,x=["S","M","T","W","T","F","S"].map(v=>a(t,"span","blockeditor-check-cal-dow",{},v)),T=[];for(let v=0;v<M;v+=1){let P=$(h,k,1-m.getDay()+v),R=S(P),V=a(t,"button","blockeditor-check-cal-day",{type:"button","data-check":"date-day","data-date":R,"data-outside":String(P.getMonth()!==k),"data-today":String(R===l),"aria-pressed":String(R===r),"aria-label":lt(P)},String(P.getDate()));V.addEventListener("click",()=>C(R)),T.push(V)}Y.replaceChildren(...x,...T)},Q=(m,D)=>{let M=t.activeElement?.closest?.('[data-check="date-day"]');if(!M)return;if(m.key==="Enter"||m.key===" "){m.preventDefault(),M.click();return}let x={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7}[m.key];if(!x)return;m.preventDefault();let T=W(M.dataset.date),v=$(T.getFullYear(),T.getMonth(),T.getDate()+x);(v.getMonth()!==k||v.getFullYear()!==h)&&(h=v.getFullYear(),k=v.getMonth(),H()),D.querySelector(`[data-check="date-day"][data-date="${S(v)}"]`)?.focus()},K=a(t,"button","blockeditor-check-quick-row blockeditor-check-danger",{type:"button","data-check":"clear-date"});K.append(q(t,L.clear),a(t,"span","blockeditor-check-quick-label",{},"Clear date")),K.disabled=!r,K.addEventListener("click",()=>C(null)),f.append(w,c,a(t,"div","blockeditor-check-divider"),K),H(),E(),(Y.querySelector('[data-check="date-day"][aria-pressed="true"]')??Y.querySelector('[data-check="date-day"][data-today="true"]'))?.focus()}function ut(e,o){let n=e.dom.ownerDocument,t=n.createElement("span");t.className="blockeditor-check-controls",t.contentEditable="false",t.dataset.empty=String(!o.attrs.owner&&!o.attrs.due);let r=S(),l=o.attrs.owner||"Unassigned",s=j(n,{name:"owner",paths:L.person,label:l,aria:`Assignee: ${l}`,filled:!!o.attrs.owner}),i=rt(o.attrs.due,r),y=!!o.attrs.due&&!o.attrs.checked&&B.test(o.attrs.due)&&o.attrs.due<r,h=j(n,{name:"date",paths:y?L.clock:L.calendar,label:i,aria:`Due date: ${i}`,filled:!!o.attrs.due,overdue:y});return s.addEventListener("click",()=>at(e,o.attrs.id,s)),h.addEventListener("click",()=>dt(e,o.attrs.id,h)),t.append(s,h),t}function pt(e,o){let n=e.state.selection.$head;if(n.depth!==1||n.parent.type!==F.nodes.list_item||n.parent.attrs.kind!=="check")return!1;let t=n.parent.attrs.id,l=[...e.dom.querySelectorAll(".blockeditor-check-controls")].find(s=>s.dataset.item===t)?.querySelector(`[data-check="${o}"]`);return l?(l.dataset.fromKeys="true",l.click(),!0):!1}function ht(e){let o=[],n=S();return e.doc.forEach((t,r)=>{t.type!==F.nodes.list_item||t.attrs.kind!=="check"||o.push(tt.widget(r+t.nodeSize-1,l=>{let s=ut(l,t);return s.dataset.item=t.attrs.id,s},{key:`${t.attrs.id}:${t.attrs.owner}:${t.attrs.due}:${t.attrs.checked}:${n}`,side:-1,stopEvent:l=>!!l.target.closest?.(".blockeditor-check-chip, .blockeditor-check-popup"),ignoreSelection:!0}))}),et.create(e.doc,o)}function kt(e){let o=S(),n=()=>{e.isDestroyed||S()===o||(o=S(),e.dispatch(e.state.tr.setMeta("addToHistory",!1)))},t=e.dom.ownerDocument.defaultView,r=t.setInterval(n,6e4);return t.document.addEventListener("visibilitychange",n),()=>{t.clearInterval(r),t.document.removeEventListener("visibilitychange",n)}}function gt({view:e=null}={}){let o=e?z(e,{decorations:ht,focusControl:pt}):()=>{},n=e?kt(e):()=>{};return e&&!e.isDestroyed&&e.dispatch(e.state.tr.setMeta("addToHistory",!1)),{id:"checklist",dispose(){o(),n()}}}export{gt as createFeature,ht as decorations,pt as focusControl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as H,D as X,d as M,g as L,h as O,j as D,m as I,n as R,o as k,p as C,q as A,r as N,t as $}from"./c-
|
|
1
|
+
import{C as H,D as X,d as M,g as L,h as O,j as D,m as I,n as R,o as k,p as C,q as A,r as N,t as $}from"./c-3Y234AUB.js";import{d as B}from"./c-OH2FPYSY.js";var _=new WeakMap;function g(s){let t=_.get(s);return t||_.set(s,t=O(s)),t}var F=B.nodes,w=s=>s.type===F.list_item,S=s=>s.type===F.toggle,y=s=>s.attrs.parent??null;function J(s,t,e){if(e<0)return[null];let n=[],i=s[e].node;S(i)&&i.attrs.open&&!s[e].hidden&&n.unshift(i.attrs.id);for(let r=y(i);r!==null&&!n.includes(r);){let c=s[t.get(r)];if(!c)break;n.unshift(r),r=y(c.node)}let o=[null];for(let r of n){let c=s[t.get(r)];if(!c.node.attrs.open||c.hidden)break;o.push(r)}return o}function Y(s,t,e,n){let i=y(s[t].node),o=w(s[t].node)?n.indent-s[t].node.attrs.indent:0;return r=>r.i<t||r.i>e||y(r.node)!==i?null:w(r.node)?{parent:n.parent,indent:r.node.attrs.indent+o}:{parent:n.parent}}function Q(s,t){let e=null;s.doc.forEach((n,i)=>{n.attrs.id===t&&S(n)&&(e={n,off:i})}),e&&!e.n.attrs.open&&s.setNodeMarkup(e.off,null,{...e.n.attrs,open:!0})}function P(s,t,e,n,i,o=null){let r=Y(t,e,n,i),c=t[e].at,d=t[n].end,h=o??new C(s.doc.resolve(c),s.doc.resolve(d)),a;if(i.at===c||i.at===d){a=s.tr;for(let l=e;l<=n;l++){let p=r(t[l]);p&&a.setNodeMarkup(t[l].at,null,{...t[l].node.attrs,...p})}a.setSelection(h.map(a.doc,a.mapping)),a.setMeta(L,A(t,e,n,i.at,r))}else a=N(s,t,e,n,i.at,r,h);if(i.open){Q(a,i.open);let l=a.getMeta(L);l&&a.setMeta(L,{...l,attrs:{...l.attrs,[i.open]:{open:!0}}})}return a}function K(s,t,e,n,i){if(i.parent!=null&&t.slice(e,n+1).some(a=>a.node.attrs.id===i.parent))return!1;let o=t[n].end-t[e].at,r=Y(t,e,n,i);for(let a=e;a<=n;a++)if(w(t[a].node)&&(r(t[a])?.indent??t[a].node.attrs.indent)>$)return!1;let c=P(s,t,e,n,i),h=i.at===t[e].at||i.at===t[n].end?t[e].at:i.at>t[e].at?i.at-o:i.at;return D(c.doc,s.doc).every(a=>a.at>=h&&a.at<h+o)}function U(s,t,e,n,i){let o=new Map;t.forEach(l=>{S(l.node)&&l.node.attrs.id&&o.set(l.node.attrs.id,l.i)});let r=i<0?s.doc.content.size:t[i].at;if(r>t[e].at&&r<t[n].end)return[];let c=(i<0?t.length:i)-1,d=J(t,o,c),h=d.indexOf(i<0?null:y(t[i].node)),a=[];for(let l of d.slice(Math.max(0,h))){let p=l===null?0:t[o.get(l)].depth+1,E=c>=0&&w(t[c].node)&&y(t[c].node)===l?t[c].node:null,f=w(t[e].node)&&E?E.attrs.indent+1:0;for(let u=0;u<=f;u++){let m={at:r,parent:l,indent:u,depth:p+(w(t[e].node)?u:0)};K(s,t,e,n,m)&&a.push(m)}}return a}function q(s,t,e,n,i){let o=t[i];if(!o||!S(o.node)||o.node.attrs.open||o.hidden||i>=e&&i<=n||o.at>t[e].at&&o.at<t[n].end)return null;let r=o.node.attrs.id,c={at:t[o.subEnd].end,parent:r,indent:0,depth:o.depth+1,open:r};return K(s,t,e,n,c)?c:null}function z(s,t){let e=null;for(let n of s)(!e||Math.abs(n.depth-t)<Math.abs(e.depth-t))&&(e=n);return e}var Z=4,tt=250,V=8,b=56,W=18;function et(s){for(let t=s.parentElement;t;t=t.parentElement){let e=getComputedStyle(t).overflowY;if((e==="auto"||e==="scroll")&&t.scrollHeight>t.clientHeight)return t}return s.ownerDocument.scrollingElement}var j=new WeakMap;function nt(s,t){let e=j.get(s);if(!e){e=[];for(let n of s){if(n.hidden)continue;let i=t.nodeDOM(n.at);i?.getBoundingClientRect&&e.push({i:n.i,dom:i})}j.set(s,e)}return e}function it(s,t){let e=0,n=s.length;for(;e<n;){let i=e+n>>1,o=s[i].dom.getBoundingClientRect();t<o.top+o.height/2?n=i:e=i+1}return e<s.length?e:-1}var G=class{constructor(t,e,{index:n,onClick:i}){this.view=t,this.grip=e,this.index=n,this.onClick=i,this.shell=t.dom.parentElement,this.line=document.createElement("div"),this.line.className="blockeditor-drop",this.line.hidden=!0,this.line.setAttribute("aria-hidden","true"),this.shell.append(this.line),this.state=null,this.onMove=o=>this.move(o),this.onUp=o=>this.end(o),this.onCancel=o=>{o.pointerId===this.state?.pointer&&this.cancel()},this.onKey=o=>{o.key==="Escape"&&this.state?.active&&(o.preventDefault(),o.stopPropagation(),this.cancel())},this.onOther=o=>{this.state&&o.pointerId!==this.state.pointer&&this.cancel()},this.onBlur=()=>this.cancel(),this.onScroll=()=>{this.state&&!this.state.active&&this.stop()},e.addEventListener("pointerdown",o=>this.start(o))}start(t){if(t.button!==0||this.state)return;let e=this.view.state,n=g(e.doc),i=e.selection,o=Math.min(this.index(),n.length-1),r=i instanceof C&&n[o].at>=i.from&&n[o].end<=i.to,{lo:c,hi:d}=r?i.span(e.doc):I(n,o,o);if(this.state={index:o,span:R(n,c,d),touch:t.pointerType==="touch",pointer:t.pointerId,x0:t.clientX,y0:t.clientY,x:t.clientX,y:t.clientY,hold:0,active:!1,raf:0,gap:void 0,targets:[],target:null},this.grip.setPointerCapture?.(t.pointerId),this.grip.addEventListener("pointermove",this.onMove),this.grip.addEventListener("pointerup",this.onUp),this.grip.addEventListener("pointercancel",this.onCancel),this.grip.addEventListener("lostpointercapture",this.onCancel),this.state.touch){let h=this.state;h.hold=setTimeout(()=>this.held(h),tt),window.addEventListener("pointerdown",this.onOther,!0),window.addEventListener("blur",this.onBlur),window.addEventListener("scroll",this.onScroll,!0)}t.preventDefault()}held(t){if(!(this.state!==t||t.active)){if(t.hold=0,Math.hypot(t.x-t.x0,t.y-t.y0)>V||!this.view.editable)return this.stop();this.begin()}}move(t){let e=this.state;if(!(!e||t.pointerId!==e.pointer)){if(e.x=t.clientX,e.y=t.clientY,e.touch&&!this.view.editable)return e.active?this.cancel():this.stop();if(!e.active){let n=Math.hypot(e.x-e.x0,e.y-e.y0);if(e.touch){n>V&&this.stop();return}if(n<=Z)return;this.begin()}this.track()}}begin(){let t=this.state;if(!t||t.active)return;let e=this.view.state,n=g(e.doc),i=k(n,t.span);if(!i)return this.cancel();t.active=!0,this.view.dispatch(e.tr.setSelection(X(e.doc,i.lo,i.hi))),this.shell.classList.add("is-dragging");let o=this.shell.appendChild(document.createElement("div"));o.style.cssText="position:absolute;visibility:hidden;width:var(--blockeditor-indent)",this.indentPx=o.getBoundingClientRect().width||27,o.remove(),this.scroller=et(this.view.dom),window.addEventListener("keydown",this.onKey,!0),this.loop(),this.track()}track(){let t=this.state,e=this.view,n=e.state;if(!t)return;let i=g(n.doc),o=k(i,t.span);if(!o)return this.cancel();let{lo:r,hi:c}=o,d=nt(i,e),h=it(d,t.y),a=-1,l=null,p=null,E=h<0?d.length:h+1;for(let x=Math.max(0,E-2);x<E;x++){let v=d[x].dom.getBoundingClientRect();t.y>=v.top+v.height/4&&t.y<=v.bottom-v.height/4&&(p={i:d[x].i,bottom:v.bottom}),l=v.bottom+2}h>=0&&(a=d[h].i,l=d[h].dom.getBoundingClientRect().top-2);let f=r<0?null:p&&q(n,i,r,c,p.i),u=f?`summary:${p.i}`:a;(u!==t.gap||n.doc!==t.doc)&&(t.gap=u,t.doc=n.doc,t.targets=r<0?[]:f?[f]:U(n,i,r,c,a)),f&&(l=p.bottom+2);let m=e.dom.getBoundingClientRect().left;t.target=z(t.targets,(t.x-m)/this.indentPx);let T=this.shell.getBoundingClientRect();if(!t.target||l===null){this.line.hidden=!0,this.shell.dataset.drop="none";return}this.shell.dataset.drop="ok",this.line.hidden=!1,this.line.style.setProperty("--blockeditor-drop-y",`${l-T.top}px`),this.line.style.setProperty("--blockeditor-drop-x",`${m-T.left+t.target.depth*this.indentPx}px`),this.line.style.setProperty("--blockeditor-drop-w",`${e.dom.getBoundingClientRect().right-m-t.target.depth*this.indentPx}px`)}loop(){let t=()=>{let e=this.state;if(!e?.active)return;if(e.touch&&!this.view.editable)return this.cancel();let n=this.scroller,i=n===n.ownerDocument.scrollingElement?{top:0,bottom:window.innerHeight}:n.getBoundingClientRect(),o=0;e.y<i.top+b?o=-W*Math.min(1,(i.top+b-e.y)/b):e.y>i.bottom-b&&(o=W*Math.min(1,(e.y-(i.bottom-b))/b)),o&&(n.scrollTop+=o,this.track()),e.raf=requestAnimationFrame(t)};this.state.raf=requestAnimationFrame(t)}end(t){let e=this.state;if(!e||t.pointerId!==e.pointer)return;if(!e.active){if(this.stop(),t.type==="pointerup"){let l=g(this.view.state.doc),p=k(l,e.span);p&&this.onClick(p.lo)}return}if(this.track(),this.state!==e)return;let n=e.target,i=this.view.state,o=g(i.doc),r=k(o,e.span);if(this.stop(),!n||!r)return;let{lo:c,hi:d}=r;if(!n.open&&(n.at===o[c].at||n.at===o[d].end)&&n.parent===(o[c].node.attrs.parent??null)&&(o[c].node.type.name!=="list_item"||n.indent===o[c].node.attrs.indent))return;if(this.view.dispatch(H(P(i,o,c,d,n)).scrollIntoView()),this.view.state.doc===i.doc)return M(this.view,"Move cancelled");let a=d-c+1;M(this.view,`Moved ${a} ${a===1?"block":"blocks"}`),this.view.focus()}cancel(){this.stop(),M(this.view,"Move cancelled")}stop(){let t=this.state;t&&(this.state=null,clearTimeout(t.hold),cancelAnimationFrame(t.raf),this.grip.removeEventListener("pointermove",this.onMove),this.grip.removeEventListener("pointerup",this.onUp),this.grip.removeEventListener("pointercancel",this.onCancel),this.grip.removeEventListener("lostpointercapture",this.onCancel),this.grip.releasePointerCapture?.(t.pointer),window.removeEventListener("pointerdown",this.onOther,!0),window.removeEventListener("blur",this.onBlur),window.removeEventListener("scroll",this.onScroll,!0),window.removeEventListener("keydown",this.onKey,!0),this.shell.classList.remove("is-dragging"),delete this.shell.dataset.drop,this.line.hidden=!0)}destroy(){this.stop(),this.line.remove()}};export{g as a,et as b,G as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as k,B as P,C as g,D as T,E as y,F as A,G as E,H as z,I as x,J as O,K as tt,L as et,M as ot,N as B,O as D,R as it,S as K,c as M,d as L,e as f,n as J,s as $,w as v,x as Q,z as Z}from"./c-
|
|
1
|
+
import{A as k,B as P,C as g,D as T,E as y,F as A,G as E,H as z,I as x,J as O,K as tt,L as et,M as ot,N as B,O as D,R as it,S as K,c as M,d as L,e as f,n as J,s as $,w as v,x as Q,z as Z}from"./c-LUBZU4AZ.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-T7LOTEWO.js";import"./c-A3OKSYRI.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{C as Y,d as N}from"./c-3Y234AUB.js";import{N as G,d as V,z as X}from"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import"./c-RETTCOWO.js";import"./c-JC4RZW4E.js";import"./c-57XDY6HC.js";import{a as j}from"./c-I2SCCUEW.js";import"./c-VHNSBD2M.js";var nt=`
|
|
2
2
|
.blockeditor-editor .blockeditor-table { position: relative; }
|
|
3
3
|
.blockeditor-table td { position: relative; }
|
|
4
4
|
.blockeditor-table th { position: relative; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=o=>!!o&&!o.bevel,f=(o,r,n)=>`color-mix(in srgb, ${o}, ${r} ${n}%)`,e=(o,r)=>r?[`${o}:${r}`]:[];function b({hover:o=!1,active:r=!1,focus:n=!1,disabled:c=!1}={}){let u=["base"];return!c&&o&&u.push("hover"),!c&&r&&u.push("active"),n&&u.push("focus"),c&&u.push("disabled"),u}function a(o,r){return o.background&&o.background!==o.surface?r>8?f(o.background,o.text||"currentColor",6):o.background:o.surface?f(o.surface,o.text||"currentColor",r):o.background}function p(o,r,n){let c=[],u={primary:["accent","accentText"],danger:["danger","dangerText"]}[r];if(n==="base"&&c.push(...e("font-family",o.font),...e("border-radius",o.radius)),n==="base"&&o.buttonHeight&&c.push("height:auto","block-size:auto",`min-height:${o.buttonHeight}`),u){let i=o[u[0]],s=o[u[1]];n==="base"&&c.push(...e("background",i),...e("border-color",i),...e("color",s)),n==="hover"&&i&&s&&c.push(`background:${f(i,s,12)}`),n==="active"&&i&&c.push(`border-color:${i}`,...s?[`background:${f(i,s,20)}`]:[]),n==="disabled"&&i&&c.push("opacity:.55")}else r==="quiet"?(n==="base"&&c.push(...e("color",o.text)),n==="hover"&&c.push(...e("background",a(o,7))),n==="active"&&c.push(...e("background",a(o,12))),n==="disabled"&&c.push(...e("color",o.mutedText))):(n==="base"&&c.push(...e("background",o.surface),...e("color",o.text),...e("border-color",o.border)),n==="hover"&&c.push(...e("background",a(o,7))),n==="active"&&c.push(...e("background",a(o,12)),...e("border-color",o.border)),n==="disabled"&&c.push(...e("color",o.mutedText)));return n==="focus"&&o.accent&&c.push(`outline:2px solid ${o.accent}`),c}var d={input:(o,r)=>r==="base"?[...e("font-family",o.font),...e("color",o.text),...e("background",o.surface),...e("border-color",o.border),...e("border-radius",o.radius)]:r==="hover"?e("border-color",o.mutedText):r==="focus"&&o.accent?[`outline:2px solid ${o.accent}`,`border-color:${o.accent}`]:[],surface:(o,r)=>r==="base"?[...e("background",o.surface),...e("color",o.text),...e("border-color",o.border),...e("box-shadow",o.shadow),...e("border-radius",o.radius),...e("font-family",o.font)]:[],text:(o,r)=>r==="base"?[...e("color",o.text),...e("font-family",o.font)]:[],mutedText:(o,r)=>r==="base"?[...e("color",o.mutedText),...e("font-family",o.font)]:[],heading:(o,r)=>r==="base"?[...e("font-family",o.headingFont||o.font),...e("color",o.text)]:[],code:(o,r)=>r==="base"?e("color",o.text):[],well:(o,r)=>r==="base"?[...e("background",o.background),...o.border?[`border:1px solid ${o.border}`]:[],...e("border-radius",o.radius)]:[],overlay:(o,r)=>r==="base"?e("background",o.overlay):[],close:(o,r)=>r==="base"?[...e("background",o.surface),...e("color",o.mutedText),...e("border-color",o.border)]:r==="hover"?e("background",a(o,7)):r==="focus"&&o.accent?[`outline:2px solid ${o.accent}`]:[]};function x(o,r,n="base"){return t(o)?r.startsWith("button.")?p(o.tokens,r.slice(7),n):d[r]?d[r](o.tokens,n):[]:[]}function $(o,r,n){return b(n).flatMap(c=>x(o,r,c))}function m(o,r,n){if(!t(o)||!r?.length)return[];let c=b(n),u=[];for(let i of r){let s=o.parts[i];if(s)for(let l of c)for(let[h,g]of Object.entries(s[l]||{}))u.push(`${h}:${g}`)}return u}function v(o,r,n){t(r)&&n?.length&&o.setAttribute("data-clay-part",n.join(" "))}function k(o,r,n){if(!n)return[];let c=[...o].reverse().find(s=>s.startsWith(`${r}:`)),u=c?c.slice(r.length+1).trim():"",i=[`${r}:${n}px`];return u&&u!==`${n}px`&&i.push(`${r}:max(${n}px, ${u})`),i}function y(o,r){return r?k(o,"min-height",44):[]}export{t as a,b,x as c,$ as d,m as e,v as f,k as g,y as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as $}from"./c-EHAR4RJJ.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-KU3PX7LL.js";import"./c-EQ5NBOGA.js";import"./c-IJUK2GPW.js";import"./c-C7SUMNMI.js";import{c as k}from"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import{b as u}from"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-UW6MMZ4V.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var O="Some saved data was removed",W={recent:"A change from outside this page removed something you typed","all-typed":"A change from outside this page removed everything you typed",emptied:"A change from outside this page emptied this page's data",unreadable:"A change from outside this page left its data unreadable"},B=3,V=36e5,T="data-guard-done",K=6e3,Y=1500,G=5e3,H=3e4,J=1e4,q=6e3,X=["clay:save-error","clay:save-offline","clay:save-conflict"],I="Could not reach the server. Try again.",z="That did not go through. Try again.",Q="Save your changes first, then try again.",Z="Reload the page, then try again.",n=null,d=null,m=(e,t)=>`${e} ${t}${e===1?"":"s"}`,D=e=>!!e&&typeof e.id=="string"&&e.status==="pending",E=(e,t,i,s)=>s===!0&&!e.refused.has(`${t.id}:${i}`),A=(e,t)=>E(e,t,"restore",t.restorable),f=(e,t)=>E(e,t,"revert",t.canRevert),L=(e,t)=>E(e,t,"put-back",t.canPutBack),p=e=>Array.isArray(e.typed)?e.typed:[],C=e=>!!e.reason,ee=e=>W[e.reason]??O,P=e=>e.reason==="recent"||e.reason==="all-typed",te=e=>P(e)?"info":"warning",M=()=>k()?"omit":"same-origin",N=e=>$()||e.lastExternal>0&&Date.now()-e.lastExternal<J,U=(e={})=>({"Document-URL":location.href,...e});function b(){for(let e of document.querySelectorAll("[data-htmlclay-guard]"))e.remove()}function l(e,t){import("./c-C6DXZIXD.js").then(i=>{d=i,i.default(e,t)},()=>{})}function y(e){let t=e.lossSummary||{},i=t.provenance==="external"?"A change from outside this page":"A save from this page",s=t.removedItems>0?`removed ${m(t.removedItems,"item")}`:t.destroyedAtoms>0?`erased ${m(t.destroyedAtoms,"value")}`:"changed saved data",a=Array.isArray(e.preview)?e.preview[0]:null,o=[`${i} ${s}.`];return a&&o.push(`${a.key}: ${a.yours} before, ${a.now} now.`),o}function ie(e){let t=String(e??"").split(".").filter(s=>s&&!/^\[[^\]]*\]$/.test(s));return(t[t.length-1]??"").replace(/\[[^\]]*\]/g,"").trim().replace(/[_-]+/g," ")||"value"}function ae(e){let t=p(e);if(!t.length)return"";let i=t.slice(0,B).map(a=>`${ie(a.path)}: "${a.yours}"`),s=t.length-i.length;return`${i.join("; ")}${s>0?` and ${s} more.`:"."}`}function se(e){if(e.reason==="all-typed")return"";let t=p(e)[0],i=typeof t?.at=="number"?t.at:Date.parse(t?.at);if(!Number.isFinite(i))return"";let s=Date.now()-i;if(s<0||s>=V)return"";let a=Math.max(1,Math.floor(s/6e4));return`You typed ${p(e).length===1?"it":"them"} ${m(a,"minute")} ago.`}function oe(e,t){if(!C(t)){let s=y(t);return A(e,t)?t.droppedAdditions>0&&s.push(`Restoring removes ${m(t.droppedAdditions,"item")} added or changed since.`):f(e,t)?s.push("This data no longer fits the page, but the whole change can be undone."):s.push("It cannot be restored from here."),f(e,t)&&s.push("Undo the change also removes edits made since."),s.join(" ")}let i=[];if(P(t)){i.push(ae(t)||y(t).join(" "));let s=se(t);s&&i.push(s)}else i.push(y(t).join(" "));return f(e,t)&&i.push("Undo the change also removes edits made since."),i.join(" ")}function ne(e,t){let i=[];return C(t)?(L(e,t)&&i.push({label:"Put it back",onClick:()=>r(e,t,"put-back")}),f(e,t)&&i.push({label:"Undo the change",onClick:()=>r(e,t,"revert")}),i.push({label:"Keep the change",onClick:()=>r(e,t,"dismiss")}),i):(A(e,t)&&i.push({label:"Restore",onClick:()=>r(e,t,"restore")}),f(e,t)&&i.push({label:"Undo the change",onClick:()=>r(e,t,"revert")}),i.push({label:"Keep as is",onClick:()=>r(e,t,"dismiss")}),i)}async function v(e,t){let i=ee(t),s=oe(e,t),a=[t.id,i,t.reason??"",JSON.stringify(p(t)),A(e,t),L(e,t),f(e,t),t.lastWriteAt,s].join("|");if(e.drawn===a)return!0;e.drawn=a,e.eventId=t.id;try{d??=await import("./c-C6DXZIXD.js")}catch{return e.drawn===a&&(e.drawn=null,e.eventId=null),!1}if(n!==e||e.drawn!==a)return!1;let o=e.title;return e.title=i,o&&o!==i&&d.dismissPersistent(o,{now:!0}),d.dismissPersistent(i,{now:!0}),d.toastPersistent(i,te(t),{detail:s,actions:ne(e,t)}),!0}function g(e){let t=e.title;e.drawn=null,e.eventId=null,e.title=null,t&&d?.dismissPersistent(t,{now:!0})}async function h(e){let t=++e.turn;e.lastRead=Date.now();let i=new AbortController,s=setTimeout(()=>i.abort(),K),a;try{let o=await fetch(e.url,{method:"GET",credentials:M(),headers:U(),cache:"no-store",redirect:"manual",signal:i.signal});if(!o.ok)return;a=await o.json()}catch{return}finally{clearTimeout(s)}if(!(n!==e||t!==e.turn)&&!(!a||typeof a!="object"||!("event"in a))){if(D(a.event)){if(e.resolved.has(a.event.id)||e.waiting===a.event.id)return;if(!e.waited.has(a.event.id)&&N(e)){x(e,a.event.id);return}await v(e,a.event)&&b();return}g(e),b()}}function F(e,t){e.resolved.add(t.id),e.eventId===t.id&&g(e)}function le(e,t,i){if(F(e,t),i==="dismiss"){l("Kept the page as it is.","info");return}u.session.set(T,i),e.reload()}function re(e,t,i,s,a){n===e&&(s===200&&a?.ok===!0?le(e,t,i):s===404?(F(e,t),l("This was already taken care of somewhere else. Reload to see the current page.","info")):s===409?(e.drawn=null,l("This page changed after the notice appeared. Check the notice and try again.","warning"),h(e)):s===422?(e.refused.add(`${t.id}:${i}`),e.eventId===t.id&&!e.resolved.has(t.id)&&v(e,t),l(i==="restore"||i==="put-back"?"That data no longer fits this page, so it could not be restored.":"That earlier version is no longer available.","warning")):l(s===401||s===403?Z:s===400?z:I,"error"))}async function de(){let e=window.clay;if(!e?.hasUnsavedChanges?.())return!0;if(typeof e.save?.flush!="function")return!1;try{await e.save.flush()}catch{return!1}return!e.hasUnsavedChanges()}async function r(e,t,i){if(!(e.busy||n!==e)){e.busy=!0;try{if(i!=="dismiss"&&!await de()){n===e&&l(Q,"warning");return}if(n!==e)return;let s=await fetch(e.url,{method:"POST",credentials:M(),headers:U({"Content-Type":"application/json"}),redirect:"manual",body:JSON.stringify({id:t.id,choice:i})}),a=await s.json().catch(()=>null);re(e,t,i,s.status,a)}catch{n===e&&l(I,"error")}finally{e.busy=!1}}}function fe(e,t){let{msgType:i,action:s,data:a}=t.detail||{};if(i==="data-loss"){if(s==="resolved"){if(typeof a?.id!="string")return;e.turn++,e.resolved.add(a.id),e.waiting===a.id&&j(e),e.eventId===a.id&&g(e);return}if(s==="raised"&&D(a)&&!e.resolved.has(a.id)){if(e.turn++,e.waiting===a.id)return;if(!e.waited.has(a.id)&&N(e)){x(e,a.id);return}v(e,a).then(o=>{o&&b()},()=>{})}}}var _=e=>Math.max(e.lastSave+Y,e.lastRead+G);function j(e){return e.waiting?(e.waiting=null,clearTimeout(e.waitTimer),e.waitTimer=null,!0):!1}function S(e,{now:t=!1}={}){!j(e)||n!==e||(t?h(e):R(e))}function x(e,t){e.waited.add(t),e.waiting=t,clearTimeout(e.waitTimer),e.waitTimer=setTimeout(()=>S(e,{now:!0}),q)}function R(e){e.timer||(e.timer=setTimeout(()=>{e.timer=null,n===e&&(_(e)>Date.now()?R(e):h(e))},Math.max(_(e)-Date.now(),0)))}function me({href:e,reload:t=()=>window.location.reload()}){if(n)return;let i;try{i=new URL(e,location.href)}catch{return}if(i.origin!==location.origin)return;let s=new AbortController,a={url:i.href,reload:t,listeners:s,turn:0,lastRead:0,lastSave:0,timer:null,lastExternal:0,waiting:null,waitTimer:null,waited:new Set,busy:!1,drawn:null,eventId:null,title:null,resolved:new Set,refused:new Set};n=a;let{signal:o}=s;document.addEventListener("clay:notification",c=>fe(a,c),{signal:o}),document.addEventListener("clay:sync-applied",c=>{c.detail?.source==="disk"&&(a.lastExternal=Date.now())},{signal:o}),document.addEventListener("clay:save-saved",()=>{a.lastSave=Date.now(),a.waiting?S(a):R(a)},{signal:o});for(let c of X)document.addEventListener(c,()=>S(a,{now:!0}),{signal:o});document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&Date.now()-a.lastRead>=H&&h(a)},{signal:o});let w=u.session.get(T);w&&(u.session.remove(T),l(w==="restore"||w==="put-back"?"Your saved data is back.":"The earlier version is back.","success")),h(a)}function pe(){let e=n;e&&(n=null,e.listeners.abort(),clearTimeout(e.timer),clearTimeout(e.waitTimer),g(e))}export{me as start,pe as stop};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as h}from"./c-
|
|
1
|
+
import{C as h}from"./c-3Y234AUB.js";import"./c-OH2FPYSY.js";import"./c-RETTCOWO.js";import"./c-VHNSBD2M.js";var u=(t,s)=>{let l=-1;return t.forEach((n,a,c)=>{n.attrs.id===s&&(l=c)}),l};function k(t,s,l){let n=t.state,a=u(n.doc,s);if(a<0)return!1;let c=0;for(let e=0;e<a;e++)c+=n.doc.child(e).nodeSize;let r=n.doc.child(a);return t.dispatch(h(n.tr.setNodeMarkup(c,null,{...r.attrs,...l}))),!0}function E(t,s){let l=u(t.state.doc,s);if(l<0)return!1;let n=t.dom.parentElement,a=n.ownerDocument,c=0;for(let o=0;o<l;o++)c+=t.state.doc.child(o).nodeSize;let r=a.createElement("div");r.className="blockeditor-link",r.dataset.mode="alt";let e=a.createElement("input");e.className="blockeditor-link-input",e.type="text",e.value=t.state.doc.child(l).attrs.alt||"",e.placeholder="Describe the image",e.setAttribute("aria-label","Alt text"),r.append(e);let d=t.nodeDOM(c)?.getBoundingClientRect?.(),p=n.getBoundingClientRect();d&&(r.style.setProperty("--blockeditor-pop-x",`${d.left-p.left}px`),r.style.setProperty("--blockeditor-pop-y",`${d.bottom-p.top+6}px`)),n.append(r);let f=!1,i=(o,b=!0)=>{if(f)return;f=!0;let m=e.value.trim();r.remove();let x=u(t.state.doc,s);o&&x>=0&&m!==t.state.doc.child(x).attrs.alt&&k(t,s,{alt:m}),b&&t.focus()};return e.addEventListener("keydown",o=>{o.key==="Enter"?(o.preventDefault(),i(!0)):o.key==="Escape"&&(o.preventDefault(),o.stopPropagation(),i(!1))}),e.addEventListener("blur",()=>i(!0,!1)),e.focus(),!0}export{E as openAltEditor,k as setImageAttrs};
|