@panphora/clayjs 1.22.0 → 1.23.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 (177) hide show
  1. package/dist/all.js +1 -1
  2. package/dist/clay-dom.js +1 -1
  3. package/dist/clay-events.js +1 -1
  4. package/dist/clay-internals.js +1 -1
  5. package/dist/clay-options.js +1 -1
  6. package/dist/clay-router.js +1 -1
  7. package/dist/clay-ui.js +1 -1
  8. package/dist/clay-utils.js +1 -1
  9. package/dist/clay.js +1 -1
  10. package/dist/clay.standalone.js +1228 -715
  11. package/dist/m/attrs/{save-freeze-MTFVVYV5.js → save-freeze-JZHKRQLR.js} +1 -1
  12. package/dist/m/{c-TV7JHSRL.js → c-24PMUJIV.js} +1 -1
  13. package/dist/m/{c-NBNRLZXO.js → c-2AYVYEI4.js} +1 -1
  14. package/dist/m/{c-VIW5X35H.js → c-2L6O5PDS.js} +1 -1
  15. package/dist/m/{c-FNIGX4FI.js → c-2RYOGUQM.js} +1 -1
  16. package/dist/m/{c-LDUNOR57.js → c-2Z22FCFK.js} +13 -25
  17. package/dist/m/{c-DKFSOJCV.js → c-2ZVOEU4M.js} +1 -1
  18. package/dist/m/{c-BJPZCWAV.js → c-37NAONZA.js} +1 -1
  19. package/dist/m/{c-CSNE5EIF.js → c-4PO3YGDC.js} +1 -1
  20. package/dist/m/{c-UWT4CXQ4.js → c-5OJ7YF2N.js} +1 -1
  21. package/dist/m/{c-CAWNFER6.js → c-5TIZ2I64.js} +1 -1
  22. package/dist/m/{c-ZO6VL2SC.js → c-5WMXEKFH.js} +1 -1
  23. package/dist/m/{c-4TWARTLS.js → c-6RDOKLN7.js} +1 -1
  24. package/dist/m/{c-6RC66MYY.js → c-6TYGD5AB.js} +1 -1
  25. package/dist/m/c-A4IP6MBC.js +1 -0
  26. package/dist/m/{c-ZAHTFCXQ.js → c-ALDVFPWL.js} +1 -1
  27. package/dist/m/{c-LV5MABYD.js → c-AYVGD6A6.js} +1 -1
  28. package/dist/m/{c-N33TPVTL.js → c-B6O7AJYG.js} +1 -1
  29. package/dist/m/{c-P3WATEDR.js → c-BCGWJYXW.js} +1 -1
  30. package/dist/m/{c-4OGEVKR3.js → c-BGKAT2FL.js} +1 -1
  31. package/dist/m/{c-N7Y52HJH.js → c-BXYSDKAN.js} +1 -1
  32. package/dist/m/c-CRPIDGXC.js +78 -0
  33. package/dist/m/c-CUMXGHVD.js +1 -0
  34. package/dist/m/{c-Q5KAQJAG.js → c-DTMZ3ZHI.js} +1 -1
  35. package/dist/m/{c-GY4ODHO2.js → c-ELYIIYRS.js} +1 -1
  36. package/dist/m/{c-67LGZ52V.js → c-FCSZ3DC5.js} +1 -1
  37. package/dist/m/{c-NLWEZYKJ.js → c-FQGHR32O.js} +1 -1
  38. package/dist/m/{c-PCEMXY2K.js → c-G4PWUDD5.js} +1 -1
  39. package/dist/m/{c-6KBKYLPO.js → c-G6COVIZB.js} +1 -1
  40. package/dist/m/c-GBTVCJXC.js +1 -0
  41. package/dist/m/c-GC2HICFJ.js +1 -0
  42. package/dist/m/{c-TMT5TL65.js → c-HCNWJE4A.js} +2 -2
  43. package/dist/m/{c-DZBZ57EE.js → c-JCOQVZYS.js} +1 -1
  44. package/dist/m/{c-FAXQU7MQ.js → c-JGHEACGK.js} +1 -1
  45. package/dist/m/{c-PWBJVHA4.js → c-JGLX6TBK.js} +1 -1
  46. package/dist/m/c-JNRKHYWO.js +1 -0
  47. package/dist/m/{c-6UEFPHHE.js → c-KDXIJEEF.js} +1 -1
  48. package/dist/m/{c-FMCPQ4VT.js → c-L4KMT7FO.js} +2 -2
  49. package/dist/m/{c-OI2BYWVV.js → c-LCYPMULG.js} +1 -1
  50. package/dist/m/{c-4RFZROCF.js → c-LIGQYZ7M.js} +4 -4
  51. package/dist/m/{c-QHVCUTJV.js → c-LKIWEPAV.js} +1 -1
  52. package/dist/m/{c-EDSPKYMA.js → c-LUXAB2XI.js} +1 -1
  53. package/dist/m/{c-DEAFCHDO.js → c-LWIDDWAR.js} +2 -2
  54. package/dist/m/c-MPSKIU2I.js +1 -0
  55. package/dist/m/{c-6PBXRWDX.js → c-NK33MMYF.js} +1 -1
  56. package/dist/m/{c-F5AER2ID.js → c-NQLWOHLH.js} +1 -1
  57. package/dist/m/{c-L7K5EXU2.js → c-NTHUTABN.js} +1 -1
  58. package/dist/m/{c-4PHDUV3H.js → c-NW54NHKE.js} +1 -1
  59. package/dist/m/{c-3AXJDL2P.js → c-OG6GFSUX.js} +1 -1
  60. package/dist/m/{c-MTQHWQC3.js → c-OKEGUICD.js} +1 -1
  61. package/dist/m/c-OPONJ2UK.js +128 -0
  62. package/dist/m/{c-LF6HNVPU.js → c-OWQWOGYI.js} +1 -1
  63. package/dist/m/{c-FDAXZ2PM.js → c-P6Q2ZTFQ.js} +1 -1
  64. package/dist/m/c-PKCCHJ5X.js +1 -0
  65. package/dist/m/c-PWJSJEJU.js +1 -0
  66. package/dist/m/{c-Z7RJANGO.js → c-PXLTUYZC.js} +1 -1
  67. package/dist/m/c-QEN6HZCA.js +1 -0
  68. package/dist/m/{c-26KVJS6J.js → c-QGAPG7OM.js} +1 -1
  69. package/dist/m/{c-HWR6GMGK.js → c-QIR5CAKM.js} +1 -1
  70. package/dist/m/{c-QJFYVCJO.js → c-QM5LXRDT.js} +1 -1
  71. package/dist/m/{c-MRURHLKV.js → c-QUGCKMWF.js} +1 -1
  72. package/dist/m/{c-KE33W4RE.js → c-QYYUVLVG.js} +1 -1
  73. package/dist/m/c-RO73MKKR.js +1 -0
  74. package/dist/m/c-SBCBXKOZ.js +26 -0
  75. package/dist/m/{c-XDVAZDUE.js → c-SGRIYOAJ.js} +1 -1
  76. package/dist/m/c-SKF5HL4I.js +4 -0
  77. package/dist/m/{c-IWTTOC2V.js → c-SRPC3VBE.js} +1 -1
  78. package/dist/m/{c-XZJ5IK6Q.js → c-T5NK2TVY.js} +1 -1
  79. package/dist/m/{c-VFES2BP5.js → c-TANBH7FI.js} +1 -1
  80. package/dist/m/{c-H6DXQEH2.js → c-THGQQDYY.js} +1 -1
  81. package/dist/m/{c-BV6FQQXM.js → c-TSBVMWAH.js} +1 -1
  82. package/dist/m/{c-QTC6VGA4.js → c-UD5JZTDL.js} +1 -1
  83. package/dist/m/{c-ZYEJLZEY.js → c-UDGEFWNU.js} +1 -1
  84. package/dist/m/{c-ZSCBEB7I.js → c-UHUNXWKN.js} +1 -1
  85. package/dist/m/{c-FWFJUU3T.js → c-VIRFF5HG.js} +1 -1
  86. package/dist/m/{c-GPTKI7AQ.js → c-VYJ7O4RI.js} +1 -1
  87. package/dist/m/{c-TUGVINJR.js → c-W5E5P2TZ.js} +1 -1
  88. package/dist/m/{c-WWE67K5Y.js → c-W7IPVCAA.js} +1 -1
  89. package/dist/m/{c-HAVGDXAL.js → c-WJ5DRBHT.js} +1 -1
  90. package/dist/m/{c-V2J5C5MT.js → c-WQZTI5P2.js} +1 -1
  91. package/dist/m/c-X5WC4PX5.js +1 -0
  92. package/dist/m/{c-ZKELCT4T.js → c-XCFQEWW6.js} +2 -2
  93. package/dist/m/c-XLQ3BDMM.js +1 -0
  94. package/dist/m/{c-FLBUYV3P.js → c-XX75FFNL.js} +1 -1
  95. package/dist/m/{c-JHJR5BQX.js → c-YK2L436K.js} +1 -1
  96. package/dist/m/{c-MEWUGR4D.js → c-YYMZWQLR.js} +1 -1
  97. package/dist/m/core/{admin-attrs-ZG7R5V3E.js → admin-attrs-U7IJNYBG.js} +1 -1
  98. package/dist/m/core/{autosave-GI3WNJYN.js → autosave-F5YQCKVL.js} +1 -1
  99. package/dist/m/core/{conflict-notice-CEI3XY6A.js → conflict-notice-42H4ASLA.js} +1 -1
  100. package/dist/m/core/{persist-3OPWJKZS.js → persist-CJXIL7D4.js} +1 -1
  101. package/dist/m/core/{save-OJ5NSLS7.js → save-ESPSQPLV.js} +1 -1
  102. package/dist/m/core/{save-core-DX3RFVO3.js → save-core-6SQHOR6W.js} +1 -1
  103. package/dist/m/core/snapshot-FJP5IJL3.js +1 -0
  104. package/dist/m/core/{unsaved-warning-HGYH7O4H.js → unsaved-warning-HNQVTA2D.js} +1 -1
  105. package/dist/m/internals/{index-V4WC44FU.js → index-NRPNDTSA.js} +1 -1
  106. package/dist/m/loader-FBDE2UAB.js +1 -0
  107. package/dist/m/manifest-1D2F5CA5.js +1 -0
  108. package/dist/m/manifest-edit-F7CC5CFD.js +1 -0
  109. package/dist/m/manifest.json +1090 -1020
  110. package/dist/m/page/{editor-BQEPCJLG.js → editor-OSKOW6RS.js} +2 -2
  111. package/dist/m/plugins/{ai-edit-45A2J6LC.js → ai-edit-VV4QTINH.js} +1 -1
  112. package/dist/m/plugins/{cms-IFTKWF4S.js → cms-H7DTMUQX.js} +1 -1
  113. package/dist/m/plugins/{indicator-IPZJ35K6.js → indicator-WVPGMOZ7.js} +1 -1
  114. package/dist/m/plugins/{live-GPQXSXSM.js → live-DCUBKXY4.js} +1 -1
  115. package/dist/m/plugins/menu-Q4MFFQ6E.js +1 -0
  116. package/dist/m/plugins/{page-BAVLWCP6.js → page-OAWUJQEL.js} +2 -2
  117. package/dist/m/plugins/{page-view-P3UGJFDZ.js → page-view-DZ26ZDDQ.js} +1 -1
  118. package/dist/m/plugins/{people-Z4RGVQAV.js → people-5XRNRP5U.js} +1 -1
  119. package/dist/m/plugins/{quickcrop-E34PUYA3.js → quickcrop-WWF5I422.js} +2 -2
  120. package/dist/m/plugins/{richclay-S4NVJYIK.js → richclay-PGOOJ4OK.js} +2 -2
  121. package/dist/m/plugins/{sortable-WJZZBM7R.js → sortable-266HY6TR.js} +1 -1
  122. package/dist/m/plugins/{source-KVN6YNTY.js → source-6BKMK4PO.js} +1 -1
  123. package/dist/m/plugins/{upgrade-KTSICB22.js → upgrade-BNZVFHMZ.js} +1 -1
  124. package/dist/m/plugins/visitor-drafts-2AUYKAIJ.js +20 -0
  125. package/dist/m/plugins/{visitor-drafts-owner-MZP45XSG.js → visitor-drafts-owner-Z5B2OQBR.js} +1 -1
  126. package/dist/m/plugins/visitor-menu-4LQMKLPP.js +1 -0
  127. package/dist/m/plugins/{wire-SYVIBNSE.js → wire-W2EV36KZ.js} +1 -1
  128. package/dist/m/{reader-core-RUIFH32Y.js → reader-core-POFQCKRV.js} +2 -2
  129. package/dist/m/sync/{live-sync-RGQMMWK2.js → live-sync-XGUPHI3I.js} +1 -1
  130. package/dist/m/ui/{index-EZGLEM5P.js → index-VGYAKAKI.js} +1 -1
  131. package/dist/offline-manifest.json +636 -570
  132. package/docs/guide.md +36 -25
  133. package/package.json +1 -1
  134. package/src/core/save-replace.js +5 -2
  135. package/src/core/serialize-steps.js +10 -2
  136. package/src/core/snapshot.js +37 -1
  137. package/src/core/upgrade-run.js +16 -2
  138. package/src/loader-logic.js +6 -2
  139. package/src/plugins/menu/dom-items.js +45 -0
  140. package/src/plugins/menu/looks.js +32 -0
  141. package/src/plugins/menu/shell-style.js +143 -0
  142. package/src/plugins/menu/shell.js +398 -0
  143. package/src/plugins/menu/style.js +15 -116
  144. package/src/plugins/menu/variants.js +56 -10
  145. package/src/plugins/menu/visitor.js +78 -0
  146. package/src/plugins/menu.js +21 -313
  147. package/src/plugins/visitor-drafts/inert.js +1 -0
  148. package/src/plugins/visitor-drafts/intro-style.js +6 -0
  149. package/src/plugins/visitor-drafts/intro.js +77 -25
  150. package/src/plugins/visitor-drafts/owner-chip.js +18 -23
  151. package/src/plugins/visitor-drafts/prompt.js +2 -2
  152. package/src/plugins/visitor-drafts/store.js +58 -5
  153. package/src/plugins/visitor-drafts.js +1 -0
  154. package/src/plugins/visitor-menu.js +13 -0
  155. package/src/sync/live-sync.js +2 -1
  156. package/src/sync/page-relay.js +2 -2
  157. package/src/ui/page-colour.js +17 -9
  158. package/dist/m/c-5AQYL27I.js +0 -1
  159. package/dist/m/c-DP4X4JID.js +0 -1
  160. package/dist/m/c-ECY5AZMH.js +0 -1
  161. package/dist/m/c-EGTIAL6P.js +0 -1
  162. package/dist/m/c-HDWZEJHM.js +0 -183
  163. package/dist/m/c-ILGQ3UXQ.js +0 -1
  164. package/dist/m/c-JFST6QE7.js +0 -1
  165. package/dist/m/c-JH5FF4NL.js +0 -20
  166. package/dist/m/c-KV7R47FR.js +0 -1
  167. package/dist/m/c-MHI3GYKF.js +0 -1
  168. package/dist/m/c-NNNR7OXA.js +0 -3
  169. package/dist/m/c-VSPAFOKU.js +0 -1
  170. package/dist/m/core/snapshot-O7II2AGG.js +0 -1
  171. package/dist/m/loader-V6VI46HU.js +0 -1
  172. package/dist/m/manifest-83C18DED.js +0 -1
  173. package/dist/m/manifest-edit-B28C1985.js +0 -1
  174. package/dist/m/plugins/menu-UN3KRCOF.js +0 -1
  175. package/dist/m/plugins/visitor-drafts-2AWNT23K.js +0 -20
  176. /package/dist/m/plugins/{quickcrop-E34PUYA3.js.LEGAL.txt → quickcrop-WWF5I422.js.LEGAL.txt} +0 -0
  177. /package/dist/m/plugins/{richclay-S4NVJYIK.js.LEGAL.txt → richclay-PGOOJ4OK.js.LEGAL.txt} +0 -0
