@panphora/clayjs 1.16.0 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.js +1 -1
- package/dist/clay-dom.js +1 -1
- package/dist/clay-events.js +1 -1
- package/dist/clay-internals.js +1 -1
- package/dist/clay-options.js +1 -1
- package/dist/clay-router.js +1 -1
- package/dist/clay-ui.js +1 -1
- package/dist/clay-utils.js +1 -1
- package/dist/clay.js +1 -1
- package/dist/clay.standalone.js +7917 -5621
- package/dist/m/attrs/refetch-on-save-ZUE7PSCI.js +1 -0
- package/dist/m/attrs/save-freeze-MYNVXREN.js +1 -0
- package/dist/m/c-2YYDMLNZ.js +1 -0
- package/dist/m/c-336SGU5W.js +1 -0
- package/dist/m/c-3H6BZDNJ.js +6 -0
- package/dist/m/{c-LR4CGEPT.js → c-3RUU4TPX.js} +1 -1
- package/dist/m/c-3XIRD4NU.js +1 -0
- package/dist/m/c-4DFEJ2PO.js +3 -0
- package/dist/m/c-56QRZTZH.js +1 -0
- package/dist/m/c-5J4E7O4Y.js +4 -0
- package/dist/m/c-5LKDWQTL.js +19 -0
- package/dist/m/c-5QWQ7A5L.js +1 -0
- package/dist/m/c-5RJFTLSF.js +1 -0
- package/dist/m/c-6AZOGAPE.js +1 -0
- package/dist/m/{c-Y6USGTS5.js → c-6CRUUXOX.js} +5 -5
- package/dist/m/{c-54RCDCBU.js → c-6KEVEQ7L.js} +1 -1
- package/dist/m/{c-LTGMXXKO.js → c-6NC5I2TV.js} +1 -1
- package/dist/m/{c-YDH7Q3NY.js → c-74MGYWZF.js} +1 -1
- package/dist/m/{c-Z36J63PP.js → c-7OLLJPWP.js} +1 -1
- package/dist/m/c-A3E3NIMC.js +1 -0
- package/dist/m/{c-5R4PTRG2.js → c-AMSNPOCX.js} +1 -1
- package/dist/m/c-B3JM5ZXC.js +1 -0
- package/dist/m/c-BPF2NSPV.js +1 -0
- package/dist/m/c-BQ6LOBEE.js +1 -0
- package/dist/m/c-CJ3A7ZKE.js +1 -0
- package/dist/m/c-CQHPGKX2.js +1 -0
- package/dist/m/c-DCXOXBF3.js +1 -0
- package/dist/m/c-DFS4XZJV.js +2 -0
- package/dist/m/{c-F3CKJTJS.js → c-DNENWY4O.js} +1 -1
- package/dist/m/c-E4LIR5X5.js +1 -0
- package/dist/m/c-EVCQ3BKA.js +1 -0
- package/dist/m/{c-5Y6TNX5W.js → c-EZU56NQV.js} +2 -2
- package/dist/m/c-FDNHHZY5.js +1 -0
- package/dist/m/{c-SWRJFCNN.js → c-FRLHSY7E.js} +1 -1
- package/dist/m/c-FROJUZMV.js +1 -0
- package/dist/m/c-G2JPKCTP.js +1 -0
- package/dist/m/c-GB6TU7WV.js +1 -0
- package/dist/m/{c-GB3JTV6E.js → c-GFJJEBTU.js} +1 -1
- package/dist/m/{c-J7CA54IP.js → c-GSFIGKOP.js} +1 -1
- package/dist/m/{c-OYTFP5QN.js → c-GY422N3Q.js} +1 -1
- package/dist/m/c-HAWFNBYG.js +1 -0
- package/dist/m/{c-33HUYEDI.js → c-HDDEEL77.js} +1 -1
- package/dist/m/c-HFKUVACH.js +1 -0
- package/dist/m/c-HHDFCNHV.js +1 -0
- package/dist/m/c-I2ZATQCD.js +2 -0
- package/dist/m/c-IEM4NTCS.js +1 -0
- package/dist/m/c-IW6GGOU2.js +1 -0
- package/dist/m/{c-SGCCC4FW.js → c-JDCX26UP.js} +2 -2
- package/dist/m/c-JRKY44DK.js +1 -0
- package/dist/m/c-JU3NK25H.js +1 -0
- package/dist/m/{c-VFX45IZQ.js → c-KAU6E43D.js} +1 -1
- package/dist/m/c-KBS3UV6B.js +1 -0
- package/dist/m/c-KGVGROZT.js +1 -0
- package/dist/m/{c-YG2NJYS6.js → c-KQ6TYJAP.js} +2 -2
- package/dist/m/{c-2JL6E75N.js → c-KU3ZFADW.js} +1 -1
- package/dist/m/c-LWLBHLVC.js +3 -0
- package/dist/m/c-M2L47S2X.js +7 -0
- package/dist/m/c-MFP2ZWD4.js +1 -0
- package/dist/m/{c-4YSCRICO.js → c-MKSQ4Y57.js} +1 -1
- package/dist/m/{c-2M73252O.js → c-NUFFJVVJ.js} +1 -1
- package/dist/m/c-NUHSPT5P.js +1 -0
- package/dist/m/c-O72HVYSA.js +1 -0
- package/dist/m/c-OW5QIGG3.js +1 -0
- package/dist/m/c-PGRCK73F.js +1 -0
- package/dist/m/{c-4DRMS4QG.js → c-PS5ARVWR.js} +1 -1
- package/dist/m/c-Q622NS2Y.js +1 -0
- package/dist/m/c-Q7NQD65V.js +1 -0
- package/dist/m/c-QH63LQOS.js +1 -0
- package/dist/m/{c-TQZ2JYHD.js → c-QICP2YR5.js} +1 -1
- package/dist/m/{c-7VGZ7RU5.js → c-QJ4OM3G6.js} +1 -1
- package/dist/m/{c-MMUIUUZG.js → c-R3L7ZJGB.js} +1 -1
- package/dist/m/c-R7IWVINQ.js +1 -0
- package/dist/m/{c-HVYXIS72.js → c-RSMOODDU.js} +1 -1
- package/dist/m/{c-KKWLDOPM.js → c-RYUXUUBX.js} +1 -1
- package/dist/m/c-S4ZEH46B.js +9 -0
- package/dist/m/c-SDAXDM2D.js +1 -0
- package/dist/m/c-SMBZG5X4.js +1 -0
- package/dist/m/{c-UXBMRDZB.js → c-SMGU7RT3.js} +1 -1
- package/dist/m/c-SPIORRYS.js +1 -0
- package/dist/m/c-SWLRT66R.js +1 -0
- package/dist/m/c-SZGYW5HT.js +1 -0
- package/dist/m/c-TCJTVAFN.js +1 -0
- package/dist/m/{c-HRDCD3WN.js → c-TJ6WOJL3.js} +1 -1
- package/dist/m/c-TYLXX4NF.js +21 -0
- package/dist/m/c-U62OB4BT.js +1 -0
- package/dist/m/{c-NMJRXKPC.js → c-U6YWUAR3.js} +1 -1
- package/dist/m/c-UDCSU5G5.js +2 -0
- package/dist/m/{c-NZMNXVF6.js → c-UDUUJPFZ.js} +1 -1
- package/dist/m/c-VE6ZMYMC.js +1 -0
- package/dist/m/c-VG5XIN4T.js +1 -0
- package/dist/m/c-VHM5XQHK.js +1 -0
- package/dist/m/c-VI5RMSVY.js +1 -0
- package/dist/m/c-VRZN56XY.js +1 -0
- package/dist/m/c-W5MCHEGA.js +1 -0
- package/dist/m/c-WDC5GVKU.js +1 -0
- package/dist/m/c-WWXIDH4O.js +28 -0
- package/dist/m/{c-QIX5BJYN.js → c-XCNTK76U.js} +1 -1
- package/dist/m/c-XMS6DPBR.js +1 -0
- package/dist/m/c-Y5HBBIQ4.js +1 -0
- package/dist/m/{c-5M4YEKCX.js → c-ZVPVXTJF.js} +1 -1
- package/dist/m/c-ZVRKXKM7.js +1 -0
- package/dist/m/{c-HT33EQRN.js → c-ZWIOJGMT.js} +1 -1
- package/dist/m/core/admin-attrs-QHOKPJ7W.js +1 -0
- package/dist/m/core/autosave-HRYGUWV6.js +1 -0
- package/dist/m/core/conflict-notice-6MROJN2L.js +1 -0
- package/dist/m/core/host-permission-FNXVEFNE.js +1 -0
- package/dist/m/core/is-edit-mode-KTWA3O5N.js +1 -0
- package/dist/m/core/{persist-HKHA66IY.js → persist-JFYRHMRJ.js} +1 -1
- package/dist/m/core/recovery-FLTCC2OC.js +1 -0
- package/dist/m/core/save-HQZ4S667.js +1 -0
- package/dist/m/core/save-core-KGQWFUNH.js +1 -0
- package/dist/m/core/snapshot-EGQZNT45.js +1 -0
- package/dist/m/core/unsaved-warning-IDJLD66H.js +1 -0
- package/dist/m/events/index-RN2JNGBV.js +1 -0
- package/dist/m/internals/index-PVXGPUDA.js +1 -0
- package/dist/m/lib/cache-bust-MUMFXZK6.js +1 -0
- package/dist/m/loader-S4I7GKXR.js +1 -0
- package/dist/m/manifest-4C419D67.js +1 -0
- package/dist/m/manifest-edit-B077F288.js +1 -0
- package/dist/m/manifest.json +1555 -1058
- package/dist/m/options/options-EJMS3K24.js +1 -0
- package/dist/m/page/{editor-XUTB2HB2.js → editor-NNJA4OKD.js} +21 -8
- package/dist/m/plugins/{ai-edit-ZQ4CGWIP.js → ai-edit-QN4PMMNL.js} +1 -1
- package/dist/m/plugins/demo-RM5IR6AO.js +1 -0
- package/dist/m/plugins/indicator-URDBBOQO.js +1 -0
- package/dist/m/plugins/live-HFWD4OIH.js +1 -0
- package/dist/m/plugins/{menu-HCKO3DSP.js → menu-3HIEQSI6.js} +2 -2
- package/dist/m/plugins/page-JOKB6XPR.js +2 -0
- package/dist/m/plugins/page-view-NXOJHNW6.js +1 -0
- package/dist/m/plugins/people-SGPJKANK.js +1 -0
- package/dist/m/plugins/{richclay-RC3L2F6X.js → richclay-NRQDSWX6.js} +2 -2
- package/dist/m/plugins/sortable-GWT4PWDV.js +1 -0
- package/dist/m/plugins/source-4ZRSAIYM.js +1 -0
- package/dist/m/plugins/undo-VDA5P7FH.js +1 -0
- package/dist/m/plugins/{upgrade-ZNYODP5Y.js → upgrade-W7FG5VFG.js} +1 -1
- package/dist/m/plugins/upload-WLYKK6TL.js +1 -0
- package/dist/m/plugins/visitor-drafts-LIDY7NH6.js +21 -0
- package/dist/m/plugins/visitor-drafts-owner-ZXCKBZE7.js +1 -0
- package/dist/m/plugins/wire-4N6GYAF6.js +1 -0
- package/dist/m/{reader-core-ILWLXVMP.js → reader-core-DXYCURFF.js} +2 -2
- package/dist/m/sync/live-sync-J7VMYTKS.js +1 -0
- package/dist/m/ui/{index-EVHKMKBL.js → index-3JLVI27O.js} +1 -1
- package/dist/offline-manifest.json +857 -623
- package/dist/page/themes/light-1.css +25 -1
- package/dist/server/core.cjs +115 -24
- package/package.json +1 -1
- package/src/core/boot-phase.js +2 -1
- package/src/core/conflict-download.js +3 -29
- package/src/core/download.js +32 -0
- package/src/core/host-meta.js +18 -0
- package/src/core/save-core.js +8 -4
- package/src/core/save.js +4 -4
- package/src/core/snapshot.js +39 -1
- package/src/lib/autosave-scheduler.js +3 -4
- package/src/page/blocks.js +34 -1
- package/src/page/board-views.js +2 -16
- package/src/page/chart-tables.js +11 -0
- package/src/page/chart.js +6 -10
- package/src/page/checkpoint-proof.js +289 -0
- package/src/page/chrome.js +24 -6
- package/src/page/document-title-dom.js +12 -0
- package/src/page/document-title-runtime.js +15 -1
- package/src/page/document-title.js +4 -1
- package/src/page/editor.js +77 -12
- package/src/page/emoji-data.js +162 -0
- package/src/page/features/board.js +12 -3
- package/src/page/features/chart.js +11 -0
- package/src/page/features/dates.js +180 -0
- package/src/page/features/emoji.js +187 -0
- package/src/page/features/mentions.js +188 -0
- package/src/page/features/registry.js +6 -1
- package/src/page/features/table.js +2 -2
- package/src/page/format-command.js +9 -0
- package/src/page/format-host.js +54 -0
- package/src/page/format-native-commands.js +142 -0
- package/src/page/format-native.js +42 -0
- package/src/page/inline.js +32 -8
- package/src/page/items.js +15 -3
- package/src/page/markdown.js +26 -2
- package/src/page/mention-picker.js +99 -0
- package/src/page/merge.js +1 -1
- package/src/page/projection.js +58 -15
- package/src/page/save-projection.js +39 -0
- package/src/page/save-states.js +1 -1
- package/src/page/schema.js +33 -0
- package/src/page/themes/content.css +25 -1
- package/src/page/themes/light-1.css +25 -1
- package/src/page/view-hooks.js +32 -0
- package/src/page/ybind/binding.js +31 -4
- package/src/page/ybind/marks.js +2 -1
- package/src/page/ybind/provider.js +13 -2
- package/src/page/ybind/recovery-replay.js +362 -4
- package/src/plugins/live.js +37 -1
- package/src/plugins/page.js +117 -3
- package/src/plugins/visitor-drafts/intro.js +2 -1
- package/src/server/checkpoint/index.js +2 -2
- package/src/sync/saved-stream.js +17 -8
- package/dist/m/attrs/refetch-on-save-NWPPXOCZ.js +0 -1
- package/dist/m/attrs/save-freeze-FUP4Q4X3.js +0 -1
- package/dist/m/c-35NBGMZB.js +0 -1
- package/dist/m/c-3IQRECYS.js +0 -1
- package/dist/m/c-4B6H4G5V.js +0 -1
- package/dist/m/c-4FFHZM32.js +0 -1
- package/dist/m/c-66O32MV3.js +0 -28
- package/dist/m/c-7O6AFR65.js +0 -1
- package/dist/m/c-ANQTJ3B5.js +0 -2
- package/dist/m/c-AYVOREBE.js +0 -1
- package/dist/m/c-B2ZXPOS3.js +0 -3
- package/dist/m/c-BMIZKMPV.js +0 -1
- package/dist/m/c-CJZSLMVQ.js +0 -1
- package/dist/m/c-DBE6ORSI.js +0 -1
- package/dist/m/c-EDHUR4MX.js +0 -1
- package/dist/m/c-EY6UOM54.js +0 -1
- package/dist/m/c-F7Y6FLPY.js +0 -1
- package/dist/m/c-FA4DZVTC.js +0 -1
- package/dist/m/c-G2BUZITR.js +0 -1
- package/dist/m/c-GBGWXTX4.js +0 -1
- package/dist/m/c-GHBCCVG4.js +0 -1
- package/dist/m/c-IB52R237.js +0 -1
- package/dist/m/c-IKWNE4R4.js +0 -1
- package/dist/m/c-IU3IYEU6.js +0 -1
- package/dist/m/c-IZ2EBRAJ.js +0 -1
- package/dist/m/c-KR4UW4KW.js +0 -1
- package/dist/m/c-KY3VJGUA.js +0 -8
- package/dist/m/c-LXENEBV7.js +0 -1
- package/dist/m/c-PPOSCAQD.js +0 -1
- package/dist/m/c-QQHEX6HA.js +0 -1
- package/dist/m/c-R7RMANJI.js +0 -9
- package/dist/m/c-RI4NT75Y.js +0 -1
- package/dist/m/c-RUJKSUQW.js +0 -1
- package/dist/m/c-T4VO4OCB.js +0 -1
- package/dist/m/c-TR6RMDQ7.js +0 -3
- package/dist/m/c-UKHTLWUW.js +0 -1
- package/dist/m/c-UNN7LWCT.js +0 -1
- package/dist/m/c-V7PZZRG7.js +0 -1
- package/dist/m/c-VL52ADDR.js +0 -1
- package/dist/m/c-WWDBYXLK.js +0 -1
- package/dist/m/c-XNNW2CWK.js +0 -1
- package/dist/m/c-Z4VRC7GU.js +0 -7
- package/dist/m/c-Z6K52OLP.js +0 -19
- package/dist/m/c-ZDY2MDAA.js +0 -21
- package/dist/m/core/admin-attrs-VGNLAUDK.js +0 -1
- package/dist/m/core/autosave-E4PEFPZ6.js +0 -1
- package/dist/m/core/conflict-notice-VQ6Y64PH.js +0 -1
- package/dist/m/core/host-permission-XN3K2IW3.js +0 -1
- package/dist/m/core/is-edit-mode-JXHDVGUL.js +0 -1
- package/dist/m/core/recovery-TBBSICE2.js +0 -1
- package/dist/m/core/save-WUCHTQBE.js +0 -1
- package/dist/m/core/save-core-FJVHT5M3.js +0 -1
- package/dist/m/core/snapshot-F3SWDZMM.js +0 -1
- package/dist/m/core/unsaved-warning-STKBHE6G.js +0 -1
- package/dist/m/events/index-23DPTUT4.js +0 -1
- package/dist/m/internals/index-WOVAP3RU.js +0 -1
- package/dist/m/lib/cache-bust-CGWT6ZJI.js +0 -1
- package/dist/m/loader-HXX6YNH5.js +0 -1
- package/dist/m/manifest-F22DEDAC.js +0 -1
- package/dist/m/manifest-edit-C3C7376B.js +0 -1
- package/dist/m/options/options-2LH76JQ3.js +0 -1
- package/dist/m/plugins/demo-ZIBFAA3R.js +0 -1
- package/dist/m/plugins/indicator-PV4YW2ID.js +0 -1
- package/dist/m/plugins/live-NUTTXSBS.js +0 -1
- package/dist/m/plugins/page-KSUH7G6J.js +0 -2
- package/dist/m/plugins/page-view-W73OW7WI.js +0 -1
- package/dist/m/plugins/people-AJJ32YCG.js +0 -1
- package/dist/m/plugins/sortable-YRMQX3ZU.js +0 -1
- package/dist/m/plugins/source-KHK5UUSK.js +0 -1
- package/dist/m/plugins/undo-OF2L3CXU.js +0 -1
- package/dist/m/plugins/upload-XSGNILUY.js +0 -1
- package/dist/m/plugins/visitor-drafts-XK5GW55Q.js +0 -21
- package/dist/m/plugins/visitor-drafts-owner-KSSH75EV.js +0 -1
- package/dist/m/plugins/wire-ZWVWKF76.js +0 -1
- package/dist/m/sync/live-sync-4AUVXVJU.js +0 -1
- /package/dist/m/plugins/{richclay-RC3L2F6X.js.LEGAL.txt → richclay-NRQDSWX6.js.LEGAL.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as p}from"./c-
|
|
1
|
+
import{d as p}from"./c-VRZN56XY.js";import{e as u}from"./c-OW5QIGG3.js";var d=window.__clayWorkspaceBackground===!0;document.addEventListener("clay:workspace-background",()=>{d=!0});document.addEventListener("clay:workspace-foreground",()=>{d=!1});var a=()=>document.hidden||d,m=class extends EventTarget{constructor(e,{shared:t=!1,sharedData:i=!1,documentURL:n,lane:s,clientId:o,startupCheck:c=!1,keepAliveWhenHidden:v=!1}={}){super(),this.url=e,this.readyState=0,this.onopen=null,this.onmessage=null,this.onerror=null,this._shared=t&&typeof SharedWorker=="function",this._sharedData=i,this._documentURL=n,this._lane=s,this._clientId=o,this._keepAliveWhenHidden=v,this._since=0,this._closed=!1,this._suspended=!1,this._repair=!1,this._startup=c,this._worker=null,this._source=null,this._visibility=()=>{clearTimeout(this._hiddenTimer),a()?(this._worker&&this._postWorker(this._worker,"hidden"),this._keepAliveWhenHidden||(this._hiddenTimer=setTimeout(()=>this._suspend(),5e3))):this._suspended?this._resume():this._worker&&this._postWorker(this._worker,"visible")},this._pagehide=()=>this._suspend(!0),this._pageshow=()=>{(!a()||this._keepAliveWhenHidden)&&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(),a()&&this._visibility()}_emit(e,t){if(this._closed)return;let i=t===void 0?new Event(e):new MessageEvent(e,{data:t});this.dispatchEvent(i),this[`on${e}`]?.(i)}_postWorker(e,t,i={}){e.port.postMessage({v:this._sharedData?2:1,type:t,...i})}_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 t=Date.now(),i=!1;e.onerror=()=>{this._worker===e&&(this._shared=!1,this._repair=!0,this._reopen())},this._startTimer=setTimeout(e.onerror,5e3),e.port.onmessage=({data:s})=>{if(!(this._worker!==e||s?.v!==(this._sharedData?2:1))){if(this._sharedData){if(s.type==="unsupported"){e.onerror();return}if(s.type==="gone"){this.readyState=2,this._emit("error"),this.close();return}if(!i){if(s.type!=="hello")return;if(!Array.isArray(s.features)||!s.features.includes("live-data")){e.onerror();return}i=!0,clearTimeout(this._startTimer),t=Date.now();return}if(s.type==="hello")return}if(t=Date.now(),!this._sharedData&&["status","pong","cursor","frame","gone"].includes(s.type)&&clearTimeout(this._startTimer),s.type==="status")s.state==="open"?(!this._sharedData||this.readyState!==1)&&(this.readyState=1,this._emit("open")):s.state==="connecting"&&(this.readyState=0,this._emit("error"));else if(s.type==="cursor"){clearTimeout(this._startTimer),Number.isSafeInteger(s.seq)&&(this._since=Math.max(this._since,s.seq));let o=s.resync===!0||this._repair,c=this._startup;this._repair=!1,this._startup=!1,this._emit("cursor",JSON.stringify({...s,resync:o,startup:c}))}else if(s.type==="frame"&&typeof s.data=="string")this._remember(s.data),this._emit("message",s.data);else if(this._sharedData&&s.type==="event"&&["data","data-state","data-writer"].includes(s.event)&&s.data!==null&&typeof s.data=="object"&&!Array.isArray(s.data))try{this._emit(s.event,JSON.stringify(s.data))}catch{}else s.type==="gone"&&(this.readyState=2,this._emit("error"),this.close())}},e.port.start(),this._postWorker(e,a()?"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),this._pingTimer=setInterval(()=>{this._worker===e&&(Date.now()-t>15e3*3?(this._repair=!0,this._reopen()):this._postWorker(e,"ping"))},15e3)}catch{this._shared=!1,this._reopen()}}}_openDirect(){let e=new EventSource(this.url);this._source=e,e.onopen=()=>{if(this._source===e&&(this.readyState=1,this._emit("open"),this._repair||this._startup)){let t=this._repair,i=this._startup;this._repair=!1,this._startup=!1,this._emit("cursor",JSON.stringify({resync:t,startup:i}))}},e.onerror=()=>{this._source===e&&(this.readyState=e.readyState,this._emit("error"))},e.onmessage=t=>{this._source===e&&(this._remember(t.data),this._emit("message",t.data))};for(let t of["cursor","presence","data","data-state","data-writer"])e.addEventListener(t,i=>{this._source===e&&this._emit(t,i.data)})}_remember(e){try{let{seq:t}=JSON.parse(e);Number.isSafeInteger(t)&&(this._since=Math.max(this._since,t))}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)}_reopen(){let e=(this._sharedData||this._keepAliveWhenHidden)&&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&&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 f="This document was upgraded.",h=!1;function l(r,e){let t=r.querySelector(`meta[name="${e}"]`),i=t?t.getAttribute("content"):null;return i&&i.trim()?i.trim():null}function g(r=document){return l(r,"hyper-version")}function w(r){return typeof r!="string"||!r.includes("hyper-version")?null:l(new DOMParser().parseFromString(r,"text/html"),"hyper-version")}function y(r){let e=g();return!!e&&!!r&&r!==e}function T(r){return h?!0:y(w(r))}function D(r){return h?!0:!r||typeof r.querySelector!="function"?!1:y(l(r,"hyper-version"))}function S(){if(h)return Promise.resolve();h=!0;let r=u?import("./core/save-HQZ4S667.js").then(i=>i.holdAllSaves(f),()=>{}):Promise.resolve(),e=new CustomEvent("clay:document-upgraded",{detail:{message:f}}),t=u?Promise.resolve():import("./c-M2L47S2X.js").then(i=>i.start(e),()=>{});return document.dispatchEvent(e),Promise.all([r,t]).then(()=>{})}var _={spec:{name:"spec",relayPath:"/_/sync",documentHeader:"Document-URL",snapshotKey:"snapshot",streamPath:(r,e,t,i)=>`/_/sync?document-url=${encodeURIComponent(r)}&lane=${e}&resume-id=${t}&client-id=${encodeURIComponent(i)}`},legacy:{name:"legacy",relayPath:"/_/live-sync/save",documentHeader:"Page-URL",snapshotKey:"html",streamPath:(r,e,t,i)=>`/_/live-sync/stream?page-url=${encodeURIComponent(r)}&lane=${e}&resume-id=${t}&client-id=${encodeURIComponent(i)}`}};function I(){return p().then(r=>{let e=r?.extensions||[],t=e.includes("sync"),i=e.includes("live-data"),n=e.includes("presence"),s=t&&i&&e.includes("sync-worker-data")&&!n,o=t&&!n&&(s||e.includes("sync-worker")&&!i);return{profile:t?_.spec:_.legacy,sharedSync:o,sharedData:s,liveData:i}}).catch(()=>({profile:_.legacy,sharedSync:!1,sharedData:!1,liveData:!1}))}export{m as a,T as b,D as c,S as d,_ as e,I as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as t,e as o}from"./c-W5MCHEGA.js";import"./c-3H6BZDNJ.js";import"./c-4DFEJ2PO.js";import"./c-6CRUUXOX.js";import{e}from"./c-336SGU5W.js";import"./c-6KEVEQ7L.js";import"./c-5J4E7O4Y.js";import"./c-WWXIDH4O.js";import"./c-4L3BTFRK.js";import"./c-5V3MOVJT.js";import"./c-VHNSBD2M.js";function c({view:r=null}={}){let a=r?e(r,{update:o}):()=>{};return{id:"chart",nodeViews:{chart:(i,n,d)=>new t(i,n,d)},dispose(){a()}}}export{c as createFeature};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as y,b as e}from"./c-KIPQJX4B.js";import{d as x}from"./c-QHWJ5ZIJ.js";import{c as b}from"./c-ZUCOKOHT.js";import{a as T}from"./c-UL2YUY52.js";import{g as H,j as u,n as w,p as N}from"./c-OIBUTDXI.js";import{b as h,c as k,e as m}from"./c-VAK7SG37.js";import{a as v}from"./c-VKEDWYDF.js";function O(t,r,n="",o=!1,l="",a="OK"){let i=x(),c=u("div",["display:flex","flex-direction:column","gap:14px",`font:14.5px/1.55 ${h}`,`color:${m["ink-2"]}`],{theme:i,parts:["dialog.content"],role:"text"}),s=null;o&&(s=N("input",{rules:["display:block","width:100%","margin:0"],theme:i,parts:["dialog.input"]}),s.setAttribute("value",String(l)),s.required=!0,c.append(s)),c.insertAdjacentHTML("beforeend",n),e.title=t,e.html=o||n?c:"",e.width="440px",e[y]=i,e.closeHtml="x",e.no="Cancel",e.yes=a;let d=new Promise((f,g)=>{e.onYes(()=>{let p;if(o&&(p=s.value,!p))return!1;if(r)try{r(p)}catch(C){return b(C.message||"An error occurred","error"),!1}return setTimeout(()=>f(p),0),!0}),e.onNo=()=>{setTimeout(g,0)}});return e.open(),setTimeout(()=>{let f=document.querySelector("[data-clay-modal]");f&&f.addEventListener("click",g=>{let p=g.target.closest("[data-copy]");p&&(T(p.dataset.copy),b("Copied","success"))})},0),d.catch(()=>{}),d}function q(t,r,n="",o=""){return O(t,r,o,!0,n,"OK")}function B(t,r,n=""){return O(t,r,n,!1,"","Confirm")}function F(t,...r){let n=x(),o=u("div",["display:flex","flex-direction:column","gap:12px"],{theme:n,parts:["dialog.content"]});for(let a of r){let i=w("div",[`font:14.5px/1.55 ${h}`,`color:${m["ink-2"]}`,"overflow-wrap:anywhere"],void 0,{theme:n});i.innerHTML=a,o.append(i)}e.title=t,e.html=r.length?o:"",e.width="470px",e[y]=n,e.closeHtml="x",e.yes="OK";let l=new Promise((a,i)=>{e.onYes(()=>(setTimeout(a,0),!0)),e.onNo=()=>{setTimeout(i,0)}});return e.open(),l.catch(()=>{}),l}function R(t,r,n=""){let o=x(),l=u("div",["display:block"],{theme:o,parts:["dialog.content"]}),a=u("div",["display:block","max-width:100%","overflow-x:auto","margin:0 0 14px","padding:14px 16px",`background:${m.sunk}`,`border:1px solid ${m["line-2"]}`],{theme:o,parts:["dialog.well"],role:"well"}),i=w("pre",["display:block","margin:0","white-space:nowrap",`font:13px/1.6 ${k}`],void 0,{theme:o,parts:["dialog.code"],role:"code"});i.innerHTML=r,a.append(i);let c=H("Copy",{small:!0,extra:["margin:0 0 14px"],theme:o,parts:["dialog.button","dialog.copyButton"],labelParts:["dialog.buttonLabel"],onClick:()=>{T(r),b("Copied to clipboard!","success")}});l.append(a,c),l.insertAdjacentHTML("beforeend",n||""),e.title=t,e.html=l,e.width="540px",e[y]=o,e.closeHtml="x",e.yes="";let s=new Promise(d=>{e.onYes(()=>(setTimeout(d,0),!0)),e.onNo=()=>{setTimeout(d,0)}});return e.open(),s}function M(){v(()=>{let t=document.querySelector("[data-clay-modal]");t&&(t.remove(),document.body.style.overflow="")})}M();export{q as a,B as b,F as c,R as d,M as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h}from"./c-JRKY44DK.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{c as DRAFT_MODE,b as EDIT_MODE,a as PATH_KIND,h as createIdentity,e as hostIdentityOf,d as newWriterId,f as pathIdentityOf,g as sameAuthority};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as o,e as n}from"./c-HA6INT6J.js";var s=typeof document>"u"?null:document.documentElement.getAttribute("documentetag")||null,i=new Set(["private","public"]),a=(()=>{if(typeof document>"u")return null;let e=document.documentElement.getAttribute("sitevisibility");return i.has(e)?e:null})(),u=!1;function l(){u||!n.some(t=>document.documentElement.getAttribute(t))||(u=!0,console.warn("[clay] This page was served with the pre-1.9.0 save token ("+n.join(", ")+"), which this version no longer accepts. Saving will fail until the host is updated. If this is HTML Clay, upgrade it to 1.9.0 or newer."))}function r(){if(typeof document>"u")return null;for(let e of o){let t=document.documentElement.getAttribute(e);if(t)return t}return l(),null}function d(){return r()!==null}function f(){return typeof document>"u"||r()!==null?!1:n.some(e=>document.documentElement.getAttribute(e))}export{s as a,a as b,r as c,d,f as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as A}from"./c-KBS3UV6B.js";import{l as b}from"./c-3H6BZDNJ.js";import"./c-4DFEJ2PO.js";import"./c-6CRUUXOX.js";import"./c-336SGU5W.js";import"./c-6KEVEQ7L.js";import{A as x}from"./c-5J4E7O4Y.js";import{b as h}from"./c-WWXIDH4O.js";import"./c-4L3BTFRK.js";import"./c-5V3MOVJT.js";import"./c-VHNSBD2M.js";function S(o){let s=String(o??""),n=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter("en",{granularity:"grapheme"}):null;return n?[...n.segment(s)].map(a=>a.segment):[...s]}var I=o=>S(o).length===1&&!/^\s*$/.test(String(o??""));function L(o){let s=[];for(let[n,a]of Object.entries(o??{}))for(let u of Array.isArray(a)?a:[]){let[f,m,d=""]=u??[];typeof f!="string"||typeof m!="string"||s.push({id:`${n}:${m}`,char:f,name:`${f} ${m}`,keywords:`${m} ${d}`})}return s}var P=(o,s)=>{let n=String(s??"").trim().toLowerCase();return n?o.filter(a=>a.char===n||a.keywords.toLowerCase().includes(n)):o};function T(o=()=>import("./c-SZGYW5HT.js")){let s=null;return()=>(s??=Promise.resolve().then(()=>o()).then(n=>L(n.EMOJI)).catch(n=>{throw s=null,n}),s)}function w({view:o=null,load:s=()=>import("./c-SZGYW5HT.js")}={}){if(!o)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let n=o.dom.ownerDocument,a=T(s),u=null;function f(t){let e=o.state,r=e.selection;if(r.from!==t.from||r.to!==t.to||t.from<0||t.to>e.doc.content.size)return null;let c=e.doc.resolve(t.from),i=e.doc.resolve(t.to);return!c.parent.isTextblock||c.parent!==i.parent?null:{from:t.from,to:t.to}}function m(t){try{let e=o.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=o.coordsAtPos(t.from);return{x:Math.max(8,r.left-e.left),y:r.bottom+6-e.top}}catch{return null}}function d(t){let e=t.picker.activeId();e?o.dom.setAttribute("aria-activedescendant",e):o.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&o.dom.removeAttribute("aria-activedescendant")}function l(){let t=u;if(t){u=null;for(let[e,r,c,i]of t.listen)e.removeEventListener(r,c,i);o.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&o.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function j(t,e){let r=o.state.tr.insertText(e,t.from,t.to);return r.setSelection(h.TextSelection.create(r.doc,t.from+e.length)),o.dispatch(x(r)),o.focus(),{ok:!0,emoji:e}}function p(t){let e=u;if(!e)return{ok:!1,code:"not-editing"};let r=e.picker.personAt(t),c=f(e);return!r||c===null||!I(r.char)?(l(),r?c===null?{ok:!1,code:"stale-target"}:{ok:!1,code:"invalid-emoji"}:{ok:!1,code:"no-emoji"}):(l(),j(c,r.char))}function E(t){let e=u;if(!e||b(t,o))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),e.picker.move(t.key==="ArrowDown"?1:-1),d(e)):t.key==="Enter"?(r(),p(e.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),l())}async function $(t={}){l();let e={from:o.state.selection.from,to:o.state.selection.to,picker:null,listen:[]};e.picker=A({document:n,label:"Insert an emoji",empty:"No emoji found",onPick:i=>p(i)}),u=e;let r=(i,k,g,y)=>{i.addEventListener(k,g,y),e.listen.push([i,k,g,y])};r(n,"keydown",i=>E(i),!0),r(o.dom,"input",()=>l()),r(n,"mousedown",i=>{e.picker.el.contains(i.target)||l()},!0),(o.dom.parentElement??n.body).appendChild(e.picker.el);let c;try{c=await a()}catch(i){return l(),{ok:!1,code:"unavailable",error:i}}return u!==e?{ok:!1,code:"not-editing"}:f(e)===null?(l(),{ok:!1,code:"stale-target"}):(e.picker.show(P(c,t?.query),m(e)),d(e),{ok:!0,picker:!0})}return{async run(t){return $(t)},dispose(){l()}}}export{w as createFeature,L as emojiEntries,T as emojiLibrary,P as filterEmoji,S as graphemes,I as isEmojiText};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as l}from"./c-74MGYWZF.js";import{f as n}from"./c-GFJJEBTU.js";import{b as h,c as a}from"./c-BWFVSBDF.js";import"./c-N326R2JD.js";import{b as E,g as T}from"./c-NUFFJVVJ.js";import{b as p}from"./c-RYUXUUBX.js";import{b as w}from"./c-HHDFCNHV.js";import"./c-XCNTK76U.js";import"./c-VKEDWYDF.js";import{A as y,B as k,J as g,L as v,P as b,q as d,r as f,x as m}from"./c-TCJTVAFN.js";import"./c-GQ6F6IDK.js";import"./c-2SPVQSHC.js";import"./c-5VYOWDTI.js";import"./c-QJ4OM3G6.js";import"./c-MKSQ4Y57.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-ZWIOJGMT.js";import"./c-LWLBHLVC.js";import"./c-SDAXDM2D.js";import"./c-TQEMVJCS.js";import"./c-DCXOXBF3.js";import"./c-VRZN56XY.js";import"./c-IJUK2GPW.js";import"./c-OW5QIGG3.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-SPIORRYS.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var x=250,A=2e3,u=["focusin","focusout","selectionchange","clay:sync-applied","clay:workspace-background","clay:workspace-foreground"],S=s=>n.setGeneric(s),o=class{constructor({send:t=S,now:i=()=>Date.now()}){this.send=t,this.now=i,this.others=!1,this.background=!1,this.sent=null,this.lastAt=-1/0,this.timer=null,this.poked=null,this.inflight=!1,this.retry=null,this.stopped=!1,this._onEvent=e=>{e.type==="clay:workspace-background"&&(this.background=!0),e.type==="clay:workspace-foreground"&&(this.background=!1),this.poke()}}start(){this.stopped=!1;for(let t of u)document.addEventListener(t,this._onEvent)}stop(){this.stopped=!0;for(let t of u)document.removeEventListener(t,this._onEvent);clearTimeout(this.timer),clearTimeout(this.poked),clearTimeout(this.retry),this.timer=null,this.poked=null,this.retry=null}roster(t){let e=(t&&Array.isArray(t.people)?t.people:[]).some(r=>r&&r.you!==!0);e!==this.others&&(this.others=e,this.schedule())}reconnected(){this.sent=null,this.schedule()}wanted(){return!this.others||this.background?null:a(h(document.activeElement))}poke(){this.poked===null&&(this.poked=setTimeout(()=>{this.poked=null,this.schedule()},0))}schedule(){if(this.stopped||this.timer!==null||this.inflight||this.wanted()===this.sent)return;let t=Math.max(0,this.lastAt+x-this.now());this.timer=setTimeout(()=>{this.timer=null,this.flush()},t)}flush(){if(this.inflight)return;let t=this.wanted();if(t===this.sent)return;this.sent=t,this.lastAt=this.now(),this.inflight=!0;let i=e=>{if(this.inflight=!1,!this.stopped){if(e)clearTimeout(this.retry),this.retry=null;else if(this.sent===t){this.sent=void 0,this.retry===null&&(this.retry=setTimeout(()=>{this.retry=null,this.schedule()},A));return}this.schedule()}};Promise.resolve(this.send(t)).then(e=>i(!!e),()=>i(!1))}};function I(s){let t=()=>(n.setGeneric(null),n.releaseTarget(),s.lane==="live"&&s._morphInFlight?{ok:!1,code:"pending-input"}:{ok:!0}),i=()=>s.stop();return{id:"clay:sync",order:50,async prepare(e){if(await l(),e?.initial)return{quiesce:t,dispose:i};let r=!1;return{quiesce:t,enable(){let c=s.currentFile;s.stop(),s.start(c,{lane:"live"}),r=!0},dispose:()=>{r&&s.stop()}}}}}export{o as EditingSender,g as baselineSettled,f as conflictResolvedBySync,T as enableAdminInputs,p as enableAdminResources,w as enableContentEditable,E as enableOnClick,y as getLastSavedBytes,d as isSaveConflicted,b as savePageThrottled,v as schedulePaintHeal,k as setLastSavedBaselines,m as setUnsavedChanges,I as syncParticipant};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./c-SWLRT66R.js";import{a as c,c as o,e as n,g as i}from"./c-SDAXDM2D.js";import"./c-TQEMVJCS.js";import{f as a}from"./c-VRZN56XY.js";import"./c-OW5QIGG3.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var u="page-format-activation-failed";function d(){let e=document.querySelector(`meta[name="${c}"]`);return e?n(e.outerHTML):0}var p=async e=>(await import("./core/save-HQZ4S667.js")).savePageForce(()=>{},e);function g({save:e=p,supported:s=()=>a().then(r=>r===1)}={}){return{read(){return{floor:Math.max(i(),d()),revision:null}},capabilities(){return[]},supported:s,async activate({floor:r=1}={}){let t;try{t=await e({pageFormatFloor:r})}catch(m){return{accepted:!1,code:m?.code??u}}return t?.ok?{accepted:!0,revision:null,receipt:t.receipt??t.etag??null}:t?.code===o?{accepted:!1,code:o}:{accepted:!1,code:t?.code??u}}}}export{g as createFormatHost};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as i}from"./c-VRZN56XY.js";import{e as l}from"./c-OW5QIGG3.js";import{a as r}from"./c-BPF2NSPV.js";var e=r,a=r,s=!1,n=0;function k(){return e}function w(){return s}function p(t){e=typeof t=="string"&&t!==""?t:null,n++,a=e}function L(){return a}function g(){a=null}function m(){p(null)}function c(t){typeof t.spec=="number"&&(s=t.extensions.includes("conditional"))}async function b(){return c(await i()),s}async function y({fresh:t=!1,clearIfMissing:d=t}={}){let f=n,u=await i({fresh:t});if(c(u),n!==f||r&&!(t&&d))return e;let o=u.document?.etag;return typeof o=="string"&&o!==""?(e=o,n++):d&&(e=null,n++),e}document.addEventListener("clay:sync-applied",t=>{t.detail?.source==="disk"&&(typeof t.detail.etag=="string"&&t.detail.etag||g())});document.addEventListener("clay:sync-applied",t=>{l&&t.detail?.source==="disk"&&(typeof t.detail.etag=="string"&&t.detail.etag||(m(),y({fresh:!0})))});export{k as a,w as b,p as c,L as d,g as e,m as f,b as g,y as h};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{s as M}from"./c-3H6BZDNJ.js";import"./c-4DFEJ2PO.js";import"./c-6CRUUXOX.js";import"./c-336SGU5W.js";import"./c-6KEVEQ7L.js";import{d}from"./c-5J4E7O4Y.js";import{e as x,m as f,t as k,v as g}from"./c-WWXIDH4O.js";import"./c-4L3BTFRK.js";import"./c-5V3MOVJT.js";import"./c-VHNSBD2M.js";var b="page-step",p=t=>x.closeHistory(t).setMeta(b,!0),y=(t,e)=>!!t&&Object.keys(t.type.attrs).every(r=>t.attrs[r]===e[r]);function S(t,e,r){let o=t.state,{from:n,to:s,empty:a,$from:c}=o.selection,u=o.tr;if(a)y(e.isInSet(o.storedMarks||c.marks()),r)?u.removeStoredMark(e):u.addStoredMark(e.create(r));else{let i=!0;o.doc.nodesBetween(n,s,h=>{i&&h.isText&&!y(e.isInSet(h.marks),r)&&(i=!1)}),i?u.removeMark(n,s,e):u.addMark(n,s,e.create(r))}return t.dispatch(p(u)),!0}function P(t,e){let r=t.state,o=r.tr;return r.selection.empty?o.removeStoredMark(e):o.removeMark(r.selection.from,r.selection.to,e),t.dispatch(p(o)),!0}function m(t,e){let r=t.runFormatCommand;return typeof r!="function"?Promise.resolve({status:"unsupported-host",code:"page-format-unsupported",retry:!1}):r(e)}function $(t,e,r={},{reset:o=!1}={}){let n=f.marks[e];return n?t.editable?g(t.state,n)?m(t,()=>o?P(t,n):S(t,n,r)):Promise.resolve({status:"refused",code:"mark-not-allowed"}):Promise.resolve({status:"refused",code:"not-editable"}):Promise.resolve({status:"refused",code:"unsupported-format"})}function E(t,e,r,o){let n=()=>{if(t.isDestroyed)return!1;let a=t.state;return a.selection.from!==r||a.selection.to!==o?!1:(t.dispatch(a.tr.replaceSelection(e).scrollIntoView()),!0)},s=()=>{let a=e.content.textBetween(0,e.content.size,`
|
|
2
|
+
`," ");return!t.isDestroyed&&a&&t.dispatch(t.state.tr.insertText(a,r,o)),!1};m(t,n).then(a=>{a?.status!=="applied"&&(t.isDestroyed||d(t,a?.message??"That format isn\u2019t available here."),s())},s)}function I(t,e,{at:r,from:o,to:n},s){let a=()=>{if(e.isDestroyed)return!1;let c=e.state,u=c.doc.nodeAt(r);if(!u||u.type!==f.nodes.paragraph||u.textContent!=='"')return s();let i=c.tr.delete(r+1,r+2).setNodeMarkup(r,f.nodes.quote,u.attrs);return e.dispatch(p(i.setMeta(t,{transform:i,from:o,to:n,text:" "}))),!0};e.runFormatCommand(a).then(c=>{c?.status!=="applied"&&s()},s)}var C="This text can\u2019t take that format.",F=t=>t.status==="upgrade-required"?t.message:t.code==="mark-not-allowed"?C:"That format isn\u2019t available here.",T=(t,e)=>{e?.status!=="applied"&&!t.isDestroyed&&d(t,F(e??{}))},l=(t,e,r={},o=void 0)=>{$(t,e,r,o).then(n=>T(t,n))},L=(t,e)=>{m(t,e).then(r=>T(t,r))};function B(t,e,r){if(e==="underline")return l(t,e);let o=e==="text_color"?"Text":"Highlight",n=e==="text_color"?"Automatic":"No highlight";return M(t,r,[...k.map(s=>({key:`${e}_${s}`,label:`${o}: ${s[0].toUpperCase()}${s.slice(1)}`,icon:"\u25CF",run:a=>l(a,e,{color:s})})),{key:`${e}_none`,label:n,icon:"\xD7",run:s=>l(s,e,{},{reset:!0})}])}export{$ as formatMark,L as gateTurn,B as nativeMenu,E as pasteFormats,I as quoteFromSpace,m as runFormat,l as runNative};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e}from"./c-
|
|
1
|
+
import{a,b,c,d,e}from"./c-AMSNPOCX.js";import"./c-KIPQJX4B.js";import"./c-QHWJ5ZIJ.js";import"./c-ZUCOKOHT.js";import"./c-UL2YUY52.js";import"./c-LFPHCXY3.js";import"./c-OIBUTDXI.js";import"./c-4JZDZFF6.js";import"./c-VAK7SG37.js";import"./c-46XYM55L.js";import"./c-NUHP2XDB.js";import"./c-VKEDWYDF.js";import"./c-VHNSBD2M.js";export{a as ask,b as consent,e as init,d as snippet,c as tell};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as b,b as c,c as d,d as e,e as f}from"./c-W5MCHEGA.js";import{g as a}from"./c-3H6BZDNJ.js";import"./c-4DFEJ2PO.js";import"./c-6CRUUXOX.js";import"./c-336SGU5W.js";import"./c-6KEVEQ7L.js";import"./c-5J4E7O4Y.js";import"./c-WWXIDH4O.js";import"./c-4L3BTFRK.js";import"./c-5V3MOVJT.js";import"./c-VHNSBD2M.js";export{e as ChartView,d as chartFromSlash,a as chartTables,b as insertChartAfterTable,f as refreshCharts,c as tableLabel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as _,d as v}from"./c-BWFVSBDF.js";import{b as c}from"./c-RVMWGXEJ.js";import{b as u,c as s}from"./c-NUHP2XDB.js";import{e as b}from"./c-VRZN56XY.js";import"./c-OW5QIGG3.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-HA6INT6J.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var d="#FFFCF6",l=["all:initial","color-scheme:inherit","direction:ltr","unicode-bidi:isolate"],y=18,h=3,p=null,f=null;function C(){return f??=Promise.all([import("./c-6HMB24EV.js"),import("./c-ZE46QDIH.js")]).then(([i,e])=>p={RUNTIME_ONLY:i.RUNTIME_ONLY,CHIP_FONT:`600 11px/16px ${e.FONT_MONO}`}).catch(i=>{throw f=null,i}),f}var $=()=>C().then(()=>!0,()=>!1);function a(i){return i.setAttribute("clay",p.RUNTIME_ONLY),i}function A(i){let e=i&&Array.isArray(i.people)?i.people:[],o=[];for(let t of e){if(!t||t.you===!0||typeof t.id!="string"||!t.id||typeof t.editing!="string"||!_.test(t.editing))continue;let n=typeof t.name=="string"&&t.name.trim()?t.name.trim():"Someone";o.push({id:t.id,name:n,path:t.editing})}return o}var m=class{constructor(){this.editors=[],this.root=null,this._gate=null,this._frame=0,this._following=!1,this._onMove=()=>this.schedule()}supported(){return this._gate||(this._gate=b("presence").then(e=>e===!0,()=>!1)),this._gate}async update(e){this.editors=A(e),await this.supported()&&await this.render()}clear(){this.editors=[],this.follow(!1),this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this.root&&this.root.remove(),this.root=null}schedule(){this._frame||(this._frame=requestAnimationFrame(()=>{this._frame=0,this.render()}))}render(){return p?(this.paint(),Promise.resolve()):$().then(e=>{e&&this.paint()})}paint(){let e=new Map;for(let t of this.editors){let n=v(t.path);n&&(e.has(n)||e.set(n,[]),e.get(n).push(t))}let o=[];for(let[t,n]of e){let r=this.box(t,n);r&&o.push(r)}if(!o.length){this.root&&(this.root.textContent="",u(this.root,"display","none")),this.follow(this.editors.length>0);return}this.build()&&(this.root.textContent="",this.root.append(...o),u(this.root,"display","block"),this.follow(!0))}box(e,o){let t=e.getBoundingClientRect();if(!(t.width||t.height))return null;let n=c(o[0].id),r=a(s("div",[...l,"position:fixed","box-sizing:border-box","pointer-events:none",`top:${Math.round(t.top-h)}px`,`left:${Math.round(t.left-h)}px`,`width:${Math.round(t.width+h*2)}px`,`height:${Math.round(t.height+h*2)}px`,`border:2px solid ${n}`,`box-shadow:0 0 0 1px ${d}, inset 0 0 0 1px ${d}`]));r.setAttribute("data-clay-editing-marker","");let M=t.top-h>=y+2,x=a(s("div",[...l,"position:absolute","left:-2px",M?"bottom:100%":"top:100%","display:flex","gap:2px","pointer-events:none"]));for(let g of o){let w=a(s("span",[...l,"box-sizing:border-box",`height:${y}px`,"padding:1px 6px",`font:${p.CHIP_FONT}`,"letter-spacing:.02em","white-space:nowrap","max-width:180px","overflow:hidden","text-overflow:ellipsis",`background-color:${c(g.id)}`,`color:${d}`,`box-shadow:0 0 0 1px ${d}`],g.name));w.setAttribute("data-clay-editing-chip",""),x.appendChild(w)}return r.appendChild(x),r}build(){return this.root&&this.root.isConnected?!0:typeof document>"u"||!document.body?!1:(this.root=a(s("div",[...l,"position:fixed","top:0","left:0","width:0","height:0","overflow:visible","z-index:2147482999","pointer-events:none","display:none"])),this.root.setAttribute("data-clay-editing",""),document.body.appendChild(this.root),!0)}follow(e){if(typeof window>"u"||!!e===this._following)return;this._following=!!e;let o=e?"addEventListener":"removeEventListener";window[o]("scroll",this._onMove,{capture:!0,passive:!0}),window[o]("resize",this._onMove,{passive:!0}),document[o]("input",this._onMove),document[o]("clay:sync-applied",this._onMove)}},N=new m;var O=N;export{m as EditingMarker,O as default,N as editingMarker};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as d,b as w}from"./c-6KEVEQ7L.js";import{A as g}from"./c-5J4E7O4Y.js";import{j as x}from"./c-WWXIDH4O.js";import"./c-VHNSBD2M.js";var y=`
|
|
2
2
|
.page-editor .page-image { margin-inline: 0; }
|
|
3
3
|
.page-image-frame { position: relative; margin: 0 auto; max-width: 100%; }
|
|
4
4
|
.page-image-frame img { display: block; width: 100%; height: auto; border-radius: var(--page-image-radius, 6px); }
|
|
@@ -31,4 +31,4 @@ import{a as g,b as w}from"./c-54RCDCBU.js";import{A as d}from"./c-TR6RMDQ7.js";i
|
|
|
31
31
|
.page-upload[data-state="error"] .page-upload-msg, .page-upload[data-state="embed-choice"] .page-upload-msg { flex: 1; }
|
|
32
32
|
.page-upload[data-state="error"] .page-upload-msg { color: var(--page-danger, #9E3B2F); }
|
|
33
33
|
.page-upload-btn { border: 0; padding: 4px 8px; border-radius: 6px; background: none; color: inherit; font: inherit; cursor: pointer; }
|
|
34
|
-
.page-upload-btn:hover { background: var(--page-pop-hover); }`;function c(i,e,t,r){let n=i.createElement("button");return n.type="button",n.className="page-upload-btn",n.dataset.act=e,n.dataset.upload=r,n.textContent=t,n}function k(i,e){let t=i.createElement("div");if(t.className="page-upload",t.dataset.state=e.state,t.dataset.kind=e.kind,t.contentEditable="false",t.setAttribute("role",e.state==="uploading"?"status":"alert"),e.preview){let a=i.createElement("img");a.className="page-upload-preview",a.src=e.preview,a.alt="",t.append(a)}let r=i.createElement("span");if(r.className="page-upload-name",r.textContent=e.name,t.append(r),e.state==="uploading"){let a=i.createElement("span");a.className="page-upload-bar",a.setAttribute("role","progressbar"),a.setAttribute("aria-label",`Uploading ${e.name}`),a.setAttribute("aria-valuemin","0"),a.setAttribute("aria-valuemax","100"),a.setAttribute("aria-valuenow",String(e.percent));let s=i.createElement("span");return s.style.width=`${e.percent}%`,a.append(s),t.append(a,c(i,"cancel","Cancel",e.id)),t}let n=i.createElement("span");return n.className="page-upload-msg",n.textContent=e.message,t.append(n),e.state==="embed-choice"&&t.append(c(i,"embed","Keep this image inside the document",e.id)),w.has(e.code)&&t.append(c(i,"retry","Retry",e.id)),t.append(c(i,"remove","Remove",e.id)),t}var E=48,M=[["left","Align left",'<path d="M2.5 3.5h11M2.5 6.5h6M2.5 9.5h11M2.5 12.5h6"/>'],["center","Centre",'<path d="M2.5 3.5h11M5 6.5h6M2.5 9.5h11M5 12.5h6"/>'],["right","Align right",'<path d="M2.5 3.5h11M7.5 6.5h6M2.5 9.5h11M7.5 12.5h6"/>']],m=class{constructor(e,t,r){this.node=e,this.view=t,this.getPos=r;let n=t.dom.ownerDocument;this.dom=n.createElement("figure"),this.dom.className="page-image",this.dom.addEventListener("dragstart",a=>{a.preventDefault(),a.stopPropagation()}),this.dom.draggable=!1,this.frame=n.createElement("div"),this.frame.className="page-image-frame",this.img=n.createElement("img"),this.img.draggable=!1,this.img.addEventListener("error",()=>this.dom.toggleAttribute("data-broken",!0)),this.img.addEventListener("load",()=>this.dom.removeAttribute("data-broken")),this.handle=n.createElement("span"),this.handle.className="page-image-handle",this.handle.setAttribute("aria-hidden","true"),this.handle.addEventListener("pointerdown",a=>this.resize(a)),this.alignBar=n.createElement("div"),this.alignBar.className="page-image-align",this.alignBar.setAttribute("role","toolbar"),this.alignBar.setAttribute("aria-label","Image alignment");for(let[a,s,p]of M){let o=n.createElement("button");o.type="button",o.dataset.align=a,o.setAttribute("aria-label",s),o.title=s,o.innerHTML=`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true">${p}</svg>`,this.alignBar.append(o)}this.alignBar.addEventListener("mousedown",a=>a.preventDefault()),this.alignBar.addEventListener("click",a=>{let s=a.target.closest("[data-align]");s&&this.setAlign(s.dataset.align==="center"?null:s.dataset.align)}),this.frame.append(this.img,this.handle,this.alignBar),this.caption=n.createElement("figcaption"),this.caption.className="page-image-caption",this.caption.contentEditable="plaintext-only",this.caption.setAttribute("aria-label","Caption"),this.caption.dataset.placeholder="Add a caption",this.caption.addEventListener("keydown",a=>{a.isComposing||this.view.composing||(a.key==="Enter"&&(a.preventDefault(),this.commitCaption(),this.view.focus()),a.key==="Escape"&&(a.preventDefault(),this.caption.textContent=this.node.attrs.caption,this.view.focus()))}),this.caption.addEventListener("blur",()=>this.commitCaption()),this.caption.addEventListener("input",()=>this.caption.toggleAttribute("data-empty",!this.caption.textContent)),this.dom.append(this.frame,this.caption),this.render(e)}render(e){this.node=e,this.dom.dataset.id=e.attrs.id??"",this.img.getAttribute("src")!==e.attrs.src&&(this.img.src=e.attrs.src),this.img.alt=e.attrs.alt||"",this.frame.style.width=e.attrs.width?`${e.attrs.width}px`:"",e.attrs.align?this.dom.dataset.align=e.attrs.align:delete this.dom.dataset.align;for(let t of this.alignBar.children)t.setAttribute("aria-pressed",String((e.attrs.align??"center")===t.dataset.align));this.dom.ownerDocument.activeElement!==this.caption&&(this.caption.textContent=e.attrs.caption||""),this.caption.toggleAttribute("data-empty",!e.attrs.caption)}update(e){return e.type!==this.node.type?!1:(this.render(e),!0)}setAlign(e){let t=this.getPos();t==null||e===(this.node.attrs.align??null)||this.view.dispatch(
|
|
34
|
+
.page-upload-btn:hover { background: var(--page-pop-hover); }`;function c(i,e,t,r){let n=i.createElement("button");return n.type="button",n.className="page-upload-btn",n.dataset.act=e,n.dataset.upload=r,n.textContent=t,n}function k(i,e){let t=i.createElement("div");if(t.className="page-upload",t.dataset.state=e.state,t.dataset.kind=e.kind,t.contentEditable="false",t.setAttribute("role",e.state==="uploading"?"status":"alert"),e.preview){let a=i.createElement("img");a.className="page-upload-preview",a.src=e.preview,a.alt="",t.append(a)}let r=i.createElement("span");if(r.className="page-upload-name",r.textContent=e.name,t.append(r),e.state==="uploading"){let a=i.createElement("span");a.className="page-upload-bar",a.setAttribute("role","progressbar"),a.setAttribute("aria-label",`Uploading ${e.name}`),a.setAttribute("aria-valuemin","0"),a.setAttribute("aria-valuemax","100"),a.setAttribute("aria-valuenow",String(e.percent));let s=i.createElement("span");return s.style.width=`${e.percent}%`,a.append(s),t.append(a,c(i,"cancel","Cancel",e.id)),t}let n=i.createElement("span");return n.className="page-upload-msg",n.textContent=e.message,t.append(n),e.state==="embed-choice"&&t.append(c(i,"embed","Keep this image inside the document",e.id)),w.has(e.code)&&t.append(c(i,"retry","Retry",e.id)),t.append(c(i,"remove","Remove",e.id)),t}var E=48,M=[["left","Align left",'<path d="M2.5 3.5h11M2.5 6.5h6M2.5 9.5h11M2.5 12.5h6"/>'],["center","Centre",'<path d="M2.5 3.5h11M5 6.5h6M2.5 9.5h11M5 12.5h6"/>'],["right","Align right",'<path d="M2.5 3.5h11M7.5 6.5h6M2.5 9.5h11M7.5 12.5h6"/>']],m=class{constructor(e,t,r){this.node=e,this.view=t,this.getPos=r;let n=t.dom.ownerDocument;this.dom=n.createElement("figure"),this.dom.className="page-image",this.dom.addEventListener("dragstart",a=>{a.preventDefault(),a.stopPropagation()}),this.dom.draggable=!1,this.frame=n.createElement("div"),this.frame.className="page-image-frame",this.img=n.createElement("img"),this.img.draggable=!1,this.img.addEventListener("error",()=>this.dom.toggleAttribute("data-broken",!0)),this.img.addEventListener("load",()=>this.dom.removeAttribute("data-broken")),this.handle=n.createElement("span"),this.handle.className="page-image-handle",this.handle.setAttribute("aria-hidden","true"),this.handle.addEventListener("pointerdown",a=>this.resize(a)),this.alignBar=n.createElement("div"),this.alignBar.className="page-image-align",this.alignBar.setAttribute("role","toolbar"),this.alignBar.setAttribute("aria-label","Image alignment");for(let[a,s,p]of M){let o=n.createElement("button");o.type="button",o.dataset.align=a,o.setAttribute("aria-label",s),o.title=s,o.innerHTML=`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true">${p}</svg>`,this.alignBar.append(o)}this.alignBar.addEventListener("mousedown",a=>a.preventDefault()),this.alignBar.addEventListener("click",a=>{let s=a.target.closest("[data-align]");s&&this.setAlign(s.dataset.align==="center"?null:s.dataset.align)}),this.frame.append(this.img,this.handle,this.alignBar),this.caption=n.createElement("figcaption"),this.caption.className="page-image-caption",this.caption.contentEditable="plaintext-only",this.caption.setAttribute("aria-label","Caption"),this.caption.dataset.placeholder="Add a caption",this.caption.addEventListener("keydown",a=>{a.isComposing||this.view.composing||(a.key==="Enter"&&(a.preventDefault(),this.commitCaption(),this.view.focus()),a.key==="Escape"&&(a.preventDefault(),this.caption.textContent=this.node.attrs.caption,this.view.focus()))}),this.caption.addEventListener("blur",()=>this.commitCaption()),this.caption.addEventListener("input",()=>this.caption.toggleAttribute("data-empty",!this.caption.textContent)),this.dom.append(this.frame,this.caption),this.render(e)}render(e){this.node=e,this.dom.dataset.id=e.attrs.id??"",this.img.getAttribute("src")!==e.attrs.src&&(this.img.src=e.attrs.src),this.img.alt=e.attrs.alt||"",this.frame.style.width=e.attrs.width?`${e.attrs.width}px`:"",e.attrs.align?this.dom.dataset.align=e.attrs.align:delete this.dom.dataset.align;for(let t of this.alignBar.children)t.setAttribute("aria-pressed",String((e.attrs.align??"center")===t.dataset.align));this.dom.ownerDocument.activeElement!==this.caption&&(this.caption.textContent=e.attrs.caption||""),this.caption.toggleAttribute("data-empty",!e.attrs.caption)}update(e){return e.type!==this.node.type?!1:(this.render(e),!0)}setAlign(e){let t=this.getPos();t==null||e===(this.node.attrs.align??null)||this.view.dispatch(g(this.view.state.tr.setNodeMarkup(t,null,{...this.node.attrs,align:e})))}commitCaption(){let e=this.caption.textContent.replace(/\s+/g," ").trim(),t=this.getPos();t==null||e===(this.node.attrs.caption||"")||this.view.dispatch(g(this.view.state.tr.setNodeMarkup(t,null,{...this.node.attrs,caption:e})))}resize(e){e.preventDefault(),e.stopPropagation();let t=this.view.dom.getBoundingClientRect().width,r=this.frame.getBoundingClientRect().width,n=this.dom.ownerDocument.defaultView.getComputedStyle(this.dom).direction==="rtl",a=e.clientX,s=e.currentTarget;s.setPointerCapture?.(e.pointerId);let p=this.node.attrs.width,o=h=>{let l=(h.clientX-a)*(n?-1:1);p=Math.max(E,Math.min(Math.floor(t)||E,Math.round(r+l))),this.frame.style.width=`${p}px`},f=h=>{s.removeEventListener("pointermove",o),s.removeEventListener("pointerup",b),s.removeEventListener("pointercancel",v);let l=this.getPos();h&&l!=null&&p!==this.node.attrs.width?this.view.dispatch(g(this.view.state.tr.setNodeMarkup(l,null,{...this.node.attrs,width:p}))):this.frame.style.width=this.node.attrs.width?`${this.node.attrs.width}px`:""},b=()=>f(!0),v=()=>f(!1);s.addEventListener("pointermove",o),s.addEventListener("pointerup",b),s.addEventListener("pointercancel",v)}selectNode(){this.dom.classList.add("is-selected")}deselectNode(){this.dom.classList.remove("is-selected")}stopEvent(e){return this.caption.contains(e.target)||this.alignBar.contains(e.target)||e.target.classList?.contains("page-image-handle")}ignoreMutation(){return!0}},A=i=>i==null?"":i<1024?`${i} B`:i<1024*1024?`${Math.round(i/1024)} KB`:`${(i/(1024*1024)).toFixed(1)} MB`,u=class{constructor(e,t){this.node=e;let r=t.dom.ownerDocument;this.dom=r.createElement("div"),this.dom.className="page-file",this.dom.addEventListener("dragstart",n=>{n.preventDefault(),n.stopPropagation()}),this.link=r.createElement("a"),this.link.className="page-file-link",this.link.target="_blank",this.link.rel="noopener noreferrer",this.icon=r.createElement("span"),this.icon.className="page-file-icon",this.icon.textContent="\u2398",this.name=r.createElement("span"),this.name.className="page-file-name",this.meta=r.createElement("span"),this.meta.className="page-file-meta",this.link.append(this.icon,this.name,this.meta),this.dom.append(this.link),this.render(e)}render(e){this.node=e,this.dom.dataset.id=e.attrs.id??"";let t=x(e.attrs.src);t?this.link.setAttribute("href",t):this.link.removeAttribute("href"),this.name.textContent=e.attrs.name||"file",this.meta.textContent=A(e.attrs.size)}update(e){return e.type!==this.node.type?!1:(this.render(e),!0)}selectNode(){this.dom.classList.add("is-selected")}deselectNode(){this.dom.classList.remove("is-selected")}stopEvent(e){return this.link.contains(e.target)}ignoreMutation(){return!0}};function D({view:i=null}={}){return i&&d.set(i,k),{id:"media",nodeViews:{image:(e,t,r)=>new m(e,t,r),file:(e,t)=>new u(e,t)},css:y,dispose(){i&&d.get(i)===k&&d.delete(i)}}}export{u as FileView,m as ImageView,y as MEDIA_CSS,D as createFeature};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function a(t,e){if(typeof t.runFormatCommand!="function")return{ok:!1,code:"page-format-unsupported"};let r=await t.runFormatCommand(e);return r?.status==="applied"?r.result:{ok:!1,code:r?.code??r?.status??"page-format-refused",retry:r?.retry===!0}}export{a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as T,F as O,Q as d,R as g,T as _}from"./c-
|
|
1
|
+
import{D as T,F as O,Q as d,R as g,T as _}from"./c-6CRUUXOX.js";import{L as z}from"./c-WWXIDH4O.js";var b=(t,n)=>{let e=new Map,r=[];for(let o of n??[]){let s=e.get(o.id)??[];s.push(o.implicit),e.set(o.id,s)}let c=new Map;return t.forEach(o=>{let s=o.attrs.id,i=c.get(s)??0;r.push(e.get(s)?.[i]??!1),c.set(s,i+1)}),r},A=t=>t.attrs.raw??null,j=t=>{let n=A(t);if(n){let r={...n};return delete r.t,delete r.pos,r}let e={};for(let r of T(t.type))e[r]=t.attrs[r];return t.type.name==="table"&&(e.rows=z(t).rows),e},y=t=>A(t)?.t??t.type.name;function K(t,n=new Map,e=null){let r=[],c=b(t,e);return t.forEach((o,s,i)=>{let a=c[i]&&!n.has(o.attrs.id),f=e?e[i]?.brk??null:null;a||r.push({k:"b",id:c[i]&&n.has(o.attrs.id)?n.get(o.attrs.id):o.attrs.id,t:y(o),attrs:j(o),brk:f}),o.isTextblock&&o.content.forEach(l=>{if(l.isText){let u=y(o)==="code_block"?[]:l.marks,m=g(u),p=d(u);for(let h=0;h<l.text.length;h++)r.push({k:"c",ch:l.text[h],mk:m,ma:p})}else l.type.name==="hard_break"&&r.push({k:"h"})})}),r}function w(t,n=new Map,e=null){let r=new Int32Array(t.content.size+1),c=0,o=b(t,e);return t.forEach((s,i,a)=>{let l=o[a]&&!n.has(s.attrs.id)?0:1;if(s.isTextblock){let u=s.content.size;r[i]=c;for(let m=0;m<=u;m++)r[i+1+m]=c+l+m;r[i+2+u]=c+l+u,c+=l+u}else r[i]=c,r[i+s.nodeSize]=c+l,c+=l}),r}function P(t,n,e){let r=t.resolve(n),c=t.resolve(e);if(r.depth!==1||c.depth!==1||r.index(0)!==c.index(0)||!r.parent.isTextblock)throw new RangeError("token range must stay inside one text block");let o=r.index(0),s=0,i=0,a=null;t.forEach((p,h,x)=>{x<o?s+=p.isTextblock?p.content.size+1:1:x===o&&(a=p,i=h)});let f=n-i-1,l=e-i-1,u=[],m=0;return a.content.forEach(p=>{let h=Math.max(0,f-m),x=Math.min(p.nodeSize,l-m);if(h<x)if(p.isText){let M=y(a)==="code_block"?[]:p.marks,I=g(M),S=d(M);for(let k=h;k<x;k++)u.push({k:"c",ch:p.text[k],mk:I,ma:S})}else p.type.name==="hard_break"&&u.push({k:"h"});m+=p.nodeSize}),{start:s+1+f,end:s+1+l,tokens:u}}var q=(t,n)=>t.k===n.k&&(t.k==="b"?t.id===n.id&&t.t===n.t&&O(t.attrs,n.attrs):t.k==="h"||t.ch===n.ch&&t.mk===n.mk),C=(t,n)=>{let e=n;for(let r of t)r.at<=n&&(e+=r.len);return e},E=(t,n)=>{let e=n;for(let r of t)r.at<n&&(e+=r.len);return e},N=(t,n,e)=>_({tokens:t,holes:n},e);var D=(t,n,e,r)=>E(n,w(t,new Map,r)[e]);function G(t,n,e,r,c=null){let o=0,s=e;for(;o<s;){let f=o+s+1>>1;E(n,f)<=r?o=f:s=f-1}let i=w(t,new Map,c),a=-1;for(let f=0;f<i.length;f++)if(!(i[f]<o)){if(i[f]>o)break;if(a<0&&(a=f),t.resolve(f).parent.inlineContent)return f}return a<0?t.content.size:a}var H=(t,n)=>{let e=t.resolve(n);return e.depth!==3||e.parent.type.name!=="table_cell"?null:{table:e.node(1).attrs.id,row:e.node(2).attrs.id,col:e.parent.attrs.col,offset:e.parentOffset}},R=(t,n)=>{let e=null;return t.forEach((r,c)=>{e!==null||r.type.name!=="table"||r.attrs.id!==n.table||r.forEach((o,s)=>{e!==null||o.attrs.id!==n.row||o.forEach((i,a)=>{e===null&&i.attrs.col===n.col&&(e={from:c+2+s+a,to:c+2+s+a+i.nodeSize,block:n.table,row:n.row,col:n.col})})})}),e},L=(t,n)=>{let e=R(t,n);if(!e)return null;let r=t.nodeAt(e.from);return e.from+1+Math.min(n.offset??0,r?r.content.size:0)};export{K as a,w as b,P as c,q as d,C as e,E as f,N as g,D as h,G as i,H as j,R as k,L as l};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as ue,b as me}from"./c-R7IWVINQ.js";import{i as pe,k as U,t as A}from"./c-4DFEJ2PO.js";import{D as ae,E as K,M as fe,Q as le,f as se,h as ce,s as ie,z as de}from"./c-6CRUUXOX.js";import{$ as H,B as Q,M as G,N as q,P as X,_ as Z,a as L,ca as z,da as ee,e as N,ha as S,ia as D,ja as te,ka as v,la as k,m as E,ma as oe,na as V,oa as ne,pa as re,ra as I,w as W,x as P,y as J}from"./c-WWXIDH4O.js";var ge="page-adopt",R=(o,e)=>k(o)===k(e),C=({id:o,parent:e,...t})=>({...t,parent:e??null});function qe(o,e,t=v(o)){let s=t,r=new Map(s.map(n=>[n.id,n])),i=new Map(e.map(n=>[n.id,n])),a=new Map,d=new Map;for(let n of e){let h=r.get(n.id);h?R(C(h),C(n))||a.set(n.id,n):d.set(n.id,n)}let f=s.filter(n=>!i.has(n.id)).map(n=>n.id),m=e.filter(n=>r.has(n.id)).map(n=>n.id),u=s.filter(n=>i.has(n.id)).map(n=>n.id),y=m.some((n,h)=>n!==u[h]);return!a.size&&!d.size&&!f.length&&!y?null:{edited:a,created:d,deleted:f,order:e.map(n=>n.id),reordered:y,base:r}}function B(o,e,t,s=r=>r){let r=o.map(d=>({id:d.id,pos:e?.[d.id]?.pos??null})),i=X(r,t),a={};return o.forEach((d,f)=>{a[d.id]=s({...d,pos:i[f]?i[f].pos:r[f].pos})}),a}function Y(o,e){let{id:t,t:s,...r}=o,i={t:s,pos:e?.pos??null};if(Object.assign(i,r),s==="table"&&!r.rows.length&&r.cols.length&&(r.rows=[{id:`r-${t}`,cells:{}}]),s==="table"&&(i.cols=B(r.cols,e?.cols,"c",({id:a,...d})=>d),i.rows=B(r.rows,e?.rows,"r",({id:a,cells:d,pos:f})=>({pos:f,cells:d}))),s==="board"){i.columns=B(r.columns,e?.columns,"c",({id:f,...m})=>m);let a={},d=new Map;for(let f of r.cards)(d.get(f.col)??d.set(f.col,[]).get(f.col)).push(f);for(let f of d.values())Object.assign(a,B(f,e?.cards,"k",({id:m,...u})=>u));i.cards=a}return i}var we=(o,e,t)=>{let{t:s,pos:r,c:i,m:a,...d}=t,f=typeof i=="string"&&i?Q(o,i,S(a,i.length),o.nodes.opaque_block):null;return o.nodes.opaque_block.create({id:e,pos:r,raw:{t:s,...d}},f)},be=o=>Object.fromEntries(Object.entries(o).map(([e,t])=>{if(t.t!=="opaque_block")return[e,t];let{t:s,raw:r,...i}=t,{t:a,...d}=r??{};return[e,{t:a??"paragraph",pos:t.pos,...d,...i}]}));function M(o,e){let t=null;return o.forEach((s,r)=>{!t&&s.attrs.id===e&&(t={node:s,pos:r})}),t}function ke(o,e){let t=o.filter(d=>e.has(d)),s=[],r=[],i=new Array(t.length).fill(-1);t.forEach((d,f)=>{let m=e.get(d),u=0,y=s.length;for(;u<y;){let n=u+y>>1;s[n]<m?u=n+1:y=n}u>0&&(i[f]=r[u-1]),s[u]=m,r[u]=f});let a=new Set;for(let d=r[s.length-1]??-1;d>=0;d=i[d])a.add(t[d]);return a}function Oe(o,e,t){let{node:s,pos:r}=M(o.doc,e),i={...t.attrs,id:s.attrs.id,pos:s.attrs.pos};if(s.isTextblock&&t.isTextblock&&t.type.validContent(s.content)){(s.type!==t.type||!R(s.attrs,i))&&o.setNodeMarkup(r,t.type,i);let a=M(o.doc,e).node,d=a.content.findDiffStart(t.content);if(d==null)return;let{a:f,b:m}=a.content.findDiffEnd(t.content),u=d-Math.min(f,m);u>0&&(f+=u,m+=u),o.replace(r+1+d,r+1+f,new L.Slice(t.content.cut(d,m),0,0));return}o.replaceWith(r,r+s.nodeSize,t.type.create(i,t.content,t.marks))}function ze(o,e){if(!e)return null;let t=o.schema,s=o.doc,r=be(G(s)),i=o.tr,a=new Map(v(r).map(c=>[c.id,c])),d={};for(let c of[...e.edited.keys(),...e.deleted]){let l=e.base.get(c),p=a.get(c);l&&p&&!R(C(l),C(p))&&(d[c]=r[c])}let f=(c,l)=>{let p=Y(l,r[c]);return Object.hasOwn(z,l.t)?q(t,c,p):we(t,c,p)},m=e.base.size?[]:Object.keys(r).filter(c=>r[c].t==="paragraph"&&!r[c].c&&!e.order.includes(c));for(let c of e.deleted){let l=M(i.doc,c);l&&i.delete(l.pos,l.pos+l.node.nodeSize)}let u=[];i.doc.forEach(c=>u.push(c.attrs.id));let y=new Set(e.order),n=e.order.filter(c=>!e.deleted.includes(c));e.reordered?u.forEach((c,l)=>{if(y.has(c))return;let p=u.slice(0,l).reverse().find(w=>n.includes(w));n.splice(p?n.indexOf(p)+1:0,0,c)}):(n=u.slice(),e.order.forEach((c,l)=>{if(!e.created.has(c)||n.includes(c))return;let p=l-1;for(;p>=0&&!n.includes(e.order[p]);)p--;n.splice(p>=0?n.indexOf(e.order[p])+1:0,0,c)}));let h=new Map(u.map((c,l)=>[c,l]));n=n.filter(c=>h.has(c)||e.edited.has(c)||e.created.has(c));let _=ke(n,h),O=new Map;for(let c of u.slice().reverse()){if(_.has(c)||!n.includes(c))continue;let l=M(i.doc,c);O.set(c,l.node),i.delete(l.pos,l.pos+l.node.nodeSize)}let j=0;for(let c of n){if(_.has(c)){let w=M(i.doc,c);j=w.pos+w.node.nodeSize;continue}let l=e.edited.get(c)||e.created.get(c),p=l?f(c,l):O.get(c);i.insert(j,p),j+=p.nodeSize}for(let[c,l]of[...e.edited,...e.created])_.has(c)&&Oe(i,c,f(c,l));for(let c of m){let l=M(i.doc,c);l&&i.doc.childCount>1&&i.delete(l.pos,l.pos+l.node.nodeSize)}return i.docChanged?N.closeHistory(i).setMeta(ge,{displaced:d}):null}function Ae(o,e,t=""){let s=v(o),r=new Map(s.map(d=>[d.id,d])),i=d=>typeof o[d]?.artifact?.fallbackHtml=="string"?o[d].artifact.fallbackHtml:"",a=e.createElement("article");return a.innerHTML=re(s,{fallbackOf:i,clean:ne(e)}),I(a,{seed:t,known:r})}function De(o,e){let t=o.getAttribute("data-rev"),s=me(e),r=v(s),i=new Map(r.map(y=>[y.id,y])),a=t??"",d=I(o,{seed:a,known:i}),f=V(d);if(t&&f===t)return{kind:"untouched"};let m=V(r);if(t&&m!==t)return{kind:"unbased",A:f,R:t,T:m};if(!t){let y=new Set(d.map(n=>n.id));if(!r.every(n=>y.has(n.id)))return{kind:"unbased",A:f,R:t,T:m}}let u=Ae(s,o.ownerDocument,a);return{kind:"adopt",base:s,parsed:d,baseItems:u,A:f}}var F=class extends Error{constructor(e){super(e),this.name="YMigrationError",this.code="invalid-source"}},g=o=>{throw new F(o)},x=o=>o!==null&&typeof o=="object"&&!Array.isArray(o),$=o=>JSON.parse(k(o));function Me(o){(!Array.isArray(o)||!o.length)&&g("Expected at least one hybrid page value");for(let e of o){(!x(e)||!x(e.blocks)||Object.keys(e).some(t=>t!=="blocks"&&t!=="deleted"))&&g("Expected a hybrid page value with blocks and optional deleted ids"),e.deleted!=null&&!x(e.deleted)&&g("Invalid hybrid page tombstones");for(let[t,s]of Object.entries(e.blocks))!e.deleted?.[t]&&(!t||t==="__proto__"||!x(s))&&g(`Invalid hybrid page block: ${t}`),!e.deleted?.[t]&&/^~|~\d+$/.test(t)&&g(`Reserved hybrid page block id: ${t}`)}return te(o)}var $e=(o,e)=>{let t;try{t=P(E,o)}catch{return g(`Invalid mark key on block: ${e}`)}return W([...t].sort((s,r)=>s.type.rank-r.type.rank))},he=(o,e)=>{let t=S(o.m,o.c.length);t||g(`Invalid mark runs on block: ${e}`);for(let s=0;s<t.length;s++){let r=t[s];typeof r!="string"&&g(`Invalid mark key on block: ${e}`),r.startsWith("@")&&(r!==H||o.c[s]!==Z)&&g(`Unsupported inline atom on block: ${e}`),o.t==="code_block"&&r&&g(`Unsupported formatting in code block: ${e}`),r.startsWith("@")||(t[s]=$e(r,e))}return t};function je(o,e,t){let s={t:e.t,pos:t};for(let r of Object.keys(e))r==="t"||r==="pos"||r==="c"||r==="m"||(s[r]=$(e[r]));if(e.c!=null&&typeof e.c!="string"&&g(`Invalid text on block: ${o}`),s.c=e.c??"",typeof e.c=="string"&&e.m!=null){let r=he(e,o);r.some(Boolean)&&(s.m=D(r))}else e.m!=null&&g(`Mark runs require flat text on block: ${o}`);return s}function Ee(o,e,t){let s=Object.hasOwn(z,e.t);!s&&(typeof e.t!="string"||!e.t||e.t==="opaque_block")&&g(`Unsupported hybrid block type: ${e.t}`);let r=String(t+1).padStart(8,"0");if(!s)return je(o,e,r);let i=E.nodes[e.t],a=ae(i),d=new Set(["t","pos","c","m",...a,...e.t==="table"?["rows"]:[]]),f={t:e.t,pos:r};for(let n of Object.keys(e))d.has(n)||(f[n]=$(e[n]));for(let n of a){let h=e[n]===void 0?K(i,n):e[n];k(h)!==k(K(i,n))&&(f[n]=$(h))}if(e.t==="table"&&(e.rows!==void 0&&!x(e.rows)&&g(`Invalid table rows: ${o}`),f.rows=$(e.rows??{})),!i.isTextblock)return e.c!=null&&e.c!==""&&!(Array.isArray(e.c)&&!e.c.length)&&g(`Unexpected text on block: ${o}`),e.m!=null&&!(Array.isArray(e.m)&&!e.m.length)&&g(`Unexpected marks on block: ${o}`),f;e.c!=null&&typeof e.c!="string"&&!Array.isArray(e.c)&&g(`Invalid text on block: ${o}`),typeof e.c=="string"&&e.m!=null?he(e,o):e.m!=null&&g(`Mark runs require flat text on block: ${o}`);let m=q(E,o,e);m.check();let{c:u,m:y}=J(m.content);return f.c=u,y.some(Boolean)&&(f.m=D(y)),f}function Se(o,e){let t;try{let s=Me(o),r=ee(s),i=Object.fromEntries(r.map((n,h)=>[n,Ee(n,s[n],h)]));t=new se,t.clientID=e;let a=fe(t),d=0;t.transact(()=>{for(let n of r){let h=i[n],{pos:_,c:O,m:j,...c}=h;if(h.t==="board"&&(delete c.columns,delete c.cards),a.attrs.set(n,new ie(Object.entries($(c)))),h.t==="board"){for(let[p,w]of Object.entries(h.columns??{})){a.boardFields.set(A(n,"column",p,"alive"),!0);for(let b of["name","pos"])a.boardFields.set(A(n,"column",p,b),w[b]??"")}for(let[p,w]of Object.entries(h.cards??{})){a.boardFields.set(A(n,"card",p,"alive"),!0);for(let b of["title","owner","due"])w[b]!==void 0&&a.boardFields.set(A(n,"card",p,b),w[b]);a.boardFields.set(A(n,"card",p,"placement"),{columnId:w.col??"",pos:w.pos??""})}}if(a.flow.insertEmbed(a.flow.length,{b:n},{}),!O)continue;let l=0;for(let[p,w]of D(S(j,O.length)??Array(O.length).fill(""))){if(w===H)for(let b=0;b<p;b++)a.flow.insertEmbed(a.flow.length,{br:1},{});else{let b=Object.fromEntries(Object.entries(le(P(E,w))).map(([ye,T])=>[`${ye}~${e}-m${(d++).toString(36)}`,T&&typeof T=="object"?$(T):T]));a.flow.insert(a.flow.length,O.slice(l,l+p),b)}l+=p}}},de);let f=pe(ce(t)),m=Math.ceil(f.length/U),y={v:1,g:0,y:m<=1?{seed:f}:Object.fromEntries(Array.from({length:m},(n,h)=>[`seed.${h}.${m}`,f.slice(h*U,(h+1)*U)]))};return k(ue(y))!==k(i)&&g("Hybrid page data cannot be represented without loss"),y}catch(s){throw s instanceof F?s:new F(`Cannot migrate hybrid page: ${s.message}`)}finally{t?.destroy()}}function ve(o){let e=parseInt(oe(`page-seed:v1:${k(o)}`).slice(0,8),16)>>>0;return e<2?e+2:e}function Je(o){let e=I(o,{seed:o.getAttribute("data-rev")??""}),t={};return e.forEach((s,r)=>{let i=Y(s,null);i.pos=String(r+1).padStart(8,"0"),t[s.id]=i}),Se([{blocks:t}],ve(t))}export{ge as a,qe as b,ze as c,Ae as d,De as e,Je as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Ge,b as oe,d as he,e as ce,f as We}from"./c-7OLLJPWP.js";import{a as $e,b as je,c as ae,d as ze}from"./c-LZJPNR2W.js";import{a as C,b as W}from"./c-FILLTJA7.js";import{b as Ue}from"./c-5VYOWDTI.js";import{b as se,c as re,d as E,f as le,h as Oe}from"./c-QJ4OM3G6.js";import{a as A}from"./c-ZWIOJGMT.js";import{a as Ne}from"./c-TQEMVJCS.js";import{a as te,b as Me,c as P,d as ne,e as ie,h as Be}from"./c-DCXOXBF3.js";import{e as Pe}from"./c-VRZN56XY.js";import{d as Ae}from"./c-IJUK2GPW.js";import{e as G,i as Q}from"./c-OW5QIGG3.js";import{a as De}from"./c-BPF2NSPV.js";import{b as k,j as ee,n as F,r as Fe,s as z,t as qe,v as q}from"./c-SPIORRYS.js";import{a as He,b as Ce,c as Re,e as $,g as j,h as Z}from"./c-VG5XIN4T.js";import{m as ke,n as xe}from"./c-HA6INT6J.js";import{a as Ie,b as be,l as Te,m as Le}from"./c-DCFSEJZG.js";function Ye(s){let e=new WeakMap,t=0,n=r=>e.get(r)||null,i=r=>{let a=e.get(r);return a||(a=`${s}:${++t}`,e.set(r,a)),a};return{idOf:n,ensure:i,adopt:(r,a)=>{r&&typeof a=="string"&&a&&e.set(r,a)},exportMap:(r,a)=>{let l={},h=[],c=[],d=(f,y)=>{let m=a(f);m&&(l[y]=i(m));let w=f.children;h.push(w.length),c.push(f.tagName.toLowerCase());for(let p=0;p<w.length;p++)d(w[p],y===""?String(p):`${y}.${p}`)};return d(r,""),l["~"]=h.join(","),l["^"]=c.join(","),l}}}function at(s){return e=>{for(let t of s){let n=t(e);if(typeof n=="string"&&n!=="")return n}return null}}var Et=at([s=>s.getAttribute("data-id"),s=>s.getAttribute("id")]);var ot={"merge-tokens":"tokens","merge-max":"max"};function Je(s,e){if(!e.startsWith("data-")||e==="data-id"||!s?.closest)return null;for(let[t,n]of Object.entries(ot)){let i=s.closest(`[${t}]`);if(i&&i.getAttribute(t).split(/\s+/).includes(e))return n}return null}var _=null,Ve=null,M=new Map;function Y(){return Ve??=Promise.all([import("./c-3XIRD4NU.js"),import("./c-EJTGYSLN.js")]).then(([s,e])=>{_={...s,beginLineageCapture:e.beginLineageCapture};for(let t of[...M.keys()])M.set(t,s.registerContext(t));return _}),Ve}var Xe=()=>_,x={get size(){return _?_.conflicts.size:0},list(){return _?_.conflicts.list():[]},get(s){return _?_.conflicts.get(s):null},acknowledge(s,e={}){if(_)return _.conflicts.acknowledge(s,e);if(!Array.isArray(s))throw new TypeError("clay.conflicts.acknowledge needs an array of ids");return{removedIds:[],remainingIds:[]}},claim(s,e={}){if(_)return _.conflicts.claim(s,e);if(!e.owner)throw new TypeError("clay.conflicts.claim needs an owner");return{release(){}}},registerContext(s){if(_)return _.conflicts.registerContext(s);if(typeof s!="function")throw new TypeError("clay.conflicts.registerContext needs a resolver function");return M.set(s,null),()=>{let e=M.get(s);M.delete(s),e&&e()}},contextFor(s,e){return _?_.conflicts.contextFor(s,e):null},recoveryOf(s){return _?_.conflicts.recoveryOf(s):null},hasPendingApply(){return _?_.conflicts.hasPendingApply():!1}};var u=null,de=null;function R(){return de??=new Promise(s=>setTimeout(s,0)).then(()=>import("./c-CJ3A7ZKE.js")).then(s=>u=s).catch(s=>{throw de=null,s}),de}var _e=null,ue=null;function ct(){return ue??=import("./c-SMBZG5X4.js").then(s=>_e=s.presence).catch(s=>{throw ue=null,s}),ue}var Ze=Q().phase==="entering";G&&!Ze&&R().catch(()=>{});G&&Y().catch(()=>{});var D=null,fe=null,V=[];function et(s){D.presence.update(s),D.editingMarker.update(s)}function dt(){return fe??=Promise.all([import("./c-HFKUVACH.js"),import("./c-EVCQ3BKA.js")]).then(([s,e])=>{D={presence:s.presence,editingMarker:e.editingMarker};let t=V;V=[];for(let n of t)et(n);return D}).catch(s=>{throw fe=null,s}),fe}function ut(s){if(D){et(s);return}V.push(s),dt().catch(()=>{})}var Ke=Object.freeze({bytes:null,etag:null,seq:null}),ft=()=>({msg:"Not in edit mode",msgType:"skipped",code:null,etag:null}),tt=["[editor-ui]",'[clay~="editor-ui"]',"[save-ignore]","[snapshot-remove]","[no-snapshot]","[no-save]","[save-remove]","[freeze] *","[save-freeze] *",'[clay~="no-save"]','[clay~="no-snapshot"]','[clay~="freeze"] *',Te,Ie].join(","),nt='[clay~="freeze"], [freeze], [save-freeze]';function J(s){for(let e of s.querySelectorAll(nt))e.replaceChildren();return j()&&Re(s),s}function Qe(s){if(s==null)return s;let e=typeof s=="string"?new DOMParser().parseFromString(s,"text/html"):s;return ee(e),J(e),e}var pt=[Le,'[clay~="no-watch"]',"[no-watch]","[mutations-ignore]"].join(","),_t=(s,e,t)=>ke(s,e,t)||be.test(e.toLowerCase()),it=s=>s.getAttribute("data-id")||s.getAttribute("id")||null;function gt(s){let e=new Map,t=i=>{if(i.matches(tt))return;let r=it(i);r&&e.set(r,(e.get(r)||0)+1);let a=i.localName==="template"&&i.content?i.content.children:i.children;for(let l of a)t(l)},n=s.nodeType===9?[s.documentElement]:s.nodeType===11?s.children:[s];for(let i of n)i&&i.nodeType===1&&t(i);return e}var yt=s=>e=>{let t=it(e);if(!t)return null;let n=e.getRootNode(),i=s.get(n);return i||s.set(n,i=gt(n)),i.get(t)===1?t:null},pe=s=>!!s&&typeof s=="object"&&!Array.isArray(s);function mt(s){return typeof s!="string"||s===""?null:new DOMParser().parseFromString(s,"text/html").documentElement?.getAttribute("documentetag")||null}function vt(s,e){e!=="live"||!s||!u||(u.enableContentEditable(s),u.enableOnClick(s),u.enableAdminInputs(s),u.enableAdminResources(s))}function St(){let{forComparison:s,forDirty:e}=Fe({flushUndo:!1});return[s,e]}var ge=class{constructor(){this.sse=null,this.currentFile=null,this.lastHtml=null,this._diskBase=null,this._diskBaseTicket=0,this._agreeSeq=0,this._saveTicket=0,this._peerBaseTicket=0,this._acceptedSaveTicket=0,this._morphTicket=0,this.clientId=this.generateClientId(),this.resumeId=null,this._savedSnapshot=null,this._sendInFlight=!1,this._queuedSend=null,this._profile=null,this._profilePromise=null,this._sharedData=!1,this._sharedSync=!1,this._liveData=!1,this._editing=null,this._presenceLease=null,this._ready=null,this._startGen=0,this.isPaused=!1,this.isDestroyed=!1,this.debug=!1,this._lane=G?"live":"saved",this._laneChosen=!1,this._snapshotHandler=null,this.lastSeenSeq=0,this._pendingHtml=null,this._pendingSeq=null,this._pendingIdentityMap=null,this._pendingEtag=null,this._pendingBy=null,this._morphInFlight=!1,this._rafHandle=null,this._represented=Ke,this._handoff=null,this._handoffHeld=!1,this._pendingExternal=null,this._lastExternalSeq=0,this._saveEpoch=0,this._saveSavedHandler=null,this._saveConflictHandler=null,this._settledHandler=null,this._lastIdentityMap=null,this._applyGen=0,this._holdRetryPeer=null,this._holdRetryExt=null,this._servedFetchId=0,this._startupRetry=null,this._engineRetry=null,this._heldLive=!1,this._heldExt=!1,this.identity=Ye(this.clientId),this.onConnect=null,this.onDisconnect=null,this.onUpdate=null,this.onError=null,this.onNotification=null}get unresolvedConflicts(){return x.list().filter(e=>e.kind!=="apply-incomplete")}_log(e,t=null){if(!this.debug)return;let n=`[LiveSync ${new Date().toISOString()}]`;t!==null?console.log(n,e,t):console.log(n,e)}generateClientId(){return Math.random().toString(36).slice(2,11)+Date.now().toString(36)}generateResumeId(){try{let e=new Uint8Array(16);return(globalThis.crypto||window.crypto).getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}catch{return Math.random().toString(36).slice(2)+Date.now().toString(36)}}_seedBases(){if(E())return;let e=F({flushUndo:!1});this._setPeerBase(q(e),this.identity.exportMap(e,k),this._ticket()),this._setDiskBase(z({emitForSync:!1}).forSave,this._ticket())}get lane(){return this._lane}set lane(e){this._lane=e,this._laneChosen=!0}start(e=null,{lane:t,represented:n}={}){if(this.isDestroyed=!1,(this.sse||this._snapshotHandler)&&this.cleanup(),this.currentFile=e||this.detectCurrentFile(),!this.currentFile){console.warn("[LiveSync] No file detected");return}let i=Q().mode==="edit"?"live":"saved",r=this.lane==="live";this._lane=t||(this._laneChosen?this._lane:i),this.lastHtml=null,this._lastIdentityMap=null,this._peerBaseTicket=this._ticket(),this._diskBase=null,this._diskBaseTicket=this._ticket(),this._saveTicket=0,this._savedSnapshot=null,this._applyGen++,this.lastSeenSeq=0,this._lastExternalSeq=0,this._represented=n?Object.freeze({bytes:n.bytes??null,etag:n.etag??null,seq:n.seq??null}):Ke,this._acquireEmptySaved=r&&this.lane==="saved"&&this._represented.bytes===null,this._pendingExternal=null,this.resumeId=this.generateResumeId(),this.lane==="live"&&this._seedBases(),this.lane==="live"&&Y().catch(()=>{}),console.log(`[LiveSync] Starting for: ${this.currentFile} (lane=${this.lane})`);let a=++this._startGen;if(this.lane==="live"&&!(u&&u.baselineSettled())){let l=this._applyGen,h=this._morphTicket,c=this._saveEpoch,d=this.lastHtml,f=this._diskBaseTicket,y=this._diskBase!==null;this._settledHandler=()=>{if(this._settledHandler=null,!(this.isDestroyed||this._startGen!==a)&&!Ae()&&!E()&&this._saveTicket===0&&this._morphTicket===h){if(d!==null&&this._applyGen===l&&this._saveEpoch===c&&this.lastHtml===d){let m=F({flushUndo:!1});this._setPeerBase(q(m),this.identity.exportMap(m,k),this._ticket())}y&&this._diskBaseTicket===f&&this._setDiskBase(z({emitForSync:!1}).forSave,this._ticket())}},document.addEventListener("clay:baseline-settled",this._settledHandler,{once:!0})}this._ready=Promise.all([this.lane==="live"?R():null,this._resolveProfile()]).then(()=>{this.isDestroyed||this._startGen!==a||this.connect()}),this.lane==="live"&&(this.listenForSnapshots(),ct().then(l=>this._startPresence(l,a),()=>{}),this._saveSavedHandler=()=>{this._saveEpoch++;let l=this._saveTicket||this._ticket();this._saveTicket=0,l>this._acceptedSaveTicket&&(this._acceptedSaveTicket=l);let h=u?u.getLastSavedBytes():null;h!=null&&this._setDiskBase(h,l),this._relayCommit()},document.addEventListener("clay:save-saved",this._saveSavedHandler),this._saveConflictHandler=l=>{let h=l.detail&&l.detail.etag;h&&queueMicrotask(()=>{this.isDestroyed||h===te()&&(u?.conflictResolvedBySync(h),this._saveAfterMerge(E(),!1))})},document.addEventListener("clay:save-conflict",this._saveConflictHandler))}cleanup(){this.sse&&(this.sse.close(),this.sse=null),ae(),V=[],D&&(D.presence.clear(),D.editingMarker.clear()),this._editing&&(this._editing.stop(),this._editing=null),this._presenceLease&&(this._presenceLease.detach(),this._presenceLease=null),this._lastRoster=null,this._snapshotHandler&&(document.removeEventListener("clay:snapshot-ready",this._snapshotHandler),this._snapshotHandler=null),this._saveSavedHandler&&(document.removeEventListener("clay:save-saved",this._saveSavedHandler),this._saveSavedHandler=null),this._saveConflictHandler&&(document.removeEventListener("clay:save-conflict",this._saveConflictHandler),this._saveConflictHandler=null),this._settledHandler&&(document.removeEventListener("clay:baseline-settled",this._settledHandler),this._settledHandler=null),this._queuedSend=null,this._rafHandle!=null&&(this._cancelFrame(this._rafHandle),this._rafHandle=null),this._pendingHtml=null,this._pendingSeq=null,this._pendingIdentityMap=null,this._pendingBy=null,this._pendingExternal=null,this._handoff=null,this._handoffHeld=!1,clearTimeout(this._holdRetryPeer),clearTimeout(this._holdRetryExt),this._holdRetryPeer=null,this._holdRetryExt=null,clearTimeout(this._startupRetry),this._startupRetry=null,clearTimeout(this._engineRetry),this._engineRetry=null,this._servedFetchId++}detectCurrentFile(){let e=window.location.pathname;if(e==="/")return"index.html";e=e.replace(/^\//,"");let t=e.match(/^(.*?\.html(?:clay)?)/);return t?t[1]:e}_resolveProfile(){return this._profilePromise||(this._profilePromise=We().then(e=>(this._sharedData=e.sharedData,this._sharedSync=e.sharedSync,this._liveData=e.liveData,this._profile=e.profile,this._log(`Wire profile: ${e.profile.name}`),e.profile))),this._profilePromise}_setHeld(e,t,n){let i=e==="live"?"_heldLive":"_heldExt";this[i]!==t&&(this[i]=t,!t&&!this._heldLive&&!this._heldExt&&Be({fresh:!0,clearIfMissing:!1}),document.dispatchEvent(new CustomEvent(t?"clay:sync-held":"clay:sync-resumed",{detail:{lane:e,el:n||null}})))}_applyEtagFrame(e){return typeof e.etag!="string"||typeof e.html=="string"?!1:(this._log("Dropping a stamp that arrived with no document: nothing proves this tab holds those bytes"),!0)}connect(){if(this.isDestroyed)return;let t=(this._profile||ce.legacy).streamPath(window.location.href,this.lane,this.resumeId,this.clientId);this.sse=new Ge(new URL(t,window.location.origin).href,{shared:this._sharedSync,sharedData:this._sharedData,documentURL:window.location.href,lane:this.lane,clientId:this.clientId,keepAliveWhenHidden:this._liveData&&this.lane==="live",startupCheck:!!De}),this._acquireEmptySaved&&(this._acquireEmptySaved=!1,this._fetchServedDocument(void 0,{repair:!0})),this.sse.onopen=()=>{console.log("[LiveSync] Connected"),this._editing&&this._editing.reconnected(),_e&&_e.reconnect(),this.onConnect&&this.onConnect()},this.sse.addEventListener("open",()=>je({clientId:this.clientId,lane:this.lane})),this.sse.addEventListener("error",()=>ae());for(let n of $e)this.sse.addEventListener(n,i=>{let r;try{r=JSON.parse(i.data)}catch{return}ze(n,r)});this.sse.addEventListener("cursor",n=>{let i;try{i=JSON.parse(n.data)}catch{return}if(!i||i.resync!==!0&&i.startup!==!0)return;let r=i.resync===!0,a=i.startup===!0&&!r;console.log(r?"[LiveSync] Server could not replay everything; refetching the document":"[LiveSync] Checking the served document against the version this tab was served"),this._fetchServedDocument(typeof i.seq=="number"?i.seq:void 0,{repair:r,startup:a})}),this.sse.addEventListener("presence",n=>{let i;try{i=JSON.parse(n.data)}catch{return}ut(i),this._lastRoster=i,this._editing&&this._editing.roster(i)}),this.sse.onmessage=n=>{let i=JSON.parse(n.data),{seq:r}=i;if(typeof r=="number"&&r<=this.lastSeenSeq){this._log(`Dropping stale message: seq=${r}, lastSeen=${this.lastSeenSeq}`);return}if(typeof r=="number"&&(this.lastSeenSeq=r),i.type==="notification"){if(this._maybeAcceptExternalChange(i))return;this.handleNotification(i);return}if(i.error){console.error("[LiveSync] Server error:",i.error),this.onError&&this.onError(new Error(i.error));return}if(this._applyEtagFrame(i))return;let{html:a,sender:l,identityMap:h}=i;if(l===this.clientId){this._log("Ignoring own message (sender matches clientId)");return}if(typeof a!="string"){console.error("[LiveSync] Received invalid html, ignoring");return}let c=typeof i.etag=="string"&&i.etag?i.etag:null;if(this.lane==="live"&&!c&&Me()){this._log(`Dropping an unstamped live frame on a stamping host (seq=${r})`);return}if(this.lane==="saved"&&a===this._represented.bytes){this._represented=Object.freeze({bytes:a,etag:c||null,seq:r??null}),P(c);return}if(c&&a===this.lastHtml){this._log(`Taking the stamp from a peer save of content already applied (seq=${r})`),P(c),u&&u.isSaveConflicted()&&(u.conflictResolvedBySync(c),this._saveAfterMerge(E(),!1));return}this._log(`Received update from: ${l} (my clientId: ${this.clientId}, seq=${r})`),this.applyUpdate(a,r,h,c,i.by),this.onUpdate&&this.onUpdate({html:a,sender:l,seq:r,identityMap:h,etag:c})},this.sse.onerror=()=>{this.sse.readyState===EventSource.CONNECTING?console.log("[LiveSync] Reconnecting..."):this.sse.readyState===EventSource.CLOSED&&(console.log("[LiveSync] Connection closed"),this.onError&&this.onError(new Error("Connection closed"))),this.onDisconnect&&this.onDisconnect()}}listenForSnapshots(){this._snapshotHandler=e=>{if(!e.detail||e.detail.forSave!==!0)return;this._saveTicket=this._ticket();let{documentElement:t}=e.detail;if(!t)return;this._log("snapshot-ready received, preparing to send");let n=q(t),i=this.identity.exportMap(t,k);this._savedSnapshot={html:n,identityMap:i,ticket:this._saveTicket}},document.addEventListener("clay:snapshot-ready",this._snapshotHandler)}_enqueueSend(e,t,n=null){if(!this._profile){this._queuedSend={html:e,identityMap:t,etag:n},this._resolveProfile().then(()=>this._flushQueuedSend());return}if(this._sendInFlight){this._queuedSend={html:e,identityMap:t,etag:n};return}this._postUpdate(e,t,n)}_flushQueuedSend(){if(this.isDestroyed||this._sendInFlight)return;let e=this._queuedSend;e&&(this._queuedSend=null,this._postUpdate(e.html,e.identityMap,e.etag))}_relayCommit(){if(this.isDestroyed)return;let e=te(),t=this._savedSnapshot;if(this._savedSnapshot=null,!t||typeof t.html!="string")return;let n=!e&&t.html===this.lastHtml;if(this._setPeerBase(t.html,t.identityMap,t.ticket),n){this._log("Skipping send - HTML unchanged");return}this._enqueueSend(t.html,t.identityMap,e||null)}_postUpdate(e,t,n=null,i=0){this._log(`Sending update (HTML length: ${e.length})`),this._sendInFlight=!0;let r=!1,a=this._profile||ce.legacy;fetch(new URL(a.relayPath,window.location.origin).href,{method:"POST",headers:{"Content-Type":"application/json",[a.documentHeader]:window.location.href,[Ne]:String(1)},body:JSON.stringify({[a.snapshotKey]:e,sender:this.clientId,identityMap:t,...n?{etag:n}:{}})}).then(l=>{l.ok||(console.warn("[LiveSync] Save returned status:",l.status),r=l.status>=500||l.status===408||l.status===429)}).catch(l=>{console.error("[LiveSync] Save failed:",l),this.onError&&this.onError(l),r=!0}).finally(()=>{this._sendInFlight=!1;let l=this._queuedSend;if(this._queuedSend=null,l){this._postUpdate(l.html,l.identityMap,l.etag);return}!r||!n||i>=3||this.isDestroyed||(this._sendInFlight=!0,setTimeout(()=>{if(this._sendInFlight=!1,this.isDestroyed)return;let h=this._queuedSend;this._queuedSend=null,h?this._postUpdate(h.html,h.identityMap,h.etag):this._postUpdate(e,t,n,i+1)},500*2**i))})}_startPresence(e,t){return this.isDestroyed||this._startGen!==t||this._presenceLease?null:e.connect({send:n=>this._postPresence(n)}).then(n=>this.isDestroyed||this._startGen!==t?(n?.detach(),null):(this._presenceLease=n||null,Pe("presence-editing")),()=>!1).then(n=>{if(!(!n||this.isDestroyed||this._startGen!==t||this._editing))return R().then(i=>{this.isDestroyed||this._startGen!==t||this._editing||(this._editing=new i.EditingSender({}),this._editing.start(),this._editing.roster(this._lastRoster))})})}_postPresence(e){let t=new URL("/_/presence",window.location.origin);return t.searchParams.set("client-id",this.clientId),fetch(t.href,{method:"POST",headers:{"Content-Type":"application/json","Document-URL":window.location.href},body:JSON.stringify(e)}).then(n=>n.ok,()=>!1)}_maybeAcceptExternalChange(e){if(this.lane!=="live")return!1;let t=e.data;return t&&t.kind==="external-change"?(typeof t.html=="string"?this._enqueueExternal(t.html,e.seq,t.etag,t.by):this._fetchExternalChange(e.seq),!0):typeof e.msg=="string"&&e.msg.endsWith("changed on disk outside this tab")?(this._fetchExternalChange(e.seq),!0):!1}_enqueueExternal(e,t,n,i){if(typeof t=="number"){if(t<=this._lastExternalSeq){this._log(`Dropping replayed external change: seq=${t}`);return}this._lastExternalSeq=t}this._pendingExternal={html:e,seq:t,saveEpoch:this._saveEpoch,etag:typeof n=="string"&&n?n:null,by:i??null},this._scheduleNextFrame()}_fetchExternalChange(e){if(typeof e=="number"){if(e<=this._lastExternalSeq)return;this._lastExternalSeq=e}this._fetchServedDocument(e)}_fetchServedDocument(e,{attempt:t=0,repair:n=!1,startup:i=!1}={}){if(i&&(this._morphInFlight||this._pendingHtml!=null||this._pendingExternal!=null)){this._retryStartup(t);return}let r=this._saveEpoch,a=this._startGen,l=this.lastSeenSeq,h=this._applyGen,c=++this._servedFetchId;n&&typeof e!="number"&&(e=this._lastExternalSeq),fetch(new URL(window.location.href),{cache:"no-store"}).then(d=>d.ok?d.text():null).then(d=>{if(this.isDestroyed||d==null||this._startGen!==a)return;let f=mt(d),y=i||n&&!!f;if(y){if(c!==this._servedFetchId){n&&this._retryStartup(t+1,{repair:n,startup:i},typeof e=="number"?Math.max(e,this._lastExternalSeq):e);return}if(r!==this._saveEpoch||l!==this.lastSeenSeq||h!==this._applyGen||this._morphInFlight||this._pendingHtml!=null||this._pendingExternal!=null){this._retryStartup(t+1,{repair:n,startup:i},e);return}if(f){if(f===ne()){(n||i)&&this.lane==="saved"&&(this._represented=Object.freeze({bytes:d,etag:f,seq:e??null}));return}}else if(!n)return}else if(typeof e=="number"&&e<this._lastExternalSeq){n&&t<3&&this._fetchServedDocument(this._lastExternalSeq,{attempt:t+1,repair:n,startup:i});return}else if(this._saveEpoch>r){t<3&&(console.log("[LiveSync] Refetching external change: own save landed mid-fetch"),this._fetchServedDocument(e,{attempt:t+1,repair:n,startup:i}));return}this._pendingExternal={html:d,seq:e,saveEpoch:r,etag:f,by:null,fetchOptions:{repair:n,startup:i,attempt:t,versionCheck:y},startGen:a,seenSeq:l,applyGen:h,fetchId:c},this._scheduleNextFrame()}).catch(d=>{this._log("External-change fetch failed",d),typeof e=="number"&&this._lastExternalSeq===e&&(this._lastExternalSeq=e-1)})}_retryStartup(e=0,t={startup:!0},n){this.isDestroyed||e>3||(clearTimeout(this._startupRetry),this._startupRetry=setTimeout(()=>{if(this._startupRetry=null,!this.isDestroyed){if(this._morphInFlight||this._pendingHtml!=null||this._pendingExternal!=null){this._retryStartup(e,t,n);return}this._fetchServedDocument(n,{...t,attempt:e})}},16))}applyUpdate(e,t,n,i,r){this.isDestroyed||(this._pendingHtml=e,this._pendingSeq=t,this._pendingIdentityMap=n,this._pendingEtag=i??null,this._pendingBy=r??null,this._scheduleNextFrame())}prepareHandoff(e={}){return this._handoff?Promise.resolve(this._handoff):this.isDestroyed?Promise.reject(new Error("LiveSync: stopped")):(this._handoffHeld=!0,this._rafHandle!=null&&(this._cancelFrame(this._rafHandle),this._rafHandle=null),import("./c-GSFIGKOP.js").then(({engineHandoff:t})=>t(this,e)).then(t=>this._handoff=t))}_scheduleNextFrame(){this.isDestroyed||this._handoffHeld||this._rafHandle==null&&(this._morphInFlight||(this._rafHandle=this._requestFrame(()=>this._runPending())))}async _runPending(){if(this._rafHandle=null,this.isDestroyed)return;if(!C()){this._morphInFlight=!0;try{await W()}catch(r){this._log("Merge engine failed to load",r),this._engineRetry=setTimeout(()=>this._scheduleNextFrame(),2e3);return}finally{this._morphInFlight=!1}if(this.isDestroyed)return}let e=this._pendingExternal,t=e?.fetchOptions||null,n=!!(t?.startup||t?.versionCheck),i=!1;if(e!=null&&(n&&this._pendingHtml!=null?i=!1:this._pendingHtml==null?i=!0:i=!(typeof e.seq=="number"&&typeof this._pendingSeq=="number"&&this._pendingSeq<e.seq)),i)if(this._pendingExternal=null,typeof e.seq=="number"&&e.seq<this._lastExternalSeq)n&&t?.repair?this._retryStartup((t.attempt||0)+1,t,this._lastExternalSeq):this._log("Dropping superseded external change at drain");else if(n&&e.startGen!==this._startGen)this._log("Dropping superseded startup check at drain");else if(n&&e.fetchId!==this._servedFetchId)t?.repair?this._retryStartup((t.attempt||0)+1,t,this._lastExternalSeq):this._log("Dropping superseded startup check at drain");else if(n&&(e.saveEpoch!==this._saveEpoch||e.seenSeq!==this.lastSeenSeq||e.applyGen!==this._applyGen))this._retryStartup((t.attempt||0)+1,t,e.seq);else if(n&&e.etag!=null&&e.etag===ne())this._log("Startup check found the same version: nothing to apply");else if(!n&&e.saveEpoch!==this._saveEpoch)console.log("[LiveSync] Refetching external change: own save landed after queue"),this._fetchServedDocument(e.seq,t||{});else{this._morphInFlight=!0;try{await this._doApplyExternal(e.html,e.seq,e.etag,e.by,t)}catch(r){console.error("[LiveSync] applyExternal failed:",r)}finally{this._morphInFlight=!1}}else{let r=this._pendingHtml,a=this._pendingSeq,l=this._pendingIdentityMap,h=this._pendingEtag,c=this._pendingBy;if(this._pendingHtml=null,this._pendingSeq=null,this._pendingIdentityMap=null,this._pendingEtag=null,this._pendingBy=null,r==null)return;this._morphInFlight=!0;try{await this._doApplyUpdate(r,a,l,h,c)}catch(d){console.error("[LiveSync] applyUpdate failed:",d)}finally{this._morphInFlight=!1}}!this.isDestroyed&&(this._pendingHtml!=null||this._pendingExternal!=null)&&this._scheduleNextFrame()}_ticket(){return++this._agreeSeq}_setDiskBase(e,t){t<=this._diskBaseTicket||(this._diskBase=e,this._diskBaseTicket=t)}_setPeerBase(e,t,n){return n<this._peerBaseTicket?!1:(this._peerBaseTicket=n,this.lastHtml=e,this._lastIdentityMap=t&&typeof t=="object"&&!Array.isArray(t)?t:null,!0)}_requestFrame(e){return typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(e):setTimeout(e,16)}_cancelFrame(e){if(typeof window<"u"&&typeof window.cancelAnimationFrame=="function"){window.cancelAnimationFrame(e);return}clearTimeout(e)}async _mergeIncoming(e,t,{base:n,baseIdentityMap:i=null,captureLocal:r,synthetic:a,source:l="peer",seq:h=null,etag:c=null,extra:d={}}){C()||await W();let{beginApply:f,completeApply:y,failApply:m,beginLineageCapture:w}=Xe()||await Y(),p,v=o=>{p=w(x.list());try{let g=C().HyperMorph.mergeDocument({...o,lineage:p.lineage});return p.returned(),g}catch(g){throw p.invalidate(x.list()),p.finish(x.list()),g}},b=this.identity,st=xe,T=yt(new WeakMap),B=o=>pe(o)?{first:T,map:o,then:T}:T,N=a?o=>T(o)||b.idOf(k(o)||o)||null:T,I=e,me=new Map;if(pe(t)){I=new DOMParser().parseFromString(e,"text/html"),ee(I);let o=C().HyperMorph.importMap(I.documentElement,t);for(let g of I.querySelectorAll("[data-id], [id]")){let S=T(g),we=S&&o.get(g);we&&me.set(S,we)}}I=Qe(I);let X={live:document,remote:I,ignore:o=>o.matches(tt),opaque:o=>o.matches(nt)||j()&&Ce(o),remoteWins:o=>o.matches(pt),ignoreAttribute:(o,g,S)=>_t(o,g,S)||j()&&He(S||o,g),attributeMerge:Je,protectFocusedValue:!0,keepLiveOnly:l==="peer",scripts:{mergeTags:C().mergeTagRecognizers},hooks:{beforeAttributeUpdated:st},...d},ve=this.lane==="live"&&E(),Se=le(),O,K=null,L=null;if(n==null)O=v({...X,base:null,local:{root:J(r()),toLive:k},identity:{local:N,remote:B(t)}});else if(ve){let o=r(),g=o.cloneNode(!0);K=J(o),L=f({source:l,seq:h,etag:c,root:K,recoveryRoot:g,domain:l==="disk"?"save":"sync"});try{O=v({...X,base:Qe(n),local:{root:K,toLive:k},identity:{base:B(i),local:N,remote:B(t)}})}catch(S){throw m(L,S),S}}else{let o=J(r()),g=o.ownerDocument;g.documentElement!==o&&g.replaceChild(o,g.documentElement),O=v({...X,base:g,local:{root:o,toLive:k},fastPath:!0,identity:{base:N,local:N,remote:B(t)}})}let U=this._ticket();this._morphTicket=U;let H;try{H=await O}catch(o){p.invalidate(x.list());try{L&&m(L,o,{ticket:U})}finally{p.finish(x.list())}throw o}let rt=le().gen!==Se.gen,Ee;try{p.prepareComplete(H,x.list()),Ee=L?y(L,H.conflicts,{ticket:U}):[]}finally{p.finish(x.list())}ve&&!H.localDiverged&&Oe(Se);let lt=new Set(pe(t)?Object.values(t):[]);for(let[o,g]of H.identities){let S=lt.has(g)?g:me.get(g);S&&b.adopt(o,S)}return{report:H,ticket:U,typedDuringWait:rt,conflictIds:Ee}}_saveAfterMerge(e,t){(e||t)&&Ue()&&(u?u.savePageThrottled():ft())}async _doApplyUpdate(e,t,n,i,r=null){if(oe(e)){await he();return}this.lane==="live"&&!u&&await R(),this._log("applyUpdate - pausing mutations and morphing"),this.isPaused=!0;let a=window.scrollX,l=window.scrollY;A.pause(),se();let h=!1,c=!1,d=!1;try{if(this.lane==="live"&&E()&&this.lastHtml===null){console.log("[LiveSync] Holding incoming update: unsaved local edits and no baseline to merge against"),this._setHeld("live",!0,null);let p=this._saveEpoch,v=this.lastSeenSeq;clearTimeout(this._holdRetryPeer),this._holdRetryPeer=setTimeout(()=>{this._holdRetryPeer=null,!(this.isDestroyed||this._pendingHtml!=null)&&this._saveEpoch===p&&this.lastSeenSeq===v&&(this._pendingHtml=e,this._pendingSeq=t,this._pendingIdentityMap=n,this._pendingBy=r,this._scheduleNextFrame())},3e3);return}this._setHeld("live",!1);let{report:f,ticket:y,typedDuringWait:m,conflictIds:w}=await this._mergeIncoming(e,n,{base:this.lastHtml,baseIdentityMap:this._lastIdentityMap,captureLocal:()=>F({flushUndo:!1}),synthetic:!0,source:"peer",seq:t,etag:i});if(h=f.localDiverged,c=m,Z(),window.scrollTo(a,l),this._setPeerBase(e,n,y),this._applyGen++,this._acceptedSaveTicket>y||(typeof i=="string"&&i?(P(i),d=!0):ie()),this.lane==="live"&&!h&&!E()){let{forSave:p,forComparison:v,forDirty:b}=z({emitForSync:!1,flushUndo:!1});u.setLastSavedBaselines(v,b),this._setDiskBase(p,this._ticket())}this.lane==="saved"&&(this._represented=Object.freeze({bytes:e,etag:i||null,seq:t??null})),document.dispatchEvent(new CustomEvent("clay:sync-applied",{detail:{seq:t,source:this.lane==="saved"?"disk":"peer",lane:this.lane,by:r||null,html:e,report:f,unresolved:this.unresolvedConflicts,conflictIds:w}}))}finally{this._log("applyUpdate - morph complete, resuming mutations"),A.resume(),re(),await new Promise(f=>setTimeout(f,0)),this.isPaused=!1}d&&u?.conflictResolvedBySync(i),this._saveAfterMerge(h,c)}async _doApplyExternal(e,t,n=null,i=null,r=null){if(oe(e)){await he();return}this.lane==="live"&&!u&&await R();let a=this._diskBase;this._log(`applyExternal - external disk change (seq=${t})`),this.isPaused=!0;let l=window.scrollX,h=window.scrollY;A.pause(),se();let c=!1,d=!1,f=!1;try{if(this.lane==="live"&&E()&&this._diskBase===null){if(console.log("[LiveSync] Holding external change: unsaved local edits and no baseline to merge against"),this._setHeld("external",!0,null),r?.startup||r?.versionCheck){clearTimeout(this._holdRetryExt),this._holdRetryExt=setTimeout(()=>{if(this._holdRetryExt=null,this.isDestroyed)return;let b=typeof t=="number"?Math.max(t,this._lastExternalSeq):t;this._retryStartup(0,r,b)},3e3);return}let v=this._saveEpoch;clearTimeout(this._holdRetryExt),this._holdRetryExt=setTimeout(()=>{this._holdRetryExt=null,!(this.isDestroyed||this._pendingExternal!=null)&&(this._pendingExternal={html:e,seq:t,saveEpoch:v,etag:n,by:i},this._scheduleNextFrame())},3e3);return}this._setHeld("external",!1);let{report:y,ticket:m,typedDuringWait:w,conflictIds:p}=await this._mergeIncoming(e,null,{base:this._diskBase,captureLocal:()=>qe().saveClone,synthetic:!1,source:"disk",seq:t,etag:n,extra:{beforeApply:v=>vt(v.documentElement,this.lane)}});if(c=y.localDiverged,d=w,Z(),this._setDiskBase(e,m),window.scrollTo(l,h),this._acceptedSaveTicket>m||(typeof n=="string"&&n?(P(n),f=!0):ie()),this.lane==="live"&&!c&&!E()){u.setLastSavedBaselines(...St()),u.setUnsavedChanges(!1);let v=F({flushUndo:!1});this._setPeerBase(q(v),this.identity.exportMap(v,k),m),this._applyGen++}this.lane==="saved"&&(this._represented=Object.freeze({bytes:e,etag:n||null,seq:t??null})),document.dispatchEvent(new CustomEvent("clay:sync-applied",{detail:{seq:t,source:"disk",etag:typeof n=="string"&&n?n:null,by:i||null,html:e,report:y,conflictIds:p,unresolved:this.unresolvedConflicts}}))}finally{this._log("applyExternal - morph complete, resuming mutations"),A.resume(),re(),await new Promise(y=>setTimeout(y,0)),this.isPaused=!1}f&&u?.conflictResolvedBySync(n),this._saveAfterMerge(c,d),a!=null&&$(a)===$(e)&&u&&u.schedulePaintHeal(()=>this._diskBase==null?null:$(this._diskBase))}handleNotification({msgType:e,msg:t,action:n,persistent:i,data:r}){this._log(`Notification received: ${e} - ${t}`),e==="data-loss"||(i&&window.toastPersistent?window.toastPersistent(t,e):window.toast?window.toast(t,e):console.log(`[LiveSync] Notification: ${t}`)),document.dispatchEvent(new CustomEvent("clay:notification",{detail:{msgType:e,msg:t,action:n,persistent:i,data:r}})),this.onNotification&&this.onNotification({msgType:e,msg:t,action:n,persistent:i,data:r})}stop(){this.cleanup(),this.isDestroyed=!0,console.log("[LiveSync] Stopped")}editParticipant(){return R().then(e=>e.syncParticipant(this))}},ye=new ge;typeof window<"u"&&!Ze&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>ye.start()):ye.start());var Yt=(s,e,t)=>W().then(({morph:n})=>n(s,e,t));var Jt=ye;export{x as a,tt as b,pt as c,ge as d,ye as e,Yt as f,Jt as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as b,e as m}from"./c-PGRCK73F.js";import"./c-R7IWVINQ.js";import"./c-IW6GGOU2.js";import"./c-HAWFNBYG.js";import{e as d,f as h,g as l,h as w}from"./c-4DFEJ2PO.js";import"./c-6CRUUXOX.js";import"./c-WWXIDH4O.js";import"./c-TCCA5BZN.js";import"./c-5V3MOVJT.js";import"./c-6NC5I2TV.js";import"./c-XCNTK76U.js";import"./c-ZWIOJGMT.js";import"./c-IJUK2GPW.js";import{c as T}from"./c-BPF2NSPV.js";import{e as v}from"./c-SPIORRYS.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";v(b);var A=1,y=class extends Error{constructor(a,o){super(o),this.name="PageCheckpointError",this.code=a}},k=(e,a)=>{throw new y(e,a)},t=(e,a)=>({ok:!1,code:e,message:a}),P=/^[0-9a-f]{64}$/,j=/^[0-9a-f]{32}$/,E=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function H(e){return{v:e.v,g:e.g,y:{...e.y??{}}}}function I(e){let a;try{a=JSON.parse(e)}catch{k("invalid-state","The page state is not JSON")}return(!E(a)||a.v!==1)&&k("invalid-state","Expected a version 1 Yjs page value"),{state:H(a),bytes:h(a)}}var S=e=>e==null?"":String(e);async function N({href:e,etag:a,fetch:o=globalThis.fetch,signal:s=null}={}){if(typeof a!="string"||!a)return t("missing-etag","A conditional read needs the accepted ETag");if(typeof e!="string"||!e)return t("no-page-state","This host names no page-state resource");if(typeof o!="function")return t("unavailable","This tab cannot read the page state");let i=globalThis.location?.href??"http://localhost/",u;try{u=new URL(e,i).href}catch{return t("no-page-state","The page-state resource is not a URL")}let c=T(),n;try{n=await o(u,{method:"GET",credentials:c?"omit":"same-origin",headers:{"If-Match":a,"Document-URL":globalThis.location?.href??i},cache:"no-store",redirect:"manual",signal:s})}catch{return t("unavailable","The page-state request did not complete")}if(!n||typeof n.status!="number")return t("unavailable","The page-state request did not answer");if(n.status===412)return t("etag-mismatch","Another version of this document is stored");if(n.status===428)return t("etag-required","The host needs a condition this read cannot send");if(n.status===404)return t("no-page-state","This host keeps no page state");if(!n.ok)return t("unavailable",`The host answered ${n.status}`);let r;try{r=JSON.parse(await n.text())}catch{return t("invalid-state","The page-state answer is not JSON")}return!E(r)||r.version!==A?t("unsupported-version","Unknown page-state version"):typeof r.tag!="string"||!r.tag?t("invalid-state","The page-state answer carries no page tag"):typeof r.stateHash!="string"||!P.test(r.stateHash)?t("invalid-state","The page-state answer carries no state digest"):typeof r.generation!="string"||!j.test(r.generation)?t("invalid-state","The page-state answer carries no generation"):typeof r.etag!="string"||!r.etag?t("invalid-state","The page-state answer carries no ETag"):Object.hasOwn(r,"documentId")?{ok:!0,version:r.version,documentId:r.documentId,generation:r.generation,etag:r.etag,stateHash:r.stateHash,tag:r.tag}:t("invalid-state","The page-state answer carries no document identity")}async function _(e,{accepted:a,article:o,etag:s}={}){if(!e||e.ok!==!0)return t(e?.code??"unavailable",e?.message??"The page state was not read");if(S(e.documentId)!==S(a?.authority?.documentId))return t("foreign-document","The page state belongs to another document");if(typeof a?.lineage?.generation!="string"||e.generation!==a.lineage.generation)return t("foreign-generation","The page state belongs to another generation");if(e.etag!==s)return t("etag-mismatch","The page state belongs to another version of this document");let i,u;try{({state:u,bytes:i}=I(e.tag))}catch(n){return t(n?.code??"invalid-state",n?.message??"The page state does not decode")}if(await d(i)!==e.stateHash)return t("state-digest-mismatch","The page state is not the one the host hashed");if(typeof o!="string")return t("missing-article","A proof names the final outgoing article");let c;try{c=m(u)}catch(n){return t("invalid-state",n?.message??"The page state does not project")}return c!==o?t("article-mismatch","The page state does not project to the accepted article"):{ok:!0,state:u,receipt:{file:e.etag,pageState:e.stateHash}}}async function O(e,a){let o=(a||[]).map(({id:s,revision:i})=>({id:s,revision:i}));try{return{ok:!0,proof:e,covered:await w(e,o)}}catch(s){return t(s?.code??"invalid-proof",s?.message??"The proof does not validate")}}async function R({capture:e,records:a=[],accepted:o,article:s,state:i=null,etag:u=null}={}){if(!i)return t("no-capture-state","No page state was pinned to this capture");if(typeof u!="string"||!u)return t("missing-etag","An accepted save with no ETag proves no stored pair");if(typeof s!="string")return t("missing-article","The accepted bytes hold no article");let c,n;try{c=m(i),n=h(i)}catch(p){return t(p?.code??"invalid-state",p?.message??"The pinned page state does not decode")}if(c!==s)return t("article-mismatch","The pinned page state does not project to the accepted article");let r;try{r=await l({capture:e,records:a,accepted:o,article:s,state:i,receipt:{file:u,pageState:await d(n)}})}catch(p){return t(p?.code??"invalid-proof",p?.message??"The proof could not be built")}return O(r,a)}async function B({read:e,capture:a,records:o=[],accepted:s,article:i,etag:u=null}={}){let c=await _(e,{accepted:s,article:i,etag:u});if(!c.ok)return c;let n;try{n=await l({capture:a,records:o,accepted:s,article:i,state:c.state,receipt:c.receipt})}catch(r){return t(r?.code??"invalid-proof",r?.message??"The proof could not be built")}return O(n,o)}async function G({channel:e,records:a=[],capture:o,accepted:s,article:i,state:u=null,etag:c=null,href:n=null,read:r=N,fetch:p}={}){if(!e||typeof e.checkpoint!="function")return{ok:!1,code:"no-channel",retired:[],proof:null};let f=await R({capture:o,records:a,accepted:s,article:i,state:u,etag:c});if(!f.ok){let x=await r({href:n,etag:c,fetch:p});f=await B({read:x,capture:o,records:a,accepted:s,article:i,etag:c})}if(!f.ok)return{ok:!1,code:f.code,retired:[],proof:null};let g=await e.checkpoint({records:f.covered,proof:f.proof});return!g||g.ok!==!0?{ok:!1,code:g?.code??"checkpoint-failed",retired:[],proof:f.proof}:{ok:!0,retired:g.retired??[],proof:f.proof}}export{A as PAGE_STATE_VERSION,y as PageCheckpointError,R as captureProof,G as checkpointAccepted,N as readPageState,B as refetchedProof,_ as verifyPageState};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as K}from"./c-BWFVSBDF.js";import{d as A}from"./c-
|
|
1
|
+
import{a as K}from"./c-BWFVSBDF.js";import{d as A}from"./c-VRZN56XY.js";var p=1,P=8*1024,B=256,L=1024,Y=128,X=128,G=Object.freeze(["title","description","labels","members","dates","checklist","comment","attachments"]),m=250,E=5e3,ie=15e3;var W=new Set(["kind","id","field"]),$=new Set(["kind","v","epoch","generation","selection"]),q=new Set(["kind","anchor","head"]),F=new Set(["kind","ids"]),J=new Set(["kind","block","row","col"]),V=new Set(["block","rel"]),H=/^[\x20-\x7e]+$/,U=/^[A-Za-z0-9+/]+={0,2}$/,Z=/[\u0000-\u001f\u007f]/,o=e=>({ok:!1,reason:e}),a=e=>({ok:!0,target:e}),g=e=>!!e&&typeof e=="object"&&!Array.isArray(e),d=(e,t)=>{for(let n of Object.keys(e))if(!t.has(n))return!1;return!0};function T(e){let t=0;for(let n of e){let s=n.codePointAt(0);t+=s<128?1:s<2048?2:s<65536?3:4}return t}function f(e){return typeof e=="string"&&e.length>0&&!Z.test(e)&&T(e)<=B}function Q(e){if(typeof e!="string"||!e.length||e.length%4!==0||!U.test(e))return!1;let t=e.endsWith("==")?2:e.endsWith("=")?1:0;return e.length/4*3-t<=L}function _(e){return!g(e)||!d(e,V)||!f(e.block)||!Q(e.rel)?null:{block:e.block,rel:e.rel}}function v(e){if(!g(e))return null;if(e.kind==="text"){if(!d(e,q))return null;let t=_(e.anchor),n=_(e.head);return t&&n?{kind:"text",anchor:t,head:n}:null}if(e.kind==="blocks"){if(!d(e,F)||!Array.isArray(e.ids)||!e.ids.length||e.ids.length>X)return null;for(let t of e.ids)if(!f(t))return null;return{kind:"blocks",ids:[...e.ids]}}return e.kind==="cell"?!d(e,J)||!f(e.block)||!f(e.row)||!f(e.col)?null:{kind:"cell",block:e.block,row:e.row,col:e.col}:null}function w(e){return T(JSON.stringify(e))<=P}function ee(e){if(!d(e,W))return o("key");let t=e.id;if(typeof t!="string"||!t.length||t.length>Y||!H.test(t))return o("id");if(e.field===void 0){let s={kind:"record",id:t};return w(s)?a(s):o("size")}if(typeof e.field!="string"||!G.includes(e.field))return o("field");let n={kind:"record",id:t,field:e.field};return w(n)?a(n):o("size")}function te(e){if(!d(e,$))return o("key");if(e.v!==p)return o("version");if(!f(e.epoch))return o("epoch");if(!Number.isSafeInteger(e.generation)||e.generation<0)return o("generation");let t=v(e.selection);if(!t)return o("selection");let n={kind:"page",v:p,epoch:e.epoch,generation:e.generation,selection:t};return w(n)?a(n):o("size")}function y(e){return e===null?a(null):typeof e=="string"?K.test(e)?a(e):o("path"):g(e)?e.kind==="record"?ee(e):e.kind==="page"?te(e):o("kind"):o("shape")}function O(e){let t=y(e===void 0?null:e);return!t.ok||t.target!==null&&typeof t.target=="object"&&t.target.kind!=="record"?null:t.target}function R(e){return e==null?"":typeof e=="string"?`path:${e}`:`target:${JSON.stringify(e)}`}function z(e,t=null){let n=Array.isArray(e)?e:[],s=[];for(let i of n){if(!g(i))continue;let r=f(i.id)?i.id:null;if(!r)continue;let l=Number.isSafeInteger(i.n)&&i.n>=0?i.n:0,h=t&&t.get(r);if(h&&l<h.n){s.push(h);continue}let u=y(i.editing===void 0?null:i.editing);s.push({id:r,you:i.you===!0,n:l,editing:u.ok?u.target:null})}return s}function I(e){if(!g(e))return null;let t=f(e.id)?e.id:null,n=typeof e.token=="string"&&e.token.length?e.token:null;return t&&n?{id:t,token:n}:null}function N({target:e=null,session:t=null,n=0}){if(e==null||typeof e=="string")return{editing:e??null};let s=t&&typeof t.token=="string"&&t.token.length?t.token:null;return s?!Number.isSafeInteger(n)||n<0?null:{v:p,session:s,n,editing:e}:e.kind==="record"?{editing:e}:null}var ne=()=>Object.freeze({supported:!1,recordAwareness:!1,pageAwareness:!1,people:Object.freeze([]),anonymous:0}),S=class{constructor(){this.supported=!1,this.recordAwareness=!1,this.pageAwareness=!1,this.people=[],this.anonymous=0,this.snapshot=ne(),this.listeners=new Set,this.sessions=new Map,this.session=null,this.target=null,this.heldKey="",this.owner=null,this.explicit=!1,this.connecting=null,this.n=0,this.sentKey=null,this.timer=null,this.timerKind=null,this.inflight=!1}getSnapshot(){return this.snapshot}subscribe(t){if(typeof t!="function")throw new TypeError("clay.presence.subscribe needs a listener function");return this.listeners.add(t),t(this.snapshot),()=>{this.listeners.delete(t)}}setCapabilities({supported:t=!1,recordAwareness:n=!1,pageAwareness:s=!1}={}){let i=t===!0,r=n===!0,l=s===!0;return i===this.supported&&r===this.recordAwareness&&l===this.pageAwareness?this.snapshot:(this.supported=i,this.recordAwareness=r,this.pageAwareness=l,this.emit())}receive(t){let n=t&&typeof t=="object"?t:{},s=Array.isArray(n.people)?n.people:[],i=this.sessions,r=new Map,l=[];for(let c of s){if(!c||typeof c.id!="string"||!c.id)continue;let D=typeof c.name=="string"&&c.name.trim()?c.name.trim():"Someone",k=z(c.sessions,i);for(let b of k)r.set(b.id,b);let x={id:c.id,name:D,you:c.you===!0,editing:O(c.editing),sessions:k};typeof c.canEdit=="boolean"&&(x.canEdit=c.canEdit),l.push(x)}this.people=l,this.sessions=r;let h=n.anonymous;this.anonymous=typeof h=="number"&&Number.isFinite(h)&&h>0?Math.floor(h):0;let u=I(n.selfSession),M=!this.session||!this.session.token;u&&(this.session=u);let j=this.emit();return u&&M&&this.owner&&this.target!==null&&(this.sentKey=null,this.flush()),j}clear(){return this.people=[],this.anonymous=0,this.sessions=new Map,this.session=null,this.cancel(),this.sentKey=null,this.emit()}setTarget(t){let n=y(t===void 0?null:t);return n.ok?(this.explicit=!0,this.hold(n.target)):!1}setGeneric(t){if(this.explicit)return!1;let n=y(t===void 0?null:t);return n.ok?this.hold(n.target):!1}releaseTarget(){return this.explicit?(this.explicit=!1,this.hold(null)):!1}hold(t){let n=R(t);return n===this.heldKey?(this.owner&&this.sentKey!==n&&this.schedule(m),!0):(this.target=t,this.heldKey=n,t===null?(this.cancel(),this.flush(),!0):(this.schedule(m),!0))}attachTransport(t){if(!t||typeof t.send!="function")throw new TypeError("clay.presence.attachTransport needs a transport with a send function");let n=this,s={send:t.send,get active(){return n.owner===s},detach(){n.owner===s&&(n.owner=null,n.session=null,n.n=0,n.sentKey=null,n.cancel(),n.target=null,n.heldKey="",n.explicit=!1,n.clear())}};return this.owner=s,this.session=null,this.n=0,this.sentKey=null,this.cancel(),this.target!==null&&this.flush(),s}connect({send:t=null}={}){return this.connecting?this.connecting:(this.connecting=A().then(n=>{let s=Array.isArray(n?.extensions)?n.extensions:[],i=n?.document&&typeof n.document=="object"?n.document.awareness:null;if(i&&i.transport==="broadcast"&&(s.includes("page-awareness-v1")||s.includes("record-awareness-v1"))){let r=typeof i.scope=="string"&&i.scope?i.scope:null;return import("./c-Q622NS2Y.js").then(({localPresence:l})=>l({scope:r,store:this}).start()??null)}return typeof t=="function"&&s.includes("presence-editing")?this.attachTransport({send:t}):null}).finally(()=>{this.connecting=null}),this.connecting)}reconnect(){this.session=null,this.n=0,this.sentKey=null,this.cancel(),!(!this.owner||this.target===null)&&this.flush()}emit(){let t=this.people.map(n=>Object.freeze({...n,sessions:Object.freeze(n.sessions)}));this.snapshot=Object.freeze({supported:this.supported,recordAwareness:this.recordAwareness,pageAwareness:this.pageAwareness,people:Object.freeze(t),anonymous:this.anonymous});for(let n of[...this.listeners])n(this.snapshot);return this.snapshot}schedule(t,n="coalesce"){if(this.timer!==null){if(this.timerKind==="coalesce")return;clearTimeout(this.timer)}this.timerKind=n,this.timer=setTimeout(()=>{this.timer=null,this.timerKind=null,this.flush()},t)}cancel(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null,this.timerKind=null)}renew(){this.timer!==null||!this.owner||this.target===null||this.schedule(E,"renew")}flush(){if(this.inflight)return;let t=this.owner;if(!t)return;let n=this.n+1,s=N({target:this.target,session:this.session,n});if(!s)return;this.cancel(),this.sentKey=this.heldKey,this.inflight=!0,s.v===p&&(this.n=n);let i=r=>{if(this.inflight=!1,this.owner===t){if(this.heldKey!==this.sentKey){this.flush();return}r?this.renew():this.schedule(E,"renew")}};Promise.resolve(t.send(s)).then(r=>i(!!r),()=>i(!1))}},C=new S,le=C;typeof window<"u"&&(window.clay=window.clay||{},window.clay.presence||(window.clay.presence=C));export{p as a,E as b,ie as c,y as d,S as e,C as f,le as g};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./c-VHNSBD2M.js";var l=(e,n)=>Object.assign(new Error(`clayjs: ${e}`),{code:n}),u=(e,n)=>!e||n.seq===null||e.seq===null||n.seq>e.seq?n:e;function a({stream:e,apply:n,retire:f,yieldArticle:i=()=>!1,reclaimArticle:s=()=>!1}){let t=null,r=!1;e.adopt({onSnapshot:o=>(t=u(t,o),!0)});let d=()=>{let o=t;return t=null,o};return{get represented(){return e.represented},get held(){return t??e.represented},yieldArticle(){return r||!i()?!1:(r=!0,!0)},reclaimArticle(){return!r||!s()?!1:(r=!1,!0)},reconcile(){let o=d();return o&&!n(o)?Promise.reject(l("the switch could not apply the saved file","load-failed")):Promise.resolve()},resume(){e.adopt({onSnapshot:n});let o=d();o&&n(o)},commit(){if(!r){let o=d();if(o&&!n(o))return!1}return e.represented.bytes===null?!1:(e.stop(),f())}}}async function c({stream:e,options:n,apply:f,retire:i,yieldArticle:s=()=>!1,reclaimArticle:t=()=>!1}){if(e)return a({stream:e,apply:f,retire:i,yieldArticle:s,reclaimArticle:t});let r=await import("./sync/live-sync-
|
|
1
|
+
import"./c-VHNSBD2M.js";var l=(e,n)=>Object.assign(new Error(`clayjs: ${e}`),{code:n}),u=(e,n)=>!e||n.seq===null||e.seq===null||n.seq>e.seq?n:e;function a({stream:e,apply:n,retire:f,yieldArticle:i=()=>!1,reclaimArticle:s=()=>!1}){let t=null,r=!1;e.adopt({onSnapshot:o=>(t=u(t,o),!0)});let d=()=>{let o=t;return t=null,o};return{get represented(){return e.represented},get held(){return t??e.represented},yieldArticle(){return r||!i()?!1:(r=!0,!0)},reclaimArticle(){return!r||!s()?!1:(r=!1,!0)},reconcile(){let o=d();return o&&!n(o)?Promise.reject(l("the switch could not apply the saved file","load-failed")):Promise.resolve()},resume(){e.adopt({onSnapshot:n});let o=d();o&&n(o)},commit(){if(!r){let o=d();if(o&&!n(o))return!1}return e.represented.bytes===null?!1:(e.stop(),f())}}}async function c({stream:e,options:n,apply:f,retire:i,yieldArticle:s=()=>!1,reclaimArticle:t=()=>!1}){if(e)return a({stream:e,apply:f,retire:i,yieldArticle:s,reclaimArticle:t});let r=await import("./sync/live-sync-J7VMYTKS.js").then(({liveSync:d})=>d.prepareHandoff(n));return{get represented(){return r.represented},get held(){return r.held},yieldArticle:s,reclaimArticle:t,reconcile:()=>r.reconcile(),resume:()=>r.resume(),commit:()=>r.commit()&&i()}}async function p(e,{signal:n,deadline:f=15e3}={}){let i=Date.now()+f;for(;e._morphInFlight;){if(n?.aborted)throw e._handoffHeld=!1,l("the switch was cancelled","aborted");if(Date.now()>=i)throw e._handoffHeld=!1,l("the apply did not settle","timeout");await new Promise(t=>setTimeout(t,1))}let s=()=>e._pendingHtml!=null||e._pendingExternal!=null;return{get represented(){return e._represented},get held(){let t=e._represented;return e._pendingHtml!=null&&(t=u(t,{bytes:e._pendingHtml,etag:e._pendingEtag??null,seq:e._pendingSeq??null})),e._pendingExternal&&(t=u(t,{bytes:e._pendingExternal.html,etag:e._pendingExternal.etag??null,seq:e._pendingExternal.seq??null})),t},async reconcile(){if(!(!e._handoff||e.isDestroyed)){for(let t=0;t<8;t++){if(e._morphInFlight){await new Promise(r=>setTimeout(r,1));continue}if(!s())return;await e._runPending()}if(s())throw l("the held frame could not be applied","load-failed")}},resume(){e._handoff&&(e._handoff=null,e._handoffHeld=!1,e._scheduleNextFrame())},commit(){return e._represented.bytes?(e._handoff=null,e._handoffHeld=!1,e.stop(),!0):!1}}}export{p as engineHandoff,c as readerHandoff};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as f,b as u}from"./c-7SWMYKAI.js";import{b as l}from"./c-UGHH4MB3.js";import{a as s}from"./c-
|
|
1
|
+
import{a as f,b as u}from"./c-7SWMYKAI.js";import{b as l}from"./c-UGHH4MB3.js";import{a as s}from"./c-ZWIOJGMT.js";var c=(t=[])=>i=>{let e=(i.getAttribute("clay")??"").split(/\s+/).filter(Boolean),n=["no-dirty",...t].filter(r=>!e.includes(r));n.length&&i.setAttribute("clay",[...e,...n].join(" "))},p=c();function S(t,i){return y(t,i)}function b(t,i,e,n=[]){return y(t,i,e,n)}function y(t,i,e,n=[]){let r=typeof i=="string",a=r?{name:t,legacyId:e}:{href:f(t)},d=e===void 0?[]:document.querySelectorAll(`style[id="${e}"]:not([data-name])`);s.pause();try{l(a);for(let o of d)o.dataset.name=t;if(r){let o=u(t,i,c(n));return e!==void 0&&(o.id=e),o}return u(t,o=>{p(o),o.getAttribute("href")!==t&&o.setAttribute("href",t)})}finally{s.resume()}}export{S as a,b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r="Untitled";function s(i,{custom:l=!1,currentTitle:n="",keepWithoutHeading:f=!1}={}){if(l)return n;let e=i.find(t=>t.t==="heading"&&(t.level??2)===1&&t.parent==null);return!e&&f&&!["",r].includes(String(n).trim())?n:String(e?.c??"").replace(/[\s\uFFFC]+/gu," ").trim()||r}export{r as a,s as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as i,d as n}from"./c-
|
|
1
|
+
import{b as i,d as n}from"./c-WWXIDH4O.js";var{Plugin:g,PluginKey:c}=i,{DecorationSet:p}=n,e=new c("page-highlight");function h(){return new g({key:e,state:{init:()=>p.empty,apply(t,a){let o=t.getMeta(e);return o?p.create(t.doc,o):a.map(t.mapping,t.doc)}},props:{decorations:t=>e.getState(t)}})}export{e as a,h as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as h}from"./c-GFJJEBTU.js";import"./c-BWFVSBDF.js";import{b as m,c as f}from"./c-RVMWGXEJ.js";import{b as n,c as r}from"./c-NUHP2XDB.js";import{e as c}from"./c-VRZN56XY.js";import"./c-OW5QIGG3.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-HA6INT6J.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var x=30,b=6,e=null,u=null;function y(){return u??=Promise.all([import("./c-6HMB24EV.js"),import("./c-ZE46QDIH.js")]).then(([o,t])=>e={pageScheme:o.pageScheme,RUNTIME_ONLY:o.RUNTIME_ONLY,TOKENS:t.TOKENS,SHADOW:t.SHADOW,FONT:`600 11px/1 ${t.FONT_MONO}`,LABEL_FONT:`500 11px/1.4 ${t.FONT_MONO}`}).catch(o=>{throw u=null,o}),u}var O=()=>y().then(()=>!0,()=>!1),a=["all:initial","color-scheme:inherit","direction:ltr","unicode-bidi:isolate"],N="#FFFCF6";function l(o){return o.setAttribute("clay",e.RUNTIME_ONLY),o}function T(o){return{people:o.people.map(i=>({id:i.id,name:i.name,you:i.you})),anonymous:o.anonymous}}var d=class{constructor(){this.roster={people:[],anonymous:0},this.root=null,this.stack=null,this.count=null,this.tip=null,this._gate=null}supported(){return this._gate||(this._gate=Promise.all([c("presence"),c("record-awareness-v1"),c("page-awareness-v1")]).then(([t,i,s])=>(h.setCapabilities({supported:t,recordAwareness:i,pageAwareness:s}),t===!0),()=>!1)),this._gate}async update(t){let i=T(h.receive(t)),s=this.root&&JSON.stringify(i)===JSON.stringify(this.roster);if(this.roster=i,!!await this.supported()){if(s){n(this.root,"color-scheme",e.pageScheme());return}await this.render()}}clear(){h.clear(),this.roster={people:[],anonymous:0},this.root&&(this.root.remove(),this.root=null,this.stack=null,this.count=null,this.tip=null)}async render(){let{people:t,anonymous:i}=this.roster;if(t.length+i<=1){this.hide();return}if(await O()&&this.build()){this.hideTip(),n(this.root,"color-scheme",e.pageScheme()),this.stack.textContent="";for(let s of t)this.stack.appendChild(this.avatar(s));this.stack.firstElementChild&&n(this.stack.firstElementChild,"margin-left","0"),i>0?(this.count.textContent=`+${i} viewing`,n(this.count,"display","inline-block")):(this.count.textContent="",n(this.count,"display","none")),n(this.root,"display","flex")}}hide(){this.root&&(this.hideTip(),this.stack.textContent="",this.count.textContent="",n(this.root,"display","none"))}build(){return this.root?!0:typeof document>"u"||!document.body?!1:(this.root=l(r("div",[...a,`color-scheme:${e.pageScheme()}`,"position:fixed","top:calc(12px + env(safe-area-inset-top,0px))","right:calc(12px + env(safe-area-inset-right,0px))","z-index:2147483000","display:flex","align-items:center","gap:8px","max-width:calc(100vw - 24px)",`font:${e.LABEL_FONT}`,`color:${e.TOKENS.ink}`,"pointer-events:none"])),this.root.setAttribute("data-clay-presence",""),this.count=l(r("span",[...a,"box-sizing:border-box","flex:none","white-space:nowrap","padding:3px 8px","border-radius:0",`background:${e.TOKENS.surface}`,`color:${e.TOKENS.muted}`,`border:1px solid ${e.TOKENS["line-2"]}`,`font:${e.LABEL_FONT}`,"letter-spacing:.02em",`box-shadow:${e.SHADOW}`,"display:none","pointer-events:none"])),this.count.setAttribute("data-clay-presence-count",""),this.stack=l(r("div",[...a,"display:flex","align-items:center","flex:none","pointer-events:none"])),this.tip=l(r("span",[...a,"position:absolute","top:100%","right:0","margin-top:6px","box-sizing:border-box","white-space:nowrap","pointer-events:none","padding:5px 9px","border-radius:0",`background:${e.TOKENS.ink}`,`color:${e.TOKENS.ground}`,`font:${e.LABEL_FONT}`,"letter-spacing:.02em",`box-shadow:${e.SHADOW}`,"display:none"])),this.tip.setAttribute("data-clay-presence-tip",""),this.root.append(this.stack,this.count,this.tip),document.body.appendChild(this.root),!0)}avatar(t){let i=m(t.id),s=[`background-color:${N}`,`color:${i}`,`border-color:${i}`],p=l(r("div",[...a,"box-sizing:border-box","flex:none",`width:${x}px`,`height:${x}px`,"border-radius:0","display:flex","align-items:center","justify-content:center",`font:${e.FONT}`,"letter-spacing:.02em",`margin-left:-${b}px`,"border-width:2px","border-style:solid","background-image:none",`box-shadow:${e.SHADOW}`,"user-select:none","cursor:default","pointer-events:auto",...s],f(t.name)));p.setAttribute("data-clay-presence-avatar","");let g=t.you?`${t.name} (you)`:t.name;return p.addEventListener("mouseenter",()=>this.showTip(g)),p.addEventListener("mouseleave",()=>this.hideTip()),p}showTip(t){this.tip&&(this.tip.textContent=t,n(this.tip,"display","block"))}hideTip(){this.tip&&(this.tip.textContent="",n(this.tip,"display","none"))}},E=new d;var v=E;export{d as Presence,v as default,E as presence};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b as d,c,d as o}from"./c-XCNTK76U.js";import{a as l}from"./c-VKEDWYDF.js";import{e as i}from"./c-OW5QIGG3.js";import{m as u}from"./c-SPIORRYS.js";var n="[editmode\\:contenteditable]";function f(){u(t=>{t.querySelectorAll(n).forEach(o)})}function m(){i&&l(()=>{s()})}function s(t=document){t.querySelectorAll(n).forEach(e=>{a(e);let r=e.getAttribute("inert-contenteditable")??e.getAttribute("contenteditable")??d(e,"inert-contenteditable")??"true",b=r.toLowerCase();e.setAttribute("contenteditable",["","true","false","plaintext-only"].includes(b)?r:"true"),e.removeAttribute("inert-contenteditable")})}function h(){document.querySelectorAll(n).forEach(t=>{o(t),c(t)})}function y(){f(),m()}export{n as a,s as b,h as c,y as d};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as P}from"./c-FDNHHZY5.js";import{a as T,b as E,c as S}from"./c-KBS3UV6B.js";import{l as A}from"./c-3H6BZDNJ.js";import"./c-4DFEJ2PO.js";import"./c-6CRUUXOX.js";import"./c-336SGU5W.js";import"./c-6KEVEQ7L.js";import{A as q}from"./c-5J4E7O4Y.js";import{b as k,m as x}from"./c-WWXIDH4O.js";import"./c-4L3BTFRK.js";import"./c-5V3MOVJT.js";import"./c-VHNSBD2M.js";var R=/^[A-Za-z0-9_-]{8,64}$/,D="@",F=100;function _({view:o=null}={}){if(!o)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let f=o.dom.ownerDocument,y=()=>globalThis.clay?.people??null,l=null;function d(t){let e=o.state;if(!e.selection.empty)return null;let r=e.selection.head;if(r<=t.from||r-t.from>F+1||r>e.doc.content.size)return null;let n=e.doc.resolve(t.from);return!n.parent.isTextblock||n.parent.type.spec.code||r>n.end()||r<n.start()||n.parentOffset&&!/\s/.test(e.doc.textBetween(t.from-1,t.from,"",`
|
|
2
|
+
`))||e.doc.textBetween(t.from,t.from+1)!==D?null:{head:r,query:e.doc.textBetween(t.from+1,r)}}function $(t){try{let e=o.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=o.coordsAtPos(t.from);return{x:Math.max(8,r.left-e.left),y:r.bottom+6-e.top}}catch{return null}}function h(t){let e=t.picker.activeId();e?o.dom.setAttribute("aria-activedescendant",e):o.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&o.dom.removeAttribute("aria-activedescendant")}function m(t){t.picker.show(E(T(t.saved,t.allowed),t.query),$(t)),h(t)}function i(){let t=l;if(t){l=null;for(let[e,r,n,s]of t.listen)e.removeEventListener(r,n,s);o.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&o.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function p(){let t=l;if(!t||o.composing)return;let e=d(t);if(!e)return i();t.query=e.query,m(t)}async function g(t){let e=l;if(!e)return{ok:!1,code:"not-editing"};let r=e.picker.personAt(t),n=d(e);if(!(r&&n&&n.query===e.query&&R.test(String(r.id??""))&&String(r.name??"").trim()))return i(),{ok:!1,code:r?"stale-target":"no-person"};let c=String(r.name).trim();return i(),P(o,()=>{let u=d(e);if(!u||u.query!==e.query)return{ok:!1,code:"stale-target"};let a=o.state.tr.insertText(c,e.from,u.head);return a.addMark(e.from,e.from+c.length,x.marks.mention.create({id:r.id})),a.insertText(" ",e.from+c.length),a.setSelection(k.TextSelection.create(a.doc,e.from+c.length+1)),o.dispatch(q(a)),o.focus(),{ok:!0,id:r.id,label:c}})}function B(t){let e=l;if(!e||A(t,o))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),e.picker.move(t.key==="ArrowDown"?1:-1),h(e)):t.key==="Enter"?(r(),g(e.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),i())}function I(t){let e=y()?.available;e&&Promise.resolve().then(()=>e()).then(r=>{l===t&&(t.allowed=Array.isArray(r)?r:null,m(t))}).catch(()=>{})}function M(t){i();let e=S({document:f,onPick:c=>g(c)}),r={from:t,picker:e,query:"",allowed:null,saved:[],listen:[]};try{r.saved=y()?.list?.()??[]}catch{r.saved=[]}l=r;let n=(c,u,a,b)=>{c.addEventListener(u,a,b),r.listen.push([c,u,a,b])};n(f,"keydown",c=>B(c),!0),n(o.dom,"input",()=>p()),n(o.dom,"keyup",()=>p()),n(o.dom,"compositionend",()=>p()),n(f,"mousedown",c=>{r.picker.el.contains(c.target)||i()},!0),(o.dom.parentElement??f.body).appendChild(e.el);let s=d(r);return s?(r.query=s.query,m(r),I(r),{ok:!0,picker:!0}):(i(),{ok:!1,code:"stale-target"})}return{async run(t={}){let e=Number.isInteger(t?.from)?t.from:null;if(e===null){let r=o.state,n=r.selection.$from;if(!r.selection.empty||!n.parent.isTextblock||n.parent.type.spec.code)return{ok:!1,code:"stale-target"};e=r.selection.from;let s=o.state.tr.insertText(D);s.setSelection(k.TextSelection.create(s.doc,e+1)),o.dispatch(s)}return M(e)},dispose(){i()}}}export{_ as createFeature};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as u}from"./c-XMS6DPBR.js";import"./c-PZ4XEPUP.js";import{g as p,l as w,n as v,q as s}from"./c-OIBUTDXI.js";import{a as f}from"./c-4JZDZFF6.js";import"./c-VAK7SG37.js";import"./c-MFP2ZWD4.js";import{b as c}from"./c-NUHP2XDB.js";import{e as l}from"./c-OW5QIGG3.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-SPIORRYS.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var E="Download a copy, then reduce its size; saving still works.",$="Download a copy to keep your work.",t=null,a=null,o=null,r=null;function m(e){return typeof e!="number"||!Number.isFinite(e)||e<0?"an unknown size":e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.max(1,Math.round(e/1024))} KB`:`${e} bytes`}function z({bytes:e,maxBytes:n,state:g}){let d=`At the last save attempt: ${m(e)} of ${m(n)}.`;return g==="over"?`This host can't save a file this size. ${d} ${$}`:`This file is getting large. ${d} ${E}`}function i(){if(!t)return;let e=window.visualViewport,n=e?Math.max(0,window.innerHeight-e.height-e.offsetTop):0;c(t,"bottom",`calc(${16+n}px + env(safe-area-inset-bottom,0px))`)}function S(){u({})}function b(){t=w("div",["position:fixed","left:50%","transform:translateX(-50%)","z-index:2147483000","display:flex","align-items:center","gap:10px 12px","width:max-content","max-width:calc(100vw - 24px)","flex-wrap:wrap","padding:8px 8px 8px 14px","text-align:left",`color-scheme:${f()}`]),t.setAttribute("clay","editor-ui"),t.setAttribute("data-clay-save-size",""),t.setAttribute("role","status"),a=v("span",[],""),o=p("Download my copy",{small:!0,onClick:S}),s(o,!1,"inline-flex"),t.append(a,o),document.body.appendChild(t),i(),window.visualViewport?.addEventListener("resize",i),window.visualViewport?.addEventListener("scroll",i)}function y(e){t||b(),a.textContent=z(e),s(o,e.state==="over","inline-flex"),i()}function h(){t&&(window.visualViewport?.removeEventListener("resize",i),window.visualViewport?.removeEventListener("scroll",i),t.remove(),t=null,a=null,o=null)}function x(e){let n=e?.detail;n&&(n.state==="near"||n.state==="over"?y(n):h())}function A(){l||M()}function T(e){l&&(r||=new AbortController,document.addEventListener("clay:save-size",x,{signal:r.signal}),document.addEventListener("clay:modechange",A,{signal:r.signal}),e?.type==="clay:save-size"&&x(e))}function M(){r?.abort(),r=null,h()}export{T as start,M as stop};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as u}from"./c-HAWFNBYG.js";var c="clay-seo-title-mode",n=t=>t?.nodeType===9?t.head:t?.tagName==="HEAD"?t:t?.querySelector?.("head")??null;function l(t){let r=n(t);if(!r)return!1;for(let e of r.querySelectorAll("meta"))if((e.getAttribute("name")??"").trim().toLowerCase()===c&&(e.getAttribute("content")??"").trim().toLowerCase()==="custom")return!0;return!1}function f(t){let r=n(t);if(!r||l(t))return!1;let e=r.ownerDocument.createElement("meta");return e.setAttribute("name",c),e.setAttribute("content","custom"),r.insertBefore(e,r.querySelector("title")??r.firstChild),!0}function s(t){return n(t)?.querySelector("title")?.textContent??""}function m(t,r){let e=n(t);if(!e)return!1;let o=e.querySelector("title");if(o)return o.textContent===r?!1:(o.textContent=r,!0);let i=e.ownerDocument.createElement("title");return i.textContent=r,e.insertBefore(i,e.firstChild),!0}function d(t,r){let e=l(t);return{custom:e,title:u(r,{custom:e,currentTitle:s(t)})}}export{l as a,f as b,s as c,m as d,d as e};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{A as U,B as z,C as W,D as y,E,F as m,G as f,H as V,I as N,J as O,M as j,N as x,c as D,d as A,e as g,h as T,s as v,u as S,w as H,x as L,y as X,z as M}from"./c-3H6BZDNJ.js";import"./c-4DFEJ2PO.js";import"./c-6CRUUXOX.js";import"./c-336SGU5W.js";import"./c-6KEVEQ7L.js";import{A as q}from"./c-5J4E7O4Y.js";import{H as _,V as K,m as F}from"./c-WWXIDH4O.js";import"./c-4L3BTFRK.js";import"./c-5V3MOVJT.js";import"./c-VHNSBD2M.js";var G=`
|
|
2
2
|
.page-editor .page-table { position: relative; }
|
|
3
3
|
.page-table td { position: relative; }
|
|
4
4
|
.page-table th { position: relative; }
|
|
@@ -22,4 +22,4 @@ import{$ as U,I as D,J as A,K as g,O as S,Q as q,R as L,S as H,T as M,U as X,V a
|
|
|
22
22
|
.page-table-add-row::after { content: " Row"; }
|
|
23
23
|
.page-table-add-col::after { content: " Column"; }
|
|
24
24
|
}
|
|
25
|
-
`;var R=F.nodes,k=c=>_(c.attrs.cols),J=["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing"],Q=c=>{let t=c.ownerDocument,e=t.defaultView.getComputedStyle(c),i=t.createElement("span");for(let o of J)i.style[o]=e[o];Object.assign(i.style,{position:"absolute",visibility:"hidden",whiteSpace:"pre",left:"-9999px",top:"0"}),i.textContent=c.textContent,t.body.append(i);let s=i.getBoundingClientRect().width;return i.remove(),Math.ceil(s)},Y=c=>Number.isFinite(c)&&c>0?Math.round(Math.min(y,Math.max(v,c))):null,P=(c,t,e)=>{let i=c.createElement("button");return i.type="button",i.textContent=t,i.setAttribute("aria-label",t),i.addEventListener("click",e),i},$=class{constructor(t,e,i){this.node=t,this.view=e,this.getPos=i,this.preview=null,this.focusCol=null;let s=e.dom.ownerDocument;this.dom=s.createElement("div"),this.dom.className="page-table",this.dom.dataset.id=t.attrs.id??"",this.dom.setAttribute("role","group"),this.dom.setAttribute("aria-label","Table");let o=s.createElement("div");o.className="page-table-scroll";let n=s.createElement("table");this.table=n,this.colgroup=s.createElement("colgroup"),this.header=s.createElement("thead"),this.header.contentEditable="false",this.contentDOM=s.createElement("tbody"),n.append(this.colgroup,this.header,this.contentDOM),o.append(n);let a=P(s,"+",()=>this.append("row"));a.className="page-table-add-row",a.setAttribute("aria-label","Add a row"),a.title="Add a row";let l=P(s,"+",()=>this.append("column"));l.className="page-table-add-col",l.setAttribute("aria-label","Add a column"),l.title="Add a column";for(let r of[a,l])r.contentEditable="false",r.addEventListener("mousedown",h=>h.preventDefault());this.dom.append(o,a,l),this.render()}append(t){let e=this.getPos();if(e==null)return;let i=t==="row"?[this.node.childCount-1,0]:[0,this.node.child(0).childCount-1];E(this.view,e,...i),(t==="row"?L(!0):M(!0))(this.view.state,this.view.dispatch),this.view.focus()}widths(){let t=k(this.node).some(i=>this.node.attrs.cols[i].width),e=k(this.node).map(i=>{let s=this.dom.ownerDocument.createElement("col");s.dataset.col=i;let o=this.node.attrs.cols[i].width;return t&&(s.style.width=`${o??m}px`),s});this.colgroup.replaceChildren(...e),this.table.classList.toggle("is-sized",t),this.table.style.width=t?`${k(this.node).reduce((i,s)=>i+(this.node.attrs.cols[s].width??m),0)}px`:""}resizer(t,e,i,s){let o=this.dom.ownerDocument,n=o.createElement("span");return n.className="page-table-resize",n.dataset.col=t,n.setAttribute("role","separator"),n.setAttribute("aria-orientation","vertical"),n.setAttribute("aria-label",`Resize column ${i.name||`Column ${s+1}`}`),n.setAttribute("aria-valuemin",String(v)),n.setAttribute("aria-valuemax",String(y)),n.setAttribute("aria-valuenow",String(this.widthOfColumn(t))),n.tabIndex=0,n.title="Drag or use the arrow keys to resize, double-click to fit",n.addEventListener("mousedown",a=>a.preventDefault()),n.addEventListener("focus",()=>{this.focusCol=t}),n.addEventListener("blur",()=>this.commitWidth(t)),n.addEventListener("keydown",a=>this.resizeKey(a,t)),n.addEventListener("keyup",a=>{["ArrowLeft","ArrowRight","Home","End"].includes(a.key)&&this.commitWidth(t)}),n.addEventListener("pointerdown",a=>{a.preventDefault();let l=a.clientX,r=this.node.attrs.cols[t].width??(e.getBoundingClientRect().width||m),h=this.dom.ownerDocument.defaultView.getComputedStyle?.(this.dom).direction==="rtl",b=r,u=d=>{b=Y(r+(h?l-d.clientX:d.clientX-l))??r;let f=[...this.colgroup.children].find(p=>p.dataset.col===t);f&&(this.table.classList.add("is-sized"),f.style.width=`${b}px`)},C=()=>{o.removeEventListener("pointermove",u),o.removeEventListener("pointerup",C),b!==r?this.command(w(t,b)):this.widths()};o.addEventListener("pointermove",u),o.addEventListener("pointerup",C)}),n.addEventListener("dblclick",a=>{a.preventDefault(),this.fit(t)}),n}widthOfColumn(t){return this.node.attrs.cols[t]?.width??m}handleFor(t){return[...this.header.querySelectorAll(".page-table-resize")].find(e=>e.dataset.col===t)??null}resizeKey(t,e){let i=t.shiftKey?50:10,s=this.preview?.col===e?this.preview.width:this.widthOfColumn(e),o;if(t.key==="ArrowLeft")o=s-i;else if(t.key==="ArrowRight")o=s+i;else if(t.key==="Home")o=v;else if(t.key==="End")o=y;else if(t.key==="Enter"){t.preventDefault(),this.commitWidth(e);return}else if(t.key==="Escape"){t.preventDefault(),this.cancelWidth(e);return}else return;t.preventDefault(),this.previewWidth(e,Math.min(y,Math.max(v,Math.round(o))))}previewWidth(t,e){let i=this.preview?.col===t?this.preview.base:this.widthOfColumn(t);this.preview={col:t,width:e,base:i};let s=[...this.colgroup.children].find(n=>n.dataset.col===t);s&&(this.table.classList.add("is-sized"),s.style.width=`${e}px`);let o=this.handleFor(t);o&&o.setAttribute("aria-valuenow",String(e))}cancelWidth(t){this.preview?.col===t&&(this.preview=null),this.widths(),this.handleFor(t)?.setAttribute("aria-valuenow",String(this.widthOfColumn(t)))}commitWidth(t){let e=this.preview;if(!e||e.col!==t)return!1;this.preview=null;let i=this.getPos(),s=i==null?null:this.view.state.doc.nodeAt(i),o=s?.type===R.table&&s.attrs.id===this.node.attrs.id?s.attrs.cols[t]:null;if(!o)return this.widths(),!1;if((o.width??m)===e.width)return this.widths(),!1;let n={...s.attrs.cols,[t]:{...o,width:e.width}};return this.view.dispatch(T(this.view.state.tr.setNodeMarkup(i,null,{...s.attrs,cols:n}))),!0}command(t){let e=this.getPos();if(e==null)return!1;E(this.view,e,0,0);let i=t(this.view.state,this.view.dispatch);return this.view.focus(),i}fit(t){let e=0;for(let s of this.contentDOM.querySelectorAll("td"))s.dataset.col===t&&(e=Math.max(e,Q(s.firstElementChild??s)));let i=[...this.header.querySelectorAll("th")].find(s=>s.dataset.col===t)?.querySelector("button");return e=Math.max(e,i?.scrollWidth??0),this.command(w(t,e+24))}render(t=null){let e=this.dom.ownerDocument,i=e.createElement("tr"),s=D(this.node);this.widths();for(let[o,n]of k(this.node).entries()){let a=this.node.attrs.cols[n],l=s[n],r=e.createElement("th");r.dataset.col=n,r.dataset.kind=l,this.node.attrs.sort?.col===n&&r.setAttribute("aria-sort",this.node.attrs.sort.dir==="asc"?"ascending":"descending");let h=P(e,a.name||`Column ${o+1}`,b=>{b.preventDefault();let u=d=>()=>{E(this.view,this.getPos(),0,o),d(this.view.state,this.view.dispatch),this.view.focus()},C=()=>{let d=e.createElement("input");d.type="text",d.value=a.name,d.setAttribute("aria-label","Column name");let f=p=>{p&&d.value.trim()?u(U(n,d.value))():d.isConnected&&(d.replaceWith(h),h.focus())};d.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),f(!0)),p.key==="Escape"&&(p.preventDefault(),f(!1)),p.stopPropagation()}),h.replaceWith(d),d.focus(),d.select()};x(this.view,h,[{label:"Rename",run:C,focus:!1},{label:"Kind \u25B8",icon:A[l],hint:a.kind?g[l]:`Auto: ${g[l]}`,run:()=>x(this.view,h,[{label:"Auto",icon:a.kind?"":A[l],hint:a.kind?"":g[l],checked:!a.kind,run:u(N(n,"auto"))},...K.map(d=>({label:g[d],icon:A[d],checked:a.kind===d,run:u(N(n,d))}))]),focus:!1},{label:"Sort ascending",icon:"\u2191",run:u(O(n,"asc"))},{label:"Sort descending",icon:"\u2193",run:u(O(n,"desc"))},{label:"Width \u25B8",icon:"\u2194",hint:a.width?`${a.width}px`:"Auto",focus:!1,run:()=>x(this.view,h,[{label:"Wider",icon:"+",run:()=>this.command(w(n,(a.width??(r.getBoundingClientRect().width||m))+40))},{label:"Narrower",icon:"\u2212",run:()=>this.command(w(n,(a.width??(r.getBoundingClientRect().width||m))-40))},{label:"Fit to content",icon:"\u2194",run:()=>this.fit(n)},...a.width?[{label:"Reset width",icon:"\xD7",run:()=>this.command(w(n,null))}]:[]])},{label:"Chart this table",icon:"\u{1F4CA}",run:()=>j(this.view,this.getPos())},{label:"Insert column left",icon:"+",run:u(M(!1))},{label:"Insert column right",icon:"+",run:u(M(!0))},...o>0?[{label:"Move left",icon:"\u2190",run:u(W(-1))}]:[],...o<k(this.node).length-1?[{label:"Move right",icon:"\u2192",run:u(W(1))}]:[],{label:"Select column",icon:"\u25A6",run:()=>S(this.view,this.getPos(),"col",o)},{label:"Delete column",icon:"\xD7",run:u(X)}])});h.dataset.kind=l,r.append(h,this.resizer(n,r,a,o)),i.append(r)}this.header.replaceChildren(i),t&&this.handleFor(t)?.focus()}update(t){if(t.type!==R.table)return!1;let e=this.focusCol&&this.dom.contains(this.dom.ownerDocument.activeElement),i=this.preview;this.node=t,this.dom.dataset.id=t.attrs.id??"",this.preview=null,this.render(e?this.focusCol:null),i&&t.attrs.cols[i.col]&&(t.attrs.cols[i.col].width??m)===i.base&&this.previewWidth(i.col,i.width);let s=D(t);for(let o of this.contentDOM.querySelectorAll("td[data-col]"))o.dataset.kind=s[o.dataset.col]??"text";return!0}stopEvent(t){return!!t.target.closest?.("thead")}ignoreMutation(t){return!this.contentDOM.contains(t.target)}},B=class{constructor(t,e,i){this.node=t,this.view=e,this.getPos=i,this.date=null;let s=e.dom.ownerDocument;this.dom=s.createElement("td"),q.set(this.dom,this),this.dom.dataset.col=t.attrs.col,this.contentDOM=s.createElement("span"),this.dom.append(this.contentDOM);let o=s.createElement("button");o.type="button",o.className="page-table-row-menu",o.textContent="Row actions",o.setAttribute("aria-label","Row actions"),o.contentEditable="false",o.addEventListener("click",()=>{let n=this.view.state.doc.resolve(this.getPos()),a=n.before(1),l=n.index(1),r=b=>()=>{E(this.view,a,l,0),b(this.view.state,this.view.dispatch),this.view.focus()},h=n.node(1).childCount;x(this.view,o,[{label:"Insert above",icon:"+",run:r(L(!1))},{label:"Insert below",icon:"+",run:r(L(!0))},...l>0?[{label:"Move up",icon:"\u2191",run:r(z(-1))}]:[],...l<h-1?[{label:"Move down",icon:"\u2193",run:r(z(1))}]:[],{label:"Select row",icon:"\u25A6",run:()=>S(this.view,a,"row",l)},{label:"Delete row",icon:"\xD7",run:r(H)}])}),this.menu=o,this.dom.append(o),this.update(t)}update(t){if(t.type!==R.table_cell)return!1;this.node=t;let e=this.view.state.doc.resolve(this.getPos()),i=e.node(1);return this.dom.dataset.kind=D(i)[t.attrs.col]??"text",this.menu.hidden=e.index(2)!==0,this.dom.dataset.kind!=="date"&&this.closeDate(),!0}openDate(){if(this.date||this.dom.dataset.kind!=="date")return!1;let e=this.dom.ownerDocument.createElement("input");e.type="date",e.className="page-table-date",e.contentEditable="false",e.setAttribute("aria-label","Pick a date");let i=this.node.textContent.trim();/^\d{4}-\d{2}-\d{2}$/.test(i)&&(e.value=i),e.addEventListener("change",()=>{e.value&&V(this.view,this.getPos(),e.value),this.closeDate(),this.view.focus()}),e.addEventListener("keydown",s=>{s.key==="Escape"&&(s.preventDefault(),this.closeDate(),this.view.focus()),s.stopPropagation()}),e.addEventListener("blur",()=>this.closeDate()),this.date=e,this.dom.append(e);try{e.showPicker?.()}catch{}return!0}closeDate(){let t=this.date;this.date=null,t?.isConnected&&t.remove()}destroy(){this.closeDate()}stopEvent(t){return!!t.target.closest?.(".page-table-row-menu, .page-table-date")}ignoreMutation(t){return!this.contentDOM.contains(t.target)}};function ct(){return{id:"table",nodeViews:{table:(c,t,e)=>new $(c,t,e),table_cell:(c,t,e)=>new B(c,t,e)},css:G,dispose(){}}}export{B as TableCellView,$ as TableView,ct as createFeature};
|
|
25
|
+
`;var R=F.nodes,k=c=>_(c.attrs.cols),J=["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing"],Q=c=>{let t=c.ownerDocument,e=t.defaultView.getComputedStyle(c),i=t.createElement("span");for(let o of J)i.style[o]=e[o];Object.assign(i.style,{position:"absolute",visibility:"hidden",whiteSpace:"pre",left:"-9999px",top:"0"}),i.textContent=c.textContent,t.body.append(i);let s=i.getBoundingClientRect().width;return i.remove(),Math.ceil(s)},Y=c=>Number.isFinite(c)&&c>0?Math.round(Math.min(E,Math.max(y,c))):null,P=(c,t,e)=>{let i=c.createElement("button");return i.type="button",i.textContent=t,i.setAttribute("aria-label",t),i.addEventListener("click",e),i},$=class{constructor(t,e,i){this.node=t,this.view=e,this.getPos=i,this.preview=null,this.focusCol=null;let s=e.dom.ownerDocument;this.dom=s.createElement("div"),this.dom.className="page-table",this.dom.dataset.id=t.attrs.id??"",this.dom.setAttribute("role","group"),this.dom.setAttribute("aria-label","Table");let o=s.createElement("div");o.className="page-table-scroll";let n=s.createElement("table");this.table=n,this.colgroup=s.createElement("colgroup"),this.header=s.createElement("thead"),this.header.contentEditable="false",this.contentDOM=s.createElement("tbody"),n.append(this.colgroup,this.header,this.contentDOM),o.append(n);let a=P(s,"+",()=>this.append("row"));a.className="page-table-add-row",a.setAttribute("aria-label","Add a row"),a.title="Add a row";let d=P(s,"+",()=>this.append("column"));d.className="page-table-add-col",d.setAttribute("aria-label","Add a column"),d.title="Add a column";for(let l of[a,d])l.contentEditable="false",l.addEventListener("mousedown",h=>h.preventDefault());this.dom.append(o,a,d),this.render()}append(t){let e=this.getPos();if(e==null)return;let i=t==="row"?[this.node.childCount-1,0]:[0,this.node.child(0).childCount-1];x(this.view,e,...i),(t==="row"?L(!0):M(!0))(this.view.state,this.view.dispatch),this.view.focus()}widths(){let t=k(this.node).some(i=>this.node.attrs.cols[i].width),e=k(this.node).map(i=>{let s=this.dom.ownerDocument.createElement("col");s.dataset.col=i;let o=this.node.attrs.cols[i].width;return t&&(s.style.width=`${o??m}px`),s});this.colgroup.replaceChildren(...e),this.table.classList.toggle("is-sized",t),this.table.style.width=t?`${k(this.node).reduce((i,s)=>i+(this.node.attrs.cols[s].width??m),0)}px`:""}resizer(t,e,i,s){let o=this.dom.ownerDocument,n=o.createElement("span");return n.className="page-table-resize",n.dataset.col=t,n.setAttribute("role","separator"),n.setAttribute("aria-orientation","vertical"),n.setAttribute("aria-label",`Resize column ${i.name||`Column ${s+1}`}`),n.setAttribute("aria-valuemin",String(y)),n.setAttribute("aria-valuemax",String(E)),n.setAttribute("aria-valuenow",String(this.widthOfColumn(t))),n.tabIndex=0,n.title="Drag or use the arrow keys to resize, double-click to fit",n.addEventListener("mousedown",a=>a.preventDefault()),n.addEventListener("focus",()=>{this.focusCol=t}),n.addEventListener("blur",()=>this.commitWidth(t)),n.addEventListener("keydown",a=>this.resizeKey(a,t)),n.addEventListener("keyup",a=>{["ArrowLeft","ArrowRight","Home","End"].includes(a.key)&&this.commitWidth(t)}),n.addEventListener("pointerdown",a=>{a.preventDefault();let d=a.clientX,l=this.node.attrs.cols[t].width??(e.getBoundingClientRect().width||m),h=this.dom.ownerDocument.defaultView.getComputedStyle?.(this.dom).direction==="rtl",b=l,u=r=>{b=Y(l+(h?d-r.clientX:r.clientX-d))??l;let w=[...this.colgroup.children].find(p=>p.dataset.col===t);w&&(this.table.classList.add("is-sized"),w.style.width=`${b}px`)},C=()=>{o.removeEventListener("pointermove",u),o.removeEventListener("pointerup",C),b!==l?this.command(f(t,b)):this.widths()};o.addEventListener("pointermove",u),o.addEventListener("pointerup",C)}),n.addEventListener("dblclick",a=>{a.preventDefault(),this.fit(t)}),n}widthOfColumn(t){return this.node.attrs.cols[t]?.width??m}handleFor(t){return[...this.header.querySelectorAll(".page-table-resize")].find(e=>e.dataset.col===t)??null}resizeKey(t,e){let i=t.shiftKey?50:10,s=this.preview?.col===e?this.preview.width:this.widthOfColumn(e),o;if(t.key==="ArrowLeft")o=s-i;else if(t.key==="ArrowRight")o=s+i;else if(t.key==="Home")o=y;else if(t.key==="End")o=E;else if(t.key==="Enter"){t.preventDefault(),this.commitWidth(e);return}else if(t.key==="Escape"){t.preventDefault(),this.cancelWidth(e);return}else return;t.preventDefault(),this.previewWidth(e,Math.min(E,Math.max(y,Math.round(o))))}previewWidth(t,e){let i=this.preview?.col===t?this.preview.base:this.widthOfColumn(t);this.preview={col:t,width:e,base:i};let s=[...this.colgroup.children].find(n=>n.dataset.col===t);s&&(this.table.classList.add("is-sized"),s.style.width=`${e}px`);let o=this.handleFor(t);o&&o.setAttribute("aria-valuenow",String(e))}cancelWidth(t){this.preview?.col===t&&(this.preview=null),this.widths(),this.handleFor(t)?.setAttribute("aria-valuenow",String(this.widthOfColumn(t)))}commitWidth(t){let e=this.preview;if(!e||e.col!==t)return!1;this.preview=null;let i=this.getPos(),s=i==null?null:this.view.state.doc.nodeAt(i),o=s?.type===R.table&&s.attrs.id===this.node.attrs.id?s.attrs.cols[t]:null;if(!o)return this.widths(),!1;if((o.width??m)===e.width)return this.widths(),!1;let n={...s.attrs.cols,[t]:{...o,width:e.width}};return this.view.dispatch(q(this.view.state.tr.setNodeMarkup(i,null,{...s.attrs,cols:n}))),!0}command(t){let e=this.getPos();if(e==null)return!1;x(this.view,e,0,0);let i=t(this.view.state,this.view.dispatch);return this.view.focus(),i}fit(t){let e=0;for(let s of this.contentDOM.querySelectorAll("td"))s.dataset.col===t&&(e=Math.max(e,Q(s.firstElementChild??s)));let i=[...this.header.querySelectorAll("th")].find(s=>s.dataset.col===t)?.querySelector("button");return e=Math.max(e,i?.scrollWidth??0),this.command(f(t,e+24))}render(t=null){let e=this.dom.ownerDocument,i=e.createElement("tr"),s=D(this.node);this.widths();for(let[o,n]of k(this.node).entries()){let a=this.node.attrs.cols[n],d=s[n],l=e.createElement("th");l.dataset.col=n,l.dataset.kind=d,this.node.attrs.sort?.col===n&&l.setAttribute("aria-sort",this.node.attrs.sort.dir==="asc"?"ascending":"descending");let h=P(e,a.name||`Column ${o+1}`,b=>{b.preventDefault();let u=r=>()=>{x(this.view,this.getPos(),0,o),r(this.view.state,this.view.dispatch),this.view.focus()},C=()=>{let r=e.createElement("input");r.type="text",r.value=a.name,r.setAttribute("aria-label","Column name");let w=p=>{p&&r.value.trim()?u(V(n,r.value))():r.isConnected&&(r.replaceWith(h),h.focus())};r.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),w(!0)),p.key==="Escape"&&(p.preventDefault(),w(!1)),p.stopPropagation()}),h.replaceWith(r),r.focus(),r.select()};v(this.view,h,[{label:"Rename",run:C,focus:!1},{label:"Kind \u25B8",icon:A[d],hint:a.kind?g[d]:`Auto: ${g[d]}`,run:()=>v(this.view,h,[{label:"Auto",icon:a.kind?"":A[d],hint:a.kind?"":g[d],checked:!a.kind,run:u(N(n,"auto"))},...K.map(r=>({label:g[r],icon:A[r],checked:a.kind===r,run:u(N(n,r))}))]),focus:!1},{label:"Sort ascending",icon:"\u2191",run:u(O(n,"asc"))},{label:"Sort descending",icon:"\u2193",run:u(O(n,"desc"))},{label:"Width \u25B8",icon:"\u2194",hint:a.width?`${a.width}px`:"Auto",focus:!1,run:()=>v(this.view,h,[{label:"Wider",icon:"+",run:()=>this.command(f(n,(a.width??(l.getBoundingClientRect().width||m))+40))},{label:"Narrower",icon:"\u2212",run:()=>this.command(f(n,(a.width??(l.getBoundingClientRect().width||m))-40))},{label:"Fit to content",icon:"\u2194",run:()=>this.fit(n)},...a.width?[{label:"Reset width",icon:"\xD7",run:()=>this.command(f(n,null))}]:[]])},{label:"Chart this table",icon:"\u{1F4CA}",run:()=>{let r=this.getPos();return T(this.view).then(({insertChartAfterTable:w})=>w(this.view,r))}},{label:"Insert column left",icon:"+",run:u(M(!1))},{label:"Insert column right",icon:"+",run:u(M(!0))},...o>0?[{label:"Move left",icon:"\u2190",run:u(W(-1))}]:[],...o<k(this.node).length-1?[{label:"Move right",icon:"\u2192",run:u(W(1))}]:[],{label:"Select column",icon:"\u25A6",run:()=>S(this.view,this.getPos(),"col",o)},{label:"Delete column",icon:"\xD7",run:u(U)}])});h.dataset.kind=d,l.append(h,this.resizer(n,l,a,o)),i.append(l)}this.header.replaceChildren(i),t&&this.handleFor(t)?.focus()}update(t){if(t.type!==R.table)return!1;let e=this.focusCol&&this.dom.contains(this.dom.ownerDocument.activeElement),i=this.preview;this.node=t,this.dom.dataset.id=t.attrs.id??"",this.preview=null,this.render(e?this.focusCol:null),i&&t.attrs.cols[i.col]&&(t.attrs.cols[i.col].width??m)===i.base&&this.previewWidth(i.col,i.width);let s=D(t);for(let o of this.contentDOM.querySelectorAll("td[data-col]"))o.dataset.kind=s[o.dataset.col]??"text";return!0}stopEvent(t){return!!t.target.closest?.("thead")}ignoreMutation(t){return!this.contentDOM.contains(t.target)}},B=class{constructor(t,e,i){this.node=t,this.view=e,this.getPos=i,this.date=null;let s=e.dom.ownerDocument;this.dom=s.createElement("td"),H.set(this.dom,this),this.dom.dataset.col=t.attrs.col,this.contentDOM=s.createElement("span"),this.dom.append(this.contentDOM);let o=s.createElement("button");o.type="button",o.className="page-table-row-menu",o.textContent="Row actions",o.setAttribute("aria-label","Row actions"),o.contentEditable="false",o.addEventListener("click",()=>{let n=this.view.state.doc.resolve(this.getPos()),a=n.before(1),d=n.index(1),l=b=>()=>{x(this.view,a,d,0),b(this.view.state,this.view.dispatch),this.view.focus()},h=n.node(1).childCount;v(this.view,o,[{label:"Insert above",icon:"+",run:l(L(!1))},{label:"Insert below",icon:"+",run:l(L(!0))},...d>0?[{label:"Move up",icon:"\u2191",run:l(z(-1))}]:[],...d<h-1?[{label:"Move down",icon:"\u2193",run:l(z(1))}]:[],{label:"Select row",icon:"\u25A6",run:()=>S(this.view,a,"row",d)},{label:"Delete row",icon:"\xD7",run:l(X)}])}),this.menu=o,this.dom.append(o),this.update(t)}update(t){if(t.type!==R.table_cell)return!1;this.node=t;let e=this.view.state.doc.resolve(this.getPos()),i=e.node(1);return this.dom.dataset.kind=D(i)[t.attrs.col]??"text",this.menu.hidden=e.index(2)!==0,this.dom.dataset.kind!=="date"&&this.closeDate(),!0}openDate(){if(this.date||this.dom.dataset.kind!=="date")return!1;let e=this.dom.ownerDocument.createElement("input");e.type="date",e.className="page-table-date",e.contentEditable="false",e.setAttribute("aria-label","Pick a date");let i=this.node.textContent.trim();/^\d{4}-\d{2}-\d{2}$/.test(i)&&(e.value=i),e.addEventListener("change",()=>{e.value&&j(this.view,this.getPos(),e.value),this.closeDate(),this.view.focus()}),e.addEventListener("keydown",s=>{s.key==="Escape"&&(s.preventDefault(),this.closeDate(),this.view.focus()),s.stopPropagation()}),e.addEventListener("blur",()=>this.closeDate()),this.date=e,this.dom.append(e);try{e.showPicker?.()}catch{}return!0}closeDate(){let t=this.date;this.date=null,t?.isConnected&&t.remove()}destroy(){this.closeDate()}stopEvent(t){return!!t.target.closest?.(".page-table-row-menu, .page-table-date")}ignoreMutation(t){return!this.contentDOM.contains(t.target)}};function ct(){return{id:"table",nodeViews:{table:(c,t,e)=>new $(c,t,e),table_cell:(c,t,e)=>new B(c,t,e)},css:G,dispose(){}}}export{B as TableCellView,$ as TableView,ct as createFeature};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as a}from"./c-HA6INT6J.js";var T="path",p="edit",u="draft";function k(){let t=globalThis.crypto?.randomUUID?.();return t||`wr-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function f(t=globalThis.document?.documentElement){if(!t||typeof t.getAttribute!="function")return null;for(let n of a){let o=t.getAttribute(n);if(o)return{kind:n,identity:o}}return null}function x(t){let n=String(t||"/").split(/[?#]/)[0];return{kind:T,identity:n||"/"}}function E(t,n){return!t||!n||!t.host||!t.documentId||!t.principalId?!1:t.host===n.host&&t.documentId===n.documentId&&t.principalId===n.principalId}function A({mode:t=p,root:n=globalThis.document?.documentElement,location:o=globalThis.window?.location,pathname:m,origin:h,writerId:y}={}){let c=t===u?u:p,l=m??o?.pathname??"/",s=h??o?.origin??"",I=x(l),e=c===u?null:f(n),r=e??I,d=[s,r.kind,r.identity,c];return{origin:s,pathname:l,mode:c,scope:d,writerId:y||k(),identityKind:r.kind,identity:r.identity,check(g=globalThis.document?.documentElement){let i=f(g);return e?i?i.kind!==e.kind||i.identity!==e.identity?{ok:!1,code:"identity-mismatch",captured:e,found:i,scope:d}:{ok:!0,code:null}:{ok:!1,code:"identity-missing",captured:e,scope:d}:i?{ok:!0,code:null,bound:i,scope:d}:{ok:!0,code:null}}}}export{T as a,p as b,u as c,k as d,f as e,x as f,E as g,A as h};
|