@panphora/clayjs 1.18.1 → 1.20.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/README.md +1 -1
- 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 +8773 -8444
- package/dist/m/attrs/{refetch-on-save-ZUE7PSCI.js → refetch-on-save-DPGJJMGN.js} +1 -1
- package/dist/m/attrs/save-freeze-MTFVVYV5.js +1 -0
- package/dist/m/{c-KP64LT2A.js → c-2VB555FG.js} +1 -1
- package/dist/m/{c-KGHVFRR3.js → c-3AXJDL2P.js} +1 -1
- package/dist/m/{c-372N6H3B.js → c-3GJ4XARY.js} +1 -1
- package/dist/m/c-3TWCKFOP.js +1 -0
- package/dist/m/{c-U7SHNWDH.js → c-3YH6JSIL.js} +1 -1
- package/dist/m/{c-AMU3BPPR.js → c-44B5ODN7.js} +2 -2
- package/dist/m/{c-S2U6NJU4.js → c-62HZW5DH.js} +1 -1
- package/dist/m/{c-ZK4GIZH2.js → c-67ILSNPR.js} +1 -1
- package/dist/m/c-67LGZ52V.js +20 -0
- package/dist/m/{c-W6DQSHXI.js → c-7SXYQCN4.js} +1 -1
- package/dist/m/{c-5OOVFCJM.js → c-AL4RBJF2.js} +1 -1
- package/dist/m/{c-L42OLXWM.js → c-ANNFZFLN.js} +1 -1
- package/dist/m/{c-QO4HNGCQ.js → c-B4VYNXTQ.js} +1 -1
- package/dist/m/{c-7PRJCA3E.js → c-BJPZCWAV.js} +1 -1
- package/dist/m/{c-SW4YEG2D.js → c-BTLFLLML.js} +1 -1
- package/dist/m/c-C4IIQZGJ.js +1 -0
- package/dist/m/{c-5T6NZHNM.js → c-CAWNFER6.js} +1 -1
- package/dist/m/c-CSNE5EIF.js +1 -0
- package/dist/m/{c-DVYGFTSK.js → c-DDDOKPI6.js} +2 -2
- package/dist/m/{c-6DB2OLRJ.js → c-DHXPDLW6.js} +1 -1
- package/dist/m/{c-WCXLG3MV.js → c-E4IBSAQM.js} +1 -1
- package/dist/m/{c-IVTRVENZ.js → c-EDSPKYMA.js} +1 -1
- package/dist/m/{c-UORXLSD3.js → c-EFD6QNTE.js} +1 -1
- package/dist/m/{c-7MG5RU63.js → c-EGTIAL6P.js} +1 -1
- package/dist/m/{c-SPZPGD3R.js → c-EOCKLMKX.js} +1 -1
- package/dist/m/{c-HMV6P4RX.js → c-EOCZ2YVL.js} +1 -1
- package/dist/m/{c-B5UJQT7W.js → c-EZ7B5AZT.js} +1 -1
- package/dist/m/{c-UPD33ZPE.js → c-FDAXZ2PM.js} +1 -1
- package/dist/m/{c-RND3G2S2.js → c-FNVQAACK.js} +1 -1
- package/dist/m/c-FSWRGBVQ.js +1 -0
- package/dist/m/c-FTWGYI5E.js +1 -0
- package/dist/m/{c-CCQ25GFY.js → c-GKEATME6.js} +1 -1
- package/dist/m/{c-YBKHUAK7.js → c-GPGYKER7.js} +1 -1
- package/dist/m/{c-FWKHM4E7.js → c-GSRLXYWL.js} +1 -1
- package/dist/m/{c-B7J4K2AE.js → c-GVPNDIKJ.js} +2 -2
- package/dist/m/{c-AMYEFA2E.js → c-I2IFKJX2.js} +1 -1
- package/dist/m/c-ICMAOOGK.js +1 -0
- package/dist/m/{c-BUAYFEV5.js → c-J3BXFTZS.js} +1 -1
- package/dist/m/{c-BIJALSRD.js → c-JDZDF2QM.js} +1 -1
- package/dist/m/{c-UDHIVLYH.js → c-JH5FF4NL.js} +1 -1
- package/dist/m/{c-OYRZ7XG2.js → c-JHJR5BQX.js} +1 -1
- package/dist/m/{c-V44KWI2L.js → c-JOH753EJ.js} +2 -2
- package/dist/m/{c-P3OFYUMA.js → c-JUE7B4OX.js} +1 -1
- package/dist/m/c-K76AUL4I.js +7 -0
- package/dist/m/{c-ZWIOJGMT.js → c-LA2BW7UY.js} +1 -1
- package/dist/m/{c-ICJYHABF.js → c-LDUNOR57.js} +1 -1
- package/dist/m/{c-C6IPRG34.js → c-LIBE4HPD.js} +1 -1
- package/dist/m/c-LPUJXRXW.js +1 -0
- package/dist/m/{c-TTB5EK4S.js → c-LQU7TXIH.js} +1 -1
- package/dist/m/{c-5ZQV7KC4.js → c-LV5MABYD.js} +1 -1
- package/dist/m/{c-URSMSFCB.js → c-M4FSPNQ2.js} +1 -1
- package/dist/m/{c-2KIEGNC4.js → c-MEWUGR4D.js} +1 -1
- package/dist/m/c-MIL4B2JQ.js +1 -0
- package/dist/m/{c-IVMD3FEM.js → c-N7Y52HJH.js} +1 -1
- package/dist/m/{c-PLN76GF3.js → c-NFR673TL.js} +2 -2
- package/dist/m/{c-T637T7SN.js → c-NLZ5AN4L.js} +1 -1
- package/dist/m/{c-OPLUZR3A.js → c-OABVRYOT.js} +1 -1
- package/dist/m/c-PIVIYLTY.js +1 -0
- package/dist/m/{c-L7JL5TL3.js → c-QY7F6EN6.js} +1 -1
- package/dist/m/{c-UY4QX42B.js → c-RG6XUZFA.js} +1 -1
- package/dist/m/c-RHMPKZZ7.js +1 -0
- package/dist/m/{c-TJAXGIRV.js → c-RQRMPZXD.js} +1 -1
- package/dist/m/{c-GY422N3Q.js → c-RS77ODLY.js} +1 -1
- package/dist/m/{c-IMZCWYHR.js → c-RT3C74GY.js} +1 -1
- package/dist/m/{c-CAS3NND4.js → c-S5IEIZCN.js} +1 -1
- package/dist/m/{c-K3ADYNLU.js → c-SBSMJIPC.js} +1 -1
- package/dist/m/c-SFKI6OLM.js +2 -0
- package/dist/m/{c-4TXNLX4K.js → c-SJPD46ZO.js} +4 -4
- package/dist/m/{c-HHGJBU4D.js → c-SO63UGPQ.js} +1 -1
- package/dist/m/{c-PLP4JKFC.js → c-TUGVINJR.js} +1 -1
- package/dist/m/{c-Q26MME6N.js → c-TWCXBWS3.js} +1 -1
- package/dist/m/{c-GNDL3TKB.js → c-U5X57T4L.js} +1 -1
- package/dist/m/{c-4YU3BR4D.js → c-UXEVJ63W.js} +1 -1
- package/dist/m/{c-KJJPV77R.js → c-V2J5C5MT.js} +1 -1
- package/dist/m/{c-6UGWFMQC.js → c-VBLFAQD2.js} +1 -1
- package/dist/m/{c-ERQSNR6K.js → c-VQCEOGKH.js} +2 -2
- package/dist/m/{c-YVZ2L7CE.js → c-VSPAFOKU.js} +1 -1
- package/dist/m/{c-5ONTYIUI.js → c-VY6XRBOW.js} +1 -1
- package/dist/m/{c-2KL3BD52.js → c-W23KVGUO.js} +1 -1
- package/dist/m/{c-COPTL5WB.js → c-W3K23S72.js} +1 -1
- package/dist/m/c-WFMRX5RZ.js +1 -0
- package/dist/m/{c-BWFVSBDF.js → c-WN3MXOLT.js} +1 -1
- package/dist/m/{c-X5TSXZYJ.js → c-XD5MOROJ.js} +1 -1
- package/dist/m/{c-MWXFLW4J.js → c-XQSXKIKM.js} +1 -1
- package/dist/m/{c-OTMKN2OO.js → c-Y33LUUIQ.js} +1 -1
- package/dist/m/{c-JNLX3RJB.js → c-YQUJ74R3.js} +1 -1
- package/dist/m/{c-2GRUM77Q.js → c-YSB6JKV2.js} +2 -2
- package/dist/m/{c-WQWIRWO3.js → c-Z32V4MHK.js} +1 -1
- package/dist/m/{c-BHZYSHW4.js → c-ZJLU56DV.js} +1 -1
- package/dist/m/{c-DKLS74XB.js → c-ZQXNHZZT.js} +2 -2
- package/dist/m/{c-TNEM3RNM.js → c-ZSCBEB7I.js} +1 -1
- package/dist/m/core/{admin-attrs-YY7T5FGU.js → admin-attrs-ZG7R5V3E.js} +1 -1
- package/dist/m/core/{autosave-S6OMNDCK.js → autosave-VPORYJSE.js} +1 -1
- package/dist/m/core/{conflict-notice-IWHMHH43.js → conflict-notice-JMAZLVRX.js} +1 -1
- package/dist/m/core/{persist-UKXV5KLA.js → persist-3OPWJKZS.js} +1 -1
- package/dist/m/core/{save-LYY7K6U7.js → save-AOJBDSOK.js} +1 -1
- package/dist/m/core/{save-core-MKRPSEEO.js → save-core-IOCMXO5L.js} +1 -1
- package/dist/m/core/{snapshot-NU3YM6GR.js → snapshot-O7II2AGG.js} +1 -1
- package/dist/m/core/unsaved-warning-U5VUJFOE.js +1 -0
- package/dist/m/events/{index-RN2JNGBV.js → index-B6TGDYMG.js} +1 -1
- package/dist/m/internals/{index-TGLQINN3.js → index-HDRANDWE.js} +1 -1
- package/dist/m/lib/{cache-bust-MUMFXZK6.js → cache-bust-NH7VBWHO.js} +1 -1
- package/dist/m/lib/{region-policy-SB2AWVG5.js → region-policy-KWBPROWF.js} +1 -1
- package/dist/m/loader-DZZLUBVB.js +1 -0
- package/dist/m/manifest-3AEF5191.js +1 -0
- package/dist/m/manifest-edit-29A26F22.js +1 -0
- package/dist/m/manifest.json +1336 -1281
- package/dist/m/options/{options-EJMS3K24.js → options-55LQHSJ4.js} +1 -1
- package/dist/m/page/{editor-6LRB3GE4.js → editor-EY2WAAGB.js} +2 -2
- package/dist/m/plugins/{ai-edit-UTV7YO2I.js → ai-edit-J5VLSW5I.js} +1 -1
- package/dist/m/plugins/{demo-OYO5GCAO.js → demo-42BSYQ7T.js} +1 -1
- package/dist/m/plugins/like-EV7MTZ56.js +1 -0
- package/dist/m/plugins/{live-AD4H6XSL.js → live-5EZN2EYP.js} +1 -1
- package/dist/m/plugins/menu-KGWKT6CS.js +1 -0
- package/dist/m/plugins/{page-MD3T2ZX3.js → page-LVW5DWA4.js} +2 -2
- package/dist/m/plugins/{page-view-PAWVZNFY.js → page-view-5KQ76IJB.js} +1 -1
- package/dist/m/plugins/{sortable-4S6SQC3D.js → sortable-WJZZBM7R.js} +1 -1
- package/dist/m/plugins/{source-TJXOIOYY.js → source-CCEUM3OR.js} +1 -1
- package/dist/m/plugins/{undo-NLPGCJQY.js → undo-3JEYK5QY.js} +1 -1
- package/dist/m/plugins/{upgrade-HSUNDNJD.js → upgrade-NW556WJD.js} +1 -1
- package/dist/m/plugins/{upload-NHGJXZK2.js → upload-TTCQRIM5.js} +1 -1
- package/dist/m/plugins/{visitor-drafts-BW43DGY3.js → visitor-drafts-2AWNT23K.js} +2 -2
- package/dist/m/plugins/{visitor-drafts-owner-7ODQG7JX.js → visitor-drafts-owner-MZP45XSG.js} +1 -1
- package/dist/m/plugins/{wire-VBWXEXU2.js → wire-VRYPY6EJ.js} +1 -1
- package/dist/m/{reader-core-4W2KYEWQ.js → reader-core-2GXY7SHY.js} +2 -2
- package/dist/m/sync/{live-sync-MO5DH33W.js → live-sync-SKPMFYOO.js} +1 -1
- package/dist/m/ui/{index-IVWN2QC4.js → index-QNIPDHXQ.js} +1 -1
- package/dist/offline-manifest.json +652 -616
- package/docs/guide.md +25 -8
- package/package.json +4 -2
- package/src/core/conflict-download.js +8 -7
- package/src/core/conflict-notice-ui.js +4 -4
- package/src/core/copy-content.js +103 -0
- package/src/core/download.js +14 -2
- package/src/core/save-size-notice.js +2 -2
- package/src/core/upgrade-run.js +5 -1
- package/src/lib/region-policy.js +1 -1
- package/src/loader-logic.js +5 -1
- package/src/loader.js +2 -0
- package/src/page/features/export-html.js +4 -4
- package/src/page/features/export-markdown.js +2 -2
- package/src/page/recovery-ui.js +2 -2
- package/src/page/save-states.js +4 -4
- package/src/plugins/like.js +254 -0
- package/src/plugins/menu/actions.js +1 -1
- package/src/plugins/page.js +4 -4
- package/src/plugins/visitor-drafts/prompt.js +12 -12
- package/src/plugins/wire.js +3 -1
- package/dist/m/attrs/save-freeze-LWGF6XUN.js +0 -1
- package/dist/m/c-D5IKEKXW.js +0 -7
- package/dist/m/c-DCFSEJZG.js +0 -1
- package/dist/m/c-EVYAISP3.js +0 -1
- package/dist/m/c-GRXHHFPO.js +0 -1
- package/dist/m/c-HT2DKBV2.js +0 -1
- package/dist/m/c-MCOOHCSG.js +0 -1
- package/dist/m/c-VILENZTD.js +0 -1
- package/dist/m/c-VR2BJ4AN.js +0 -1
- package/dist/m/c-WGW764WX.js +0 -1
- package/dist/m/c-WNTYKCDG.js +0 -1
- package/dist/m/c-YBSS55KU.js +0 -20
- package/dist/m/core/unsaved-warning-7QTKEN7Z.js +0 -1
- package/dist/m/loader-3BBNZZGM.js +0 -1
- package/dist/m/manifest-26C55578.js +0 -1
- package/dist/m/manifest-edit-4396A009.js +0 -1
- package/dist/m/plugins/menu-M5WW7DBF.js +0 -1
- /package/dist/m/{c-QTTJYJMA.js → c-FILLTJA7.js} +0 -0
- /package/dist/m/plugins/{people-JCHVPF7P.js → people-C7TVBBMR.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as O,c as N}from"./c-IJUK2GPW.js";import{f as v}from"./c-VG5XIN4T.js";import{a as y,h as k,j as C,k as R}from"./c-HA6INT6J.js";import{b as E,s as g,t as _,u as S,v as m}from"./c-DCFSEJZG.js";import{g as w}from"./c-WRBKEJD4.js";import{a as M}from"./c-VHNSBD2M.js";var L={};M(L,{default:()=>B});var P=document.createElement("div"),x=new Set(k);function T(e){if(e.type!=="attributes")return!1;let t=e.attributeName;return t===R||y(t,e.target)?!0:e.target===document.documentElement&&(x.has(t)||t.startsWith(C))}function A(e){return e.some(T)?e.filter(t=>!T(t)):e}var V={_callbacks:{anyChange:[],addOrRemove:[],addElement:[],removeElement:[],attribute:[]},_observing:!1,_pauseDepth:0,_hasNonPausable:!1,debug:!1,_rawSubscribers:[],_deferredChangeRecords:null,_deferredChangeScheduled:!1,pause(){this._pauseDepth===0&&this._deliverBeforePause(),this._pauseDepth++,typeof window<"u"&&window.clay?.undo?.pause&&window.clay.undo.pause(),this._log("Paused",this._pauseDepth)},_deliverBeforePause(){if(!this._observer)return;let e=this._observer.takeRecords();e.length&&this._onRecords(e)},dropQueued(){this._observer&&this._drainBrowserQueue(this)},resume(){this._pauseDepth!==0&&(this._pauseDepth--,this._pauseDepth===0&&this._observer&&this._drainBrowserQueue(this),typeof window<"u"&&window.clay?.undo?.resume&&window.clay.undo.resume(),this._log("Resumed",this._pauseDepth))},_log(e,t=null,s="log"){if(!this.debug)return;let i=`[Mutation ${new Date().toISOString()}]`;t?console[s](i,e,t):console[s](i,e)},_notify(e,t,s=!1){this._log(`Notifying ${this._callbacks[e].length} callbacks of type "${e}"`,{changes:t});for(let r of this._callbacks[e]){if(s&&r.pausable!==!1)continue;let{fn:i,debounce:u=0,maxWait:l=0,selectorFilter:n,omitChangeDetails:c,require:h,skip:d}=r,f=t.filter(o=>{if(h!=="observed"&&v(o))return!1;let a=m(this._policyForChange(o),h,d);if(!o.policyTransition)return!a;let b=m(o.previousPolicy,h,d);return!(a&&b)});if(!f.length){this._log("No changes passed the region policy, skipping callback");continue}if(n&&(this._log("Applying selector filter",{selectorFilter:n}),f=f.filter(o=>{if(typeof n=="string"){let a=o.element.matches?.(n)||!1;return this._log(`Selector "${n}" match:`,{element:o.element,matches:a}),a}if(typeof n=="function"){let a=n(o.element);return this._log("Custom filter match:",{element:o.element,matches:a}),a}return!1}),this._log("Changes after filtering:",{filteredChanges:f})),!f.length){this._log("No changes passed the filter, skipping callback");continue}if(u===0)try{c?i():i(f)}catch(o){this._log("Error in callback execution:",o,"error"),console.error("Error in Mutation callback:",o)}else{r.timeout&&(clearTimeout(r.timeout),r.timeout=null),r.firstPendingAt||(r.firstPendingAt=Date.now());let o=l>0?Math.max(0,Math.min(u,l-(Date.now()-r.firstPendingAt))):u;c?r.timeout=setTimeout(()=>{r.timeout=null,r.firstPendingAt=null;try{this._log("Executing debounced callback (no details)"),i()}catch(a){this._log("Error in callback execution:",a,"error"),console.error("Error in Mutation callback:",a)}},o):(r.pendingChanges||(r.pendingChanges=[]),r.pendingChanges.push(...f),r.timeout=setTimeout(()=>{let a=r.pendingChanges;r.pendingChanges=null,r.timeout=null,r.firstPendingAt=null;try{this._log("Executing debounced callback with changes:",{changes:a}),a&&a.length>0&&i(a)}catch(b){this._log("Error in callback execution:",b,"error"),console.error("Error in Mutation callback:",b)}},o))}}},_policyForChange(e){if(e.__policy)return e.__policy;let t=e.element,s=g(t);return e.parent&&t&&t.isConnected===!1&&(s=S(s,g(e.parent))),e.__policy=s,s},_onRecords(e){let t=A(e);t.length&&(this._fanOutRaw(t),this._handleMutations(t))},_fanOutRaw(e){if(!(!this._rawSubscribers.length||!e.length))for(let t of this._rawSubscribers)try{t.cb(e)}catch(s){this._log("Error in raw subscriber callback:",s,"error"),console.error("Error in Mutation raw subscriber:",s)}},_drainBrowserQueue(e){let t=A(this._observer?this._observer.takeRecords():[]),s=!!e&&this._rawSubscribers.indexOf(e)!==-1;if(t.length){for(let r of this._rawSubscribers)r!==e&&(r.buffer.push(...t),this._scheduleBufferFlush(r));s?this._deferChangeLane(t):this._hasNonPausable&&this._processMutations(t,!0)}if(s){let r=e.buffer;return e.buffer=[],r.length?r.concat(t):t}return t},_scheduleBufferFlush(e){e._flushScheduled||(e._flushScheduled=!0,queueMicrotask(()=>{if(e._flushScheduled=!1,!e.buffer.length)return;let t=e.buffer;e.buffer=[];try{e.cb(t)}catch(s){this._log("Error in raw subscriber flush:",s,"error"),console.error("Error in Mutation raw subscriber:",s)}}))},_deferChangeLane(e){this._deferredChangeRecords||(this._deferredChangeRecords=[]),this._deferredChangeRecords.push(...e),!this._deferredChangeScheduled&&(this._deferredChangeScheduled=!0,queueMicrotask(()=>{this._deferredChangeScheduled=!1;let t=this._deferredChangeRecords;this._deferredChangeRecords=null,t&&t.length&&this._handleMutations(t)}))},subscribeRaw(e){let t={cb:e,buffer:[],_flushScheduled:!1};return this._rawSubscribers.push(t),this._startObserving(),{drain:()=>this._drainBrowserQueue(t),unsubscribe:()=>{let s=this._rawSubscribers.indexOf(t);s!==-1&&this._rawSubscribers.splice(s,1)}}},createObserver(e){let t=null;return{observe:s=>{if(s!==document.body)throw new Error("Mutation.createObserver only supports observing document.body");this._startObserving(),t||(t=this.subscribeRaw(e))},disconnect:()=>{t&&(t.unsubscribe(),t=null)},takeRecords:()=>t?t.drain():[]}},_handleMutations(e){if(this._pauseDepth>0){if(!this._hasNonPausable){this._log(`Skipping ${e.length} mutations (paused)`);return}this._processMutations(e,!0);return}this._processMutations(e,!1)},_processMutations(e,t=!1){let s=[],r={add:[],remove:[],attribute:[],characterData:[]};for(let i of e){let u=i.type==="attributes"&&w(i.attributeName);if(!(!u&&_(i.target))&&!(i.type==="attributes"&&i.attributeName&&E.test(i.attributeName.toLowerCase()))){if(i.type==="characterData"){this._log("Processing characterData mutation",{element:i.target.parentElement,oldValue:i.oldValue,newValue:i.target.textContent});let l={type:"characterData",element:i.target.parentElement??P,oldValue:i.oldValue,newValue:i.target.textContent};s.push(l),r.characterData.push(l)}if(i.type==="childList"){this._log("Processing childList mutation",{addedNodes:i.addedNodes,removedNodes:i.removedNodes});for(let n of i.addedNodes)if(n.nodeType===1&&!_(n)){let c=[n,...n.querySelectorAll("*")];this._log(`Processing ${c.length} added nodes`,{addedNodes:c});for(let h of c){let d={type:"add",element:h,parent:i.target,previousSibling:i.previousSibling,nextSibling:i.nextSibling};s.push(d),r.add.push(d)}}for(let n of i.removedNodes)if(n.nodeType===1&&!_(n)){let c=[n,...n.querySelectorAll("*")];this._log(`Processing ${c.length} removed nodes`,{removedNodes:c});for(let h of c){let d={type:"remove",element:h,parent:i.target,previousSibling:i.previousSibling,nextSibling:i.nextSibling};s.push(d),r.remove.push(d)}}let l=!1;for(let n of i.addedNodes)if(n.nodeType===3){l=!0;break}if(!l){for(let n of i.removedNodes)if(n.nodeType===3){l=!0;break}}if(l&&i.target.nodeType===1){let n={type:"characterData",element:i.target,oldValue:void 0,newValue:i.target.textContent};s.push(n),r.characterData.push(n)}}if(i.type==="attributes"){this._log("Processing attribute mutation",{element:i.target,attribute:i.attributeName,oldValue:i.oldValue,newValue:i.target.getAttribute(i.attributeName)});let l={type:"attribute",element:i.target,attribute:i.attributeName,oldValue:i.oldValue,newValue:i.target.getAttribute(i.attributeName),policyTransition:u,previousPolicy:u?F(i):null};s.push(l),r.attribute.push(l)}}}if(s.length){if(this._log("Processing collected changes",{total:s.length,byType:{add:r.add.length,remove:r.remove.length,attribute:r.attribute.length}}),!t&&O()){for(let u of s)if(!v(u)&&!m(this._policyForChange(u),"dirty")){N();break}}this._notify("anyChange",s,t);let i=[...r.add,...r.remove];i.length&&this._notify("addOrRemove",i,t),r.add.length&&this._notify("addElement",r.add,t),r.remove.length&&this._notify("removeElement",r.remove,t),r.attribute.length&&this._notify("attribute",r.attribute,t)}},_observer:null,_initializeObserver(){this._observer||(this._log("Initializing MutationObserver"),this._observer=new MutationObserver(this._onRecords.bind(this)))},_addCallback(e,t={},s){this._log("Adding callback",{type:e,options:t}),t.debug&&(this.debug=!0);let r={fn:s,debounce:t.debounce||0,maxWait:t.maxWait||0,selectorFilter:t.selectorFilter,omitChangeDetails:t.omitChangeDetails,require:t.require,skip:t.skip,pausable:t.pausable!==!1,timeout:null,pendingChanges:null,firstPendingAt:null};return this._callbacks[e].push(r),this._recomputeHasNonPausable(),this._log(`Added callback to ${e}. Total callbacks:`,{[e]:this._callbacks[e].length}),this._startObserving(),()=>{this._log("Removing callback",{type:e});let i=this._callbacks[e].indexOf(r);i!==-1&&(clearTimeout(r.timeout),r.pendingChanges=null,this._callbacks[e].splice(i,1),this._recomputeHasNonPausable(),this._log(`Removed callback from ${e}. Remaining callbacks:`,{[e]:this._callbacks[e].length}))}},_recomputeHasNonPausable(){this._hasNonPausable=Object.values(this._callbacks).some(e=>e.some(t=>t.pausable===!1))},_startObserving(){if(this._observing){this._log("Already observing, skipping initialization");return}this._log("Starting observation"),this._initializeObserver(),this._observer.observe(document.documentElement,{childList:!0,attributes:!0,subtree:!0,characterData:!0,attributeOldValue:!0,characterDataOldValue:!0}),this._observing=!0,this._log("Observation started")},onAnyChange(e={},t){return this._addCallback("anyChange",e,t)},onAddOrRemove(e={},t){return this._addCallback("addOrRemove",e,t)},onAddElement(e={},t){return this._addCallback("addElement",e,t)},onRemoveElement(e={},t){return this._addCallback("removeElement",e,t)},onAttribute(e={},t){return this._addCallback("attribute",e,t)},ensureObserving(){this._startObserving()}},D=typeof window<"u"&&window.__clayMutation,p=D||V;if(typeof window<"u"&&!D){window.__clayMutation=p,window.clay=window.clay||{},window.clay.Mutation=p;try{document.dispatchEvent(new CustomEvent("clay:mutation-ready",{detail:{Mutation:p}}))}catch{}}var B=p;function F(e){let t=e.target,s=t.cloneNode(!1),r=s;for(;t.parentElement;){t=t.parentElement;let i=t.cloneNode(!1);i.appendChild(s),s=i}return e.oldValue==null?r.removeAttribute(e.attributeName):r.setAttribute(e.attributeName,e.oldValue),g(r)}export{B as a,L as b};
|
|
1
|
+
import{b as O,c as N}from"./c-IJUK2GPW.js";import{f as v}from"./c-VG5XIN4T.js";import{a as y,h as k,j as C,k as R}from"./c-HA6INT6J.js";import{b as E,s as g,t as _,u as S,v as m}from"./c-ICMAOOGK.js";import{g as w}from"./c-WRBKEJD4.js";import{a as M}from"./c-VHNSBD2M.js";var L={};M(L,{default:()=>B});var P=document.createElement("div"),x=new Set(k);function T(e){if(e.type!=="attributes")return!1;let t=e.attributeName;return t===R||y(t,e.target)?!0:e.target===document.documentElement&&(x.has(t)||t.startsWith(C))}function A(e){return e.some(T)?e.filter(t=>!T(t)):e}var V={_callbacks:{anyChange:[],addOrRemove:[],addElement:[],removeElement:[],attribute:[]},_observing:!1,_pauseDepth:0,_hasNonPausable:!1,debug:!1,_rawSubscribers:[],_deferredChangeRecords:null,_deferredChangeScheduled:!1,pause(){this._pauseDepth===0&&this._deliverBeforePause(),this._pauseDepth++,typeof window<"u"&&window.clay?.undo?.pause&&window.clay.undo.pause(),this._log("Paused",this._pauseDepth)},_deliverBeforePause(){if(!this._observer)return;let e=this._observer.takeRecords();e.length&&this._onRecords(e)},dropQueued(){this._observer&&this._drainBrowserQueue(this)},resume(){this._pauseDepth!==0&&(this._pauseDepth--,this._pauseDepth===0&&this._observer&&this._drainBrowserQueue(this),typeof window<"u"&&window.clay?.undo?.resume&&window.clay.undo.resume(),this._log("Resumed",this._pauseDepth))},_log(e,t=null,s="log"){if(!this.debug)return;let i=`[Mutation ${new Date().toISOString()}]`;t?console[s](i,e,t):console[s](i,e)},_notify(e,t,s=!1){this._log(`Notifying ${this._callbacks[e].length} callbacks of type "${e}"`,{changes:t});for(let r of this._callbacks[e]){if(s&&r.pausable!==!1)continue;let{fn:i,debounce:u=0,maxWait:l=0,selectorFilter:n,omitChangeDetails:c,require:h,skip:d}=r,f=t.filter(o=>{if(h!=="observed"&&v(o))return!1;let a=m(this._policyForChange(o),h,d);if(!o.policyTransition)return!a;let b=m(o.previousPolicy,h,d);return!(a&&b)});if(!f.length){this._log("No changes passed the region policy, skipping callback");continue}if(n&&(this._log("Applying selector filter",{selectorFilter:n}),f=f.filter(o=>{if(typeof n=="string"){let a=o.element.matches?.(n)||!1;return this._log(`Selector "${n}" match:`,{element:o.element,matches:a}),a}if(typeof n=="function"){let a=n(o.element);return this._log("Custom filter match:",{element:o.element,matches:a}),a}return!1}),this._log("Changes after filtering:",{filteredChanges:f})),!f.length){this._log("No changes passed the filter, skipping callback");continue}if(u===0)try{c?i():i(f)}catch(o){this._log("Error in callback execution:",o,"error"),console.error("Error in Mutation callback:",o)}else{r.timeout&&(clearTimeout(r.timeout),r.timeout=null),r.firstPendingAt||(r.firstPendingAt=Date.now());let o=l>0?Math.max(0,Math.min(u,l-(Date.now()-r.firstPendingAt))):u;c?r.timeout=setTimeout(()=>{r.timeout=null,r.firstPendingAt=null;try{this._log("Executing debounced callback (no details)"),i()}catch(a){this._log("Error in callback execution:",a,"error"),console.error("Error in Mutation callback:",a)}},o):(r.pendingChanges||(r.pendingChanges=[]),r.pendingChanges.push(...f),r.timeout=setTimeout(()=>{let a=r.pendingChanges;r.pendingChanges=null,r.timeout=null,r.firstPendingAt=null;try{this._log("Executing debounced callback with changes:",{changes:a}),a&&a.length>0&&i(a)}catch(b){this._log("Error in callback execution:",b,"error"),console.error("Error in Mutation callback:",b)}},o))}}},_policyForChange(e){if(e.__policy)return e.__policy;let t=e.element,s=g(t);return e.parent&&t&&t.isConnected===!1&&(s=S(s,g(e.parent))),e.__policy=s,s},_onRecords(e){let t=A(e);t.length&&(this._fanOutRaw(t),this._handleMutations(t))},_fanOutRaw(e){if(!(!this._rawSubscribers.length||!e.length))for(let t of this._rawSubscribers)try{t.cb(e)}catch(s){this._log("Error in raw subscriber callback:",s,"error"),console.error("Error in Mutation raw subscriber:",s)}},_drainBrowserQueue(e){let t=A(this._observer?this._observer.takeRecords():[]),s=!!e&&this._rawSubscribers.indexOf(e)!==-1;if(t.length){for(let r of this._rawSubscribers)r!==e&&(r.buffer.push(...t),this._scheduleBufferFlush(r));s?this._deferChangeLane(t):this._hasNonPausable&&this._processMutations(t,!0)}if(s){let r=e.buffer;return e.buffer=[],r.length?r.concat(t):t}return t},_scheduleBufferFlush(e){e._flushScheduled||(e._flushScheduled=!0,queueMicrotask(()=>{if(e._flushScheduled=!1,!e.buffer.length)return;let t=e.buffer;e.buffer=[];try{e.cb(t)}catch(s){this._log("Error in raw subscriber flush:",s,"error"),console.error("Error in Mutation raw subscriber:",s)}}))},_deferChangeLane(e){this._deferredChangeRecords||(this._deferredChangeRecords=[]),this._deferredChangeRecords.push(...e),!this._deferredChangeScheduled&&(this._deferredChangeScheduled=!0,queueMicrotask(()=>{this._deferredChangeScheduled=!1;let t=this._deferredChangeRecords;this._deferredChangeRecords=null,t&&t.length&&this._handleMutations(t)}))},subscribeRaw(e){let t={cb:e,buffer:[],_flushScheduled:!1};return this._rawSubscribers.push(t),this._startObserving(),{drain:()=>this._drainBrowserQueue(t),unsubscribe:()=>{let s=this._rawSubscribers.indexOf(t);s!==-1&&this._rawSubscribers.splice(s,1)}}},createObserver(e){let t=null;return{observe:s=>{if(s!==document.body)throw new Error("Mutation.createObserver only supports observing document.body");this._startObserving(),t||(t=this.subscribeRaw(e))},disconnect:()=>{t&&(t.unsubscribe(),t=null)},takeRecords:()=>t?t.drain():[]}},_handleMutations(e){if(this._pauseDepth>0){if(!this._hasNonPausable){this._log(`Skipping ${e.length} mutations (paused)`);return}this._processMutations(e,!0);return}this._processMutations(e,!1)},_processMutations(e,t=!1){let s=[],r={add:[],remove:[],attribute:[],characterData:[]};for(let i of e){let u=i.type==="attributes"&&w(i.attributeName);if(!(!u&&_(i.target))&&!(i.type==="attributes"&&i.attributeName&&E.test(i.attributeName.toLowerCase()))){if(i.type==="characterData"){this._log("Processing characterData mutation",{element:i.target.parentElement,oldValue:i.oldValue,newValue:i.target.textContent});let l={type:"characterData",element:i.target.parentElement??P,oldValue:i.oldValue,newValue:i.target.textContent};s.push(l),r.characterData.push(l)}if(i.type==="childList"){this._log("Processing childList mutation",{addedNodes:i.addedNodes,removedNodes:i.removedNodes});for(let n of i.addedNodes)if(n.nodeType===1&&!_(n)){let c=[n,...n.querySelectorAll("*")];this._log(`Processing ${c.length} added nodes`,{addedNodes:c});for(let h of c){let d={type:"add",element:h,parent:i.target,previousSibling:i.previousSibling,nextSibling:i.nextSibling};s.push(d),r.add.push(d)}}for(let n of i.removedNodes)if(n.nodeType===1&&!_(n)){let c=[n,...n.querySelectorAll("*")];this._log(`Processing ${c.length} removed nodes`,{removedNodes:c});for(let h of c){let d={type:"remove",element:h,parent:i.target,previousSibling:i.previousSibling,nextSibling:i.nextSibling};s.push(d),r.remove.push(d)}}let l=!1;for(let n of i.addedNodes)if(n.nodeType===3){l=!0;break}if(!l){for(let n of i.removedNodes)if(n.nodeType===3){l=!0;break}}if(l&&i.target.nodeType===1){let n={type:"characterData",element:i.target,oldValue:void 0,newValue:i.target.textContent};s.push(n),r.characterData.push(n)}}if(i.type==="attributes"){this._log("Processing attribute mutation",{element:i.target,attribute:i.attributeName,oldValue:i.oldValue,newValue:i.target.getAttribute(i.attributeName)});let l={type:"attribute",element:i.target,attribute:i.attributeName,oldValue:i.oldValue,newValue:i.target.getAttribute(i.attributeName),policyTransition:u,previousPolicy:u?F(i):null};s.push(l),r.attribute.push(l)}}}if(s.length){if(this._log("Processing collected changes",{total:s.length,byType:{add:r.add.length,remove:r.remove.length,attribute:r.attribute.length}}),!t&&O()){for(let u of s)if(!v(u)&&!m(this._policyForChange(u),"dirty")){N();break}}this._notify("anyChange",s,t);let i=[...r.add,...r.remove];i.length&&this._notify("addOrRemove",i,t),r.add.length&&this._notify("addElement",r.add,t),r.remove.length&&this._notify("removeElement",r.remove,t),r.attribute.length&&this._notify("attribute",r.attribute,t)}},_observer:null,_initializeObserver(){this._observer||(this._log("Initializing MutationObserver"),this._observer=new MutationObserver(this._onRecords.bind(this)))},_addCallback(e,t={},s){this._log("Adding callback",{type:e,options:t}),t.debug&&(this.debug=!0);let r={fn:s,debounce:t.debounce||0,maxWait:t.maxWait||0,selectorFilter:t.selectorFilter,omitChangeDetails:t.omitChangeDetails,require:t.require,skip:t.skip,pausable:t.pausable!==!1,timeout:null,pendingChanges:null,firstPendingAt:null};return this._callbacks[e].push(r),this._recomputeHasNonPausable(),this._log(`Added callback to ${e}. Total callbacks:`,{[e]:this._callbacks[e].length}),this._startObserving(),()=>{this._log("Removing callback",{type:e});let i=this._callbacks[e].indexOf(r);i!==-1&&(clearTimeout(r.timeout),r.pendingChanges=null,this._callbacks[e].splice(i,1),this._recomputeHasNonPausable(),this._log(`Removed callback from ${e}. Remaining callbacks:`,{[e]:this._callbacks[e].length}))}},_recomputeHasNonPausable(){this._hasNonPausable=Object.values(this._callbacks).some(e=>e.some(t=>t.pausable===!1))},_startObserving(){if(this._observing){this._log("Already observing, skipping initialization");return}this._log("Starting observation"),this._initializeObserver(),this._observer.observe(document.documentElement,{childList:!0,attributes:!0,subtree:!0,characterData:!0,attributeOldValue:!0,characterDataOldValue:!0}),this._observing=!0,this._log("Observation started")},onAnyChange(e={},t){return this._addCallback("anyChange",e,t)},onAddOrRemove(e={},t){return this._addCallback("addOrRemove",e,t)},onAddElement(e={},t){return this._addCallback("addElement",e,t)},onRemoveElement(e={},t){return this._addCallback("removeElement",e,t)},onAttribute(e={},t){return this._addCallback("attribute",e,t)},ensureObserving(){this._startObserving()}},D=typeof window<"u"&&window.__clayMutation,p=D||V;if(typeof window<"u"&&!D){window.__clayMutation=p,window.clay=window.clay||{},window.clay.Mutation=p;try{document.dispatchEvent(new CustomEvent("clay:mutation-ready",{detail:{Mutation:p}}))}catch{}}var B=p;function F(e){let t=e.target,s=t.cloneNode(!1),r=s;for(;t.parentElement;){t=t.parentElement;let i=t.cloneNode(!1);i.appendChild(s),s=i}return e.oldValue==null?r.removeAttribute(e.attributeName):r.setAttribute(e.attributeName,e.oldValue),g(r)}export{B as a,L as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as u,b as m,c as g,d as b}from"./c-Y6F2FORL.js";import{b as v}from"./c-
|
|
1
|
+
import{a as u,b as m,c as g,d as b}from"./c-Y6F2FORL.js";import{b as v}from"./c-QY7F6EN6.js";import{b as y}from"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var c={draft:"You're seeing a private draft, like a visitor.",draftAction:"Edit the original",edit:"You're editing the original. Visitors get these changes.",editAction:"Back to my draft",close:"Hide this note"},k=`.clay-owner {
|
|
2
2
|
--hcp-ground: #FDF8F0;
|
|
3
3
|
--hcp-surface: #FFFCF6;
|
|
4
4
|
--hcp-sunk: #F4ECDF;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as S}from"./c-5ZQV7KC4.js";import{a as ne,b as F,c as re,d as oe}from"./c-N326R2JD.js";import{a as H}from"./c-JAX2667S.js";import{b as le,c as ae}from"./c-5OOVFCJM.js";import"./c-6DB2OLRJ.js";import"./c-LZJPNR2W.js";import{b as ce,g as ie}from"./c-IVMD3FEM.js";import{b as Z}from"./c-TNEM3RNM.js";import{b as se}from"./c-PLP4JKFC.js";import"./c-QTTJYJMA.js";import"./c-Q26MME6N.js";import"./c-VKEDWYDF.js";import{D as te}from"./c-T637T7SN.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import{g as ee}from"./c-FWKHM4E7.js";import"./c-X5LNHET5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import{a as J}from"./c-ZWIOJGMT.js";import"./c-B7J4K2AE.js";import"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import{f as X}from"./c-IJUK2GPW.js";import"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-7MG5RU63.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import{h as Q}from"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var T="This spot changed again. Review the latest edit or download your copy.",ue="\uFFFC",C="",M=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),ge=new Set(["BR","WBR","IMG"]),L=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" ")),ke=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" ")),we=new Set("P H1 H2 H3 H4 H5 H6 SUMMARY".split(" ")),Ne=/[\u001E]/,ve={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0},k=e=>!!e&&e.nodeType===1,W=e=>k(e)&&M.has(e.tagName),B=e=>e.matches(le),z=e=>e.matches(ae),y=e=>e.localName==="template"&&e.content?e.content:e,w=e=>Array.prototype.indexOf.call(e.parentNode.childNodes,e),x=e=>e.getAttribute("data-id")||e.getAttribute("id")||null;function Ce(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function ye(e){if(e.nodeType===3)return!0;if(!k(e))return!1;if(B(e)||ge.has(e.tagName))return!0;if(!M.has(e.tagName))return!L.has(e.tagName);if(z(e))return!1;for(let n of e.childNodes)if(!ye(n))return!1;return!0}function Y(e){if(!ke.has(e.tagName)||B(e)||z(e))return!1;for(let n of e.childNodes)if(n.nodeType===8||!ye(n))return!1;return!0}function xe(e,n=document){for(let t of n.querySelectorAll("template")){if(t.content===e)return t;let r=xe(e,t.content);if(r)return r}return null}function m(e,n){for(let t=e;t;t=t.nodeType===11?xe(t):t.parentNode)if(t===n)return!0;return!1}var h=e=>m(e,document);function Ae(e,n){let t=e;for(let r of n)if(t=r==="content"?t.content:t.childNodes[r],!t)return null;return t}function D(e,n=new Set){if(k(e)){let t=x(e);t&&n.add(t)}if(e.nodeType===1||e.nodeType===11)for(let t of y(e).childNodes)D(t,n);return n}function Re(e){let n=document.createElement("template");return n.innerHTML=e,n.content}var Ie=e=>[...e.querySelectorAll("*")].some(n=>L.has(n.tagName));function Se(e){let n=[];for(let t=e;t.childNodes.length===1&&k(t.firstChild);t=t.firstChild)n.push(t.firstChild);return n}function De(e,n){let t=e.lastIndexOf("content");if(t<0)return document;let r=$(e.slice(0,t),n);return r&&r.content?r.content:null}function $(e,n){let t=Ae(n.root,e);if(!k(t))return null;let r=x(t),o=r?De(e,n):null;if(!o)return null;let s=[...o.querySelectorAll(t.localName)].filter(i=>i.namespaceURI===t.namespaceURI&&x(i)===r);return s.length===1?s[0]:null}function Me(e){let n=x(e);if(!n)return null;let t=[...document.querySelectorAll(e.localName)].filter(r=>r.namespaceURI===e.namespaceURI&&x(r)===n);return t.length===1?t[0]:null}function b(e,n,t=e?e.nodeType:1){if(!e)return null;for(let o of e.live)if(o.nodeType===t&&h(o))return o;if(t!==1)return null;if(e.local.length)return $(e.local[0],n);let r=e.live.find(k);return r?Me(r):null}function Pe(e){let n=e.live.find(k),t=n?x(n):null;return!!t&&![...document.querySelectorAll(n.localName)].some(r=>x(r)===t)}function _(e){let n=y(e),t={root:e,container:n,text:"",nodes:[],atoms:[],blocks:[]},r=s=>{for(let i of s){if(i.nodeType===3){if(!i.data)continue;t.nodes.push({node:i,s:t.text.length,e:t.text.length+i.data.length}),t.text+=i.data;continue}if(!k(i)||B(i))continue;if(Y(i)){t.text.length&&t.text[t.text.length-1]!==C&&(t.text+=C);let l={el:i,from:t.text.length,to:-1};t.blocks.push(l),r(i.childNodes),t.text+=C,l.to=t.text.length;continue}let c=M.has(i.tagName)&&Ce(i);if(ge.has(i.tagName)||!M.has(i.tagName)||z(i)||c){t.atoms.push({i:t.text.length,el:i}),t.text+=ue;continue}r(i.childNodes)}};if(r(n.childNodes),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&!t.blocks.length&&t.text.replace(ue,"").trim()===""){let s=t.atoms[0].i;t.text=t.text.slice(0,s)+t.text.slice(s+1),t.atoms=[];for(let i of t.nodes)i.s>s&&(i.s--,i.e--)}return t}function fe(e,n,t){for(let s of e.nodes)if(t==="start"?s.s<=n&&n<s.e:s.s<n&&n<=s.e)return[s.node,n-s.s];let r=t==="start"?n:n-1,o=e.atoms.find(s=>s.i===r);if(o)return[o.el.parentNode,w(o.el)+(t==="start"?0:1)];if(e.text[r]===C){let s=e.blocks.find(c=>c.to===r+1);if(s)return t==="start"?[s.el,s.el.childNodes.length]:[s.el.parentNode,w(s.el)+1];let i=e.blocks.find(c=>c.from===r+1);if(i)return t==="start"?[i.el,0]:[i.el.parentNode,w(i.el)]}for(let s of e.nodes)if(s.s===n||s.e===n)return[s.node,n-s.s];return[e.container,n===0?0:e.container.childNodes.length]}function j(e,n){let t=document.createRange();return t.setStart(e,n),t.setEnd(e,n),t}function K(e,n,t){if(n.nodeType===3){let i=e.nodes.find(c=>c.node===n);return i?i.s+t:null}if(n!==e.container&&!m(n,e.root))return null;let r=j(n,t),o=e.text.length,s=(i,c)=>{try{return r.comparePoint(i,c)>=0}catch{return!1}};for(let i of e.nodes)s(i.node,0)&&(o=Math.min(o,i.s));for(let i of e.atoms)s(i.el.parentNode,w(i.el))&&(o=Math.min(o,i.i));return o}function Le(e,n){let t=e.slice(n.bs,n.be),r=0;for(;r<t.length&&r<n.text.length&&t[r]===n.text[r];)r++;let o=0;for(;o<t.length-r&&o<n.text.length-r&&t[t.length-1-o]===n.text[n.text.length-1-o];)o++;return{bs:n.bs+r,be:n.be-o,text:n.text.slice(r,n.text.length-o)}}function G(e,n,t,r){if(e===n)return{s:t,e:r};let o=0,s=0,i=H.diff(e,n).map(c=>Le(e,c)).sort((c,l)=>c.bs-l.bs);for(let c of i){if(c.bs===c.be&&!c.text)continue;let l=c.text.length-(c.be-c.bs);if(c.be<=t)o+=l;else{if(c.bs>=r)continue;if(c.bs>=t&&c.be<=r){if(Ne.test(e.slice(c.bs,c.be)+c.text))return null;s+=l}else return null}}return{s:t+o,e:r+o+s}}function Be(e,n,t){let r=e.liveScope;if(r&&r.startContainer&&m(r.startContainer,n)&&m(r.endContainer,n)){let s=K(t,r.startContainer,r.startOffset);if(s!==null)return s}if(Y(n))return 0;let o=e.merged.text?t.text.indexOf(e.merged.text):-1;return o>=0&&t.text.indexOf(e.merged.text,o+1)<0?o:null}function Te(e,n){let t=e.commonAncestorContainer;for(t.nodeType===3&&(t=t.parentNode);t&&t!==n;t=t.parentNode)if(k(t)&&Y(t))return t;return n}var Oe=(e,n)=>e.tagName===n.tagName&&e.attributes.length===n.attributes.length&&[...e.attributes].every(t=>n.getAttribute(t.name)===t.value);function de(e,n){let t=[];for(let r=k(e)?e:e.parentNode;r&&r!==n&&W(r);r=r.parentNode)t.unshift(r);return t}function Ue(e,n,t){let[r,o]=e;if(r.nodeType===3){if(o!==0&&o!==r.data.length)return e;[r,o]=[r.parentNode,w(r)+(o===0?0:1)]}let s=!1;for(;r!==n&&W(r)&&(o===0||o===r.childNodes.length)&&!t.some(i=>Oe(i,r));)[r,o]=[r.parentNode,w(r)+(o===0?0:1)],s=!0;return s?[r,o]:e}function He(e,n,t){let r=de(n.startContainer,t),o=de(n.endContainer,t);return r.length!==o.length||r.some((s,i)=>s!==o[i])||r.length>e.wrappers.length||r.some((s,i)=>!Oe(s,e.wrappers[i]))?!1:(e.peel=r.length,!e.wrappers.slice(e.peel).some(s=>r.some(i=>i.tagName===s.tagName)))}function Fe(e,n,t,r){let o=e.childNodes.length===1&&k(e.firstChild)?e.firstChild:null;if(!o||!L.has(o.tagName))return;let s=document.createRange();s.setStart(...n),s.setEnd(...t);let i=Te(s,r);i===r||i.tagName!==o.tagName||i.namespaceURI!==o.namespaceURI||x(i)!==x(o)||o.replaceWith(...o.childNodes)}function Ge(e){if(!e.parsed)return e.fragment;let n=e.parsed.childNodes;return n.length?n.length===1&&n[0].nodeType===3?n[0].data:null:""}function Ve(e,n){let t=e.recovery.text,r=e.recovery.subject,o=b(r,n,r.nodeType);if(!o)return null;let s=o.nodeType===3&&o.parentNode?.localName==="textarea"?o.parentNode:o,i=t.local.text.slice(t.local.start,t.local.end);if(Ne.test(t.merged.text.slice(t.merged.start,t.merged.end))||i.includes(C))return null;let c={kind:"text",id:e.id,ticket:n.ticket,key:r.key,fragment:t.local.fragment,encoding:t.encoding,local:i,ids:new Set,range:document.createRange()};if(o.nodeType===8){let g=G(t.merged.text,o.data,t.merged.start,t.merged.end);return g?(c.range.setStart(o,g.s),c.range.setEnd(o,g.e),{...c,root:o,owner:o,scope:o,s:g.s,e:g.e,before:o.data,bs:g.s,be:g.e}):null}if(s.localName==="textarea"){if(c.encoding!=="plain")return null;let g=G(t.merged.text,s.value,t.merged.start,t.merged.end);return g?(c.range.selectNodeContents(s),{...c,root:s,field:s,scope:s,f:{text:s.value},s:g.s,e:g.e,before:s.value,bs:g.s,be:g.e}):null}let l=_(o),u=Be(t,o,l);if(u===null)return null;let d=G(t.merged.text,l.text.slice(u),t.merged.start,t.merged.end);if(!d)return null;let N=u+d.s,v=u+d.e,A=fe(l,N,"start"),a=N===v?A:fe(l,v,"end");if(c.parsed=c.encoding==="html"?Re(c.fragment):null,c.parsed&&Fe(c.parsed,A,a,o),c.parsed&&Ie(c.parsed)||(c.wrappers=c.parsed?Se(c.parsed):[],c.parsed&&D(c.parsed,c.ids),c.plain=Ge(c),N===v&&(A=a=Ue(A,o,c.wrappers)),c.range.setStart(...A),c.range.setEnd(...a),!He(c,c.range,o)))return null;let f=Te(c.range,o),p=f===o?l:_(f),E=K(p,...A),U=N===v?E:K(p,...a);return E===null||U===null||p.text.slice(E,U)!==l.text.slice(N,v)?null:{...c,root:o,f:l,s:N,e:v,scope:f,before:p.text,bs:E,be:U}}function qe(e){if(e.owner){let o=e.owner.data;e.owner.data=o.slice(0,e.s)+e.fragment+o.slice(e.e),e.check=()=>e.owner.data.slice(e.s,e.s+e.fragment.length)===e.fragment&&h(e.owner);return}if(e.field){let o=e.field,s=o.value.slice(0,e.s)+e.fragment+o.value.slice(e.e);o.textContent=s,o.value!==s&&(o.value=s,e.wroteProperty=!0),o.hasAttribute("data-value")&&o.setAttribute("data-value",s),e.check=()=>h(o)&&o.value===s&&o.textContent===s;return}let n=e.range,t=n.startContainer;if(e.plain!==null&&t.nodeType===3&&n.endContainer===t){let o=n.startOffset;t.replaceData(o,n.endOffset-o,e.plain),e.check=()=>h(t)&&t.data.slice(o,o+e.plain.length)===e.plain;return}n.deleteContents();let r=[];if(e.fragment)if(e.parsed){let o=document.importNode(e.parsed,!0),s=Se(o);for(let i=0;i<e.peel;i++)s[i].replaceWith(...s[i].childNodes);r=[...o.childNodes],n.insertNode(o)}else r=[document.createTextNode(e.fragment)],n.insertNode(r[0]);e.check=()=>r.every(h)&&(e.parsed||!r.length||r[0].data===e.fragment)}function _e(e,n){let t=b(e.recovery.subject,n,1);if(!t)return null;let r=e.recovery.attribute,o={kind:"attr",id:e.id,ticket:n.ticket,key:e.recovery.subject.key,el:t,ns:r.namespaceURI,name:r.qualifiedName,local:r.localName,value:e.local??null,ids:new Set};try{o.ns===null?document.createAttribute(o.name):document.createAttributeNS(o.ns,o.name)}catch{return null}return o}var je=new Set(["hidden","submit","image","reset","button","checkbox","radio","file"]);function Ke(e,n){let t=document.createElement("input");return t.type=e.type,t.value=n,t.value}function We(e){let n=e.el;return e.ns!==null||n.namespaceURI!=="http://www.w3.org/1999/xhtml"?null:n.localName==="input"&&e.name==="checked"&&(n.type==="checkbox"||n.type==="radio")?["checked",e.value!==null]:n.localName==="input"&&e.name==="value"&&!je.has(n.type)?["value",Ke(n,e.value??"")]:n.localName==="option"&&e.name==="selected"?["selected",e.value!==null]:null}function ze(e){e.ns===null?e.value===null?e.el.removeAttribute(e.name):e.el.setAttribute(e.name,e.value):e.value===null?e.el.removeAttributeNS(e.ns,e.local):e.el.setAttributeNS(e.ns,e.name,e.value);let n=We(e);n&&e.el[n[0]]!==n[1]&&(e.el[n[0]]=n[1],e.wroteProperty=!0);let t=()=>e.ns===null?e.el.getAttribute(e.name):e.el.getAttributeNS(e.ns,e.local);e.check=()=>h(e.el)&&t()===e.value&&(!n||e.el[n[0]]===n[1])}function Ye(e,n){let t=e.recovery.structure,r=e.recovery.subject,o=b(r,n,r.nodeType),s={id:e.id,ticket:n.ticket,key:r.key,apply:n,ids:new Set},i=c=>c?b(c.parent,n,1):null;if(t.localAction==="deleted")return o?{...s,kind:"remove",node:o}:Pe(r)?{...s,kind:"done",check:()=>!0}:null;if(t.localAction==="moved"){let c=i(t.localPlacement);return!o||!c||o===c||m(c,o)?null:{...s,kind:"move",node:o,parent:c,placement:t.localPlacement}}if(t.localAction==="reordered"){if(!o||!t.localOrder)return null;let c=y(o),l=t.localOrder.map(u=>b(u,n,u.nodeType)).filter(u=>u&&u.parentNode===c);return l.length<2?null:{...s,kind:"reorder",parent:o,order:l}}if(t.localAction==="inserted"){let c=i(t.localPlacement);if(!c||o&&o.parentNode!==y(c))return null;if(t.fragmentKind!=="element")return typeof t.localFragment!="string"?null:{...s,kind:"run",node:o,parent:c,placement:t.localPlacement,text:t.localFragment,nodeType:r.nodeType};let l=r.local.length?Ae(n.root,r.local[0]):null;if(!k(l))return null;let u=o?o.tagName===l.tagName&&o.namespaceURI===l.namespaceURI?"morph":"replace":"place";return{...s,kind:"realize",node:o,parent:c,placement:t.localPlacement,src:l,mode:u,ids:D(l)}}return null}function V(e,n,t,r){let o=y(n),s=l=>{for(let u of l){let d=b(u,r,u.nodeType);if(d&&d!==e&&d.parentNode===o)return d}return null},i=s(t.before);if(i)return o.insertBefore(e,i);let c=s(t.after);return c?o.insertBefore(e,c.nextSibling):t.before.length?o.insertBefore(e,o.firstChild):o.appendChild(e)}function $e(e){let n=document.importNode(e.src,!0),t=document.createDocumentFragment();return t.append(n),e.apply.domain==="save"&&(se(t),ce(t),ie(t),Z(t)),n}function Qe(e,n){let t=e.filter(r=>r.kind==="move");for(let r of t)n.append(r.node);for(let r of e){if(r.kind==="run"){r.node?r.node.data=r.text:r.node=V(r.nodeType===8?document.createComment(r.text):document.createTextNode(r.text),r.parent,r.placement,r.apply),r.check=()=>h(r.node)&&r.node.parentNode===y(r.parent)&&r.node.data===r.text;continue}if(r.kind!=="realize")continue;let o=$e(r);r.mode==="morph"?H.morphElement(r.node,o,{ignore:B,scripts:{execute:!1}}):r.mode==="replace"?(r.node.replaceWith(o),r.node=o):r.node=V(o,r.parent,r.placement,r.apply),r.check=()=>h(r.node)&&r.node.parentNode===y(r.parent)}for(let r of t)V(r.node,r.parent,r.placement,r.apply),r.check=()=>r.node.parentNode===y(r.parent)&&h(r.node);for(let r of e){if(r.kind!=="reorder")continue;let o=y(r.parent),s=r.order.filter(u=>u.parentNode===o),i=s.slice(),c=[...o.childNodes].map(u=>s.includes(u)?i.shift():u),l=null;for(let u=c.length-1;u>=0;u--){let d=c[u];s.includes(d)&&d.nextSibling!==l&&o.insertBefore(d,l),l=d}r.check=()=>{let u=[...o.childNodes].filter(d=>s.includes(d));return u.length===s.length&&u.every((d,N)=>d===s[N])}}for(let r of e)r.kind==="remove"&&(r.node.remove(),r.check=()=>!h(r.node))}function O(e){return e.kind==="move"||e.kind==="remove"?[e.node]:e.kind==="realize"||e.kind==="run"?e.node?[e.node]:[]:[]}function R(e){return e.kind==="text"?[e.scope]:e.kind==="move"||e.kind==="reorder"?[e.parent]:(e.kind==="realize"||e.kind==="run")&&!e.node?[e.parent]:[]}var be=e=>e.kind==="attr"?[e.el]:[...O(e),...R(e)];function Xe(e,n){try{let t=j(e.startContainer,e.startOffset),r=j(n.startContainer,n.startOffset);return e.collapsed&&n.collapsed?t.comparePoint(n.startContainer,n.startOffset)===0:t.comparePoint(n.endContainer,n.endOffset)>0&&r.comparePoint(e.endContainer,e.endOffset)>0}catch{return!1}}function Je(e,n){try{return e.comparePoint(n.startContainer,n.startOffset)===0&&e.comparePoint(n.endContainer,n.endOffset)===0}catch{return!1}}function Ze(e,n){try{return e.intersectsNode(n)&&!m(e.commonAncestorContainer,n)}catch{return!1}}function I(e,n){if(!e.ids.size&&!n.ids.size)return!1;let t=s=>{let i=new Set;for(let c of be(s))D(c,i);return i},r=e.ids.size?null:t(e),o=t(n);return[...e.ids].some(s=>n.ids.has(s)||o.has(s))||[...n.ids].some(s=>(r||t(e)).has(s))}function me(e,n){return n.kind==="text"?Ze(n.range,e.el):O(n).some(t=>m(e.el,t))||n.ids.has(x(e.el))}function pe(e,n){return n.kind==="reorder"?m(n.parent,e.scope)||I(e,n):O(n).some(t=>m(t,e.scope)||m(e.scope,t))||R(n).some(t=>m(t,e.scope))?!0:I(e,n)}function he(e,n){return O(n).some(t=>e.order.includes(t)||m(e.parent,t))||R(n).includes(e.parent)?!0:I(e,n)}function q(e,n){if(e.kind==="done"||n.kind==="done")return!1;if(e.kind==="text"&&n.kind==="text")return Xe(e.range,n.range);if(e.kind==="attr"&&n.kind==="attr")return e.el===n.el&&e.ns===n.ns&&e.local===n.local;if(e.kind==="attr")return me(e,n);if(n.kind==="attr")return me(n,e);if(e.kind==="text")return pe(e,n);if(n.kind==="text")return pe(n,e);if(e.kind==="reorder"&&n.kind==="reorder")return e.parent===n.parent||I(e,n);if(e.kind==="reorder")return he(e,n);if(n.kind==="reorder")return he(n,e);for(let t of O(e))for(let r of O(n))if(m(t,r)||m(r,t))return!0;for(let t of O(e))for(let r of R(n))if(m(r,t))return!0;for(let t of O(n))for(let r of R(e))if(m(r,t))return!0;return I(e,n)}function et(e,n){return e.kind==="done"?!1:e.kind==="attr"?m(e.el,n.node):be(e).some(t=>m(t,n.node)||m(n.node,t))?!0:e.ids.size?(n.ids||(n.ids=D(n.node)),[...e.ids].some(t=>n.ids.has(t))):!1}function tt(e,n){return e.kind==="text"&&n.kind==="text"&&!e.field&&e.root===n.root&&Je(e.range,n.range)}function nt(e,n){let t=oe(e);return t?t.nodes:[rt(e,n)]}function rt(e,n){let t=e.recovery,r=t.subject;for(let c of t.text?[t.text.liveSpan,t.text.liveScope]:[])if(c&&c.startContainer&&h(c.startContainer)&&h(c.endContainer))return st(ot(c));let o=r?b(r,n,r.nodeType):null;if(o)return o;let s=t.structure&&t.structure.localPlacement?b(t.structure.localPlacement.parent,n,1):null;if(s)return s;let i=r&&r.local.length?r.local[0]:[];for(let c=i.length-1;c>0;c--){if(i[c-1]==="content")continue;let l=$(i.slice(0,c),n);if(l)return l}return document.documentElement}function ot(e){let n=new Set;for(let r=e.startContainer;r;r=r.parentNode)n.add(r);let t=e.endContainer;for(;t&&!n.has(t);)t=t.parentNode;return t.nodeType===1||t.nodeType===11?t:t.parentNode}function st(e){for(let n=e;n;n=n.parentNode)if(k(n)&&ke.has(n.tagName))return n;return e}function ct(e,n){let t=e.recovery;return t.applied===!1||t.unavailable?null:t.structure?Ye(e,n):t.text?Ve(e,n):t.attribute?_e(e,n):null}var P=()=>`${re()}|${S.hasPendingApply()?1:0}|${S.list().map(e=>e.id).join(",")}`;function Ee(){let e={ids:new Map,nested:new Set},n=r=>{for(let o of["id","data-id"]){let s=r.getAttribute(o);s&&e.ids.set(`${o} ${s}`,(e.ids.get(`${o} ${s}`)||0)+1)}},t=(r,o)=>{for(let s of y(r).children)n(s),o&&L.has(s.tagName)&&e.nested.add(s),t(s,o||W(s)||we.has(s.tagName))};return n(document.documentElement),t(document.documentElement,!1),e}function it(e){let n=Ee();for(let[r,o]of n.ids)if(o>1&&(e.before.ids.get(r)||0)<=1)return!1;for(let r of n.nested)if(!e.before.nested.has(r))return!1;let t=new Map;for(let r of e.ops)r.kind==="text"&&t.set(r.scope,[...t.get(r.scope)||[],r]);for(let[r,o]of t){let s=o[0].before;for(let c of[...o].sort((l,u)=>u.bs-l.bs))s=s.slice(0,c.bs)+c.local+s.slice(c.be);if((o[0].owner?r.data:o[0].field?r.value:_(r).text)!==s)return!1}return!0}function lt(){let e=new Map,n=c=>{for(let l of c.querySelectorAll("*"))e.set(l,[...l.attributes].map(u=>[u,u.value])),l.localName==="template"&&l.content&&n(l.content)};n(document);let t=[];for(let c of document.querySelectorAll("input, textarea"))t.push([c,"value",c.value]);for(let c of document.querySelectorAll("input"))t.push([c,"checked",c.checked]);for(let c of document.querySelectorAll("option"))t.push([c,"selected",c.selected]);let r=document.activeElement,o=null;try{r&&typeof r.selectionStart=="number"&&(o=[r.selectionStart,r.selectionEnd,r.selectionDirection])}catch{}let s=document.getSelection(),i=s&&s.rangeCount?[s.anchorNode,s.anchorOffset,s.focusNode,s.focusOffset]:null;return{attrs:e,controls:t,active:r,caret:o,selection:i}}function at(e,n){let t=e.attributes;return t.length===n.length&&n.every(([r,o],s)=>t[s]===r&&r.value===o)}function ut(e,n){let t=new Set;for(let s=e.length-1;s>=0;s--){let i=e[s];if(i.type==="characterData")i.target.data=i.oldValue;else if(i.type==="attributes")t.add(i.target);else{for(let c of i.addedNodes)c.parentNode===i.target&&i.target.removeChild(c);for(let c of i.removedNodes)i.target.insertBefore(c,i.nextSibling)}}for(let s of t){let i=n.attrs.get(s);if(!(!i||at(s,i))){for(let c of[...s.attributes])s.removeAttributeNode(c);for(let[c,l]of i)c.value=l,s.setAttributeNode(c)}}for(let[s,i,c]of n.controls)if(s[i]!==c)try{s[i]=c}catch{}let r=document.getSelection();r&&n.selection?h(n.selection[0])&&h(n.selection[2])&&r.setBaseAndExtent(...n.selection):r&&r.rangeCount&&r.removeAllRanges();let o=n.active;if(o&&o!==document.activeElement&&o!==document.body&&h(o)&&o.focus&&o.focus({preventScroll:!0}),n.caret&&document.activeElement===o)try{o.setSelectionRange(...n.caret)}catch{}}function ft(e){let n=t=>{e.observe(t,ve);for(let r of t.querySelectorAll("template"))r.content&&n(r.content)};n(document)}function dt(e){let n=new Set;for(let t of e)if(t.type==="characterData"){if(n.has(t.target))return!1;n.add(t.target)}return!0}function mt(e){let n=P(),t=new Map,r=new Map,o=[],s=new Set;for(let a of e){if(s.has(a))continue;s.add(a);let f=S.get(a);f&&(f.claimedBy||f.kind==="apply-incomplete"||f.kind==="json"||!f.recovery?t.set(a,T):o.push(f))}if(S.hasPendingApply()){for(let a of o)t.set(a.id,T);return{ops:[],covered:r,blocked:t,revision:n,before:null}}let i=[],c=a=>{let f=S.recoveryOf(a.id),p=f?ct(a,f):null;if(!p&&f)for(let E of nt(a,f))i.push({ticket:f.ticket,node:E});return p},l=[];for(let a of o){let f=c(a);f?l.push(f):t.set(a.id,T)}let u=[];for(let a of S.list())if(!s.has(a.id)){if(a.kind==="apply-incomplete")i.push({ticket:a.ticket,node:document.documentElement});else if(a.recovery){let f=c(a);f&&u.push(f)}}l.sort((a,f)=>f.ticket-a.ticket);let d=[],N=[],v=a=>{t.set(a.id,T),N.push(a)};for(let a of l){if(i.some(p=>p.ticket>a.ticket&&et(a,p))||u.some(p=>p.ticket>a.ticket&&q(p,a))||N.some(p=>q(p,a))){v(a);continue}let f=d.find(p=>q(p,a));if(!f){d.push(a);continue}if(tt(f,a)){r.set(a.id,f.id);continue}v(a),f.ticket===a.ticket&&(d.splice(d.indexOf(f),1),v(f))}let A=ne(i.filter(a=>d.some(f=>a.ticket>f.ticket)).map(a=>a.node));return{ops:d,covered:r,blocked:t,revision:P(),protectedWitnesses:A,before:Ee()}}function pt(e){if(e.revision!==P()||!F(e.protectedWitnesses||[])){for(let c of e.ops)e.blocked.set(c.id,T);for(let c of e.covered.keys())e.blocked.set(c,T);return[]}let n=lt(),t=window.clay?.undo;t?.pause?.();let r=new MutationObserver(()=>{}),o=document.createDocumentFragment(),s=[],i=!1;try{ft(r),r.observe(o,ve);let c=e.ops.filter(l=>l.kind==="text").sort((l,u)=>l.root===u.root?u.s-l.s||u.e-l.e:0);for(let l of c)qe(l);for(let l of e.ops)l.kind==="attr"&&ze(l);Qe(e.ops.filter(l=>l.kind!=="text"&&l.kind!=="attr"),o),s=r.takeRecords(),i=e.ops.every(l=>l.check())&&it(e)&&e.revision===P()&&F(e.protectedWitnesses||[])}catch(c){console.error("[clay] Revert to mine failed while writing and was undone",c)}finally{s=s.concat(r.takeRecords()),r.disconnect()}if(i)return dt(s)&&!e.ops.some(c=>c.wroteProperty)?t?.commitCaptured?.("Revert to mine"):t?.discardCaptured?.(),t?.resume?.(),[...e.ops.map(c=>c.id),...e.covered.keys()];try{ut(s,n)}finally{J.dropQueued(),t?.discardCaptured?.(),t?.resume?.()}for(let c of e.ops)e.blocked.set(c.id,T);for(let c of e.covered.keys())e.blocked.set(c,T);return[]}async function wt(e){await Promise.resolve();let n=mt(e),t=pt(n);Q();let r=null;return t.length&&(ee(),S.acknowledge(t,{reason:"reverted"}),X(),await Promise.resolve(),r=await te()),{revertedIds:t,blockedIds:[...n.blocked.keys()],saveResult:r}}export{T as BLOCKED,pt as applyRevert,mt as prepareRevert,wt as revertConflicts};
|
|
1
|
+
import{f as S}from"./c-LV5MABYD.js";import{a as ne,b as F,c as re,d as oe}from"./c-N326R2JD.js";import{a as H}from"./c-JAX2667S.js";import{b as le,c as ae}from"./c-AL4RBJF2.js";import"./c-DHXPDLW6.js";import"./c-LZJPNR2W.js";import{b as ce,g as ie}from"./c-N7Y52HJH.js";import{b as Z}from"./c-ZSCBEB7I.js";import{b as se}from"./c-TUGVINJR.js";import"./c-FILLTJA7.js";import"./c-TWCXBWS3.js";import"./c-VKEDWYDF.js";import{D as te}from"./c-NLZ5AN4L.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import{g as ee}from"./c-GSRLXYWL.js";import"./c-X5LNHET5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import{a as J}from"./c-LA2BW7UY.js";import"./c-GVPNDIKJ.js";import"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import{f as X}from"./c-IJUK2GPW.js";import"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-EGTIAL6P.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import{h as Q}from"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var T="This spot changed again. Review the latest edit or download your copy.",ue="\uFFFC",C="",M=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),ge=new Set(["BR","WBR","IMG"]),L=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" ")),ke=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" ")),we=new Set("P H1 H2 H3 H4 H5 H6 SUMMARY".split(" ")),Ne=/[\u001E]/,ve={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0},k=e=>!!e&&e.nodeType===1,W=e=>k(e)&&M.has(e.tagName),B=e=>e.matches(le),z=e=>e.matches(ae),y=e=>e.localName==="template"&&e.content?e.content:e,w=e=>Array.prototype.indexOf.call(e.parentNode.childNodes,e),x=e=>e.getAttribute("data-id")||e.getAttribute("id")||null;function Ce(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function ye(e){if(e.nodeType===3)return!0;if(!k(e))return!1;if(B(e)||ge.has(e.tagName))return!0;if(!M.has(e.tagName))return!L.has(e.tagName);if(z(e))return!1;for(let n of e.childNodes)if(!ye(n))return!1;return!0}function Y(e){if(!ke.has(e.tagName)||B(e)||z(e))return!1;for(let n of e.childNodes)if(n.nodeType===8||!ye(n))return!1;return!0}function xe(e,n=document){for(let t of n.querySelectorAll("template")){if(t.content===e)return t;let r=xe(e,t.content);if(r)return r}return null}function m(e,n){for(let t=e;t;t=t.nodeType===11?xe(t):t.parentNode)if(t===n)return!0;return!1}var h=e=>m(e,document);function Ae(e,n){let t=e;for(let r of n)if(t=r==="content"?t.content:t.childNodes[r],!t)return null;return t}function D(e,n=new Set){if(k(e)){let t=x(e);t&&n.add(t)}if(e.nodeType===1||e.nodeType===11)for(let t of y(e).childNodes)D(t,n);return n}function Re(e){let n=document.createElement("template");return n.innerHTML=e,n.content}var Ie=e=>[...e.querySelectorAll("*")].some(n=>L.has(n.tagName));function Se(e){let n=[];for(let t=e;t.childNodes.length===1&&k(t.firstChild);t=t.firstChild)n.push(t.firstChild);return n}function De(e,n){let t=e.lastIndexOf("content");if(t<0)return document;let r=$(e.slice(0,t),n);return r&&r.content?r.content:null}function $(e,n){let t=Ae(n.root,e);if(!k(t))return null;let r=x(t),o=r?De(e,n):null;if(!o)return null;let s=[...o.querySelectorAll(t.localName)].filter(i=>i.namespaceURI===t.namespaceURI&&x(i)===r);return s.length===1?s[0]:null}function Me(e){let n=x(e);if(!n)return null;let t=[...document.querySelectorAll(e.localName)].filter(r=>r.namespaceURI===e.namespaceURI&&x(r)===n);return t.length===1?t[0]:null}function b(e,n,t=e?e.nodeType:1){if(!e)return null;for(let o of e.live)if(o.nodeType===t&&h(o))return o;if(t!==1)return null;if(e.local.length)return $(e.local[0],n);let r=e.live.find(k);return r?Me(r):null}function Pe(e){let n=e.live.find(k),t=n?x(n):null;return!!t&&![...document.querySelectorAll(n.localName)].some(r=>x(r)===t)}function _(e){let n=y(e),t={root:e,container:n,text:"",nodes:[],atoms:[],blocks:[]},r=s=>{for(let i of s){if(i.nodeType===3){if(!i.data)continue;t.nodes.push({node:i,s:t.text.length,e:t.text.length+i.data.length}),t.text+=i.data;continue}if(!k(i)||B(i))continue;if(Y(i)){t.text.length&&t.text[t.text.length-1]!==C&&(t.text+=C);let l={el:i,from:t.text.length,to:-1};t.blocks.push(l),r(i.childNodes),t.text+=C,l.to=t.text.length;continue}let c=M.has(i.tagName)&&Ce(i);if(ge.has(i.tagName)||!M.has(i.tagName)||z(i)||c){t.atoms.push({i:t.text.length,el:i}),t.text+=ue;continue}r(i.childNodes)}};if(r(n.childNodes),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&!t.blocks.length&&t.text.replace(ue,"").trim()===""){let s=t.atoms[0].i;t.text=t.text.slice(0,s)+t.text.slice(s+1),t.atoms=[];for(let i of t.nodes)i.s>s&&(i.s--,i.e--)}return t}function fe(e,n,t){for(let s of e.nodes)if(t==="start"?s.s<=n&&n<s.e:s.s<n&&n<=s.e)return[s.node,n-s.s];let r=t==="start"?n:n-1,o=e.atoms.find(s=>s.i===r);if(o)return[o.el.parentNode,w(o.el)+(t==="start"?0:1)];if(e.text[r]===C){let s=e.blocks.find(c=>c.to===r+1);if(s)return t==="start"?[s.el,s.el.childNodes.length]:[s.el.parentNode,w(s.el)+1];let i=e.blocks.find(c=>c.from===r+1);if(i)return t==="start"?[i.el,0]:[i.el.parentNode,w(i.el)]}for(let s of e.nodes)if(s.s===n||s.e===n)return[s.node,n-s.s];return[e.container,n===0?0:e.container.childNodes.length]}function j(e,n){let t=document.createRange();return t.setStart(e,n),t.setEnd(e,n),t}function K(e,n,t){if(n.nodeType===3){let i=e.nodes.find(c=>c.node===n);return i?i.s+t:null}if(n!==e.container&&!m(n,e.root))return null;let r=j(n,t),o=e.text.length,s=(i,c)=>{try{return r.comparePoint(i,c)>=0}catch{return!1}};for(let i of e.nodes)s(i.node,0)&&(o=Math.min(o,i.s));for(let i of e.atoms)s(i.el.parentNode,w(i.el))&&(o=Math.min(o,i.i));return o}function Le(e,n){let t=e.slice(n.bs,n.be),r=0;for(;r<t.length&&r<n.text.length&&t[r]===n.text[r];)r++;let o=0;for(;o<t.length-r&&o<n.text.length-r&&t[t.length-1-o]===n.text[n.text.length-1-o];)o++;return{bs:n.bs+r,be:n.be-o,text:n.text.slice(r,n.text.length-o)}}function G(e,n,t,r){if(e===n)return{s:t,e:r};let o=0,s=0,i=H.diff(e,n).map(c=>Le(e,c)).sort((c,l)=>c.bs-l.bs);for(let c of i){if(c.bs===c.be&&!c.text)continue;let l=c.text.length-(c.be-c.bs);if(c.be<=t)o+=l;else{if(c.bs>=r)continue;if(c.bs>=t&&c.be<=r){if(Ne.test(e.slice(c.bs,c.be)+c.text))return null;s+=l}else return null}}return{s:t+o,e:r+o+s}}function Be(e,n,t){let r=e.liveScope;if(r&&r.startContainer&&m(r.startContainer,n)&&m(r.endContainer,n)){let s=K(t,r.startContainer,r.startOffset);if(s!==null)return s}if(Y(n))return 0;let o=e.merged.text?t.text.indexOf(e.merged.text):-1;return o>=0&&t.text.indexOf(e.merged.text,o+1)<0?o:null}function Te(e,n){let t=e.commonAncestorContainer;for(t.nodeType===3&&(t=t.parentNode);t&&t!==n;t=t.parentNode)if(k(t)&&Y(t))return t;return n}var Oe=(e,n)=>e.tagName===n.tagName&&e.attributes.length===n.attributes.length&&[...e.attributes].every(t=>n.getAttribute(t.name)===t.value);function de(e,n){let t=[];for(let r=k(e)?e:e.parentNode;r&&r!==n&&W(r);r=r.parentNode)t.unshift(r);return t}function Ue(e,n,t){let[r,o]=e;if(r.nodeType===3){if(o!==0&&o!==r.data.length)return e;[r,o]=[r.parentNode,w(r)+(o===0?0:1)]}let s=!1;for(;r!==n&&W(r)&&(o===0||o===r.childNodes.length)&&!t.some(i=>Oe(i,r));)[r,o]=[r.parentNode,w(r)+(o===0?0:1)],s=!0;return s?[r,o]:e}function He(e,n,t){let r=de(n.startContainer,t),o=de(n.endContainer,t);return r.length!==o.length||r.some((s,i)=>s!==o[i])||r.length>e.wrappers.length||r.some((s,i)=>!Oe(s,e.wrappers[i]))?!1:(e.peel=r.length,!e.wrappers.slice(e.peel).some(s=>r.some(i=>i.tagName===s.tagName)))}function Fe(e,n,t,r){let o=e.childNodes.length===1&&k(e.firstChild)?e.firstChild:null;if(!o||!L.has(o.tagName))return;let s=document.createRange();s.setStart(...n),s.setEnd(...t);let i=Te(s,r);i===r||i.tagName!==o.tagName||i.namespaceURI!==o.namespaceURI||x(i)!==x(o)||o.replaceWith(...o.childNodes)}function Ge(e){if(!e.parsed)return e.fragment;let n=e.parsed.childNodes;return n.length?n.length===1&&n[0].nodeType===3?n[0].data:null:""}function Ve(e,n){let t=e.recovery.text,r=e.recovery.subject,o=b(r,n,r.nodeType);if(!o)return null;let s=o.nodeType===3&&o.parentNode?.localName==="textarea"?o.parentNode:o,i=t.local.text.slice(t.local.start,t.local.end);if(Ne.test(t.merged.text.slice(t.merged.start,t.merged.end))||i.includes(C))return null;let c={kind:"text",id:e.id,ticket:n.ticket,key:r.key,fragment:t.local.fragment,encoding:t.encoding,local:i,ids:new Set,range:document.createRange()};if(o.nodeType===8){let g=G(t.merged.text,o.data,t.merged.start,t.merged.end);return g?(c.range.setStart(o,g.s),c.range.setEnd(o,g.e),{...c,root:o,owner:o,scope:o,s:g.s,e:g.e,before:o.data,bs:g.s,be:g.e}):null}if(s.localName==="textarea"){if(c.encoding!=="plain")return null;let g=G(t.merged.text,s.value,t.merged.start,t.merged.end);return g?(c.range.selectNodeContents(s),{...c,root:s,field:s,scope:s,f:{text:s.value},s:g.s,e:g.e,before:s.value,bs:g.s,be:g.e}):null}let l=_(o),u=Be(t,o,l);if(u===null)return null;let d=G(t.merged.text,l.text.slice(u),t.merged.start,t.merged.end);if(!d)return null;let N=u+d.s,v=u+d.e,A=fe(l,N,"start"),a=N===v?A:fe(l,v,"end");if(c.parsed=c.encoding==="html"?Re(c.fragment):null,c.parsed&&Fe(c.parsed,A,a,o),c.parsed&&Ie(c.parsed)||(c.wrappers=c.parsed?Se(c.parsed):[],c.parsed&&D(c.parsed,c.ids),c.plain=Ge(c),N===v&&(A=a=Ue(A,o,c.wrappers)),c.range.setStart(...A),c.range.setEnd(...a),!He(c,c.range,o)))return null;let f=Te(c.range,o),p=f===o?l:_(f),E=K(p,...A),U=N===v?E:K(p,...a);return E===null||U===null||p.text.slice(E,U)!==l.text.slice(N,v)?null:{...c,root:o,f:l,s:N,e:v,scope:f,before:p.text,bs:E,be:U}}function qe(e){if(e.owner){let o=e.owner.data;e.owner.data=o.slice(0,e.s)+e.fragment+o.slice(e.e),e.check=()=>e.owner.data.slice(e.s,e.s+e.fragment.length)===e.fragment&&h(e.owner);return}if(e.field){let o=e.field,s=o.value.slice(0,e.s)+e.fragment+o.value.slice(e.e);o.textContent=s,o.value!==s&&(o.value=s,e.wroteProperty=!0),o.hasAttribute("data-value")&&o.setAttribute("data-value",s),e.check=()=>h(o)&&o.value===s&&o.textContent===s;return}let n=e.range,t=n.startContainer;if(e.plain!==null&&t.nodeType===3&&n.endContainer===t){let o=n.startOffset;t.replaceData(o,n.endOffset-o,e.plain),e.check=()=>h(t)&&t.data.slice(o,o+e.plain.length)===e.plain;return}n.deleteContents();let r=[];if(e.fragment)if(e.parsed){let o=document.importNode(e.parsed,!0),s=Se(o);for(let i=0;i<e.peel;i++)s[i].replaceWith(...s[i].childNodes);r=[...o.childNodes],n.insertNode(o)}else r=[document.createTextNode(e.fragment)],n.insertNode(r[0]);e.check=()=>r.every(h)&&(e.parsed||!r.length||r[0].data===e.fragment)}function _e(e,n){let t=b(e.recovery.subject,n,1);if(!t)return null;let r=e.recovery.attribute,o={kind:"attr",id:e.id,ticket:n.ticket,key:e.recovery.subject.key,el:t,ns:r.namespaceURI,name:r.qualifiedName,local:r.localName,value:e.local??null,ids:new Set};try{o.ns===null?document.createAttribute(o.name):document.createAttributeNS(o.ns,o.name)}catch{return null}return o}var je=new Set(["hidden","submit","image","reset","button","checkbox","radio","file"]);function Ke(e,n){let t=document.createElement("input");return t.type=e.type,t.value=n,t.value}function We(e){let n=e.el;return e.ns!==null||n.namespaceURI!=="http://www.w3.org/1999/xhtml"?null:n.localName==="input"&&e.name==="checked"&&(n.type==="checkbox"||n.type==="radio")?["checked",e.value!==null]:n.localName==="input"&&e.name==="value"&&!je.has(n.type)?["value",Ke(n,e.value??"")]:n.localName==="option"&&e.name==="selected"?["selected",e.value!==null]:null}function ze(e){e.ns===null?e.value===null?e.el.removeAttribute(e.name):e.el.setAttribute(e.name,e.value):e.value===null?e.el.removeAttributeNS(e.ns,e.local):e.el.setAttributeNS(e.ns,e.name,e.value);let n=We(e);n&&e.el[n[0]]!==n[1]&&(e.el[n[0]]=n[1],e.wroteProperty=!0);let t=()=>e.ns===null?e.el.getAttribute(e.name):e.el.getAttributeNS(e.ns,e.local);e.check=()=>h(e.el)&&t()===e.value&&(!n||e.el[n[0]]===n[1])}function Ye(e,n){let t=e.recovery.structure,r=e.recovery.subject,o=b(r,n,r.nodeType),s={id:e.id,ticket:n.ticket,key:r.key,apply:n,ids:new Set},i=c=>c?b(c.parent,n,1):null;if(t.localAction==="deleted")return o?{...s,kind:"remove",node:o}:Pe(r)?{...s,kind:"done",check:()=>!0}:null;if(t.localAction==="moved"){let c=i(t.localPlacement);return!o||!c||o===c||m(c,o)?null:{...s,kind:"move",node:o,parent:c,placement:t.localPlacement}}if(t.localAction==="reordered"){if(!o||!t.localOrder)return null;let c=y(o),l=t.localOrder.map(u=>b(u,n,u.nodeType)).filter(u=>u&&u.parentNode===c);return l.length<2?null:{...s,kind:"reorder",parent:o,order:l}}if(t.localAction==="inserted"){let c=i(t.localPlacement);if(!c||o&&o.parentNode!==y(c))return null;if(t.fragmentKind!=="element")return typeof t.localFragment!="string"?null:{...s,kind:"run",node:o,parent:c,placement:t.localPlacement,text:t.localFragment,nodeType:r.nodeType};let l=r.local.length?Ae(n.root,r.local[0]):null;if(!k(l))return null;let u=o?o.tagName===l.tagName&&o.namespaceURI===l.namespaceURI?"morph":"replace":"place";return{...s,kind:"realize",node:o,parent:c,placement:t.localPlacement,src:l,mode:u,ids:D(l)}}return null}function V(e,n,t,r){let o=y(n),s=l=>{for(let u of l){let d=b(u,r,u.nodeType);if(d&&d!==e&&d.parentNode===o)return d}return null},i=s(t.before);if(i)return o.insertBefore(e,i);let c=s(t.after);return c?o.insertBefore(e,c.nextSibling):t.before.length?o.insertBefore(e,o.firstChild):o.appendChild(e)}function $e(e){let n=document.importNode(e.src,!0),t=document.createDocumentFragment();return t.append(n),e.apply.domain==="save"&&(se(t),ce(t),ie(t),Z(t)),n}function Qe(e,n){let t=e.filter(r=>r.kind==="move");for(let r of t)n.append(r.node);for(let r of e){if(r.kind==="run"){r.node?r.node.data=r.text:r.node=V(r.nodeType===8?document.createComment(r.text):document.createTextNode(r.text),r.parent,r.placement,r.apply),r.check=()=>h(r.node)&&r.node.parentNode===y(r.parent)&&r.node.data===r.text;continue}if(r.kind!=="realize")continue;let o=$e(r);r.mode==="morph"?H.morphElement(r.node,o,{ignore:B,scripts:{execute:!1}}):r.mode==="replace"?(r.node.replaceWith(o),r.node=o):r.node=V(o,r.parent,r.placement,r.apply),r.check=()=>h(r.node)&&r.node.parentNode===y(r.parent)}for(let r of t)V(r.node,r.parent,r.placement,r.apply),r.check=()=>r.node.parentNode===y(r.parent)&&h(r.node);for(let r of e){if(r.kind!=="reorder")continue;let o=y(r.parent),s=r.order.filter(u=>u.parentNode===o),i=s.slice(),c=[...o.childNodes].map(u=>s.includes(u)?i.shift():u),l=null;for(let u=c.length-1;u>=0;u--){let d=c[u];s.includes(d)&&d.nextSibling!==l&&o.insertBefore(d,l),l=d}r.check=()=>{let u=[...o.childNodes].filter(d=>s.includes(d));return u.length===s.length&&u.every((d,N)=>d===s[N])}}for(let r of e)r.kind==="remove"&&(r.node.remove(),r.check=()=>!h(r.node))}function O(e){return e.kind==="move"||e.kind==="remove"?[e.node]:e.kind==="realize"||e.kind==="run"?e.node?[e.node]:[]:[]}function R(e){return e.kind==="text"?[e.scope]:e.kind==="move"||e.kind==="reorder"?[e.parent]:(e.kind==="realize"||e.kind==="run")&&!e.node?[e.parent]:[]}var be=e=>e.kind==="attr"?[e.el]:[...O(e),...R(e)];function Xe(e,n){try{let t=j(e.startContainer,e.startOffset),r=j(n.startContainer,n.startOffset);return e.collapsed&&n.collapsed?t.comparePoint(n.startContainer,n.startOffset)===0:t.comparePoint(n.endContainer,n.endOffset)>0&&r.comparePoint(e.endContainer,e.endOffset)>0}catch{return!1}}function Je(e,n){try{return e.comparePoint(n.startContainer,n.startOffset)===0&&e.comparePoint(n.endContainer,n.endOffset)===0}catch{return!1}}function Ze(e,n){try{return e.intersectsNode(n)&&!m(e.commonAncestorContainer,n)}catch{return!1}}function I(e,n){if(!e.ids.size&&!n.ids.size)return!1;let t=s=>{let i=new Set;for(let c of be(s))D(c,i);return i},r=e.ids.size?null:t(e),o=t(n);return[...e.ids].some(s=>n.ids.has(s)||o.has(s))||[...n.ids].some(s=>(r||t(e)).has(s))}function me(e,n){return n.kind==="text"?Ze(n.range,e.el):O(n).some(t=>m(e.el,t))||n.ids.has(x(e.el))}function pe(e,n){return n.kind==="reorder"?m(n.parent,e.scope)||I(e,n):O(n).some(t=>m(t,e.scope)||m(e.scope,t))||R(n).some(t=>m(t,e.scope))?!0:I(e,n)}function he(e,n){return O(n).some(t=>e.order.includes(t)||m(e.parent,t))||R(n).includes(e.parent)?!0:I(e,n)}function q(e,n){if(e.kind==="done"||n.kind==="done")return!1;if(e.kind==="text"&&n.kind==="text")return Xe(e.range,n.range);if(e.kind==="attr"&&n.kind==="attr")return e.el===n.el&&e.ns===n.ns&&e.local===n.local;if(e.kind==="attr")return me(e,n);if(n.kind==="attr")return me(n,e);if(e.kind==="text")return pe(e,n);if(n.kind==="text")return pe(n,e);if(e.kind==="reorder"&&n.kind==="reorder")return e.parent===n.parent||I(e,n);if(e.kind==="reorder")return he(e,n);if(n.kind==="reorder")return he(n,e);for(let t of O(e))for(let r of O(n))if(m(t,r)||m(r,t))return!0;for(let t of O(e))for(let r of R(n))if(m(r,t))return!0;for(let t of O(n))for(let r of R(e))if(m(r,t))return!0;return I(e,n)}function et(e,n){return e.kind==="done"?!1:e.kind==="attr"?m(e.el,n.node):be(e).some(t=>m(t,n.node)||m(n.node,t))?!0:e.ids.size?(n.ids||(n.ids=D(n.node)),[...e.ids].some(t=>n.ids.has(t))):!1}function tt(e,n){return e.kind==="text"&&n.kind==="text"&&!e.field&&e.root===n.root&&Je(e.range,n.range)}function nt(e,n){let t=oe(e);return t?t.nodes:[rt(e,n)]}function rt(e,n){let t=e.recovery,r=t.subject;for(let c of t.text?[t.text.liveSpan,t.text.liveScope]:[])if(c&&c.startContainer&&h(c.startContainer)&&h(c.endContainer))return st(ot(c));let o=r?b(r,n,r.nodeType):null;if(o)return o;let s=t.structure&&t.structure.localPlacement?b(t.structure.localPlacement.parent,n,1):null;if(s)return s;let i=r&&r.local.length?r.local[0]:[];for(let c=i.length-1;c>0;c--){if(i[c-1]==="content")continue;let l=$(i.slice(0,c),n);if(l)return l}return document.documentElement}function ot(e){let n=new Set;for(let r=e.startContainer;r;r=r.parentNode)n.add(r);let t=e.endContainer;for(;t&&!n.has(t);)t=t.parentNode;return t.nodeType===1||t.nodeType===11?t:t.parentNode}function st(e){for(let n=e;n;n=n.parentNode)if(k(n)&&ke.has(n.tagName))return n;return e}function ct(e,n){let t=e.recovery;return t.applied===!1||t.unavailable?null:t.structure?Ye(e,n):t.text?Ve(e,n):t.attribute?_e(e,n):null}var P=()=>`${re()}|${S.hasPendingApply()?1:0}|${S.list().map(e=>e.id).join(",")}`;function Ee(){let e={ids:new Map,nested:new Set},n=r=>{for(let o of["id","data-id"]){let s=r.getAttribute(o);s&&e.ids.set(`${o} ${s}`,(e.ids.get(`${o} ${s}`)||0)+1)}},t=(r,o)=>{for(let s of y(r).children)n(s),o&&L.has(s.tagName)&&e.nested.add(s),t(s,o||W(s)||we.has(s.tagName))};return n(document.documentElement),t(document.documentElement,!1),e}function it(e){let n=Ee();for(let[r,o]of n.ids)if(o>1&&(e.before.ids.get(r)||0)<=1)return!1;for(let r of n.nested)if(!e.before.nested.has(r))return!1;let t=new Map;for(let r of e.ops)r.kind==="text"&&t.set(r.scope,[...t.get(r.scope)||[],r]);for(let[r,o]of t){let s=o[0].before;for(let c of[...o].sort((l,u)=>u.bs-l.bs))s=s.slice(0,c.bs)+c.local+s.slice(c.be);if((o[0].owner?r.data:o[0].field?r.value:_(r).text)!==s)return!1}return!0}function lt(){let e=new Map,n=c=>{for(let l of c.querySelectorAll("*"))e.set(l,[...l.attributes].map(u=>[u,u.value])),l.localName==="template"&&l.content&&n(l.content)};n(document);let t=[];for(let c of document.querySelectorAll("input, textarea"))t.push([c,"value",c.value]);for(let c of document.querySelectorAll("input"))t.push([c,"checked",c.checked]);for(let c of document.querySelectorAll("option"))t.push([c,"selected",c.selected]);let r=document.activeElement,o=null;try{r&&typeof r.selectionStart=="number"&&(o=[r.selectionStart,r.selectionEnd,r.selectionDirection])}catch{}let s=document.getSelection(),i=s&&s.rangeCount?[s.anchorNode,s.anchorOffset,s.focusNode,s.focusOffset]:null;return{attrs:e,controls:t,active:r,caret:o,selection:i}}function at(e,n){let t=e.attributes;return t.length===n.length&&n.every(([r,o],s)=>t[s]===r&&r.value===o)}function ut(e,n){let t=new Set;for(let s=e.length-1;s>=0;s--){let i=e[s];if(i.type==="characterData")i.target.data=i.oldValue;else if(i.type==="attributes")t.add(i.target);else{for(let c of i.addedNodes)c.parentNode===i.target&&i.target.removeChild(c);for(let c of i.removedNodes)i.target.insertBefore(c,i.nextSibling)}}for(let s of t){let i=n.attrs.get(s);if(!(!i||at(s,i))){for(let c of[...s.attributes])s.removeAttributeNode(c);for(let[c,l]of i)c.value=l,s.setAttributeNode(c)}}for(let[s,i,c]of n.controls)if(s[i]!==c)try{s[i]=c}catch{}let r=document.getSelection();r&&n.selection?h(n.selection[0])&&h(n.selection[2])&&r.setBaseAndExtent(...n.selection):r&&r.rangeCount&&r.removeAllRanges();let o=n.active;if(o&&o!==document.activeElement&&o!==document.body&&h(o)&&o.focus&&o.focus({preventScroll:!0}),n.caret&&document.activeElement===o)try{o.setSelectionRange(...n.caret)}catch{}}function ft(e){let n=t=>{e.observe(t,ve);for(let r of t.querySelectorAll("template"))r.content&&n(r.content)};n(document)}function dt(e){let n=new Set;for(let t of e)if(t.type==="characterData"){if(n.has(t.target))return!1;n.add(t.target)}return!0}function mt(e){let n=P(),t=new Map,r=new Map,o=[],s=new Set;for(let a of e){if(s.has(a))continue;s.add(a);let f=S.get(a);f&&(f.claimedBy||f.kind==="apply-incomplete"||f.kind==="json"||!f.recovery?t.set(a,T):o.push(f))}if(S.hasPendingApply()){for(let a of o)t.set(a.id,T);return{ops:[],covered:r,blocked:t,revision:n,before:null}}let i=[],c=a=>{let f=S.recoveryOf(a.id),p=f?ct(a,f):null;if(!p&&f)for(let E of nt(a,f))i.push({ticket:f.ticket,node:E});return p},l=[];for(let a of o){let f=c(a);f?l.push(f):t.set(a.id,T)}let u=[];for(let a of S.list())if(!s.has(a.id)){if(a.kind==="apply-incomplete")i.push({ticket:a.ticket,node:document.documentElement});else if(a.recovery){let f=c(a);f&&u.push(f)}}l.sort((a,f)=>f.ticket-a.ticket);let d=[],N=[],v=a=>{t.set(a.id,T),N.push(a)};for(let a of l){if(i.some(p=>p.ticket>a.ticket&&et(a,p))||u.some(p=>p.ticket>a.ticket&&q(p,a))||N.some(p=>q(p,a))){v(a);continue}let f=d.find(p=>q(p,a));if(!f){d.push(a);continue}if(tt(f,a)){r.set(a.id,f.id);continue}v(a),f.ticket===a.ticket&&(d.splice(d.indexOf(f),1),v(f))}let A=ne(i.filter(a=>d.some(f=>a.ticket>f.ticket)).map(a=>a.node));return{ops:d,covered:r,blocked:t,revision:P(),protectedWitnesses:A,before:Ee()}}function pt(e){if(e.revision!==P()||!F(e.protectedWitnesses||[])){for(let c of e.ops)e.blocked.set(c.id,T);for(let c of e.covered.keys())e.blocked.set(c,T);return[]}let n=lt(),t=window.clay?.undo;t?.pause?.();let r=new MutationObserver(()=>{}),o=document.createDocumentFragment(),s=[],i=!1;try{ft(r),r.observe(o,ve);let c=e.ops.filter(l=>l.kind==="text").sort((l,u)=>l.root===u.root?u.s-l.s||u.e-l.e:0);for(let l of c)qe(l);for(let l of e.ops)l.kind==="attr"&&ze(l);Qe(e.ops.filter(l=>l.kind!=="text"&&l.kind!=="attr"),o),s=r.takeRecords(),i=e.ops.every(l=>l.check())&&it(e)&&e.revision===P()&&F(e.protectedWitnesses||[])}catch(c){console.error("[clay] Revert to mine failed while writing and was undone",c)}finally{s=s.concat(r.takeRecords()),r.disconnect()}if(i)return dt(s)&&!e.ops.some(c=>c.wroteProperty)?t?.commitCaptured?.("Revert to mine"):t?.discardCaptured?.(),t?.resume?.(),[...e.ops.map(c=>c.id),...e.covered.keys()];try{ut(s,n)}finally{J.dropQueued(),t?.discardCaptured?.(),t?.resume?.()}for(let c of e.ops)e.blocked.set(c.id,T);for(let c of e.covered.keys())e.blocked.set(c,T);return[]}async function wt(e){await Promise.resolve();let n=mt(e),t=pt(n);Q();let r=null;return t.length&&(ee(),S.acknowledge(t,{reason:"reverted"}),X(),await Promise.resolve(),r=await te()),{revertedIds:t,blockedIds:[...n.blocked.keys()],saveResult:r}}export{T as BLOCKED,pt as applyRevert,mt as prepareRevert,wt as revertConflicts};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o={table:{types:["table"],views:["table","table_cell"],module:"page/features/table.js",load:()=>import("./c-LQU7TXIH.js")},board:{types:["board"],module:"page/features/board.js",load:()=>import("./c-7SXYQCN4.js")},chart:{types:["chart"],views:["chart"],module:"page/features/chart.js",load:()=>import("./c-VY6XRBOW.js")},checklist:{types:[],views:[],match:e=>e.type.name==="list_item"&&e.attrs.kind==="check",module:"page/features/checklist.js",load:()=>import("./c-SBSMJIPC.js")},code:{types:["code_block"],module:"page/features/code.js",load:()=>import("./c-OABVRYOT.js")},toc:{types:["toc"],module:"page/features/toc.js",load:()=>import("./c-M4FSPNQ2.js")},titleIcon:{types:[],views:["heading"],match:e=>e.attrs.pageIcon!=null||e.attrs.pageCoverSrc!=null,module:"page/features/title-icon.js",load:()=>import("./c-NFR673TL.js")},media:{types:["image","file"],module:"page/features/media.js",load:()=>import("./c-2VB555FG.js")},tool:{types:["tool"],module:"page/features/tool.js",boot:["page/tools.js","page/tool-data.js"],load:()=>import("./c-GKEATME6.js")}},r=e=>Object.keys(o).find(t=>o[t].types.includes(e))??null,s=e=>{for(let t of Object.keys(o)){let a=o[t];if(a.match?a.match(e):a.types.includes(e.type.name))return t}return null},l={mentions:{module:"page/features/mentions.js",load:()=>import("./c-XD5MOROJ.js")},dates:{module:"page/features/dates.js",load:()=>import("./c-3GJ4XARY.js")},emoji:{module:"page/features/emoji.js",load:()=>import("./c-EOCZ2YVL.js")},titleIcon:{module:"page/features/title-icon.js",load:()=>import("./c-NFR673TL.js")},titleCover:{module:"page/features/title-cover.js",load:()=>import("./c-GPGYKER7.js")},exportHtml:{module:"page/features/export-html.js",load:()=>import("./c-ZQXNHZZT.js")},importMarkdown:{module:"page/features/import-markdown.js",load:()=>import("./c-W3K23S72.js")},exportMarkdown:{module:"page/features/export-markdown.js",load:()=>import("./c-VQCEOGKH.js")}};export{o as a,r as b,s as c,l as d};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as v,B as P,C as x,D as T,E as A,F as k,G as E,H as z,I as C,J as O,K as tt,L as et,M as nt,N as B,O as D,R as it,S as K,c as M,d as L,e as f,n as J,s as $,w as g,x as Q,z as Z}from"./c-
|
|
1
|
+
import{A as v,B as P,C as x,D as T,E as A,F as k,G as E,H as z,I as C,J as O,K as tt,L as et,M as nt,N as B,O as D,R as it,S as K,c as M,d as L,e as f,n as J,s as $,w as g,x as Q,z as Z}from"./c-SJPD46ZO.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-XQSXKIKM.js";import"./c-67ILSNPR.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as Y,d as N}from"./c-44B5ODN7.js";import{I as X,W as G,m as V}from"./c-QIXT3Q7C.js";import"./c-E4IBSAQM.js";import"./c-57XDY6HC.js";import{a as j}from"./c-I2SCCUEW.js";import"./c-VHNSBD2M.js";var ot=`
|
|
2
2
|
.page-editor .page-table { position: relative; }
|
|
3
3
|
.page-table td { position: relative; }
|
|
4
4
|
.page-table th { position: relative; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as k}from"./c-N326R2JD.js";import{a as w}from"./c-I2SCCUEW.js";import{f as v}from"./c-3O7OBDCM.js";var j=new Set(["accepted","reverted","reconciled"]),T=Math.random().toString(36).slice(2,8),z=0,l=new Map,f=new Map,p=new Set,h=new Set,x=null,O=20,y=null,b=null,u=[];function E(){b??=import("./c-
|
|
1
|
+
import{e as k}from"./c-N326R2JD.js";import{a as w}from"./c-I2SCCUEW.js";import{f as v}from"./c-3O7OBDCM.js";var j=new Set(["accepted","reverted","reconciled"]),T=Math.random().toString(36).slice(2,8),z=0,l=new Map,f=new Map,p=new Set,h=new Set,x=null,O=20,y=null,b=null,u=[];function E(){b??=import("./c-EDSPKYMA.js").then(e=>{for(y=e;u.length;)y.keep(u.shift())},e=>{b=null,console.error("clayjs: the conflict recovery module could not be downloaded; conflicts stay in this tab only",e)})}v&&E();function S(e=""){return`${T}:${e}${++z}`}function m(){return x||=w({id:"live-sync-conflicts",isPending:()=>l.size>0||p.size>0}),x}function g(e){m().changed(),document.dispatchEvent(new CustomEvent("clay:sync-conflicts-changed",{detail:{open:[...l.keys()],added:[],removedIds:[],updatedIds:[],...e}}))}function $(e){let t=e.recovery;return t?t.applied===!1&&t.unavailable==="hook-veto"?!1:t.localLost!==!1:!0}var C=["kind","id","label","field"];function I(e){if(!e||typeof e!="object")return null;let t={};for(let n of C){let o=e[n];typeof o=="string"&&o?t[n]=o:typeof o=="number"&&Number.isFinite(o)&&(t[n]=String(o))}return Object.keys(t).length?t:null}function F(e){let t=I(e);return t?(typeof e.open=="function"&&(t.open=e.open),t):null}function A(e,t){for(let n of[...h].reverse()){let o;try{o=n(e,t)}catch(r){console.error("clayjs: a conflict context resolver threw; the conflict stays generic",r);continue}let c=F(o);if(c)return c}return null}function L(e){if(typeof e!="function")throw new TypeError("clay.conflicts.registerContext needs a resolver function");return h.add(e),()=>h.delete(e)}function B(e,t){let n=S(),o=Object.assign(t[0],{id:n,applyId:e.id,source:e.source,ticket:e.ticket,rawReports:t,claimedBy:null});return o.context=A(o,e),l.set(n,o),e.ids.add(n),n}function D({source:e,seq:t=null,etag:n=null,domain:o,root:c,recoveryRoot:r=null}){let i=S("a");return f.set(i,{id:i,source:e,seq:t,etag:n,ticket:0,domain:o,root:c,recoveryRoot:r,ids:new Set}),p.add(i),m().changed(),i}function N(e){if(!e.every(n=>n.kind==="structure"&&n.detail==="insert-collision"&&n.recovery?.applied===!0&&!n.recovery.unavailable&&n.recovery.structure?.localAction==="inserted"&&n.recovery.structure.fragmentKind==="element"))return null;let t=e[0].recovery.subject;return t?.local?.length!==1||t.merged?.length!==1||t.live?.length!==1?null:{local:t.local[0],merged:t.merged[0],live:t.live[0]}}function P(e){let t=new Map(e.map(r=>[r,N(r)])),n=(r,i)=>r.length<i.length&&r.every((s,d)=>s===i[d]),o=(r,i)=>i.reduce((s,d)=>d==="content"?s?.content:s?.childNodes[d],r),c=new Map;for(let r of e){let i=t.get(r),s=r;if(i)for(let d of e){let a=t.get(d);a&&a.local.length<t.get(s).local.length&&n(a.local,i.local)&&n(a.merged,i.merged)&&(a.live.contains(i.live)||o(a.live,i.merged.slice(a.merged.length))===i.live)&&(s=d)}c.has(s)||c.set(s,[...s]),r!==s&&c.get(s).push(...r)}return[...c.values()]}function M(e,t){let n=t.map(c=>l.get(c)).filter(Boolean);if(!n.length)return;let o={apply:e,records:n.map(c=>({rec:c,context:I(c.context)}))};if(y)return y.keep(o);u.push(o),u.length>O&&u.shift(),E()}function Q(e,t,{ticket:n}){let o=f.get(e);if(!o)return[];o.ticket=n;let c=new Map;for(let i of t){if(!$(i))continue;let s=i.recovery?.key??Symbol();c.has(s)||c.set(s,[]),c.get(s).push(i)}let r=P([...c.values()]).map(i=>B(o,i));return r.length&&M(o,r),p.delete(e),r.length||f.delete(e),r.length?g({added:r.map(i=>l.get(i))}):m().changed(),r}function X(e,t,{ticket:n=0}={}){let o=f.get(e);if(!o)return[];o.ticket=n,p.delete(e);let c=B(o,[{kind:"apply-incomplete",detail:null,error:String(t)}]);return l.get(c).rawReports=[],M(o,[c]),g({added:[l.get(c)]}),[c]}var q={get size(){return l.size},list(){return[...l.values()]},get(e){return l.get(e)||null},acknowledge(e,{reason:t}={}){if(!Array.isArray(e))throw new TypeError("clay.conflicts.acknowledge needs an array of ids");if(!j.has(t))throw new TypeError(`clay.conflicts.acknowledge: unknown reason "${t}"`);let n=[];for(let o of e){let c=l.get(o);if(!c)continue;k(c),l.delete(o),n.push(o);let r=f.get(c.applyId);r&&(r.ids.delete(o),r.ids.size||f.delete(c.applyId))}return n.length&&(g({removedIds:n,reason:t}),import("./c-EDSPKYMA.js").then(o=>o.dismiss(n),()=>{})),{removedIds:n,remainingIds:[...l.keys()]}},claim(e,{owner:t}){if(!t)throw new TypeError("clay.conflicts.claim needs an owner");for(let c of e){let r=l.get(c);if(r&&r.claimedBy&&r.claimedBy!==t)throw new Error(`conflict ${c} is already claimed by ${r.claimedBy}`)}let n=[];for(let c of e){let r=l.get(c);r&&!r.claimedBy&&(r.claimedBy=t,n.push(c))}n.length&&g({updatedIds:n,reason:"claimed"});let o=!1;return{release(){if(o)return;o=!0;let c=n.filter(r=>l.get(r)?.claimedBy===t);for(let r of c)l.get(r).claimedBy=null;c.length&&g({updatedIds:c,reason:"released"})}}},registerContext:L,contextFor:A,recoveryOf(e){let t=l.get(e);return t&&f.get(t.applyId)||null},hasPendingApply(){return p.size>0}};export{E as a,L as b,D as c,Q as d,X as e,q as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d}from"./c-KQ7E3PYY.js";import{d as h,h as p,v as g}from"./c-
|
|
1
|
+
import{a as d}from"./c-KQ7E3PYY.js";import{d as h,h as p,v as g}from"./c-44B5ODN7.js";import{N as u,b as l,ea as c,m,na as f}from"./c-QIXT3Q7C.js";import"./c-VHNSBD2M.js";var{TextSelection:b}=l;function T(r,t){let e=p(r.state.doc),n=e.findIndex(o=>o.node.attrs.id===t);if(n<0)return h(r,"That link's block is gone"),null;let s=[];for(let o=e[n].up;o>=0;o=e[o].up)e[o].node.type===m.nodes.toggle&&!e[o].open&&s.push(e[o].node.attrs.id);let i=r.state.tr.setSelection(b.create(r.state.doc,e[n].at+1)).setMeta("addToHistory",!1);return r.dispatch(g(i,s).scrollIntoView()),e[n]}var a=class{constructor(t,e){this.node=t,this.view=e,this.doc=e.state.doc;let n=e.dom.ownerDocument;this.dom=n.createElement("div"),this.dom.className="page-toc",this.dom.contentEditable="false",this.dom.setAttribute("role","group"),this.dom.setAttribute("aria-label","Table of contents"),this.dom.addEventListener("mousedown",s=>{s.target.closest?.("a")&&s.preventDefault()}),this.dom.addEventListener("click",s=>{let i=s.target.closest?.("a");if(!i)return;s.preventDefault();let o=d(i.getAttribute("href"));o!==null&&T(this.view,o)}),this.render()}update(t){return this.node=t,this.view.state.doc!==this.doc&&(this.doc=this.view.state.doc,this.render()),!0}render(){let t=c(this.node.attrs,f(u(this.doc)));this.dom.innerHTML!==t&&(this.dom.innerHTML=t)}stopEvent(t){return!!t.target.closest?.("a")}ignoreMutation(){return!0}};function I(){return{id:"toc",nodeViews:{toc:(r,t)=>new a(r,t)},css:null,dispose(){}}}export{a as TocView,I as createFeature,T as followTocLink};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d}from"./c-
|
|
1
|
+
import{a,b,c,d}from"./c-VSPAFOKU.js";import"./c-EGTIAL6P.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{b as serializeCloneSteps,c as serializeForCompareSteps,d as serializeForSyncSteps,a as serializeTreeSteps};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c}from"./c-RG6XUZFA.js";import"./c-QY7F6EN6.js";import"./c-BJ7YQ5QZ.js";import"./c-4JZDZFF6.js";import"./c-VAK7SG37.js";import"./c-MHI3GYKF.js";import"./c-NUHP2XDB.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{c as default,b as dismissPersistent,a as toastPersistent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as A,b as m,c as n}from"./c-
|
|
1
|
+
import{a as A,b as m,c as n}from"./c-TWCXBWS3.js";import{a as c}from"./c-VKEDWYDF.js";import{f as i}from"./c-3O7OBDCM.js";import{b as l,q as d}from"./c-EGTIAL6P.js";var f="[editmode\\:onclick]";function b(){d(o=>{o.querySelectorAll(f).forEach(t=>{let e=t.getAttribute("onclick");e!==null&&(t.setAttribute("inert-onclick",e),t.removeAttribute("onclick"),n(t,l(t)??t))})})}function p(){i&&c(()=>{E()})}function E(o=document){o.querySelectorAll(f).forEach(t=>{let e=t.getAttribute("inert-onclick");e&&(t.setAttribute("onclick",e),t.removeAttribute("inert-onclick"))})}function D(){document.querySelectorAll(f).forEach(o=>{let t=o.getAttribute("onclick");t&&(o.setAttribute("inert-onclick",t),o.removeAttribute("onclick")),n(o)})}function q(){b(),p()}var O="[viewmode\\:disabled]",S="[viewmode\\:readonly]",u=[[O,"disabled"],[S,"readonly"]];function k(){d(o=>{for(let[t,e]of u)o.querySelectorAll(t).forEach(r=>{if(r.hasAttribute(e))return;let a=l(r),s=a?m(a,e):null;r.setAttribute(e,s===null?"":s),n(r,a??r)})})}function h(){i&&c(()=>{x()})}function x(o=document){for(let[t,e]of u)o.querySelectorAll(t).forEach(r=>{A(r),r.removeAttribute(e)})}function M(){for(let[o,t]of u)document.querySelectorAll(o).forEach(e=>{let r=m(e,t);r===null?e.removeAttribute(t):e.setAttribute(t,r),n(e)})}function P(){k(),h()}export{f as a,E as b,D as c,q as d,O as e,S as f,x as g,M as h,P as i};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{c as E}from"./c-KBS3UV6B.js";import{i as x,j as I}from"./c-
|
|
1
|
+
import{c as E}from"./c-KBS3UV6B.js";import{i as x,j as I}from"./c-SJPD46ZO.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-XQSXKIKM.js";import"./c-67ILSNPR.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as C}from"./c-44B5ODN7.js";import{G as b,J as A,m as f}from"./c-QIXT3Q7C.js";import"./c-E4IBSAQM.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var D=`
|
|
2
2
|
[data-page-heading]{display:block}
|
|
3
3
|
[data-page-heading]>span[data-page-icon]{display:inline-block;font-size:34px;line-height:1;margin-block-end:.2em}
|
|
4
4
|
[data-page-heading]>img[data-page-cover]{display:block;width:100%;height:180px;object-fit:cover;border-radius:var(--page-image-radius, 6px);margin-block-end:.6em}
|
|
5
5
|
[data-page-heading]>h1{font-family:var(--page-font-display);font-size:var(--page-h1-size);font-weight:var(--page-h1-weight);letter-spacing:var(--page-h1-tracking);line-height:var(--page-h1-line);color:var(--page-ink-strong);margin-block:0 .6em}
|
|
6
|
-
`,v=null,P=()=>v??=import("./c-
|
|
6
|
+
`,v=null,P=()=>v??=import("./c-EOCZ2YVL.js").catch(r=>{throw v=null,r});function z(r){let t=typeof r=="string"?r:"";return!t.trim()||typeof Intl>"u"||typeof Intl.Segmenter!="function"||[...new Intl.Segmenter("en",{granularity:"grapheme"}).segment(t)].length!==1?!1:[...t].length<=32&&new TextEncoder().encode(t).length<=128}function S(r){let t=0;for(let i=0;i<r.childCount;i++){let a=r.child(i);if(a.type===f.nodes.heading&&a.attrs.level===1&&a.attrs.parent==null)return{index:i,at:t,node:a};t+=a.nodeSize}return null}function L(r,t){let i=r.createElement("img");return i.setAttribute("data-page-cover",""),i.setAttribute("src",t.pageCoverSrc),i.setAttribute("alt",t.pageCoverAlt??""),i.setAttribute("style",`object-position:${t.pageCoverX}% ${t.pageCoverY}%`),i}var g=class{constructor(t,i){this.node=t,this.decorated=!!(t.attrs.pageIcon||t.attrs.pageCoverSrc);let a=i.dom.ownerDocument,p=a.createElement(`h${t.attrs.level}`);if(p.setAttribute("data-id",t.attrs.id),this.dom=this.contentDOM=p,!this.decorated)return;let l=a.createElement("header");if(l.setAttribute("data-id",t.attrs.id),l.setAttribute("data-page-heading","1"),p.removeAttribute("data-id"),t.attrs.pageCoverSrc&&l.append(L(a,t.attrs)),t.attrs.pageIcon){let c=a.createElement("span");c.setAttribute("data-page-icon",""),c.setAttribute("aria-hidden","true"),c.textContent=t.attrs.pageIcon,l.append(c)}l.append(p),this.dom=l}update(t){return this.decorated!==!!(t.attrs.pageIcon||t.attrs.pageCoverSrc)||!t.sameMarkup(this.node)?!1:(this.node=t,!0)}ignoreMutation(t){return!this.contentDOM.contains(t.target)}};function W({view:r=null}={}){if(!r)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let t=r.dom.ownerDocument,i=null,a=null;function p(){try{let n=r.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},e=r.coordsAtPos(r.state.selection.from);return{x:Math.max(8,e.left-n.left),y:e.bottom+6-n.top}}catch{return null}}function l(n){let e=n.picker.activeId();e?r.dom.setAttribute("aria-activedescendant",e):r.dom.getAttribute("aria-activedescendant")?.startsWith(n.picker.el.id)&&r.dom.removeAttribute("aria-activedescendant")}function c(){let n=a;if(n){a=null;for(let[e,o,u,d]of n.listen)e.removeEventListener(o,u,d);r.dom.getAttribute("aria-activedescendant")?.startsWith(`${n.picker.el.id}-`)&&r.dom.removeAttribute("aria-activedescendant"),n.picker.destroy()}}function j(n,e){let o=S(r.state.doc);if((o?o.node.attrs.id:null)!==n.owner)return{ok:!1,code:"stale-target"};let d=r.state.tr;if(o)d.setNodeMarkup(o.at,null,{...o.node.attrs,pageIcon:e});else{let s=r.state.doc.maybeChild(0);d.insert(0,f.nodes.heading.create({id:A(),pos:b(null,s?.attrs.pos??null),parent:null,level:1,pageIcon:e}))}return r.dispatch(C(d)),{ok:!0,icon:e}}async function m(n){let e=a;if(!e)return{ok:!1,code:"not-editing"};let o=e.picker.personAt(n);return c(),o?z(o.char)?x(r,()=>j(e,o.char)):{ok:!1,code:"invalid-icon"}:{ok:!1,code:"no-emoji"}}function w(n){let e=a;if(!e||I(n,r))return;let o=()=>{n.preventDefault(),n.stopPropagation()};n.key==="ArrowDown"||n.key==="ArrowUp"?(o(),e.picker.move(n.key==="ArrowDown"?1:-1),l(e)):n.key==="Enter"?(o(),m(e.picker.index())):(n.key==="Escape"||n.key==="Tab")&&(o(),c())}async function M(n){c();let e={owner:S(r.state.doc)?.node.attrs.id??null,picker:null,listen:[]};e.picker=E({document:t,label:"Choose a page icon",empty:"No emoji found",onPick:s=>m(s)}),a=e;let o=(s,h,k,y)=>{s.addEventListener(h,k,y),e.listen.push([s,h,k,y])};o(t,"keydown",s=>w(s),!0),o(r.dom,"input",()=>c()),o(t,"mousedown",s=>{e.picker.el.contains(s.target)||c()},!0),(r.dom.parentElement??t.body).appendChild(e.picker.el);let u,d;try{let s=await P();d=s.filterEmoji,i??=s.emojiLibrary(),u=await i()}catch(s){return c(),{ok:!1,code:"unavailable",error:s}}return a!==e?{ok:!1,code:"not-editing"}:(e.picker.show(d(u,n?.query),p()),l(e),{ok:!0,picker:!0})}return{nodeViews:{heading:(n,e)=>new g(n,e)},css:D,async run(n){return M(n)},dispose(){c()}}}export{W as createFeature,z as isIconGlyph,S as titleOf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Gt}from"./c-4ASQPRQL.js";import{a as Dt}from"./c-GQ6F6IDK.js";import{c as F}from"./c-I2SCCUEW.js";import{b as He}from"./c-5VYOWDTI.js";import{a as Wt,d as ne,e as Be,f as b,h as N}from"./c-FWKHM4E7.js";import{a as Ge,b as Qt,c as Vt,d as $t}from"./c-X5LNHET5.js";import{a as Kt}from"./c-UGHH4MB3.js";import{a as Pt}from"./c-ZWIOJGMT.js";import{a as Ot,e as Rt,f as P,g as bt,h as Nt,i as Ft,l as Ut,t as qt,v as Bt,w as Ht}from"./c-B7J4K2AE.js";import{b as It,h as qe}from"./c-EK63G3CG.js";import{a as Fe,c as kt,g as Lt,h as Ue}from"./c-NQJRVJ56.js";import{a as Oe,f as Ie,h as Q}from"./c-IJUK2GPW.js";import{b as K,e as Ct,f as w}from"./c-3O7OBDCM.js";import{i as At,k as Tt}from"./c-N7JPUPGC.js";import{D as Ne,h as Re,q as be,t as _t,x as V,y as me}from"./c-7MG5RU63.js";import{d as xt}from"./c-VG5XIN4T.js";import{a as pe}from"./c-2YYDMLNZ.js";import{d as St,e as yt,g as Et,h as wt}from"./c-HA6INT6J.js";import{k as Mt}from"./c-DCFSEJZG.js";var hn="clay:debug:autosave";function ve(){try{return localStorage.getItem(hn)==="true"}catch{return!1}}function ge(){return import("./c-CFHW5AMY.js").catch(e=>(console.warn("[autosave-debug] Failed to load the debug logger:",e),null))}function he(e,t){ve()&&ge().then(n=>n?.logSaveCheck(e,t))}function re(e,t=""){ve()&&ge().then(n=>n?.logBaseline(e,t))}function Yt(e,t){ve()&&ge().then(n=>n?.logUnloadDiffSync(e,t))}function zt(){ve()&&ge().then(e=>e?.preloadIfEnabled())}var U=Number.NEGATIVE_INFINITY;function Sn({firstDirtyAt:e=U,lastActivityAt:t=U,finishedAt:n=U,costMs:o=0}={}){let r=e??U,i=t??U,a=n??U,f=Math.min(3e4,Math.max(1200,4*o)),u=Math.max(i,a)+1500,m=Math.max(r+1e4,a+f);return Math.max(a+1200,Math.min(u,m))}function Xt({now:e=()=>Date.now(),setTimer:t=(r,i)=>setTimeout(r,i),clearTimer:n=r=>clearTimeout(r),run:o=()=>{}}={}){let r=null,i=null,a=U,f=0,u=null,m=null,c=!1,p=!1;function S(){return Sn({firstDirtyAt:r,lastActivityAt:i,finishedAt:a,costMs:f})}function y(){if(!c||p)return;let E=S();if(u!==null){if(m===E)return;n(u)}m=E,u=t(d,Math.max(0,E-e()))}function d(){if(u=null,m=null,!(!c||p)){if(e()<S()){y();return}g()}}function g(){c=!1,p=!0,r=null,i=null;let E;try{E=o()}catch{l();return}Promise.resolve(E).then(l,l)}function l(){p=!1,a=e(),c&&y()}function s({at:E=e()}={}){r===null&&(r=E),i=E,c=!0,y()}function v(){c=!0,y()}function M(E){E>0&&(f=Math.max(E,f*.8))}return{noteActivity:s,request:v,noteCost:M,dueAt:S,costEstimate:()=>f,pending:()=>c||p,running:()=>p}}be(e=>{for(let t of wt)e.removeAttribute(t)});be(e=>{for(let t of[...St,...yt,...Et])e.removeAttribute(t)});var x=null;function A(e,t="",n="",o=null){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus",e);let r=new CustomEvent(`clay:save-${e}`,{detail:{msg:t,msgType:n,timestamp:Date.now(),...o||{}}});document.dispatchEvent(r)}function nt(){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus","offline")}function yn(){x=setTimeout(()=>{A("saving")},500)}window.addEventListener("offline",()=>{nt()});window.addEventListener("online",()=>{document.documentElement.getAttribute("savestatus")==="offline"&&I().then(e=>{e.msgType==="skipped"&&document.documentElement.getAttribute("savestatus")==="offline"&&document.documentElement.setAttribute("savestatus","saved")})});var q=!1,L="",C="",ie=0,Ee=new Set,D=!1,k=!1,we=!1,B=0,$e=!1;function En(){B++}function rn(){B!==0&&(B--,!(B>0)&&(fe&&(fe=!1,J=setTimeout(dt,0)),$e&&($e=!1,ke())))}function wn(){return B>0}var $=0,te=!1,ae=!1,Ae=!1;function de(e=null){return $===0||an(e)}function rt(){return te}function An(){if(te)return!0;try{let e=V({flushUndo:!1});return gt(e)?!1:e!==C}catch{return!0}}function Tn(){let e="idle",t=0;return{get phase(){return e},get open(){return e==="open"},changedWhileClosed(){return e==="quiesced"&&Be()!==t},start(){e==="idle"&&(e="open")},quiesce(){e==="open"&&(e="quiesced",t=Be(),$++)},resume(){e==="quiesced"&&(e="open",$--,!($>0)&&(Wn(),tn()))},stop(){if(e==="stopped")return;let n=e==="quiesced";(n||e==="open")&&An()&&(Ae=!0),e="stopped",n&&($--,$===0&&tn())}}}var jt=!1,oe=null,Ye=null,ze=!1;function Ir(e=R){if(!oe||oe.generation!==e)return null;let{bytes:t,etag:n}=oe;return{bytes:t,etag:n}}function Rr({represented:e}={}){let t=b(),{forComparison:n,forDirty:o}=me(),r=typeof e?.etag=="string"&&e.etag?e.etag:null;return!(ze&&r!==null&&r!==Ye)&&Ae&&(n!==L||o!==C)?{ok:!1,code:"pending-input"}:(Ae=!1,ue(n,o),W=n,Z=!1,pt=!0,Ye=r,ze=!0,N(t),document.documentElement.setAttribute("savestatus","saved"),document.dispatchEvent(new CustomEvent("clay:baseline-settled")),{ok:!0})}var ot=Promise.resolve(!1),Te=!1,Cn=()=>(Te=!0,Lt().catch(()=>!1).then(e=>(Te=!1,e)));function br(){return{id:"clay:save",order:10,prepare(e={}){let t=Tn();return e.initial===!0&&t.start(),{enable(){ot=Cn();let n=e.represented?.etag;typeof n=="string"&&n&&kt(n),e.initial!==!0&&(Mn(),t.start())},quiesce:()=>t.quiesce(),resume:()=>t.resume(),dispose:()=>t.stop()}}}}function Mn(){jt||(jt=!0,Wt(),Oe(),vn(),gn())}var O=0,Xe=!1,Ce=!1,st="Waiting for the AI edit to be kept or reverted",Y=new Map;function Nr(e=st){O++,Y.set(e,(Y.get(e)||0)+1)}function Fr({replay:e=!0,reason:t=st}={}){let n=Y.get(t)||0;if(n===0||(n===1?Y.delete(t):Y.set(t,n-1),O--,O>0))return;let o=Xe,r=Ce;Xe=!1,Ce=!1,e&&(o?I():r&&ke())}function Ur(){return O>0}function it(){return O===0?null:Y.keys().next().value||st}function on(e,t){if(O===0)return!1;Xe=!0,Q();let n=h(it());return e(n),t(n),n}var H=!1,se=null;function xn(e){se=e??null,!H&&(H=!0,En())}function Pn(){H&&(H=!1,se=null,rn())}function je(){return H}function qr(e){if(!H||se&&e!==se)return;H=!1,se=null,!He()&&ne()||(document.documentElement.getAttribute("savestatus")==="conflict"&&document.documentElement.setAttribute("savestatus","saved"),document.dispatchEvent(new CustomEvent("clay:save-conflict-resolved",{detail:{timestamp:Date.now()}}))),document.dispatchEvent(new CustomEvent("clay:save-conflict-released",{detail:{etag:e??null}})),rn()}function h(e){return{ok:!1,msg:e,msgType:"skipped",code:null,etag:null}}function at(e){return(ne()||F())&&(te=!0),h(e)}function sn(){return{ok:!1,msg:"You are not allowed to save this document.",msgType:"forbidden",code:"forbidden",status:403,sent:!1,etag:null}}function ut(){return Ct()===!1}var lt=new Set,R=0;function Br(){return R}function Hr(e){typeof e=="number"&&(R=e)}function _n(e=R){let t=Object.freeze({generation:e});return lt.add(t),t}function Dn(e){lt.delete(e)}function an(e){return!!e&<.has(e)&&e.generation===R}function z(e,t){e!=null&&$t({captureId:e,ok:t.ok===!0,etag:t.etag??null})}function kn(e,t,n,o,r,i=null,a=null,f=!1){if(z(a,e),e.ok)te=!1,ue(t,n),Me=i,oe={bytes:i,etag:Fe(),generation:R},Ye=oe.etag,ze=!0,Ae=!1,q=!1,N(r),A("saved",e.msg||"Saved",e.msgType,{etag:e.etag??null,captureId:a}),re(o,`${L.length} chars`),Pn();else if(e.msgType==="conflict"){if(f){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus","saved");return}xn(e.conflictEtag),A("conflict",e.msg,e.msgType,{hadTimeout:e.hadTimeout===!0,changedBy:e.changedBy??null,afterTimeout:e.afterTimeout===!0,etag:e.conflictEtag??null,code:e.code??null,reason:e.reason??null,retryAfter:e.retryAfter??null,captureId:a})}else if(e.msgType!=="skipped"){let u={status:e.status??null,hadTimeout:e.hadTimeout===!0,code:e.code??null,reason:e.reason??null,retryAfter:e.retryAfter??null,captureId:a};navigator.onLine?A("error",e.msg,"",u):A("offline",e.msg,"",u)}}function un(){if(!(!D&&!k)&&!Ut()){if(D){D=!1,k=!1,I();return}k=!1,et.request()}}function Gr(){return q}function Wr(e){q=e}function Kr(){return L}function ft(){return C}var Me=null;function Qr(){return Me}function ue(e,t){L=e,C=t,ie++}function Vr(e){ue(e,e)}var G=()=>typeof performance<"u"&&performance.now?performance.now():Date.now();var Ln=4,Jt="Save cancelled: the page changed while it prepared",X=null,le=null,We=null,ln=!1;function fn(){return We||(We=import("./c-KGHVFRR3.js").then(e=>(le=e,e),e=>(ln=!0,console.info("clayjs: sliced save off ("+(e&&e.message?e.message:e)+"); saves prepare in one task"),null))),We}function On(){try{return performance.getEntriesByType("navigation")[0]?.decodedBodySize||0}catch{return 0}}var In=()=>typeof Me=="string"?Me.length:On();function xe(){return ln||document.hidden||Ft()?!1:In()>=307200}function Zt(e,t,n){return n?"morph":R!==t.generation||!w?"mode":de(e.permit)?ut()?"refused":ie!==t.baselines?"newer save":Math.max(qe(),e.pageFormatFloor)>t.floor?"floor":null:"session"}function Rn(e=150,t=2e3){return new Promise(n=>{let o=G(),r=null,i=()=>{document.removeEventListener("clay:sync-applied",a),n()},a=()=>{clearTimeout(r),r=setTimeout(i,Math.max(0,Math.min(e,t-(G()-o))))};document.addEventListener("clay:sync-applied",a),a()})}async function ct({explicit:e,forced:t=!1,forSave:n,forComparison:o,forDirty:r,captureId:i,gateToken:a,costMs:f,pageFormatFloor:u=0,quietConflict:m=!1,laneHeld:c=!1,lane:p=null,capture:S,noteRecovery:y,release:d,callback:g}){if(y(),e&&!t){if(q=r!==C,he("savePage dirty check",!q),!q){Q(),N(a),d();let s=h("No changes to save");return z(i,s),typeof g=="function"&&g(s),{result:s,dispatched:!1}}}else if(!e){let s=!Z||o!==W,v=o!==L;if(he("throttled vs baseline",!s),he("throttled vs lastSave",!v),!(s&&v)){let M=!1;try{M=!v&&(!document.querySelector(Mt)||ne()&&r===C)}catch(ht){console.error("savePageThrottled: dirty domain check failed",ht)}M&&N(a),et.noteCost(f),d();let E=h("No changes to save");return z(i,E),typeof g=="function"&&g(E),{result:E,dispatched:!1}}if(q=!0,!c&&P()){D=!0,d();let M=h("Save already in progress");return z(i,M),typeof g=="function"&&g(M),{result:M,dispatched:!1}}}yn();let l={forComparison:o,forDirty:r};return Ee.add(l),we=!0,new Promise(s=>{qt(n,i,v=>{we=!1,Ee.delete(l);let M=G();kn(v,l.forComparison,l.forDirty,t?"updated after force save":"updated after save",a,n,i,m),e||et.noteCost(f+(G()-M)),typeof g=="function"&&g(v),s({result:v,dispatched:!0}),c||un()},{capture:S,pageFormatFloor:u,lane:p})})}async function bn(e,t){let n={over:!1},o=()=>{n.over=!0};document.addEventListener("clay:sync-applied",o);try{for(let i=0;i<2;i++){let a=b(),f={generation:R,baselines:ie,floor:Math.max(qe(),e.pageFormatFloor)},u=le.beginSaveCapture({requestRefresh:!0,forRequest:!0,pageFormatMarker:f.floor?{name:It,content:String(f.floor)}:null});Qt(u.captureId);let m=null,c={get aborted(){let d=Zt(e,f,n.over);return d&&(m=d),!!d}},p;try{p=await le.runPreparedSteps(u.steps(),{budgetMs:Ln,signal:c})}catch(d){console.error(`${e.explicit?"savePage":"savePageThrottled"}: preparing the save failed`,d),u.drop();let g={msg:d&&d.message?d.message:"Save failed",msgType:"error",code:d?.code??null,etag:null};return A("error",g.msg,"",{sent:!1,code:g.code}),z(u.captureId,g),typeof e.callback=="function"&&e.callback(g),{result:g,dispatched:!1}}let S=p.aborted?m:Zt(e,f,n.over);if(!S){let d=p.result;return await ct({explicit:e.explicit,forced:e.forced,forSave:d.forSave,forComparison:d.forComparison,forDirty:d.forDirty,captureId:d.captureId,gateToken:a,costMs:p.activeMs,pageFormatFloor:e.pageFormatFloor,quietConflict:e.quietConflict,laneHeld:!0,lane:t,capture:d,noteRecovery:()=>Vt(d.captureId,d.forSave),release:()=>u.drop(),callback:e.callback})}u.drop();let y=h(Jt);if(S==="session"&&(ae=!0),z(u.captureId,y),!(S==="floor"&&i===0)){if(S==="morph"&&e.explicit&&i===0){await Rn(),n.over=!1;continue}return typeof e.callback=="function"&&e.callback(y),{result:y,dispatched:!1}}}let r=h(Jt);return typeof e.callback=="function"&&e.callback(r),{result:r,dispatched:!1}}finally{document.removeEventListener("clay:sync-applied",o),Nt(t)}}function cn(e){let t=bt();if(!t)return!1;let n=bn(e,t).catch(o=>{console.error("save: preparing the save failed",o);let r={msg:o&&o.message?o.message:"Save failed",msgType:"error",code:o?.code??null,etag:null};return A("error",r.msg,"",{sent:!1,code:r.code}),typeof e.callback=="function"&&e.callback(r),{result:r,dispatched:!1}});return X=n,n.then(o=>{X===n&&(X=null),e.resolve(o.result),e.settleSoonQueued(o.result),(o.dispatched||D||k||_e.length)&&un()}),!0}function De(e,t=()=>{}){return Te?ot.then(()=>De(e,t)):ee?ce.then(()=>Pe(e,t)):Pe(e,t)}function Pe({kind:e,permit:t=null},n=()=>{}){let o=e==="explicit";return new Promise(r=>{if(!w&&!window.clay?.testMode){o&&Q();let s=h("Not in edit mode");return T().forEach(v=>v(s)),n(s),r(s)}if(!de(t)){ae=!0;let s=at("Save session is quiesced");return o&&T().forEach(v=>v(s)),n(s),r(s)}if(ut()){o&&Q();let s=sn();return A("error",s.msg,"",{code:s.code,status:s.status,sent:!1}),T().forEach(v=>v(s)),n(s),r(s)}if(o){let s=on(n,r);if(s){T().forEach(v=>v(s));return}if(P()){D=!0;let v=h("Save already in progress");return n(v),r(v)}}else{if(O>0){Ce=!0;let s=h(it());return n(s),r(s)}if(P()&&!Z&&we){k=!0;let s=h("Save already in progress");return n(s),r(s)}if(X){k=!0;let s=h("Save already in progress");return n(s),r(s)}if(!Z&&!ne()){let s=h("No changes to save");return n(s),r(s)}}let i=window.clay?.source?.ensureForSave?.();if(i)return i.then(()=>r(Pe({kind:e,permit:t},n)));if(xe()&&!le){fn().then(()=>r(Pe({kind:e,permit:t},n)));return}let a=o?T():[],f=s=>a.forEach(v=>v(s));if(!navigator.onLine&&nt(),xe()&&cn({explicit:o,forced:!1,permit:t,pageFormatFloor:0,quietConflict:!1,settleSoonQueued:f,callback:n,resolve:r}))return;let m=G(),c,p,S,y,d,g=b();try{c=Ne({requestRefresh:!0,forRequest:!0}),{forSave:p,forComparison:S,forDirty:y,captureId:d}=c}catch(s){console.error(`${o?"savePage":"savePageThrottled"}: captureForSaveAndComparison failed`,s),o?(Q(),A("error",s.message,"",{sent:!1,code:s.code??null})):A("error",s.message);let v={msg:s.message,msgType:"error",code:o?s.code??null:null,etag:null};typeof n=="function"&&n(v),r(v),f(v);return}let l=G()-m;ct({explicit:o,forSave:p,forComparison:S,forDirty:y,captureId:d,gateToken:g,costMs:l,capture:c,noteRecovery:()=>Ge({captureId:d,html:p}),release:()=>Re(c),callback:n}).then(s=>{r(s.result),f(s.result)})})}function I(e=()=>{}){return De({kind:"explicit"},e)}function Nn(e,t=()=>{}){return De({kind:"explicit",permit:e},t)}function j(e=()=>{},{quietConflict:t=!1,pageFormatFloor:n=0,permit:o=null}={}){return Te?ot.then(()=>j(e,{quietConflict:t,pageFormatFloor:n,permit:o})):new Promise(r=>{if(!w&&!window.clay?.testMode){let l=h("Not in edit mode");return T().forEach(s=>s(l)),e(l),r(l)}if(!de(o)||o&&!an(o)){let l=at("Save session is quiesced");return T().forEach(s=>s(l)),e(l),r(l)}if(ut()){let l=sn();return A("error",l.msg,"",{code:l.code,status:l.status,sent:!1}),T().forEach(s=>s(l)),e(l),r(l)}let i=on(e,r);if(i){T().forEach(l=>l(i));return}if(P()){D=!0;let l=h("Save already in progress");return T().forEach(s=>s(l)),e(l),r(l)}let a=window.clay?.source?.ensureForSave?.();if(a)return a.then(()=>r(j(e,{quietConflict:t,pageFormatFloor:n,permit:o})));if(!navigator.onLine&&nt(),xe()&&!le){fn().then(()=>r(j(e,{quietConflict:t,pageFormatFloor:n,permit:o})));return}let u=T(),m=l=>u.forEach(s=>s(l));if(xe()&&cn({explicit:!0,forced:!0,permit:o,pageFormatFloor:n,quietConflict:t,settleSoonQueued:m,callback:e,resolve:r}))return;let c,p,S,y,d,g=b();try{c=Ne({requestRefresh:!0,forRequest:!0}),{forSave:p,forComparison:S,forDirty:y,captureId:d}=c}catch(l){console.error("savePageForce: captureForSaveAndComparison failed",l),A("error",l.message,"",{sent:!1,code:l.code??null});let s={msg:l.message,msgType:"error",code:l.code??null,etag:null};typeof e=="function"&&e(s),r(s),m(s);return}ct({explicit:!0,forced:!0,forSave:p,forComparison:S,forDirty:y,captureId:d,gateToken:g,costMs:0,pageFormatFloor:n,quietConflict:t,capture:c,noteRecovery:()=>Ge({captureId:d,html:p}),release:()=>Re(c),callback:e}).then(l=>{r(l.result),m(l.result)})})}Ht(e=>j(()=>{},{permit:e}));function Fn(e){let t=["clay:save-saved","clay:save-error","clay:save-offline","clay:save-conflict"];return new Promise((n,o)=>{let r=null,i=()=>{clearTimeout(r);for(let u of t)document.removeEventListener(u,a)},a=()=>{i(),n()},f=e-Date.now();if(f<=0){o(Object.assign(new Error("Save timed out."),{state:"failed"}));return}r=setTimeout(()=>{i(),o(Object.assign(new Error("Save timed out."),{state:"failed"}))},f);for(let u of t)document.addEventListener(u,a)})}function _(e,t){return Object.assign(new Error(e),{state:t})}function Un(e,t){return new Promise((n,o)=>{let r=t-Date.now();if(r<=0)return o(_("Save timed out.","failed"));let i=setTimeout(()=>{document.removeEventListener(e,a),o(_("Save timed out.","failed"))},r),a=()=>{clearTimeout(i),n()};document.addEventListener(e,a,{once:!0})})}async function $r({keepalive:e=!1,timeoutMs:t=15e3,permit:n=null}={}){if(!w)return{state:"view",etag:null};let o=Date.now()+t,r=n||_n(),i={over:!1},a=null,f=new Promise((u,m)=>{a=setTimeout(()=>m(_("Save timed out.","failed")),Math.max(0,t))});try{return await Promise.race([qn(e,o,r,i),f])}catch(u){throw u&&typeof u.state=="string"?u:_(u?.message||"Save failed","failed")}finally{i.over=!0,clearTimeout(a),n||Dn(r)}}async function qn(e,t,n,o={over:!1}){if(dn()||await Un("clay:baseline-settled",t),o.over)return null;let r=!1,i=null;for(let a=0;a<4;a++){if(X&&(await X,o.over)||P()&&(await Fn(t),o.over))return null;if(je())throw _("This document has a conflict to resolve.","conflict");let f=b();if(!tt()){if(N(f),F())throw _("This document has unsaved work a save cannot write.","blocked");return te=!1,{state:r?"saved":"clean",etag:i??Fe()}}if(o.over)return null;let u=await Rt(e,()=>Nn(n));if(u.msgType!=="skipped"){if(!u.ok)throw _(u.msg||"Save failed",u.msgType==="conflict"||je()?"conflict":"failed");r=!0,i=u.etag??null}}throw _("The document kept changing while saving.","failed")}async function Yr(e=()=>{}){return await Ue({fresh:!0}),j(e)}function zr(e){!w||K||Bt(e,t=>{t.ok?window.location.reload():t.msgType==="skipped"?A("error",t.msg||"Template not saved"):A("error",t.msg||"Failed to save template")})}var Bn=Dt(e=>De({kind:"automatic"},e),1200),Hn=250,Gn=1e3,J=null,en=0,Je=[],_e=[],fe=!1,T=()=>{let e=_e;return _e=[],e};function dt(){if(J=null,B>0||!de()){fe=!0;return}let e=Je;if(Je=[],P()){_e.push(...e),I();return}I().then(t=>e.forEach(n=>n(t)))}function Xr(){let e=Date.now();return J===null?en=e:clearTimeout(J),new Promise(t=>{Je.push(t),J=setTimeout(dt,Math.max(0,Math.min(Hn,en+Gn-e)))})}function Wn(){ae&&(ae=!1,ke())}function tn(){fe&&(fe=!1,J=setTimeout(dt,0))}var W="",Z=!0,pt=!1;function dn(){return pt}var Ke=!1,Kn=250,Qn=1250,Qe=null,pn="clay:paint-heal:"+location.pathname;function mn(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)|0;return String(t>>>0)}function Vn(e){try{return localStorage.getItem(pn)===mn(e)}catch{return!1}}function $n(e){try{localStorage.setItem(pn,mn(e))}catch{}}function Yn(){return xt(_t({flushUndo:!1}))}function jr(e){!w||K||(clearTimeout(Qe),Qe=setTimeout(async()=>{Qe=null,ee&&await ce;let t=typeof e=="function"?e():e;t==null||!He()||!dn()||je()||wn()||V({flushUndo:!1})===C&&t!==Yn()&&(Vn(t)||($n(t),j(()=>{},{quietConflict:!0})))},Kn+Math.random()*Qn))}var Se=null,Ve=null,ee=0,ce=Promise.resolve(),mt=!1,vt=[];function zn(){return Ve??=import("./c-KNPDOMDY.js").catch(e=>(Ve=null,console.error("style-comparisons failed to load",e),null)),Ve}async function Xn(e){try{if(Se||(Se=(await zn())?.styleComparisonStripper??null),!Se)return;let t=Se(e);L=t(L),C=t(C),W=t(W);for(let n of Ee)n.forComparison=t(n.forComparison),n.forDirty=t(n.forDirty)}catch(t){console.error("style adoption failed",t)}finally{ee--,vt.shift()}}var ye=e=>e.replace(/&/g,"&").replace(/"/g,""");function jn(e){if(e.name!==void 0){let n=[`data-name="${ye(e.name)}"`];return e.legacyId!==void 0&&n.push(`id="${ye(e.legacyId)}"`),n}let t=[ye(e.href)];try{let{pathname:n}=new URL(e.href);n&&t.push(ye(n))}catch{}return t}function Jn(e){let t=[L,C,W];for(let n of Ee)t.push(n.forComparison,n.forDirty);return t.some(n=>n&&e.some(o=>o&&n.includes(o)))}function Zn(e,t){let n=[];for(let{markers:i,tag:a}of t)for(let f of i)for(let u=e.indexOf(f);u>=0;u=e.indexOf(f,u+f.length)){let m=e.lastIndexOf("<",u);if(m<0||e.slice(m+1,m+1+a.length).toLowerCase()!==a)continue;let c=a==="style"?e.indexOf("</style",u):u;if(c<0)continue;let p=e.indexOf(">",c);p>=0&&n.push([m,p+1])}n.sort((i,a)=>i[0]-a[0]);let o="",r=0;for(let[i,a]of n)i<r||(o+=e.slice(r,i),r=a);return o+e.slice(r)}Kt(e=>{let t=jn(e);Jn(t)&&(ee||(mt=!1),ee++,vt.push({markers:t,tag:e.name!==void 0?"style":"link"}),ce=ce.then(()=>Xn(e)))});function Jr(){return ce}function gt(e){return!ee||mt||F()||P()||D||k||te||typeof e!="string"?!1:e===Zn(C,vt)}var er=500,tr=3e3,nr=1e4,Ze=null;function rr(){pe.holdSettle=!1,Ze&&Ze()}function nn(){if(!w)return;let e=!1,t=null,{forComparison:n,forDirty:o}=me();ue(n,o);let r=ie;W=n,re("immediate capture",`${n.length} chars`);let i=["keydown","pointerdown","drop","input","change","paste"],a=new Set(["Shift","Control","Alt","Meta"]),f=c=>{c.type==="keydown"&&a.has(c.key)||(mt=!0,e||(Ke=!0))};i.forEach(c=>document.addEventListener(c,f,!0));let u=()=>{if(!e){if(e=!0,t&&t(),!Ke&&ie===r){let c=b(),{forComparison:p,forDirty:S}=me();ue(p,S),W=p,N(c),re("settled capture",`${p.length} chars`)}else re("settled skipped",Ke?"user edited":"save occurred during settle");Z=!1,document.documentElement.setAttribute("savestatus","saved"),pt=!0,document.dispatchEvent(new CustomEvent("clay:baseline-settled"))}};Ze=u;let m=()=>{pe.holdSettle||u()};t=Pt.onAnyChange({debounce:er,omitChangeDetails:!0,require:"autosave"},m),setTimeout(()=>{e||m()},tr),setTimeout(()=>{!e&&pe.holdSettle&&rr()},nr)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",nn):nn();function ke(e=()=>{}){if(!w){let t=h("Not in edit mode");return e(t),Promise.resolve(t)}if(O>0){Ce=!0;let t=h(it());return e(t),Promise.resolve(t)}if(!de()){ae=!0;let t=at("Save session is quiesced");return e(t),Promise.resolve(t)}if(B>0){$e=!0;let t=h("Autosave suspended");return e(t),Promise.resolve(t)}if(!Z&&we){k=!0;let t=h("Save already in progress");return e(t),Promise.resolve(t)}return Bn(e).catch(t=>{let n={ok:!1,msg:t?.message||"Save failed",msgType:"error",code:null,etag:null};return A("error",n.msg),n})}var et=Xt({now:G,run:()=>ke()});function vn(){document.addEventListener("keydown",function(e){if((window.navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)&&e.keyCode==83){if(!w)return;e.preventDefault(),e.isTrusted&&Ie(),I()}})}function gn(){document.addEventListener("click",e=>{e.target.closest("[trigger-save]")&&(e.isTrusted&&Ie(),I())})}function or(){w&&(Ue(),Ot(),Oe(),vn(),gn())}or();var Zr=I;var Le=!1;function ao({isCurrent:e,reload:t}){return e()?(Le=!0,setTimeout(()=>{Le=!1},1e3),t(),!0):!1}zt();function sr(){return rt()?!0:w?F()?!0:K?Tt():window.clay?.demo?!1:tt():!1}function tt(){if(!w)return!1;try{let e=V();return gt(e)?!1:e!==ft()}catch{return!0}}window.addEventListener("beforeunload",e=>{if(!w&&!rt())return;if(Le){Le=!1;return}if(!((!K||At())&&!sr())&&(e.preventDefault(),e.returnValue="",!window.clay?.demo&&!F()))try{let n=V(),o=ft();n!==o&&Yt(n,o)}catch{}});export{ao as a,sr as b,tt as c,En as d,rn as e,wn as f,de as g,rt as h,Tn as i,Ir as j,Rr as k,br as l,Nr as m,Fr as n,Ur as o,it as p,je as q,qr as r,Br as s,Hr as t,_n as u,Dn as v,Gr as w,Wr as x,Kr as y,ft as z,Qr as A,ue as B,Vr as C,I as D,j as E,$r as F,Yr as G,zr as H,Xr as I,dn as J,Yn as K,jr as L,Jr as M,gt as N,rr as O,ke as P,et as Q,vn as R,gn as S,or as T,Zr as U};
|
|
1
|
+
import{a as Gt}from"./c-4ASQPRQL.js";import{a as Dt}from"./c-GQ6F6IDK.js";import{c as F}from"./c-I2SCCUEW.js";import{b as He}from"./c-5VYOWDTI.js";import{a as Wt,d as ne,e as Be,f as b,h as N}from"./c-GSRLXYWL.js";import{a as Ge,b as Qt,c as Vt,d as $t}from"./c-X5LNHET5.js";import{a as Kt}from"./c-UGHH4MB3.js";import{a as Pt}from"./c-LA2BW7UY.js";import{a as Ot,e as Rt,f as P,g as bt,h as Nt,i as Ft,l as Ut,t as qt,v as Bt,w as Ht}from"./c-GVPNDIKJ.js";import{b as It,h as qe}from"./c-EK63G3CG.js";import{a as Fe,c as kt,g as Lt,h as Ue}from"./c-NQJRVJ56.js";import{a as Oe,f as Ie,h as Q}from"./c-IJUK2GPW.js";import{b as K,e as Ct,f as w}from"./c-3O7OBDCM.js";import{i as At,k as Tt}from"./c-N7JPUPGC.js";import{D as Ne,h as Re,q as be,t as _t,x as V,y as me}from"./c-EGTIAL6P.js";import{d as xt}from"./c-VG5XIN4T.js";import{a as pe}from"./c-2YYDMLNZ.js";import{d as St,e as yt,g as Et,h as wt}from"./c-HA6INT6J.js";import{k as Mt}from"./c-ICMAOOGK.js";var hn="clay:debug:autosave";function ve(){try{return localStorage.getItem(hn)==="true"}catch{return!1}}function ge(){return import("./c-CFHW5AMY.js").catch(e=>(console.warn("[autosave-debug] Failed to load the debug logger:",e),null))}function he(e,t){ve()&&ge().then(n=>n?.logSaveCheck(e,t))}function re(e,t=""){ve()&&ge().then(n=>n?.logBaseline(e,t))}function Yt(e,t){ve()&&ge().then(n=>n?.logUnloadDiffSync(e,t))}function zt(){ve()&&ge().then(e=>e?.preloadIfEnabled())}var U=Number.NEGATIVE_INFINITY;function Sn({firstDirtyAt:e=U,lastActivityAt:t=U,finishedAt:n=U,costMs:o=0}={}){let r=e??U,i=t??U,a=n??U,f=Math.min(3e4,Math.max(1200,4*o)),u=Math.max(i,a)+1500,m=Math.max(r+1e4,a+f);return Math.max(a+1200,Math.min(u,m))}function Xt({now:e=()=>Date.now(),setTimer:t=(r,i)=>setTimeout(r,i),clearTimer:n=r=>clearTimeout(r),run:o=()=>{}}={}){let r=null,i=null,a=U,f=0,u=null,m=null,c=!1,p=!1;function S(){return Sn({firstDirtyAt:r,lastActivityAt:i,finishedAt:a,costMs:f})}function y(){if(!c||p)return;let E=S();if(u!==null){if(m===E)return;n(u)}m=E,u=t(d,Math.max(0,E-e()))}function d(){if(u=null,m=null,!(!c||p)){if(e()<S()){y();return}g()}}function g(){c=!1,p=!0,r=null,i=null;let E;try{E=o()}catch{l();return}Promise.resolve(E).then(l,l)}function l(){p=!1,a=e(),c&&y()}function s({at:E=e()}={}){r===null&&(r=E),i=E,c=!0,y()}function v(){c=!0,y()}function M(E){E>0&&(f=Math.max(E,f*.8))}return{noteActivity:s,request:v,noteCost:M,dueAt:S,costEstimate:()=>f,pending:()=>c||p,running:()=>p}}be(e=>{for(let t of wt)e.removeAttribute(t)});be(e=>{for(let t of[...St,...yt,...Et])e.removeAttribute(t)});var x=null;function A(e,t="",n="",o=null){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus",e);let r=new CustomEvent(`clay:save-${e}`,{detail:{msg:t,msgType:n,timestamp:Date.now(),...o||{}}});document.dispatchEvent(r)}function nt(){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus","offline")}function yn(){x=setTimeout(()=>{A("saving")},500)}window.addEventListener("offline",()=>{nt()});window.addEventListener("online",()=>{document.documentElement.getAttribute("savestatus")==="offline"&&I().then(e=>{e.msgType==="skipped"&&document.documentElement.getAttribute("savestatus")==="offline"&&document.documentElement.setAttribute("savestatus","saved")})});var q=!1,L="",C="",ie=0,Ee=new Set,D=!1,k=!1,we=!1,B=0,$e=!1;function En(){B++}function rn(){B!==0&&(B--,!(B>0)&&(fe&&(fe=!1,J=setTimeout(dt,0)),$e&&($e=!1,ke())))}function wn(){return B>0}var $=0,te=!1,ae=!1,Ae=!1;function de(e=null){return $===0||an(e)}function rt(){return te}function An(){if(te)return!0;try{let e=V({flushUndo:!1});return gt(e)?!1:e!==C}catch{return!0}}function Tn(){let e="idle",t=0;return{get phase(){return e},get open(){return e==="open"},changedWhileClosed(){return e==="quiesced"&&Be()!==t},start(){e==="idle"&&(e="open")},quiesce(){e==="open"&&(e="quiesced",t=Be(),$++)},resume(){e==="quiesced"&&(e="open",$--,!($>0)&&(Wn(),tn()))},stop(){if(e==="stopped")return;let n=e==="quiesced";(n||e==="open")&&An()&&(Ae=!0),e="stopped",n&&($--,$===0&&tn())}}}var jt=!1,oe=null,Ye=null,ze=!1;function Ir(e=R){if(!oe||oe.generation!==e)return null;let{bytes:t,etag:n}=oe;return{bytes:t,etag:n}}function Rr({represented:e}={}){let t=b(),{forComparison:n,forDirty:o}=me(),r=typeof e?.etag=="string"&&e.etag?e.etag:null;return!(ze&&r!==null&&r!==Ye)&&Ae&&(n!==L||o!==C)?{ok:!1,code:"pending-input"}:(Ae=!1,ue(n,o),W=n,Z=!1,pt=!0,Ye=r,ze=!0,N(t),document.documentElement.setAttribute("savestatus","saved"),document.dispatchEvent(new CustomEvent("clay:baseline-settled")),{ok:!0})}var ot=Promise.resolve(!1),Te=!1,Cn=()=>(Te=!0,Lt().catch(()=>!1).then(e=>(Te=!1,e)));function br(){return{id:"clay:save",order:10,prepare(e={}){let t=Tn();return e.initial===!0&&t.start(),{enable(){ot=Cn();let n=e.represented?.etag;typeof n=="string"&&n&&kt(n),e.initial!==!0&&(Mn(),t.start())},quiesce:()=>t.quiesce(),resume:()=>t.resume(),dispose:()=>t.stop()}}}}function Mn(){jt||(jt=!0,Wt(),Oe(),vn(),gn())}var O=0,Xe=!1,Ce=!1,st="Waiting for the AI edit to be kept or reverted",Y=new Map;function Nr(e=st){O++,Y.set(e,(Y.get(e)||0)+1)}function Fr({replay:e=!0,reason:t=st}={}){let n=Y.get(t)||0;if(n===0||(n===1?Y.delete(t):Y.set(t,n-1),O--,O>0))return;let o=Xe,r=Ce;Xe=!1,Ce=!1,e&&(o?I():r&&ke())}function Ur(){return O>0}function it(){return O===0?null:Y.keys().next().value||st}function on(e,t){if(O===0)return!1;Xe=!0,Q();let n=h(it());return e(n),t(n),n}var H=!1,se=null;function xn(e){se=e??null,!H&&(H=!0,En())}function Pn(){H&&(H=!1,se=null,rn())}function je(){return H}function qr(e){if(!H||se&&e!==se)return;H=!1,se=null,!He()&&ne()||(document.documentElement.getAttribute("savestatus")==="conflict"&&document.documentElement.setAttribute("savestatus","saved"),document.dispatchEvent(new CustomEvent("clay:save-conflict-resolved",{detail:{timestamp:Date.now()}}))),document.dispatchEvent(new CustomEvent("clay:save-conflict-released",{detail:{etag:e??null}})),rn()}function h(e){return{ok:!1,msg:e,msgType:"skipped",code:null,etag:null}}function at(e){return(ne()||F())&&(te=!0),h(e)}function sn(){return{ok:!1,msg:"You are not allowed to save this document.",msgType:"forbidden",code:"forbidden",status:403,sent:!1,etag:null}}function ut(){return Ct()===!1}var lt=new Set,R=0;function Br(){return R}function Hr(e){typeof e=="number"&&(R=e)}function _n(e=R){let t=Object.freeze({generation:e});return lt.add(t),t}function Dn(e){lt.delete(e)}function an(e){return!!e&<.has(e)&&e.generation===R}function z(e,t){e!=null&&$t({captureId:e,ok:t.ok===!0,etag:t.etag??null})}function kn(e,t,n,o,r,i=null,a=null,f=!1){if(z(a,e),e.ok)te=!1,ue(t,n),Me=i,oe={bytes:i,etag:Fe(),generation:R},Ye=oe.etag,ze=!0,Ae=!1,q=!1,N(r),A("saved",e.msg||"Saved",e.msgType,{etag:e.etag??null,captureId:a}),re(o,`${L.length} chars`),Pn();else if(e.msgType==="conflict"){if(f){x&&(clearTimeout(x),x=null),document.documentElement.setAttribute("savestatus","saved");return}xn(e.conflictEtag),A("conflict",e.msg,e.msgType,{hadTimeout:e.hadTimeout===!0,changedBy:e.changedBy??null,afterTimeout:e.afterTimeout===!0,etag:e.conflictEtag??null,code:e.code??null,reason:e.reason??null,retryAfter:e.retryAfter??null,captureId:a})}else if(e.msgType!=="skipped"){let u={status:e.status??null,hadTimeout:e.hadTimeout===!0,code:e.code??null,reason:e.reason??null,retryAfter:e.retryAfter??null,captureId:a};navigator.onLine?A("error",e.msg,"",u):A("offline",e.msg,"",u)}}function un(){if(!(!D&&!k)&&!Ut()){if(D){D=!1,k=!1,I();return}k=!1,et.request()}}function Gr(){return q}function Wr(e){q=e}function Kr(){return L}function ft(){return C}var Me=null;function Qr(){return Me}function ue(e,t){L=e,C=t,ie++}function Vr(e){ue(e,e)}var G=()=>typeof performance<"u"&&performance.now?performance.now():Date.now();var Ln=4,Jt="Save cancelled: the page changed while it prepared",X=null,le=null,We=null,ln=!1;function fn(){return We||(We=import("./c-3AXJDL2P.js").then(e=>(le=e,e),e=>(ln=!0,console.info("clayjs: sliced save off ("+(e&&e.message?e.message:e)+"); saves prepare in one task"),null))),We}function On(){try{return performance.getEntriesByType("navigation")[0]?.decodedBodySize||0}catch{return 0}}var In=()=>typeof Me=="string"?Me.length:On();function xe(){return ln||document.hidden||Ft()?!1:In()>=307200}function Zt(e,t,n){return n?"morph":R!==t.generation||!w?"mode":de(e.permit)?ut()?"refused":ie!==t.baselines?"newer save":Math.max(qe(),e.pageFormatFloor)>t.floor?"floor":null:"session"}function Rn(e=150,t=2e3){return new Promise(n=>{let o=G(),r=null,i=()=>{document.removeEventListener("clay:sync-applied",a),n()},a=()=>{clearTimeout(r),r=setTimeout(i,Math.max(0,Math.min(e,t-(G()-o))))};document.addEventListener("clay:sync-applied",a),a()})}async function ct({explicit:e,forced:t=!1,forSave:n,forComparison:o,forDirty:r,captureId:i,gateToken:a,costMs:f,pageFormatFloor:u=0,quietConflict:m=!1,laneHeld:c=!1,lane:p=null,capture:S,noteRecovery:y,release:d,callback:g}){if(y(),e&&!t){if(q=r!==C,he("savePage dirty check",!q),!q){Q(),N(a),d();let s=h("No changes to save");return z(i,s),typeof g=="function"&&g(s),{result:s,dispatched:!1}}}else if(!e){let s=!Z||o!==W,v=o!==L;if(he("throttled vs baseline",!s),he("throttled vs lastSave",!v),!(s&&v)){let M=!1;try{M=!v&&(!document.querySelector(Mt)||ne()&&r===C)}catch(ht){console.error("savePageThrottled: dirty domain check failed",ht)}M&&N(a),et.noteCost(f),d();let E=h("No changes to save");return z(i,E),typeof g=="function"&&g(E),{result:E,dispatched:!1}}if(q=!0,!c&&P()){D=!0,d();let M=h("Save already in progress");return z(i,M),typeof g=="function"&&g(M),{result:M,dispatched:!1}}}yn();let l={forComparison:o,forDirty:r};return Ee.add(l),we=!0,new Promise(s=>{qt(n,i,v=>{we=!1,Ee.delete(l);let M=G();kn(v,l.forComparison,l.forDirty,t?"updated after force save":"updated after save",a,n,i,m),e||et.noteCost(f+(G()-M)),typeof g=="function"&&g(v),s({result:v,dispatched:!0}),c||un()},{capture:S,pageFormatFloor:u,lane:p})})}async function bn(e,t){let n={over:!1},o=()=>{n.over=!0};document.addEventListener("clay:sync-applied",o);try{for(let i=0;i<2;i++){let a=b(),f={generation:R,baselines:ie,floor:Math.max(qe(),e.pageFormatFloor)},u=le.beginSaveCapture({requestRefresh:!0,forRequest:!0,pageFormatMarker:f.floor?{name:It,content:String(f.floor)}:null});Qt(u.captureId);let m=null,c={get aborted(){let d=Zt(e,f,n.over);return d&&(m=d),!!d}},p;try{p=await le.runPreparedSteps(u.steps(),{budgetMs:Ln,signal:c})}catch(d){console.error(`${e.explicit?"savePage":"savePageThrottled"}: preparing the save failed`,d),u.drop();let g={msg:d&&d.message?d.message:"Save failed",msgType:"error",code:d?.code??null,etag:null};return A("error",g.msg,"",{sent:!1,code:g.code}),z(u.captureId,g),typeof e.callback=="function"&&e.callback(g),{result:g,dispatched:!1}}let S=p.aborted?m:Zt(e,f,n.over);if(!S){let d=p.result;return await ct({explicit:e.explicit,forced:e.forced,forSave:d.forSave,forComparison:d.forComparison,forDirty:d.forDirty,captureId:d.captureId,gateToken:a,costMs:p.activeMs,pageFormatFloor:e.pageFormatFloor,quietConflict:e.quietConflict,laneHeld:!0,lane:t,capture:d,noteRecovery:()=>Vt(d.captureId,d.forSave),release:()=>u.drop(),callback:e.callback})}u.drop();let y=h(Jt);if(S==="session"&&(ae=!0),z(u.captureId,y),!(S==="floor"&&i===0)){if(S==="morph"&&e.explicit&&i===0){await Rn(),n.over=!1;continue}return typeof e.callback=="function"&&e.callback(y),{result:y,dispatched:!1}}}let r=h(Jt);return typeof e.callback=="function"&&e.callback(r),{result:r,dispatched:!1}}finally{document.removeEventListener("clay:sync-applied",o),Nt(t)}}function cn(e){let t=bt();if(!t)return!1;let n=bn(e,t).catch(o=>{console.error("save: preparing the save failed",o);let r={msg:o&&o.message?o.message:"Save failed",msgType:"error",code:o?.code??null,etag:null};return A("error",r.msg,"",{sent:!1,code:r.code}),typeof e.callback=="function"&&e.callback(r),{result:r,dispatched:!1}});return X=n,n.then(o=>{X===n&&(X=null),e.resolve(o.result),e.settleSoonQueued(o.result),(o.dispatched||D||k||_e.length)&&un()}),!0}function De(e,t=()=>{}){return Te?ot.then(()=>De(e,t)):ee?ce.then(()=>Pe(e,t)):Pe(e,t)}function Pe({kind:e,permit:t=null},n=()=>{}){let o=e==="explicit";return new Promise(r=>{if(!w&&!window.clay?.testMode){o&&Q();let s=h("Not in edit mode");return T().forEach(v=>v(s)),n(s),r(s)}if(!de(t)){ae=!0;let s=at("Save session is quiesced");return o&&T().forEach(v=>v(s)),n(s),r(s)}if(ut()){o&&Q();let s=sn();return A("error",s.msg,"",{code:s.code,status:s.status,sent:!1}),T().forEach(v=>v(s)),n(s),r(s)}if(o){let s=on(n,r);if(s){T().forEach(v=>v(s));return}if(P()){D=!0;let v=h("Save already in progress");return n(v),r(v)}}else{if(O>0){Ce=!0;let s=h(it());return n(s),r(s)}if(P()&&!Z&&we){k=!0;let s=h("Save already in progress");return n(s),r(s)}if(X){k=!0;let s=h("Save already in progress");return n(s),r(s)}if(!Z&&!ne()){let s=h("No changes to save");return n(s),r(s)}}let i=window.clay?.source?.ensureForSave?.();if(i)return i.then(()=>r(Pe({kind:e,permit:t},n)));if(xe()&&!le){fn().then(()=>r(Pe({kind:e,permit:t},n)));return}let a=o?T():[],f=s=>a.forEach(v=>v(s));if(!navigator.onLine&&nt(),xe()&&cn({explicit:o,forced:!1,permit:t,pageFormatFloor:0,quietConflict:!1,settleSoonQueued:f,callback:n,resolve:r}))return;let m=G(),c,p,S,y,d,g=b();try{c=Ne({requestRefresh:!0,forRequest:!0}),{forSave:p,forComparison:S,forDirty:y,captureId:d}=c}catch(s){console.error(`${o?"savePage":"savePageThrottled"}: captureForSaveAndComparison failed`,s),o?(Q(),A("error",s.message,"",{sent:!1,code:s.code??null})):A("error",s.message);let v={msg:s.message,msgType:"error",code:o?s.code??null:null,etag:null};typeof n=="function"&&n(v),r(v),f(v);return}let l=G()-m;ct({explicit:o,forSave:p,forComparison:S,forDirty:y,captureId:d,gateToken:g,costMs:l,capture:c,noteRecovery:()=>Ge({captureId:d,html:p}),release:()=>Re(c),callback:n}).then(s=>{r(s.result),f(s.result)})})}function I(e=()=>{}){return De({kind:"explicit"},e)}function Nn(e,t=()=>{}){return De({kind:"explicit",permit:e},t)}function j(e=()=>{},{quietConflict:t=!1,pageFormatFloor:n=0,permit:o=null}={}){return Te?ot.then(()=>j(e,{quietConflict:t,pageFormatFloor:n,permit:o})):new Promise(r=>{if(!w&&!window.clay?.testMode){let l=h("Not in edit mode");return T().forEach(s=>s(l)),e(l),r(l)}if(!de(o)||o&&!an(o)){let l=at("Save session is quiesced");return T().forEach(s=>s(l)),e(l),r(l)}if(ut()){let l=sn();return A("error",l.msg,"",{code:l.code,status:l.status,sent:!1}),T().forEach(s=>s(l)),e(l),r(l)}let i=on(e,r);if(i){T().forEach(l=>l(i));return}if(P()){D=!0;let l=h("Save already in progress");return T().forEach(s=>s(l)),e(l),r(l)}let a=window.clay?.source?.ensureForSave?.();if(a)return a.then(()=>r(j(e,{quietConflict:t,pageFormatFloor:n,permit:o})));if(!navigator.onLine&&nt(),xe()&&!le){fn().then(()=>r(j(e,{quietConflict:t,pageFormatFloor:n,permit:o})));return}let u=T(),m=l=>u.forEach(s=>s(l));if(xe()&&cn({explicit:!0,forced:!0,permit:o,pageFormatFloor:n,quietConflict:t,settleSoonQueued:m,callback:e,resolve:r}))return;let c,p,S,y,d,g=b();try{c=Ne({requestRefresh:!0,forRequest:!0}),{forSave:p,forComparison:S,forDirty:y,captureId:d}=c}catch(l){console.error("savePageForce: captureForSaveAndComparison failed",l),A("error",l.message,"",{sent:!1,code:l.code??null});let s={msg:l.message,msgType:"error",code:l.code??null,etag:null};typeof e=="function"&&e(s),r(s),m(s);return}ct({explicit:!0,forced:!0,forSave:p,forComparison:S,forDirty:y,captureId:d,gateToken:g,costMs:0,pageFormatFloor:n,quietConflict:t,capture:c,noteRecovery:()=>Ge({captureId:d,html:p}),release:()=>Re(c),callback:e}).then(l=>{r(l.result),m(l.result)})})}Ht(e=>j(()=>{},{permit:e}));function Fn(e){let t=["clay:save-saved","clay:save-error","clay:save-offline","clay:save-conflict"];return new Promise((n,o)=>{let r=null,i=()=>{clearTimeout(r);for(let u of t)document.removeEventListener(u,a)},a=()=>{i(),n()},f=e-Date.now();if(f<=0){o(Object.assign(new Error("Save timed out."),{state:"failed"}));return}r=setTimeout(()=>{i(),o(Object.assign(new Error("Save timed out."),{state:"failed"}))},f);for(let u of t)document.addEventListener(u,a)})}function _(e,t){return Object.assign(new Error(e),{state:t})}function Un(e,t){return new Promise((n,o)=>{let r=t-Date.now();if(r<=0)return o(_("Save timed out.","failed"));let i=setTimeout(()=>{document.removeEventListener(e,a),o(_("Save timed out.","failed"))},r),a=()=>{clearTimeout(i),n()};document.addEventListener(e,a,{once:!0})})}async function $r({keepalive:e=!1,timeoutMs:t=15e3,permit:n=null}={}){if(!w)return{state:"view",etag:null};let o=Date.now()+t,r=n||_n(),i={over:!1},a=null,f=new Promise((u,m)=>{a=setTimeout(()=>m(_("Save timed out.","failed")),Math.max(0,t))});try{return await Promise.race([qn(e,o,r,i),f])}catch(u){throw u&&typeof u.state=="string"?u:_(u?.message||"Save failed","failed")}finally{i.over=!0,clearTimeout(a),n||Dn(r)}}async function qn(e,t,n,o={over:!1}){if(dn()||await Un("clay:baseline-settled",t),o.over)return null;let r=!1,i=null;for(let a=0;a<4;a++){if(X&&(await X,o.over)||P()&&(await Fn(t),o.over))return null;if(je())throw _("This document has a conflict to resolve.","conflict");let f=b();if(!tt()){if(N(f),F())throw _("This document has unsaved work a save cannot write.","blocked");return te=!1,{state:r?"saved":"clean",etag:i??Fe()}}if(o.over)return null;let u=await Rt(e,()=>Nn(n));if(u.msgType!=="skipped"){if(!u.ok)throw _(u.msg||"Save failed",u.msgType==="conflict"||je()?"conflict":"failed");r=!0,i=u.etag??null}}throw _("The document kept changing while saving.","failed")}async function Yr(e=()=>{}){return await Ue({fresh:!0}),j(e)}function zr(e){!w||K||Bt(e,t=>{t.ok?window.location.reload():t.msgType==="skipped"?A("error",t.msg||"Template not saved"):A("error",t.msg||"Failed to save template")})}var Bn=Dt(e=>De({kind:"automatic"},e),1200),Hn=250,Gn=1e3,J=null,en=0,Je=[],_e=[],fe=!1,T=()=>{let e=_e;return _e=[],e};function dt(){if(J=null,B>0||!de()){fe=!0;return}let e=Je;if(Je=[],P()){_e.push(...e),I();return}I().then(t=>e.forEach(n=>n(t)))}function Xr(){let e=Date.now();return J===null?en=e:clearTimeout(J),new Promise(t=>{Je.push(t),J=setTimeout(dt,Math.max(0,Math.min(Hn,en+Gn-e)))})}function Wn(){ae&&(ae=!1,ke())}function tn(){fe&&(fe=!1,J=setTimeout(dt,0))}var W="",Z=!0,pt=!1;function dn(){return pt}var Ke=!1,Kn=250,Qn=1250,Qe=null,pn="clay:paint-heal:"+location.pathname;function mn(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)|0;return String(t>>>0)}function Vn(e){try{return localStorage.getItem(pn)===mn(e)}catch{return!1}}function $n(e){try{localStorage.setItem(pn,mn(e))}catch{}}function Yn(){return xt(_t({flushUndo:!1}))}function jr(e){!w||K||(clearTimeout(Qe),Qe=setTimeout(async()=>{Qe=null,ee&&await ce;let t=typeof e=="function"?e():e;t==null||!He()||!dn()||je()||wn()||V({flushUndo:!1})===C&&t!==Yn()&&(Vn(t)||($n(t),j(()=>{},{quietConflict:!0})))},Kn+Math.random()*Qn))}var Se=null,Ve=null,ee=0,ce=Promise.resolve(),mt=!1,vt=[];function zn(){return Ve??=import("./c-KNPDOMDY.js").catch(e=>(Ve=null,console.error("style-comparisons failed to load",e),null)),Ve}async function Xn(e){try{if(Se||(Se=(await zn())?.styleComparisonStripper??null),!Se)return;let t=Se(e);L=t(L),C=t(C),W=t(W);for(let n of Ee)n.forComparison=t(n.forComparison),n.forDirty=t(n.forDirty)}catch(t){console.error("style adoption failed",t)}finally{ee--,vt.shift()}}var ye=e=>e.replace(/&/g,"&").replace(/"/g,""");function jn(e){if(e.name!==void 0){let n=[`data-name="${ye(e.name)}"`];return e.legacyId!==void 0&&n.push(`id="${ye(e.legacyId)}"`),n}let t=[ye(e.href)];try{let{pathname:n}=new URL(e.href);n&&t.push(ye(n))}catch{}return t}function Jn(e){let t=[L,C,W];for(let n of Ee)t.push(n.forComparison,n.forDirty);return t.some(n=>n&&e.some(o=>o&&n.includes(o)))}function Zn(e,t){let n=[];for(let{markers:i,tag:a}of t)for(let f of i)for(let u=e.indexOf(f);u>=0;u=e.indexOf(f,u+f.length)){let m=e.lastIndexOf("<",u);if(m<0||e.slice(m+1,m+1+a.length).toLowerCase()!==a)continue;let c=a==="style"?e.indexOf("</style",u):u;if(c<0)continue;let p=e.indexOf(">",c);p>=0&&n.push([m,p+1])}n.sort((i,a)=>i[0]-a[0]);let o="",r=0;for(let[i,a]of n)i<r||(o+=e.slice(r,i),r=a);return o+e.slice(r)}Kt(e=>{let t=jn(e);Jn(t)&&(ee||(mt=!1),ee++,vt.push({markers:t,tag:e.name!==void 0?"style":"link"}),ce=ce.then(()=>Xn(e)))});function Jr(){return ce}function gt(e){return!ee||mt||F()||P()||D||k||te||typeof e!="string"?!1:e===Zn(C,vt)}var er=500,tr=3e3,nr=1e4,Ze=null;function rr(){pe.holdSettle=!1,Ze&&Ze()}function nn(){if(!w)return;let e=!1,t=null,{forComparison:n,forDirty:o}=me();ue(n,o);let r=ie;W=n,re("immediate capture",`${n.length} chars`);let i=["keydown","pointerdown","drop","input","change","paste"],a=new Set(["Shift","Control","Alt","Meta"]),f=c=>{c.type==="keydown"&&a.has(c.key)||(mt=!0,e||(Ke=!0))};i.forEach(c=>document.addEventListener(c,f,!0));let u=()=>{if(!e){if(e=!0,t&&t(),!Ke&&ie===r){let c=b(),{forComparison:p,forDirty:S}=me();ue(p,S),W=p,N(c),re("settled capture",`${p.length} chars`)}else re("settled skipped",Ke?"user edited":"save occurred during settle");Z=!1,document.documentElement.setAttribute("savestatus","saved"),pt=!0,document.dispatchEvent(new CustomEvent("clay:baseline-settled"))}};Ze=u;let m=()=>{pe.holdSettle||u()};t=Pt.onAnyChange({debounce:er,omitChangeDetails:!0,require:"autosave"},m),setTimeout(()=>{e||m()},tr),setTimeout(()=>{!e&&pe.holdSettle&&rr()},nr)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",nn):nn();function ke(e=()=>{}){if(!w){let t=h("Not in edit mode");return e(t),Promise.resolve(t)}if(O>0){Ce=!0;let t=h(it());return e(t),Promise.resolve(t)}if(!de()){ae=!0;let t=at("Save session is quiesced");return e(t),Promise.resolve(t)}if(B>0){$e=!0;let t=h("Autosave suspended");return e(t),Promise.resolve(t)}if(!Z&&we){k=!0;let t=h("Save already in progress");return e(t),Promise.resolve(t)}return Bn(e).catch(t=>{let n={ok:!1,msg:t?.message||"Save failed",msgType:"error",code:null,etag:null};return A("error",n.msg),n})}var et=Xt({now:G,run:()=>ke()});function vn(){document.addEventListener("keydown",function(e){if((window.navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)&&e.keyCode==83){if(!w)return;e.preventDefault(),e.isTrusted&&Ie(),I()}})}function gn(){document.addEventListener("click",e=>{e.target.closest("[trigger-save]")&&(e.isTrusted&&Ie(),I())})}function or(){w&&(Ue(),Ot(),Oe(),vn(),gn())}or();var Zr=I;var Le=!1;function ao({isCurrent:e,reload:t}){return e()?(Le=!0,setTimeout(()=>{Le=!1},1e3),t(),!0):!1}zt();function sr(){return rt()?!0:w?F()?!0:K?Tt():window.clay?.demo?!1:tt():!1}function tt(){if(!w)return!1;try{let e=V();return gt(e)?!1:e!==ft()}catch{return!0}}window.addEventListener("beforeunload",e=>{if(!w&&!rt())return;if(Le){Le=!1;return}if(!((!K||At())&&!sr())&&(e.preventDefault(),e.returnValue="",!window.clay?.demo&&!F()))try{let n=V(),o=ft();n!==o&&Yt(n,o)}catch{}});export{ao as a,sr as b,tt as c,En as d,rn as e,wn as f,de as g,rt as h,Tn as i,Ir as j,Rr as k,br as l,Nr as m,Fr as n,Ur as o,it as p,je as q,qr as r,Br as s,Hr as t,_n as u,Dn as v,Gr as w,Wr as x,Kr as y,ft as z,Qr as A,ue as B,Vr as C,I as D,j as E,$r as F,Yr as G,zr as H,Xr as I,dn as J,Yn as K,jr as L,Jr as M,gt as N,rr as O,ke as P,et as Q,vn as R,gn as S,or as T,Zr as U};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as u}from"./c-VJYEVRYK.js";import{B as M}from"./c-
|
|
1
|
+
import{a as u}from"./c-VJYEVRYK.js";import{B as M}from"./c-44B5ODN7.js";import{b,d as x,m as v}from"./c-QIXT3Q7C.js";import"./c-VHNSBD2M.js";var{Plugin:R}=b,{Decoration:D}=x;var O=[["","Plain text"],["javascript","JavaScript"],["typescript","TypeScript"],["jsx","JSX"],["tsx","TSX"],["json","JSON"],["html","HTML"],["css","CSS"],["python","Python"],["shellscript","Shell"],["sql","SQL"],["go","Go"],["rust","Rust"],["java","Java"],["c","C"],["cpp","C++"],["csharp","C#"],["ruby","Ruby"],["php","PHP"],["yaml","YAML"],["markdown","Markdown"],["diff","Diff"],["swift","Swift"],["kotlin","Kotlin"],["xml","XML"]],L=new Set(O.map(([s])=>s)),T={js:"javascript",mjs:"javascript",ts:"typescript",py:"python",sh:"shellscript",bash:"shellscript",shell:"shellscript",zsh:"shellscript",rb:"ruby",yml:"yaml",md:"markdown",htm:"html",golang:"go",rs:"rust","c++":"cpp",cs:"csharp","c#":"csharp",kt:"kotlin"},m=s=>{let t=String(s??"").trim().toLowerCase(),e=T[t]??t;return L.has(e)?e:""},n=s=>({color:s}),C={name:"page",appearance:"light",cssVariables:{prefix:"--page-code-token-"},style:{syntax:{comment:n("comment"),keyword:n("keyword"),operator:n("keyword"),preproc:n("keyword"),"punctuation.special":n("keyword"),string:n("string-expression"),"string.escape":n("constant"),"string.regex":n("constant"),"string.special":n("constant"),number:n("constant"),boolean:n("constant"),constant:n("constant"),type:n("constant"),property:n("constant"),enum:n("constant"),variant:n("constant"),namespace:n("constant"),label:n("constant"),function:n("function"),constructor:n("function"),selector:n("function"),attribute:n("function"),"variable.parameter":n("parameter"),tag:n("string-expression"),link_uri:n("link"),link_text:n("link"),"diff.plus":n("string-expression"),"diff.minus":n("keyword"),title:{font_weight:700},emphasis:{font_style:"italic"},"emphasis.strong":{font_weight:700}}}},E=null;async function P(s,t){E??=import("./c-3OWDMNJR.js");let{codeToTokens:e}=await E;return e(s,{lang:t,theme:C}).tokens}var _="var(--page-code-token-foreground)",A=s=>{let t=[];return s.color&&s.color!==_&&t.push(`color: ${s.color}`),s.fontStyle&1&&t.push("font-style: italic"),s.fontStyle&2&&t.push("font-weight: 600"),s.fontStyle&4&&t.push("text-decoration: underline"),t.join("; ")},H=200,y=class{constructor(t,e,i){this.view=t,this.run=e,this.delay=i,this.cache=new Map,this.pending=new Set,this.visible=new Set,this.targets=new Map,this.timer=0;let c=t.dom.ownerDocument.defaultView.IntersectionObserver;this.io=c?new c(a=>{for(let o of a){let r=o.target.dataset.id;this.targets.get(r)===o.target&&this.visible[o.isIntersecting?"add":"delete"](r)}this.schedule(0)},{rootMargin:"200px 0px"}):null,this.schedule(0)}update(t,e){(!e||t.state.doc!==e.doc)&&this.schedule(this.delay)}schedule(t){clearTimeout(this.timer),this.timer=setTimeout(()=>this.pass(),t)}pass(){let{view:t}=this;if(t.isDestroyed)return;let e=[],i=new Map,c=u.getState(t.state);t.state.doc.forEach((o,r)=>{if(o.type!==v.nodes.code_block)return;let p=o.attrs.id,d=t.nodeDOM(r);d&&i.set(p,d);let g=m(o.attrs.lang);if(!g)return;let k=o.textContent,l=`${g}
|
|
2
2
|
${k}`,w=this.cache.get(l);if(w)for(let h of w){let S=A(h);S&&h.content&&e.push(D.inline(r+1+h.offset,r+1+h.offset+h.content.length,{style:S}))}else{if(e.push(...c.find(r,r+o.nodeSize)),this.io&&!this.visible.has(p)||this.pending.has(l))return;this.pending.add(l),this.run(k,g).then(h=>h.flat(),()=>[]).then(h=>{this.pending.delete(l),this.cache.set(l,h),this.cache.size>H&&this.cache.delete(this.cache.keys().next().value),this.schedule(0)})}}),this.track(i);let a=o=>o.map(r=>`${r.from}:${r.to}:${r.type.attrs.style}`).join("|");a(e)!==a(u.getState(t.state).find())&&t.dispatch(t.state.tr.setMeta(u,e).setMeta("addToHistory",!1))}track(t){if(this.io){for(let[e,i]of this.targets)t.get(e)!==i&&(this.io.unobserve(i),this.targets.delete(e),this.visible.delete(e));for(let[e,i]of t)this.targets.get(e)!==i&&(this.targets.set(e,i),this.io.observe(i))}}destroy(){clearTimeout(this.timer),this.io?.disconnect()}};function j(s,{tokenize:t=P,delay:e=300}={}){let i=new y(s,t,e),c=s.dispatch.bind(s),a=s.state.doc,o=p=>{if(c(p),s.state.doc===a)return;let d={doc:a};a=s.state.doc,i.update(s,d)};s.dispatch=o;let r=i.destroy.bind(i);return i.destroy=()=>{s.dispatch===o&&(s.dispatch=c),r()},i}var f=class{constructor(t,e,i){this.node=t,this.view=e,this.getPos=i;let c=e.dom.ownerDocument;this.dom=c.createElement("pre"),this.contentDOM=c.createElement("code"),this.select=c.createElement("select"),this.select.className="page-code-lang",this.select.contentEditable="false",this.select.setAttribute("aria-label","Code language");for(let[a,o]of O)this.select.append(new Option(o,a));this.select.addEventListener("change",()=>this.setLang(this.select.value)),this.dom.append(this.select,this.contentDOM),this.render(t)}render(t){this.node=t,this.dom.dataset.id=t.attrs.id??"";let e=m(t.attrs.lang);e?this.dom.dataset.lang=e:delete this.dom.dataset.lang,this.select.value=e}setLang(t){let e=this.getPos();e==null||t===m(this.node.attrs.lang)||(this.view.dispatch(M(this.view.state.tr.setNodeMarkup(e,null,{...this.node.attrs,lang:t}))),this.view.focus())}update(t){return t.type!==this.node.type?!1:(this.render(t),!0)}stopEvent(t){return this.select.contains(t.target)}ignoreMutation(t){return t.type!=="selection"&&this.select.contains(t.target)}};function X({view:s=null,highlight:t={}}={}){let e=s?j(s,t):null;return{id:"code",nodeViews:{code_block:(i,c,a)=>new f(i,c,a)},css:null,dispose(){e?.destroy()}}}export{X as createFeature};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as d}from"./c-CSNE5EIF.js";import"./c-PZ4XEPUP.js";import"./c-SFKI6OLM.js";import"./c-Q3XOWZEV.js";import{g as m,l as v,n as x,q as s}from"./c-BJ7YQ5QZ.js";import{a as p}from"./c-4JZDZFF6.js";import{e as f}from"./c-VAK7SG37.js";import{b as w}from"./c-MHI3GYKF.js";import"./c-RHMPKZZ7.js";import{b as c}from"./c-NUHP2XDB.js";import{f as l}from"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-EGTIAL6P.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var $="Download a copy, then reduce its size; saving still works.",b="Download a copy to keep your work.",t=null,r=null,i=null,a=null;function h(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 y({bytes:e,maxBytes:n,state:S}){let u=`At the last save attempt: ${h(e)} of ${h(n)}.`;return S==="over"?`This host can't save a file this size. ${u} ${b}`:`This file is getting large. ${u} ${$}`}function o(){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))`)}async function z(){await d({})}function A(){t=v("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:${p()}`]),t.setAttribute("clay","editor-ui"),t.setAttribute("data-clay-save-size",""),t.setAttribute("role","status"),r=x("span",[],""),i=m("Download my copy",{small:!0,onClick:z}),s(i,!1,"inline-flex"),t.append(r,i),document.body.appendChild(t),o(),window.visualViewport?.addEventListener("resize",o),window.visualViewport?.addEventListener("scroll",o)}function M(e){t||A(),r.textContent=y(e),s(i,e.state==="over","inline-flex"),o(),w(t,{background:f.surface})}function E(){t&&(window.visualViewport?.removeEventListener("resize",o),window.visualViewport?.removeEventListener("scroll",o),t.remove(),t=null,r=null,i=null)}function g(e){let n=e?.detail;n&&(n.state==="near"||n.state==="over"?M(n):E())}function k(){l||L()}function N(e){l&&(a||=new AbortController,document.addEventListener("clay:save-size",g,{signal:a.signal}),document.addEventListener("clay:modechange",k,{signal:a.signal}),e?.type==="clay:save-size"&&g(e))}function L(){a?.abort(),a=null,E()}export{N as start,L as stop};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{g as p}from"./c-
|
|
1
|
+
import{g as p}from"./c-ICMAOOGK.js";var h=`:host { all: initial !important; display: contents !important; }
|
|
2
2
|
:host([hidden]) { display: none !important; }
|
|
3
3
|
@media print { :host { display: none !important; } }`,l=new WeakMap,u=new WeakSet,m=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);function S(e){if(e.ctrlKey||e.metaKey||e.altKey||e.key?.length!==1&&!m.has(e.key))return;let t=e.composedPath()[0];!t?.matches?.("input, textarea, select")&&!t?.isContentEditable||t.getRootNode().host?.localName==="clay-editor-ui"&&e.stopPropagation()}function w(e){if(!(!e||u.has(e))){u.add(e);for(let t of["keydown","keypress","keyup"])e.addEventListener(t,S,!0)}}function g(e,t){return"adoptedStyleSheets"in t&&typeof e.defaultView?.CSSStyleSheet?.prototype?.replaceSync=="function"}function k(e,t){let r=l.get(e);r||l.set(e,r=new Map);let o=r.get(t);return o||(o=new e.defaultView.CSSStyleSheet,o.replaceSync(t),r.set(t,o)),o}function A({name:e,content:t,css:r=[],parent:o=document.body,before:y=null,attributes:f={}}){let a=o.ownerDocument,n=a.createElement("clay-editor-ui");n.setAttribute("data-clay-ui",e),p(n,"editor-ui");for(let[i,d]of Object.entries(f))n.setAttribute(i,d);p(t,"editor-ui");let s=n.attachShadow({mode:"open"}),c=[h,...r];if(g(a,s))s.adoptedStyleSheets=c.map(i=>k(a,i));else for(let i of c){let d=a.createElement("style");d.textContent=i,s.append(d)}return s.append(t),w(a.defaultView),o.insertBefore(n,y),{host:n,shadow:s,content:t,remove:()=>n.remove()}}export{h as a,A as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as L}from"./c-
|
|
1
|
+
import{b as L}from"./c-QY7F6EN6.js";import{f as b,g as h,j as p,l as E,n as m}from"./c-BJ7YQ5QZ.js";import{e as i,f as d,g as x}from"./c-VAK7SG37.js";import{b as w}from"./c-MHI3GYKF.js";import{b as o}from"./c-NUHP2XDB.js";var g={success:{edge:i.teal,icon:d.toastSuccess},error:{edge:i.ox,icon:d.toastWarning},warning:{edge:i.brass,icon:d.toastWarning},info:{edge:i.brass,icon:d.toastInfo}},M=d.toastClose,P=["opacity:0","transform:translateX(24px)"];function $(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches?"none":"opacity .5s ease-in-out, transform .5s ease-in-out"}function A(){let e=document.querySelector('clay-editor-ui[data-clay-ui="toasts"]')?.shadowRoot.querySelector("[data-clay-toasts]");if(e)return e;let t=p("div",["position:fixed","top:18px","right:18px","z-index:9999","display:flex","flex-direction:column","align-items:flex-end","gap:10px","width:min(330px, calc(100vw - 36px))","pointer-events:none"]);return t.setAttribute("data-clay-toasts",""),t.setAttribute("aria-live","polite"),L({name:"toasts",content:t}),t}function k(e,t,{detail:n="",actions:r=[]}={}){let c=g[t],s=E("div",["display:flex","align-items:flex-start",...x.toast,"width:100%",`border-inline-start:3px solid ${c.edge}`,"cursor:pointer","pointer-events:auto",...P,`transition:${$()}`]);s.setAttribute("data-clay-toast",t);let l=p("div",["flex:1 1 auto","min-width:0","display:flex","flex-direction:column","gap:8px"]),f=p("div",["display:flex","align-items:flex-start","gap:8px"]),v=m("span",["display:inline-grid","flex:none","padding-top:1px",`color:${c.edge}`]);v.innerHTML=c.icon,b(v.firstElementChild,16);let T=m("span",["flex:1 1 auto","min-width:120px",...x.toastTitle,"overflow-wrap:anywhere"],e);if(f.append(v,T),l.append(f),n&&l.append(m("span",["display:block",`color:${i.muted}`,"overflow-wrap:anywhere"],n)),r.length){let y=p("div",["display:flex","flex-wrap:wrap","gap:8px"]);for(let{label:C,onClick:I}of r)y.append(h(C,{small:!0,variant:"quiet",onClick:I}));l.append(y)}return s.append(l),s}function D(e){let t=p("button",["flex:none","display:inline-grid","place-items:center",...x.toastClose,"cursor:pointer"]);t.type="button",t.setAttribute("aria-label","Dismiss"),t.title="Dismiss",t.innerHTML=M,b(t.firstElementChild,14);let n=r=>{o(t,"color",r?i.ink:i.muted),o(t,"background",r?i.sunk:"transparent")};return t.addEventListener("pointerenter",()=>n(!0)),t.addEventListener("pointerleave",()=>n(!1)),t.addEventListener("focus",()=>{n(!0),o(t,"outline",`2px solid ${i.brass}`),o(t,"outline-offset","1px")}),t.addEventListener("blur",()=>{n(!1),o(t,"outline","none")}),t.addEventListener("click",e),t}function S(e){A().append(e),w(e,{background:i.surface}),setTimeout(()=>{o(e,"opacity","1"),o(e,"transform","none")},10)}function u(e,t){o(e,"opacity","0"),o(e,"transform","translateX(24px)"),setTimeout(()=>{e.remove(),t?.()},500)}function H(e,t="success"){let n=k(e,g[t]?t:"success");n.addEventListener("click",()=>u(n)),S(n),setTimeout(()=>u(n),6600)}var a=new Map;function R(e,t="warning",{detail:n="",actions:r=[]}={}){let c=a.get(e);c&&(u(c),a.delete(e));let s=k(e,g[t]?t:"warning",{detail:n,actions:r});o(s,"cursor","default");let l=D(f=>{f.stopPropagation(),u(s,()=>{a.get(e)===s&&a.delete(e)})});s.append(l),a.set(e,s),S(s)}function U(e,{now:t=!1}={}){let n=a.get(e);if(n){if(a.delete(e),t){n.remove();return}u(n)}}var W=H;export{R as a,U as b,W as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=["text/html","application/xhtml+xml"];function i(t){return typeof t!="string"?!1:c.includes(t.split(";")[0].trim().toLowerCase())}function s(t=location.pathname){let o=t.split("/").filter(Boolean).pop();if(!o)return t.endsWith("/")||t===""?"index":"page";let n=o;try{n=decodeURIComponent(o)}catch{}return n.replace(/\.(html?|htmlclay)$/i,"")||"page"}async function d({html:t,name:o,type:n="text/html"}){let r=null;try{let l=t;if(i(n)&&typeof t=="string"&&/clay|data-paid-only/i.test(t)){let{stripCopyContent:a}=await import("./c-C4IIQZGJ.js");l=a(t)}r=URL.createObjectURL(new Blob([l],{type:n}));let e=document.createElement("a");return e.setAttribute("clay","no-save no-watch no-snapshot"),e.href=r,e.download=o,e.style.setProperty("display","none","important"),document.body.appendChild(e),e.click(),e.remove(),setTimeout(()=>URL.revokeObjectURL(r),4e4),!0}catch(l){return console.error("clayjs: could not build the download",l),r&&URL.revokeObjectURL(r),!1}}export{s as a,d as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as O}from"./c-
|
|
1
|
+
import{a as O}from"./c-WN3MXOLT.js";import{d as A}from"./c-XGH4GS2T.js";var p=1,D=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 u(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)||!u(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(!u(t))return null;return{kind:"blocks",ids:[...e.ids]}}return e.kind==="cell"?!d(e,J)||!u(e.block)||!u(e.row)||!u(e.col)?null:{kind:"cell",block:e.block,row:e.row,col:e.col}:null}function w(e){return T(JSON.stringify(e))<=D}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(!u(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"?O.test(e)?a(e):o("path"):g(e)?e.kind==="record"?ee(e):e.kind==="page"?te(e):o("kind"):o("shape")}function R(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 z(e){return e==null?"":typeof e=="string"?`path:${e}`:`target:${JSON.stringify(e)}`}function C(e,t=null){let n=Array.isArray(e)?e:[],s=[];for(let i of n){if(!g(i))continue;let r=u(i.id)?i.id:null;if(!r)continue;let h=Number.isSafeInteger(i.n)&&i.n>=0?i.n:0,c=t&&t.get(r);if(c&&h<c.n){s.push(c);continue}let f=y(i.editing===void 0?null:i.editing);s.push({id:r,you:i.you===!0,n:h,editing:f.ok?f.target:null})}return s}function I(e){if(!g(e))return null;let t=u(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,this.inflightOwner=null,this.inflightKey=null}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,h=s===!0;return i===this.supported&&r===this.recordAwareness&&h===this.pageAwareness?this.snapshot:(this.supported=i,this.recordAwareness=r,this.pageAwareness=h,this.emit())}receive(t){let n=t&&typeof t=="object"?t:{},s=Array.isArray(n.people)?n.people:[],i=this.sessions,r=new Map,h=[];for(let l of s){if(!l||typeof l.id!="string"||!l.id)continue;let P=typeof l.name=="string"&&l.name.trim()?l.name.trim():"Someone",x=C(l.sessions,i);for(let K of x)r.set(K.id,K);let b={id:l.id,name:P,you:l.you===!0,editing:R(l.editing),sessions:x};typeof l.canEdit=="boolean"&&(b.canEdit=l.canEdit),h.push(b)}this.people=h,this.sessions=r;let c=n.anonymous;this.anonymous=typeof c=="number"&&Number.isFinite(c)&&c>0?Math.floor(c):0;let f=I(n.selfSession),M=!this.session||!this.session.token;f&&(this.session=f);let j=this.emit();return f&&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=z(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(){if(n.owner!==s)return;let i=n.heldKey===""&&typeof n.inflightKey=="string"&&n.inflightKey!=="";if(n.owner=null,n.session=null,n.n=0,n.sentKey=null,n.inflight=!1,n.inflightOwner=null,n.inflightKey=null,n.cancel(),n.target=null,n.heldKey="",n.explicit=!1,n.clear(),i)try{Promise.resolve(s.send({editing:null})).catch(()=>{})}catch{}}};return this.owner=s,this.session=null,this.n=0,this.sentKey=null,this.inflight=!1,this.inflightOwner=null,this.inflightKey=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-62HZW5DH.js").then(({localPresence:h})=>{let c=h({scope:r,store:this}),f=c.start();return f?Object.defineProperty(f,"stop",{value:()=>c.stop()}):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,this.inflightOwner=t,this.inflightKey=this.sentKey,s.v===p&&(this.n=n);let i=r=>{if(this.inflightOwner===t&&(this.inflight=!1,this.inflightOwner=null,this.inflightKey=null,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))}},k=new S,ce=k;if(typeof window<"u"&&(window.clay=window.clay||{},!window.clay.presence)){window.clay.presence=k;try{document.dispatchEvent(new CustomEvent("clay:presence-ready",{detail:{presence:k}}))}catch{}}export{p as a,E as b,ie as c,y as d,S as e,k as f,ce as g};
|
|
@@ -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-LA2BW7UY.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};
|