@@ -1,4 +1,4 @@
1
1
  import{A as Kt,B as Ht,C as jt,E as ot,H as lt,I as dt,J as V,a as O,b as D,ba as Ut,ca as ut,d as $,da as Ft,e as Z,f as Vt,g as tt,ga as Wt,ha as Gt,ia as Xt,j as L,k as et,m as T,ma as ft,n as nt,q as Rt,t as qt,ta as Qt,v as ct,z as _t}from"./c-QIXT3Q7C.js";var be=e=>e==="left"||e==="right"?e:null,{Plugin:wt,PluginKey:ke,TextSelection:I,NodeSelection:Yt,Selection:st}=D,M=T.nodes,S=e=>e.type===M.list_item,A=e=>e.type===M.toggle,k=e=>e.attrs.parent??null,Et="page-step",q="page-move",Mt=e=>e&&(n=>e(Z.closeHistory(n).setMeta(Et,!0)));function y(e,n=null){let t=[],o=new Map,r=[];e.forEach((s,a)=>{let i=t.length,l=t[i-1],c=k(s),d=c!==null&&o.has(c)?o.get(c):-1,f=d;if(S(s)){for(l&&S(l.node)&&k(l.node)===c||(r=[]);r.length&&t[r[r.length-1]].node.attrs.indent>=s.attrs.indent;)r.pop();r.length&&(f=r[r.length-1]),r.push(i)}else r=[];let p=A(s)&&(s.attrs.open||!!n?.has(s.attrs.id)),u=d>=0&&(t[d].hidden||!t[d].open);t.push({node:s,at:a,end:a+s.nodeSize,i,up:f,depth:d>=0?t[d].depth+1:0,hidden:u,open:p,subEnd:i}),A(s)&&s.attrs.id&&o.set(s.attrs.id,i)});for(let s=t.length-1;s>=0;s--){let a=t[s].up;a>=0&&t[s].subEnd>t[a].subEnd&&(t[a].subEnd=t[s].subEnd)}return t}var Jn=(e,n)=>({from:e[n].at,to:e[e[n].subEnd].end});function xe(e,n=null){let t=new Map;n?.forEach(c=>{c.attrs.id&&t.set(c.attrs.id,k(c))}),e.forEach(c=>{c.attrs.id&&t.set(c.attrs.id,k(c))});let o=[];e.forEach((c,d)=>o.push({node:c,at:d}));let r=new Array(o.length).fill(null);for(let c=o.length-2;c>=0;c--){let d=k(o[c+1].node);r[c]=d!==k(o[c].node)?d:r[c+1]}let s=[],a=[null],i=null,l=[];return o.forEach(({node:c,at:d},f)=>{let p=k(c),u=new Set;for(;p!==null&&!a.includes(p)&&!u.has(p);)u.add(p),p=t.has(p)?t.get(p):null;a.includes(p)||(p=null);let h=r[f];a.indexOf(h)>a.indexOf(p)&&(p=h);let m=a.slice(0,a.indexOf(p)+1),g=c.attrs.indent;if(S(c)){let E=Number.isInteger(g)&&g>0?g:0,b=i&&S(i.node)&&i.parent===p;for(b||(l=[]);l.length&&l[l.length-1].orig>E;)l.pop();let N=0;if(l.length){let C=l[l.length-1];N=C.shift,C.orig===E&&l.pop()}g=Math.max(0,Math.min(E-N,b?i.indent+1:0)),l.push({orig:E,shift:E-g})}else l=[];(p!==k(c)||S(c)&&g!==c.attrs.indent)&&s.push({at:d,attrs:{...c.attrs,parent:p,...S(c)?{indent:g}:{}}}),i={node:c,parent:p,indent:g},a=A(c)&&c.attrs.id?[...m,c.attrs.id]:m}),s}function Zn(){let e=new WeakSet;return new wt({appendTransaction(n,t,o){if(!n.some(a=>a.docChanged&&!a.getMeta(ot)))return null;if(e.has(t.doc)&&je(t.doc,o.doc))return e.add(o.doc),null;let r=xe(o.doc,t.doc);if(!r.length)return e.add(o.doc),null;let s=o.tr;for(let a of r)s.setNodeMarkup(a.at,null,a.attrs);return s}})}function at(e,n,t){let o=e.resolve(n.from).index(0),r=Math.min(e.resolve(n.to).index(0),t.length-1);return r>o&&n.to<=t[r].at&&r--,[Math.min(o,t.length-1),r]}var ne=at;function z(e,n,t){let o=n;for(;e[o].up>=0&&t>e[e[o].up].subEnd;)o=e[o].up;let r=e[o].up,s=e[o].subEnd;for(;s<t;)s=e[s+1].subEnd;return{lo:o,hi:s,up:r}}var ye=(e,n,t)=>{let o=e.resolve(Math.max(0,Math.min(n,e.content.size)));return o.depth===0?o.pos:t<0?o.before(1):o.after(1)},Jt=e=>({id:e.node.attrs.id,at:e.at,node:e.node}),bt=(e,n)=>n.id?e.node.attrs.id===n.id:e.at===n.at&&e.node.type===n.node.type&&e.node.content.eq(n.node.content);function Ae(e,n,t){let o=[];for(let r=n;r<=t;r=e[r].subEnd+1)o.push(Jt(e[r]));return{roots:o,members:e.slice(n,t+1).map(Jt)}}function Se(e,n){let t=n.roots.map(a=>e.findIndex(i=>bt(i,a))).filter(a=>a>=0);if(!t.length||t.some(a=>e[a].hidden))return null;let o=t[0],r=e[o].up,s=e[o].subEnd;for(let a of t.slice(1)){if(a!==s+1||e[a].up!==r)return null;s=e[a].subEnd}return e.slice(o,s+1).some(a=>!n.members.some(i=>bt(a,i)))?null:{lo:o,hi:s}}var we=(e,n)=>{let t=o=>({...o,at:n.map(o.at,1)});return{roots:e.roots.map(t),members:e.members.map(t)}},x=class e extends st{map(n,t){return this.getBookmark().map(t).resolve(n)}eq(n){return n instanceof e&&n.anchor===this.anchor&&n.head===this.head}toJSON(){return{type:"page-block",anchor:this.anchor,head:this.head}}static fromJSON(n,t){return new e(n.resolve(t.anchor),n.resolve(t.head))}getBookmark(){let{lo:n,hi:t}=this.span();return new kt(this.anchor,this.head,Ae(y(this.$from.doc),n,t))}span(n=this.$from.doc){return{lo:n.resolve(this.from).index(0),hi:n.resolve(this.to).index(0)-1}}};x.prototype.visible=!1;st.jsonID("page-block",x);var kt=class e{constructor(n,t,o){this.anchor=n,this.head=t,this.span=o}map(n){let t=this.anchor<=this.head;return new e(n.map(this.anchor,t?1:-1),n.map(this.head,t?-1:1),we(this.span,n))}resolve(n){let t=y(n),o=Se(t,this.span);if(!o){let a=t.find(i=>bt(i,this.span.roots[0]));return st.near(n.resolve(a?.at??ye(n,Math.min(this.anchor,this.head),-1)))}let r=t[o.lo].at,s=t[o.hi].end;return this.anchor<=this.head?new x(n.resolve(r),n.resolve(s)):new x(n.resolve(s),n.resolve(r))}},oe=(e,n)=>{for(let t=n-1;t>=0;t--)if(e[t].up===e[n].up)return t;return-1};function G(e,n,t,o,r=()=>null){let s=r(e[n])||{},a="parent"in s?s.parent:k(e[n].node),i=null;for(let d=0;d<e.length&&e[d].end<=o;d++)d>=n&&d<=t||k(e[d].node)===a&&(i=e[d].node.attrs.id);let l=[],c={};for(let d=n;d<=t;d++){let f=e[d].node,p=r(e[d]);l.push(f.attrs.id),p&&"indent"in p&&p.indent!==f.attrs.indent&&(c[f.attrs.id]={indent:p.indent})}return{ids:l,afterId:i,parent:a,attrs:c}}function re(e,n,t,o,r,s=()=>null,a=e.selection){let i=n[t].at,l=n[o].end,c=l-i,d=[];for(let h=t;h<=o;h++){let m=n[h].node;d.push(m.type.create({...m.attrs,...s(n[h])||{},pos:null},m.content,m.marks))}let f=e.tr.delete(i,l),p=r>i?r-c:r;f.insert(p,d);let u=p-i;return a instanceof x?f.setSelection(new x(f.doc.resolve(a.anchor+u),f.doc.resolve(a.head+u))):a instanceof Yt?f.setSelection(Yt.create(f.doc,a.from+u)):f.setSelection(I.create(f.doc,a.anchor+u,a.head+u)),f.setMeta(q,G(n,t,o,r,s))}function xt(e,n,t){let o=e[t].node;if(A(o)){let s=o.attrs.id,a=k(o);return i=>k(i.node)===s?{parent:a}:null}let r=o.attrs.indent-e[n].node.attrs.indent;return s=>S(s.node)?{indent:s.node.attrs.indent+r}:null}var Zt=e=>(n,t)=>{t=Mt(t);let o=y(n.doc);if(!o.length)return!1;let[r,s]=at(n.doc,n.selection,o),{lo:a,hi:i,up:l}=z(o,r,s),c,d=()=>null;if(e<0){let f=oe(o,a);if(f>=0)c=o[f].at;else if(l>=0)c=o[l].at,d=xt(o,a,l);else return!0}else{let f=i+1;if(f<o.length&&o[f].up===l)c=o[o[f].subEnd].end;else if(l>=0)c=o[o[l].subEnd].end,d=xt(o,a,l);else return!0}return t&&t(re(n,o,a,i,c,d).scrollIntoView()),!0},Ee=8,rt=(e,n)=>S(e.node)&&S(n.node)&&k(e.node)===k(n.node);function Me(e,n){n=Mt(n);let t=y(e.doc);if(!t.length)return!1;let[o,r]=at(e.doc,e.selection,t),s=t[o];if(S(s.node)&&o>0&&rt(t[o-1],s)){if(s.node.attrs.indent>t[o-1].node.attrs.indent)return!0;for(let i=o;i<=Math.max(r,s.subEnd);i++)if(t[i].node.attrs.indent>=Ee)return!0;if(n){let i=e.tr,l=r;for(let d=o;d<=l;d++)l=Math.max(l,t[d].subEnd);let c=o-1;for(let d=o;d<=l&&rt(t[d],s);d++)i.setNodeMarkup(t[d].at,null,{...t[d].node.attrs,indent:t[d].node.attrs.indent+1}),c=d;i.setMeta(q,G(t,o,c,t[o].at,d=>d.i>=o&&d.i<=c?{indent:d.node.attrs.indent+1}:null)),n(i)}return!0}let a=oe(t,o);if(a<0||!A(t[a].node)||t[a].subEnd!==o-1)return!0;if(n){let{hi:i}=z(t,o,r),l=e.tr,c=k(s.node),d=t[a].node.attrs.id,f=[];for(let u=o;u<=i;u++)k(t[u].node)===c&&(l.setNodeMarkup(t[u].at,null,{...t[u].node.attrs,parent:d}),f.push(t[u].node.attrs.id));t[a].node.attrs.open||l.setNodeMarkup(t[a].at,null,{...t[a].node.attrs,open:!0});let p=G(t,o,i,t[o].at,u=>u.i>=o&&u.i<=i&&k(u.node)===c?{parent:d}:null);l.setMeta(q,{...p,ids:f,attrs:t[a].node.attrs.open?p.attrs:{...p.attrs,[d]:{open:!0}}}),n(l)}return!0}function vt(e,n){n=Mt(n);let t=y(e.doc);if(!t.length)return!1;let[o,r]=at(e.doc,e.selection,t),s=t[o];if(S(s.node)&&s.node.attrs.indent>0){if(n){let{lo:d,hi:f}=z(t,o,r),p=e.tr,u=new Set;for(let h=o;h<=r;){let m=t[h];if(S(m.node)&&m.node.attrs.indent>0)for(let g=h;g<=m.subEnd;g++)S(t[g].node)&&(p.setNodeMarkup(t[g].at,null,{...t[g].node.attrs,indent:t[g].node.attrs.indent-1}),u.add(g));h=m.subEnd+1}p.setMeta(q,G(t,d,f,t[d].at,h=>u.has(h.i)?{indent:h.node.attrs.indent-1}:null)),n(p)}return!0}if(k(s.node)===null)return!0;let{lo:i,hi:l}=z(t,o,r),c=t[i].up;for(;c>=0&&!A(t[c].node);)c=t[c].up;if(c<0)return!0;if(n){let d=xt(t,i,c),f=t[c].subEnd;if(l===f){let p=e.tr;for(let u=i;u<=l;u++){let h=d(t[u]);h&&p.setNodeMarkup(t[u].at,null,{...t[u].node.attrs,...h})}p.setMeta(q,G(t,i,l,t[i].at,d)),n(p)}else n(re(e,t,i,l,t[f].end,d).scrollIntoView())}return!0}function se(e){let n=e.tr;return e.selection.empty||n.deleteSelection(),n}function ve(e,n){let{$from:t,$to:o,empty:r}=e.selection;if(t.depth!==1||!S(t.parent)||!t.sameParent(o))return!1;if(r&&t.parent.content.size===0){let h=t.parent;return h.attrs.indent>0?vt(e,n):(n&&n(e.tr.setNodeMarkup(t.before(),M.paragraph,{id:h.attrs.id,pos:h.attrs.pos,parent:h.attrs.parent})),!0)}let s=se(e),a=s.selection.$from,i=a.parent,l=y(s.doc),c=a.index(0),d=a.parentOffset===0,f=a.parentOffset===i.content.size,p=l[c+1],u=f&&p&&rt(p,l[c])&&p.node.attrs.indent>i.attrs.indent;return d?(s.split(a.pos,1,[{type:M.list_item,attrs:i.attrs}]),s.setNodeMarkup(l[c].at,null,{...i.attrs,checked:!1})):s.split(a.pos,1,[{type:M.list_item,attrs:{...i.attrs,checked:!1,indent:i.attrs.indent+(u?1:0)}}]),n&&n(s.scrollIntoView()),!0}function Te(e,n){let{$from:t,$to:o}=e.selection;if(t.depth!==1||!A(t.parent)||!t.sameParent(o))return!1;let r=se(e),s=r.selection.$from,a=s.parent,i=y(r.doc),l=s.index(0),c=i[l],d=c.subEnd>l;if(a.content.size===0&&!d)return r.setNodeMarkup(c.at,M.paragraph,{id:a.attrs.id,pos:a.attrs.pos,parent:a.attrs.parent}),n&&n(r),!0;if(s.parentOffset===0&&a.content.size>0)return r.insert(c.at,M.paragraph.create({parent:k(a)})),n&&n(r.scrollIntoView()),!0;let f=a.content.cut(s.parentOffset);if(a.attrs.open)r.split(s.pos,1,[{type:M.paragraph,attrs:{parent:a.attrs.id}}]);else{let p=i[c.subEnd].end,u=r.steps.length;r.delete(s.pos,c.end-1);let h=r.mapping.slice(u).map(p);r.insert(h,M.toggle.create({parent:k(a),open:!1},f)),r.setSelection(I.create(r.doc,h+1))}return n&&n(r.scrollIntoView()),!0}function Ne(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||t.parent.type!==M.paragraph||t.parent.content.size)return!1;let r=k(t.parent);if(r===null)return!1;let s=y(e.doc),a=t.index(0),i=s.findIndex(l=>l.node.attrs.id===r);if(i<0||s[i].subEnd!==a)return!1;if(n){let l=s[a].node.attrs.id,c=k(s[i].node),d=a>0?s[a-1].node:null,f=e.tr.setNodeMarkup(s[a].at,null,{...t.parent.attrs,parent:c});f.setMeta(q,{ids:[l],afterId:d?d.attrs.id:null,parent:k(d??s[a].node),attrs:{[l]:{parent:c}}}),n(f)}return!0}function Ie(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||!t.parent.isTextblock||t.parent.type.spec.code)return!1;let r=t.parent;if(S(r)||A(r)||k(r)===null||t.parentOffset!==r.content.size)return!1;if(n){let s=e.tr.split(t.pos,1,[{type:M.paragraph,attrs:{parent:k(r)}}]);n(s.scrollIntoView())}return!0}function Ce(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||!S(t.parent)||t.parentOffset!==0)return!1;if(t.parent.attrs.indent>0)return vt(e,n);let r=t.parent;return n&&n(e.tr.setNodeMarkup(t.before(),M.paragraph,{id:r.attrs.id,pos:r.attrs.pos,parent:r.attrs.parent})),!0}function Oe(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||!A(t.parent)||t.parentOffset!==0)return!1;let r=t.parent;return n&&n(e.tr.setNodeMarkup(t.before(),M.paragraph,{id:r.attrs.id,pos:r.attrs.pos,parent:r.attrs.parent})),!0}function Tt(e,n){if(n<=0||!e[n-1].hidden)return-1;let t=n-1;for(;t>=0&&e[t].hidden;)t--;return t>=0&&A(e[t].node)&&e[t].subEnd>=n-1?t:-1}function Nt(e,n,t,o){let r=e.tr,s=n[o],a=n[t].end-1;return r.delete(s.at,s.end),s.node.content.size&&r.insert(a,s.node.content),r.setSelection(I.create(r.doc,a))}function De(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||t.parentOffset!==0||!t.parent.isTextblock)return!1;let r=y(e.doc),s=t.index(0),a=Tt(r,s);return a<0?!1:(n&&n(Nt(e,r,a,s).scrollIntoView()),!0)}function $e(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||!A(t.parent)||t.parent.attrs.open||t.parentOffset!==t.parent.content.size)return!1;let r=y(e.doc),s=t.index(0),a=r[s].subEnd+1;return a===s+1?!1:(a>=r.length||!r[a].node.isTextblock||n&&n(Nt(e,r,s,a).scrollIntoView()),!0)}function Le(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1)return!1;let r=t.parent,s=t.index(0);if(!r.isTextblock||r.type.spec.code||A(r)||!r.content.size||t.parentOffset!==r.content.size||s+1>=e.doc.childCount||!A(e.doc.child(s+1)))return!1;if(n&&r.type!==M.paragraph)n(e.tr.setSelection(I.create(e.doc,t.after()+1)).scrollIntoView());else if(n){let a=t.before(),i=e.tr.insert(t.after()+1,r.content).delete(a,t.after());n(i.setSelection(I.create(i.doc,a+1+r.content.size)).scrollIntoView())}return!0}var ae=e=>(n,t)=>{let{$from:o,empty:r}=n.selection;if(!r||o.depth!==1||!o.parent.isTextblock)return!1;let s=o.parent,a=o.index(0);if(o.parentOffset!==(e<0?0:s.content.size))return!1;let i=y(n.doc),l=e<0?Tt(i,a):-1,c=l>=0?l:a+e;if(c<0||c>=i.length)return!1;let d=i[c].node;if(!d.isTextblock||!s.type.spec.code&&!d.type.spec.code)return!1;if(!t)return!0;let f=n.tr,p=i[a],u=i[c],h=e<0?u.end-1:u.at+1;return!s.content.size&&!s.type.spec.code?f.delete(p.at,p.end).setSelection(I.create(f.doc,f.mapping.map(h))):!d.content.size&&!d.type.spec.code?f.delete(u.at,u.end):f.setSelection(I.create(f.doc,h)),t(f.scrollIntoView()),!0},Be=ae(-1),Pe=ae(1);function ze(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||t.parentOffset!==0||!t.parent.isTextblock)return!1;let r=t.parent;if(S(r)||A(r)||k(r)===null)return!1;let s=t.index(0);return e.doc.child(s-1).attrs.id!==k(r)?!1:(n&&n(Nt(e,y(e.doc),s-1,s).scrollIntoView()),!0)}var It="page-reveal";function to(e,n){return n.length?e.setMeta(It,{add:n}):e}function ie(e,n,t,o=y(e.doc)){let r=o[n];return e.tr.setNodeMarkup(r.at,null,{...r.node.attrs,open:t}).setMeta("addToHistory",!1).setMeta(It,{clear:[r.node.attrs.id]})}function Ve(e,n){let{$from:t}=e.selection;return t.depth!==1||!A(t.parent)?!1:(n&&n(ie(e,t.index(0),!t.parent.attrs.open)),!0)}function Re(e){let n=[];for(let t of e)!A(t.node)||t.hidden||t.open||t.subEnd===t.i||n.push({line:t.at+1,sumEnd:t.end-1,from:t.end,to:e[t.subEnd].end});return n}var yt=(e,n)=>n>e.from&&n<e.to;function At(e,n,t,o){if(o>0){let r=t.to;for(;;){let s=st.findFrom(e.resolve(r),1,!0);if(!s)break;let a=n.find(i=>yt(i,s.head));if(!a)return s.head;r=a.to}}return t.sumEnd}function te(e,n,t,o=-1,r=!1){if(!t.length)return null;let{anchor:s,head:a}=n;if(!(n instanceof I)){let c=t.find(d=>n.from>=d.from&&n.from<d.to);return c?I.create(e,c.sumEnd):null}let i=t.find(c=>yt(c,a));i&&(a=At(e,t,i,o));let l=t.find(c=>yt(c,s));if(l&&(s=l.sumEnd),!r&&s!==a){let c=Math.min(s,a),d=Math.max(s,a),f=t.find(p=>(c>p.line||c===p.sumEnd)&&c<p.from&&d>=p.to);if(f){let p=c===f.sumEnd?At(e,t,f,1):f.line;s<a?s=p:a=p}}return s===n.anchor&&a===n.head?null:I.create(e,s,a)}var qe=e=>{let n="";for(;e>0;)e--,n=String.fromCharCode(97+e%26)+n,e=Math.floor(e/26);return n},_e=e=>[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]].reduce((n,[t,o])=>{for(;e>=t;)n+=o,e-=t;return n},"");function Ke(e){let n=new Map,t=[];return e.forEach((o,r)=>{if(!S(o.node)){t=[];return}r>0&&!rt(e[r-1],o)&&(t=[]);let s=o.node.attrs.indent;if(t.length=s+1,o.node.attrs.kind!=="ordered"){t[s]=0;return}t[s]=(t[s]||0)+1;let a=t[s];n.set(r,`${s%3===0?a:s%3===1?qe(a):_e(a)}.`)}),n}var F=new ke("page-collapse"),He=["id","parent","indent","kind","open"];function je(e,n){if(e.childCount!==n.childCount)return!1;for(let t=0;t<e.childCount;t++){let o=e.child(t),r=n.child(t);if(o!==r){if(o.type!==r.type)return!1;for(let s of He)if(o.attrs[s]!==r.attrs[s])return!1}}return!0}var Ue=new Set;function pt(e,n=Ue){let t=y(e,n);return{decos:Ge(e,t),ranges:Re(t),reveal:n}}var Fe=null,We=()=>Fe??=class extends $.DecorationSet{forChild(e,n){if(n.isLeaf)return $.DecorationSet.empty;let t=this.children,o=0,r=t.length/3;for(;o<r;){let s=o+r>>1;t[s*3]<e?o=s+1:r=s}return o*3<t.length&&t[o*3]===e?t[o*3+2]:$.DecorationSet.empty}};function Ge(e,n=y(e)){let{Decoration:t,DecorationSet:o}=$,r=Ke(n),s=[],a=[];for(let i of n){let l={};if(i.hidden&&(l.class="page-hidden",l["aria-hidden"]="true"),i.depth&&(l.style=`--page-depth:${i.depth}`),r.has(i.i)&&(l["data-marker"]=r.get(i.i)),A(i.node)&&(l["aria-expanded"]=i.open?"true":"false"),Object.keys(l).length&&s.push(t.node(i.at,i.end,l)),A(i.node)&&!i.hidden){let c=t.widget(0,()=>Xe(i.node,i.open),{side:-1,ignoreSelection:!0,key:`t:${i.node.attrs.id}:${i.open}`});a.push(i.at,i.end,new o([c],[]))}}return!s.length&&!a.length?o.empty:new(We())(s,a)}function Xe(e,n=e.attrs.open){let t=document.createElement("button");return t.type="button",t.className="page-toggle-button",t.contentEditable="false",t.setAttribute("aria-label",n?"Collapse":"Expand"),t.setAttribute("data-toggle",e.attrs.id||""),t}function eo(){let e=!1;return new wt({key:F,state:{init:(n,t)=>pt(t.doc),apply(n,t,o,r){let s=n.getMeta(It);if(s){let a=new Set(t.reveal);for(let i of s.add??[])a.add(i);for(let i of s.clear??[])a.delete(i);return pt(r.doc,a)}return n.docChanged?pt(r.doc,t.reveal):t}},appendTransaction(n,t,o){if(!n.some(i=>i.docChanged||i.selectionSet))return null;let s=n.some(i=>i.selectionSet)&&o.selection.head>=t.selection.head?1:-1,a=te(o.doc,o.selection,F.getState(o).ranges,s,e);return a?o.tr.setSelection(a):null},props:{decorations:n=>F.getState(n).decos,handleDOMEvents:{mousedown:(n,t)=>{let o=t.target.closest?.(".page-toggle-button");if(o){t.preventDefault();let a=y(n.state.doc),i=a.findIndex(l=>l.node.attrs.id===o.dataset.toggle);return i>=0&&n.dispatch(ie(n.state,i,!a[i].node.attrs.open,a)),!0}e=!0;let r=n.dom.ownerDocument.defaultView,s=()=>{e=!1,r.removeEventListener("mouseup",s,!0);let a=te(n.state.doc,n.state.selection,F.getState(n.state).ranges,1,!1);a&&n.dispatch(n.state.tr.setSelection(a))};return r.addEventListener("mouseup",s,!0),!1}},handleKeyDown(n,t){let o={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1}[t.key];if(!o||t.altKey||t.metaKey||t.ctrlKey)return!1;let{head:r}=n.state.selection,a=t.key==="ArrowDown"||t.key==="ArrowUp"?o>0?"down":"up":o>0?"forward":"backward";if(!n.endOfTextblock(a))return!1;let i=y(n.state.doc),{ranges:l}=F.getState(n.state),d=n.state.doc.resolve(r).index(0),f=null;if(o>0){let u=l.find(h=>h.from===i[d].end);u&&(f=At(n.state.doc,l,u,1))}else{let u=Tt(i,d);u>=0&&(f=t.shiftKey?i[u].at+1:i[u].end-1)}if(f===null||f===r)return!1;let p=t.shiftKey?n.state.selection.anchor:f;return n.dispatch(n.state.tr.setSelection(I.create(n.state.doc,p,f)).scrollIntoView()),!0}}})}var ee=/^([ \t]*)(?:([-*+•])|(\d+)[.)])[ \t]+(?:\[([ xX])\][ \t]+)?(.*)$/;function Qe(e){let n=e.replace(/\r\n?/g,`
2
2
  `).split(`
3
- `);if(!n.some(r=>ee.test(r)))return null;let t=[],o=[];for(let r of n){if(!r.trim())continue;let s=ee.exec(r);if(!s){t.length=0,o.push(M.paragraph.create(null,r.trim()?T.text(r.trim()):null));continue}let a=s[1].replace(/\t/g," ").length;for(;t.length&&t[t.length-1]>a;)t.pop();(!t.length||t[t.length-1]<a)&&t.push(a);let i=Math.min(t.length-1,o.length&&S(o[o.length-1])?o[o.length-1].attrs.indent+1:0),l=s[4]!==void 0?"check":s[3]!==void 0?"ordered":"bullet";o.push(M.list_item.create({kind:l,indent:i,checked:s[4]==="x"||s[4]==="X"},s[5]?T.text(s[5]):null))}return new O.Slice(O.Fragment.from(o),0,0)}var ht=new Set(["UL","OL"]),mt=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","PRE","BLOCKQUOTE","UL","OL","LI","DETAILS","SUMMARY","TABLE","HR","FIGURE"]);function Ye(e){let n=e.querySelector(":scope > input[type=checkbox], :scope > p > input[type=checkbox], :scope > label > input[type=checkbox]");if(n)return{check:!0,checked:n.checked||n.hasAttribute("checked")};if(e.getAttribute("role")==="checkbox"||e.hasAttribute("aria-checked"))return{check:!0,checked:e.getAttribute("aria-checked")==="true"};if(e.hasAttribute("data-checked"))return{check:!0,checked:e.getAttribute("data-checked")==="true"};let o=e.className||"";return/\b(checked|task-list-item|to-do)\b/.test(o)||e.closest?.("ul.to-do-list, ul.contains-task-list")?{check:!0,checked:/\bchecked\b/.test(o)||!!e.querySelector(".checkbox-on")}:{check:!1,checked:!1}}function Je(e){let n=(e.getAttribute("style")||"")+";"+(e.parentElement?.getAttribute("style")||""),t=/list-style-type\s*:\s*([a-z-]+)/i.exec(e.getAttribute("style")||"")?.[1];return t?/decimal|alpha|roman|latin|greek/.test(t)?"ordered":"bullet":e.parentElement?.tagName==="OL"?"ordered":"bullet"}function Ze(e,n=globalThis.document){let t=n.createElement("div");t.innerHTML=e;for(let u of t.querySelectorAll('b[style*="font-weight:normal"], b[style*="font-weight: normal"]'))u.replaceWith(...u.childNodes);let o=0,r=n.createElement("div"),s=u=>{let h=parseInt(u.getAttribute("aria-level"),10);if(h>0)return h-1;let m=-1;for(let g=u.parentElement;g&&g!==t;g=g.parentElement)ht.has(g.tagName)&&m++;return Math.max(0,m)},a=[];function i(u,h,m){let g=n.createElement("div"),{check:E,checked:b}=Ye(u);g.setAttribute("data-page-li",""),g.setAttribute("data-kind",E?"check":Je(u)),g.setAttribute("data-checked",b?"true":"false"),g.dataset.depth=String(s(u)),h&&g.setAttribute("data-page-parent",h);let N=!0,C=[];for(let w of[...u.childNodes]){if(w.nodeType===1&&ht.has(w.tagName)){C.push(w);continue}if(!(w.nodeType===1&&w.tagName==="INPUT")){if(w.nodeType===1&&mt.has(w.tagName)){N||g.appendChild(n.createElement("br"));for(let P of[...w.childNodes])P.nodeType===1&&P.tagName==="INPUT"||g.appendChild(P);N=!1;continue}g.appendChild(w),(w.nodeType!==3||w.textContent.trim())&&(N=!1)}}m.appendChild(g),a.push(g);for(let w of C)l(w,h,m)}function l(u,h,m){let g=null,E=b=>{g||(g=n.createElement("p"),h&&g.setAttribute("data-page-parent",h),m.appendChild(g)),g.appendChild(b)};for(let b of[...u.childNodes])if(!(b.nodeType===1&&(b.tagName==="META"||b.tagName==="STYLE"))){if(b.nodeType===1&&b.tagName==="BR"){g=null;continue}if(b.nodeType!==1){b.nodeType===3&&(g||b.textContent.trim())&&E(b);continue}if(!mt.has(b.tagName)&&b.tagName!=="ASIDE"){E(b);continue}if(g=null,ht.has(b.tagName)){l(b,h,m);continue}if(b.tagName==="LI"){i(b,h,m);continue}if(b.tagName==="DETAILS"){let N=`paste-${++o}`,C=b.querySelector(":scope > summary"),w=n.createElement("div");w.setAttribute("data-page-toggle",N),b.hasAttribute("open")&&w.setAttribute("data-open","true"),h&&w.setAttribute("data-page-parent",h);let P=C?.querySelector(":scope > h1, :scope > h2, :scope > h3");P?(w.setAttribute("data-level",P.tagName[1]),w.append(...P.childNodes)):C&&w.append(...C.childNodes),m.appendChild(w);for(let Pt of[...b.childNodes])if(Pt!==C){let zt=n.createElement("div");zt.appendChild(Pt),l(zt,N,m)}continue}if(b.tagName==="DIV"&&!b.hasAttribute("data-page-li")&&[...b.children].some(N=>mt.has(N.tagName))){l(b,h,m);continue}h&&b.setAttribute("data-page-parent",h),m.appendChild(b)}}l(t,null,r);let c=a.length?Math.min(...a.map(u=>+u.dataset.depth)):0,d=null;for(let u of a){let h=+u.dataset.depth-c,m=d&&u.previousElementSibling===d?+d.getAttribute("data-indent")+1:0;u.setAttribute("data-indent",String(Math.min(h,m))),u.removeAttribute("data-depth"),d=u}let f=u=>{if(u.nodeType!==1||u.tagName==="IMG")return[u.cloneNode(!0)];let h=[],m=u.cloneNode(!1);for(let g of u.childNodes)for(let E of f(g))E.nodeType===1&&E.tagName==="IMG"?(m.hasChildNodes()&&h.push(m),h.push(E),m=u.cloneNode(!1)):m.appendChild(E);return(m.hasChildNodes()||!h.length)&&h.push(m),h};for(let u of[...r.children]){if(!u.matches("p, h1, h2, h3, h4, h5, h6, aside, div[data-page-li], div.page-li")||!u.querySelector("img"))continue;let h=f(u),m=u.getAttribute("data-page-parent");if(m)for(let g of h)g.setAttribute("data-page-parent",m);u.replaceWith(...h)}let p=t.querySelector("[data-pm-slice]");return p&&r.firstElementChild?.setAttribute("data-pm-slice",p.dataset.pmSlice),r.innerHTML}var gt=(e,n=0)=>e!==null&&e!==""&&Number.isInteger(+e)&&+e>=n?+e:null,v=e=>e.getAttribute("data-page-parent")||null,tn=Rt([]).type,en=Object.create(T,{marks:{value:{...T.marks,[nt]:tn}}}),ce=e=>{let n;try{n=Qt(e)}catch{return null}return!n||typeof n.t!="string"||n.t==="opaque_block"||Object.hasOwn(Ft,n.t)?null:n},nn=e=>{let n=ce(e);return n?{raw:n,parent:v(e)}:!1},on=e=>{let n=ce(e);if(!n||typeof n.c!="string"||!n.c)return O.Fragment.empty;let t=Ht(n.m,n.c.length);return O.Fragment.from(jt(T,n.c,t,T.nodes.opaque_block))},rn=e=>{try{return{entries:Wt(e.getAttribute(ut))}}catch{return!1}},X=null,sn=()=>import("./c-4OGEVKR3.js").then(e=>{X=e},()=>{}),an=new O.DOMParser(en,[{tag:"table",node:"table",getAttrs:e=>X?.table(e)??!1,getContent:e=>X.rows(e)},{tag:`div[${Ut}]`,node:"opaque_block",getAttrs:nn,getContent:on},{tag:`span[${ut}]`,mark:nt,getAttrs:rn},{tag:"div[data-page-li]",node:"list_item",getAttrs:e=>({kind:e.getAttribute("data-kind")||"bullet",indent:+e.getAttribute("data-indent")||0,checked:e.getAttribute("data-checked")==="true",parent:v(e)})},{tag:"div.page-li",node:"list_item",getAttrs:e=>({kind:e.getAttribute("data-kind")||"bullet",indent:+e.getAttribute("data-indent")||0,checked:e.getAttribute("data-checked")==="true",parent:v(e)})},{tag:"div[data-page-toggle]",node:"toggle",getAttrs:e=>({id:e.getAttribute("data-page-toggle"),open:e.getAttribute("data-open")==="true",parent:v(e),level:ft(Number(e.getAttribute("data-level")))})},{tag:"div.page-toggle",node:"toggle",getAttrs:e=>({id:e.getAttribute("data-id"),open:e.getAttribute("data-open")==="true",parent:null,level:ft(Number(e.getAttribute("data-level")))})},{tag:"h1",node:"heading",getAttrs:e=>({level:1,parent:v(e)})},{tag:"h2",node:"heading",getAttrs:e=>({level:2,parent:v(e)})},{tag:"h3",node:"heading",getAttrs:e=>({level:3,parent:v(e)})},{tag:"h4",node:"heading",getAttrs:e=>({level:3,parent:v(e)})},{tag:"pre",node:"code_block",preserveWhitespace:"full",getAttrs:e=>({lang:e.getAttribute("data-lang")||"",parent:v(e)})},{tag:"hr",node:"divider",getAttrs:e=>({parent:v(e)})},{tag:"aside.page-callout",node:"callout",getAttrs:e=>({parent:v(e)})},{tag:'figure:not([data-type]), figure[data-type="image"]',node:"image",getAttrs:e=>{let n=e.querySelector("img"),t=et(n?.getAttribute("src"));return t?{src:t,alt:n.getAttribute("alt")||"",caption:e.querySelector("figcaption")?.textContent||"",width:gt(e.getAttribute("data-width")??n.getAttribute("width"),1),align:be(e.getAttribute("data-align")),parent:v(e)}:!1}},{tag:"img[src]",node:"image",getAttrs:e=>{let n=et(e.getAttribute("src"));return n?{src:n,alt:e.getAttribute("alt")||"",width:gt(e.getAttribute("width"),1),parent:v(e)}:!1}},{tag:'div.page-file, div[data-type="file"]',node:"file",getAttrs:e=>{let n=L(e.getAttribute("data-src"));return n?{src:n,name:e.getAttribute("data-name")||"file",size:gt(e.getAttribute("data-size")),mime:e.getAttribute("data-mime")||null,parent:v(e)}:!1}},{tag:"p",node:"paragraph",getAttrs:e=>({parent:v(e)})},{tag:"br",node:"hard_break"},{tag:"strong",mark:"strong"},{tag:"b",mark:"strong",getAttrs:e=>/font-weight\s*:\s*(normal|[1-5]00)\b/.test(e.getAttribute("style")||"")?!1:null},{tag:"span",mark:"strong",getAttrs:e=>/font-weight\s*:\s*(bold|[6-9]00)\b/.test(e.getAttribute("style")||"")?null:!1},{tag:"em",mark:"em"},{tag:"i",mark:"em"},{tag:"span",mark:"em",getAttrs:e=>/font-style\s*:\s*italic/.test(e.getAttribute("style")||"")?null:!1},{tag:"s",mark:"strike"},{tag:"del",mark:"strike"},{tag:"code",mark:"code"},{tag:"a[href]",mark:"link",getAttrs:e=>{let n=L(e.getAttribute("href"));return n?{href:n}:!1}},{tag:"blockquote",node:"quote",getAttrs:e=>({parent:v(e)})},{tag:"u",mark:"underline"},{tag:"mark",mark:"highlight",getAttrs:e=>ct("highlight",{color:e.getAttribute("data-color")})??!1},{tag:"span[data-color]",mark:"text_color",getAttrs:e=>ct("text_color",{color:e.getAttribute("data-color")})??!1}]);function cn(e,n){let t=n.selection.$from,o=n.selection instanceof x,r=o?n.doc.child(n.selection.span().lo):t.depth>=1?t.node(1):null,s=r?k(r):null,a=r&&S(r)?r.attrs.indent:0,i=new Map;e.content.forEach(m=>{A(m)&&m.attrs.id&&i.set(m.attrs.id,V())});let l=[];e.content.forEach(m=>{if(!m.type.spec.group?.includes("block")){l.push(m);return}let g=k(m),E={...m.attrs,pos:null,id:A(m)?i.get(m.attrs.id)??null:null,parent:g!==null&&i.has(g)?i.get(g):s};S(m)&&(E.indent=m.attrs.indent+a),l.push(m.type.create(E,m.content,m.marks))});let c=!r||!(S(r)||A(r)),d=m=>m&&(S(m)||A(m)),f=c&&d(l[0])?0:e.openStart,p=l[l.length-1],u=new Set(i.values()),h=c&&(d(p)||p&&u.has(k(p)))?0:e.openEnd;return new O.Slice(O.Fragment.from(l),o?0:f,o?0:h)}var St=class extends O.DOMSerializer{serializeFragment(n,t,o){let r=super.serializeFragment(n,t,o);if(!n.firstChild?.isBlock)return r;let s=[...r.childNodes];return n.forEach((a,i,l)=>{let c=s[l];!c||c.nodeType!==1||(k(a)!==null&&c.setAttribute("data-page-parent",k(a)),A(a)&&a.attrs.id&&c.setAttribute("data-page-toggle",a.attrs.id),a.type===M.image&&a.attrs.width&&c.setAttribute("data-width",String(a.attrs.width)))}),X?.copy(n,s),r}},le=O.DOMSerializer.fromSchema(T),ln=e=>{let{t:n,...t}=e.attrs.raw??{},{c:o,m:r}=_t(e.content);return o?{t:n,...t,c:o,...r.some(Boolean)?{m:Kt(r)}:{}}:{t:n,...t}},dn=e=>["div",{"data-type":"newer-format",...Gt(ln(e))},0],un=e=>["span",Xt(e.attrs.entries),0],fn={...le.nodes,opaque_block:dn},pn={...le.marks,[nt]:un},hn=new St(fn,pn);function mn(e,n,t){let{$from:o}=e.state.selection,r=o.depth>=1?o.node(1):null;if(!r||!A(r)||r.attrs.open||t.content.childCount<2)return!1;let s=e.state.tr.setNodeMarkup(o.before(1),null,{...r.attrs,open:!0}).replaceSelection(t);return e.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function gn(e){let n=!1;return e?.content?.descendants(t=>n?!1:((t.type===M.quote||t.isText&&t.marks.some(o=>qt.has(o.type.name)))&&(n=!0),!n)),n}function bn(e,n,t){let o=e.state.selection.from,r=e.state.selection.to,s=e.state.doc,a=()=>{let i=t.content.textBetween(0,t.content.size,`
4
- `," ");return!e.isDestroyed&&i&&e.state.doc===s&&e.dispatch(e.state.tr.insertText(i,o,r)),!1};return import("./c-FNIGX4FI.js").then(({pasteFormats:i})=>i(e,t,o,r),a),!0}function no(){return new wt({view(){return sn(),{}},props:{handlePaste(e,n,t){return gn(t)?bn(e,n,t):mn(e,n,t)},clipboardSerializer:hn,clipboardTextSerializer:e=>X?.text(e),transformPastedHTML:e=>Ze(e),clipboardParser:an,clipboardTextParser:(e,n,t)=>t?null:Qe(e),transformPasted:(e,n)=>cn(e,n.state)}})}var W=tt.chainCommands(Ce,Oe,Be,ze,De),R=tt.chainCommands($e,Le,Pe),oo={Enter:tt.chainCommands(ve,Te,Ne,Ie),Backspace:W,"Shift-Backspace":W,"Mod-Backspace":W,"Alt-Backspace":W,"Ctrl-h":W,Delete:R,"Shift-Delete":R,"Mod-Delete":R,"Alt-Delete":R,"Ctrl-d":R,"Ctrl-Alt-Backspace":R,Tab:Me,"Shift-Tab":vt,"Mod-Shift-ArrowUp":Zt(-1),"Mod-Shift-ArrowDown":Zt(1),"Mod-Enter":Ve};function io(){return new D.Plugin({view(e){let n=e.dom.ownerDocument.createElement("div");return n.className="page-live",n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),e.dom.parentElement.appendChild(n),{destroy:()=>n.remove()}}})}function Ct(e,n){let t=e.dom.parentElement?.querySelector(".page-live");t&&(t.textContent="",t.textContent=n)}var de=new D.PluginKey("tableRect");var{Selection:kn,TextSelection:K,NodeSelection:xn,Plugin:yn,PluginKey:An}=D,Q=T.nodes,H=e=>Z.closeHistory(e).setMeta(Et,!0);function Y(e,n,t=n,o=y(e)){let{lo:r,hi:s}=z(o,Math.min(n,t),Math.max(n,t)),a=o[r].at,i=o[s].end;return n<=t?new x(e.resolve(a),e.resolve(i)):new x(e.resolve(i),e.resolve(a))}function Sn(e,n=y(e.doc)){let[t,o]=ne(e.doc,e.selection,n);return z(n,t,o)}var _=(e,n,t)=>{for(let o=n;o>=0&&o<e.length;o+=t)if(!e[o].hidden)return o;return-1};function wn(e,n){if(e.selection instanceof x)return!1;let t=Math.min(e.selection.$head.index(0),e.doc.childCount-1);return n&&n(e.tr.setSelection(Y(e.doc,t))),!0}var ue=e=>(n,t)=>{let o=n.selection;if(!(o instanceof x))return!1;let r=y(n.doc),{lo:s,hi:a}=o.span(n.doc),i=e<0?_(r,s-1,-1):_(r,a+1,1);return i<0||t&&t(n.tr.setSelection(Y(n.doc,i)).scrollIntoView()),!0};function Dt(e,n,t,o){if(o<0)return n;let r=n;for(;e[r].subEnd<t;)r=e[r].subEnd+1;return r}function En(e,n){for(let t=n-1;t>=0;t--)if(e[t].up===e[n].up)return t;return n}var fe=e=>(n,t)=>{let o=n.selection;if(!(o instanceof x))return!1;let r=y(n.doc),{lo:s,hi:a}=o.span(n.doc),i=o.anchor<=o.head,l=i?s:Dt(r,s,a,1),c=i?Dt(r,s,a,1):s;return e>0?i||s===a||c===l?c=_(r,(i?a:c)+1,1):c=_(r,r[c].subEnd+1,1):!i||c===l?c=_(r,(i?c:s)-1,-1):c=En(r,c),c<0||t&&t(n.tr.setSelection(Y(n.doc,l,c,r)).scrollIntoView()),!0};function it(e,n){let t=e.selection;if(!(t instanceof x))return!1;if(n){let o=e.tr.delete(t.from,t.to);o.doc.content.size===0&&o.insert(0,Q.paragraph.create()),o.setSelection(kn.near(o.doc.resolve(Math.min(t.from,o.doc.content.size)),-1)),n(H(o).scrollIntoView())}return!0}function Mn({columns:e={},cards:n={}}){let t=dt(e),o=new Map(t.map(a=>[a,V("c")])),r=lt(null,null,t.length),s={};for(let a of new Set([...t,...Object.values(n).map(i=>i.col)])){let i=dt(Object.fromEntries(Object.entries(n).filter(([,c])=>c.col===a))),l=lt(null,null,i.length);i.forEach((c,d)=>{s[V("k")]={...n[c],col:o.get(a)??a,pos:l[d]}})}return{columns:Object.fromEntries(t.map((a,i)=>[o.get(a),{...e[a],pos:r[i]}])),cards:s}}function vn(e,n){let t=y(e.doc);if(!t.length)return!1;let{lo:o,hi:r}=Sn(e,t);if(n){let s=new Map;for(let f=o;f<=r;f++)t[f].node.type===Q.toggle&&t[f].node.attrs.id&&s.set(t[f].node.attrs.id,V());let a=[];for(let f=o;f<=r;f++){let p=t[f].node,u=p.attrs.parent??null;a.push(p.type.create({...p.attrs,...p.type===Q.board?Mn(p.attrs):{},id:s.get(p.attrs.id)??null,pos:null,parent:s.get(u)??u},p.content,p.marks))}let i=t[r].end,l=i-t[o].at,c=e.tr.insert(i,a),d=e.selection;c.setSelection(d instanceof x?new x(c.doc.resolve(i),c.doc.resolve(i+l)):K.create(c.doc,d.anchor+l,d.head+l)),n(H(c).scrollIntoView())}return!0}var he=(e,n,t,o)=>{for(let r=t;r<=o;r++)if(n[r].node.isTextblock)return n[r].end-1;return-1};function pe(e,n){let t=e.selection;if(!(t instanceof x))return!1;let o=y(e.doc),{lo:r,hi:s}=t.span(e.doc);if(n){let a=he(e.doc,o,r,s);n(e.tr.setSelection(a>=0?K.create(e.doc,a):xn.create(e.doc,o[r].at)))}return!0}var Tn=({$from:e,$to:n})=>{if(e.depth<2||n.depth<2)return null;let t=e.node(1);return t.type.name==="table"&&n.node(1)===t?{from:e.before(1),to:e.after(1)}:null};function Nn(e,n){let t=e.selection,{$from:o,$to:r}=t,s=o.parent.isTextblock&&o.sameParent(r)&&!de.getState(e),a=s&&o.parentOffset===0&&r.parentOffset===r.parent.content.size;if(s&&!a&&o.parent.content.size)return n&&n(e.tr.setSelection(K.create(e.doc,o.start(),o.end()))),!0;let i=Tn(t);return i&&!(t instanceof x&&t.from===i.from&&t.to===i.to)?(n&&n(e.tr.setSelection(new x(e.doc.resolve(i.from),e.doc.resolve(i.to)))),!0):(n&&n(e.tr.setSelection(new x(e.doc.resolve(0),e.doc.resolve(e.doc.content.size)))),!0)}var In=(e,n)=>{let t=e.state,o=t.selection;if(!(o instanceof x))return!1;let r=y(t.doc),{lo:s,hi:a}=o.span(t.doc),i=he(t.doc,r,s,a),l=t.tr;if(i<0){let c=r[a].end;l.insert(c,Q.paragraph.create({parent:r[s].node.attrs.parent??null})),l.setSelection(K.create(l.doc,c+1)),H(l)}else l.setSelection(K.create(l.doc,i));return l.insertText(n),e.dispatch(l.scrollIntoView()),!0},Cn=(e,n,t)=>{let o=e.selection;if(!(o instanceof K)||!t?.endOfTextblock("down"))return!1;let{$anchor:r,$head:s}=o;if(r.depth!==1||r.parent.type!==Q.toggle||r.parent.attrs.open||r.index(0)!==s.index(0))return!1;let a=y(e.doc),i=r.index(0),l=_(a,a[i].subEnd+1,1);return l<0?!1:(n&&n(e.tr.setSelection(Y(e.doc,i,l,a)).scrollIntoView()),!0)},On=e=>(n,t,o)=>n.selection instanceof x&&e(n,t,o),Dn={Escape:(e,n)=>pe(e,n)||wn(e,n),Enter:On(pe),ArrowUp:ue(-1),ArrowDown:ue(1),"Shift-ArrowUp":fe(-1),"Shift-ArrowDown":(e,n,t)=>fe(1)(e,n)||Cn(e,n,t),Backspace:it,"Alt-Backspace":it,"Ctrl-h":it,Delete:it,"Mod-d":vn,"Mod-a":Nn},Ot=new An("page-blocksel"),$n=e=>{let n=e.selection,{lo:t,hi:o}=n.span(e.doc);return y(e.doc).filter(r=>r.i>=t&&r.i<=o&&!r.hidden).length};function ko(){let e=Vt.keymap(Dn);return new yn({key:Ot,state:{init:()=>0,apply:(n,t,o,r)=>n.getMeta(ot)&&o.selection instanceof x&&!(r.selection instanceof x)?t+1:t},props:{handleKeyDown:(n,t)=>e.props.handleKeyDown(n,t),handleTextInput:(n,t,o,r)=>In(n,r),decorations(n){let t=n.selection;if(!(t instanceof x))return null;let o=[];return n.doc.nodesBetween(t.from,t.to,(r,s)=>(o.push($.Decoration.node(s,s+r.nodeSize,{class:"page-block-selected"})),!1)),$.DecorationSet.create(n.doc,o)},createSelectionBetween(n,t,o){let r=n.state.selection;return r instanceof x&&t.pos===r.anchor&&o.pos===r.head?r:null},handleDOMEvents:{mousedown(n,t){let o=n.state.selection;if(!t.shiftKey||!(o instanceof x)||t.button!==0)return!1;let r=n.posAtCoords({left:t.clientX,top:t.clientY});if(!r)return!1;let s=y(n.state.doc),a=Math.min(n.state.doc.resolve(r.inside>=0?r.inside:r.pos).index(0),s.length-1),{lo:i,hi:l}=o.span(n.state.doc),c=o.anchor<=o.head?i:Dt(s,i,l,1);return t.preventDefault(),n.dispatch(n.state.tr.setSelection(Y(n.state.doc,c,a,s))),!0}}},view:()=>({update(n,t){let o=n.state.selection,r=t.selection;if(o instanceof x&&!o.eq(r)){let s=$n(n.state);Ct(n,`${s} ${s===1?"block":"blocks"} selected`)}else r instanceof x&&!(o instanceof x)&&Ct(n,Ot.getState(n.state)!==Ot.getState(t)?"Block selection cleared because the document changed":"Selection cleared")}})})}var{Plugin:Ln,PluginKey:Bn,TextSelection:J}=D,{Decoration:Pn,DecorationSet:zn}=$,U=T.marks.link,Vn=e=>/^(https?:\/\/|mailto:|tel:|www\.)\S+$/i.test(e.trim())&&L(e)!==null;function $t(e,n){let t=e.resolve(n);if(!t.parent.inlineContent)return null;let o=U.isInSet((t.nodeAfter??t.nodeBefore)?.marks??[]);if(!o)return null;let r=[];t.parent.forEach((c,d)=>r.push({n:c,off:d}));let s=r.findIndex(({n:c,off:d})=>d<=t.parentOffset&&t.parentOffset<=d+c.nodeSize&&o.isInSet(c.marks));if(s<0)return null;let a=s,i=s;for(;a>0&&o.isInSet(r[a-1].n.marks);)a--;for(;i<r.length-1&&o.isInSet(r[i+1].n.marks);)i++;let l=t.start();return{from:l+r[a].off,to:l+r[i].off+r[i].n.nodeSize,href:o.attrs.href}}function me(e,n,t,o){let r=e.tr.removeMark(n,t,U);return o&&r.addMark(n,t,U.create({href:o})),H(r)}var B=new Bn("page-link"),Lt=new WeakMap,ge=e=>`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e}</svg>`,Rn=ge('<path d="M9 3h4v4M13 3 7.5 8.5M11 9.5V13H3V5h3.5"/>'),qn=ge('<path d="M4 4l8 8M12 4l-8 8"/>');function j(e,n,t,o={}){let r=e.createElement(n);t&&(r.className=t);for(let[s,a]of Object.entries(o))r.setAttribute(s,a);return r}function _n(e,n,t){let o=null;return e.doc.nodesBetween(n,t,r=>{let s=U.isInSet(r.marks);s&&(o=s.attrs.href)}),o}var Bt=class{constructor(n){this.view=n,this.shell=n.dom.parentElement,this.doc=n.dom.ownerDocument,this.mode=null,this.range=null;let t=this.doc;this.dom=j(t,"div","page-link",{role:"dialog","aria-label":"Link",hidden:""}),this.input=j(t,"input","page-link-input",{type:"url","aria-label":"Link address",placeholder:"Paste or type a link",autocomplete:"off",spellcheck:"false"}),this.url=j(t,"a","page-link-url",{target:"_blank",rel:"noopener noreferrer"}),this.open=j(t,"a","page-link-btn",{"data-act":"open",target:"_blank",rel:"noopener noreferrer","aria-label":"Open link in a new tab",title:"Open in a new tab"}),this.open.innerHTML=Rn,this.edit=j(t,"button","page-link-btn",{type:"button","data-act":"edit"}),this.edit.textContent="Edit",this.remove=j(t,"button","page-link-btn",{type:"button","data-act":"remove","aria-label":"Remove link",title:"Remove link"}),this.remove.innerHTML=qn,this.dom.append(this.input,this.url,this.open,this.edit,this.remove),this.shell.append(this.dom),Lt.set(n,this),this.dom.addEventListener("mousedown",o=>{o.target!==this.input&&o.preventDefault()}),this.edit.addEventListener("click",()=>this.openEdit()),this.remove.addEventListener("click",()=>this.apply("")),this.input.addEventListener("keydown",o=>{o.isComposing||o.keyCode===229||(o.key==="Enter"?(o.preventDefault(),this.apply(this.input.value)):o.key==="Escape"&&(o.preventDefault(),this.close()))}),this.onDocDown=o=>{this.mode==="edit"&&!this.dom.contains(o.target)&&this.close(!1)},this.doc.addEventListener("mousedown",this.onDocDown,!0)}openEdit(){let n=this.view.state,t=n.selection;if(!(t instanceof J)||!t.$from.sameParent(t.$to)||!t.$from.parent.inlineContent||t.$from.parent.type.spec.code)return!1;let o=t.empty?$t(n.doc,t.head):null;return this.range=o??{from:t.from,to:t.to,href:t.empty?null:_n(n,t.from,t.to)},this.mode="edit",this.view.dispatch(n.tr.setMeta(B,{from:this.range.from,to:this.range.to})),this.render(),this.input.value=this.range.href??"",this.input.removeAttribute("aria-invalid"),this.input.focus(),this.input.select(),!0}apply(n){let t=String(n).trim(),o=t?L(t):null;if(t&&!o){this.input.setAttribute("aria-invalid","true");return}let r=this.view.state,s=B.getState(r)??(this.mode==="view"?this.range:null);if(!s)return this.close();let a;if(s.from===s.to){if(!o)return this.close();a=r.tr.insert(s.from,T.text(t,[U.create({href:o})])),a.setSelection(J.create(a.doc,s.from+t.length))}else a=me(r,s.from,s.to,o),a.setSelection(J.create(a.doc,s.to));this.view.dispatch(H(a).setMeta(B,null)),this.close()}close(n=!0){this.mode=null,this.range=null,B.getState(this.view.state)&&this.view.dispatch(this.view.state.tr.setMeta(B,null)),this.dom.hidden=!0,this.dom.dataset.mode="",n&&this.view.focus(),this.update(this.view)}render(){let n=this.mode==="edit",t=L(this.range?.href);this.dom.dataset.mode=this.mode??"",this.input.hidden=!n,this.url.hidden=n,this.edit.hidden=n,this.open.hidden=!t,this.remove.hidden=!this.range?.href,t?(this.open.href=t,this.url.href=t,this.url.textContent=t.replace(/^https?:\/\//,"")):(this.open.removeAttribute("href"),this.url.removeAttribute("href"),this.url.textContent=""),this.dom.hidden=!1,this.place()}place(){let n=this.range;if(!n)return;let t=this.shell.getBoundingClientRect(),o=this.view.coordsAtPos(n.from),r=this.view.coordsAtPos(n.to,-1);this.dom.style.setProperty("--page-pop-x",`${Math.min(o.left,r.left)-t.left}px`),this.dom.style.setProperty("--page-pop-y",`${Math.max(o.bottom,r.bottom)-t.top+6}px`)}update(n){if(this.view=n,this.mode==="edit"){let r=B.getState(n.state);if(r)return this.range={...this.range,...r},this.place();this.mode=null,this.range=null,this.dom.hidden=!0,this.dom.dataset.mode="";return}let t=n.state.selection,o=t instanceof J&&t.empty&&n.hasFocus()?$t(n.state.doc,t.head):null;if(!o||t.head===o.from||t.head===o.to){this.mode=null,this.range=null,this.dom.hidden=!0,this.dom.dataset.mode="";return}this.mode="view",this.range=o,this.render()}destroy(){this.doc.removeEventListener("mousedown",this.onDocDown,!0),this.dom.remove(),Lt.delete(this.view)}},Kn=e=>Lt.get(e)?.openEdit()??!1;function Hn(e,n){if(n.clipboardData?.files?.length)return!1;let t=n.clipboardData?.getData("text/plain")??"";if(!Vn(t))return!1;let o=e.state.selection;if(!(o instanceof J)||!o.$from.sameParent(o.$to)||o.$from.parent.type.spec.code)return!1;let r=L(t),s=o.empty?e.state.tr.replaceSelectionWith(T.text(t.trim(),[U.create({href:r})]),!1):me(e.state,o.from,o.to,r);return e.dispatch(s.scrollIntoView().setMeta("uiEvent","paste")),!0}function Eo(){return new Ln({key:B,state:{init:()=>null,apply(e,n){let t=e.getMeta(B);if(t!==void 0)return t;if(!n||!e.docChanged)return n;let o=e.mapping.mapResult(n.from,1),r=e.mapping.mapResult(n.to,n.from===n.to?1:-1);return o.deletedAcross||r.deletedAcross||n.from!==n.to&&o.pos>=r.pos?null:{from:o.pos,to:r.pos}}},view:e=>new Bt(e),props:{decorations(e){let n=B.getState(e);return n&&n.from<n.to?zn.create(e.doc,[Pn.inline(n.from,n.to,{class:"page-link-pending"})]):null},handleKeyDown(e,n){return(n.metaKey||n.ctrlKey)&&!n.altKey&&!n.shiftKey&&n.key.toLowerCase()==="k"?(n.preventDefault(),Kn(e)||!0):!1},handlePaste:Hn,handleClick(e,n,t){if(!(t.metaKey||t.ctrlKey))return!1;let o=$t(e.state.doc,n),r=L(o?.href);return r?(e.dom.ownerDocument.defaultView.open(r,"_blank","noopener,noreferrer"),!0):!1}}})}export{Kn as a,Eo as b,io as c,Ct as d,de as e,Et as f,q as g,y as h,Jn as i,xe as j,Zn as k,z as l,Ae as m,Se as n,x as o,G as p,re as q,Zt as r,Ee as s,Me as t,vt as u,to as v,eo as w,an as x,hn as y,no as z,oo as A,H as B,Y as C,Sn as D,it as E,vn as F,In as G,ko as H};
3
+ `);if(!n.some(r=>ee.test(r)))return null;let t=[],o=[];for(let r of n){if(!r.trim())continue;let s=ee.exec(r);if(!s){t.length=0,o.push(M.paragraph.create(null,r.trim()?T.text(r.trim()):null));continue}let a=s[1].replace(/\t/g," ").length;for(;t.length&&t[t.length-1]>a;)t.pop();(!t.length||t[t.length-1]<a)&&t.push(a);let i=Math.min(t.length-1,o.length&&S(o[o.length-1])?o[o.length-1].attrs.indent+1:0),l=s[4]!==void 0?"check":s[3]!==void 0?"ordered":"bullet";o.push(M.list_item.create({kind:l,indent:i,checked:s[4]==="x"||s[4]==="X"},s[5]?T.text(s[5]):null))}return new O.Slice(O.Fragment.from(o),0,0)}var ht=new Set(["UL","OL"]),mt=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","PRE","BLOCKQUOTE","UL","OL","LI","DETAILS","SUMMARY","TABLE","HR","FIGURE"]);function Ye(e){let n=e.querySelector(":scope > input[type=checkbox], :scope > p > input[type=checkbox], :scope > label > input[type=checkbox]");if(n)return{check:!0,checked:n.checked||n.hasAttribute("checked")};if(e.getAttribute("role")==="checkbox"||e.hasAttribute("aria-checked"))return{check:!0,checked:e.getAttribute("aria-checked")==="true"};if(e.hasAttribute("data-checked"))return{check:!0,checked:e.getAttribute("data-checked")==="true"};let o=e.className||"";return/\b(checked|task-list-item|to-do)\b/.test(o)||e.closest?.("ul.to-do-list, ul.contains-task-list")?{check:!0,checked:/\bchecked\b/.test(o)||!!e.querySelector(".checkbox-on")}:{check:!1,checked:!1}}function Je(e){let n=(e.getAttribute("style")||"")+";"+(e.parentElement?.getAttribute("style")||""),t=/list-style-type\s*:\s*([a-z-]+)/i.exec(e.getAttribute("style")||"")?.[1];return t?/decimal|alpha|roman|latin|greek/.test(t)?"ordered":"bullet":e.parentElement?.tagName==="OL"?"ordered":"bullet"}function Ze(e,n=globalThis.document){let t=n.createElement("div");t.innerHTML=e;for(let u of t.querySelectorAll('b[style*="font-weight:normal"], b[style*="font-weight: normal"]'))u.replaceWith(...u.childNodes);let o=0,r=n.createElement("div"),s=u=>{let h=parseInt(u.getAttribute("aria-level"),10);if(h>0)return h-1;let m=-1;for(let g=u.parentElement;g&&g!==t;g=g.parentElement)ht.has(g.tagName)&&m++;return Math.max(0,m)},a=[];function i(u,h,m){let g=n.createElement("div"),{check:E,checked:b}=Ye(u);g.setAttribute("data-page-li",""),g.setAttribute("data-kind",E?"check":Je(u)),g.setAttribute("data-checked",b?"true":"false"),g.dataset.depth=String(s(u)),h&&g.setAttribute("data-page-parent",h);let N=!0,C=[];for(let w of[...u.childNodes]){if(w.nodeType===1&&ht.has(w.tagName)){C.push(w);continue}if(!(w.nodeType===1&&w.tagName==="INPUT")){if(w.nodeType===1&&mt.has(w.tagName)){N||g.appendChild(n.createElement("br"));for(let P of[...w.childNodes])P.nodeType===1&&P.tagName==="INPUT"||g.appendChild(P);N=!1;continue}g.appendChild(w),(w.nodeType!==3||w.textContent.trim())&&(N=!1)}}m.appendChild(g),a.push(g);for(let w of C)l(w,h,m)}function l(u,h,m){let g=null,E=b=>{g||(g=n.createElement("p"),h&&g.setAttribute("data-page-parent",h),m.appendChild(g)),g.appendChild(b)};for(let b of[...u.childNodes])if(!(b.nodeType===1&&(b.tagName==="META"||b.tagName==="STYLE"))){if(b.nodeType===1&&b.tagName==="BR"){g=null;continue}if(b.nodeType!==1){b.nodeType===3&&(g||b.textContent.trim())&&E(b);continue}if(!mt.has(b.tagName)&&b.tagName!=="ASIDE"){E(b);continue}if(g=null,ht.has(b.tagName)){l(b,h,m);continue}if(b.tagName==="LI"){i(b,h,m);continue}if(b.tagName==="DETAILS"){let N=`paste-${++o}`,C=b.querySelector(":scope > summary"),w=n.createElement("div");w.setAttribute("data-page-toggle",N),b.hasAttribute("open")&&w.setAttribute("data-open","true"),h&&w.setAttribute("data-page-parent",h);let P=C?.querySelector(":scope > h1, :scope > h2, :scope > h3");P?(w.setAttribute("data-level",P.tagName[1]),w.append(...P.childNodes)):C&&w.append(...C.childNodes),m.appendChild(w);for(let Pt of[...b.childNodes])if(Pt!==C){let zt=n.createElement("div");zt.appendChild(Pt),l(zt,N,m)}continue}if(b.tagName==="DIV"&&!b.hasAttribute("data-page-li")&&[...b.children].some(N=>mt.has(N.tagName))){l(b,h,m);continue}h&&b.setAttribute("data-page-parent",h),m.appendChild(b)}}l(t,null,r);let c=a.length?Math.min(...a.map(u=>+u.dataset.depth)):0,d=null;for(let u of a){let h=+u.dataset.depth-c,m=d&&u.previousElementSibling===d?+d.getAttribute("data-indent")+1:0;u.setAttribute("data-indent",String(Math.min(h,m))),u.removeAttribute("data-depth"),d=u}let f=u=>{if(u.nodeType!==1||u.tagName==="IMG")return[u.cloneNode(!0)];let h=[],m=u.cloneNode(!1);for(let g of u.childNodes)for(let E of f(g))E.nodeType===1&&E.tagName==="IMG"?(m.hasChildNodes()&&h.push(m),h.push(E),m=u.cloneNode(!1)):m.appendChild(E);return(m.hasChildNodes()||!h.length)&&h.push(m),h};for(let u of[...r.children]){if(!u.matches("p, h1, h2, h3, h4, h5, h6, aside, div[data-page-li], div.page-li")||!u.querySelector("img"))continue;let h=f(u),m=u.getAttribute("data-page-parent");if(m)for(let g of h)g.setAttribute("data-page-parent",m);u.replaceWith(...h)}let p=t.querySelector("[data-pm-slice]");return p&&r.firstElementChild?.setAttribute("data-pm-slice",p.dataset.pmSlice),r.innerHTML}var gt=(e,n=0)=>e!==null&&e!==""&&Number.isInteger(+e)&&+e>=n?+e:null,v=e=>e.getAttribute("data-page-parent")||null,tn=Rt([]).type,en=Object.create(T,{marks:{value:{...T.marks,[nt]:tn}}}),ce=e=>{let n;try{n=Qt(e)}catch{return null}return!n||typeof n.t!="string"||n.t==="opaque_block"||Object.hasOwn(Ft,n.t)?null:n},nn=e=>{let n=ce(e);return n?{raw:n,parent:v(e)}:!1},on=e=>{let n=ce(e);if(!n||typeof n.c!="string"||!n.c)return O.Fragment.empty;let t=Ht(n.m,n.c.length);return O.Fragment.from(jt(T,n.c,t,T.nodes.opaque_block))},rn=e=>{try{return{entries:Wt(e.getAttribute(ut))}}catch{return!1}},X=null,sn=()=>import("./c-BGKAT2FL.js").then(e=>{X=e},()=>{}),an=new O.DOMParser(en,[{tag:"table",node:"table",getAttrs:e=>X?.table(e)??!1,getContent:e=>X.rows(e)},{tag:`div[${Ut}]`,node:"opaque_block",getAttrs:nn,getContent:on},{tag:`span[${ut}]`,mark:nt,getAttrs:rn},{tag:"div[data-page-li]",node:"list_item",getAttrs:e=>({kind:e.getAttribute("data-kind")||"bullet",indent:+e.getAttribute("data-indent")||0,checked:e.getAttribute("data-checked")==="true",parent:v(e)})},{tag:"div.page-li",node:"list_item",getAttrs:e=>({kind:e.getAttribute("data-kind")||"bullet",indent:+e.getAttribute("data-indent")||0,checked:e.getAttribute("data-checked")==="true",parent:v(e)})},{tag:"div[data-page-toggle]",node:"toggle",getAttrs:e=>({id:e.getAttribute("data-page-toggle"),open:e.getAttribute("data-open")==="true",parent:v(e),level:ft(Number(e.getAttribute("data-level")))})},{tag:"div.page-toggle",node:"toggle",getAttrs:e=>({id:e.getAttribute("data-id"),open:e.getAttribute("data-open")==="true",parent:null,level:ft(Number(e.getAttribute("data-level")))})},{tag:"h1",node:"heading",getAttrs:e=>({level:1,parent:v(e)})},{tag:"h2",node:"heading",getAttrs:e=>({level:2,parent:v(e)})},{tag:"h3",node:"heading",getAttrs:e=>({level:3,parent:v(e)})},{tag:"h4",node:"heading",getAttrs:e=>({level:3,parent:v(e)})},{tag:"pre",node:"code_block",preserveWhitespace:"full",getAttrs:e=>({lang:e.getAttribute("data-lang")||"",parent:v(e)})},{tag:"hr",node:"divider",getAttrs:e=>({parent:v(e)})},{tag:"aside.page-callout",node:"callout",getAttrs:e=>({parent:v(e)})},{tag:'figure:not([data-type]), figure[data-type="image"]',node:"image",getAttrs:e=>{let n=e.querySelector("img"),t=et(n?.getAttribute("src"));return t?{src:t,alt:n.getAttribute("alt")||"",caption:e.querySelector("figcaption")?.textContent||"",width:gt(e.getAttribute("data-width")??n.getAttribute("width"),1),align:be(e.getAttribute("data-align")),parent:v(e)}:!1}},{tag:"img[src]",node:"image",getAttrs:e=>{let n=et(e.getAttribute("src"));return n?{src:n,alt:e.getAttribute("alt")||"",width:gt(e.getAttribute("width"),1),parent:v(e)}:!1}},{tag:'div.page-file, div[data-type="file"]',node:"file",getAttrs:e=>{let n=L(e.getAttribute("data-src"));return n?{src:n,name:e.getAttribute("data-name")||"file",size:gt(e.getAttribute("data-size")),mime:e.getAttribute("data-mime")||null,parent:v(e)}:!1}},{tag:"p",node:"paragraph",getAttrs:e=>({parent:v(e)})},{tag:"br",node:"hard_break"},{tag:"strong",mark:"strong"},{tag:"b",mark:"strong",getAttrs:e=>/font-weight\s*:\s*(normal|[1-5]00)\b/.test(e.getAttribute("style")||"")?!1:null},{tag:"span",mark:"strong",getAttrs:e=>/font-weight\s*:\s*(bold|[6-9]00)\b/.test(e.getAttribute("style")||"")?null:!1},{tag:"em",mark:"em"},{tag:"i",mark:"em"},{tag:"span",mark:"em",getAttrs:e=>/font-style\s*:\s*italic/.test(e.getAttribute("style")||"")?null:!1},{tag:"s",mark:"strike"},{tag:"del",mark:"strike"},{tag:"code",mark:"code"},{tag:"a[href]",mark:"link",getAttrs:e=>{let n=L(e.getAttribute("href"));return n?{href:n}:!1}},{tag:"blockquote",node:"quote",getAttrs:e=>({parent:v(e)})},{tag:"u",mark:"underline"},{tag:"mark",mark:"highlight",getAttrs:e=>ct("highlight",{color:e.getAttribute("data-color")})??!1},{tag:"span[data-color]",mark:"text_color",getAttrs:e=>ct("text_color",{color:e.getAttribute("data-color")})??!1}]);function cn(e,n){let t=n.selection.$from,o=n.selection instanceof x,r=o?n.doc.child(n.selection.span().lo):t.depth>=1?t.node(1):null,s=r?k(r):null,a=r&&S(r)?r.attrs.indent:0,i=new Map;e.content.forEach(m=>{A(m)&&m.attrs.id&&i.set(m.attrs.id,V())});let l=[];e.content.forEach(m=>{if(!m.type.spec.group?.includes("block")){l.push(m);return}let g=k(m),E={...m.attrs,pos:null,id:A(m)?i.get(m.attrs.id)??null:null,parent:g!==null&&i.has(g)?i.get(g):s};S(m)&&(E.indent=m.attrs.indent+a),l.push(m.type.create(E,m.content,m.marks))});let c=!r||!(S(r)||A(r)),d=m=>m&&(S(m)||A(m)),f=c&&d(l[0])?0:e.openStart,p=l[l.length-1],u=new Set(i.values()),h=c&&(d(p)||p&&u.has(k(p)))?0:e.openEnd;return new O.Slice(O.Fragment.from(l),o?0:f,o?0:h)}var St=class extends O.DOMSerializer{serializeFragment(n,t,o){let r=super.serializeFragment(n,t,o);if(!n.firstChild?.isBlock)return r;let s=[...r.childNodes];return n.forEach((a,i,l)=>{let c=s[l];!c||c.nodeType!==1||(k(a)!==null&&c.setAttribute("data-page-parent",k(a)),A(a)&&a.attrs.id&&c.setAttribute("data-page-toggle",a.attrs.id),a.type===M.image&&a.attrs.width&&c.setAttribute("data-width",String(a.attrs.width)))}),X?.copy(n,s),r}},le=O.DOMSerializer.fromSchema(T),ln=e=>{let{t:n,...t}=e.attrs.raw??{},{c:o,m:r}=_t(e.content);return o?{t:n,...t,c:o,...r.some(Boolean)?{m:Kt(r)}:{}}:{t:n,...t}},dn=e=>["div",{"data-type":"newer-format",...Gt(ln(e))},0],un=e=>["span",Xt(e.attrs.entries),0],fn={...le.nodes,opaque_block:dn},pn={...le.marks,[nt]:un},hn=new St(fn,pn);function mn(e,n,t){let{$from:o}=e.state.selection,r=o.depth>=1?o.node(1):null;if(!r||!A(r)||r.attrs.open||t.content.childCount<2)return!1;let s=e.state.tr.setNodeMarkup(o.before(1),null,{...r.attrs,open:!0}).replaceSelection(t);return e.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function gn(e){let n=!1;return e?.content?.descendants(t=>n?!1:((t.type===M.quote||t.isText&&t.marks.some(o=>qt.has(o.type.name)))&&(n=!0),!n)),n}function bn(e,n,t){let o=e.state.selection.from,r=e.state.selection.to,s=e.state.doc,a=()=>{let i=t.content.textBetween(0,t.content.size,`
4
+ `," ");return!e.isDestroyed&&i&&e.state.doc===s&&e.dispatch(e.state.tr.insertText(i,o,r)),!1};return import("./c-2RYOGUQM.js").then(({pasteFormats:i})=>i(e,t,o,r),a),!0}function no(){return new wt({view(){return sn(),{}},props:{handlePaste(e,n,t){return gn(t)?bn(e,n,t):mn(e,n,t)},clipboardSerializer:hn,clipboardTextSerializer:e=>X?.text(e),transformPastedHTML:e=>Ze(e),clipboardParser:an,clipboardTextParser:(e,n,t)=>t?null:Qe(e),transformPasted:(e,n)=>cn(e,n.state)}})}var W=tt.chainCommands(Ce,Oe,Be,ze,De),R=tt.chainCommands($e,Le,Pe),oo={Enter:tt.chainCommands(ve,Te,Ne,Ie),Backspace:W,"Shift-Backspace":W,"Mod-Backspace":W,"Alt-Backspace":W,"Ctrl-h":W,Delete:R,"Shift-Delete":R,"Mod-Delete":R,"Alt-Delete":R,"Ctrl-d":R,"Ctrl-Alt-Backspace":R,Tab:Me,"Shift-Tab":vt,"Mod-Shift-ArrowUp":Zt(-1),"Mod-Shift-ArrowDown":Zt(1),"Mod-Enter":Ve};function io(){return new D.Plugin({view(e){let n=e.dom.ownerDocument.createElement("div");return n.className="page-live",n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),e.dom.parentElement.appendChild(n),{destroy:()=>n.remove()}}})}function Ct(e,n){let t=e.dom.parentElement?.querySelector(".page-live");t&&(t.textContent="",t.textContent=n)}var de=new D.PluginKey("tableRect");var{Selection:kn,TextSelection:K,NodeSelection:xn,Plugin:yn,PluginKey:An}=D,Q=T.nodes,H=e=>Z.closeHistory(e).setMeta(Et,!0);function Y(e,n,t=n,o=y(e)){let{lo:r,hi:s}=z(o,Math.min(n,t),Math.max(n,t)),a=o[r].at,i=o[s].end;return n<=t?new x(e.resolve(a),e.resolve(i)):new x(e.resolve(i),e.resolve(a))}function Sn(e,n=y(e.doc)){let[t,o]=ne(e.doc,e.selection,n);return z(n,t,o)}var _=(e,n,t)=>{for(let o=n;o>=0&&o<e.length;o+=t)if(!e[o].hidden)return o;return-1};function wn(e,n){if(e.selection instanceof x)return!1;let t=Math.min(e.selection.$head.index(0),e.doc.childCount-1);return n&&n(e.tr.setSelection(Y(e.doc,t))),!0}var ue=e=>(n,t)=>{let o=n.selection;if(!(o instanceof x))return!1;let r=y(n.doc),{lo:s,hi:a}=o.span(n.doc),i=e<0?_(r,s-1,-1):_(r,a+1,1);return i<0||t&&t(n.tr.setSelection(Y(n.doc,i)).scrollIntoView()),!0};function Dt(e,n,t,o){if(o<0)return n;let r=n;for(;e[r].subEnd<t;)r=e[r].subEnd+1;return r}function En(e,n){for(let t=n-1;t>=0;t--)if(e[t].up===e[n].up)return t;return n}var fe=e=>(n,t)=>{let o=n.selection;if(!(o instanceof x))return!1;let r=y(n.doc),{lo:s,hi:a}=o.span(n.doc),i=o.anchor<=o.head,l=i?s:Dt(r,s,a,1),c=i?Dt(r,s,a,1):s;return e>0?i||s===a||c===l?c=_(r,(i?a:c)+1,1):c=_(r,r[c].subEnd+1,1):!i||c===l?c=_(r,(i?c:s)-1,-1):c=En(r,c),c<0||t&&t(n.tr.setSelection(Y(n.doc,l,c,r)).scrollIntoView()),!0};function it(e,n){let t=e.selection;if(!(t instanceof x))return!1;if(n){let o=e.tr.delete(t.from,t.to);o.doc.content.size===0&&o.insert(0,Q.paragraph.create()),o.setSelection(kn.near(o.doc.resolve(Math.min(t.from,o.doc.content.size)),-1)),n(H(o).scrollIntoView())}return!0}function Mn({columns:e={},cards:n={}}){let t=dt(e),o=new Map(t.map(a=>[a,V("c")])),r=lt(null,null,t.length),s={};for(let a of new Set([...t,...Object.values(n).map(i=>i.col)])){let i=dt(Object.fromEntries(Object.entries(n).filter(([,c])=>c.col===a))),l=lt(null,null,i.length);i.forEach((c,d)=>{s[V("k")]={...n[c],col:o.get(a)??a,pos:l[d]}})}return{columns:Object.fromEntries(t.map((a,i)=>[o.get(a),{...e[a],pos:r[i]}])),cards:s}}function vn(e,n){let t=y(e.doc);if(!t.length)return!1;let{lo:o,hi:r}=Sn(e,t);if(n){let s=new Map;for(let f=o;f<=r;f++)t[f].node.type===Q.toggle&&t[f].node.attrs.id&&s.set(t[f].node.attrs.id,V());let a=[];for(let f=o;f<=r;f++){let p=t[f].node,u=p.attrs.parent??null;a.push(p.type.create({...p.attrs,...p.type===Q.board?Mn(p.attrs):{},id:s.get(p.attrs.id)??null,pos:null,parent:s.get(u)??u},p.content,p.marks))}let i=t[r].end,l=i-t[o].at,c=e.tr.insert(i,a),d=e.selection;c.setSelection(d instanceof x?new x(c.doc.resolve(i),c.doc.resolve(i+l)):K.create(c.doc,d.anchor+l,d.head+l)),n(H(c).scrollIntoView())}return!0}var he=(e,n,t,o)=>{for(let r=t;r<=o;r++)if(n[r].node.isTextblock)return n[r].end-1;return-1};function pe(e,n){let t=e.selection;if(!(t instanceof x))return!1;let o=y(e.doc),{lo:r,hi:s}=t.span(e.doc);if(n){let a=he(e.doc,o,r,s);n(e.tr.setSelection(a>=0?K.create(e.doc,a):xn.create(e.doc,o[r].at)))}return!0}var Tn=({$from:e,$to:n})=>{if(e.depth<2||n.depth<2)return null;let t=e.node(1);return t.type.name==="table"&&n.node(1)===t?{from:e.before(1),to:e.after(1)}:null};function Nn(e,n){let t=e.selection,{$from:o,$to:r}=t,s=o.parent.isTextblock&&o.sameParent(r)&&!de.getState(e),a=s&&o.parentOffset===0&&r.parentOffset===r.parent.content.size;if(s&&!a&&o.parent.content.size)return n&&n(e.tr.setSelection(K.create(e.doc,o.start(),o.end()))),!0;let i=Tn(t);return i&&!(t instanceof x&&t.from===i.from&&t.to===i.to)?(n&&n(e.tr.setSelection(new x(e.doc.resolve(i.from),e.doc.resolve(i.to)))),!0):(n&&n(e.tr.setSelection(new x(e.doc.resolve(0),e.doc.resolve(e.doc.content.size)))),!0)}var In=(e,n)=>{let t=e.state,o=t.selection;if(!(o instanceof x))return!1;let r=y(t.doc),{lo:s,hi:a}=o.span(t.doc),i=he(t.doc,r,s,a),l=t.tr;if(i<0){let c=r[a].end;l.insert(c,Q.paragraph.create({parent:r[s].node.attrs.parent??null})),l.setSelection(K.create(l.doc,c+1)),H(l)}else l.setSelection(K.create(l.doc,i));return l.insertText(n),e.dispatch(l.scrollIntoView()),!0},Cn=(e,n,t)=>{let o=e.selection;if(!(o instanceof K)||!t?.endOfTextblock("down"))return!1;let{$anchor:r,$head:s}=o;if(r.depth!==1||r.parent.type!==Q.toggle||r.parent.attrs.open||r.index(0)!==s.index(0))return!1;let a=y(e.doc),i=r.index(0),l=_(a,a[i].subEnd+1,1);return l<0?!1:(n&&n(e.tr.setSelection(Y(e.doc,i,l,a)).scrollIntoView()),!0)},On=e=>(n,t,o)=>n.selection instanceof x&&e(n,t,o),Dn={Escape:(e,n)=>pe(e,n)||wn(e,n),Enter:On(pe),ArrowUp:ue(-1),ArrowDown:ue(1),"Shift-ArrowUp":fe(-1),"Shift-ArrowDown":(e,n,t)=>fe(1)(e,n)||Cn(e,n,t),Backspace:it,"Alt-Backspace":it,"Ctrl-h":it,Delete:it,"Mod-d":vn,"Mod-a":Nn},Ot=new An("page-blocksel"),$n=e=>{let n=e.selection,{lo:t,hi:o}=n.span(e.doc);return y(e.doc).filter(r=>r.i>=t&&r.i<=o&&!r.hidden).length};function ko(){let e=Vt.keymap(Dn);return new yn({key:Ot,state:{init:()=>0,apply:(n,t,o,r)=>n.getMeta(ot)&&o.selection instanceof x&&!(r.selection instanceof x)?t+1:t},props:{handleKeyDown:(n,t)=>e.props.handleKeyDown(n,t),handleTextInput:(n,t,o,r)=>In(n,r),decorations(n){let t=n.selection;if(!(t instanceof x))return null;let o=[];return n.doc.nodesBetween(t.from,t.to,(r,s)=>(o.push($.Decoration.node(s,s+r.nodeSize,{class:"page-block-selected"})),!1)),$.DecorationSet.create(n.doc,o)},createSelectionBetween(n,t,o){let r=n.state.selection;return r instanceof x&&t.pos===r.anchor&&o.pos===r.head?r:null},handleDOMEvents:{mousedown(n,t){let o=n.state.selection;if(!t.shiftKey||!(o instanceof x)||t.button!==0)return!1;let r=n.posAtCoords({left:t.clientX,top:t.clientY});if(!r)return!1;let s=y(n.state.doc),a=Math.min(n.state.doc.resolve(r.inside>=0?r.inside:r.pos).index(0),s.length-1),{lo:i,hi:l}=o.span(n.state.doc),c=o.anchor<=o.head?i:Dt(s,i,l,1);return t.preventDefault(),n.dispatch(n.state.tr.setSelection(Y(n.state.doc,c,a,s))),!0}}},view:()=>({update(n,t){let o=n.state.selection,r=t.selection;if(o instanceof x&&!o.eq(r)){let s=$n(n.state);Ct(n,`${s} ${s===1?"block":"blocks"} selected`)}else r instanceof x&&!(o instanceof x)&&Ct(n,Ot.getState(n.state)!==Ot.getState(t)?"Block selection cleared because the document changed":"Selection cleared")}})})}var{Plugin:Ln,PluginKey:Bn,TextSelection:J}=D,{Decoration:Pn,DecorationSet:zn}=$,U=T.marks.link,Vn=e=>/^(https?:\/\/|mailto:|tel:|www\.)\S+$/i.test(e.trim())&&L(e)!==null;function $t(e,n){let t=e.resolve(n);if(!t.parent.inlineContent)return null;let o=U.isInSet((t.nodeAfter??t.nodeBefore)?.marks??[]);if(!o)return null;let r=[];t.parent.forEach((c,d)=>r.push({n:c,off:d}));let s=r.findIndex(({n:c,off:d})=>d<=t.parentOffset&&t.parentOffset<=d+c.nodeSize&&o.isInSet(c.marks));if(s<0)return null;let a=s,i=s;for(;a>0&&o.isInSet(r[a-1].n.marks);)a--;for(;i<r.length-1&&o.isInSet(r[i+1].n.marks);)i++;let l=t.start();return{from:l+r[a].off,to:l+r[i].off+r[i].n.nodeSize,href:o.attrs.href}}function me(e,n,t,o){let r=e.tr.removeMark(n,t,U);return o&&r.addMark(n,t,U.create({href:o})),H(r)}var B=new Bn("page-link"),Lt=new WeakMap,ge=e=>`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e}</svg>`,Rn=ge('<path d="M9 3h4v4M13 3 7.5 8.5M11 9.5V13H3V5h3.5"/>'),qn=ge('<path d="M4 4l8 8M12 4l-8 8"/>');function j(e,n,t,o={}){let r=e.createElement(n);t&&(r.className=t);for(let[s,a]of Object.entries(o))r.setAttribute(s,a);return r}function _n(e,n,t){let o=null;return e.doc.nodesBetween(n,t,r=>{let s=U.isInSet(r.marks);s&&(o=s.attrs.href)}),o}var Bt=class{constructor(n){this.view=n,this.shell=n.dom.parentElement,this.doc=n.dom.ownerDocument,this.mode=null,this.range=null;let t=this.doc;this.dom=j(t,"div","page-link",{role:"dialog","aria-label":"Link",hidden:""}),this.input=j(t,"input","page-link-input",{type:"url","aria-label":"Link address",placeholder:"Paste or type a link",autocomplete:"off",spellcheck:"false"}),this.url=j(t,"a","page-link-url",{target:"_blank",rel:"noopener noreferrer"}),this.open=j(t,"a","page-link-btn",{"data-act":"open",target:"_blank",rel:"noopener noreferrer","aria-label":"Open link in a new tab",title:"Open in a new tab"}),this.open.innerHTML=Rn,this.edit=j(t,"button","page-link-btn",{type:"button","data-act":"edit"}),this.edit.textContent="Edit",this.remove=j(t,"button","page-link-btn",{type:"button","data-act":"remove","aria-label":"Remove link",title:"Remove link"}),this.remove.innerHTML=qn,this.dom.append(this.input,this.url,this.open,this.edit,this.remove),this.shell.append(this.dom),Lt.set(n,this),this.dom.addEventListener("mousedown",o=>{o.target!==this.input&&o.preventDefault()}),this.edit.addEventListener("click",()=>this.openEdit()),this.remove.addEventListener("click",()=>this.apply("")),this.input.addEventListener("keydown",o=>{o.isComposing||o.keyCode===229||(o.key==="Enter"?(o.preventDefault(),this.apply(this.input.value)):o.key==="Escape"&&(o.preventDefault(),this.close()))}),this.onDocDown=o=>{this.mode==="edit"&&!this.dom.contains(o.target)&&this.close(!1)},this.doc.addEventListener("mousedown",this.onDocDown,!0)}openEdit(){let n=this.view.state,t=n.selection;if(!(t instanceof J)||!t.$from.sameParent(t.$to)||!t.$from.parent.inlineContent||t.$from.parent.type.spec.code)return!1;let o=t.empty?$t(n.doc,t.head):null;return this.range=o??{from:t.from,to:t.to,href:t.empty?null:_n(n,t.from,t.to)},this.mode="edit",this.view.dispatch(n.tr.setMeta(B,{from:this.range.from,to:this.range.to})),this.render(),this.input.value=this.range.href??"",this.input.removeAttribute("aria-invalid"),this.input.focus(),this.input.select(),!0}apply(n){let t=String(n).trim(),o=t?L(t):null;if(t&&!o){this.input.setAttribute("aria-invalid","true");return}let r=this.view.state,s=B.getState(r)??(this.mode==="view"?this.range:null);if(!s)return this.close();let a;if(s.from===s.to){if(!o)return this.close();a=r.tr.insert(s.from,T.text(t,[U.create({href:o})])),a.setSelection(J.create(a.doc,s.from+t.length))}else a=me(r,s.from,s.to,o),a.setSelection(J.create(a.doc,s.to));this.view.dispatch(H(a).setMeta(B,null)),this.close()}close(n=!0){this.mode=null,this.range=null,B.getState(this.view.state)&&this.view.dispatch(this.view.state.tr.setMeta(B,null)),this.dom.hidden=!0,this.dom.dataset.mode="",n&&this.view.focus(),this.update(this.view)}render(){let n=this.mode==="edit",t=L(this.range?.href);this.dom.dataset.mode=this.mode??"",this.input.hidden=!n,this.url.hidden=n,this.edit.hidden=n,this.open.hidden=!t,this.remove.hidden=!this.range?.href,t?(this.open.href=t,this.url.href=t,this.url.textContent=t.replace(/^https?:\/\//,"")):(this.open.removeAttribute("href"),this.url.removeAttribute("href"),this.url.textContent=""),this.dom.hidden=!1,this.place()}place(){let n=this.range;if(!n)return;let t=this.shell.getBoundingClientRect(),o=this.view.coordsAtPos(n.from),r=this.view.coordsAtPos(n.to,-1);this.dom.style.setProperty("--page-pop-x",`${Math.min(o.left,r.left)-t.left}px`),this.dom.style.setProperty("--page-pop-y",`${Math.max(o.bottom,r.bottom)-t.top+6}px`)}update(n){if(this.view=n,this.mode==="edit"){let r=B.getState(n.state);if(r)return this.range={...this.range,...r},this.place();this.mode=null,this.range=null,this.dom.hidden=!0,this.dom.dataset.mode="";return}let t=n.state.selection,o=t instanceof J&&t.empty&&n.hasFocus()?$t(n.state.doc,t.head):null;if(!o||t.head===o.from||t.head===o.to){this.mode=null,this.range=null,this.dom.hidden=!0,this.dom.dataset.mode="";return}this.mode="view",this.range=o,this.render()}destroy(){this.doc.removeEventListener("mousedown",this.onDocDown,!0),this.dom.remove(),Lt.delete(this.view)}},Kn=e=>Lt.get(e)?.openEdit()??!1;function Hn(e,n){if(n.clipboardData?.files?.length)return!1;let t=n.clipboardData?.getData("text/plain")??"";if(!Vn(t))return!1;let o=e.state.selection;if(!(o instanceof J)||!o.$from.sameParent(o.$to)||o.$from.parent.type.spec.code)return!1;let r=L(t),s=o.empty?e.state.tr.replaceSelectionWith(T.text(t.trim(),[U.create({href:r})]),!1):me(e.state,o.from,o.to,r);return e.dispatch(s.scrollIntoView().setMeta("uiEvent","paste")),!0}function Eo(){return new Ln({key:B,state:{init:()=>null,apply(e,n){let t=e.getMeta(B);if(t!==void 0)return t;if(!n||!e.docChanged)return n;let o=e.mapping.mapResult(n.from,1),r=e.mapping.mapResult(n.to,n.from===n.to?1:-1);return o.deletedAcross||r.deletedAcross||n.from!==n.to&&o.pos>=r.pos?null:{from:o.pos,to:r.pos}}},view:e=>new Bt(e),props:{decorations(e){let n=B.getState(e);return n&&n.from<n.to?zn.create(e.doc,[Pn.inline(n.from,n.to,{class:"page-link-pending"})]):null},handleKeyDown(e,n){return(n.metaKey||n.ctrlKey)&&!n.altKey&&!n.shiftKey&&n.key.toLowerCase()==="k"?(n.preventDefault(),Kn(e)||!0):!1},handlePaste:Hn,handleClick(e,n,t){if(!(t.metaKey||t.ctrlKey))return!1;let o=$t(e.state.doc,n),r=L(o?.href);return r?(e.dom.ownerDocument.defaultView.open(r,"_blank","noopener,noreferrer"),!0):!1}}})}export{Kn as a,Eo as b,io as c,Ct as d,de as e,Et as f,q as g,y as h,Jn as i,xe as j,Zn as k,z as l,Ae as m,Se as n,x as o,G as p,re as q,Zt as r,Ee as s,Me as t,vt as u,to as v,eo as w,an as x,hn as y,no as z,oo as A,H as B,Y as C,Sn as D,it as E,vn as F,In as G,ko as H};
@@ -1 +1 @@
1
- import{f as S}from"./c-LV5MABYD.js";import{a as ne,b as F,c as re,d as oe}from"./c-N326R2JD.js";import{a as H}from"./c-JAX2667S.js";import{b as le,c as ae}from"./c-ILGQ3UXQ.js";import"./c-6PBXRWDX.js";import"./c-LZJPNR2W.js";import{b as ce,g as ie}from"./c-N7Y52HJH.js";import{b as Z}from"./c-ZSCBEB7I.js";import{b as se}from"./c-TUGVINJR.js";import"./c-FILLTJA7.js";import"./c-TWCXBWS3.js";import"./c-VKEDWYDF.js";import{D as te}from"./c-DKFSOJCV.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import{g as ee}from"./c-GSRLXYWL.js";import"./c-X5LNHET5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import{a as J}from"./c-LA2BW7UY.js";import"./c-ZKELCT4T.js";import"./c-ATKAOH23.js";import"./c-EK63G3CG.js";import"./c-NQJRVJ56.js";import"./c-XGH4GS2T.js";import{f as X}from"./c-IJUK2GPW.js";import"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-EGTIAL6P.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import{h as Q}from"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var T="This spot changed again. Review the latest edit or download your copy.",ue="\uFFFC",C="",M=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),ge=new Set(["BR","WBR","IMG"]),L=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" ")),ke=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" ")),we=new Set("P H1 H2 H3 H4 H5 H6 SUMMARY".split(" ")),Ne=/[\u001E]/,ve={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0},k=e=>!!e&&e.nodeType===1,W=e=>k(e)&&M.has(e.tagName),B=e=>e.matches(le),z=e=>e.matches(ae),y=e=>e.localName==="template"&&e.content?e.content:e,w=e=>Array.prototype.indexOf.call(e.parentNode.childNodes,e),x=e=>e.getAttribute("data-id")||e.getAttribute("id")||null;function Ce(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function ye(e){if(e.nodeType===3)return!0;if(!k(e))return!1;if(B(e)||ge.has(e.tagName))return!0;if(!M.has(e.tagName))return!L.has(e.tagName);if(z(e))return!1;for(let n of e.childNodes)if(!ye(n))return!1;return!0}function Y(e){if(!ke.has(e.tagName)||B(e)||z(e))return!1;for(let n of e.childNodes)if(n.nodeType===8||!ye(n))return!1;return!0}function xe(e,n=document){for(let t of n.querySelectorAll("template")){if(t.content===e)return t;let r=xe(e,t.content);if(r)return r}return null}function m(e,n){for(let t=e;t;t=t.nodeType===11?xe(t):t.parentNode)if(t===n)return!0;return!1}var h=e=>m(e,document);function Ae(e,n){let t=e;for(let r of n)if(t=r==="content"?t.content:t.childNodes[r],!t)return null;return t}function D(e,n=new Set){if(k(e)){let t=x(e);t&&n.add(t)}if(e.nodeType===1||e.nodeType===11)for(let t of y(e).childNodes)D(t,n);return n}function Re(e){let n=document.createElement("template");return n.innerHTML=e,n.content}var Ie=e=>[...e.querySelectorAll("*")].some(n=>L.has(n.tagName));function Se(e){let n=[];for(let t=e;t.childNodes.length===1&&k(t.firstChild);t=t.firstChild)n.push(t.firstChild);return n}function De(e,n){let t=e.lastIndexOf("content");if(t<0)return document;let r=$(e.slice(0,t),n);return r&&r.content?r.content:null}function $(e,n){let t=Ae(n.root,e);if(!k(t))return null;let r=x(t),o=r?De(e,n):null;if(!o)return null;let s=[...o.querySelectorAll(t.localName)].filter(i=>i.namespaceURI===t.namespaceURI&&x(i)===r);return s.length===1?s[0]:null}function Me(e){let n=x(e);if(!n)return null;let t=[...document.querySelectorAll(e.localName)].filter(r=>r.namespaceURI===e.namespaceURI&&x(r)===n);return t.length===1?t[0]:null}function b(e,n,t=e?e.nodeType:1){if(!e)return null;for(let o of e.live)if(o.nodeType===t&&h(o))return o;if(t!==1)return null;if(e.local.length)return $(e.local[0],n);let r=e.live.find(k);return r?Me(r):null}function Pe(e){let n=e.live.find(k),t=n?x(n):null;return!!t&&![...document.querySelectorAll(n.localName)].some(r=>x(r)===t)}function _(e){let n=y(e),t={root:e,container:n,text:"",nodes:[],atoms:[],blocks:[]},r=s=>{for(let i of s){if(i.nodeType===3){if(!i.data)continue;t.nodes.push({node:i,s:t.text.length,e:t.text.length+i.data.length}),t.text+=i.data;continue}if(!k(i)||B(i))continue;if(Y(i)){t.text.length&&t.text[t.text.length-1]!==C&&(t.text+=C);let l={el:i,from:t.text.length,to:-1};t.blocks.push(l),r(i.childNodes),t.text+=C,l.to=t.text.length;continue}let c=M.has(i.tagName)&&Ce(i);if(ge.has(i.tagName)||!M.has(i.tagName)||z(i)||c){t.atoms.push({i:t.text.length,el:i}),t.text+=ue;continue}r(i.childNodes)}};if(r(n.childNodes),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&!t.blocks.length&&t.text.replace(ue,"").trim()===""){let s=t.atoms[0].i;t.text=t.text.slice(0,s)+t.text.slice(s+1),t.atoms=[];for(let i of t.nodes)i.s>s&&(i.s--,i.e--)}return t}function fe(e,n,t){for(let s of e.nodes)if(t==="start"?s.s<=n&&n<s.e:s.s<n&&n<=s.e)return[s.node,n-s.s];let r=t==="start"?n:n-1,o=e.atoms.find(s=>s.i===r);if(o)return[o.el.parentNode,w(o.el)+(t==="start"?0:1)];if(e.text[r]===C){let s=e.blocks.find(c=>c.to===r+1);if(s)return t==="start"?[s.el,s.el.childNodes.length]:[s.el.parentNode,w(s.el)+1];let i=e.blocks.find(c=>c.from===r+1);if(i)return t==="start"?[i.el,0]:[i.el.parentNode,w(i.el)]}for(let s of e.nodes)if(s.s===n||s.e===n)return[s.node,n-s.s];return[e.container,n===0?0:e.container.childNodes.length]}function j(e,n){let t=document.createRange();return t.setStart(e,n),t.setEnd(e,n),t}function K(e,n,t){if(n.nodeType===3){let i=e.nodes.find(c=>c.node===n);return i?i.s+t:null}if(n!==e.container&&!m(n,e.root))return null;let r=j(n,t),o=e.text.length,s=(i,c)=>{try{return r.comparePoint(i,c)>=0}catch{return!1}};for(let i of e.nodes)s(i.node,0)&&(o=Math.min(o,i.s));for(let i of e.atoms)s(i.el.parentNode,w(i.el))&&(o=Math.min(o,i.i));return o}function Le(e,n){let t=e.slice(n.bs,n.be),r=0;for(;r<t.length&&r<n.text.length&&t[r]===n.text[r];)r++;let o=0;for(;o<t.length-r&&o<n.text.length-r&&t[t.length-1-o]===n.text[n.text.length-1-o];)o++;return{bs:n.bs+r,be:n.be-o,text:n.text.slice(r,n.text.length-o)}}function G(e,n,t,r){if(e===n)return{s:t,e:r};let o=0,s=0,i=H.diff(e,n).map(c=>Le(e,c)).sort((c,l)=>c.bs-l.bs);for(let c of i){if(c.bs===c.be&&!c.text)continue;let l=c.text.length-(c.be-c.bs);if(c.be<=t)o+=l;else{if(c.bs>=r)continue;if(c.bs>=t&&c.be<=r){if(Ne.test(e.slice(c.bs,c.be)+c.text))return null;s+=l}else return null}}return{s:t+o,e:r+o+s}}function Be(e,n,t){let r=e.liveScope;if(r&&r.startContainer&&m(r.startContainer,n)&&m(r.endContainer,n)){let s=K(t,r.startContainer,r.startOffset);if(s!==null)return s}if(Y(n))return 0;let o=e.merged.text?t.text.indexOf(e.merged.text):-1;return o>=0&&t.text.indexOf(e.merged.text,o+1)<0?o:null}function Te(e,n){let t=e.commonAncestorContainer;for(t.nodeType===3&&(t=t.parentNode);t&&t!==n;t=t.parentNode)if(k(t)&&Y(t))return t;return n}var Oe=(e,n)=>e.tagName===n.tagName&&e.attributes.length===n.attributes.length&&[...e.attributes].every(t=>n.getAttribute(t.name)===t.value);function de(e,n){let t=[];for(let r=k(e)?e:e.parentNode;r&&r!==n&&W(r);r=r.parentNode)t.unshift(r);return t}function Ue(e,n,t){let[r,o]=e;if(r.nodeType===3){if(o!==0&&o!==r.data.length)return e;[r,o]=[r.parentNode,w(r)+(o===0?0:1)]}let s=!1;for(;r!==n&&W(r)&&(o===0||o===r.childNodes.length)&&!t.some(i=>Oe(i,r));)[r,o]=[r.parentNode,w(r)+(o===0?0:1)],s=!0;return s?[r,o]:e}function He(e,n,t){let r=de(n.startContainer,t),o=de(n.endContainer,t);return r.length!==o.length||r.some((s,i)=>s!==o[i])||r.length>e.wrappers.length||r.some((s,i)=>!Oe(s,e.wrappers[i]))?!1:(e.peel=r.length,!e.wrappers.slice(e.peel).some(s=>r.some(i=>i.tagName===s.tagName)))}function Fe(e,n,t,r){let o=e.childNodes.length===1&&k(e.firstChild)?e.firstChild:null;if(!o||!L.has(o.tagName))return;let s=document.createRange();s.setStart(...n),s.setEnd(...t);let i=Te(s,r);i===r||i.tagName!==o.tagName||i.namespaceURI!==o.namespaceURI||x(i)!==x(o)||o.replaceWith(...o.childNodes)}function Ge(e){if(!e.parsed)return e.fragment;let n=e.parsed.childNodes;return n.length?n.length===1&&n[0].nodeType===3?n[0].data:null:""}function Ve(e,n){let t=e.recovery.text,r=e.recovery.subject,o=b(r,n,r.nodeType);if(!o)return null;let s=o.nodeType===3&&o.parentNode?.localName==="textarea"?o.parentNode:o,i=t.local.text.slice(t.local.start,t.local.end);if(Ne.test(t.merged.text.slice(t.merged.start,t.merged.end))||i.includes(C))return null;let c={kind:"text",id:e.id,ticket:n.ticket,key:r.key,fragment:t.local.fragment,encoding:t.encoding,local:i,ids:new Set,range:document.createRange()};if(o.nodeType===8){let g=G(t.merged.text,o.data,t.merged.start,t.merged.end);return g?(c.range.setStart(o,g.s),c.range.setEnd(o,g.e),{...c,root:o,owner:o,scope:o,s:g.s,e:g.e,before:o.data,bs:g.s,be:g.e}):null}if(s.localName==="textarea"){if(c.encoding!=="plain")return null;let g=G(t.merged.text,s.value,t.merged.start,t.merged.end);return g?(c.range.selectNodeContents(s),{...c,root:s,field:s,scope:s,f:{text:s.value},s:g.s,e:g.e,before:s.value,bs:g.s,be:g.e}):null}let l=_(o),u=Be(t,o,l);if(u===null)return null;let d=G(t.merged.text,l.text.slice(u),t.merged.start,t.merged.end);if(!d)return null;let N=u+d.s,v=u+d.e,A=fe(l,N,"start"),a=N===v?A:fe(l,v,"end");if(c.parsed=c.encoding==="html"?Re(c.fragment):null,c.parsed&&Fe(c.parsed,A,a,o),c.parsed&&Ie(c.parsed)||(c.wrappers=c.parsed?Se(c.parsed):[],c.parsed&&D(c.parsed,c.ids),c.plain=Ge(c),N===v&&(A=a=Ue(A,o,c.wrappers)),c.range.setStart(...A),c.range.setEnd(...a),!He(c,c.range,o)))return null;let f=Te(c.range,o),p=f===o?l:_(f),E=K(p,...A),U=N===v?E:K(p,...a);return E===null||U===null||p.text.slice(E,U)!==l.text.slice(N,v)?null:{...c,root:o,f:l,s:N,e:v,scope:f,before:p.text,bs:E,be:U}}function qe(e){if(e.owner){let o=e.owner.data;e.owner.data=o.slice(0,e.s)+e.fragment+o.slice(e.e),e.check=()=>e.owner.data.slice(e.s,e.s+e.fragment.length)===e.fragment&&h(e.owner);return}if(e.field){let o=e.field,s=o.value.slice(0,e.s)+e.fragment+o.value.slice(e.e);o.textContent=s,o.value!==s&&(o.value=s,e.wroteProperty=!0),o.hasAttribute("data-value")&&o.setAttribute("data-value",s),e.check=()=>h(o)&&o.value===s&&o.textContent===s;return}let n=e.range,t=n.startContainer;if(e.plain!==null&&t.nodeType===3&&n.endContainer===t){let o=n.startOffset;t.replaceData(o,n.endOffset-o,e.plain),e.check=()=>h(t)&&t.data.slice(o,o+e.plain.length)===e.plain;return}n.deleteContents();let r=[];if(e.fragment)if(e.parsed){let o=document.importNode(e.parsed,!0),s=Se(o);for(let i=0;i<e.peel;i++)s[i].replaceWith(...s[i].childNodes);r=[...o.childNodes],n.insertNode(o)}else r=[document.createTextNode(e.fragment)],n.insertNode(r[0]);e.check=()=>r.every(h)&&(e.parsed||!r.length||r[0].data===e.fragment)}function _e(e,n){let t=b(e.recovery.subject,n,1);if(!t)return null;let r=e.recovery.attribute,o={kind:"attr",id:e.id,ticket:n.ticket,key:e.recovery.subject.key,el:t,ns:r.namespaceURI,name:r.qualifiedName,local:r.localName,value:e.local??null,ids:new Set};try{o.ns===null?document.createAttribute(o.name):document.createAttributeNS(o.ns,o.name)}catch{return null}return o}var je=new Set(["hidden","submit","image","reset","button","checkbox","radio","file"]);function Ke(e,n){let t=document.createElement("input");return t.type=e.type,t.value=n,t.value}function We(e){let n=e.el;return e.ns!==null||n.namespaceURI!=="http://www.w3.org/1999/xhtml"?null:n.localName==="input"&&e.name==="checked"&&(n.type==="checkbox"||n.type==="radio")?["checked",e.value!==null]:n.localName==="input"&&e.name==="value"&&!je.has(n.type)?["value",Ke(n,e.value??"")]:n.localName==="option"&&e.name==="selected"?["selected",e.value!==null]:null}function ze(e){e.ns===null?e.value===null?e.el.removeAttribute(e.name):e.el.setAttribute(e.name,e.value):e.value===null?e.el.removeAttributeNS(e.ns,e.local):e.el.setAttributeNS(e.ns,e.name,e.value);let n=We(e);n&&e.el[n[0]]!==n[1]&&(e.el[n[0]]=n[1],e.wroteProperty=!0);let t=()=>e.ns===null?e.el.getAttribute(e.name):e.el.getAttributeNS(e.ns,e.local);e.check=()=>h(e.el)&&t()===e.value&&(!n||e.el[n[0]]===n[1])}function Ye(e,n){let t=e.recovery.structure,r=e.recovery.subject,o=b(r,n,r.nodeType),s={id:e.id,ticket:n.ticket,key:r.key,apply:n,ids:new Set},i=c=>c?b(c.parent,n,1):null;if(t.localAction==="deleted")return o?{...s,kind:"remove",node:o}:Pe(r)?{...s,kind:"done",check:()=>!0}:null;if(t.localAction==="moved"){let c=i(t.localPlacement);return!o||!c||o===c||m(c,o)?null:{...s,kind:"move",node:o,parent:c,placement:t.localPlacement}}if(t.localAction==="reordered"){if(!o||!t.localOrder)return null;let c=y(o),l=t.localOrder.map(u=>b(u,n,u.nodeType)).filter(u=>u&&u.parentNode===c);return l.length<2?null:{...s,kind:"reorder",parent:o,order:l}}if(t.localAction==="inserted"){let c=i(t.localPlacement);if(!c||o&&o.parentNode!==y(c))return null;if(t.fragmentKind!=="element")return typeof t.localFragment!="string"?null:{...s,kind:"run",node:o,parent:c,placement:t.localPlacement,text:t.localFragment,nodeType:r.nodeType};let l=r.local.length?Ae(n.root,r.local[0]):null;if(!k(l))return null;let u=o?o.tagName===l.tagName&&o.namespaceURI===l.namespaceURI?"morph":"replace":"place";return{...s,kind:"realize",node:o,parent:c,placement:t.localPlacement,src:l,mode:u,ids:D(l)}}return null}function V(e,n,t,r){let o=y(n),s=l=>{for(let u of l){let d=b(u,r,u.nodeType);if(d&&d!==e&&d.parentNode===o)return d}return null},i=s(t.before);if(i)return o.insertBefore(e,i);let c=s(t.after);return c?o.insertBefore(e,c.nextSibling):t.before.length?o.insertBefore(e,o.firstChild):o.appendChild(e)}function $e(e){let n=document.importNode(e.src,!0),t=document.createDocumentFragment();return t.append(n),e.apply.domain==="save"&&(se(t),ce(t),ie(t),Z(t)),n}function Qe(e,n){let t=e.filter(r=>r.kind==="move");for(let r of t)n.append(r.node);for(let r of e){if(r.kind==="run"){r.node?r.node.data=r.text:r.node=V(r.nodeType===8?document.createComment(r.text):document.createTextNode(r.text),r.parent,r.placement,r.apply),r.check=()=>h(r.node)&&r.node.parentNode===y(r.parent)&&r.node.data===r.text;continue}if(r.kind!=="realize")continue;let o=$e(r);r.mode==="morph"?H.morphElement(r.node,o,{ignore:B,scripts:{execute:!1}}):r.mode==="replace"?(r.node.replaceWith(o),r.node=o):r.node=V(o,r.parent,r.placement,r.apply),r.check=()=>h(r.node)&&r.node.parentNode===y(r.parent)}for(let r of t)V(r.node,r.parent,r.placement,r.apply),r.check=()=>r.node.parentNode===y(r.parent)&&h(r.node);for(let r of e){if(r.kind!=="reorder")continue;let o=y(r.parent),s=r.order.filter(u=>u.parentNode===o),i=s.slice(),c=[...o.childNodes].map(u=>s.includes(u)?i.shift():u),l=null;for(let u=c.length-1;u>=0;u--){let d=c[u];s.includes(d)&&d.nextSibling!==l&&o.insertBefore(d,l),l=d}r.check=()=>{let u=[...o.childNodes].filter(d=>s.includes(d));return u.length===s.length&&u.every((d,N)=>d===s[N])}}for(let r of e)r.kind==="remove"&&(r.node.remove(),r.check=()=>!h(r.node))}function O(e){return e.kind==="move"||e.kind==="remove"?[e.node]:e.kind==="realize"||e.kind==="run"?e.node?[e.node]:[]:[]}function R(e){return e.kind==="text"?[e.scope]:e.kind==="move"||e.kind==="reorder"?[e.parent]:(e.kind==="realize"||e.kind==="run")&&!e.node?[e.parent]:[]}var be=e=>e.kind==="attr"?[e.el]:[...O(e),...R(e)];function Xe(e,n){try{let t=j(e.startContainer,e.startOffset),r=j(n.startContainer,n.startOffset);return e.collapsed&&n.collapsed?t.comparePoint(n.startContainer,n.startOffset)===0:t.comparePoint(n.endContainer,n.endOffset)>0&&r.comparePoint(e.endContainer,e.endOffset)>0}catch{return!1}}function Je(e,n){try{return e.comparePoint(n.startContainer,n.startOffset)===0&&e.comparePoint(n.endContainer,n.endOffset)===0}catch{return!1}}function Ze(e,n){try{return e.intersectsNode(n)&&!m(e.commonAncestorContainer,n)}catch{return!1}}function I(e,n){if(!e.ids.size&&!n.ids.size)return!1;let t=s=>{let i=new Set;for(let c of be(s))D(c,i);return i},r=e.ids.size?null:t(e),o=t(n);return[...e.ids].some(s=>n.ids.has(s)||o.has(s))||[...n.ids].some(s=>(r||t(e)).has(s))}function me(e,n){return n.kind==="text"?Ze(n.range,e.el):O(n).some(t=>m(e.el,t))||n.ids.has(x(e.el))}function pe(e,n){return n.kind==="reorder"?m(n.parent,e.scope)||I(e,n):O(n).some(t=>m(t,e.scope)||m(e.scope,t))||R(n).some(t=>m(t,e.scope))?!0:I(e,n)}function he(e,n){return O(n).some(t=>e.order.includes(t)||m(e.parent,t))||R(n).includes(e.parent)?!0:I(e,n)}function q(e,n){if(e.kind==="done"||n.kind==="done")return!1;if(e.kind==="text"&&n.kind==="text")return Xe(e.range,n.range);if(e.kind==="attr"&&n.kind==="attr")return e.el===n.el&&e.ns===n.ns&&e.local===n.local;if(e.kind==="attr")return me(e,n);if(n.kind==="attr")return me(n,e);if(e.kind==="text")return pe(e,n);if(n.kind==="text")return pe(n,e);if(e.kind==="reorder"&&n.kind==="reorder")return e.parent===n.parent||I(e,n);if(e.kind==="reorder")return he(e,n);if(n.kind==="reorder")return he(n,e);for(let t of O(e))for(let r of O(n))if(m(t,r)||m(r,t))return!0;for(let t of O(e))for(let r of R(n))if(m(r,t))return!0;for(let t of O(n))for(let r of R(e))if(m(r,t))return!0;return I(e,n)}function et(e,n){return e.kind==="done"?!1:e.kind==="attr"?m(e.el,n.node):be(e).some(t=>m(t,n.node)||m(n.node,t))?!0:e.ids.size?(n.ids||(n.ids=D(n.node)),[...e.ids].some(t=>n.ids.has(t))):!1}function tt(e,n){return e.kind==="text"&&n.kind==="text"&&!e.field&&e.root===n.root&&Je(e.range,n.range)}function nt(e,n){let t=oe(e);return t?t.nodes:[rt(e,n)]}function rt(e,n){let t=e.recovery,r=t.subject;for(let c of t.text?[t.text.liveSpan,t.text.liveScope]:[])if(c&&c.startContainer&&h(c.startContainer)&&h(c.endContainer))return st(ot(c));let o=r?b(r,n,r.nodeType):null;if(o)return o;let s=t.structure&&t.structure.localPlacement?b(t.structure.localPlacement.parent,n,1):null;if(s)return s;let i=r&&r.local.length?r.local[0]:[];for(let c=i.length-1;c>0;c--){if(i[c-1]==="content")continue;let l=$(i.slice(0,c),n);if(l)return l}return document.documentElement}function ot(e){let n=new Set;for(let r=e.startContainer;r;r=r.parentNode)n.add(r);let t=e.endContainer;for(;t&&!n.has(t);)t=t.parentNode;return t.nodeType===1||t.nodeType===11?t:t.parentNode}function st(e){for(let n=e;n;n=n.parentNode)if(k(n)&&ke.has(n.tagName))return n;return e}function ct(e,n){let t=e.recovery;return t.applied===!1||t.unavailable?null:t.structure?Ye(e,n):t.text?Ve(e,n):t.attribute?_e(e,n):null}var P=()=>`${re()}|${S.hasPendingApply()?1:0}|${S.list().map(e=>e.id).join(",")}`;function Ee(){let e={ids:new Map,nested:new Set},n=r=>{for(let o of["id","data-id"]){let s=r.getAttribute(o);s&&e.ids.set(`${o} ${s}`,(e.ids.get(`${o} ${s}`)||0)+1)}},t=(r,o)=>{for(let s of y(r).children)n(s),o&&L.has(s.tagName)&&e.nested.add(s),t(s,o||W(s)||we.has(s.tagName))};return n(document.documentElement),t(document.documentElement,!1),e}function it(e){let n=Ee();for(let[r,o]of n.ids)if(o>1&&(e.before.ids.get(r)||0)<=1)return!1;for(let r of n.nested)if(!e.before.nested.has(r))return!1;let t=new Map;for(let r of e.ops)r.kind==="text"&&t.set(r.scope,[...t.get(r.scope)||[],r]);for(let[r,o]of t){let s=o[0].before;for(let c of[...o].sort((l,u)=>u.bs-l.bs))s=s.slice(0,c.bs)+c.local+s.slice(c.be);if((o[0].owner?r.data:o[0].field?r.value:_(r).text)!==s)return!1}return!0}function lt(){let e=new Map,n=c=>{for(let l of c.querySelectorAll("*"))e.set(l,[...l.attributes].map(u=>[u,u.value])),l.localName==="template"&&l.content&&n(l.content)};n(document);let t=[];for(let c of document.querySelectorAll("input, textarea"))t.push([c,"value",c.value]);for(let c of document.querySelectorAll("input"))t.push([c,"checked",c.checked]);for(let c of document.querySelectorAll("option"))t.push([c,"selected",c.selected]);let r=document.activeElement,o=null;try{r&&typeof r.selectionStart=="number"&&(o=[r.selectionStart,r.selectionEnd,r.selectionDirection])}catch{}let s=document.getSelection(),i=s&&s.rangeCount?[s.anchorNode,s.anchorOffset,s.focusNode,s.focusOffset]:null;return{attrs:e,controls:t,active:r,caret:o,selection:i}}function at(e,n){let t=e.attributes;return t.length===n.length&&n.every(([r,o],s)=>t[s]===r&&r.value===o)}function ut(e,n){let t=new Set;for(let s=e.length-1;s>=0;s--){let i=e[s];if(i.type==="characterData")i.target.data=i.oldValue;else if(i.type==="attributes")t.add(i.target);else{for(let c of i.addedNodes)c.parentNode===i.target&&i.target.removeChild(c);for(let c of i.removedNodes)i.target.insertBefore(c,i.nextSibling)}}for(let s of t){let i=n.attrs.get(s);if(!(!i||at(s,i))){for(let c of[...s.attributes])s.removeAttributeNode(c);for(let[c,l]of i)c.value=l,s.setAttributeNode(c)}}for(let[s,i,c]of n.controls)if(s[i]!==c)try{s[i]=c}catch{}let r=document.getSelection();r&&n.selection?h(n.selection[0])&&h(n.selection[2])&&r.setBaseAndExtent(...n.selection):r&&r.rangeCount&&r.removeAllRanges();let o=n.active;if(o&&o!==document.activeElement&&o!==document.body&&h(o)&&o.focus&&o.focus({preventScroll:!0}),n.caret&&document.activeElement===o)try{o.setSelectionRange(...n.caret)}catch{}}function ft(e){let n=t=>{e.observe(t,ve);for(let r of t.querySelectorAll("template"))r.content&&n(r.content)};n(document)}function dt(e){let n=new Set;for(let t of e)if(t.type==="characterData"){if(n.has(t.target))return!1;n.add(t.target)}return!0}function mt(e){let n=P(),t=new Map,r=new Map,o=[],s=new Set;for(let a of e){if(s.has(a))continue;s.add(a);let f=S.get(a);f&&(f.claimedBy||f.kind==="apply-incomplete"||f.kind==="json"||!f.recovery?t.set(a,T):o.push(f))}if(S.hasPendingApply()){for(let a of o)t.set(a.id,T);return{ops:[],covered:r,blocked:t,revision:n,before:null}}let i=[],c=a=>{let f=S.recoveryOf(a.id),p=f?ct(a,f):null;if(!p&&f)for(let E of nt(a,f))i.push({ticket:f.ticket,node:E});return p},l=[];for(let a of o){let f=c(a);f?l.push(f):t.set(a.id,T)}let u=[];for(let a of S.list())if(!s.has(a.id)){if(a.kind==="apply-incomplete")i.push({ticket:a.ticket,node:document.documentElement});else if(a.recovery){let f=c(a);f&&u.push(f)}}l.sort((a,f)=>f.ticket-a.ticket);let d=[],N=[],v=a=>{t.set(a.id,T),N.push(a)};for(let a of l){if(i.some(p=>p.ticket>a.ticket&&et(a,p))||u.some(p=>p.ticket>a.ticket&&q(p,a))||N.some(p=>q(p,a))){v(a);continue}let f=d.find(p=>q(p,a));if(!f){d.push(a);continue}if(tt(f,a)){r.set(a.id,f.id);continue}v(a),f.ticket===a.ticket&&(d.splice(d.indexOf(f),1),v(f))}let A=ne(i.filter(a=>d.some(f=>a.ticket>f.ticket)).map(a=>a.node));return{ops:d,covered:r,blocked:t,revision:P(),protectedWitnesses:A,before:Ee()}}function pt(e){if(e.revision!==P()||!F(e.protectedWitnesses||[])){for(let c of e.ops)e.blocked.set(c.id,T);for(let c of e.covered.keys())e.blocked.set(c,T);return[]}let n=lt(),t=window.clay?.undo;t?.pause?.();let r=new MutationObserver(()=>{}),o=document.createDocumentFragment(),s=[],i=!1;try{ft(r),r.observe(o,ve);let c=e.ops.filter(l=>l.kind==="text").sort((l,u)=>l.root===u.root?u.s-l.s||u.e-l.e:0);for(let l of c)qe(l);for(let l of e.ops)l.kind==="attr"&&ze(l);Qe(e.ops.filter(l=>l.kind!=="text"&&l.kind!=="attr"),o),s=r.takeRecords(),i=e.ops.every(l=>l.check())&&it(e)&&e.revision===P()&&F(e.protectedWitnesses||[])}catch(c){console.error("[clay] Revert to mine failed while writing and was undone",c)}finally{s=s.concat(r.takeRecords()),r.disconnect()}if(i)return dt(s)&&!e.ops.some(c=>c.wroteProperty)?t?.commitCaptured?.("Revert to mine"):t?.discardCaptured?.(),t?.resume?.(),[...e.ops.map(c=>c.id),...e.covered.keys()];try{ut(s,n)}finally{J.dropQueued(),t?.discardCaptured?.(),t?.resume?.()}for(let c of e.ops)e.blocked.set(c.id,T);for(let c of e.covered.keys())e.blocked.set(c,T);return[]}async function wt(e){await Promise.resolve();let n=mt(e),t=pt(n);Q();let r=null;return t.length&&(ee(),S.acknowledge(t,{reason:"reverted"}),X(),await Promise.resolve(),r=await te()),{revertedIds:t,blockedIds:[...n.blocked.keys()],saveResult:r}}export{T as BLOCKED,pt as applyRevert,mt as prepareRevert,wt as revertConflicts};
1
+ import{f as S}from"./c-AYVGD6A6.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-XLQ3BDMM.js";import"./c-NK33MMYF.js";import"./c-LZJPNR2W.js";import{b as ce,g as ie}from"./c-BXYSDKAN.js";import{b as Z}from"./c-UHUNXWKN.js";import{b as se}from"./c-W5E5P2TZ.js";import"./c-FILLTJA7.js";import"./c-TWCXBWS3.js";import"./c-VKEDWYDF.js";import{D as te}from"./c-2ZVOEU4M.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import{g as ee}from"./c-GSRLXYWL.js";import"./c-X5LNHET5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import{a as J}from"./c-LA2BW7UY.js";import"./c-XCFQEWW6.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-PWJSJEJU.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import{h as Q}from"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var T="This spot changed again. Review the latest edit or download your copy.",ue="\uFFFC",C="",M=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),ge=new Set(["BR","WBR","IMG"]),L=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" ")),ke=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" ")),we=new Set("P H1 H2 H3 H4 H5 H6 SUMMARY".split(" ")),Ne=/[\u001E]/,ve={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0},k=e=>!!e&&e.nodeType===1,W=e=>k(e)&&M.has(e.tagName),B=e=>e.matches(le),z=e=>e.matches(ae),y=e=>e.localName==="template"&&e.content?e.content:e,w=e=>Array.prototype.indexOf.call(e.parentNode.childNodes,e),x=e=>e.getAttribute("data-id")||e.getAttribute("id")||null;function Ce(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function ye(e){if(e.nodeType===3)return!0;if(!k(e))return!1;if(B(e)||ge.has(e.tagName))return!0;if(!M.has(e.tagName))return!L.has(e.tagName);if(z(e))return!1;for(let n of e.childNodes)if(!ye(n))return!1;return!0}function Y(e){if(!ke.has(e.tagName)||B(e)||z(e))return!1;for(let n of e.childNodes)if(n.nodeType===8||!ye(n))return!1;return!0}function xe(e,n=document){for(let t of n.querySelectorAll("template")){if(t.content===e)return t;let r=xe(e,t.content);if(r)return r}return null}function m(e,n){for(let t=e;t;t=t.nodeType===11?xe(t):t.parentNode)if(t===n)return!0;return!1}var h=e=>m(e,document);function Ae(e,n){let t=e;for(let r of n)if(t=r==="content"?t.content:t.childNodes[r],!t)return null;return t}function D(e,n=new Set){if(k(e)){let t=x(e);t&&n.add(t)}if(e.nodeType===1||e.nodeType===11)for(let t of y(e).childNodes)D(t,n);return n}function Re(e){let n=document.createElement("template");return n.innerHTML=e,n.content}var Ie=e=>[...e.querySelectorAll("*")].some(n=>L.has(n.tagName));function Se(e){let n=[];for(let t=e;t.childNodes.length===1&&k(t.firstChild);t=t.firstChild)n.push(t.firstChild);return n}function De(e,n){let t=e.lastIndexOf("content");if(t<0)return document;let r=$(e.slice(0,t),n);return r&&r.content?r.content:null}function $(e,n){let t=Ae(n.root,e);if(!k(t))return null;let r=x(t),o=r?De(e,n):null;if(!o)return null;let s=[...o.querySelectorAll(t.localName)].filter(i=>i.namespaceURI===t.namespaceURI&&x(i)===r);return s.length===1?s[0]:null}function Me(e){let n=x(e);if(!n)return null;let t=[...document.querySelectorAll(e.localName)].filter(r=>r.namespaceURI===e.namespaceURI&&x(r)===n);return t.length===1?t[0]:null}function b(e,n,t=e?e.nodeType:1){if(!e)return null;for(let o of e.live)if(o.nodeType===t&&h(o))return o;if(t!==1)return null;if(e.local.length)return $(e.local[0],n);let r=e.live.find(k);return r?Me(r):null}function Pe(e){let n=e.live.find(k),t=n?x(n):null;return!!t&&![...document.querySelectorAll(n.localName)].some(r=>x(r)===t)}function _(e){let n=y(e),t={root:e,container:n,text:"",nodes:[],atoms:[],blocks:[]},r=s=>{for(let i of s){if(i.nodeType===3){if(!i.data)continue;t.nodes.push({node:i,s:t.text.length,e:t.text.length+i.data.length}),t.text+=i.data;continue}if(!k(i)||B(i))continue;if(Y(i)){t.text.length&&t.text[t.text.length-1]!==C&&(t.text+=C);let l={el:i,from:t.text.length,to:-1};t.blocks.push(l),r(i.childNodes),t.text+=C,l.to=t.text.length;continue}let c=M.has(i.tagName)&&Ce(i);if(ge.has(i.tagName)||!M.has(i.tagName)||z(i)||c){t.atoms.push({i:t.text.length,el:i}),t.text+=ue;continue}r(i.childNodes)}};if(r(n.childNodes),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&!t.blocks.length&&t.text.replace(ue,"").trim()===""){let s=t.atoms[0].i;t.text=t.text.slice(0,s)+t.text.slice(s+1),t.atoms=[];for(let i of t.nodes)i.s>s&&(i.s--,i.e--)}return t}function fe(e,n,t){for(let s of e.nodes)if(t==="start"?s.s<=n&&n<s.e:s.s<n&&n<=s.e)return[s.node,n-s.s];let r=t==="start"?n:n-1,o=e.atoms.find(s=>s.i===r);if(o)return[o.el.parentNode,w(o.el)+(t==="start"?0:1)];if(e.text[r]===C){let s=e.blocks.find(c=>c.to===r+1);if(s)return t==="start"?[s.el,s.el.childNodes.length]:[s.el.parentNode,w(s.el)+1];let i=e.blocks.find(c=>c.from===r+1);if(i)return t==="start"?[i.el,0]:[i.el.parentNode,w(i.el)]}for(let s of e.nodes)if(s.s===n||s.e===n)return[s.node,n-s.s];return[e.container,n===0?0:e.container.childNodes.length]}function j(e,n){let t=document.createRange();return t.setStart(e,n),t.setEnd(e,n),t}function K(e,n,t){if(n.nodeType===3){let i=e.nodes.find(c=>c.node===n);return i?i.s+t:null}if(n!==e.container&&!m(n,e.root))return null;let r=j(n,t),o=e.text.length,s=(i,c)=>{try{return r.comparePoint(i,c)>=0}catch{return!1}};for(let i of e.nodes)s(i.node,0)&&(o=Math.min(o,i.s));for(let i of e.atoms)s(i.el.parentNode,w(i.el))&&(o=Math.min(o,i.i));return o}function Le(e,n){let t=e.slice(n.bs,n.be),r=0;for(;r<t.length&&r<n.text.length&&t[r]===n.text[r];)r++;let o=0;for(;o<t.length-r&&o<n.text.length-r&&t[t.length-1-o]===n.text[n.text.length-1-o];)o++;return{bs:n.bs+r,be:n.be-o,text:n.text.slice(r,n.text.length-o)}}function G(e,n,t,r){if(e===n)return{s:t,e:r};let o=0,s=0,i=H.diff(e,n).map(c=>Le(e,c)).sort((c,l)=>c.bs-l.bs);for(let c of i){if(c.bs===c.be&&!c.text)continue;let l=c.text.length-(c.be-c.bs);if(c.be<=t)o+=l;else{if(c.bs>=r)continue;if(c.bs>=t&&c.be<=r){if(Ne.test(e.slice(c.bs,c.be)+c.text))return null;s+=l}else return null}}return{s:t+o,e:r+o+s}}function Be(e,n,t){let r=e.liveScope;if(r&&r.startContainer&&m(r.startContainer,n)&&m(r.endContainer,n)){let s=K(t,r.startContainer,r.startOffset);if(s!==null)return s}if(Y(n))return 0;let o=e.merged.text?t.text.indexOf(e.merged.text):-1;return o>=0&&t.text.indexOf(e.merged.text,o+1)<0?o:null}function Te(e,n){let t=e.commonAncestorContainer;for(t.nodeType===3&&(t=t.parentNode);t&&t!==n;t=t.parentNode)if(k(t)&&Y(t))return t;return n}var Oe=(e,n)=>e.tagName===n.tagName&&e.attributes.length===n.attributes.length&&[...e.attributes].every(t=>n.getAttribute(t.name)===t.value);function de(e,n){let t=[];for(let r=k(e)?e:e.parentNode;r&&r!==n&&W(r);r=r.parentNode)t.unshift(r);return t}function Ue(e,n,t){let[r,o]=e;if(r.nodeType===3){if(o!==0&&o!==r.data.length)return e;[r,o]=[r.parentNode,w(r)+(o===0?0:1)]}let s=!1;for(;r!==n&&W(r)&&(o===0||o===r.childNodes.length)&&!t.some(i=>Oe(i,r));)[r,o]=[r.parentNode,w(r)+(o===0?0:1)],s=!0;return s?[r,o]:e}function He(e,n,t){let r=de(n.startContainer,t),o=de(n.endContainer,t);return r.length!==o.length||r.some((s,i)=>s!==o[i])||r.length>e.wrappers.length||r.some((s,i)=>!Oe(s,e.wrappers[i]))?!1:(e.peel=r.length,!e.wrappers.slice(e.peel).some(s=>r.some(i=>i.tagName===s.tagName)))}function Fe(e,n,t,r){let o=e.childNodes.length===1&&k(e.firstChild)?e.firstChild:null;if(!o||!L.has(o.tagName))return;let s=document.createRange();s.setStart(...n),s.setEnd(...t);let i=Te(s,r);i===r||i.tagName!==o.tagName||i.namespaceURI!==o.namespaceURI||x(i)!==x(o)||o.replaceWith(...o.childNodes)}function Ge(e){if(!e.parsed)return e.fragment;let n=e.parsed.childNodes;return n.length?n.length===1&&n[0].nodeType===3?n[0].data:null:""}function Ve(e,n){let t=e.recovery.text,r=e.recovery.subject,o=b(r,n,r.nodeType);if(!o)return null;let s=o.nodeType===3&&o.parentNode?.localName==="textarea"?o.parentNode:o,i=t.local.text.slice(t.local.start,t.local.end);if(Ne.test(t.merged.text.slice(t.merged.start,t.merged.end))||i.includes(C))return null;let c={kind:"text",id:e.id,ticket:n.ticket,key:r.key,fragment:t.local.fragment,encoding:t.encoding,local:i,ids:new Set,range:document.createRange()};if(o.nodeType===8){let g=G(t.merged.text,o.data,t.merged.start,t.merged.end);return g?(c.range.setStart(o,g.s),c.range.setEnd(o,g.e),{...c,root:o,owner:o,scope:o,s:g.s,e:g.e,before:o.data,bs:g.s,be:g.e}):null}if(s.localName==="textarea"){if(c.encoding!=="plain")return null;let g=G(t.merged.text,s.value,t.merged.start,t.merged.end);return g?(c.range.selectNodeContents(s),{...c,root:s,field:s,scope:s,f:{text:s.value},s:g.s,e:g.e,before:s.value,bs:g.s,be:g.e}):null}let l=_(o),u=Be(t,o,l);if(u===null)return null;let d=G(t.merged.text,l.text.slice(u),t.merged.start,t.merged.end);if(!d)return null;let N=u+d.s,v=u+d.e,A=fe(l,N,"start"),a=N===v?A:fe(l,v,"end");if(c.parsed=c.encoding==="html"?Re(c.fragment):null,c.parsed&&Fe(c.parsed,A,a,o),c.parsed&&Ie(c.parsed)||(c.wrappers=c.parsed?Se(c.parsed):[],c.parsed&&D(c.parsed,c.ids),c.plain=Ge(c),N===v&&(A=a=Ue(A,o,c.wrappers)),c.range.setStart(...A),c.range.setEnd(...a),!He(c,c.range,o)))return null;let f=Te(c.range,o),p=f===o?l:_(f),E=K(p,...A),U=N===v?E:K(p,...a);return E===null||U===null||p.text.slice(E,U)!==l.text.slice(N,v)?null:{...c,root:o,f:l,s:N,e:v,scope:f,before:p.text,bs:E,be:U}}function qe(e){if(e.owner){let o=e.owner.data;e.owner.data=o.slice(0,e.s)+e.fragment+o.slice(e.e),e.check=()=>e.owner.data.slice(e.s,e.s+e.fragment.length)===e.fragment&&h(e.owner);return}if(e.field){let o=e.field,s=o.value.slice(0,e.s)+e.fragment+o.value.slice(e.e);o.textContent=s,o.value!==s&&(o.value=s,e.wroteProperty=!0),o.hasAttribute("data-value")&&o.setAttribute("data-value",s),e.check=()=>h(o)&&o.value===s&&o.textContent===s;return}let n=e.range,t=n.startContainer;if(e.plain!==null&&t.nodeType===3&&n.endContainer===t){let o=n.startOffset;t.replaceData(o,n.endOffset-o,e.plain),e.check=()=>h(t)&&t.data.slice(o,o+e.plain.length)===e.plain;return}n.deleteContents();let r=[];if(e.fragment)if(e.parsed){let o=document.importNode(e.parsed,!0),s=Se(o);for(let i=0;i<e.peel;i++)s[i].replaceWith(...s[i].childNodes);r=[...o.childNodes],n.insertNode(o)}else r=[document.createTextNode(e.fragment)],n.insertNode(r[0]);e.check=()=>r.every(h)&&(e.parsed||!r.length||r[0].data===e.fragment)}function _e(e,n){let t=b(e.recovery.subject,n,1);if(!t)return null;let r=e.recovery.attribute,o={kind:"attr",id:e.id,ticket:n.ticket,key:e.recovery.subject.key,el:t,ns:r.namespaceURI,name:r.qualifiedName,local:r.localName,value:e.local??null,ids:new Set};try{o.ns===null?document.createAttribute(o.name):document.createAttributeNS(o.ns,o.name)}catch{return null}return o}var je=new Set(["hidden","submit","image","reset","button","checkbox","radio","file"]);function Ke(e,n){let t=document.createElement("input");return t.type=e.type,t.value=n,t.value}function We(e){let n=e.el;return e.ns!==null||n.namespaceURI!=="http://www.w3.org/1999/xhtml"?null:n.localName==="input"&&e.name==="checked"&&(n.type==="checkbox"||n.type==="radio")?["checked",e.value!==null]:n.localName==="input"&&e.name==="value"&&!je.has(n.type)?["value",Ke(n,e.value??"")]:n.localName==="option"&&e.name==="selected"?["selected",e.value!==null]:null}function ze(e){e.ns===null?e.value===null?e.el.removeAttribute(e.name):e.el.setAttribute(e.name,e.value):e.value===null?e.el.removeAttributeNS(e.ns,e.local):e.el.setAttributeNS(e.ns,e.name,e.value);let n=We(e);n&&e.el[n[0]]!==n[1]&&(e.el[n[0]]=n[1],e.wroteProperty=!0);let t=()=>e.ns===null?e.el.getAttribute(e.name):e.el.getAttributeNS(e.ns,e.local);e.check=()=>h(e.el)&&t()===e.value&&(!n||e.el[n[0]]===n[1])}function Ye(e,n){let t=e.recovery.structure,r=e.recovery.subject,o=b(r,n,r.nodeType),s={id:e.id,ticket:n.ticket,key:r.key,apply:n,ids:new Set},i=c=>c?b(c.parent,n,1):null;if(t.localAction==="deleted")return o?{...s,kind:"remove",node:o}:Pe(r)?{...s,kind:"done",check:()=>!0}:null;if(t.localAction==="moved"){let c=i(t.localPlacement);return!o||!c||o===c||m(c,o)?null:{...s,kind:"move",node:o,parent:c,placement:t.localPlacement}}if(t.localAction==="reordered"){if(!o||!t.localOrder)return null;let c=y(o),l=t.localOrder.map(u=>b(u,n,u.nodeType)).filter(u=>u&&u.parentNode===c);return l.length<2?null:{...s,kind:"reorder",parent:o,order:l}}if(t.localAction==="inserted"){let c=i(t.localPlacement);if(!c||o&&o.parentNode!==y(c))return null;if(t.fragmentKind!=="element")return typeof t.localFragment!="string"?null:{...s,kind:"run",node:o,parent:c,placement:t.localPlacement,text:t.localFragment,nodeType:r.nodeType};let l=r.local.length?Ae(n.root,r.local[0]):null;if(!k(l))return null;let u=o?o.tagName===l.tagName&&o.namespaceURI===l.namespaceURI?"morph":"replace":"place";return{...s,kind:"realize",node:o,parent:c,placement:t.localPlacement,src:l,mode:u,ids:D(l)}}return null}function V(e,n,t,r){let o=y(n),s=l=>{for(let u of l){let d=b(u,r,u.nodeType);if(d&&d!==e&&d.parentNode===o)return d}return null},i=s(t.before);if(i)return o.insertBefore(e,i);let c=s(t.after);return c?o.insertBefore(e,c.nextSibling):t.before.length?o.insertBefore(e,o.firstChild):o.appendChild(e)}function $e(e){let n=document.importNode(e.src,!0),t=document.createDocumentFragment();return t.append(n),e.apply.domain==="save"&&(se(t),ce(t),ie(t),Z(t)),n}function Qe(e,n){let t=e.filter(r=>r.kind==="move");for(let r of t)n.append(r.node);for(let r of e){if(r.kind==="run"){r.node?r.node.data=r.text:r.node=V(r.nodeType===8?document.createComment(r.text):document.createTextNode(r.text),r.parent,r.placement,r.apply),r.check=()=>h(r.node)&&r.node.parentNode===y(r.parent)&&r.node.data===r.text;continue}if(r.kind!=="realize")continue;let o=$e(r);r.mode==="morph"?H.morphElement(r.node,o,{ignore:B,scripts:{execute:!1}}):r.mode==="replace"?(r.node.replaceWith(o),r.node=o):r.node=V(o,r.parent,r.placement,r.apply),r.check=()=>h(r.node)&&r.node.parentNode===y(r.parent)}for(let r of t)V(r.node,r.parent,r.placement,r.apply),r.check=()=>r.node.parentNode===y(r.parent)&&h(r.node);for(let r of e){if(r.kind!=="reorder")continue;let o=y(r.parent),s=r.order.filter(u=>u.parentNode===o),i=s.slice(),c=[...o.childNodes].map(u=>s.includes(u)?i.shift():u),l=null;for(let u=c.length-1;u>=0;u--){let d=c[u];s.includes(d)&&d.nextSibling!==l&&o.insertBefore(d,l),l=d}r.check=()=>{let u=[...o.childNodes].filter(d=>s.includes(d));return u.length===s.length&&u.every((d,N)=>d===s[N])}}for(let r of e)r.kind==="remove"&&(r.node.remove(),r.check=()=>!h(r.node))}function O(e){return e.kind==="move"||e.kind==="remove"?[e.node]:e.kind==="realize"||e.kind==="run"?e.node?[e.node]:[]:[]}function R(e){return e.kind==="text"?[e.scope]:e.kind==="move"||e.kind==="reorder"?[e.parent]:(e.kind==="realize"||e.kind==="run")&&!e.node?[e.parent]:[]}var be=e=>e.kind==="attr"?[e.el]:[...O(e),...R(e)];function Xe(e,n){try{let t=j(e.startContainer,e.startOffset),r=j(n.startContainer,n.startOffset);return e.collapsed&&n.collapsed?t.comparePoint(n.startContainer,n.startOffset)===0:t.comparePoint(n.endContainer,n.endOffset)>0&&r.comparePoint(e.endContainer,e.endOffset)>0}catch{return!1}}function Je(e,n){try{return e.comparePoint(n.startContainer,n.startOffset)===0&&e.comparePoint(n.endContainer,n.endOffset)===0}catch{return!1}}function Ze(e,n){try{return e.intersectsNode(n)&&!m(e.commonAncestorContainer,n)}catch{return!1}}function I(e,n){if(!e.ids.size&&!n.ids.size)return!1;let t=s=>{let i=new Set;for(let c of be(s))D(c,i);return i},r=e.ids.size?null:t(e),o=t(n);return[...e.ids].some(s=>n.ids.has(s)||o.has(s))||[...n.ids].some(s=>(r||t(e)).has(s))}function me(e,n){return n.kind==="text"?Ze(n.range,e.el):O(n).some(t=>m(e.el,t))||n.ids.has(x(e.el))}function pe(e,n){return n.kind==="reorder"?m(n.parent,e.scope)||I(e,n):O(n).some(t=>m(t,e.scope)||m(e.scope,t))||R(n).some(t=>m(t,e.scope))?!0:I(e,n)}function he(e,n){return O(n).some(t=>e.order.includes(t)||m(e.parent,t))||R(n).includes(e.parent)?!0:I(e,n)}function q(e,n){if(e.kind==="done"||n.kind==="done")return!1;if(e.kind==="text"&&n.kind==="text")return Xe(e.range,n.range);if(e.kind==="attr"&&n.kind==="attr")return e.el===n.el&&e.ns===n.ns&&e.local===n.local;if(e.kind==="attr")return me(e,n);if(n.kind==="attr")return me(n,e);if(e.kind==="text")return pe(e,n);if(n.kind==="text")return pe(n,e);if(e.kind==="reorder"&&n.kind==="reorder")return e.parent===n.parent||I(e,n);if(e.kind==="reorder")return he(e,n);if(n.kind==="reorder")return he(n,e);for(let t of O(e))for(let r of O(n))if(m(t,r)||m(r,t))return!0;for(let t of O(e))for(let r of R(n))if(m(r,t))return!0;for(let t of O(n))for(let r of R(e))if(m(r,t))return!0;return I(e,n)}function et(e,n){return e.kind==="done"?!1:e.kind==="attr"?m(e.el,n.node):be(e).some(t=>m(t,n.node)||m(n.node,t))?!0:e.ids.size?(n.ids||(n.ids=D(n.node)),[...e.ids].some(t=>n.ids.has(t))):!1}function tt(e,n){return e.kind==="text"&&n.kind==="text"&&!e.field&&e.root===n.root&&Je(e.range,n.range)}function nt(e,n){let t=oe(e);return t?t.nodes:[rt(e,n)]}function rt(e,n){let t=e.recovery,r=t.subject;for(let c of t.text?[t.text.liveSpan,t.text.liveScope]:[])if(c&&c.startContainer&&h(c.startContainer)&&h(c.endContainer))return st(ot(c));let o=r?b(r,n,r.nodeType):null;if(o)return o;let s=t.structure&&t.structure.localPlacement?b(t.structure.localPlacement.parent,n,1):null;if(s)return s;let i=r&&r.local.length?r.local[0]:[];for(let c=i.length-1;c>0;c--){if(i[c-1]==="content")continue;let l=$(i.slice(0,c),n);if(l)return l}return document.documentElement}function ot(e){let n=new Set;for(let r=e.startContainer;r;r=r.parentNode)n.add(r);let t=e.endContainer;for(;t&&!n.has(t);)t=t.parentNode;return t.nodeType===1||t.nodeType===11?t:t.parentNode}function st(e){for(let n=e;n;n=n.parentNode)if(k(n)&&ke.has(n.tagName))return n;return e}function ct(e,n){let t=e.recovery;return t.applied===!1||t.unavailable?null:t.structure?Ye(e,n):t.text?Ve(e,n):t.attribute?_e(e,n):null}var P=()=>`${re()}|${S.hasPendingApply()?1:0}|${S.list().map(e=>e.id).join(",")}`;function Ee(){let e={ids:new Map,nested:new Set},n=r=>{for(let o of["id","data-id"]){let s=r.getAttribute(o);s&&e.ids.set(`${o} ${s}`,(e.ids.get(`${o} ${s}`)||0)+1)}},t=(r,o)=>{for(let s of y(r).children)n(s),o&&L.has(s.tagName)&&e.nested.add(s),t(s,o||W(s)||we.has(s.tagName))};return n(document.documentElement),t(document.documentElement,!1),e}function it(e){let n=Ee();for(let[r,o]of n.ids)if(o>1&&(e.before.ids.get(r)||0)<=1)return!1;for(let r of n.nested)if(!e.before.nested.has(r))return!1;let t=new Map;for(let r of e.ops)r.kind==="text"&&t.set(r.scope,[...t.get(r.scope)||[],r]);for(let[r,o]of t){let s=o[0].before;for(let c of[...o].sort((l,u)=>u.bs-l.bs))s=s.slice(0,c.bs)+c.local+s.slice(c.be);if((o[0].owner?r.data:o[0].field?r.value:_(r).text)!==s)return!1}return!0}function lt(){let e=new Map,n=c=>{for(let l of c.querySelectorAll("*"))e.set(l,[...l.attributes].map(u=>[u,u.value])),l.localName==="template"&&l.content&&n(l.content)};n(document);let t=[];for(let c of document.querySelectorAll("input, textarea"))t.push([c,"value",c.value]);for(let c of document.querySelectorAll("input"))t.push([c,"checked",c.checked]);for(let c of document.querySelectorAll("option"))t.push([c,"selected",c.selected]);let r=document.activeElement,o=null;try{r&&typeof r.selectionStart=="number"&&(o=[r.selectionStart,r.selectionEnd,r.selectionDirection])}catch{}let s=document.getSelection(),i=s&&s.rangeCount?[s.anchorNode,s.anchorOffset,s.focusNode,s.focusOffset]:null;return{attrs:e,controls:t,active:r,caret:o,selection:i}}function at(e,n){let t=e.attributes;return t.length===n.length&&n.every(([r,o],s)=>t[s]===r&&r.value===o)}function ut(e,n){let t=new Set;for(let s=e.length-1;s>=0;s--){let i=e[s];if(i.type==="characterData")i.target.data=i.oldValue;else if(i.type==="attributes")t.add(i.target);else{for(let c of i.addedNodes)c.parentNode===i.target&&i.target.removeChild(c);for(let c of i.removedNodes)i.target.insertBefore(c,i.nextSibling)}}for(let s of t){let i=n.attrs.get(s);if(!(!i||at(s,i))){for(let c of[...s.attributes])s.removeAttributeNode(c);for(let[c,l]of i)c.value=l,s.setAttributeNode(c)}}for(let[s,i,c]of n.controls)if(s[i]!==c)try{s[i]=c}catch{}let r=document.getSelection();r&&n.selection?h(n.selection[0])&&h(n.selection[2])&&r.setBaseAndExtent(...n.selection):r&&r.rangeCount&&r.removeAllRanges();let o=n.active;if(o&&o!==document.activeElement&&o!==document.body&&h(o)&&o.focus&&o.focus({preventScroll:!0}),n.caret&&document.activeElement===o)try{o.setSelectionRange(...n.caret)}catch{}}function ft(e){let n=t=>{e.observe(t,ve);for(let r of t.querySelectorAll("template"))r.content&&n(r.content)};n(document)}function dt(e){let n=new Set;for(let t of e)if(t.type==="characterData"){if(n.has(t.target))return!1;n.add(t.target)}return!0}function mt(e){let n=P(),t=new Map,r=new Map,o=[],s=new Set;for(let a of e){if(s.has(a))continue;s.add(a);let f=S.get(a);f&&(f.claimedBy||f.kind==="apply-incomplete"||f.kind==="json"||!f.recovery?t.set(a,T):o.push(f))}if(S.hasPendingApply()){for(let a of o)t.set(a.id,T);return{ops:[],covered:r,blocked:t,revision:n,before:null}}let i=[],c=a=>{let f=S.recoveryOf(a.id),p=f?ct(a,f):null;if(!p&&f)for(let E of nt(a,f))i.push({ticket:f.ticket,node:E});return p},l=[];for(let a of o){let f=c(a);f?l.push(f):t.set(a.id,T)}let u=[];for(let a of S.list())if(!s.has(a.id)){if(a.kind==="apply-incomplete")i.push({ticket:a.ticket,node:document.documentElement});else if(a.recovery){let f=c(a);f&&u.push(f)}}l.sort((a,f)=>f.ticket-a.ticket);let d=[],N=[],v=a=>{t.set(a.id,T),N.push(a)};for(let a of l){if(i.some(p=>p.ticket>a.ticket&&et(a,p))||u.some(p=>p.ticket>a.ticket&&q(p,a))||N.some(p=>q(p,a))){v(a);continue}let f=d.find(p=>q(p,a));if(!f){d.push(a);continue}if(tt(f,a)){r.set(a.id,f.id);continue}v(a),f.ticket===a.ticket&&(d.splice(d.indexOf(f),1),v(f))}let A=ne(i.filter(a=>d.some(f=>a.ticket>f.ticket)).map(a=>a.node));return{ops:d,covered:r,blocked:t,revision:P(),protectedWitnesses:A,before:Ee()}}function pt(e){if(e.revision!==P()||!F(e.protectedWitnesses||[])){for(let c of e.ops)e.blocked.set(c.id,T);for(let c of e.covered.keys())e.blocked.set(c,T);return[]}let n=lt(),t=window.clay?.undo;t?.pause?.();let r=new MutationObserver(()=>{}),o=document.createDocumentFragment(),s=[],i=!1;try{ft(r),r.observe(o,ve);let c=e.ops.filter(l=>l.kind==="text").sort((l,u)=>l.root===u.root?u.s-l.s||u.e-l.e:0);for(let l of c)qe(l);for(let l of e.ops)l.kind==="attr"&&ze(l);Qe(e.ops.filter(l=>l.kind!=="text"&&l.kind!=="attr"),o),s=r.takeRecords(),i=e.ops.every(l=>l.check())&&it(e)&&e.revision===P()&&F(e.protectedWitnesses||[])}catch(c){console.error("[clay] Revert to mine failed while writing and was undone",c)}finally{s=s.concat(r.takeRecords()),r.disconnect()}if(i)return dt(s)&&!e.ops.some(c=>c.wroteProperty)?t?.commitCaptured?.("Revert to mine"):t?.discardCaptured?.(),t?.resume?.(),[...e.ops.map(c=>c.id),...e.covered.keys()];try{ut(s,n)}finally{J.dropQueued(),t?.discardCaptured?.(),t?.resume?.()}for(let c of e.ops)e.blocked.set(c.id,T);for(let c of e.covered.keys())e.blocked.set(c,T);return[]}async function wt(e){await Promise.resolve();let n=mt(e),t=pt(n);Q();let r=null;return t.length&&(ee(),S.acknowledge(t,{reason:"reverted"}),X(),await Promise.resolve(),r=await te()),{revertedIds:t,blockedIds:[...n.blocked.keys()],saveResult:r}}export{T as BLOCKED,pt as applyRevert,mt as prepareRevert,wt as revertConflicts};
@@ -1 +1 @@
1
- import{b as L}from"./c-QY7F6EN6.js";import{f as b,g as h,j as p,l as E,n as m}from"./c-IHUWUKIU.js";import{e as i,f as d,g as x}from"./c-EUGJVHDD.js";import{b as w}from"./c-MHI3GYKF.js";import{b as o}from"./c-NUHP2XDB.js";var g={success:{edge:i.teal,icon:d.toastSuccess},error:{edge:i.ox,icon:d.toastWarning},warning:{edge:i.brass,icon:d.toastWarning},info:{edge:i.brass,icon:d.toastInfo}},M=d.toastClose,P=["opacity:0","transform:translateX(24px)"];function $(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches?"none":"opacity .5s ease-in-out, transform .5s ease-in-out"}function A(){let e=document.querySelector('clay-editor-ui[data-clay-ui="toasts"]')?.shadowRoot.querySelector("[data-clay-toasts]");if(e)return e;let t=p("div",["position:fixed","top:18px","right:18px","z-index:9999","display:flex","flex-direction:column","align-items:flex-end","gap:10px","width:min(330px, calc(100vw - 36px))","pointer-events:none"]);return t.setAttribute("data-clay-toasts",""),t.setAttribute("aria-live","polite"),L({name:"toasts",content:t}),t}function k(e,t,{detail:n="",actions:r=[]}={}){let c=g[t],s=E("div",["display:flex","align-items:flex-start",...x.toast,"width:100%",`border-inline-start:3px solid ${c.edge}`,"cursor:pointer","pointer-events:auto",...P,`transition:${$()}`]);s.setAttribute("data-clay-toast",t);let l=p("div",["flex:1 1 auto","min-width:0","display:flex","flex-direction:column","gap:8px"]),f=p("div",["display:flex","align-items:flex-start","gap:8px"]),v=m("span",["display:inline-grid","flex:none","padding-top:1px",`color:${c.edge}`]);v.innerHTML=c.icon,b(v.firstElementChild,16);let T=m("span",["flex:1 1 auto","min-width:120px",...x.toastTitle,"overflow-wrap:anywhere"],e);if(f.append(v,T),l.append(f),n&&l.append(m("span",["display:block",`color:${i.muted}`,"overflow-wrap:anywhere"],n)),r.length){let y=p("div",["display:flex","flex-wrap:wrap","gap:8px"]);for(let{label:C,onClick:I}of r)y.append(h(C,{small:!0,variant:"quiet",onClick:I}));l.append(y)}return s.append(l),s}function D(e){let t=p("button",["flex:none","display:inline-grid","place-items:center",...x.toastClose,"cursor:pointer"]);t.type="button",t.setAttribute("aria-label","Dismiss"),t.title="Dismiss",t.innerHTML=M,b(t.firstElementChild,14);let n=r=>{o(t,"color",r?i.ink:i.muted),o(t,"background",r?i.sunk:"transparent")};return t.addEventListener("pointerenter",()=>n(!0)),t.addEventListener("pointerleave",()=>n(!1)),t.addEventListener("focus",()=>{n(!0),o(t,"outline",`2px solid ${i.brass}`),o(t,"outline-offset","1px")}),t.addEventListener("blur",()=>{n(!1),o(t,"outline","none")}),t.addEventListener("click",e),t}function S(e){A().append(e),w(e,{background:i.surface}),setTimeout(()=>{o(e,"opacity","1"),o(e,"transform","none")},10)}function u(e,t){o(e,"opacity","0"),o(e,"transform","translateX(24px)"),setTimeout(()=>{e.remove(),t?.()},500)}function H(e,t="success"){let n=k(e,g[t]?t:"success");n.addEventListener("click",()=>u(n)),S(n),setTimeout(()=>u(n),6600)}var a=new Map;function R(e,t="warning",{detail:n="",actions:r=[]}={}){let c=a.get(e);c&&(u(c),a.delete(e));let s=k(e,g[t]?t:"warning",{detail:n,actions:r});o(s,"cursor","default");let l=D(f=>{f.stopPropagation(),u(s,()=>{a.get(e)===s&&a.delete(e)})});s.append(l),a.set(e,s),S(s)}function U(e,{now:t=!1}={}){let n=a.get(e);if(n){if(a.delete(e),t){n.remove();return}u(n)}}var W=H;export{R as a,U as b,W as c};
1
+ import{b as L}from"./c-QY7F6EN6.js";import{f as b,g as h,j as p,l as E,n as m}from"./c-IHUWUKIU.js";import{e as i,f as d,g as x}from"./c-EUGJVHDD.js";import{b as w}from"./c-PKCCHJ5X.js";import{b as o}from"./c-NUHP2XDB.js";var g={success:{edge:i.teal,icon:d.toastSuccess},error:{edge:i.ox,icon:d.toastWarning},warning:{edge:i.brass,icon:d.toastWarning},info:{edge:i.brass,icon:d.toastInfo}},M=d.toastClose,P=["opacity:0","transform:translateX(24px)"];function $(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches?"none":"opacity .5s ease-in-out, transform .5s ease-in-out"}function A(){let e=document.querySelector('clay-editor-ui[data-clay-ui="toasts"]')?.shadowRoot.querySelector("[data-clay-toasts]");if(e)return e;let t=p("div",["position:fixed","top:18px","right:18px","z-index:9999","display:flex","flex-direction:column","align-items:flex-end","gap:10px","width:min(330px, calc(100vw - 36px))","pointer-events:none"]);return t.setAttribute("data-clay-toasts",""),t.setAttribute("aria-live","polite"),L({name:"toasts",content:t}),t}function k(e,t,{detail:n="",actions:r=[]}={}){let c=g[t],s=E("div",["display:flex","align-items:flex-start",...x.toast,"width:100%",`border-inline-start:3px solid ${c.edge}`,"cursor:pointer","pointer-events:auto",...P,`transition:${$()}`]);s.setAttribute("data-clay-toast",t);let l=p("div",["flex:1 1 auto","min-width:0","display:flex","flex-direction:column","gap:8px"]),f=p("div",["display:flex","align-items:flex-start","gap:8px"]),v=m("span",["display:inline-grid","flex:none","padding-top:1px",`color:${c.edge}`]);v.innerHTML=c.icon,b(v.firstElementChild,16);let T=m("span",["flex:1 1 auto","min-width:120px",...x.toastTitle,"overflow-wrap:anywhere"],e);if(f.append(v,T),l.append(f),n&&l.append(m("span",["display:block",`color:${i.muted}`,"overflow-wrap:anywhere"],n)),r.length){let y=p("div",["display:flex","flex-wrap:wrap","gap:8px"]);for(let{label:C,onClick:I}of r)y.append(h(C,{small:!0,variant:"quiet",onClick:I}));l.append(y)}return s.append(l),s}function D(e){let t=p("button",["flex:none","display:inline-grid","place-items:center",...x.toastClose,"cursor:pointer"]);t.type="button",t.setAttribute("aria-label","Dismiss"),t.title="Dismiss",t.innerHTML=M,b(t.firstElementChild,14);let n=r=>{o(t,"color",r?i.ink:i.muted),o(t,"background",r?i.sunk:"transparent")};return t.addEventListener("pointerenter",()=>n(!0)),t.addEventListener("pointerleave",()=>n(!1)),t.addEventListener("focus",()=>{n(!0),o(t,"outline",`2px solid ${i.brass}`),o(t,"outline-offset","1px")}),t.addEventListener("blur",()=>{n(!1),o(t,"outline","none")}),t.addEventListener("click",e),t}function S(e){A().append(e),w(e,{background:i.surface}),setTimeout(()=>{o(e,"opacity","1"),o(e,"transform","none")},10)}function u(e,t){o(e,"opacity","0"),o(e,"transform","translateX(24px)"),setTimeout(()=>{e.remove(),t?.()},500)}function H(e,t="success"){let n=k(e,g[t]?t:"success");n.addEventListener("click",()=>u(n)),S(n),setTimeout(()=>u(n),6600)}var a=new Map;function R(e,t="warning",{detail:n="",actions:r=[]}={}){let c=a.get(e);c&&(u(c),a.delete(e));let s=k(e,g[t]?t:"warning",{detail:n,actions:r});o(s,"cursor","default");let l=D(f=>{f.stopPropagation(),u(s,()=>{a.get(e)===s&&a.delete(e)})});s.append(l),a.set(e,s),S(s)}function U(e,{now:t=!1}={}){let n=a.get(e);if(n){if(a.delete(e),t){n.remove();return}u(n)}}var W=H;export{R as a,U as b,W as c};
@@ -1 +1 @@
1
- import{c as h}from"./c-KBS3UV6B.js";import{i as k,j as y}from"./c-4RFZROCF.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-4TWARTLS.js";import"./c-Q5KAQJAG.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as g}from"./c-TMT5TL65.js";import{b as m,m as d}from"./c-QIXT3Q7C.js";import"./c-OI2BYWVV.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var b=e=>String(e).padStart(2,"0");function A(e){if(typeof e!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;let s=new Date(`${e}T12:00:00Z`);return Number.isFinite(s.valueOf())&&s.toISOString().slice(0,10)===e}var $=(e=new Date)=>`${e.getFullYear()}-${b(e.getMonth()+1)}-${b(e.getDate())}`,E=(e,s)=>{let a=new Date(`${e}T12:00:00Z`);return a.setUTCDate(a.getUTCDate()+s),a.toISOString().slice(0,10)},I=e=>{let s=E(e,1);return[{id:"today",name:`Today (${e})`,date:e},{id:"tomorrow",name:`Tomorrow (${s})`,date:s}]};function L({view:e=null}={}){if(!e)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let s=e.dom.ownerDocument,a=null;function l(t){let o=e.state;if(!o.selection.empty||o.selection.from!==t.from||t.from<0||t.from>o.doc.content.size)return null;let r=o.doc.resolve(t.from);return!r.parent.isTextblock||r.parent.type.spec.code||!r.parent.type.allowsMarkType(d.marks.date)?null:t.from}function D(t){try{let o=e.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=e.coordsAtPos(t.from);return{x:Math.max(8,r.left-o.left),y:r.bottom+6-o.top}}catch{return null}}function u(t){let o=t.picker.activeId();o?e.dom.setAttribute("aria-activedescendant",o):e.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&e.dom.removeAttribute("aria-activedescendant")}function c(){let t=a;if(t){a=null;for(let[o,r,n,i]of t.listen)o.removeEventListener(r,n,i);e.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&e.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function x(t,o){let r=String(o),n=e.state.tr.insertText(r,t,t);return n.addMark(t,t+r.length,d.marks.date.create({date:r})),n.insertText(" ",t+r.length),n.setSelection(m.TextSelection.create(n.doc,t+r.length+1)),e.dispatch(g(n)),e.focus(),{ok:!0,date:r}}async function f(t){let o=a;if(!o)return{ok:!1,code:"not-editing"};let r=o.picker.personAt(t),n=l(o);return n===null||!r||!A(r.date)?(c(),r?n===null?{ok:!1,code:"stale-target"}:{ok:!1,code:"invalid-date"}:{ok:!1,code:"no-date"}):(c(),k(e,()=>{let i=l(o);return i===null?{ok:!1,code:"stale-target"}:x(i,r.date)}))}function S(t){let o=a;if(!o||y(t,e))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),o.picker.move(t.key==="ArrowDown"?1:-1),u(o)):t.key==="Enter"?(r(),f(o.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),c())}function T(){c();let t={from:e.state.selection.from,days:I($()),picker:null,listen:[]};t.picker=h({document:s,label:"Insert a date",empty:"No date to insert",onPick:r=>f(r)}),a=t;let o=(r,n,i,p)=>{r.addEventListener(n,i,p),t.listen.push([r,n,i,p])};return o(s,"keydown",r=>S(r),!0),o(e.dom,"input",()=>c()),o(s,"mousedown",r=>{t.picker.el.contains(r.target)||c()},!0),(e.dom.parentElement??s.body).appendChild(t.picker.el),l(t)===null?(c(),{ok:!1,code:"stale-target"}):(t.picker.show(t.days,D(t)),u(t),{ok:!0,picker:!0})}return{async run(){return T()},dispose(){c()}}}export{L as createFeature,I as earlyDays,A as isISODate,$ as localISODate};
1
+ import{c as h}from"./c-KBS3UV6B.js";import{i as k,j as y}from"./c-LIGQYZ7M.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-6RDOKLN7.js";import"./c-DTMZ3ZHI.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as g}from"./c-HCNWJE4A.js";import{b as m,m as d}from"./c-QIXT3Q7C.js";import"./c-LCYPMULG.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var b=e=>String(e).padStart(2,"0");function A(e){if(typeof e!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;let s=new Date(`${e}T12:00:00Z`);return Number.isFinite(s.valueOf())&&s.toISOString().slice(0,10)===e}var $=(e=new Date)=>`${e.getFullYear()}-${b(e.getMonth()+1)}-${b(e.getDate())}`,E=(e,s)=>{let a=new Date(`${e}T12:00:00Z`);return a.setUTCDate(a.getUTCDate()+s),a.toISOString().slice(0,10)},I=e=>{let s=E(e,1);return[{id:"today",name:`Today (${e})`,date:e},{id:"tomorrow",name:`Tomorrow (${s})`,date:s}]};function L({view:e=null}={}){if(!e)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let s=e.dom.ownerDocument,a=null;function l(t){let o=e.state;if(!o.selection.empty||o.selection.from!==t.from||t.from<0||t.from>o.doc.content.size)return null;let r=o.doc.resolve(t.from);return!r.parent.isTextblock||r.parent.type.spec.code||!r.parent.type.allowsMarkType(d.marks.date)?null:t.from}function D(t){try{let o=e.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=e.coordsAtPos(t.from);return{x:Math.max(8,r.left-o.left),y:r.bottom+6-o.top}}catch{return null}}function u(t){let o=t.picker.activeId();o?e.dom.setAttribute("aria-activedescendant",o):e.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&e.dom.removeAttribute("aria-activedescendant")}function c(){let t=a;if(t){a=null;for(let[o,r,n,i]of t.listen)o.removeEventListener(r,n,i);e.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&e.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function x(t,o){let r=String(o),n=e.state.tr.insertText(r,t,t);return n.addMark(t,t+r.length,d.marks.date.create({date:r})),n.insertText(" ",t+r.length),n.setSelection(m.TextSelection.create(n.doc,t+r.length+1)),e.dispatch(g(n)),e.focus(),{ok:!0,date:r}}async function f(t){let o=a;if(!o)return{ok:!1,code:"not-editing"};let r=o.picker.personAt(t),n=l(o);return n===null||!r||!A(r.date)?(c(),r?n===null?{ok:!1,code:"stale-target"}:{ok:!1,code:"invalid-date"}:{ok:!1,code:"no-date"}):(c(),k(e,()=>{let i=l(o);return i===null?{ok:!1,code:"stale-target"}:x(i,r.date)}))}function S(t){let o=a;if(!o||y(t,e))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),o.picker.move(t.key==="ArrowDown"?1:-1),u(o)):t.key==="Enter"?(r(),f(o.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),c())}function T(){c();let t={from:e.state.selection.from,days:I($()),picker:null,listen:[]};t.picker=h({document:s,label:"Insert a date",empty:"No date to insert",onPick:r=>f(r)}),a=t;let o=(r,n,i,p)=>{r.addEventListener(n,i,p),t.listen.push([r,n,i,p])};return o(s,"keydown",r=>S(r),!0),o(e.dom,"input",()=>c()),o(s,"mousedown",r=>{t.picker.el.contains(r.target)||c()},!0),(e.dom.parentElement??s.body).appendChild(t.picker.el),l(t)===null?(c(),{ok:!1,code:"stale-target"}):(t.picker.show(t.days,D(t)),u(t),{ok:!0,picker:!0})}return{async run(){return T()},dispose(){c()}}}export{L as createFeature,I as earlyDays,A as isISODate,$ as localISODate};
@@ -0,0 +1 @@
1
+ import{b as K}from"./c-QY7F6EN6.js";var oe="[clay-menu-item]:not([cms-template])",U=()=>window.clay?.mode==="edit"||window.clay?.mode==="draft";async function re(u){if(await window.clay?.ready,!U()||!u.isConnected)return!1;let v=window.clay?.undo;return v&&typeof v.commit=="function"?v.commit("Remove this item",()=>u.remove()):u.remove(),window.clay?.save?.soon?.(),!0}function pe({addItem:u,removeItem:v,beforeOpen:N}){let b=new Set;function m(){let w=new Set;for(let a of document.querySelectorAll(oe)){let l=a.getAttribute("data-id")||a.id;if(!l){console.warn("[clay] A clay-menu-item needs a data-id or an id.",a);continue}let s=`dom.${l}`;w.add(s);let A=a.getAttribute("clay-menu-dismiss");u({id:s,label:a.textContent.trim(),href:a.getAttribute("href")||"",section:a.getAttribute("clay-menu-section")||void 0,quiet:a.hasAttribute("clay-menu-quiet"),run:a.hasAttribute("href")?null:()=>a.click(),dismiss:A&&U()?{label:A,run:()=>re(a)}:void 0})}for(let a of b)w.has(a)||v(a);b.clear();for(let a of w)b.add(a)}N.push(m);for(let w of["clay:drafts-restored","clay:sync-applied","clay:modechange"])document.addEventListener(w,m);m()}var V='<svg xmlns="http://www.w3.org/2000/svg" viewBox="-45.87 -57.96 100.26 60.98" fill="currentColor" aria-hidden="true" focusable="false"><path fill-rule="evenodd" d="M44.35 -4.56Q40.03 -0.52 34.69 -0.39Q29.34 -0.25 24.81 -0.14Q20.27 -0.02 15.6 0Q10.93 0.02 6.41 0Q1.89 -0.02 -2.79 -0.02Q-7.48 -0.02 -12.11 -0.14Q-16.73 -0.25 -21.64 -0.27Q-26.55 -0.3 -31.72 -2.25Q-36.88 -4.2 -39.87 -9.12Q-42.87 -14.03 -42.8 -19.61Q-42.74 -25.18 -40.43 -29.94Q-38.12 -34.69 -34.82 -38.78Q-31.52 -42.87 -27.25 -45.6Q-22.98 -48.33 -18.35 -50.59Q-13.73 -52.85 -8.7 -53.88Q-3.68 -54.91 1.32 -54.93Q6.32 -54.96 11.44 -54.56Q16.55 -54.16 21.35 -52.2Q26.16 -50.24 30.69 -48.01Q35.22 -45.78 38.99 -42.18Q42.76 -38.59 45.67 -34.37Q48.59 -30.15 49.99 -24.87Q51.39 -19.59 50.04 -14.09Q48.68 -8.6 44.35 -4.56ZM0.66 -30.49C0.5 -28.73 -0.88 -27.42 -2.42 -27.57C-3.96 -27.71 -5.08 -29.25 -4.91 -31.01C-4.75 -32.77 -3.36 -34.08 -1.83 -33.94C-0.29 -33.79 0.83 -32.25 0.66 -30.49ZM13.61 -29.28C13.44 -27.52 12.06 -26.21 10.52 -26.35C8.98 -26.5 7.87 -28.04 8.03 -29.8C8.2 -31.56 9.58 -32.87 11.12 -32.73C12.66 -32.58 13.77 -31.04 13.61 -29.28ZM-1.23 -17.71Q-0.62 -17.35 -0.03 -17.08Q0.56 -16.81 1.15 -16.54Q1.73 -16.28 2.4 -16Q3.07 -15.72 3.87 -15.6Q4.66 -15.48 5.4 -15.55Q6.13 -15.62 6.77 -15.79Q7.41 -15.96 7.97 -16.23Q8.53 -16.5 9 -16.91Q9.46 -17.32 9.73 -17.9Q9.99 -18.47 10.08 -19.12Q10.17 -19.77 10.08 -20.42Q9.99 -21.06 9.45 -21.32Q8.91 -21.58 8.27 -21.38Q7.63 -21.17 6.99 -20.91Q6.36 -20.65 5.7 -20.61Q5.04 -20.56 4.33 -20.73Q3.62 -20.9 2.92 -21.14Q2.23 -21.39 1.54 -21.68Q0.85 -21.97 0.16 -22.27Q-0.52 -22.56 -1.22 -22.79Q-1.92 -23.03 -2.49 -22.61Q-3.05 -22.19 -3.23 -21.5Q-3.4 -20.81 -3.2 -20.09Q-3.01 -19.38 -3.02 -19.15Q-3.02 -18.93 -2.42 -18.5Q-1.83 -18.06 -1.23 -17.71Z"/></svg>';var j="1",k=8,se='<svg viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M1 0 5 4l4-4 1 1-4 4 4 4-1 1-4-4-4 4-1-1 4-4-4-4z"/></svg>',le='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" aria-hidden="true" focusable="false"><path d="M224,128a8,8,0,0,1-8,8H59.31l58.35,58.34a8,8,0,0,1-11.32,11.32l-72-72a8,8,0,0,1,0-11.32l72-72a8,8,0,0,1,11.32,11.32L59.31,120H216A8,8,0,0,1,224,128Z"/></svg>',ie='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" aria-hidden="true" focusable="false"><path d="M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z"/></svg>',ce='<span class="clay-menu-track" aria-hidden="true"><span class="clay-menu-thumb"></span></span>',ue=6e3;function de(){let u=document.querySelectorAll("[clay-menu-slot]");return u.length>1&&console.warn("[clay] This page has more than one clay-menu-slot. The menu uses the first."),u[0]||null}function fe(){let u=document.querySelector("style[clay-menu-skin]");return u?u.getAttribute("clay-menu-skin")!==j?(console.warn(`[clay] This runtime reads clay-menu-skin="${j}". The menu keeps its default look.`),null):u.textContent:null}function ve({capsuleStart:u="",sections:v=[null]}={}){let N=new Set(v.flat().filter(Boolean)),b=de(),m=!!b,w=m?fe():null,a=document.createElement("div");a.className="clay-menu-dock",a.setAttribute("clay","editor-ui"),a.setAttribute("part","dock"),m&&(a.dataset.embedded=""),a.dataset.corner="top-right",a.innerHTML='<div class="clay-menu" part="capsule" clay="editor-ui">'+u+`<button type="button" class="clay-menu-goo" part="button" aria-haspopup="menu" aria-expanded="false" aria-label="Clay menu">${V}</button></div><div class="clay-menu-list" part="list" role="menu" aria-label="Clay menu" hidden></div><div class="clay-menu-note" part="note" role="status" hidden></div>`;let l=a.querySelector(".clay-menu-goo"),s=a.querySelector(".clay-menu-list"),A=a.querySelector(".clay-menu-note"),f=new Map,H=[];if(m){let e=b.querySelector("template[clay-menu-icon]");e&&l.replaceChildren(e.content.cloneNode(!0));let n=b.getAttribute("clay-menu-label");n&&(l.setAttribute("aria-label",n),l.title=n,s.setAttribute("aria-label",n))}let q=m&&typeof s.showPopover=="function";q&&s.setAttribute("popover","manual");function $(){let e=l.getBoundingClientRect(),{offsetWidth:n,offsetHeight:t}=s,o=Math.max(k,Math.min(e.right-n,window.innerWidth-n-k)),r=e.bottom+k,i=r+t>window.innerHeight-k?Math.max(k,e.top-t-k):r;s.style.left=`${Math.round(o)}px`,s.style.top=`${Math.round(i)}px`}let T=()=>a.getRootNode().activeElement||null,y=()=>!s.hidden;function P(e){s.hidden=!e,l.setAttribute("aria-expanded",e?"true":"false"),q&&(e?(s.showPopover(),$()):s.matches(":popover-open")&&s.hidePopover())}let B=()=>[...s.querySelectorAll('[role^="menuitem"]:not([aria-disabled="true"])')];function S(e){let n=B();n.length&&n[(e+n.length)%n.length].focus()}function Q(){y()&&P(!1)}function O(){if(!y()){for(let e of H)e();C(),P(!0)}}function R(e){let n=e.href&&!e.disabled,t=document.createElement(n?"a":"button");if(n?(t.href=e.href,t.target="_blank",t.rel="noopener"):t.type="button",t.setAttribute("role","menuitem"),t.setAttribute("part",e.quiet?"item quiet":"item"),t.dataset.menuId=e.id,e.badge&&e.id==="upgrade"){let o=document.createElement("span");o.className="clay-menu-upgrade",o.textContent=e.label,t.append(o)}else t.textContent=e.label;if(e.keys){let o=document.createElement("kbd");o.textContent=e.keys,t.append(o)}return e.toggle&&(t.setAttribute("role","menuitemcheckbox"),t.setAttribute("aria-checked",e.checked?"true":"false"),t.classList.add("clay-menu-toggle"),t.insertAdjacentHTML("beforeend",ce)),e.disabled&&t.setAttribute("aria-disabled","true"),t.addEventListener("click",()=>{e.disabled||(!e.toggle&&!e.keepOpen&&Q(),e.run&&e.run({anchor:l}))}),t}function X(e){if(e.text){let n=document.createElement("p");return n.className="clay-menu-version",n.setAttribute("part","text"),n.dataset.menuId=e.id,n.textContent=e.label,n}if(e.pair){let n=document.createElement("div");n.className="clay-menu-pair",n.dataset.menuId=e.id;for(let t of e.pair)n.append(R(t));return n}return e.stepper?F(e):e.dismiss?Y(e):R(e)}function Y(e){let n=document.createElement("div");n.className="clay-menu-row",n.dataset.menuId=e.id;let t=document.createElement("button");return t.type="button",t.setAttribute("role","menuitem"),t.setAttribute("part","dismiss"),t.dataset.menuId=`${e.id}.dismiss`,t.setAttribute("aria-label",e.dismiss.label),t.title=e.dismiss.label,t.innerHTML=se,t.addEventListener("click",async()=>{t.disabled=!0;let o;try{o=await e.dismiss.run?.()}catch(r){console.warn("[clay] A menu item could not be removed.",r),t.disabled=!1,W("That didn't work. Try again.");return}if(o===!1){t.disabled=!1;return}Z(e.id)}),n.append(R(e),t),n}function F(e){let{label:n,value:t,prevLabel:o,nextLabel:r}=e.stepper,i=document.createElement("div");i.className="clay-menu-stepper",i.setAttribute("part","stepper"),i.dataset.menuId=e.id;let c=document.createElement("span");c.className="clay-menu-stepper-label",c.textContent=n;let h=document.createElement("span");h.className="clay-menu-stepper-value",h.setAttribute("aria-live","polite"),h.textContent=t;let L=(x,D,E)=>{let p=document.createElement("button");return p.type="button",p.setAttribute("role","menuitem"),p.setAttribute("part","step"),p.setAttribute("aria-label",E),p.dataset.menuId=`${e.id}.${x}`,p.innerHTML=D,p.addEventListener("click",()=>f.get(e.id)?.stepper?.[x]?.()),p};return i.append(c,L("prev",le,o),h,L("next",ie,r)),i}function J(){let e=o=>[...f.values()].filter(r=>r.section===o),n=[...f.keys()].filter(o=>!N.has(o)&&!f.get(o).section),t=v.map(o=>(o||n).map(r=>f.get(r)).filter(Boolean));return[e("start"),...t,e("end")].filter(o=>o.length)}function C(){let e=T(),n=e&&s.contains(e)?e.dataset.menuId:null;s.textContent="",J().forEach((r,i)=>{if(i){let c=document.createElement("div");c.className="clay-menu-sep",c.setAttribute("role","separator"),c.setAttribute("part","separator"),s.append(c)}for(let c of r)s.append(X(c))});let t=l.querySelector(".clay-menu-dot"),o=[...f.values()].some(r=>r.badge);if(o&&!t){let r=document.createElement("span");r.className="clay-menu-dot",r.setAttribute("aria-hidden","true"),l.append(r)}else!o&&t&&t.remove();if(n){let r=B().find(i=>i.dataset.menuId===n);r?r.focus():S(0)}}let _=({id:e,label:n,run:t,badge:o,keys:r,disabled:i,href:c,keepOpen:h})=>({id:e,href:typeof c=="string"?c:"",label:String(n??""),run:typeof t=="function"?t:null,badge:!!o,keys:r?String(r):"",disabled:!!i,keepOpen:!!h});function ee({id:e,label:n,run:t,badge:o,keys:r,disabled:i,text:c,pair:h,href:L,section:x,quiet:D,dismiss:E,toggle:p,checked:ne,keepOpen:ae,stepper:g}={}){if(!e)return null;let d=_({id:e,label:n,run:t,badge:o,keys:r,disabled:i,href:L,keepOpen:ae});if((x==="start"||x==="end")&&(d.section=x),D&&(d.quiet=!0),g){d.stepper={label:String(g.label??""),value:String(g.value??""),prev:typeof g.prev=="function"?g.prev:null,next:typeof g.next=="function"?g.next:null,prevLabel:String(g.prevLabel||"Previous"),nextLabel:String(g.nextLabel||"Next")};let z=[...s.querySelectorAll(".clay-menu-stepper")].find(M=>M.dataset.menuId===e)?.querySelector(".clay-menu-stepper-value"),I=f.get(e);if(I?.stepper&&["label","prevLabel","nextLabel"].every(M=>I.stepper[M]===d.stepper[M])&&I.section===d.section&&I.quiet===d.quiet&&z)return f.set(e,d),z.textContent=d.stepper.value,e}return c&&(d.text=!0),Array.isArray(h)&&(d.pair=h.map(_)),p&&(d.toggle=!0,d.checked=!!ne),E&&(d.dismiss={label:String(E.label||"Dismiss"),run:typeof E.run=="function"?E.run:null}),f.set(e,d),C(),e}function Z(e){f.delete(e)&&C()}function W(e){e&&(A.textContent=e,A.hidden=!1,clearTimeout(G),G=setTimeout(()=>{A.hidden=!0,A.textContent=""},ue))}let G=0;l.addEventListener("click",()=>{y()?Q():O()}),document.addEventListener("click",e=>{y()&&!e.composedPath().includes(a)&&Q()}),a.addEventListener("keydown",e=>{if(e.key==="Escape"){if(!y())return;e.preventDefault(),Q(),l.focus();return}if(e.target===l&&(e.key==="Enter"||e.key===" ")){e.preventDefault(),y()?Q():(O(),S(0));return}if(!y())return;if(e.key==="Enter"&&s.contains(e.target)){e.preventDefault(),e.target.click();return}let n=B();if(!n.length)return;let t=n.indexOf(T());e.key==="ArrowDown"?(e.preventDefault(),S(t<0?0:t+1)):e.key==="ArrowUp"&&(e.preventDefault(),S(t<0?n.length-1:t-1))});function te(e){let n=K({name:"menu",content:a,css:e,parent:b||document.body,attributes:{"clay-mode-toggle":""}});return m&&(window.addEventListener("resize",Q),window.addEventListener("scroll",()=>{q&&y()&&$()},{capture:!0,passive:!0})),n}return{root:a,goo:l,list:s,slot:b,embedded:m,skin:w,items:f,addItem:ee,removeItem:Z,render:C,open:O,close:Q,isOpen:y,note:W,beforeOpen:H,focusedEl:T,mount:te}}export{pe as a,ce as b,ve as c};
@@ -1 +1 @@
1
- import{a as d}from"./c-CSNE5EIF.js";import"./c-PZ4XEPUP.js";import"./c-SFKI6OLM.js";import"./c-Q3XOWZEV.js";import{g as m,l as v,n as x,q as s}from"./c-IHUWUKIU.js";import{a as p}from"./c-4JZDZFF6.js";import{e as f}from"./c-EUGJVHDD.js";import{b as w}from"./c-MHI3GYKF.js";import"./c-RHMPKZZ7.js";import{b as c}from"./c-NUHP2XDB.js";import{f as l}from"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-EGTIAL6P.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var $="Download a copy, then reduce its size; saving still works.",b="Download a copy to keep your work.",t=null,r=null,i=null,a=null;function h(e){return typeof e!="number"||!Number.isFinite(e)||e<0?"an unknown size":e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.max(1,Math.round(e/1024))} KB`:`${e} bytes`}function y({bytes:e,maxBytes:n,state:S}){let u=`At the last save attempt: ${h(e)} of ${h(n)}.`;return S==="over"?`This host can't save a file this size. ${u} ${b}`:`This file is getting large. ${u} ${$}`}function o(){if(!t)return;let e=window.visualViewport,n=e?Math.max(0,window.innerHeight-e.height-e.offsetTop):0;c(t,"bottom",`calc(${16+n}px + env(safe-area-inset-bottom,0px))`)}async function z(){await d({})}function A(){t=v("div",["position:fixed","left:50%","transform:translateX(-50%)","z-index:2147483000","display:flex","align-items:center","gap:10px 12px","width:max-content","max-width:calc(100vw - 24px)","flex-wrap:wrap","padding:8px 8px 8px 14px","text-align:left",`color-scheme:${p()}`]),t.setAttribute("clay","editor-ui"),t.setAttribute("data-clay-save-size",""),t.setAttribute("role","status"),r=x("span",[],""),i=m("Download my copy",{small:!0,onClick:z}),s(i,!1,"inline-flex"),t.append(r,i),document.body.appendChild(t),o(),window.visualViewport?.addEventListener("resize",o),window.visualViewport?.addEventListener("scroll",o)}function M(e){t||A(),r.textContent=y(e),s(i,e.state==="over","inline-flex"),o(),w(t,{background:f.surface})}function E(){t&&(window.visualViewport?.removeEventListener("resize",o),window.visualViewport?.removeEventListener("scroll",o),t.remove(),t=null,r=null,i=null)}function g(e){let n=e?.detail;n&&(n.state==="near"||n.state==="over"?M(n):E())}function k(){l||L()}function N(e){l&&(a||=new AbortController,document.addEventListener("clay:save-size",g,{signal:a.signal}),document.addEventListener("clay:modechange",k,{signal:a.signal}),e?.type==="clay:save-size"&&g(e))}function L(){a?.abort(),a=null,E()}export{N as start,L as stop};
1
+ import{a as d}from"./c-4PO3YGDC.js";import"./c-PZ4XEPUP.js";import"./c-SFKI6OLM.js";import"./c-Q3XOWZEV.js";import{g as m,l as v,n as x,q as s}from"./c-IHUWUKIU.js";import{a as p}from"./c-4JZDZFF6.js";import{e as f}from"./c-EUGJVHDD.js";import{b as w}from"./c-PKCCHJ5X.js";import"./c-RHMPKZZ7.js";import{b as c}from"./c-NUHP2XDB.js";import{f as l}from"./c-3O7OBDCM.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-PWJSJEJU.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var $="Download a copy, then reduce its size; saving still works.",b="Download a copy to keep your work.",t=null,r=null,i=null,a=null;function h(e){return typeof e!="number"||!Number.isFinite(e)||e<0?"an unknown size":e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.max(1,Math.round(e/1024))} KB`:`${e} bytes`}function y({bytes:e,maxBytes:n,state:S}){let u=`At the last save attempt: ${h(e)} of ${h(n)}.`;return S==="over"?`This host can't save a file this size. ${u} ${b}`:`This file is getting large. ${u} ${$}`}function o(){if(!t)return;let e=window.visualViewport,n=e?Math.max(0,window.innerHeight-e.height-e.offsetTop):0;c(t,"bottom",`calc(${16+n}px + env(safe-area-inset-bottom,0px))`)}async function z(){await d({})}function A(){t=v("div",["position:fixed","left:50%","transform:translateX(-50%)","z-index:2147483000","display:flex","align-items:center","gap:10px 12px","width:max-content","max-width:calc(100vw - 24px)","flex-wrap:wrap","padding:8px 8px 8px 14px","text-align:left",`color-scheme:${p()}`]),t.setAttribute("clay","editor-ui"),t.setAttribute("data-clay-save-size",""),t.setAttribute("role","status"),r=x("span",[],""),i=m("Download my copy",{small:!0,onClick:z}),s(i,!1,"inline-flex"),t.append(r,i),document.body.appendChild(t),o(),window.visualViewport?.addEventListener("resize",o),window.visualViewport?.addEventListener("scroll",o)}function M(e){t||A(),r.textContent=y(e),s(i,e.state==="over","inline-flex"),o(),w(t,{background:f.surface})}function E(){t&&(window.visualViewport?.removeEventListener("resize",o),window.visualViewport?.removeEventListener("scroll",o),t.remove(),t=null,r=null,i=null)}function g(e){let n=e?.detail;n&&(n.state==="near"||n.state==="over"?M(n):E())}function k(){l||L()}function N(e){l&&(a||=new AbortController,document.addEventListener("clay:save-size",g,{signal:a.signal}),document.addEventListener("clay:modechange",k,{signal:a.signal}),e?.type==="clay:save-size"&&g(e))}function L(){a?.abort(),a=null,E()}export{N as start,L as stop};
@@ -1,6 +1,6 @@
1
- import{c as E}from"./c-KBS3UV6B.js";import{i as x,j as I}from"./c-4RFZROCF.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-4TWARTLS.js";import"./c-Q5KAQJAG.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as C}from"./c-TMT5TL65.js";import{G as b,J as A,m as f}from"./c-QIXT3Q7C.js";import"./c-OI2BYWVV.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-LIGQYZ7M.js";import"./c-EXKHPOVC.js";import"./c-L5VFATT6.js";import"./c-6RDOKLN7.js";import"./c-DTMZ3ZHI.js";import"./c-W4JCVLAB.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{B as C}from"./c-HCNWJE4A.js";import{G as b,J as A,m as f}from"./c-QIXT3Q7C.js";import"./c-LCYPMULG.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-NBNRLZXO.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-2AYVYEI4.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
- var o=null,n=()=>o??=import("./c-MRURHLKV.js"),s=t=>(...i)=>{n().then(e=>(t?e[t]:e.default)(...i))},l=s(null),r=s("toastPersistent"),a=(...t)=>{o&&s("dismissPersistent")(...t)};export{l as a,r as b,a as c};
1
+ var o=null,n=()=>o??=import("./c-QUGCKMWF.js"),s=t=>(...i)=>{n().then(e=>(t?e[t]:e.default)(...i))},l=s(null),r=s("toastPersistent"),a=(...t)=>{o&&s("dismissPersistent")(...t)};export{l as a,r as b,a as c};