@panphora/clayjs 1.18.1 → 1.19.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.
Files changed (80) hide show
  1. package/README.md +1 -1
  2. package/dist/all.js +1 -1
  3. package/dist/clay-dom.js +1 -1
  4. package/dist/clay-events.js +1 -1
  5. package/dist/clay-internals.js +1 -1
  6. package/dist/clay-options.js +1 -1
  7. package/dist/clay-router.js +1 -1
  8. package/dist/clay-ui.js +1 -1
  9. package/dist/clay-utils.js +1 -1
  10. package/dist/clay.js +1 -1
  11. package/dist/clay.standalone.js +618 -399
  12. package/dist/m/{c-6DB2OLRJ.js → c-2RARVIAK.js} +1 -1
  13. package/dist/m/{c-UORXLSD3.js → c-2Y4DOHSY.js} +1 -1
  14. package/dist/m/{c-4TXNLX4K.js → c-4FJTBE6I.js} +3 -3
  15. package/dist/m/{c-6UGWFMQC.js → c-7PYNAULW.js} +1 -1
  16. package/dist/m/{c-AMU3BPPR.js → c-AIWN4QN4.js} +2 -2
  17. package/dist/m/{c-COPTL5WB.js → c-AXGY2WTB.js} +1 -1
  18. package/dist/m/{c-IMZCWYHR.js → c-BAUBNYXK.js} +1 -1
  19. package/dist/m/{c-MWXFLW4J.js → c-CQQDL6O4.js} +1 -1
  20. package/dist/m/{c-KP64LT2A.js → c-DHUCEMXE.js} +1 -1
  21. package/dist/m/{c-VILENZTD.js → c-EXEDYU4H.js} +1 -1
  22. package/dist/m/{c-2GRUM77Q.js → c-F6G2OGYG.js} +2 -2
  23. package/dist/m/{c-SPZPGD3R.js → c-FCNAO2MI.js} +1 -1
  24. package/dist/m/{c-372N6H3B.js → c-FOOE4GML.js} +1 -1
  25. package/dist/m/{c-AMYEFA2E.js → c-FTQKI7SP.js} +1 -1
  26. package/dist/m/{c-URSMSFCB.js → c-GWNC3UGL.js} +1 -1
  27. package/dist/m/{c-BUAYFEV5.js → c-HUISJXHF.js} +1 -1
  28. package/dist/m/{c-K3ADYNLU.js → c-HXPHZN7Q.js} +1 -1
  29. package/dist/m/{c-OTMKN2OO.js → c-I4MQHOEY.js} +1 -1
  30. package/dist/m/{c-HHGJBU4D.js → c-JCP3XDSJ.js} +1 -1
  31. package/dist/m/{c-JNLX3RJB.js → c-JDARJDOT.js} +1 -1
  32. package/dist/m/{c-TTB5EK4S.js → c-JK3PHE7J.js} +1 -1
  33. package/dist/m/{c-B5UJQT7W.js → c-K72SY2TL.js} +1 -1
  34. package/dist/m/{c-5ONTYIUI.js → c-L6FLIUXP.js} +1 -1
  35. package/dist/m/{c-5OOVFCJM.js → c-LACAAQFB.js} +1 -1
  36. package/dist/m/{c-U7SHNWDH.js → c-LPCZOYTX.js} +1 -1
  37. package/dist/m/{c-X5TSXZYJ.js → c-MIKZEG5I.js} +1 -1
  38. package/dist/m/{c-EVYAISP3.js → c-MMXKAX2W.js} +1 -1
  39. package/dist/m/{c-PLN76GF3.js → c-O4JMKN6U.js} +2 -2
  40. package/dist/m/{c-RND3G2S2.js → c-P3CK66NT.js} +1 -1
  41. package/dist/m/{c-YBKHUAK7.js → c-QINHDETP.js} +1 -1
  42. package/dist/m/{c-OPLUZR3A.js → c-RRZJWFLE.js} +1 -1
  43. package/dist/m/{c-HMV6P4RX.js → c-UXFUJEZO.js} +1 -1
  44. package/dist/m/{c-SW4YEG2D.js → c-V52FE5FI.js} +1 -1
  45. package/dist/m/{c-D5IKEKXW.js → c-VE7RKNKZ.js} +1 -1
  46. package/dist/m/{c-CCQ25GFY.js → c-WKNRJX3C.js} +1 -1
  47. package/dist/m/{c-C6IPRG34.js → c-XSZKP646.js} +1 -1
  48. package/dist/m/{c-ZK4GIZH2.js → c-ZGDYHKG3.js} +1 -1
  49. package/dist/m/{c-T637T7SN.js → c-ZKNBMNN3.js} +1 -1
  50. package/dist/m/{c-W6DQSHXI.js → c-ZRUQ5FSU.js} +1 -1
  51. package/dist/m/{c-4YU3BR4D.js → c-ZS4US2XV.js} +1 -1
  52. package/dist/m/core/{autosave-S6OMNDCK.js → autosave-RVJPYLRT.js} +1 -1
  53. package/dist/m/core/{conflict-notice-IWHMHH43.js → conflict-notice-2WGT52LH.js} +1 -1
  54. package/dist/m/core/{recovery-DRFZRJED.js → recovery-ZOUOJVIX.js} +1 -1
  55. package/dist/m/core/{save-LYY7K6U7.js → save-A5JXV6ME.js} +1 -1
  56. package/dist/m/core/{unsaved-warning-7QTKEN7Z.js → unsaved-warning-4ZPEV7BF.js} +1 -1
  57. package/dist/m/loader-34YPFKOH.js +1 -0
  58. package/dist/m/manifest-0D166F4F.js +1 -0
  59. package/dist/m/manifest-edit-3877153E.js +1 -0
  60. package/dist/m/manifest.json +566 -555
  61. package/dist/m/page/{editor-6LRB3GE4.js → editor-WRQGHDSG.js} +2 -2
  62. package/dist/m/plugins/{ai-edit-UTV7YO2I.js → ai-edit-X2L2KIEP.js} +1 -1
  63. package/dist/m/plugins/like-EV7MTZ56.js +1 -0
  64. package/dist/m/plugins/{live-AD4H6XSL.js → live-7C36XEI2.js} +1 -1
  65. package/dist/m/plugins/{menu-M5WW7DBF.js → menu-MFC4DI5E.js} +1 -1
  66. package/dist/m/plugins/{page-MD3T2ZX3.js → page-BSW6MGDO.js} +2 -2
  67. package/dist/m/plugins/{page-view-PAWVZNFY.js → page-view-WFZVTPQK.js} +1 -1
  68. package/dist/m/plugins/{wire-VBWXEXU2.js → wire-6OSIL3I7.js} +1 -1
  69. package/dist/m/{reader-core-4W2KYEWQ.js → reader-core-PLZYLYLT.js} +2 -2
  70. package/dist/m/sync/{live-sync-MO5DH33W.js → live-sync-UXNI6ZF6.js} +1 -1
  71. package/dist/offline-manifest.json +312 -300
  72. package/docs/guide.md +1 -0
  73. package/package.json +2 -1
  74. package/src/loader-logic.js +5 -1
  75. package/src/loader.js +2 -0
  76. package/src/plugins/like.js +254 -0
  77. package/dist/m/loader-3BBNZZGM.js +0 -1
  78. package/dist/m/manifest-26C55578.js +0 -1
  79. package/dist/m/manifest-edit-4396A009.js +0 -1
  80. /package/dist/m/{c-X5LNHET5.js → c-5JLFROUB.js} +0 -0
