@grapesjs/studio-sdk-plugins 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const rr="app.grapesjs.com",oo="app-stage.grapesjs.com",Or=[rr,oo,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],ga="license:check:start",ya="license:check:end",lo=()=>typeof window<"u",ba=({isDev:n,isStage:e})=>`${n?"":`https://${e?oo:rr}`}/api`,xa=()=>{const n=lo()&&window.location.hostname;return!!n&&(Or.includes(n)||Or.some(e=>n.endsWith(e)))},Ca=()=>(lo()&&window.location.hostname)===rr;function ao(n){return typeof n=="function"}var wa={};const Sa=wa.NODE_ENV!=="production";async function ka({path:n,method:e="GET",headers:t={},body:i}){const s=`${ba({isDev:Sa,isStage:!Ca()})}${n}`,o={method:e,headers:{"Content-Type":"application/json",...t}};i&&(o.body=JSON.stringify(i));const l=await fetch(s,o);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return l.json()}function va(n){const e=n;return e.init=t=>i=>n(i,t),e}const Pt=n=>va(n);async function zt({editor:n,pluginName:e,licenseKey:t,cleanup:i}){let r=!1;const s=xa();n.on(ga,()=>{r=!0}),n.on(ya,({sdkLicense:o})=>{o||i()}),setTimeout(async()=>{if(!r){if(s)return;t&&await Ma({licenseKey:t,pluginName:e})||i()}},2e3)}async function Ma({licenseKey:n,pluginName:e}){try{const t=await ka({path:`/sdk/${n}`,method:"POST",body:JSON.stringify({d:window.location.hostname,pn:e})}),{license:i}=t.result||{};return!!i}catch(t){return console.error("Error during SDK license check:",t),!1}}const si=(n,e)=>{var t;return!!((t=n==null?void 0:n.hasAttribute)!=null&&t.call(n,e))},Ei="gjs-plg-",Ar=(...n)=>n.map(e=>`[data-gjs-type="${e}"]`).join(","),Ta="dialogComponent",Oa=function(n,e={}){const{Blocks:t,Components:i}=n,{licenseKey:r}=e,s="gjs-plg-dialog",o="gjs-plg-dialog-overlay",l="gjs-plg-dialog-content",a="gjs-plg-dialog-close",c="gjs-plg-dialog-title",h="gjs-plg-dialog-body",d="gjs-plg-dialog-description",f="gjs-plg-dialog-placeholder";t.add(s,{label:"Dialog",media:`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const lo="app.grapesjs.com",ao="app-stage.grapesjs.com",Or=[lo,ao,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],ya="license:check:start",ba="license:check:end",xa=()=>typeof window<"u",Ca=({isDev:n,isStage:e})=>`${n?"":`https://${e?ao:lo}`}/api`,wa=()=>{const n=xa()&&window.location.hostname;return!!n&&(Or.includes(n)||Or.some(e=>n.endsWith(e)))};function co(n){return typeof n=="function"}var pe=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(pe||{});async function Sa({path:n,baseApiUrl:e,method:t="GET",headers:i={},params:r,body:s}){const l=`${e||Ca({isDev:!1,isStage:!1})}${n}`,a={method:t,headers:{"Content-Type":"application/json",...i}};s&&(a.body=JSON.stringify(s));const c=r?new URLSearchParams(r).toString():"",h=c?`?${c}`:"",d=await fetch(`${l}${h}`,a);if(!d.ok)throw new Error(`HTTP error! status: ${d.status}`);return d.json()}const Ar={[pe.free]:0,[pe.startup]:10,[pe.business]:20,[pe.enterprise]:30};function ka(n){const e=n;return e.init=t=>i=>n(i,t),e}const zt=n=>ka(n);async function Bt({editor:n,plan:e,pluginName:t,licenseKey:i,cleanup:r}){let s="",o=!1;const l=wa(),a=h=>{console.warn("Cleanup plugin:",t,"Reason:",h),r()},c=(h={})=>{var m;const{error:d,sdkLicense:f}=h,p=(m=h.plan)==null?void 0:m.category;if(!(f||h.license)||d)a(d||"Invalid license");else if(p){const g=Ar[e],y=Ar[p];g>y&&a({pluginRequiredPlan:e,licensePlan:p})}};n.on(ya,h=>{s=h==null?void 0:h.baseApiUrl,o=!0}),n.on(ba,h=>{c(h)}),setTimeout(async()=>{if(!o){if(l)return;if(i){const h=await va({licenseKey:i,pluginName:t,baseApiUrl:s});h&&c(h)}else a("The `licenseKey` option not provided")}},2e3)}async function va(n){const{licenseKey:e,pluginName:t,baseApiUrl:i}=n;try{return(await Sa({baseApiUrl:i,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(r){return console.error("Error during SDK license check:",r),!1}}const oi=(n,e)=>{var t;return!!((t=n==null?void 0:n.hasAttribute)!=null&&t.call(n,e))},Di="gjs-plg-",Nr=(...n)=>n.map(e=>`[data-gjs-type="${e}"]`).join(","),Ma="dialogComponent",Ta=function(n,e={}){const{Blocks:t,Components:i}=n,{licenseKey:r}=e,s="gjs-plg-dialog",o="gjs-plg-dialog-overlay",l="gjs-plg-dialog-content",a="gjs-plg-dialog-close",c="gjs-plg-dialog-title",h="gjs-plg-dialog-body",d="gjs-plg-dialog-description",f="gjs-plg-dialog-placeholder";t.add(s,{label:"Dialog",media:`
2
2
  <svg viewBox="0 0 24 24">
3
3
  <path d="M4 4h16v10H8l-4 4V4z"></path>
4
4
  </svg>
5
- `,category:"Extra",content:{type:s},activate:!0,...e.block}),i.addType(s,{model:{defaults:{tagName:"div",attributes:{class:s,"data-type-role":s},components:[{type:o},{type:f}],draggable:Ar("wrapper"),droppable:Ar(s),styles:`
5
+ `,category:"Extra",content:{type:s},activate:!0,...e.block}),i.addType(s,{model:{defaults:{tagName:"div",attributes:{class:s,"data-type-role":s},components:[{type:o},{type:f}],draggable:Nr("wrapper"),droppable:Nr(s),styles:`
6
6
  .${s} {
7
7
  position: relative;
8
8
  z-index: 1;
@@ -56,28 +56,28 @@
56
56
  .${d} {
57
57
  margin: 0;
58
58
  }
59
- `}}}),i.addType(f,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:f,"data-type-role":f},components:"Dialog (click me to open)",droppable:!1,draggable:!1}},view:{init(){this.listenTo(this.em,"run:core:preview",()=>{this.el.style.display="none"}),this.listenTo(this.em,"stop:core:preview",()=>{this.el.style.display=""})}}}),zt({editor:n,licenseKey:r,pluginName:Ta,cleanup:()=>{t.remove(s),i.removeType(s)}})},Aa=Pt(Oa);function co(n,e,t){let i,r,s,o,l;const a=e;function c(){const d=Date.now()-o;d<a&&d>=0?i=setTimeout(c,a-d):(i=null,l=n.apply(s,r),s=r=null)}const h=function(){return s=this,r=arguments,o=Date.now(),i||(i=setTimeout(c,a)),l};return h.clear=function(){i&&(clearTimeout(i),i=null)},h.flush=function(){i&&(l=n.apply(s,r),s=r=null,clearTimeout(i),i=null)},h}var Xt=(n=>(n.toastAdd="studio:toastAdd",n.dialogOpen="studio:dialogOpen",n.dialogClose="studio:dialogClose",n.sidebarLeftSet="studio:sidebarLeft:set",n.sidebarLeftGet="studio:sidebarLeft:get",n.sidebarLeftToggle="studio:sidebarLeft:toggle",n.sidebarRightSet="studio:sidebarRight:set",n.sidebarRightGet="studio:sidebarRight:get",n.sidebarRightToggle="studio:sidebarRight:toggle",n.sidebarTopSet="studio:sidebarTop:set",n.sidebarTopGet="studio:sidebarTop:get",n.sidebarTopToggle="studio:sidebarTop:toggle",n.sidebarBottomSet="studio:sidebarBottom:set",n.sidebarBottomGet="studio:sidebarBottom:get",n.sidebarBottomToggle="studio:sidebarBottom:toggle",n.symbolAdd="studio:symbolAdd",n.symbolDetach="studio:symbolDetach",n.symbolOverride="studio:symbolOverride",n.symbolPropagateStyles="studio:propagateStyles",n.getPagesConfig="studio:getPagesConfig",n.setPagesConfig="studio:setPagesConfig",n.getPageSettings="studio:getPageSettings",n.setPageSettings="studio:setPageSettings",n.projectFiles="studio:projectFiles",n.canvasReload="studio:canvasReload",n.getBlocksPanel="studio:getBlocksPanel",n.setBlocksPanel="studio:setBlocksPanel",n.contextMenuComponent="studio:contextMenuComponent",n.layoutAdd="studio:layoutAdd",n.layoutRemove="studio:layoutRemove",n.layoutToggle="studio:layoutToggle",n))(Xt||{}),v=(n=>(n.table="table",n.tableSettings="tableSettings",n.tableDelete="tableDelete",n.tableHead="tableHead",n.tableFoot="tableFoot",n.tableCellItems="tableCellItems",n.tableCellProperties="tableCellProperties",n.tableCellMerge="tableCellMerge",n.tableCellSplit="tableCellSplit",n.tableRowItems="tableRowItems",n.tableRowInsertBefore="tableRowInsertBefore",n.tableRowInsertAfter="tableRowInsertAfter",n.tableRowDelete="tableRowDelete",n.tableRowProperties="tableRowProperties",n.tableRowCut="tableRowCut",n.tableRowCopy="tableRowCopy",n.tableRowPasteBefore="tableRowPasteBefore",n.tableRowPasteAfter="tableRowPasteAfter",n.tableColumn="tableColumn",n.tableColumnItems="tableColumnItems",n.tableColumnInsertBefore="tableColumnInsertBefore",n.tableColumnInsertAfter="tableColumnInsertAfter",n.tableColumnDelete="tableColumnDelete",n.tableColumnCut="tableColumnCut",n.tableColumnCopy="tableColumnCopy",n.tableColumnPasteBefore="tableColumnPasteBefore",n.tableColumnPasteAfter="tableColumnPasteAfter",n))(v||{});const D={table:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableSettings:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 6v12h14V6H5z"/><path d="m14.4 8.6 1 1-2.3 2.4 2.3 2.4-1 1-2.4-2.3-2.4 2.3-1-1 2.3-2.4-2.3-2.4 1-1 2.4 2.3z"/></svg>',tableHead:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableFoot:'<svg viewBox="0 0 24 24" data-test="1" style="transform: rotate(180deg);"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableColumn:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm0 9h-4v5h4v-5Zm-6 0H9v5h4v-5Zm0-7H9v5h4V6Zm6 0h-4v5h4V6Z"/></svg>',tableCellItems:"",tableCellProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zm-8 9H5v5h6v-5zm8 0h-6v5h6v-5zm-8-7H5v5h6V6z"/></svg>',tableCellMerge:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zM5 16v2h3v-2H5zm14-5h-9v7h9v-7zm0-5h-4v3h4V6zM8 6H5v3h3V6zm5 0h-3v3h3V6zm-8 8h3v-3H5v3z"/></svg>',tableCellSplit:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM8 15.5H5V18h3v-2.5zm11-5h-9V18h9v-7.5zm-2.5 1 1 1-2 2 2 2-1 1-2-2-2 2-1-1 2-2-2-2 1-1 2 2 2-2zm-8.5-1H5v3h3v-3zM19 6h-4v2.5h4V6zM8 6H5v2.5h3V6zm5 0h-3v2.5h3V6z"/></svg>',tableRowItems:"",tableRowInsertBefore:'<svg viewBox="0 0 24 24"><path d="M6 4a1 1 0 1 1 0 2H5v6h14V6h-1a1 1 0 0 1 0-2h2c.6 0 1 .4 1 1v13a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5c0-.6.4-1 1-1h2zm5 10H5v4h6v-4zm8 0h-6v4h6v-4zM12 3c.5 0 1 .4 1 .9V6h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 .1V8H9a1 1 0 0 1 0-2h2V4c0-.6.4-1 1-1z"/></svg>',tableRowInsertAfter:'<svg viewBox="0 0 24 24"><path d="M12 13c.5 0 1 .4 1 .9V16h2a1 1 0 0 1 .1 2H13v2a1 1 0 0 1-2 .1V18H9a1 1 0 0 1-.1-2H11v-2c0-.6.4-1 1-1zm6 7a1 1 0 0 1 0-2h1v-6H5v6h1a1 1 0 0 1 0 2H4a1 1 0 0 1-1-1V6c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v13c0 .5-.4 1-.9 1H18zM11 6H5v4h6V6zm8 0h-6v4h6V6z"/></svg>',tableRowDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm0 2H5v3h2.5v2H5v2h2.5v2H5v3h14v-3h-2.5v-2H19v-2h-2.5V9H19V6zm-4.7 1.8 1.2 1L13 12l2.6 3.3-1.2 1-2.3-3-2.3 3-1.2-1L11 12 8.5 8.7l1.2-1 2.3 3 2.3-3z"/></svg>',tableRowProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 15v3h6v-3H5zm14 0h-6v3h6v-3zm0-9h-6v3h6V6zM5 9h6V6H5v3z"/></svg>',tableRowCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M22 3v5H9l3 3 2-2h4l-4 4 1 1h.5c.4 0 .8 0 1.2.3.5.2.9.4 1.2.8.7.6 1 1.3 1 2.2.2.8 0 1.5-.6 2l-.8.5-1 .2c-.4 0-.8 0-1.2-.3a3.9 3.9 0 0 1-2.1-2.2c-.2-.5-.3-1-.2-1.5l-1-1-1 1c0 .5 0 1-.2 1.5-.1.5-.4 1-.9 1.4-.3.4-.7.6-1.2.8l-1.2.3c-.4 0-.7 0-1-.2-.3 0-.6-.3-.8-.5-.5-.5-.8-1.2-.7-2a3 3 0 0 1 1-2.2A3.7 3.7 0 0 1 8.6 14H9l1-1-4-4-.5-1a3.3 3.3 0 0 1 0-2c0-.4.3-.7.5-1l2 2V3h14zM8.5 15.3h-.3a2.6 2.6 0 0 0-.8.4 2.5 2.5 0 0 0-.9 1.1l-.1.4v.7l.2.5.5.2h.7a2.5 2.5 0 0 0 .8-.3L9 18l.4-.4.2-.4.1-.4v-.7a1 1 0 0 0-.2-.5 1 1 0 0 0-.4-.2h-.5zm7 0H15a1 1 0 0 0-.4.3 1 1 0 0 0-.2.5 1.5 1.5 0 0 0 0 .7v.4a2.8 2.8 0 0 0 .5.7h.1a2.8 2.8 0 0 0 .8.6l.4.1h.7l.5-.2.2-.5v-.7a2.6 2.6 0 0 0-.3-.8 2.4 2.4 0 0 0-.7-.7 2.5 2.5 0 0 0-.8-.3h-.3zM12 11.6c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zm8.5-7.1h-11v2h11v-2z"/></svg>',tableRowCopy:'<svg viewBox="0 0 24 24"><path d="M22 11v7H6v-7h16zm-2 2H8v3h12v-3zm-1-6v2H4v5H2V7h17z"/></svg>',tableRowPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h12v-4h2v4c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 7v5H8V8h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableRowPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V11h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h14c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 11v5H8v-5h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnItems:"",tableColumnInsertBefore:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a1 1 0 0 1-1-1v-2a1 1 0 0 1 2 0v1h8V6H5v1a1 1 0 1 1-2 0V5c0-.6.4-1 1-1h15zm0 9h-4v5h4v-5zM8 8c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H9v2a1 1 0 0 1-2 .1V13H5a1 1 0 0 1-.1-2H7V9c0-.6.4-1 1-1zm11-2h-4v5h4V6z"/></svg>',tableColumnInsertAfter:'<svg viewBox="0 0 24 24"><path d="M20 4c.6 0 1 .4 1 1v2a1 1 0 0 1-2 0V6h-8v12h8v-1a1 1 0 0 1 2 0v2c0 .5-.4 1-.9 1H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h15zM9 13H5v5h4v-5zm7-5c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H17v2a1 1 0 0 1-2 .1V13h-2a1 1 0 0 1-.1-2H15V9c0-.6.4-1 1-1zM9 6H5v5h4V6z"/></svg>',tableColumnDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm-4 4h-2V6h-2v2H9V6H5v12h4v-2h2v2h2v-2h2v2h4V6h-4v2zm.3.5 1 1.2-3 2.3 3 2.3-1 1.2L12 13l-3.3 2.6-1-1.2 3-2.3-3-2.3 1-1.2L12 11l3.3-2.5z"/></svg>',tableColumnCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M7.2 4.5a3 3 0 0 1 2.2 1A3.7 3.7 0 0 1 10.5 8v.5l1 1 4-4 1-.5a3.3 3.3 0 0 1 2 0c.4 0 .7.3 1 .5L17 8h4v13h-6V10l-1.5 1.5.5.5v4l-2.5-2.5-1 1v.5c0 .4 0 .8-.3 1.2-.2.5-.4.9-.8 1.2-.6.7-1.3 1-2.2 1-.8.2-1.5 0-2-.6l-.5-.8-.2-1c0-.4 0-.8.3-1.2A3.9 3.9 0 0 1 7 12.7c.5-.2 1-.3 1.5-.2l1-1-1-1c-.5 0-1 0-1.5-.2-.5-.1-1-.4-1.4-.9-.4-.3-.6-.7-.8-1.2L4.5 7c0-.4 0-.7.2-1 0-.3.3-.6.5-.8.5-.5 1.2-.8 2-.7zm12.3 5h-3v10h3v-10zM8 13.8h-.3l-.4.2a2.8 2.8 0 0 0-.7.4v.1a2.8 2.8 0 0 0-.6.8l-.1.4v.7l.2.5.5.2h.7a2.6 2.6 0 0 0 .8-.3 2.4 2.4 0 0 0 .7-.7 2.5 2.5 0 0 0 .3-.8 1.5 1.5 0 0 0 0-.8 1 1 0 0 0-.2-.4 1 1 0 0 0-.5-.2H8zm3.5-3.7c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zM7 5.8h-.4a1 1 0 0 0-.5.3 1 1 0 0 0-.2.5v.7a2.5 2.5 0 0 0 .3.8l.2.3h.1l.4.4.4.2.4.1h.7L9 9l.2-.4a1.6 1.6 0 0 0 0-.8 2.6 2.6 0 0 0-.3-.8 2.5 2.5 0 0 0-1.2-1l-.4-.1H7z"/></svg>',tableColumnCopy:'<svg viewBox="0 0 24 24"><path d="M17 6v16h-7V6h7zm-2 2h-3v12h3V8zm-2-6v2H8v15H6V2h7z"/></svg>',tableColumnPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V18c0 1-.8 2-1.9 2H11v-2h7V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v2H4V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm-2 7v12H4V8h6zM8.5 9.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h7v2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm8 7v12h-6V8h6zm-1.5 1.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>'},ye="table",ho="thead",fo="tfoot",Di="tbody",ne="row",V="cell",sr="clipboardTable",Na=[ye,ho,fo,Di,ne,V],_n=n=>n.em.get(sr)||[],Ea=n=>n.every(e=>e.is(V)),or=(n,e)=>{const{editor:t,event:i,opts:r}=n,s=i.currentTarget||i.target,{x:o,y:l,width:a,height:c}=s.getBoundingClientRect(),h={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:o,y:l,w:a,h:c},layout:{type:"tabs",value:"props",tabs:[{id:"styles",label:"Styles",children:{type:"panelStyles"}},{id:"props",label:"Properties",children:{type:"panelProperties",style:{padding:"14px 7px"}}}]},...e};ao(r.openSettings)?r.openSettings({...n,layoutProps:h}):t.runCommand(Xt.layoutToggle,h)},Da=(n,{rows:e=1,cells:t=5,text:i}={})=>({type:n,components:Array.from(Array(e).keys()).map(r=>({type:ne,components:Array.from(Array(t).keys()).map(s=>({type:V,components:i?{type:"text",content:ao(i)?i({y:r,x:s}):i}:void 0}))}))}),uo="Table settings",po=n=>{const{component:e}=n;return e.is(ye)?e:e.closestType(ye)},Ia=n=>{var e;(e=po(n))==null||e.remove(n.opts)},Ra=n=>{const e=po(n);e&&(n.editor.select(e),or(n,{id:"tableSettings",header:{label:uo}}))},mo=n=>[{id:v.table,icon:D[v.table],label:"Table",items:[{id:v.tableSettings,label:uo,icon:D[v.tableSettings],onClick:({event:t})=>Ra({...n,event:t})},{id:v.tableDelete,label:"Delete table",icon:D[v.tableDelete],onClick:()=>Ia(n)}]}],go=({editor:n})=>{const e=_n(n);return e.length&&Ea(e)},Nr=({component:n,editor:e,after:t})=>{if(!n.is(V))return;const i=n.closestType(ye),r=n.closestType(ne),s=n.index()+(t?1:0);i==null||i.findType(ne).forEach(l=>l.append({type:V},{at:s}));const o=r==null?void 0:r.components().at(s);o&&e.select(o)},yo=({component:n,opts:e})=>{if(!n.is(V))return;const t=n.closestType(ye),i=n.index();t==null||t.findType(ne).forEach(r=>{var s;return(s=r.components().at(i))==null?void 0:s.remove(e)})},bo=({component:n,editor:e})=>{if(!n.is(V))return;const t=n.closestType(ye),i=n.index(),r=(t==null?void 0:t.findType(ne).map(s=>s.components().at(i)))||[];r.length&&e.em.set(sr,r)},Er=n=>{const{component:e,editor:t,after:i}=n;if(!e.is(V)||!go(n))return;const r=_n(t),s=e.closestType(ye),o=e.index()+(i?1:0);s==null||s.findType(ne).forEach((l,a)=>{const c=r[a],h=(c==null?void 0:c.clone())||{type:V};l.append(h,{at:o})})},Va=n=>{const{component:e}=n;e.is(V)&&(bo(n),yo({...n,opts:{temporary:!0}}))},Pa=n=>{const e=go(n);return[{id:v.tableColumnItems,icon:D[v.tableColumn],label:"Column",items:[{id:v.tableColumnInsertBefore,label:"Insert column before",icon:D[v.tableColumnInsertBefore],onClick:()=>Nr(n)},{id:v.tableColumnInsertAfter,label:"Insert column after",icon:D[v.tableColumnInsertAfter],onClick:()=>Nr({...n,after:!0})},{id:v.tableColumnDelete,label:"Delete column",icon:D[v.tableColumnDelete],onClick:()=>yo(n)},{id:v.tableColumnCut,label:"Cut column",icon:D[v.tableColumnCut],onClick:()=>Va(n)},{id:v.tableColumnCopy,label:"Copy column",icon:D[v.tableColumnCopy],onClick:()=>bo(n)},{id:v.tableColumnPasteBefore,label:"Paste column before",icon:D[v.tableColumnPasteBefore],disabled:!e,onClick:()=>Er(n)},{id:v.tableColumnPasteAfter,label:"Paste column after",icon:D[v.tableColumnPasteAfter],disabled:!e,onClick:()=>Er({...n,after:!0})}]}]},xo="Row settings",za=n=>n.every(e=>e.is(ne)),Bt=n=>{const{component:e}=n,t=e.is(V),i=e.is(ne);if(!(!t&&!i))return i?e:e.closestType(ne)},Dr=n=>{const{component:e,editor:t,after:i}=n,r=Bt(n);if(!r)return;const s=r.index()+(i?1:0),o=r.components().length,l=Array.from(Array(o).keys()).map(()=>({type:V})),a=r.parent();if(a){const c=a.append({type:ne,components:l},{at:s})[0];if(e.is(V)&&c){const h=e.index(),d=c.components().at(h);d&&t.select(d)}}},Co=n=>{var e;(e=Bt(n))==null||e.remove(n.opts)},wo=n=>{const e=Bt(n);e&&n.editor.em.set(sr,[e])},Ir=n=>{var l;const{editor:e,after:t}=n,i=Bt(n);if(!i||!So(n))return;const s=_n(e)[0],o=i.index()+(t?1:0);s&&((l=i.parent())==null||l.append(s.clone(),{at:o}))},Ba=n=>{Bt(n)&&(wo(n),Co({...n,opts:{temporary:!0}}))},So=({editor:n})=>{const e=_n(n);return e.length&&za(e)},La=n=>{const e=Bt(n);e&&(n.editor.select(e),or(n,{id:"tableRowSettings",header:{label:xo}}))},ko=n=>{const e=So(n);return[{id:v.tableRowItems,icon:D[v.tableRowProperties],label:"Row",items:[{id:v.tableRowInsertBefore,label:"Insert row before",icon:D[v.tableRowInsertBefore],onClick:()=>Dr(n)},{id:v.tableRowInsertAfter,label:"Insert row after",icon:D[v.tableRowInsertAfter],onClick:()=>Dr({...n,after:!0})},{id:v.tableRowDelete,label:"Delete row",icon:D[v.tableRowDelete],onClick:()=>Co(n)},{id:v.tableRowProperties,label:xo,icon:D[v.tableRowProperties],onClick:({event:i})=>La({...n,event:i})},{id:v.tableRowCut,label:"Cut row",icon:D[v.tableRowCut],onClick:()=>Ba(n)},{id:v.tableRowCopy,label:"Copy row",icon:D[v.tableRowCopy],onClick:()=>wo(n)},{id:v.tableRowPasteBefore,label:"Paste row before",icon:D[v.tableRowPasteBefore],disabled:!e,onClick:()=>Ir(n)},{id:v.tableRowPasteAfter,label:"Paste row after",icon:D[v.tableRowPasteAfter],disabled:!e,onClick:()=>Ir({...n,after:!0})}]},...mo(n)]},lr=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),i=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:i}};function vo(n){const e=[];return n.components().forEach((t,i)=>{t.components().each((r,s)=>{const{rowspan:o,colspan:l}=lr(r);if(e[i])for(;e[i][s];)s++;for(let a=i;a<i+o;a++){e[a]||(e[a]=[]);for(let c=s;c<s+l;c++)e[a][c]={real:a===i&&c===s,cell:r,rowspan:o,colspan:l}}})}),e}function St(n,e,t){var i;return(i=n[t])==null?void 0:i[e]}const Ii=n=>n.closestType(ne);function Ha(n,{x:e,y:t,rows:i,cols:r}){var l;let s=Ii(n[t][e].cell),o;for(let a=1;a<=i;a++)if(s=(l=s==null?void 0:s.parent())==null?void 0:l.components().at(s.index()+1),s){for(o=e;o>=0;o--){const{cell:c}=n[t+a][o],h=Ii(c);if(h===s){for(let d=1;d<=r;d++){const f=c.index();h.append({type:V},{at:f+1})}break}}if(o===-1){const h=s.components().at(0).index();for(let d=1;d<=r;d++)s.append({type:V},{at:h})}}}function Mo(n){for(let e=0;e<n.length;e++)for(let t=0;t<n[e].length;t++){const r=n[e][t].cell;if(r.em.selected.hasComponent(r)){const{rowspan:s,colspan:o}=lr(r);if(o>1||s>1){r.addAttributes({colspan:1,rowspan:1});for(let l=0;l<o-1;l++){const a=r.index();Ii(r).append({type:V},{at:a+1})}Ha(n,{x:t,y:e,rows:s-1,cols:o})}}}}function Fa(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const Gn=(n,e={})=>{var o;const t=vo(n),{em:i}=n;let r,s;for(let l=0;l<t.length;l++)for(let a=0;a<t[l].length;a++){const c=t[l][a];if((o=e.selected)!=null&&o.includes(c.cell)||i.selected.hasComponent(c.cell)){const h={x:a,y:l};r||(r=h),s=h}}return{grid:t,startPos:r,endPos:s}};function $a(n,e={}){const t=Gn(n),{startPos:i,endPos:r}=t;let{grid:s}=t;const{em:o}=n;if(!i||!r)return;const l=i.x,a=i.y,c=r.x,h=r.y,d=St(s,l,a),f=St(s,c,h);if(d&&f){Mo(s),s=vo(n);const p=[],u=St(s,l,a).cell;u.addAttributes({colspan:c-l+1,rowspan:h-a+1});for(let m=a;m<=h;m++)for(let g=l;g<=c;g++){const y=St(s,g,m);if(!y)continue;const{cell:S}=y;S!==u&&p.push(S)}p.forEach(m=>{e.mergeContent&&u.append(m.components().models),m.remove()}),o.setSelected(u),Fa(n)}}const To="Cell settings",Wa="Merge cells",Ja="Split cell",Ka=n=>n.closestType(ne),At=n=>{var e;return(e=Ka(n))==null?void 0:e.parent()},qa=n=>{const e=n.editor.getSelectedAll(),t=At(e[0]),i=e[0];if(!t||!(i!=null&&i.is(V))||e.length>1)return!1;const{rowspan:r,colspan:s}=lr(i);return!(s<2&&r<2)},ja=n=>{const t=n.editor.getSelectedAll()[0],i=At(t),{grid:r}=Gn(i);Mo(r)},Oo=n=>{const e=n.editor.getSelectedAll(),t=At(e[0]);if(!t||e.length<2||e.some(l=>!l.is(V)||At(l)!==t))return!1;const{grid:i,startPos:r,endPos:s}=Gn(t),{em:o}=t;if(!r||!s)return!1;for(let l=r.y;l<=s.y;l++)for(let a=r.x;a<=s.x;a++){const c=St(i,a,l);if(!c||!o.selected.hasComponent(c.cell))return!1}return!0},_a=n=>{const{editor:e}=n;if(!Oo(n))return;const t=e.getSelectedAll(),i=At(t[0]);$a(i,{mergeContent:!0})},Ga=n=>{or(n,{id:"tableCellSettings",header:{label:To}})},Ua=n=>[{id:v.tableCellItems,icon:D[v.tableCellProperties],label:"Cell",items:[{id:v.tableCellProperties,label:To,icon:D[v.tableCellProperties],onClick:({event:t})=>Ga({...n,event:t})},{id:v.tableCellMerge,label:Wa,icon:D[v.tableCellMerge],onClick:()=>_a(n),disabled:!Oo(n)},{id:v.tableCellSplit,label:Ja,icon:D[v.tableCellSplit],onClick:()=>ja(n),disabled:!qa(n)}]},...Pa(n),...ko(n)],Za=n=>{const e=n[0]&&At(n[0]);if(!e)return;const{grid:t,startPos:i,endPos:r}=Gn(e,{selected:n});if(!i||!r)return;const s=[];for(let o=i.y;o<=r.y;o++)for(let l=i.x;l<=r.x;l++){const a=St(t,l,o);a&&s.push(a.cell)}s.length&&e.em.setSelected(s,{fromCell:!0})},Xa="tableComponent",Ya=function(n,e={}){const t={block:{},...e},{Components:i}=n,r={copyable:!1,emptyState:!0,highlightable:!1,stylable:["color","font-family","font-size","font-weight","line-height","text-align","vertical-align","background-color","border-width","border-style","border-color"]};i.addType(ye,{block:t.block&&{label:"Table",media:D.table,category:"Extra",content:{type:ye,style:{width:"100%"}},select:!0,...t.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:D.table,stylable:["width","height","margin","font-family","font-size","font-weight","line-height","text-align","background","background-color","border-width","border-style","border-color"],traits:[{type:"number",min:0,name:"cellspacing",label:"Cell spacing"},{type:"number",min:0,name:"cellpadding",label:"Cell padding"},{id:"tableCaption",type:"checkbox",label:"Caption",setValue({component:o,value:l,emitUpdate:a}){const c=o.find("caption")[0];l?!c&&o.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):c==null||c.remove(),a(),n.refresh({tools:!0})},getValue(o){return!!o.component.find("caption")[0]}}],components:Da(Di,{rows:5}),contextMenu:({items:o,editor:l,component:a})=>[...mo({editor:l,component:a,opts:t}),...o]}}}),i.addType(ho,{model:{defaults:{icon:D.tableHead,...r}}}),i.addType(fo,{model:{defaults:{icon:D.tableFoot,...r}}}),i.addType(Di,{model:{defaults:{icon:D.tableRowProperties,...r}}}),i.addType(ne,{model:{defaults:{icon:D.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:o,editor:l,component:a})=>[...ko({editor:l,component:a,opts:t}),...o]}}}),i.addType(V,{model:{defaults:{icon:D.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","background-color","text-align","vertical-align","border-width","border-style","border-color"],traits:[{id:"tableCellType",type:"select",options:[{value:"td",name:"Cell"},{value:"th",name:"Header Cell"}],label:"Cell type",name:"tagName",changeProp:!0},{id:"tableCellScope",type:"select",options:[{value:!1,name:"None"},{value:"row",name:"Row"},{value:"col",name:"Column"},{value:"rowgroup",name:"Row group"},{value:"colgroup",name:"Column group"}],label:"Scope",name:"scope"}],contextMenu:({items:o,editor:l,component:a})=>[...Ua({editor:l,component:a,opts:t}),...o]}}});const s=co((o,l)=>{var d;const a=n.getSelectedAll(),c=!!((d=l==null?void 0:l.event)!=null&&d.shiftKey);if(a.length<2||!c||l.fromCell)return;const h=a.map(f=>f.is(V)?f:f.closestType(V)).filter(Boolean);h.length===a.length&&Za(h)},0);n.on("component:select",s),zt({editor:n,licenseKey:t.licenseKey,pluginName:Xa,cleanup:()=>{n.off("component:select",s),n.Blocks.remove(ye),Na.forEach(o=>i.removeType(o))}})},Qa=Pt(Ya),Rr="page://",Ge="list-pages",ut="list-pages-item",Ue="list-pages-link",ec=n=>n.components().reduce((e,t)=>{var o;const i=t.findFirstType(Ue),r=(o=i==null?void 0:i.attributes.attributes)==null?void 0:o.href,s=r!=null&&r.startsWith(Rr)?r.replace(Rr,""):"";if(s&&i){const l=e[s];l?l.push(i):e[s]=[i]}return e},{}),tc="listPagesComponent",kn="data-type-role",nc="page_root",ic=n=>e=>e.is(n),rc=n=>(e,t)=>t.is(n),oi=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,kn))===n},sc=function(n,e={}){const{Blocks:t,Components:i,Pages:r}=n,{licenseKey:s,block:o={}}=e,l="List Pages",a="List Pages Item",c="Link",h=`${Ei}${Ge}`,d=`${Ei}${Ue}`,f='<svg viewBox="0 0 24 24"><path d="M11 15H17V17H11V15M9 7H7V9H9V7M11 13H17V11H11V13M11 9H17V7H11V9M9 11H7V13H9V11M21 5V19C21 20.1 20.1 21 19 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H19C20.1 3 21 3.9 21 5M19 5H5V19H19V5M9 15H7V17H9V15Z"/></svg>',p='<svg viewBox="0 0 24 24"><path d="M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z" /></svg>';i.addType(Ge,{block:o&&{label:l,media:f,category:"Extra",select:!0,...e.block},isComponent:oi(Ge),model:{defaults:{tagName:"ul",name:l,[nc]:"",classes:h,attributes:{[kn]:Ge},droppable:ic(ut),styles:`
59
+ `}}}),i.addType(f,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:f,"data-type-role":f},components:"Dialog (click me to open)",droppable:!1,draggable:!1}},view:{init(){this.listenTo(this.em,"run:core:preview",()=>{this.el.style.display="none"}),this.listenTo(this.em,"stop:core:preview",()=>{this.el.style.display=""})}}}),Bt({editor:n,licenseKey:r,plan:pe.free,pluginName:Ma,cleanup:()=>{t.remove(s),i.removeType(s)}})},Oa=zt(Ta);function ho(n,e,t){let i,r,s,o,l;const a=e;function c(){const d=Date.now()-o;d<a&&d>=0?i=setTimeout(c,a-d):(i=null,l=n.apply(s,r),s=r=null)}const h=function(){return s=this,r=arguments,o=Date.now(),i||(i=setTimeout(c,a)),l};return h.clear=function(){i&&(clearTimeout(i),i=null)},h.flush=function(){i&&(l=n.apply(s,r),s=r=null,clearTimeout(i),i=null)},h}var Yt=(n=>(n.toastAdd="studio:toastAdd",n.dialogOpen="studio:dialogOpen",n.dialogClose="studio:dialogClose",n.sidebarLeftSet="studio:sidebarLeft:set",n.sidebarLeftGet="studio:sidebarLeft:get",n.sidebarLeftToggle="studio:sidebarLeft:toggle",n.sidebarRightSet="studio:sidebarRight:set",n.sidebarRightGet="studio:sidebarRight:get",n.sidebarRightToggle="studio:sidebarRight:toggle",n.sidebarTopSet="studio:sidebarTop:set",n.sidebarTopGet="studio:sidebarTop:get",n.sidebarTopToggle="studio:sidebarTop:toggle",n.sidebarBottomSet="studio:sidebarBottom:set",n.sidebarBottomGet="studio:sidebarBottom:get",n.sidebarBottomToggle="studio:sidebarBottom:toggle",n.symbolAdd="studio:symbolAdd",n.symbolDetach="studio:symbolDetach",n.symbolOverride="studio:symbolOverride",n.symbolPropagateStyles="studio:propagateStyles",n.getPagesConfig="studio:getPagesConfig",n.setPagesConfig="studio:setPagesConfig",n.getPageSettings="studio:getPageSettings",n.setPageSettings="studio:setPageSettings",n.projectFiles="studio:projectFiles",n.canvasReload="studio:canvasReload",n.getBlocksPanel="studio:getBlocksPanel",n.setBlocksPanel="studio:setBlocksPanel",n.contextMenuComponent="studio:contextMenuComponent",n.layoutAdd="studio:layoutAdd",n.layoutRemove="studio:layoutRemove",n.layoutToggle="studio:layoutToggle",n))(Yt||{}),v=(n=>(n.table="table",n.tableSettings="tableSettings",n.tableDelete="tableDelete",n.tableHead="tableHead",n.tableFoot="tableFoot",n.tableCellItems="tableCellItems",n.tableCellProperties="tableCellProperties",n.tableCellMerge="tableCellMerge",n.tableCellSplit="tableCellSplit",n.tableRowItems="tableRowItems",n.tableRowInsertBefore="tableRowInsertBefore",n.tableRowInsertAfter="tableRowInsertAfter",n.tableRowDelete="tableRowDelete",n.tableRowProperties="tableRowProperties",n.tableRowCut="tableRowCut",n.tableRowCopy="tableRowCopy",n.tableRowPasteBefore="tableRowPasteBefore",n.tableRowPasteAfter="tableRowPasteAfter",n.tableColumn="tableColumn",n.tableColumnItems="tableColumnItems",n.tableColumnInsertBefore="tableColumnInsertBefore",n.tableColumnInsertAfter="tableColumnInsertAfter",n.tableColumnDelete="tableColumnDelete",n.tableColumnCut="tableColumnCut",n.tableColumnCopy="tableColumnCopy",n.tableColumnPasteBefore="tableColumnPasteBefore",n.tableColumnPasteAfter="tableColumnPasteAfter",n))(v||{});const D={table:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableSettings:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 6v12h14V6H5z"/><path d="m14.4 8.6 1 1-2.3 2.4 2.3 2.4-1 1-2.4-2.3-2.4 2.3-1-1 2.3-2.4-2.3-2.4 1-1 2.4 2.3z"/></svg>',tableHead:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableFoot:'<svg viewBox="0 0 24 24" data-test="1" style="transform: rotate(180deg);"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableColumn:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm0 9h-4v5h4v-5Zm-6 0H9v5h4v-5Zm0-7H9v5h4V6Zm6 0h-4v5h4V6Z"/></svg>',tableCellItems:"",tableCellProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zm-8 9H5v5h6v-5zm8 0h-6v5h6v-5zm-8-7H5v5h6V6z"/></svg>',tableCellMerge:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zM5 16v2h3v-2H5zm14-5h-9v7h9v-7zm0-5h-4v3h4V6zM8 6H5v3h3V6zm5 0h-3v3h3V6zm-8 8h3v-3H5v3z"/></svg>',tableCellSplit:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM8 15.5H5V18h3v-2.5zm11-5h-9V18h9v-7.5zm-2.5 1 1 1-2 2 2 2-1 1-2-2-2 2-1-1 2-2-2-2 1-1 2 2 2-2zm-8.5-1H5v3h3v-3zM19 6h-4v2.5h4V6zM8 6H5v2.5h3V6zm5 0h-3v2.5h3V6z"/></svg>',tableRowItems:"",tableRowInsertBefore:'<svg viewBox="0 0 24 24"><path d="M6 4a1 1 0 1 1 0 2H5v6h14V6h-1a1 1 0 0 1 0-2h2c.6 0 1 .4 1 1v13a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5c0-.6.4-1 1-1h2zm5 10H5v4h6v-4zm8 0h-6v4h6v-4zM12 3c.5 0 1 .4 1 .9V6h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 .1V8H9a1 1 0 0 1 0-2h2V4c0-.6.4-1 1-1z"/></svg>',tableRowInsertAfter:'<svg viewBox="0 0 24 24"><path d="M12 13c.5 0 1 .4 1 .9V16h2a1 1 0 0 1 .1 2H13v2a1 1 0 0 1-2 .1V18H9a1 1 0 0 1-.1-2H11v-2c0-.6.4-1 1-1zm6 7a1 1 0 0 1 0-2h1v-6H5v6h1a1 1 0 0 1 0 2H4a1 1 0 0 1-1-1V6c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v13c0 .5-.4 1-.9 1H18zM11 6H5v4h6V6zm8 0h-6v4h6V6z"/></svg>',tableRowDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm0 2H5v3h2.5v2H5v2h2.5v2H5v3h14v-3h-2.5v-2H19v-2h-2.5V9H19V6zm-4.7 1.8 1.2 1L13 12l2.6 3.3-1.2 1-2.3-3-2.3 3-1.2-1L11 12 8.5 8.7l1.2-1 2.3 3 2.3-3z"/></svg>',tableRowProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 15v3h6v-3H5zm14 0h-6v3h6v-3zm0-9h-6v3h6V6zM5 9h6V6H5v3z"/></svg>',tableRowCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M22 3v5H9l3 3 2-2h4l-4 4 1 1h.5c.4 0 .8 0 1.2.3.5.2.9.4 1.2.8.7.6 1 1.3 1 2.2.2.8 0 1.5-.6 2l-.8.5-1 .2c-.4 0-.8 0-1.2-.3a3.9 3.9 0 0 1-2.1-2.2c-.2-.5-.3-1-.2-1.5l-1-1-1 1c0 .5 0 1-.2 1.5-.1.5-.4 1-.9 1.4-.3.4-.7.6-1.2.8l-1.2.3c-.4 0-.7 0-1-.2-.3 0-.6-.3-.8-.5-.5-.5-.8-1.2-.7-2a3 3 0 0 1 1-2.2A3.7 3.7 0 0 1 8.6 14H9l1-1-4-4-.5-1a3.3 3.3 0 0 1 0-2c0-.4.3-.7.5-1l2 2V3h14zM8.5 15.3h-.3a2.6 2.6 0 0 0-.8.4 2.5 2.5 0 0 0-.9 1.1l-.1.4v.7l.2.5.5.2h.7a2.5 2.5 0 0 0 .8-.3L9 18l.4-.4.2-.4.1-.4v-.7a1 1 0 0 0-.2-.5 1 1 0 0 0-.4-.2h-.5zm7 0H15a1 1 0 0 0-.4.3 1 1 0 0 0-.2.5 1.5 1.5 0 0 0 0 .7v.4a2.8 2.8 0 0 0 .5.7h.1a2.8 2.8 0 0 0 .8.6l.4.1h.7l.5-.2.2-.5v-.7a2.6 2.6 0 0 0-.3-.8 2.4 2.4 0 0 0-.7-.7 2.5 2.5 0 0 0-.8-.3h-.3zM12 11.6c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zm8.5-7.1h-11v2h11v-2z"/></svg>',tableRowCopy:'<svg viewBox="0 0 24 24"><path d="M22 11v7H6v-7h16zm-2 2H8v3h12v-3zm-1-6v2H4v5H2V7h17z"/></svg>',tableRowPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h12v-4h2v4c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 7v5H8V8h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableRowPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V11h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h14c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 11v5H8v-5h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnItems:"",tableColumnInsertBefore:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a1 1 0 0 1-1-1v-2a1 1 0 0 1 2 0v1h8V6H5v1a1 1 0 1 1-2 0V5c0-.6.4-1 1-1h15zm0 9h-4v5h4v-5zM8 8c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H9v2a1 1 0 0 1-2 .1V13H5a1 1 0 0 1-.1-2H7V9c0-.6.4-1 1-1zm11-2h-4v5h4V6z"/></svg>',tableColumnInsertAfter:'<svg viewBox="0 0 24 24"><path d="M20 4c.6 0 1 .4 1 1v2a1 1 0 0 1-2 0V6h-8v12h8v-1a1 1 0 0 1 2 0v2c0 .5-.4 1-.9 1H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h15zM9 13H5v5h4v-5zm7-5c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H17v2a1 1 0 0 1-2 .1V13h-2a1 1 0 0 1-.1-2H15V9c0-.6.4-1 1-1zM9 6H5v5h4V6z"/></svg>',tableColumnDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm-4 4h-2V6h-2v2H9V6H5v12h4v-2h2v2h2v-2h2v2h4V6h-4v2zm.3.5 1 1.2-3 2.3 3 2.3-1 1.2L12 13l-3.3 2.6-1-1.2 3-2.3-3-2.3 1-1.2L12 11l3.3-2.5z"/></svg>',tableColumnCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M7.2 4.5a3 3 0 0 1 2.2 1A3.7 3.7 0 0 1 10.5 8v.5l1 1 4-4 1-.5a3.3 3.3 0 0 1 2 0c.4 0 .7.3 1 .5L17 8h4v13h-6V10l-1.5 1.5.5.5v4l-2.5-2.5-1 1v.5c0 .4 0 .8-.3 1.2-.2.5-.4.9-.8 1.2-.6.7-1.3 1-2.2 1-.8.2-1.5 0-2-.6l-.5-.8-.2-1c0-.4 0-.8.3-1.2A3.9 3.9 0 0 1 7 12.7c.5-.2 1-.3 1.5-.2l1-1-1-1c-.5 0-1 0-1.5-.2-.5-.1-1-.4-1.4-.9-.4-.3-.6-.7-.8-1.2L4.5 7c0-.4 0-.7.2-1 0-.3.3-.6.5-.8.5-.5 1.2-.8 2-.7zm12.3 5h-3v10h3v-10zM8 13.8h-.3l-.4.2a2.8 2.8 0 0 0-.7.4v.1a2.8 2.8 0 0 0-.6.8l-.1.4v.7l.2.5.5.2h.7a2.6 2.6 0 0 0 .8-.3 2.4 2.4 0 0 0 .7-.7 2.5 2.5 0 0 0 .3-.8 1.5 1.5 0 0 0 0-.8 1 1 0 0 0-.2-.4 1 1 0 0 0-.5-.2H8zm3.5-3.7c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zM7 5.8h-.4a1 1 0 0 0-.5.3 1 1 0 0 0-.2.5v.7a2.5 2.5 0 0 0 .3.8l.2.3h.1l.4.4.4.2.4.1h.7L9 9l.2-.4a1.6 1.6 0 0 0 0-.8 2.6 2.6 0 0 0-.3-.8 2.5 2.5 0 0 0-1.2-1l-.4-.1H7z"/></svg>',tableColumnCopy:'<svg viewBox="0 0 24 24"><path d="M17 6v16h-7V6h7zm-2 2h-3v12h3V8zm-2-6v2H8v15H6V2h7z"/></svg>',tableColumnPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V18c0 1-.8 2-1.9 2H11v-2h7V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v2H4V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm-2 7v12H4V8h6zM8.5 9.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h7v2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm8 7v12h-6V8h6zm-1.5 1.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>'},be="table",fo="thead",uo="tfoot",Ii="tbody",ne="row",P="cell",sr="clipboardTable",Aa=[be,fo,uo,Ii,ne,P],Gn=n=>n.em.get(sr)||[],Na=n=>n.every(e=>e.is(P)),or=(n,e)=>{const{editor:t,event:i,opts:r}=n,s=i.currentTarget||i.target,{x:o,y:l,width:a,height:c}=s.getBoundingClientRect(),h={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:o,y:l,w:a,h:c},layout:{type:"tabs",value:"props",tabs:[{id:"styles",label:"Styles",children:{type:"panelStyles"}},{id:"props",label:"Properties",children:{type:"panelProperties",style:{padding:"14px 7px"}}}]},...e};co(r.openSettings)?r.openSettings({...n,layoutProps:h}):t.runCommand(Yt.layoutToggle,h)},Ea=(n,{rows:e=1,cells:t=5,text:i}={})=>({type:n,components:Array.from(Array(e).keys()).map(r=>({type:ne,components:Array.from(Array(t).keys()).map(s=>({type:P,components:i?{type:"text",content:co(i)?i({y:r,x:s}):i}:void 0}))}))}),po="Table settings",mo=n=>{const{component:e}=n;return e.is(be)?e:e.closestType(be)},Da=n=>{var e;(e=mo(n))==null||e.remove(n.opts)},Ia=n=>{const e=mo(n);e&&(n.editor.select(e),or(n,{id:"tableSettings",header:{label:po}}))},go=n=>[{id:v.table,icon:D[v.table],label:"Table",items:[{id:v.tableSettings,label:po,icon:D[v.tableSettings],onClick:({event:t})=>Ia({...n,event:t})},{id:v.tableDelete,label:"Delete table",icon:D[v.tableDelete],onClick:()=>Da(n)}]}],yo=({editor:n})=>{const e=Gn(n);return e.length&&Na(e)},Er=({component:n,editor:e,after:t})=>{if(!n.is(P))return;const i=n.closestType(be),r=n.closestType(ne),s=n.index()+(t?1:0);i==null||i.findType(ne).forEach(l=>l.append({type:P},{at:s}));const o=r==null?void 0:r.components().at(s);o&&e.select(o)},bo=({component:n,opts:e})=>{if(!n.is(P))return;const t=n.closestType(be),i=n.index();t==null||t.findType(ne).forEach(r=>{var s;return(s=r.components().at(i))==null?void 0:s.remove(e)})},xo=({component:n,editor:e})=>{if(!n.is(P))return;const t=n.closestType(be),i=n.index(),r=(t==null?void 0:t.findType(ne).map(s=>s.components().at(i)))||[];r.length&&e.em.set(sr,r)},Dr=n=>{const{component:e,editor:t,after:i}=n;if(!e.is(P)||!yo(n))return;const r=Gn(t),s=e.closestType(be),o=e.index()+(i?1:0);s==null||s.findType(ne).forEach((l,a)=>{const c=r[a],h=(c==null?void 0:c.clone())||{type:P};l.append(h,{at:o})})},Ra=n=>{const{component:e}=n;e.is(P)&&(xo(n),bo({...n,opts:{temporary:!0}}))},Pa=n=>{const e=yo(n);return[{id:v.tableColumnItems,icon:D[v.tableColumn],label:"Column",items:[{id:v.tableColumnInsertBefore,label:"Insert column before",icon:D[v.tableColumnInsertBefore],onClick:()=>Er(n)},{id:v.tableColumnInsertAfter,label:"Insert column after",icon:D[v.tableColumnInsertAfter],onClick:()=>Er({...n,after:!0})},{id:v.tableColumnDelete,label:"Delete column",icon:D[v.tableColumnDelete],onClick:()=>bo(n)},{id:v.tableColumnCut,label:"Cut column",icon:D[v.tableColumnCut],onClick:()=>Ra(n)},{id:v.tableColumnCopy,label:"Copy column",icon:D[v.tableColumnCopy],onClick:()=>xo(n)},{id:v.tableColumnPasteBefore,label:"Paste column before",icon:D[v.tableColumnPasteBefore],disabled:!e,onClick:()=>Dr(n)},{id:v.tableColumnPasteAfter,label:"Paste column after",icon:D[v.tableColumnPasteAfter],disabled:!e,onClick:()=>Dr({...n,after:!0})}]}]},Co="Row settings",Va=n=>n.every(e=>e.is(ne)),Lt=n=>{const{component:e}=n,t=e.is(P),i=e.is(ne);if(!(!t&&!i))return i?e:e.closestType(ne)},Ir=n=>{const{component:e,editor:t,after:i}=n,r=Lt(n);if(!r)return;const s=r.index()+(i?1:0),o=r.components().length,l=Array.from(Array(o).keys()).map(()=>({type:P})),a=r.parent();if(a){const c=a.append({type:ne,components:l},{at:s})[0];if(e.is(P)&&c){const h=e.index(),d=c.components().at(h);d&&t.select(d)}}},wo=n=>{var e;(e=Lt(n))==null||e.remove(n.opts)},So=n=>{const e=Lt(n);e&&n.editor.em.set(sr,[e])},Rr=n=>{var l;const{editor:e,after:t}=n,i=Lt(n);if(!i||!ko(n))return;const s=Gn(e)[0],o=i.index()+(t?1:0);s&&((l=i.parent())==null||l.append(s.clone(),{at:o}))},za=n=>{Lt(n)&&(So(n),wo({...n,opts:{temporary:!0}}))},ko=({editor:n})=>{const e=Gn(n);return e.length&&Va(e)},Ba=n=>{const e=Lt(n);e&&(n.editor.select(e),or(n,{id:"tableRowSettings",header:{label:Co}}))},vo=n=>{const e=ko(n);return[{id:v.tableRowItems,icon:D[v.tableRowProperties],label:"Row",items:[{id:v.tableRowInsertBefore,label:"Insert row before",icon:D[v.tableRowInsertBefore],onClick:()=>Ir(n)},{id:v.tableRowInsertAfter,label:"Insert row after",icon:D[v.tableRowInsertAfter],onClick:()=>Ir({...n,after:!0})},{id:v.tableRowDelete,label:"Delete row",icon:D[v.tableRowDelete],onClick:()=>wo(n)},{id:v.tableRowProperties,label:Co,icon:D[v.tableRowProperties],onClick:({event:i})=>Ba({...n,event:i})},{id:v.tableRowCut,label:"Cut row",icon:D[v.tableRowCut],onClick:()=>za(n)},{id:v.tableRowCopy,label:"Copy row",icon:D[v.tableRowCopy],onClick:()=>So(n)},{id:v.tableRowPasteBefore,label:"Paste row before",icon:D[v.tableRowPasteBefore],disabled:!e,onClick:()=>Rr(n)},{id:v.tableRowPasteAfter,label:"Paste row after",icon:D[v.tableRowPasteAfter],disabled:!e,onClick:()=>Rr({...n,after:!0})}]},...go(n)]},lr=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),i=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:i}};function Mo(n){const e=[];return n.components().forEach((t,i)=>{t.components().each((r,s)=>{const{rowspan:o,colspan:l}=lr(r);if(e[i])for(;e[i][s];)s++;for(let a=i;a<i+o;a++){e[a]||(e[a]=[]);for(let c=s;c<s+l;c++)e[a][c]={real:a===i&&c===s,cell:r,rowspan:o,colspan:l}}})}),e}function kt(n,e,t){var i;return(i=n[t])==null?void 0:i[e]}const Ri=n=>n.closestType(ne);function La(n,{x:e,y:t,rows:i,cols:r}){var l;let s=Ri(n[t][e].cell),o;for(let a=1;a<=i;a++)if(s=(l=s==null?void 0:s.parent())==null?void 0:l.components().at(s.index()+1),s){for(o=e;o>=0;o--){const{cell:c}=n[t+a][o],h=Ri(c);if(h===s){for(let d=1;d<=r;d++){const f=c.index();h.append({type:P},{at:f+1})}break}}if(o===-1){const h=s.components().at(0).index();for(let d=1;d<=r;d++)s.append({type:P},{at:h})}}}function To(n){for(let e=0;e<n.length;e++)for(let t=0;t<n[e].length;t++){const r=n[e][t].cell;if(r.em.selected.hasComponent(r)){const{rowspan:s,colspan:o}=lr(r);if(o>1||s>1){r.addAttributes({colspan:1,rowspan:1});for(let l=0;l<o-1;l++){const a=r.index();Ri(r).append({type:P},{at:a+1})}La(n,{x:t,y:e,rows:s-1,cols:o})}}}}function Ha(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const Un=(n,e={})=>{var o;const t=Mo(n),{em:i}=n;let r,s;for(let l=0;l<t.length;l++)for(let a=0;a<t[l].length;a++){const c=t[l][a];if((o=e.selected)!=null&&o.includes(c.cell)||i.selected.hasComponent(c.cell)){const h={x:a,y:l};r||(r=h),s=h}}return{grid:t,startPos:r,endPos:s}};function Fa(n,e={}){const t=Un(n),{startPos:i,endPos:r}=t;let{grid:s}=t;const{em:o}=n;if(!i||!r)return;const l=i.x,a=i.y,c=r.x,h=r.y,d=kt(s,l,a),f=kt(s,c,h);if(d&&f){To(s),s=Mo(n);const p=[],u=kt(s,l,a).cell;u.addAttributes({colspan:c-l+1,rowspan:h-a+1});for(let m=a;m<=h;m++)for(let g=l;g<=c;g++){const y=kt(s,g,m);if(!y)continue;const{cell:S}=y;S!==u&&p.push(S)}p.forEach(m=>{e.mergeContent&&u.append(m.components().models),m.remove()}),o.setSelected(u),Ha(n)}}const Oo="Cell settings",$a="Merge cells",Wa="Split cell",Ka=n=>n.closestType(ne),Nt=n=>{var e;return(e=Ka(n))==null?void 0:e.parent()},Ja=n=>{const e=n.editor.getSelectedAll(),t=Nt(e[0]),i=e[0];if(!t||!(i!=null&&i.is(P))||e.length>1)return!1;const{rowspan:r,colspan:s}=lr(i);return!(s<2&&r<2)},qa=n=>{const t=n.editor.getSelectedAll()[0],i=Nt(t),{grid:r}=Un(i);To(r)},Ao=n=>{const e=n.editor.getSelectedAll(),t=Nt(e[0]);if(!t||e.length<2||e.some(l=>!l.is(P)||Nt(l)!==t))return!1;const{grid:i,startPos:r,endPos:s}=Un(t),{em:o}=t;if(!r||!s)return!1;for(let l=r.y;l<=s.y;l++)for(let a=r.x;a<=s.x;a++){const c=kt(i,a,l);if(!c||!o.selected.hasComponent(c.cell))return!1}return!0},ja=n=>{const{editor:e}=n;if(!Ao(n))return;const t=e.getSelectedAll(),i=Nt(t[0]);Fa(i,{mergeContent:!0})},_a=n=>{or(n,{id:"tableCellSettings",header:{label:Oo}})},Ga=n=>[{id:v.tableCellItems,icon:D[v.tableCellProperties],label:"Cell",items:[{id:v.tableCellProperties,label:Oo,icon:D[v.tableCellProperties],onClick:({event:t})=>_a({...n,event:t})},{id:v.tableCellMerge,label:$a,icon:D[v.tableCellMerge],onClick:()=>ja(n),disabled:!Ao(n)},{id:v.tableCellSplit,label:Wa,icon:D[v.tableCellSplit],onClick:()=>qa(n),disabled:!Ja(n)}]},...Pa(n),...vo(n)],Ua=n=>{const e=n[0]&&Nt(n[0]);if(!e)return;const{grid:t,startPos:i,endPos:r}=Un(e,{selected:n});if(!i||!r)return;const s=[];for(let o=i.y;o<=r.y;o++)for(let l=i.x;l<=r.x;l++){const a=kt(t,l,o);a&&s.push(a.cell)}s.length&&e.em.setSelected(s,{fromCell:!0})},Za="tableComponent",Xa=function(n,e={}){const t={block:{},...e},{Components:i}=n,r={copyable:!1,emptyState:!0,highlightable:!1,stylable:["color","font-family","font-size","font-weight","line-height","text-align","vertical-align","background-color","border-width","border-style","border-color"]};i.addType(be,{block:t.block&&{label:"Table",media:D.table,category:"Extra",content:{type:be,style:{width:"100%"}},select:!0,...t.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:D.table,stylable:["width","height","margin","font-family","font-size","font-weight","line-height","text-align","background","background-color","border-width","border-style","border-color"],traits:[{type:"number",min:0,name:"cellspacing",label:"Cell spacing"},{type:"number",min:0,name:"cellpadding",label:"Cell padding"},{id:"tableCaption",type:"checkbox",label:"Caption",setValue({component:o,value:l,emitUpdate:a}){const c=o.find("caption")[0];l?!c&&o.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):c==null||c.remove(),a(),n.refresh({tools:!0})},getValue(o){return!!o.component.find("caption")[0]}}],components:Ea(Ii,{rows:5}),contextMenu:({items:o,editor:l,component:a})=>[...go({editor:l,component:a,opts:t}),...o]}}}),i.addType(fo,{model:{defaults:{icon:D.tableHead,...r}}}),i.addType(uo,{model:{defaults:{icon:D.tableFoot,...r}}}),i.addType(Ii,{model:{defaults:{icon:D.tableRowProperties,...r}}}),i.addType(ne,{model:{defaults:{icon:D.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:o,editor:l,component:a})=>[...vo({editor:l,component:a,opts:t}),...o]}}}),i.addType(P,{model:{defaults:{icon:D.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","background-color","text-align","vertical-align","border-width","border-style","border-color"],traits:[{id:"tableCellType",type:"select",options:[{value:"td",name:"Cell"},{value:"th",name:"Header Cell"}],label:"Cell type",name:"tagName",changeProp:!0},{id:"tableCellScope",type:"select",options:[{value:!1,name:"None"},{value:"row",name:"Row"},{value:"col",name:"Column"},{value:"rowgroup",name:"Row group"},{value:"colgroup",name:"Column group"}],label:"Scope",name:"scope"}],contextMenu:({items:o,editor:l,component:a})=>[...Ga({editor:l,component:a,opts:t}),...o]}}});const s=ho((o,l)=>{var d;const a=n.getSelectedAll(),c=!!((d=l==null?void 0:l.event)!=null&&d.shiftKey);if(a.length<2||!c||l.fromCell)return;const h=a.map(f=>f.is(P)?f:f.closestType(P)).filter(Boolean);h.length===a.length&&Ua(h)},0);n.on("component:select",s),Bt({editor:n,plan:pe.free,licenseKey:t.licenseKey,pluginName:Za,cleanup:()=>{n.off("component:select",s),n.Blocks.remove(be),Aa.forEach(o=>i.removeType(o))}})},Ya=zt(Xa),Pr="page://",Ue="list-pages",pt="list-pages-item",Ze="list-pages-link",Qa=n=>n.components().reduce((e,t)=>{var o;const i=t.findFirstType(Ze),r=(o=i==null?void 0:i.attributes.attributes)==null?void 0:o.href,s=r!=null&&r.startsWith(Pr)?r.replace(Pr,""):"";if(s&&i){const l=e[s];l?l.push(i):e[s]=[i]}return e},{}),ec="listPagesComponent",vn="data-type-role",tc="page_root",nc=n=>e=>e.is(n),ic=n=>(e,t)=>t.is(n),li=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,vn))===n},rc=function(n,e={}){const{Blocks:t,Components:i,Pages:r}=n,{licenseKey:s,block:o={}}=e,l="List Pages",a="List Pages Item",c="Link",h=`${Di}${Ue}`,d=`${Di}${Ze}`,f='<svg viewBox="0 0 24 24"><path d="M11 15H17V17H11V15M9 7H7V9H9V7M11 13H17V11H11V13M11 9H17V7H11V9M9 11H7V13H9V11M21 5V19C21 20.1 20.1 21 19 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H19C20.1 3 21 3.9 21 5M19 5H5V19H19V5M9 15H7V17H9V15Z"/></svg>',p='<svg viewBox="0 0 24 24"><path d="M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z" /></svg>';i.addType(Ue,{block:o&&{label:l,media:f,category:"Extra",select:!0,...e.block},isComponent:li(Ue),model:{defaults:{tagName:"ul",name:l,[tc]:"",classes:h,attributes:{[vn]:Ue},droppable:nc(pt),styles:`
60
60
  .${h} {
61
61
  list-style: none;
62
62
  margin: 0;
63
63
  padding: 0;
64
64
  }
65
- `},init(){this.syncPageItems=co(this.syncPageItems.bind(this),0),this.listenTo(this.em,r.events.all,this.syncPageItems),this.syncPageItems()},syncPageItems(){if(n.Components.getSymbolInfo(this).isInstance)return;const u=this.em.Pages.getAll(),m=this.components(),g=ec(this);u.forEach((y,S)=>{const b=y.id,C=y.getName(),k=g[b];k?k==null||k.forEach(M=>{M.getInnerHTML()!==C&&M.components(C)}):m.add({type:ut,components:[{type:Ue,attributes:{href:`page://${b}`},components:{type:"textnode",content:C}}]},{at:S})})}}}),i.addType(ut,{isComponent:oi(ut),model:{defaults:{name:a,tagName:"li",icon:p,attributes:{[kn]:ut},components:{type:Ue},draggable:rc(Ge)}}}),i.addType(Ue,{extend:"link",isComponent:oi(Ue),model:{defaults:{removable:!1,copyable:!1,delegate:{move:u=>u.closestType(ut)},name:c,classes:d,attributes:{[kn]:Ue},components:{type:"textnode",content:"Item"},styles:`
65
+ `},init(){this.syncPageItems=ho(this.syncPageItems.bind(this),0),this.listenTo(this.em,r.events.all,this.syncPageItems),this.syncPageItems()},syncPageItems(){if(n.Components.getSymbolInfo(this).isInstance)return;const u=this.em.Pages.getAll(),m=this.components(),g=Qa(this);u.forEach((y,S)=>{const b=y.id,C=y.getName(),k=g[b];k?k==null||k.forEach(M=>{M.getInnerHTML()!==C&&M.components(C)}):m.add({type:pt,components:[{type:Ze,attributes:{href:`page://${b}`},components:{type:"textnode",content:C}}]},{at:S})})}}}),i.addType(pt,{isComponent:li(pt),model:{defaults:{name:a,tagName:"li",icon:p,attributes:{[vn]:pt},components:{type:Ze},draggable:ic(Ue)}}}),i.addType(Ze,{extend:"link",isComponent:li(Ze),model:{defaults:{removable:!1,copyable:!1,delegate:{move:u=>u.closestType(pt)},name:c,classes:d,attributes:{[vn]:Ze},components:{type:"textnode",content:"Item"},styles:`
66
66
  .${d} {
67
67
  text-decoration: none;
68
68
  }
69
- `}}}),zt({editor:n,licenseKey:s,pluginName:tc,cleanup:()=>{t.remove(Ge),i.removeType(Ge)}})},oc=Pt(sc),lc="fsLightboxComponent",pn="data-fslightbox",mn="data-type",ac="fslightbox-open",pt="fslightbox",mt={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',imageLightbox:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},cc=function(n,e={}){const{Blocks:t,Components:i}=n,r="Lightbox",s=`${Ei}${pt}`,o={toolbarIconOpen:mt.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=o,h=function(S){const b=this,C="data-fslightbox",k=window,M=()=>{var Q;const E=k.refreshFsLightbox;E==null||E();const L=b.getAttribute(C);if((Q=k.fsLightboxInstances)==null||Q[L],!k._isEditor)return;Array.from(document.querySelectorAll(`[${C}]`)).forEach(P=>{const q=P.onclick;P.onclick=function(je){je.preventDefault();const oe=P;!oe.__skipLb&&(q==null||q(je)),oe.__skipLb=!0}})};if(k.refreshFsLightbox)M();else{const E=document.createElement("script");E.src=S.cdnScript,E.onload=M,document.head.appendChild(E)}},d=S=>({id:`${pt}-open-lb`,label:a,command:()=>{const b=S.getView();b==null||b.toggleLightbox()}}),f="source-type",p={type:"radio",name:f,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:mt.image},{id:"video",label:"Video",icon:mt.video},{id:"el",label:"Custom Element",icon:mt.external}],labelToTitle:!0},u={id:"href-image",name:"href",type:"file",label:"Source Image"},m={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},g={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},y={image:[u],video:[m],el:[g]};i.addType(pt,{block:l&&{label:r,media:mt.imageLightbox,category:"Extra",select:!0,...o.block},isComponent:S=>{var b;return(b=S.hasAttribute)==null?void 0:b.call(S,pn)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:r,icon:mt.imageLightbox,classes:s,draggable:(S,b)=>!b.is(pt),attributes:{[pn]:"lightbox",[mn]:"image",href:c},components:{type:"image",src:c},script:h,cdnScript:o.cdnScript,"script-props":["attributes","cdnScript"],[f]:"image",traits:[p,{name:pn,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(S,b){var k;const C=(k=b.target)==null?void 0:k.getView();C==null||C.toggleLightbox()}}],styles:`
69
+ `}}}),Bt({editor:n,licenseKey:s,plan:pe.free,pluginName:ec,cleanup:()=>{t.remove(Ue),i.removeType(Ue)}})},sc=zt(rc),oc="fsLightboxComponent",mn="data-fslightbox",gn="data-type",lc="fslightbox-open",mt="fslightbox",gt={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',imageLightbox:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},ac=function(n,e={}){const{Blocks:t,Components:i}=n,r="Lightbox",s=`${Di}${mt}`,o={toolbarIconOpen:gt.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=o,h=function(S){const b=this,C="data-fslightbox",k=window,M=()=>{var Q;const E=k.refreshFsLightbox;E==null||E();const L=b.getAttribute(C);if((Q=k.fsLightboxInstances)==null||Q[L],!k._isEditor)return;Array.from(document.querySelectorAll(`[${C}]`)).forEach(V=>{const q=V.onclick;V.onclick=function(_e){_e.preventDefault();const oe=V;!oe.__skipLb&&(q==null||q(_e)),oe.__skipLb=!0}})};if(k.refreshFsLightbox)M();else{const E=document.createElement("script");E.src=S.cdnScript,E.onload=M,document.head.appendChild(E)}},d=S=>({id:`${mt}-open-lb`,label:a,command:()=>{const b=S.getView();b==null||b.toggleLightbox()}}),f="source-type",p={type:"radio",name:f,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:gt.image},{id:"video",label:"Video",icon:gt.video},{id:"el",label:"Custom Element",icon:gt.external}],labelToTitle:!0},u={id:"href-image",name:"href",type:"file",label:"Source Image"},m={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},g={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},y={image:[u],video:[m],el:[g]};i.addType(mt,{block:l&&{label:r,media:gt.imageLightbox,category:"Extra",select:!0,...o.block},isComponent:S=>{var b;return(b=S.hasAttribute)==null?void 0:b.call(S,mn)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:r,icon:gt.imageLightbox,classes:s,draggable:(S,b)=>!b.is(mt),attributes:{[mn]:"lightbox",[gn]:"image",href:c},components:{type:"image",src:c},script:h,cdnScript:o.cdnScript,"script-props":["attributes","cdnScript"],[f]:"image",traits:[p,{name:mn,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(S,b){var k;const C=(k=b.target)==null?void 0:k.getView();C==null||C.toggleLightbox()}}],styles:`
70
70
  .${s} {
71
71
  display: inline-block;
72
72
  padding: 10px;
73
73
  }
74
- `},init(){const S=[f].map(b=>`change:${b}`).join(" ");this.on(S,this.updateTraits),this.on(`change:${f}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(S,b,C){if(C.adjust)return;const M=this.get(f)==="video"?"video":"image";this.addAttributes({[mn]:M,href:""})},adjustSourceType(){const S=this.get(f),b=this.getAttributes().href||"",C={adjust:!0};if(S==="video"){const k=b.includes("youtube.com")?"youtube":"video";this.addAttributes({[mn]:k},C)}else S!=="el"&&b.startsWith("#")?this.set(f,"el",C):S==="image"&&this.addAttributes({[mn]:"image"},C)},updateTraits(S={}){const{changed:b}=this,{init:C}=S;if(b[p.name]||C){this.removeTrait([u.name,m.name,g.name]);const k=this.get(f)||"image",M=this.getTraitIndex(f)+1;this.addTrait(y[k],{at:M})}},initToolbar(){if(!a)return;const{toolbar:S}=this,b=d(this);!S.find(k=>k.id===b.id)&&(S==null||S.unshift(b))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var P;const{em:S,el:b,model:C}=this,{Canvas:k}=S,M=C.getAttributes()[pn],{defaultView:E,documentElement:L}=b.ownerDocument,O=(P=E.fsLightboxInstances)==null?void 0:P[M];if(L.classList.contains(ac))O.close();else{b.__skipLb=!1;let q;O.props.onOpen=()=>{q=k.getSpots(),setTimeout(()=>k.removeSpots())},O.props.onClose=()=>{q.forEach(je=>k.addSpot(je.attributes))},b.click()}}}}),zt({editor:n,licenseKey:o.licenseKey,pluginName:lc,cleanup:()=>{t.remove(pt),i.removeType(pt)}})},hc=Pt(cc);var xt=(n=>(n.image="image",n.video="video",n.external="external",n))(xt||{});const Ze="lightGallery",Vr=`${Ze}-item`,vn="data-lightgallery",Pr=`${vn}-item`,En="toggle",Qe={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',gallery:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',galleryItem:'<svg viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M8 14H6v-2h2v2m0-3H6V9h2v2m0-3H6V6h2v2m7 6h-5v-2h5v2m3-3h-8V9h8v2m0-3h-8V6h8v2Z"/></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},li={propKeys:[],props:{},traits:[]},Lt=(n,e={})=>{var r;const t={},i=[];for(const s in n){const{value:o,...l}=n[s];i.push({id:s,name:s,changeProp:!0,category:e.category,...l}),t[s]=o;const{subTraits:a={}}=l;for(const c in l.subTraits)(r=a[c])==null||r.forEach(h=>{const d=h.id||h.name;t[d]=h.value})}return{propKeys:Object.keys(t),props:t,traits:i}},Ri=(n,e)=>{const t=n.getTrait(e),i=t.get("category"),r=t.get("subTraits")||{},o=(Object.values(r).flat()||[]).map(c=>c.id||c.name);n.removeTrait(o);const l=r[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:i,...c})),{at:a})},ai=(n,e)=>{e.forEach(t=>{const i=n.getTrait(t);if(!i||!i.get("subTraits"))return;const r=i.changeProp?`change:${t}`:`change:attributes:${t}`;n.on(r,()=>Ri(n,t)),Ri(n,t)})},dc=(n,e,t)=>{const r=n.getTrait(e).get("subTraits")||{},o=(Object.values(r).flat()||[]).map(a=>{const c=a.name||a.id;return a.changeProp?`change:${c}`:`change:attributes:${c}`}),l=Array.from(new Set(o));l.length&&n.on(l.join(" "),t)},fc={[En]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var t,i;return(i=(t=e.target)==null?void 0:t.getView())==null?void 0:i.toggleGallery()}},speed:{type:"number",label:"Speed",tip:"Transition duration between slides (in ms)",value:400,step:50,min:0},inline:{type:"checkbox",label:"Inline Gallery",value:!1},allowMediaOverlap:{type:"checkbox",label:"Allow media overlap",tip:"If enabled, toolbar, captions and thumbnails will overlap with the media element",value:!1},controls:{type:"checkbox",label:"Show controls",tip:"If disabled, prev/next buttons will not be displayed",value:!0},counter:{type:"checkbox",label:"Show counter",tip:"Display the total number of images and index number of the currently displayed slide",value:!0},download:{type:"checkbox",label:"Download icon",tip:"Enable download button",value:!0},enableDrag:{type:"checkbox",label:"Enable drag",tip:"Enables desktop mouse drag support",value:!0},enableSwipe:{type:"checkbox",label:"Enable swipe",tip:"Enables swipe support for mobile devices",value:!0},escKey:{type:"checkbox",label:"Enable Esc key",tip:'Whether the gallery could be closed by pressing the "Esc" key',value:!0},keyPress:{type:"checkbox",label:"Enable keyboard navigation",value:!1},loop:{type:"checkbox",label:"Loop",tip:"If false, will disable the ability to loop back to the beginning of the gallery from the last slide",value:!0},getCaptionFromTitleOrAlt:{type:"checkbox",label:"Caption from title or alt",tip:"Get captions from alt or title tags",value:!0},showMaximizeIcon:{type:"checkbox",label:"Show maximize icon",value:!1},closable:{type:"checkbox",label:"Closable",tip:"If false, it won't be possible to close the gallery",value:!0},showCloseIcon:{type:"checkbox",label:"Show close icon",tip:"If false, close button won't be displayed.",visible:({component:n})=>!!n.getTrait("closable").getValue(),value:!0},closeOnTap:{type:"checkbox",label:"Close on tap",tip:"Allows clicks on black area to close gallery",visible:({component:n})=>!!n.getTrait("closable").getValue(),value:!0}},uc={thumbnail:{category:{id:"thumbnail-options",label:"Thumbnail Options"},type:"checkbox",label:"Thumbnails",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"enableThumbDrag",label:"Thumbnail drag",tip:"Enable thumbnail drag on desktop",changeProp:!0,value:!0},{type:"checkbox",name:"enableThumbSwipe",label:"Thumbnail swipe",tip:"Enable thumbnail swipe on mobile devices",changeProp:!0,value:!0},{type:"select",name:"alignThumbnails",tip:"Position of thumbnails when the width of all thumbnails combined is less than the gallery's width",label:"Align Thumbnails",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"select",name:"currentPagerPosition",label:"Select thumbnail position",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"number",name:"thumbMargin",label:"Thumb margin",tip:"Spacing between each thumbnails",changeProp:!0,min:0,value:"5"},{type:"number",name:"thumbWidth",label:"Thumb width",tip:"Width of each thumbnails",changeProp:!0,min:0,value:"100"}]}}},pc={autoplay:{category:{id:"autoplay-options",label:"Autoplay options"},type:"checkbox",label:"Autoplay",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"autoplayControls",label:"Autoplay controls",tip:"Show/hide autoplay controls",changeProp:!0,value:!0},{type:"checkbox",name:"progressBar",label:"Progress bar",tip:"Show autoplay progress bar",changeProp:!0,value:!0},{type:"checkbox",name:"forceSlideShowAutoplay",label:"Force autoplay",tip:"If false, autoplay will be stopped after first user action",changeProp:!0,value:!1},{type:"checkbox",name:"slideShowAutoplay",label:"Start autoplay",tip:"Enable autoplay on start",changeProp:!0,value:!1},{type:"number",name:"slideShowInterval",label:"Interval",tip:"The time (in ms) between each auto transition",changeProp:!0,min:0,step:50,value:5e3}]}}},mc={zoom:{category:{id:"zoom-options",label:"Zoom options"},type:"checkbox",label:"Zoom",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"actualSize",label:"Show actual size icon",changeProp:!0,value:!0},{type:"checkbox",name:"infiniteZoom",label:"Infinte zoom",changeProp:!0,value:!0},{type:"checkbox",name:"showZoomInOutIcons",label:"Show zoom in/out icons",changeProp:!0,value:!1},{type:"number",name:"scale",label:"Scale",tip:"Value of zoom should be incremented/decremented",changeProp:!0,min:0,value:1}]}}},Ee="sourceType",gn="data-iframe",Vi={name:"href",type:"file",label:"Image Source"},Dn={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},Pi={name:"data-poster",label:"Video Poster",type:"file"},zr={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},Ao={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},gc={[En]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var r,s;const t=e.target,i=(r=t==null?void 0:t.closestType(Ze))==null?void 0:r.getView();if(i&&t){const o=((s=i.getLightGallery())==null?void 0:s.items)||[],l=Array.from(o).indexOf(t.getEl());l>=0&&i.toggleGallery(l)}}},[Ee]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[Vi],video:[Dn,Pi],external:[zr]},options:[{id:"image",label:Vi.label||"",icon:Qe.image},{id:"video",label:Dn.label||"",icon:Qe.video},{id:"external",label:zr.label||"",icon:Qe.external}]},subHtml:Ao},yc="lightGalleryComponent",Br="lgThumbnail",bc="lgVideo",Lr="lgAutoplay",Hr="lgZoom",gt="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",xc=function(n,e={}){const{Blocks:t,Components:i}=n,r="LightGallery",s="LightGallery Item",o={toolbarIconOpen:Qe.eye,block:{},lgLicenseKey:"0000-0000-000-0000",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[Br,bc,Lr,Hr],cdnScript:[`${gt}/lightgallery.min.js`,`${gt}/plugins/thumbnail/lg-thumbnail.min.js`,`${gt}/plugins/video/lg-video.min.js`,`${gt}/plugins/autoplay/lg-autoplay.min.js`,`${gt}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${gt}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=o,h=function(b){const C=this,k=window,{plugins:M,cdnScript:E,cdnStyle:L,inline:O,lgLicenseKey:Q,...P}=b||{},q=oe=>isNaN(oe)?void 0:parseInt(oe,10),je=()=>{var fn;const oe={...P,licenseKey:Q,speed:q(P.speed),startAnimationDuration:q(P.startAnimationDuration),thumbMargin:q(P.thumbMargin),thumbWidth:q(P.thumbWidth),slideShowInterval:q(P.slideShowInterval),scale:q(P.scale),enableZoomAfter:q(P.enableZoomAfter),plugins:(M||[]).map(un=>k[un])};O&&(oe.container=C,oe.closable=!1);const ri=(fn=k.lightGallery)==null?void 0:fn.call(k,C,oe);O&&ri.openGallery()};if(k.lightGallery)je();else{const{head:oe}=document,ri=Array.isArray(E)?[...E]:[E],fn=Array.isArray(L)?[...L]:[L],un=_e=>{if(_e.length){const Ne=document.createElement("link");Ne.href=_e.shift(),Ne.rel="stylesheet",oe.appendChild(Ne),un(_e)}},Tr=_e=>{if(_e.length){const Ne=document.createElement("script");Ne.src=_e.shift(),Ne.onerror=Ne.onload=Tr.bind(null,_e),oe.appendChild(Ne)}else je()};un(fn),Tr(ri)}},d=b=>{const C=b.getTrait(En);if(!a||!C)return;const{toolbar:k}=b,M={id:En,label:a,command:()=>setTimeout(()=>C.runCommand(),100)};!k.find(L=>L.id===M.id)&&(k==null||k.unshift(M))};let f=[];const p=o.plugins||[],u=Lt(fc),m=p.includes(Br)?Lt(uc):li,g=p.includes(Lr)?Lt(pc):li,y=p.includes(Hr)?Lt(mc):li;i.addType(Ze,{block:l&&{label:r,media:Qe.gallery,category:"Extra",select:!0,...o.block},isComponent:b=>si(b,vn),extendFn:["init","initToolbar"],model:{defaults:{name:r,icon:Qe.gallery,draggable:(b,C)=>!C.is(Ze),attributes:{[vn]:!0},components:{type:Vr},script:h,selector:"",exThumbImage:"",cdnScript:o.cdnScript,cdnStyle:o.cdnStyle,plugins:o.plugins,lgLicenseKey:o.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...u.propKeys,...m.propKeys,...g.propKeys,...y.propKeys],...u.props,...m.props,...g.props,...y.props,traits:[...u.traits,...m.traits,...g.traits,...y.traits]},init(){ai(this,["thumbnail"]),ai(this,["autoplay"]),ai(this,["zoom"])},initToolbar(){d(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){const b=i.events.scriptUnmount;b&&this.listenTo(this.model,b,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const b=this.getLightGallery();b==null||b.destroy()},disableLgInCanvas(){const b=this.getLightGallery();b.lgOpened=!0},isInlineGallery(){var C;const b=this.getLightGallery();return((C=b==null?void 0:b.settings)==null?void 0:C.container)===this.el},onLgInit(b){this.el.__lg=b.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:b}=this,{Canvas:C}=b,k=this.getLightGallery();f=C.getSpots(),setTimeout(()=>C.removeSpots()),k.__lgOpened=!0},onLgClose(){const b=this.getLightGallery();f.forEach(C=>this.em.Canvas.addSpot(C.attributes)),f=[],b.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(b){const C=this.getLightGallery();if(C.__lgOpened)return C.closeGallery(!0);C.lgOpened=!1,C.openGallery(b)}}});const S=Lt(gc);i.addType(Vr,{isComponent:b=>si(b,Pr)||b.tagName==="A"&&si(b.parentElement,vn),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:s,icon:Qe.galleryItem,attributes:{[Pr]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...S.props,traits:[...S.traits]},init(){const b=[Ee].map(C=>`change:${C}`).join(" ");this.initSourceType(),this.on(b,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),dc(this,Ee,this.triggerGalleryUpdate)},initToolbar(){d(this)},initScriptUpdate(){const b=[Ao.name].map(C=>`change:attributes:${C}`).join(" ");this.on(b,this.triggerGalleryUpdate)},triggerGalleryUpdate(...b){var C;(C=this.closestType(Ze))==null||C.__scriptPropsChange(...b)},updateTraits(b={}){const{changed:C}=this,{init:k}=b;if(C[Ee]||k){Ri(this,Ee);const M=this.getTrait(Ee).getValue();if(M===xt.image){this.removeAttributes([Dn.name,Pi.name,gn]);const E=this.getTrait(Vi.name);E.setValue(E.getValue()||c)}else M===xt.video?this.removeAttributes([gn]):M===xt.external&&this.addAttributes({[gn]:!0})}},initSourceType(){const b=this.getAttributes({noClass:!0,noStyle:!0});b[gn]?this.set(Ee,xt.external):(b[Dn.name]||b[Pi.name])&&this.set(Ee,xt.video)}}}),zt({editor:n,licenseKey:o.licenseKey,pluginName:yc,cleanup:()=>{t.remove(Ze),i.removeType(Ze)}})},Cc=Pt(xc);function $(n){this.content=n}$.prototype={constructor:$,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var i=t&&t!=n?this.remove(t):this,r=i.find(n),s=i.content.slice();return r==-1?s.push(t||n,e):(s[r+1]=e,t&&(s[r]=t)),new $(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new $(t)},addToStart:function(n,e){return new $([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new $(t)},addBefore:function(n,e,t){var i=this.remove(e),r=i.content.slice(),s=i.find(n);return r.splice(s==-1?r.length:s,0,e,t),new $(r)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=$.from(n),n.size?new $(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=$.from(n),n.size?new $(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=$.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};$.from=function(n){if(n instanceof $)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new $(e)};function No(n,e,t){for(let i=0;;i++){if(i==n.childCount||i==e.childCount)return n.childCount==e.childCount?null:t;let r=n.child(i),s=e.child(i);if(r==s){t+=r.nodeSize;continue}if(!r.sameMarkup(s))return t;if(r.isText&&r.text!=s.text){for(let o=0;r.text[o]==s.text[o];o++)t++;return t}if(r.content.size||s.content.size){let o=No(r.content,s.content,t+1);if(o!=null)return o}t+=r.nodeSize}}function Eo(n,e,t,i){for(let r=n.childCount,s=e.childCount;;){if(r==0||s==0)return r==s?null:{a:t,b:i};let o=n.child(--r),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,i-=a;continue}if(!o.sameMarkup(l))return{a:t,b:i};if(o.isText&&o.text!=l.text){let c=0,h=Math.min(o.text.length,l.text.length);for(;c<h&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,i--;return{a:t,b:i}}if(o.content.size||l.content.size){let c=Eo(o.content,l.content,t-1,i-1);if(c)return c}t-=a,i-=a}}class x{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let i=0;i<e.length;i++)this.size+=e[i].nodeSize}nodesBetween(e,t,i,r=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&i(a,r+l,s||null,o)!==!1&&a.content.size){let h=l+1;a.nodesBetween(Math.max(0,e-h),Math.min(a.content.size,t-h),i,r+h)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,i,r){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?r?typeof r=="function"?r(l):r:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&i&&(o?o=!1:s+=i),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,i=e.firstChild,r=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(i)&&(r[r.length-1]=t.withText(t.text+i.text),s=1);s<e.content.length;s++)r.push(e.content[s]);return new x(r,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let i=[],r=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),i.push(l),r+=l.nodeSize),o=a}return new x(i,r)}cutByIndex(e,t){return e==t?x.empty:e==0&&t==this.content.length?this:new x(this.content.slice(e,t))}replaceChild(e,t){let i=this.content[e];if(i==t)return this;let r=this.content.slice(),s=this.size+t.nodeSize-i.nodeSize;return r[e]=t,new x(r,s)}addToStart(e){return new x([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new x(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,i=0;t<this.content.length;t++){let r=this.content[t];e(r,i,t),i+=r.nodeSize}}findDiffStart(e,t=0){return No(this,e,t)}findDiffEnd(e,t=this.size,i=e.size){return Eo(this,e,t,i)}findIndex(e,t=-1){if(e==0)return yn(0,e);if(e==this.size)return yn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let i=0,r=0;;i++){let s=this.child(i),o=r+s.nodeSize;if(o>=e)return o==e||t>0?yn(i+1,o):yn(i,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return x.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new x(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return x.empty;let t,i=0;for(let r=0;r<e.length;r++){let s=e[r];i+=s.nodeSize,r&&s.isText&&e[r-1].sameMarkup(s)?(t||(t=e.slice(0,r)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new x(t||e,i)}static from(e){if(!e)return x.empty;if(e instanceof x)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new x([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}x.empty=new x([],0);const ci={index:0,offset:0};function yn(n,e){return ci.index=n,ci.offset=e,ci}function In(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!In(n[i],e[i]))return!1}else{for(let i in n)if(!(i in e)||!In(n[i],e[i]))return!1;for(let i in e)if(!(i in n))return!1}return!0}class I{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,i=!1;for(let r=0;r<e.length;r++){let s=e[r];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,r));else{if(s.type.excludes(this.type))return e;!i&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),i=!0),t&&t.push(s)}}return t||(t=e.slice()),i||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&In(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let i=e.marks[t.type];if(!i)throw new RangeError(`There is no mark type ${t.type} in this schema`);let r=i.create(t.attrs);return i.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!e[i].eq(t[i]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return I.none;if(e instanceof I)return[e];let t=e.slice();return t.sort((i,r)=>i.type.rank-r.type.rank),t}}I.none=[];class Rn extends Error{}class w{constructor(e,t,i){this.content=e,this.openStart=t,this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let i=Io(this.content,e+this.openStart,t);return i&&new w(i,this.openStart,this.openEnd)}removeBetween(e,t){return new w(Do(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return w.empty;let i=t.openStart||0,r=t.openEnd||0;if(typeof i!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new w(x.fromJSON(e,t.content),i,r)}static maxOpen(e,t=!0){let i=0,r=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)i++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)r++;return new w(e,i,r)}}w.empty=new w(x.empty,0,0);function Do(n,e,t){let{index:i,offset:r}=n.findIndex(e),s=n.maybeChild(i),{index:o,offset:l}=n.findIndex(t);if(r==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(i!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(i,s.copy(Do(s.content,e-r-1,t-r-1)))}function Io(n,e,t,i){let{index:r,offset:s}=n.findIndex(e),o=n.maybeChild(r);if(s==e||o.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=Io(o.content,e-s-1,t);return l&&n.replaceChild(r,o.copy(l))}function wc(n,e,t){if(t.openStart>n.depth)throw new Rn("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Rn("Inconsistent open depths");return Ro(n,e,t,0)}function Ro(n,e,t,i){let r=n.index(i),s=n.node(i);if(r==e.index(i)&&i<n.depth-t.openStart){let o=Ro(n,e,t,i+1);return s.copy(s.content.replaceChild(r,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==i&&e.depth==i){let o=n.parent,l=o.content;return rt(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Sc(t,n);return rt(s,Po(n,o,l,e,i))}else return rt(s,Vn(n,e,i))}function Vo(n,e){if(!e.type.compatibleContent(n.type))throw new Rn("Cannot join "+e.type.name+" onto "+n.type.name)}function zi(n,e,t){let i=n.node(t);return Vo(i,e.node(t)),i}function it(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function jt(n,e,t,i){let r=(e||n).node(t),s=0,o=e?e.index(t):r.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(it(n.nodeAfter,i),s++));for(let l=s;l<o;l++)it(r.child(l),i);e&&e.depth==t&&e.textOffset&&it(e.nodeBefore,i)}function rt(n,e){return n.type.checkContent(e),n.copy(e)}function Po(n,e,t,i,r){let s=n.depth>r&&zi(n,e,r+1),o=i.depth>r&&zi(t,i,r+1),l=[];return jt(null,n,r,l),s&&o&&e.index(r)==t.index(r)?(Vo(s,o),it(rt(s,Po(n,e,t,i,r+1)),l)):(s&&it(rt(s,Vn(n,e,r+1)),l),jt(e,t,r,l),o&&it(rt(o,Vn(t,i,r+1)),l)),jt(i,null,r,l),new x(l)}function Vn(n,e,t){let i=[];if(jt(null,n,t,i),n.depth>t){let r=zi(n,e,t+1);it(rt(r,Vn(n,e,t+1)),i)}return jt(e,null,t,i),new x(i)}function Sc(n,e){let t=e.depth-n.openStart,r=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)r=e.node(s).copy(x.from(r));return{start:r.resolveNoCache(n.openStart+t),end:r.resolveNoCache(r.content.size-n.openEnd-t)}}class Yt{constructor(e,t,i){this.pos=e,this.path=t,this.parentOffset=i,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let i=this.pos-this.path[this.path.length-1],r=e.child(t);return i?e.child(t).cut(i):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let i=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)r+=i.child(s).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return I.none;if(this.textOffset)return e.child(t).marks;let i=e.maybeChild(t-1),r=e.maybeChild(t);if(!i){let l=i;i=r,r=l}let s=i.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!r||!s[o].isInSet(r.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let i=t.marks,r=e.parent.maybeChild(e.index());for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!r||!i[s].isInSet(r.marks))&&(i=i[s--].removeFromSet(i));return i}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let i=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);i>=0;i--)if(e.pos<=this.end(i)&&(!t||t(this.node(i))))return new Pn(this,e,i);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let i=[],r=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(i.push(o,l,r+a),!c||(o=o.child(l),o.isText))break;s=c-1,r+=a+1}return new Yt(t,i,s)}static resolveCached(e,t){let i=Fr.get(e);if(i)for(let s=0;s<i.elts.length;s++){let o=i.elts[s];if(o.pos==t)return o}else Fr.set(e,i=new kc);let r=i.elts[i.i]=Yt.resolve(e,t);return i.i=(i.i+1)%vc,r}}class kc{constructor(){this.elts=[],this.i=0}}const vc=12,Fr=new WeakMap;class Pn{constructor(e,t,i){this.$from=e,this.$to=t,this.depth=i}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Mc=Object.create(null);let st=class Bi{constructor(e,t,i,r=I.none){this.type=e,this.attrs=t,this.marks=r,this.content=i||x.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,i,r=0){this.content.nodesBetween(e,t,i,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,i,r){return this.content.textBetween(e,t,i,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,i){return this.type==e&&In(this.attrs,t||e.defaultAttrs||Mc)&&I.sameSet(this.marks,i||I.none)}copy(e=null){return e==this.content?this:new Bi(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Bi(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,i=!1){if(e==t)return w.empty;let r=this.resolve(e),s=this.resolve(t),o=i?0:r.sharedDepth(t),l=r.start(o),c=r.node(o).content.cut(r.pos-l,s.pos-l);return new w(c,r.depth-o,s.depth-o)}replace(e,t,i){return wc(this.resolve(e),this.resolve(t),i)}nodeAt(e){for(let t=this;;){let{index:i,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(i),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:i}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:i}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:i}=this.content.findIndex(e);if(i<e)return{node:this.content.child(t),index:t,offset:i};let r=this.content.child(t-1);return{node:r,index:t-1,offset:i-r.nodeSize}}resolve(e){return Yt.resolveCached(this,e)}resolveNoCache(e){return Yt.resolve(this,e)}rangeHasMark(e,t,i){let r=!1;return t>e&&this.nodesBetween(e,t,s=>(i.isInSet(s.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),zo(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,i=x.empty,r=0,s=i.childCount){let o=this.contentMatchAt(e).matchFragment(i,r,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=r;a<s;a++)if(!this.type.allowsMarks(i.child(a).marks))return!1;return!0}canReplaceWith(e,t,i,r){if(r&&!this.type.allowsMarks(r))return!1;let s=this.contentMatchAt(e).matchType(i),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=I.none;for(let t=0;t<this.marks.length;t++){let i=this.marks[t];i.type.checkAttrs(i.attrs),e=i.addToSet(e)}if(!I.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let i;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,i)}let r=x.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,r,i);return s.type.checkAttrs(s.attrs),s}};st.prototype.text=void 0;class zn extends st{constructor(e,t,i,r){if(super(e,t,null,r),!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):zo(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new zn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new zn(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function zo(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class ct{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let i=new Tc(e,t);if(i.next==null)return ct.empty;let r=Bo(i);i.next&&i.err("Unexpected trailing text");let s=Rc(Ic(r));return Vc(s,i),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,i=e.childCount){let r=this;for(let s=t;r&&s<i;s++)r=r.matchType(e.child(s).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let i=0;i<e.next.length;i++)if(this.next[t].type==e.next[i].type)return!0;return!1}fillBefore(e,t=!1,i=0){let r=[this];function s(o,l){let a=o.matchFragment(e,i);if(a&&(!t||a.validEnd))return x.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:h,next:d}=o.next[c];if(!(h.isText||h.hasRequiredAttrs())&&r.indexOf(d)==-1){r.push(d);let f=s(d,l.concat(h));if(f)return f}}return null}return s(this,[])}findWrapping(e){for(let i=0;i<this.wrapCache.length;i+=2)if(this.wrapCache[i]==e)return this.wrapCache[i+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),i=[{match:this,type:null,via:null}];for(;i.length;){let r=i.shift(),s=r.match;if(s.matchType(e)){let o=[];for(let l=r;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!r.type||a.validEnd)&&(i.push({match:l.contentMatch,type:l,via:r}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(i){e.push(i);for(let r=0;r<i.next.length;r++)e.indexOf(i.next[r].next)==-1&&t(i.next[r].next)}return t(this),e.map((i,r)=>{let s=r+(i.validEnd?"*":" ")+" ";for(let o=0;o<i.next.length;o++)s+=(o?", ":"")+i.next[o].type.name+"->"+e.indexOf(i.next[o].next);return s}).join(`
75
- `)}}ct.empty=new ct(!0);class Tc{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Bo(n){let e=[];do e.push(Oc(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Oc(n){let e=[];do e.push(Ac(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Ac(n){let e=Dc(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Nc(n,e);else break;return e}function $r(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Nc(n,e){let t=$r(n),i=t;return n.eat(",")&&(n.next!="}"?i=$r(n):i=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:i,expr:e}}function Ec(n,e){let t=n.nodeTypes,i=t[e];if(i)return[i];let r=[];for(let s in t){let o=t[s];o.isInGroup(e)&&r.push(o)}return r.length==0&&n.err("No node type or group '"+e+"' found"),r}function Dc(n){if(n.eat("(")){let e=Bo(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Ec(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Ic(n){let e=[[]];return r(s(n,0),t()),e;function t(){return e.push([])-1}function i(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function r(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;r(c,l=t())}else if(o.type=="star"){let a=t();return i(l,a),r(s(o.expr,a),a),[i(a)]}else if(o.type=="plus"){let a=t();return r(s(o.expr,l),a),r(s(o.expr,a),a),[i(a)]}else{if(o.type=="opt")return[i(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let h=t();r(s(o.expr,a),h),a=h}if(o.max==-1)r(s(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let h=t();i(a,h),r(s(o.expr,a),h),a=h}return[i(a)]}else{if(o.type=="name")return[i(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Lo(n,e){return e-n}function Wr(n,e){let t=[];return i(e),t.sort(Lo);function i(r){let s=n[r];if(s.length==1&&!s[0].term)return i(s[0].to);t.push(r);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&i(a)}}}function Rc(n){let e=Object.create(null);return t(Wr(n,0));function t(i){let r=[];i.forEach(o=>{n[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let h=0;h<r.length;h++)r[h][0]==l&&(c=r[h][1]);Wr(n,a).forEach(h=>{c||r.push([l,c=[]]),c.indexOf(h)==-1&&c.push(h)})})});let s=e[i.join(",")]=new ct(i.indexOf(n.length-1)>-1);for(let o=0;o<r.length;o++){let l=r[o][1].sort(Lo);s.next.push({type:r[o][0],next:e[l.join(",")]||t(l)})}return s}}function Vc(n,e){for(let t=0,i=[n];t<i.length;t++){let r=i[t],s=!r.validEnd,o=[];for(let l=0;l<r.next.length;l++){let{type:a,next:c}=r.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),i.indexOf(c)==-1&&i.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ho(n){let e=Object.create(null);for(let t in n){let i=n[t];if(!i.hasDefault)return null;e[t]=i.default}return e}function Fo(n,e){let t=Object.create(null);for(let i in n){let r=e&&e[i];if(r===void 0){let s=n[i];if(s.hasDefault)r=s.default;else throw new RangeError("No value supplied for attribute "+i)}t[i]=r}return t}function $o(n,e,t,i){for(let r in e)if(!(r in n))throw new RangeError(`Unsupported attribute ${r} for ${t} of type ${r}`);for(let r in n){let s=n[r];s.validate&&s.validate(e[r])}}function Wo(n,e){let t=Object.create(null);if(e)for(let i in e)t[i]=new zc(n,i,e[i]);return t}let Jr=class Jo{constructor(e,t,i){this.name=e,this.schema=t,this.spec=i,this.markSet=null,this.groups=i.group?i.group.split(" "):[],this.attrs=Wo(e,i.attrs),this.defaultAttrs=Ho(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(i.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ct.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Fo(this.attrs,e)}create(e=null,t,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new st(this,this.computeAttrs(e),x.from(t),I.setFrom(i))}createChecked(e=null,t,i){return t=x.from(t),this.checkContent(t),new st(this,this.computeAttrs(e),t,I.setFrom(i))}createAndFill(e=null,t,i){if(e=this.computeAttrs(e),t=x.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let r=this.contentMatch.matchFragment(t),s=r&&r.fillBefore(x.empty,!0);return s?new st(this,e,t.append(s),I.setFrom(i)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let i=0;i<e.childCount;i++)if(!this.allowsMarks(e.child(i).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){$o(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let i=0;i<e.length;i++)this.allowsMarkType(e[i].type)?t&&t.push(e[i]):t||(t=e.slice(0,i));return t?t.length?t:I.none:e}static compile(e,t){let i=Object.create(null);e.forEach((s,o)=>i[s]=new Jo(s,t,o));let r=t.spec.topNode||"doc";if(!i[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!i.text)throw new RangeError("Every schema needs a 'text' type");for(let s in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}};function Pc(n,e,t){let i=t.split("|");return r=>{let s=r===null?"null":typeof r;if(i.indexOf(s)<0)throw new RangeError(`Expected value of type ${i} for attribute ${e} on type ${n}, got ${s}`)}}class zc{constructor(e,t,i){this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default"),this.default=i.default,this.validate=typeof i.validate=="string"?Pc(e,t,i.validate):i.validate}get isRequired(){return!this.hasDefault}}class Un{constructor(e,t,i,r){this.name=e,this.rank=t,this.schema=i,this.spec=r,this.attrs=Wo(e,r.attrs),this.excluded=null;let s=Ho(this.attrs);this.instance=s?new I(this,s):null}create(e=null){return!e&&this.instance?this.instance:new I(this,Fo(this.attrs,e))}static compile(e,t){let i=Object.create(null),r=0;return e.forEach((s,o)=>i[s]=new Un(s,r++,t,o)),i}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){$o(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Bc{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let r in e)t[r]=e[r];t.nodes=$.from(e.nodes),t.marks=$.from(e.marks||{}),this.nodes=Jr.compile(this.spec.nodes,this),this.marks=Un.compile(this.spec.marks,this);let i=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let s=this.nodes[r],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=i[o]||(i[o]=ct.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?Kr(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let r in this.marks){let s=this.marks[r],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:Kr(this,o.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,i,r){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Jr){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,i,r)}text(e,t){let i=this.nodes.text;return new zn(i,i.defaultAttrs,e,I.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return st.fromJSON(this,e)}markFromJSON(e){return I.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Kr(n,e){let t=[];for(let i=0;i<e.length;i++){let r=e[i],s=n.marks[r],o=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(r=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(r)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[i]+"'")}return t}function Lc(n){return n.tag!=null}function Hc(n){return n.style!=null}class Nt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let i=this.matchedStyles=[];t.forEach(r=>{if(Lc(r))this.tags.push(r);else if(Hc(r)){let s=/[^=]*/.exec(r.style)[0];i.indexOf(s)<0&&i.push(s),this.styles.push(r)}}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let s=e.nodes[r.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let i=new jr(this,t,!1);return i.addAll(e,I.none,t.from,t.to),i.finish()}parseSlice(e,t={}){let i=new jr(this,t,!0);return i.addAll(e,I.none,t.from,t.to),w.maxOpen(i.finish())}matchTag(e,t,i){for(let r=i?this.tags.indexOf(i)+1:0;r<this.tags.length;r++){let s=this.tags[r];if(Wc(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,i,r){for(let s=r?this.styles.indexOf(r)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!i.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function i(r){let s=r.priority==null?50:r.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,r)}for(let r in e.marks){let s=e.marks[r].spec.parseDOM;s&&s.forEach(o=>{i(o=_r(o)),o.mark||o.ignore||o.clearMark||(o.mark=r)})}for(let r in e.nodes){let s=e.nodes[r].spec.parseDOM;s&&s.forEach(o=>{i(o=_r(o)),o.node||o.ignore||o.mark||(o.node=r)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Nt(e,Nt.schemaRules(e)))}}const Ko={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Fc={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},qo={ol:!0,ul:!0},Bn=1,Ln=2,_t=4;function qr(n,e,t){return e!=null?(e?Bn:0)|(e==="full"?Ln:0):n&&n.whitespace=="pre"?Bn|Ln:t&~_t}class bn{constructor(e,t,i,r,s,o){this.type=e,this.attrs=t,this.marks=i,this.solid=r,this.options=o,this.content=[],this.activeMarks=I.none,this.match=s||(o&_t?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(x.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let i=this.type.contentMatch,r;return(r=i.findWrapping(e.type))?(this.match=i,r):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Bn)){let i=this.content[this.content.length-1],r;if(i&&i.isText&&(r=/[ \t\r\n\u000c]+$/.exec(i.text))){let s=i;i.text.length==r[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-r[0].length))}}let t=x.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(x.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ko.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class jr{constructor(e,t,i){this.parser=e,this.options=t,this.isOpen=i,this.open=0;let r=t.topNode,s,o=qr(null,t.preserveWhitespace,0)|(i?_t:0);r?s=new bn(r.type,r.attrs,I.none,!0,t.topMatch||r.type.contentMatch,o):i?s=new bn(null,null,I.none,!0,null,o):s=new bn(e.schema.topNodeType,null,I.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let i=e.nodeValue,r=this.top;if(r.options&Ln||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(i)){if(r.options&Bn)r.options&Ln?i=i.replace(/\r\n?/g,`
76
- `):i=i.replace(/\r?\n|\r/g," ");else if(i=i.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(i)&&this.open==this.nodes.length-1){let s=r.content[r.content.length-1],o=e.previousSibling;(!s||o&&o.nodeName=="BR"||s.isText&&/[ \t\r\n\u000c]$/.test(s.text))&&(i=i.slice(1))}i&&this.insertNode(this.parser.schema.text(i),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,i){let r=e.nodeName.toLowerCase(),s;qo.hasOwnProperty(r)&&this.parser.normalizeLists&&$c(e);let o=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(s=this.parser.matchTag(e,this,i));if(o?o.ignore:Fc.hasOwnProperty(r))this.findInside(e),this.ignoreFallback(e,t);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(e=o.skip);let l,a=this.top,c=this.needsBlock;if(Ko.hasOwnProperty(r))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),l=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);return}let h=o&&o.skip?t:this.readStyles(e,t);h&&this.addAll(e,h),l&&this.sync(a),this.needsBlock=c}else{let l=this.readStyles(e,t);l&&this.addElementByRule(e,o,l,o.consuming===!1?s:void 0)}}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
77
- `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let i=e.style;if(i&&i.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let s=this.parser.matchedStyles[r],o=i.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,i,r){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),i)||this.leafFallback(e,i);else{let a=this.enter(o,t.attrs||null,i,t.preserveWhitespace);a&&(s=!0,i=a)}else{let a=this.parser.schema.marks[t.mark];i=i.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,i,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,i));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,i),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,i,r){let s=i||0;for(let o=i?e.childNodes[i]:e.firstChild,l=r==null?null:e.childNodes[r];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t){let i,r;for(let s=this.open;s>=0;s--){let o=this.nodes[s],l=o.findWrapping(e);if(l&&(!i||i.length>l.length)&&(i=l,r=o,!l.length)||o.solid)break}if(!i)return null;this.sync(r);for(let s=0;s<i.length;s++)t=this.enterInner(i[s],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let r=this.textblockFromContext();r&&(t=this.enterInner(r,null,t))}let i=this.findPlace(e,t);if(i){this.closeExtra();let r=this.top;r.match&&(r.match=r.match.matchType(e.type));let s=I.none;for(let o of i.concat(e.marks))(r.type?r.type.allowsMarkType(o.type):Gr(o.type,e.type))&&(s=o.addToSet(s));return r.content.push(e.mark(s)),!0}return!1}enter(e,t,i,r){let s=this.findPlace(e.create(t),i);return s&&(s=this.enterInner(e,t,i,!0,r)),s}enterInner(e,t,i,r=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=qr(e,s,o.options);o.options&_t&&o.content.length==0&&(l|=_t);let a=I.none;return i=i.filter(c=>(o.type?o.type.allowsMarkType(c.type):Gr(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new bn(e,t,a,r,null,l)),this.open++,i}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let i=this.nodes[t].content;for(let r=i.length-1;r>=0;r--)e+=i[r].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let i=0;i<this.find.length;i++)this.find[i].node==e&&this.find[i].offset==t&&(this.find[i].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,i){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(i?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),i=this.options.context,r=!this.isOpen&&(!i||i.parent.type==this.nodes[0].type),s=-(i?i.depth+1:0)+(r?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let h=a>0||a==0&&r?this.nodes[a].type:i&&a>=s?i.node(a-s).type:null;if(!h||h.name!=c&&!h.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(i&&i.isTextblock&&i.defaultAttrs)return i}for(let t in this.parser.schema.nodes){let i=this.parser.schema.nodes[t];if(i.isTextblock&&i.defaultAttrs)return i}}}function $c(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let i=e.nodeType==1?e.nodeName.toLowerCase():null;i&&qo.hasOwnProperty(i)&&t?(t.appendChild(e),e=t):i=="li"?t=e:i&&(t=null)}}function Wc(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function _r(n){let e={};for(let t in n)e[t]=n[t];return e}function Gr(n,e){let t=e.schema.nodes;for(let i in t){let r=t[i];if(!r.allowsMarkType(n))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:h}=l.edge(a);if(c==e||s.indexOf(h)<0&&o(h))return!0}};if(o(r.contentMatch))return!0}}class ft{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},i){i||(i=hi(t).createDocumentFragment());let r=i,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)r=s.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],h=this.serializeMark(c,o.isInline,t);h&&(s.push([c,r]),r.appendChild(h.dom),r=h.contentDOM||h.dom)}}r.appendChild(this.serializeNodeInner(o,t))}),i}serializeNodeInner(e,t){let{dom:i,contentDOM:r}=Mn(hi(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return i}serializeNode(e,t={}){let i=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let s=this.serializeMark(e.marks[r],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(i),i=s.dom)}return i}serializeMark(e,t,i={}){let r=this.marks[e.type.name];return r&&Mn(hi(i),r(e,t),null,e.attrs)}static renderSpec(e,t,i=null,r){return Mn(e,t,i,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ft(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Ur(e.nodes);return t.text||(t.text=i=>i.text),t}static marksFromSchema(e){return Ur(e.marks)}}function Ur(n){let e={};for(let t in n){let i=n[t].spec.toDOM;i&&(e[t]=i)}return e}function hi(n){return n.document||window.document}const Zr=new WeakMap;function Jc(n){let e=Zr.get(n);return e===void 0&&Zr.set(n,e=Kc(n)),e}function Kc(n){let e=null;function t(i){if(i&&typeof i=="object")if(Array.isArray(i))if(typeof i[0]=="string")e||(e=[]),e.push(i);else for(let r=0;r<i.length;r++)t(i[r]);else for(let r in i)t(i[r])}return t(n),e}function Mn(n,e,t,i){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let r=e[0],s;if(typeof r!="string")throw new RangeError("Invalid array passed to renderSpec");if(i&&(s=Jc(i))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=r.indexOf(" ");o>0&&(t=r.slice(0,o),r=r.slice(o+1));let l,a=t?n.createElementNS(t,r):n.createElement(r),c=e[1],h=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){h=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):a.setAttribute(d,c[d])}}for(let d=h;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:p,contentDOM:u}=Mn(n,f,t,i);if(a.appendChild(p),u){if(l)throw new RangeError("Multiple content holes");l=u}}}return{dom:a,contentDOM:l}}const jo=65535,_o=Math.pow(2,16);function qc(n,e){return n+e*_o}function Xr(n){return n&jo}function jc(n){return(n-(n&jo))/_o}const Go=1,Uo=2,Tn=4,Zo=8;class Li{constructor(e,t,i){this.pos=e,this.delInfo=t,this.recover=i}get deleted(){return(this.delInfo&Zo)>0}get deletedBefore(){return(this.delInfo&(Go|Tn))>0}get deletedAfter(){return(this.delInfo&(Uo|Tn))>0}get deletedAcross(){return(this.delInfo&Tn)>0}}class ie{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&ie.empty)return ie.empty}recover(e){let t=0,i=Xr(e);if(!this.inverted)for(let r=0;r<i;r++)t+=this.ranges[r*3+2]-this.ranges[r*3+1];return this.ranges[i*3]+t+jc(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,i){let r=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],h=this.ranges[l+o],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,p=a+r+(f<0?0:h);if(i)return p;let u=e==(t<0?a:d)?null:qc(l/3,e-a),m=e==a?Uo:e==d?Go:Tn;return(t<0?e!=a:e!=d)&&(m|=Zo),new Li(p,m,u)}r+=h-c}return i?e+r:new Li(e+r,0,null)}touches(e,t){let i=0,r=Xr(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+s],h=a+c;if(e<=h&&l==r*3)return!0;i+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,i=this.inverted?1:2;for(let r=0,s=0;r<this.ranges.length;r+=3){let o=this.ranges[r],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[r+t],h=this.ranges[r+i];e(l,l+c,a,a+h),s+=h-c}}invert(){return new ie(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ie.empty:new ie(e<0?[0,-e,0]:[0,0,e])}}ie.empty=new ie([]);class vt{constructor(e=[],t,i=0,r=e.length){this.maps=e,this.mirror=t,this.from=i,this.to=r}slice(e=0,t=this.maps.length){return new vt(this.maps,this.mirror,e,t)}copy(){return new vt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,i=this.maps.length;t<e.maps.length;t++){let r=e.getMirror(t);this.appendMap(e.maps[t],r!=null&&r<t?i+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,i=this.maps.length+e.maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e.maps[t].invert(),r!=null&&r>t?i-r-1:void 0)}}invert(){let e=new vt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let i=this.from;i<this.to;i++)e=this.maps[i].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,i){let r=0;for(let s=this.from;s<this.to;s++){let o=this.maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this.maps[a].recover(l.recover);continue}}r|=l.delInfo,e=l.pos}return i?e:new Li(e,r,null)}}const di=Object.create(null);class U{getMap(){return ie.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let i=di[t.stepType];if(!i)throw new RangeError(`No step type ${t.stepType} defined`);return i.fromJSON(e,t)}static jsonID(e,t){if(e in di)throw new RangeError("Duplicate use of step JSON ID "+e);return di[e]=t,t.prototype.jsonID=e,t}}class B{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new B(e,null)}static fail(e){return new B(null,e)}static fromReplace(e,t,i,r){try{return B.ok(e.replace(t,i,r))}catch(s){if(s instanceof Rn)return B.fail(s.message);throw s}}}function ar(n,e,t){let i=[];for(let r=0;r<n.childCount;r++){let s=n.child(r);s.content.size&&(s=s.copy(ar(s.content,e,s))),s.isInline&&(s=e(s,t,r)),i.push(s)}return x.fromArray(i)}class Be extends U{constructor(e,t,i){super(),this.from=e,this.to=t,this.mark=i}apply(e){let t=e.slice(this.from,this.to),i=e.resolve(this.from),r=i.node(i.sharedDepth(this.to)),s=new w(ar(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),r),t.openStart,t.openEnd);return B.fromReplace(e,this.from,this.to,s)}invert(){return new ge(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deleted&&i.deleted||t.pos>=i.pos?null:new Be(t.pos,i.pos,this.mark)}merge(e){return e instanceof Be&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Be(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Be(t.from,t.to,e.markFromJSON(t.mark))}}U.jsonID("addMark",Be);class ge extends U{constructor(e,t,i){super(),this.from=e,this.to=t,this.mark=i}apply(e){let t=e.slice(this.from,this.to),i=new w(ar(t.content,r=>r.mark(this.mark.removeFromSet(r.marks)),e),t.openStart,t.openEnd);return B.fromReplace(e,this.from,this.to,i)}invert(){return new Be(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deleted&&i.deleted||t.pos>=i.pos?null:new ge(t.pos,i.pos,this.mark)}merge(e){return e instanceof ge&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ge(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ge(t.from,t.to,e.markFromJSON(t.mark))}}U.jsonID("removeMark",ge);class Le extends U{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return B.fail("No node at mark step's position");let i=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return B.fromReplace(e,this.pos,this.pos+1,new w(x.from(i),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let i=this.mark.addToSet(t.marks);if(i.length==t.marks.length){for(let r=0;r<t.marks.length;r++)if(!t.marks[r].isInSet(i))return new Le(this.pos,t.marks[r]);return new Le(this.pos,this.mark)}}return new Et(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Le(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Le(t.pos,e.markFromJSON(t.mark))}}U.jsonID("addNodeMark",Le);class Et extends U{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return B.fail("No node at mark step's position");let i=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return B.fromReplace(e,this.pos,this.pos+1,new w(x.from(i),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Le(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Et(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Et(t.pos,e.markFromJSON(t.mark))}}U.jsonID("removeNodeMark",Et);class _ extends U{constructor(e,t,i,r=!1){super(),this.from=e,this.to=t,this.slice=i,this.structure=r}apply(e){return this.structure&&Hi(e,this.from,this.to)?B.fail("Structure replace would overwrite content"):B.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ie([this.from,this.to-this.from,this.slice.size])}invert(e){return new _(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deletedAcross&&i.deletedAcross?null:new _(t.pos,Math.max(t.pos,i.pos),this.slice)}merge(e){if(!(e instanceof _)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?w.empty:new w(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new _(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?w.empty:new w(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new _(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new _(t.from,t.to,w.fromJSON(e,t.slice),!!t.structure)}}U.jsonID("replace",_);class K extends U{constructor(e,t,i,r,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=i,this.gapTo=r,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Hi(e,this.from,this.gapFrom)||Hi(e,this.gapTo,this.to)))return B.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return B.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,t.content);return i?B.fromReplace(e,this.from,this.to,i):B.fail("Content does not fit in gap")}getMap(){return new ie([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new K(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?i.pos:e.map(this.gapTo,1);return t.deletedAcross&&i.deletedAcross||r<t.pos||s>i.pos?null:new K(t.pos,i.pos,r,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new K(t.from,t.to,t.gapFrom,t.gapTo,w.fromJSON(e,t.slice),t.insert,!!t.structure)}}U.jsonID("replaceAround",K);function Hi(n,e,t){let i=n.resolve(e),r=t-e,s=i.depth;for(;r>0&&s>0&&i.indexAfter(s)==i.node(s).childCount;)s--,r--;if(r>0){let o=i.node(s).maybeChild(i.indexAfter(s));for(;r>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,r--}}return!1}function _c(n,e,t,i){let r=[],s=[],o,l;n.doc.nodesBetween(e,t,(a,c,h)=>{if(!a.isInline)return;let d=a.marks;if(!i.isInSet(d)&&h.type.allowsMarkType(i.type)){let f=Math.max(c,e),p=Math.min(c+a.nodeSize,t),u=i.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(u)||(o&&o.to==f&&o.mark.eq(d[m])?o.to=p:r.push(o=new ge(f,p,d[m])));l&&l.to==f?l.to=p:s.push(l=new Be(f,p,i))}}),r.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function Gc(n,e,t,i){let r=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(i instanceof Un){let c=o.marks,h;for(;h=i.isInSet(c);)(a||(a=[])).push(h),c=h.removeFromSet(c)}else i?i.isInSet(o.marks)&&(a=[i]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let h=0;h<a.length;h++){let d=a[h],f;for(let p=0;p<r.length;p++){let u=r[p];u.step==s-1&&d.eq(r[p].style)&&(f=u)}f?(f.to=c,f.step=s):r.push({style:d,from:Math.max(l,e),to:c,step:s})}}}),r.forEach(o=>n.step(new ge(o.from,o.to,o.style)))}function cr(n,e,t,i=t.contentMatch,r=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),h=l+c.nodeSize,d=i.matchType(c.type);if(!d)o.push(new _(l,h,w.empty));else{i=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new ge(l,h,c.marks[f]));if(r&&c.isText&&t.whitespace!="pre"){let f,p=/\r?\n|\r/g,u;for(;f=p.exec(c.text);)u||(u=new w(x.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new _(l+f.index,l+f.index+f[0].length,u))}}l=h}if(!i.validEnd){let a=i.fillBefore(x.empty,!0);n.replace(l,l,new w(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function Uc(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Zn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let i=n.depth;;--i){let r=n.$from.node(i),s=n.$from.index(i),o=n.$to.indexAfter(i);if(i<n.depth&&r.canReplace(s,o,t))return i;if(i==0||r.type.spec.isolating||!Uc(r,s,o))break}return null}function Zc(n,e,t){let{$from:i,$to:r,depth:s}=e,o=i.before(s+1),l=r.after(s+1),a=o,c=l,h=x.empty,d=0;for(let u=s,m=!1;u>t;u--)m||i.index(u)>0?(m=!0,h=x.from(i.node(u).copy(h)),d++):a--;let f=x.empty,p=0;for(let u=s,m=!1;u>t;u--)m||r.after(u+1)<r.end(u)?(m=!0,f=x.from(r.node(u).copy(f)),p++):c++;n.step(new K(a,c,o,l,new w(h.append(f),d,p),h.size-d,!0))}function Xo(n,e,t=null,i=n){let r=Xc(n,e),s=r&&Yc(i,e);return s?r.map(Yr).concat({type:e,attrs:t}).concat(s.map(Yr)):null}function Yr(n){return{type:n,attrs:null}}function Xc(n,e){let{parent:t,startIndex:i,endIndex:r}=n,s=t.contentMatchAt(i).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(i,r,o)?s:null}function Yc(n,e){let{parent:t,startIndex:i,endIndex:r}=n,s=t.child(i),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=i;a&&c<r;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function Qc(n,e,t){let i=x.empty;for(let o=t.length-1;o>=0;o--){if(i.size){let l=t[o].type.contentMatch.matchFragment(i);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=x.from(t[o].type.create(t[o].attrs,i))}let r=e.start,s=e.end;n.step(new K(r,s,r,s,new w(i,0,0),t.length,!0))}function eh(n,e,t,i,r){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof r=="function"?r(o):r;if(o.isTextblock&&!o.hasMarkup(i,a)&&th(n.doc,n.mapping.slice(s).map(l),i)){let c=null;if(i.schema.linebreakReplacement){let p=i.whitespace=="pre",u=!!i.contentMatch.matchType(i.schema.linebreakReplacement);p&&!u?c=!1:!p&&u&&(c=!0)}c===!1&&Qo(n,o,l,s),cr(n,n.mapping.slice(s).map(l,1),i,void 0,c===null);let h=n.mapping.slice(s),d=h.map(l,1),f=h.map(l+o.nodeSize,1);return n.step(new K(d,f,d+1,f-1,new w(x.from(i.create(a,null,o.marks)),0,0),1,!0)),c===!0&&Yo(n,o,l,s),!1}})}function Yo(n,e,t,i){e.forEach((r,s)=>{if(r.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(r.text);){let a=n.mapping.slice(i).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Qo(n,e,t,i){e.forEach((r,s)=>{if(r.type==r.type.schema.linebreakReplacement){let o=n.mapping.slice(i).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
78
- `))}})}function th(n,e,t){let i=n.resolve(e),r=i.index();return i.parent.canReplaceWith(r,r+1,t)}function nh(n,e,t,i,r){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(i,null,r||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new K(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new w(x.from(o),0,0),1,!0))}function Mt(n,e,t=1,i){let r=n.resolve(e),s=r.depth-t,o=i&&i[i.length-1]||r.parent;if(s<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!o.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let c=r.depth-1,h=t-2;c>s;c--,h--){let d=r.node(c),f=r.index(c);if(d.type.spec.isolating)return!1;let p=d.content.cutByIndex(f,d.childCount),u=i&&i[h+1];u&&(p=p.replaceChild(0,u.type.create(u.attrs)));let m=i&&i[h]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(p))return!1}let l=r.indexAfter(s),a=i&&i[0];return r.node(s).canReplaceWith(l,l,a?a.type:r.node(s+1).type)}function ih(n,e,t=1,i){let r=n.doc.resolve(e),s=x.empty,o=x.empty;for(let l=r.depth,a=r.depth-t,c=t-1;l>a;l--,c--){s=x.from(r.node(l).copy(s));let h=i&&i[c];o=x.from(h?h.type.create(h.attrs,o):r.node(l).copy(o))}n.step(new _(e,e,new w(s.append(o),t,t),!0))}function Xn(n,e){let t=n.resolve(e),i=t.index();return sh(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(i,i+1)}function rh(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:i}=n.type.schema;for(let r=0;r<e.childCount;r++){let s=e.child(r),o=s.type==i?n.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function sh(n,e){return!!(n&&e&&!n.isLeaf&&rh(n,e))}function oh(n,e,t){let i=null,{linebreakReplacement:r}=n.doc.type.schema,s=n.doc.resolve(e-t),o=s.node().type;if(r&&o.inlineContent){let h=o.whitespace=="pre",d=!!o.contentMatch.matchType(r);h&&!d?i=!1:!h&&d&&(i=!0)}let l=n.steps.length;if(i===!1){let h=n.doc.resolve(e+t);Qo(n,h.node(),h.before(),l)}o.inlineContent&&cr(n,e+t-1,o,s.node().contentMatchAt(s.index()),i==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new _(c,a.map(e+t,-1),w.empty,!0)),i===!0){let h=n.doc.resolve(c);Yo(n,h.node(),h.before(),n.steps.length)}return n}function lh(n,e,t){let i=n.resolve(e);if(i.parent.canReplaceWith(i.index(),i.index(),t))return e;if(i.parentOffset==0)for(let r=i.depth-1;r>=0;r--){let s=i.index(r);if(i.node(r).canReplaceWith(s,s,t))return i.before(r+1);if(s>0)return null}if(i.parentOffset==i.parent.content.size)for(let r=i.depth-1;r>=0;r--){let s=i.indexAfter(r);if(i.node(r).canReplaceWith(s,s,t))return i.after(r+1);if(s<i.node(r).childCount)return null}return null}function ah(n,e,t){let i=n.resolve(e);if(!t.content.size)return e;let r=t.content;for(let s=0;s<t.openStart;s++)r=r.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=i.depth;o>=0;o--){let l=o==i.depth?0:i.pos<=(i.start(o+1)+i.end(o+1))/2?-1:1,a=i.index(o)+(l>0?1:0),c=i.node(o),h=!1;if(s==1)h=c.canReplace(a,a,r);else{let d=c.contentMatchAt(a).findWrapping(r.firstChild.type);h=d&&c.canReplaceWith(a,a,d[0])}if(h)return l==0?i.pos:l<0?i.before(o+1):i.after(o+1)}return null}function hr(n,e,t=e,i=w.empty){if(e==t&&!i.size)return null;let r=n.resolve(e),s=n.resolve(t);return el(r,s,i)?new _(e,t,i):new ch(r,s,i).fit()}function el(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class ch{constructor(e,t,i){this.$from=e,this.$to=t,this.unplaced=i,this.frontier=[],this.placed=x.empty;for(let r=0;r<=e.depth;r++){let s=e.node(r);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(r))})}for(let r=e.depth;r>0;r--)this.placed=x.from(e.node(r).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,i=this.$from,r=this.close(e<0?this.$to:i.doc.resolve(e));if(!r)return null;let s=this.placed,o=i.depth,l=r.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new w(s,o,l);return e>-1?new K(i.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||i.pos!=this.$to.pos?new _(i.pos,r.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,i=0,r=this.unplaced.openEnd;i<e;i++){let s=t.firstChild;if(t.childCount>1&&(r=0),s.type.spec.isolating&&r<=i){e=i;break}t=s.content}for(let t=1;t<=2;t++)for(let i=t==1?e:this.unplaced.openStart;i>=0;i--){let r,s=null;i?(s=fi(this.unplaced.content,i-1).firstChild,r=s.content):r=this.unplaced.content;let o=r.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],h,d=null;if(t==1&&(o?c.matchType(o.type)||(d=c.fillBefore(x.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:i,frontierDepth:l,parent:s,inject:d};if(t==2&&o&&(h=c.findWrapping(o.type)))return{sliceDepth:i,frontierDepth:l,parent:s,wrap:h};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:i}=this.unplaced,r=fi(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new w(e,t+1,Math.max(i,r.size+t>=e.size-i?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:i}=this.unplaced,r=fi(e,t);if(r.childCount<=1&&t>0){let s=e.size-t<=t+r.size;this.unplaced=new w(Jt(e,t-1,1),t-1,s?t-1:i)}else this.unplaced=new w(Jt(e,t,1),t,i)}placeNodes({sliceDepth:e,frontierDepth:t,parent:i,inject:r,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let o=this.unplaced,l=i?i.content:o.content,a=o.openStart-e,c=0,h=[],{match:d,type:f}=this.frontier[t];if(r){for(let m=0;m<r.childCount;m++)h.push(r.child(m));d=d.matchFragment(r)}let p=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let m=l.child(c),g=d.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(d=g,h.push(tl(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?p:-1)))}let u=c==l.childCount;u||(p=-1),this.placed=Kt(this.placed,t,x.from(h)),this.frontier[t].match=d,u&&p<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<p;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=u?e==0?w.empty:new w(Jt(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new w(Jt(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!ui(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:i}=this.$to,r=this.$to.after(i);for(;i>1&&r==this.$to.end(--i);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:i,type:r}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=ui(e,t,r,i,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],h=ui(e,l,c,a,!0);if(!h||h.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Kt(this.placed,t.depth,t.fit)),e=t.move;for(let i=t.depth+1;i<=e.depth;i++){let r=e.node(i),s=r.type.contentMatch.fillBefore(r.content,!0,e.index(i));this.openFrontierNode(r.type,r.attrs,s)}return e}openFrontierNode(e,t=null,i){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Kt(this.placed,this.depth,x.from(e.create(t,i))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(x.empty,!0);t.childCount&&(this.placed=Kt(this.placed,this.frontier.length,t))}}function Jt(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Jt(n.firstChild.content,e-1,t)))}function Kt(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Kt(n.lastChild.content,e-1,t)))}function fi(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function tl(n,e,t){if(e<=0)return n;let i=n.content;return e>1&&(i=i.replaceChild(0,tl(i.firstChild,e-1,i.childCount==1?t-1:0))),e>0&&(i=n.type.contentMatch.fillBefore(i).append(i),t<=0&&(i=i.append(n.type.contentMatch.matchFragment(i).fillBefore(x.empty,!0)))),n.copy(i)}function ui(n,e,t,i,r){let s=n.node(e),o=r?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=i.fillBefore(s.content,!0,o);return l&&!hh(t,s.content,o)?l:null}function hh(n,e,t){for(let i=t;i<e.childCount;i++)if(!n.allowsMarks(e.child(i).marks))return!0;return!1}function dh(n){return n.spec.defining||n.spec.definingForContent}function fh(n,e,t,i){if(!i.size)return n.deleteRange(e,t);let r=n.doc.resolve(e),s=n.doc.resolve(t);if(el(r,s,i))return n.step(new _(e,t,i));let o=il(r,n.doc.resolve(t));o[o.length-1]==0&&o.pop();let l=-(r.depth+1);o.unshift(l);for(let f=r.depth,p=r.pos-1;f>0;f--,p--){let u=r.node(f).type.spec;if(u.defining||u.definingAsContext||u.isolating)break;o.indexOf(f)>-1?l=f:r.before(f)==p&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],h=i.openStart;for(let f=i.content,p=0;;p++){let u=f.firstChild;if(c.push(u),p==i.openStart)break;f=u.content}for(let f=h-1;f>=0;f--){let p=c[f],u=dh(p.type);if(u&&!p.sameMarkup(r.node(Math.abs(l)-1)))h=f;else if(u||!p.type.isTextblock)break}for(let f=i.openStart;f>=0;f--){let p=(f+h+1)%(i.openStart+1),u=c[p];if(u)for(let m=0;m<o.length;m++){let g=o[(m+a)%o.length],y=!0;g<0&&(y=!1,g=-g);let S=r.node(g-1),b=r.index(g-1);if(S.canReplaceWith(b,b,u.type,u.marks))return n.replace(r.before(g),y?s.after(g):t,new w(nl(i.content,0,i.openStart,p),p,i.openEnd))}}let d=n.steps.length;for(let f=o.length-1;f>=0&&(n.replace(e,t,i),!(n.steps.length>d));f--){let p=o[f];p<0||(e=r.before(p),t=s.after(p))}}function nl(n,e,t,i,r){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(nl(s.content,e+1,t,i,s)))}if(e>i){let s=r.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(x.empty,!0))}return n}function uh(n,e,t,i){if(!i.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let r=lh(n.doc,e,i.type);r!=null&&(e=t=r)}n.replaceRange(e,t,new w(x.from(i),0,0))}function ph(n,e,t){let i=n.doc.resolve(e),r=n.doc.resolve(t),s=il(i,r);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||i.node(l).type.contentMatch.validEnd)return n.delete(i.start(l),r.end(l));if(l>0&&(a||i.node(l-1).canReplace(i.index(l-1),r.indexAfter(l-1))))return n.delete(i.before(l),r.after(l))}for(let o=1;o<=i.depth&&o<=r.depth;o++)if(e-i.start(o)==i.depth-o&&t>i.end(o)&&r.end(o)-t!=r.depth-o&&i.start(o-1)==r.start(o-1)&&i.node(o-1).canReplace(i.index(o-1),r.index(o-1)))return n.delete(i.before(o),t);n.delete(e,t)}function il(n,e){let t=[],i=Math.min(n.depth,e.depth);for(let r=i;r>=0;r--){let s=n.start(r);if(s<n.pos-(n.depth-r)||e.end(r)>e.pos+(e.depth-r)||n.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(s==e.start(r)||r==n.depth&&r==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==s-1)&&t.push(r)}return t}class Tt extends U{constructor(e,t,i){super(),this.pos=e,this.attr=t,this.value=i}apply(e){let t=e.nodeAt(this.pos);if(!t)return B.fail("No node at attribute step's position");let i=Object.create(null);for(let s in t.attrs)i[s]=t.attrs[s];i[this.attr]=this.value;let r=t.type.create(i,null,t.marks);return B.fromReplace(e,this.pos,this.pos+1,new w(x.from(r),0,t.isLeaf?0:1))}getMap(){return ie.empty}invert(e){return new Tt(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Tt(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Tt(t.pos,t.attr,t.value)}}U.jsonID("attr",Tt);class Qt extends U{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let r in e.attrs)t[r]=e.attrs[r];t[this.attr]=this.value;let i=e.type.create(t,e.content,e.marks);return B.ok(i)}getMap(){return ie.empty}invert(e){return new Qt(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Qt(t.attr,t.value)}}U.jsonID("docAttr",Qt);let Dt=class extends Error{};Dt=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Dt.prototype=Object.create(Error.prototype);Dt.prototype.constructor=Dt;Dt.prototype.name="TransformError";class rl{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new vt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Dt(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,i=w.empty){let r=hr(this.doc,e,t,i);return r&&this.step(r),this}replaceWith(e,t,i){return this.replace(e,t,new w(x.from(i),0,0))}delete(e,t){return this.replace(e,t,w.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,i){return fh(this,e,t,i),this}replaceRangeWith(e,t,i){return uh(this,e,t,i),this}deleteRange(e,t){return ph(this,e,t),this}lift(e,t){return Zc(this,e,t),this}join(e,t=1){return oh(this,e,t),this}wrap(e,t){return Qc(this,e,t),this}setBlockType(e,t=e,i,r=null){return eh(this,e,t,i,r),this}setNodeMarkup(e,t,i=null,r){return nh(this,e,t,i,r),this}setNodeAttribute(e,t,i){return this.step(new Tt(e,t,i)),this}setDocAttribute(e,t){return this.step(new Qt(e,t)),this}addNodeMark(e,t){return this.step(new Le(e,t)),this}removeNodeMark(e,t){if(!(t instanceof I)){let i=this.doc.nodeAt(e);if(!i)throw new RangeError("No node at position "+e);if(t=t.isInSet(i.marks),!t)return this}return this.step(new Et(e,t)),this}split(e,t=1,i){return ih(this,e,t,i),this}addMark(e,t,i){return _c(this,e,t,i),this}removeMark(e,t,i){return Gc(this,e,t,i),this}clearIncompatible(e,t,i){return cr(this,e,t,i),this}}const pi=Object.create(null);class A{constructor(e,t,i){this.$anchor=e,this.$head=t,this.ranges=i||[new sl(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=w.empty){let i=t.content.lastChild,r=null;for(let l=0;l<t.openEnd;l++)r=i,i=i.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],h=e.mapping.slice(s);e.replaceRange(h.map(a.pos),h.map(c.pos),l?w.empty:t),l==0&&ts(e,s,(i?i.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let i=e.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:o,$to:l}=r[s],a=e.mapping.slice(i),c=a.map(o.pos),h=a.map(l.pos);s?e.deleteRange(c,h):(e.replaceRangeWith(c,h,t),ts(e,i,t.isInline?-1:1))}}static findFrom(e,t,i=!1){let r=e.parent.inlineContent?new N(e):Ct(e.node(0),e.parent,e.pos,e.index(),t,i);if(r)return r;for(let s=e.depth-1;s>=0;s--){let o=t<0?Ct(e.node(0),e.node(s),e.before(s+1),e.index(s),t,i):Ct(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,i);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new se(e.node(0))}static atStart(e){return Ct(e,e,0,0,1)||new se(e)}static atEnd(e){return Ct(e,e,e.content.size,e.childCount,-1)||new se(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let i=pi[t.type];if(!i)throw new RangeError(`No selection type ${t.type} defined`);return i.fromJSON(e,t)}static jsonID(e,t){if(e in pi)throw new RangeError("Duplicate use of selection JSON ID "+e);return pi[e]=t,t.prototype.jsonID=e,t}getBookmark(){return N.between(this.$anchor,this.$head).getBookmark()}}A.prototype.visible=!0;class sl{constructor(e,t){this.$from=e,this.$to=t}}let Qr=!1;function es(n){!Qr&&!n.parent.inlineContent&&(Qr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class N extends A{constructor(e,t=e){es(e),es(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let i=e.resolve(t.map(this.head));if(!i.parent.inlineContent)return A.near(i);let r=e.resolve(t.map(this.anchor));return new N(r.parent.inlineContent?r:i,i)}replace(e,t=w.empty){if(super.replace(e,t),t==w.empty){let i=this.$from.marksAcross(this.$to);i&&e.ensureMarks(i)}}eq(e){return e instanceof N&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Yn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new N(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,i=t){let r=e.resolve(t);return new this(r,i==t?r:e.resolve(i))}static between(e,t,i){let r=e.pos-t.pos;if((!i||r)&&(i=r>=0?1:-1),!t.parent.inlineContent){let s=A.findFrom(t,i,!0)||A.findFrom(t,-i,!0);if(s)t=s.$head;else return A.near(t,i)}return e.parent.inlineContent||(r==0?e=t:(e=(A.findFrom(e,-i,!0)||A.findFrom(e,i,!0)).$anchor,e.pos<t.pos!=r<0&&(e=t))),new N(e,t)}}A.jsonID("text",N);class Yn{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Yn(e.map(this.anchor),e.map(this.head))}resolve(e){return N.between(e.resolve(this.anchor),e.resolve(this.head))}}class T extends A{constructor(e){let t=e.nodeAfter,i=e.node(0).resolve(e.pos+t.nodeSize);super(e,i),this.node=t}map(e,t){let{deleted:i,pos:r}=t.mapResult(this.anchor),s=e.resolve(r);return i?A.near(s):new T(s)}content(){return new w(x.from(this.node),0,0)}eq(e){return e instanceof T&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new dr(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new T(e.resolve(t.anchor))}static create(e,t){return new T(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}T.prototype.visible=!1;A.jsonID("node",T);class dr{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:i}=e.mapResult(this.anchor);return t?new Yn(i,i):new dr(i)}resolve(e){let t=e.resolve(this.anchor),i=t.nodeAfter;return i&&T.isSelectable(i)?new T(t):A.near(t)}}class se extends A{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=w.empty){if(t==w.empty){e.delete(0,e.doc.content.size);let i=A.atStart(e.doc);i.eq(e.selection)||e.setSelection(i)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new se(e)}map(e){return new se(e)}eq(e){return e instanceof se}getBookmark(){return mh}}A.jsonID("all",se);const mh={map(){return this},resolve(n){return new se(n)}};function Ct(n,e,t,i,r,s=!1){if(e.inlineContent)return N.create(n,t);for(let o=i-(r>0?0:1);r>0?o<e.childCount:o>=0;o+=r){let l=e.child(o);if(l.isAtom){if(!s&&T.isSelectable(l))return T.create(n,t-(r<0?l.nodeSize:0))}else{let a=Ct(n,l,t+r,r<0?l.childCount:0,r,s);if(a)return a}t+=l.nodeSize*r}return null}function ts(n,e,t){let i=n.steps.length-1;if(i<e)return;let r=n.steps[i];if(!(r instanceof _||r instanceof K))return;let s=n.mapping.maps[i],o;s.forEach((l,a,c,h)=>{o==null&&(o=h)}),n.setSelection(A.near(n.doc.resolve(o),t))}const ns=1,xn=2,is=4;class gh extends rl{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|ns)&~xn,this.storedMarks=null,this}get selectionSet(){return(this.updated&ns)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=xn,this}ensureMarks(e){return I.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&xn)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~xn,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let i=this.selection;return t&&(e=e.mark(this.storedMarks||(i.empty?i.$from.marks():i.$from.marksAcross(i.$to)||I.none))),i.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,i){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(i==null&&(i=t),i=i??t,!e)return this.deleteRange(t,i);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=i==t?o.marks():o.marksAcross(this.doc.resolve(i))}return this.replaceRangeWith(t,i,r.text(e,s)),this.selection.empty||this.setSelection(A.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=is,this}get scrolledIntoView(){return(this.updated&is)>0}}function rs(n,e){return!e||!n?n:n.bind(e)}class qt{constructor(e,t,i){this.name=e,this.init=rs(t.init,i),this.apply=rs(t.apply,i)}}const yh=[new qt("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new qt("selection",{init(n,e){return n.selection||A.atStart(e.doc)},apply(n){return n.selection}}),new qt("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,i){return i.selection.$cursor?n.storedMarks:null}}),new qt("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class mi{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=yh.slice(),t&&t.forEach(i=>{if(this.pluginsByKey[i.key])throw new RangeError("Adding different instances of a keyed plugin ("+i.key+")");this.plugins.push(i),this.pluginsByKey[i.key]=i,i.spec.state&&this.fields.push(new qt(i.key,i.spec.state,i))})}}class kt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let i=0;i<this.config.plugins.length;i++)if(i!=t){let r=this.config.plugins[i];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],i=this.applyInner(e),r=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=r?r[o].n:0,c=r?r[o].state:this,h=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,i);if(h&&i.filterTransaction(h,o)){if(h.setMeta("appendedTransaction",e),!r){r=[];for(let d=0;d<this.config.plugins.length;d++)r.push(d<o?{state:i,n:t.length}:{state:this,n:0})}t.push(h),i=i.applyInner(h),s=!0}r&&(r[o]={state:i,n:t.length})}}if(!s)return{state:i,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new kt(this.config),i=this.config.fields;for(let r=0;r<i.length;r++){let s=i[r];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new gh(this)}static create(e){let t=new mi(e.doc?e.doc.type.schema:e.schema,e.plugins),i=new kt(t);for(let r=0;r<t.fields.length;r++)i[t.fields[r].name]=t.fields[r].init(e,i);return i}reconfigure(e){let t=new mi(this.schema,e.plugins),i=t.fields,r=new kt(t);for(let s=0;s<i.length;s++){let o=i[s].name;r[o]=this.hasOwnProperty(o)?this[o]:i[s].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(i=>i.toJSON())),e&&typeof e=="object")for(let i in e){if(i=="doc"||i=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[i],s=r.spec.state;s&&s.toJSON&&(t[i]=s.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,i){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new mi(e.schema,e.plugins),s=new kt(r);return r.fields.forEach(o=>{if(o.name=="doc")s.doc=st.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=A.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(i)for(let l in i){let a=i[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=c.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function ol(n,e,t){for(let i in n){let r=n[i];r instanceof Function?r=r.bind(e):i=="handleDOMEvents"&&(r=ol(r,e,{})),t[i]=r}return t}class on{constructor(e){this.spec=e,this.props={},e.props&&ol(e.props,this,this.props),this.key=e.key?e.key.key:ll("plugin")}getState(e){return e[this.key]}}const gi=Object.create(null);function ll(n){return n in gi?n+"$"+ ++gi[n]:(gi[n]=0,n+"$")}class ln{constructor(e="key"){this.key=ll(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const al=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function bh(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const xh=(n,e,t)=>{let i=bh(n,t);if(!i)return!1;let r=cl(i);if(!r){let o=i.blockRange(),l=o&&Zn(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=r.nodeBefore;if(ml(n,r,e,-1))return!0;if(i.parent.content.size==0&&(It(s,"end")||T.isSelectable(s)))for(let o=i.depth;;o--){let l=hr(n.doc,i.before(o),i.after(o),w.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(It(s,"end")?A.findFrom(a.doc.resolve(a.mapping.map(r.pos,-1)),-1):T.create(a.doc,r.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||i.node(o-1).childCount>1)break}return s.isAtom&&r.depth==i.depth-1?(e&&e(n.tr.delete(r.pos-s.nodeSize,r.pos).scrollIntoView()),!0):!1};function It(n,e,t=!1){for(let i=n;i;i=e=="start"?i.firstChild:i.lastChild){if(i.isTextblock)return!0;if(t&&i.childCount!=1)return!1}return!1}const Ch=(n,e,t)=>{let{$head:i,empty:r}=n.selection,s=i;if(!r)return!1;if(i.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):i.parentOffset>0)return!1;s=cl(i)}let o=s&&s.nodeBefore;return!o||!T.isSelectable(o)?!1:(e&&e(n.tr.setSelection(T.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function cl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function wh(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Sh=(n,e,t)=>{let i=wh(n,t);if(!i)return!1;let r=hl(i);if(!r)return!1;let s=r.nodeAfter;if(ml(n,r,e,1))return!0;if(i.parent.content.size==0&&(It(s,"start")||T.isSelectable(s))){let o=hr(n.doc,i.before(),i.after(),w.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(It(s,"start")?A.findFrom(l.doc.resolve(l.mapping.map(r.pos)),1):T.create(l.doc,l.mapping.map(r.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&r.depth==i.depth-1?(e&&e(n.tr.delete(r.pos,r.pos+s.nodeSize).scrollIntoView()),!0):!1},kh=(n,e,t)=>{let{$head:i,empty:r}=n.selection,s=i;if(!r)return!1;if(i.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):i.parentOffset<i.parent.content.size)return!1;s=hl(i)}let o=s&&s.nodeAfter;return!o||!T.isSelectable(o)?!1:(e&&e(n.tr.setSelection(T.create(n.doc,s.pos)).scrollIntoView()),!0)};function hl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const vh=(n,e)=>{let{$head:t,$anchor:i}=n.selection;return!t.parent.type.spec.code||!t.sameParent(i)?!1:(e&&e(n.tr.insertText(`
79
- `).scrollIntoView()),!0)};function fr(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const dl=(n,e)=>{let{$head:t,$anchor:i}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(i))return!1;let r=t.node(-1),s=t.indexAfter(-1),o=fr(r.contentMatchAt(s));if(!o||!r.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(A.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Mh=(n,e)=>{let t=n.selection,{$from:i,$to:r}=t;if(t instanceof se||i.parent.inlineContent||r.parent.inlineContent)return!1;let s=fr(r.parent.contentMatchAt(r.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!i.parentOffset&&r.index()<r.parent.childCount?i:r).pos,l=n.tr.insert(o,s.createAndFill());l.setSelection(N.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},fl=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Mt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let i=t.blockRange(),r=i&&Zn(i);return r==null?!1:(e&&e(n.tr.lift(i,r).scrollIntoView()),!0)};function ul(n){return(e,t)=>{let{$from:i,$to:r}=e.selection;if(e.selection instanceof T&&e.selection.node.isBlock)return!i.parentOffset||!Mt(e.doc,i.pos)?!1:(t&&t(e.tr.split(i.pos).scrollIntoView()),!0);if(!i.depth)return!1;let s=[],o,l,a=!1,c=!1;for(let p=i.depth;;p--)if(i.node(p).isBlock){a=i.end(p)==i.pos+(i.depth-p),c=i.start(p)==i.pos-(i.depth-p),l=fr(i.node(p-1).contentMatchAt(i.indexAfter(p-1)));let m=n&&n(r.parent,a,i);s.unshift(m||(a&&l?{type:l}:null)),o=p;break}else{if(p==1)return!1;s.unshift(null)}let h=e.tr;(e.selection instanceof N||e.selection instanceof se)&&h.deleteSelection();let d=h.mapping.map(i.pos),f=Mt(h.doc,d,s.length,s);if(f||(s[0]=l?{type:l}:null,f=Mt(h.doc,d,s.length,s)),h.split(d,s.length,s),!a&&c&&i.node(o).type!=l){let p=h.mapping.map(i.before(o)),u=h.doc.resolve(p);l&&i.node(o-1).canReplaceWith(u.index(),u.index()+1,l)&&h.setNodeMarkup(h.mapping.map(i.before(o)),l)}return t&&t(h.scrollIntoView()),!0}}const Th=ul(),pl=(n,e)=>(e&&e(n.tr.setSelection(new se(n.doc))),!0);function Oh(n,e,t){let i=e.nodeBefore,r=e.nodeAfter,s=e.index();return!i||!r||!i.type.compatibleContent(r.type)?!1:!i.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-i.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(r.isTextblock||Xn(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function ml(n,e,t,i){let r=e.nodeBefore,s=e.nodeAfter,o,l,a=r.type.spec.isolating||s.type.spec.isolating;if(!a&&Oh(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=r.contentMatchAt(r.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let p=e.pos+s.nodeSize,u=x.empty;for(let y=o.length-1;y>=0;y--)u=x.from(o[y].create(null,u));u=x.from(r.copy(u));let m=n.tr.step(new K(e.pos-1,p,e.pos,p,new w(u,1,0),o.length,!0)),g=m.doc.resolve(p+2*o.length);g.nodeAfter&&g.nodeAfter.type==r.type&&Xn(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let h=s.type.spec.isolating||i>0&&a?null:A.findFrom(e,1),d=h&&h.$from.blockRange(h.$to),f=d&&Zn(d);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(d,f).scrollIntoView()),!0;if(c&&It(s,"start",!0)&&It(r,"end")){let p=r,u=[];for(;u.push(p),!p.isTextblock;)p=p.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,m.content)){if(t){let y=x.empty;for(let b=u.length-1;b>=0;b--)y=x.from(u[b].copy(y));let S=n.tr.step(new K(e.pos-u.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new w(y,u.length,0),0,!0));t(S.scrollIntoView())}return!0}}return!1}function gl(n){return function(e,t){let i=e.selection,r=n<0?i.$from:i.$to,s=r.depth;for(;r.node(s).isInline;){if(!s)return!1;s--}return r.node(s).isTextblock?(t&&t(e.tr.setSelection(N.create(e.doc,n<0?r.start(s):r.end(s)))),!0):!1}}const Ah=gl(-1),Nh=gl(1);function Eh(n,e=null){return function(t,i){let r=!1;for(let s=0;s<t.selection.ranges.length&&!r;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,c)=>{if(r)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)r=!0;else{let h=t.doc.resolve(c),d=h.index();r=h.parent.canReplaceWith(d,d+1,n)}})}if(!r)return!1;if(i){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,n,e)}i(s.scrollIntoView())}return!0}}function Dh(n,e,t,i){for(let r=0;r<e.length;r++){let{$from:s,$to:o}=e[r],l=s.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(s.pos,o.pos,(a,c)=>{if(l||!i)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function Xe(n,e=null,t){let i=t!==!1;return function(r,s){let{empty:o,$cursor:l,ranges:a}=r.selection;if(o&&!l||!Dh(r.doc,a,n,i))return!1;if(s)if(l)n.isInSet(r.storedMarks||l.marks())?s(r.tr.removeStoredMark(n)):s(r.tr.addStoredMark(n.create(e)));else{let c,h=r.tr;c=!a.some(d=>r.doc.rangeHasMark(d.$from.pos,d.$to.pos,n));for(let d=0;d<a.length;d++){let{$from:f,$to:p}=a[d];if(!c)h.removeMark(f.pos,p.pos,n);else{let u=f.pos,m=p.pos,g=f.nodeAfter,y=p.nodeBefore,S=g&&g.isText?/^\s*/.exec(g.text)[0].length:0,b=y&&y.isText?/\s*$/.exec(y.text)[0].length:0;u+S<m&&(u+=S,m-=b),h.addMark(u,m,n.create(e))}}s(h.scrollIntoView())}return!0}}function en(...n){return function(e,t,i){for(let r=0;r<n.length;r++)if(n[r](e,t,i))return!0;return!1}}let yi=en(al,xh,Ch),ss=en(al,Sh,kh);const Te={Enter:en(vh,Mh,fl,Th),"Mod-Enter":dl,Backspace:yi,"Mod-Backspace":yi,"Shift-Backspace":yi,Delete:ss,"Mod-Delete":ss,"Mod-a":pl},yl={"Ctrl-h":Te.Backspace,"Alt-Backspace":Te["Mod-Backspace"],"Ctrl-d":Te.Delete,"Ctrl-Alt-Backspace":Te["Mod-Delete"],"Alt-Delete":Te["Mod-Delete"],"Alt-d":Te["Mod-Delete"],"Ctrl-a":Ah,"Ctrl-e":Nh};for(let n in Te)yl[n]=Te[n];const Ih=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Rh=Ih?yl:Te;var Hn=200,H=function(){};H.prototype.append=function(e){return e.length?(e=H.from(e),!this.length&&e||e.length<Hn&&this.leafAppend(e)||this.length<Hn&&e.leafPrepend(this)||this.appendInner(e)):this};H.prototype.prepend=function(e){return e.length?H.from(e).append(this):this};H.prototype.appendInner=function(e){return new Vh(this,e)};H.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?H.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};H.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};H.prototype.forEach=function(e,t,i){t===void 0&&(t=0),i===void 0&&(i=this.length),t<=i?this.forEachInner(e,t,i,0):this.forEachInvertedInner(e,t,i,0)};H.prototype.map=function(e,t,i){t===void 0&&(t=0),i===void 0&&(i=this.length);var r=[];return this.forEach(function(s,o){return r.push(e(s,o))},t,i),r};H.from=function(e){return e instanceof H?e:e&&e.length?new bl(e):H.empty};var bl=function(n){function e(i){n.call(this),this.values=i}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(r,s){return r==0&&s==this.length?this:new e(this.values.slice(r,s))},e.prototype.getInner=function(r){return this.values[r]},e.prototype.forEachInner=function(r,s,o,l){for(var a=s;a<o;a++)if(r(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,o,l){for(var a=s-1;a>=o;a--)if(r(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(r){if(this.length+r.length<=Hn)return new e(this.values.concat(r.flatten()))},e.prototype.leafPrepend=function(r){if(this.length+r.length<=Hn)return new e(r.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(H);H.empty=new bl([]);var Vh=function(n){function e(t,i){n.call(this),this.left=t,this.right=i,this.length=t.length+i.length,this.depth=Math.max(t.depth,i.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(i){return i<this.left.length?this.left.get(i):this.right.get(i-this.left.length)},e.prototype.forEachInner=function(i,r,s,o){var l=this.left.length;if(r<l&&this.left.forEachInner(i,r,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(i,Math.max(r-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,r,s,o){var l=this.left.length;if(r>l&&this.right.forEachInvertedInner(i,r-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(i,Math.min(r,l),s,o)===!1)return!1},e.prototype.sliceInner=function(i,r){if(i==0&&r==this.length)return this;var s=this.left.length;return r<=s?this.left.slice(i,r):i>=s?this.right.slice(i-s,r-s):this.left.slice(i,s).append(this.right.slice(0,r-s))},e.prototype.leafAppend=function(i){var r=this.right.leafAppend(i);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(i){var r=this.left.leafPrepend(i);if(r)return new e(r,this.right)},e.prototype.appendInner=function(i){return this.left.depth>=Math.max(this.right.depth,i.depth)+1?new e(this.left,new e(this.right,i)):new e(this,i)},e}(H);const Ph=500;class ue{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let i=this.items.length;for(;;i--)if(this.items.get(i-1).selection){--i;break}let r,s;t&&(r=this.remapping(i,this.items.length),s=r.maps.length);let o=e.tr,l,a,c=[],h=[];return this.items.forEach((d,f)=>{if(!d.step){r||(r=this.remapping(i,f+1),s=r.maps.length),s--,h.push(d);return}if(r){h.push(new me(d.map));let p=d.step.map(r.slice(s)),u;p&&o.maybeStep(p).doc&&(u=o.mapping.maps[o.mapping.maps.length-1],c.push(new me(u,void 0,void 0,c.length+h.length))),s--,u&&r.appendMap(u,s)}else o.maybeStep(d.step);if(d.selection)return l=r?d.selection.map(r.slice(s)):d.selection,a=new ue(this.items.slice(0,i).append(h.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,i,r){let s=[],o=this.eventCount,l=this.items,a=!r&&l.length?l.get(l.length-1):null;for(let h=0;h<e.steps.length;h++){let d=e.steps[h].invert(e.docs[h]),f=new me(e.mapping.maps[h],d,t),p;(p=a&&a.merge(f))&&(f=p,h?s.pop():l=l.slice(0,l.length-1)),s.push(f),t&&(o++,t=void 0),r||(a=f)}let c=o-i.depth;return c>Bh&&(l=zh(l,c),o-=c),new ue(l.append(s),o)}remapping(e,t){let i=new vt;return this.items.forEach((r,s)=>{let o=r.mirrorOffset!=null&&s-r.mirrorOffset>=e?i.maps.length-r.mirrorOffset:void 0;i.appendMap(r.map,o)},e,t),i}addMaps(e){return this.eventCount==0?this:new ue(this.items.append(e.map(t=>new me(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let i=[],r=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},r);let a=t;this.items.forEach(f=>{let p=s.getMirror(--a);if(p==null)return;o=Math.min(o,p);let u=s.maps[p];if(f.step){let m=e.steps[p].invert(e.docs[p]),g=f.selection&&f.selection.map(s.slice(a+1,p));g&&l++,i.push(new me(u,m,g))}else i.push(new me(u))},r);let c=[];for(let f=t;f<o;f++)c.push(new me(s.maps[f]));let h=this.items.slice(0,r).append(c).append(i),d=new ue(h,l);return d.emptyItemCount()>Ph&&(d=d.compress(this.items.length-i.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),i=t.maps.length,r=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)r.push(o),o.selection&&s++;else if(o.step){let a=o.step.map(t.slice(i)),c=a&&a.getMap();if(i--,c&&t.appendMap(c,i),a){let h=o.selection&&o.selection.map(t.slice(i));h&&s++;let d=new me(c.invert(),a,h),f,p=r.length-1;(f=r.length&&r[p].merge(d))?r[p]=f:r.push(d)}}else o.map&&i--},this.items.length,0),new ue(H.from(r.reverse()),s)}}ue.empty=new ue(H.empty,0);function zh(n,e){let t;return n.forEach((i,r)=>{if(i.selection&&e--==0)return t=r,!1}),n.slice(t)}class me{constructor(e,t,i,r){this.map=e,this.step=t,this.selection=i,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new me(t.getMap().invert(),t,this.selection)}}}class Ie{constructor(e,t,i,r,s){this.done=e,this.undone=t,this.prevRanges=i,this.prevTime=r,this.prevComposition=s}}const Bh=20;function Lh(n,e,t,i){let r=t.getMeta(ot),s;if(r)return r.historyState;t.getMeta($h)&&(n=new Ie(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(ot))return o.getMeta(ot).redo?new Ie(n.done.addTransform(t,void 0,i,On(e)),n.undone,ls(t.mapping.maps),n.prevTime,n.prevComposition):new Ie(n.done,n.undone.addTransform(t,void 0,i,On(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-i.newGroupDelay||!Hh(t,n.prevRanges)),c=o?bi(n.prevRanges,t.mapping):ls(t.mapping.maps);return new Ie(n.done.addTransform(t,a?e.selection.getBookmark():void 0,i,On(e)),ue.empty,c,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new Ie(n.done.rebased(t,s),n.undone.rebased(t,s),bi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Ie(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),bi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Hh(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((i,r)=>{for(let s=0;s<e.length;s+=2)i<=e[s+1]&&r>=e[s]&&(t=!0)}),t}function ls(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((i,r,s,o)=>e.push(s,o));return e}function bi(n,e){if(!n)return null;let t=[];for(let i=0;i<n.length;i+=2){let r=e.map(n[i],1),s=e.map(n[i+1],-1);r<=s&&t.push(r,s)}return t}function Fh(n,e,t){let i=On(e),r=ot.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,i);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),r,i),a=new Ie(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(ot,{redo:t,historyState:a})}let xi=!1,as=null;function On(n){let e=n.plugins;if(as!=e){xi=!1,as=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){xi=!0;break}}return xi}const ot=new ln("history"),$h=new ln("closeHistory");function Wh(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new on({key:ot,state:{init(){return new Ie(ue.empty,ue.empty,null,0,-1)},apply(e,t,i){return Lh(t,i,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let i=t.inputType,r=i=="historyUndo"?Cl:i=="historyRedo"?Fi:null;return r?(t.preventDefault(),r(e.state,e.dispatch)):!1}}}})}function xl(n,e){return(t,i)=>{let r=ot.getState(t);if(!r||(n?r.undone:r.done).eventCount==0)return!1;if(i){let s=Fh(r,t,n);s&&i(e?s.scrollIntoView():s)}return!0}}const Cl=xl(!1,!0),Fi=xl(!0,!0);var Je={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Fn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Jh=typeof navigator<"u"&&/Mac/.test(navigator.platform),Kh=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var W=0;W<10;W++)Je[48+W]=Je[96+W]=String(W);for(var W=1;W<=24;W++)Je[W+111]="F"+W;for(var W=65;W<=90;W++)Je[W]=String.fromCharCode(W+32),Fn[W]=String.fromCharCode(W);for(var Ci in Je)Fn.hasOwnProperty(Ci)||(Fn[Ci]=Je[Ci]);function qh(n){var e=Jh&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Kh&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Fn:Je)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const jh=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function _h(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let i,r,s,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))i=!0;else if(/^(c|ctrl|control)$/i.test(a))r=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))jh?o=!0:r=!0;else throw new Error("Unrecognized modifier name: "+a)}return i&&(t="Alt-"+t),r&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Gh(n){let e=Object.create(null);for(let t in n)e[_h(t)]=n[t];return e}function wi(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Si(n){return new on({props:{handleKeyDown:wl(n)}})}function wl(n){let e=Gh(n);return function(t,i){let r=qh(i),s,o=e[wi(r,i)];if(o&&o(t.state,t.dispatch,t))return!0;if(r.length==1&&r!=" "){if(i.shiftKey){let l=e[wi(r,i,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((i.shiftKey||i.altKey||i.metaKey||r.charCodeAt(0)>127)&&(s=Je[i.keyCode])&&s!=r){let l=e[wi(s,i)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}function cs(n,e=null){return function(t,i){let{$from:r,$to:s}=t.selection,o=r.blockRange(s),l=!1,a=o;if(!o)return!1;if(o.depth>=2&&r.node(o.depth-1).type.compatibleContent(n)&&o.startIndex==0){if(r.index(o.depth-1)==0)return!1;let h=t.doc.resolve(o.start-2);a=new Pn(h,h,o.depth),o.endIndex<o.parent.childCount&&(o=new Pn(r,t.doc.resolve(s.end(o.depth)),o.depth)),l=!0}let c=Xo(a,n,e,o);return c?(i&&i(Uh(t.tr,o,c,l,n).scrollIntoView()),!0):!1}}function Uh(n,e,t,i,r){let s=x.empty;for(let h=t.length-1;h>=0;h--)s=x.from(t[h].type.create(t[h].attrs,s));n.step(new K(e.start-(i?2:0),e.end,e.start,e.end,new w(s,0,0),t.length,!0));let o=0;for(let h=0;h<t.length;h++)t[h].type==r&&(o=h+1);let l=t.length-o,a=e.start+t.length-(i?2:0),c=e.parent;for(let h=e.startIndex,d=e.endIndex,f=!0;h<d;h++,f=!1)!f&&Mt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(h).nodeSize;return n}function Zh(n,e){return function(t,i){let{$from:r,$to:s,node:o}=t.selection;if(o&&o.isBlock||r.depth<2||!r.sameParent(s))return!1;let l=r.node(-1);if(l.type!=n)return!1;if(r.parent.content.size==0&&r.node(-1).childCount==r.indexAfter(-1)){if(r.depth==3||r.node(-3).type!=n||r.index(-2)!=r.node(-2).childCount-1)return!1;if(i){let d=x.empty,f=r.index(-1)?1:r.index(-2)?2:3;for(let y=r.depth-f;y>=r.depth-3;y--)d=x.from(r.node(y).copy(d));let p=r.indexAfter(-1)<r.node(-2).childCount?1:r.indexAfter(-2)<r.node(-3).childCount?2:3;d=d.append(x.from(n.createAndFill()));let u=r.before(r.depth-(f-1)),m=t.tr.replace(u,r.after(-p),new w(d,4-f,0)),g=-1;m.doc.nodesBetween(u,m.doc.content.size,(y,S)=>{if(g>-1)return!1;y.isTextblock&&y.content.size==0&&(g=S+1)}),g>-1&&m.setSelection(A.near(m.doc.resolve(g))),i(m.scrollIntoView())}return!0}let a=s.pos==r.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(r.pos,s.pos),h=a?[null,{type:a}]:void 0;return Mt(c.doc,r.pos,2,h)?(i&&i(c.split(r.pos,2,h).scrollIntoView()),!0):!1}}function $i(n){return function(e,t){let{$from:i,$to:r}=e.selection,s=i.blockRange(r,o=>o.childCount>0&&o.firstChild.type==n);return s?t?i.node(s.depth-1).type==n?Xh(e,t,n,s):Yh(e,t,s):!0:!1}}function Xh(n,e,t,i){let r=n.tr,s=i.end,o=i.$to.end(i.depth);s<o&&(r.step(new K(s-1,o,s,o,new w(x.from(t.create(null,i.parent.copy())),1,0),1,!0)),i=new Pn(r.doc.resolve(i.$from.pos),r.doc.resolve(o),i.depth));const l=Zn(i);if(l==null)return!1;r.lift(i,l);let a=r.mapping.map(s,-1)-1;return Xn(r.doc,a)&&r.join(a),e(r.scrollIntoView()),!0}function Yh(n,e,t){let i=n.tr,r=t.parent;for(let p=t.end,u=t.endIndex-1,m=t.startIndex;u>m;u--)p-=r.child(u).nodeSize,i.delete(p-1,p+1);let s=i.doc.resolve(t.start),o=s.nodeAfter;if(i.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==r.childCount,c=s.node(-1),h=s.index(-1);if(!c.canReplace(h+(l?0:1),h+1,o.content.append(a?x.empty:x.from(r))))return!1;let d=s.pos,f=d+o.nodeSize;return i.step(new K(d-(l?1:0),f+(a?1:0),d+1,f-1,new w((l?x.empty:x.from(r.copy(x.empty))).append(a?x.empty:x.from(r.copy(x.empty))),l?0:1,a?0:1),l?0:1)),e(i.scrollIntoView()),!0}function Qh(n){return function(e,t){let{$from:i,$to:r}=e.selection,s=i.blockRange(r,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,h=x.from(c?n.create():null),d=new w(x.from(n.create(null,x.from(l.type.create(null,h)))),c?3:1,0),f=s.start,p=s.end;t(e.tr.step(new K(f-(c?3:1),p,f,p,d,1,!0)).scrollIntoView())}return!0}}const J=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},tn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Wi=null;const Me=function(n,e,t){let i=Wi||(Wi=document.createRange());return i.setEnd(n,t??n.nodeValue.length),i.setStart(n,e||0),i},ed=function(){Wi=null},ht=function(n,e,t,i){return t&&(hs(n,e,t,i,-1)||hs(n,e,t,i,1))},td=/^(img|br|input|textarea|hr)$/i;function hs(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:ce(n))){let s=n.parentNode;if(!s||s.nodeType!=1||an(n)||td.test(n.nodeName)||n.contentEditable=="false")return!1;e=J(n)+(r<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(r<0?-1:0)],n.contentEditable=="false")return!1;e=r<0?ce(n):0}else return!1}}function ce(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function nd(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=ce(n)}else if(n.parentNode&&!an(n))e=J(n),n=n.parentNode;else return null}}function id(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!an(n))e=J(n)+1,n=n.parentNode;else return null}}function rd(n,e,t){for(let i=e==0,r=e==ce(n);i||r;){if(n==t)return!0;let s=J(n);if(n=n.parentNode,!n)return!1;i=i&&s==0,r=r&&s==ce(n)}}function an(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Qn=function(n){return n.focusNode&&ht(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Ye(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function sd(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function od(n,e,t){if(n.caretPositionFromPoint)try{let i=n.caretPositionFromPoint(e,t);if(i)return{node:i.offsetNode,offset:Math.min(ce(i.offsetNode),i.offset)}}catch{}if(n.caretRangeFromPoint){let i=n.caretRangeFromPoint(e,t);if(i)return{node:i.startContainer,offset:Math.min(ce(i.startContainer),i.startOffset)}}}const be=typeof navigator<"u"?navigator:null,ds=typeof document<"u"?document:null,Ke=be&&be.userAgent||"",Ji=/Edge\/(\d+)/.exec(Ke),Sl=/MSIE \d/.exec(Ke),Ki=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ke),te=!!(Sl||Ki||Ji),Fe=Sl?document.documentMode:Ki?+Ki[1]:Ji?+Ji[1]:0,pe=!te&&/gecko\/(\d+)/i.test(Ke);pe&&+(/Firefox\/(\d+)/.exec(Ke)||[0,0])[1];const qi=!te&&/Chrome\/(\d+)/.exec(Ke),G=!!qi,kl=qi?+qi[1]:0,Z=!te&&!!be&&/Apple Computer/.test(be.vendor),Rt=Z&&(/Mobile\/\w+/.test(Ke)||!!be&&be.maxTouchPoints>2),ae=Rt||(be?/Mac/.test(be.platform):!1),ld=be?/Win/.test(be.platform):!1,fe=/Android \d/.test(Ke),cn=!!ds&&"webkitFontSmoothing"in ds.documentElement.style,ad=cn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function cd(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function we(n,e){return typeof n=="number"?n:n[e]}function hd(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,i=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*i}}function fs(n,e,t){let i=n.someProp("scrollThreshold")||0,r=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let o=t||n.dom;o;o=tn(o)){if(o.nodeType!=1)continue;let l=o,a=l==s.body,c=a?cd(s):hd(l),h=0,d=0;if(e.top<c.top+we(i,"top")?d=-(c.top-e.top+we(r,"top")):e.bottom>c.bottom-we(i,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+we(r,"top")-c.top:e.bottom-c.bottom+we(r,"bottom")),e.left<c.left+we(i,"left")?h=-(c.left-e.left+we(r,"left")):e.right>c.right-we(i,"right")&&(h=e.right-c.right+we(r,"right")),h||d)if(a)s.defaultView.scrollBy(h,d);else{let f=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),h&&(l.scrollLeft+=h);let u=l.scrollLeft-f,m=l.scrollTop-p;e={left:e.left-u,top:e.top-m,right:e.right-u,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(o).position))break}}function dd(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),i,r;for(let s=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=n.root.elementFromPoint(s,o);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){i=l,r=a.top;break}}return{refDOM:i,refTop:r,stack:vl(n.dom)}}function vl(n){let e=[],t=n.ownerDocument;for(let i=n;i&&(e.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),n!=t);i=tn(i));return e}function fd({refDOM:n,refTop:e,stack:t}){let i=n?n.getBoundingClientRect().top:0;Ml(t,i==0?0:i-e)}function Ml(n,e){for(let t=0;t<n.length;t++){let{dom:i,top:r,left:s}=n[t];i.scrollTop!=r+e&&(i.scrollTop=r+e),i.scrollLeft!=s&&(i.scrollLeft=s)}}let yt=null;function ud(n){if(n.setActive)return n.setActive();if(yt)return n.focus(yt);let e=vl(n);n.focus(yt==null?{get preventScroll(){return yt={preventScroll:!0},!0}}:void 0),yt||(yt=!1,Ml(e,0))}function Tl(n,e){let t,i=2e8,r,s=0,o=e.top,l=e.top,a,c;for(let h=n.firstChild,d=0;h;h=h.nextSibling,d++){let f;if(h.nodeType==1)f=h.getClientRects();else if(h.nodeType==3)f=Me(h).getClientRects();else continue;for(let p=0;p<f.length;p++){let u=f[p];if(u.top<=o&&u.bottom>=l){o=Math.max(u.bottom,o),l=Math.min(u.top,l);let m=u.left>e.left?u.left-e.left:u.right<e.left?e.left-u.right:0;if(m<i){t=h,i=m,r=m&&t.nodeType==3?{left:u.right<e.left?u.right:u.left,top:e.top}:e,h.nodeType==1&&m&&(s=d+(e.left>=(u.left+u.right)/2?1:0));continue}}else u.top>e.top&&!a&&u.left<=e.left&&u.right>=e.left&&(a=h,c={left:Math.max(u.left,Math.min(u.right,e.left)),top:u.top});!t&&(e.left>=u.right&&e.top>=u.top||e.left>=u.left&&e.top>=u.bottom)&&(s=d+1)}}return!t&&a&&(t=a,r=c,i=0),t&&t.nodeType==3?pd(t,r):!t||i&&t.nodeType==1?{node:n,offset:s}:Tl(t,r)}function pd(n,e){let t=n.nodeValue.length,i=document.createRange();for(let r=0;r<t;r++){i.setEnd(n,r+1),i.setStart(n,r);let s=De(i,1);if(s.top!=s.bottom&&ur(e,s))return{node:n,offset:r+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function ur(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function md(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function gd(n,e,t){let{node:i,offset:r}=Tl(e,t),s=-1;if(i.nodeType==1&&!i.firstChild){let o=i.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(i,r,s)}function yd(n,e,t,i){let r=-1;for(let s=e,o=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!o&&a.left>i.left||a.top>i.top?r=l.posBefore:(!o&&a.right<i.left||a.bottom<i.top)&&(r=l.posAfter),o=!0),!l.contentDOM&&r<0&&!l.node.isText)return(l.node.isBlock?i.top<(a.top+a.bottom)/2:i.left<(a.left+a.right)/2)?l.posBefore:l.posAfter}s=l.dom.parentNode}return r>-1?r:n.docView.posFromDOM(e,t,-1)}function Ol(n,e,t){let i=n.childNodes.length;if(i&&t.top<t.bottom)for(let r=Math.max(0,Math.min(i-1,Math.floor(i*(e.top-t.top)/(t.bottom-t.top))-2)),s=r;;){let o=n.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(ur(e,c))return Ol(o,e,c)}}if((s=(s+1)%i)==r)break}return n}function bd(n,e){let t=n.dom.ownerDocument,i,r=0,s=od(t,e.left,e.top);s&&({node:i,offset:r}=s);let o=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!o||!n.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=n.dom.getBoundingClientRect();if(!ur(e,c)||(o=Ol(n.dom,e,c),!o))return null}if(Z)for(let c=o;i&&c;c=tn(c))c.draggable&&(i=void 0);if(o=md(o,e),i){if(pe&&i.nodeType==1&&(r=Math.min(r,i.childNodes.length),r<i.childNodes.length)){let h=i.childNodes[r],d;h.nodeName=="IMG"&&(d=h.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&r++}let c;cn&&r&&i.nodeType==1&&(c=i.childNodes[r-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&r--,i==n.dom&&r==i.childNodes.length-1&&i.lastChild.nodeType==1&&e.top>i.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(r==0||i.nodeType!=1||i.childNodes[r-1].nodeName!="BR")&&(l=yd(n,i,r,e))}l==null&&(l=gd(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function us(n){return n.top<n.bottom||n.left<n.right}function De(n,e){let t=n.getClientRects();if(t.length){let i=t[e<0?0:t.length-1];if(us(i))return i}return Array.prototype.find.call(t,us)||n.getBoundingClientRect()}const xd=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Al(n,e,t){let{node:i,offset:r,atom:s}=n.docView.domFromPos(e,t<0?-1:1),o=cn||pe;if(i.nodeType==3)if(o&&(xd.test(i.nodeValue)||(t<0?!r:r==i.nodeValue.length))){let a=De(Me(i,r,r),t);if(pe&&r&&/\s/.test(i.nodeValue[r-1])&&r<i.nodeValue.length){let c=De(Me(i,r-1,r-1),-1);if(c.top==a.top){let h=De(Me(i,r,r+1),-1);if(h.top!=a.top)return Ht(h,h.left<c.left)}}return a}else{let a=r,c=r,h=t<0?1:-1;return t<0&&!r?(c++,h=-1):t>=0&&r==i.nodeValue.length?(a--,h=1):t<0?a--:c++,Ht(De(Me(i,a,c),h),h<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&r&&(t<0||r==ce(i))){let a=i.childNodes[r-1];if(a.nodeType==1)return ki(a.getBoundingClientRect(),!1)}if(s==null&&r<ce(i)){let a=i.childNodes[r];if(a.nodeType==1)return ki(a.getBoundingClientRect(),!0)}return ki(i.getBoundingClientRect(),t>=0)}if(s==null&&r&&(t<0||r==ce(i))){let a=i.childNodes[r-1],c=a.nodeType==3?Me(a,ce(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Ht(De(c,1),!1)}if(s==null&&r<ce(i)){let a=i.childNodes[r];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Me(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return Ht(De(c,-1),!0)}return Ht(De(i.nodeType==3?Me(i):i,-t),t>=0)}function Ht(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function ki(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Nl(n,e,t){let i=n.state,r=n.root.activeElement;i!=e&&n.updateState(e),r!=n.dom&&n.focus();try{return t()}finally{i!=e&&n.updateState(i),r!=n.dom&&r&&r.focus()}}function Cd(n,e,t){let i=e.selection,r=t=="up"?i.$from:i.$to;return Nl(n,e,()=>{let{node:s}=n.docView.domFromPos(r.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Al(n,r.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Me(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let h=a[c];if(h.bottom>h.top+1&&(t=="up"?o.top-h.top>(h.bottom-o.top)*2:h.bottom-o.bottom>(o.bottom-h.top)*2))return!1}}return!0})}const wd=/[\u0590-\u08ac]/;function Sd(n,e,t){let{$head:i}=e.selection;if(!i.parent.isTextblock)return!1;let r=i.parentOffset,s=!r,o=r==i.parent.content.size,l=n.domSelection();return l?!wd.test(i.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Nl(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:h,anchorOffset:d}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let p=i.depth?n.docView.domAfterPos(i.before()):n.dom,{focusNode:u,focusOffset:m}=n.domSelectionRange(),g=u&&!p.contains(u.nodeType==1?u:u.parentNode)||a==u&&c==m;try{l.collapse(h,d),a&&(a!=h||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):i.pos==i.start()||i.pos==i.end()}let ps=null,ms=null,gs=!1;function kd(n,e,t){return ps==e&&ms==t?gs:(ps=e,ms=t,gs=t=="up"||t=="down"?Cd(n,e,t):Sd(n,e,t))}const he=0,ys=1,et=2,xe=3;class hn{constructor(e,t,i,r){this.parent=e,this.children=t,this.dom=i,this.contentDOM=r,this.dirty=he,i.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,i){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,i=this.posAtStart;;t++){let r=this.children[t];if(r==e)return i;i+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,i){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(i<0){let s,o;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>J(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){r=!1;break}if(s.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){r=!0;break}if(s.nextSibling)break}}return r??i>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let i=!0,r=e;r;r=r.parentNode){let s=this.getDesc(r),o;if(s&&(!t||s.node))if(i&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))i=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let i=t;i;i=i.parent)if(i==this)return t}posFromDOM(e,t,i){for(let r=e;r;r=r.parentNode){let s=this.getDesc(r);if(s)return s.localPosFromDOM(e,t,i)}return-1}descAt(e){for(let t=0,i=0;t<this.children.length;t++){let r=this.children[t],s=i+r.size;if(i==e&&s!=i){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(e<s)return r.descAt(e-i-r.border);i=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let i=0,r=0;for(let s=0;i<this.children.length;i++){let o=this.children[i],l=s+o.size;if(l>e||o instanceof Dl){r=e-s;break}s=l}if(r)return this.children[i].domFromPos(r-this.children[i].border,t);for(let s;i&&!(s=this.children[i-1]).size&&s instanceof El&&s.side>=0;i--);if(t<=0){let s,o=!0;for(;s=i?this.children[i-1]:null,!(!s||s.dom.parentNode==this.contentDOM);i--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?J(s.dom)+1:0}}else{let s,o=!0;for(;s=i<this.children.length?this.children[i]:null,!(!s||s.dom.parentNode==this.contentDOM);i++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?J(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,i=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,s=-1;for(let o=i,l=0;;l++){let a=this.children[l],c=o+a.size;if(r==-1&&e<=c){let h=o+a.border;if(e>=h&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,h);e=o;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){r=J(f.dom)+1;break}e-=f.size}r==-1&&(r=0)}if(r>-1&&(c>t||l==this.children.length-1)){t=c;for(let h=l+1;h<this.children.length;h++){let d=this.children[h];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){s=J(d.dom);break}t+=d.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:i}=this.domFromPos(e,0);if(t.nodeType!=1||i==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[i]}setSelection(e,t,i,r=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let p=0,u=0;p<this.children.length;p++){let m=this.children[p],g=u+m.size;if(s>u&&o<g)return m.setSelection(e-u-m.border,t-u-m.border,i,r);u=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=i.root.getSelection(),h=i.domSelectionRange(),d=!1;if((pe||Z)&&e==t){let{node:p,offset:u}=l;if(p.nodeType==3){if(d=!!(u&&p.nodeValue[u-1]==`
80
- `),d&&u==p.nodeValue.length)for(let m=p,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:J(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=p.childNodes[u-1];d=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(pe&&h.focusNode&&h.focusNode!=a.node&&h.focusNode.nodeType==1){let p=h.focusNode.childNodes[h.focusOffset];p&&p.contentEditable=="false"&&(r=!0)}if(!(r||d&&Z)&&ht(l.node,l.offset,h.anchorNode,h.anchorOffset)&&ht(a.node,a.offset,h.focusNode,h.focusOffset))return;let f=!1;if((c.extend||e==t)&&!d){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let u=l;l=a,a=u}let p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let i=0,r=0;r<this.children.length;r++){let s=this.children[r],o=i+s.size;if(i==o?e<=o&&t>=i:e<o&&t>i){let l=i+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==i||t==o?et:ys,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=xe:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?et:xe}i=o}this.dirty=et}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let i=e==1?et:ys;t.dirty<i&&(t.dirty=i)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class El extends hn{constructor(e,t,i,r){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(i,()=>{if(!s)return r;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==he&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class vd extends hn{constructor(e,t,i,r){super(e,[],t,null),this.textDOM=i,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class dt extends hn{constructor(e,t,i,r,s){super(e,[],i,r),this.mark=t,this.spec=s}static create(e,t,i,r){let s=r.nodeViews[t.type.name],o=s&&s(t,r,i);return(!o||!o.dom)&&(o=ft.renderSpec(document,t.type.spec.toDOM(t,i),null,t.attrs)),new dt(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&xe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=xe&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=he){let i=this.parent;for(;!i.node;)i=i.parent;i.dirty<this.dirty&&(i.dirty=this.dirty),this.dirty=he}}slice(e,t,i){let r=dt.create(this.parent,this.mark,!0,i),s=this.children,o=this.size;t<o&&(s=_i(s,t,o,i)),e>0&&(s=_i(s,0,e,i));for(let l=0;l<s.length;l++)s[l].parent=r;return r.children=s,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class $e extends hn{constructor(e,t,i,r,s,o,l,a,c){super(e,[],s,o),this.node=t,this.outerDeco=i,this.innerDeco=r,this.nodeDOM=l}static create(e,t,i,r,s,o){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},i,r),h=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!h)h=document.createTextNode(t.text);else if(h.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else h||({dom:h,contentDOM:d}=ft.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&h.nodeName!="BR"&&(h.hasAttribute("contenteditable")||(h.contentEditable="false"),t.type.spec.draggable&&(h.draggable=!0));let f=h;return h=Vl(h,i,t),c?a=new Md(e,t,i,r,h,d||null,f,c,s,o+1):t.isText?new ei(e,t,i,r,h,f,s):new $e(e,t,i,r,h,d||null,f,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let i=this.children[t];if(this.dom.contains(i.dom.parentNode)){e.contentElement=i.dom.parentNode;break}}e.contentElement||(e.getContent=()=>x.empty)}return e}matchesNode(e,t,i){return this.dirty==he&&e.eq(this.node)&&$n(t,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let i=this.node.inlineContent,r=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Od(this,o&&o.node,e);Ed(this.node,this.innerDeco,(c,h,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,i,e):c.type.side>=0&&!d&&a.syncToMarks(h==this.node.childCount?I.none:this.node.child(h).marks,i,e),a.placeWidget(c,e,r)},(c,h,d,f)=>{a.syncToMarks(c.marks,i,e);let p;a.findNodeMatch(c,h,d,f)||l&&e.state.selection.from>r&&e.state.selection.to<r+c.nodeSize&&(p=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,h,d,p,e)||a.updateNextNode(c,h,d,e,f,r)||a.addNode(c,h,d,e,r),r+=c.nodeSize}),a.syncToMarks([],i,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==et)&&(o&&this.protectLocalComposition(e,o),Il(this.contentDOM,this.children,e),Rt&&Dd(this.dom))}localCompositionInfo(e,t){let{from:i,to:r}=e.state.selection;if(!(e.state.selection instanceof N)||i<t||r>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=Id(this.node.content,o,i-t,r-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:i,text:r}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new vd(this,s,t,r);e.input.compositionNodes.push(o),this.children=_i(this.children,i,i+r.length,e,o)}update(e,t,i,r){return this.dirty==xe||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,i,r),!0)}updateInner(e,t,i,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=i,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=he}updateOuterDeco(e){if($n(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,i=this.dom;this.dom=Rl(this.dom,this.nodeDOM,ji(this.outerDeco,this.node,t),ji(e,this.node,t)),this.dom!=i&&(i.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function bs(n,e,t,i,r){Vl(i,e,n);let s=new $e(void 0,n,e,t,i,i,i,r,0);return s.contentDOM&&s.updateChildren(r,0),s}class ei extends $e{constructor(e,t,i,r,s,o,l){super(e,t,i,r,s,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,i,r){return this.dirty==xe||this.dirty!=he&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=he||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=he,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,i){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,i)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,i){let r=this.node.cut(e,t),s=document.createTextNode(r.text);return new ei(this.parent,r,this.outerDeco,this.innerDeco,s,s,i)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=xe)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Dl extends hn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==he&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Md extends $e{constructor(e,t,i,r,s,o,l,a,c,h){super(e,t,i,r,s,o,l,c,h),this.spec=a}update(e,t,i,r){if(this.dirty==xe)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,i);return s&&this.updateInner(e,t,i,r),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,i,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,i,r){this.spec.setSelection?this.spec.setSelection(e,t,i.root):super.setSelection(e,t,i,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Il(n,e,t){let i=n.firstChild,r=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==n){for(;l!=i;)i=xs(i),r=!0;i=i.nextSibling}else r=!0,n.insertBefore(l,i);if(o instanceof dt){let a=i?i.previousSibling:n.lastChild;Il(o.contentDOM,o.children,t),i=a?a.nextSibling:n.firstChild}}for(;i;)i=xs(i),r=!0;r&&t.trackWrites==n&&(t.trackWrites=null)}const Gt=function(n){n&&(this.nodeName=n)};Gt.prototype=Object.create(null);const tt=[new Gt];function ji(n,e,t){if(n.length==0)return tt;let i=t?tt[0]:new Gt,r=[i];for(let s=0;s<n.length;s++){let o=n[s].type.attrs;if(o){o.nodeName&&r.push(i=new Gt(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&r.length==1&&r.push(i=new Gt(e.isInline?"span":"div")),l=="class"?i.class=(i.class?i.class+" ":"")+a:l=="style"?i.style=(i.style?i.style+";":"")+a:l!="nodeName"&&(i[l]=a))}}}return r}function Rl(n,e,t,i){if(t==tt&&i==tt)return e;let r=e;for(let s=0;s<i.length;s++){let o=i[s],l=t[s];if(s){let a;l&&l.nodeName==o.nodeName&&r!=n&&(a=r.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(r),l=tt[0]),r=a}Td(r,l||tt[0],o)}return r}function Td(n,e,t){for(let i in e)i!="class"&&i!="style"&&i!="nodeName"&&!(i in t)&&n.removeAttribute(i);for(let i in t)i!="class"&&i!="style"&&i!="nodeName"&&t[i]!=e[i]&&n.setAttribute(i,t[i]);if(e.class!=t.class){let i=e.class?e.class.split(" ").filter(Boolean):[],r=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&n.classList.remove(i[s]);for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&n.classList.add(r[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=i.exec(e.style);)n.style.removeProperty(r[1])}t.style&&(n.style.cssText+=t.style)}}function Vl(n,e,t){return Rl(n,n,tt,ji(e,t,n.nodeType!=1))}function $n(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function xs(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Od{constructor(e,t,i){this.lock=t,this.view=i,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Ad(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let i=e;i<t;i++)this.top.children[i].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,i){let r=0,s=this.stack.length>>1,o=Math.min(s,e.length);for(;r<o&&(r==s-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&e[r].type.spec.spanning!==!1;)r++;for(;r<s;)this.destroyRest(),this.top.dirty=he,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=dt.create(this.top,e[s],t,i);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,i,r){let s=-1,o;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,i))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,i)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,i,r,s){let o=this.top.children[r];return o.dirty==xe&&o.dom==o.contentDOM&&(o.dirty=et),o.update(e,t,i,s)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let i=e.pmViewDesc;if(i){for(let r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==i)return r}return-1}e=t}}updateNextNode(e,t,i,r,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof $e){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let h=a.dom,d,f=this.isLocked(h)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=xe&&$n(t,a.outerDeco));if(!f&&a.update(e,t,i,r))return this.destroyBetween(this.index,l),a.dom!=h&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,t,i,r,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=et,d.updateChildren(r,o+1),d.dirty=he),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,i,r,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!$n(i,e.outerDeco)||!r.eq(e.innerDeco))return null;let l=$e.create(this.top,t,i,r,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,i,r,s){let o=$e.create(this.top,e,t,i,r,s);o.contentDOM&&o.updateChildren(r,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,i){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let s=new El(this.top,e,t,i);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof dt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof ei)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Z||G)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let i=document.createElement(e);e=="IMG"&&(i.className="ProseMirror-separator",i.alt=""),e=="BR"&&(i.className="ProseMirror-trailingBreak");let r=new Dl(this.top,[],i,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Ad(n,e){let t=e,i=t.children.length,r=n.childCount,s=new Map,o=[];e:for(;r>0;){let l;for(;;)if(i){let c=t.children[i-1];if(c instanceof dt)t=c,i=c.children.length;else{l=c,i--;break}}else{if(t==e)break e;i=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(r-1))break;--r,s.set(l,r),o.push(l)}}return{index:r,matched:s,matches:o.reverse()}}function Nd(n,e){return n.type.side-e.type.side}function Ed(n,e,t,i){let r=e.locals(n),s=0;if(r.length==0){for(let c=0;c<n.childCount;c++){let h=n.child(c);i(h,r,e.forChild(s,h),c),s+=h.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let h,d;for(;o<r.length&&r[o].to==s;){let g=r[o++];g.widget&&(h?(d||(d=[h])).push(g):h=g)}if(h)if(d){d.sort(Nd);for(let g=0;g<d.length;g++)t(d[g],c,!!a)}else t(h,c,!!a);let f,p;if(a)p=-1,f=a,a=null;else if(c<n.childCount)p=c,f=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;o<r.length&&r[o].from<=s&&r[o].to>s;)l.push(r[o++]);let u=s+f.nodeSize;if(f.isText){let g=u;o<r.length&&r[o].from<g&&(g=r[o].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<u&&(a=f.cut(g-s),f=f.cut(0,g-s),u=g,p=-1)}else for(;o<r.length&&r[o].to<u;)o++;let m=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();i(f,m,e.forChild(s,f),p),s=u}}function Dd(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Id(n,e,t,i){for(let r=0,s=0;r<n.childCount&&s<=i;){let o=n.child(r++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;r<n.childCount;){let c=n.child(r++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=t){if(s>=i&&a.slice(i-e.length-l,i-l)==e)return i-e.length;let c=l<i?a.lastIndexOf(e,i-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==i&&a.length>=i+e.length-l&&a.slice(i-l,i-l+e.length)==e)return i}}return-1}function _i(n,e,t,i,r){let s=[];for(let o=0,l=0;o<n.length;o++){let a=n[o],c=l,h=l+=a.size;c>=t||h<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,i)),r&&(s.push(r),r=void 0),h>t&&s.push(a.slice(t-c,a.size,i)))}return s}function pr(n,e=null){let t=n.domSelectionRange(),i=n.state.doc;if(!t.focusNode)return null;let r=n.docView.nearestDesc(t.focusNode),s=r&&r.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=i.resolve(o),a,c;if(Qn(t)){for(a=o;r&&!r.node;)r=r.parent;let d=r.node;if(r&&d.isAtom&&T.isSelectable(d)&&r.parent&&!(d.isInline&&rd(t.focusNode,t.focusOffset,r.dom))){let f=r.posBefore;c=new T(o==f?l:i.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=o,f=o;for(let p=0;p<t.rangeCount;p++){let u=t.getRangeAt(p);d=Math.min(d,n.docView.posFromDOM(u.startContainer,u.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(u.endContainer,u.endOffset,-1))}if(d<0)return null;[a,o]=f==n.state.selection.anchor?[f,d]:[d,f],l=i.resolve(o)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let h=i.resolve(a);if(!c){let d=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=mr(n,h,l,d)}return c}function Pl(n){return n.editable?n.hasFocus():Bl(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Oe(n,e=!1){let t=n.state.selection;if(zl(n,t),!!Pl(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&G){let i=n.domSelectionRange(),r=n.domObserver.currentSelection;if(i.anchorNode&&r.anchorNode&&ht(i.anchorNode,i.anchorOffset,r.anchorNode,r.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Vd(n);else{let{anchor:i,head:r}=t,s,o;Cs&&!(t instanceof N)&&(t.$from.parent.inlineContent||(s=ws(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=ws(n,t.to))),n.docView.setSelection(i,r,n,e),Cs&&(s&&Ss(s),o&&Ss(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Rd(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Cs=Z||G&&kl<63;function ws(n,e){let{node:t,offset:i}=n.docView.domFromPos(e,0),r=i<t.childNodes.length?t.childNodes[i]:null,s=i?t.childNodes[i-1]:null;if(Z&&r&&r.contentEditable=="false")return vi(r);if((!r||r.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(r)return vi(r);if(s)return vi(s)}}function vi(n){return n.contentEditable="true",Z&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Ss(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Rd(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),i=t.anchorNode,r=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=i||t.anchorOffset!=r)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Pl(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Vd(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let i=n.cursorWrapper.dom,r=i.nodeName=="IMG";r?t.setStart(i.parentNode,J(i)+1):t.setStart(i,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!r&&!n.state.selection.visible&&te&&Fe<=11&&(i.disabled=!0,i.disabled=!1)}function zl(n,e){if(e instanceof T){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ks(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ks(n)}function ks(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function mr(n,e,t,i){return n.someProp("createSelectionBetween",r=>r(n,e,t))||N.between(e,t,i)}function vs(n){return n.editable&&!n.hasFocus()?!1:Bl(n)}function Bl(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Pd(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return ht(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Gi(n,e){let{$anchor:t,$head:i}=n.selection,r=e>0?t.max(i):t.min(i),s=r.parent.inlineContent?r.depth?n.doc.resolve(e>0?r.after():r.before()):null:r;return s&&A.findFrom(s,e)}function Re(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Ms(n,e,t){let i=n.state.selection;if(i instanceof N)if(t.indexOf("s")>-1){let{$head:r}=i,s=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(r.pos+s.nodeSize*(e<0?-1:1));return Re(n,new N(i.$anchor,o))}else if(i.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let r=Gi(n.state,e);return r&&r instanceof T?Re(n,r):!1}else if(!(ae&&t.indexOf("m")>-1)){let r=i.$head,s=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?r.pos-s.nodeSize:r.pos;return s.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?T.isSelectable(s)?Re(n,new T(e<0?n.state.doc.resolve(r.pos-s.nodeSize):r)):cn?Re(n,new N(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(i instanceof T&&i.node.isInline)return Re(n,new N(e>0?i.$to:i.$from));{let r=Gi(n.state,e);return r?Re(n,r):!1}}}function Wn(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Ut(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function bt(n,e){return e<0?zd(n):Bd(n)}function zd(n){let e=n.domSelectionRange(),t=e.focusNode,i=e.focusOffset;if(!t)return;let r,s,o=!1;for(pe&&t.nodeType==1&&i<Wn(t)&&Ut(t.childNodes[i],-1)&&(o=!0);;)if(i>0){if(t.nodeType!=1)break;{let l=t.childNodes[i-1];if(Ut(l,-1))r=t,s=--i;else if(l.nodeType==3)t=l,i=t.nodeValue.length;else break}}else{if(Ll(t))break;{let l=t.previousSibling;for(;l&&Ut(l,-1);)r=t.parentNode,s=J(l),l=l.previousSibling;if(l)t=l,i=Wn(t);else{if(t=t.parentNode,t==n.dom)break;i=0}}}o?Ui(n,t,i):r&&Ui(n,r,s)}function Bd(n){let e=n.domSelectionRange(),t=e.focusNode,i=e.focusOffset;if(!t)return;let r=Wn(t),s,o;for(;;)if(i<r){if(t.nodeType!=1)break;let l=t.childNodes[i];if(Ut(l,1))s=t,o=++i;else break}else{if(Ll(t))break;{let l=t.nextSibling;for(;l&&Ut(l,1);)s=l.parentNode,o=J(l)+1,l=l.nextSibling;if(l)t=l,i=0,r=Wn(t);else{if(t=t.parentNode,t==n.dom)break;i=r=0}}}s&&Ui(n,s,o)}function Ll(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Ld(n,e){for(;n&&e==n.childNodes.length&&!an(n);)e=J(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function Hd(n,e){for(;n&&!e&&!an(n);)e=J(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Ui(n,e,t){if(e.nodeType!=3){let s,o;(o=Ld(e,t))?(e=o,t=0):(s=Hd(e,t))&&(e=s,t=s.nodeValue.length)}let i=n.domSelection();if(!i)return;if(Qn(i)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),i.removeAllRanges(),i.addRange(s)}else i.extend&&i.extend(e,t);n.domObserver.setCurSelection();let{state:r}=n;setTimeout(()=>{n.state==r&&Oe(n)},50)}function Ts(n,e){let t=n.state.doc.resolve(e);if(!(G||ld)&&t.parent.inlineContent){let r=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(s.left-r.left)>1)return s.left<r.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(s.left-r.left)>1)return s.left>r.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Os(n,e,t){let i=n.state.selection;if(i instanceof N&&!i.empty||t.indexOf("s")>-1||ae&&t.indexOf("m")>-1)return!1;let{$from:r,$to:s}=i;if(!r.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Gi(n.state,e);if(o&&o instanceof T)return Re(n,o)}if(!r.parent.inlineContent){let o=e<0?r:s,l=i instanceof se?A.near(o,e):A.findFrom(o,e);return l?Re(n,l):!1}return!1}function As(n,e){if(!(n.state.selection instanceof N))return!0;let{$head:t,$anchor:i,empty:r}=n.state.selection;if(!t.sameParent(i))return!0;if(!r)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=n.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),n.dispatch(o),!0}return!1}function Ns(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Fd(n){if(!Z||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let i=e.firstChild;Ns(n,i,"true"),setTimeout(()=>Ns(n,i,"false"),20)}return!1}function $d(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Wd(n,e){let t=e.keyCode,i=$d(e);if(t==8||ae&&t==72&&i=="c")return As(n,-1)||bt(n,-1);if(t==46&&!e.shiftKey||ae&&t==68&&i=="c")return As(n,1)||bt(n,1);if(t==13||t==27)return!0;if(t==37||ae&&t==66&&i=="c"){let r=t==37?Ts(n,n.state.selection.from)=="ltr"?-1:1:-1;return Ms(n,r,i)||bt(n,r)}else if(t==39||ae&&t==70&&i=="c"){let r=t==39?Ts(n,n.state.selection.from)=="ltr"?1:-1:1;return Ms(n,r,i)||bt(n,r)}else{if(t==38||ae&&t==80&&i=="c")return Os(n,-1,i)||bt(n,-1);if(t==40||ae&&t==78&&i=="c")return Fd(n)||Os(n,1,i)||bt(n,1);if(i==(ae?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Hl(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:i,openStart:r,openEnd:s}=e;for(;r>1&&s>1&&i.childCount==1&&i.firstChild.childCount==1;){r--,s--;let p=i.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),i=p.content}let o=n.someProp("clipboardSerializer")||ft.fromSchema(n.state.schema),l=ql(),a=l.createElement("div");a.appendChild(o.serializeFragment(i,{document:l}));let c=a.firstChild,h,d=0;for(;c&&c.nodeType==1&&(h=Kl[c.nodeName.toLowerCase()]);){for(let p=h.length-1;p>=0;p--){let u=l.createElement(h[p]);for(;a.firstChild;)u.appendChild(a.firstChild);a.appendChild(u),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${r} ${s}${d?` -${d}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,`
74
+ `},init(){const S=[f].map(b=>`change:${b}`).join(" ");this.on(S,this.updateTraits),this.on(`change:${f}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(S,b,C){if(C.adjust)return;const M=this.get(f)==="video"?"video":"image";this.addAttributes({[gn]:M,href:""})},adjustSourceType(){const S=this.get(f),b=this.getAttributes().href||"",C={adjust:!0};if(S==="video"){const k=b.includes("youtube.com")?"youtube":"video";this.addAttributes({[gn]:k},C)}else S!=="el"&&b.startsWith("#")?this.set(f,"el",C):S==="image"&&this.addAttributes({[gn]:"image"},C)},updateTraits(S={}){const{changed:b}=this,{init:C}=S;if(b[p.name]||C){this.removeTrait([u.name,m.name,g.name]);const k=this.get(f)||"image",M=this.getTraitIndex(f)+1;this.addTrait(y[k],{at:M})}},initToolbar(){if(!a)return;const{toolbar:S}=this,b=d(this);!S.find(k=>k.id===b.id)&&(S==null||S.unshift(b))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var V;const{em:S,el:b,model:C}=this,{Canvas:k}=S,M=C.getAttributes()[mn],{defaultView:E,documentElement:L}=b.ownerDocument,O=(V=E.fsLightboxInstances)==null?void 0:V[M];if(L.classList.contains(lc))O.close();else{b.__skipLb=!1;let q;O.props.onOpen=()=>{q=k.getSpots(),setTimeout(()=>k.removeSpots())},O.props.onClose=()=>{q.forEach(_e=>k.addSpot(_e.attributes))},b.click()}}}}),Bt({editor:n,plan:pe.free,licenseKey:o.licenseKey,pluginName:oc,cleanup:()=>{t.remove(mt),i.removeType(mt)}})},cc=zt(ac);var Ct=(n=>(n.image="image",n.video="video",n.external="external",n))(Ct||{});const Xe="lightGallery",Vr=`${Xe}-item`,Mn="data-lightgallery",zr=`${Mn}-item`,Dn="toggle",et={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',gallery:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',galleryItem:'<svg viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M8 14H6v-2h2v2m0-3H6V9h2v2m0-3H6V6h2v2m7 6h-5v-2h5v2m3-3h-8V9h8v2m0-3h-8V6h8v2Z"/></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},ai={propKeys:[],props:{},traits:[]},Ht=(n,e={})=>{var r;const t={},i=[];for(const s in n){const{value:o,...l}=n[s];i.push({id:s,name:s,changeProp:!0,category:e.category,...l}),t[s]=o;const{subTraits:a={}}=l;for(const c in l.subTraits)(r=a[c])==null||r.forEach(h=>{const d=h.id||h.name;t[d]=h.value})}return{propKeys:Object.keys(t),props:t,traits:i}},Pi=(n,e)=>{const t=n.getTrait(e),i=t.get("category"),r=t.get("subTraits")||{},o=(Object.values(r).flat()||[]).map(c=>c.id||c.name);n.removeTrait(o);const l=r[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:i,...c})),{at:a})},ci=(n,e)=>{e.forEach(t=>{const i=n.getTrait(t);if(!i||!i.get("subTraits"))return;const r=i.changeProp?`change:${t}`:`change:attributes:${t}`;n.on(r,()=>Pi(n,t)),Pi(n,t)})},hc=(n,e,t)=>{const r=n.getTrait(e).get("subTraits")||{},o=(Object.values(r).flat()||[]).map(a=>{const c=a.name||a.id;return a.changeProp?`change:${c}`:`change:attributes:${c}`}),l=Array.from(new Set(o));l.length&&n.on(l.join(" "),t)},dc={[Dn]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var t,i;return(i=(t=e.target)==null?void 0:t.getView())==null?void 0:i.toggleGallery()}},speed:{type:"number",label:"Speed",tip:"Transition duration between slides (in ms)",value:400,step:50,min:0},inline:{type:"checkbox",label:"Inline Gallery",value:!1},allowMediaOverlap:{type:"checkbox",label:"Allow media overlap",tip:"If enabled, toolbar, captions and thumbnails will overlap with the media element",value:!1},controls:{type:"checkbox",label:"Show controls",tip:"If disabled, prev/next buttons will not be displayed",value:!0},counter:{type:"checkbox",label:"Show counter",tip:"Display the total number of images and index number of the currently displayed slide",value:!0},download:{type:"checkbox",label:"Download icon",tip:"Enable download button",value:!0},enableDrag:{type:"checkbox",label:"Enable drag",tip:"Enables desktop mouse drag support",value:!0},enableSwipe:{type:"checkbox",label:"Enable swipe",tip:"Enables swipe support for mobile devices",value:!0},escKey:{type:"checkbox",label:"Enable Esc key",tip:'Whether the gallery could be closed by pressing the "Esc" key',value:!0},keyPress:{type:"checkbox",label:"Enable keyboard navigation",value:!1},loop:{type:"checkbox",label:"Loop",tip:"If false, will disable the ability to loop back to the beginning of the gallery from the last slide",value:!0},getCaptionFromTitleOrAlt:{type:"checkbox",label:"Caption from title or alt",tip:"Get captions from alt or title tags",value:!0},showMaximizeIcon:{type:"checkbox",label:"Show maximize icon",value:!1},closable:{type:"checkbox",label:"Closable",tip:"If false, it won't be possible to close the gallery",value:!0},showCloseIcon:{type:"checkbox",label:"Show close icon",tip:"If false, close button won't be displayed.",visible:({component:n})=>!!n.getTrait("closable").getValue(),value:!0},closeOnTap:{type:"checkbox",label:"Close on tap",tip:"Allows clicks on black area to close gallery",visible:({component:n})=>!!n.getTrait("closable").getValue(),value:!0}},fc={thumbnail:{category:{id:"thumbnail-options",label:"Thumbnail Options"},type:"checkbox",label:"Thumbnails",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"enableThumbDrag",label:"Thumbnail drag",tip:"Enable thumbnail drag on desktop",changeProp:!0,value:!0},{type:"checkbox",name:"enableThumbSwipe",label:"Thumbnail swipe",tip:"Enable thumbnail swipe on mobile devices",changeProp:!0,value:!0},{type:"select",name:"alignThumbnails",tip:"Position of thumbnails when the width of all thumbnails combined is less than the gallery's width",label:"Align Thumbnails",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"select",name:"currentPagerPosition",label:"Select thumbnail position",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"number",name:"thumbMargin",label:"Thumb margin",tip:"Spacing between each thumbnails",changeProp:!0,min:0,value:"5"},{type:"number",name:"thumbWidth",label:"Thumb width",tip:"Width of each thumbnails",changeProp:!0,min:0,value:"100"}]}}},uc={autoplay:{category:{id:"autoplay-options",label:"Autoplay options"},type:"checkbox",label:"Autoplay",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"autoplayControls",label:"Autoplay controls",tip:"Show/hide autoplay controls",changeProp:!0,value:!0},{type:"checkbox",name:"progressBar",label:"Progress bar",tip:"Show autoplay progress bar",changeProp:!0,value:!0},{type:"checkbox",name:"forceSlideShowAutoplay",label:"Force autoplay",tip:"If false, autoplay will be stopped after first user action",changeProp:!0,value:!1},{type:"checkbox",name:"slideShowAutoplay",label:"Start autoplay",tip:"Enable autoplay on start",changeProp:!0,value:!1},{type:"number",name:"slideShowInterval",label:"Interval",tip:"The time (in ms) between each auto transition",changeProp:!0,min:0,step:50,value:5e3}]}}},pc={zoom:{category:{id:"zoom-options",label:"Zoom options"},type:"checkbox",label:"Zoom",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"actualSize",label:"Show actual size icon",changeProp:!0,value:!0},{type:"checkbox",name:"infiniteZoom",label:"Infinte zoom",changeProp:!0,value:!0},{type:"checkbox",name:"showZoomInOutIcons",label:"Show zoom in/out icons",changeProp:!0,value:!1},{type:"number",name:"scale",label:"Scale",tip:"Value of zoom should be incremented/decremented",changeProp:!0,min:0,value:1}]}}},De="sourceType",yn="data-iframe",Vi={name:"href",type:"file",label:"Image Source"},In={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},zi={name:"data-poster",label:"Video Poster",type:"file"},Br={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},No={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},mc={[Dn]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var r,s;const t=e.target,i=(r=t==null?void 0:t.closestType(Xe))==null?void 0:r.getView();if(i&&t){const o=((s=i.getLightGallery())==null?void 0:s.items)||[],l=Array.from(o).indexOf(t.getEl());l>=0&&i.toggleGallery(l)}}},[De]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[Vi],video:[In,zi],external:[Br]},options:[{id:"image",label:Vi.label||"",icon:et.image},{id:"video",label:In.label||"",icon:et.video},{id:"external",label:Br.label||"",icon:et.external}]},subHtml:No},gc="lightGalleryComponent",Lr="lgThumbnail",yc="lgVideo",Hr="lgAutoplay",Fr="lgZoom",yt="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",bc=function(n,e={}){const{Blocks:t,Components:i}=n,r="LightGallery",s="LightGallery Item",o={toolbarIconOpen:et.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[Lr,yc,Hr,Fr],cdnScript:[`${yt}/lightgallery.min.js`,`${yt}/plugins/thumbnail/lg-thumbnail.min.js`,`${yt}/plugins/video/lg-video.min.js`,`${yt}/plugins/autoplay/lg-autoplay.min.js`,`${yt}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${yt}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=o,h=function(b){const C=this,k=window,{plugins:M,cdnScript:E,cdnStyle:L,inline:O,lgLicenseKey:Q,...V}=b||{},q=oe=>isNaN(oe)?void 0:parseInt(oe,10),_e=()=>{var un;const oe={...V,licenseKey:Q,speed:q(V.speed),startAnimationDuration:q(V.startAnimationDuration),thumbMargin:q(V.thumbMargin),thumbWidth:q(V.thumbWidth),slideShowInterval:q(V.slideShowInterval),scale:q(V.scale),enableZoomAfter:q(V.enableZoomAfter),plugins:(M||[]).map(pn=>k[pn])};O&&(oe.container=C,oe.closable=!1);const si=(un=k.lightGallery)==null?void 0:un.call(k,C,oe);O&&si.openGallery()};if(k.lightGallery)_e();else{const{head:oe}=document,si=Array.isArray(E)?[...E]:[E],un=Array.isArray(L)?[...L]:[L],pn=Ge=>{if(Ge.length){const Ee=document.createElement("link");Ee.href=Ge.shift(),Ee.rel="stylesheet",oe.appendChild(Ee),pn(Ge)}},Tr=Ge=>{if(Ge.length){const Ee=document.createElement("script");Ee.src=Ge.shift(),Ee.onerror=Ee.onload=Tr.bind(null,Ge),oe.appendChild(Ee)}else _e()};pn(un),Tr(si)}},d=b=>{const C=b.getTrait(Dn);if(!a||!C)return;const{toolbar:k}=b,M={id:Dn,label:a,command:()=>setTimeout(()=>C.runCommand(),100)};!k.find(L=>L.id===M.id)&&(k==null||k.unshift(M))};let f=[];const p=o.plugins||[],u=Ht(dc),m=p.includes(Lr)?Ht(fc):ai,g=p.includes(Hr)?Ht(uc):ai,y=p.includes(Fr)?Ht(pc):ai;i.addType(Xe,{block:l&&{label:r,media:et.gallery,category:"Extra",select:!0,...o.block},isComponent:b=>oi(b,Mn),extendFn:["init","initToolbar"],model:{defaults:{name:r,icon:et.gallery,draggable:(b,C)=>!C.is(Xe),attributes:{[Mn]:!0},components:{type:Vr},script:h,selector:"",exThumbImage:"",cdnScript:o.cdnScript,cdnStyle:o.cdnStyle,plugins:o.plugins,lgLicenseKey:o.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...u.propKeys,...m.propKeys,...g.propKeys,...y.propKeys],...u.props,...m.props,...g.props,...y.props,traits:[...u.traits,...m.traits,...g.traits,...y.traits]},init(){ci(this,["thumbnail"]),ci(this,["autoplay"]),ci(this,["zoom"])},initToolbar(){d(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){const b=i.events.scriptUnmount;b&&this.listenTo(this.model,b,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const b=this.getLightGallery();b==null||b.destroy()},disableLgInCanvas(){const b=this.getLightGallery();b.lgOpened=!0},isInlineGallery(){var C;const b=this.getLightGallery();return((C=b==null?void 0:b.settings)==null?void 0:C.container)===this.el},onLgInit(b){this.el.__lg=b.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:b}=this,{Canvas:C}=b,k=this.getLightGallery();f=C.getSpots(),setTimeout(()=>C.removeSpots()),k.__lgOpened=!0},onLgClose(){const b=this.getLightGallery();f.forEach(C=>this.em.Canvas.addSpot(C.attributes)),f=[],b.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(b){const C=this.getLightGallery();if(C.__lgOpened)return C.closeGallery(!0);C.lgOpened=!1,C.openGallery(b)}}});const S=Ht(mc);i.addType(Vr,{isComponent:b=>oi(b,zr)||b.tagName==="A"&&oi(b.parentElement,Mn),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:s,icon:et.galleryItem,attributes:{[zr]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...S.props,traits:[...S.traits]},init(){const b=[De].map(C=>`change:${C}`).join(" ");this.initSourceType(),this.on(b,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),hc(this,De,this.triggerGalleryUpdate)},initToolbar(){d(this)},initScriptUpdate(){const b=[No.name].map(C=>`change:attributes:${C}`).join(" ");this.on(b,this.triggerGalleryUpdate)},triggerGalleryUpdate(...b){var C;(C=this.closestType(Xe))==null||C.__scriptPropsChange(...b)},updateTraits(b={}){const{changed:C}=this,{init:k}=b;if(C[De]||k){Pi(this,De);const M=this.getTrait(De).getValue();if(M===Ct.image){this.removeAttributes([In.name,zi.name,yn]);const E=this.getTrait(Vi.name);E.setValue(E.getValue()||c)}else M===Ct.video?this.removeAttributes([yn]):M===Ct.external&&this.addAttributes({[yn]:!0})}},initSourceType(){const b=this.getAttributes({noClass:!0,noStyle:!0});b[yn]?this.set(De,Ct.external):(b[In.name]||b[zi.name])&&this.set(De,Ct.video)}}}),Bt({editor:n,plan:pe.free,licenseKey:o.licenseKey,pluginName:gc,cleanup:()=>{t.remove(Xe),i.removeType(Xe)}})},xc=zt(bc);function $(n){this.content=n}$.prototype={constructor:$,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var i=t&&t!=n?this.remove(t):this,r=i.find(n),s=i.content.slice();return r==-1?s.push(t||n,e):(s[r+1]=e,t&&(s[r]=t)),new $(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new $(t)},addToStart:function(n,e){return new $([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new $(t)},addBefore:function(n,e,t){var i=this.remove(e),r=i.content.slice(),s=i.find(n);return r.splice(s==-1?r.length:s,0,e,t),new $(r)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=$.from(n),n.size?new $(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=$.from(n),n.size?new $(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=$.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};$.from=function(n){if(n instanceof $)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new $(e)};function Eo(n,e,t){for(let i=0;;i++){if(i==n.childCount||i==e.childCount)return n.childCount==e.childCount?null:t;let r=n.child(i),s=e.child(i);if(r==s){t+=r.nodeSize;continue}if(!r.sameMarkup(s))return t;if(r.isText&&r.text!=s.text){for(let o=0;r.text[o]==s.text[o];o++)t++;return t}if(r.content.size||s.content.size){let o=Eo(r.content,s.content,t+1);if(o!=null)return o}t+=r.nodeSize}}function Do(n,e,t,i){for(let r=n.childCount,s=e.childCount;;){if(r==0||s==0)return r==s?null:{a:t,b:i};let o=n.child(--r),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,i-=a;continue}if(!o.sameMarkup(l))return{a:t,b:i};if(o.isText&&o.text!=l.text){let c=0,h=Math.min(o.text.length,l.text.length);for(;c<h&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,i--;return{a:t,b:i}}if(o.content.size||l.content.size){let c=Do(o.content,l.content,t-1,i-1);if(c)return c}t-=a,i-=a}}class x{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let i=0;i<e.length;i++)this.size+=e[i].nodeSize}nodesBetween(e,t,i,r=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&i(a,r+l,s||null,o)!==!1&&a.content.size){let h=l+1;a.nodesBetween(Math.max(0,e-h),Math.min(a.content.size,t-h),i,r+h)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,i,r){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?r?typeof r=="function"?r(l):r:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&i&&(o?o=!1:s+=i),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,i=e.firstChild,r=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(i)&&(r[r.length-1]=t.withText(t.text+i.text),s=1);s<e.content.length;s++)r.push(e.content[s]);return new x(r,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let i=[],r=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),i.push(l),r+=l.nodeSize),o=a}return new x(i,r)}cutByIndex(e,t){return e==t?x.empty:e==0&&t==this.content.length?this:new x(this.content.slice(e,t))}replaceChild(e,t){let i=this.content[e];if(i==t)return this;let r=this.content.slice(),s=this.size+t.nodeSize-i.nodeSize;return r[e]=t,new x(r,s)}addToStart(e){return new x([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new x(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,i=0;t<this.content.length;t++){let r=this.content[t];e(r,i,t),i+=r.nodeSize}}findDiffStart(e,t=0){return Eo(this,e,t)}findDiffEnd(e,t=this.size,i=e.size){return Do(this,e,t,i)}findIndex(e,t=-1){if(e==0)return bn(0,e);if(e==this.size)return bn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let i=0,r=0;;i++){let s=this.child(i),o=r+s.nodeSize;if(o>=e)return o==e||t>0?bn(i+1,o):bn(i,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return x.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new x(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return x.empty;let t,i=0;for(let r=0;r<e.length;r++){let s=e[r];i+=s.nodeSize,r&&s.isText&&e[r-1].sameMarkup(s)?(t||(t=e.slice(0,r)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new x(t||e,i)}static from(e){if(!e)return x.empty;if(e instanceof x)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new x([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}x.empty=new x([],0);const hi={index:0,offset:0};function bn(n,e){return hi.index=n,hi.offset=e,hi}function Rn(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!Rn(n[i],e[i]))return!1}else{for(let i in n)if(!(i in e)||!Rn(n[i],e[i]))return!1;for(let i in e)if(!(i in n))return!1}return!0}class I{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,i=!1;for(let r=0;r<e.length;r++){let s=e[r];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,r));else{if(s.type.excludes(this.type))return e;!i&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),i=!0),t&&t.push(s)}}return t||(t=e.slice()),i||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Rn(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let i=e.marks[t.type];if(!i)throw new RangeError(`There is no mark type ${t.type} in this schema`);let r=i.create(t.attrs);return i.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!e[i].eq(t[i]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return I.none;if(e instanceof I)return[e];let t=e.slice();return t.sort((i,r)=>i.type.rank-r.type.rank),t}}I.none=[];class Pn extends Error{}class w{constructor(e,t,i){this.content=e,this.openStart=t,this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let i=Ro(this.content,e+this.openStart,t);return i&&new w(i,this.openStart,this.openEnd)}removeBetween(e,t){return new w(Io(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return w.empty;let i=t.openStart||0,r=t.openEnd||0;if(typeof i!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new w(x.fromJSON(e,t.content),i,r)}static maxOpen(e,t=!0){let i=0,r=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)i++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)r++;return new w(e,i,r)}}w.empty=new w(x.empty,0,0);function Io(n,e,t){let{index:i,offset:r}=n.findIndex(e),s=n.maybeChild(i),{index:o,offset:l}=n.findIndex(t);if(r==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(i!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(i,s.copy(Io(s.content,e-r-1,t-r-1)))}function Ro(n,e,t,i){let{index:r,offset:s}=n.findIndex(e),o=n.maybeChild(r);if(s==e||o.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=Ro(o.content,e-s-1,t);return l&&n.replaceChild(r,o.copy(l))}function Cc(n,e,t){if(t.openStart>n.depth)throw new Pn("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Pn("Inconsistent open depths");return Po(n,e,t,0)}function Po(n,e,t,i){let r=n.index(i),s=n.node(i);if(r==e.index(i)&&i<n.depth-t.openStart){let o=Po(n,e,t,i+1);return s.copy(s.content.replaceChild(r,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==i&&e.depth==i){let o=n.parent,l=o.content;return st(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=wc(t,n);return st(s,zo(n,o,l,e,i))}else return st(s,Vn(n,e,i))}function Vo(n,e){if(!e.type.compatibleContent(n.type))throw new Pn("Cannot join "+e.type.name+" onto "+n.type.name)}function Bi(n,e,t){let i=n.node(t);return Vo(i,e.node(t)),i}function rt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function _t(n,e,t,i){let r=(e||n).node(t),s=0,o=e?e.index(t):r.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(rt(n.nodeAfter,i),s++));for(let l=s;l<o;l++)rt(r.child(l),i);e&&e.depth==t&&e.textOffset&&rt(e.nodeBefore,i)}function st(n,e){return n.type.checkContent(e),n.copy(e)}function zo(n,e,t,i,r){let s=n.depth>r&&Bi(n,e,r+1),o=i.depth>r&&Bi(t,i,r+1),l=[];return _t(null,n,r,l),s&&o&&e.index(r)==t.index(r)?(Vo(s,o),rt(st(s,zo(n,e,t,i,r+1)),l)):(s&&rt(st(s,Vn(n,e,r+1)),l),_t(e,t,r,l),o&&rt(st(o,Vn(t,i,r+1)),l)),_t(i,null,r,l),new x(l)}function Vn(n,e,t){let i=[];if(_t(null,n,t,i),n.depth>t){let r=Bi(n,e,t+1);rt(st(r,Vn(n,e,t+1)),i)}return _t(e,null,t,i),new x(i)}function wc(n,e){let t=e.depth-n.openStart,r=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)r=e.node(s).copy(x.from(r));return{start:r.resolveNoCache(n.openStart+t),end:r.resolveNoCache(r.content.size-n.openEnd-t)}}class Qt{constructor(e,t,i){this.pos=e,this.path=t,this.parentOffset=i,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let i=this.pos-this.path[this.path.length-1],r=e.child(t);return i?e.child(t).cut(i):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let i=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)r+=i.child(s).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return I.none;if(this.textOffset)return e.child(t).marks;let i=e.maybeChild(t-1),r=e.maybeChild(t);if(!i){let l=i;i=r,r=l}let s=i.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!r||!s[o].isInSet(r.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let i=t.marks,r=e.parent.maybeChild(e.index());for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!r||!i[s].isInSet(r.marks))&&(i=i[s--].removeFromSet(i));return i}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let i=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);i>=0;i--)if(e.pos<=this.end(i)&&(!t||t(this.node(i))))return new zn(this,e,i);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let i=[],r=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(i.push(o,l,r+a),!c||(o=o.child(l),o.isText))break;s=c-1,r+=a+1}return new Qt(t,i,s)}static resolveCached(e,t){let i=$r.get(e);if(i)for(let s=0;s<i.elts.length;s++){let o=i.elts[s];if(o.pos==t)return o}else $r.set(e,i=new Sc);let r=i.elts[i.i]=Qt.resolve(e,t);return i.i=(i.i+1)%kc,r}}class Sc{constructor(){this.elts=[],this.i=0}}const kc=12,$r=new WeakMap;class zn{constructor(e,t,i){this.$from=e,this.$to=t,this.depth=i}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const vc=Object.create(null);let ot=class Li{constructor(e,t,i,r=I.none){this.type=e,this.attrs=t,this.marks=r,this.content=i||x.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,i,r=0){this.content.nodesBetween(e,t,i,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,i,r){return this.content.textBetween(e,t,i,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,i){return this.type==e&&Rn(this.attrs,t||e.defaultAttrs||vc)&&I.sameSet(this.marks,i||I.none)}copy(e=null){return e==this.content?this:new Li(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Li(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,i=!1){if(e==t)return w.empty;let r=this.resolve(e),s=this.resolve(t),o=i?0:r.sharedDepth(t),l=r.start(o),c=r.node(o).content.cut(r.pos-l,s.pos-l);return new w(c,r.depth-o,s.depth-o)}replace(e,t,i){return Cc(this.resolve(e),this.resolve(t),i)}nodeAt(e){for(let t=this;;){let{index:i,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(i),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:i}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:i}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:i}=this.content.findIndex(e);if(i<e)return{node:this.content.child(t),index:t,offset:i};let r=this.content.child(t-1);return{node:r,index:t-1,offset:i-r.nodeSize}}resolve(e){return Qt.resolveCached(this,e)}resolveNoCache(e){return Qt.resolve(this,e)}rangeHasMark(e,t,i){let r=!1;return t>e&&this.nodesBetween(e,t,s=>(i.isInSet(s.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Bo(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,i=x.empty,r=0,s=i.childCount){let o=this.contentMatchAt(e).matchFragment(i,r,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=r;a<s;a++)if(!this.type.allowsMarks(i.child(a).marks))return!1;return!0}canReplaceWith(e,t,i,r){if(r&&!this.type.allowsMarks(r))return!1;let s=this.contentMatchAt(e).matchType(i),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=I.none;for(let t=0;t<this.marks.length;t++){let i=this.marks[t];i.type.checkAttrs(i.attrs),e=i.addToSet(e)}if(!I.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let i;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,i)}let r=x.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,r,i);return s.type.checkAttrs(s.attrs),s}};ot.prototype.text=void 0;class Bn extends ot{constructor(e,t,i,r){if(super(e,t,null,r),!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Bo(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Bn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Bn(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Bo(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class ht{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let i=new Mc(e,t);if(i.next==null)return ht.empty;let r=Lo(i);i.next&&i.err("Unexpected trailing text");let s=Ic(Dc(r));return Rc(s,i),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,i=e.childCount){let r=this;for(let s=t;r&&s<i;s++)r=r.matchType(e.child(s).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let i=0;i<e.next.length;i++)if(this.next[t].type==e.next[i].type)return!0;return!1}fillBefore(e,t=!1,i=0){let r=[this];function s(o,l){let a=o.matchFragment(e,i);if(a&&(!t||a.validEnd))return x.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:h,next:d}=o.next[c];if(!(h.isText||h.hasRequiredAttrs())&&r.indexOf(d)==-1){r.push(d);let f=s(d,l.concat(h));if(f)return f}}return null}return s(this,[])}findWrapping(e){for(let i=0;i<this.wrapCache.length;i+=2)if(this.wrapCache[i]==e)return this.wrapCache[i+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),i=[{match:this,type:null,via:null}];for(;i.length;){let r=i.shift(),s=r.match;if(s.matchType(e)){let o=[];for(let l=r;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!r.type||a.validEnd)&&(i.push({match:l.contentMatch,type:l,via:r}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(i){e.push(i);for(let r=0;r<i.next.length;r++)e.indexOf(i.next[r].next)==-1&&t(i.next[r].next)}return t(this),e.map((i,r)=>{let s=r+(i.validEnd?"*":" ")+" ";for(let o=0;o<i.next.length;o++)s+=(o?", ":"")+i.next[o].type.name+"->"+e.indexOf(i.next[o].next);return s}).join(`
75
+ `)}}ht.empty=new ht(!0);class Mc{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Lo(n){let e=[];do e.push(Tc(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Tc(n){let e=[];do e.push(Oc(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Oc(n){let e=Ec(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Ac(n,e);else break;return e}function Wr(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Ac(n,e){let t=Wr(n),i=t;return n.eat(",")&&(n.next!="}"?i=Wr(n):i=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:i,expr:e}}function Nc(n,e){let t=n.nodeTypes,i=t[e];if(i)return[i];let r=[];for(let s in t){let o=t[s];o.isInGroup(e)&&r.push(o)}return r.length==0&&n.err("No node type or group '"+e+"' found"),r}function Ec(n){if(n.eat("(")){let e=Lo(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Nc(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Dc(n){let e=[[]];return r(s(n,0),t()),e;function t(){return e.push([])-1}function i(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function r(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;r(c,l=t())}else if(o.type=="star"){let a=t();return i(l,a),r(s(o.expr,a),a),[i(a)]}else if(o.type=="plus"){let a=t();return r(s(o.expr,l),a),r(s(o.expr,a),a),[i(a)]}else{if(o.type=="opt")return[i(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let h=t();r(s(o.expr,a),h),a=h}if(o.max==-1)r(s(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let h=t();i(a,h),r(s(o.expr,a),h),a=h}return[i(a)]}else{if(o.type=="name")return[i(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Ho(n,e){return e-n}function Kr(n,e){let t=[];return i(e),t.sort(Ho);function i(r){let s=n[r];if(s.length==1&&!s[0].term)return i(s[0].to);t.push(r);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&i(a)}}}function Ic(n){let e=Object.create(null);return t(Kr(n,0));function t(i){let r=[];i.forEach(o=>{n[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let h=0;h<r.length;h++)r[h][0]==l&&(c=r[h][1]);Kr(n,a).forEach(h=>{c||r.push([l,c=[]]),c.indexOf(h)==-1&&c.push(h)})})});let s=e[i.join(",")]=new ht(i.indexOf(n.length-1)>-1);for(let o=0;o<r.length;o++){let l=r[o][1].sort(Ho);s.next.push({type:r[o][0],next:e[l.join(",")]||t(l)})}return s}}function Rc(n,e){for(let t=0,i=[n];t<i.length;t++){let r=i[t],s=!r.validEnd,o=[];for(let l=0;l<r.next.length;l++){let{type:a,next:c}=r.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),i.indexOf(c)==-1&&i.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Fo(n){let e=Object.create(null);for(let t in n){let i=n[t];if(!i.hasDefault)return null;e[t]=i.default}return e}function $o(n,e){let t=Object.create(null);for(let i in n){let r=e&&e[i];if(r===void 0){let s=n[i];if(s.hasDefault)r=s.default;else throw new RangeError("No value supplied for attribute "+i)}t[i]=r}return t}function Wo(n,e,t,i){for(let r in e)if(!(r in n))throw new RangeError(`Unsupported attribute ${r} for ${t} of type ${r}`);for(let r in n){let s=n[r];s.validate&&s.validate(e[r])}}function Ko(n,e){let t=Object.create(null);if(e)for(let i in e)t[i]=new Vc(n,i,e[i]);return t}let Jr=class Jo{constructor(e,t,i){this.name=e,this.schema=t,this.spec=i,this.markSet=null,this.groups=i.group?i.group.split(" "):[],this.attrs=Ko(e,i.attrs),this.defaultAttrs=Fo(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(i.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ht.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:$o(this.attrs,e)}create(e=null,t,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ot(this,this.computeAttrs(e),x.from(t),I.setFrom(i))}createChecked(e=null,t,i){return t=x.from(t),this.checkContent(t),new ot(this,this.computeAttrs(e),t,I.setFrom(i))}createAndFill(e=null,t,i){if(e=this.computeAttrs(e),t=x.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let r=this.contentMatch.matchFragment(t),s=r&&r.fillBefore(x.empty,!0);return s?new ot(this,e,t.append(s),I.setFrom(i)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let i=0;i<e.childCount;i++)if(!this.allowsMarks(e.child(i).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Wo(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let i=0;i<e.length;i++)this.allowsMarkType(e[i].type)?t&&t.push(e[i]):t||(t=e.slice(0,i));return t?t.length?t:I.none:e}static compile(e,t){let i=Object.create(null);e.forEach((s,o)=>i[s]=new Jo(s,t,o));let r=t.spec.topNode||"doc";if(!i[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!i.text)throw new RangeError("Every schema needs a 'text' type");for(let s in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}};function Pc(n,e,t){let i=t.split("|");return r=>{let s=r===null?"null":typeof r;if(i.indexOf(s)<0)throw new RangeError(`Expected value of type ${i} for attribute ${e} on type ${n}, got ${s}`)}}class Vc{constructor(e,t,i){this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default"),this.default=i.default,this.validate=typeof i.validate=="string"?Pc(e,t,i.validate):i.validate}get isRequired(){return!this.hasDefault}}class Zn{constructor(e,t,i,r){this.name=e,this.rank=t,this.schema=i,this.spec=r,this.attrs=Ko(e,r.attrs),this.excluded=null;let s=Fo(this.attrs);this.instance=s?new I(this,s):null}create(e=null){return!e&&this.instance?this.instance:new I(this,$o(this.attrs,e))}static compile(e,t){let i=Object.create(null),r=0;return e.forEach((s,o)=>i[s]=new Zn(s,r++,t,o)),i}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Wo(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class zc{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let r in e)t[r]=e[r];t.nodes=$.from(e.nodes),t.marks=$.from(e.marks||{}),this.nodes=Jr.compile(this.spec.nodes,this),this.marks=Zn.compile(this.spec.marks,this);let i=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let s=this.nodes[r],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=i[o]||(i[o]=ht.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?qr(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let r in this.marks){let s=this.marks[r],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:qr(this,o.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,i,r){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Jr){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,i,r)}text(e,t){let i=this.nodes.text;return new Bn(i,i.defaultAttrs,e,I.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return ot.fromJSON(this,e)}markFromJSON(e){return I.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function qr(n,e){let t=[];for(let i=0;i<e.length;i++){let r=e[i],s=n.marks[r],o=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(r=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(r)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[i]+"'")}return t}function Bc(n){return n.tag!=null}function Lc(n){return n.style!=null}class Et{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let i=this.matchedStyles=[];t.forEach(r=>{if(Bc(r))this.tags.push(r);else if(Lc(r)){let s=/[^=]*/.exec(r.style)[0];i.indexOf(s)<0&&i.push(s),this.styles.push(r)}}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let s=e.nodes[r.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let i=new _r(this,t,!1);return i.addAll(e,I.none,t.from,t.to),i.finish()}parseSlice(e,t={}){let i=new _r(this,t,!0);return i.addAll(e,I.none,t.from,t.to),w.maxOpen(i.finish())}matchTag(e,t,i){for(let r=i?this.tags.indexOf(i)+1:0;r<this.tags.length;r++){let s=this.tags[r];if($c(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,i,r){for(let s=r?this.styles.indexOf(r)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!i.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function i(r){let s=r.priority==null?50:r.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,r)}for(let r in e.marks){let s=e.marks[r].spec.parseDOM;s&&s.forEach(o=>{i(o=Gr(o)),o.mark||o.ignore||o.clearMark||(o.mark=r)})}for(let r in e.nodes){let s=e.nodes[r].spec.parseDOM;s&&s.forEach(o=>{i(o=Gr(o)),o.node||o.ignore||o.mark||(o.node=r)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Et(e,Et.schemaRules(e)))}}const qo={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Hc={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},jo={ol:!0,ul:!0},Ln=1,Hn=2,Gt=4;function jr(n,e,t){return e!=null?(e?Ln:0)|(e==="full"?Hn:0):n&&n.whitespace=="pre"?Ln|Hn:t&~Gt}class xn{constructor(e,t,i,r,s,o){this.type=e,this.attrs=t,this.marks=i,this.solid=r,this.options=o,this.content=[],this.activeMarks=I.none,this.match=s||(o&Gt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(x.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let i=this.type.contentMatch,r;return(r=i.findWrapping(e.type))?(this.match=i,r):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ln)){let i=this.content[this.content.length-1],r;if(i&&i.isText&&(r=/[ \t\r\n\u000c]+$/.exec(i.text))){let s=i;i.text.length==r[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-r[0].length))}}let t=x.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(x.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!qo.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class _r{constructor(e,t,i){this.parser=e,this.options=t,this.isOpen=i,this.open=0;let r=t.topNode,s,o=jr(null,t.preserveWhitespace,0)|(i?Gt:0);r?s=new xn(r.type,r.attrs,I.none,!0,t.topMatch||r.type.contentMatch,o):i?s=new xn(null,null,I.none,!0,null,o):s=new xn(e.schema.topNodeType,null,I.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let i=e.nodeValue,r=this.top;if(r.options&Hn||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(i)){if(r.options&Ln)r.options&Hn?i=i.replace(/\r\n?/g,`
76
+ `):i=i.replace(/\r?\n|\r/g," ");else if(i=i.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(i)&&this.open==this.nodes.length-1){let s=r.content[r.content.length-1],o=e.previousSibling;(!s||o&&o.nodeName=="BR"||s.isText&&/[ \t\r\n\u000c]$/.test(s.text))&&(i=i.slice(1))}i&&this.insertNode(this.parser.schema.text(i),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,i){let r=e.nodeName.toLowerCase(),s;jo.hasOwnProperty(r)&&this.parser.normalizeLists&&Fc(e);let o=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(s=this.parser.matchTag(e,this,i));if(o?o.ignore:Hc.hasOwnProperty(r))this.findInside(e),this.ignoreFallback(e,t);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(e=o.skip);let l,a=this.top,c=this.needsBlock;if(qo.hasOwnProperty(r))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),l=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);return}let h=o&&o.skip?t:this.readStyles(e,t);h&&this.addAll(e,h),l&&this.sync(a),this.needsBlock=c}else{let l=this.readStyles(e,t);l&&this.addElementByRule(e,o,l,o.consuming===!1?s:void 0)}}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
77
+ `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let i=e.style;if(i&&i.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let s=this.parser.matchedStyles[r],o=i.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,i,r){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),i)||this.leafFallback(e,i);else{let a=this.enter(o,t.attrs||null,i,t.preserveWhitespace);a&&(s=!0,i=a)}else{let a=this.parser.schema.marks[t.mark];i=i.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,i,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,i));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,i),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,i,r){let s=i||0;for(let o=i?e.childNodes[i]:e.firstChild,l=r==null?null:e.childNodes[r];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t){let i,r;for(let s=this.open;s>=0;s--){let o=this.nodes[s],l=o.findWrapping(e);if(l&&(!i||i.length>l.length)&&(i=l,r=o,!l.length)||o.solid)break}if(!i)return null;this.sync(r);for(let s=0;s<i.length;s++)t=this.enterInner(i[s],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let r=this.textblockFromContext();r&&(t=this.enterInner(r,null,t))}let i=this.findPlace(e,t);if(i){this.closeExtra();let r=this.top;r.match&&(r.match=r.match.matchType(e.type));let s=I.none;for(let o of i.concat(e.marks))(r.type?r.type.allowsMarkType(o.type):Ur(o.type,e.type))&&(s=o.addToSet(s));return r.content.push(e.mark(s)),!0}return!1}enter(e,t,i,r){let s=this.findPlace(e.create(t),i);return s&&(s=this.enterInner(e,t,i,!0,r)),s}enterInner(e,t,i,r=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=jr(e,s,o.options);o.options&Gt&&o.content.length==0&&(l|=Gt);let a=I.none;return i=i.filter(c=>(o.type?o.type.allowsMarkType(c.type):Ur(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new xn(e,t,a,r,null,l)),this.open++,i}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let i=this.nodes[t].content;for(let r=i.length-1;r>=0;r--)e+=i[r].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let i=0;i<this.find.length;i++)this.find[i].node==e&&this.find[i].offset==t&&(this.find[i].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,i){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(i?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),i=this.options.context,r=!this.isOpen&&(!i||i.parent.type==this.nodes[0].type),s=-(i?i.depth+1:0)+(r?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let h=a>0||a==0&&r?this.nodes[a].type:i&&a>=s?i.node(a-s).type:null;if(!h||h.name!=c&&!h.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(i&&i.isTextblock&&i.defaultAttrs)return i}for(let t in this.parser.schema.nodes){let i=this.parser.schema.nodes[t];if(i.isTextblock&&i.defaultAttrs)return i}}}function Fc(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let i=e.nodeType==1?e.nodeName.toLowerCase():null;i&&jo.hasOwnProperty(i)&&t?(t.appendChild(e),e=t):i=="li"?t=e:i&&(t=null)}}function $c(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Gr(n){let e={};for(let t in n)e[t]=n[t];return e}function Ur(n,e){let t=e.schema.nodes;for(let i in t){let r=t[i];if(!r.allowsMarkType(n))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:h}=l.edge(a);if(c==e||s.indexOf(h)<0&&o(h))return!0}};if(o(r.contentMatch))return!0}}class ut{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},i){i||(i=di(t).createDocumentFragment());let r=i,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)r=s.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],h=this.serializeMark(c,o.isInline,t);h&&(s.push([c,r]),r.appendChild(h.dom),r=h.contentDOM||h.dom)}}r.appendChild(this.serializeNodeInner(o,t))}),i}serializeNodeInner(e,t){let{dom:i,contentDOM:r}=Tn(di(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return i}serializeNode(e,t={}){let i=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let s=this.serializeMark(e.marks[r],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(i),i=s.dom)}return i}serializeMark(e,t,i={}){let r=this.marks[e.type.name];return r&&Tn(di(i),r(e,t),null,e.attrs)}static renderSpec(e,t,i=null,r){return Tn(e,t,i,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ut(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Zr(e.nodes);return t.text||(t.text=i=>i.text),t}static marksFromSchema(e){return Zr(e.marks)}}function Zr(n){let e={};for(let t in n){let i=n[t].spec.toDOM;i&&(e[t]=i)}return e}function di(n){return n.document||window.document}const Xr=new WeakMap;function Wc(n){let e=Xr.get(n);return e===void 0&&Xr.set(n,e=Kc(n)),e}function Kc(n){let e=null;function t(i){if(i&&typeof i=="object")if(Array.isArray(i))if(typeof i[0]=="string")e||(e=[]),e.push(i);else for(let r=0;r<i.length;r++)t(i[r]);else for(let r in i)t(i[r])}return t(n),e}function Tn(n,e,t,i){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let r=e[0],s;if(typeof r!="string")throw new RangeError("Invalid array passed to renderSpec");if(i&&(s=Wc(i))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=r.indexOf(" ");o>0&&(t=r.slice(0,o),r=r.slice(o+1));let l,a=t?n.createElementNS(t,r):n.createElement(r),c=e[1],h=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){h=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):a.setAttribute(d,c[d])}}for(let d=h;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:p,contentDOM:u}=Tn(n,f,t,i);if(a.appendChild(p),u){if(l)throw new RangeError("Multiple content holes");l=u}}}return{dom:a,contentDOM:l}}const _o=65535,Go=Math.pow(2,16);function Jc(n,e){return n+e*Go}function Yr(n){return n&_o}function qc(n){return(n-(n&_o))/Go}const Uo=1,Zo=2,On=4,Xo=8;class Hi{constructor(e,t,i){this.pos=e,this.delInfo=t,this.recover=i}get deleted(){return(this.delInfo&Xo)>0}get deletedBefore(){return(this.delInfo&(Uo|On))>0}get deletedAfter(){return(this.delInfo&(Zo|On))>0}get deletedAcross(){return(this.delInfo&On)>0}}class ie{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&ie.empty)return ie.empty}recover(e){let t=0,i=Yr(e);if(!this.inverted)for(let r=0;r<i;r++)t+=this.ranges[r*3+2]-this.ranges[r*3+1];return this.ranges[i*3]+t+qc(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,i){let r=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],h=this.ranges[l+o],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,p=a+r+(f<0?0:h);if(i)return p;let u=e==(t<0?a:d)?null:Jc(l/3,e-a),m=e==a?Zo:e==d?Uo:On;return(t<0?e!=a:e!=d)&&(m|=Xo),new Hi(p,m,u)}r+=h-c}return i?e+r:new Hi(e+r,0,null)}touches(e,t){let i=0,r=Yr(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+s],h=a+c;if(e<=h&&l==r*3)return!0;i+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,i=this.inverted?1:2;for(let r=0,s=0;r<this.ranges.length;r+=3){let o=this.ranges[r],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[r+t],h=this.ranges[r+i];e(l,l+c,a,a+h),s+=h-c}}invert(){return new ie(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ie.empty:new ie(e<0?[0,-e,0]:[0,0,e])}}ie.empty=new ie([]);class Mt{constructor(e=[],t,i=0,r=e.length){this.maps=e,this.mirror=t,this.from=i,this.to=r}slice(e=0,t=this.maps.length){return new Mt(this.maps,this.mirror,e,t)}copy(){return new Mt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,i=this.maps.length;t<e.maps.length;t++){let r=e.getMirror(t);this.appendMap(e.maps[t],r!=null&&r<t?i+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,i=this.maps.length+e.maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e.maps[t].invert(),r!=null&&r>t?i-r-1:void 0)}}invert(){let e=new Mt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let i=this.from;i<this.to;i++)e=this.maps[i].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,i){let r=0;for(let s=this.from;s<this.to;s++){let o=this.maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this.maps[a].recover(l.recover);continue}}r|=l.delInfo,e=l.pos}return i?e:new Hi(e,r,null)}}const fi=Object.create(null);class U{getMap(){return ie.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let i=fi[t.stepType];if(!i)throw new RangeError(`No step type ${t.stepType} defined`);return i.fromJSON(e,t)}static jsonID(e,t){if(e in fi)throw new RangeError("Duplicate use of step JSON ID "+e);return fi[e]=t,t.prototype.jsonID=e,t}}class B{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new B(e,null)}static fail(e){return new B(null,e)}static fromReplace(e,t,i,r){try{return B.ok(e.replace(t,i,r))}catch(s){if(s instanceof Pn)return B.fail(s.message);throw s}}}function ar(n,e,t){let i=[];for(let r=0;r<n.childCount;r++){let s=n.child(r);s.content.size&&(s=s.copy(ar(s.content,e,s))),s.isInline&&(s=e(s,t,r)),i.push(s)}return x.fromArray(i)}class Le extends U{constructor(e,t,i){super(),this.from=e,this.to=t,this.mark=i}apply(e){let t=e.slice(this.from,this.to),i=e.resolve(this.from),r=i.node(i.sharedDepth(this.to)),s=new w(ar(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),r),t.openStart,t.openEnd);return B.fromReplace(e,this.from,this.to,s)}invert(){return new ye(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deleted&&i.deleted||t.pos>=i.pos?null:new Le(t.pos,i.pos,this.mark)}merge(e){return e instanceof Le&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Le(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Le(t.from,t.to,e.markFromJSON(t.mark))}}U.jsonID("addMark",Le);class ye extends U{constructor(e,t,i){super(),this.from=e,this.to=t,this.mark=i}apply(e){let t=e.slice(this.from,this.to),i=new w(ar(t.content,r=>r.mark(this.mark.removeFromSet(r.marks)),e),t.openStart,t.openEnd);return B.fromReplace(e,this.from,this.to,i)}invert(){return new Le(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deleted&&i.deleted||t.pos>=i.pos?null:new ye(t.pos,i.pos,this.mark)}merge(e){return e instanceof ye&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ye(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ye(t.from,t.to,e.markFromJSON(t.mark))}}U.jsonID("removeMark",ye);class He extends U{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return B.fail("No node at mark step's position");let i=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return B.fromReplace(e,this.pos,this.pos+1,new w(x.from(i),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let i=this.mark.addToSet(t.marks);if(i.length==t.marks.length){for(let r=0;r<t.marks.length;r++)if(!t.marks[r].isInSet(i))return new He(this.pos,t.marks[r]);return new He(this.pos,this.mark)}}return new Dt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new He(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new He(t.pos,e.markFromJSON(t.mark))}}U.jsonID("addNodeMark",He);class Dt extends U{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return B.fail("No node at mark step's position");let i=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return B.fromReplace(e,this.pos,this.pos+1,new w(x.from(i),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new He(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Dt(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Dt(t.pos,e.markFromJSON(t.mark))}}U.jsonID("removeNodeMark",Dt);class _ extends U{constructor(e,t,i,r=!1){super(),this.from=e,this.to=t,this.slice=i,this.structure=r}apply(e){return this.structure&&Fi(e,this.from,this.to)?B.fail("Structure replace would overwrite content"):B.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ie([this.from,this.to-this.from,this.slice.size])}invert(e){return new _(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deletedAcross&&i.deletedAcross?null:new _(t.pos,Math.max(t.pos,i.pos),this.slice)}merge(e){if(!(e instanceof _)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?w.empty:new w(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new _(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?w.empty:new w(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new _(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new _(t.from,t.to,w.fromJSON(e,t.slice),!!t.structure)}}U.jsonID("replace",_);class J extends U{constructor(e,t,i,r,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=i,this.gapTo=r,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Fi(e,this.from,this.gapFrom)||Fi(e,this.gapTo,this.to)))return B.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return B.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,t.content);return i?B.fromReplace(e,this.from,this.to,i):B.fail("Content does not fit in gap")}getMap(){return new ie([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new J(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?i.pos:e.map(this.gapTo,1);return t.deletedAcross&&i.deletedAcross||r<t.pos||s>i.pos?null:new J(t.pos,i.pos,r,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new J(t.from,t.to,t.gapFrom,t.gapTo,w.fromJSON(e,t.slice),t.insert,!!t.structure)}}U.jsonID("replaceAround",J);function Fi(n,e,t){let i=n.resolve(e),r=t-e,s=i.depth;for(;r>0&&s>0&&i.indexAfter(s)==i.node(s).childCount;)s--,r--;if(r>0){let o=i.node(s).maybeChild(i.indexAfter(s));for(;r>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,r--}}return!1}function jc(n,e,t,i){let r=[],s=[],o,l;n.doc.nodesBetween(e,t,(a,c,h)=>{if(!a.isInline)return;let d=a.marks;if(!i.isInSet(d)&&h.type.allowsMarkType(i.type)){let f=Math.max(c,e),p=Math.min(c+a.nodeSize,t),u=i.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(u)||(o&&o.to==f&&o.mark.eq(d[m])?o.to=p:r.push(o=new ye(f,p,d[m])));l&&l.to==f?l.to=p:s.push(l=new Le(f,p,i))}}),r.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function _c(n,e,t,i){let r=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(i instanceof Zn){let c=o.marks,h;for(;h=i.isInSet(c);)(a||(a=[])).push(h),c=h.removeFromSet(c)}else i?i.isInSet(o.marks)&&(a=[i]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let h=0;h<a.length;h++){let d=a[h],f;for(let p=0;p<r.length;p++){let u=r[p];u.step==s-1&&d.eq(r[p].style)&&(f=u)}f?(f.to=c,f.step=s):r.push({style:d,from:Math.max(l,e),to:c,step:s})}}}),r.forEach(o=>n.step(new ye(o.from,o.to,o.style)))}function cr(n,e,t,i=t.contentMatch,r=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),h=l+c.nodeSize,d=i.matchType(c.type);if(!d)o.push(new _(l,h,w.empty));else{i=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new ye(l,h,c.marks[f]));if(r&&c.isText&&t.whitespace!="pre"){let f,p=/\r?\n|\r/g,u;for(;f=p.exec(c.text);)u||(u=new w(x.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new _(l+f.index,l+f.index+f[0].length,u))}}l=h}if(!i.validEnd){let a=i.fillBefore(x.empty,!0);n.replace(l,l,new w(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function Gc(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Xn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let i=n.depth;;--i){let r=n.$from.node(i),s=n.$from.index(i),o=n.$to.indexAfter(i);if(i<n.depth&&r.canReplace(s,o,t))return i;if(i==0||r.type.spec.isolating||!Gc(r,s,o))break}return null}function Uc(n,e,t){let{$from:i,$to:r,depth:s}=e,o=i.before(s+1),l=r.after(s+1),a=o,c=l,h=x.empty,d=0;for(let u=s,m=!1;u>t;u--)m||i.index(u)>0?(m=!0,h=x.from(i.node(u).copy(h)),d++):a--;let f=x.empty,p=0;for(let u=s,m=!1;u>t;u--)m||r.after(u+1)<r.end(u)?(m=!0,f=x.from(r.node(u).copy(f)),p++):c++;n.step(new J(a,c,o,l,new w(h.append(f),d,p),h.size-d,!0))}function Yo(n,e,t=null,i=n){let r=Zc(n,e),s=r&&Xc(i,e);return s?r.map(Qr).concat({type:e,attrs:t}).concat(s.map(Qr)):null}function Qr(n){return{type:n,attrs:null}}function Zc(n,e){let{parent:t,startIndex:i,endIndex:r}=n,s=t.contentMatchAt(i).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(i,r,o)?s:null}function Xc(n,e){let{parent:t,startIndex:i,endIndex:r}=n,s=t.child(i),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=i;a&&c<r;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function Yc(n,e,t){let i=x.empty;for(let o=t.length-1;o>=0;o--){if(i.size){let l=t[o].type.contentMatch.matchFragment(i);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=x.from(t[o].type.create(t[o].attrs,i))}let r=e.start,s=e.end;n.step(new J(r,s,r,s,new w(i,0,0),t.length,!0))}function Qc(n,e,t,i,r){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof r=="function"?r(o):r;if(o.isTextblock&&!o.hasMarkup(i,a)&&eh(n.doc,n.mapping.slice(s).map(l),i)){let c=null;if(i.schema.linebreakReplacement){let p=i.whitespace=="pre",u=!!i.contentMatch.matchType(i.schema.linebreakReplacement);p&&!u?c=!1:!p&&u&&(c=!0)}c===!1&&el(n,o,l,s),cr(n,n.mapping.slice(s).map(l,1),i,void 0,c===null);let h=n.mapping.slice(s),d=h.map(l,1),f=h.map(l+o.nodeSize,1);return n.step(new J(d,f,d+1,f-1,new w(x.from(i.create(a,null,o.marks)),0,0),1,!0)),c===!0&&Qo(n,o,l,s),!1}})}function Qo(n,e,t,i){e.forEach((r,s)=>{if(r.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(r.text);){let a=n.mapping.slice(i).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function el(n,e,t,i){e.forEach((r,s)=>{if(r.type==r.type.schema.linebreakReplacement){let o=n.mapping.slice(i).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
78
+ `))}})}function eh(n,e,t){let i=n.resolve(e),r=i.index();return i.parent.canReplaceWith(r,r+1,t)}function th(n,e,t,i,r){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(i,null,r||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new J(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new w(x.from(o),0,0),1,!0))}function Tt(n,e,t=1,i){let r=n.resolve(e),s=r.depth-t,o=i&&i[i.length-1]||r.parent;if(s<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!o.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let c=r.depth-1,h=t-2;c>s;c--,h--){let d=r.node(c),f=r.index(c);if(d.type.spec.isolating)return!1;let p=d.content.cutByIndex(f,d.childCount),u=i&&i[h+1];u&&(p=p.replaceChild(0,u.type.create(u.attrs)));let m=i&&i[h]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(p))return!1}let l=r.indexAfter(s),a=i&&i[0];return r.node(s).canReplaceWith(l,l,a?a.type:r.node(s+1).type)}function nh(n,e,t=1,i){let r=n.doc.resolve(e),s=x.empty,o=x.empty;for(let l=r.depth,a=r.depth-t,c=t-1;l>a;l--,c--){s=x.from(r.node(l).copy(s));let h=i&&i[c];o=x.from(h?h.type.create(h.attrs,o):r.node(l).copy(o))}n.step(new _(e,e,new w(s.append(o),t,t),!0))}function Yn(n,e){let t=n.resolve(e),i=t.index();return rh(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(i,i+1)}function ih(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:i}=n.type.schema;for(let r=0;r<e.childCount;r++){let s=e.child(r),o=s.type==i?n.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function rh(n,e){return!!(n&&e&&!n.isLeaf&&ih(n,e))}function sh(n,e,t){let i=null,{linebreakReplacement:r}=n.doc.type.schema,s=n.doc.resolve(e-t),o=s.node().type;if(r&&o.inlineContent){let h=o.whitespace=="pre",d=!!o.contentMatch.matchType(r);h&&!d?i=!1:!h&&d&&(i=!0)}let l=n.steps.length;if(i===!1){let h=n.doc.resolve(e+t);el(n,h.node(),h.before(),l)}o.inlineContent&&cr(n,e+t-1,o,s.node().contentMatchAt(s.index()),i==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new _(c,a.map(e+t,-1),w.empty,!0)),i===!0){let h=n.doc.resolve(c);Qo(n,h.node(),h.before(),n.steps.length)}return n}function oh(n,e,t){let i=n.resolve(e);if(i.parent.canReplaceWith(i.index(),i.index(),t))return e;if(i.parentOffset==0)for(let r=i.depth-1;r>=0;r--){let s=i.index(r);if(i.node(r).canReplaceWith(s,s,t))return i.before(r+1);if(s>0)return null}if(i.parentOffset==i.parent.content.size)for(let r=i.depth-1;r>=0;r--){let s=i.indexAfter(r);if(i.node(r).canReplaceWith(s,s,t))return i.after(r+1);if(s<i.node(r).childCount)return null}return null}function lh(n,e,t){let i=n.resolve(e);if(!t.content.size)return e;let r=t.content;for(let s=0;s<t.openStart;s++)r=r.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=i.depth;o>=0;o--){let l=o==i.depth?0:i.pos<=(i.start(o+1)+i.end(o+1))/2?-1:1,a=i.index(o)+(l>0?1:0),c=i.node(o),h=!1;if(s==1)h=c.canReplace(a,a,r);else{let d=c.contentMatchAt(a).findWrapping(r.firstChild.type);h=d&&c.canReplaceWith(a,a,d[0])}if(h)return l==0?i.pos:l<0?i.before(o+1):i.after(o+1)}return null}function hr(n,e,t=e,i=w.empty){if(e==t&&!i.size)return null;let r=n.resolve(e),s=n.resolve(t);return tl(r,s,i)?new _(e,t,i):new ah(r,s,i).fit()}function tl(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class ah{constructor(e,t,i){this.$from=e,this.$to=t,this.unplaced=i,this.frontier=[],this.placed=x.empty;for(let r=0;r<=e.depth;r++){let s=e.node(r);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(r))})}for(let r=e.depth;r>0;r--)this.placed=x.from(e.node(r).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,i=this.$from,r=this.close(e<0?this.$to:i.doc.resolve(e));if(!r)return null;let s=this.placed,o=i.depth,l=r.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new w(s,o,l);return e>-1?new J(i.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||i.pos!=this.$to.pos?new _(i.pos,r.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,i=0,r=this.unplaced.openEnd;i<e;i++){let s=t.firstChild;if(t.childCount>1&&(r=0),s.type.spec.isolating&&r<=i){e=i;break}t=s.content}for(let t=1;t<=2;t++)for(let i=t==1?e:this.unplaced.openStart;i>=0;i--){let r,s=null;i?(s=ui(this.unplaced.content,i-1).firstChild,r=s.content):r=this.unplaced.content;let o=r.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],h,d=null;if(t==1&&(o?c.matchType(o.type)||(d=c.fillBefore(x.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:i,frontierDepth:l,parent:s,inject:d};if(t==2&&o&&(h=c.findWrapping(o.type)))return{sliceDepth:i,frontierDepth:l,parent:s,wrap:h};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:i}=this.unplaced,r=ui(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new w(e,t+1,Math.max(i,r.size+t>=e.size-i?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:i}=this.unplaced,r=ui(e,t);if(r.childCount<=1&&t>0){let s=e.size-t<=t+r.size;this.unplaced=new w(Jt(e,t-1,1),t-1,s?t-1:i)}else this.unplaced=new w(Jt(e,t,1),t,i)}placeNodes({sliceDepth:e,frontierDepth:t,parent:i,inject:r,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let o=this.unplaced,l=i?i.content:o.content,a=o.openStart-e,c=0,h=[],{match:d,type:f}=this.frontier[t];if(r){for(let m=0;m<r.childCount;m++)h.push(r.child(m));d=d.matchFragment(r)}let p=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let m=l.child(c),g=d.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(d=g,h.push(nl(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?p:-1)))}let u=c==l.childCount;u||(p=-1),this.placed=qt(this.placed,t,x.from(h)),this.frontier[t].match=d,u&&p<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<p;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=u?e==0?w.empty:new w(Jt(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new w(Jt(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!pi(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:i}=this.$to,r=this.$to.after(i);for(;i>1&&r==this.$to.end(--i);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:i,type:r}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=pi(e,t,r,i,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],h=pi(e,l,c,a,!0);if(!h||h.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=qt(this.placed,t.depth,t.fit)),e=t.move;for(let i=t.depth+1;i<=e.depth;i++){let r=e.node(i),s=r.type.contentMatch.fillBefore(r.content,!0,e.index(i));this.openFrontierNode(r.type,r.attrs,s)}return e}openFrontierNode(e,t=null,i){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=qt(this.placed,this.depth,x.from(e.create(t,i))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(x.empty,!0);t.childCount&&(this.placed=qt(this.placed,this.frontier.length,t))}}function Jt(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Jt(n.firstChild.content,e-1,t)))}function qt(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(qt(n.lastChild.content,e-1,t)))}function ui(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function nl(n,e,t){if(e<=0)return n;let i=n.content;return e>1&&(i=i.replaceChild(0,nl(i.firstChild,e-1,i.childCount==1?t-1:0))),e>0&&(i=n.type.contentMatch.fillBefore(i).append(i),t<=0&&(i=i.append(n.type.contentMatch.matchFragment(i).fillBefore(x.empty,!0)))),n.copy(i)}function pi(n,e,t,i,r){let s=n.node(e),o=r?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=i.fillBefore(s.content,!0,o);return l&&!ch(t,s.content,o)?l:null}function ch(n,e,t){for(let i=t;i<e.childCount;i++)if(!n.allowsMarks(e.child(i).marks))return!0;return!1}function hh(n){return n.spec.defining||n.spec.definingForContent}function dh(n,e,t,i){if(!i.size)return n.deleteRange(e,t);let r=n.doc.resolve(e),s=n.doc.resolve(t);if(tl(r,s,i))return n.step(new _(e,t,i));let o=rl(r,n.doc.resolve(t));o[o.length-1]==0&&o.pop();let l=-(r.depth+1);o.unshift(l);for(let f=r.depth,p=r.pos-1;f>0;f--,p--){let u=r.node(f).type.spec;if(u.defining||u.definingAsContext||u.isolating)break;o.indexOf(f)>-1?l=f:r.before(f)==p&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],h=i.openStart;for(let f=i.content,p=0;;p++){let u=f.firstChild;if(c.push(u),p==i.openStart)break;f=u.content}for(let f=h-1;f>=0;f--){let p=c[f],u=hh(p.type);if(u&&!p.sameMarkup(r.node(Math.abs(l)-1)))h=f;else if(u||!p.type.isTextblock)break}for(let f=i.openStart;f>=0;f--){let p=(f+h+1)%(i.openStart+1),u=c[p];if(u)for(let m=0;m<o.length;m++){let g=o[(m+a)%o.length],y=!0;g<0&&(y=!1,g=-g);let S=r.node(g-1),b=r.index(g-1);if(S.canReplaceWith(b,b,u.type,u.marks))return n.replace(r.before(g),y?s.after(g):t,new w(il(i.content,0,i.openStart,p),p,i.openEnd))}}let d=n.steps.length;for(let f=o.length-1;f>=0&&(n.replace(e,t,i),!(n.steps.length>d));f--){let p=o[f];p<0||(e=r.before(p),t=s.after(p))}}function il(n,e,t,i,r){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(il(s.content,e+1,t,i,s)))}if(e>i){let s=r.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(x.empty,!0))}return n}function fh(n,e,t,i){if(!i.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let r=oh(n.doc,e,i.type);r!=null&&(e=t=r)}n.replaceRange(e,t,new w(x.from(i),0,0))}function uh(n,e,t){let i=n.doc.resolve(e),r=n.doc.resolve(t),s=rl(i,r);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||i.node(l).type.contentMatch.validEnd)return n.delete(i.start(l),r.end(l));if(l>0&&(a||i.node(l-1).canReplace(i.index(l-1),r.indexAfter(l-1))))return n.delete(i.before(l),r.after(l))}for(let o=1;o<=i.depth&&o<=r.depth;o++)if(e-i.start(o)==i.depth-o&&t>i.end(o)&&r.end(o)-t!=r.depth-o&&i.start(o-1)==r.start(o-1)&&i.node(o-1).canReplace(i.index(o-1),r.index(o-1)))return n.delete(i.before(o),t);n.delete(e,t)}function rl(n,e){let t=[],i=Math.min(n.depth,e.depth);for(let r=i;r>=0;r--){let s=n.start(r);if(s<n.pos-(n.depth-r)||e.end(r)>e.pos+(e.depth-r)||n.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(s==e.start(r)||r==n.depth&&r==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==s-1)&&t.push(r)}return t}class Ot extends U{constructor(e,t,i){super(),this.pos=e,this.attr=t,this.value=i}apply(e){let t=e.nodeAt(this.pos);if(!t)return B.fail("No node at attribute step's position");let i=Object.create(null);for(let s in t.attrs)i[s]=t.attrs[s];i[this.attr]=this.value;let r=t.type.create(i,null,t.marks);return B.fromReplace(e,this.pos,this.pos+1,new w(x.from(r),0,t.isLeaf?0:1))}getMap(){return ie.empty}invert(e){return new Ot(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ot(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ot(t.pos,t.attr,t.value)}}U.jsonID("attr",Ot);class en extends U{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let r in e.attrs)t[r]=e.attrs[r];t[this.attr]=this.value;let i=e.type.create(t,e.content,e.marks);return B.ok(i)}getMap(){return ie.empty}invert(e){return new en(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new en(t.attr,t.value)}}U.jsonID("docAttr",en);let It=class extends Error{};It=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};It.prototype=Object.create(Error.prototype);It.prototype.constructor=It;It.prototype.name="TransformError";class sl{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Mt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new It(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,i=w.empty){let r=hr(this.doc,e,t,i);return r&&this.step(r),this}replaceWith(e,t,i){return this.replace(e,t,new w(x.from(i),0,0))}delete(e,t){return this.replace(e,t,w.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,i){return dh(this,e,t,i),this}replaceRangeWith(e,t,i){return fh(this,e,t,i),this}deleteRange(e,t){return uh(this,e,t),this}lift(e,t){return Uc(this,e,t),this}join(e,t=1){return sh(this,e,t),this}wrap(e,t){return Yc(this,e,t),this}setBlockType(e,t=e,i,r=null){return Qc(this,e,t,i,r),this}setNodeMarkup(e,t,i=null,r){return th(this,e,t,i,r),this}setNodeAttribute(e,t,i){return this.step(new Ot(e,t,i)),this}setDocAttribute(e,t){return this.step(new en(e,t)),this}addNodeMark(e,t){return this.step(new He(e,t)),this}removeNodeMark(e,t){if(!(t instanceof I)){let i=this.doc.nodeAt(e);if(!i)throw new RangeError("No node at position "+e);if(t=t.isInSet(i.marks),!t)return this}return this.step(new Dt(e,t)),this}split(e,t=1,i){return nh(this,e,t,i),this}addMark(e,t,i){return jc(this,e,t,i),this}removeMark(e,t,i){return _c(this,e,t,i),this}clearIncompatible(e,t,i){return cr(this,e,t,i),this}}const mi=Object.create(null);class A{constructor(e,t,i){this.$anchor=e,this.$head=t,this.ranges=i||[new ol(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=w.empty){let i=t.content.lastChild,r=null;for(let l=0;l<t.openEnd;l++)r=i,i=i.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],h=e.mapping.slice(s);e.replaceRange(h.map(a.pos),h.map(c.pos),l?w.empty:t),l==0&&ns(e,s,(i?i.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let i=e.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:o,$to:l}=r[s],a=e.mapping.slice(i),c=a.map(o.pos),h=a.map(l.pos);s?e.deleteRange(c,h):(e.replaceRangeWith(c,h,t),ns(e,i,t.isInline?-1:1))}}static findFrom(e,t,i=!1){let r=e.parent.inlineContent?new N(e):wt(e.node(0),e.parent,e.pos,e.index(),t,i);if(r)return r;for(let s=e.depth-1;s>=0;s--){let o=t<0?wt(e.node(0),e.node(s),e.before(s+1),e.index(s),t,i):wt(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,i);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new se(e.node(0))}static atStart(e){return wt(e,e,0,0,1)||new se(e)}static atEnd(e){return wt(e,e,e.content.size,e.childCount,-1)||new se(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let i=mi[t.type];if(!i)throw new RangeError(`No selection type ${t.type} defined`);return i.fromJSON(e,t)}static jsonID(e,t){if(e in mi)throw new RangeError("Duplicate use of selection JSON ID "+e);return mi[e]=t,t.prototype.jsonID=e,t}getBookmark(){return N.between(this.$anchor,this.$head).getBookmark()}}A.prototype.visible=!0;class ol{constructor(e,t){this.$from=e,this.$to=t}}let es=!1;function ts(n){!es&&!n.parent.inlineContent&&(es=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class N extends A{constructor(e,t=e){ts(e),ts(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let i=e.resolve(t.map(this.head));if(!i.parent.inlineContent)return A.near(i);let r=e.resolve(t.map(this.anchor));return new N(r.parent.inlineContent?r:i,i)}replace(e,t=w.empty){if(super.replace(e,t),t==w.empty){let i=this.$from.marksAcross(this.$to);i&&e.ensureMarks(i)}}eq(e){return e instanceof N&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Qn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new N(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,i=t){let r=e.resolve(t);return new this(r,i==t?r:e.resolve(i))}static between(e,t,i){let r=e.pos-t.pos;if((!i||r)&&(i=r>=0?1:-1),!t.parent.inlineContent){let s=A.findFrom(t,i,!0)||A.findFrom(t,-i,!0);if(s)t=s.$head;else return A.near(t,i)}return e.parent.inlineContent||(r==0?e=t:(e=(A.findFrom(e,-i,!0)||A.findFrom(e,i,!0)).$anchor,e.pos<t.pos!=r<0&&(e=t))),new N(e,t)}}A.jsonID("text",N);class Qn{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Qn(e.map(this.anchor),e.map(this.head))}resolve(e){return N.between(e.resolve(this.anchor),e.resolve(this.head))}}class T extends A{constructor(e){let t=e.nodeAfter,i=e.node(0).resolve(e.pos+t.nodeSize);super(e,i),this.node=t}map(e,t){let{deleted:i,pos:r}=t.mapResult(this.anchor),s=e.resolve(r);return i?A.near(s):new T(s)}content(){return new w(x.from(this.node),0,0)}eq(e){return e instanceof T&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new dr(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new T(e.resolve(t.anchor))}static create(e,t){return new T(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}T.prototype.visible=!1;A.jsonID("node",T);class dr{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:i}=e.mapResult(this.anchor);return t?new Qn(i,i):new dr(i)}resolve(e){let t=e.resolve(this.anchor),i=t.nodeAfter;return i&&T.isSelectable(i)?new T(t):A.near(t)}}class se extends A{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=w.empty){if(t==w.empty){e.delete(0,e.doc.content.size);let i=A.atStart(e.doc);i.eq(e.selection)||e.setSelection(i)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new se(e)}map(e){return new se(e)}eq(e){return e instanceof se}getBookmark(){return ph}}A.jsonID("all",se);const ph={map(){return this},resolve(n){return new se(n)}};function wt(n,e,t,i,r,s=!1){if(e.inlineContent)return N.create(n,t);for(let o=i-(r>0?0:1);r>0?o<e.childCount:o>=0;o+=r){let l=e.child(o);if(l.isAtom){if(!s&&T.isSelectable(l))return T.create(n,t-(r<0?l.nodeSize:0))}else{let a=wt(n,l,t+r,r<0?l.childCount:0,r,s);if(a)return a}t+=l.nodeSize*r}return null}function ns(n,e,t){let i=n.steps.length-1;if(i<e)return;let r=n.steps[i];if(!(r instanceof _||r instanceof J))return;let s=n.mapping.maps[i],o;s.forEach((l,a,c,h)=>{o==null&&(o=h)}),n.setSelection(A.near(n.doc.resolve(o),t))}const is=1,Cn=2,rs=4;class mh extends sl{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|is)&~Cn,this.storedMarks=null,this}get selectionSet(){return(this.updated&is)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Cn,this}ensureMarks(e){return I.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Cn)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Cn,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let i=this.selection;return t&&(e=e.mark(this.storedMarks||(i.empty?i.$from.marks():i.$from.marksAcross(i.$to)||I.none))),i.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,i){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(i==null&&(i=t),i=i??t,!e)return this.deleteRange(t,i);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=i==t?o.marks():o.marksAcross(this.doc.resolve(i))}return this.replaceRangeWith(t,i,r.text(e,s)),this.selection.empty||this.setSelection(A.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=rs,this}get scrolledIntoView(){return(this.updated&rs)>0}}function ss(n,e){return!e||!n?n:n.bind(e)}class jt{constructor(e,t,i){this.name=e,this.init=ss(t.init,i),this.apply=ss(t.apply,i)}}const gh=[new jt("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new jt("selection",{init(n,e){return n.selection||A.atStart(e.doc)},apply(n){return n.selection}}),new jt("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,i){return i.selection.$cursor?n.storedMarks:null}}),new jt("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class gi{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=gh.slice(),t&&t.forEach(i=>{if(this.pluginsByKey[i.key])throw new RangeError("Adding different instances of a keyed plugin ("+i.key+")");this.plugins.push(i),this.pluginsByKey[i.key]=i,i.spec.state&&this.fields.push(new jt(i.key,i.spec.state,i))})}}class vt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let i=0;i<this.config.plugins.length;i++)if(i!=t){let r=this.config.plugins[i];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],i=this.applyInner(e),r=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=r?r[o].n:0,c=r?r[o].state:this,h=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,i);if(h&&i.filterTransaction(h,o)){if(h.setMeta("appendedTransaction",e),!r){r=[];for(let d=0;d<this.config.plugins.length;d++)r.push(d<o?{state:i,n:t.length}:{state:this,n:0})}t.push(h),i=i.applyInner(h),s=!0}r&&(r[o]={state:i,n:t.length})}}if(!s)return{state:i,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new vt(this.config),i=this.config.fields;for(let r=0;r<i.length;r++){let s=i[r];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new mh(this)}static create(e){let t=new gi(e.doc?e.doc.type.schema:e.schema,e.plugins),i=new vt(t);for(let r=0;r<t.fields.length;r++)i[t.fields[r].name]=t.fields[r].init(e,i);return i}reconfigure(e){let t=new gi(this.schema,e.plugins),i=t.fields,r=new vt(t);for(let s=0;s<i.length;s++){let o=i[s].name;r[o]=this.hasOwnProperty(o)?this[o]:i[s].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(i=>i.toJSON())),e&&typeof e=="object")for(let i in e){if(i=="doc"||i=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[i],s=r.spec.state;s&&s.toJSON&&(t[i]=s.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,i){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new gi(e.schema,e.plugins),s=new vt(r);return r.fields.forEach(o=>{if(o.name=="doc")s.doc=ot.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=A.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(i)for(let l in i){let a=i[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=c.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function ll(n,e,t){for(let i in n){let r=n[i];r instanceof Function?r=r.bind(e):i=="handleDOMEvents"&&(r=ll(r,e,{})),t[i]=r}return t}class ln{constructor(e){this.spec=e,this.props={},e.props&&ll(e.props,this,this.props),this.key=e.key?e.key.key:al("plugin")}getState(e){return e[this.key]}}const yi=Object.create(null);function al(n){return n in yi?n+"$"+ ++yi[n]:(yi[n]=0,n+"$")}class an{constructor(e="key"){this.key=al(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const cl=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function yh(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const bh=(n,e,t)=>{let i=yh(n,t);if(!i)return!1;let r=hl(i);if(!r){let o=i.blockRange(),l=o&&Xn(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=r.nodeBefore;if(gl(n,r,e,-1))return!0;if(i.parent.content.size==0&&(Rt(s,"end")||T.isSelectable(s)))for(let o=i.depth;;o--){let l=hr(n.doc,i.before(o),i.after(o),w.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(Rt(s,"end")?A.findFrom(a.doc.resolve(a.mapping.map(r.pos,-1)),-1):T.create(a.doc,r.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||i.node(o-1).childCount>1)break}return s.isAtom&&r.depth==i.depth-1?(e&&e(n.tr.delete(r.pos-s.nodeSize,r.pos).scrollIntoView()),!0):!1};function Rt(n,e,t=!1){for(let i=n;i;i=e=="start"?i.firstChild:i.lastChild){if(i.isTextblock)return!0;if(t&&i.childCount!=1)return!1}return!1}const xh=(n,e,t)=>{let{$head:i,empty:r}=n.selection,s=i;if(!r)return!1;if(i.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):i.parentOffset>0)return!1;s=hl(i)}let o=s&&s.nodeBefore;return!o||!T.isSelectable(o)?!1:(e&&e(n.tr.setSelection(T.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function hl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Ch(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const wh=(n,e,t)=>{let i=Ch(n,t);if(!i)return!1;let r=dl(i);if(!r)return!1;let s=r.nodeAfter;if(gl(n,r,e,1))return!0;if(i.parent.content.size==0&&(Rt(s,"start")||T.isSelectable(s))){let o=hr(n.doc,i.before(),i.after(),w.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(Rt(s,"start")?A.findFrom(l.doc.resolve(l.mapping.map(r.pos)),1):T.create(l.doc,l.mapping.map(r.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&r.depth==i.depth-1?(e&&e(n.tr.delete(r.pos,r.pos+s.nodeSize).scrollIntoView()),!0):!1},Sh=(n,e,t)=>{let{$head:i,empty:r}=n.selection,s=i;if(!r)return!1;if(i.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):i.parentOffset<i.parent.content.size)return!1;s=dl(i)}let o=s&&s.nodeAfter;return!o||!T.isSelectable(o)?!1:(e&&e(n.tr.setSelection(T.create(n.doc,s.pos)).scrollIntoView()),!0)};function dl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const kh=(n,e)=>{let{$head:t,$anchor:i}=n.selection;return!t.parent.type.spec.code||!t.sameParent(i)?!1:(e&&e(n.tr.insertText(`
79
+ `).scrollIntoView()),!0)};function fr(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const fl=(n,e)=>{let{$head:t,$anchor:i}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(i))return!1;let r=t.node(-1),s=t.indexAfter(-1),o=fr(r.contentMatchAt(s));if(!o||!r.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(A.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},vh=(n,e)=>{let t=n.selection,{$from:i,$to:r}=t;if(t instanceof se||i.parent.inlineContent||r.parent.inlineContent)return!1;let s=fr(r.parent.contentMatchAt(r.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!i.parentOffset&&r.index()<r.parent.childCount?i:r).pos,l=n.tr.insert(o,s.createAndFill());l.setSelection(N.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},ul=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Tt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let i=t.blockRange(),r=i&&Xn(i);return r==null?!1:(e&&e(n.tr.lift(i,r).scrollIntoView()),!0)};function pl(n){return(e,t)=>{let{$from:i,$to:r}=e.selection;if(e.selection instanceof T&&e.selection.node.isBlock)return!i.parentOffset||!Tt(e.doc,i.pos)?!1:(t&&t(e.tr.split(i.pos).scrollIntoView()),!0);if(!i.depth)return!1;let s=[],o,l,a=!1,c=!1;for(let p=i.depth;;p--)if(i.node(p).isBlock){a=i.end(p)==i.pos+(i.depth-p),c=i.start(p)==i.pos-(i.depth-p),l=fr(i.node(p-1).contentMatchAt(i.indexAfter(p-1)));let m=n&&n(r.parent,a,i);s.unshift(m||(a&&l?{type:l}:null)),o=p;break}else{if(p==1)return!1;s.unshift(null)}let h=e.tr;(e.selection instanceof N||e.selection instanceof se)&&h.deleteSelection();let d=h.mapping.map(i.pos),f=Tt(h.doc,d,s.length,s);if(f||(s[0]=l?{type:l}:null,f=Tt(h.doc,d,s.length,s)),h.split(d,s.length,s),!a&&c&&i.node(o).type!=l){let p=h.mapping.map(i.before(o)),u=h.doc.resolve(p);l&&i.node(o-1).canReplaceWith(u.index(),u.index()+1,l)&&h.setNodeMarkup(h.mapping.map(i.before(o)),l)}return t&&t(h.scrollIntoView()),!0}}const Mh=pl(),ml=(n,e)=>(e&&e(n.tr.setSelection(new se(n.doc))),!0);function Th(n,e,t){let i=e.nodeBefore,r=e.nodeAfter,s=e.index();return!i||!r||!i.type.compatibleContent(r.type)?!1:!i.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-i.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(r.isTextblock||Yn(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function gl(n,e,t,i){let r=e.nodeBefore,s=e.nodeAfter,o,l,a=r.type.spec.isolating||s.type.spec.isolating;if(!a&&Th(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=r.contentMatchAt(r.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let p=e.pos+s.nodeSize,u=x.empty;for(let y=o.length-1;y>=0;y--)u=x.from(o[y].create(null,u));u=x.from(r.copy(u));let m=n.tr.step(new J(e.pos-1,p,e.pos,p,new w(u,1,0),o.length,!0)),g=m.doc.resolve(p+2*o.length);g.nodeAfter&&g.nodeAfter.type==r.type&&Yn(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let h=s.type.spec.isolating||i>0&&a?null:A.findFrom(e,1),d=h&&h.$from.blockRange(h.$to),f=d&&Xn(d);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(d,f).scrollIntoView()),!0;if(c&&Rt(s,"start",!0)&&Rt(r,"end")){let p=r,u=[];for(;u.push(p),!p.isTextblock;)p=p.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,m.content)){if(t){let y=x.empty;for(let b=u.length-1;b>=0;b--)y=x.from(u[b].copy(y));let S=n.tr.step(new J(e.pos-u.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new w(y,u.length,0),0,!0));t(S.scrollIntoView())}return!0}}return!1}function yl(n){return function(e,t){let i=e.selection,r=n<0?i.$from:i.$to,s=r.depth;for(;r.node(s).isInline;){if(!s)return!1;s--}return r.node(s).isTextblock?(t&&t(e.tr.setSelection(N.create(e.doc,n<0?r.start(s):r.end(s)))),!0):!1}}const Oh=yl(-1),Ah=yl(1);function Nh(n,e=null){return function(t,i){let r=!1;for(let s=0;s<t.selection.ranges.length&&!r;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,c)=>{if(r)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)r=!0;else{let h=t.doc.resolve(c),d=h.index();r=h.parent.canReplaceWith(d,d+1,n)}})}if(!r)return!1;if(i){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,n,e)}i(s.scrollIntoView())}return!0}}function Eh(n,e,t,i){for(let r=0;r<e.length;r++){let{$from:s,$to:o}=e[r],l=s.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(s.pos,o.pos,(a,c)=>{if(l||!i)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function Ye(n,e=null,t){let i=t!==!1;return function(r,s){let{empty:o,$cursor:l,ranges:a}=r.selection;if(o&&!l||!Eh(r.doc,a,n,i))return!1;if(s)if(l)n.isInSet(r.storedMarks||l.marks())?s(r.tr.removeStoredMark(n)):s(r.tr.addStoredMark(n.create(e)));else{let c,h=r.tr;c=!a.some(d=>r.doc.rangeHasMark(d.$from.pos,d.$to.pos,n));for(let d=0;d<a.length;d++){let{$from:f,$to:p}=a[d];if(!c)h.removeMark(f.pos,p.pos,n);else{let u=f.pos,m=p.pos,g=f.nodeAfter,y=p.nodeBefore,S=g&&g.isText?/^\s*/.exec(g.text)[0].length:0,b=y&&y.isText?/\s*$/.exec(y.text)[0].length:0;u+S<m&&(u+=S,m-=b),h.addMark(u,m,n.create(e))}}s(h.scrollIntoView())}return!0}}function tn(...n){return function(e,t,i){for(let r=0;r<n.length;r++)if(n[r](e,t,i))return!0;return!1}}let bi=tn(cl,bh,xh),ls=tn(cl,wh,Sh);const Oe={Enter:tn(kh,vh,ul,Mh),"Mod-Enter":fl,Backspace:bi,"Mod-Backspace":bi,"Shift-Backspace":bi,Delete:ls,"Mod-Delete":ls,"Mod-a":ml},bl={"Ctrl-h":Oe.Backspace,"Alt-Backspace":Oe["Mod-Backspace"],"Ctrl-d":Oe.Delete,"Ctrl-Alt-Backspace":Oe["Mod-Delete"],"Alt-Delete":Oe["Mod-Delete"],"Alt-d":Oe["Mod-Delete"],"Ctrl-a":Oh,"Ctrl-e":Ah};for(let n in Oe)bl[n]=Oe[n];const Dh=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Ih=Dh?bl:Oe;var Fn=200,H=function(){};H.prototype.append=function(e){return e.length?(e=H.from(e),!this.length&&e||e.length<Fn&&this.leafAppend(e)||this.length<Fn&&e.leafPrepend(this)||this.appendInner(e)):this};H.prototype.prepend=function(e){return e.length?H.from(e).append(this):this};H.prototype.appendInner=function(e){return new Rh(this,e)};H.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?H.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};H.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};H.prototype.forEach=function(e,t,i){t===void 0&&(t=0),i===void 0&&(i=this.length),t<=i?this.forEachInner(e,t,i,0):this.forEachInvertedInner(e,t,i,0)};H.prototype.map=function(e,t,i){t===void 0&&(t=0),i===void 0&&(i=this.length);var r=[];return this.forEach(function(s,o){return r.push(e(s,o))},t,i),r};H.from=function(e){return e instanceof H?e:e&&e.length?new xl(e):H.empty};var xl=function(n){function e(i){n.call(this),this.values=i}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(r,s){return r==0&&s==this.length?this:new e(this.values.slice(r,s))},e.prototype.getInner=function(r){return this.values[r]},e.prototype.forEachInner=function(r,s,o,l){for(var a=s;a<o;a++)if(r(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,o,l){for(var a=s-1;a>=o;a--)if(r(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(r){if(this.length+r.length<=Fn)return new e(this.values.concat(r.flatten()))},e.prototype.leafPrepend=function(r){if(this.length+r.length<=Fn)return new e(r.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(H);H.empty=new xl([]);var Rh=function(n){function e(t,i){n.call(this),this.left=t,this.right=i,this.length=t.length+i.length,this.depth=Math.max(t.depth,i.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(i){return i<this.left.length?this.left.get(i):this.right.get(i-this.left.length)},e.prototype.forEachInner=function(i,r,s,o){var l=this.left.length;if(r<l&&this.left.forEachInner(i,r,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(i,Math.max(r-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,r,s,o){var l=this.left.length;if(r>l&&this.right.forEachInvertedInner(i,r-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(i,Math.min(r,l),s,o)===!1)return!1},e.prototype.sliceInner=function(i,r){if(i==0&&r==this.length)return this;var s=this.left.length;return r<=s?this.left.slice(i,r):i>=s?this.right.slice(i-s,r-s):this.left.slice(i,s).append(this.right.slice(0,r-s))},e.prototype.leafAppend=function(i){var r=this.right.leafAppend(i);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(i){var r=this.left.leafPrepend(i);if(r)return new e(r,this.right)},e.prototype.appendInner=function(i){return this.left.depth>=Math.max(this.right.depth,i.depth)+1?new e(this.left,new e(this.right,i)):new e(this,i)},e}(H);const Ph=500;class ue{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let i=this.items.length;for(;;i--)if(this.items.get(i-1).selection){--i;break}let r,s;t&&(r=this.remapping(i,this.items.length),s=r.maps.length);let o=e.tr,l,a,c=[],h=[];return this.items.forEach((d,f)=>{if(!d.step){r||(r=this.remapping(i,f+1),s=r.maps.length),s--,h.push(d);return}if(r){h.push(new ge(d.map));let p=d.step.map(r.slice(s)),u;p&&o.maybeStep(p).doc&&(u=o.mapping.maps[o.mapping.maps.length-1],c.push(new ge(u,void 0,void 0,c.length+h.length))),s--,u&&r.appendMap(u,s)}else o.maybeStep(d.step);if(d.selection)return l=r?d.selection.map(r.slice(s)):d.selection,a=new ue(this.items.slice(0,i).append(h.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,i,r){let s=[],o=this.eventCount,l=this.items,a=!r&&l.length?l.get(l.length-1):null;for(let h=0;h<e.steps.length;h++){let d=e.steps[h].invert(e.docs[h]),f=new ge(e.mapping.maps[h],d,t),p;(p=a&&a.merge(f))&&(f=p,h?s.pop():l=l.slice(0,l.length-1)),s.push(f),t&&(o++,t=void 0),r||(a=f)}let c=o-i.depth;return c>zh&&(l=Vh(l,c),o-=c),new ue(l.append(s),o)}remapping(e,t){let i=new Mt;return this.items.forEach((r,s)=>{let o=r.mirrorOffset!=null&&s-r.mirrorOffset>=e?i.maps.length-r.mirrorOffset:void 0;i.appendMap(r.map,o)},e,t),i}addMaps(e){return this.eventCount==0?this:new ue(this.items.append(e.map(t=>new ge(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let i=[],r=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},r);let a=t;this.items.forEach(f=>{let p=s.getMirror(--a);if(p==null)return;o=Math.min(o,p);let u=s.maps[p];if(f.step){let m=e.steps[p].invert(e.docs[p]),g=f.selection&&f.selection.map(s.slice(a+1,p));g&&l++,i.push(new ge(u,m,g))}else i.push(new ge(u))},r);let c=[];for(let f=t;f<o;f++)c.push(new ge(s.maps[f]));let h=this.items.slice(0,r).append(c).append(i),d=new ue(h,l);return d.emptyItemCount()>Ph&&(d=d.compress(this.items.length-i.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),i=t.maps.length,r=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)r.push(o),o.selection&&s++;else if(o.step){let a=o.step.map(t.slice(i)),c=a&&a.getMap();if(i--,c&&t.appendMap(c,i),a){let h=o.selection&&o.selection.map(t.slice(i));h&&s++;let d=new ge(c.invert(),a,h),f,p=r.length-1;(f=r.length&&r[p].merge(d))?r[p]=f:r.push(d)}}else o.map&&i--},this.items.length,0),new ue(H.from(r.reverse()),s)}}ue.empty=new ue(H.empty,0);function Vh(n,e){let t;return n.forEach((i,r)=>{if(i.selection&&e--==0)return t=r,!1}),n.slice(t)}class ge{constructor(e,t,i,r){this.map=e,this.step=t,this.selection=i,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new ge(t.getMap().invert(),t,this.selection)}}}class Re{constructor(e,t,i,r,s){this.done=e,this.undone=t,this.prevRanges=i,this.prevTime=r,this.prevComposition=s}}const zh=20;function Bh(n,e,t,i){let r=t.getMeta(lt),s;if(r)return r.historyState;t.getMeta(Fh)&&(n=new Re(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(lt))return o.getMeta(lt).redo?new Re(n.done.addTransform(t,void 0,i,An(e)),n.undone,as(t.mapping.maps),n.prevTime,n.prevComposition):new Re(n.done,n.undone.addTransform(t,void 0,i,An(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-i.newGroupDelay||!Lh(t,n.prevRanges)),c=o?xi(n.prevRanges,t.mapping):as(t.mapping.maps);return new Re(n.done.addTransform(t,a?e.selection.getBookmark():void 0,i,An(e)),ue.empty,c,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new Re(n.done.rebased(t,s),n.undone.rebased(t,s),xi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Re(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),xi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Lh(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((i,r)=>{for(let s=0;s<e.length;s+=2)i<=e[s+1]&&r>=e[s]&&(t=!0)}),t}function as(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((i,r,s,o)=>e.push(s,o));return e}function xi(n,e){if(!n)return null;let t=[];for(let i=0;i<n.length;i+=2){let r=e.map(n[i],1),s=e.map(n[i+1],-1);r<=s&&t.push(r,s)}return t}function Hh(n,e,t){let i=An(e),r=lt.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,i);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),r,i),a=new Re(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(lt,{redo:t,historyState:a})}let Ci=!1,cs=null;function An(n){let e=n.plugins;if(cs!=e){Ci=!1,cs=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ci=!0;break}}return Ci}const lt=new an("history"),Fh=new an("closeHistory");function $h(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new ln({key:lt,state:{init(){return new Re(ue.empty,ue.empty,null,0,-1)},apply(e,t,i){return Bh(t,i,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let i=t.inputType,r=i=="historyUndo"?wl:i=="historyRedo"?$i:null;return r?(t.preventDefault(),r(e.state,e.dispatch)):!1}}}})}function Cl(n,e){return(t,i)=>{let r=lt.getState(t);if(!r||(n?r.undone:r.done).eventCount==0)return!1;if(i){let s=Hh(r,t,n);s&&i(e?s.scrollIntoView():s)}return!0}}const wl=Cl(!1,!0),$i=Cl(!0,!0);var Je={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},$n={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Wh=typeof navigator<"u"&&/Mac/.test(navigator.platform),Kh=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var W=0;W<10;W++)Je[48+W]=Je[96+W]=String(W);for(var W=1;W<=24;W++)Je[W+111]="F"+W;for(var W=65;W<=90;W++)Je[W]=String.fromCharCode(W+32),$n[W]=String.fromCharCode(W);for(var wi in Je)$n.hasOwnProperty(wi)||($n[wi]=Je[wi]);function Jh(n){var e=Wh&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Kh&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?$n:Je)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const qh=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function jh(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let i,r,s,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))i=!0;else if(/^(c|ctrl|control)$/i.test(a))r=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))qh?o=!0:r=!0;else throw new Error("Unrecognized modifier name: "+a)}return i&&(t="Alt-"+t),r&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function _h(n){let e=Object.create(null);for(let t in n)e[jh(t)]=n[t];return e}function Si(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function ki(n){return new ln({props:{handleKeyDown:Sl(n)}})}function Sl(n){let e=_h(n);return function(t,i){let r=Jh(i),s,o=e[Si(r,i)];if(o&&o(t.state,t.dispatch,t))return!0;if(r.length==1&&r!=" "){if(i.shiftKey){let l=e[Si(r,i,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((i.shiftKey||i.altKey||i.metaKey||r.charCodeAt(0)>127)&&(s=Je[i.keyCode])&&s!=r){let l=e[Si(s,i)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}function hs(n,e=null){return function(t,i){let{$from:r,$to:s}=t.selection,o=r.blockRange(s),l=!1,a=o;if(!o)return!1;if(o.depth>=2&&r.node(o.depth-1).type.compatibleContent(n)&&o.startIndex==0){if(r.index(o.depth-1)==0)return!1;let h=t.doc.resolve(o.start-2);a=new zn(h,h,o.depth),o.endIndex<o.parent.childCount&&(o=new zn(r,t.doc.resolve(s.end(o.depth)),o.depth)),l=!0}let c=Yo(a,n,e,o);return c?(i&&i(Gh(t.tr,o,c,l,n).scrollIntoView()),!0):!1}}function Gh(n,e,t,i,r){let s=x.empty;for(let h=t.length-1;h>=0;h--)s=x.from(t[h].type.create(t[h].attrs,s));n.step(new J(e.start-(i?2:0),e.end,e.start,e.end,new w(s,0,0),t.length,!0));let o=0;for(let h=0;h<t.length;h++)t[h].type==r&&(o=h+1);let l=t.length-o,a=e.start+t.length-(i?2:0),c=e.parent;for(let h=e.startIndex,d=e.endIndex,f=!0;h<d;h++,f=!1)!f&&Tt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(h).nodeSize;return n}function Uh(n,e){return function(t,i){let{$from:r,$to:s,node:o}=t.selection;if(o&&o.isBlock||r.depth<2||!r.sameParent(s))return!1;let l=r.node(-1);if(l.type!=n)return!1;if(r.parent.content.size==0&&r.node(-1).childCount==r.indexAfter(-1)){if(r.depth==3||r.node(-3).type!=n||r.index(-2)!=r.node(-2).childCount-1)return!1;if(i){let d=x.empty,f=r.index(-1)?1:r.index(-2)?2:3;for(let y=r.depth-f;y>=r.depth-3;y--)d=x.from(r.node(y).copy(d));let p=r.indexAfter(-1)<r.node(-2).childCount?1:r.indexAfter(-2)<r.node(-3).childCount?2:3;d=d.append(x.from(n.createAndFill()));let u=r.before(r.depth-(f-1)),m=t.tr.replace(u,r.after(-p),new w(d,4-f,0)),g=-1;m.doc.nodesBetween(u,m.doc.content.size,(y,S)=>{if(g>-1)return!1;y.isTextblock&&y.content.size==0&&(g=S+1)}),g>-1&&m.setSelection(A.near(m.doc.resolve(g))),i(m.scrollIntoView())}return!0}let a=s.pos==r.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(r.pos,s.pos),h=a?[null,{type:a}]:void 0;return Tt(c.doc,r.pos,2,h)?(i&&i(c.split(r.pos,2,h).scrollIntoView()),!0):!1}}function Wi(n){return function(e,t){let{$from:i,$to:r}=e.selection,s=i.blockRange(r,o=>o.childCount>0&&o.firstChild.type==n);return s?t?i.node(s.depth-1).type==n?Zh(e,t,n,s):Xh(e,t,s):!0:!1}}function Zh(n,e,t,i){let r=n.tr,s=i.end,o=i.$to.end(i.depth);s<o&&(r.step(new J(s-1,o,s,o,new w(x.from(t.create(null,i.parent.copy())),1,0),1,!0)),i=new zn(r.doc.resolve(i.$from.pos),r.doc.resolve(o),i.depth));const l=Xn(i);if(l==null)return!1;r.lift(i,l);let a=r.mapping.map(s,-1)-1;return Yn(r.doc,a)&&r.join(a),e(r.scrollIntoView()),!0}function Xh(n,e,t){let i=n.tr,r=t.parent;for(let p=t.end,u=t.endIndex-1,m=t.startIndex;u>m;u--)p-=r.child(u).nodeSize,i.delete(p-1,p+1);let s=i.doc.resolve(t.start),o=s.nodeAfter;if(i.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==r.childCount,c=s.node(-1),h=s.index(-1);if(!c.canReplace(h+(l?0:1),h+1,o.content.append(a?x.empty:x.from(r))))return!1;let d=s.pos,f=d+o.nodeSize;return i.step(new J(d-(l?1:0),f+(a?1:0),d+1,f-1,new w((l?x.empty:x.from(r.copy(x.empty))).append(a?x.empty:x.from(r.copy(x.empty))),l?0:1,a?0:1),l?0:1)),e(i.scrollIntoView()),!0}function Yh(n){return function(e,t){let{$from:i,$to:r}=e.selection,s=i.blockRange(r,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,h=x.from(c?n.create():null),d=new w(x.from(n.create(null,x.from(l.type.create(null,h)))),c?3:1,0),f=s.start,p=s.end;t(e.tr.step(new J(f-(c?3:1),p,f,p,d,1,!0)).scrollIntoView())}return!0}}const K=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},nn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Ki=null;const Te=function(n,e,t){let i=Ki||(Ki=document.createRange());return i.setEnd(n,t??n.nodeValue.length),i.setStart(n,e||0),i},Qh=function(){Ki=null},dt=function(n,e,t,i){return t&&(ds(n,e,t,i,-1)||ds(n,e,t,i,1))},ed=/^(img|br|input|textarea|hr)$/i;function ds(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:ce(n))){let s=n.parentNode;if(!s||s.nodeType!=1||cn(n)||ed.test(n.nodeName)||n.contentEditable=="false")return!1;e=K(n)+(r<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(r<0?-1:0)],n.contentEditable=="false")return!1;e=r<0?ce(n):0}else return!1}}function ce(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function td(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=ce(n)}else if(n.parentNode&&!cn(n))e=K(n),n=n.parentNode;else return null}}function nd(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!cn(n))e=K(n)+1,n=n.parentNode;else return null}}function id(n,e,t){for(let i=e==0,r=e==ce(n);i||r;){if(n==t)return!0;let s=K(n);if(n=n.parentNode,!n)return!1;i=i&&s==0,r=r&&s==ce(n)}}function cn(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const ei=function(n){return n.focusNode&&dt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Qe(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function rd(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function sd(n,e,t){if(n.caretPositionFromPoint)try{let i=n.caretPositionFromPoint(e,t);if(i)return{node:i.offsetNode,offset:Math.min(ce(i.offsetNode),i.offset)}}catch{}if(n.caretRangeFromPoint){let i=n.caretRangeFromPoint(e,t);if(i)return{node:i.startContainer,offset:Math.min(ce(i.startContainer),i.startOffset)}}}const xe=typeof navigator<"u"?navigator:null,fs=typeof document<"u"?document:null,qe=xe&&xe.userAgent||"",Ji=/Edge\/(\d+)/.exec(qe),kl=/MSIE \d/.exec(qe),qi=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(qe),te=!!(kl||qi||Ji),$e=kl?document.documentMode:qi?+qi[1]:Ji?+Ji[1]:0,me=!te&&/gecko\/(\d+)/i.test(qe);me&&+(/Firefox\/(\d+)/.exec(qe)||[0,0])[1];const ji=!te&&/Chrome\/(\d+)/.exec(qe),G=!!ji,vl=ji?+ji[1]:0,Z=!te&&!!xe&&/Apple Computer/.test(xe.vendor),Pt=Z&&(/Mobile\/\w+/.test(qe)||!!xe&&xe.maxTouchPoints>2),ae=Pt||(xe?/Mac/.test(xe.platform):!1),od=xe?/Win/.test(xe.platform):!1,fe=/Android \d/.test(qe),hn=!!fs&&"webkitFontSmoothing"in fs.documentElement.style,ld=hn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ad(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Se(n,e){return typeof n=="number"?n:n[e]}function cd(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,i=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*i}}function us(n,e,t){let i=n.someProp("scrollThreshold")||0,r=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let o=t||n.dom;o;o=nn(o)){if(o.nodeType!=1)continue;let l=o,a=l==s.body,c=a?ad(s):cd(l),h=0,d=0;if(e.top<c.top+Se(i,"top")?d=-(c.top-e.top+Se(r,"top")):e.bottom>c.bottom-Se(i,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+Se(r,"top")-c.top:e.bottom-c.bottom+Se(r,"bottom")),e.left<c.left+Se(i,"left")?h=-(c.left-e.left+Se(r,"left")):e.right>c.right-Se(i,"right")&&(h=e.right-c.right+Se(r,"right")),h||d)if(a)s.defaultView.scrollBy(h,d);else{let f=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),h&&(l.scrollLeft+=h);let u=l.scrollLeft-f,m=l.scrollTop-p;e={left:e.left-u,top:e.top-m,right:e.right-u,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(o).position))break}}function hd(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),i,r;for(let s=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=n.root.elementFromPoint(s,o);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){i=l,r=a.top;break}}return{refDOM:i,refTop:r,stack:Ml(n.dom)}}function Ml(n){let e=[],t=n.ownerDocument;for(let i=n;i&&(e.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),n!=t);i=nn(i));return e}function dd({refDOM:n,refTop:e,stack:t}){let i=n?n.getBoundingClientRect().top:0;Tl(t,i==0?0:i-e)}function Tl(n,e){for(let t=0;t<n.length;t++){let{dom:i,top:r,left:s}=n[t];i.scrollTop!=r+e&&(i.scrollTop=r+e),i.scrollLeft!=s&&(i.scrollLeft=s)}}let bt=null;function fd(n){if(n.setActive)return n.setActive();if(bt)return n.focus(bt);let e=Ml(n);n.focus(bt==null?{get preventScroll(){return bt={preventScroll:!0},!0}}:void 0),bt||(bt=!1,Tl(e,0))}function Ol(n,e){let t,i=2e8,r,s=0,o=e.top,l=e.top,a,c;for(let h=n.firstChild,d=0;h;h=h.nextSibling,d++){let f;if(h.nodeType==1)f=h.getClientRects();else if(h.nodeType==3)f=Te(h).getClientRects();else continue;for(let p=0;p<f.length;p++){let u=f[p];if(u.top<=o&&u.bottom>=l){o=Math.max(u.bottom,o),l=Math.min(u.top,l);let m=u.left>e.left?u.left-e.left:u.right<e.left?e.left-u.right:0;if(m<i){t=h,i=m,r=m&&t.nodeType==3?{left:u.right<e.left?u.right:u.left,top:e.top}:e,h.nodeType==1&&m&&(s=d+(e.left>=(u.left+u.right)/2?1:0));continue}}else u.top>e.top&&!a&&u.left<=e.left&&u.right>=e.left&&(a=h,c={left:Math.max(u.left,Math.min(u.right,e.left)),top:u.top});!t&&(e.left>=u.right&&e.top>=u.top||e.left>=u.left&&e.top>=u.bottom)&&(s=d+1)}}return!t&&a&&(t=a,r=c,i=0),t&&t.nodeType==3?ud(t,r):!t||i&&t.nodeType==1?{node:n,offset:s}:Ol(t,r)}function ud(n,e){let t=n.nodeValue.length,i=document.createRange();for(let r=0;r<t;r++){i.setEnd(n,r+1),i.setStart(n,r);let s=Ie(i,1);if(s.top!=s.bottom&&ur(e,s))return{node:n,offset:r+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function ur(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function pd(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function md(n,e,t){let{node:i,offset:r}=Ol(e,t),s=-1;if(i.nodeType==1&&!i.firstChild){let o=i.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(i,r,s)}function gd(n,e,t,i){let r=-1;for(let s=e,o=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!o&&a.left>i.left||a.top>i.top?r=l.posBefore:(!o&&a.right<i.left||a.bottom<i.top)&&(r=l.posAfter),o=!0),!l.contentDOM&&r<0&&!l.node.isText)return(l.node.isBlock?i.top<(a.top+a.bottom)/2:i.left<(a.left+a.right)/2)?l.posBefore:l.posAfter}s=l.dom.parentNode}return r>-1?r:n.docView.posFromDOM(e,t,-1)}function Al(n,e,t){let i=n.childNodes.length;if(i&&t.top<t.bottom)for(let r=Math.max(0,Math.min(i-1,Math.floor(i*(e.top-t.top)/(t.bottom-t.top))-2)),s=r;;){let o=n.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(ur(e,c))return Al(o,e,c)}}if((s=(s+1)%i)==r)break}return n}function yd(n,e){let t=n.dom.ownerDocument,i,r=0,s=sd(t,e.left,e.top);s&&({node:i,offset:r}=s);let o=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!o||!n.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=n.dom.getBoundingClientRect();if(!ur(e,c)||(o=Al(n.dom,e,c),!o))return null}if(Z)for(let c=o;i&&c;c=nn(c))c.draggable&&(i=void 0);if(o=pd(o,e),i){if(me&&i.nodeType==1&&(r=Math.min(r,i.childNodes.length),r<i.childNodes.length)){let h=i.childNodes[r],d;h.nodeName=="IMG"&&(d=h.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&r++}let c;hn&&r&&i.nodeType==1&&(c=i.childNodes[r-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&r--,i==n.dom&&r==i.childNodes.length-1&&i.lastChild.nodeType==1&&e.top>i.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(r==0||i.nodeType!=1||i.childNodes[r-1].nodeName!="BR")&&(l=gd(n,i,r,e))}l==null&&(l=md(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function ps(n){return n.top<n.bottom||n.left<n.right}function Ie(n,e){let t=n.getClientRects();if(t.length){let i=t[e<0?0:t.length-1];if(ps(i))return i}return Array.prototype.find.call(t,ps)||n.getBoundingClientRect()}const bd=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Nl(n,e,t){let{node:i,offset:r,atom:s}=n.docView.domFromPos(e,t<0?-1:1),o=hn||me;if(i.nodeType==3)if(o&&(bd.test(i.nodeValue)||(t<0?!r:r==i.nodeValue.length))){let a=Ie(Te(i,r,r),t);if(me&&r&&/\s/.test(i.nodeValue[r-1])&&r<i.nodeValue.length){let c=Ie(Te(i,r-1,r-1),-1);if(c.top==a.top){let h=Ie(Te(i,r,r+1),-1);if(h.top!=a.top)return Ft(h,h.left<c.left)}}return a}else{let a=r,c=r,h=t<0?1:-1;return t<0&&!r?(c++,h=-1):t>=0&&r==i.nodeValue.length?(a--,h=1):t<0?a--:c++,Ft(Ie(Te(i,a,c),h),h<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&r&&(t<0||r==ce(i))){let a=i.childNodes[r-1];if(a.nodeType==1)return vi(a.getBoundingClientRect(),!1)}if(s==null&&r<ce(i)){let a=i.childNodes[r];if(a.nodeType==1)return vi(a.getBoundingClientRect(),!0)}return vi(i.getBoundingClientRect(),t>=0)}if(s==null&&r&&(t<0||r==ce(i))){let a=i.childNodes[r-1],c=a.nodeType==3?Te(a,ce(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Ft(Ie(c,1),!1)}if(s==null&&r<ce(i)){let a=i.childNodes[r];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Te(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return Ft(Ie(c,-1),!0)}return Ft(Ie(i.nodeType==3?Te(i):i,-t),t>=0)}function Ft(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function vi(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function El(n,e,t){let i=n.state,r=n.root.activeElement;i!=e&&n.updateState(e),r!=n.dom&&n.focus();try{return t()}finally{i!=e&&n.updateState(i),r!=n.dom&&r&&r.focus()}}function xd(n,e,t){let i=e.selection,r=t=="up"?i.$from:i.$to;return El(n,e,()=>{let{node:s}=n.docView.domFromPos(r.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Nl(n,r.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Te(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let h=a[c];if(h.bottom>h.top+1&&(t=="up"?o.top-h.top>(h.bottom-o.top)*2:h.bottom-o.bottom>(o.bottom-h.top)*2))return!1}}return!0})}const Cd=/[\u0590-\u08ac]/;function wd(n,e,t){let{$head:i}=e.selection;if(!i.parent.isTextblock)return!1;let r=i.parentOffset,s=!r,o=r==i.parent.content.size,l=n.domSelection();return l?!Cd.test(i.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:El(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:h,anchorOffset:d}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let p=i.depth?n.docView.domAfterPos(i.before()):n.dom,{focusNode:u,focusOffset:m}=n.domSelectionRange(),g=u&&!p.contains(u.nodeType==1?u:u.parentNode)||a==u&&c==m;try{l.collapse(h,d),a&&(a!=h||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):i.pos==i.start()||i.pos==i.end()}let ms=null,gs=null,ys=!1;function Sd(n,e,t){return ms==e&&gs==t?ys:(ms=e,gs=t,ys=t=="up"||t=="down"?xd(n,e,t):wd(n,e,t))}const he=0,bs=1,tt=2,Ce=3;class dn{constructor(e,t,i,r){this.parent=e,this.children=t,this.dom=i,this.contentDOM=r,this.dirty=he,i.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,i){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,i=this.posAtStart;;t++){let r=this.children[t];if(r==e)return i;i+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,i){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(i<0){let s,o;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>K(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){r=!1;break}if(s.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){r=!0;break}if(s.nextSibling)break}}return r??i>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let i=!0,r=e;r;r=r.parentNode){let s=this.getDesc(r),o;if(s&&(!t||s.node))if(i&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))i=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let i=t;i;i=i.parent)if(i==this)return t}posFromDOM(e,t,i){for(let r=e;r;r=r.parentNode){let s=this.getDesc(r);if(s)return s.localPosFromDOM(e,t,i)}return-1}descAt(e){for(let t=0,i=0;t<this.children.length;t++){let r=this.children[t],s=i+r.size;if(i==e&&s!=i){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(e<s)return r.descAt(e-i-r.border);i=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let i=0,r=0;for(let s=0;i<this.children.length;i++){let o=this.children[i],l=s+o.size;if(l>e||o instanceof Il){r=e-s;break}s=l}if(r)return this.children[i].domFromPos(r-this.children[i].border,t);for(let s;i&&!(s=this.children[i-1]).size&&s instanceof Dl&&s.side>=0;i--);if(t<=0){let s,o=!0;for(;s=i?this.children[i-1]:null,!(!s||s.dom.parentNode==this.contentDOM);i--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?K(s.dom)+1:0}}else{let s,o=!0;for(;s=i<this.children.length?this.children[i]:null,!(!s||s.dom.parentNode==this.contentDOM);i++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?K(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,i=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,s=-1;for(let o=i,l=0;;l++){let a=this.children[l],c=o+a.size;if(r==-1&&e<=c){let h=o+a.border;if(e>=h&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,h);e=o;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){r=K(f.dom)+1;break}e-=f.size}r==-1&&(r=0)}if(r>-1&&(c>t||l==this.children.length-1)){t=c;for(let h=l+1;h<this.children.length;h++){let d=this.children[h];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){s=K(d.dom);break}t+=d.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:i}=this.domFromPos(e,0);if(t.nodeType!=1||i==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[i]}setSelection(e,t,i,r=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let p=0,u=0;p<this.children.length;p++){let m=this.children[p],g=u+m.size;if(s>u&&o<g)return m.setSelection(e-u-m.border,t-u-m.border,i,r);u=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=i.root.getSelection(),h=i.domSelectionRange(),d=!1;if((me||Z)&&e==t){let{node:p,offset:u}=l;if(p.nodeType==3){if(d=!!(u&&p.nodeValue[u-1]==`
80
+ `),d&&u==p.nodeValue.length)for(let m=p,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:K(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=p.childNodes[u-1];d=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(me&&h.focusNode&&h.focusNode!=a.node&&h.focusNode.nodeType==1){let p=h.focusNode.childNodes[h.focusOffset];p&&p.contentEditable=="false"&&(r=!0)}if(!(r||d&&Z)&&dt(l.node,l.offset,h.anchorNode,h.anchorOffset)&&dt(a.node,a.offset,h.focusNode,h.focusOffset))return;let f=!1;if((c.extend||e==t)&&!d){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let u=l;l=a,a=u}let p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let i=0,r=0;r<this.children.length;r++){let s=this.children[r],o=i+s.size;if(i==o?e<=o&&t>=i:e<o&&t>i){let l=i+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==i||t==o?tt:bs,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Ce:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?tt:Ce}i=o}this.dirty=tt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let i=e==1?tt:bs;t.dirty<i&&(t.dirty=i)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class Dl extends dn{constructor(e,t,i,r){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(i,()=>{if(!s)return r;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==he&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class kd extends dn{constructor(e,t,i,r){super(e,[],t,null),this.textDOM=i,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class ft extends dn{constructor(e,t,i,r,s){super(e,[],i,r),this.mark=t,this.spec=s}static create(e,t,i,r){let s=r.nodeViews[t.type.name],o=s&&s(t,r,i);return(!o||!o.dom)&&(o=ut.renderSpec(document,t.type.spec.toDOM(t,i),null,t.attrs)),new ft(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Ce||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ce&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=he){let i=this.parent;for(;!i.node;)i=i.parent;i.dirty<this.dirty&&(i.dirty=this.dirty),this.dirty=he}}slice(e,t,i){let r=ft.create(this.parent,this.mark,!0,i),s=this.children,o=this.size;t<o&&(s=Gi(s,t,o,i)),e>0&&(s=Gi(s,0,e,i));for(let l=0;l<s.length;l++)s[l].parent=r;return r.children=s,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class We extends dn{constructor(e,t,i,r,s,o,l,a,c){super(e,[],s,o),this.node=t,this.outerDeco=i,this.innerDeco=r,this.nodeDOM=l}static create(e,t,i,r,s,o){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},i,r),h=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!h)h=document.createTextNode(t.text);else if(h.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else h||({dom:h,contentDOM:d}=ut.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&h.nodeName!="BR"&&(h.hasAttribute("contenteditable")||(h.contentEditable="false"),t.type.spec.draggable&&(h.draggable=!0));let f=h;return h=Vl(h,i,t),c?a=new vd(e,t,i,r,h,d||null,f,c,s,o+1):t.isText?new ti(e,t,i,r,h,f,s):new We(e,t,i,r,h,d||null,f,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let i=this.children[t];if(this.dom.contains(i.dom.parentNode)){e.contentElement=i.dom.parentNode;break}}e.contentElement||(e.getContent=()=>x.empty)}return e}matchesNode(e,t,i){return this.dirty==he&&e.eq(this.node)&&Wn(t,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let i=this.node.inlineContent,r=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Td(this,o&&o.node,e);Nd(this.node,this.innerDeco,(c,h,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,i,e):c.type.side>=0&&!d&&a.syncToMarks(h==this.node.childCount?I.none:this.node.child(h).marks,i,e),a.placeWidget(c,e,r)},(c,h,d,f)=>{a.syncToMarks(c.marks,i,e);let p;a.findNodeMatch(c,h,d,f)||l&&e.state.selection.from>r&&e.state.selection.to<r+c.nodeSize&&(p=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,h,d,p,e)||a.updateNextNode(c,h,d,e,f,r)||a.addNode(c,h,d,e,r),r+=c.nodeSize}),a.syncToMarks([],i,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==tt)&&(o&&this.protectLocalComposition(e,o),Rl(this.contentDOM,this.children,e),Pt&&Ed(this.dom))}localCompositionInfo(e,t){let{from:i,to:r}=e.state.selection;if(!(e.state.selection instanceof N)||i<t||r>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=Dd(this.node.content,o,i-t,r-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:i,text:r}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new kd(this,s,t,r);e.input.compositionNodes.push(o),this.children=Gi(this.children,i,i+r.length,e,o)}update(e,t,i,r){return this.dirty==Ce||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,i,r),!0)}updateInner(e,t,i,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=i,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=he}updateOuterDeco(e){if(Wn(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,i=this.dom;this.dom=Pl(this.dom,this.nodeDOM,_i(this.outerDeco,this.node,t),_i(e,this.node,t)),this.dom!=i&&(i.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function xs(n,e,t,i,r){Vl(i,e,n);let s=new We(void 0,n,e,t,i,i,i,r,0);return s.contentDOM&&s.updateChildren(r,0),s}class ti extends We{constructor(e,t,i,r,s,o,l){super(e,t,i,r,s,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,i,r){return this.dirty==Ce||this.dirty!=he&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=he||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=he,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,i){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,i)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,i){let r=this.node.cut(e,t),s=document.createTextNode(r.text);return new ti(this.parent,r,this.outerDeco,this.innerDeco,s,s,i)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ce)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Il extends dn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==he&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class vd extends We{constructor(e,t,i,r,s,o,l,a,c,h){super(e,t,i,r,s,o,l,c,h),this.spec=a}update(e,t,i,r){if(this.dirty==Ce)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,i);return s&&this.updateInner(e,t,i,r),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,i,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,i,r){this.spec.setSelection?this.spec.setSelection(e,t,i.root):super.setSelection(e,t,i,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Rl(n,e,t){let i=n.firstChild,r=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==n){for(;l!=i;)i=Cs(i),r=!0;i=i.nextSibling}else r=!0,n.insertBefore(l,i);if(o instanceof ft){let a=i?i.previousSibling:n.lastChild;Rl(o.contentDOM,o.children,t),i=a?a.nextSibling:n.firstChild}}for(;i;)i=Cs(i),r=!0;r&&t.trackWrites==n&&(t.trackWrites=null)}const Ut=function(n){n&&(this.nodeName=n)};Ut.prototype=Object.create(null);const nt=[new Ut];function _i(n,e,t){if(n.length==0)return nt;let i=t?nt[0]:new Ut,r=[i];for(let s=0;s<n.length;s++){let o=n[s].type.attrs;if(o){o.nodeName&&r.push(i=new Ut(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&r.length==1&&r.push(i=new Ut(e.isInline?"span":"div")),l=="class"?i.class=(i.class?i.class+" ":"")+a:l=="style"?i.style=(i.style?i.style+";":"")+a:l!="nodeName"&&(i[l]=a))}}}return r}function Pl(n,e,t,i){if(t==nt&&i==nt)return e;let r=e;for(let s=0;s<i.length;s++){let o=i[s],l=t[s];if(s){let a;l&&l.nodeName==o.nodeName&&r!=n&&(a=r.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(r),l=nt[0]),r=a}Md(r,l||nt[0],o)}return r}function Md(n,e,t){for(let i in e)i!="class"&&i!="style"&&i!="nodeName"&&!(i in t)&&n.removeAttribute(i);for(let i in t)i!="class"&&i!="style"&&i!="nodeName"&&t[i]!=e[i]&&n.setAttribute(i,t[i]);if(e.class!=t.class){let i=e.class?e.class.split(" ").filter(Boolean):[],r=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&n.classList.remove(i[s]);for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&n.classList.add(r[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=i.exec(e.style);)n.style.removeProperty(r[1])}t.style&&(n.style.cssText+=t.style)}}function Vl(n,e,t){return Pl(n,n,nt,_i(e,t,n.nodeType!=1))}function Wn(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Cs(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Td{constructor(e,t,i){this.lock=t,this.view=i,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Od(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let i=e;i<t;i++)this.top.children[i].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,i){let r=0,s=this.stack.length>>1,o=Math.min(s,e.length);for(;r<o&&(r==s-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&e[r].type.spec.spanning!==!1;)r++;for(;r<s;)this.destroyRest(),this.top.dirty=he,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=ft.create(this.top,e[s],t,i);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,i,r){let s=-1,o;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,i))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,i)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,i,r,s){let o=this.top.children[r];return o.dirty==Ce&&o.dom==o.contentDOM&&(o.dirty=tt),o.update(e,t,i,s)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let i=e.pmViewDesc;if(i){for(let r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==i)return r}return-1}e=t}}updateNextNode(e,t,i,r,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof We){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let h=a.dom,d,f=this.isLocked(h)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Ce&&Wn(t,a.outerDeco));if(!f&&a.update(e,t,i,r))return this.destroyBetween(this.index,l),a.dom!=h&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,t,i,r,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=tt,d.updateChildren(r,o+1),d.dirty=he),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,i,r,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Wn(i,e.outerDeco)||!r.eq(e.innerDeco))return null;let l=We.create(this.top,t,i,r,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,i,r,s){let o=We.create(this.top,e,t,i,r,s);o.contentDOM&&o.updateChildren(r,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,i){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let s=new Dl(this.top,e,t,i);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof ft;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof ti)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Z||G)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let i=document.createElement(e);e=="IMG"&&(i.className="ProseMirror-separator",i.alt=""),e=="BR"&&(i.className="ProseMirror-trailingBreak");let r=new Il(this.top,[],i,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Od(n,e){let t=e,i=t.children.length,r=n.childCount,s=new Map,o=[];e:for(;r>0;){let l;for(;;)if(i){let c=t.children[i-1];if(c instanceof ft)t=c,i=c.children.length;else{l=c,i--;break}}else{if(t==e)break e;i=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(r-1))break;--r,s.set(l,r),o.push(l)}}return{index:r,matched:s,matches:o.reverse()}}function Ad(n,e){return n.type.side-e.type.side}function Nd(n,e,t,i){let r=e.locals(n),s=0;if(r.length==0){for(let c=0;c<n.childCount;c++){let h=n.child(c);i(h,r,e.forChild(s,h),c),s+=h.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let h,d;for(;o<r.length&&r[o].to==s;){let g=r[o++];g.widget&&(h?(d||(d=[h])).push(g):h=g)}if(h)if(d){d.sort(Ad);for(let g=0;g<d.length;g++)t(d[g],c,!!a)}else t(h,c,!!a);let f,p;if(a)p=-1,f=a,a=null;else if(c<n.childCount)p=c,f=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;o<r.length&&r[o].from<=s&&r[o].to>s;)l.push(r[o++]);let u=s+f.nodeSize;if(f.isText){let g=u;o<r.length&&r[o].from<g&&(g=r[o].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<u&&(a=f.cut(g-s),f=f.cut(0,g-s),u=g,p=-1)}else for(;o<r.length&&r[o].to<u;)o++;let m=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();i(f,m,e.forChild(s,f),p),s=u}}function Ed(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Dd(n,e,t,i){for(let r=0,s=0;r<n.childCount&&s<=i;){let o=n.child(r++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;r<n.childCount;){let c=n.child(r++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=t){if(s>=i&&a.slice(i-e.length-l,i-l)==e)return i-e.length;let c=l<i?a.lastIndexOf(e,i-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==i&&a.length>=i+e.length-l&&a.slice(i-l,i-l+e.length)==e)return i}}return-1}function Gi(n,e,t,i,r){let s=[];for(let o=0,l=0;o<n.length;o++){let a=n[o],c=l,h=l+=a.size;c>=t||h<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,i)),r&&(s.push(r),r=void 0),h>t&&s.push(a.slice(t-c,a.size,i)))}return s}function pr(n,e=null){let t=n.domSelectionRange(),i=n.state.doc;if(!t.focusNode)return null;let r=n.docView.nearestDesc(t.focusNode),s=r&&r.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=i.resolve(o),a,c;if(ei(t)){for(a=o;r&&!r.node;)r=r.parent;let d=r.node;if(r&&d.isAtom&&T.isSelectable(d)&&r.parent&&!(d.isInline&&id(t.focusNode,t.focusOffset,r.dom))){let f=r.posBefore;c=new T(o==f?l:i.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=o,f=o;for(let p=0;p<t.rangeCount;p++){let u=t.getRangeAt(p);d=Math.min(d,n.docView.posFromDOM(u.startContainer,u.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(u.endContainer,u.endOffset,-1))}if(d<0)return null;[a,o]=f==n.state.selection.anchor?[f,d]:[d,f],l=i.resolve(o)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let h=i.resolve(a);if(!c){let d=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=mr(n,h,l,d)}return c}function zl(n){return n.editable?n.hasFocus():Ll(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Ae(n,e=!1){let t=n.state.selection;if(Bl(n,t),!!zl(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&G){let i=n.domSelectionRange(),r=n.domObserver.currentSelection;if(i.anchorNode&&r.anchorNode&&dt(i.anchorNode,i.anchorOffset,r.anchorNode,r.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Rd(n);else{let{anchor:i,head:r}=t,s,o;ws&&!(t instanceof N)&&(t.$from.parent.inlineContent||(s=Ss(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=Ss(n,t.to))),n.docView.setSelection(i,r,n,e),ws&&(s&&ks(s),o&&ks(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Id(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const ws=Z||G&&vl<63;function Ss(n,e){let{node:t,offset:i}=n.docView.domFromPos(e,0),r=i<t.childNodes.length?t.childNodes[i]:null,s=i?t.childNodes[i-1]:null;if(Z&&r&&r.contentEditable=="false")return Mi(r);if((!r||r.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(r)return Mi(r);if(s)return Mi(s)}}function Mi(n){return n.contentEditable="true",Z&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function ks(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Id(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),i=t.anchorNode,r=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=i||t.anchorOffset!=r)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!zl(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Rd(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let i=n.cursorWrapper.dom,r=i.nodeName=="IMG";r?t.setStart(i.parentNode,K(i)+1):t.setStart(i,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!r&&!n.state.selection.visible&&te&&$e<=11&&(i.disabled=!0,i.disabled=!1)}function Bl(n,e){if(e instanceof T){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(vs(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else vs(n)}function vs(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function mr(n,e,t,i){return n.someProp("createSelectionBetween",r=>r(n,e,t))||N.between(e,t,i)}function Ms(n){return n.editable&&!n.hasFocus()?!1:Ll(n)}function Ll(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Pd(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return dt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ui(n,e){let{$anchor:t,$head:i}=n.selection,r=e>0?t.max(i):t.min(i),s=r.parent.inlineContent?r.depth?n.doc.resolve(e>0?r.after():r.before()):null:r;return s&&A.findFrom(s,e)}function Pe(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Ts(n,e,t){let i=n.state.selection;if(i instanceof N)if(t.indexOf("s")>-1){let{$head:r}=i,s=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(r.pos+s.nodeSize*(e<0?-1:1));return Pe(n,new N(i.$anchor,o))}else if(i.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let r=Ui(n.state,e);return r&&r instanceof T?Pe(n,r):!1}else if(!(ae&&t.indexOf("m")>-1)){let r=i.$head,s=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?r.pos-s.nodeSize:r.pos;return s.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?T.isSelectable(s)?Pe(n,new T(e<0?n.state.doc.resolve(r.pos-s.nodeSize):r)):hn?Pe(n,new N(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(i instanceof T&&i.node.isInline)return Pe(n,new N(e>0?i.$to:i.$from));{let r=Ui(n.state,e);return r?Pe(n,r):!1}}}function Kn(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Zt(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function xt(n,e){return e<0?Vd(n):zd(n)}function Vd(n){let e=n.domSelectionRange(),t=e.focusNode,i=e.focusOffset;if(!t)return;let r,s,o=!1;for(me&&t.nodeType==1&&i<Kn(t)&&Zt(t.childNodes[i],-1)&&(o=!0);;)if(i>0){if(t.nodeType!=1)break;{let l=t.childNodes[i-1];if(Zt(l,-1))r=t,s=--i;else if(l.nodeType==3)t=l,i=t.nodeValue.length;else break}}else{if(Hl(t))break;{let l=t.previousSibling;for(;l&&Zt(l,-1);)r=t.parentNode,s=K(l),l=l.previousSibling;if(l)t=l,i=Kn(t);else{if(t=t.parentNode,t==n.dom)break;i=0}}}o?Zi(n,t,i):r&&Zi(n,r,s)}function zd(n){let e=n.domSelectionRange(),t=e.focusNode,i=e.focusOffset;if(!t)return;let r=Kn(t),s,o;for(;;)if(i<r){if(t.nodeType!=1)break;let l=t.childNodes[i];if(Zt(l,1))s=t,o=++i;else break}else{if(Hl(t))break;{let l=t.nextSibling;for(;l&&Zt(l,1);)s=l.parentNode,o=K(l)+1,l=l.nextSibling;if(l)t=l,i=0,r=Kn(t);else{if(t=t.parentNode,t==n.dom)break;i=r=0}}}s&&Zi(n,s,o)}function Hl(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Bd(n,e){for(;n&&e==n.childNodes.length&&!cn(n);)e=K(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function Ld(n,e){for(;n&&!e&&!cn(n);)e=K(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Zi(n,e,t){if(e.nodeType!=3){let s,o;(o=Bd(e,t))?(e=o,t=0):(s=Ld(e,t))&&(e=s,t=s.nodeValue.length)}let i=n.domSelection();if(!i)return;if(ei(i)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),i.removeAllRanges(),i.addRange(s)}else i.extend&&i.extend(e,t);n.domObserver.setCurSelection();let{state:r}=n;setTimeout(()=>{n.state==r&&Ae(n)},50)}function Os(n,e){let t=n.state.doc.resolve(e);if(!(G||od)&&t.parent.inlineContent){let r=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(s.left-r.left)>1)return s.left<r.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(s.left-r.left)>1)return s.left>r.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function As(n,e,t){let i=n.state.selection;if(i instanceof N&&!i.empty||t.indexOf("s")>-1||ae&&t.indexOf("m")>-1)return!1;let{$from:r,$to:s}=i;if(!r.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Ui(n.state,e);if(o&&o instanceof T)return Pe(n,o)}if(!r.parent.inlineContent){let o=e<0?r:s,l=i instanceof se?A.near(o,e):A.findFrom(o,e);return l?Pe(n,l):!1}return!1}function Ns(n,e){if(!(n.state.selection instanceof N))return!0;let{$head:t,$anchor:i,empty:r}=n.state.selection;if(!t.sameParent(i))return!0;if(!r)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=n.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),n.dispatch(o),!0}return!1}function Es(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Hd(n){if(!Z||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let i=e.firstChild;Es(n,i,"true"),setTimeout(()=>Es(n,i,"false"),20)}return!1}function Fd(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function $d(n,e){let t=e.keyCode,i=Fd(e);if(t==8||ae&&t==72&&i=="c")return Ns(n,-1)||xt(n,-1);if(t==46&&!e.shiftKey||ae&&t==68&&i=="c")return Ns(n,1)||xt(n,1);if(t==13||t==27)return!0;if(t==37||ae&&t==66&&i=="c"){let r=t==37?Os(n,n.state.selection.from)=="ltr"?-1:1:-1;return Ts(n,r,i)||xt(n,r)}else if(t==39||ae&&t==70&&i=="c"){let r=t==39?Os(n,n.state.selection.from)=="ltr"?1:-1:1;return Ts(n,r,i)||xt(n,r)}else{if(t==38||ae&&t==80&&i=="c")return As(n,-1,i)||xt(n,-1);if(t==40||ae&&t==78&&i=="c")return Hd(n)||As(n,1,i)||xt(n,1);if(i==(ae?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Fl(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:i,openStart:r,openEnd:s}=e;for(;r>1&&s>1&&i.childCount==1&&i.firstChild.childCount==1;){r--,s--;let p=i.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),i=p.content}let o=n.someProp("clipboardSerializer")||ut.fromSchema(n.state.schema),l=jl(),a=l.createElement("div");a.appendChild(o.serializeFragment(i,{document:l}));let c=a.firstChild,h,d=0;for(;c&&c.nodeType==1&&(h=ql[c.nodeName.toLowerCase()]);){for(let p=h.length-1;p>=0;p--){let u=l.createElement(h[p]);for(;a.firstChild;)u.appendChild(a.firstChild);a.appendChild(u),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${r} ${s}${d?` -${d}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,`
81
81
 
82
- `);return{dom:a,text:f,slice:e}}function Fl(n,e,t,i,r){let s=r.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=e&&(i||s||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,s||i,n)}),s)return e?new w(x.from(n.state.schema.text(e.replace(/\r\n?/g,`
83
- `))),0,0):w.empty;let d=n.someProp("clipboardTextParser",f=>f(e,r,i,n));if(d)l=d;else{let f=r.marks(),{schema:p}=n.state,u=ft.fromSchema(p);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(u.serializeNode(p.text(m,f)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),o=jd(t),cn&&_d(o);let c=o&&o.querySelector("[data-pm-slice]"),h=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let d=+h[3];d>0;d--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Nt.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||h),context:r,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Jd.test(f.parentNode.nodeName)?{ignore:!0}:null}})),h)l=Gd(Es(l,+h[1],+h[2]),h[4]);else if(l=w.maxOpen(Kd(l.content,r),!0),l.openStart||l.openEnd){let d=0,f=0;for(let p=l.content.firstChild;d<l.openStart&&!p.type.spec.isolating;d++,p=p.firstChild);for(let p=l.content.lastChild;f<l.openEnd&&!p.type.spec.isolating;f++,p=p.lastChild);l=Es(l,d,f)}return n.someProp("transformPasted",d=>{l=d(l,n)}),l}const Jd=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Kd(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let a=r.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&Wl(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Jl(o[o.length-1],s.length));let h=$l(l,a);o.push(h),r=r.matchType(h.type),s=a}}),o)return x.from(o)}return n}function $l(n,e,t=0){for(let i=e.length-1;i>=t;i--)n=e[i].create(null,x.from(n));return n}function Wl(n,e,t,i,r){if(r<n.length&&r<e.length&&n[r]==e[r]){let s=Wl(n,e,t,i.lastChild,r+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));if(i.contentMatchAt(i.childCount).matchType(r==n.length-1?t.type:n[r+1]))return i.copy(i.content.append(x.from($l(t,n,r+1))))}}function Jl(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Jl(n.lastChild,e-1)),i=n.contentMatchAt(n.childCount).fillBefore(x.empty,!0);return n.copy(t.append(i))}function Zi(n,e,t,i,r,s){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(s=0),r<i-1&&(l=Zi(l,e,t,i,r+1,s)),r>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=r).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(x.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function Es(n,e,t){return e<n.openStart&&(n=new w(Zi(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new w(Zi(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Kl={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Ds=null;function ql(){return Ds||(Ds=document.implementation.createHTMLDocument("title"))}let Mi=null;function qd(n){let e=window.trustedTypes;return e?(Mi||(Mi=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Mi.createHTML(n)):n}function jd(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=ql().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(n),r;if((r=i&&Kl[i[1].toLowerCase()])&&(n=r.map(s=>"<"+s+">").join("")+n+r.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=qd(n),r)for(let s=0;s<r.length;s++)t=t.querySelector(r[s])||t;return t}function _d(n){let e=n.querySelectorAll(G?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let i=e[t];i.childNodes.length==1&&i.textContent==" "&&i.parentNode&&i.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),i)}}function Gd(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,i;try{i=JSON.parse(e)}catch{return n}let{content:r,openStart:s,openEnd:o}=n;for(let l=i.length-2;l>=0;l-=2){let a=t.nodes[i[l]];if(!a||a.hasRequiredAttrs())break;r=x.from(a.create(i[l+1],r)),s++,o++}return new w(r,s,o)}const X={},Y={},Ud={touchstart:!0,touchmove:!0};class Zd{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Xd(n){for(let e in X){let t=X[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=i=>{Qd(n,i)&&!gr(n,i)&&(n.editable||!(i.type in Y))&&t(n,i)},Ud[e]?{passive:!0}:void 0)}Z&&n.dom.addEventListener("input",()=>null),Xi(n)}function He(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Yd(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Xi(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=i=>gr(n,i))})}function gr(n,e){return n.someProp("handleDOMEvents",t=>{let i=t[e.type];return i?i(n,e)||e.defaultPrevented:!1})}function Qd(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function ef(n,e){!gr(n,e)&&X[e.type]&&(n.editable||!(e.type in Y))&&X[e.type](n,e)}Y.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!_l(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(fe&&G&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Rt&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let i=Date.now();n.input.lastIOSEnter=i,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==i&&(n.someProp("handleKeyDown",r=>r(n,Ye(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",i=>i(n,t))||Wd(n,t)?t.preventDefault():He(n,"key")};Y.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Y.keypress=(n,e)=>{let t=e;if(_l(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ae&&t.metaKey)return;if(n.someProp("handleKeyPress",r=>r(n,t))){t.preventDefault();return}let i=n.state.selection;if(!(i instanceof N)||!i.$from.sameParent(i.$to)){let r=String.fromCharCode(t.charCode);!/[\r\n]/.test(r)&&!n.someProp("handleTextInput",s=>s(n,i.$from.pos,i.$to.pos,r))&&n.dispatch(n.state.tr.insertText(r).scrollIntoView()),t.preventDefault()}};function ti(n){return{left:n.clientX,top:n.clientY}}function tf(n,e){let t=e.x-n.clientX,i=e.y-n.clientY;return t*t+i*i<100}function yr(n,e,t,i,r){if(i==-1)return!1;let s=n.state.doc.resolve(i);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,l=>o>s.depth?l(n,t,s.nodeAfter,s.before(o),r,!0):l(n,t,s.node(o),s.before(o),r,!1)))return!0;return!1}function Ot(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let i=n.state.tr.setSelection(e);i.setMeta("pointer",!0),n.dispatch(i)}function nf(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),i=t.nodeAfter;return i&&i.isAtom&&T.isSelectable(i)?(Ot(n,new T(t)),!0):!1}function rf(n,e){if(e==-1)return!1;let t=n.state.selection,i,r;t instanceof T&&(i=t.node);let s=n.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(T.isSelectable(l)){i&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?r=s.before(t.$from.depth):r=s.before(o);break}}return r!=null?(Ot(n,T.create(n.state.doc,r)),!0):!1}function sf(n,e,t,i,r){return yr(n,"handleClickOn",e,t,i)||n.someProp("handleClick",s=>s(n,e,i))||(r?rf(n,t):nf(n,t))}function of(n,e,t,i){return yr(n,"handleDoubleClickOn",e,t,i)||n.someProp("handleDoubleClick",r=>r(n,e,i))}function lf(n,e,t,i){return yr(n,"handleTripleClickOn",e,t,i)||n.someProp("handleTripleClick",r=>r(n,e,i))||af(n,t,i)}function af(n,e,t){if(t.button!=0)return!1;let i=n.state.doc;if(e==-1)return i.inlineContent?(Ot(n,N.create(i,0,i.content.size)),!0):!1;let r=i.resolve(e);for(let s=r.depth+1;s>0;s--){let o=s>r.depth?r.nodeAfter:r.node(s),l=r.before(s);if(o.inlineContent)Ot(n,N.create(i,l+1,l+1+o.content.size));else if(T.isSelectable(o))Ot(n,T.create(i,l));else continue;return!0}}function br(n){return Jn(n)}const jl=ae?"metaKey":"ctrlKey";X.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let i=br(n),r=Date.now(),s="singleClick";r-n.input.lastClick.time<500&&tf(t,n.input.lastClick)&&!t[jl]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:r,x:t.clientX,y:t.clientY,type:s};let o=n.posAtCoords(ti(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new cf(n,o,t,!!i)):(s=="doubleClick"?of:lf)(n,o.pos,o.inside,t)?t.preventDefault():He(n,"pointer"))};class cf{constructor(e,t,i,r){this.view=e,this.pos=t,this.event=i,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!i[jl],this.allowDefault=i.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let h=e.state.doc.resolve(t.pos);s=h.parent,o=h.depth?h.before():0}const l=r?null:i.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(i.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof T&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&pe&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),He(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Oe(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(ti(e))),this.updateAllowDefault(e),this.allowDefault||!t?He(this.view,"pointer"):sf(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Z&&this.mightDrag&&!this.mightDrag.node.isAtom||G&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ot(this.view,A.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):He(this.view,"pointer")}move(e){this.updateAllowDefault(e),He(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}X.touchstart=n=>{n.input.lastTouch=Date.now(),br(n),He(n,"pointer")};X.touchmove=n=>{n.input.lastTouch=Date.now(),He(n,"pointer")};X.contextmenu=n=>br(n);function _l(n,e){return n.composing?!0:Z&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const hf=fe?5e3:-1;Y.compositionstart=Y.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof N&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(i=>i.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Jn(n,!0),n.markCursor=null;else if(Jn(n,!e.selection.empty),pe&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let i=n.domSelectionRange();for(let r=i.focusNode,s=i.focusOffset;r&&r.nodeType==1&&s!=0;){let o=s<0?r.lastChild:r.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else r=o,s=-1}}n.input.composing=!0}Gl(n,hf)};Y.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Gl(n,20))};function Gl(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Jn(n),e))}function Ul(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=ff());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function df(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=nd(e.focusNode,e.focusOffset),i=id(e.focusNode,e.focusOffset);if(t&&i&&t!=i){let r=i.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||i==s)return s;if(!r||!r.isText(i.nodeValue))return i;if(n.input.compositionNode==i){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return i}}return t||i}function ff(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Jn(n,e=!1){if(!(fe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ul(n),e||n.docView&&n.docView.dirty){let t=pr(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function uf(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let i=getSelection(),r=document.createRange();r.selectNodeContents(e),n.dom.blur(),i.removeAllRanges(),i.addRange(r),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const nn=te&&Fe<15||Rt&&ad<604;X.copy=Y.cut=(n,e)=>{let t=e,i=n.state.selection,r=t.type=="cut";if(i.empty)return;let s=nn?null:t.clipboardData,o=i.content(),{dom:l,text:a}=Hl(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):uf(n,l),r&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function pf(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function mf(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,i=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();let r=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),i.parentNode&&i.parentNode.removeChild(i),t?rn(n,i.value,null,r,e):rn(n,i.textContent,i.innerHTML,r,e)},50)}function rn(n,e,t,i,r){let s=Fl(n,e,t,i,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,r,s||w.empty)))return!0;if(!s)return!1;let o=pf(s),l=o?n.state.tr.replaceSelectionWith(o,i):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Zl(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Y.paste=(n,e)=>{let t=e;if(n.composing&&!fe)return;let i=nn?null:t.clipboardData,r=n.input.shiftKey&&n.input.lastKeyCode!=45;i&&rn(n,Zl(i),i.getData("text/html"),r,t)?t.preventDefault():mf(n,t)};class Xl{constructor(e,t,i){this.slice=e,this.move=t,this.node=i}}const Yl=ae?"altKey":"ctrlKey";X.dragstart=(n,e)=>{let t=e,i=n.input.mouseDown;if(i&&i.done(),!t.dataTransfer)return;let r=n.state.selection,s=r.empty?null:n.posAtCoords(ti(t)),o;if(!(s&&s.pos>=r.from&&s.pos<=(r instanceof T?r.to-1:r.to))){if(i&&i.mightDrag)o=T.create(n.state.doc,i.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(o=T.create(n.state.doc,d.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:h}=Hl(n,l);(!t.dataTransfer.files.length||!G||kl>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(nn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",nn||t.dataTransfer.setData("text/plain",c),n.dragging=new Xl(h,!t[Yl],o)};X.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Y.dragover=Y.dragenter=(n,e)=>e.preventDefault();Y.drop=(n,e)=>{let t=e,i=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let r=n.posAtCoords(ti(t));if(!r)return;let s=n.state.doc.resolve(r.pos),o=i&&i.slice;o?n.someProp("transformPasted",u=>{o=u(o,n)}):o=Fl(n,Zl(t.dataTransfer),nn?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(i&&!t[Yl]);if(n.someProp("handleDrop",u=>u(n,t,o||w.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?ah(n.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:u}=i;u?u.replace(c):c.deleteSelection()}let h=c.mapping.map(a),d=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(h,h,o.content.firstChild):c.replaceRange(h,h,o),c.doc.eq(f))return;let p=c.doc.resolve(h);if(d&&T.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new T(p));else{let u=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,S)=>u=S),c.setSelection(mr(n,p,c.doc.resolve(u)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};X.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Oe(n)},20))};X.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};X.beforeinput=(n,e)=>{if(G&&fe&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:i}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=i||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Ye(8,"Backspace")))))return;let{$cursor:r}=n.state.selection;r&&r.pos>0&&n.dispatch(n.state.tr.delete(r.pos-1,r.pos).scrollIntoView())},50)}};for(let n in Y)X[n]=Y[n];function sn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Kn{constructor(e,t){this.toDOM=e,this.spec=t||lt,this.side=this.spec.side||0}map(e,t,i,r){let{pos:s,deleted:o}=e.mapResult(t.from+r,this.side<0?-1:1);return o?null:new ee(s-i,s-i,this)}valid(){return!0}eq(e){return this==e||e instanceof Kn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&sn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class We{constructor(e,t){this.attrs=e,this.spec=t||lt}map(e,t,i,r){let s=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-i,o=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-i;return s>=o?null:new ee(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof We&&sn(this.attrs,e.attrs)&&sn(this.spec,e.spec)}static is(e){return e.type instanceof We}destroy(){}}class xr{constructor(e,t){this.attrs=e,this.spec=t||lt}map(e,t,i,r){let s=e.mapResult(t.from+r,1);if(s.deleted)return null;let o=e.mapResult(t.to+r,-1);return o.deleted||o.pos<=s.pos?null:new ee(s.pos-i,o.pos-i,this)}valid(e,t){let{index:i,offset:r}=e.content.findIndex(t.from),s;return r==t.from&&!(s=e.child(i)).isText&&r+s.nodeSize==t.to}eq(e){return this==e||e instanceof xr&&sn(this.attrs,e.attrs)&&sn(this.spec,e.spec)}destroy(){}}class ee{constructor(e,t,i){this.from=e,this.to=t,this.type=i}copy(e,t){return new ee(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,i){return this.type.map(e,this,t,i)}static widget(e,t,i){return new ee(e,e,new Kn(t,i))}static inline(e,t,i,r){return new ee(e,t,new We(i,r))}static node(e,t,i,r){return new ee(e,t,new xr(i,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof We}get widget(){return this.type instanceof Kn}}const wt=[],lt={};class R{constructor(e,t){this.local=e.length?e:wt,this.children=t.length?t:wt}static create(e,t){return t.length?qn(t,e,0,lt):j}find(e,t,i){let r=[];return this.findInner(e??0,t??1e9,r,0,i),r}findInner(e,t,i,r,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&i.push(l.copy(l.from+r,l.to+r))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,i,r+l,s)}}map(e,t,i){return this==j||e.maps.length==0?this:this.mapInner(e,t,0,0,i||lt)}mapInner(e,t,i,r,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,i,r);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?gf(this.children,o||[],e,t,i,r,s):o?new R(o.sort(at),wt):j}add(e,t){return t.length?this==j?R.create(e,t):this.addInner(e,t,0):this}addInner(e,t,i){let r,s=0;e.forEach((l,a)=>{let c=a+i,h;if(h=ea(t,l,c)){for(r||(r=this.children.slice());s<r.length&&r[s]<a;)s+=3;r[s]==a?r[s+2]=r[s+2].addInner(l,h,c+1):r.splice(s,0,a,a+l.nodeSize,qn(h,l,c+1,lt)),s+=3}});let o=Ql(s?ta(t):t,-i);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new R(o.length?this.local.concat(o).sort(at):this.local,r||this.children)}remove(e){return e.length==0||this==j?this:this.removeInner(e,0)}removeInner(e,t){let i=this.children,r=this.local;for(let s=0;s<i.length;s+=3){let o,l=i[s]+t,a=i[s+1]+t;for(let h=0,d;h<e.length;h++)(d=e[h])&&d.from>l&&d.to<a&&(e[h]=null,(o||(o=[])).push(d));if(!o)continue;i==this.children&&(i=this.children.slice());let c=i[s+2].removeInner(o,l+1);c!=j?i[s+2]=c:(i.splice(s,3),s-=3)}if(r.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<r.length;l++)r[l].eq(o,t)&&(r==this.local&&(r=this.local.slice()),r.splice(l--,1))}return i==this.children&&r==this.local?this:r.length||i.length?new R(r,i):j}forChild(e,t){if(this==j)return this;if(t.isLeaf)return R.empty;let i,r;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(i=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof We){let c=Math.max(s,a.from)-s,h=Math.min(o,a.to)-s;c<h&&(r||(r=[])).push(a.copy(c,h))}}if(r){let l=new R(r.sort(at),wt);return i?new Pe([l,i]):l}return i||j}eq(e){if(this==e)return!0;if(!(e instanceof R)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Cr(this.localsInner(e))}localsInner(e){if(this==j)return wt;if(e.inlineContent||!this.local.some(We.is))return this.local;let t=[];for(let i=0;i<this.local.length;i++)this.local[i].type instanceof We||t.push(this.local[i]);return t}forEachSet(e){e(this)}}R.empty=new R([],[]);R.removeOverlap=Cr;const j=R.empty;class Pe{constructor(e){this.members=e}map(e,t){const i=this.members.map(r=>r.map(e,t,lt));return Pe.from(i)}forChild(e,t){if(t.isLeaf)return R.empty;let i=[];for(let r=0;r<this.members.length;r++){let s=this.members[r].forChild(e,t);s!=j&&(s instanceof Pe?i=i.concat(s.members):i.push(s))}return Pe.from(i)}eq(e){if(!(e instanceof Pe)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,i=!0;for(let r=0;r<this.members.length;r++){let s=this.members[r].localsInner(e);if(s.length)if(!t)t=s;else{i&&(t=t.slice(),i=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?Cr(i?t:t.sort(at)):wt}static from(e){switch(e.length){case 0:return j;case 1:return e[0];default:return new Pe(e.every(t=>t instanceof R)?e:e.reduce((t,i)=>t.concat(i instanceof R?i:i.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function gf(n,e,t,i,r,s,o){let l=n.slice();for(let c=0,h=s;c<t.maps.length;c++){let d=0;t.maps[c].forEach((f,p,u,m)=>{let g=m-u-(p-f);for(let y=0;y<l.length;y+=3){let S=l[y+1];if(S<0||f>S+h-d)continue;let b=l[y]+h-d;p>=b?l[y+1]=f<=b?-2:-1:f>=h&&g&&(l[y]+=g,l[y+1]+=g)}d+=g}),h=t.maps[c].map(h,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let h=t.map(n[c]+s),d=h-r;if(d<0||d>=i.content.size){a=!0;continue}let f=t.map(n[c+1]+s,-1),p=f-r,{index:u,offset:m}=i.content.findIndex(d),g=i.maybeChild(u);if(g&&m==d&&m+g.nodeSize==p){let y=l[c+2].mapInner(t,g,h+1,n[c]+s+1,o);y!=j?(l[c]=d,l[c+1]=p,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=yf(l,n,e,t,r,s,o),h=qn(c,i,0,o);e=h.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<h.children.length;d+=3){let p=h.children[d];for(;f<l.length&&l[f]<p;)f+=3;l.splice(f,0,h.children[d],h.children[d+1],h.children[d+2])}}return new R(e.sort(at),l)}function Ql(n,e){if(!e||!n.length)return n;let t=[];for(let i=0;i<n.length;i++){let r=n[i];t.push(new ee(r.from+e,r.to+e,r.type))}return t}function yf(n,e,t,i,r,s,o){function l(a,c){for(let h=0;h<a.local.length;h++){let d=a.local[h].map(i,r,c);d?t.push(d):o.onRemove&&o.onRemove(a.local[h].spec)}for(let h=0;h<a.children.length;h+=3)l(a.children[h+2],a.children[h]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function ea(n,e,t){if(e.isLeaf)return null;let i=t+e.nodeSize,r=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<i&&((r||(r=[])).push(o),n[s]=null);return r}function ta(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function qn(n,e,t,i){let r=[],s=!1;e.forEach((l,a)=>{let c=ea(n,l,a+t);if(c){s=!0;let h=qn(c,l,t+a+1,i);h!=j&&r.push(a,a+l.nodeSize,h)}});let o=Ql(s?ta(n):n,-t).sort(at);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(i.onRemove&&i.onRemove(o[l].spec),o.splice(l--,1));return o.length||r.length?new R(o,r):j}function at(n,e){return n.from-e.from||n.to-e.to}function Cr(n){let e=n;for(let t=0;t<e.length-1;t++){let i=e[t];if(i.from!=i.to)for(let r=t+1;r<e.length;r++){let s=e[r];if(s.from==i.from){s.to!=i.to&&(e==n&&(e=n.slice()),e[r]=s.copy(s.from,i.to),Is(e,r+1,s.copy(i.to,s.to)));continue}else{s.from<i.to&&(e==n&&(e=n.slice()),e[t]=i.copy(i.from,s.from),Is(e,r,i.copy(s.from,i.to)));break}}}return e}function Is(n,e,t){for(;e<n.length&&at(t,n[e])>0;)e++;n.splice(e,0,t)}function Ti(n){let e=[];return n.someProp("decorations",t=>{let i=t(n.state);i&&i!=j&&e.push(i)}),n.cursorWrapper&&e.push(R.create(n.state.doc,[n.cursorWrapper.deco])),Pe.from(e)}const bf={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},xf=te&&Fe<=11;class Cf{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class wf{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Cf,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(i=>{for(let r=0;r<i.length;r++)this.queue.push(i[r]);te&&Fe<=11&&i.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),xf&&(this.onCharData=i=>{this.queue.push({target:i.target,type:"characterData",oldValue:i.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,bf)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(vs(this.view)){if(this.suppressingSelectionUpdates)return Oe(this.view);if(te&&Fe<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ht(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,i;for(let s=e.focusNode;s;s=tn(s))t.add(s);for(let s=e.anchorNode;s;s=tn(s))if(t.has(s)){i=s;break}let r=i&&this.view.docView.nearestDesc(i);if(r&&r.ignoreMutation({type:"selection",target:i.nodeType==3?i.parentNode:i}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let i=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&vs(e)&&!this.ignoreSelectionChange(i),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let h=0;h<t.length;h++){let d=this.registerMutation(t[h],a);d&&(s=s<0?d.from:Math.min(d.from,s),o=o<0?d.to:Math.max(d.to,o),d.typeOver&&(l=!0))}if(pe&&a.length){let h=a.filter(d=>d.nodeName=="BR");if(h.length==2){let[d,f]=h;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of h){let p=f.parentNode;p&&p.nodeName=="LI"&&(!d||vf(e,d)!=p)&&f.remove()}}}let c=null;s<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Qn(i)&&(c=pr(e))&&c.eq(A.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Oe(e),this.currentSelection.set(i),e.scrollToSelection()):(s>-1||r)&&(s>-1&&(e.docView.markDirty(s,o),Sf(e)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(i)||Oe(e),this.currentSelection.set(i))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let i=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(i==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!i||i.ignoreMutation(e))return null;if(e.type=="childList"){for(let h=0;h<e.addedNodes.length;h++){let d=e.addedNodes[h];t.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(i.contentDOM&&i.contentDOM!=i.dom&&!i.contentDOM.contains(e.target))return{from:i.posBefore,to:i.posAfter};let r=e.previousSibling,s=e.nextSibling;if(te&&Fe<=11&&e.addedNodes.length)for(let h=0;h<e.addedNodes.length;h++){let{previousSibling:d,nextSibling:f}=e.addedNodes[h];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(r=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(s=f)}let o=r&&r.parentNode==e.target?J(r)+1:0,l=i.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?J(s):e.target.childNodes.length,c=i.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:i.posAtStart-i.border,to:i.posAtEnd+i.border}:(this.lastChangedTextNode=e.target,{from:i.posAtStart,to:i.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Rs=new WeakMap,Vs=!1;function Sf(n){if(!Rs.has(n)&&(Rs.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=pe,Vs)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Vs=!0}}function Ps(n,e){let t=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return ht(o.node,o.offset,r,s)&&([t,i,r,s]=[r,s,t,i]),{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}}function kf(n,e){if(e.getComposedRanges){let r=e.getComposedRanges(n.root)[0];if(r)return Ps(n,r)}let t;function i(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",i,!0),t?Ps(n,t):null}function vf(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let i=n.docView.nearestDesc(t,!0);if(i&&i.node.isBlock)return t}return null}function Mf(n,e,t){let{node:i,fromOffset:r,toOffset:s,from:o,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,h=a.anchorNode;if(h&&n.dom.contains(h.nodeType==1?h:h.parentNode)&&(c=[{node:h,offset:a.anchorOffset}],Qn(a)||c.push({node:a.focusNode,offset:a.focusOffset})),G&&n.input.lastKeyCode===8)for(let g=s;g>r;g--){let y=i.childNodes[g-1],S=y.pmViewDesc;if(y.nodeName=="BR"&&!S){s=g;break}if(!S||S.size)break}let d=n.state.doc,f=n.someProp("domParser")||Nt.fromSchema(n.state.schema),p=d.resolve(o),u=null,m=f.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:r,to:s,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Tf,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),u={anchor:g+o,head:y+o}}return{doc:m,sel:u,from:o,to:l}}function Tf(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Z&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Z&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Of=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Af(n,e,t,i,r){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let O=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,Q=pr(n,O);if(Q&&!n.state.selection.eq(Q)){if(G&&fe&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",q=>q(n,Ye(13,"Enter"))))return;let P=n.state.tr.setSelection(Q);O=="pointer"?P.setMeta("pointer",!0):O=="key"&&P.scrollIntoView(),s&&P.setMeta("composition",s),n.dispatch(P)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Mf(n,e,t),h=n.state.doc,d=h.slice(c.from,c.to),f,p;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,p="end"):(f=n.state.selection.from,p="start"),n.input.lastKeyCode=null;let u=Df(d.content,c.doc.content,c.from,f,p);if(u&&n.input.domChangeCount++,(Rt&&n.input.lastIOSEnter>Date.now()-225||fe)&&r.some(O=>O.nodeType==1&&!Of.test(O.nodeName))&&(!u||u.endA>=u.endB)&&n.someProp("handleKeyDown",O=>O(n,Ye(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!u)if(i&&a instanceof N&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))u={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let O=zs(n,n.state.doc,c.sel);if(O&&!O.eq(n.state.selection)){let Q=n.state.tr.setSelection(O);s&&Q.setMeta("composition",s),n.dispatch(Q)}}return}n.state.selection.from<n.state.selection.to&&u.start==u.endB&&n.state.selection instanceof N&&(u.start>n.state.selection.from&&u.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?u.start=n.state.selection.from:u.endA<n.state.selection.to&&u.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(u.endB+=n.state.selection.to-u.endA,u.endA=n.state.selection.to)),te&&Fe<=11&&u.endB==u.start+1&&u.endA==u.start&&u.start>c.from&&c.doc.textBetween(u.start-c.from-1,u.start-c.from+1)=="  "&&(u.start--,u.endA--,u.endB--);let m=c.doc.resolveNoCache(u.start-c.from),g=c.doc.resolveNoCache(u.endB-c.from),y=h.resolve(u.start),S=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=u.endA,b;if((Rt&&n.input.lastIOSEnter>Date.now()-225&&(!S||r.some(O=>O.nodeName=="DIV"||O.nodeName=="P"))||!S&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(b=A.findFrom(c.doc.resolve(m.pos+1),1,!0))&&b.head==g.pos)&&n.someProp("handleKeyDown",O=>O(n,Ye(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>u.start&&Ef(h,u.start,u.endA,m,g)&&n.someProp("handleKeyDown",O=>O(n,Ye(8,"Backspace")))){fe&&G&&n.domObserver.suppressSelectionUpdates();return}G&&fe&&u.endB==u.start&&(n.input.lastAndroidDelete=Date.now()),fe&&!S&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==u.endA&&(u.endB-=2,g=c.doc.resolveNoCache(u.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(O){return O(n,Ye(13,"Enter"))})},20));let C=u.start,k=u.endA,M,E,L;if(S){if(m.pos==g.pos)te&&Fe<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Oe(n),20)),M=n.state.tr.delete(C,k),E=h.resolve(u.start).marksAcross(h.resolve(u.endA));else if(u.endA==u.endB&&(L=Nf(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,u.endA-y.start()))))M=n.state.tr,L.type=="add"?M.addMark(C,k,L.mark):M.removeMark(C,k,L.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let O=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",Q=>Q(n,C,k,O)))return;M=n.state.tr.insertText(O,C,k)}}if(M||(M=n.state.tr.replace(C,k,c.doc.slice(u.start-c.from,u.endB-c.from))),c.sel){let O=zs(n,M.doc,c.sel);O&&!(G&&fe&&n.composing&&O.empty&&(u.start!=u.endB||n.input.lastAndroidDelete<Date.now()-100)&&(O.head==C||O.head==M.mapping.map(k)-1)||te&&O.empty&&O.head==C)&&M.setSelection(O)}E&&M.ensureMarks(E),s&&M.setMeta("composition",s),n.dispatch(M.scrollIntoView())}function zs(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:mr(n,e.resolve(t.anchor),e.resolve(t.head))}function Nf(n,e){let t=n.firstChild.marks,i=e.firstChild.marks,r=t,s=i,o,l,a;for(let h=0;h<i.length;h++)r=i[h].removeFromSet(r);for(let h=0;h<t.length;h++)s=t[h].removeFromSet(s);if(r.length==1&&s.length==0)l=r[0],o="add",a=h=>h.mark(l.addToSet(h.marks));else if(r.length==0&&s.length==1)l=s[0],o="remove",a=h=>h.mark(l.removeFromSet(h.marks));else return null;let c=[];for(let h=0;h<e.childCount;h++)c.push(a(e.child(h)));if(x.from(c).eq(n))return{mark:l,type:o}}function Ef(n,e,t,i,r){if(t-e<=r.pos-i.pos||Oi(i,!0,!1)<r.pos)return!1;let s=n.resolve(e);if(!i.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=n.resolve(Oi(s,!0,!0));return!o.parent.isTextblock||o.pos>t||Oi(o,!0,!1)<t?!1:i.parent.content.cut(i.parentOffset).eq(o.parent.content)}function Oi(n,e,t){let i=n.depth,r=e?n.end():n.pos;for(;i>0&&(e||n.indexAfter(i)==n.node(i).childCount);)i--,r++,e=!1;if(t){let s=n.node(i).maybeChild(n.indexAfter(i));for(;s&&!s.isLeaf;)s=s.firstChild,r++}return r}function Df(n,e,t,i,r){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:o,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(r=="end"){let a=Math.max(0,s-Math.min(o,l));i-=o+a-s}if(o<s&&n.size<e.size){let a=i<=s&&i>=o?s-i:0;s-=a,s&&s<e.size&&Bs(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-o),o=s}else if(l<s){let a=i<=s&&i>=l?s-i:0;s-=a,s&&s<n.size&&Bs(n.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function Bs(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class If{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Zd,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Ws),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Fs(this),Hs(this),this.nodeViews=$s(this),this.docView=bs(this.state.doc,Ls(this),Ti(this),this.dom,this),this.domObserver=new wf(this,(i,r,s,o)=>Af(this,i,r,s,o)),this.domObserver.start(),Xd(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Xi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Ws),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let i in this._props)t[i]=this._props[i];t.state=this.state;for(let i in e)t[i]=e[i];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var i;let r=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(Ul(this),o=!0),this.state=e;let l=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=$s(this);Vf(p,this.nodeViews)&&(this.nodeViews=p,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Xi(this),this.editable=Fs(this),Hs(this);let a=Ti(this),c=Ls(this),h=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",d=s||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(r.selection))&&(o=!0);let f=h=="preserve"&&o&&this.dom.style.overflowAnchor==null&&dd(this);if(o){this.domObserver.stop();let p=d&&(te||G)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&Rf(r.selection,e.selection);if(d){let u=G?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=df(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=bs(e.doc,c,a,this.dom,this)),u&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Pd(this))?Oe(this,p):(zl(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),!((i=this.dragging)===null||i===void 0)&&i.node&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),h=="reset"?this.dom.scrollTop=0:h=="to selection"?this.scrollToSelection():f&&fd(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof T){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&fs(this,t.getBoundingClientRect(),e)}else fs(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let i=this.directPlugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let i=this.state.plugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let i=this.pluginViews[t];i.update&&i.update(this,e)}}updateDraggedNode(e,t){let i=e.node,r=-1;if(this.state.doc.nodeAt(i.from)==i.node)r=i.from;else{let s=i.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==i.node&&(r=s)}this.dragging=new Xl(e.slice,e.move,r<0?void 0:T.create(this.state.doc,r))}someProp(e,t){let i=this._props&&this._props[e],r;if(i!=null&&(r=t?t(i):i))return r;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(r=t?t(l):l))return r}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(r=t?t(l):l))return r}}hasFocus(){if(te){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&ud(this.dom),Oe(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return bd(this,e)}coordsAtPos(e,t=1){return Al(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,i=-1){let r=this.docView.posFromDOM(e,t,i);if(r==null)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return kd(this,t||this.state,e)}pasteHTML(e,t){return rn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return rn(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Yd(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ti(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ed())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return ef(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?Z&&this.root.nodeType===11&&sd(this.dom.ownerDocument)==this.dom&&kf(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Ls(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let i in t)i=="class"?e.class+=" "+t[i]:i=="style"?e.style=(e.style?e.style+";":"")+t[i]:!e[i]&&i!="contenteditable"&&i!="nodeName"&&(e[i]=String(t[i]))}),e.translate||(e.translate="no"),[ee.node(0,n.state.doc.content.size,e)]}function Hs(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:ee.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Fs(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Rf(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function $s(n){let e=Object.create(null);function t(i){for(let r in i)Object.prototype.hasOwnProperty.call(e,r)||(e[r]=i[r])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Vf(n,e){let t=0,i=0;for(let r in n){if(n[r]!=e[r])return!0;t++}for(let r in e)i++;return t!=i}function Ws(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Yi,Qi;if(typeof WeakMap<"u"){let n=new WeakMap;Yi=e=>n.get(e),Qi=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Yi=i=>{for(let r=0;r<n.length;r+=2)if(n[r]==i)return n[r+1]},Qi=(i,r)=>(t==10&&(t=0),n[t++]=i,n[t++]=r)}var z=class{constructor(n,e,t,i){this.width=n,this.height=e,this.map=t,this.problems=i}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const i=e%this.width,r=e/this.width|0;let s=i+1,o=r+1;for(let l=1;s<this.width&&this.map[e+l]==t;l++)s++;for(let l=1;o<this.height&&this.map[e+this.width*l]==t;l++)o++;return{left:i,top:r,right:s,bottom:o}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:i,right:r,top:s,bottom:o}=this.findCell(n);return e=="horiz"?(t<0?i==0:r==this.width)?null:this.map[s*this.width+(t<0?i-1:r)]:(t<0?s==0:o==this.height)?null:this.map[i+this.width*(t<0?s-1:o)]}rectBetween(n,e){const{left:t,right:i,top:r,bottom:s}=this.findCell(n),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,o),top:Math.min(r,a),right:Math.max(i,l),bottom:Math.max(s,c)}}cellsInRect(n){const e=[],t={};for(let i=n.top;i<n.bottom;i++)for(let r=n.left;r<n.right;r++){const s=i*this.width+r,o=this.map[s];t[o]||(t[o]=!0,!(r==n.left&&r&&this.map[s-1]==o||i==n.top&&i&&this.map[s-this.width]==o)&&e.push(o))}return e}positionAt(n,e,t){for(let i=0,r=0;;i++){const s=r+t.child(i).nodeSize;if(i==n){let o=e+n*this.width;const l=(n+1)*this.width;for(;o<l&&this.map[o]<r;)o++;return o==l?s-1:this.map[o]}r=s}}static get(n){return Yi(n)||Qi(n,Pf(n))}};function Pf(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=zf(n),t=n.childCount,i=[];let r=0,s=null;const o=[];for(let c=0,h=e*t;c<h;c++)i[c]=0;for(let c=0,h=0;c<t;c++){const d=n.child(c);h++;for(let u=0;;u++){for(;r<i.length&&i[r]!=0;)r++;if(u==d.childCount)break;const m=d.child(u),{colspan:g,rowspan:y,colwidth:S}=m.attrs;for(let b=0;b<y;b++){if(b+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:h,n:y-b});break}const C=r+b*e;for(let k=0;k<g;k++){i[C+k]==0?i[C+k]=h:(s||(s=[])).push({type:"collision",row:c,pos:h,n:g-k});const M=S&&S[k];if(M){const E=(C+k)%e*2,L=o[E];L==null||L!=M&&o[E+1]==1?(o[E]=M,o[E+1]=1):L==M&&o[E+1]++}}}r+=g,h+=m.nodeSize}const f=(c+1)*e;let p=0;for(;r<f;)i[r++]==0&&p++;p&&(s||(s=[])).push({type:"missing",row:c,n:p}),h++}const l=new z(e,t,i,s);let a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(a=!0);return a&&Bf(l,o,n),l}function zf(n){let e=-1,t=!1;for(let i=0;i<n.childCount;i++){const r=n.child(i);let s=0;if(t)for(let o=0;o<i;o++){const l=n.child(o);for(let a=0;a<l.childCount;a++){const c=l.child(a);o+c.attrs.rowspan>i&&(s+=c.attrs.colspan)}}for(let o=0;o<r.childCount;o++){const l=r.child(o);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function Bf(n,e,t){n.problems||(n.problems=[]);const i={};for(let r=0;r<n.map.length;r++){const s=n.map[r];if(i[s])continue;i[s]=!0;const o=t.nodeAt(s);if(!o)throw new RangeError(`No cell with offset ${s} found`);let l=null;const a=o.attrs;for(let c=0;c<a.colspan;c++){const h=(r+c)%n.width,d=e[h*2];d!=null&&(!a.colwidth||a.colwidth[c]!=d)&&((l||(l=Lf(a)))[c]=d)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function Lf(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Js(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),i=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(o=>Number(o)):null,r=Number(n.getAttribute("colspan")||1),s={colspan:r,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:i&&i.length==r?i:null};for(const o in e){const l=e[o].getFromDOM,a=l&&l(n);a!=null&&(s[o]=a)}return s}function Ks(n,e){const t={};n.attrs.colspan!=1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!=1&&(t.rowspan=n.attrs.rowspan),n.attrs.colwidth&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(const i in e){const r=e[i].setDOMAttr;r&&r(n.attrs[i],t)}return t}function Hf(n){const e=n.cellAttributes||{},t={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const i in e)t[i]={default:e[i].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:n.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:i=>Js(i,e)}],toDOM(i){return["td",Ks(i,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:i=>Js(i,e)}],toDOM(i){return["th",Ks(i,e),0]}}}}function Ce(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const i=n.nodes[t],r=i.spec.tableRole;r&&(e[r]=i)}}return e}var ze=new ln("selectingCells");function dn(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function ni(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function wr(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=dn(e.$head)||Ff(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Ff(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const i=e.type.spec.tableRole;if(i=="cell"||i=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const i=e.type.spec.tableRole;if(i=="cell"||i=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function er(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function $f(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Sr(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function na(n,e,t){const i=n.node(-1),r=z.get(i),s=n.start(-1),o=r.nextCell(n.pos-s,e,t);return o==null?null:n.node(0).resolve(s+o)}function Vt(n,e,t=1){const i={...n,colspan:n.colspan-t};return i.colwidth&&(i.colwidth=i.colwidth.slice(),i.colwidth.splice(e,t),i.colwidth.some(r=>r>0)||(i.colwidth=null)),i}var F=class ve extends A{constructor(e,t=e){const i=e.node(-1),r=z.get(i),s=e.start(-1),o=r.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=r.cellsInRect(o).filter(h=>h!=t.pos-s);a.unshift(t.pos-s);const c=a.map(h=>{const d=i.nodeAt(h);if(!d)throw RangeError(`No cell with offset ${h} found`);const f=s+h+1;return new sl(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const i=e.resolve(t.map(this.$anchorCell.pos)),r=e.resolve(t.map(this.$headCell.pos));if(er(i)&&er(r)&&Sr(i,r)){const s=this.$anchorCell.node(-1)!=i.node(-1);return s&&this.isRowSelection()?ve.rowSelection(i,r):s&&this.isColSelection()?ve.colSelection(i,r):new ve(i,r)}return N.between(i,r)}content(){const e=this.$anchorCell.node(-1),t=z.get(e),i=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i),s={},o=[];for(let a=r.top;a<r.bottom;a++){const c=[];for(let h=a*t.width+r.left,d=r.left;d<r.right;d++,h++){const f=t.map[h];if(s[f])continue;s[f]=!0;const p=t.findCell(f);let u=e.nodeAt(f);if(!u)throw RangeError(`No cell with offset ${f} found`);const m=r.left-p.left,g=p.right-r.right;if(m>0||g>0){let y=u.attrs;if(m>0&&(y=Vt(y,0,m)),g>0&&(y=Vt(y,y.colspan-g,g)),p.left<r.left){if(u=u.type.createAndFill(y),!u)throw RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else u=u.type.create(y,u.content)}if(p.top<r.top||p.bottom>r.bottom){const y={...u.attrs,rowspan:Math.min(p.bottom,r.bottom)-Math.max(p.top,r.top)};p.top<r.top?u=u.type.createAndFill(y):u=u.type.create(y,u.content)}c.push(u)}o.push(e.child(a).copy(x.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new w(x.from(l),1,1)}replace(e,t=w.empty){const i=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){const{$from:l,$to:a}=r[o],c=e.mapping.slice(i);e.replace(c.map(l.pos),c.map(a.pos),o?w.empty:t)}const s=A.findFrom(e.doc.resolve(e.mapping.slice(i).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new w(x.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),i=z.get(t),r=this.$anchorCell.start(-1),s=i.cellsInRect(i.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let o=0;o<s.length;o++)e(t.nodeAt(s[o]),r+s[o])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const i=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(i,r)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const i=e.node(-1),r=z.get(i),s=e.start(-1),o=r.findCell(e.pos-s),l=r.findCell(t.pos-s),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(s+r.map[o.left])),l.bottom<r.height&&(t=a.resolve(s+r.map[r.width*(r.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(s+r.map[l.left])),o.bottom<r.height&&(e=a.resolve(s+r.map[r.width*(r.height-1)+o.right-1]))),new ve(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=z.get(e),i=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-i),s=t.colCount(this.$headCell.pos-i);if(Math.min(r,s)>0)return!1;const o=r+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==t.width}eq(e){return e instanceof ve&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const i=e.node(-1),r=z.get(i),s=e.start(-1),o=r.findCell(e.pos-s),l=r.findCell(t.pos-s),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(s+r.map[o.top*r.width])),l.right<r.width&&(t=a.resolve(s+r.map[r.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(s+r.map[l.top*r.width])),o.right<r.width&&(e=a.resolve(s+r.map[r.width*(o.top+1)-1]))),new ve(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new ve(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,i=t){return new ve(e.resolve(t),e.resolve(i))}getBookmark(){return new Wf(this.$anchorCell.pos,this.$headCell.pos)}};F.prototype.visible=!1;A.jsonID("cell",F);var Wf=class ia{constructor(e,t){this.anchor=e,this.head=t}map(e){return new ia(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),i=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&i.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&i.index()<i.parent.childCount&&Sr(t,i)?new F(t,i):A.near(i,1)}};function Jf(n){if(!(n.selection instanceof F))return null;const e=[];return n.selection.forEachCell((t,i)=>{e.push(ee.node(i,i+t.nodeSize,{class:"selectedCell"}))}),R.create(n.doc,e)}function Kf({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,i=e.pos,r=n.depth;for(;r>=0&&!(n.after(r+1)<n.end(r));r--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,i--);return t==i&&/row|table/.test(n.node(r).type.spec.tableRole)}function qf({$from:n,$to:e}){let t,i;for(let r=n.depth;r>0;r--){const s=n.node(r);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let r=e.depth;r>0;r--){const s=e.node(r);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){i=s;break}}return t!==i&&e.parentOffset===0}function jf(n,e,t){const i=(e||n).selection,r=(e||n).doc;let s,o;if(i instanceof T&&(o=i.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=F.create(r,i.from);else if(o=="row"){const l=r.resolve(i.from+1);s=F.rowSelection(l,l)}else if(!t){const l=z.get(i.node),a=i.from+1,c=a+l.map[l.width*l.height-1];s=F.create(r,a+1,c)}}else i instanceof N&&Kf(i)?s=N.create(r,i.from):i instanceof N&&qf(i)&&(s=N.create(r,i.$from.start(),i.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}var _f=new ln("fix-tables");function ra(n,e,t,i){const r=n.childCount,s=e.childCount;e:for(let o=0,l=0;o<s;o++){const a=e.child(o);for(let c=l,h=Math.min(r,o+3);c<h;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}i(a,t),l<r&&n.child(l).sameMarkup(a)?ra(n.child(l),a,t+1,i):a.nodesBetween(0,a.content.size,i,t+1),t+=a.nodeSize}}function Gf(n,e){let t;const i=(r,s)=>{r.type.spec.tableRole=="table"&&(t=Uf(n,r,s,t))};return e?e.doc!=n.doc&&ra(e.doc,n.doc,0,i):n.doc.descendants(i),t}function Uf(n,e,t,i){const r=z.get(e);if(!r.problems)return i;i||(i=n.tr);const s=[];for(let a=0;a<r.height;a++)s.push(0);for(let a=0;a<r.problems.length;a++){const c=r.problems[a];if(c.type=="collision"){const h=e.nodeAt(c.pos);if(!h)continue;const d=h.attrs;for(let f=0;f<d.rowspan;f++)s[c.row+f]+=c.n;i.setNodeMarkup(i.mapping.map(t+1+c.pos),null,Vt(d,d.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const h=e.nodeAt(c.pos);if(!h)continue;i.setNodeMarkup(i.mapping.map(t+1+c.pos),null,{...h.attrs,rowspan:h.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const h=e.nodeAt(c.pos);if(!h)continue;i.setNodeMarkup(i.mapping.map(t+1+c.pos),null,{...h.attrs,colwidth:c.colwidth})}}let o,l;for(let a=0;a<s.length;a++)s[a]&&(o==null&&(o=a),l=a);for(let a=0,c=t+1;a<r.height;a++){const h=e.child(a),d=c+h.nodeSize,f=s[a];if(f>0){let p="cell";h.firstChild&&(p=h.firstChild.type.spec.tableRole);const u=[];for(let g=0;g<f;g++){const y=Ce(n.schema)[p].createAndFill();y&&u.push(y)}const m=(a==0||o==a-1)&&l==a?c+1:d-1;i.insert(i.mapping.map(m),u)}c=d}return i.setMeta(_f,{fixTables:!0})}function sa(n){const e=n.selection,t=wr(n),i=t.node(-1),r=t.start(-1),s=z.get(i);return{...e instanceof F?s.rectBetween(e.$anchorCell.pos-r,e.$headCell.pos-r):s.findCell(t.pos-r),tableStart:r,map:s,table:i}}function Zf(n){return function(e,t){if(!ni(e))return!1;if(t){const i=Ce(e.schema),r=sa(e),s=e.tr,o=r.map.cellsInRect(n=="column"?{left:r.left,top:0,right:r.right,bottom:r.map.height}:n=="row"?{left:0,top:r.top,right:r.map.width,bottom:r.bottom}:r),l=o.map(a=>r.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==i.header_cell&&s.setNodeMarkup(r.tableStart+o[a],i.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<o.length;a++)s.setNodeMarkup(r.tableStart+o[a],i.header_cell,l[a].attrs);t(s)}return!0}}function qs(n,e,t){const i=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let r=0;r<i.length;r++){const s=e.table.nodeAt(i[r]);if(s&&s.type!==t.header_cell)return!1}return!0}function kr(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Zf(n):function(t,i){if(!ni(t))return!1;if(i){const r=Ce(t.schema),s=sa(t),o=t.tr,l=qs("row",s,r),a=qs("column",s,r),h=(n==="column"?l:n==="row"?a:!1)?1:0,d=n=="column"?{left:0,top:h,right:1,bottom:s.map.height}:n=="row"?{left:h,top:0,right:s.map.width,bottom:1}:s,f=n=="column"?a?r.cell:r.header_cell:n=="row"?l?r.cell:r.header_cell:r.cell;s.map.cellsInRect(d).forEach(p=>{const u=p+s.tableStart,m=o.doc.nodeAt(u);m&&o.setNodeMarkup(u,f,m.attrs)}),i(o)}return!0}}kr("row",{useDeprecatedLogic:!0});kr("column",{useDeprecatedLogic:!0});kr("cell",{useDeprecatedLogic:!0});function Xf(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let i=n.index(-1)-1,r=n.before();i>=0;i--){const s=n.node(-1).child(i),o=s.lastChild;if(o)return r-1-o.nodeSize;r-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let i=n.indexAfter(-1),r=n.after();i<t.childCount;i++){const s=t.child(i);if(s.childCount)return r+1;r+=s.nodeSize}}return null}function js(n){return function(e,t){if(!ni(e))return!1;const i=Xf(wr(e),n);if(i==null)return!1;if(t){const r=e.doc.resolve(i);t(e.tr.setSelection(N.between(r,$f(r))).scrollIntoView())}return!0}}function Cn(n,e){const t=n.selection;if(!(t instanceof F))return!1;if(e){const i=n.tr,r=Ce(n.schema).cell.createAndFill().content;t.forEachCell((s,o)=>{s.content.eq(r)||i.replace(i.mapping.map(o+1),i.mapping.map(o+s.nodeSize-1),new w(r,0,0))}),i.docChanged&&e(i)}return!0}function Yf(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:i}=n;for(;e.childCount==1&&(t>0&&i>0||e.child(0).type.spec.tableRole=="table");)t--,i--,e=e.child(0).content;const r=e.child(0),s=r.type.spec.tableRole,o=r.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const h=a?0:Math.max(0,t-1),d=a<e.childCount-1?0:Math.max(0,i-1);(h||d)&&(c=tr(Ce(o).row,new w(c,h,d)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||i?tr(Ce(o).row,new w(e,t,i)).content:e);else return null;return Qf(o,l)}function Qf(n,e){const t=[];for(let r=0;r<e.length;r++){const s=e[r];for(let o=s.childCount-1;o>=0;o--){const{rowspan:l,colspan:a}=s.child(o).attrs;for(let c=r;c<r+l;c++)t[c]=(t[c]||0)+a}}let i=0;for(let r=0;r<t.length;r++)i=Math.max(i,t[r]);for(let r=0;r<t.length;r++)if(r>=e.length&&e.push(x.empty),t[r]<i){const s=Ce(n).cell.createAndFill(),o=[];for(let l=t[r];l<i;l++)o.push(s);e[r]=e[r].append(x.from(o))}return{height:e.length,width:i,rows:e}}function tr(n,e){const t=n.createAndFill();return new rl(t).replace(0,t.content.size,e).doc}function eu({width:n,height:e,rows:t},i,r){if(n!=i){const s=[],o=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let h=s[l]||0,d=0;h<i;d++){let f=a.child(d%a.childCount);h+f.attrs.colspan>i&&(f=f.type.createChecked(Vt(f.attrs,f.attrs.colspan,h+f.attrs.colspan-i),f.content)),c.push(f),h+=f.attrs.colspan;for(let p=1;p<f.attrs.rowspan;p++)s[l+p]=(s[l+p]||0)+f.attrs.colspan}o.push(x.from(c))}t=o,n=i}if(e!=r){const s=[];for(let o=0,l=0;o<r;o++,l++){const a=[],c=t[l%e];for(let h=0;h<c.childCount;h++){let d=c.child(h);o+d.attrs.rowspan>r&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,r-d.attrs.rowspan)},d.content)),a.push(d)}s.push(x.from(a))}t=s,e=r}return{width:n,height:e,rows:t}}function tu(n,e,t,i,r,s,o){const l=n.doc.type.schema,a=Ce(l);let c,h;if(r>e.width)for(let d=0,f=0;d<e.height;d++){const p=t.child(d);f+=p.nodeSize;const u=[];let m;p.lastChild==null||p.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=h||(h=a.header_cell.createAndFill());for(let g=e.width;g<r;g++)u.push(m);n.insert(n.mapping.slice(o).map(f-1+i),u)}if(s>e.height){const d=[];for(let u=0,m=(e.height-1)*e.width;u<Math.max(e.width,r);u++){const g=u>=e.width?!1:t.nodeAt(e.map[m+u]).type==a.header_cell;d.push(g?h||(h=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const f=a.row.create(null,x.from(d)),p=[];for(let u=e.height;u<s;u++)p.push(f);n.insert(n.mapping.slice(o).map(i+t.nodeSize-2),p)}return!!(c||h)}function _s(n,e,t,i,r,s,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=r;c<s;c++){const h=o*e.width+c,d=e.map[h];if(e.map[h-e.width]==d){a=!0;const f=t.nodeAt(d),{top:p,left:u}=e.findCell(d);n.setNodeMarkup(n.mapping.slice(l).map(d+i),null,{...f.attrs,rowspan:o-p}),n.insert(n.mapping.slice(l).map(e.positionAt(o,u,t)),f.type.createAndFill({...f.attrs,rowspan:p+f.attrs.rowspan-o})),c+=f.attrs.colspan-1}}return a}function Gs(n,e,t,i,r,s,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=r;c<s;c++){const h=c*e.width+o,d=e.map[h];if(e.map[h-1]==d){a=!0;const f=t.nodeAt(d),p=e.colCount(d),u=n.mapping.slice(l).map(d+i);n.setNodeMarkup(u,null,Vt(f.attrs,o-p,f.attrs.colspan-(o-p))),n.insert(u+f.nodeSize,f.type.createAndFill(Vt(f.attrs,0,o-p))),c+=f.attrs.rowspan-1}}return a}function Us(n,e,t,i,r){let s=t?n.doc.nodeAt(t-1):n.doc;if(!s)throw new Error("No table found");let o=z.get(s);const{top:l,left:a}=i,c=a+r.width,h=l+r.height,d=n.tr;let f=0;function p(){if(s=t?d.doc.nodeAt(t-1):d.doc,!s)throw new Error("No table found");o=z.get(s),f=d.mapping.maps.length}tu(d,o,s,t,c,h,f)&&p(),_s(d,o,s,t,a,c,l,f)&&p(),_s(d,o,s,t,a,c,h,f)&&p(),Gs(d,o,s,t,l,h,a,f)&&p(),Gs(d,o,s,t,l,h,c,f)&&p();for(let u=l;u<h;u++){const m=o.positionAt(u,a,s),g=o.positionAt(u,c,s);d.replace(d.mapping.slice(f).map(m+t),d.mapping.slice(f).map(g+t),new w(r.rows[u-l],0,0))}p(),d.setSelection(new F(d.doc.resolve(t+o.positionAt(l,a,s)),d.doc.resolve(t+o.positionAt(h-1,c-1,s)))),e(d)}var nu=wl({ArrowLeft:wn("horiz",-1),ArrowRight:wn("horiz",1),ArrowUp:wn("vert",-1),ArrowDown:wn("vert",1),"Shift-ArrowLeft":Sn("horiz",-1),"Shift-ArrowRight":Sn("horiz",1),"Shift-ArrowUp":Sn("vert",-1),"Shift-ArrowDown":Sn("vert",1),Backspace:Cn,"Mod-Backspace":Cn,Delete:Cn,"Mod-Delete":Cn});function An(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function wn(n,e){return(t,i,r)=>{if(!r)return!1;const s=t.selection;if(s instanceof F)return An(t,i,A.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const o=oa(r,n,e);if(o==null)return!1;if(n=="horiz")return An(t,i,A.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(o),a=na(l,n,e);let c;return a?c=A.near(a,1):e<0?c=A.near(t.doc.resolve(l.before(-1)),-1):c=A.near(t.doc.resolve(l.after(-1)),1),An(t,i,c)}}}function Sn(n,e){return(t,i,r)=>{if(!r)return!1;const s=t.selection;let o;if(s instanceof F)o=s;else{const a=oa(r,n,e);if(a==null)return!1;o=new F(t.doc.resolve(a))}const l=na(o.$headCell,n,e);return l?An(t,i,new F(o.$anchorCell,l)):!1}}function iu(n,e){const t=n.state.doc,i=dn(t.resolve(e));return i?(n.dispatch(n.state.tr.setSelection(new F(i))),!0):!1}function ru(n,e,t){if(!ni(n.state))return!1;let i=Yf(t);const r=n.state.selection;if(r instanceof F){i||(i={width:1,height:1,rows:[x.from(tr(Ce(n.state.schema).cell,t))]});const s=r.$anchorCell.node(-1),o=r.$anchorCell.start(-1),l=z.get(s).rectBetween(r.$anchorCell.pos-o,r.$headCell.pos-o);return i=eu(i,l.right-l.left,l.bottom-l.top),Us(n.state,n.dispatch,o,l,i),!0}else if(i){const s=wr(n.state),o=s.start(-1);return Us(n.state,n.dispatch,o,z.get(s.node(-1)).findCell(s.pos-o),i),!0}else return!1}function su(n,e){var t;if(e.ctrlKey||e.metaKey)return;const i=Zs(n,e.target);let r;if(e.shiftKey&&n.state.selection instanceof F)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&i&&(r=dn(n.state.selection.$anchor))!=null&&((t=Ai(n,e))==null?void 0:t.pos)!=r.pos)s(r,e),e.preventDefault();else if(!i)return;function s(a,c){let h=Ai(n,c);const d=ze.getState(n.state)==null;if(!h||!Sr(a,h))if(d)h=a;else return;const f=new F(a,h);if(d||!n.state.selection.eq(f)){const p=n.state.tr.setSelection(f);d&&p.setMeta(ze,a.pos),n.dispatch(p)}}function o(){n.root.removeEventListener("mouseup",o),n.root.removeEventListener("dragstart",o),n.root.removeEventListener("mousemove",l),ze.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(ze,-1))}function l(a){const c=a,h=ze.getState(n.state);let d;if(h!=null)d=n.state.doc.resolve(h);else if(Zs(n,c.target)!=i&&(d=Ai(n,e),!d))return o();d&&s(d,c)}n.root.addEventListener("mouseup",o),n.root.addEventListener("dragstart",o),n.root.addEventListener("mousemove",l)}function oa(n,e,t){if(!(n.state.selection instanceof N))return null;const{$head:i}=n.state.selection;for(let r=i.depth-1;r>=0;r--){const s=i.node(r);if((t<0?i.index(r):i.indexAfter(r))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=i.before(r),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Zs(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Ai(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?dn(n.state.doc.resolve(t.pos)):null}var ou=class{constructor(n,e){this.node=n,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),nr(n,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(n){return n.type!=this.node.type?!1:(this.node=n,nr(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function nr(n,e,t,i,r,s){var o;let l=0,a=!0,c=e.firstChild;const h=n.firstChild;if(h){for(let d=0,f=0;d<h.childCount;d++){const{colspan:p,colwidth:u}=h.child(d).attrs;for(let m=0;m<p;m++,f++){const g=r==f?s:u&&u[m],y=g?g+"px":"";if(l+=g||i,g||(a=!1),c)c.style.width!=y&&(c.style.width=y),c=c.nextSibling;else{const S=document.createElement("col");S.style.width=y,e.appendChild(S)}}}for(;c;){const d=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=d}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var re=new ln("tableColumnResizing");function lu({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:i=ou,lastColumnResizable:r=!0}={}){const s=new on({key:re,state:{init(o,l){var a,c;const h=(c=(a=s.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,d=Ce(l.schema).table.name;return i&&h&&(h[d]=(f,p)=>new i(f,t,p)),new au(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=re.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{cu(o,l,n,r)},mouseleave:o=>{hu(o)},mousedown:(o,l)=>{du(o,l,e,t)}},decorations:o=>{const l=re.getState(o);if(l&&l.activeHandle>-1)return gu(o,l.activeHandle)},nodeViews:{}}});return s}var au=class Nn{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,i=e.getMeta(re);if(i&&i.setHandle!=null)return new Nn(i.setHandle,!1);if(i&&i.setDragging!==void 0)return new Nn(t.activeHandle,i.setDragging);if(t.activeHandle>-1&&e.docChanged){let r=e.mapping.map(t.activeHandle,-1);return er(e.doc.resolve(r))||(r=-1),new Nn(r,t.dragging)}return t}};function cu(n,e,t,i){const r=re.getState(n.state);if(r&&!r.dragging){const s=uu(e.target);let o=-1;if(s){const{left:l,right:a}=s.getBoundingClientRect();e.clientX-l<=t?o=Xs(n,e,"left",t):a-e.clientX<=t&&(o=Xs(n,e,"right",t))}if(o!=r.activeHandle){if(!i&&o!==-1){const l=n.state.doc.resolve(o),a=l.node(-1),c=z.get(a),h=l.start(-1);if(c.colCount(l.pos-h)+l.nodeAfter.attrs.colspan-1==c.width-1)return}la(n,o)}}}function hu(n){const e=re.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&la(n,-1)}function du(n,e,t,i){var r;const s=(r=n.dom.ownerDocument.defaultView)!=null?r:window,o=re.getState(n.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=n.state.doc.nodeAt(o.activeHandle),a=fu(n,o.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(re,{setDragging:{startX:e.clientX,startWidth:a}}));function c(d){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",h);const f=re.getState(n.state);f!=null&&f.dragging&&(pu(n,f.activeHandle,Ys(f.dragging,d,t)),n.dispatch(n.state.tr.setMeta(re,{setDragging:null})))}function h(d){if(!d.which)return c(d);const f=re.getState(n.state);if(f&&f.dragging){const p=Ys(f.dragging,d,t);Qs(n,f.activeHandle,p,i)}}return Qs(n,o.activeHandle,a,i),s.addEventListener("mouseup",c),s.addEventListener("mousemove",h),e.preventDefault(),!0}function fu(n,e,{colspan:t,colwidth:i}){const r=i&&i[i.length-1];if(r)return r;const s=n.domAtPos(e);let l=s.node.childNodes[s.offset].offsetWidth,a=t;if(i)for(let c=0;c<t;c++)i[c]&&(l-=i[c],a--);return l/a}function uu(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Xs(n,e,t,i){const r=t=="right"?-i:i,s=n.posAtCoords({left:e.clientX+r,top:e.clientY});if(!s)return-1;const{pos:o}=s,l=dn(n.state.doc.resolve(o));if(!l)return-1;if(t=="right")return l.pos;const a=z.get(l.node(-1)),c=l.start(-1),h=a.map.indexOf(l.pos-c);return h%a.width==0?-1:c+a.map[h-1]}function Ys(n,e,t){const i=e.clientX-n.startX;return Math.max(t,n.startWidth+i)}function la(n,e){n.dispatch(n.state.tr.setMeta(re,{setHandle:e}))}function pu(n,e,t){const i=n.state.doc.resolve(e),r=i.node(-1),s=z.get(r),o=i.start(-1),l=s.colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<s.height;c++){const h=c*s.width+l;if(c&&s.map[h]==s.map[h-s.width])continue;const d=s.map[h],f=r.nodeAt(d).attrs,p=f.colspan==1?0:l-s.colCount(d);if(f.colwidth&&f.colwidth[p]==t)continue;const u=f.colwidth?f.colwidth.slice():mu(f.colspan);u[p]=t,a.setNodeMarkup(o+d,null,{...f,colwidth:u})}a.docChanged&&n.dispatch(a)}function Qs(n,e,t,i){const r=n.state.doc.resolve(e),s=r.node(-1),o=r.start(-1),l=z.get(s).colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;let a=n.domAtPos(r.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&nr(s,a.firstChild,a,i,l,t)}function mu(n){return Array(n).fill(0)}function gu(n,e){var t;const i=[],r=n.doc.resolve(e),s=r.node(-1);if(!s)return R.empty;const o=z.get(s),l=r.start(-1),a=o.colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<o.height;c++){const h=a+c*o.width;if((a==o.width-1||o.map[h]!=o.map[h+1])&&(c==0||o.map[h]!=o.map[h-o.width])){const d=o.map[h],f=l+d+s.nodeAt(d).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",(t=re.getState(n))!=null&&t.dragging&&i.push(ee.node(l+d,l+d+s.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),i.push(ee.widget(f,p))}}return R.create(n.doc,i)}function yu({allowTableNodeSelection:n=!1}={}){return new on({key:ze,state:{init(){return null},apply(e,t){const i=e.getMeta(ze);if(i!=null)return i==-1?null:i;if(t==null||!e.docChanged)return t;const{deleted:r,pos:s}=e.mapping.mapResult(t);return r?null:s}},props:{decorations:Jf,handleDOMEvents:{mousedown:su},createSelectionBetween(e){return ze.getState(e.state)!=null?e.state.selection:null},handleTripleClick:iu,handleKeyDown:nu,handlePaste:ru},appendTransaction(e,t,i){return jf(i,Gf(i,t),n)}})}const Zt=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},eo="data-gs-mrk-fs",to="data-gs-ib",jn="data-gs-ifrg",Ae="attrs",aa={[Ae]:{default:"{}"}},Se={[Ae]:{default:{}}},ca=n=>({[Ae]:JSON.stringify(Zt(n))}),ke=n=>({attrs:Zt(n)}),Ft=n=>e=>[n,e.attrs.attrs,0],Ve=n=>n.attrs[Ae]?JSON.parse(n.attrs[Ae]):{},bu={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${jn}]`,getAttrs:ke}],toDOM:()=>["span",{[jn]:""},0]},div:{group:"block",content:"inline*",attrs:Se,parseDOM:[{tag:"div",getAttrs:ke}],toDOM:Ft("div")},paragraph:{group:"block",content:"inline*",attrs:Se,parseDOM:[{tag:"p",getAttrs:ke}],toDOM:Ft("p")},orderedList:{group:"block",content:"listItem+",attrs:Se,parseDOM:[{tag:"ol",getAttrs:ke}],toDOM:Ft("ol")},bulletList:{group:"block",content:"listItem+",attrs:Se,parseDOM:[{tag:"ul",getAttrs:ke}],toDOM:Ft("ul")},listItem:{content:"block*",group:"block",attrs:Se,parseDOM:[{tag:"li",getAttrs:ke}],toDOM:Ft("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:Se,parseDOM:[{tag:"pre",getAttrs:ke}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:Se,parseDOM:[{tag:"img[src]",getAttrs:ke}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${to}]`}],toDOM(){return["br",{[to]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:Se,parseDOM:[{tag:"br",getAttrs:ke}],toDOM:n=>["br",{...n.attrs.attrs}]},heading:{group:"block",content:"inline*",attrs:{level:{default:1},attrs:{default:{}}},defining:!0,parseDOM:Array.from({length:6},(n,e)=>({tag:`h${e+1}`,getAttrs:t=>({level:e+1,attrs:Zt(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...Hf({tableGroup:"block",cellContent:"block+",cellAttributes:{[Ae]:{default:Se[Ae].default,getFromDOM:Zt,setDOMAttr:(n,e)=>{n&&Object.assign(e,n)}},background:{default:null,getFromDOM(n){return n.style.backgroundColor||null},setDOMAttr(n,e){n&&(e.style=(e.style||"")+`background-color: ${n};`)}}}}),nonTextNode:{group:"block",content:"block*",attrs:{tagName:{default:"span"},attrs:{default:{}}},parseDOM:[{tag:"*:not(tbody)",getAttrs:n=>({tagName:n.tagName.toLowerCase(),attrs:Zt(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},$t=(n,e)=>({attrs:aa,parseDOM:n.map(t=>({tag:t,getAttrs:ca})),toDOM:e}),xu={strong:$t(["strong","b"],n=>["b",Ve(n)]),link:$t(["a"],n=>["a",Ve(n),0]),em:$t(["em","i"],n=>["em",Ve(n)]),underline:$t(["u"],n=>["u",Ve(n),0]),strikethrough:$t(["s"],n=>["s",Ve(n),0]),font_size:{attrs:{...aa,size:{default:null}},parseDOM:[{tag:`span[${eo}]`,getAttrs:n=>({...ca(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...Ve(n),[eo]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},no=new Bc({nodes:bu,marks:xu}),ii=new WeakMap,vr=new WeakMap,Cu=(n,e)=>{ii.set(n,e),vr.set(e,n)},wu=(n,e)=>{ii.delete(n),vr.delete(e)},Ni=n=>ii.get(n),Su=n=>vr.get(n),io=n=>{var t;const e=Su(n);return(t=e==null?void 0:e.__gjsv)==null?void 0:t.model},ku=n=>n.dispatchEvent(new CustomEvent("input"));function vu(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(jn)){if(t.getAttribute("style")){t.removeAttribute(jn);return}const i=t.parentElement;if(i){for(;t.firstChild;)i.insertBefore(t.firstChild,t);i.removeChild(t)}}else Array.from(t.children).forEach(i=>e(i))};e(n)}function Mu(n,e={}){if(!e.enableOnClick)return()=>{};const t=n.Components.events,i=h=>n.getSelectedAll().includes(h),r=h=>h.isInstanceOf("text")&&!h.isChildOf("text"),s=h=>h.isChildOf("text"),o=h=>n.getEditing()===h,l=(h,d={})=>{h.trigger("focus",d.event)},a=(h,d)=>{i(h)&&r(h)&&!o(h)&&l(h,d)},c=(h,d)=>{if(i(h)&&!r(h)&&s(h)){const f=h.parents().find(p=>p.isInstanceOf("text"));f&&(l(f,d),setTimeout(()=>n.select(f),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const Tu=(n,e)=>{const t=Ou(n);return t&&zu(t)?Au(n,e):t?ul(()=>({type:n.schema.nodes.div}))(n,e):!1};function Ou(n){const e=n.selection.$from;if(e.node(e.depth).type===n.schema.nodes.inlineFragment){const t=e.depth-1;return e.node(t)}return e.node(e.depth)}function Au(n,e){const{selection:t,schema:i,tr:r}=n;r.split(t.from,1);const s=t.from+1,o=r.doc.nodeAt(s),l={...o.attrs.attrs,id:void 0},a=o.textContent.length>0,c=o.textContent.length||0,h=o.textContent||" ",d=i.text(h),f=i.nodes.div.create(l,a?d:[],[]);return r.replaceRangeWith(s,s+c+2,f),r.setSelection(N.create(r.doc,s+1)),e==null||e(r.scrollIntoView()),!0}function Nu(n,e,t){const{state:i,dispatch:r}=n,{selection:s,tr:o}=i,l=(a,c,h)=>{const d={};return a.split(";").forEach(f=>{const[p,u]=f.split(":").map(m=>m.trim());p&&(d[p]=u)}),d[c]=h,Object.entries(d).map(([f,p])=>`${f}: ${p}`).join("; ")};if(!s.empty||t)o.doc.nodesBetween(s.from,s.to,(a,c)=>{var h,d;if(a.type===i.schema.nodes.image){const f=l(((h=a.attrs.attrs)==null?void 0:h.style)||"","float",e);o.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:f}})}else if(a.type.isBlock){const f=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","text-align",e);ha(a)?o.setBlockType(s.from,void 0,i.schema.nodes.div,{attrs:{style:f}}):o.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:f}})}});else{const a=i.doc.resolve(s.from),c=a.start(a.depth),h=i.doc.nodeAt(c);if(h!=null&&h.type.isBlock){const d=l(h.attrs.style||"","text-align",e);o.setNodeMarkup(c,void 0,{...h.attrs,style:d})}}o.docChanged&&r(o.scrollIntoView())}const Wt=(n,e)=>{const{from:t,to:i}=n.selection;let r=!1;return n.doc.nodesBetween(t,i,s=>{if(r)return!1;s.marks.some(o=>o.type===e)&&(r=!0)}),r};function Eu(n,e,t="_blank"){const{state:i,dispatch:r}=n,{schema:s,selection:o,tr:l}=i,a=s.marks.link;try{const c=a.create({[Ae]:JSON.stringify({href:e,target:t})});l.addMark(o.from,o.to,c),r(l.scrollIntoView())}catch(c){console.error("Error applying link mark:",c)}}function Du(n,e){const{state:t,dispatch:i}=n,{selection:r,tr:s}=t;if(r.empty)return;const o=t.schema.marks.font_size;if(!o){console.error("Font size mark is not defined in the schema.");return}s.addMark(r.from,r.to,o.create({size:e})),i(s.scrollIntoView())}const nt=(n,e)=>{const{doc:t,selection:i}=n.state,r=t.resolve(i.from);for(let s=r.depth;s>0;s--){const o=r.node(s);if(e(o))return{pos:s>0?r.before(s):0,start:r.start(s),depth:s,node:o}}},Iu=n=>(n||"").split(";").map(e=>e.split(":")).reduce((e,[t,i])=>(t=t.replace(/-./g,r=>r.toUpperCase()[1]).trim(),e[t]=`${i}`.trim(),e),{});function Ru(...n){return(e,t)=>{const i=o=>{e=e.apply(o),t==null||t(o)},r=n.pop();return n.reduce((o,l)=>o||l(e,i),!1)&&r!==void 0&&r(e,t)}}const Vu=(n,e)=>{const{state:t,dispatch:i}=n;if(e!=null&&e.event){const{event:r}=e,s=n.posAtCoords({left:r.clientX,top:r.clientY});s!=null&&s.pos&&i(t.tr.setSelection(N.create(t.doc,s.pos)))}else pl(t,i);setTimeout(()=>setTimeout(()=>n.focus()))},ir=n=>n.isBlock,ha=n=>n.type.name==="inlineFragment",Pu=n=>ir(n)&&!ha(n),da=n=>n.type.name==="bulletList",fa=n=>n.type.name==="orderedList",zu=n=>n.type.name==="heading",Bu=n=>da(n)||fa(n),ro=(n,e)=>{var s,o;const t=(s=nt(n,l=>l.type===e))==null?void 0:s.node,i=n.state.schema.nodes.listItem;let r;return t?r=$i(i):(o=nt(n,Bu))!=null&&o.node?r=Ru($i(i),cs(e)):r=cs(e),r(n.state,n.dispatch)},ua=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(i=>i.type.name===e)},Lu=n=>{var o;const{view:e,prop:t,editor:i,propCSS:r}=n,s=(o=nt(e,Pu))==null?void 0:o.node;if(s){const l=s.attrs.attrs||{},a=Iu(l.style);if(t in a)return a[t]||"";if(l.id){const c=i.Components.getById(l.id);return((c==null?void 0:c.getStyle())||{})[r]||""}}return""},Hu=n=>{const{view:e,prop:t,markName:i,editor:r,propCSS:s}=n,o=ua(e,i);if(o){const l=o.attrs;if(l[t])return l[t];if(l[Ae]){const a=Ve(o).id;if(a){const c=r.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[s]||""}}}return""},pa=(n,e)=>{const{dispatch:t}=n,{nodes:i,marks:r}=n.state.schema;return{text:{selected:()=>{const{selection:s,doc:o}=n.state;return o.textBetween(s.from,s.to," ")},replace:(s,o={})=>{const{state:l}=n,{from:a}=l.selection;let c=l.tr.replaceSelectionWith(l.schema.text(s));o.select&&(c=c.setSelection(N.create(c.doc,a,a+s.length))),t==null||t(c)}},bold:{toggle:()=>Xe(r.strong)(n.state,t),isActive:()=>Wt(n.state,r.strong)},italic:{toggle:()=>Xe(r.em)(n.state,t),isActive:()=>Wt(n.state,r.em)},underline:{toggle:()=>Xe(r.underline)(n.state,t),isActive:()=>Wt(n.state,r.underline)},strikethrough:{toggle:()=>Xe(r.strikethrough)(n.state,t),isActive:()=>Wt(n.state,r.strikethrough)},link:{get:()=>{const s=io(n);if(s!=null&&s.is("link"))return s.getAttributes();{const o=ua(n,"link");return o?Ve(o):{}}},toggle:()=>Xe(r.link)(n.state,t),isActive:()=>Wt(n.state,r.link),create:s=>{const o=io(n);o!=null&&o.is("link")?(o.addAttributes({href:s.url,target:s.target}),n.focus()):Eu(n,s.url,s.target)}},alignText:{get:()=>Lu({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:s=>Nu(n,s.value,!0)},fontSize:{get:()=>Hu({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:s=>Du(n,s.value)},image:{open(){const s="assetLayout",{state:o,dispatch:l}=n,{selection:a,doc:c}=o,h=c.textBetween(a.from,a.to," "),d={id:s,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:f=>{const p={alt:h,src:f.asset.getSrc()};l(o.tr.replaceSelectionWith(i.image.createAndFill({attrs:p})))}}};e.runCommand(Xt.layoutToggle,d)}},heading:{get:()=>{var o;const s=(o=nt(n,ir))==null?void 0:o.node;return`${(s==null?void 0:s.attrs.level)||""}`},set:({value:s})=>{var a;const{state:o}=n,l=(a=nt(n,ir))==null?void 0:a.node;Eh(o.schema.nodes.heading,{attrs:l==null?void 0:l.attrs.attrs,level:s?parseInt(s,10):0})(o,t)}},listBullet:{isActive:()=>{var s;return!!((s=nt(n,da))!=null&&s.node)},toggle:()=>ro(n,i.bulletList)},listOrdered:{isActive:()=>{var s;return!!((s=nt(n,fa))!=null&&s.node)},toggle:()=>ro(n,i.orderedList)}}},de="rte:selectionchange",le={bold:'<svg viewBox="0 0 24 24"><path d="M13.5,15.5H10V12.5H13.5A1.5,1.5 0 0,1 15,14A1.5,1.5 0 0,1 13.5,15.5M10,6.5H13A1.5,1.5 0 0,1 14.5,8A1.5,1.5 0 0,1 13,9.5H10M15.6,10.79C16.57,10.11 17.25,9 17.25,8C17.25,5.74 15.5,4 13.25,4H7V18H14.04C16.14,18 17.75,16.3 17.75,14.21C17.75,12.69 16.89,11.39 15.6,10.79Z" /></svg>',italic:'<svg viewBox="0 0 24 24"><path d="M10,4V7H12.21L8.79,15H6V18H14V15H11.79L15.21,7H18V4H10Z" /></svg>',underline:'<svg viewBox="0 0 24 24"><path d="M5,21H19V19H5V21M12,17A6,6 0 0,0 18,11V3H15.5V11A3.5,3.5 0 0,1 12,14.5A3.5,3.5 0 0,1 8.5,11V3H6V11A6,6 0 0,0 12,17Z" /></svg>',strikethrough:'<svg viewBox="0 0 24 24"><path d="M7.2 9.8c-1.2-2.3.5-5 2.9-5.5 3.1-1 7.6.4 7.5 4.2h-3l-.1-.8c-.2-.6-.6-.9-1.2-1.1-.8-.3-2.1-.2-2.8.3C9 8.2 10.4 9.5 12 10H7.4l-.2-.2M21 13v-2H3v2h9.6l.6.2c.6.3 1.1.5 1.3 1.1.1.4.2.9 0 1.3-.2.5-.6.7-1.1.9-1.8.5-4-.2-3.9-2.4h-3c-.1 2.6 2.1 4.4 4.5 4.7 3.8.8 8.3-1.6 6.3-5.9l3.7.1Z"/></svg>',link:'<svg viewBox="0 0 24 24"><path d="M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z" /></svg>',image:'<svg viewBox="0 0 24 24"><path d="M19,19H5V5H19M19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M13.96,12.29L11.21,15.83L9.25,13.47L6.5,17H17.5L13.96,12.29Z"></path></svg>',listBullet:'<svg viewBox="0 0 24 24"><path d="M7 5h14v2H7V5m0 8v-2h14v2H7M4 4.5A1.5 1.5 0 0 1 5.5 6 1.5 1.5 0 0 1 4 7.5 1.5 1.5 0 0 1 2.5 6 1.5 1.5 0 0 1 4 4.5m0 6A1.5 1.5 0 0 1 5.5 12 1.5 1.5 0 0 1 4 13.5 1.5 1.5 0 0 1 2.5 12 1.5 1.5 0 0 1 4 10.5M7 19v-2h14v2H7m-3-2.5A1.5 1.5 0 0 1 5.5 18 1.5 1.5 0 0 1 4 19.5 1.5 1.5 0 0 1 2.5 18 1.5 1.5 0 0 1 4 16.5Z"/></svg>',listOrdered:'<svg viewBox="0 0 24 24"><path d="M7 13v-2h14v2H7m0 6v-2h14v2H7M7 7V5h14v2H7M3 8V5H2V4h2v4H3m-1 9v-1h3v4H2v-1h2v-.5H3v-1h1V17H2m2.3-7a.8.8 0 0 1 .7.8c0 .1 0 .3-.2.5L3 13h2v1H2v-1l2-2H2v-1h2.3Z"/></svg>',alignTextLeft:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H15V9H3V7M3,11H21V13H3V11M3,15H15V17H3V15M3,19H21V21H3V19Z" /></svg>',alignTextCenter:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M7,7H17V9H7V7M3,11H21V13H3V11M7,15H17V17H7V15M3,19H21V21H3V19Z" /></svg>',alignTextRight:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M9,7H21V9H9V7M3,11H21V13H3V11M9,15H21V17H9V15M3,19H21V21H3V19Z" /></svg>',alignTextJustify:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H21V9H3V7M3,11H21V13H3V11M3,15H21V17H3V15M3,19H21V21H3V19Z" /></svg>'},Fu=(n,e)=>{var a;const{editor:t,el:i}=n,r=ii.get(i),s=pa(r,t),o={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},bold:{id:"bold",icon:le.bold,size:"s",type:"button",editorEvents:{[de]:({setState:c})=>{c({active:s.bold.isActive()})}},onClick:({setState:c})=>{s.bold.toggle(),c({active:s.bold.isActive()})}},italic:{id:"italic",icon:le.italic,size:"s",type:"button",editorEvents:{[de]:({setState:c})=>{c({active:s.italic.isActive()})}},onClick:({setState:c})=>{s.italic.toggle(),c({active:s.italic.isActive()})}},underline:{id:"underline",icon:le.underline,size:"s",type:"button",editorEvents:{[de]:({setState:c})=>{c({active:s.underline.isActive()})}},onClick:({setState:c})=>{s.underline.toggle(),c({active:s.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:le.strikethrough,size:"s",type:"button",editorEvents:{[de]:({setState:c})=>{c({active:s.strikethrough.isActive()})}},onClick:({setState:c})=>{s.strikethrough.toggle(),c({active:s.strikethrough.isActive()})}},image:{id:"image",icon:le.image,size:"s",type:"button",onClick:()=>s.image.open()},link:{id:"link",icon:le.link,size:"s",type:"button",editorEvents:{[de]:({setState:c})=>{c({active:s.link.isActive(),disabled:r.state.selection.empty})}},onClick:({event:c})=>{const h=c.currentTarget||c.target,{x:d,y:f,width:p,height:u}=h.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(Xt.layoutRemove,{id:m}),y=s.link.get(),S={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:d,y:f,w:p,h:u},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:b=>{b.preventDefault();const C=new FormData(b.currentTarget);s.link.create({url:C.get("url"),target:C.get("target")}),g()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(y==null?void 0:y.href)||"",onChange:({value:b,setState:C})=>C({value:b})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(y==null?void 0:y.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:b,setState:C})=>C({value:b})},{type:"row",style:{gap:10,justifyContent:"end"},children:[s.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{s.link.toggle(),g()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(Xt.layoutToggle,S)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:le.alignTextLeft},{id:"center",icon:le.alignTextCenter},{id:"right",icon:le.alignTextRight},{id:"justify",icon:le.alignTextJustify}],editorEvents:{[de]:({setState:c})=>{c({value:s.alignText.get()})}},onChange:({value:c,setState:h})=>{h({value:c}),s.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:le.listBullet,size:"s",type:"button",editorEvents:{[de]:({setState:c})=>{c({active:s.listBullet.isActive()})}},onClick:({setState:c})=>{s.listBullet.toggle(),c({active:s.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:le.listOrdered,size:"s",type:"button",editorEvents:{[de]:({setState:c})=>{c({active:s.listOrdered.isActive()})}},onClick:({setState:c})=>{s.listOrdered.toggle(),c({active:s.listOrdered.isActive()})}},heading:{id:"heading",type:"selectField",size:"s",value:"",emptyState:"Heading",options:[{id:"",label:"Normal"},{id:"1",label:"Heading 1"},{id:"2",label:"Heading 2"},{id:"3",label:"Heading 3"},{id:"4",label:"Heading 4"},{id:"5",label:"Heading 5"},{id:"6",label:"Heading 6"}],editorEvents:{[de]:({setState:c})=>{c({value:s.heading.get()})}},onChange:({value:c,setState:h})=>{h({value:c}),s.heading.set({value:c}),r.focus()}},fontSize:{id:"fontSize",type:"selectField",size:"s",value:"",emptyState:"Font size",options:[{id:"8pt",label:"8pt"},{id:"10pt",label:"10pt"},{id:"12pt",label:"12pt"},{id:"14pt",label:"14pt"},{id:"18pt",label:"18pt"},{id:"24pt",label:"24pt"},{id:"36pt",label:"36pt"}],editorEvents:{[de]:({setState:c})=>{c({value:s.fontSize.get()})}},onChange:({value:c,setState:h})=>{h({value:c}),s.fontSize.set({value:c}),r.focus()}}},l=[o.bold,o.italic,o.underline,o.strikethrough,o.image,o.link,o.listBullet,o.listOrdered,o.alignText,o.heading,o.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:s,layouts:o,proseMirror:{view:r},items:l}))||l};class $u{constructor(e,t,i){this.editor=i,this.node=e,this.dom=document.createElement("img"),this.view=t,Object.keys(e.attrs.attrs).forEach(r=>{this.dom.setAttribute(r,e.attrs.attrs[r])}),this.dom.addEventListener("dblclick",r=>this.handleDoubleClick(r))}handleDoubleClick(e){const{editor:t,view:i}=this;pa(i,t).image.open(),e.preventDefault()}update(e){return e.type!==this.node.type?!1:(this.node=e,Object.keys(e.attrs.attrs).forEach(t=>{this.dom.setAttribute(t,e.attrs.attrs[t])}),!0)}selectNode(){this.dom.style.outline="2px solid #ffca6f"}deselectNode(){this.dom.style.outline=""}}class qe{constructor(e,t,i={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Wu(t):t,this.undoable=i.undoable!==!1,this.inCode=i.inCode||!1}}function Wu(n){return function(e,t,i,r){let s=n;if(t[1]){let o=t[0].lastIndexOf(t[1]);s+=t[0].slice(o+t[1].length),i+=o;let l=i-r;l>0&&(s=t[0].slice(o-l,o)+s,i=r)}return e.tr.insertText(s,i,r)}}const Ju=500;function Ku({rules:n}){let e=new on({state:{init(){return null},apply(t,i){let r=t.getMeta(this);return r||(t.selectionSet||t.docChanged?null:i)}},props:{handleTextInput(t,i,r,s){return so(t,i,r,s,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:i}=t.state.selection;i&&so(t,i.pos,i.pos,"",n,e)})}}},isInputRules:!0});return e}function so(n,e,t,i,r,s){if(n.composing)return!1;let o=n.state,l=o.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-Ju),l.parentOffset,null,"")+i;for(let c=0;c<r.length;c++){let h=r[c];if(l.parent.type.spec.code){if(!h.inCode)continue}else if(h.inCode==="only")continue;let d=h.match.exec(a),f=d&&h.handler(o,d,e-(d[0].length-i.length),t);if(f)return h.undoable&&f.setMeta(s,{transform:f,from:e,to:t,text:i}),n.dispatch(f),!0}return!1}const qu=new qe(/--$/,"—"),ju=new qe(/\.\.\.$/,"…"),_u=new qe(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),Gu=new qe(/"$/,"”"),Uu=new qe(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),Zu=new qe(/'$/,"’"),Xu=[_u,Gu,Uu,Zu];function Mr(n,e,t=null,i){return new qe(n,(r,s,o,l)=>{let a=t instanceof Function?t(s):t,c=r.tr.delete(o,l),h=c.doc.resolve(o),d=h.blockRange(),f=d&&Xo(d,e,a);if(!f)return null;c.wrap(d,f);let p=c.doc.resolve(o-1).nodeBefore;return p&&p.type==e&&Xn(c.doc,o-1)&&(!i||i(s,p))&&c.join(o-1),c})}function ma(n,e,t=null){return new qe(n,(i,r,s,o)=>{let l=i.doc.resolve(s),a=t instanceof Function?t(r):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?i.tr.delete(s,o).setBlockType(s,s,e,a):null})}function Yu(n){return Mr(/^\s*>\s$/,n)}function Qu(n){return Mr(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function ep(n){return Mr(/^\s*([-+*])\s$/,n)}function tp(n){return ma(/^```$/,n)}function np(n,e){return ma(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function ip(n){const e=Xu.concat(ju,qu);let t;return(t=n.nodes.blockquote)&&e.push(Yu(t)),(t=n.nodes.orderedList)&&e.push(Qu(t)),(t=n.nodes.bulletList)&&e.push(ep(t)),(t=n.nodes.codeBlock)&&e.push(tp(t)),(t=n.nodes.heading)&&e.push(np(t,6)),Ku({rules:e})}const rp="rteProseMirror",sp=function(n,e={}){const t={plugins:o=>o.plugins,...e},i=(o,l)=>{var u,m;const a=((u=t.schema)==null?void 0:u.call(t,{editor:n,schema:no}))||no,{nodes:c,marks:h}=a,d=Nt.fromSchema(a).parse(o),f=kt.create({doc:d,schema:a,plugins:(m=t.plugins)==null?void 0:m.call(t,{editor:n,plugins:[lu(),yu(),ip(a),Wh(),Si({Tab:js(1),"Shift-Tab":js(-1)}),Si({Enter:en(fl,Zh(c.listItem),Tu),"Shift-Enter":en(dl,(g,y)=>(y&&y(g.tr.replaceSelectionWith(c.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":Cl,"Mod-y":Fi,"Mod-Shift-z":Fi,"Mod-b":Xe(h.strong),"Mod-i":Xe(h.em),"Shift-Tab":$i(c.listItem),Tab:Qh(c.listItem)}),Si(Rh)]})}),p=new If({mount:o},{state:f,dispatchTransaction(g){var k;const{state:y}=p,S=y.apply(g),b=!y.doc.eq(S.doc);p.updateState(S);const C=!y.selection.eq(S.selection);b&&(ku(((k=l==null?void 0:l.view)==null?void 0:k.el)||o),p.focus()),(C||b)&&n.trigger(de)}});return o.__rteView=p,p.setProps({nodeViews:{image(g){return new $u(g,p,n)}}}),p},r=o=>Fu(o,t);n.setCustomRte({toolbar:r,parseContent:!0,async enable(o,l,a){const c=Ni(o);if(c)return c;const h=i(o,a);return Cu(o,h),Vu(h,a),h},disable(o){const l=Ni(o);if(l)return wu(o,l),l.destroy(),{forceSync:!0}},getContent(o){const l=Ni(o);if(l){const{schema:a,doc:c}=l.state,h=document.createElement("div"),d=ft.fromSchema(a).serializeFragment(c.content);return d.childNodes.forEach(f=>{f.nodeType===Node.ELEMENT_NODE&&f.innerHTML===""&&(f.innerHTML="<br/>")}),h.appendChild(d),vu(h),o.classList.remove("ProseMirror-focused"),h.innerHTML}return o.innerHTML}});const s=Mu(n,t);zt({editor:n,licenseKey:t.licenseKey,pluginName:rp,cleanup:()=>{n.RichTextEditor.customRte=void 0,s()}})},op=Pt(sp);exports.dialogComponent=Aa;exports.fsLightboxComponent=hc;exports.lightGalleryComponent=Cc;exports.listPagesComponent=oc;exports.rteProseMirror=op;exports.tableComponent=Qa;
82
+ `);return{dom:a,text:f,slice:e}}function $l(n,e,t,i,r){let s=r.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=e&&(i||s||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,s||i,n)}),s)return e?new w(x.from(n.state.schema.text(e.replace(/\r\n?/g,`
83
+ `))),0,0):w.empty;let d=n.someProp("clipboardTextParser",f=>f(e,r,i,n));if(d)l=d;else{let f=r.marks(),{schema:p}=n.state,u=ut.fromSchema(p);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(u.serializeNode(p.text(m,f)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),o=qd(t),hn&&jd(o);let c=o&&o.querySelector("[data-pm-slice]"),h=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let d=+h[3];d>0;d--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Et.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||h),context:r,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Wd.test(f.parentNode.nodeName)?{ignore:!0}:null}})),h)l=_d(Ds(l,+h[1],+h[2]),h[4]);else if(l=w.maxOpen(Kd(l.content,r),!0),l.openStart||l.openEnd){let d=0,f=0;for(let p=l.content.firstChild;d<l.openStart&&!p.type.spec.isolating;d++,p=p.firstChild);for(let p=l.content.lastChild;f<l.openEnd&&!p.type.spec.isolating;f++,p=p.lastChild);l=Ds(l,d,f)}return n.someProp("transformPasted",d=>{l=d(l,n)}),l}const Wd=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Kd(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let a=r.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&Kl(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Jl(o[o.length-1],s.length));let h=Wl(l,a);o.push(h),r=r.matchType(h.type),s=a}}),o)return x.from(o)}return n}function Wl(n,e,t=0){for(let i=e.length-1;i>=t;i--)n=e[i].create(null,x.from(n));return n}function Kl(n,e,t,i,r){if(r<n.length&&r<e.length&&n[r]==e[r]){let s=Kl(n,e,t,i.lastChild,r+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));if(i.contentMatchAt(i.childCount).matchType(r==n.length-1?t.type:n[r+1]))return i.copy(i.content.append(x.from(Wl(t,n,r+1))))}}function Jl(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Jl(n.lastChild,e-1)),i=n.contentMatchAt(n.childCount).fillBefore(x.empty,!0);return n.copy(t.append(i))}function Xi(n,e,t,i,r,s){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(s=0),r<i-1&&(l=Xi(l,e,t,i,r+1,s)),r>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=r).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(x.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function Ds(n,e,t){return e<n.openStart&&(n=new w(Xi(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new w(Xi(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const ql={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Is=null;function jl(){return Is||(Is=document.implementation.createHTMLDocument("title"))}let Ti=null;function Jd(n){let e=window.trustedTypes;return e?(Ti||(Ti=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Ti.createHTML(n)):n}function qd(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=jl().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(n),r;if((r=i&&ql[i[1].toLowerCase()])&&(n=r.map(s=>"<"+s+">").join("")+n+r.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=Jd(n),r)for(let s=0;s<r.length;s++)t=t.querySelector(r[s])||t;return t}function jd(n){let e=n.querySelectorAll(G?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let i=e[t];i.childNodes.length==1&&i.textContent==" "&&i.parentNode&&i.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),i)}}function _d(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,i;try{i=JSON.parse(e)}catch{return n}let{content:r,openStart:s,openEnd:o}=n;for(let l=i.length-2;l>=0;l-=2){let a=t.nodes[i[l]];if(!a||a.hasRequiredAttrs())break;r=x.from(a.create(i[l+1],r)),s++,o++}return new w(r,s,o)}const X={},Y={},Gd={touchstart:!0,touchmove:!0};class Ud{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Zd(n){for(let e in X){let t=X[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=i=>{Yd(n,i)&&!gr(n,i)&&(n.editable||!(i.type in Y))&&t(n,i)},Gd[e]?{passive:!0}:void 0)}Z&&n.dom.addEventListener("input",()=>null),Yi(n)}function Fe(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Xd(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Yi(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=i=>gr(n,i))})}function gr(n,e){return n.someProp("handleDOMEvents",t=>{let i=t[e.type];return i?i(n,e)||e.defaultPrevented:!1})}function Yd(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Qd(n,e){!gr(n,e)&&X[e.type]&&(n.editable||!(e.type in Y))&&X[e.type](n,e)}Y.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Gl(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(fe&&G&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Pt&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let i=Date.now();n.input.lastIOSEnter=i,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==i&&(n.someProp("handleKeyDown",r=>r(n,Qe(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",i=>i(n,t))||$d(n,t)?t.preventDefault():Fe(n,"key")};Y.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Y.keypress=(n,e)=>{let t=e;if(Gl(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ae&&t.metaKey)return;if(n.someProp("handleKeyPress",r=>r(n,t))){t.preventDefault();return}let i=n.state.selection;if(!(i instanceof N)||!i.$from.sameParent(i.$to)){let r=String.fromCharCode(t.charCode);!/[\r\n]/.test(r)&&!n.someProp("handleTextInput",s=>s(n,i.$from.pos,i.$to.pos,r))&&n.dispatch(n.state.tr.insertText(r).scrollIntoView()),t.preventDefault()}};function ni(n){return{left:n.clientX,top:n.clientY}}function ef(n,e){let t=e.x-n.clientX,i=e.y-n.clientY;return t*t+i*i<100}function yr(n,e,t,i,r){if(i==-1)return!1;let s=n.state.doc.resolve(i);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,l=>o>s.depth?l(n,t,s.nodeAfter,s.before(o),r,!0):l(n,t,s.node(o),s.before(o),r,!1)))return!0;return!1}function At(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let i=n.state.tr.setSelection(e);i.setMeta("pointer",!0),n.dispatch(i)}function tf(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),i=t.nodeAfter;return i&&i.isAtom&&T.isSelectable(i)?(At(n,new T(t)),!0):!1}function nf(n,e){if(e==-1)return!1;let t=n.state.selection,i,r;t instanceof T&&(i=t.node);let s=n.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(T.isSelectable(l)){i&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?r=s.before(t.$from.depth):r=s.before(o);break}}return r!=null?(At(n,T.create(n.state.doc,r)),!0):!1}function rf(n,e,t,i,r){return yr(n,"handleClickOn",e,t,i)||n.someProp("handleClick",s=>s(n,e,i))||(r?nf(n,t):tf(n,t))}function sf(n,e,t,i){return yr(n,"handleDoubleClickOn",e,t,i)||n.someProp("handleDoubleClick",r=>r(n,e,i))}function of(n,e,t,i){return yr(n,"handleTripleClickOn",e,t,i)||n.someProp("handleTripleClick",r=>r(n,e,i))||lf(n,t,i)}function lf(n,e,t){if(t.button!=0)return!1;let i=n.state.doc;if(e==-1)return i.inlineContent?(At(n,N.create(i,0,i.content.size)),!0):!1;let r=i.resolve(e);for(let s=r.depth+1;s>0;s--){let o=s>r.depth?r.nodeAfter:r.node(s),l=r.before(s);if(o.inlineContent)At(n,N.create(i,l+1,l+1+o.content.size));else if(T.isSelectable(o))At(n,T.create(i,l));else continue;return!0}}function br(n){return Jn(n)}const _l=ae?"metaKey":"ctrlKey";X.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let i=br(n),r=Date.now(),s="singleClick";r-n.input.lastClick.time<500&&ef(t,n.input.lastClick)&&!t[_l]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:r,x:t.clientX,y:t.clientY,type:s};let o=n.posAtCoords(ni(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new af(n,o,t,!!i)):(s=="doubleClick"?sf:of)(n,o.pos,o.inside,t)?t.preventDefault():Fe(n,"pointer"))};class af{constructor(e,t,i,r){this.view=e,this.pos=t,this.event=i,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!i[_l],this.allowDefault=i.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let h=e.state.doc.resolve(t.pos);s=h.parent,o=h.depth?h.before():0}const l=r?null:i.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(i.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof T&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&me&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Fe(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Ae(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(ni(e))),this.updateAllowDefault(e),this.allowDefault||!t?Fe(this.view,"pointer"):rf(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Z&&this.mightDrag&&!this.mightDrag.node.isAtom||G&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(At(this.view,A.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Fe(this.view,"pointer")}move(e){this.updateAllowDefault(e),Fe(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}X.touchstart=n=>{n.input.lastTouch=Date.now(),br(n),Fe(n,"pointer")};X.touchmove=n=>{n.input.lastTouch=Date.now(),Fe(n,"pointer")};X.contextmenu=n=>br(n);function Gl(n,e){return n.composing?!0:Z&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const cf=fe?5e3:-1;Y.compositionstart=Y.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof N&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(i=>i.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Jn(n,!0),n.markCursor=null;else if(Jn(n,!e.selection.empty),me&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let i=n.domSelectionRange();for(let r=i.focusNode,s=i.focusOffset;r&&r.nodeType==1&&s!=0;){let o=s<0?r.lastChild:r.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else r=o,s=-1}}n.input.composing=!0}Ul(n,cf)};Y.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Ul(n,20))};function Ul(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Jn(n),e))}function Zl(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=df());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function hf(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=td(e.focusNode,e.focusOffset),i=nd(e.focusNode,e.focusOffset);if(t&&i&&t!=i){let r=i.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||i==s)return s;if(!r||!r.isText(i.nodeValue))return i;if(n.input.compositionNode==i){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return i}}return t||i}function df(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Jn(n,e=!1){if(!(fe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Zl(n),e||n.docView&&n.docView.dirty){let t=pr(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function ff(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let i=getSelection(),r=document.createRange();r.selectNodeContents(e),n.dom.blur(),i.removeAllRanges(),i.addRange(r),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const rn=te&&$e<15||Pt&&ld<604;X.copy=Y.cut=(n,e)=>{let t=e,i=n.state.selection,r=t.type=="cut";if(i.empty)return;let s=rn?null:t.clipboardData,o=i.content(),{dom:l,text:a}=Fl(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):ff(n,l),r&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function uf(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function pf(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,i=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();let r=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),i.parentNode&&i.parentNode.removeChild(i),t?sn(n,i.value,null,r,e):sn(n,i.textContent,i.innerHTML,r,e)},50)}function sn(n,e,t,i,r){let s=$l(n,e,t,i,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,r,s||w.empty)))return!0;if(!s)return!1;let o=uf(s),l=o?n.state.tr.replaceSelectionWith(o,i):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Xl(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Y.paste=(n,e)=>{let t=e;if(n.composing&&!fe)return;let i=rn?null:t.clipboardData,r=n.input.shiftKey&&n.input.lastKeyCode!=45;i&&sn(n,Xl(i),i.getData("text/html"),r,t)?t.preventDefault():pf(n,t)};class Yl{constructor(e,t,i){this.slice=e,this.move=t,this.node=i}}const Ql=ae?"altKey":"ctrlKey";X.dragstart=(n,e)=>{let t=e,i=n.input.mouseDown;if(i&&i.done(),!t.dataTransfer)return;let r=n.state.selection,s=r.empty?null:n.posAtCoords(ni(t)),o;if(!(s&&s.pos>=r.from&&s.pos<=(r instanceof T?r.to-1:r.to))){if(i&&i.mightDrag)o=T.create(n.state.doc,i.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(o=T.create(n.state.doc,d.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:h}=Fl(n,l);(!t.dataTransfer.files.length||!G||vl>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(rn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",rn||t.dataTransfer.setData("text/plain",c),n.dragging=new Yl(h,!t[Ql],o)};X.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Y.dragover=Y.dragenter=(n,e)=>e.preventDefault();Y.drop=(n,e)=>{let t=e,i=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let r=n.posAtCoords(ni(t));if(!r)return;let s=n.state.doc.resolve(r.pos),o=i&&i.slice;o?n.someProp("transformPasted",u=>{o=u(o,n)}):o=$l(n,Xl(t.dataTransfer),rn?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(i&&!t[Ql]);if(n.someProp("handleDrop",u=>u(n,t,o||w.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?lh(n.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:u}=i;u?u.replace(c):c.deleteSelection()}let h=c.mapping.map(a),d=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(h,h,o.content.firstChild):c.replaceRange(h,h,o),c.doc.eq(f))return;let p=c.doc.resolve(h);if(d&&T.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new T(p));else{let u=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,S)=>u=S),c.setSelection(mr(n,p,c.doc.resolve(u)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};X.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Ae(n)},20))};X.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};X.beforeinput=(n,e)=>{if(G&&fe&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:i}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=i||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Qe(8,"Backspace")))))return;let{$cursor:r}=n.state.selection;r&&r.pos>0&&n.dispatch(n.state.tr.delete(r.pos-1,r.pos).scrollIntoView())},50)}};for(let n in Y)X[n]=Y[n];function on(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class qn{constructor(e,t){this.toDOM=e,this.spec=t||at,this.side=this.spec.side||0}map(e,t,i,r){let{pos:s,deleted:o}=e.mapResult(t.from+r,this.side<0?-1:1);return o?null:new ee(s-i,s-i,this)}valid(){return!0}eq(e){return this==e||e instanceof qn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&on(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ke{constructor(e,t){this.attrs=e,this.spec=t||at}map(e,t,i,r){let s=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-i,o=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-i;return s>=o?null:new ee(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ke&&on(this.attrs,e.attrs)&&on(this.spec,e.spec)}static is(e){return e.type instanceof Ke}destroy(){}}class xr{constructor(e,t){this.attrs=e,this.spec=t||at}map(e,t,i,r){let s=e.mapResult(t.from+r,1);if(s.deleted)return null;let o=e.mapResult(t.to+r,-1);return o.deleted||o.pos<=s.pos?null:new ee(s.pos-i,o.pos-i,this)}valid(e,t){let{index:i,offset:r}=e.content.findIndex(t.from),s;return r==t.from&&!(s=e.child(i)).isText&&r+s.nodeSize==t.to}eq(e){return this==e||e instanceof xr&&on(this.attrs,e.attrs)&&on(this.spec,e.spec)}destroy(){}}class ee{constructor(e,t,i){this.from=e,this.to=t,this.type=i}copy(e,t){return new ee(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,i){return this.type.map(e,this,t,i)}static widget(e,t,i){return new ee(e,e,new qn(t,i))}static inline(e,t,i,r){return new ee(e,t,new Ke(i,r))}static node(e,t,i,r){return new ee(e,t,new xr(i,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ke}get widget(){return this.type instanceof qn}}const St=[],at={};class R{constructor(e,t){this.local=e.length?e:St,this.children=t.length?t:St}static create(e,t){return t.length?jn(t,e,0,at):j}find(e,t,i){let r=[];return this.findInner(e??0,t??1e9,r,0,i),r}findInner(e,t,i,r,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&i.push(l.copy(l.from+r,l.to+r))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,i,r+l,s)}}map(e,t,i){return this==j||e.maps.length==0?this:this.mapInner(e,t,0,0,i||at)}mapInner(e,t,i,r,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,i,r);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?mf(this.children,o||[],e,t,i,r,s):o?new R(o.sort(ct),St):j}add(e,t){return t.length?this==j?R.create(e,t):this.addInner(e,t,0):this}addInner(e,t,i){let r,s=0;e.forEach((l,a)=>{let c=a+i,h;if(h=ta(t,l,c)){for(r||(r=this.children.slice());s<r.length&&r[s]<a;)s+=3;r[s]==a?r[s+2]=r[s+2].addInner(l,h,c+1):r.splice(s,0,a,a+l.nodeSize,jn(h,l,c+1,at)),s+=3}});let o=ea(s?na(t):t,-i);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new R(o.length?this.local.concat(o).sort(ct):this.local,r||this.children)}remove(e){return e.length==0||this==j?this:this.removeInner(e,0)}removeInner(e,t){let i=this.children,r=this.local;for(let s=0;s<i.length;s+=3){let o,l=i[s]+t,a=i[s+1]+t;for(let h=0,d;h<e.length;h++)(d=e[h])&&d.from>l&&d.to<a&&(e[h]=null,(o||(o=[])).push(d));if(!o)continue;i==this.children&&(i=this.children.slice());let c=i[s+2].removeInner(o,l+1);c!=j?i[s+2]=c:(i.splice(s,3),s-=3)}if(r.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<r.length;l++)r[l].eq(o,t)&&(r==this.local&&(r=this.local.slice()),r.splice(l--,1))}return i==this.children&&r==this.local?this:r.length||i.length?new R(r,i):j}forChild(e,t){if(this==j)return this;if(t.isLeaf)return R.empty;let i,r;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(i=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof Ke){let c=Math.max(s,a.from)-s,h=Math.min(o,a.to)-s;c<h&&(r||(r=[])).push(a.copy(c,h))}}if(r){let l=new R(r.sort(ct),St);return i?new ze([l,i]):l}return i||j}eq(e){if(this==e)return!0;if(!(e instanceof R)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Cr(this.localsInner(e))}localsInner(e){if(this==j)return St;if(e.inlineContent||!this.local.some(Ke.is))return this.local;let t=[];for(let i=0;i<this.local.length;i++)this.local[i].type instanceof Ke||t.push(this.local[i]);return t}forEachSet(e){e(this)}}R.empty=new R([],[]);R.removeOverlap=Cr;const j=R.empty;class ze{constructor(e){this.members=e}map(e,t){const i=this.members.map(r=>r.map(e,t,at));return ze.from(i)}forChild(e,t){if(t.isLeaf)return R.empty;let i=[];for(let r=0;r<this.members.length;r++){let s=this.members[r].forChild(e,t);s!=j&&(s instanceof ze?i=i.concat(s.members):i.push(s))}return ze.from(i)}eq(e){if(!(e instanceof ze)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,i=!0;for(let r=0;r<this.members.length;r++){let s=this.members[r].localsInner(e);if(s.length)if(!t)t=s;else{i&&(t=t.slice(),i=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?Cr(i?t:t.sort(ct)):St}static from(e){switch(e.length){case 0:return j;case 1:return e[0];default:return new ze(e.every(t=>t instanceof R)?e:e.reduce((t,i)=>t.concat(i instanceof R?i:i.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function mf(n,e,t,i,r,s,o){let l=n.slice();for(let c=0,h=s;c<t.maps.length;c++){let d=0;t.maps[c].forEach((f,p,u,m)=>{let g=m-u-(p-f);for(let y=0;y<l.length;y+=3){let S=l[y+1];if(S<0||f>S+h-d)continue;let b=l[y]+h-d;p>=b?l[y+1]=f<=b?-2:-1:f>=h&&g&&(l[y]+=g,l[y+1]+=g)}d+=g}),h=t.maps[c].map(h,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let h=t.map(n[c]+s),d=h-r;if(d<0||d>=i.content.size){a=!0;continue}let f=t.map(n[c+1]+s,-1),p=f-r,{index:u,offset:m}=i.content.findIndex(d),g=i.maybeChild(u);if(g&&m==d&&m+g.nodeSize==p){let y=l[c+2].mapInner(t,g,h+1,n[c]+s+1,o);y!=j?(l[c]=d,l[c+1]=p,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=gf(l,n,e,t,r,s,o),h=jn(c,i,0,o);e=h.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<h.children.length;d+=3){let p=h.children[d];for(;f<l.length&&l[f]<p;)f+=3;l.splice(f,0,h.children[d],h.children[d+1],h.children[d+2])}}return new R(e.sort(ct),l)}function ea(n,e){if(!e||!n.length)return n;let t=[];for(let i=0;i<n.length;i++){let r=n[i];t.push(new ee(r.from+e,r.to+e,r.type))}return t}function gf(n,e,t,i,r,s,o){function l(a,c){for(let h=0;h<a.local.length;h++){let d=a.local[h].map(i,r,c);d?t.push(d):o.onRemove&&o.onRemove(a.local[h].spec)}for(let h=0;h<a.children.length;h+=3)l(a.children[h+2],a.children[h]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function ta(n,e,t){if(e.isLeaf)return null;let i=t+e.nodeSize,r=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<i&&((r||(r=[])).push(o),n[s]=null);return r}function na(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function jn(n,e,t,i){let r=[],s=!1;e.forEach((l,a)=>{let c=ta(n,l,a+t);if(c){s=!0;let h=jn(c,l,t+a+1,i);h!=j&&r.push(a,a+l.nodeSize,h)}});let o=ea(s?na(n):n,-t).sort(ct);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(i.onRemove&&i.onRemove(o[l].spec),o.splice(l--,1));return o.length||r.length?new R(o,r):j}function ct(n,e){return n.from-e.from||n.to-e.to}function Cr(n){let e=n;for(let t=0;t<e.length-1;t++){let i=e[t];if(i.from!=i.to)for(let r=t+1;r<e.length;r++){let s=e[r];if(s.from==i.from){s.to!=i.to&&(e==n&&(e=n.slice()),e[r]=s.copy(s.from,i.to),Rs(e,r+1,s.copy(i.to,s.to)));continue}else{s.from<i.to&&(e==n&&(e=n.slice()),e[t]=i.copy(i.from,s.from),Rs(e,r,i.copy(s.from,i.to)));break}}}return e}function Rs(n,e,t){for(;e<n.length&&ct(t,n[e])>0;)e++;n.splice(e,0,t)}function Oi(n){let e=[];return n.someProp("decorations",t=>{let i=t(n.state);i&&i!=j&&e.push(i)}),n.cursorWrapper&&e.push(R.create(n.state.doc,[n.cursorWrapper.deco])),ze.from(e)}const yf={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},bf=te&&$e<=11;class xf{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Cf{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new xf,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(i=>{for(let r=0;r<i.length;r++)this.queue.push(i[r]);te&&$e<=11&&i.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),bf&&(this.onCharData=i=>{this.queue.push({target:i.target,type:"characterData",oldValue:i.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,yf)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Ms(this.view)){if(this.suppressingSelectionUpdates)return Ae(this.view);if(te&&$e<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&dt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,i;for(let s=e.focusNode;s;s=nn(s))t.add(s);for(let s=e.anchorNode;s;s=nn(s))if(t.has(s)){i=s;break}let r=i&&this.view.docView.nearestDesc(i);if(r&&r.ignoreMutation({type:"selection",target:i.nodeType==3?i.parentNode:i}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let i=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&Ms(e)&&!this.ignoreSelectionChange(i),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let h=0;h<t.length;h++){let d=this.registerMutation(t[h],a);d&&(s=s<0?d.from:Math.min(d.from,s),o=o<0?d.to:Math.max(d.to,o),d.typeOver&&(l=!0))}if(me&&a.length){let h=a.filter(d=>d.nodeName=="BR");if(h.length==2){let[d,f]=h;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of h){let p=f.parentNode;p&&p.nodeName=="LI"&&(!d||kf(e,d)!=p)&&f.remove()}}}let c=null;s<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&ei(i)&&(c=pr(e))&&c.eq(A.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ae(e),this.currentSelection.set(i),e.scrollToSelection()):(s>-1||r)&&(s>-1&&(e.docView.markDirty(s,o),wf(e)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(i)||Ae(e),this.currentSelection.set(i))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let i=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(i==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!i||i.ignoreMutation(e))return null;if(e.type=="childList"){for(let h=0;h<e.addedNodes.length;h++){let d=e.addedNodes[h];t.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(i.contentDOM&&i.contentDOM!=i.dom&&!i.contentDOM.contains(e.target))return{from:i.posBefore,to:i.posAfter};let r=e.previousSibling,s=e.nextSibling;if(te&&$e<=11&&e.addedNodes.length)for(let h=0;h<e.addedNodes.length;h++){let{previousSibling:d,nextSibling:f}=e.addedNodes[h];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(r=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(s=f)}let o=r&&r.parentNode==e.target?K(r)+1:0,l=i.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?K(s):e.target.childNodes.length,c=i.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:i.posAtStart-i.border,to:i.posAtEnd+i.border}:(this.lastChangedTextNode=e.target,{from:i.posAtStart,to:i.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Ps=new WeakMap,Vs=!1;function wf(n){if(!Ps.has(n)&&(Ps.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=me,Vs)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Vs=!0}}function zs(n,e){let t=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return dt(o.node,o.offset,r,s)&&([t,i,r,s]=[r,s,t,i]),{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}}function Sf(n,e){if(e.getComposedRanges){let r=e.getComposedRanges(n.root)[0];if(r)return zs(n,r)}let t;function i(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",i,!0),t?zs(n,t):null}function kf(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let i=n.docView.nearestDesc(t,!0);if(i&&i.node.isBlock)return t}return null}function vf(n,e,t){let{node:i,fromOffset:r,toOffset:s,from:o,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,h=a.anchorNode;if(h&&n.dom.contains(h.nodeType==1?h:h.parentNode)&&(c=[{node:h,offset:a.anchorOffset}],ei(a)||c.push({node:a.focusNode,offset:a.focusOffset})),G&&n.input.lastKeyCode===8)for(let g=s;g>r;g--){let y=i.childNodes[g-1],S=y.pmViewDesc;if(y.nodeName=="BR"&&!S){s=g;break}if(!S||S.size)break}let d=n.state.doc,f=n.someProp("domParser")||Et.fromSchema(n.state.schema),p=d.resolve(o),u=null,m=f.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:r,to:s,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Mf,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),u={anchor:g+o,head:y+o}}return{doc:m,sel:u,from:o,to:l}}function Mf(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Z&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Z&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Tf=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Of(n,e,t,i,r){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let O=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,Q=pr(n,O);if(Q&&!n.state.selection.eq(Q)){if(G&&fe&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",q=>q(n,Qe(13,"Enter"))))return;let V=n.state.tr.setSelection(Q);O=="pointer"?V.setMeta("pointer",!0):O=="key"&&V.scrollIntoView(),s&&V.setMeta("composition",s),n.dispatch(V)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=vf(n,e,t),h=n.state.doc,d=h.slice(c.from,c.to),f,p;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,p="end"):(f=n.state.selection.from,p="start"),n.input.lastKeyCode=null;let u=Ef(d.content,c.doc.content,c.from,f,p);if(u&&n.input.domChangeCount++,(Pt&&n.input.lastIOSEnter>Date.now()-225||fe)&&r.some(O=>O.nodeType==1&&!Tf.test(O.nodeName))&&(!u||u.endA>=u.endB)&&n.someProp("handleKeyDown",O=>O(n,Qe(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!u)if(i&&a instanceof N&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))u={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let O=Bs(n,n.state.doc,c.sel);if(O&&!O.eq(n.state.selection)){let Q=n.state.tr.setSelection(O);s&&Q.setMeta("composition",s),n.dispatch(Q)}}return}n.state.selection.from<n.state.selection.to&&u.start==u.endB&&n.state.selection instanceof N&&(u.start>n.state.selection.from&&u.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?u.start=n.state.selection.from:u.endA<n.state.selection.to&&u.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(u.endB+=n.state.selection.to-u.endA,u.endA=n.state.selection.to)),te&&$e<=11&&u.endB==u.start+1&&u.endA==u.start&&u.start>c.from&&c.doc.textBetween(u.start-c.from-1,u.start-c.from+1)=="  "&&(u.start--,u.endA--,u.endB--);let m=c.doc.resolveNoCache(u.start-c.from),g=c.doc.resolveNoCache(u.endB-c.from),y=h.resolve(u.start),S=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=u.endA,b;if((Pt&&n.input.lastIOSEnter>Date.now()-225&&(!S||r.some(O=>O.nodeName=="DIV"||O.nodeName=="P"))||!S&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(b=A.findFrom(c.doc.resolve(m.pos+1),1,!0))&&b.head==g.pos)&&n.someProp("handleKeyDown",O=>O(n,Qe(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>u.start&&Nf(h,u.start,u.endA,m,g)&&n.someProp("handleKeyDown",O=>O(n,Qe(8,"Backspace")))){fe&&G&&n.domObserver.suppressSelectionUpdates();return}G&&fe&&u.endB==u.start&&(n.input.lastAndroidDelete=Date.now()),fe&&!S&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==u.endA&&(u.endB-=2,g=c.doc.resolveNoCache(u.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(O){return O(n,Qe(13,"Enter"))})},20));let C=u.start,k=u.endA,M,E,L;if(S){if(m.pos==g.pos)te&&$e<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ae(n),20)),M=n.state.tr.delete(C,k),E=h.resolve(u.start).marksAcross(h.resolve(u.endA));else if(u.endA==u.endB&&(L=Af(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,u.endA-y.start()))))M=n.state.tr,L.type=="add"?M.addMark(C,k,L.mark):M.removeMark(C,k,L.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let O=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",Q=>Q(n,C,k,O)))return;M=n.state.tr.insertText(O,C,k)}}if(M||(M=n.state.tr.replace(C,k,c.doc.slice(u.start-c.from,u.endB-c.from))),c.sel){let O=Bs(n,M.doc,c.sel);O&&!(G&&fe&&n.composing&&O.empty&&(u.start!=u.endB||n.input.lastAndroidDelete<Date.now()-100)&&(O.head==C||O.head==M.mapping.map(k)-1)||te&&O.empty&&O.head==C)&&M.setSelection(O)}E&&M.ensureMarks(E),s&&M.setMeta("composition",s),n.dispatch(M.scrollIntoView())}function Bs(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:mr(n,e.resolve(t.anchor),e.resolve(t.head))}function Af(n,e){let t=n.firstChild.marks,i=e.firstChild.marks,r=t,s=i,o,l,a;for(let h=0;h<i.length;h++)r=i[h].removeFromSet(r);for(let h=0;h<t.length;h++)s=t[h].removeFromSet(s);if(r.length==1&&s.length==0)l=r[0],o="add",a=h=>h.mark(l.addToSet(h.marks));else if(r.length==0&&s.length==1)l=s[0],o="remove",a=h=>h.mark(l.removeFromSet(h.marks));else return null;let c=[];for(let h=0;h<e.childCount;h++)c.push(a(e.child(h)));if(x.from(c).eq(n))return{mark:l,type:o}}function Nf(n,e,t,i,r){if(t-e<=r.pos-i.pos||Ai(i,!0,!1)<r.pos)return!1;let s=n.resolve(e);if(!i.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=n.resolve(Ai(s,!0,!0));return!o.parent.isTextblock||o.pos>t||Ai(o,!0,!1)<t?!1:i.parent.content.cut(i.parentOffset).eq(o.parent.content)}function Ai(n,e,t){let i=n.depth,r=e?n.end():n.pos;for(;i>0&&(e||n.indexAfter(i)==n.node(i).childCount);)i--,r++,e=!1;if(t){let s=n.node(i).maybeChild(n.indexAfter(i));for(;s&&!s.isLeaf;)s=s.firstChild,r++}return r}function Ef(n,e,t,i,r){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:o,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(r=="end"){let a=Math.max(0,s-Math.min(o,l));i-=o+a-s}if(o<s&&n.size<e.size){let a=i<=s&&i>=o?s-i:0;s-=a,s&&s<e.size&&Ls(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-o),o=s}else if(l<s){let a=i<=s&&i>=l?s-i:0;s-=a,s&&s<n.size&&Ls(n.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function Ls(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Df{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Ud,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Ks),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=$s(this),Fs(this),this.nodeViews=Ws(this),this.docView=xs(this.state.doc,Hs(this),Oi(this),this.dom,this),this.domObserver=new Cf(this,(i,r,s,o)=>Of(this,i,r,s,o)),this.domObserver.start(),Zd(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Yi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Ks),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let i in this._props)t[i]=this._props[i];t.state=this.state;for(let i in e)t[i]=e[i];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var i;let r=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(Zl(this),o=!0),this.state=e;let l=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=Ws(this);Rf(p,this.nodeViews)&&(this.nodeViews=p,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Yi(this),this.editable=$s(this),Fs(this);let a=Oi(this),c=Hs(this),h=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",d=s||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(r.selection))&&(o=!0);let f=h=="preserve"&&o&&this.dom.style.overflowAnchor==null&&hd(this);if(o){this.domObserver.stop();let p=d&&(te||G)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&If(r.selection,e.selection);if(d){let u=G?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=hf(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=xs(e.doc,c,a,this.dom,this)),u&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Pd(this))?Ae(this,p):(Bl(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),!((i=this.dragging)===null||i===void 0)&&i.node&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),h=="reset"?this.dom.scrollTop=0:h=="to selection"?this.scrollToSelection():f&&dd(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof T){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&us(this,t.getBoundingClientRect(),e)}else us(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let i=this.directPlugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let i=this.state.plugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let i=this.pluginViews[t];i.update&&i.update(this,e)}}updateDraggedNode(e,t){let i=e.node,r=-1;if(this.state.doc.nodeAt(i.from)==i.node)r=i.from;else{let s=i.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==i.node&&(r=s)}this.dragging=new Yl(e.slice,e.move,r<0?void 0:T.create(this.state.doc,r))}someProp(e,t){let i=this._props&&this._props[e],r;if(i!=null&&(r=t?t(i):i))return r;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(r=t?t(l):l))return r}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(r=t?t(l):l))return r}}hasFocus(){if(te){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&fd(this.dom),Ae(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return yd(this,e)}coordsAtPos(e,t=1){return Nl(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,i=-1){let r=this.docView.posFromDOM(e,t,i);if(r==null)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return Sd(this,t||this.state,e)}pasteHTML(e,t){return sn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return sn(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Xd(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Oi(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Qh())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Qd(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?Z&&this.root.nodeType===11&&rd(this.dom.ownerDocument)==this.dom&&Sf(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Hs(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let i in t)i=="class"?e.class+=" "+t[i]:i=="style"?e.style=(e.style?e.style+";":"")+t[i]:!e[i]&&i!="contenteditable"&&i!="nodeName"&&(e[i]=String(t[i]))}),e.translate||(e.translate="no"),[ee.node(0,n.state.doc.content.size,e)]}function Fs(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:ee.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function $s(n){return!n.someProp("editable",e=>e(n.state)===!1)}function If(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Ws(n){let e=Object.create(null);function t(i){for(let r in i)Object.prototype.hasOwnProperty.call(e,r)||(e[r]=i[r])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Rf(n,e){let t=0,i=0;for(let r in n){if(n[r]!=e[r])return!0;t++}for(let r in e)i++;return t!=i}function Ks(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Qi,er;if(typeof WeakMap<"u"){let n=new WeakMap;Qi=e=>n.get(e),er=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Qi=i=>{for(let r=0;r<n.length;r+=2)if(n[r]==i)return n[r+1]},er=(i,r)=>(t==10&&(t=0),n[t++]=i,n[t++]=r)}var z=class{constructor(n,e,t,i){this.width=n,this.height=e,this.map=t,this.problems=i}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const i=e%this.width,r=e/this.width|0;let s=i+1,o=r+1;for(let l=1;s<this.width&&this.map[e+l]==t;l++)s++;for(let l=1;o<this.height&&this.map[e+this.width*l]==t;l++)o++;return{left:i,top:r,right:s,bottom:o}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:i,right:r,top:s,bottom:o}=this.findCell(n);return e=="horiz"?(t<0?i==0:r==this.width)?null:this.map[s*this.width+(t<0?i-1:r)]:(t<0?s==0:o==this.height)?null:this.map[i+this.width*(t<0?s-1:o)]}rectBetween(n,e){const{left:t,right:i,top:r,bottom:s}=this.findCell(n),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,o),top:Math.min(r,a),right:Math.max(i,l),bottom:Math.max(s,c)}}cellsInRect(n){const e=[],t={};for(let i=n.top;i<n.bottom;i++)for(let r=n.left;r<n.right;r++){const s=i*this.width+r,o=this.map[s];t[o]||(t[o]=!0,!(r==n.left&&r&&this.map[s-1]==o||i==n.top&&i&&this.map[s-this.width]==o)&&e.push(o))}return e}positionAt(n,e,t){for(let i=0,r=0;;i++){const s=r+t.child(i).nodeSize;if(i==n){let o=e+n*this.width;const l=(n+1)*this.width;for(;o<l&&this.map[o]<r;)o++;return o==l?s-1:this.map[o]}r=s}}static get(n){return Qi(n)||er(n,Pf(n))}};function Pf(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=Vf(n),t=n.childCount,i=[];let r=0,s=null;const o=[];for(let c=0,h=e*t;c<h;c++)i[c]=0;for(let c=0,h=0;c<t;c++){const d=n.child(c);h++;for(let u=0;;u++){for(;r<i.length&&i[r]!=0;)r++;if(u==d.childCount)break;const m=d.child(u),{colspan:g,rowspan:y,colwidth:S}=m.attrs;for(let b=0;b<y;b++){if(b+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:h,n:y-b});break}const C=r+b*e;for(let k=0;k<g;k++){i[C+k]==0?i[C+k]=h:(s||(s=[])).push({type:"collision",row:c,pos:h,n:g-k});const M=S&&S[k];if(M){const E=(C+k)%e*2,L=o[E];L==null||L!=M&&o[E+1]==1?(o[E]=M,o[E+1]=1):L==M&&o[E+1]++}}}r+=g,h+=m.nodeSize}const f=(c+1)*e;let p=0;for(;r<f;)i[r++]==0&&p++;p&&(s||(s=[])).push({type:"missing",row:c,n:p}),h++}const l=new z(e,t,i,s);let a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(a=!0);return a&&zf(l,o,n),l}function Vf(n){let e=-1,t=!1;for(let i=0;i<n.childCount;i++){const r=n.child(i);let s=0;if(t)for(let o=0;o<i;o++){const l=n.child(o);for(let a=0;a<l.childCount;a++){const c=l.child(a);o+c.attrs.rowspan>i&&(s+=c.attrs.colspan)}}for(let o=0;o<r.childCount;o++){const l=r.child(o);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function zf(n,e,t){n.problems||(n.problems=[]);const i={};for(let r=0;r<n.map.length;r++){const s=n.map[r];if(i[s])continue;i[s]=!0;const o=t.nodeAt(s);if(!o)throw new RangeError(`No cell with offset ${s} found`);let l=null;const a=o.attrs;for(let c=0;c<a.colspan;c++){const h=(r+c)%n.width,d=e[h*2];d!=null&&(!a.colwidth||a.colwidth[c]!=d)&&((l||(l=Bf(a)))[c]=d)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function Bf(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Js(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),i=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(o=>Number(o)):null,r=Number(n.getAttribute("colspan")||1),s={colspan:r,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:i&&i.length==r?i:null};for(const o in e){const l=e[o].getFromDOM,a=l&&l(n);a!=null&&(s[o]=a)}return s}function qs(n,e){const t={};n.attrs.colspan!=1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!=1&&(t.rowspan=n.attrs.rowspan),n.attrs.colwidth&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(const i in e){const r=e[i].setDOMAttr;r&&r(n.attrs[i],t)}return t}function Lf(n){const e=n.cellAttributes||{},t={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const i in e)t[i]={default:e[i].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:n.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:i=>Js(i,e)}],toDOM(i){return["td",qs(i,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:i=>Js(i,e)}],toDOM(i){return["th",qs(i,e),0]}}}}function we(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const i=n.nodes[t],r=i.spec.tableRole;r&&(e[r]=i)}}return e}var Be=new an("selectingCells");function fn(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function ii(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function wr(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=fn(e.$head)||Hf(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Hf(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const i=e.type.spec.tableRole;if(i=="cell"||i=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const i=e.type.spec.tableRole;if(i=="cell"||i=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function tr(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function Ff(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Sr(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function ia(n,e,t){const i=n.node(-1),r=z.get(i),s=n.start(-1),o=r.nextCell(n.pos-s,e,t);return o==null?null:n.node(0).resolve(s+o)}function Vt(n,e,t=1){const i={...n,colspan:n.colspan-t};return i.colwidth&&(i.colwidth=i.colwidth.slice(),i.colwidth.splice(e,t),i.colwidth.some(r=>r>0)||(i.colwidth=null)),i}var F=class Me extends A{constructor(e,t=e){const i=e.node(-1),r=z.get(i),s=e.start(-1),o=r.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=r.cellsInRect(o).filter(h=>h!=t.pos-s);a.unshift(t.pos-s);const c=a.map(h=>{const d=i.nodeAt(h);if(!d)throw RangeError(`No cell with offset ${h} found`);const f=s+h+1;return new ol(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const i=e.resolve(t.map(this.$anchorCell.pos)),r=e.resolve(t.map(this.$headCell.pos));if(tr(i)&&tr(r)&&Sr(i,r)){const s=this.$anchorCell.node(-1)!=i.node(-1);return s&&this.isRowSelection()?Me.rowSelection(i,r):s&&this.isColSelection()?Me.colSelection(i,r):new Me(i,r)}return N.between(i,r)}content(){const e=this.$anchorCell.node(-1),t=z.get(e),i=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i),s={},o=[];for(let a=r.top;a<r.bottom;a++){const c=[];for(let h=a*t.width+r.left,d=r.left;d<r.right;d++,h++){const f=t.map[h];if(s[f])continue;s[f]=!0;const p=t.findCell(f);let u=e.nodeAt(f);if(!u)throw RangeError(`No cell with offset ${f} found`);const m=r.left-p.left,g=p.right-r.right;if(m>0||g>0){let y=u.attrs;if(m>0&&(y=Vt(y,0,m)),g>0&&(y=Vt(y,y.colspan-g,g)),p.left<r.left){if(u=u.type.createAndFill(y),!u)throw RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else u=u.type.create(y,u.content)}if(p.top<r.top||p.bottom>r.bottom){const y={...u.attrs,rowspan:Math.min(p.bottom,r.bottom)-Math.max(p.top,r.top)};p.top<r.top?u=u.type.createAndFill(y):u=u.type.create(y,u.content)}c.push(u)}o.push(e.child(a).copy(x.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new w(x.from(l),1,1)}replace(e,t=w.empty){const i=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){const{$from:l,$to:a}=r[o],c=e.mapping.slice(i);e.replace(c.map(l.pos),c.map(a.pos),o?w.empty:t)}const s=A.findFrom(e.doc.resolve(e.mapping.slice(i).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new w(x.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),i=z.get(t),r=this.$anchorCell.start(-1),s=i.cellsInRect(i.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let o=0;o<s.length;o++)e(t.nodeAt(s[o]),r+s[o])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const i=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(i,r)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const i=e.node(-1),r=z.get(i),s=e.start(-1),o=r.findCell(e.pos-s),l=r.findCell(t.pos-s),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(s+r.map[o.left])),l.bottom<r.height&&(t=a.resolve(s+r.map[r.width*(r.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(s+r.map[l.left])),o.bottom<r.height&&(e=a.resolve(s+r.map[r.width*(r.height-1)+o.right-1]))),new Me(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=z.get(e),i=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-i),s=t.colCount(this.$headCell.pos-i);if(Math.min(r,s)>0)return!1;const o=r+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==t.width}eq(e){return e instanceof Me&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const i=e.node(-1),r=z.get(i),s=e.start(-1),o=r.findCell(e.pos-s),l=r.findCell(t.pos-s),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(s+r.map[o.top*r.width])),l.right<r.width&&(t=a.resolve(s+r.map[r.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(s+r.map[l.top*r.width])),o.right<r.width&&(e=a.resolve(s+r.map[r.width*(o.top+1)-1]))),new Me(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Me(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,i=t){return new Me(e.resolve(t),e.resolve(i))}getBookmark(){return new $f(this.$anchorCell.pos,this.$headCell.pos)}};F.prototype.visible=!1;A.jsonID("cell",F);var $f=class ra{constructor(e,t){this.anchor=e,this.head=t}map(e){return new ra(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),i=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&i.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&i.index()<i.parent.childCount&&Sr(t,i)?new F(t,i):A.near(i,1)}};function Wf(n){if(!(n.selection instanceof F))return null;const e=[];return n.selection.forEachCell((t,i)=>{e.push(ee.node(i,i+t.nodeSize,{class:"selectedCell"}))}),R.create(n.doc,e)}function Kf({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,i=e.pos,r=n.depth;for(;r>=0&&!(n.after(r+1)<n.end(r));r--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,i--);return t==i&&/row|table/.test(n.node(r).type.spec.tableRole)}function Jf({$from:n,$to:e}){let t,i;for(let r=n.depth;r>0;r--){const s=n.node(r);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let r=e.depth;r>0;r--){const s=e.node(r);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){i=s;break}}return t!==i&&e.parentOffset===0}function qf(n,e,t){const i=(e||n).selection,r=(e||n).doc;let s,o;if(i instanceof T&&(o=i.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=F.create(r,i.from);else if(o=="row"){const l=r.resolve(i.from+1);s=F.rowSelection(l,l)}else if(!t){const l=z.get(i.node),a=i.from+1,c=a+l.map[l.width*l.height-1];s=F.create(r,a+1,c)}}else i instanceof N&&Kf(i)?s=N.create(r,i.from):i instanceof N&&Jf(i)&&(s=N.create(r,i.$from.start(),i.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}var jf=new an("fix-tables");function sa(n,e,t,i){const r=n.childCount,s=e.childCount;e:for(let o=0,l=0;o<s;o++){const a=e.child(o);for(let c=l,h=Math.min(r,o+3);c<h;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}i(a,t),l<r&&n.child(l).sameMarkup(a)?sa(n.child(l),a,t+1,i):a.nodesBetween(0,a.content.size,i,t+1),t+=a.nodeSize}}function _f(n,e){let t;const i=(r,s)=>{r.type.spec.tableRole=="table"&&(t=Gf(n,r,s,t))};return e?e.doc!=n.doc&&sa(e.doc,n.doc,0,i):n.doc.descendants(i),t}function Gf(n,e,t,i){const r=z.get(e);if(!r.problems)return i;i||(i=n.tr);const s=[];for(let a=0;a<r.height;a++)s.push(0);for(let a=0;a<r.problems.length;a++){const c=r.problems[a];if(c.type=="collision"){const h=e.nodeAt(c.pos);if(!h)continue;const d=h.attrs;for(let f=0;f<d.rowspan;f++)s[c.row+f]+=c.n;i.setNodeMarkup(i.mapping.map(t+1+c.pos),null,Vt(d,d.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const h=e.nodeAt(c.pos);if(!h)continue;i.setNodeMarkup(i.mapping.map(t+1+c.pos),null,{...h.attrs,rowspan:h.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const h=e.nodeAt(c.pos);if(!h)continue;i.setNodeMarkup(i.mapping.map(t+1+c.pos),null,{...h.attrs,colwidth:c.colwidth})}}let o,l;for(let a=0;a<s.length;a++)s[a]&&(o==null&&(o=a),l=a);for(let a=0,c=t+1;a<r.height;a++){const h=e.child(a),d=c+h.nodeSize,f=s[a];if(f>0){let p="cell";h.firstChild&&(p=h.firstChild.type.spec.tableRole);const u=[];for(let g=0;g<f;g++){const y=we(n.schema)[p].createAndFill();y&&u.push(y)}const m=(a==0||o==a-1)&&l==a?c+1:d-1;i.insert(i.mapping.map(m),u)}c=d}return i.setMeta(jf,{fixTables:!0})}function oa(n){const e=n.selection,t=wr(n),i=t.node(-1),r=t.start(-1),s=z.get(i);return{...e instanceof F?s.rectBetween(e.$anchorCell.pos-r,e.$headCell.pos-r):s.findCell(t.pos-r),tableStart:r,map:s,table:i}}function Uf(n){return function(e,t){if(!ii(e))return!1;if(t){const i=we(e.schema),r=oa(e),s=e.tr,o=r.map.cellsInRect(n=="column"?{left:r.left,top:0,right:r.right,bottom:r.map.height}:n=="row"?{left:0,top:r.top,right:r.map.width,bottom:r.bottom}:r),l=o.map(a=>r.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==i.header_cell&&s.setNodeMarkup(r.tableStart+o[a],i.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<o.length;a++)s.setNodeMarkup(r.tableStart+o[a],i.header_cell,l[a].attrs);t(s)}return!0}}function js(n,e,t){const i=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let r=0;r<i.length;r++){const s=e.table.nodeAt(i[r]);if(s&&s.type!==t.header_cell)return!1}return!0}function kr(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Uf(n):function(t,i){if(!ii(t))return!1;if(i){const r=we(t.schema),s=oa(t),o=t.tr,l=js("row",s,r),a=js("column",s,r),h=(n==="column"?l:n==="row"?a:!1)?1:0,d=n=="column"?{left:0,top:h,right:1,bottom:s.map.height}:n=="row"?{left:h,top:0,right:s.map.width,bottom:1}:s,f=n=="column"?a?r.cell:r.header_cell:n=="row"?l?r.cell:r.header_cell:r.cell;s.map.cellsInRect(d).forEach(p=>{const u=p+s.tableStart,m=o.doc.nodeAt(u);m&&o.setNodeMarkup(u,f,m.attrs)}),i(o)}return!0}}kr("row",{useDeprecatedLogic:!0});kr("column",{useDeprecatedLogic:!0});kr("cell",{useDeprecatedLogic:!0});function Zf(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let i=n.index(-1)-1,r=n.before();i>=0;i--){const s=n.node(-1).child(i),o=s.lastChild;if(o)return r-1-o.nodeSize;r-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let i=n.indexAfter(-1),r=n.after();i<t.childCount;i++){const s=t.child(i);if(s.childCount)return r+1;r+=s.nodeSize}}return null}function _s(n){return function(e,t){if(!ii(e))return!1;const i=Zf(wr(e),n);if(i==null)return!1;if(t){const r=e.doc.resolve(i);t(e.tr.setSelection(N.between(r,Ff(r))).scrollIntoView())}return!0}}function wn(n,e){const t=n.selection;if(!(t instanceof F))return!1;if(e){const i=n.tr,r=we(n.schema).cell.createAndFill().content;t.forEachCell((s,o)=>{s.content.eq(r)||i.replace(i.mapping.map(o+1),i.mapping.map(o+s.nodeSize-1),new w(r,0,0))}),i.docChanged&&e(i)}return!0}function Xf(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:i}=n;for(;e.childCount==1&&(t>0&&i>0||e.child(0).type.spec.tableRole=="table");)t--,i--,e=e.child(0).content;const r=e.child(0),s=r.type.spec.tableRole,o=r.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const h=a?0:Math.max(0,t-1),d=a<e.childCount-1?0:Math.max(0,i-1);(h||d)&&(c=nr(we(o).row,new w(c,h,d)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||i?nr(we(o).row,new w(e,t,i)).content:e);else return null;return Yf(o,l)}function Yf(n,e){const t=[];for(let r=0;r<e.length;r++){const s=e[r];for(let o=s.childCount-1;o>=0;o--){const{rowspan:l,colspan:a}=s.child(o).attrs;for(let c=r;c<r+l;c++)t[c]=(t[c]||0)+a}}let i=0;for(let r=0;r<t.length;r++)i=Math.max(i,t[r]);for(let r=0;r<t.length;r++)if(r>=e.length&&e.push(x.empty),t[r]<i){const s=we(n).cell.createAndFill(),o=[];for(let l=t[r];l<i;l++)o.push(s);e[r]=e[r].append(x.from(o))}return{height:e.length,width:i,rows:e}}function nr(n,e){const t=n.createAndFill();return new sl(t).replace(0,t.content.size,e).doc}function Qf({width:n,height:e,rows:t},i,r){if(n!=i){const s=[],o=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let h=s[l]||0,d=0;h<i;d++){let f=a.child(d%a.childCount);h+f.attrs.colspan>i&&(f=f.type.createChecked(Vt(f.attrs,f.attrs.colspan,h+f.attrs.colspan-i),f.content)),c.push(f),h+=f.attrs.colspan;for(let p=1;p<f.attrs.rowspan;p++)s[l+p]=(s[l+p]||0)+f.attrs.colspan}o.push(x.from(c))}t=o,n=i}if(e!=r){const s=[];for(let o=0,l=0;o<r;o++,l++){const a=[],c=t[l%e];for(let h=0;h<c.childCount;h++){let d=c.child(h);o+d.attrs.rowspan>r&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,r-d.attrs.rowspan)},d.content)),a.push(d)}s.push(x.from(a))}t=s,e=r}return{width:n,height:e,rows:t}}function eu(n,e,t,i,r,s,o){const l=n.doc.type.schema,a=we(l);let c,h;if(r>e.width)for(let d=0,f=0;d<e.height;d++){const p=t.child(d);f+=p.nodeSize;const u=[];let m;p.lastChild==null||p.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=h||(h=a.header_cell.createAndFill());for(let g=e.width;g<r;g++)u.push(m);n.insert(n.mapping.slice(o).map(f-1+i),u)}if(s>e.height){const d=[];for(let u=0,m=(e.height-1)*e.width;u<Math.max(e.width,r);u++){const g=u>=e.width?!1:t.nodeAt(e.map[m+u]).type==a.header_cell;d.push(g?h||(h=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const f=a.row.create(null,x.from(d)),p=[];for(let u=e.height;u<s;u++)p.push(f);n.insert(n.mapping.slice(o).map(i+t.nodeSize-2),p)}return!!(c||h)}function Gs(n,e,t,i,r,s,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=r;c<s;c++){const h=o*e.width+c,d=e.map[h];if(e.map[h-e.width]==d){a=!0;const f=t.nodeAt(d),{top:p,left:u}=e.findCell(d);n.setNodeMarkup(n.mapping.slice(l).map(d+i),null,{...f.attrs,rowspan:o-p}),n.insert(n.mapping.slice(l).map(e.positionAt(o,u,t)),f.type.createAndFill({...f.attrs,rowspan:p+f.attrs.rowspan-o})),c+=f.attrs.colspan-1}}return a}function Us(n,e,t,i,r,s,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=r;c<s;c++){const h=c*e.width+o,d=e.map[h];if(e.map[h-1]==d){a=!0;const f=t.nodeAt(d),p=e.colCount(d),u=n.mapping.slice(l).map(d+i);n.setNodeMarkup(u,null,Vt(f.attrs,o-p,f.attrs.colspan-(o-p))),n.insert(u+f.nodeSize,f.type.createAndFill(Vt(f.attrs,0,o-p))),c+=f.attrs.rowspan-1}}return a}function Zs(n,e,t,i,r){let s=t?n.doc.nodeAt(t-1):n.doc;if(!s)throw new Error("No table found");let o=z.get(s);const{top:l,left:a}=i,c=a+r.width,h=l+r.height,d=n.tr;let f=0;function p(){if(s=t?d.doc.nodeAt(t-1):d.doc,!s)throw new Error("No table found");o=z.get(s),f=d.mapping.maps.length}eu(d,o,s,t,c,h,f)&&p(),Gs(d,o,s,t,a,c,l,f)&&p(),Gs(d,o,s,t,a,c,h,f)&&p(),Us(d,o,s,t,l,h,a,f)&&p(),Us(d,o,s,t,l,h,c,f)&&p();for(let u=l;u<h;u++){const m=o.positionAt(u,a,s),g=o.positionAt(u,c,s);d.replace(d.mapping.slice(f).map(m+t),d.mapping.slice(f).map(g+t),new w(r.rows[u-l],0,0))}p(),d.setSelection(new F(d.doc.resolve(t+o.positionAt(l,a,s)),d.doc.resolve(t+o.positionAt(h-1,c-1,s)))),e(d)}var tu=Sl({ArrowLeft:Sn("horiz",-1),ArrowRight:Sn("horiz",1),ArrowUp:Sn("vert",-1),ArrowDown:Sn("vert",1),"Shift-ArrowLeft":kn("horiz",-1),"Shift-ArrowRight":kn("horiz",1),"Shift-ArrowUp":kn("vert",-1),"Shift-ArrowDown":kn("vert",1),Backspace:wn,"Mod-Backspace":wn,Delete:wn,"Mod-Delete":wn});function Nn(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Sn(n,e){return(t,i,r)=>{if(!r)return!1;const s=t.selection;if(s instanceof F)return Nn(t,i,A.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const o=la(r,n,e);if(o==null)return!1;if(n=="horiz")return Nn(t,i,A.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(o),a=ia(l,n,e);let c;return a?c=A.near(a,1):e<0?c=A.near(t.doc.resolve(l.before(-1)),-1):c=A.near(t.doc.resolve(l.after(-1)),1),Nn(t,i,c)}}}function kn(n,e){return(t,i,r)=>{if(!r)return!1;const s=t.selection;let o;if(s instanceof F)o=s;else{const a=la(r,n,e);if(a==null)return!1;o=new F(t.doc.resolve(a))}const l=ia(o.$headCell,n,e);return l?Nn(t,i,new F(o.$anchorCell,l)):!1}}function nu(n,e){const t=n.state.doc,i=fn(t.resolve(e));return i?(n.dispatch(n.state.tr.setSelection(new F(i))),!0):!1}function iu(n,e,t){if(!ii(n.state))return!1;let i=Xf(t);const r=n.state.selection;if(r instanceof F){i||(i={width:1,height:1,rows:[x.from(nr(we(n.state.schema).cell,t))]});const s=r.$anchorCell.node(-1),o=r.$anchorCell.start(-1),l=z.get(s).rectBetween(r.$anchorCell.pos-o,r.$headCell.pos-o);return i=Qf(i,l.right-l.left,l.bottom-l.top),Zs(n.state,n.dispatch,o,l,i),!0}else if(i){const s=wr(n.state),o=s.start(-1);return Zs(n.state,n.dispatch,o,z.get(s.node(-1)).findCell(s.pos-o),i),!0}else return!1}function ru(n,e){var t;if(e.ctrlKey||e.metaKey)return;const i=Xs(n,e.target);let r;if(e.shiftKey&&n.state.selection instanceof F)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&i&&(r=fn(n.state.selection.$anchor))!=null&&((t=Ni(n,e))==null?void 0:t.pos)!=r.pos)s(r,e),e.preventDefault();else if(!i)return;function s(a,c){let h=Ni(n,c);const d=Be.getState(n.state)==null;if(!h||!Sr(a,h))if(d)h=a;else return;const f=new F(a,h);if(d||!n.state.selection.eq(f)){const p=n.state.tr.setSelection(f);d&&p.setMeta(Be,a.pos),n.dispatch(p)}}function o(){n.root.removeEventListener("mouseup",o),n.root.removeEventListener("dragstart",o),n.root.removeEventListener("mousemove",l),Be.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Be,-1))}function l(a){const c=a,h=Be.getState(n.state);let d;if(h!=null)d=n.state.doc.resolve(h);else if(Xs(n,c.target)!=i&&(d=Ni(n,e),!d))return o();d&&s(d,c)}n.root.addEventListener("mouseup",o),n.root.addEventListener("dragstart",o),n.root.addEventListener("mousemove",l)}function la(n,e,t){if(!(n.state.selection instanceof N))return null;const{$head:i}=n.state.selection;for(let r=i.depth-1;r>=0;r--){const s=i.node(r);if((t<0?i.index(r):i.indexAfter(r))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=i.before(r),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Xs(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Ni(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?fn(n.state.doc.resolve(t.pos)):null}var su=class{constructor(n,e){this.node=n,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ir(n,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(n){return n.type!=this.node.type?!1:(this.node=n,ir(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function ir(n,e,t,i,r,s){var o;let l=0,a=!0,c=e.firstChild;const h=n.firstChild;if(h){for(let d=0,f=0;d<h.childCount;d++){const{colspan:p,colwidth:u}=h.child(d).attrs;for(let m=0;m<p;m++,f++){const g=r==f?s:u&&u[m],y=g?g+"px":"";if(l+=g||i,g||(a=!1),c)c.style.width!=y&&(c.style.width=y),c=c.nextSibling;else{const S=document.createElement("col");S.style.width=y,e.appendChild(S)}}}for(;c;){const d=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=d}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var re=new an("tableColumnResizing");function ou({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:i=su,lastColumnResizable:r=!0}={}){const s=new ln({key:re,state:{init(o,l){var a,c;const h=(c=(a=s.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,d=we(l.schema).table.name;return i&&h&&(h[d]=(f,p)=>new i(f,t,p)),new lu(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=re.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{au(o,l,n,r)},mouseleave:o=>{cu(o)},mousedown:(o,l)=>{hu(o,l,e,t)}},decorations:o=>{const l=re.getState(o);if(l&&l.activeHandle>-1)return mu(o,l.activeHandle)},nodeViews:{}}});return s}var lu=class En{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,i=e.getMeta(re);if(i&&i.setHandle!=null)return new En(i.setHandle,!1);if(i&&i.setDragging!==void 0)return new En(t.activeHandle,i.setDragging);if(t.activeHandle>-1&&e.docChanged){let r=e.mapping.map(t.activeHandle,-1);return tr(e.doc.resolve(r))||(r=-1),new En(r,t.dragging)}return t}};function au(n,e,t,i){const r=re.getState(n.state);if(r&&!r.dragging){const s=fu(e.target);let o=-1;if(s){const{left:l,right:a}=s.getBoundingClientRect();e.clientX-l<=t?o=Ys(n,e,"left",t):a-e.clientX<=t&&(o=Ys(n,e,"right",t))}if(o!=r.activeHandle){if(!i&&o!==-1){const l=n.state.doc.resolve(o),a=l.node(-1),c=z.get(a),h=l.start(-1);if(c.colCount(l.pos-h)+l.nodeAfter.attrs.colspan-1==c.width-1)return}aa(n,o)}}}function cu(n){const e=re.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&aa(n,-1)}function hu(n,e,t,i){var r;const s=(r=n.dom.ownerDocument.defaultView)!=null?r:window,o=re.getState(n.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=n.state.doc.nodeAt(o.activeHandle),a=du(n,o.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(re,{setDragging:{startX:e.clientX,startWidth:a}}));function c(d){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",h);const f=re.getState(n.state);f!=null&&f.dragging&&(uu(n,f.activeHandle,Qs(f.dragging,d,t)),n.dispatch(n.state.tr.setMeta(re,{setDragging:null})))}function h(d){if(!d.which)return c(d);const f=re.getState(n.state);if(f&&f.dragging){const p=Qs(f.dragging,d,t);eo(n,f.activeHandle,p,i)}}return eo(n,o.activeHandle,a,i),s.addEventListener("mouseup",c),s.addEventListener("mousemove",h),e.preventDefault(),!0}function du(n,e,{colspan:t,colwidth:i}){const r=i&&i[i.length-1];if(r)return r;const s=n.domAtPos(e);let l=s.node.childNodes[s.offset].offsetWidth,a=t;if(i)for(let c=0;c<t;c++)i[c]&&(l-=i[c],a--);return l/a}function fu(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Ys(n,e,t,i){const r=t=="right"?-i:i,s=n.posAtCoords({left:e.clientX+r,top:e.clientY});if(!s)return-1;const{pos:o}=s,l=fn(n.state.doc.resolve(o));if(!l)return-1;if(t=="right")return l.pos;const a=z.get(l.node(-1)),c=l.start(-1),h=a.map.indexOf(l.pos-c);return h%a.width==0?-1:c+a.map[h-1]}function Qs(n,e,t){const i=e.clientX-n.startX;return Math.max(t,n.startWidth+i)}function aa(n,e){n.dispatch(n.state.tr.setMeta(re,{setHandle:e}))}function uu(n,e,t){const i=n.state.doc.resolve(e),r=i.node(-1),s=z.get(r),o=i.start(-1),l=s.colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<s.height;c++){const h=c*s.width+l;if(c&&s.map[h]==s.map[h-s.width])continue;const d=s.map[h],f=r.nodeAt(d).attrs,p=f.colspan==1?0:l-s.colCount(d);if(f.colwidth&&f.colwidth[p]==t)continue;const u=f.colwidth?f.colwidth.slice():pu(f.colspan);u[p]=t,a.setNodeMarkup(o+d,null,{...f,colwidth:u})}a.docChanged&&n.dispatch(a)}function eo(n,e,t,i){const r=n.state.doc.resolve(e),s=r.node(-1),o=r.start(-1),l=z.get(s).colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;let a=n.domAtPos(r.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&ir(s,a.firstChild,a,i,l,t)}function pu(n){return Array(n).fill(0)}function mu(n,e){var t;const i=[],r=n.doc.resolve(e),s=r.node(-1);if(!s)return R.empty;const o=z.get(s),l=r.start(-1),a=o.colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<o.height;c++){const h=a+c*o.width;if((a==o.width-1||o.map[h]!=o.map[h+1])&&(c==0||o.map[h]!=o.map[h-o.width])){const d=o.map[h],f=l+d+s.nodeAt(d).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",(t=re.getState(n))!=null&&t.dragging&&i.push(ee.node(l+d,l+d+s.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),i.push(ee.widget(f,p))}}return R.create(n.doc,i)}function gu({allowTableNodeSelection:n=!1}={}){return new ln({key:Be,state:{init(){return null},apply(e,t){const i=e.getMeta(Be);if(i!=null)return i==-1?null:i;if(t==null||!e.docChanged)return t;const{deleted:r,pos:s}=e.mapping.mapResult(t);return r?null:s}},props:{decorations:Wf,handleDOMEvents:{mousedown:ru},createSelectionBetween(e){return Be.getState(e.state)!=null?e.state.selection:null},handleTripleClick:nu,handleKeyDown:tu,handlePaste:iu},appendTransaction(e,t,i){return qf(i,_f(i,t),n)}})}const Xt=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},to="data-gs-mrk-fs",no="data-gs-ib",_n="data-gs-ifrg",Ne="attrs",ca={[Ne]:{default:"{}"}},ke={[Ne]:{default:{}}},ha=n=>({[Ne]:JSON.stringify(Xt(n))}),ve=n=>({attrs:Xt(n)}),$t=n=>e=>[n,e.attrs.attrs,0],Ve=n=>n.attrs[Ne]?JSON.parse(n.attrs[Ne]):{},yu={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${_n}]`,getAttrs:ve}],toDOM:()=>["span",{[_n]:""},0]},div:{group:"block",content:"inline*",attrs:ke,parseDOM:[{tag:"div",getAttrs:ve}],toDOM:$t("div")},paragraph:{group:"block",content:"inline*",attrs:ke,parseDOM:[{tag:"p",getAttrs:ve}],toDOM:$t("p")},orderedList:{group:"block",content:"listItem+",attrs:ke,parseDOM:[{tag:"ol",getAttrs:ve}],toDOM:$t("ol")},bulletList:{group:"block",content:"listItem+",attrs:ke,parseDOM:[{tag:"ul",getAttrs:ve}],toDOM:$t("ul")},listItem:{content:"block*",group:"block",attrs:ke,parseDOM:[{tag:"li",getAttrs:ve}],toDOM:$t("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:ke,parseDOM:[{tag:"pre",getAttrs:ve}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:ke,parseDOM:[{tag:"img[src]",getAttrs:ve}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${no}]`}],toDOM(){return["br",{[no]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:ke,parseDOM:[{tag:"br",getAttrs:ve}],toDOM:n=>["br",{...n.attrs.attrs}]},heading:{group:"block",content:"inline*",attrs:{level:{default:1},attrs:{default:{}}},defining:!0,parseDOM:Array.from({length:6},(n,e)=>({tag:`h${e+1}`,getAttrs:t=>({level:e+1,attrs:Xt(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...Lf({tableGroup:"block",cellContent:"block+",cellAttributes:{[Ne]:{default:ke[Ne].default,getFromDOM:Xt,setDOMAttr:(n,e)=>{n&&Object.assign(e,n)}},background:{default:null,getFromDOM(n){return n.style.backgroundColor||null},setDOMAttr(n,e){n&&(e.style=(e.style||"")+`background-color: ${n};`)}}}}),nonTextNode:{group:"block",content:"block*",attrs:{tagName:{default:"span"},attrs:{default:{}}},parseDOM:[{tag:"*:not(tbody)",getAttrs:n=>({tagName:n.tagName.toLowerCase(),attrs:Xt(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},Wt=(n,e)=>({attrs:ca,parseDOM:n.map(t=>({tag:t,getAttrs:ha})),toDOM:e}),bu={strong:Wt(["strong","b"],n=>["b",Ve(n)]),link:Wt(["a"],n=>["a",Ve(n),0]),em:Wt(["em","i"],n=>["em",Ve(n)]),underline:Wt(["u"],n=>["u",Ve(n),0]),strikethrough:Wt(["s"],n=>["s",Ve(n),0]),font_size:{attrs:{...ca,size:{default:null}},parseDOM:[{tag:`span[${to}]`,getAttrs:n=>({...ha(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...Ve(n),[to]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},io=new zc({nodes:yu,marks:bu}),ri=new WeakMap,vr=new WeakMap,xu=(n,e)=>{ri.set(n,e),vr.set(e,n)},Cu=(n,e)=>{ri.delete(n),vr.delete(e)},Ei=n=>ri.get(n),wu=n=>vr.get(n),ro=n=>{var t;const e=wu(n);return(t=e==null?void 0:e.__gjsv)==null?void 0:t.model},Su=n=>n.dispatchEvent(new CustomEvent("input"));function ku(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(_n)){if(t.getAttribute("style")){t.removeAttribute(_n);return}const i=t.parentElement;if(i){for(;t.firstChild;)i.insertBefore(t.firstChild,t);i.removeChild(t)}}else Array.from(t.children).forEach(i=>e(i))};e(n)}function vu(n,e={}){if(!e.enableOnClick)return()=>{};const t=n.Components.events,i=h=>n.getSelectedAll().includes(h),r=h=>h.isInstanceOf("text")&&!h.isChildOf("text"),s=h=>h.isChildOf("text"),o=h=>n.getEditing()===h,l=(h,d={})=>{h.trigger("focus",d.event)},a=(h,d)=>{i(h)&&r(h)&&!o(h)&&l(h,d)},c=(h,d)=>{if(i(h)&&!r(h)&&s(h)){const f=h.parents().find(p=>p.isInstanceOf("text"));f&&(l(f,d),setTimeout(()=>n.select(f),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const Mu=(n,e)=>{const t=Tu(n);return t&&Vu(t)?Ou(n,e):t?pl(()=>({type:n.schema.nodes.div}))(n,e):!1};function Tu(n){const e=n.selection.$from;if(e.node(e.depth).type===n.schema.nodes.inlineFragment){const t=e.depth-1;return e.node(t)}return e.node(e.depth)}function Ou(n,e){const{selection:t,schema:i,tr:r}=n;r.split(t.from,1);const s=t.from+1,o=r.doc.nodeAt(s),l={...o.attrs.attrs,id:void 0},a=o.textContent.length>0,c=o.textContent.length||0,h=o.textContent||" ",d=i.text(h),f=i.nodes.div.create(l,a?d:[],[]);return r.replaceRangeWith(s,s+c+2,f),r.setSelection(N.create(r.doc,s+1)),e==null||e(r.scrollIntoView()),!0}function Au(n,e,t){const{state:i,dispatch:r}=n,{selection:s,tr:o}=i,l=(a,c,h)=>{const d={};return a.split(";").forEach(f=>{const[p,u]=f.split(":").map(m=>m.trim());p&&(d[p]=u)}),d[c]=h,Object.entries(d).map(([f,p])=>`${f}: ${p}`).join("; ")};if(!s.empty||t)o.doc.nodesBetween(s.from,s.to,(a,c)=>{var h,d;if(a.type===i.schema.nodes.image){const f=l(((h=a.attrs.attrs)==null?void 0:h.style)||"","float",e);o.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:f}})}else if(a.type.isBlock){const f=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","text-align",e);da(a)?o.setBlockType(s.from,void 0,i.schema.nodes.div,{attrs:{style:f}}):o.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:f}})}});else{const a=i.doc.resolve(s.from),c=a.start(a.depth),h=i.doc.nodeAt(c);if(h!=null&&h.type.isBlock){const d=l(h.attrs.style||"","text-align",e);o.setNodeMarkup(c,void 0,{...h.attrs,style:d})}}o.docChanged&&r(o.scrollIntoView())}const Kt=(n,e)=>{const{from:t,to:i}=n.selection;let r=!1;return n.doc.nodesBetween(t,i,s=>{if(r)return!1;s.marks.some(o=>o.type===e)&&(r=!0)}),r};function Nu(n,e,t="_blank"){const{state:i,dispatch:r}=n,{schema:s,selection:o,tr:l}=i,a=s.marks.link;try{const c=a.create({[Ne]:JSON.stringify({href:e,target:t})});l.addMark(o.from,o.to,c),r(l.scrollIntoView())}catch(c){console.error("Error applying link mark:",c)}}function Eu(n,e){const{state:t,dispatch:i}=n,{selection:r,tr:s}=t;if(r.empty)return;const o=t.schema.marks.font_size;if(!o){console.error("Font size mark is not defined in the schema.");return}s.addMark(r.from,r.to,o.create({size:e})),i(s.scrollIntoView())}const it=(n,e)=>{const{doc:t,selection:i}=n.state,r=t.resolve(i.from);for(let s=r.depth;s>0;s--){const o=r.node(s);if(e(o))return{pos:s>0?r.before(s):0,start:r.start(s),depth:s,node:o}}},Du=n=>(n||"").split(";").map(e=>e.split(":")).reduce((e,[t,i])=>(t=t.replace(/-./g,r=>r.toUpperCase()[1]).trim(),e[t]=`${i}`.trim(),e),{});function Iu(...n){return(e,t)=>{const i=o=>{e=e.apply(o),t==null||t(o)},r=n.pop();return n.reduce((o,l)=>o||l(e,i),!1)&&r!==void 0&&r(e,t)}}const Ru=(n,e)=>{const{state:t,dispatch:i}=n;if(e!=null&&e.event){const{event:r}=e,s=n.posAtCoords({left:r.clientX,top:r.clientY});s!=null&&s.pos&&i(t.tr.setSelection(N.create(t.doc,s.pos)))}else ml(t,i);setTimeout(()=>setTimeout(()=>n.focus()))},rr=n=>n.isBlock,da=n=>n.type.name==="inlineFragment",Pu=n=>rr(n)&&!da(n),fa=n=>n.type.name==="bulletList",ua=n=>n.type.name==="orderedList",Vu=n=>n.type.name==="heading",zu=n=>fa(n)||ua(n),so=(n,e)=>{var s,o;const t=(s=it(n,l=>l.type===e))==null?void 0:s.node,i=n.state.schema.nodes.listItem;let r;return t?r=Wi(i):(o=it(n,zu))!=null&&o.node?r=Iu(Wi(i),hs(e)):r=hs(e),r(n.state,n.dispatch)},pa=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(i=>i.type.name===e)},Bu=n=>{var o;const{view:e,prop:t,editor:i,propCSS:r}=n,s=(o=it(e,Pu))==null?void 0:o.node;if(s){const l=s.attrs.attrs||{},a=Du(l.style);if(t in a)return a[t]||"";if(l.id){const c=i.Components.getById(l.id);return((c==null?void 0:c.getStyle())||{})[r]||""}}return""},Lu=n=>{const{view:e,prop:t,markName:i,editor:r,propCSS:s}=n,o=pa(e,i);if(o){const l=o.attrs;if(l[t])return l[t];if(l[Ne]){const a=Ve(o).id;if(a){const c=r.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[s]||""}}}return""},ma=(n,e)=>{const{dispatch:t}=n,{nodes:i,marks:r}=n.state.schema;return{text:{selected:()=>{const{selection:s,doc:o}=n.state;return o.textBetween(s.from,s.to," ")},replace:(s,o={})=>{const{state:l}=n,{from:a}=l.selection;let c=l.tr.replaceSelectionWith(l.schema.text(s));o.select&&(c=c.setSelection(N.create(c.doc,a,a+s.length))),t==null||t(c)}},bold:{toggle:()=>Ye(r.strong)(n.state,t),isActive:()=>Kt(n.state,r.strong)},italic:{toggle:()=>Ye(r.em)(n.state,t),isActive:()=>Kt(n.state,r.em)},underline:{toggle:()=>Ye(r.underline)(n.state,t),isActive:()=>Kt(n.state,r.underline)},strikethrough:{toggle:()=>Ye(r.strikethrough)(n.state,t),isActive:()=>Kt(n.state,r.strikethrough)},link:{get:()=>{const s=ro(n);if(s!=null&&s.is("link"))return s.getAttributes();{const o=pa(n,"link");return o?Ve(o):{}}},toggle:()=>Ye(r.link)(n.state,t),isActive:()=>Kt(n.state,r.link),create:s=>{const o=ro(n);o!=null&&o.is("link")?(o.addAttributes({href:s.url,target:s.target}),n.focus()):Nu(n,s.url,s.target)}},alignText:{get:()=>Bu({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:s=>Au(n,s.value,!0)},fontSize:{get:()=>Lu({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:s=>Eu(n,s.value)},image:{open(){const s="assetLayout",{state:o,dispatch:l}=n,{selection:a,doc:c}=o,h=c.textBetween(a.from,a.to," "),d={id:s,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:f=>{const p={alt:h,src:f.asset.getSrc()};l(o.tr.replaceSelectionWith(i.image.createAndFill({attrs:p})))}}};e.runCommand(Yt.layoutToggle,d)}},heading:{get:()=>{var o;const s=(o=it(n,rr))==null?void 0:o.node;return`${(s==null?void 0:s.attrs.level)||""}`},set:({value:s})=>{var a;const{state:o}=n,l=(a=it(n,rr))==null?void 0:a.node;Nh(o.schema.nodes.heading,{attrs:l==null?void 0:l.attrs.attrs,level:s?parseInt(s,10):0})(o,t)}},listBullet:{isActive:()=>{var s;return!!((s=it(n,fa))!=null&&s.node)},toggle:()=>so(n,i.bulletList)},listOrdered:{isActive:()=>{var s;return!!((s=it(n,ua))!=null&&s.node)},toggle:()=>so(n,i.orderedList)}}},de="rte:selectionchange",le={bold:'<svg viewBox="0 0 24 24"><path d="M13.5,15.5H10V12.5H13.5A1.5,1.5 0 0,1 15,14A1.5,1.5 0 0,1 13.5,15.5M10,6.5H13A1.5,1.5 0 0,1 14.5,8A1.5,1.5 0 0,1 13,9.5H10M15.6,10.79C16.57,10.11 17.25,9 17.25,8C17.25,5.74 15.5,4 13.25,4H7V18H14.04C16.14,18 17.75,16.3 17.75,14.21C17.75,12.69 16.89,11.39 15.6,10.79Z" /></svg>',italic:'<svg viewBox="0 0 24 24"><path d="M10,4V7H12.21L8.79,15H6V18H14V15H11.79L15.21,7H18V4H10Z" /></svg>',underline:'<svg viewBox="0 0 24 24"><path d="M5,21H19V19H5V21M12,17A6,6 0 0,0 18,11V3H15.5V11A3.5,3.5 0 0,1 12,14.5A3.5,3.5 0 0,1 8.5,11V3H6V11A6,6 0 0,0 12,17Z" /></svg>',strikethrough:'<svg viewBox="0 0 24 24"><path d="M7.2 9.8c-1.2-2.3.5-5 2.9-5.5 3.1-1 7.6.4 7.5 4.2h-3l-.1-.8c-.2-.6-.6-.9-1.2-1.1-.8-.3-2.1-.2-2.8.3C9 8.2 10.4 9.5 12 10H7.4l-.2-.2M21 13v-2H3v2h9.6l.6.2c.6.3 1.1.5 1.3 1.1.1.4.2.9 0 1.3-.2.5-.6.7-1.1.9-1.8.5-4-.2-3.9-2.4h-3c-.1 2.6 2.1 4.4 4.5 4.7 3.8.8 8.3-1.6 6.3-5.9l3.7.1Z"/></svg>',link:'<svg viewBox="0 0 24 24"><path d="M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z" /></svg>',image:'<svg viewBox="0 0 24 24"><path d="M19,19H5V5H19M19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M13.96,12.29L11.21,15.83L9.25,13.47L6.5,17H17.5L13.96,12.29Z"></path></svg>',listBullet:'<svg viewBox="0 0 24 24"><path d="M7 5h14v2H7V5m0 8v-2h14v2H7M4 4.5A1.5 1.5 0 0 1 5.5 6 1.5 1.5 0 0 1 4 7.5 1.5 1.5 0 0 1 2.5 6 1.5 1.5 0 0 1 4 4.5m0 6A1.5 1.5 0 0 1 5.5 12 1.5 1.5 0 0 1 4 13.5 1.5 1.5 0 0 1 2.5 12 1.5 1.5 0 0 1 4 10.5M7 19v-2h14v2H7m-3-2.5A1.5 1.5 0 0 1 5.5 18 1.5 1.5 0 0 1 4 19.5 1.5 1.5 0 0 1 2.5 18 1.5 1.5 0 0 1 4 16.5Z"/></svg>',listOrdered:'<svg viewBox="0 0 24 24"><path d="M7 13v-2h14v2H7m0 6v-2h14v2H7M7 7V5h14v2H7M3 8V5H2V4h2v4H3m-1 9v-1h3v4H2v-1h2v-.5H3v-1h1V17H2m2.3-7a.8.8 0 0 1 .7.8c0 .1 0 .3-.2.5L3 13h2v1H2v-1l2-2H2v-1h2.3Z"/></svg>',alignTextLeft:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H15V9H3V7M3,11H21V13H3V11M3,15H15V17H3V15M3,19H21V21H3V19Z" /></svg>',alignTextCenter:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M7,7H17V9H7V7M3,11H21V13H3V11M7,15H17V17H7V15M3,19H21V21H3V19Z" /></svg>',alignTextRight:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M9,7H21V9H9V7M3,11H21V13H3V11M9,15H21V17H9V15M3,19H21V21H3V19Z" /></svg>',alignTextJustify:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H21V9H3V7M3,11H21V13H3V11M3,15H21V17H3V15M3,19H21V21H3V19Z" /></svg>'},Hu=(n,e)=>{var a;const{editor:t,el:i}=n,r=ri.get(i),s=ma(r,t),o={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},bold:{id:"bold",icon:le.bold,size:"s",type:"button",editorEvents:{[de]:({setState:c})=>{c({active:s.bold.isActive()})}},onClick:({setState:c})=>{s.bold.toggle(),c({active:s.bold.isActive()})}},italic:{id:"italic",icon:le.italic,size:"s",type:"button",editorEvents:{[de]:({setState:c})=>{c({active:s.italic.isActive()})}},onClick:({setState:c})=>{s.italic.toggle(),c({active:s.italic.isActive()})}},underline:{id:"underline",icon:le.underline,size:"s",type:"button",editorEvents:{[de]:({setState:c})=>{c({active:s.underline.isActive()})}},onClick:({setState:c})=>{s.underline.toggle(),c({active:s.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:le.strikethrough,size:"s",type:"button",editorEvents:{[de]:({setState:c})=>{c({active:s.strikethrough.isActive()})}},onClick:({setState:c})=>{s.strikethrough.toggle(),c({active:s.strikethrough.isActive()})}},image:{id:"image",icon:le.image,size:"s",type:"button",onClick:()=>s.image.open()},link:{id:"link",icon:le.link,size:"s",type:"button",editorEvents:{[de]:({setState:c})=>{c({active:s.link.isActive(),disabled:r.state.selection.empty})}},onClick:({event:c})=>{const h=c.currentTarget||c.target,{x:d,y:f,width:p,height:u}=h.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(Yt.layoutRemove,{id:m}),y=s.link.get(),S={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:d,y:f,w:p,h:u},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:b=>{b.preventDefault();const C=new FormData(b.currentTarget);s.link.create({url:C.get("url"),target:C.get("target")}),g()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(y==null?void 0:y.href)||"",onChange:({value:b,setState:C})=>C({value:b})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(y==null?void 0:y.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:b,setState:C})=>C({value:b})},{type:"row",style:{gap:10,justifyContent:"end"},children:[s.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{s.link.toggle(),g()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(Yt.layoutToggle,S)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:le.alignTextLeft},{id:"center",icon:le.alignTextCenter},{id:"right",icon:le.alignTextRight},{id:"justify",icon:le.alignTextJustify}],editorEvents:{[de]:({setState:c})=>{c({value:s.alignText.get()})}},onChange:({value:c,setState:h})=>{h({value:c}),s.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:le.listBullet,size:"s",type:"button",editorEvents:{[de]:({setState:c})=>{c({active:s.listBullet.isActive()})}},onClick:({setState:c})=>{s.listBullet.toggle(),c({active:s.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:le.listOrdered,size:"s",type:"button",editorEvents:{[de]:({setState:c})=>{c({active:s.listOrdered.isActive()})}},onClick:({setState:c})=>{s.listOrdered.toggle(),c({active:s.listOrdered.isActive()})}},heading:{id:"heading",type:"selectField",size:"s",value:"",emptyState:"Heading",options:[{id:"",label:"Normal"},{id:"1",label:"Heading 1"},{id:"2",label:"Heading 2"},{id:"3",label:"Heading 3"},{id:"4",label:"Heading 4"},{id:"5",label:"Heading 5"},{id:"6",label:"Heading 6"}],editorEvents:{[de]:({setState:c})=>{c({value:s.heading.get()})}},onChange:({value:c,setState:h})=>{h({value:c}),s.heading.set({value:c}),r.focus()}},fontSize:{id:"fontSize",type:"selectField",size:"s",value:"",emptyState:"Font size",options:[{id:"8pt",label:"8pt"},{id:"10pt",label:"10pt"},{id:"12pt",label:"12pt"},{id:"14pt",label:"14pt"},{id:"18pt",label:"18pt"},{id:"24pt",label:"24pt"},{id:"36pt",label:"36pt"}],editorEvents:{[de]:({setState:c})=>{c({value:s.fontSize.get()})}},onChange:({value:c,setState:h})=>{h({value:c}),s.fontSize.set({value:c}),r.focus()}}},l=[o.bold,o.italic,o.underline,o.strikethrough,o.image,o.link,o.listBullet,o.listOrdered,o.alignText,o.heading,o.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:s,layouts:o,proseMirror:{view:r},items:l}))||l};class Fu{constructor(e,t,i){this.editor=i,this.node=e,this.dom=document.createElement("img"),this.view=t,Object.keys(e.attrs.attrs).forEach(r=>{this.dom.setAttribute(r,e.attrs.attrs[r])}),this.dom.addEventListener("dblclick",r=>this.handleDoubleClick(r))}handleDoubleClick(e){const{editor:t,view:i}=this;ma(i,t).image.open(),e.preventDefault()}update(e){return e.type!==this.node.type?!1:(this.node=e,Object.keys(e.attrs.attrs).forEach(t=>{this.dom.setAttribute(t,e.attrs.attrs[t])}),!0)}selectNode(){this.dom.style.outline="2px solid #ffca6f"}deselectNode(){this.dom.style.outline=""}}class je{constructor(e,t,i={}){this.match=e,this.match=e,this.handler=typeof t=="string"?$u(t):t,this.undoable=i.undoable!==!1,this.inCode=i.inCode||!1}}function $u(n){return function(e,t,i,r){let s=n;if(t[1]){let o=t[0].lastIndexOf(t[1]);s+=t[0].slice(o+t[1].length),i+=o;let l=i-r;l>0&&(s=t[0].slice(o-l,o)+s,i=r)}return e.tr.insertText(s,i,r)}}const Wu=500;function Ku({rules:n}){let e=new ln({state:{init(){return null},apply(t,i){let r=t.getMeta(this);return r||(t.selectionSet||t.docChanged?null:i)}},props:{handleTextInput(t,i,r,s){return oo(t,i,r,s,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:i}=t.state.selection;i&&oo(t,i.pos,i.pos,"",n,e)})}}},isInputRules:!0});return e}function oo(n,e,t,i,r,s){if(n.composing)return!1;let o=n.state,l=o.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-Wu),l.parentOffset,null,"")+i;for(let c=0;c<r.length;c++){let h=r[c];if(l.parent.type.spec.code){if(!h.inCode)continue}else if(h.inCode==="only")continue;let d=h.match.exec(a),f=d&&h.handler(o,d,e-(d[0].length-i.length),t);if(f)return h.undoable&&f.setMeta(s,{transform:f,from:e,to:t,text:i}),n.dispatch(f),!0}return!1}const Ju=new je(/--$/,"—"),qu=new je(/\.\.\.$/,"…"),ju=new je(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),_u=new je(/"$/,"”"),Gu=new je(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),Uu=new je(/'$/,"’"),Zu=[ju,_u,Gu,Uu];function Mr(n,e,t=null,i){return new je(n,(r,s,o,l)=>{let a=t instanceof Function?t(s):t,c=r.tr.delete(o,l),h=c.doc.resolve(o),d=h.blockRange(),f=d&&Yo(d,e,a);if(!f)return null;c.wrap(d,f);let p=c.doc.resolve(o-1).nodeBefore;return p&&p.type==e&&Yn(c.doc,o-1)&&(!i||i(s,p))&&c.join(o-1),c})}function ga(n,e,t=null){return new je(n,(i,r,s,o)=>{let l=i.doc.resolve(s),a=t instanceof Function?t(r):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?i.tr.delete(s,o).setBlockType(s,s,e,a):null})}function Xu(n){return Mr(/^\s*>\s$/,n)}function Yu(n){return Mr(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function Qu(n){return Mr(/^\s*([-+*])\s$/,n)}function ep(n){return ga(/^```$/,n)}function tp(n,e){return ga(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function np(n){const e=Zu.concat(qu,Ju);let t;return(t=n.nodes.blockquote)&&e.push(Xu(t)),(t=n.nodes.orderedList)&&e.push(Yu(t)),(t=n.nodes.bulletList)&&e.push(Qu(t)),(t=n.nodes.codeBlock)&&e.push(ep(t)),(t=n.nodes.heading)&&e.push(tp(t,6)),Ku({rules:e})}const ip="rteProseMirror",rp=function(n,e={}){const t={plugins:o=>o.plugins,...e},i=(o,l)=>{var u,m;const a=((u=t.schema)==null?void 0:u.call(t,{editor:n,schema:io}))||io,{nodes:c,marks:h}=a,d=Et.fromSchema(a).parse(o),f=vt.create({doc:d,schema:a,plugins:(m=t.plugins)==null?void 0:m.call(t,{editor:n,plugins:[ou(),gu(),np(a),$h(),ki({Tab:_s(1),"Shift-Tab":_s(-1)}),ki({Enter:tn(ul,Uh(c.listItem),Mu),"Shift-Enter":tn(fl,(g,y)=>(y&&y(g.tr.replaceSelectionWith(c.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":wl,"Mod-y":$i,"Mod-Shift-z":$i,"Mod-b":Ye(h.strong),"Mod-i":Ye(h.em),"Shift-Tab":Wi(c.listItem),Tab:Yh(c.listItem)}),ki(Ih)]})}),p=new Df({mount:o},{state:f,dispatchTransaction(g){var k;const{state:y}=p,S=y.apply(g),b=!y.doc.eq(S.doc);p.updateState(S);const C=!y.selection.eq(S.selection);b&&(Su(((k=l==null?void 0:l.view)==null?void 0:k.el)||o),p.focus()),(C||b)&&n.trigger(de)}});return o.__rteView=p,p.setProps({nodeViews:{image(g){return new Fu(g,p,n)}}}),p},r=o=>Hu(o,t);n.setCustomRte({toolbar:r,parseContent:!0,async enable(o,l,a){const c=Ei(o);if(c)return c;const h=i(o,a);return xu(o,h),Ru(h,a),h},disable(o){const l=Ei(o);if(l)return Cu(o,l),l.destroy(),{forceSync:!0}},getContent(o){const l=Ei(o);if(l){const{schema:a,doc:c}=l.state,h=document.createElement("div"),d=ut.fromSchema(a).serializeFragment(c.content);return d.childNodes.forEach(f=>{f.nodeType===Node.ELEMENT_NODE&&f.innerHTML===""&&(f.innerHTML="<br/>")}),h.appendChild(d),ku(h),o.classList.remove("ProseMirror-focused"),h.innerHTML}return o.innerHTML}});const s=vu(n,t);Bt({editor:n,licenseKey:t.licenseKey,plan:pe.free,pluginName:ip,cleanup:()=>{n.RichTextEditor.customRte=void 0,s()}})},sp=zt(rp);exports.dialogComponent=Oa;exports.fsLightboxComponent=cc;exports.lightGalleryComponent=xc;exports.listPagesComponent=sc;exports.rteProseMirror=sp;exports.tableComponent=Ya;