@@ -1,2 +1,2 @@
1
- import{a as E,b as S,c as P}from"./c-KBS3UV6B.js";import{i as A,j as q}from"./c-4TXNLX4K.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-MWXFLW4J.js";import"./c-ZK4GIZH2.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as T}from"./c-AMU3BPPR.js";import{b as k,m as x}from"./c-QIXT3Q7C.js";import"./c-WCXLG3MV.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var R=/^[A-Za-z0-9_-]{8,64}$/,D="@",F=100;function _({view:o=null}={}){if(!o)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let f=o.dom.ownerDocument,y=()=>globalThis.clay?.people??null,l=null;function d(t){let e=o.state;if(!e.selection.empty)return null;let r=e.selection.head;if(r<=t.from||r-t.from>F+1||r>e.doc.content.size)return null;let n=e.doc.resolve(t.from);return!n.parent.isTextblock||n.parent.type.spec.code||r>n.end()||r<n.start()||n.parentOffset&&!/\s/.test(e.doc.textBetween(t.from-1,t.from,"",`
1
+ import{a as E,b as S,c as P}from"./c-KBS3UV6B.js";import{i as A,j as q}from"./c-4FJTBE6I.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-CQQDL6O4.js";import"./c-ZGDYHKG3.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as T}from"./c-AIWN4QN4.js";import{b as k,m as x}from"./c-QIXT3Q7C.js";import"./c-WCXLG3MV.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var R=/^[A-Za-z0-9_-]{8,64}$/,D="@",F=100;function _({view:o=null}={}){if(!o)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let f=o.dom.ownerDocument,y=()=>globalThis.clay?.people??null,l=null;function d(t){let e=o.state;if(!e.selection.empty)return null;let r=e.selection.head;if(r<=t.from||r-t.from>F+1||r>e.doc.content.size)return null;let n=e.doc.resolve(t.from);return!n.parent.isTextblock||n.parent.type.spec.code||r>n.end()||r<n.start()||n.parentOffset&&!/\s/.test(e.doc.textBetween(t.from-1,t.from,"",`
2
2
  `))||e.doc.textBetween(t.from,t.from+1)!==D?null:{head:r,query:e.doc.textBetween(t.from+1,r)}}function $(t){try{let e=o.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=o.coordsAtPos(t.from);return{x:Math.max(8,r.left-e.left),y:r.bottom+6-e.top}}catch{return null}}function h(t){let e=t.picker.activeId();e?o.dom.setAttribute("aria-activedescendant",e):o.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&o.dom.removeAttribute("aria-activedescendant")}function m(t){t.picker.show(S(E(t.saved,t.allowed),t.query),$(t)),h(t)}function i(){let t=l;if(t){l=null;for(let[e,r,n,s]of t.listen)e.removeEventListener(r,n,s);o.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&o.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function p(){let t=l;if(!t||o.composing)return;let e=d(t);if(!e)return i();t.query=e.query,m(t)}async function g(t){let e=l;if(!e)return{ok:!1,code:"not-editing"};let r=e.picker.personAt(t),n=d(e);if(!(r&&n&&n.query===e.query&&R.test(String(r.id??""))&&String(r.name??"").trim()))return i(),{ok:!1,code:r?"stale-target":"no-person"};let c=String(r.name).trim();return i(),A(o,()=>{let u=d(e);if(!u||u.query!==e.query)return{ok:!1,code:"stale-target"};let a=o.state.tr.insertText(c,e.from,u.head);return a.addMark(e.from,e.from+c.length,x.marks.mention.create({id:r.id})),a.insertText(" ",e.from+c.length),a.setSelection(k.TextSelection.create(a.doc,e.from+c.length+1)),o.dispatch(T(a)),o.focus(),{ok:!0,id:r.id,label:c}})}function B(t){let e=l;if(!e||q(t,o))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),e.picker.move(t.key==="ArrowDown"?1:-1),h(e)):t.key==="Enter"?(r(),g(e.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),i())}function I(t){let e=y()?.available;e&&Promise.resolve().then(()=>e()).then(r=>{l===t&&(t.allowed=Array.isArray(r)?r:null,m(t))}).catch(()=>{})}function M(t){i();let e=P({document:f,onPick:c=>g(c)}),r={from:t,picker:e,query:"",allowed:null,saved:[],listen:[]};try{r.saved=y()?.list?.()??[]}catch{r.saved=[]}l=r;let n=(c,u,a,b)=>{c.addEventListener(u,a,b),r.listen.push([c,u,a,b])};n(f,"keydown",c=>B(c),!0),n(o.dom,"input",()=>p()),n(o.dom,"keyup",()=>p()),n(o.dom,"compositionend",()=>p()),n(f,"mousedown",c=>{r.picker.el.contains(c.target)||i()},!0),(o.dom.parentElement??f.body).appendChild(e.el);let s=d(r);return s?(r.query=s.query,m(r),I(r),{ok:!0,picker:!0}):(i(),{ok:!1,code:"stale-target"})}return{async run(t={}){let e=Number.isInteger(t?.from)?t.from:null;if(e===null){let r=o.state,n=r.selection.$from;if(!r.selection.empty||!n.parent.isTextblock||n.parent.type.spec.code)return{ok:!1,code:"stale-target"};e=r.selection.from;let s=o.state.tr.insertText(D);s.setSelection(k.TextSelection.create(s.doc,e+1)),o.dispatch(s)}return M(e)},dispose(){i()}}}export{_ as createFeature};
@@ -1 +1 @@
1
- import{a as b,b as c,c as d,d as e,e as f}from"./c-SPZPGD3R.js";import{g as a}from"./c-4TXNLX4K.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-MWXFLW4J.js";import"./c-ZK4GIZH2.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-AMU3BPPR.js";import"./c-QIXT3Q7C.js";import"./c-WCXLG3MV.js";import"./c-57XDY6HC.js";import"./c-I2SCCUEW.js";import"./c-VHNSBD2M.js";export{e as ChartView,d as chartFromSlash,a as chartTables,b as insertChartAfterTable,f as refreshCharts,c as tableLabel};
1
+ import{a as b,b as c,c as d,d as e,e as f}from"./c-FCNAO2MI.js";import{g as a}from"./c-4FJTBE6I.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-CQQDL6O4.js";import"./c-ZGDYHKG3.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-AIWN4QN4.js";import"./c-QIXT3Q7C.js";import"./c-WCXLG3MV.js";import"./c-57XDY6HC.js";import"./c-I2SCCUEW.js";import"./c-VHNSBD2M.js";export{e as ChartView,d as chartFromSlash,a as chartTables,b as insertChartAfterTable,f as refreshCharts,c as tableLabel};
@@ -1,6 +1,6 @@
1
- import{c as E}from"./c-KBS3UV6B.js";import{i as x,j as I}from"./c-4TXNLX4K.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-MWXFLW4J.js";import"./c-ZK4GIZH2.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as C}from"./c-AMU3BPPR.js";import{G as b,J as A,m as f}from"./c-QIXT3Q7C.js";import"./c-WCXLG3MV.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var D=`
1
+ import{c as E}from"./c-KBS3UV6B.js";import{i as x,j as I}from"./c-4FJTBE6I.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-CQQDL6O4.js";import"./c-ZGDYHKG3.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as C}from"./c-AIWN4QN4.js";import{G as b,J as A,m as f}from"./c-QIXT3Q7C.js";import"./c-WCXLG3MV.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-HMV6P4RX.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};
6
+ `,v=null,P=()=>v??=import("./c-UXFUJEZO.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 u}from"./c-5ZQV7KC4.js";import"./c-N326R2JD.js";import{f as n}from"./c-TJAXGIRV.js";import{b as h,c as a}from"./c-BWFVSBDF.js";import{b as T,g as _}from"./c-IVMD3FEM.js";import{b as p}from"./c-TNEM3RNM.js";import{b}from"./c-PLP4JKFC.js";import"./c-Q26MME6N.js";import"./c-VKEDWYDF.js";import{A as v,B as g,J as k,L as E,P as w,q as f,r as m,x as y}from"./c-T637T7SN.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-FWKHM4E7.js";import"./c-X5LNHET5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-ZWIOJGMT.js";import"./c-B7J4K2AE.js";import"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import"./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"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var x=250,A=2e3,c=["focusin","focusout","selectionchange","clay:sync-applied","clay:workspace-background","clay:workspace-foreground"],S=t=>n.setGeneric(t),o=class{constructor({send:e=S,now:i=()=>Date.now()}){this.send=e,this.now=i,this.others=!1,this.background=!1,this.sent=null,this.lastAt=-1/0,this.timer=null,this.poked=null,this.inflight=!1,this.retry=null,this.stopped=!1,this._onEvent=s=>{s.type==="clay:workspace-background"&&(this.background=!0),s.type==="clay:workspace-foreground"&&(this.background=!1),this.poke()}}start(){this.stopped=!1;for(let e of c)document.addEventListener(e,this._onEvent)}resume(){this.stopped&&(this.start(),this.sent=null,this.schedule())}stop(){this.stopped=!0;for(let e of c)document.removeEventListener(e,this._onEvent);clearTimeout(this.timer),clearTimeout(this.poked),clearTimeout(this.retry),this.timer=null,this.poked=null,this.retry=null}roster(e){let s=(e&&Array.isArray(e.people)?e.people:[]).some(r=>r&&r.you!==!0);s!==this.others&&(this.others=s,this.schedule())}reconnected(){this.sent=null,this.schedule()}wanted(){return!this.others||this.background?null:a(h(document.activeElement))}poke(){this.poked===null&&(this.poked=setTimeout(()=>{this.poked=null,this.schedule()},0))}schedule(){if(this.stopped||this.timer!==null||this.inflight||this.wanted()===this.sent)return;let e=Math.max(0,this.lastAt+x-this.now());this.timer=setTimeout(()=>{this.timer=null,this.flush()},e)}flush(){if(this.inflight)return;let e=this.wanted();if(e===this.sent)return;this.sent=e,this.lastAt=this.now(),this.inflight=!0;let i=s=>{if(this.inflight=!1,!this.stopped){if(s)clearTimeout(this.retry),this.retry=null;else if(this.sent===e){this.sent=void 0,this.retry===null&&(this.retry=setTimeout(()=>{this.retry=null,this.schedule()},A));return}this.schedule()}};Promise.resolve(this.send(e)).then(s=>i(!!s),()=>i(!1))}};function P(t){let e=()=>(t._presenceQuiesced=!0,t._editing?.stop(),n.setGeneric(null),n.releaseTarget(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-quiesce")),t.lane==="live"&&t._morphInFlight?{ok:!1,code:"pending-input"}:{ok:!0}),i=()=>{t._presenceQuiesced=!1,t._editing?.resume(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))},s=()=>{t._presenceQuiesced=!1,t.stop(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))};return{id:"clay:sync",order:50,async prepare(r){if(await u(),r?.initial)return{quiesce:e,resume:i,dispose:s};let l=!1;return{quiesce:e,resume:i,enable(){let d=t.currentFile;t.stop(),t.start(d,{lane:"live"}),l=!0},dispose:()=>{t._presenceQuiesced=!1,l&&t.stop(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))}}}}}export{o as EditingSender,k as baselineSettled,m as conflictResolvedBySync,_ as enableAdminInputs,p as enableAdminResources,b as enableContentEditable,T as enableOnClick,v as getLastSavedBytes,f as isSaveConflicted,w as savePageThrottled,E as schedulePaintHeal,g as setLastSavedBaselines,y as setUnsavedChanges,P as syncParticipant};
1
+ import{f as n}from"./c-TJAXGIRV.js";import{b as h,c as a}from"./c-BWFVSBDF.js";import{a as u}from"./c-5ZQV7KC4.js";import"./c-N326R2JD.js";import{b as T,g as _}from"./c-IVMD3FEM.js";import{b as p}from"./c-TNEM3RNM.js";import{b}from"./c-PLP4JKFC.js";import"./c-Q26MME6N.js";import"./c-VKEDWYDF.js";import{A as v,B as g,J as k,L as E,P as w,q as f,r as m,x as y}from"./c-ZKNBMNN3.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-FWKHM4E7.js";import"./c-5JLFROUB.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-ZWIOJGMT.js";import"./c-B7J4K2AE.js";import"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import"./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"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var x=250,A=2e3,c=["focusin","focusout","selectionchange","clay:sync-applied","clay:workspace-background","clay:workspace-foreground"],S=t=>n.setGeneric(t),o=class{constructor({send:e=S,now:i=()=>Date.now()}){this.send=e,this.now=i,this.others=!1,this.background=!1,this.sent=null,this.lastAt=-1/0,this.timer=null,this.poked=null,this.inflight=!1,this.retry=null,this.stopped=!1,this._onEvent=s=>{s.type==="clay:workspace-background"&&(this.background=!0),s.type==="clay:workspace-foreground"&&(this.background=!1),this.poke()}}start(){this.stopped=!1;for(let e of c)document.addEventListener(e,this._onEvent)}resume(){this.stopped&&(this.start(),this.sent=null,this.schedule())}stop(){this.stopped=!0;for(let e of c)document.removeEventListener(e,this._onEvent);clearTimeout(this.timer),clearTimeout(this.poked),clearTimeout(this.retry),this.timer=null,this.poked=null,this.retry=null}roster(e){let s=(e&&Array.isArray(e.people)?e.people:[]).some(r=>r&&r.you!==!0);s!==this.others&&(this.others=s,this.schedule())}reconnected(){this.sent=null,this.schedule()}wanted(){return!this.others||this.background?null:a(h(document.activeElement))}poke(){this.poked===null&&(this.poked=setTimeout(()=>{this.poked=null,this.schedule()},0))}schedule(){if(this.stopped||this.timer!==null||this.inflight||this.wanted()===this.sent)return;let e=Math.max(0,this.lastAt+x-this.now());this.timer=setTimeout(()=>{this.timer=null,this.flush()},e)}flush(){if(this.inflight)return;let e=this.wanted();if(e===this.sent)return;this.sent=e,this.lastAt=this.now(),this.inflight=!0;let i=s=>{if(this.inflight=!1,!this.stopped){if(s)clearTimeout(this.retry),this.retry=null;else if(this.sent===e){this.sent=void 0,this.retry===null&&(this.retry=setTimeout(()=>{this.retry=null,this.schedule()},A));return}this.schedule()}};Promise.resolve(this.send(e)).then(s=>i(!!s),()=>i(!1))}};function P(t){let e=()=>(t._presenceQuiesced=!0,t._editing?.stop(),n.setGeneric(null),n.releaseTarget(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-quiesce")),t.lane==="live"&&t._morphInFlight?{ok:!1,code:"pending-input"}:{ok:!0}),i=()=>{t._presenceQuiesced=!1,t._editing?.resume(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))},s=()=>{t._presenceQuiesced=!1,t.stop(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))};return{id:"clay:sync",order:50,async prepare(r){if(await u(),r?.initial)return{quiesce:e,resume:i,dispose:s};let l=!1;return{quiesce:e,resume:i,enable(){let d=t.currentFile;t.stop(),t.start(d,{lane:"live"}),l=!0},dispose:()=>{t._presenceQuiesced=!1,l&&t.stop(),typeof document<"u"&&document.dispatchEvent(new Event("clay:presence-resume"))}}}}}export{o as EditingSender,k as baselineSettled,m as conflictResolvedBySync,_ as enableAdminInputs,p as enableAdminResources,b as enableContentEditable,T as enableOnClick,v as getLastSavedBytes,f as isSaveConflicted,w as savePageThrottled,E as schedulePaintHeal,g as setLastSavedBaselines,y as setUnsavedChanges,P as syncParticipant};
@@ -1,4 +1,4 @@
1
- import{b as F,c as M}from"./c-MWXFLW4J.js";import{B as N,d as $}from"./c-AMU3BPPR.js";import{G as U,J as A,k as X,l as Y,m as w}from"./c-QIXT3Q7C.js";import{b as P}from"./c-L7JL5TL3.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var k=5;function v(n){let u=0;for(let s=0;s<n.childCount;s++){let i=n.child(s);if(i.type===w.nodes.heading&&i.attrs.level===1&&i.attrs.parent==null)return{index:s,at:u,node:i};u+=i.nodeSize}return null}var O=`
1
+ import{b as F,c as M}from"./c-CQQDL6O4.js";import{B as N,d as $}from"./c-AIWN4QN4.js";import{G as U,J as A,k as X,l as Y,m as w}from"./c-QIXT3Q7C.js";import{b as P}from"./c-L7JL5TL3.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var k=5;function v(n){let u=0;for(let s=0;s<n.childCount;s++){let i=n.child(s);if(i.type===w.nodes.heading&&i.attrs.level===1&&i.attrs.parent==null)return{index:s,at:u,node:i};u+=i.nodeSize}return null}var O=`
2
2
  :host{font:inherit !important;color:inherit !important}
3
3
  .page-cover-panel{display:flex;align-items:center;gap:8px;margin:8px 0;padding:6px 10px;border:1px solid var(--page-pop-line);border-radius:8px;background:var(--page-pop-bg);color:var(--page-pop-ink);box-shadow:var(--page-pop-shadow);font-size:.88em}
4
4
  .page-cover-msg{max-width:34ch}
@@ -1,2 +1,2 @@
1
- import{a as u}from"./c-VJYEVRYK.js";import{B as M}from"./c-AMU3BPPR.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}
1
+ import{a as u}from"./c-VJYEVRYK.js";import{B as M}from"./c-AIWN4QN4.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};
@@ -1 +1 @@
1
- import{c as A}from"./c-KBS3UV6B.js";import{j as b}from"./c-4TXNLX4K.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-MWXFLW4J.js";import"./c-ZK4GIZH2.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as x}from"./c-AMU3BPPR.js";import{b as h}from"./c-QIXT3Q7C.js";import"./c-WCXLG3MV.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";function S(o){let s=String(o??""),n=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter("en",{granularity:"grapheme"}):null;return n?[...n.segment(s)].map(a=>a.segment):[...s]}var I=o=>S(o).length===1&&!/^\s*$/.test(String(o??""));function L(o){let s=[];for(let[n,a]of Object.entries(o??{}))for(let u of Array.isArray(a)?a:[]){let[f,m,d=""]=u??[];typeof f!="string"||typeof m!="string"||s.push({id:`${n}:${m}`,char:f,name:`${f} ${m}`,keywords:`${m} ${d}`})}return s}var P=(o,s)=>{let n=String(s??"").trim().toLowerCase();return n?o.filter(a=>a.char===n||a.keywords.toLowerCase().includes(n)):o};function T(o=()=>import("./c-SZGYW5HT.js")){let s=null;return()=>(s??=Promise.resolve().then(()=>o()).then(n=>L(n.EMOJI)).catch(n=>{throw s=null,n}),s)}function w({view:o=null,load:s=()=>import("./c-SZGYW5HT.js")}={}){if(!o)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let n=o.dom.ownerDocument,a=T(s),u=null;function f(t){let e=o.state,r=e.selection;if(r.from!==t.from||r.to!==t.to||t.from<0||t.to>e.doc.content.size)return null;let c=e.doc.resolve(t.from),i=e.doc.resolve(t.to);return!c.parent.isTextblock||c.parent!==i.parent?null:{from:t.from,to:t.to}}function m(t){try{let e=o.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=o.coordsAtPos(t.from);return{x:Math.max(8,r.left-e.left),y:r.bottom+6-e.top}}catch{return null}}function d(t){let e=t.picker.activeId();e?o.dom.setAttribute("aria-activedescendant",e):o.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&o.dom.removeAttribute("aria-activedescendant")}function l(){let t=u;if(t){u=null;for(let[e,r,c,i]of t.listen)e.removeEventListener(r,c,i);o.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&o.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function j(t,e){let r=o.state.tr.insertText(e,t.from,t.to);return r.setSelection(h.TextSelection.create(r.doc,t.from+e.length)),o.dispatch(x(r)),o.focus(),{ok:!0,emoji:e}}function p(t){let e=u;if(!e)return{ok:!1,code:"not-editing"};let r=e.picker.personAt(t),c=f(e);return!r||c===null||!I(r.char)?(l(),r?c===null?{ok:!1,code:"stale-target"}:{ok:!1,code:"invalid-emoji"}:{ok:!1,code:"no-emoji"}):(l(),j(c,r.char))}function E(t){let e=u;if(!e||b(t,o))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),e.picker.move(t.key==="ArrowDown"?1:-1),d(e)):t.key==="Enter"?(r(),p(e.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),l())}async function $(t={}){l();let e={from:o.state.selection.from,to:o.state.selection.to,picker:null,listen:[]};e.picker=A({document:n,label:"Insert an emoji",empty:"No emoji found",onPick:i=>p(i)}),u=e;let r=(i,k,g,y)=>{i.addEventListener(k,g,y),e.listen.push([i,k,g,y])};r(n,"keydown",i=>E(i),!0),r(o.dom,"input",()=>l()),r(n,"mousedown",i=>{e.picker.el.contains(i.target)||l()},!0),(o.dom.parentElement??n.body).appendChild(e.picker.el);let c;try{c=await a()}catch(i){return l(),{ok:!1,code:"unavailable",error:i}}return u!==e?{ok:!1,code:"not-editing"}:f(e)===null?(l(),{ok:!1,code:"stale-target"}):(e.picker.show(P(c,t?.query),m(e)),d(e),{ok:!0,picker:!0})}return{async run(t){return $(t)},dispose(){l()}}}export{w as createFeature,L as emojiEntries,T as emojiLibrary,P as filterEmoji,S as graphemes,I as isEmojiText};
1
+ import{c as A}from"./c-KBS3UV6B.js";import{j as b}from"./c-4FJTBE6I.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-CQQDL6O4.js";import"./c-ZGDYHKG3.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as x}from"./c-AIWN4QN4.js";import{b as h}from"./c-QIXT3Q7C.js";import"./c-WCXLG3MV.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";function S(o){let s=String(o??""),n=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter("en",{granularity:"grapheme"}):null;return n?[...n.segment(s)].map(a=>a.segment):[...s]}var I=o=>S(o).length===1&&!/^\s*$/.test(String(o??""));function L(o){let s=[];for(let[n,a]of Object.entries(o??{}))for(let u of Array.isArray(a)?a:[]){let[f,m,d=""]=u??[];typeof f!="string"||typeof m!="string"||s.push({id:`${n}:${m}`,char:f,name:`${f} ${m}`,keywords:`${m} ${d}`})}return s}var P=(o,s)=>{let n=String(s??"").trim().toLowerCase();return n?o.filter(a=>a.char===n||a.keywords.toLowerCase().includes(n)):o};function T(o=()=>import("./c-SZGYW5HT.js")){let s=null;return()=>(s??=Promise.resolve().then(()=>o()).then(n=>L(n.EMOJI)).catch(n=>{throw s=null,n}),s)}function w({view:o=null,load:s=()=>import("./c-SZGYW5HT.js")}={}){if(!o)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let n=o.dom.ownerDocument,a=T(s),u=null;function f(t){let e=o.state,r=e.selection;if(r.from!==t.from||r.to!==t.to||t.from<0||t.to>e.doc.content.size)return null;let c=e.doc.resolve(t.from),i=e.doc.resolve(t.to);return!c.parent.isTextblock||c.parent!==i.parent?null:{from:t.from,to:t.to}}function m(t){try{let e=o.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=o.coordsAtPos(t.from);return{x:Math.max(8,r.left-e.left),y:r.bottom+6-e.top}}catch{return null}}function d(t){let e=t.picker.activeId();e?o.dom.setAttribute("aria-activedescendant",e):o.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&o.dom.removeAttribute("aria-activedescendant")}function l(){let t=u;if(t){u=null;for(let[e,r,c,i]of t.listen)e.removeEventListener(r,c,i);o.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&o.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function j(t,e){let r=o.state.tr.insertText(e,t.from,t.to);return r.setSelection(h.TextSelection.create(r.doc,t.from+e.length)),o.dispatch(x(r)),o.focus(),{ok:!0,emoji:e}}function p(t){let e=u;if(!e)return{ok:!1,code:"not-editing"};let r=e.picker.personAt(t),c=f(e);return!r||c===null||!I(r.char)?(l(),r?c===null?{ok:!1,code:"stale-target"}:{ok:!1,code:"invalid-emoji"}:{ok:!1,code:"no-emoji"}):(l(),j(c,r.char))}function E(t){let e=u;if(!e||b(t,o))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),e.picker.move(t.key==="ArrowDown"?1:-1),d(e)):t.key==="Enter"?(r(),p(e.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),l())}async function $(t={}){l();let e={from:o.state.selection.from,to:o.state.selection.to,picker:null,listen:[]};e.picker=A({document:n,label:"Insert an emoji",empty:"No emoji found",onPick:i=>p(i)}),u=e;let r=(i,k,g,y)=>{i.addEventListener(k,g,y),e.listen.push([i,k,g,y])};r(n,"keydown",i=>E(i),!0),r(o.dom,"input",()=>l()),r(n,"mousedown",i=>{e.picker.el.contains(i.target)||l()},!0),(o.dom.parentElement??n.body).appendChild(e.picker.el);let c;try{c=await a()}catch(i){return l(),{ok:!1,code:"unavailable",error:i}}return u!==e?{ok:!1,code:"not-editing"}:f(e)===null?(l(),{ok:!1,code:"stale-target"}):(e.picker.show(P(c,t?.query),m(e)),d(e),{ok:!0,picker:!0})}return{async run(t){return $(t)},dispose(){l()}}}export{w as createFeature,L as emojiEntries,T as emojiLibrary,P as filterEmoji,S as graphemes,I as isEmojiText};
@@ -1,4 +1,4 @@
1
- import{e as X,f as G,h as J,i as Q,j as P,k as U}from"./c-QIKT6SKM.js";import{a as C,f as L}from"./c-TJAXGIRV.js";import"./c-BWFVSBDF.js";import"./c-L5VFATT6.js";import{a as O,b as N,k as z,l as K,m as j,n as V,v as T}from"./c-WMRJKQ2V.js";import{o as w}from"./c-AMU3BPPR.js";import{b as k,d as H}from"./c-QIXT3Q7C.js";import{b as W}from"./c-GY422N3Q.js";import"./c-7SWMYKAI.js";import"./c-UGHH4MB3.js";import"./c-ZWIOJGMT.js";import{d as q}from"./c-XGH4GS2T.js";import"./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-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var ie=128,D=r=>r.depth?r.node(1).attrs.id:null,Z=r=>!!r.depth&&r.node(1).type.name==="table",ce=(r,t,n,e,o)=>O(K(z(r.flow,J(t,n.holes,e,n.visible),o)));function te({pd:r,w:t,doc:n},e){if(!r||!t||!n||!e)return null;if(e instanceof k.TextSelection){let o=e.$anchor,s=e.$head;if(Z(o)||Z(s)){let c=P(n,o.pos),u=P(n,s.pos);return!c||!u||c.table!==u.table||c.row!==u.row||c.col!==u.col?null:{kind:"cell",block:c.table,row:c.row,col:c.col}}let a=Math.min(e.from,e.to),l=c=>{let u=D(c);return u===null?null:{block:u,rel:ce(r,n,t,c.pos,e.empty||c.pos===a?0:-1)}},i=l(o),d=l(s);return i&&d?{kind:"text",anchor:i,head:d}:null}if(e instanceof w||e instanceof k.NodeSelection){let o=[];if(e instanceof w){let{lo:s,hi:a}=e.span();n.forEach((l,i,d)=>{d>=s&&d<=a&&o.push(l.attrs.id)})}else{let s=n.nodeAt(e.from);s&&o.push(s.attrs.id)}if(!o.length)return null;if(o.length>ie){let s=D(e.$from);return s?{kind:"blocks",ids:[s]}:null}return{kind:"blocks",ids:o}}return null}var ue=(r,t)=>{if(!t||typeof t!="object"||typeof t.block!="string"||!t.block||typeof t.rel!="string"||!t.rel)return null;let n;try{n=j(N(t.rel))}catch{return null}let e;try{e=V(n,r.ydoc)}catch{return null}return!e||e.type!==r.flow?null:e.index},fe=(r,t)=>{let n=0;for(let e=r.flow._start;e;e=e.right){let o=n+e.length;if(t<o)return!e.deleted;n=o}return!1},pe=(r,t)=>{for(let n=r.flow._start;n;n=n.right)if(!n.deleted&&n.content instanceof T&&n.content.embed?.b===t)return!0;return!1},de=(r,t)=>{let n=0,e=null,o=0;for(let s=r.flow._start;s;s=s.right)if(s.content instanceof T&&s.content.embed?.b!==void 0&&(e=s.content.embed.b,o=n+s.length),n+=s.length,n>t&&e!==null)return{id:e,offset:t-o};return e===null?null:{id:e,offset:t-o}},me=(r,t,n)=>{let e=null;return r.forEach((o,s)=>{e===null&&o.attrs.id===t&&o.isTextblock&&(e=s+1+Math.min(Math.max(n,0),o.content.size))}),e},ee=({pd:r,w:t,doc:n},e)=>{let o=ue(r,e);if(o===null)return null;let s=Q(n,t.holes,t.tokens,o,t.visible);if(D(n.resolve(s))===e.block)return s;let a=de(r,o);if(a&&a.id===e.block){let l=me(n,e.block,a.offset);if(l!==null)return l}return pe(r,e.block)||!fe(r,o)||t.holes.some(l=>o>=G(t.holes,l.at)&&o<X(t.holes,l.at))?null:n.resolve(s).parent.inlineContent?s:null};function ne({pd:r,w:t,doc:n},e){if(!r||!t||!n||!e||typeof e!="object")return null;if(e.kind==="text"){let o=ee({pd:r,w:t,doc:n},e.anchor),s=ee({pd:r,w:t,doc:n},e.head);return o===null||s===null?null:{kind:"text",from:Math.min(o,s),to:Math.max(o,s)}}if(e.kind==="cell"){let o=U(n,{table:e.block,row:e.row,col:e.col,offset:0});return o?{kind:"cell",from:o.from,to:o.to,block:o.block,row:o.row,col:o.col}:null}if(e.kind==="blocks"){let o=[],s=[];for(let a of Array.isArray(e.ids)?e.ids:[])n.forEach((l,i)=>{l.attrs.id!==a||o.includes(a)||(o.push(a),s.push({from:i,to:i+l.nodeSize}))});return s.length?{kind:"blocks",ids:o,ranges:s}:null}return null}var{Plugin:ge,PluginKey:he}=k,{Decoration:b,DecorationSet:x}=H,y=new he("page-awareness"),oe="page-awareness-style",be=`
1
+ import{e as X,f as G,h as J,i as Q,j as P,k as U}from"./c-QIKT6SKM.js";import{a as C,f as L}from"./c-TJAXGIRV.js";import"./c-BWFVSBDF.js";import"./c-L5VFATT6.js";import{a as O,b as N,k as z,l as K,m as j,n as V,v as T}from"./c-WMRJKQ2V.js";import{o as w}from"./c-AIWN4QN4.js";import{b as k,d as H}from"./c-QIXT3Q7C.js";import{b as W}from"./c-GY422N3Q.js";import"./c-7SWMYKAI.js";import"./c-UGHH4MB3.js";import"./c-ZWIOJGMT.js";import{d as q}from"./c-XGH4GS2T.js";import"./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-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var ie=128,D=r=>r.depth?r.node(1).attrs.id:null,Z=r=>!!r.depth&&r.node(1).type.name==="table",ce=(r,t,n,e,o)=>O(K(z(r.flow,J(t,n.holes,e,n.visible),o)));function te({pd:r,w:t,doc:n},e){if(!r||!t||!n||!e)return null;if(e instanceof k.TextSelection){let o=e.$anchor,s=e.$head;if(Z(o)||Z(s)){let c=P(n,o.pos),u=P(n,s.pos);return!c||!u||c.table!==u.table||c.row!==u.row||c.col!==u.col?null:{kind:"cell",block:c.table,row:c.row,col:c.col}}let a=Math.min(e.from,e.to),l=c=>{let u=D(c);return u===null?null:{block:u,rel:ce(r,n,t,c.pos,e.empty||c.pos===a?0:-1)}},i=l(o),d=l(s);return i&&d?{kind:"text",anchor:i,head:d}:null}if(e instanceof w||e instanceof k.NodeSelection){let o=[];if(e instanceof w){let{lo:s,hi:a}=e.span();n.forEach((l,i,d)=>{d>=s&&d<=a&&o.push(l.attrs.id)})}else{let s=n.nodeAt(e.from);s&&o.push(s.attrs.id)}if(!o.length)return null;if(o.length>ie){let s=D(e.$from);return s?{kind:"blocks",ids:[s]}:null}return{kind:"blocks",ids:o}}return null}var ue=(r,t)=>{if(!t||typeof t!="object"||typeof t.block!="string"||!t.block||typeof t.rel!="string"||!t.rel)return null;let n;try{n=j(N(t.rel))}catch{return null}let e;try{e=V(n,r.ydoc)}catch{return null}return!e||e.type!==r.flow?null:e.index},fe=(r,t)=>{let n=0;for(let e=r.flow._start;e;e=e.right){let o=n+e.length;if(t<o)return!e.deleted;n=o}return!1},pe=(r,t)=>{for(let n=r.flow._start;n;n=n.right)if(!n.deleted&&n.content instanceof T&&n.content.embed?.b===t)return!0;return!1},de=(r,t)=>{let n=0,e=null,o=0;for(let s=r.flow._start;s;s=s.right)if(s.content instanceof T&&s.content.embed?.b!==void 0&&(e=s.content.embed.b,o=n+s.length),n+=s.length,n>t&&e!==null)return{id:e,offset:t-o};return e===null?null:{id:e,offset:t-o}},me=(r,t,n)=>{let e=null;return r.forEach((o,s)=>{e===null&&o.attrs.id===t&&o.isTextblock&&(e=s+1+Math.min(Math.max(n,0),o.content.size))}),e},ee=({pd:r,w:t,doc:n},e)=>{let o=ue(r,e);if(o===null)return null;let s=Q(n,t.holes,t.tokens,o,t.visible);if(D(n.resolve(s))===e.block)return s;let a=de(r,o);if(a&&a.id===e.block){let l=me(n,e.block,a.offset);if(l!==null)return l}return pe(r,e.block)||!fe(r,o)||t.holes.some(l=>o>=G(t.holes,l.at)&&o<X(t.holes,l.at))?null:n.resolve(s).parent.inlineContent?s:null};function ne({pd:r,w:t,doc:n},e){if(!r||!t||!n||!e||typeof e!="object")return null;if(e.kind==="text"){let o=ee({pd:r,w:t,doc:n},e.anchor),s=ee({pd:r,w:t,doc:n},e.head);return o===null||s===null?null:{kind:"text",from:Math.min(o,s),to:Math.max(o,s)}}if(e.kind==="cell"){let o=U(n,{table:e.block,row:e.row,col:e.col,offset:0});return o?{kind:"cell",from:o.from,to:o.to,block:o.block,row:o.row,col:o.col}:null}if(e.kind==="blocks"){let o=[],s=[];for(let a of Array.isArray(e.ids)?e.ids:[])n.forEach((l,i)=>{l.attrs.id!==a||o.includes(a)||(o.push(a),s.push({from:i,to:i+l.nodeSize}))});return s.length?{kind:"blocks",ids:o,ranges:s}:null}return null}var{Plugin:ge,PluginKey:he}=k,{Decoration:b,DecorationSet:x}=H,y=new he("page-awareness"),oe="page-awareness-style",be=`
2
2
  .page-remote-selection { background-color: color-mix(in srgb, var(--page-remote-color, currentColor) 22%, transparent); }
3
3
  .page-remote-caret { position: relative; display: inline-block; width: 0; height: 1.1em; vertical-align: text-bottom; }
4
4
  .page-remote-caret::before { content: ""; position: absolute; inset-inline-start: -1px; top: 0; bottom: 0; width: 2px; background: var(--page-remote-color, currentColor); }
@@ -1,4 +1,4 @@
1
- import{d as Ae,h as Ve,i as qe}from"./c-TRS6TM6O.js";import{a as Ne,b as Pe}from"./c-WNTYKCDG.js";import{a as Ie,b as Oe}from"./c-PZ4XEPUP.js";import{e as ke,f as Ke,g as W,h as Ue,l as re,m as $e,n as p}from"./c-BJ7YQ5QZ.js";import"./c-4JZDZFF6.js";import{b as U,c as Z,e as l,f as Ye}from"./c-VAK7SG37.js";import{b as He}from"./c-MHI3GYKF.js";import"./c-MCOOHCSG.js";import{b as T,c as Fe}from"./c-NUHP2XDB.js";import{a as We,q as V}from"./c-T637T7SN.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import{f as Te}from"./c-FWKHM4E7.js";import"./c-X5LNHET5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-ZWIOJGMT.js";import"./c-B7J4K2AE.js";import"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import"./c-IJUK2GPW.js";import{f as _e}from"./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"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var E="light-dark(#D08A1E, #E3A33F)",lt=5e3,st=4e3,dt=500,ct={"another-tab":"in another tab","another-person":"by someone else","an-agent":"by an agent"},pt='<svg viewBox="0 0 12 12" width="12" height="12" aria-hidden="true"><path d="M2.5 9.5h7" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="square"/></svg>',F=(e,t)=>`${e} ${t}${e===1?"":"s"}`,ut="This spot changed again. Review the latest edit or download your copy.",ft="A data value can't be put back from here. Download your copy to keep yours.",m="hidden",P=!1,S=[],J=new Set,M=new Set,h=null,Ee=0,I=null,v=null,le=null,u=null,R=!1,Y=!1,ve=!1,G=new Map,se=0,ae=!1,te=!1,b=null,j=null,L=null,Se=0,D=!1,de=0,ce=null,ne=null,k=[],x=[],oe=!1,pe=null,ue=null,s=null,B=null,q=new Map,z=()=>window.clay?.conflicts||null,Qe=()=>k.reduce((e,t)=>e+t.conflicts.length,0)+x.length,Le=()=>{let e=window.clay?.undo;return e&&typeof e.kept=="function"?e:null},fe=()=>z()?.list().filter(e=>!e.claimedBy&&e.kind!=="apply-incomplete")??[],De=()=>z()?.list().filter(e=>!e.claimedBy&&e.kind==="apply-incomplete")??[];function ze(){return I?"upgraded":h?"refused":fe().length?"replaced":De().length?"failed":k.length||x.length?"recovered":null}function f(e,t,n){let o=Fe(e,t,n);return t[0]==="all:initial"&&T(o,"color-scheme","inherit"),o.setAttribute("clay",ke),o}function _(e,t){return q.set(t,e),e}function ie(){if(!s)return;let e=window.visualViewport,t=e?Math.max(0,window.innerHeight-e.height-e.offsetTop):0;T(s,"bottom",`calc(${16+t}px + env(safe-area-inset-bottom,0px))`),ne&&T(ne,"max-height",`${Math.max(160,(e?.height||window.innerHeight)-32)}px`)}function ht(){s=f("div",["all:initial","position:fixed","left:50%","transform:translateX(-50%)","z-index:2147483001","display:none","flex-direction:column","align-items:center","max-width:calc(100vw - 24px)",`font:14px/1.5 ${U}`,`color:${l.ink}`,"text-align:left"]),s.setAttribute("data-clay-conflict",""),document.body.appendChild(s),window.visualViewport?.addEventListener("resize",ie),window.visualViewport?.addEventListener("scroll",ie)}function d(){if(ae)return;ae=!0;let e=()=>{ae=!1,w()};typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16)}function w(){te&&(te=!1,h&&!V()&&(h=null));let e=ze();if(e?m==="hidden"&&(m="bar"):(m="hidden",P=!1,J.clear(),M.clear(),S=[],y(),ce=null,D=!1),!s){if(m==="hidden"&&!b||!document.body)return;ht()}!s.isConnected&&document.body&&document.body.appendChild(s);let t=document.activeElement,n=null;for(let[a,r]of q)r===t&&(n=a);let o=B?B.scrollTop:0;q=new Map,B=null,ne=null,s.replaceChildren(),b?s.append(wt(b)):m==="bar"?s.append(yt(e)):m==="panel"&&s.append(xt(e)),T(s,"display",b||m!=="hidden"?"flex":"none"),B&&(B.scrollTop=o);let i=L||n;i&&q.has(i)&&q.get(i).focus({preventScroll:!0}),b||(L=null),ie(),He(s)}function Xe(){return f("span",["all:initial","display:inline-block","flex:none","width:8px","height:8px","border-radius:50%",`background:${E}`])}function Ze(){return ct[h?.changedBy]||null}function gt(e,t){if(e==="upgraded")return I;if(e==="refused"){let n=Ze();return!n&&h.afterTimeout?"This page changed elsewhere, possibly by your own save that timed out. Your edits here are safe.":`This page changed ${n||"elsewhere"}. Your edits here are safe.`}return e==="failed"?"A sync update did not finish. Your edits here are safe.":e==="recovered"?`${F(t,"change")} replaced before this page loaded ${t===1?"is":"are"} still here.`:`Another edit replaced ${F(t,"change")}.`}function mt(e,t){return e==="upgraded"?I:e==="refused"?`This page changed ${Ze()||"elsewhere"}`:e==="failed"?"A sync update did not finish":e==="recovered"?`${F(t,"change")} kept from before this page loaded`:`Another edit replaced ${F(t,"change")}`}function wt(e){let t=re("div",["display:block",`border-left:3px solid ${l.teal}`,"padding:10px 14px","width:max-content","max-width:calc(100vw - 24px)"]);return t.setAttribute("role","status"),t.textContent=e,t}function yt(e){let t=e==="failed"?De().length:e==="recovered"?Qe():fe().length,n=re("div",["display:flex","flex-wrap:wrap","align-items:center","gap:10px 12px","padding:8px 8px 8px 14px","width:max-content","max-width:calc(100vw - 24px)"]),o=gt(e,t);return o!==ce&&(n.setAttribute("role",e==="refused"?"alert":"status"),ce=o),n.append(Xe(),p("span",[],o)),e==="upgraded"?(n.append(_(W("Reload",{variant:"primary",onClick:()=>window.location.reload()}),"reload")),n):(n.append(_(W("Review",{onClick:Dt}),"review")),n)}function $(e,t,{variant:n="default",onClick:o,push:i=!1}={}){let r=window.innerWidth<480?["flex:1 1 100%",...n==="primary"?["order:-1"]:[]]:i?["margin-left:auto"]:[];return _(W(e,{variant:n,onClick:o,extra:r}),t)}function A(e){return p("div",["display:block","padding:0 16px 12px",`color:${l["ink-2"]}`,"font-size:13.5px"],e)}function xt(e){let t=e==="replaced"?fe():e==="failed"?De():[],n=e==="refused"?fe():t,o=e==="recovered"?Qe():t.length;if(J.size)for(let c of t)J.has(c.id)||M.add(c.id);for(let c of[...M])t.some(N=>N.id===c)||M.delete(c);let i=mt(e,o),a=Math.max(160,(window.visualViewport?.height||window.innerHeight)-32),r=re("div",["display:flex","flex-direction:column","width:520px","max-width:calc(100vw - 24px)",`max-height:${a}px`]);ne=r,r.setAttribute("role","dialog"),r.setAttribute("aria-label",i);let g=f("div",["all:initial","display:flex","align-items:center","gap:8px","padding:12px 12px 8px 16px",`font:14px/1.5 ${U}`,`color:${l.ink}`]),K=_(p("b",["font-weight:600","font-size:14.5px","outline:none"],i),"title");K.setAttribute("tabindex","-1"),g.append(Xe(),K),e==="replaced"&&M.size&&g.append(p("span",[`font:600 10.5px/1 ${Z}`,"letter-spacing:.12em","text-transform:uppercase","padding:3px 6px",`color:color-mix(in srgb, ${l.brass} 80%, ${l.ink})`,`background:${l["brass-soft"]}`],`${M.size} new`));let X=f("span",["all:initial","display:inline-flex","margin-left:auto"]),Be=_(Ue(pt,{label:"Minimize",onClick:Je}),"minimize");if(Be.title="Minimize to the bar. Nothing is accepted until you choose.",X.append(Be),g.append(X),r.append(g),e==="recovered")return Et(r),r;if(e==="refused"){if(r.append(A("Your edits here are safe and not saved yet; nothing will be overwritten until you choose. Their version is not on this page, so there is no list of edits to compare. Keep yours, which saves over theirs, or accept theirs, which reloads the page and drops your unsaved edits.")),n.length&&r.append(A(`${F(n.length,"earlier replaced edit")} ${n.length===1?"is":"are"} also held in this tab. Download my copy includes them.`)),R&&r.append(A("That did not save either. Your edits here are still here.")),D&&r.append(A("Something changed on the page after your first press, so nothing was dropped. Press Accept theirs again if you still want their version.")),v){let c=f("div",["all:initial","display:block","margin:0 16px 12px","padding:8px 10px",`border-left:3px solid ${E}`,`background:color-mix(in srgb, ${E} 14%, transparent)`,`color:${l.ink}`,`font:13px/1.5 ${U}`]);c.append(f("b",["all:initial","font:inherit","font-weight:700","color:inherit"],"This drops your unsaved edits."),document.createTextNode(" Download your copy first if you might want them. Press again to confirm.")),r.append(c)}}else e==="upgraded"?r.append(A("Its layout and code changed with it, so this page stops here. Reload to see the new version.")):e==="failed"?r.append(A("Part of an update from elsewhere could not be applied, so this page may be missing some of it. Your edits here are safe. Download a copy of the page as you had it, or accept to keep the page as it is.")):r.append(A("The page is showing the other edit. This stays until you choose. You can also save a copy of the page as you had it."));let O=f("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","padding:0 16px 14px"]);if(e==="upgraded")return O.append($("Reload","reload",{variant:"primary",onClick:()=>window.location.reload(),push:!0})),r.append(O),S=[],r;let at=$(ve?"Try again":Y?"Downloaded":"Download my copy","download",{onClick:Bt});if(O.append(at),e==="refused"){let c=$(u==="overwrite"?"Saving\u2026":R?"Try again":"Keep mine","keep",{onClick:Pt});c.setDisabled(u==="overwrite"),O.append(c,$(v?"Yes, drop my edits":"Accept theirs","accept",{variant:"primary",onClick:Ft,push:!0}))}else{if(e==="replaced"){let c=z().hasPendingApply(),N=$(c?"Finishing the incoming edit\u2026":u==="revert"?"Putting back\u2026":"Revert to mine","revert",{onClick:Mt});N.setDisabled(c||u==="revert"),O.append(N)}O.append($("Accept theirs","accept",{variant:"primary",onClick:zt,push:!0}))}if(r.append(O),e==="replaced")if(P)r.append(vt(t));else{let c=f("div",["all:initial","display:flex","align-items:center","gap:8px",`border-top:1px solid ${l.line}`,"padding:8px 10px 8px 16px",`color:${l.muted}`,`font:13px/1.5 ${U}`]),N=f("span",["all:initial","display:inline-flex","margin-left:auto"]);N.append(_(W("See the edits",{small:!0,onClick:et}),"list")),c.append(f("span",["all:initial","font:inherit","color:inherit"],F(t.length,"edit")),N),r.append(c)}S=n.map(c=>c.id);for(let c of t)J.add(c.id);return r}function vt(e){let t=$e(["flex:1 1 auto","margin:0 16px 12px","min-height:0","overflow:auto",`background:${l.sunk}`,`border:1px solid ${l["line-2"]}`]),n=f("div",["all:initial","position:sticky","top:0","z-index:1","display:flex","align-items:center","gap:8px","padding:8px 12px",`background:${l.sunk}`,`border-bottom:1px solid ${l["line-2"]}`,`color:${l.muted}`,`font:600 10.5px/1 ${Z}`,"letter-spacing:.12em","text-transform:uppercase"]),o=f("span",["all:initial","display:inline-flex","margin-left:auto"]);return o.append(_(W("Hide",{small:!0,variant:"quiet",onClick:et}),"list")),n.append(f("span",["all:initial","font:inherit","color:inherit","letter-spacing:inherit","text-transform:inherit"],"Replaced edits"),o),t.append(n),e.forEach((i,a)=>t.append(St(i,a))),B=t,t}function Me(e){let t=e.context?.label||e.name||(e.context?.kind==="entry"?"Entry":"Edit");return e.context?.field?`${t} \xB7 ${e.context.field}`:t}var bt={"content-changed":"the page changed there","structure-changed":"the structure changed there","target-detached":"that part of the page is gone","duplicate-id":"another part of the page now has the same id",protected:"that region keeps its own history",unsupported:"this kind of step cannot be put back"},kt=e=>bt[e]||"the page changed there";function $t(e,t){let n=Array.isArray(e)?e:[];for(let o of n){if(!o||o.kind!=="text"&&o.kind!=="value")continue;let i=t==="redo"?o.after:o.before;if(typeof i=="string"&&i)return{text:i,id:o.target?.id??null}}for(let o of n){if(!o||o.kind!=="add"&&o.kind!=="remove")continue;let i=Array.isArray(o.nodes)?o.nodes.find(a=>typeof a?.html=="string"&&a.html):null;if(i)return{text:Ie(i.html).replace(/\s+/g," ").trim(),id:o.parent?.id??null}}for(let o of n){if(!o)continue;let i=t==="redo"?o.after:o.before;if(typeof i=="string"&&i)return{text:i,id:o.target?.id??null}}return{text:"",id:null}}function Tt(e){if(e==null||typeof document>"u")return"";let t=window.CSS?.escape?window.CSS.escape(String(e)):String(e).replace(/["\\]/g,"\\$&"),n=null;try{n=document.querySelector(`[data-id="${t}"]`)}catch{return""}if(!n)return"";let o=n.matches?.("input, textarea, select")?n.value:null;return(typeof o=="string"?o:n.textContent??"").replace(/\s+/g," ").trim()}function At(e){let t=e?.payload&&typeof e.payload=="object"?e.payload:{},n=String(e?.key??""),o={id:e?.id,revision:e?.revision,record:e,kind:e?.kind??"conflict"};if(n.startsWith("app:"))return{...o,name:typeof t.label=="string"&&t.label?t.label:n.slice(4),sentence:"",yours:typeof t.text=="string"?t.text:"",now:""};let i=t.direction==="redo"?"redo":"undo",g=((Array.isArray(t.context)?t.context:[]).find(X=>typeof X?.label=="string"&&X.label)??null)?.label||typeof t.label=="string"&&t.label||"Edit",K=$t(t.steps,i);return{...o,name:g,sentence:`The ${i} of "${g}" was not applied because ${kt(t.code)}.`,yours:K.text,now:K.id==null?"":Tt(K.id)}}function Ct(e){let t=Le();if(!e.record||typeof t?.reviewActionsFor!="function")return[];try{return(t.reviewActionsFor(e.record)||[]).filter(n=>n&&typeof n.run=="function"&&n.label)}catch{return[]}}var Ge=e=>({before:"",hit:e,after:"",cutBefore:!1,cutAfter:!1});function je(e){let t=p("div",["display:block","padding:8px 12px 10px"]),n=p("div",["display:flex","align-items:center","gap:8px","font-size:12.5px","font-weight:600",`color:${l["ink-2"]}`,"margin-bottom:4px"]);if(n.append(p("span",[],Me(e))),t.append(n),e.sentence&&t.append(p("div",["display:block","font-size:13px",`color:${l["ink-2"]}`],e.sentence)),e.yours){let i=p("div",["display:grid","grid-template-columns:44px 1fr","gap:3px 10px","align-items:start",`font:12.5px/1.5 ${Z}`,...e.sentence?["margin-top:4px"]:[]]);i.append(...he("Yours",Ge(e.yours),{mine:!0})),e.now&&i.append(...he("Now",Ge(e.now),{mine:!1})),t.append(i)}let o=f("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","margin-top:8px"]);return Ct(e).forEach((i,a)=>{let r=$(i.label,`run:${e.id}:${a}`,{onClick:()=>Nt(e,i,r)});o.append(r)}),o.append($(pe===e.id?"Copied":"Copy",`copy:${e.id}`,{onClick:()=>It(e)})),o.append($("Dismiss",`dismiss:${e.id}`,{onClick:()=>tt(e)})),t.append(o),t}function Et(e){e.append(A(k.length?"These copies were replaced before this page loaded. The page never puts them back on its own. Copy or download the ones you want; dismiss one when you no longer need it.":"These copies were kept because an undo could not be put back or the page set them aside. The page never puts them back on its own. Copy or download the ones you want; dismiss one when you no longer need it.")),oe&&e.append(A("That action did not run. The copy is still here."));let t=$e(["flex:1 1 auto","margin:0 16px 12px","min-height:0","overflow:auto",`background:${l.sunk}`,`border:1px solid ${l["line-2"]}`]);for(let o of k)for(let i of o.conflicts)t.append(je(i));for(let o of x)t.append(je(o));B=t,e.append(t);let n=f("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","padding:0 16px 14px"]);(k.some(o=>o.root)||x.length)&&n.append($(Y?"Downloaded":"Download my copy","download",{onClick:Ot})),e.append(n),S=[]}function he(e,t,{mine:n}){let o=[p("span",[`color:${l.faint}`,`font-family:${U}`],e)],i=p("span",["display:-webkit-box","-webkit-line-clamp:2","-webkit-box-orient:vertical","overflow:hidden","overflow-wrap:anywhere",...n?[`color:${l.ink}`]:[`color:${l.muted}`]]),a=(t.cutBefore?"\u2026":"")+t.before+t.hit+t.after+(t.cutAfter?"\u2026":"");i.title=a,t.before&&i.append(p("span",[`color:${l.faint}`],(t.cutBefore?"\u2026":"")+t.before));let r=p("span",n?[`background:color-mix(in srgb, ${E} 18%, transparent)`,"padding:0 4px"]:t.before||t.after?["text-decoration:underline",`text-decoration-color:color-mix(in srgb, ${E} 70%, transparent)`,"text-underline-offset:3px"]:[],t.hit||"(empty)");return i.append(r),t.after&&i.append(p("span",[`color:${l.faint}`],t.after+(t.cutAfter?"\u2026":""))),o.push(i),o}function St(e,t){let n=Oe(e),o=p("div",["display:block","padding:8px 12px 10px",...t?[`border-top:1px solid ${l.line}`]:[]]),i=p("div",["display:flex","align-items:center","gap:4px","font-size:12.5px","font-weight:600",`color:${l["ink-2"]}`,"margin-bottom:4px"]);if(i.append(p("span",[],n.name)),n.target&&n.target.isConnected&&i.append(_(Rt(n),`eye:${e.id}`)),o.append(i),n.sentence&&o.append(p("div",["display:block","font-size:13px",`color:${l["ink-2"]}`],n.sentence)),G.has(e.id)&&o.append(p("div",["display:block","font-size:13px","margin-top:4px",`color:${E}`],G.get(e.id))),n.yours){let a=p("div",["display:grid","grid-template-columns:44px 1fr","gap:3px 10px","align-items:start",`font:12.5px/1.5 ${Z}`,...n.sentence?["margin-top:4px"]:[]]);a.append(...he("Yours",n.yours,{mine:!0})),n.now&&a.append(...he("Now",n.now,{mine:!1})),o.append(a)}return o}function Rt(e){let t=["all:initial","color-scheme:inherit","box-sizing:border-box","cursor:pointer","display:inline-grid","place-items:center","width:22px","height:20px",`color:${l.ink}`],n=f("button",t);n.type="button",n.innerHTML=Ye.conflictEye,Ke(n.firstElementChild,16),n.setAttribute("aria-label",`Show ${e.name} on page`),n.title="Show on page";let o=i=>{n.style.cssText="";for(let a of[...t,...i]){let r=a.indexOf(":");n.style.setProperty(a.slice(0,r),a.slice(r+1),"important")}};return n.addEventListener("pointerenter",()=>o([`background:color-mix(in srgb, ${E} 16%, transparent)`])),n.addEventListener("pointerleave",()=>o([])),n.addEventListener("focus",()=>o([`outline:2px solid ${l.brass}`,"outline-offset:1px"])),n.addEventListener("blur",()=>o([])),n.addEventListener("click",()=>Lt(e.target)),n}var C=null,ge=null,me=null;function we(){clearTimeout(ge),window.removeEventListener("scroll",ee,!0),window.removeEventListener("resize",ee),C?.remove(),C=null,me=null}function ee(){if(!C||!me)return;let e=me.getBoundingClientRect();T(C,"left",`${e.left}px`),T(C,"top",`${e.top}px`),T(C,"width",`${e.width}px`),T(C,"height",`${e.height}px`)}function Lt(e){if(we(),!e||!e.isConnected)return;let n=!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches?"instant":"smooth",o=s?.getBoundingClientRect().top??0,i=s&&o>0?Math.max(0,window.innerHeight-o):0;if(!i)e.scrollIntoView?.({block:"center",behavior:n});else{e.scrollIntoView?.({block:"center",behavior:"instant"});let a=e.getBoundingClientRect(),r=window.innerHeight-i,g=a.height>r-24?a.top-12:a.top+a.height/2-r/2;window.scrollBy?.({top:g,behavior:n})}me=e,C=f("div",["all:initial","color-scheme:inherit","position:fixed","pointer-events:none","z-index:2147483001",`outline:2px solid ${E}`,"outline-offset:3px",`background:color-mix(in srgb, ${E} 14%, transparent)`]),document.body.appendChild(C),ee(),window.addEventListener("scroll",ee,!0),window.addEventListener("resize",ee),ge=setTimeout(we,2500)}function Dt(){I||(m="panel",L="title",w())}function Je(){we(),m="bar",y(),L="review",w()}function et(){P=!P,P&&M.clear(),w()}function zt(){let e=z(),t=S.filter(n=>{let o=e?.get(n);return o&&!o.claimedBy});e&&t.length&&e.acknowledge(t,{reason:"accepted"}),m=ze()?"bar":"hidden",L="review",d()}async function Mt(){let e=z();if(u||!e||e.hasPendingApply())return;let t=S.filter(r=>{let g=e.get(r);return g&&!g.claimedBy});if(!t.length)return;u="revert",w();let n=!0,o=r=>{n=!!s?.contains(r.target)};document.addEventListener("focus",o,!0);let i;try{let{revertConflicts:r}=await import("./c-C6IPRG34.js");i=await r(t)}catch(r){console.error("[clay] Revert to mine did not finish",r),i={revertedIds:[],blockedIds:t,saveResult:null}}finally{document.removeEventListener("focus",o,!0)}u=null;for(let r of i.blockedIds)G.set(r,z()?.get(r)?.kind==="json"?ft:ut);m=ze()?"bar":"hidden",L=n?"review":null;let a=i.saveResult&&(i.saveResult.ok||i.saveResult.msg==="Save already in progress");i.revertedIds.length&&a?be(`Put back ${F(i.revertedIds.length,"change")}. Saving.`):w()}var Q=null;function Bt(){let e=z(),t=h?e?.list()??[]:S.map(o=>e?.get(o)).filter(Boolean),n=Pe(t,{refused:!!h});ve=!n,Y=n,clearTimeout(Q),n&&(Q=setTimeout(()=>{Y=!1,d()},1200)),w()}async function H(){let e=null;if(Ae())try{e=await Ve()}catch{e=null}let t=Le(),n=null;if(t)try{n=await t.kept()}catch{n=null}let o=!1;if(e?.ok?(k=e.records,o=!0):!Ae()&&k.length&&(k=[],o=!0),n?.ok){let i=(Array.isArray(n.records)?n.records:[]).filter(r=>r&&r.supported!==!1).map(At);i.length===x.length&&i.every((r,g)=>r.id===x[g].id&&r.revision===x[g].revision)||(o=!0),x=i}else n&&x.length&&(x=[],o=!0);o&&d()}async function _t(e){try{return await navigator.clipboard.writeText(e),!0}catch{}let t=document.createElement("textarea");t.value=e,t.setAttribute("clay",ke),t.style.setProperty("position","fixed","important"),t.style.setProperty("opacity","0","important"),document.body?.append(t),t.select();let n=!1;try{n=document.execCommand?.("copy")===!0}catch{}return t.remove(),n}async function It(e){let t=e.record?e.yours:`${Me(e)}
1
+ import{d as Ae,h as Ve,i as qe}from"./c-TRS6TM6O.js";import{a as Ne,b as Pe}from"./c-WNTYKCDG.js";import{a as Ie,b as Oe}from"./c-PZ4XEPUP.js";import{e as ke,f as Ke,g as W,h as Ue,l as re,m as $e,n as p}from"./c-BJ7YQ5QZ.js";import"./c-4JZDZFF6.js";import{b as U,c as Z,e as l,f as Ye}from"./c-VAK7SG37.js";import{b as He}from"./c-MHI3GYKF.js";import"./c-MCOOHCSG.js";import{b as T,c as Fe}from"./c-NUHP2XDB.js";import{a as We,q as V}from"./c-ZKNBMNN3.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import{f as Te}from"./c-FWKHM4E7.js";import"./c-5JLFROUB.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-ZWIOJGMT.js";import"./c-B7J4K2AE.js";import"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import"./c-IJUK2GPW.js";import{f as _e}from"./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"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var E="light-dark(#D08A1E, #E3A33F)",lt=5e3,st=4e3,dt=500,ct={"another-tab":"in another tab","another-person":"by someone else","an-agent":"by an agent"},pt='<svg viewBox="0 0 12 12" width="12" height="12" aria-hidden="true"><path d="M2.5 9.5h7" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="square"/></svg>',F=(e,t)=>`${e} ${t}${e===1?"":"s"}`,ut="This spot changed again. Review the latest edit or download your copy.",ft="A data value can't be put back from here. Download your copy to keep yours.",m="hidden",P=!1,S=[],J=new Set,M=new Set,h=null,Ee=0,I=null,v=null,le=null,u=null,R=!1,Y=!1,ve=!1,G=new Map,se=0,ae=!1,te=!1,b=null,j=null,L=null,Se=0,D=!1,de=0,ce=null,ne=null,k=[],x=[],oe=!1,pe=null,ue=null,s=null,B=null,q=new Map,z=()=>window.clay?.conflicts||null,Qe=()=>k.reduce((e,t)=>e+t.conflicts.length,0)+x.length,Le=()=>{let e=window.clay?.undo;return e&&typeof e.kept=="function"?e:null},fe=()=>z()?.list().filter(e=>!e.claimedBy&&e.kind!=="apply-incomplete")??[],De=()=>z()?.list().filter(e=>!e.claimedBy&&e.kind==="apply-incomplete")??[];function ze(){return I?"upgraded":h?"refused":fe().length?"replaced":De().length?"failed":k.length||x.length?"recovered":null}function f(e,t,n){let o=Fe(e,t,n);return t[0]==="all:initial"&&T(o,"color-scheme","inherit"),o.setAttribute("clay",ke),o}function _(e,t){return q.set(t,e),e}function ie(){if(!s)return;let e=window.visualViewport,t=e?Math.max(0,window.innerHeight-e.height-e.offsetTop):0;T(s,"bottom",`calc(${16+t}px + env(safe-area-inset-bottom,0px))`),ne&&T(ne,"max-height",`${Math.max(160,(e?.height||window.innerHeight)-32)}px`)}function ht(){s=f("div",["all:initial","position:fixed","left:50%","transform:translateX(-50%)","z-index:2147483001","display:none","flex-direction:column","align-items:center","max-width:calc(100vw - 24px)",`font:14px/1.5 ${U}`,`color:${l.ink}`,"text-align:left"]),s.setAttribute("data-clay-conflict",""),document.body.appendChild(s),window.visualViewport?.addEventListener("resize",ie),window.visualViewport?.addEventListener("scroll",ie)}function d(){if(ae)return;ae=!0;let e=()=>{ae=!1,w()};typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16)}function w(){te&&(te=!1,h&&!V()&&(h=null));let e=ze();if(e?m==="hidden"&&(m="bar"):(m="hidden",P=!1,J.clear(),M.clear(),S=[],y(),ce=null,D=!1),!s){if(m==="hidden"&&!b||!document.body)return;ht()}!s.isConnected&&document.body&&document.body.appendChild(s);let t=document.activeElement,n=null;for(let[a,r]of q)r===t&&(n=a);let o=B?B.scrollTop:0;q=new Map,B=null,ne=null,s.replaceChildren(),b?s.append(wt(b)):m==="bar"?s.append(yt(e)):m==="panel"&&s.append(xt(e)),T(s,"display",b||m!=="hidden"?"flex":"none"),B&&(B.scrollTop=o);let i=L||n;i&&q.has(i)&&q.get(i).focus({preventScroll:!0}),b||(L=null),ie(),He(s)}function Xe(){return f("span",["all:initial","display:inline-block","flex:none","width:8px","height:8px","border-radius:50%",`background:${E}`])}function Ze(){return ct[h?.changedBy]||null}function gt(e,t){if(e==="upgraded")return I;if(e==="refused"){let n=Ze();return!n&&h.afterTimeout?"This page changed elsewhere, possibly by your own save that timed out. Your edits here are safe.":`This page changed ${n||"elsewhere"}. Your edits here are safe.`}return e==="failed"?"A sync update did not finish. Your edits here are safe.":e==="recovered"?`${F(t,"change")} replaced before this page loaded ${t===1?"is":"are"} still here.`:`Another edit replaced ${F(t,"change")}.`}function mt(e,t){return e==="upgraded"?I:e==="refused"?`This page changed ${Ze()||"elsewhere"}`:e==="failed"?"A sync update did not finish":e==="recovered"?`${F(t,"change")} kept from before this page loaded`:`Another edit replaced ${F(t,"change")}`}function wt(e){let t=re("div",["display:block",`border-left:3px solid ${l.teal}`,"padding:10px 14px","width:max-content","max-width:calc(100vw - 24px)"]);return t.setAttribute("role","status"),t.textContent=e,t}function yt(e){let t=e==="failed"?De().length:e==="recovered"?Qe():fe().length,n=re("div",["display:flex","flex-wrap:wrap","align-items:center","gap:10px 12px","padding:8px 8px 8px 14px","width:max-content","max-width:calc(100vw - 24px)"]),o=gt(e,t);return o!==ce&&(n.setAttribute("role",e==="refused"?"alert":"status"),ce=o),n.append(Xe(),p("span",[],o)),e==="upgraded"?(n.append(_(W("Reload",{variant:"primary",onClick:()=>window.location.reload()}),"reload")),n):(n.append(_(W("Review",{onClick:Dt}),"review")),n)}function $(e,t,{variant:n="default",onClick:o,push:i=!1}={}){let r=window.innerWidth<480?["flex:1 1 100%",...n==="primary"?["order:-1"]:[]]:i?["margin-left:auto"]:[];return _(W(e,{variant:n,onClick:o,extra:r}),t)}function A(e){return p("div",["display:block","padding:0 16px 12px",`color:${l["ink-2"]}`,"font-size:13.5px"],e)}function xt(e){let t=e==="replaced"?fe():e==="failed"?De():[],n=e==="refused"?fe():t,o=e==="recovered"?Qe():t.length;if(J.size)for(let c of t)J.has(c.id)||M.add(c.id);for(let c of[...M])t.some(N=>N.id===c)||M.delete(c);let i=mt(e,o),a=Math.max(160,(window.visualViewport?.height||window.innerHeight)-32),r=re("div",["display:flex","flex-direction:column","width:520px","max-width:calc(100vw - 24px)",`max-height:${a}px`]);ne=r,r.setAttribute("role","dialog"),r.setAttribute("aria-label",i);let g=f("div",["all:initial","display:flex","align-items:center","gap:8px","padding:12px 12px 8px 16px",`font:14px/1.5 ${U}`,`color:${l.ink}`]),K=_(p("b",["font-weight:600","font-size:14.5px","outline:none"],i),"title");K.setAttribute("tabindex","-1"),g.append(Xe(),K),e==="replaced"&&M.size&&g.append(p("span",[`font:600 10.5px/1 ${Z}`,"letter-spacing:.12em","text-transform:uppercase","padding:3px 6px",`color:color-mix(in srgb, ${l.brass} 80%, ${l.ink})`,`background:${l["brass-soft"]}`],`${M.size} new`));let X=f("span",["all:initial","display:inline-flex","margin-left:auto"]),Be=_(Ue(pt,{label:"Minimize",onClick:Je}),"minimize");if(Be.title="Minimize to the bar. Nothing is accepted until you choose.",X.append(Be),g.append(X),r.append(g),e==="recovered")return Et(r),r;if(e==="refused"){if(r.append(A("Your edits here are safe and not saved yet; nothing will be overwritten until you choose. Their version is not on this page, so there is no list of edits to compare. Keep yours, which saves over theirs, or accept theirs, which reloads the page and drops your unsaved edits.")),n.length&&r.append(A(`${F(n.length,"earlier replaced edit")} ${n.length===1?"is":"are"} also held in this tab. Download my copy includes them.`)),R&&r.append(A("That did not save either. Your edits here are still here.")),D&&r.append(A("Something changed on the page after your first press, so nothing was dropped. Press Accept theirs again if you still want their version.")),v){let c=f("div",["all:initial","display:block","margin:0 16px 12px","padding:8px 10px",`border-left:3px solid ${E}`,`background:color-mix(in srgb, ${E} 14%, transparent)`,`color:${l.ink}`,`font:13px/1.5 ${U}`]);c.append(f("b",["all:initial","font:inherit","font-weight:700","color:inherit"],"This drops your unsaved edits."),document.createTextNode(" Download your copy first if you might want them. Press again to confirm.")),r.append(c)}}else e==="upgraded"?r.append(A("Its layout and code changed with it, so this page stops here. Reload to see the new version.")):e==="failed"?r.append(A("Part of an update from elsewhere could not be applied, so this page may be missing some of it. Your edits here are safe. Download a copy of the page as you had it, or accept to keep the page as it is.")):r.append(A("The page is showing the other edit. This stays until you choose. You can also save a copy of the page as you had it."));let O=f("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","padding:0 16px 14px"]);if(e==="upgraded")return O.append($("Reload","reload",{variant:"primary",onClick:()=>window.location.reload(),push:!0})),r.append(O),S=[],r;let at=$(ve?"Try again":Y?"Downloaded":"Download my copy","download",{onClick:Bt});if(O.append(at),e==="refused"){let c=$(u==="overwrite"?"Saving\u2026":R?"Try again":"Keep mine","keep",{onClick:Pt});c.setDisabled(u==="overwrite"),O.append(c,$(v?"Yes, drop my edits":"Accept theirs","accept",{variant:"primary",onClick:Ft,push:!0}))}else{if(e==="replaced"){let c=z().hasPendingApply(),N=$(c?"Finishing the incoming edit\u2026":u==="revert"?"Putting back\u2026":"Revert to mine","revert",{onClick:Mt});N.setDisabled(c||u==="revert"),O.append(N)}O.append($("Accept theirs","accept",{variant:"primary",onClick:zt,push:!0}))}if(r.append(O),e==="replaced")if(P)r.append(vt(t));else{let c=f("div",["all:initial","display:flex","align-items:center","gap:8px",`border-top:1px solid ${l.line}`,"padding:8px 10px 8px 16px",`color:${l.muted}`,`font:13px/1.5 ${U}`]),N=f("span",["all:initial","display:inline-flex","margin-left:auto"]);N.append(_(W("See the edits",{small:!0,onClick:et}),"list")),c.append(f("span",["all:initial","font:inherit","color:inherit"],F(t.length,"edit")),N),r.append(c)}S=n.map(c=>c.id);for(let c of t)J.add(c.id);return r}function vt(e){let t=$e(["flex:1 1 auto","margin:0 16px 12px","min-height:0","overflow:auto",`background:${l.sunk}`,`border:1px solid ${l["line-2"]}`]),n=f("div",["all:initial","position:sticky","top:0","z-index:1","display:flex","align-items:center","gap:8px","padding:8px 12px",`background:${l.sunk}`,`border-bottom:1px solid ${l["line-2"]}`,`color:${l.muted}`,`font:600 10.5px/1 ${Z}`,"letter-spacing:.12em","text-transform:uppercase"]),o=f("span",["all:initial","display:inline-flex","margin-left:auto"]);return o.append(_(W("Hide",{small:!0,variant:"quiet",onClick:et}),"list")),n.append(f("span",["all:initial","font:inherit","color:inherit","letter-spacing:inherit","text-transform:inherit"],"Replaced edits"),o),t.append(n),e.forEach((i,a)=>t.append(St(i,a))),B=t,t}function Me(e){let t=e.context?.label||e.name||(e.context?.kind==="entry"?"Entry":"Edit");return e.context?.field?`${t} \xB7 ${e.context.field}`:t}var bt={"content-changed":"the page changed there","structure-changed":"the structure changed there","target-detached":"that part of the page is gone","duplicate-id":"another part of the page now has the same id",protected:"that region keeps its own history",unsupported:"this kind of step cannot be put back"},kt=e=>bt[e]||"the page changed there";function $t(e,t){let n=Array.isArray(e)?e:[];for(let o of n){if(!o||o.kind!=="text"&&o.kind!=="value")continue;let i=t==="redo"?o.after:o.before;if(typeof i=="string"&&i)return{text:i,id:o.target?.id??null}}for(let o of n){if(!o||o.kind!=="add"&&o.kind!=="remove")continue;let i=Array.isArray(o.nodes)?o.nodes.find(a=>typeof a?.html=="string"&&a.html):null;if(i)return{text:Ie(i.html).replace(/\s+/g," ").trim(),id:o.parent?.id??null}}for(let o of n){if(!o)continue;let i=t==="redo"?o.after:o.before;if(typeof i=="string"&&i)return{text:i,id:o.target?.id??null}}return{text:"",id:null}}function Tt(e){if(e==null||typeof document>"u")return"";let t=window.CSS?.escape?window.CSS.escape(String(e)):String(e).replace(/["\\]/g,"\\$&"),n=null;try{n=document.querySelector(`[data-id="${t}"]`)}catch{return""}if(!n)return"";let o=n.matches?.("input, textarea, select")?n.value:null;return(typeof o=="string"?o:n.textContent??"").replace(/\s+/g," ").trim()}function At(e){let t=e?.payload&&typeof e.payload=="object"?e.payload:{},n=String(e?.key??""),o={id:e?.id,revision:e?.revision,record:e,kind:e?.kind??"conflict"};if(n.startsWith("app:"))return{...o,name:typeof t.label=="string"&&t.label?t.label:n.slice(4),sentence:"",yours:typeof t.text=="string"?t.text:"",now:""};let i=t.direction==="redo"?"redo":"undo",g=((Array.isArray(t.context)?t.context:[]).find(X=>typeof X?.label=="string"&&X.label)??null)?.label||typeof t.label=="string"&&t.label||"Edit",K=$t(t.steps,i);return{...o,name:g,sentence:`The ${i} of "${g}" was not applied because ${kt(t.code)}.`,yours:K.text,now:K.id==null?"":Tt(K.id)}}function Ct(e){let t=Le();if(!e.record||typeof t?.reviewActionsFor!="function")return[];try{return(t.reviewActionsFor(e.record)||[]).filter(n=>n&&typeof n.run=="function"&&n.label)}catch{return[]}}var Ge=e=>({before:"",hit:e,after:"",cutBefore:!1,cutAfter:!1});function je(e){let t=p("div",["display:block","padding:8px 12px 10px"]),n=p("div",["display:flex","align-items:center","gap:8px","font-size:12.5px","font-weight:600",`color:${l["ink-2"]}`,"margin-bottom:4px"]);if(n.append(p("span",[],Me(e))),t.append(n),e.sentence&&t.append(p("div",["display:block","font-size:13px",`color:${l["ink-2"]}`],e.sentence)),e.yours){let i=p("div",["display:grid","grid-template-columns:44px 1fr","gap:3px 10px","align-items:start",`font:12.5px/1.5 ${Z}`,...e.sentence?["margin-top:4px"]:[]]);i.append(...he("Yours",Ge(e.yours),{mine:!0})),e.now&&i.append(...he("Now",Ge(e.now),{mine:!1})),t.append(i)}let o=f("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","margin-top:8px"]);return Ct(e).forEach((i,a)=>{let r=$(i.label,`run:${e.id}:${a}`,{onClick:()=>Nt(e,i,r)});o.append(r)}),o.append($(pe===e.id?"Copied":"Copy",`copy:${e.id}`,{onClick:()=>It(e)})),o.append($("Dismiss",`dismiss:${e.id}`,{onClick:()=>tt(e)})),t.append(o),t}function Et(e){e.append(A(k.length?"These copies were replaced before this page loaded. The page never puts them back on its own. Copy or download the ones you want; dismiss one when you no longer need it.":"These copies were kept because an undo could not be put back or the page set them aside. The page never puts them back on its own. Copy or download the ones you want; dismiss one when you no longer need it.")),oe&&e.append(A("That action did not run. The copy is still here."));let t=$e(["flex:1 1 auto","margin:0 16px 12px","min-height:0","overflow:auto",`background:${l.sunk}`,`border:1px solid ${l["line-2"]}`]);for(let o of k)for(let i of o.conflicts)t.append(je(i));for(let o of x)t.append(je(o));B=t,e.append(t);let n=f("div",["all:initial","display:flex","flex-wrap:wrap","gap:8px","padding:0 16px 14px"]);(k.some(o=>o.root)||x.length)&&n.append($(Y?"Downloaded":"Download my copy","download",{onClick:Ot})),e.append(n),S=[]}function he(e,t,{mine:n}){let o=[p("span",[`color:${l.faint}`,`font-family:${U}`],e)],i=p("span",["display:-webkit-box","-webkit-line-clamp:2","-webkit-box-orient:vertical","overflow:hidden","overflow-wrap:anywhere",...n?[`color:${l.ink}`]:[`color:${l.muted}`]]),a=(t.cutBefore?"\u2026":"")+t.before+t.hit+t.after+(t.cutAfter?"\u2026":"");i.title=a,t.before&&i.append(p("span",[`color:${l.faint}`],(t.cutBefore?"\u2026":"")+t.before));let r=p("span",n?[`background:color-mix(in srgb, ${E} 18%, transparent)`,"padding:0 4px"]:t.before||t.after?["text-decoration:underline",`text-decoration-color:color-mix(in srgb, ${E} 70%, transparent)`,"text-underline-offset:3px"]:[],t.hit||"(empty)");return i.append(r),t.after&&i.append(p("span",[`color:${l.faint}`],t.after+(t.cutAfter?"\u2026":""))),o.push(i),o}function St(e,t){let n=Oe(e),o=p("div",["display:block","padding:8px 12px 10px",...t?[`border-top:1px solid ${l.line}`]:[]]),i=p("div",["display:flex","align-items:center","gap:4px","font-size:12.5px","font-weight:600",`color:${l["ink-2"]}`,"margin-bottom:4px"]);if(i.append(p("span",[],n.name)),n.target&&n.target.isConnected&&i.append(_(Rt(n),`eye:${e.id}`)),o.append(i),n.sentence&&o.append(p("div",["display:block","font-size:13px",`color:${l["ink-2"]}`],n.sentence)),G.has(e.id)&&o.append(p("div",["display:block","font-size:13px","margin-top:4px",`color:${E}`],G.get(e.id))),n.yours){let a=p("div",["display:grid","grid-template-columns:44px 1fr","gap:3px 10px","align-items:start",`font:12.5px/1.5 ${Z}`,...n.sentence?["margin-top:4px"]:[]]);a.append(...he("Yours",n.yours,{mine:!0})),n.now&&a.append(...he("Now",n.now,{mine:!1})),o.append(a)}return o}function Rt(e){let t=["all:initial","color-scheme:inherit","box-sizing:border-box","cursor:pointer","display:inline-grid","place-items:center","width:22px","height:20px",`color:${l.ink}`],n=f("button",t);n.type="button",n.innerHTML=Ye.conflictEye,Ke(n.firstElementChild,16),n.setAttribute("aria-label",`Show ${e.name} on page`),n.title="Show on page";let o=i=>{n.style.cssText="";for(let a of[...t,...i]){let r=a.indexOf(":");n.style.setProperty(a.slice(0,r),a.slice(r+1),"important")}};return n.addEventListener("pointerenter",()=>o([`background:color-mix(in srgb, ${E} 16%, transparent)`])),n.addEventListener("pointerleave",()=>o([])),n.addEventListener("focus",()=>o([`outline:2px solid ${l.brass}`,"outline-offset:1px"])),n.addEventListener("blur",()=>o([])),n.addEventListener("click",()=>Lt(e.target)),n}var C=null,ge=null,me=null;function we(){clearTimeout(ge),window.removeEventListener("scroll",ee,!0),window.removeEventListener("resize",ee),C?.remove(),C=null,me=null}function ee(){if(!C||!me)return;let e=me.getBoundingClientRect();T(C,"left",`${e.left}px`),T(C,"top",`${e.top}px`),T(C,"width",`${e.width}px`),T(C,"height",`${e.height}px`)}function Lt(e){if(we(),!e||!e.isConnected)return;let n=!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches?"instant":"smooth",o=s?.getBoundingClientRect().top??0,i=s&&o>0?Math.max(0,window.innerHeight-o):0;if(!i)e.scrollIntoView?.({block:"center",behavior:n});else{e.scrollIntoView?.({block:"center",behavior:"instant"});let a=e.getBoundingClientRect(),r=window.innerHeight-i,g=a.height>r-24?a.top-12:a.top+a.height/2-r/2;window.scrollBy?.({top:g,behavior:n})}me=e,C=f("div",["all:initial","color-scheme:inherit","position:fixed","pointer-events:none","z-index:2147483001",`outline:2px solid ${E}`,"outline-offset:3px",`background:color-mix(in srgb, ${E} 14%, transparent)`]),document.body.appendChild(C),ee(),window.addEventListener("scroll",ee,!0),window.addEventListener("resize",ee),ge=setTimeout(we,2500)}function Dt(){I||(m="panel",L="title",w())}function Je(){we(),m="bar",y(),L="review",w()}function et(){P=!P,P&&M.clear(),w()}function zt(){let e=z(),t=S.filter(n=>{let o=e?.get(n);return o&&!o.claimedBy});e&&t.length&&e.acknowledge(t,{reason:"accepted"}),m=ze()?"bar":"hidden",L="review",d()}async function Mt(){let e=z();if(u||!e||e.hasPendingApply())return;let t=S.filter(r=>{let g=e.get(r);return g&&!g.claimedBy});if(!t.length)return;u="revert",w();let n=!0,o=r=>{n=!!s?.contains(r.target)};document.addEventListener("focus",o,!0);let i;try{let{revertConflicts:r}=await import("./c-XSZKP646.js");i=await r(t)}catch(r){console.error("[clay] Revert to mine did not finish",r),i={revertedIds:[],blockedIds:t,saveResult:null}}finally{document.removeEventListener("focus",o,!0)}u=null;for(let r of i.blockedIds)G.set(r,z()?.get(r)?.kind==="json"?ft:ut);m=ze()?"bar":"hidden",L=n?"review":null;let a=i.saveResult&&(i.saveResult.ok||i.saveResult.msg==="Save already in progress");i.revertedIds.length&&a?be(`Put back ${F(i.revertedIds.length,"change")}. Saving.`):w()}var Q=null;function Bt(){let e=z(),t=h?e?.list()??[]:S.map(o=>e?.get(o)).filter(Boolean),n=Pe(t,{refused:!!h});ve=!n,Y=n,clearTimeout(Q),n&&(Q=setTimeout(()=>{Y=!1,d()},1200)),w()}async function H(){let e=null;if(Ae())try{e=await Ve()}catch{e=null}let t=Le(),n=null;if(t)try{n=await t.kept()}catch{n=null}let o=!1;if(e?.ok?(k=e.records,o=!0):!Ae()&&k.length&&(k=[],o=!0),n?.ok){let i=(Array.isArray(n.records)?n.records:[]).filter(r=>r&&r.supported!==!1).map(At);i.length===x.length&&i.every((r,g)=>r.id===x[g].id&&r.revision===x[g].revision)||(o=!0),x=i}else n&&x.length&&(x=[],o=!0);o&&d()}async function _t(e){try{return await navigator.clipboard.writeText(e),!0}catch{}let t=document.createElement("textarea");t.value=e,t.setAttribute("clay",ke),t.style.setProperty("position","fixed","important"),t.style.setProperty("opacity","0","important"),document.body?.append(t),t.select();let n=!1;try{n=document.execCommand?.("copy")===!0}catch{}return t.remove(),n}async function It(e){let t=e.record?e.yours:`${Me(e)}
2
2
 
3
3
  Yours:
4
4
  ${e.yours}
@@ -1,4 +1,4 @@
1
- import{c as h}from"./c-GBKB5WDL.js";import{w as d}from"./c-4TXNLX4K.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-MWXFLW4J.js";import"./c-ZK4GIZH2.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-AMU3BPPR.js";import{m as p}from"./c-QIXT3Q7C.js";import{a as s}from"./c-BYTKL6UX.js";import"./c-WCXLG3MV.js";import"./c-3LDGIBMN.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var c=`
1
+ import{c as h}from"./c-GBKB5WDL.js";import{w as d}from"./c-4FJTBE6I.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-CQQDL6O4.js";import"./c-ZGDYHKG3.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-AIWN4QN4.js";import{m as p}from"./c-QIXT3Q7C.js";import{a as s}from"./c-BYTKL6UX.js";import"./c-WCXLG3MV.js";import"./c-3LDGIBMN.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var c=`
2
2
  .page-tool-block { position: relative; min-height: 48px; border: 1px solid var(--page-rule); border-radius: 8px; padding: 12px; }
3
3
  .page-tool-settings { position: absolute; top: 4px; inset-inline-end: 4px; border: 0; border-radius: 5px; background: var(--page-pop-bg); color: var(--page-ink-soft); font: 12px var(--page-font); padding: 5px 8px; cursor: pointer; opacity: 0; }
4
4
  .page-tool-block:hover .page-tool-settings, .page-tool-block:focus-within .page-tool-settings { opacity: 1; }
@@ -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-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-LACAAQFB.js";import"./c-2RARVIAK.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-ZKNBMNN3.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-5JLFROUB.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 +1 @@
1
- import{B as H,C as X,d as M,g as L,h as O,j as D,l as I,m as R,n as x,o as C,p as A,q as N,s as $}from"./c-AMU3BPPR.js";import{m as B}from"./c-QIXT3Q7C.js";var _=new WeakMap;function v(s){let t=_.get(s);return t||_.set(s,t=O(s)),t}var F=B.nodes,w=s=>s.type===F.list_item,S=s=>s.type===F.toggle,y=s=>s.attrs.parent??null;function J(s,t,e){if(e<0)return[null];let n=[],i=s[e].node;S(i)&&i.attrs.open&&!s[e].hidden&&n.unshift(i.attrs.id);for(let r=y(i);r!==null&&!n.includes(r);){let c=s[t.get(r)];if(!c)break;n.unshift(r),r=y(c.node)}let o=[null];for(let r of n){let c=s[t.get(r)];if(!c.node.attrs.open||c.hidden)break;o.push(r)}return o}function Y(s,t,e,n){let i=y(s[t].node),o=w(s[t].node)?n.indent-s[t].node.attrs.indent:0;return r=>r.i<t||r.i>e||y(r.node)!==i?null:w(r.node)?{parent:n.parent,indent:r.node.attrs.indent+o}:{parent:n.parent}}function Q(s,t){let e=null;s.doc.forEach((n,i)=>{n.attrs.id===t&&S(n)&&(e={n,off:i})}),e&&!e.n.attrs.open&&s.setNodeMarkup(e.off,null,{...e.n.attrs,open:!0})}function P(s,t,e,n,i,o=null){let r=Y(t,e,n,i),c=t[e].at,d=t[n].end,h=o??new C(s.doc.resolve(c),s.doc.resolve(d)),a;if(i.at===c||i.at===d){a=s.tr;for(let l=e;l<=n;l++){let p=r(t[l]);p&&a.setNodeMarkup(t[l].at,null,{...t[l].node.attrs,...p})}a.setSelection(h.map(a.doc,a.mapping)),a.setMeta(L,A(t,e,n,i.at,r))}else a=N(s,t,e,n,i.at,r,h);if(i.open){Q(a,i.open);let l=a.getMeta(L);l&&a.setMeta(L,{...l,attrs:{...l.attrs,[i.open]:{open:!0}}})}return a}function K(s,t,e,n,i){if(i.parent!=null&&t.slice(e,n+1).some(a=>a.node.attrs.id===i.parent))return!1;let o=t[n].end-t[e].at,r=Y(t,e,n,i);for(let a=e;a<=n;a++)if(w(t[a].node)&&(r(t[a])?.indent??t[a].node.attrs.indent)>$)return!1;let c=P(s,t,e,n,i),h=i.at===t[e].at||i.at===t[n].end?t[e].at:i.at>t[e].at?i.at-o:i.at;return D(c.doc,s.doc).every(a=>a.at>=h&&a.at<h+o)}function U(s,t,e,n,i){let o=new Map;t.forEach(l=>{S(l.node)&&l.node.attrs.id&&o.set(l.node.attrs.id,l.i)});let r=i<0?s.doc.content.size:t[i].at;if(r>t[e].at&&r<t[n].end)return[];let c=(i<0?t.length:i)-1,d=J(t,o,c),h=d.indexOf(i<0?null:y(t[i].node)),a=[];for(let l of d.slice(Math.max(0,h))){let p=l===null?0:t[o.get(l)].depth+1,E=c>=0&&w(t[c].node)&&y(t[c].node)===l?t[c].node:null,f=w(t[e].node)&&E?E.attrs.indent+1:0;for(let u=0;u<=f;u++){let m={at:r,parent:l,indent:u,depth:p+(w(t[e].node)?u:0)};K(s,t,e,n,m)&&a.push(m)}}return a}function q(s,t,e,n,i){let o=t[i];if(!o||!S(o.node)||o.node.attrs.open||o.hidden||i>=e&&i<=n||o.at>t[e].at&&o.at<t[n].end)return null;let r=o.node.attrs.id,c={at:t[o.subEnd].end,parent:r,indent:0,depth:o.depth+1,open:r};return K(s,t,e,n,c)?c:null}function z(s,t){let e=null;for(let n of s)(!e||Math.abs(n.depth-t)<Math.abs(e.depth-t))&&(e=n);return e}var Z=4,tt=250,V=8,b=56,W=18;function et(s){for(let t=s.parentElement;t;t=t.parentElement){let e=getComputedStyle(t).overflowY;if((e==="auto"||e==="scroll")&&t.scrollHeight>t.clientHeight)return t}return s.ownerDocument.scrollingElement}var j=new WeakMap;function nt(s,t){let e=j.get(s);if(!e){e=[];for(let n of s){if(n.hidden)continue;let i=t.nodeDOM(n.at);i?.getBoundingClientRect&&e.push({i:n.i,dom:i})}j.set(s,e)}return e}function it(s,t){let e=0,n=s.length;for(;e<n;){let i=e+n>>1,o=s[i].dom.getBoundingClientRect();t<o.top+o.height/2?n=i:e=i+1}return e<s.length?e:-1}var G=class{constructor(t,e,{index:n,onClick:i}){this.view=t,this.grip=e,this.index=n,this.onClick=i,this.shell=t.dom.parentElement,this.line=document.createElement("div"),this.line.className="page-drop",this.line.hidden=!0,this.line.setAttribute("aria-hidden","true"),this.shell.append(this.line),this.state=null,this.onMove=o=>this.move(o),this.onUp=o=>this.end(o),this.onCancel=o=>{o.pointerId===this.state?.pointer&&this.cancel()},this.onKey=o=>{o.key==="Escape"&&this.state?.active&&(o.preventDefault(),o.stopPropagation(),this.cancel())},this.onOther=o=>{this.state&&o.pointerId!==this.state.pointer&&this.cancel()},this.onBlur=()=>this.cancel(),this.onScroll=()=>{this.state&&!this.state.active&&this.stop()},e.addEventListener("pointerdown",o=>this.start(o))}start(t){if(t.button!==0||this.state)return;let e=this.view.state,n=v(e.doc),i=e.selection,o=Math.min(this.index(),n.length-1),r=i instanceof C&&n[o].at>=i.from&&n[o].end<=i.to,{lo:c,hi:d}=r?i.span(e.doc):I(n,o,o);if(this.state={index:o,span:R(n,c,d),touch:t.pointerType==="touch",pointer:t.pointerId,x0:t.clientX,y0:t.clientY,x:t.clientX,y:t.clientY,hold:0,active:!1,raf:0,gap:void 0,targets:[],target:null},this.grip.setPointerCapture?.(t.pointerId),this.grip.addEventListener("pointermove",this.onMove),this.grip.addEventListener("pointerup",this.onUp),this.grip.addEventListener("pointercancel",this.onCancel),this.grip.addEventListener("lostpointercapture",this.onCancel),this.state.touch){let h=this.state;h.hold=setTimeout(()=>this.held(h),tt),window.addEventListener("pointerdown",this.onOther,!0),window.addEventListener("blur",this.onBlur),window.addEventListener("scroll",this.onScroll,!0)}t.preventDefault()}held(t){if(!(this.state!==t||t.active)){if(t.hold=0,Math.hypot(t.x-t.x0,t.y-t.y0)>V||!this.view.editable)return this.stop();this.begin()}}move(t){let e=this.state;if(!(!e||t.pointerId!==e.pointer)){if(e.x=t.clientX,e.y=t.clientY,e.touch&&!this.view.editable)return e.active?this.cancel():this.stop();if(!e.active){let n=Math.hypot(e.x-e.x0,e.y-e.y0);if(e.touch){n>V&&this.stop();return}if(n<=Z)return;this.begin()}this.track()}}begin(){let t=this.state;if(!t||t.active)return;let e=this.view.state,n=v(e.doc),i=x(n,t.span);if(!i)return this.cancel();t.active=!0,this.view.dispatch(e.tr.setSelection(X(e.doc,i.lo,i.hi))),this.shell.classList.add("is-dragging");let o=this.shell.appendChild(document.createElement("div"));o.style.cssText="position:absolute;visibility:hidden;width:var(--page-indent)",this.indentPx=o.getBoundingClientRect().width||27,o.remove(),this.scroller=et(this.view.dom),window.addEventListener("keydown",this.onKey,!0),this.loop(),this.track()}track(){let t=this.state,e=this.view,n=e.state;if(!t)return;let i=v(n.doc),o=x(i,t.span);if(!o)return this.cancel();let{lo:r,hi:c}=o,d=nt(i,e),h=it(d,t.y),a=-1,l=null,p=null,E=h<0?d.length:h+1;for(let k=Math.max(0,E-2);k<E;k++){let g=d[k].dom.getBoundingClientRect();t.y>=g.top+g.height/4&&t.y<=g.bottom-g.height/4&&(p={i:d[k].i,bottom:g.bottom}),l=g.bottom+2}h>=0&&(a=d[h].i,l=d[h].dom.getBoundingClientRect().top-2);let f=r<0?null:p&&q(n,i,r,c,p.i),u=f?`summary:${p.i}`:a;(u!==t.gap||n.doc!==t.doc)&&(t.gap=u,t.doc=n.doc,t.targets=r<0?[]:f?[f]:U(n,i,r,c,a)),f&&(l=p.bottom+2);let m=e.dom.getBoundingClientRect().left;t.target=z(t.targets,(t.x-m)/this.indentPx);let T=this.shell.getBoundingClientRect();if(!t.target||l===null){this.line.hidden=!0,this.shell.dataset.drop="none";return}this.shell.dataset.drop="ok",this.line.hidden=!1,this.line.style.setProperty("--page-drop-y",`${l-T.top}px`),this.line.style.setProperty("--page-drop-x",`${m-T.left+t.target.depth*this.indentPx}px`),this.line.style.setProperty("--page-drop-w",`${e.dom.getBoundingClientRect().right-m-t.target.depth*this.indentPx}px`)}loop(){let t=()=>{let e=this.state;if(!e?.active)return;if(e.touch&&!this.view.editable)return this.cancel();let n=this.scroller,i=n===n.ownerDocument.scrollingElement?{top:0,bottom:window.innerHeight}:n.getBoundingClientRect(),o=0;e.y<i.top+b?o=-W*Math.min(1,(i.top+b-e.y)/b):e.y>i.bottom-b&&(o=W*Math.min(1,(e.y-(i.bottom-b))/b)),o&&(n.scrollTop+=o,this.track()),e.raf=requestAnimationFrame(t)};this.state.raf=requestAnimationFrame(t)}end(t){let e=this.state;if(!e||t.pointerId!==e.pointer)return;if(!e.active){if(this.stop(),t.type==="pointerup"){let l=v(this.view.state.doc),p=x(l,e.span);p&&this.onClick(p.lo)}return}if(this.track(),this.state!==e)return;let n=e.target,i=this.view.state,o=v(i.doc),r=x(o,e.span);if(this.stop(),!n||!r)return;let{lo:c,hi:d}=r;if(!n.open&&(n.at===o[c].at||n.at===o[d].end)&&n.parent===(o[c].node.attrs.parent??null)&&(o[c].node.type.name!=="list_item"||n.indent===o[c].node.attrs.indent))return;if(this.view.dispatch(H(P(i,o,c,d,n)).scrollIntoView()),this.view.state.doc===i.doc)return M(this.view,"Move cancelled");let a=d-c+1;M(this.view,`Moved ${a} ${a===1?"block":"blocks"}`),this.view.focus()}cancel(){this.stop(),M(this.view,"Move cancelled")}stop(){let t=this.state;t&&(this.state=null,clearTimeout(t.hold),cancelAnimationFrame(t.raf),this.grip.removeEventListener("pointermove",this.onMove),this.grip.removeEventListener("pointerup",this.onUp),this.grip.removeEventListener("pointercancel",this.onCancel),this.grip.removeEventListener("lostpointercapture",this.onCancel),this.grip.releasePointerCapture?.(t.pointer),window.removeEventListener("pointerdown",this.onOther,!0),window.removeEventListener("blur",this.onBlur),window.removeEventListener("scroll",this.onScroll,!0),window.removeEventListener("keydown",this.onKey,!0),this.shell.classList.remove("is-dragging"),delete this.shell.dataset.drop,this.line.hidden=!0)}destroy(){this.stop(),this.line.remove()}};export{v as a,et as b,G as c};
1
+ import{B as H,C as X,d as M,g as L,h as O,j as D,l as I,m as R,n as x,o as C,p as A,q as N,s as $}from"./c-AIWN4QN4.js";import{m as B}from"./c-QIXT3Q7C.js";var _=new WeakMap;function v(s){let t=_.get(s);return t||_.set(s,t=O(s)),t}var F=B.nodes,w=s=>s.type===F.list_item,S=s=>s.type===F.toggle,y=s=>s.attrs.parent??null;function J(s,t,e){if(e<0)return[null];let n=[],i=s[e].node;S(i)&&i.attrs.open&&!s[e].hidden&&n.unshift(i.attrs.id);for(let r=y(i);r!==null&&!n.includes(r);){let c=s[t.get(r)];if(!c)break;n.unshift(r),r=y(c.node)}let o=[null];for(let r of n){let c=s[t.get(r)];if(!c.node.attrs.open||c.hidden)break;o.push(r)}return o}function Y(s,t,e,n){let i=y(s[t].node),o=w(s[t].node)?n.indent-s[t].node.attrs.indent:0;return r=>r.i<t||r.i>e||y(r.node)!==i?null:w(r.node)?{parent:n.parent,indent:r.node.attrs.indent+o}:{parent:n.parent}}function Q(s,t){let e=null;s.doc.forEach((n,i)=>{n.attrs.id===t&&S(n)&&(e={n,off:i})}),e&&!e.n.attrs.open&&s.setNodeMarkup(e.off,null,{...e.n.attrs,open:!0})}function P(s,t,e,n,i,o=null){let r=Y(t,e,n,i),c=t[e].at,d=t[n].end,h=o??new C(s.doc.resolve(c),s.doc.resolve(d)),a;if(i.at===c||i.at===d){a=s.tr;for(let l=e;l<=n;l++){let p=r(t[l]);p&&a.setNodeMarkup(t[l].at,null,{...t[l].node.attrs,...p})}a.setSelection(h.map(a.doc,a.mapping)),a.setMeta(L,A(t,e,n,i.at,r))}else a=N(s,t,e,n,i.at,r,h);if(i.open){Q(a,i.open);let l=a.getMeta(L);l&&a.setMeta(L,{...l,attrs:{...l.attrs,[i.open]:{open:!0}}})}return a}function K(s,t,e,n,i){if(i.parent!=null&&t.slice(e,n+1).some(a=>a.node.attrs.id===i.parent))return!1;let o=t[n].end-t[e].at,r=Y(t,e,n,i);for(let a=e;a<=n;a++)if(w(t[a].node)&&(r(t[a])?.indent??t[a].node.attrs.indent)>$)return!1;let c=P(s,t,e,n,i),h=i.at===t[e].at||i.at===t[n].end?t[e].at:i.at>t[e].at?i.at-o:i.at;return D(c.doc,s.doc).every(a=>a.at>=h&&a.at<h+o)}function U(s,t,e,n,i){let o=new Map;t.forEach(l=>{S(l.node)&&l.node.attrs.id&&o.set(l.node.attrs.id,l.i)});let r=i<0?s.doc.content.size:t[i].at;if(r>t[e].at&&r<t[n].end)return[];let c=(i<0?t.length:i)-1,d=J(t,o,c),h=d.indexOf(i<0?null:y(t[i].node)),a=[];for(let l of d.slice(Math.max(0,h))){let p=l===null?0:t[o.get(l)].depth+1,E=c>=0&&w(t[c].node)&&y(t[c].node)===l?t[c].node:null,f=w(t[e].node)&&E?E.attrs.indent+1:0;for(let u=0;u<=f;u++){let m={at:r,parent:l,indent:u,depth:p+(w(t[e].node)?u:0)};K(s,t,e,n,m)&&a.push(m)}}return a}function q(s,t,e,n,i){let o=t[i];if(!o||!S(o.node)||o.node.attrs.open||o.hidden||i>=e&&i<=n||o.at>t[e].at&&o.at<t[n].end)return null;let r=o.node.attrs.id,c={at:t[o.subEnd].end,parent:r,indent:0,depth:o.depth+1,open:r};return K(s,t,e,n,c)?c:null}function z(s,t){let e=null;for(let n of s)(!e||Math.abs(n.depth-t)<Math.abs(e.depth-t))&&(e=n);return e}var Z=4,tt=250,V=8,b=56,W=18;function et(s){for(let t=s.parentElement;t;t=t.parentElement){let e=getComputedStyle(t).overflowY;if((e==="auto"||e==="scroll")&&t.scrollHeight>t.clientHeight)return t}return s.ownerDocument.scrollingElement}var j=new WeakMap;function nt(s,t){let e=j.get(s);if(!e){e=[];for(let n of s){if(n.hidden)continue;let i=t.nodeDOM(n.at);i?.getBoundingClientRect&&e.push({i:n.i,dom:i})}j.set(s,e)}return e}function it(s,t){let e=0,n=s.length;for(;e<n;){let i=e+n>>1,o=s[i].dom.getBoundingClientRect();t<o.top+o.height/2?n=i:e=i+1}return e<s.length?e:-1}var G=class{constructor(t,e,{index:n,onClick:i}){this.view=t,this.grip=e,this.index=n,this.onClick=i,this.shell=t.dom.parentElement,this.line=document.createElement("div"),this.line.className="page-drop",this.line.hidden=!0,this.line.setAttribute("aria-hidden","true"),this.shell.append(this.line),this.state=null,this.onMove=o=>this.move(o),this.onUp=o=>this.end(o),this.onCancel=o=>{o.pointerId===this.state?.pointer&&this.cancel()},this.onKey=o=>{o.key==="Escape"&&this.state?.active&&(o.preventDefault(),o.stopPropagation(),this.cancel())},this.onOther=o=>{this.state&&o.pointerId!==this.state.pointer&&this.cancel()},this.onBlur=()=>this.cancel(),this.onScroll=()=>{this.state&&!this.state.active&&this.stop()},e.addEventListener("pointerdown",o=>this.start(o))}start(t){if(t.button!==0||this.state)return;let e=this.view.state,n=v(e.doc),i=e.selection,o=Math.min(this.index(),n.length-1),r=i instanceof C&&n[o].at>=i.from&&n[o].end<=i.to,{lo:c,hi:d}=r?i.span(e.doc):I(n,o,o);if(this.state={index:o,span:R(n,c,d),touch:t.pointerType==="touch",pointer:t.pointerId,x0:t.clientX,y0:t.clientY,x:t.clientX,y:t.clientY,hold:0,active:!1,raf:0,gap:void 0,targets:[],target:null},this.grip.setPointerCapture?.(t.pointerId),this.grip.addEventListener("pointermove",this.onMove),this.grip.addEventListener("pointerup",this.onUp),this.grip.addEventListener("pointercancel",this.onCancel),this.grip.addEventListener("lostpointercapture",this.onCancel),this.state.touch){let h=this.state;h.hold=setTimeout(()=>this.held(h),tt),window.addEventListener("pointerdown",this.onOther,!0),window.addEventListener("blur",this.onBlur),window.addEventListener("scroll",this.onScroll,!0)}t.preventDefault()}held(t){if(!(this.state!==t||t.active)){if(t.hold=0,Math.hypot(t.x-t.x0,t.y-t.y0)>V||!this.view.editable)return this.stop();this.begin()}}move(t){let e=this.state;if(!(!e||t.pointerId!==e.pointer)){if(e.x=t.clientX,e.y=t.clientY,e.touch&&!this.view.editable)return e.active?this.cancel():this.stop();if(!e.active){let n=Math.hypot(e.x-e.x0,e.y-e.y0);if(e.touch){n>V&&this.stop();return}if(n<=Z)return;this.begin()}this.track()}}begin(){let t=this.state;if(!t||t.active)return;let e=this.view.state,n=v(e.doc),i=x(n,t.span);if(!i)return this.cancel();t.active=!0,this.view.dispatch(e.tr.setSelection(X(e.doc,i.lo,i.hi))),this.shell.classList.add("is-dragging");let o=this.shell.appendChild(document.createElement("div"));o.style.cssText="position:absolute;visibility:hidden;width:var(--page-indent)",this.indentPx=o.getBoundingClientRect().width||27,o.remove(),this.scroller=et(this.view.dom),window.addEventListener("keydown",this.onKey,!0),this.loop(),this.track()}track(){let t=this.state,e=this.view,n=e.state;if(!t)return;let i=v(n.doc),o=x(i,t.span);if(!o)return this.cancel();let{lo:r,hi:c}=o,d=nt(i,e),h=it(d,t.y),a=-1,l=null,p=null,E=h<0?d.length:h+1;for(let k=Math.max(0,E-2);k<E;k++){let g=d[k].dom.getBoundingClientRect();t.y>=g.top+g.height/4&&t.y<=g.bottom-g.height/4&&(p={i:d[k].i,bottom:g.bottom}),l=g.bottom+2}h>=0&&(a=d[h].i,l=d[h].dom.getBoundingClientRect().top-2);let f=r<0?null:p&&q(n,i,r,c,p.i),u=f?`summary:${p.i}`:a;(u!==t.gap||n.doc!==t.doc)&&(t.gap=u,t.doc=n.doc,t.targets=r<0?[]:f?[f]:U(n,i,r,c,a)),f&&(l=p.bottom+2);let m=e.dom.getBoundingClientRect().left;t.target=z(t.targets,(t.x-m)/this.indentPx);let T=this.shell.getBoundingClientRect();if(!t.target||l===null){this.line.hidden=!0,this.shell.dataset.drop="none";return}this.shell.dataset.drop="ok",this.line.hidden=!1,this.line.style.setProperty("--page-drop-y",`${l-T.top}px`),this.line.style.setProperty("--page-drop-x",`${m-T.left+t.target.depth*this.indentPx}px`),this.line.style.setProperty("--page-drop-w",`${e.dom.getBoundingClientRect().right-m-t.target.depth*this.indentPx}px`)}loop(){let t=()=>{let e=this.state;if(!e?.active)return;if(e.touch&&!this.view.editable)return this.cancel();let n=this.scroller,i=n===n.ownerDocument.scrollingElement?{top:0,bottom:window.innerHeight}:n.getBoundingClientRect(),o=0;e.y<i.top+b?o=-W*Math.min(1,(i.top+b-e.y)/b):e.y>i.bottom-b&&(o=W*Math.min(1,(e.y-(i.bottom-b))/b)),o&&(n.scrollTop+=o,this.track()),e.raf=requestAnimationFrame(t)};this.state.raf=requestAnimationFrame(t)}end(t){let e=this.state;if(!e||t.pointerId!==e.pointer)return;if(!e.active){if(this.stop(),t.type==="pointerup"){let l=v(this.view.state.doc),p=x(l,e.span);p&&this.onClick(p.lo)}return}if(this.track(),this.state!==e)return;let n=e.target,i=this.view.state,o=v(i.doc),r=x(o,e.span);if(this.stop(),!n||!r)return;let{lo:c,hi:d}=r;if(!n.open&&(n.at===o[c].at||n.at===o[d].end)&&n.parent===(o[c].node.attrs.parent??null)&&(o[c].node.type.name!=="list_item"||n.indent===o[c].node.attrs.indent))return;if(this.view.dispatch(H(P(i,o,c,d,n)).scrollIntoView()),this.view.state.doc===i.doc)return M(this.view,"Move cancelled");let a=d-c+1;M(this.view,`Moved ${a} ${a===1?"block":"blocks"}`),this.view.focus()}cancel(){this.stop(),M(this.view,"Move cancelled")}stop(){let t=this.state;t&&(this.state=null,clearTimeout(t.hold),cancelAnimationFrame(t.raf),this.grip.removeEventListener("pointermove",this.onMove),this.grip.removeEventListener("pointerup",this.onUp),this.grip.removeEventListener("pointercancel",this.onCancel),this.grip.removeEventListener("lostpointercapture",this.onCancel),this.grip.releasePointerCapture?.(t.pointer),window.removeEventListener("pointerdown",this.onOther,!0),window.removeEventListener("blur",this.onBlur),window.removeEventListener("scroll",this.onScroll,!0),window.removeEventListener("keydown",this.onKey,!0),this.shell.classList.remove("is-dragging"),delete this.shell.dataset.drop,this.line.hidden=!0)}destroy(){this.stop(),this.line.remove()}};export{v as a,et as b,G as c};