@grapesjs/studio-sdk-plugins 1.0.20-rc.1 → 1.0.20
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/flexComponent/index.cjs.js +8 -8
- package/dist/flexComponent/index.es.js +31 -31
- package/dist/flexComponent/index.umd.js +8 -8
- package/dist/index.cjs.js +75 -56
- package/dist/index.es.js +3549 -3395
- package/dist/index.umd.js +83 -64
- package/dist/presetPrintable/canvasSpots.d.ts +3 -0
- package/dist/presetPrintable/commands.d.ts +3 -0
- package/dist/presetPrintable/components.d.ts +3 -0
- package/dist/presetPrintable/index.cjs.js +28 -9
- package/dist/presetPrintable/index.es.js +298 -125
- package/dist/presetPrintable/index.umd.js +28 -9
- package/dist/presetPrintable/types.d.ts +11 -2
- package/dist/presetPrintable/typesSchema.d.ts +23 -0
- package/dist/presetPrintable/utils.d.ts +2 -3
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
(function(H,
|
|
1
|
+
(function(H,zt){typeof exports=="object"&&typeof module<"u"?zt(exports):typeof define=="function"&&define.amd?define(["exports"],zt):(H=typeof globalThis<"u"?globalThis:H||self,zt(H.StudioSdkPlugins={}))})(this,function(H){"use strict";const zt="app.grapesjs.com",ti="app-stage.grapesjs.com",ni=[zt,ti,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],_d="license:check:start",Gd="license:check:end",Wd=()=>typeof window<"u",oi=(n,e={})=>{const t=Jd(n)?{id:n,src:n}:n;return new Promise((o,s)=>{var a,c;const r=document.querySelector(`script[src="${t.src}"]`),{id:i}=t;if(r)return(a=e.onScript)==null||a.call(e,r),o(i);const l=document.createElement("script");l.src=t.src,l.onload=()=>o(i),l.onerror=()=>s(i),document.head.appendChild(l),(c=e.onScript)==null||c.call(e,l)})},jd=({isDev:n,isStage:e})=>`${n?"":`https://${e?ti:zt}`}/api`,qd=()=>{const n=Wd()&&window.location.hostname;return!!n&&(ni.includes(n)||ni.some(e=>n.endsWith(e)))},Kd=n=>n.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,t)=>(t?"-":"")+e.toLowerCase()),Ud=n=>typeof n<"u",Jd=n=>typeof n=="string";function $t(n){return typeof n=="function"}async function Yd({path:n,baseApiUrl:e,method:t="GET",headers:o={},params:s,body:r}){const l=`${e||jd({isDev:!1,isStage:!1})}${n}`,a={method:t,headers:{"Content-Type":"application/json",...o}};r&&(a.body=JSON.stringify(r));const c=s?new URLSearchParams(s).toString():"",d=c?`?${c}`:"",u=await fetch(`${l}${d}`,a);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return u.json()}var F=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(F||{}),si=(n=>(n.Info="info",n.Error="error",n.Success="success",n.Warning="warning",n))(si||{}),_=(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.getStateContextMenu="studio:getStateContextMenu",n.setStateContextMenu="studio:setStateContextMenu",n.contextMenuComponent="studio:contextMenuComponent",n.layoutAdd="studio:layoutAdd",n.layoutRemove="studio:layoutRemove",n.layoutToggle="studio:layoutToggle",n.layoutUpdate="studio:layoutUpdate",n.layoutGet="studio:layoutGet",n.layoutConfigGet="studio:layoutConfigGet",n.layoutConfigSet="studio:layoutConfigSet",n.getStateTheme="studio:getStateTheme",n.setStateTheme="studio:setStateTheme",n.assetProviderGet="studio:assetProviderGet",n.assetProviderAdd="studio:assetProviderAdd",n.assetProviderRemove="studio:assetProviderRemove",n.fontGet="studio:fontGet",n.fontAdd="studio:fontAdd",n.fontRemove="studio:fontRemove",n.fontManagerOpen="studio:fontManagerOpen",n.menuFontLoad="studio:menuFontLoad",n.toggleStateDataSource="studio:toggleStateDataSource",n.getStateDataSource="studio:getStateDataSource",n.setDragAbsolute="studio:setDragAbsolute",n))(_||{}),ri=(n=>(n.layoutToggleId="studio:layoutToggle:",n.toggleBlocksPanel="studio:toggleBlocksPanel",n.pageSettingsUpdate="studio:pageSettingsUpdate",n.toggleDataSourcesPreview="studio:toggleDataSourcesPreview",n))(ri||{}),ii=(n=>(n.dark="dark",n.light="light",n.auto="auto",n))(ii||{}),li=(n=>(n.web="web",n.email="email",n.document="document",n))(li||{});const ai={[F.free]:0,[F.startup]:10,[F.business]:20,[F.enterprise]:30};function Zd(n){const e=n;return e.init=t=>o=>n(o,t),e}const G=n=>Zd(n);async function W({editor:n,plan:e,pluginName:t,licenseKey:o,cleanup:s}){let r="",i=!1;const l=qd(),a=d=>{console.warn("Cleanup plugin:",t,"Reason:",d),s()},c=(d={})=>{var m;const{error:u,sdkLicense:p}=d,h=(m=d.plan)==null?void 0:m.category;if(!(p||d.license)||u)a(u||"Invalid license");else if(h){const g=ai[e],v=ai[h];g>v&&a({pluginRequiredPlan:e,licensePlan:h})}};n.on(_d,d=>{r=d==null?void 0:d.baseApiUrl,i=!0}),n.on(Gd,d=>{c(d)}),setTimeout(async()=>{if(!i){if(l)return;if(o){const d=await Xd({licenseKey:o,pluginName:t,baseApiUrl:r});d&&c(d)}else a("The `licenseKey` option not provided")}},2e3)}async function Xd(n){const{licenseKey:e,pluginName:t,baseApiUrl:o}=n;try{return(await Yd({baseApiUrl:o,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(s){return console.error("Error during SDK license check:",s),!1}}const eo=(n,e)=>{var t;return!!((t=n==null?void 0:n.hasAttribute)!=null&&t.call(n,e))},ut=(n,e)=>{var t;return!!((t=n==null?void 0:n.classList)!=null&&t.contains(e))},qe=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,ze))===n},ls=(...n)=>e=>n.some(t=>e.is(t)),as=(...n)=>(e,t)=>n.some(o=>t.is(o)),Qd=(n,e={})=>{var r;const t={},o=[],s=[];for(const i in n){const{value:l,...a}=n[i];o.push({id:i,name:i,changeProp:!0,category:e.category,...a}),t[i]=l,!Ud(l)&&s.push(i);const{subTraits:c={}}=a;for(const d in a.subTraits)(r=c[d])==null||r.forEach(u=>{const p=u.id||u.name;t[p]=u.value})}return{propKeys:Object.keys(t),propsNoValues:s,props:t,traits:o}},eu=(n,e)=>{e.forEach(t=>{if(t.subTraits){const o=`${t.id||t.name}`,s=t.changeProp?`change:${o}`:`change:attributes:${o}`;n.on(s,()=>ci(n,o)),ci(n,o)}})},ci=(n,e)=>{const t=n.getTrait(e),o=t.get("category"),s=t.get("subTraits")||{},i=(Object.values(s).flat()||[]).map(c=>c.id||c.name);n.removeTrait(i);const l=s[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:o,...c})),{at:a})},cs=(n,e,t)=>{const{doc:o=document}=t,s=t.target||o.head,r=s.querySelector(`style[${n}]`)||o.createElement("style");r.setAttribute(n,"true"),r.innerHTML=e,!s.contains(r)&&s.appendChild(r)},tu=(n,e)=>{e.forEach(t=>{const o=Kd(t);o!==t&&n.has(o)&&n.set({[t]:n.get(o),[o]:void 0})})},Ae="gjs-plg-",di="data-gs-plg-",ze="data-type-role",ui=(...n)=>n.map(e=>`[data-gjs-type="${e}"]`).join(","),nu="dialogComponent",ou=G(function(n,e={}){const{Blocks:t,Components:o}=n,{licenseKey:s}=e,r="gjs-plg-dialog",i="gjs-plg-dialog-overlay",l="gjs-plg-dialog-content",a="gjs-plg-dialog-close",c="gjs-plg-dialog-title",d="gjs-plg-dialog-body",u="gjs-plg-dialog-description",p="gjs-plg-dialog-placeholder";t.add(r,{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:
|
|
6
|
-
.${
|
|
5
|
+
`,category:"Extra",content:{type:r},activate:!0,...e.block}),o.addType(r,{model:{defaults:{tagName:"div",attributes:{class:r,"data-type-role":r},components:[{type:i},{type:p}],draggable:ui("wrapper"),droppable:ui(r),styles:`
|
|
6
|
+
.${r} {
|
|
7
7
|
position: relative;
|
|
8
8
|
z-index: 1;
|
|
9
9
|
}
|
|
10
|
-
`,traits:[{type:"button",label:"Open dialog",name:"onActive",changeProp:!0,command(f){var m;(m=f.getSelected())==null||m.trigger("active")}},{type:"checkbox",label:"Close when pressing X",name:"closeWhenPressingX",default:!0,changeProp:!0},{type:"checkbox",label:"Close when pressing ESC",name:"closeWhenPressingEsc",default:!0,changeProp:!0},{type:"checkbox",label:"Open when leaving the window",name:"openWhenLeavingWindow",default:!1,changeProp:!0},{type:"number",label:"Open when scrolling to level",name:"openWhenScrollingToLevel",default:0,changeProp:!0}],"script-props":["closeWhenPressingX","closeWhenPressingEsc","openWhenLeavingWindow","openWhenScrollingToLevel"],script:function(f){const m=this;function g(
|
|
11
|
-
.${
|
|
10
|
+
`,traits:[{type:"button",label:"Open dialog",name:"onActive",changeProp:!0,command(f){var m;(m=f.getSelected())==null||m.trigger("active")}},{type:"checkbox",label:"Close when pressing X",name:"closeWhenPressingX",default:!0,changeProp:!0},{type:"checkbox",label:"Close when pressing ESC",name:"closeWhenPressingEsc",default:!0,changeProp:!0},{type:"checkbox",label:"Open when leaving the window",name:"openWhenLeavingWindow",default:!1,changeProp:!0},{type:"number",label:"Open when scrolling to level",name:"openWhenScrollingToLevel",default:0,changeProp:!0}],"script-props":["closeWhenPressingX","closeWhenPressingEsc","openWhenLeavingWindow","openWhenScrollingToLevel"],script:function(f){const m=this;function g(b){const x=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'),S=m.querySelector('[data-type-role="gjs-plg-dialog-close"]');function C(){x.style.display="none"}b?(m._onCloseWhenPressingX=C,S.addEventListener("click",m._onCloseWhenPressingX)):(S.removeEventListener("click",m._onCloseWhenPressingX),m._onCloseWhenPressingX=null)}function v(b){const x=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function S(C){C.key==="Escape"&&(x.style.display="none")}b?(m._onCloseWhenPressingEsc=S,m.addEventListener("keydown",m._onCloseWhenPressingEsc)):(m.removeEventListener("keydown",m._onCloseWhenPressingEsc),m._onCloseWhenPressingEsc=null)}function w(b){const x=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function S(){x.style.display="flex"}b?(m._onOpenWhenLeavingWindow=S,document.addEventListener("mouseleave",m._onOpenWhenLeavingWindow)):(document.removeEventListener("mouseleave",m._onOpenWhenLeavingWindow),m._onOpenWhenLeavingWindow=null)}function y(b){const x=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function S(){const C=document.documentElement.scrollTop;b&&C>=Number(b)&&(x.style.display="flex")}b?(m._onOpenWhenScrollingToLevel=S,document.addEventListener("scroll",m._onOpenWhenScrollingToLevel)):(document.removeEventListener("scroll",m._onOpenWhenScrollingToLevel),m._onOpenWhenScrollingToLevel=null)}g(f.closeWhenPressingX),v(f.closeWhenPressingEsc),w(f.openWhenLeavingWindow),y(f.openWhenScrollingToLevel)}},init(){this.on("active",this.handleOpenWhenClickPlaceholder)},handleOpenWhenClickPlaceholder(){this.view.el.querySelector('[data-type-role="gjs-plg-dialog-placeholder"]').addEventListener("click",()=>{const m=this.view.el.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');m.style.display="flex"})}},view:{onActive(){const f=this.el.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');f.style.display="flex"}}}),o.addType(i,{model:{defaults:{tagName:"div",attributes:{class:i,"data-type-role":i},components:{type:l},droppable:!1,draggable:!1,styles:`
|
|
11
|
+
.${i} {
|
|
12
12
|
position: fixed;
|
|
13
13
|
top: 0;
|
|
14
14
|
left: 0;
|
|
@@ -56,24 +56,24 @@
|
|
|
56
56
|
.${u} {
|
|
57
57
|
margin: 0;
|
|
58
58
|
}
|
|
59
|
-
`}}}),o.addType(
|
|
59
|
+
`}}}),o.addType(p,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:p,"data-type-role":p},components:"Dialog (click me to open)",droppable:!1,draggable:!1}},view:{init(){const{em:f,el:m}=this,g="core:preview",v=f.Commands.events;this.listenTo(f,`${v.runCommand}${g}`,()=>{m.style.display="none"}),this.listenTo(f,`${v.stopCommand}${g}`,()=>{m.style.display=""})}}}),W({editor:n,licenseKey:s,plan:F.startup,pluginName:nu,cleanup:()=>{t.remove(r),o.removeType(r)}})}),su="iconifyComponent",ru=F.startup,iu={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},ds=`<svg viewBox="0 0 24 24">
|
|
60
60
|
<path d="M19 0H9C7.9 0 7 .9 7 2V18C7 19.1 7.9 20 9 20H19C20.1 20 21 19.1 21 18V2C21 .9 20.1 0 19 0M19 18H9V2H19V18M3 4V22C3 23.1 3.9 24 5 24H17V22H5V4H3M14 5L11 10L14 15L17 10L14 5Z" />
|
|
61
|
-
</svg>`,sr="layout-icon-picker",Xd="icons-layout-",ir="icons-list-layout",rr="gs-iconify-picker",rs="__iconify_collection",Qd="https://api.iconify.design",ls=new Map;let eo;const eu=({collectionId:n})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${n}@latest/icons.json`;async function lr({collectionId:n,editor:e}){try{if(ls.has(n))return ls.get(n);const t=await fetch(eu({collectionId:n}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const o=await t.json();return ls.set(n,o),o}catch(t){console.error("Error fetching collection",t),e.runCommand(_.toastAdd,au());return}}async function tu({collectionIds:n,editor:e}){try{if(eo)return eo;const t=n?`?prefixes=${n.join(",")}`:"",o=await fetch(`${Qd}/collections${t}`);if(!o.ok)throw new Error(`Failed to fetch collections: ${o.statusText}`);return eo=await o.json(),eo}catch(t){console.error("Error fetching collections",t),e.runCommand(_.toastAdd,cr());return}}function ar(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(n){var e;(e=n.getSelected())==null||e.trigger("active")}}}async function nu({collectionIds:n,editor:e,component:t}){const o=await tu({collectionIds:n,editor:e});if(!o)return;const s=({icon:a,collectionId:c,iconId:d})=>{t.components(a),t.set({collectionId:c,iconId:d})},i=Object.entries(o).map(([a,c])=>({id:a,...c})).sort((a,c)=>a.name.localeCompare(c.name)),r=t.get("collectionId")??i[0].id;e.runCommand(_.layoutToggle,{id:sr,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[iu({collectionsList:i,collectionId:r,editor:e,handleClick:s}),{id:ir,type:"column",grow:!0}]}});const l=await lr({collectionId:r,editor:e});l&&as({editor:e,collection:l,handleClick:s,collectionId:r})}function ou({editor:n,collection:e}){n.em.set(rs,e)}function su(n){return n.em.get(rs)}function as(n){const{editor:e}=n,t={id:Xd,layout:ru(n),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:ir}};e.runCommand(_.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>e.runCommand(_.layoutAdd,t),10)}function iu(n){const{collectionsList:e,collectionId:t,editor:o,handleClick:s}=n,i=e.map(({id:r,name:l,total:a})=>({id:r,label:`${l} (${a})`})).sort((r,l)=>r.label.localeCompare(l.label));return{type:"column",style:{gap:10},className:`${rr}__header`,children:[{type:"selectField",value:t,options:i,emptyState:"Select an icon collection",onChange:async({setState:r,value:l})=>{const a=await lr({collectionId:l,editor:o});a&&(r({value:l}),ou({editor:o,collection:a}),as({editor:o,collection:a,handleClick:s,collectionId:l}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${rs}`]:({setState:r})=>r({value:""})},onInput:({setState:r,value:l,editor:a})=>{const c=su(a);if(!c)return;const d=Object.fromEntries(Object.entries(c.icons).filter(([u])=>u.includes(l)));r({value:l}),as({editor:a,collection:c,handleClick:s,collectionId:l,collectionFiltered:{...c,icons:d}})}}]}}function ru({collection:n,collectionFiltered:e,handleClick:t}){const{height:o=24,width:s=24,icons:i,prefix:r}=e||n,l=Object.entries(i).map(([a,{body:c}])=>({name:a,body:c}),{});return{type:"column",className:`${rr}__content`,style:{height:"100%"},children:{type:"virtualList",items:l,itemLayout:({item:a})=>[{type:"custom",render:c=>{const{editor:d,addEl:u,removeEl:h}=c,p=document.createElementNS("http://www.w3.org/2000/svg","svg");p.setAttribute("xmlns","http://www.w3.org/2000/svg"),p.innerHTML=a.body,p.setAttribute("viewBox",`0 0 ${s} ${o}`);const{cssWidth:f,cssHeight:m}=lu(s,o);p.style.cssText=`width: ${f}px; height: ${m}px; cursor: pointer;`,p.addEventListener("mouseover",()=>{p.style.border="2px solid currentColor",p.style.borderRadius="4px",p.style.padding="4px"}),p.addEventListener("mouseout",()=>{p.style.border="none"});const g=()=>{const b=p.cloneNode(!0);b.removeAttribute("style");const w=b.outerHTML;t({icon:w,collectionId:r,iconId:a.name}),d==null||d.runCommand(_.layoutRemove,{id:sr})};return p.addEventListener("click",g),u(p),()=>{p.removeEventListener("click",g),h(p)}}}]}}}function lu(n,e){const t=n/e;let o=48,s=48;return t>1?s=48/t:t<1&&(o=48*t),{cssWidth:o,cssHeight:s}}function cr(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:Ji.Error}}function au(){return{...cr(),id:"toast-error-getCollection",content:"Error fetching collection"}}const cu=G(function(n,e={}){var p;const{Components:t,Blocks:o}=n,{collections:s,extendIconComponent:i=!0,licenseKey:r,block:l={}}=e,a="icon",c="iconify",d="Iconify",u="data-type-iconify",h={events:()=>({dblclick:"onActive"}),onActive(){nu({collectionIds:s,editor:n,component:this.model})}};if(t.addType(c,{block:l&&{label:d,media:is,content:{type:c},category:"Extra",activate:!0,...l},isComponent:f=>Qn(f,u),model:{defaults:{name:d,icon:is,droppable:!1,attributes:{[u]:!0},resizable:Zd,components:is,style:{width:"50px",height:"50px"},traits:[ar()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(f=>f.set({layerable:!1,locked:!0}))}},view:h}),i){const f=(p=t.getType(a))==null?void 0:p.model,[m,g,...b]=f.getDefaults().traits;t.addType(a,{model:{defaults:{traits:[m,g,ar(),...b]}},view:h})}W({editor:n,licenseKey:r,plan:Yd,pluginName:Jd,cleanup:()=>{o.remove(c),t.removeType(c)}})});function cs(n,e,t){let o,s,i,r,l;const a=e===void 0?100:e;function c(){const u=Date.now()-r;u<a&&u>=0?o=setTimeout(c,a-u):(o=null,l=n.apply(i,s),i=s=null)}const d=function(){return i=this,s=arguments,r=Date.now(),o||(o=setTimeout(c,a)),l};return d.clear=function(){o&&(clearTimeout(o),o=null)},d.flush=function(){o&&(l=n.apply(i,s),i=s=null,clearTimeout(o),o=null)},d}const du="tableComponent",uu=F.startup;var P=(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))(P||{});const V={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>'},Ee="table",dr="thead",ur="tfoot",ds="tbody",ue="row",j="cell",us="clipboardTable",hu=[Ee,dr,ur,ds,ue,j],to=n=>n.em.get(us)||[],pu=n=>n.every(e=>e.is(j)),hs=(n,e)=>{const{editor:t,event:o,opts:s}=n,i=o.currentTarget||o.target,{x:r,y:l,width:a,height:c}=i.getBoundingClientRect(),d={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:r,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};zt(s.openSettings)?s.openSettings({...n,layoutProps:d}):t.runCommand(_.layoutToggle,d)},fu=(n,{rows:e=1,cells:t=5,text:o}={})=>({type:n,components:Array.from(Array(e).keys()).map(s=>({type:ue,components:Array.from(Array(t).keys()).map(i=>({type:j,components:o?{type:"text",content:zt(o)?o({y:s,x:i}):o}:void 0}))}))}),hr="Table settings",pr=n=>{const{component:e}=n;return e.is(Ee)?e:e.closestType(Ee)},mu=n=>{var e;(e=pr(n))==null||e.remove(n.opts)},gu=n=>{const e=pr(n);e&&(n.editor.select(e),hs(n,{id:"tableSettings",header:{label:hr}}))},fr=n=>[{id:P.table,icon:V[P.table],label:"Table",items:[{id:P.tableSettings,label:hr,icon:V[P.tableSettings],onClick:({event:t})=>gu({...n,event:t})},{id:P.tableDelete,label:"Delete table",icon:V[P.tableDelete],onClick:()=>mu(n)}]}],mr=({editor:n})=>{const e=to(n);return e.length&&pu(e)},gr=({component:n,editor:e,after:t})=>{if(!n.is(j))return;const o=n.closestType(Ee),s=n.closestType(ue),i=n.index()+(t?1:0);o==null||o.findType(ue).forEach(l=>l.append({type:j},{at:i}));const r=s==null?void 0:s.components().at(i);r&&e.select(r)},yr=({component:n,opts:e})=>{if(!n.is(j))return;const t=n.closestType(Ee),o=n.index();t==null||t.findType(ue).forEach(s=>{var i;return(i=s.components().at(o))==null?void 0:i.remove(e)})},br=({component:n,editor:e})=>{if(!n.is(j))return;const t=n.closestType(Ee),o=n.index(),s=(t==null?void 0:t.findType(ue).map(i=>i.components().at(o)))||[];s.length&&e.em.set(us,s)},vr=n=>{const{component:e,editor:t,after:o}=n;if(!e.is(j)||!mr(n))return;const s=to(t),i=e.closestType(Ee),r=e.index()+(o?1:0);i==null||i.findType(ue).forEach((l,a)=>{const c=s[a],d=(c==null?void 0:c.clone())||{type:j};l.append(d,{at:r})})},yu=n=>{const{component:e}=n;e.is(j)&&(br(n),yr({...n,opts:{temporary:!0}}))},bu=n=>{const e=mr(n);return[{id:P.tableColumnItems,icon:V[P.tableColumn],label:"Column",items:[{id:P.tableColumnInsertBefore,label:"Insert column before",icon:V[P.tableColumnInsertBefore],onClick:()=>gr(n)},{id:P.tableColumnInsertAfter,label:"Insert column after",icon:V[P.tableColumnInsertAfter],onClick:()=>gr({...n,after:!0})},{id:P.tableColumnDelete,label:"Delete column",icon:V[P.tableColumnDelete],onClick:()=>yr(n)},{id:P.tableColumnCut,label:"Cut column",icon:V[P.tableColumnCut],onClick:()=>yu(n)},{id:P.tableColumnCopy,label:"Copy column",icon:V[P.tableColumnCopy],onClick:()=>br(n)},{id:P.tableColumnPasteBefore,label:"Paste column before",icon:V[P.tableColumnPasteBefore],disabled:!e,onClick:()=>vr(n)},{id:P.tableColumnPasteAfter,label:"Paste column after",icon:V[P.tableColumnPasteAfter],disabled:!e,onClick:()=>vr({...n,after:!0})}]}]},xr="Row settings",vu=n=>n.every(e=>e.is(ue)),Vt=n=>{const{component:e}=n,t=e.is(j),o=e.is(ue);if(!(!t&&!o))return o?e:e.closestType(ue)},Sr=n=>{const{component:e,editor:t,after:o}=n,s=Vt(n);if(!s)return;const i=s.index()+(o?1:0),r=s.components().length,l=Array.from(Array(r).keys()).map(()=>({type:j})),a=s.parent();if(a){const c=a.append({type:ue,components:l},{at:i})[0];if(e.is(j)&&c){const d=e.index(),u=c.components().at(d);u&&t.select(u)}}},wr=n=>{var e;(e=Vt(n))==null||e.remove(n.opts)},Cr=n=>{const e=Vt(n);e&&n.editor.em.set(us,[e])},kr=n=>{var l;const{editor:e,after:t}=n,o=Vt(n);if(!o||!Tr(n))return;const i=to(e)[0],r=o.index()+(t?1:0);i&&((l=o.parent())==null||l.append(i.clone(),{at:r}))},xu=n=>{Vt(n)&&(Cr(n),wr({...n,opts:{temporary:!0}}))},Tr=({editor:n})=>{const e=to(n);return e.length&&vu(e)},Su=n=>{const e=Vt(n);e&&(n.editor.select(e),hs(n,{id:"tableRowSettings",header:{label:xr}}))},Mr=n=>{const e=Tr(n);return[{id:P.tableRowItems,icon:V[P.tableRowProperties],label:"Row",items:[{id:P.tableRowInsertBefore,label:"Insert row before",icon:V[P.tableRowInsertBefore],onClick:()=>Sr(n)},{id:P.tableRowInsertAfter,label:"Insert row after",icon:V[P.tableRowInsertAfter],onClick:()=>Sr({...n,after:!0})},{id:P.tableRowDelete,label:"Delete row",icon:V[P.tableRowDelete],onClick:()=>wr(n)},{id:P.tableRowProperties,label:xr,icon:V[P.tableRowProperties],onClick:({event:o})=>Su({...n,event:o})},{id:P.tableRowCut,label:"Cut row",icon:V[P.tableRowCut],onClick:()=>xu(n)},{id:P.tableRowCopy,label:"Copy row",icon:V[P.tableRowCopy],onClick:()=>Cr(n)},{id:P.tableRowPasteBefore,label:"Paste row before",icon:V[P.tableRowPasteBefore],disabled:!e,onClick:()=>kr(n)},{id:P.tableRowPasteAfter,label:"Paste row after",icon:V[P.tableRowPasteAfter],disabled:!e,onClick:()=>kr({...n,after:!0})}]},...fr(n)]},ps=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),o=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:o}};function Ar(n){const e=[];return n.components().forEach((t,o)=>{t.components().each((s,i)=>{const{rowspan:r,colspan:l}=ps(s);if(e[o])for(;e[o][i];)i++;for(let a=o;a<o+r;a++){e[a]||(e[a]=[]);for(let c=i;c<i+l;c++)e[a][c]={real:a===o&&c===i,cell:s,rowspan:r,colspan:l}}})}),e}function $t(n,e,t){var o;return(o=n[t])==null?void 0:o[e]}const fs=n=>n.closestType(ue);function wu(n,{x:e,y:t,rows:o,cols:s}){var l;let i=fs(n[t][e].cell),r;for(let a=1;a<=o;a++)if(i=(l=i==null?void 0:i.parent())==null?void 0:l.components().at(i.index()+1),i){for(r=e;r>=0;r--){const{cell:c}=n[t+a][r],d=fs(c);if(d===i){for(let u=1;u<=s;u++){const h=c.index();d.append({type:j},{at:h+1})}break}}if(r===-1){const d=i.components().at(0).index();for(let u=1;u<=s;u++)i.append({type:j},{at:d})}}}function Er(n){for(let e=0;e<n.length;e++)for(let t=0;t<n[e].length;t++){const s=n[e][t].cell;if(s.em.selected.hasComponent(s)){const{rowspan:i,colspan:r}=ps(s);if(r>1||i>1){s.addAttributes({colspan:1,rowspan:1});for(let l=0;l<r-1;l++){const a=s.index();fs(s).append({type:j},{at:a+1})}wu(n,{x:t,y:e,rows:i-1,cols:r})}}}}function Cu(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const no=(n,e={})=>{var r;const t=Ar(n),{em:o}=n;let s,i;for(let l=0;l<t.length;l++)for(let a=0;a<t[l].length;a++){const c=t[l][a];if((r=e.selected)!=null&&r.includes(c.cell)||o.selected.hasComponent(c.cell)){const d={x:a,y:l};s||(s=d),i=d}}return{grid:t,startPos:s,endPos:i}};function ku(n,e={}){const t=no(n),{startPos:o,endPos:s}=t;let{grid:i}=t;const{em:r}=n;if(!o||!s)return;const l=o.x,a=o.y,c=s.x,d=s.y,u=$t(i,l,a),h=$t(i,c,d);if(u&&h){Er(i),i=Ar(n);const p=[],f=$t(i,l,a).cell;f.addAttributes({colspan:c-l+1,rowspan:d-a+1});for(let m=a;m<=d;m++)for(let g=l;g<=c;g++){const b=$t(i,g,m);if(!b)continue;const{cell:w}=b;w!==f&&p.push(w)}p.forEach(m=>{e.mergeContent&&f.append(m.components().models),m.remove()}),r.setSelected(f),Cu(n)}}const Nr="Cell settings",Tu="Merge cells",Mu="Split cell",Au=n=>n.closestType(ue),Bt=n=>{var e;return(e=Au(n))==null?void 0:e.parent()},Eu=n=>{const e=n.editor.getSelectedAll(),t=Bt(e[0]),o=e[0];if(!t||!(o!=null&&o.is(j))||e.length>1)return!1;const{rowspan:s,colspan:i}=ps(o);return!(i<2&&s<2)},Nu=n=>{const t=n.editor.getSelectedAll()[0],o=Bt(t),{grid:s}=no(o);Er(s)},Or=n=>{const e=n.editor.getSelectedAll(),t=Bt(e[0]);if(!t||e.length<2||e.some(l=>!l.is(j)||Bt(l)!==t))return!1;const{grid:o,startPos:s,endPos:i}=no(t),{em:r}=t;if(!s||!i)return!1;for(let l=s.y;l<=i.y;l++)for(let a=s.x;a<=i.x;a++){const c=$t(o,a,l);if(!c||!r.selected.hasComponent(c.cell))return!1}return!0},Ou=n=>{const{editor:e}=n;if(!Or(n))return;const t=e.getSelectedAll(),o=Bt(t[0]);ku(o,{mergeContent:!0})},Pu=n=>{hs(n,{id:"tableCellSettings",header:{label:Nr}})},Iu=n=>[{id:P.tableCellItems,icon:V[P.tableCellProperties],label:"Cell",items:[{id:P.tableCellProperties,label:Nr,icon:V[P.tableCellProperties],onClick:({event:t})=>Pu({...n,event:t})},{id:P.tableCellMerge,label:Tu,icon:V[P.tableCellMerge],onClick:()=>Ou(n),disabled:!Or(n)},{id:P.tableCellSplit,label:Mu,icon:V[P.tableCellSplit],onClick:()=>Nu(n),disabled:!Eu(n)}]},...bu(n),...Mr(n)],Ru=n=>{const e=n[0]&&Bt(n[0]);if(!e)return;const{grid:t,startPos:o,endPos:s}=no(e,{selected:n});if(!o||!s)return;const i=[];for(let r=o.y;r<=s.y;r++)for(let l=o.x;l<=s.x;l++){const a=$t(t,l,r);a&&i.push(a.cell)}i.length&&e.em.setSelected(i,{fromCell:!0})},Du=G(function(n,e={}){const t={block:{},...e},{Components:o}=n,s={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"]};o.addType(Ee,{block:t.block&&{label:"Table",media:V.table,category:"Extra",content:{type:Ee,style:{width:"100%"}},select:!0,...t.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:V.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:r,value:l,emitUpdate:a}){const c=r.find("caption")[0];l?!c&&r.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):c==null||c.remove(),a(),n.refresh({tools:!0})},getValue(r){return!!r.component.find("caption")[0]}}],components:fu(ds,{rows:5}),contextMenu:({items:r,editor:l,component:a})=>[...fr({editor:l,component:a,opts:t}),...r]}}}),o.addType(dr,{model:{defaults:{icon:V.tableHead,...s}}}),o.addType(ur,{model:{defaults:{icon:V.tableFoot,...s}}}),o.addType(ds,{model:{defaults:{icon:V.tableRowProperties,...s}}}),o.addType(ue,{model:{defaults:{icon:V.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:r,editor:l,component:a})=>[...Mr({editor:l,component:a,opts:t}),...r]}}}),o.addType(j,{model:{defaults:{icon:V.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","background","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:r,editor:l,component:a})=>[...Iu({editor:l,component:a,opts:t}),...r]}}});const i=cs((r,l)=>{var u;const a=n.getSelectedAll(),c=!!((u=l==null?void 0:l.event)!=null&&u.shiftKey);if(a.length<2||!c||l.fromCell)return;const d=a.map(h=>h.is(j)?h:h.closestType(j)).filter(Boolean);d.length===a.length&&Ru(d)},0);n.on("component:select",i),W({editor:n,plan:uu,pluginName:du,licenseKey:t.licenseKey,cleanup:()=>{n.off("component:select",i),n.Blocks.remove(Ee),hu.forEach(r=>o.removeType(r))}})}),Lu="listPagesComponent",zu=F.startup,Pr="page://",ht="list-pages",Ht="list-pages-item",pt="list-pages-link",Vu=n=>n.components().reduce((e,t)=>{var r;const o=t.findFirstType(pt),s=(r=o==null?void 0:o.attributes.attributes)==null?void 0:r.href,i=s!=null&&s.startsWith(Pr)?s.replace(Pr,""):"";if(i&&o){const l=e[i];l?l.push(o):e[i]=[o]}return e},{}),oo="data-type-role",$u="page_root",Bu=n=>e=>e.is(n),Hu=n=>(e,t)=>t.is(n),ms=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,oo))===n},Fu=G(function(n,e={}){const{Blocks:t,Components:o,Pages:s}=n,{licenseKey:i,block:r={}}=e,l="List Pages",a="List Pages Item",c="Link",d=`${Le}${ht}`,u=`${Le}${pt}`,h='<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>';o.addType(ht,{block:r&&{label:l,media:h,category:"Extra",select:!0,...e.block},isComponent:ms(ht),model:{defaults:{tagName:"ul",name:l,[$u]:"",classes:d,attributes:{[oo]:ht,role:"navigation"},droppable:Bu(Ht),styles:`
|
|
61
|
+
</svg>`,pi="layout-icon-picker",lu="icons-layout-",hi="icons-list-layout",fi="gs-iconify-picker",us="__iconify_collection",au="https://api.iconify.design",ps=new Map;let to;const cu=({collectionId:n})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${n}@latest/icons.json`;async function mi({collectionId:n,editor:e}){try{if(ps.has(n))return ps.get(n);const t=await fetch(cu({collectionId:n}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const o=await t.json();return ps.set(n,o),o}catch(t){console.error("Error fetching collection",t),e.runCommand(_.toastAdd,yu());return}}async function du({collectionIds:n,editor:e}){try{if(to)return to;const t=n?`?prefixes=${n.join(",")}`:"",o=await fetch(`${au}/collections${t}`);if(!o.ok)throw new Error(`Failed to fetch collections: ${o.statusText}`);return to=await o.json(),to}catch(t){console.error("Error fetching collections",t),e.runCommand(_.toastAdd,yi());return}}function gi(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(n){var e;(e=n.getSelected())==null||e.trigger("active")}}}async function uu({collectionIds:n,editor:e,component:t}){const o=await du({collectionIds:n,editor:e});if(!o)return;const s=({icon:a,collectionId:c,iconId:d})=>{t.components(a),t.set({collectionId:c,iconId:d})},r=Object.entries(o).map(([a,c])=>({id:a,...c})).sort((a,c)=>a.name.localeCompare(c.name)),i=t.get("collectionId")??r[0].id;e.runCommand(_.layoutToggle,{id:pi,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[fu({collectionsList:r,collectionId:i,editor:e,handleClick:s}),{id:hi,type:"column",grow:!0}]}});const l=await mi({collectionId:i,editor:e});l&&hs({editor:e,collection:l,handleClick:s,collectionId:i})}function pu({editor:n,collection:e}){n.em.set(us,e)}function hu(n){return n.em.get(us)}function hs(n){const{editor:e}=n,t={id:lu,layout:mu(n),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:hi}};e.runCommand(_.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>e.runCommand(_.layoutAdd,t),10)}function fu(n){const{collectionsList:e,collectionId:t,editor:o,handleClick:s}=n,r=e.map(({id:i,name:l,total:a})=>({id:i,label:`${l} (${a})`})).sort((i,l)=>i.label.localeCompare(l.label));return{type:"column",style:{gap:10},className:`${fi}__header`,children:[{type:"selectField",value:t,options:r,emptyState:"Select an icon collection",onChange:async({setState:i,value:l})=>{const a=await mi({collectionId:l,editor:o});a&&(i({value:l}),pu({editor:o,collection:a}),hs({editor:o,collection:a,handleClick:s,collectionId:l}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${us}`]:({setState:i})=>i({value:""})},onInput:({setState:i,value:l,editor:a})=>{const c=hu(a);if(!c)return;const d=Object.fromEntries(Object.entries(c.icons).filter(([u])=>u.includes(l)));i({value:l}),hs({editor:a,collection:c,handleClick:s,collectionId:l,collectionFiltered:{...c,icons:d}})}}]}}function mu({collection:n,collectionFiltered:e,handleClick:t}){const{height:o=24,width:s=24,icons:r,prefix:i}=e||n,l=Object.entries(r).map(([a,{body:c}])=>({name:a,body:c}),{});return{type:"column",className:`${fi}__content`,style:{height:"100%"},children:{type:"virtualList",items:l,itemLayout:({item:a})=>[{type:"custom",render:c=>{const{editor:d,addEl:u,removeEl:p}=c,h=document.createElementNS("http://www.w3.org/2000/svg","svg");h.setAttribute("xmlns","http://www.w3.org/2000/svg"),h.innerHTML=a.body,h.setAttribute("viewBox",`0 0 ${s} ${o}`);const{cssWidth:f,cssHeight:m}=gu(s,o);h.style.cssText=`width: ${f}px; height: ${m}px; cursor: pointer;`,h.addEventListener("mouseover",()=>{h.style.border="2px solid currentColor",h.style.borderRadius="4px",h.style.padding="4px"}),h.addEventListener("mouseout",()=>{h.style.border="none"});const g=()=>{const v=h.cloneNode(!0);v.removeAttribute("style");const w=v.outerHTML;t({icon:w,collectionId:i,iconId:a.name}),d==null||d.runCommand(_.layoutRemove,{id:pi})};return h.addEventListener("click",g),u(h),()=>{h.removeEventListener("click",g),p(h)}}}]}}}function gu(n,e){const t=n/e;let o=48,s=48;return t>1?s=48/t:t<1&&(o=48*t),{cssWidth:o,cssHeight:s}}function yi(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:si.Error}}function yu(){return{...yi(),id:"toast-error-getCollection",content:"Error fetching collection"}}const bu=G(function(n,e={}){var h;const{Components:t,Blocks:o}=n,{collections:s,extendIconComponent:r=!0,licenseKey:i,block:l={}}=e,a="icon",c="iconify",d="Iconify",u="data-type-iconify",p={events:()=>({dblclick:"onActive"}),onActive(){uu({collectionIds:s,editor:n,component:this.model})}};if(t.addType(c,{block:l&&{label:d,media:ds,content:{type:c},category:"Extra",activate:!0,...l},isComponent:f=>eo(f,u),model:{defaults:{name:d,icon:ds,droppable:!1,attributes:{[u]:!0},resizable:iu,components:ds,style:{width:"50px",height:"50px"},traits:[gi()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(f=>f.set({layerable:!1,locked:!0}))}},view:p}),r){const f=(h=t.getType(a))==null?void 0:h.model,[m,g,...v]=f.getDefaults().traits;t.addType(a,{model:{defaults:{traits:[m,g,gi(),...v]}},view:p})}W({editor:n,licenseKey:i,plan:ru,pluginName:su,cleanup:()=>{o.remove(c),t.removeType(c)}})});function no(n,e,t){let o,s,r,i,l;const a=e===void 0?100:e;function c(){const u=Date.now()-i;u<a&&u>=0?o=setTimeout(c,a-u):(o=null,l=n.apply(r,s),r=s=null)}const d=function(){return r=this,s=arguments,i=Date.now(),o||(o=setTimeout(c,a)),l};return d.clear=function(){o&&(clearTimeout(o),o=null)},d.flush=function(){o&&(l=n.apply(r,s),r=s=null,clearTimeout(o),o=null)},d}const vu="tableComponent",xu=F.startup;var O=(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))(O||{});const $={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>'},Pe="table",bi="thead",vi="tfoot",fs="tbody",ue="row",j="cell",ms="clipboardTable",Su=[Pe,bi,vi,fs,ue,j],oo=n=>n.em.get(ms)||[],wu=n=>n.every(e=>e.is(j)),gs=(n,e)=>{const{editor:t,event:o,opts:s}=n,r=o.currentTarget||o.target,{x:i,y:l,width:a,height:c}=r.getBoundingClientRect(),d={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:i,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};$t(s.openSettings)?s.openSettings({...n,layoutProps:d}):t.runCommand(_.layoutToggle,d)},Cu=(n,{rows:e=1,cells:t=5,text:o}={})=>({type:n,components:Array.from(Array(e).keys()).map(s=>({type:ue,components:Array.from(Array(t).keys()).map(r=>({type:j,components:o?{type:"text",content:$t(o)?o({y:s,x:r}):o}:void 0}))}))}),xi="Table settings",Si=n=>{const{component:e}=n;return e.is(Pe)?e:e.closestType(Pe)},ku=n=>{var e;(e=Si(n))==null||e.remove(n.opts)},Tu=n=>{const e=Si(n);e&&(n.editor.select(e),gs(n,{id:"tableSettings",header:{label:xi}}))},wi=n=>[{id:O.table,icon:$[O.table],label:"Table",items:[{id:O.tableSettings,label:xi,icon:$[O.tableSettings],onClick:({event:t})=>Tu({...n,event:t})},{id:O.tableDelete,label:"Delete table",icon:$[O.tableDelete],onClick:()=>ku(n)}]}],Ci=({editor:n})=>{const e=oo(n);return e.length&&wu(e)},ki=({component:n,editor:e,after:t})=>{if(!n.is(j))return;const o=n.closestType(Pe),s=n.closestType(ue),r=n.index()+(t?1:0);o==null||o.findType(ue).forEach(l=>l.append({type:j},{at:r}));const i=s==null?void 0:s.components().at(r);i&&e.select(i)},Ti=({component:n,opts:e})=>{if(!n.is(j))return;const t=n.closestType(Pe),o=n.index();t==null||t.findType(ue).forEach(s=>{var r;return(r=s.components().at(o))==null?void 0:r.remove(e)})},Mi=({component:n,editor:e})=>{if(!n.is(j))return;const t=n.closestType(Pe),o=n.index(),s=(t==null?void 0:t.findType(ue).map(r=>r.components().at(o)))||[];s.length&&e.em.set(ms,s)},Ei=n=>{const{component:e,editor:t,after:o}=n;if(!e.is(j)||!Ci(n))return;const s=oo(t),r=e.closestType(Pe),i=e.index()+(o?1:0);r==null||r.findType(ue).forEach((l,a)=>{const c=s[a],d=(c==null?void 0:c.clone())||{type:j};l.append(d,{at:i})})},Mu=n=>{const{component:e}=n;e.is(j)&&(Mi(n),Ti({...n,opts:{temporary:!0}}))},Eu=n=>{const e=Ci(n);return[{id:O.tableColumnItems,icon:$[O.tableColumn],label:"Column",items:[{id:O.tableColumnInsertBefore,label:"Insert column before",icon:$[O.tableColumnInsertBefore],onClick:()=>ki(n)},{id:O.tableColumnInsertAfter,label:"Insert column after",icon:$[O.tableColumnInsertAfter],onClick:()=>ki({...n,after:!0})},{id:O.tableColumnDelete,label:"Delete column",icon:$[O.tableColumnDelete],onClick:()=>Ti(n)},{id:O.tableColumnCut,label:"Cut column",icon:$[O.tableColumnCut],onClick:()=>Mu(n)},{id:O.tableColumnCopy,label:"Copy column",icon:$[O.tableColumnCopy],onClick:()=>Mi(n)},{id:O.tableColumnPasteBefore,label:"Paste column before",icon:$[O.tableColumnPasteBefore],disabled:!e,onClick:()=>Ei(n)},{id:O.tableColumnPasteAfter,label:"Paste column after",icon:$[O.tableColumnPasteAfter],disabled:!e,onClick:()=>Ei({...n,after:!0})}]}]},Ai="Row settings",Au=n=>n.every(e=>e.is(ue)),Vt=n=>{const{component:e}=n,t=e.is(j),o=e.is(ue);if(!(!t&&!o))return o?e:e.closestType(ue)},Pi=n=>{const{component:e,editor:t,after:o}=n,s=Vt(n);if(!s)return;const r=s.index()+(o?1:0),i=s.components().length,l=Array.from(Array(i).keys()).map(()=>({type:j})),a=s.parent();if(a){const c=a.append({type:ue,components:l},{at:r})[0];if(e.is(j)&&c){const d=e.index(),u=c.components().at(d);u&&t.select(u)}}},Ni=n=>{var e;(e=Vt(n))==null||e.remove(n.opts)},Oi=n=>{const e=Vt(n);e&&n.editor.em.set(ms,[e])},Ii=n=>{var l;const{editor:e,after:t}=n,o=Vt(n);if(!o||!Ri(n))return;const r=oo(e)[0],i=o.index()+(t?1:0);r&&((l=o.parent())==null||l.append(r.clone(),{at:i}))},Pu=n=>{Vt(n)&&(Oi(n),Ni({...n,opts:{temporary:!0}}))},Ri=({editor:n})=>{const e=oo(n);return e.length&&Au(e)},Nu=n=>{const e=Vt(n);e&&(n.editor.select(e),gs(n,{id:"tableRowSettings",header:{label:Ai}}))},Di=n=>{const e=Ri(n);return[{id:O.tableRowItems,icon:$[O.tableRowProperties],label:"Row",items:[{id:O.tableRowInsertBefore,label:"Insert row before",icon:$[O.tableRowInsertBefore],onClick:()=>Pi(n)},{id:O.tableRowInsertAfter,label:"Insert row after",icon:$[O.tableRowInsertAfter],onClick:()=>Pi({...n,after:!0})},{id:O.tableRowDelete,label:"Delete row",icon:$[O.tableRowDelete],onClick:()=>Ni(n)},{id:O.tableRowProperties,label:Ai,icon:$[O.tableRowProperties],onClick:({event:o})=>Nu({...n,event:o})},{id:O.tableRowCut,label:"Cut row",icon:$[O.tableRowCut],onClick:()=>Pu(n)},{id:O.tableRowCopy,label:"Copy row",icon:$[O.tableRowCopy],onClick:()=>Oi(n)},{id:O.tableRowPasteBefore,label:"Paste row before",icon:$[O.tableRowPasteBefore],disabled:!e,onClick:()=>Ii(n)},{id:O.tableRowPasteAfter,label:"Paste row after",icon:$[O.tableRowPasteAfter],disabled:!e,onClick:()=>Ii({...n,after:!0})}]},...wi(n)]},ys=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),o=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:o}};function Li(n){const e=[];return n.components().forEach((t,o)=>{t.components().each((s,r)=>{const{rowspan:i,colspan:l}=ys(s);if(e[o])for(;e[o][r];)r++;for(let a=o;a<o+i;a++){e[a]||(e[a]=[]);for(let c=r;c<r+l;c++)e[a][c]={real:a===o&&c===r,cell:s,rowspan:i,colspan:l}}})}),e}function Bt(n,e,t){var o;return(o=n[t])==null?void 0:o[e]}const bs=n=>n.closestType(ue);function Ou(n,{x:e,y:t,rows:o,cols:s}){var l;let r=bs(n[t][e].cell),i;for(let a=1;a<=o;a++)if(r=(l=r==null?void 0:r.parent())==null?void 0:l.components().at(r.index()+1),r){for(i=e;i>=0;i--){const{cell:c}=n[t+a][i],d=bs(c);if(d===r){for(let u=1;u<=s;u++){const p=c.index();d.append({type:j},{at:p+1})}break}}if(i===-1){const d=r.components().at(0).index();for(let u=1;u<=s;u++)r.append({type:j},{at:d})}}}function zi(n){for(let e=0;e<n.length;e++)for(let t=0;t<n[e].length;t++){const s=n[e][t].cell;if(s.em.selected.hasComponent(s)){const{rowspan:r,colspan:i}=ys(s);if(i>1||r>1){s.addAttributes({colspan:1,rowspan:1});for(let l=0;l<i-1;l++){const a=s.index();bs(s).append({type:j},{at:a+1})}Ou(n,{x:t,y:e,rows:r-1,cols:i})}}}}function Iu(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const so=(n,e={})=>{var i;const t=Li(n),{em:o}=n;let s,r;for(let l=0;l<t.length;l++)for(let a=0;a<t[l].length;a++){const c=t[l][a];if((i=e.selected)!=null&&i.includes(c.cell)||o.selected.hasComponent(c.cell)){const d={x:a,y:l};s||(s=d),r=d}}return{grid:t,startPos:s,endPos:r}};function Ru(n,e={}){const t=so(n),{startPos:o,endPos:s}=t;let{grid:r}=t;const{em:i}=n;if(!o||!s)return;const l=o.x,a=o.y,c=s.x,d=s.y,u=Bt(r,l,a),p=Bt(r,c,d);if(u&&p){zi(r),r=Li(n);const h=[],f=Bt(r,l,a).cell;f.addAttributes({colspan:c-l+1,rowspan:d-a+1});for(let m=a;m<=d;m++)for(let g=l;g<=c;g++){const v=Bt(r,g,m);if(!v)continue;const{cell:w}=v;w!==f&&h.push(w)}h.forEach(m=>{e.mergeContent&&f.append(m.components().models),m.remove()}),i.setSelected(f),Iu(n)}}const $i="Cell settings",Du="Merge cells",Lu="Split cell",zu=n=>n.closestType(ue),Ht=n=>{var e;return(e=zu(n))==null?void 0:e.parent()},$u=n=>{const e=n.editor.getSelectedAll(),t=Ht(e[0]),o=e[0];if(!t||!(o!=null&&o.is(j))||e.length>1)return!1;const{rowspan:s,colspan:r}=ys(o);return!(r<2&&s<2)},Vu=n=>{const t=n.editor.getSelectedAll()[0],o=Ht(t),{grid:s}=so(o);zi(s)},Vi=n=>{const e=n.editor.getSelectedAll(),t=Ht(e[0]);if(!t||e.length<2||e.some(l=>!l.is(j)||Ht(l)!==t))return!1;const{grid:o,startPos:s,endPos:r}=so(t),{em:i}=t;if(!s||!r)return!1;for(let l=s.y;l<=r.y;l++)for(let a=s.x;a<=r.x;a++){const c=Bt(o,a,l);if(!c||!i.selected.hasComponent(c.cell))return!1}return!0},Bu=n=>{const{editor:e}=n;if(!Vi(n))return;const t=e.getSelectedAll(),o=Ht(t[0]);Ru(o,{mergeContent:!0})},Hu=n=>{gs(n,{id:"tableCellSettings",header:{label:$i}})},Fu=n=>[{id:O.tableCellItems,icon:$[O.tableCellProperties],label:"Cell",items:[{id:O.tableCellProperties,label:$i,icon:$[O.tableCellProperties],onClick:({event:t})=>Hu({...n,event:t})},{id:O.tableCellMerge,label:Du,icon:$[O.tableCellMerge],onClick:()=>Bu(n),disabled:!Vi(n)},{id:O.tableCellSplit,label:Lu,icon:$[O.tableCellSplit],onClick:()=>Vu(n),disabled:!$u(n)}]},...Eu(n),...Di(n)],_u=n=>{const e=n[0]&&Ht(n[0]);if(!e)return;const{grid:t,startPos:o,endPos:s}=so(e,{selected:n});if(!o||!s)return;const r=[];for(let i=o.y;i<=s.y;i++)for(let l=o.x;l<=s.x;l++){const a=Bt(t,l,i);a&&r.push(a.cell)}r.length&&e.em.setSelected(r,{fromCell:!0})},Gu=G(function(n,e={}){const t={block:{},...e},{Components:o}=n,s={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"]};o.addType(Pe,{block:t.block&&{label:"Table",media:$.table,category:"Extra",content:{type:Pe,style:{width:"100%"}},select:!0,...t.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:$.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:i,value:l,emitUpdate:a}){const c=i.find("caption")[0];l?!c&&i.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):c==null||c.remove(),a(),n.refresh({tools:!0})},getValue(i){return!!i.component.find("caption")[0]}}],components:Cu(fs,{rows:5}),contextMenu:({items:i,editor:l,component:a})=>[...wi({editor:l,component:a,opts:t}),...i]}}}),o.addType(bi,{model:{defaults:{icon:$.tableHead,...s}}}),o.addType(vi,{model:{defaults:{icon:$.tableFoot,...s}}}),o.addType(fs,{model:{defaults:{icon:$.tableRowProperties,...s}}}),o.addType(ue,{model:{defaults:{icon:$.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:i,editor:l,component:a})=>[...Di({editor:l,component:a,opts:t}),...i]}}}),o.addType(j,{model:{defaults:{icon:$.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","background","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:i,editor:l,component:a})=>[...Fu({editor:l,component:a,opts:t}),...i]}}});const r=no((i,l)=>{var u;const a=n.getSelectedAll(),c=!!((u=l==null?void 0:l.event)!=null&&u.shiftKey);if(a.length<2||!c||l.fromCell)return;const d=a.map(p=>p.is(j)?p:p.closestType(j)).filter(Boolean);d.length===a.length&&_u(d)},0);n.on("component:select",r),W({editor:n,plan:xu,pluginName:vu,licenseKey:t.licenseKey,cleanup:()=>{n.off("component:select",r),n.Blocks.remove(Pe),Su.forEach(i=>o.removeType(i))}})}),Wu="listPagesComponent",ju=F.startup,Bi="page://",pt="list-pages",Ft="list-pages-item",ht="list-pages-link",qu=n=>n.components().reduce((e,t)=>{var i;const o=t.findFirstType(ht),s=(i=o==null?void 0:o.attributes.attributes)==null?void 0:i.href,r=s!=null&&s.startsWith(Bi)?s.replace(Bi,""):"";if(r&&o){const l=e[r];l?l.push(o):e[r]=[o]}return e},{}),ro="data-type-role",Ku="page_root",Uu=n=>e=>e.is(n),Ju=n=>(e,t)=>t.is(n),vs=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,ro))===n},Yu=G(function(n,e={}){const{Blocks:t,Components:o,Pages:s}=n,{licenseKey:r,block:i={}}=e,l="List Pages",a="List Pages Item",c="Link",d=`${Ae}${pt}`,u=`${Ae}${ht}`,p='<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>',h='<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>';o.addType(pt,{block:i&&{label:l,media:p,category:"Extra",select:!0,...e.block},isComponent:vs(pt),model:{defaults:{tagName:"ul",name:l,[Ku]:"",classes:d,attributes:{[ro]:pt,role:"navigation"},droppable:Uu(Ft),styles:`
|
|
62
62
|
.${d} {
|
|
63
63
|
list-style: none;
|
|
64
64
|
margin: 0;
|
|
65
65
|
padding: 0;
|
|
66
66
|
}
|
|
67
|
-
`},init(){this.syncPageItems=
|
|
67
|
+
`},init(){this.syncPageItems=no(this.syncPageItems.bind(this),0),this.listenTo(this.em,s.events.all,this.syncPageItems),this.syncPageItems()},syncPageItems(){if(n.Components.getSymbolInfo(this).isInstance)return;const f=this.em.Pages.getAll(),m=this.components(),g=qu(this);f.forEach((v,w)=>{const y=v.id,b=v.getName(),x=g[y];x?x==null||x.forEach(S=>{S.getInnerHTML()!==b&&S.components(b)}):m.add({type:Ft,components:[{type:ht,attributes:{href:`page://${y}`},components:{type:"textnode",content:b}}]},{at:w})})}}}),o.addType(Ft,{isComponent:vs(Ft),model:{defaults:{name:a,tagName:"li",icon:h,attributes:{[ro]:Ft},components:{type:ht},draggable:Ju(pt)}}}),o.addType(ht,{extend:"link",isComponent:vs(ht),model:{defaults:{removable:!1,copyable:!1,delegate:{move:f=>f.closestType(Ft)},name:c,classes:u,attributes:{[ro]:ht},components:{type:"textnode",content:"Item"},styles:`
|
|
68
68
|
.${u} {
|
|
69
69
|
text-decoration: none;
|
|
70
70
|
}
|
|
71
|
-
`}}}),W({editor:n,licenseKey:
|
|
72
|
-
.${
|
|
71
|
+
`}}}),W({editor:n,licenseKey:r,plan:ju,pluginName:Wu,cleanup:()=>{t.remove(pt),o.removeType(pt)}})}),Zu="fsLightboxComponent",Xu=F.startup,io="data-fslightbox",lo="data-type",Qu="fslightbox-open",_t="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>'},ep=G(function(n,e={}){const{Blocks:t,Components:o}=n,s="Lightbox",r=`${Ae}${_t}`,i={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}=i,d=function(w){const y=this,b="data-fslightbox",x=window,S=()=>{var M;const C=x.refreshFsLightbox;C==null||C();const E=y.getAttribute(b);if((M=x.fsLightboxInstances)==null||M[E],!x._isEditor)return;Array.from(document.querySelectorAll(`[${b}]`)).forEach(P=>{const I=P.onclick;P.onclick=function(N){N.preventDefault();const z=P;!z.__skipLb&&(I==null||I(N)),z.__skipLb=!0}})};if(x.refreshFsLightbox)S();else{const C=document.createElement("script");C.src=w.cdnScript,C.onload=S,document.head.appendChild(C)}},u=w=>({id:`${_t}-open-lb`,label:a,command:()=>{const y=w.getView();y==null||y.toggleLightbox()}}),p="source-type",h={type:"radio",name:p,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},f={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"},v={image:[f],video:[m],el:[g]};o.addType(_t,{block:l&&{label:s,media:Gt.imageLightbox,category:"Extra",select:!0,...i.block},isComponent:w=>{var y;return(y=w.hasAttribute)==null?void 0:y.call(w,io)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:s,icon:Gt.imageLightbox,classes:r,draggable:(w,y)=>!y.is(_t),attributes:{[io]:"lightbox",[lo]:"image",href:c},components:{type:"image",src:c},script:d,cdnScript:i.cdnScript,"script-props":["attributes","cdnScript"],[p]:"image",traits:[h,{name:io,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(w,y){var x;const b=(x=y.target)==null?void 0:x.getView();b==null||b.toggleLightbox()}}],styles:`
|
|
72
|
+
.${r} {
|
|
73
73
|
display: inline-block;
|
|
74
74
|
padding: 10px;
|
|
75
75
|
}
|
|
76
|
-
`},init(){const w=[h].map(y=>`change:${y}`).join(" ");this.on(w,this.updateTraits),this.on(`change:${h}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(w,y,v){if(v.adjust)return;const S=this.get(h)==="video"?"video":"image";this.addAttributes({[io]:S,href:""})},adjustSourceType(){const w=this.get(h),y=this.getAttributes().href||"",v={adjust:!0};if(w==="video"){const x=y.includes("youtube.com")?"youtube":"video";this.addAttributes({[io]:x},v)}else w!=="el"&&y.startsWith("#")?this.set(h,"el",v):w==="image"&&this.addAttributes({[io]:"image"},v)},updateTraits(w={}){const{changed:y}=this,{init:v}=w;if(y[p.name]||v){this.removeTrait([f.name,m.name,g.name]);const x=this.get(h)||"image",S=this.getTraitIndex(h)+1;this.addTrait(b[x],{at:S})}},initToolbar(){if(!a)return;const{toolbar:w}=this,y=u(this);!w.find(x=>x.id===y.id)&&(w==null||w.unshift(y))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var N;const{em:w,el:y,model:v}=this,{Canvas:x}=w,S=v.getAttributes()[so],{defaultView:C,documentElement:A}=y.ownerDocument,T=(N=C.fsLightboxInstances)==null?void 0:N[S];if(A.classList.contains(Wu))T.close();else{y.__skipLb=!1;let I;T.props.onOpen=()=>{I=x.getSpots(),setTimeout(()=>x.removeSpots())},T.props.onClose=()=>{I.forEach(O=>x.addSpot(O.attributes))},y.click()}}}}),W({editor:n,plan:Gu,licenseKey:r.licenseKey,pluginName:_u,cleanup:()=>{t.remove(Ft),o.removeType(Ft)}})}),qu="lightGalleryComponent",Ku=F.startup;var Gt=(n=>(n.image="image",n.video="video",n.external="external",n))(Gt||{});const ft="lightGallery",Ir=`${ft}-item`,ro="data-lightgallery",Rr=`${ro}-item`,lo="toggle",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>',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>'},gs={propKeys:[],props:{},traits:[]},pn=(n,e={})=>{var s;const t={},o=[];for(const i in n){const{value:r,...l}=n[i];o.push({id:i,name:i,changeProp:!0,category:e.category,...l}),t[i]=r;const{subTraits:a={}}=l;for(const c in l.subTraits)(s=a[c])==null||s.forEach(d=>{const u=d.id||d.name;t[u]=d.value})}return{propKeys:Object.keys(t),props:t,traits:o}},ys=(n,e)=>{const t=n.getTrait(e),o=t.get("category"),s=t.get("subTraits")||{},r=(Object.values(s).flat()||[]).map(c=>c.id||c.name);n.removeTrait(r);const l=s[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:o,...c})),{at:a})},bs=(n,e)=>{e.forEach(t=>{const o=n.getTrait(t);if(!o||!o.get("subTraits"))return;const s=o.changeProp?`change:${t}`:`change:attributes:${t}`;n.on(s,()=>ys(n,t)),ys(n,t)})},Uu=(n,e,t)=>{const s=n.getTrait(e).get("subTraits")||{},r=(Object.values(s).flat()||[]).map(a=>{const c=a.name||a.id;return a.changeProp?`change:${c}`:`change:attributes:${c}`}),l=Array.from(new Set(r));l.length&&n.on(l.join(" "),t)},Ju={[lo]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var t,o;return(o=(t=e.target)==null?void 0:t.getView())==null?void 0:o.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}},Yu={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"}]}}},Zu={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}]}}},Xu={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}]}}},qe="sourceType",ao="data-iframe",vs={name:"href",type:"file",label:"Image Source"},co={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},xs={name:"data-poster",label:"Video Poster",type:"file"},Dr={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},Lr={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},Qu={[lo]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var s,i;const t=e.target,o=(s=t==null?void 0:t.closestType(ft))==null?void 0:s.getView();if(o&&t){const r=((i=o.getLightGallery())==null?void 0:i.items)||[],l=Array.from(r).indexOf(t.getEl());l>=0&&o.toggleGallery(l)}}},[qe]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[vs],video:[co,xs],external:[Dr]},options:[{id:"image",label:vs.label||"",icon:mt.image},{id:"video",label:co.label||"",icon:mt.video},{id:"external",label:Dr.label||"",icon:mt.external}]},subHtml:Lr},zr="lgThumbnail",eh="lgVideo",Vr="lgAutoplay",$r="lgZoom",Wt="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",th=G(function(n,e={}){const{Blocks:t,Components:o}=n,s="LightGallery",i="LightGallery Item",r={toolbarIconOpen:mt.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[zr,eh,Vr,$r],cdnScript:[`${Wt}/lightgallery.min.js`,`${Wt}/plugins/thumbnail/lg-thumbnail.min.js`,`${Wt}/plugins/video/lg-video.min.js`,`${Wt}/plugins/autoplay/lg-autoplay.min.js`,`${Wt}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${Wt}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=r,d=function(y){const v=this,x=window,{plugins:S,cdnScript:C,cdnStyle:A,inline:T,lgLicenseKey:M,...N}=y||{},I=z=>isNaN(z)?void 0:parseInt(z,10),O=()=>{var te;const z={...N,licenseKey:M,speed:I(N.speed),startAnimationDuration:I(N.startAnimationDuration),thumbMargin:I(N.thumbMargin),thumbWidth:I(N.thumbWidth),slideShowInterval:I(N.slideShowInterval),scale:I(N.scale),enableZoomAfter:I(N.enableZoomAfter),plugins:(S||[]).map(Dt=>x[Dt])};T&&(z.container=v,z.closable=!1);const $=(te=x.lightGallery)==null?void 0:te.call(x,v,z);T&&$.openGallery()};if(x.lightGallery)O();else{const{head:z}=document,$=Array.isArray(C)?[...C]:[C],te=Array.isArray(A)?[...A]:[A],Dt=ne=>{if(ne.length){const Ae=document.createElement("link");Ae.href=ne.shift(),Ae.rel="stylesheet",z.appendChild(Ae),Dt(ne)}},Xn=ne=>{if(ne.length){const Ae=document.createElement("script");Ae.src=ne.shift(),Ae.onerror=Ae.onload=Xn.bind(null,ne),z.appendChild(Ae)}else O()};Dt(te),Xn($)}},u=y=>{const v=y.getTrait(lo);if(!a||!v)return;const{toolbar:x}=y,S={id:lo,label:a,command:()=>setTimeout(()=>v.runCommand(),100)};!x.find(A=>A.id===S.id)&&(x==null||x.unshift(S))};let h=[];const p=r.plugins||[],f=pn(Ju),m=p.includes(zr)?pn(Yu):gs,g=p.includes(Vr)?pn(Zu):gs,b=p.includes($r)?pn(Xu):gs;o.addType(ft,{block:l&&{label:s,media:mt.gallery,category:"Extra",select:!0,...r.block},isComponent:y=>Qn(y,ro),extendFn:["init","initToolbar"],model:{defaults:{name:s,icon:mt.gallery,draggable:(y,v)=>!v.is(ft),attributes:{[ro]:!0},components:{type:Ir},script:d,selector:"",exThumbImage:"",cdnScript:r.cdnScript,cdnStyle:r.cdnStyle,plugins:r.plugins,lgLicenseKey:r.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...f.propKeys,...m.propKeys,...g.propKeys,...b.propKeys],...f.props,...m.props,...g.props,...b.props,traits:[...f.traits,...m.traits,...g.traits,...b.traits]},init(){bs(this,["thumbnail"]),bs(this,["autoplay"]),bs(this,["zoom"])},initToolbar(){u(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,o.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const y=this.getLightGallery();y==null||y.destroy()},disableLgInCanvas(){const y=this.getLightGallery();y.lgOpened=!0},isInlineGallery(){var v;const y=this.getLightGallery();return((v=y==null?void 0:y.settings)==null?void 0:v.container)===this.el},onLgInit(y){this.el.__lg=y.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:y}=this,{Canvas:v}=y,x=this.getLightGallery();h=v.getSpots(),setTimeout(()=>v.removeSpots()),x.__lgOpened=!0},onLgClose(){const y=this.getLightGallery();h.forEach(v=>this.em.Canvas.addSpot(v.attributes)),h=[],y.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(y){const v=this.getLightGallery();if(v.__lgOpened)return v.closeGallery(!0);v.lgOpened=!1,v.openGallery(y)}}});const w=pn(Qu);o.addType(Ir,{isComponent:y=>Qn(y,Rr)||y.tagName==="A"&&Qn(y.parentElement,ro),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:i,icon:mt.galleryItem,attributes:{[Rr]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...w.props,traits:[...w.traits]},init(){const y=[qe].map(v=>`change:${v}`).join(" ");this.initSourceType(),this.on(y,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),Uu(this,qe,this.triggerGalleryUpdate)},initToolbar(){u(this)},initScriptUpdate(){const y=[Lr.name].map(v=>`change:attributes:${v}`).join(" ");this.on(y,this.triggerGalleryUpdate)},triggerGalleryUpdate(...y){var v;(v=this.closestType(ft))==null||v.__scriptPropsChange(...y)},updateTraits(y={}){const{changed:v}=this,{init:x}=y;if(v[qe]||x){ys(this,qe);const S=this.getTrait(qe).getValue();if(S===Gt.image){this.removeAttributes([co.name,xs.name,ao]);const C=this.getTrait(vs.name);C.setValue(C.getValue()||c)}else S===Gt.video?this.removeAttributes([ao]):S===Gt.external&&this.addAttributes({[ao]:!0})}},initSourceType(){const y=this.getAttributes({noClass:!0,noStyle:!0});y[ao]?this.set(qe,Gt.external):(y[co.name]||y[xs.name])&&this.set(qe,Gt.video)}}}),W({editor:n,plan:Ku,licenseKey:r.licenseKey,pluginName:qu,cleanup:()=>{t.remove(ft),o.removeType(ft)}})}),we="swiper",fn=`${we}-slide`,jt=`${we}-wrapper`,qt=`${we}-nav-prev`,uo=`${we}-nav-next`,Kt=`${we}-pagination`,mn=`${we}-scrollbar`,le={slider:`<svg viewBox="0 0 24 24">
|
|
76
|
+
`},init(){const w=[p].map(y=>`change:${y}`).join(" ");this.on(w,this.updateTraits),this.on(`change:${p}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(w,y,b){if(b.adjust)return;const S=this.get(p)==="video"?"video":"image";this.addAttributes({[lo]:S,href:""})},adjustSourceType(){const w=this.get(p),y=this.getAttributes().href||"",b={adjust:!0};if(w==="video"){const x=y.includes("youtube.com")?"youtube":"video";this.addAttributes({[lo]:x},b)}else w!=="el"&&y.startsWith("#")?this.set(p,"el",b):w==="image"&&this.addAttributes({[lo]:"image"},b)},updateTraits(w={}){const{changed:y}=this,{init:b}=w;if(y[h.name]||b){this.removeTrait([f.name,m.name,g.name]);const x=this.get(p)||"image",S=this.getTraitIndex(p)+1;this.addTrait(v[x],{at:S})}},initToolbar(){if(!a)return;const{toolbar:w}=this,y=u(this);!w.find(x=>x.id===y.id)&&(w==null||w.unshift(y))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var P;const{em:w,el:y,model:b}=this,{Canvas:x}=w,S=b.getAttributes()[io],{defaultView:C,documentElement:E}=y.ownerDocument,T=(P=C.fsLightboxInstances)==null?void 0:P[S];if(E.classList.contains(Qu))T.close();else{y.__skipLb=!1;let I;T.props.onOpen=()=>{I=x.getSpots(),setTimeout(()=>x.removeSpots())},T.props.onClose=()=>{I.forEach(N=>x.addSpot(N.attributes))},y.click()}}}}),W({editor:n,plan:Xu,licenseKey:i.licenseKey,pluginName:Zu,cleanup:()=>{t.remove(_t),o.removeType(_t)}})}),tp="lightGalleryComponent",np=F.startup;var Wt=(n=>(n.image="image",n.video="video",n.external="external",n))(Wt||{});const ft="lightGallery",Hi=`${ft}-item`,ao="data-lightgallery",Fi=`${ao}-item`,co="toggle",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>',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>'},xs={propKeys:[],props:{},traits:[]},fn=(n,e={})=>{var s;const t={},o=[];for(const r in n){const{value:i,...l}=n[r];o.push({id:r,name:r,changeProp:!0,category:e.category,...l}),t[r]=i;const{subTraits:a={}}=l;for(const c in l.subTraits)(s=a[c])==null||s.forEach(d=>{const u=d.id||d.name;t[u]=d.value})}return{propKeys:Object.keys(t),props:t,traits:o}},Ss=(n,e)=>{const t=n.getTrait(e),o=t.get("category"),s=t.get("subTraits")||{},i=(Object.values(s).flat()||[]).map(c=>c.id||c.name);n.removeTrait(i);const l=s[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:o,...c})),{at:a})},ws=(n,e)=>{e.forEach(t=>{const o=n.getTrait(t);if(!o||!o.get("subTraits"))return;const s=o.changeProp?`change:${t}`:`change:attributes:${t}`;n.on(s,()=>Ss(n,t)),Ss(n,t)})},op=(n,e,t)=>{const s=n.getTrait(e).get("subTraits")||{},i=(Object.values(s).flat()||[]).map(a=>{const c=a.name||a.id;return a.changeProp?`change:${c}`:`change:attributes:${c}`}),l=Array.from(new Set(i));l.length&&n.on(l.join(" "),t)},sp={[co]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var t,o;return(o=(t=e.target)==null?void 0:t.getView())==null?void 0:o.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}},rp={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"}]}}},ip={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}]}}},lp={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}]}}},Ke="sourceType",uo="data-iframe",Cs={name:"href",type:"file",label:"Image Source"},po={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},ks={name:"data-poster",label:"Video Poster",type:"file"},_i={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},Gi={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},ap={[co]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var s,r;const t=e.target,o=(s=t==null?void 0:t.closestType(ft))==null?void 0:s.getView();if(o&&t){const i=((r=o.getLightGallery())==null?void 0:r.items)||[],l=Array.from(i).indexOf(t.getEl());l>=0&&o.toggleGallery(l)}}},[Ke]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[Cs],video:[po,ks],external:[_i]},options:[{id:"image",label:Cs.label||"",icon:mt.image},{id:"video",label:po.label||"",icon:mt.video},{id:"external",label:_i.label||"",icon:mt.external}]},subHtml:Gi},Wi="lgThumbnail",cp="lgVideo",ji="lgAutoplay",qi="lgZoom",jt="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",dp=G(function(n,e={}){const{Blocks:t,Components:o}=n,s="LightGallery",r="LightGallery Item",i={toolbarIconOpen:mt.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[Wi,cp,ji,qi],cdnScript:[`${jt}/lightgallery.min.js`,`${jt}/plugins/thumbnail/lg-thumbnail.min.js`,`${jt}/plugins/video/lg-video.min.js`,`${jt}/plugins/autoplay/lg-autoplay.min.js`,`${jt}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${jt}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=i,d=function(y){const b=this,x=window,{plugins:S,cdnScript:C,cdnStyle:E,inline:T,lgLicenseKey:M,...P}=y||{},I=z=>isNaN(z)?void 0:parseInt(z,10),N=()=>{var te;const z={...P,licenseKey:M,speed:I(P.speed),startAnimationDuration:I(P.startAnimationDuration),thumbMargin:I(P.thumbMargin),thumbWidth:I(P.thumbWidth),slideShowInterval:I(P.slideShowInterval),scale:I(P.scale),enableZoomAfter:I(P.enableZoomAfter),plugins:(S||[]).map(Lt=>x[Lt])};T&&(z.container=b,z.closable=!1);const V=(te=x.lightGallery)==null?void 0:te.call(x,b,z);T&&V.openGallery()};if(x.lightGallery)N();else{const{head:z}=document,V=Array.isArray(C)?[...C]:[C],te=Array.isArray(E)?[...E]:[E],Lt=ne=>{if(ne.length){const Ee=document.createElement("link");Ee.href=ne.shift(),Ee.rel="stylesheet",z.appendChild(Ee),Lt(ne)}},Qn=ne=>{if(ne.length){const Ee=document.createElement("script");Ee.src=ne.shift(),Ee.onerror=Ee.onload=Qn.bind(null,ne),z.appendChild(Ee)}else N()};Lt(te),Qn(V)}},u=y=>{const b=y.getTrait(co);if(!a||!b)return;const{toolbar:x}=y,S={id:co,label:a,command:()=>setTimeout(()=>b.runCommand(),100)};!x.find(E=>E.id===S.id)&&(x==null||x.unshift(S))};let p=[];const h=i.plugins||[],f=fn(sp),m=h.includes(Wi)?fn(rp):xs,g=h.includes(ji)?fn(ip):xs,v=h.includes(qi)?fn(lp):xs;o.addType(ft,{block:l&&{label:s,media:mt.gallery,category:"Extra",select:!0,...i.block},isComponent:y=>eo(y,ao),extendFn:["init","initToolbar"],model:{defaults:{name:s,icon:mt.gallery,draggable:(y,b)=>!b.is(ft),attributes:{[ao]:!0},components:{type:Hi},script:d,selector:"",exThumbImage:"",cdnScript:i.cdnScript,cdnStyle:i.cdnStyle,plugins:i.plugins,lgLicenseKey:i.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...f.propKeys,...m.propKeys,...g.propKeys,...v.propKeys],...f.props,...m.props,...g.props,...v.props,traits:[...f.traits,...m.traits,...g.traits,...v.traits]},init(){ws(this,["thumbnail"]),ws(this,["autoplay"]),ws(this,["zoom"])},initToolbar(){u(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,o.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const y=this.getLightGallery();y==null||y.destroy()},disableLgInCanvas(){const y=this.getLightGallery();y.lgOpened=!0},isInlineGallery(){var b;const y=this.getLightGallery();return((b=y==null?void 0:y.settings)==null?void 0:b.container)===this.el},onLgInit(y){this.el.__lg=y.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:y}=this,{Canvas:b}=y,x=this.getLightGallery();p=b.getSpots(),setTimeout(()=>b.removeSpots()),x.__lgOpened=!0},onLgClose(){const y=this.getLightGallery();p.forEach(b=>this.em.Canvas.addSpot(b.attributes)),p=[],y.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(y){const b=this.getLightGallery();if(b.__lgOpened)return b.closeGallery(!0);b.lgOpened=!1,b.openGallery(y)}}});const w=fn(ap);o.addType(Hi,{isComponent:y=>eo(y,Fi)||y.tagName==="A"&&eo(y.parentElement,ao),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:r,icon:mt.galleryItem,attributes:{[Fi]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...w.props,traits:[...w.traits]},init(){const y=[Ke].map(b=>`change:${b}`).join(" ");this.initSourceType(),this.on(y,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),op(this,Ke,this.triggerGalleryUpdate)},initToolbar(){u(this)},initScriptUpdate(){const y=[Gi.name].map(b=>`change:attributes:${b}`).join(" ");this.on(y,this.triggerGalleryUpdate)},triggerGalleryUpdate(...y){var b;(b=this.closestType(ft))==null||b.__scriptPropsChange(...y)},updateTraits(y={}){const{changed:b}=this,{init:x}=y;if(b[Ke]||x){Ss(this,Ke);const S=this.getTrait(Ke).getValue();if(S===Wt.image){this.removeAttributes([po.name,ks.name,uo]);const C=this.getTrait(Cs.name);C.setValue(C.getValue()||c)}else S===Wt.video?this.removeAttributes([uo]):S===Wt.external&&this.addAttributes({[uo]:!0})}},initSourceType(){const y=this.getAttributes({noClass:!0,noStyle:!0});y[uo]?this.set(Ke,Wt.external):(y[po.name]||y[ks.name])&&this.set(Ke,Wt.video)}}}),W({editor:n,plan:np,licenseKey:i.licenseKey,pluginName:tp,cleanup:()=>{t.remove(ft),o.removeType(ft)}})}),we="swiper",mn=`${we}-slide`,qt=`${we}-wrapper`,Kt=`${we}-nav-prev`,ho=`${we}-nav-next`,Ut=`${we}-pagination`,gn=`${we}-scrollbar`,le={slider:`<svg viewBox="0 0 24 24">
|
|
77
77
|
<path d="M22 7.6c0-1-.5-1.6-1.3-1.6H3.4C2.5 6 2 6.7 2 7.6v9.8c0 1 .5 1.6 1.3 1.6h17.4c.8 0 1.3-.6 1.3-1.6V7.6zM21 18H3V7h18v11z" fill-rule="nonzero"/>
|
|
78
78
|
<path d="M4 12.5L6 14v-3zM20 12.5L18 14v-3z"/>
|
|
79
79
|
</svg>`,effect:`<svg viewBox="0 0 24 24">
|
|
@@ -96,29 +96,29 @@
|
|
|
96
96
|
<path d="M2 12c0 5 4 9 9 9 2.4 0 4.7-1 6.4-2.6l-1.5-1.5A6.7 6.7 0 0 1 11 19a7 7 0 1 1 7-7h-3l4 4h.1l3.9-4h-3a9 9 0 0 0-18 0Z"/>
|
|
97
97
|
</svg>`,prev:'<svg viewBox="0 0 24 24"><path d="M15.4 16.6 10.8 12l4.6-4.6L14 6l-6 6 6 6 1.4-1.4Z"/></svg>',next:'<svg viewBox="0 0 24 24"><path d="m8.6 16.6 4.6-4.6-4.6-4.6L10 6l6 6-6 6-1.4-1.4Z"/></svg>',add:`<svg viewBox="0 0 24 24">
|
|
98
98
|
<path d="M12 20a8 8 0 1 1 0-16 8 8 0 0 1 0 16m0-18A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2m1 5h-2v4H7v2h4v4h2v-4h4v-2h-4V7Z"/>
|
|
99
|
-
</svg>`},Br={id:"swiper-responsive",label:"Responsive",icon:le.responsive},Hr={id:"swiper-extra",label:"Extra",icon:le.extra},nh={actions:{type:"radio",label:!1,labelToTitle:!0,options:[{id:"r",label:"Reload slider",icon:le.reload},{id:"p",label:"Previous slide",icon:le.prev},{id:"n",label:"Next slide",icon:le.next},{id:"a",label:"Add new slide",icon:le.add}],setValue:({component:n,value:e})=>{var o;const t=(o=n.getView())==null?void 0:o.getSwiper();switch(e){case"r":n.reloadSlider();break;case"p":t==null||t.slidePrev();break;case"n":t==null||t.slideNext();break;case"a":n.addSlide();break}}},vertical:{type:"checkbox",label:"Vertical",value:!1},loop:{type:"checkbox",label:"Loop",value:!1},freeMode:{type:"checkbox",label:"Free mode",value:!1},autoHeight:{type:"checkbox",label:"Auto height",value:!1},navigation:{type:"checkbox",label:"Navigation",getValue:({component:n})=>!!n.findFirstType(qt),setValue:({component:n,value:e})=>{var t,o;e?n.append([{type:qt},{type:uo}]):((t=n.findFirstType(qt))==null||t.remove(),(o=n.findFirstType(uo))==null||o.remove()),n.set({navigation:e})}},initialSlide:{type:"number",label:"Initial slide",min:0,value:"0"},speed:{type:"number",label:"Speed",tip:"Transition duration (in ms)",step:500,min:0,value:300},effect:{category:{id:"swiper-effect",label:"Effects",icon:le.effect},type:"select",label:"Effect Type",value:"slide",options:[{id:"slide",label:"Slide"},{id:"fade",label:"Fade"},{id:"cube",label:"Cube"},{id:"coverflow",label:"Coverflow"},{id:"flip",label:"Flip"},{id:"cards",label:"Cards"}],subTraits:{slide:[{type:"number",name:"slidesPerView",label:"Slides per view",changeProp:!0,min:1,value:1},{type:"number",name:"slidesPerGroup",label:"Slides per group",tip:"Numbers of slides for group sliding",changeProp:!0,min:1,value:1},{type:"number",name:"spaceBetween",label:"Space between",tip:"Distance between slides in px",changeProp:!0,min:0,value:0},{type:"number",name:"slidesOffsetBefore",label:"Slides offset before",tip:"Add additional slide offset in the beginning of the container (in px, before all slides)",changeProp:!0,min:0,value:0},{type:"number",name:"slidesOffsetAfter",label:"Slides offset after",tip:"Add additional slide offset in the end of the container (in px, after all slides)",changeProp:!0,min:0,value:0},{type:"checkbox",name:"centeredSlides",label:"Centered slides",tip:"If enabled, the active slide will be centered",changeProp:!0,value:!1}],fade:[{type:"checkbox",name:"crossFade",tip:"Enables slides cross fade",label:"Cross fade",changeProp:!0,value:!1}],cube:[{type:"checkbox",name:"cubeEffectShadow",label:"Shadow",changeProp:!0,value:!0},{type:"checkbox",name:"cubeEffectSlideShadows",label:"Slide shadows",changeProp:!0,value:!0},{type:"number",name:"cubeEffectShadowOffset",label:"Shadow offset",changeProp:!0,value:20},{type:"number",name:"cubeEffectShadowScale",label:"Shadow scale",changeProp:!0,value:.94}],coverflow:[{type:"number",name:"coverflowEffectDepth",tip:"Depth offset in px (slides translate in Z axis)",label:"Depth",changeProp:!0,min:0,value:100},{type:"number",name:"coverflowEffectModifier",tip:"Effect multiplier",label:"Modifier",changeProp:!0,step:.1,min:0,value:1},{type:"number",name:"coverflowEffectRotate",tip:"Slide rotate in degrees",label:"Rotate",changeProp:!0,min:0,value:50},{type:"number",name:"coverflowEffectScale",tip:"Slide scale effect",label:"Scale",changeProp:!0,min:0,step:.1,value:1},{type:"number",name:"coverflowEffectStretch",tip:"Stretch space between slides (in px)",label:"Stretch",changeProp:!0,min:0,value:0},{type:"checkbox",name:"coverflowEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadow",changeProp:!0,value:!0}],flip:[{type:"checkbox",name:"flipEffectLimitRotation",tip:"Limit edge slides rotation",label:"Limit rotation",changeProp:!0,value:!0},{type:"checkbox",name:"flipEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadows",changeProp:!0,value:!0}],cards:[{type:"number",name:"cardsEffectPerSlideOffset",tip:"Offset distance per slide (in px)",label:"Slide offset",changeProp:!0,min:0,value:8},{type:"number",name:"cardsEffectPerSlideRotate",tip:"Rotate angle per slide (in degrees)",label:"Slide rotate",changeProp:!0,min:0,value:2},{type:"checkbox",name:"cardsEffectRotate",tip:"Enables cards rotation",label:"Rotate",changeProp:!0,value:!0},{type:"checkbox",name:"cardsEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadows",changeProp:!0,value:!0}]}},autoplay:{category:{id:"swiper-autoplay",label:"Autoplay",icon:le.autoplay},type:"checkbox",label:"Enable Autoplay",value:!1,subTraits:{true:[{type:"number",name:"autoplayDelay",label:"Delay",changeProp:!0,value:3e3},{type:"checkbox",name:"autoplayDisableOnInteraction",label:"Disable on interaction",changeProp:!0,value:!0},{type:"checkbox",name:"autoplayWaitForTransition",label:"Wait for transition",changeProp:!0,value:!0},{type:"checkbox",name:"autoplayPauseOnMouseEnter",label:"Pause on mouse enter",changeProp:!0,value:!1},{type:"checkbox",name:"autoplayReverseDirection",label:"Reverse direction",changeProp:!0,value:!1},{type:"checkbox",name:"autoplayStopOnLastSlide",label:"Stop on last slide",changeProp:!0,value:!1}]}},pagination:{category:{id:"swiper-pagination",label:"Pagination",icon:le.pagination},type:"select",label:"Pagination Type",options:[{id:"none",label:"None"},{id:"bullets",label:"Bullets"},{id:"progressbar",label:"Progressbar"},{id:"fraction",label:"Fraction"}],getValue:({component:n})=>n.findFirstType(Kt)?n.get("pagination")||"bullets":"none",setValue:({component:n,value:e})=>{const t=n.findFirstType(Kt);t==null||t.remove(),e!=="none"&&n.append({type:Kt}),n.set({pagination:e})},subTraits:{bullets:[{type:"checkbox",name:"dynamicBullets",label:"Dynamic bullets",changeProp:!0,value:!1},{type:"checkbox",name:"clickableBullets",label:"Clickable bullets",changeProp:!0,value:!0}],progressbar:[{type:"checkbox",name:"progressbarOpposite",label:"Progress opposite",changeProp:!0,value:!1}]}},scrollbar:{category:{id:"swiper-scrollbar",label:"Scrollbar",icon:le.scrollbar},type:"checkbox",label:"Enable Scrollbar",getValue:({component:n})=>!!n.findFirstType(mn),setValue:({component:n,value:e})=>{const t=n.findFirstType(mn);t==null||t.remove(),e&&n.append({type:mn}),n.set({scrollbar:e})},subTraits:{false:[],true:[{type:"checkbox",name:"scrollbarDraggable",label:"Draggable",changeProp:!0,value:!1},{type:"checkbox",name:"scrollbarHide",label:"Hide",tip:"Hide scrollbar automatically after user interaction",changeProp:!0,value:!0}]}},parallax:{category:{id:"swiper-parallax",label:"Parallax",icon:le.parallax},type:"checkbox",label:"Enable Parallax",value:!1},mobile:{category:Br,type:"checkbox",label:"Enable mobile breakpoint",value:!1,subTraits:{true:[{type:"number",name:"mobileBreakpoint",label:"Mobile breakpoint",tip:"Slide values below will be applied when the screen width is greater than this value",changeProp:!0,min:1,value:460},{type:"number",name:"mobileSlidesPerView",label:"Slides per view",changeProp:!0,min:1,value:1},{type:"number",name:"mobileSlidesPerGroup",label:"Slides per group",changeProp:!0,min:1,value:1},{type:"number",name:"mobileSpaceBetween",label:"Space between",changeProp:!0,min:0,value:0}]}},tablet:{category:Br,type:"checkbox",label:"Enable tablet breakpoint",value:!1,subTraits:{true:[{type:"number",name:"tabletBreakpoint",label:"Tablet breakpoint",tip:"Slide values below will be applied when the screen width is greater than this value",changeProp:!0,min:1,value:991},{type:"number",name:"tabletSlidesPerView",label:"Slides per view",changeProp:!0,min:1,value:1},{type:"number",name:"tabletSlidesPerGroup",label:"Slides per group",changeProp:!0,min:1,value:1},{type:"number",name:"tabletSpaceBetween",label:"Space between",changeProp:!0,min:0,value:0}]}},allowTouchMove:{category:Hr,type:"checkbox",label:"Allow touch move",tip:"Allow touch interactions",value:!0},grabCursor:{category:Hr,type:"checkbox",label:"Grab cursor",tip:'If enabled, the user will see the "grab" cursor when hover the slider',value:!1}},Fr="Slider",Ss="swiper",Ut=`${Ss}-`,oh=(n,e)=>{const{Components:t,Blocks:o,Commands:s}=n,{block:i}=e,r=Gd(nh),l="core:preview",a=s.events,c=function(h){const p=this,f=window,m=p.__onLoad,g=p.__activeSlide,b=p.__inPreview,{cdnScript:w,cdnStyle:y,slidesPerView:v}=h||{},x=C=>isNaN(C)?void 0:parseFloat(C),S=()=>{const C={loop:h.loop,speed:h.speed,initialSlide:h.initialSlide,direction:h.vertical?"vertical":"horizontal",effect:h.effect,freeMode:h.freeMode,parallax:h.parallax,autoHeight:h.autoHeight,allowTouchMove:h.allowTouchMove,grabCursor:h.grabCursor,simulateTouch:!0,breakpoints:{},slidesPerView:isNaN(v)?v:x(v),slidesPerGroup:x(h.slidesPerGroup),spaceBetween:x(h.spaceBetween),slidesOffsetBefore:x(h.slidesOffsetBefore),slidesOffsetAfter:x(h.slidesOffsetAfter),centeredSlides:h.centeredSlides,fadeEffect:{crossFade:h.crossFade},cubeEffect:{shadow:h.cubeEffectShadow,slideShadows:h.cubeEffectSlideShadows,shadowOffset:x(h.cubeEffectShadowOffset),shadowScale:x(h.cubeEffectShadowScale)},coverflowEffect:{depth:x(h.coverflowEffectDepth),modifier:x(h.coverflowEffectModifier),rotate:x(h.coverflowEffectRotate),scale:x(h.coverflowEffectScale),stretch:x(h.coverflowEffectStretch),slideShadows:h.coverflowEffectSlideShadows},flipEffect:{limitRotation:h.flipEffectLimitRotation,slideShadows:h.flipEffectSlideShadows},cardsEffect:{perSlideOffset:x(h.cardsEffectPerSlideOffset),perSlideRotate:x(h.cardsEffectPerSlideRotate),rotate:h.cardsEffectRotate,slideShadows:h.cardsEffectSlideShadows},navigation:{nextEl:p.querySelector(".swiper-button-next"),prevEl:p.querySelector(".swiper-button-prev")},pagination:{type:h.pagination||"bullets",dynamicBullets:h.dynamicBullets,clickable:h.clickableBullets,progressbarOpposite:h.progressbarOpposite,el:p.querySelector(".swiper-pagination")},scrollbar:{el:p.querySelector(".swiper-scrollbar"),draggable:h.scrollbarDraggable,hide:h.scrollbarHide},autoplay:h.autoplay&&{delay:h.autoplayDelay,disableOnInteraction:h.autoplayDisableOnInteraction,pauseOnMouseEnter:h.autoplayPauseOnMouseEnter,reverseDirection:h.autoplayReverseDirection,stopOnLastSlide:h.autoplayStopOnLastSlide,waitForTransition:h.autoplayWaitForTransition}};if(h.tablet){const{tabletBreakpoint:T,tabletSlidesPerView:M}=h,N=x(T);C.breakpoints[N]={slidesPerView:isNaN(M)?M:x(M),slidesPerGroup:x(h.tabletSlidesPerGroup),spaceBetween:x(h.tabletSpaceBetween)}}if(h.mobile){const{mobileBreakpoint:T,mobileSlidesPerView:M}=h,N=x(T);C.breakpoints[N]={slidesPerView:isNaN(M)?M:x(M),slidesPerGroup:x(h.mobileSlidesPerGroup),spaceBetween:x(h.mobileSpaceBetween)}}m&&!b&&(C.simulateTouch=!1),g&&(C.initialSlide=g);const A=new f.Swiper(p,C);m==null||m(A)};if(f.Swiper)S();else{const{head:C}=document,A=Array.isArray(w)?[...w]:[w],T=Array.isArray(y)?[...y]:[y],M=I=>{if(I.length){const O=document.createElement("link");O.href=I.shift(),O.rel="stylesheet",C.appendChild(O),M(I)}},N=I=>{if(I.length){const O=document.createElement("script");O.src=I.shift(),O.onerror=O.onload=N.bind(null,I),C.appendChild(O)}else S()};M(T),N(A)}},d=(h=0)=>({type:fn,style:{padding:"50px"},components:{type:"text",components:{type:"textnode",content:`Slide ${h}`}}}),u=t.getType("default").model;return t.addType(we,{block:i&&{label:Fr,media:le.slider,category:"Extra",select:!0,...e.block},isComponent:h=>dt(h,Ss),model:{defaults:()=>({name:Fr,icon:le.slider,classes:Ss,draggable:(h,p)=>!p.is(we),components:[{type:jt,components:[d(1),d(2),d(3)]},{type:Kt}],script:c,cdnScript:e.cdnScript,cdnStyle:e.cdnStyle,"script-props":["cdnScript","cdnStyle",...r.propKeys],...r.props,traits:[...r.traits]}),init(){const{em:h}=this;Wd(this,r.traits),jd(this,r.propKeys),this.listenTo(h,`${a.runCommand}${l}`,this.onPreviewOn),this.listenTo(h,`${a.stopCommand}${l}`,this.onPreviewOff)},onPreviewOn(){this.__inPreview=!0,this.reloadSlider()},onPreviewOff(){this.__inPreview=!1,this.reloadSlider()},reloadSlider(){this.trigger("rerender")},addSlide(){const h=this.findFirstType(jt);h==null||h.append(this.getNewSlideComponentDef())},getNewSlideComponentDef(){var p;const h=((p=this.findFirstType(jt))==null?void 0:p.components().length)||0;return{type:fn,components:{type:"text",components:{type:"textnode",content:`Slide ${h+1}`}}}},toJSON(...h){const p=u.prototype.toJSON.apply(this,h);return r.propsNoValues.forEach(f=>delete p[f]),delete p["script-props"],p}},view:{init(){this.listenTo(this.model,t.events.scriptUnmount,this.destroySwiper)},getSwiper(){return this.el.swiper},destroySwiper(){var h;(h=this.getSwiper())==null||h.destroy()},onRender(){const h=this.el;h.__onLoad=p=>p.on("slideChange",()=>this.__activeSlide=p.activeIndex),h.__activeSlide=this.__activeSlide,h.__inPreview=this.model.__inPreview}}}),()=>{t.removeType(we),o.remove(we)}},sh="Nav Prev",ih="Nav Next",ho=`${Ut}button-prev`,po=`${Ut}button-next`,rh=n=>{const{Components:e}=n,t=o=>({type:"svg",selectable:!1,hoverable:!1,attributes:{viewBox:"0 0 27 44"},components:{type:"svg-in",tagName:"path",attributes:{d:o,fill:"currentColor"}}});return e.addType(qt,{isComponent:o=>dt(o,ho),model:{defaults:{name:sh,classes:ho,copyable:!1,highlightable:!1,droppable:!1,draggable:!1,selectable:!1,hoverable:!1,layerable:!1,components:t("M0,22L22,0l2.1,2.1L4.2,22l19.9,19.9L22,44L0,22L0,22L0,22z"),styles:`
|
|
100
|
-
.${
|
|
99
|
+
</svg>`},Ki={id:"swiper-responsive",label:"Responsive",icon:le.responsive},Ui={id:"swiper-extra",label:"Extra",icon:le.extra},up={actions:{type:"radio",label:!1,labelToTitle:!0,options:[{id:"r",label:"Reload slider",icon:le.reload},{id:"p",label:"Previous slide",icon:le.prev},{id:"n",label:"Next slide",icon:le.next},{id:"a",label:"Add new slide",icon:le.add}],setValue:({component:n,value:e})=>{var o;const t=(o=n.getView())==null?void 0:o.getSwiper();switch(e){case"r":n.reloadSlider();break;case"p":t==null||t.slidePrev();break;case"n":t==null||t.slideNext();break;case"a":n.addSlide();break}}},vertical:{type:"checkbox",label:"Vertical",value:!1},loop:{type:"checkbox",label:"Loop",value:!1},freeMode:{type:"checkbox",label:"Free mode",value:!1},autoHeight:{type:"checkbox",label:"Auto height",value:!1},navigation:{type:"checkbox",label:"Navigation",getValue:({component:n})=>!!n.findFirstType(Kt),setValue:({component:n,value:e})=>{var t,o;e?n.append([{type:Kt},{type:ho}]):((t=n.findFirstType(Kt))==null||t.remove(),(o=n.findFirstType(ho))==null||o.remove()),n.set({navigation:e})}},initialSlide:{type:"number",label:"Initial slide",min:0,value:"0"},speed:{type:"number",label:"Speed",tip:"Transition duration (in ms)",step:500,min:0,value:300},effect:{category:{id:"swiper-effect",label:"Effects",icon:le.effect},type:"select",label:"Effect Type",value:"slide",options:[{id:"slide",label:"Slide"},{id:"fade",label:"Fade"},{id:"cube",label:"Cube"},{id:"coverflow",label:"Coverflow"},{id:"flip",label:"Flip"},{id:"cards",label:"Cards"}],subTraits:{slide:[{type:"number",name:"slidesPerView",label:"Slides per view",changeProp:!0,min:1,value:1},{type:"number",name:"slidesPerGroup",label:"Slides per group",tip:"Numbers of slides for group sliding",changeProp:!0,min:1,value:1},{type:"number",name:"spaceBetween",label:"Space between",tip:"Distance between slides in px",changeProp:!0,min:0,value:0},{type:"number",name:"slidesOffsetBefore",label:"Slides offset before",tip:"Add additional slide offset in the beginning of the container (in px, before all slides)",changeProp:!0,min:0,value:0},{type:"number",name:"slidesOffsetAfter",label:"Slides offset after",tip:"Add additional slide offset in the end of the container (in px, after all slides)",changeProp:!0,min:0,value:0},{type:"checkbox",name:"centeredSlides",label:"Centered slides",tip:"If enabled, the active slide will be centered",changeProp:!0,value:!1}],fade:[{type:"checkbox",name:"crossFade",tip:"Enables slides cross fade",label:"Cross fade",changeProp:!0,value:!1}],cube:[{type:"checkbox",name:"cubeEffectShadow",label:"Shadow",changeProp:!0,value:!0},{type:"checkbox",name:"cubeEffectSlideShadows",label:"Slide shadows",changeProp:!0,value:!0},{type:"number",name:"cubeEffectShadowOffset",label:"Shadow offset",changeProp:!0,value:20},{type:"number",name:"cubeEffectShadowScale",label:"Shadow scale",changeProp:!0,value:.94}],coverflow:[{type:"number",name:"coverflowEffectDepth",tip:"Depth offset in px (slides translate in Z axis)",label:"Depth",changeProp:!0,min:0,value:100},{type:"number",name:"coverflowEffectModifier",tip:"Effect multiplier",label:"Modifier",changeProp:!0,step:.1,min:0,value:1},{type:"number",name:"coverflowEffectRotate",tip:"Slide rotate in degrees",label:"Rotate",changeProp:!0,min:0,value:50},{type:"number",name:"coverflowEffectScale",tip:"Slide scale effect",label:"Scale",changeProp:!0,min:0,step:.1,value:1},{type:"number",name:"coverflowEffectStretch",tip:"Stretch space between slides (in px)",label:"Stretch",changeProp:!0,min:0,value:0},{type:"checkbox",name:"coverflowEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadow",changeProp:!0,value:!0}],flip:[{type:"checkbox",name:"flipEffectLimitRotation",tip:"Limit edge slides rotation",label:"Limit rotation",changeProp:!0,value:!0},{type:"checkbox",name:"flipEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadows",changeProp:!0,value:!0}],cards:[{type:"number",name:"cardsEffectPerSlideOffset",tip:"Offset distance per slide (in px)",label:"Slide offset",changeProp:!0,min:0,value:8},{type:"number",name:"cardsEffectPerSlideRotate",tip:"Rotate angle per slide (in degrees)",label:"Slide rotate",changeProp:!0,min:0,value:2},{type:"checkbox",name:"cardsEffectRotate",tip:"Enables cards rotation",label:"Rotate",changeProp:!0,value:!0},{type:"checkbox",name:"cardsEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadows",changeProp:!0,value:!0}]}},autoplay:{category:{id:"swiper-autoplay",label:"Autoplay",icon:le.autoplay},type:"checkbox",label:"Enable Autoplay",value:!1,subTraits:{true:[{type:"number",name:"autoplayDelay",label:"Delay",changeProp:!0,value:3e3},{type:"checkbox",name:"autoplayDisableOnInteraction",label:"Disable on interaction",changeProp:!0,value:!0},{type:"checkbox",name:"autoplayWaitForTransition",label:"Wait for transition",changeProp:!0,value:!0},{type:"checkbox",name:"autoplayPauseOnMouseEnter",label:"Pause on mouse enter",changeProp:!0,value:!1},{type:"checkbox",name:"autoplayReverseDirection",label:"Reverse direction",changeProp:!0,value:!1},{type:"checkbox",name:"autoplayStopOnLastSlide",label:"Stop on last slide",changeProp:!0,value:!1}]}},pagination:{category:{id:"swiper-pagination",label:"Pagination",icon:le.pagination},type:"select",label:"Pagination Type",options:[{id:"none",label:"None"},{id:"bullets",label:"Bullets"},{id:"progressbar",label:"Progressbar"},{id:"fraction",label:"Fraction"}],getValue:({component:n})=>n.findFirstType(Ut)?n.get("pagination")||"bullets":"none",setValue:({component:n,value:e})=>{const t=n.findFirstType(Ut);t==null||t.remove(),e!=="none"&&n.append({type:Ut}),n.set({pagination:e})},subTraits:{bullets:[{type:"checkbox",name:"dynamicBullets",label:"Dynamic bullets",changeProp:!0,value:!1},{type:"checkbox",name:"clickableBullets",label:"Clickable bullets",changeProp:!0,value:!0}],progressbar:[{type:"checkbox",name:"progressbarOpposite",label:"Progress opposite",changeProp:!0,value:!1}]}},scrollbar:{category:{id:"swiper-scrollbar",label:"Scrollbar",icon:le.scrollbar},type:"checkbox",label:"Enable Scrollbar",getValue:({component:n})=>!!n.findFirstType(gn),setValue:({component:n,value:e})=>{const t=n.findFirstType(gn);t==null||t.remove(),e&&n.append({type:gn}),n.set({scrollbar:e})},subTraits:{false:[],true:[{type:"checkbox",name:"scrollbarDraggable",label:"Draggable",changeProp:!0,value:!1},{type:"checkbox",name:"scrollbarHide",label:"Hide",tip:"Hide scrollbar automatically after user interaction",changeProp:!0,value:!0}]}},parallax:{category:{id:"swiper-parallax",label:"Parallax",icon:le.parallax},type:"checkbox",label:"Enable Parallax",value:!1},mobile:{category:Ki,type:"checkbox",label:"Enable mobile breakpoint",value:!1,subTraits:{true:[{type:"number",name:"mobileBreakpoint",label:"Mobile breakpoint",tip:"Slide values below will be applied when the screen width is greater than this value",changeProp:!0,min:1,value:460},{type:"number",name:"mobileSlidesPerView",label:"Slides per view",changeProp:!0,min:1,value:1},{type:"number",name:"mobileSlidesPerGroup",label:"Slides per group",changeProp:!0,min:1,value:1},{type:"number",name:"mobileSpaceBetween",label:"Space between",changeProp:!0,min:0,value:0}]}},tablet:{category:Ki,type:"checkbox",label:"Enable tablet breakpoint",value:!1,subTraits:{true:[{type:"number",name:"tabletBreakpoint",label:"Tablet breakpoint",tip:"Slide values below will be applied when the screen width is greater than this value",changeProp:!0,min:1,value:991},{type:"number",name:"tabletSlidesPerView",label:"Slides per view",changeProp:!0,min:1,value:1},{type:"number",name:"tabletSlidesPerGroup",label:"Slides per group",changeProp:!0,min:1,value:1},{type:"number",name:"tabletSpaceBetween",label:"Space between",changeProp:!0,min:0,value:0}]}},allowTouchMove:{category:Ui,type:"checkbox",label:"Allow touch move",tip:"Allow touch interactions",value:!0},grabCursor:{category:Ui,type:"checkbox",label:"Grab cursor",tip:'If enabled, the user will see the "grab" cursor when hover the slider',value:!1}},Ji="Slider",Ts="swiper",Jt=`${Ts}-`,pp=(n,e)=>{const{Components:t,Blocks:o,Commands:s}=n,{block:r}=e,i=Qd(up),l="core:preview",a=s.events,c=function(p){const h=this,f=window,m=h.__onLoad,g=h.__activeSlide,v=h.__inPreview,{cdnScript:w,cdnStyle:y,slidesPerView:b}=p||{},x=C=>isNaN(C)?void 0:parseFloat(C),S=()=>{const C={loop:p.loop,speed:p.speed,initialSlide:p.initialSlide,direction:p.vertical?"vertical":"horizontal",effect:p.effect,freeMode:p.freeMode,parallax:p.parallax,autoHeight:p.autoHeight,allowTouchMove:p.allowTouchMove,grabCursor:p.grabCursor,simulateTouch:!0,breakpoints:{},slidesPerView:isNaN(b)?b:x(b),slidesPerGroup:x(p.slidesPerGroup),spaceBetween:x(p.spaceBetween),slidesOffsetBefore:x(p.slidesOffsetBefore),slidesOffsetAfter:x(p.slidesOffsetAfter),centeredSlides:p.centeredSlides,fadeEffect:{crossFade:p.crossFade},cubeEffect:{shadow:p.cubeEffectShadow,slideShadows:p.cubeEffectSlideShadows,shadowOffset:x(p.cubeEffectShadowOffset),shadowScale:x(p.cubeEffectShadowScale)},coverflowEffect:{depth:x(p.coverflowEffectDepth),modifier:x(p.coverflowEffectModifier),rotate:x(p.coverflowEffectRotate),scale:x(p.coverflowEffectScale),stretch:x(p.coverflowEffectStretch),slideShadows:p.coverflowEffectSlideShadows},flipEffect:{limitRotation:p.flipEffectLimitRotation,slideShadows:p.flipEffectSlideShadows},cardsEffect:{perSlideOffset:x(p.cardsEffectPerSlideOffset),perSlideRotate:x(p.cardsEffectPerSlideRotate),rotate:p.cardsEffectRotate,slideShadows:p.cardsEffectSlideShadows},navigation:{nextEl:h.querySelector(".swiper-button-next"),prevEl:h.querySelector(".swiper-button-prev")},pagination:{type:p.pagination||"bullets",dynamicBullets:p.dynamicBullets,clickable:p.clickableBullets,progressbarOpposite:p.progressbarOpposite,el:h.querySelector(".swiper-pagination")},scrollbar:{el:h.querySelector(".swiper-scrollbar"),draggable:p.scrollbarDraggable,hide:p.scrollbarHide},autoplay:p.autoplay&&{delay:p.autoplayDelay,disableOnInteraction:p.autoplayDisableOnInteraction,pauseOnMouseEnter:p.autoplayPauseOnMouseEnter,reverseDirection:p.autoplayReverseDirection,stopOnLastSlide:p.autoplayStopOnLastSlide,waitForTransition:p.autoplayWaitForTransition}};if(p.tablet){const{tabletBreakpoint:T,tabletSlidesPerView:M}=p,P=x(T);C.breakpoints[P]={slidesPerView:isNaN(M)?M:x(M),slidesPerGroup:x(p.tabletSlidesPerGroup),spaceBetween:x(p.tabletSpaceBetween)}}if(p.mobile){const{mobileBreakpoint:T,mobileSlidesPerView:M}=p,P=x(T);C.breakpoints[P]={slidesPerView:isNaN(M)?M:x(M),slidesPerGroup:x(p.mobileSlidesPerGroup),spaceBetween:x(p.mobileSpaceBetween)}}m&&!v&&(C.simulateTouch=!1),g&&(C.initialSlide=g);const E=new f.Swiper(h,C);m==null||m(E)};if(f.Swiper)S();else{const{head:C}=document,E=Array.isArray(w)?[...w]:[w],T=Array.isArray(y)?[...y]:[y],M=I=>{if(I.length){const N=document.createElement("link");N.href=I.shift(),N.rel="stylesheet",C.appendChild(N),M(I)}},P=I=>{if(I.length){const N=document.createElement("script");N.src=I.shift(),N.onerror=N.onload=P.bind(null,I),C.appendChild(N)}else S()};M(T),P(E)}},d=(p=0)=>({type:mn,style:{padding:"50px"},components:{type:"text",components:{type:"textnode",content:`Slide ${p}`}}}),u=t.getType("default").model;return t.addType(we,{block:r&&{label:Ji,media:le.slider,category:"Extra",select:!0,...e.block},isComponent:p=>ut(p,Ts),model:{defaults:()=>({name:Ji,icon:le.slider,classes:Ts,draggable:(p,h)=>!h.is(we),components:[{type:qt,components:[d(1),d(2),d(3)]},{type:Ut}],script:c,cdnScript:e.cdnScript,cdnStyle:e.cdnStyle,"script-props":["cdnScript","cdnStyle",...i.propKeys],...i.props,traits:[...i.traits]}),init(){const{em:p}=this;eu(this,i.traits),tu(this,i.propKeys),this.listenTo(p,`${a.runCommand}${l}`,this.onPreviewOn),this.listenTo(p,`${a.stopCommand}${l}`,this.onPreviewOff)},onPreviewOn(){this.__inPreview=!0,this.reloadSlider()},onPreviewOff(){this.__inPreview=!1,this.reloadSlider()},reloadSlider(){this.trigger("rerender")},addSlide(){const p=this.findFirstType(qt);p==null||p.append(this.getNewSlideComponentDef())},getNewSlideComponentDef(){var h;const p=((h=this.findFirstType(qt))==null?void 0:h.components().length)||0;return{type:mn,components:{type:"text",components:{type:"textnode",content:`Slide ${p+1}`}}}},toJSON(...p){const h=u.prototype.toJSON.apply(this,p);return i.propsNoValues.forEach(f=>delete h[f]),delete h["script-props"],h}},view:{init(){this.listenTo(this.model,t.events.scriptUnmount,this.destroySwiper)},getSwiper(){return this.el.swiper},destroySwiper(){var p;(p=this.getSwiper())==null||p.destroy()},onRender(){const p=this.el;p.__onLoad=h=>h.on("slideChange",()=>this.__activeSlide=h.activeIndex),p.__activeSlide=this.__activeSlide,p.__inPreview=this.model.__inPreview}}}),()=>{t.removeType(we),o.remove(we)}},hp="Nav Prev",fp="Nav Next",fo=`${Jt}button-prev`,mo=`${Jt}button-next`,mp=n=>{const{Components:e}=n,t=o=>({type:"svg",selectable:!1,hoverable:!1,attributes:{viewBox:"0 0 27 44"},components:{type:"svg-in",tagName:"path",attributes:{d:o,fill:"currentColor"}}});return e.addType(Kt,{isComponent:o=>ut(o,fo),model:{defaults:{name:hp,classes:fo,copyable:!1,highlightable:!1,droppable:!1,draggable:!1,selectable:!1,hoverable:!1,layerable:!1,components:t("M0,22L22,0l2.1,2.1L4.2,22l19.9,19.9L22,44L0,22L0,22L0,22z"),styles:`
|
|
100
|
+
.${fo} {
|
|
101
101
|
color: inherit;
|
|
102
102
|
}
|
|
103
|
-
.${
|
|
103
|
+
.${fo}:after {
|
|
104
104
|
content: none;
|
|
105
105
|
}
|
|
106
|
-
`}}}),e.addType(
|
|
107
|
-
.${
|
|
106
|
+
`}}}),e.addType(ho,{extend:Kt,isComponent:o=>ut(o,mo),model:{defaults:{name:fp,classes:mo,components:t("M27,22L27,22L5,44l-2.1-2.1L22.8,22L2.9,2.1L5,0L27,22L27,22z"),styles:`
|
|
107
|
+
.${mo} {
|
|
108
108
|
color: inherit;
|
|
109
109
|
}
|
|
110
|
-
.${
|
|
110
|
+
.${mo}:after {
|
|
111
111
|
content: none;
|
|
112
112
|
}
|
|
113
|
-
`}}}),()=>{e.removeType(
|
|
113
|
+
`}}}),()=>{e.removeType(Kt),e.removeType(ho)}},gp=n=>{const{Components:e}=n,t=`${Jt}pagination`;return e.addType(Ut,{isComponent:o=>ut(o,t),model:{defaults:{name:"Pagination",classes:t,copyable:!1,highlightable:!1,droppable:!1,draggable:!1,selectable:!1,hoverable:!1,layerable:!1,styles:`
|
|
114
114
|
.${t}-bullet-active {
|
|
115
115
|
background-color: currentColor;
|
|
116
116
|
}
|
|
117
117
|
.${t}-progressbar-fill {
|
|
118
118
|
--swiper-pagination-color: currentColor;
|
|
119
119
|
}
|
|
120
|
-
`}}}),()=>{e.removeType(
|
|
121
|
-
.${
|
|
120
|
+
`}}}),()=>{e.removeType(Ut)}},yp="Scrollbar",Yi=`${Jt}scrollbar`,bp=n=>{const{Components:e}=n;return e.addType(gn,{isComponent:t=>ut(t,Yi),model:{defaults:{name:yp,classes:Yi,copyable:!1,highlightable:!1,removable:!1,selectable:!1,hoverable:!1,layerable:!1,droppable:!1,draggable:!1}}}),()=>{e.removeType(gn)}},vp="Slide",Zi=`${Jt}slide`,xp=n=>{const{Components:e}=n;return e.addType(mn,{isComponent:t=>ut(t,Zi),model:{defaults:{name:vp,classes:Zi,icon:le.slider,draggable:(t,o)=>o.is(qt)}}}),()=>{e.removeType(mn)}},Sp="Wrapper",Xi=`${Jt}wrapper`,wp=n=>{const{Components:e}=n,{events:t}=e;return e.addType(qt,{isComponent:o=>ut(o,Xi),model:{defaults:{name:Sp,icon:le.slider,classes:Xi,copyable:!1,removable:!1,draggable:!1,highlightable:!1,droppable:o=>o.is(mn)},init(){const o=this.components();this.listenTo(o,"add remove",this.updateSlider)},updateSlider(o){const s=this.closestType(we);if(s){const r=s.getView();s.reloadSlider(),this.em.once(t.scriptMount,()=>{setTimeout(()=>{var i;return(i=r.getSwiper())==null?void 0:i.slideTo(o.index())},100)})}}}}),()=>{e.removeType(qt)}},Cp="swiperComponent",kp=F.startup,Tp=G(function(n,e={}){const t={block:{},cdnScript:"https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js",cdnStyle:"https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css",...e},o=[pp(n,t),mp(n),wp(n),xp(n),gp(n),bp(n)];W({editor:n,plan:kp,licenseKey:t.licenseKey,pluginName:Cp,cleanup:()=>{o.forEach(s=>s())}})}),pe="accordion",yn=`${pe}-group`,$e=`${pe}-header`,Ue=`${pe}-content`,gt=`${pe}-marker`,Qi=`${Ae}${$e}`,Ms=`${Ae}${gt}`,Mp=`${Ae}${Ue}`,el=`${Ms}-open`,yt={accordion:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M5.616 20q-.691 0-1.153-.462T4 18.384V5.616q0-.691.463-1.153T5.616 4h12.769q.69 0 1.153.463T20 5.616v12.769q0 .69-.462 1.153T18.384 20zm0-1h12.769q.23 0 .423-.192t.192-.424V8.154H5v10.23q0 .232.192.424t.423.192"/></svg>',accordionGroup:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M8.116 16h10.769q.23 0 .423-.192t.192-.423V6h-12v9.385q0 .23.192.423t.423.192m0 1q-.69 0-1.153-.462T6.5 15.385V4.615q0-.69.463-1.153T8.116 3h10.769q.69 0 1.153.462t.462 1.153v10.77q0 .69-.462 1.152T18.884 17zm-3 3q-.69 0-1.153-.462T3.5 18.385V6.615h1v11.77q0 .23.192.423t.423.192h11.77v1zM7.5 4v12z"/></svg>',accordionHeader:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M5.616 20q-.691 0-1.153-.462T4 18.384V5.616q0-.691.463-1.153T5.616 4h12.769q.69 0 1.153.463T20 5.616v12.769q0 .69-.462 1.153T18.384 20zm0-1h12.769q.23 0 .423-.192t.192-.424V5.616q0-.231-.192-.424T18.384 5H5.616q-.231 0-.424.192T5 5.616v12.769q0 .23.192.423t.423.192M5 5v14zm2.616 4.192h6q.413 0 .706-.293q.294-.293.294-.707t-.294-.706q-.293-.294-.706-.294h-6q-.414 0-.707.294t-.293.706t.293.707t.707.293"/></svg>',accordionContent:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M4.616 19q-.691 0-1.153-.462T3 17.384V6.616q0-.691.463-1.153T4.615 5h14.77q.69 0 1.152.463T21 6.616v10.769q0 .69-.463 1.153T19.385 19zm0-1h14.769q.23 0 .423-.192t.192-.424V6.616q0-.231-.192-.424T19.385 6H4.615q-.23 0-.423.192T4 6.616v10.769q0 .23.192.423t.423.192M4 18V6zm2.23-2.116h11.54q.213 0 .356-.143t.143-.357t-.143-.356t-.357-.144H6.231q-.214 0-.357.144q-.143.143-.143.357q0 .213.143.356t.357.144m0-3.385h11.538q.214 0 .357-.143t.143-.357t-.143-.357t-.357-.143H6.231q-.214 0-.357.143T5.731 12t.143.357t.357.143m0-3.384H14q.214 0 .357-.144q.143-.143.143-.356q0-.214-.143-.357T14 8.116H6.23q-.213 0-.356.143t-.143.357t.143.356t.357.144"/></svg>',accordionMarker:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="m12 15.596l3.173-3.192H8.827zM5.616 20q-.672 0-1.144-.472T4 18.385V5.615q0-.67.472-1.143Q4.944 4 5.616 4h12.769q.67 0 1.143.472q.472.472.472 1.144v12.769q0 .67-.472 1.143q-.472.472-1.143.472zM5 9v9.385q0 .23.192.423t.423.192h12.77q.23 0 .423-.192t.192-.423V9z"/></svg>',caret:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m7.4 8.6 4.6 4.6 4.6-4.6L18 10l-6 6-6-6 1.4-1.4Z"/></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>'},tl=(n,e)=>{const{toolbarIconOpen:t=yt.eye}=e,o=n.is(pe)?n:n.closestType(pe);if(!t||!o)return;const{toolbar:s}=n,r={id:"accordion-toggle-open",label:t,command:()=>o.toggleOpen()};!s.find(l=>l.id===r.id)&&(s==null||s.unshift(r))},Ep=(n,e)=>{const{Components:t,Blocks:o}=n,{block:s={}}=e,r="Accordion",i=`${Ae}${pe}`,l=function(a={}){const c=this,d=()=>{const{clsMarkerOpen:u}=a,p=c.querySelector('[data-type-role="accordion-marker"]');!p||!u||(c.open?p.classList.add(u):p.classList.remove(u))};c.addEventListener("toggle",()=>{d(),c.dispatchEvent(new CustomEvent("details-toggle",{bubbles:!0}))}),d()};return t.addType(pe,{block:s&&{label:r,media:yt.accordion,category:"Extra",select:!0,...s},isComponent:qe(pe),extendFn:["initToolbar"],model:{defaults:{tagName:"details",name:r,classes:i,emptyState:!0,clsMarkerOpen:el,attributes:{[ze]:pe},droppable:ls($e,Ue),components:[{type:$e},{type:Ue}],"script-props":["clsMarkerOpen"],script:l,traits:[{type:"checkbox",name:"open",label:"Open"}],styles:`
|
|
121
|
+
.${i}::details-content {
|
|
122
122
|
opacity: 0;
|
|
123
123
|
block-size: 0;
|
|
124
124
|
overflow: hidden;
|
|
@@ -129,45 +129,45 @@
|
|
|
129
129
|
transition-duration: 0.2s;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
.${
|
|
132
|
+
.${i}[open]::details-content {
|
|
133
133
|
opacity: 1;
|
|
134
134
|
transform: translateY(0);
|
|
135
135
|
block-size: auto;
|
|
136
136
|
}
|
|
137
|
-
`},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){
|
|
137
|
+
`},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){tl(this,e)}}}),()=>{o.remove(pe),t.removeType(pe)}},Ap=n=>{const{Components:e}=n;return e.addType(Ue,{isComponent:qe(Ue),model:{defaults:{name:"Accordion Content",removable:!1,copyable:!1,draggable:!1,emptyState:!0,classes:Mp,icon:yt.accordionContent,attributes:{[ze]:Ue},components:"<div>Accordion content</div>"}}}),()=>{e.removeType(Ue)}},Pp=(n,e)=>{const{Components:t,Blocks:o}=n,{blockGroup:s={}}=e,r="Accordion Group",i=function(a={}){if(!a.single)return;const c=this;c.addEventListener("details-toggle",d=>{const u=d.target;if(!a.single||!u||!u.open)return;c.querySelectorAll('[data-type-role="accordion"]').forEach(h=>{u!==h&&h.open&&(h.open=!1)})})},l=(a={})=>({type:pe,attributes:{open:a.open},components:[{type:$e,components:[`<div>${a.header}</div>`,{type:gt}]},{type:Ue,components:`<div>${a.content}</div>`}]});return t.addType(yn,{block:s&&{label:r,media:yt.accordionGroup,category:"Extra",select:!0,...s},isComponent:qe(yn),model:{defaults:{name:r,attributes:{[ze]:yn},droppable:ls(pe),single:!0,emptyState:!0,components:Array(3).fill(0).map((a,c)=>l({open:c===0,header:`Accordion header ${c+1}`,content:`Accordion content ${c+1}`})),traits:[{type:"checkbox",name:"single",changeProp:!0,tip:"Only one accordion can be open at a time",label:"Single open"}],"script-props":["single"],script:i}}}),()=>{o.remove(yn),t.removeType(yn)}},Np=(n,e)=>{const{Components:t}=n;return t.addType($e,{isComponent:qe($e),extendFn:["initToolbar"],model:{defaults:{tagName:"summary",name:"Accordion Header",removable:!1,copyable:!1,draggable:!1,emptyState:!0,icon:yt.accordionHeader,classes:Qi,attributes:{[ze]:$e},components:["<div>Accordion header</div>",{type:gt}],styles:`
|
|
138
138
|
summary {
|
|
139
139
|
list-style: none;
|
|
140
140
|
}
|
|
141
|
-
.${
|
|
141
|
+
.${Qi} {
|
|
142
142
|
cursor: pointer;
|
|
143
143
|
display: flex;
|
|
144
144
|
align-items: center;
|
|
145
145
|
justify-content: space-between;
|
|
146
146
|
gap: 1rem;
|
|
147
147
|
}
|
|
148
|
-
`},initToolbar(){
|
|
149
|
-
.${
|
|
148
|
+
`},initToolbar(){tl(this,e)}}}),()=>{t.removeType($e)}},Op=n=>{const{Components:e}=n;return e.addType(gt,{extend:"icon",isComponent:qe(gt),model:{defaults:{name:"Accordion Marker",icon:yt.accordionMarker,classes:Ms,attributes:{[ze]:gt},components:yt.caret,droppable:!1,draggable:as($e),styles:`
|
|
149
|
+
.${Ms} {
|
|
150
150
|
min-width: 24px;
|
|
151
151
|
width: 24px;
|
|
152
152
|
height: 24px;
|
|
153
153
|
transition: transform 0.2s ease-in-out;
|
|
154
154
|
}
|
|
155
|
-
.${
|
|
155
|
+
.${el} {
|
|
156
156
|
transform: rotateZ(180deg);
|
|
157
157
|
}
|
|
158
|
-
`}}}),()=>{e.removeType(gt)}},
|
|
159
|
-
${u.map(
|
|
160
|
-
</div>`,a=(u,
|
|
161
|
-
.${
|
|
158
|
+
`}}}),()=>{e.removeType(gt)}},Ip="accordionComponent",Rp=F.startup,Dp=G(function(n,e={}){const t=[Ep(n,e),Pp(n,e),Np(n,e),Op(n),Ap(n)];W({editor:n,licenseKey:e.licenseKey,plan:Rp,pluginName:Ip,cleanup:()=>{t.forEach(o=>o())}})}),Yn=class Yn{constructor(e){this.config=e}getSize(e){var t;return(t=this.config)!=null&&t.getSize?this.config.getSize(e):Is(e.componentColumn,Yn.CSS_FLEX_BASIS)}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:o,sizeValue:s,partial:r}=e;o.addStyle({[Yn.CSS_FLEX_BASIS]:s},{partial:r})}}};Yn.CSS_FLEX_BASIS="flex-basis";let Es=Yn;const Zn=class Zn{constructor(e){this.config=e}isGapSupported(){return!0}getGap(e){var t;return(t=this.config)!=null&&t.getGap?this.config.getGap(e):Is(e.componentRow,Zn.CSS_GAP)}setGap(e){var t;if((t=this.config)!=null&&t.setGap)this.config.setGap(e);else{const{componentRow:o,gapValue:s,partial:r}=e;o.addStyle({[Zn.CSS_GAP]:s},{partial:r})}}};Zn.CSS_GAP="gap";let As=Zn;const ss=class ss{constructor(e){this.config=e}getParentSize(e){var r;if((r=this.config)!=null&&r.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:o}=e,s=t.getEl();return s?o?s.clientHeight:s.clientWidth:0}isLayoutVertical(e){var o;if((o=this.config)!=null&&o.isParentVertical)return this.config.isParentVertical(e);const t=Is(e.componentRow,ss.CSS_FLEX_DIRECTION,!0);return t==="column"||t==="column-reverse"}};ss.CSS_FLEX_DIRECTION="flex-direction";let Ps=ss;const Xn=class Xn{constructor(e){this.config=e}getSize(e){var o;if((o=this.config)!=null&&o.getSize)return this.config.getSize(e);const t=e.componentColumn;if(t.is(Xn.MJML_COLUMN_TYPE)){const r=t.getAttributes().width;if(r&&(r.includes("%")||!isNaN(parseFloat(r))))return parseFloat(r);const i=t.parent();return 100/(i?i.components().length:1)}return 0}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:o,sizeValue:s,partial:r}=e;o.is(Xn.MJML_COLUMN_TYPE)&&o.addAttributes({width:`${parseFloat(s)}%`},{partial:r})}}};Xn.MJML_COLUMN_TYPE="mj-column";let Ns=Xn;const rs=class rs{constructor(e){this.config=e}isGapSupported(){return!1}getGap(e){var o;if((o=this.config)!=null&&o.getGap)return this.config.getGap(e);const{componentRow:t}=e;if(t.is(rs.MJML_SECTION_TYPE)){const s=t.getAttributes();if(s&&s.padding)return parseInt(s.padding,10)||0}return 0}setGap(e){var t,o;(o=(t=this.config)==null?void 0:t.setGap)==null||o.call(t,e)}};rs.MJML_SECTION_TYPE="mj-section";let Os=rs;class Lp{constructor(e){this.config=e}getParentSize(e){var i;if((i=this.config)!=null&&i.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:o}=e,s=t.getEl();if(!s)return 0;let r=s;if(s.tagName!=="TABLE"){const l=s.querySelectorAll("table");l.length&&(r=l[0])}return o?r.clientHeight:r.clientWidth}isLayoutVertical(e){var t;return(t=this.config)!=null&&t.isParentVertical?this.config.isParentVertical(e):!1}}class Yt{constructor(){this.handlerCache=new Map}static getInstance(){return Yt.instance||(Yt.instance=new Yt),Yt.instance}getHandlers(e){const t=`${e.projectType}-${e.disableGapHandler?"nogap":"gap"}`;return this.handlerCache.has(t)||(Zt(e)?this.handlerCache.set(t,{sizeHandler:new Ns(e),gapHandler:new Os(e),parentSizeHandler:new Lp(e)}):this.handlerCache.set(t,{sizeHandler:new Es(e),gapHandler:new As(e),parentSizeHandler:new Ps(e)})),this.handlerCache.get(t)}}function bt(n){return Yt.getInstance().getHandlers(n)}const nl=n=>{n.style.display="none"},ol=n=>{n.style.display="block"},bn=n=>+parseFloat(`${n}`).toFixed(2),Zt=n=>n.projectType===li.email,go=(n,e)=>{const t=n.Canvas.getFramesEl();t&&(t.style.pointerEvents=e?"none":"")},zp=n=>n?["top","bottom"]:["left","right"],$p=n=>{const e=n.parent();return e?e.components().models.indexOf(n)===0:!1},Vp=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.indexOf(n)===t.length-1},Bp=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.length>1&&n.index()===t.length-1},Hp=(n,e,t,o)=>{const r=n+(t?e==="top"?-1:e==="bottom"?1:0:e==="left"?-1:e==="right"?1:0);return r>=0&&r<o?r:-1},yo=n=>n==="top"||n==="bottom",Fp=(n,e)=>!!($p(n)&&(e==="left"||e==="top")||Vp(n)&&(e==="right"||e==="bottom")),_p=n=>{const e=n.parent();return e?e.components().models.length>1:!1},sl=(n,e)=>n==="right"||n==="bottom"?e>0:e<0,Is=(n,e,t=!1)=>{const o=!t,s=n.getEl();if(!s)return o?0:"";const i=window.getComputedStyle(s)[e]||"";if(o){let l;return typeof i=="string"?(l=parseFloat(i.replace(/[^-\d.]/g,"")),isNaN(l)&&(l=0)):l=Number(i)||0,l}return i},rl=(n,e,t)=>{const o=Rs({componentRow:n,isVertical:e},t),s=n.components().models;return o*(s.length-1)},vn=(n,e)=>bt(e).parentSizeHandler.isLayoutVertical({componentRow:n}),xn=(n,e)=>bt(e).sizeHandler.getSize(n),Rs=(n,e)=>{if(e!=null&&e.disableGapHandler)return 0;const{gapHandler:t,parentSizeHandler:o}=bt(e);if(!t.isGapSupported())return 0;const s=t.getGap(n),r=o.getParentSize(n);return s/100*r},Ds=(n,e)=>bt(e).parentSizeHandler.getParentSize(n),Sn=(n,e)=>{bt(e).sizeHandler.setSize(n)},il=(n,e)=>{const t=xn(n,e);Sn({...n,sizeValue:`${t}%`,partial:!1},e)},ll=(n,e)=>{if(e!=null&&e.disableGapHandler)return;const{gapHandler:t}=bt(e);t.isGapSupported()&&t.setGap(n)},Gp=(n,e)=>{const t=n.getStyle().gap;if(!t)return;const o=n.components().models,s={componentRow:n,isVertical:vn(n,e)};o.map(r=>il({...s,componentColumn:r},e)),ll({...s,gapValue:String(t),partial:!1},e)};function Wp(n,e){const{Blocks:t}=n,{typeColumn:o,typeRow:s,blocks:r}=e;if(r===!1||Zt(e))return;const i=u=>({type:s,components:u.map(p=>({type:o,style:{"flex-basis":`${p}%`}}))}),l=u=>`<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
|
|
159
|
+
${u.map(p=>`<div style="flex-basis: ${p}%; border-color: currentColor; border-width: 2px; border-radius: 0.12rem;"></div>`).join("")}
|
|
160
|
+
</div>`,a=(u,p)=>({id:`flex-row-${p.join("-")}`,label:u,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:l(p),content:i(p)}),c=[a("1 Column",[100]),a("2 Columns 50/50",[50,50]),a("2 Columns 25/75",[25,75]),a("2 Columns 75/25",[75,25]),a("3 Columns",[33.33,33.33,33.33]),a("3 Columns 50/25/25",[50,25,25]),a("3 Columns 25/50/25",[25,50,25]),a("3 Columns 25/25/50",[25,25,50]),a("4 Columns",[25,25,25,25]),a("5 Columns",[20,20,20,20,20])],d=$t(r)?r({blocks:c}):c;return d.forEach(u=>t.add(u.id,u)),()=>{d.forEach(u=>t.remove(u.id))}}const jp=(n,e)=>{const{Components:t}=n,{typeRow:o,typeColumn:s,extendTypeColumn:r}=e,i=`${Ae}${s}`,a=!!s&&!!t.getType(s)&&!r;if(!(!s||a||Zt(e)))return t.addType(s,{isComponent:qe(s),model:{defaults:{name:"Column",resizable:!1,emptyState:!0,classes:i,icon:'<svg viewBox="0 0 24 24"><path d="M14.5 2.3A1.8 1.8 0 0 0 12.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8zm-8 0A1.8 1.8 0 0 0 4.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',draggable:as(o),attributes:{[ze]:s},styles:`
|
|
161
|
+
.${i} {
|
|
162
162
|
flex-grow: 1;
|
|
163
163
|
}
|
|
164
|
-
`}}}),()=>{t.removeType(s)}},
|
|
165
|
-
.${
|
|
164
|
+
`}}}),()=>{t.removeType(s)}},qp=(n,e)=>{const{Components:t}=n,{typeRow:o,typeColumn:s,extendTypeRow:r}=e,i=`${Ae}${o}`,a=!!o&&!!t.getType(o)&&!r;if(!(!o||a||Zt(e)))return t.addType(o,{isComponent:qe(o),model:{defaults:{name:"Row",classes:i,icon:'<svg viewBox="0 0 24 24"><path d="M4 4.8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3A1.8 1.8 0 0 0 20 4.7zm0 8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',emptyState:{styleIn:"width: 100%"},attributes:{[ze]:o},droppable:ls(s),traits:[{type:"checkbox",name:"snap",label:"Enable Snap",default:e.snapEnabled,changeProp:!0},{type:"number",name:"snap-divisions",label:"Snap Divisions",min:1,max:12,step:1,default:e.snapDivisions,changeProp:!0}],resizable:{tl:0,tc:0,tr:0,cl:0,bl:0,br:0},styles:`
|
|
165
|
+
.${i} {
|
|
166
166
|
display: flex;
|
|
167
167
|
align-items: stretch;
|
|
168
168
|
flex-wrap: nowrap;
|
|
169
169
|
}
|
|
170
|
-
`}}}),()=>{t.removeType(o)}}
|
|
170
|
+
`}}}),()=>{t.removeType(o)}},Kp="flexComponent",Up=F.startup;class Jp{constructor(){this.resizableChildTypes=new Set,this.gapAdjustableParentTypes=new Set,this.typeRelationships=new Map}registerResizableChild(e){this.resizableChildTypes.add(e)}registerGapAdjustableParent(e){this.gapAdjustableParentTypes.add(e)}registerTypeRelationship(e,t){this.typeRelationships.has(e)||this.typeRelationships.set(e,new Set),this.typeRelationships.get(e).add(t),this.registerResizableChild(t),this.registerGapAdjustableParent(e)}isResizableChild(e){return this.resizableChildTypes.has(e.get("type"))}isGapAdjustableParent(e){return this.gapAdjustableParentTypes.has(e.get("type"))}isValidRelationship(e,t){const o=e.get("type"),s=t.get("type");return this.typeRelationships.has(o)?this.typeRelationships.get(o).has(s):!1}}class Yp{constructor(e,t,o){this.editor=e,this.registry=t,this.opts=o,this.resizeState=new WeakMap}getState(e){return this.resizeState.has(e)||this.resizeState.set(e,{}),this.resizeState.get(e)}clearState(e){return this.resizeState.delete(e)}startResize(e,t,o){const{opts:s}=this,r=this.getState(e);r.direction=t,r.startX=o.clientX,r.startY=o.clientY,r.resizing=!0,r.lastSnappedPercent=void 0;const i=e.parent();if(!i||!this.registry.isValidRelationship(i,e))return;r.snapEnabled=i.get("snap")??s.snapEnabled,r.snapDivisions=i.get("snap-divisions")??s.snapDivisions??12;const l=i.components().models,a=l.findIndex(p=>p.cid===e.cid),c=vn(i,s),d=Hp(a,t,c,l.length);d!==-1&&(r.adjacentIdx=d);const u={componentColumn:e,componentRow:i,isVertical:c};if(r.startPercent=xn(u,s),typeof r.adjacentIdx<"u"){const p=l[r.adjacentIdx];r.neighborStartPercent=xn({...u,componentColumn:p},s)}}updateResizeByDelta(e,t,o){const s=this.getState(e),r=e.parent();!s.resizing||!r||(s.snapEnabled?this.updateSnapResize(e,t,o):this.updateContinuesResize(e,t,o))}finishResize(e){const t=e.parent(),o=t==null?void 0:t.components().models,s={componentRow:t,isVertical:!!t&&vn(t,this.opts)};o==null||o.forEach(r=>il({...s,componentColumn:r},this.opts)),this.clearState(e)}updateContinuesResize(e,t,o){const s=this.getState(e),r=e.parent(),{opts:i}=this;if(!r)return;const l=i.minItemPercent??0,a=yo(t),c=Ds({componentRow:r,isVertical:a},i),d=rl(r,a,this.opts),p=100-d/c*100,h=o/(c-d)*p,{startPercent:f=0,neighborStartPercent:m=0}=s,g={componentRow:r,isVertical:a,componentColumn:e,partial:!0},v=sl(t,o)?f+Math.abs(h):f-Math.abs(h);if(typeof s.adjacentIdx<"u"){const w=r.components().models[s.adjacentIdx],y=f+m,b=y-l,S=Math.min(b,Math.max(l,v)),C=y-S;Sn({...g,sizeValue:`${bn(S)}%`},i),Sn({...g,componentColumn:w,sizeValue:`${bn(C)}%`},i)}else{const w=Math.max(l,Math.min(p,v));Sn({...g,sizeValue:`${bn(w)}%`},i)}}updateSnapResize(e,t,o){const s=this.getState(e),r=e.parent(),i=yo(t),l=Ds({componentRow:r,isVertical:i},this.opts),a=rl(r,i,this.opts),c=l-a,d=o/c*100,u=sl(t,o),{startPercent:p=0,snapDivisions:h=12}=s,f=u?p+Math.abs(d):p-Math.abs(d),m=100/h,g=Math.floor(f/m)*m,v=Math.ceil(f/m)*m,w=Math.abs(v-f),y=Math.abs(f-g),b=m*.2,x=w<y?v:g;if(x>0&&x<100&&(w<b||y<b)&&s.lastSnappedPercent!==x){s.lastSnappedPercent=x;let E=Math.abs(x-p)/100*c;(u&&(t==="left"||t==="top")||!u&&(t==="right"||t==="bottom"))&&(E=-E),this.updateContinuesResize(e,t,E)}else w>=b&&y>=b&&(s.lastSnappedPercent=void 0)}}class Zp{constructor(e,t,o){this.editor=e,this.registry=t,this.opts=o}updateGapByDelta(e,t,o,s){if(!this.registry.isGapAdjustableParent(e))return;const{opts:r}=this,i=Math.max(0,o+t),l=Ds({componentRow:e,isVertical:s},r),a=i/l*100,c=e.components().models,d=c.length-1,u={componentRow:e,isVertical:s},p=c.reduce((b,x)=>b+xn({...u,componentColumn:x},r),0),f=100-a*d,m=r.minItemPercent||5;if(f<m*c.length)return;const v=100-d*a,w=p-v,y={componentRow:e,isVertical:s,partial:!0};c.map(b=>{const x=xn({...u,componentColumn:b},r),S=x-x/p*w;Sn({...y,componentColumn:b,sizeValue:`${bn(S)}%`},r)}),ll({...y,gapValue:`${bn(a)}%`},r)}finishGapAdjust(e){Gp(e,this.opts)}}class Xp{constructor(e,t,o){this.editor=e,this.registry=t,this.opts=o,this.resizeHandler=new Yp(e,t,o),this.gapHandler=new Zp(e,t,o)}startResize(e,t,o){this.resizeHandler.startResize(e,t,o)}updateResizeByDelta(e,t,o){this.resizeHandler.updateResizeByDelta(e,t,o)}finishResize(e){this.resizeHandler.finishResize(e)}updateGapByDelta(e,t,o,s){this.gapHandler.updateGapByDelta(e,t,o,s)}finishGapAdjust(e){this.gapHandler.finishGapAdjust(e)}canResize(e){const t=e.parent();return t?this.registry.isValidRelationship(t,e):!1}canAdjustGap(e){return this.registry.isGapAdjustableParent(e)}}const bo="gs-flex-spots",al=`${bo}__handle-size`,Qp=`${bo}__handle-gap`;function eh(n,e){const{Canvas:t}=n,o="flex-resize-spot";let s,r,i,l,a=null,c=null;const d=new Jp,u=new Xp(n,d,e),p=()=>{var S;s=document.createElement("div"),s.className=bo,s.style.display="none",r=document.createElement("div"),r.className=`${bo}__handles`,r.style.position="absolute",r.style.pointerEvents="none",r.style.zIndex="21",i={left:document.createElement("div"),right:document.createElement("div"),top:document.createElement("div"),bottom:document.createElement("div")},Object.entries(i).forEach(([C,E])=>{const T=C,M=yo(T);E.className=`${al} ${al}-${T} gjs-resizer-h gjs-cv-unscale`,E.style.cssText=`
|
|
171
171
|
pointer-events: all;
|
|
172
172
|
position: absolute;
|
|
173
173
|
z-index: 1;
|
|
@@ -177,7 +177,7 @@
|
|
|
177
177
|
${T==="right"?"right: 0px;":""}
|
|
178
178
|
${T==="top"?"top: 0px;":""}
|
|
179
179
|
${T==="bottom"?"bottom: 0px;":""}
|
|
180
|
-
`,
|
|
180
|
+
`,E.addEventListener("pointerdown",h(T)),r.appendChild(E)}),!e.disableGapHandler&&!Zt(e)&&(l=document.createElement("div"),l.className=Qp,l.style.cssText=`
|
|
181
181
|
position: absolute;
|
|
182
182
|
background-color: var(--gs-theme-cl-cmp-bg1, #3b97e3);
|
|
183
183
|
border-width: 2px;
|
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
pointer-events: all;
|
|
188
188
|
max-width: 3rem;
|
|
189
189
|
max-height: 3rem;
|
|
190
|
-
`,l.addEventListener("pointerdown",f()),
|
|
190
|
+
`,l.addEventListener("pointerdown",f()),r.appendChild(l)),s.append(r),(S=t.getSpotsEl())==null||S.appendChild(s)},h=S=>C=>{if(!a)return;go(n,!0),C.stopPropagation(),C.preventDefault(),u.startResize(a,S,C);const E=C.clientX,T=C.clientY;C.target.setPointerCapture(C.pointerId);const M=I=>{const N=n.Canvas.getZoomMultiplier(),z=(I.clientX-E)*N,V=(I.clientY-T)*N,te=yo(S)?V:z;u.updateResizeByDelta(a,S,te)},P=()=>{go(n,!1),u.finishResize(a),C.target.releasePointerCapture(C.pointerId),document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",P)};document.addEventListener("pointermove",M),document.addEventListener("pointerup",P)},f=()=>S=>{if(!c)return;const C=c;go(n,!0),S.stopPropagation(),S.preventDefault();const E=vn(C,e),T=Rs({componentRow:C,isVertical:E},e),M=S.clientX,P=S.clientY;S.target.setPointerCapture(S.pointerId);const I=z=>{const V=n.Canvas.getZoomMultiplier(),te=E?(z.clientY-P)*V:(z.clientX-M)*V;u.updateGapByDelta(C,te,T,E)},N=()=>{go(n,!1),u.finishGapAdjust(C),S.target.releasePointerCapture(S.pointerId),document.removeEventListener("pointermove",I),document.removeEventListener("pointerup",N)};document.addEventListener("pointermove",I),document.addEventListener("pointerup",N)},m=S=>{const C=S.component;if(!C||!s||(a=C,c=C.parent(),!c))return;const E=c;ol(s);const T=S.getStyle();r&&Object.assign(r.style,T);const M=vn(E,e),P=zp(M);if(Object.values(i).forEach(nl),P.forEach(N=>{if(Fp(C,N))return;const z=i[N];ol(z)}),bt(e).gapHandler.isGapSupported()&&l&&_p(C)){const N=Rs({componentRow:E,isVertical:M},e);g(N,M,Bp(C))}},g=(S,C,E=!1)=>{const T=e.gapHandleSize,M=l.style;if(C){M.height=`${T}px`;const P=l.offsetHeight;E?(M.top=`-${(S+P)/2}px`,M.bottom=""):(M.bottom=`-${(S+P)/2}px`,M.top=""),M.width="50%",M.left="50%",M.transform="translateX(-50%)",M.cursor="row-resize"}else{M.width=`${T}px`;const P=l.offsetWidth;E?(M.left=`-${(S+P)/2}px`,M.right=""):(M.right=`-${(S+P)/2}px`,M.left=""),M.height="50%",M.top="50%",M.transform="translateY(-50%)",M.cursor="col-resize"}},v=()=>{s&&(nl(s),a=null,c=null)},w=()=>{t.removeSpots({type:o});const S=n.getSelected(),C=S==null?void 0:S.parent();S&&C&&d.isValidRelationship(C,S)?t.addSpot({type:o,component:S}):v()},y=()=>{const S=t.getSpots().filter(C=>C.type===o)[0];S&&m(S)},b=(S,C)=>{d.registerTypeRelationship(S,C)};n.onReady(()=>{p(),Zt(e)?b("mj-section","mj-column"):b(e.typeRow,e.typeColumn)});const x="component:toggled";return n.on(t.events.spot,y),n.on(x,w),()=>{n.off(t.events.spot,y),n.off(x,w)}}const th=G(function(n,e={}){const t={typeRow:"flex-row",typeColumn:"flex-column",gapHandleSize:3,snapDivisions:12,minItemPercent:5,...e},o=[qp(n,t),jp(n,t)],s=eh(n,t),r=Wp(n,t);W({editor:n,licenseKey:t.licenseKey,plan:Up,pluginName:Kp,cleanup:()=>{o.forEach(i=>i==null?void 0:i()),s(),r==null||r()}})}),nh=n=>n.dispatchEvent(new CustomEvent("input"));function oh(n,e){if(!e)return()=>{};const t=n.Components.events,o=d=>n.getSelectedAll().includes(d),s=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),r=d=>d.isChildOf("text"),i=d=>n.getEditing()===d,l=(d,u={})=>{d.trigger("focus",u.event)},a=(d,u)=>{o(d)&&s(d)&&!i(d)&&l(d,u)},c=(d,u)=>{if(o(d)&&!s(d)&&r(d)){const p=d.parents().find(h=>h.isInstanceOf("text"));p&&(l(p,u),setTimeout(()=>n.select(p),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const sh="rteTinyMce",rh=F.startup,ih=`
|
|
191
191
|
.tox .tox-toolbar,
|
|
192
192
|
.tox .tox-toolbar__overflow,
|
|
193
193
|
.tox .tox-toolbar__primary,
|
|
@@ -290,25 +290,25 @@
|
|
|
290
290
|
background-color: var(--gs-theme-cl-prm-bg1);
|
|
291
291
|
border-color: var(--gs-theme-cl-prm-bg3);
|
|
292
292
|
opacity: 0.75;
|
|
293
|
-
}`,Ps=new WeakMap,Xh=(n,e)=>{Ps.set(n,e)},Qh=n=>{Ps.delete(n)},Is=n=>Ps.get(n),yo=n=>{const e=n.target,t=e.closest(".tox"),o=e.matches(".ephox-snooker-resizer-bar");(t||o)&&n.stopPropagation()},tl=n=>{n.stopPropagation(),n.preventDefault()},ep=(n,e)=>{const t=n.getDoc(),o=n.getWin();if(e!=null&&e.event){const{event:s}=e,{clientX:i,clientY:r}=s;let l;if(t.caretRangeFromPoint)l=t.caretRangeFromPoint(i,r);else if(t.caretPositionFromPoint){const a=t.caretPositionFromPoint(i,r);l=t.createRange(),l==null||l.setStart(a.offsetNode,a.offset)}if(l){const a=o.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(l),n.selection.setRng(l)}}else n.execCommand("SelectAll")},tp=n=>{var c,d;const{el:e,editor:t,componentView:o}=n,s=t.runCommand(_.getStateTheme),i=o.model,r={target:e,inline:!0,skin:(s==null?void 0:s.theme)===Zi.dark?"oxide-dark":"oxide",menubar:!1,image_advtab:!0,paste_data_images:!0,statusbar:!1,branding:!1,forced_root_block:"div",plugins:"advlist autolink lists link image media table",toolbar_mode:"sliding",toolbar:"bold italic underline strikethrough forecolor backcolor alignleft aligncenter alignright alignjustify link image | fontfamily fontsize bullist numlist outdent indent table"},l=((d=(c=n.pluginOpts)==null?void 0:c.loadConfig)==null?void 0:d.call(c,{config:r,editor:t,componentView:o,component:i}))||{};return{...r,...l}},nl=(n,e=document)=>new Promise((t,o)=>{const s=Array.isArray(n)?[...n]:[n],{head:i}=e,r=l=>{if(l.length){const a=e.createElement("script");a.src=l.shift(),a.onload=r.bind(null,l),a.onerror=o,i.appendChild(a)}else t()};r(s)}),np=G(function(n,e={}){const t={cdnScript:"https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",...e},{cdnScript:o}=t,s=n.Canvas.events,i=!t.skipCustomTheme,r="gs-plg-tinymce-studio-theme",l=async(d,u)=>{const h=d.ownerDocument,p=h.defaultView,f=u==null?void 0:u.view;if(!p||!f){console.warn("Missing required data",{win:p,componentView:f});return}const m=tp({el:d,editor:n,componentView:f,pluginOpts:t}),b=(await p.tinymce.init(m))[0];if(!b)return;const y=(await window.tinymce.init({...m,target:document.createElement("div")}))[0];return b.ui.show(),h.body.addEventListener("mousedown",yo),document.body.addEventListener("mousedown",yo),b.on("Change",()=>Kh(d)),b.on("blur",()=>b.ui.show()),b.on("OpenWindow",function(){var S;const v=(S=h.querySelector(".tox-dialog"))==null?void 0:S.closest(".tox");v&&(v==null?void 0:v.ownerDocument)!==document&&(document.body.appendChild(v),b.once("CloseWindow",()=>{v&&v.ownerDocument===document&&h.body.appendChild(v)}))}),d.addEventListener("dragstart",tl,{capture:!0}),n.runCommand(_.setStateContextMenu,{enabled:!1}),ep(b,u),{rteEditor:b,rteEditorShallow:y}},a=(d,u)=>{d.ownerDocument.body.removeEventListener("mousedown",yo),document.body.removeEventListener("mousedown",yo),d.removeEventListener("dragstart",tl,{capture:!0}),n.runCommand(_.setStateContextMenu,{enabled:!0}),u.rteEditor.destroy(),u.rteEditorShallow.destroy()};n.on(s.frameLoad,async({window:d})=>{const u=d.document;nl(o,u)}),n.onReady(()=>{nl(o,document),i&&nr(r,Zh,{target:document.body})}),n.setCustomRte({parseContent:!0,async enable(d,u,h){const p=Is(d);if(p)return p.rteEditor;const f=await l(d,h);return f&&Xh(d,f),f==null?void 0:f.rteEditor},disable(d){const u=Is(d);u&&(Qh(d),a(d,u))},getContent(d){var h,p;const u=Is(d);return u?(p=(h=u.rteEditor).getContent)==null?void 0:p.call(h):d.innerHTML}});const c=Uh(n,t.enableOnClick);W({editor:n,licenseKey:t.licenseKey,plan:Yh,pluginName:Jh,cleanup:()=>{n.RichTextEditor.customRte=void 0,c()}})});function Z(n){this.content=n}Z.prototype={constructor:Z,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 o=t&&t!=n?this.remove(t):this,s=o.find(n),i=o.content.slice();return s==-1?i.push(t||n,e):(i[s+1]=e,t&&(i[s]=t)),new Z(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Z(t)},addToStart:function(n,e){return new Z([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Z(t)},addBefore:function(n,e,t){var o=this.remove(e),s=o.content.slice(),i=o.find(n);return s.splice(i==-1?s.length:i,0,e,t),new Z(s)},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=Z.from(n),n.size?new Z(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Z.from(n),n.size?new Z(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Z.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}},Z.from=function(n){if(n instanceof Z)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Z(e)};function ol(n,e,t){for(let o=0;;o++){if(o==n.childCount||o==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(o),i=e.child(o);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){for(let r=0;s.text[r]==i.text[r];r++)t++;return t}if(s.content.size||i.content.size){let r=ol(s.content,i.content,t+1);if(r!=null)return r}t+=s.nodeSize}}function sl(n,e,t,o){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:o};let r=n.child(--s),l=e.child(--i),a=r.nodeSize;if(r==l){t-=a,o-=a;continue}if(!r.sameMarkup(l))return{a:t,b:o};if(r.isText&&r.text!=l.text){let c=0,d=Math.min(r.text.length,l.text.length);for(;c<d&&r.text[r.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,o--;return{a:t,b:o}}if(r.content.size||l.content.size){let c=sl(r.content,l.content,t-1,o-1);if(c)return c}t-=a,o-=a}}class k{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let o=0;o<e.length;o++)this.size+=e[o].nodeSize}nodesBetween(e,t,o,s=0,i){for(let r=0,l=0;l<t;r++){let a=this.content[r],c=l+a.nodeSize;if(c>e&&o(a,s+l,i||null,r)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),o,s+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,o,s){let i="",r=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&o&&(r?r=!1:i+=o),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,o=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(o)&&(s[s.length-1]=t.withText(t.text+o.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new k(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let o=[],s=0;if(t>e)for(let i=0,r=0;r<t;i++){let l=this.content[i],a=r+l.nodeSize;a>e&&((r<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-r),Math.min(l.text.length,t-r)):l=l.cut(Math.max(0,e-r-1),Math.min(l.content.size,t-r-1))),o.push(l),s+=l.nodeSize),r=a}return new k(o,s)}cutByIndex(e,t){return e==t?k.empty:e==0&&t==this.content.length?this:new k(this.content.slice(e,t))}replaceChild(e,t){let o=this.content[e];if(o==t)return this;let s=this.content.slice(),i=this.size+t.nodeSize-o.nodeSize;return s[e]=t,new k(s,i)}addToStart(e){return new k([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new k(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,o=0;t<this.content.length;t++){let s=this.content[t];e(s,o,t),o+=s.nodeSize}}findDiffStart(e,t=0){return ol(this,e,t)}findDiffEnd(e,t=this.size,o=e.size){return sl(this,e,t,o)}findIndex(e,t=-1){if(e==0)return bo(0,e);if(e==this.size)return bo(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let o=0,s=0;;o++){let i=this.child(o),r=s+i.nodeSize;if(r>=e)return r==e||t>0?bo(o+1,r):bo(o,s);s=r}}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 k.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new k(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return k.empty;let t,o=0;for(let s=0;s<e.length;s++){let i=e[s];o+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(t||(t=e.slice(0,s)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new k(t||e,o)}static from(e){if(!e)return k.empty;if(e instanceof k)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new k([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}k.empty=new k([],0);const Rs={index:0,offset:0};function bo(n,e){return Rs.index=n,Rs.offset=e,Rs}function vo(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 o=0;o<n.length;o++)if(!vo(n[o],e[o]))return!1}else{for(let o in n)if(!(o in e)||!vo(n[o],e[o]))return!1;for(let o in e)if(!(o in n))return!1}return!0}class B{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,o=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!o&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),o=!0),t&&t.push(i)}}return t||(t=e.slice()),o||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&&vo(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 o=e.marks[t.type];if(!o)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=o.create(t.attrs);return o.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let o=0;o<e.length;o++)if(!e[o].eq(t[o]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return B.none;if(e instanceof B)return[e];let t=e.slice();return t.sort((o,s)=>o.type.rank-s.type.rank),t}}B.none=[];class xo extends Error{}class E{constructor(e,t,o){this.content=e,this.openStart=t,this.openEnd=o}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let o=rl(this.content,e+this.openStart,t);return o&&new E(o,this.openStart,this.openEnd)}removeBetween(e,t){return new E(il(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 E.empty;let o=t.openStart||0,s=t.openEnd||0;if(typeof o!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new E(k.fromJSON(e,t.content),o,s)}static maxOpen(e,t=!0){let o=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)o++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new E(e,o,s)}}E.empty=new E(k.empty,0,0);function il(n,e,t){let{index:o,offset:s}=n.findIndex(e),i=n.maybeChild(o),{index:r,offset:l}=n.findIndex(t);if(s==e||i.isText){if(l!=t&&!n.child(r).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(o!=r)throw new RangeError("Removing non-flat range");return n.replaceChild(o,i.copy(il(i.content,e-s-1,t-s-1)))}function rl(n,e,t,o){let{index:s,offset:i}=n.findIndex(e),r=n.maybeChild(s);if(i==e||r.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=rl(r.content,e-i-1,t);return l&&n.replaceChild(s,r.copy(l))}function op(n,e,t){if(t.openStart>n.depth)throw new xo("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new xo("Inconsistent open depths");return ll(n,e,t,0)}function ll(n,e,t,o){let s=n.index(o),i=n.node(o);if(s==e.index(o)&&o<n.depth-t.openStart){let r=ll(n,e,t,o+1);return i.copy(i.content.replaceChild(s,r))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==o&&e.depth==o){let r=n.parent,l=r.content;return xt(r,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:r,end:l}=sp(t,n);return xt(i,cl(n,r,l,e,o))}else return xt(i,So(n,e,o))}function al(n,e){if(!e.type.compatibleContent(n.type))throw new xo("Cannot join "+e.type.name+" onto "+n.type.name)}function Ds(n,e,t){let o=n.node(t);return al(o,e.node(t)),o}function vt(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 Sn(n,e,t,o){let s=(e||n).node(t),i=0,r=e?e.index(t):s.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(vt(n.nodeAfter,o),i++));for(let l=i;l<r;l++)vt(s.child(l),o);e&&e.depth==t&&e.textOffset&&vt(e.nodeBefore,o)}function xt(n,e){return n.type.checkContent(e),n.copy(e)}function cl(n,e,t,o,s){let i=n.depth>s&&Ds(n,e,s+1),r=o.depth>s&&Ds(t,o,s+1),l=[];return Sn(null,n,s,l),i&&r&&e.index(s)==t.index(s)?(al(i,r),vt(xt(i,cl(n,e,t,o,s+1)),l)):(i&&vt(xt(i,So(n,e,s+1)),l),Sn(e,t,s,l),r&&vt(xt(r,So(t,o,s+1)),l)),Sn(o,null,s,l),new k(l)}function So(n,e,t){let o=[];if(Sn(null,n,t,o),n.depth>t){let s=Ds(n,e,t+1);vt(xt(s,So(n,e,t+1)),o)}return Sn(e,null,t,o),new k(o)}function sp(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)s=e.node(i).copy(k.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class wn{constructor(e,t,o){this.pos=e,this.path=t,this.parentOffset=o,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 o=this.pos-this.path[this.path.length-1],s=e.child(t);return o?e.child(t).cut(o):s}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 o=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)s+=o.child(i).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return B.none;if(this.textOffset)return e.child(t).marks;let o=e.maybeChild(t-1),s=e.maybeChild(t);if(!o){let l=o;o=s,s=l}let i=o.marks;for(var r=0;r<i.length;r++)i[r].type.spec.inclusive===!1&&(!s||!i[r].isInSet(s.marks))&&(i=i[r--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let o=t.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!s||!o[i].isInSet(s.marks))&&(o=o[i--].removeFromSet(o));return o}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 o=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);o>=0;o--)if(e.pos<=this.end(o)&&(!t||t(this.node(o))))return new wo(this,e,o);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 o=[],s=0,i=t;for(let r=e;;){let{index:l,offset:a}=r.content.findIndex(i),c=i-a;if(o.push(r,l,s+a),!c||(r=r.child(l),r.isText))break;i=c-1,s+=a+1}return new wn(t,o,i)}static resolveCached(e,t){let o=dl.get(e);if(o)for(let i=0;i<o.elts.length;i++){let r=o.elts[i];if(r.pos==t)return r}else dl.set(e,o=new ip);let s=o.elts[o.i]=wn.resolve(e,t);return o.i=(o.i+1)%rp,s}}class ip{constructor(){this.elts=[],this.i=0}}const rp=12,dl=new WeakMap;class wo{constructor(e,t,o){this.$from=e,this.$to=t,this.depth=o}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 lp=Object.create(null);let St=class qi{constructor(e,t,o,s=B.none){this.type=e,this.attrs=t,this.marks=s,this.content=o||k.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,o,s=0){this.content.nodesBetween(e,t,o,s,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,o,s){return this.content.textBetween(e,t,o,s)}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,o){return this.type==e&&vo(this.attrs,t||e.defaultAttrs||lp)&&B.sameSet(this.marks,o||B.none)}copy(e=null){return e==this.content?this:new qi(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new qi(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,o=!1){if(e==t)return E.empty;let s=this.resolve(e),i=this.resolve(t),r=o?0:s.sharedDepth(t),l=s.start(r),c=s.node(r).content.cut(s.pos-l,i.pos-l);return new E(c,s.depth-r,i.depth-r)}replace(e,t,o){return op(this.resolve(e),this.resolve(t),o)}nodeAt(e){for(let t=this;;){let{index:o,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(o),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:o}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:o}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:o}=this.content.findIndex(e);if(o<e)return{node:this.content.child(t),index:t,offset:o};let s=this.content.child(t-1);return{node:s,index:t-1,offset:o-s.nodeSize}}resolve(e){return wn.resolveCached(this,e)}resolveNoCache(e){return wn.resolve(this,e)}rangeHasMark(e,t,o){let s=!1;return t>e&&this.nodesBetween(e,t,i=>(o.isInSet(i.marks)&&(s=!0),!s)),s}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()+")"),ul(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,o=k.empty,s=0,i=o.childCount){let r=this.contentMatchAt(e).matchFragment(o,s,i),l=r&&r.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<i;a++)if(!this.type.allowsMarks(o.child(a).marks))return!1;return!0}canReplaceWith(e,t,o,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(o),r=i&&i.matchFragment(this.content,t);return r?r.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=B.none;for(let t=0;t<this.marks.length;t++){let o=this.marks[t];o.type.checkAttrs(o.attrs),e=o.addToSet(e)}if(!B.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 o;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");o=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,o)}let s=k.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,s,o);return i.type.checkAttrs(i.attrs),i}};St.prototype.text=void 0;class Co extends St{constructor(e,t,o,s){if(super(e,t,null,s),!o)throw new RangeError("Empty text nodes are not allowed");this.text=o}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ul(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 Co(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Co(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 ul(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class wt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let o=new ap(e,t);if(o.next==null)return wt.empty;let s=hl(o);o.next&&o.err("Unexpected trailing text");let i=mp(fp(s));return gp(i,o),i}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,o=e.childCount){let s=this;for(let i=t;s&&i<o;i++)s=s.matchType(e.child(i).type);return s}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 o=0;o<e.next.length;o++)if(this.next[t].type==e.next[o].type)return!0;return!1}fillBefore(e,t=!1,o=0){let s=[this];function i(r,l){let a=r.matchFragment(e,o);if(a&&(!t||a.validEnd))return k.from(l.map(c=>c.createAndFill()));for(let c=0;c<r.next.length;c++){let{type:d,next:u}=r.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(u)==-1){s.push(u);let h=i(u,l.concat(d));if(h)return h}}return null}return i(this,[])}findWrapping(e){for(let o=0;o<this.wrapCache.length;o+=2)if(this.wrapCache[o]==e)return this.wrapCache[o+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),o=[{match:this,type:null,via:null}];for(;o.length;){let s=o.shift(),i=s.match;if(i.matchType(e)){let r=[];for(let l=s;l.type;l=l.via)r.push(l.type);return r.reverse()}for(let r=0;r<i.next.length;r++){let{type:l,next:a}=i.next[r];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(o.push({match:l.contentMatch,type:l,via:s}),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(o){e.push(o);for(let s=0;s<o.next.length;s++)e.indexOf(o.next[s].next)==-1&&t(o.next[s].next)}return t(this),e.map((o,s)=>{let i=s+(o.validEnd?"*":" ")+" ";for(let r=0;r<o.next.length;r++)i+=(r?", ":"")+o.next[r].type.name+"->"+e.indexOf(o.next[r].next);return i}).join(`
|
|
294
|
-
`)}}wt.empty=new wt(!0);class ap{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 hl(n){let e=[];do e.push(cp(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function cp(n){let e=[];do e.push(dp(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function dp(n){let e=pp(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=up(n,e);else break;return e}function pl(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function up(n,e){let t=pl(n),o=t;return n.eat(",")&&(n.next!="}"?o=pl(n):o=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:o,expr:e}}function hp(n,e){let t=n.nodeTypes,o=t[e];if(o)return[o];let s=[];for(let i in t){let r=t[i];r.isInGroup(e)&&s.push(r)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function pp(n){if(n.eat("(")){let e=hl(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=hp(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 fp(n){let e=[[]];return s(i(n,0),t()),e;function t(){return e.push([])-1}function o(r,l,a){let c={term:a,to:l};return e[r].push(c),c}function s(r,l){r.forEach(a=>a.to=l)}function i(r,l){if(r.type=="choice")return r.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(r.type=="seq")for(let a=0;;a++){let c=i(r.exprs[a],l);if(a==r.exprs.length-1)return c;s(c,l=t())}else if(r.type=="star"){let a=t();return o(l,a),s(i(r.expr,a),a),[o(a)]}else if(r.type=="plus"){let a=t();return s(i(r.expr,l),a),s(i(r.expr,a),a),[o(a)]}else{if(r.type=="opt")return[o(l)].concat(i(r.expr,l));if(r.type=="range"){let a=l;for(let c=0;c<r.min;c++){let d=t();s(i(r.expr,a),d),a=d}if(r.max==-1)s(i(r.expr,a),a);else for(let c=r.min;c<r.max;c++){let d=t();o(a,d),s(i(r.expr,a),d),a=d}return[o(a)]}else{if(r.type=="name")return[o(l,void 0,r.value)];throw new Error("Unknown expr type")}}}}function fl(n,e){return e-n}function ml(n,e){let t=[];return o(e),t.sort(fl);function o(s){let i=n[s];if(i.length==1&&!i[0].term)return o(i[0].to);t.push(s);for(let r=0;r<i.length;r++){let{term:l,to:a}=i[r];!l&&t.indexOf(a)==-1&&o(a)}}}function mp(n){let e=Object.create(null);return t(ml(n,0));function t(o){let s=[];o.forEach(r=>{n[r].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<s.length;d++)s[d][0]==l&&(c=s[d][1]);ml(n,a).forEach(d=>{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[o.join(",")]=new wt(o.indexOf(n.length-1)>-1);for(let r=0;r<s.length;r++){let l=s[r][1].sort(fl);i.next.push({type:s[r][0],next:e[l.join(",")]||t(l)})}return i}}function gp(n,e){for(let t=0,o=[n];t<o.length;t++){let s=o[t],i=!s.validEnd,r=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];r.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),o.indexOf(c)==-1&&o.push(c)}i&&e.err("Only non-generatable nodes ("+r.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function gl(n){let e=Object.create(null);for(let t in n){let o=n[t];if(!o.hasDefault)return null;e[t]=o.default}return e}function yl(n,e){let t=Object.create(null);for(let o in n){let s=e&&e[o];if(s===void 0){let i=n[o];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+o)}t[o]=s}return t}function bl(n,e,t,o){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let i=n[s];i.validate&&i.validate(e[s])}}function vl(n,e){let t=Object.create(null);if(e)for(let o in e)t[o]=new bp(n,o,e[o]);return t}let xl=class Pd{constructor(e,t,o){this.name=e,this.schema=t,this.spec=o,this.markSet=null,this.groups=o.group?o.group.split(" "):[],this.attrs=vl(e,o.attrs),this.defaultAttrs=gl(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(o.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==wt.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:yl(this.attrs,e)}create(e=null,t,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new St(this,this.computeAttrs(e),k.from(t),B.setFrom(o))}createChecked(e=null,t,o){return t=k.from(t),this.checkContent(t),new St(this,this.computeAttrs(e),t,B.setFrom(o))}createAndFill(e=null,t,o){if(e=this.computeAttrs(e),t=k.from(t),t.size){let r=this.contentMatch.fillBefore(t);if(!r)return null;t=r.append(t)}let s=this.contentMatch.matchFragment(t),i=s&&s.fillBefore(k.empty,!0);return i?new St(this,e,t.append(i),B.setFrom(o)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let o=0;o<e.childCount;o++)if(!this.allowsMarks(e.child(o).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){bl(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 o=0;o<e.length;o++)this.allowsMarkType(e[o].type)?t&&t.push(e[o]):t||(t=e.slice(0,o));return t?t.length?t:B.none:e}static compile(e,t){let o=Object.create(null);e.forEach((i,r)=>o[i]=new Pd(i,t,r));let s=t.spec.topNode||"doc";if(!o[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let i in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};function yp(n,e,t){let o=t.split("|");return s=>{let i=s===null?"null":typeof s;if(o.indexOf(i)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${n}, got ${i}`)}}class bp{constructor(e,t,o){this.hasDefault=Object.prototype.hasOwnProperty.call(o,"default"),this.default=o.default,this.validate=typeof o.validate=="string"?yp(e,t,o.validate):o.validate}get isRequired(){return!this.hasDefault}}class ko{constructor(e,t,o,s){this.name=e,this.rank=t,this.schema=o,this.spec=s,this.attrs=vl(e,s.attrs),this.excluded=null;let i=gl(this.attrs);this.instance=i?new B(this,i):null}create(e=null){return!e&&this.instance?this.instance:new B(this,yl(this.attrs,e))}static compile(e,t){let o=Object.create(null),s=0;return e.forEach((i,r)=>o[i]=new ko(i,s++,t,r)),o}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){bl(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class vp{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=Z.from(e.nodes),t.marks=Z.from(e.marks||{}),this.nodes=xl.compile(this.spec.nodes,this),this.marks=ko.compile(this.spec.marks,this);let o=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],r=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=o[r]||(o[r]=wt.parse(r,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?Sl(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],r=i.spec.excludes;i.excluded=r==null?[i]:r==""?[]:Sl(this,r.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,o,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof xl){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,o,s)}text(e,t){let o=this.nodes.text;return new Co(o,o.defaultAttrs,e,B.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 B.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Sl(n,e){let t=[];for(let o=0;o<e.length;o++){let s=e[o],i=n.marks[s],r=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(r=a)}if(!r)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return t}function xp(n){return n.tag!=null}function Sp(n){return n.style!=null}class Zt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let o=this.matchedStyles=[];t.forEach(s=>{if(xp(s))this.tags.push(s);else if(Sp(s)){let i=/[^=]*/.exec(s.style)[0];o.indexOf(i)<0&&o.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let o=new Tl(this,t,!1);return o.addAll(e,B.none,t.from,t.to),o.finish()}parseSlice(e,t={}){let o=new Tl(this,t,!0);return o.addAll(e,B.none,t.from,t.to),E.maxOpen(o.finish())}matchTag(e,t,o){for(let s=o?this.tags.indexOf(o)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(kp(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let r=i.getAttrs(e);if(r===!1)continue;i.attrs=r||void 0}return i}}}matchStyle(e,t,o,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let r=this.styles[i],l=r.style;if(!(l.indexOf(e)!=0||r.context&&!o.matchesContext(r.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(r.getAttrs){let a=r.getAttrs(t);if(a===!1)continue;r.attrs=a||void 0}return r}}}static schemaRules(e){let t=[];function o(s){let i=s.priority==null?50:s.priority,r=0;for(;r<t.length;r++){let l=t[r];if((l.priority==null?50:l.priority)<i)break}t.splice(r,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(r=>{o(r=Ml(r)),r.mark||r.ignore||r.clearMark||(r.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(r=>{o(r=Ml(r)),r.node||r.ignore||r.mark||(r.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Zt(e,Zt.schemaRules(e)))}}const wl={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},wp={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Cl={ol:!0,ul:!0},To=1,Mo=2,Cn=4;function kl(n,e,t){return e!=null?(e?To:0)|(e==="full"?Mo:0):n&&n.whitespace=="pre"?To|Mo:t&~Cn}class Ao{constructor(e,t,o,s,i,r){this.type=e,this.attrs=t,this.marks=o,this.solid=s,this.options=r,this.content=[],this.activeMarks=B.none,this.match=i||(r&Cn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(k.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let o=this.type.contentMatch,s;return(s=o.findWrapping(e.type))?(this.match=o,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&To)){let o=this.content[this.content.length-1],s;if(o&&o.isText&&(s=/[ \t\r\n\u000c]+$/.exec(o.text))){let i=o;o.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let t=k.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(k.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&&!wl.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Tl{constructor(e,t,o){this.parser=e,this.options=t,this.isOpen=o,this.open=0;let s=t.topNode,i,r=kl(null,t.preserveWhitespace,0)|(o?Cn:0);s?i=new Ao(s.type,s.attrs,B.none,!0,t.topMatch||s.type.contentMatch,r):o?i=new Ao(null,null,B.none,!0,null,r):i=new Ao(e.schema.topNodeType,null,B.none,!0,null,r),this.nodes=[i],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 o=e.nodeValue,s=this.top;if(s.options&Mo||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(o)){if(s.options&To)s.options&Mo?o=o.replace(/\r\n?/g,`
|
|
295
|
-
`):o=o.replace(/\r?\n|\r/g," ");else if(o=o.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(o)&&this.open==this.nodes.length-1){let
|
|
296
|
-
`),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 o=e.style;if(o&&o.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],r=o.getPropertyValue(i);if(r)for(let l=void 0;;){let a=this.parser.matchStyle(i,r,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,o,s){let i,r;if(t.node)if(r=this.parser.schema.nodes[t.node],r.isLeaf)this.insertNode(r.create(t.attrs),o)||this.leafFallback(e,o);else{let a=this.enter(r,t.attrs||null,o,t.preserveWhitespace);a&&(i=!0,o=a)}else{let a=this.parser.schema.marks[t.mark];o=o.concat(a.create(t.attrs))}let l=this.top;if(r&&r.isLeaf)this.findInside(e);else if(s)this.addElement(e,o,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,o));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,o),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,o,s){let i=o||0;for(let r=o?e.childNodes[o]:e.firstChild,l=s==null?null:e.childNodes[s];r!=l;r=r.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(r,t);this.findAtPoint(e,i)}findPlace(e,t){let o,s;for(let i=this.open;i>=0;i--){let r=this.nodes[i],l=r.findWrapping(e);if(l&&(!o||o.length>l.length)&&(o=l,s=r,!l.length)||r.solid)break}if(!o)return null;this.sync(s);for(let i=0;i<o.length;i++)t=this.enterInner(o[i],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let o=this.findPlace(e,t);if(o){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let i=B.none;for(let r of o.concat(e.marks))(s.type?s.type.allowsMarkType(r.type):Al(r.type,e.type))&&(i=r.addToSet(i));return s.content.push(e.mark(i)),!0}return!1}enter(e,t,o,s){let i=this.findPlace(e.create(t),o);return i&&(i=this.enterInner(e,t,o,!0,s)),i}enterInner(e,t,o,s=!1,i){this.closeExtra();let r=this.top;r.match=r.match&&r.match.matchType(e);let l=kl(e,i,r.options);r.options&Cn&&r.content.length==0&&(l|=Cn);let a=B.none;return o=o.filter(c=>(r.type?r.type.allowsMarkType(c.type):Al(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Ao(e,t,a,s,null,l)),this.open++,o}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 o=this.nodes[t].content;for(let s=o.length-1;s>=0;s--)e+=o[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let o=0;o<this.find.length;o++)this.find[o].node==e&&this.find[o].offset==t&&(this.find[o].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,o){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(o?2:4)&&(this.find[s].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("/"),o=this.options.context,s=!this.isOpen&&(!o||o.parent.type==this.nodes[0].type),i=-(o?o.depth+1:0)+(s?0:1),r=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(r(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:o&&a>=i?o.node(a-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return r(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(o&&o.isTextblock&&o.defaultAttrs)return o}for(let t in this.parser.schema.nodes){let o=this.parser.schema.nodes[t];if(o.isTextblock&&o.defaultAttrs)return o}}}function Cp(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&Cl.hasOwnProperty(o)&&t?(t.appendChild(e),e=t):o=="li"?t=e:o&&(t=null)}}function kp(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Ml(n){let e={};for(let t in n)e[t]=n[t];return e}function Al(n,e){let t=e.schema.nodes;for(let o in t){let s=t[o];if(!s.allowsMarkType(n))continue;let i=[],r=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||i.indexOf(d)<0&&r(d))return!0}};if(r(s.contentMatch))return!0}}class Ct{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},o){o||(o=Ls(t).createDocumentFragment());let s=o,i=[];return e.forEach(r=>{if(i.length||r.marks.length){let l=0,a=0;for(;l<i.length&&a<r.marks.length;){let c=r.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<r.marks.length;){let c=r.marks[a++],d=this.serializeMark(c,r.isInline,t);d&&(i.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(r,t))}),o}serializeNodeInner(e,t){let{dom:o,contentDOM:s}=Eo(Ls(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return o}serializeNode(e,t={}){let o=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(o),o=i.dom)}return o}serializeMark(e,t,o={}){let s=this.marks[e.type.name];return s&&Eo(Ls(o),s(e,t),null,e.attrs)}static renderSpec(e,t,o=null,s){return Eo(e,t,o,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ct(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=El(e.nodes);return t.text||(t.text=o=>o.text),t}static marksFromSchema(e){return El(e.marks)}}function El(n){let e={};for(let t in n){let o=n[t].spec.toDOM;o&&(e[t]=o)}return e}function Ls(n){return n.document||window.document}const Nl=new WeakMap;function Tp(n){let e=Nl.get(n);return e===void 0&&Nl.set(n,e=Mp(n)),e}function Mp(n){let e=null;function t(o){if(o&&typeof o=="object")if(Array.isArray(o))if(typeof o[0]=="string")e||(e=[]),e.push(o);else for(let s=0;s<o.length;s++)t(o[s]);else for(let s in o)t(o[s])}return t(n),e}function Eo(n,e,t,o){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 s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(o&&(i=Tp(o))&&i.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 r=s.indexOf(" ");r>0&&(t=s.slice(0,r),s=s.slice(r+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let h=u.indexOf(" ");h>0?a.setAttributeNS(u.slice(0,h),u.slice(h+1),c[u]):a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let h=e[u];if(h===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:p,contentDOM:f}=Eo(n,h,t,o);if(a.appendChild(p),f){if(l)throw new RangeError("Multiple content holes");l=f}}}return{dom:a,contentDOM:l}}const Ol=65535,Pl=Math.pow(2,16);function Ap(n,e){return n+e*Pl}function Il(n){return n&Ol}function Ep(n){return(n-(n&Ol))/Pl}const Rl=1,Dl=2,No=4,Ll=8;class zs{constructor(e,t,o){this.pos=e,this.delInfo=t,this.recover=o}get deleted(){return(this.delInfo&Ll)>0}get deletedBefore(){return(this.delInfo&(Rl|No))>0}get deletedAfter(){return(this.delInfo&(Dl|No))>0}get deletedAcross(){return(this.delInfo&No)>0}}class me{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&me.empty)return me.empty}recover(e){let t=0,o=Il(e);if(!this.inverted)for(let s=0;s<o;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[o*3]+t+Ep(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,o){let s=0,i=this.inverted?2:1,r=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],d=this.ranges[l+r],u=a+c;if(e<=u){let h=c?e==a?-1:e==u?1:t:t,p=a+s+(h<0?0:d);if(o)return p;let f=e==(t<0?a:u)?null:Ap(l/3,e-a),m=e==a?Dl:e==u?Rl:No;return(t<0?e!=a:e!=u)&&(m|=Ll),new zs(p,m,f)}s+=d-c}return o?e+s:new zs(e+s,0,null)}touches(e,t){let o=0,s=Il(t),i=this.inverted?2:1,r=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==s*3)return!0;o+=this.ranges[l+r]-c}return!1}forEach(e){let t=this.inverted?2:1,o=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let r=this.ranges[s],l=r-(this.inverted?i:0),a=r+(this.inverted?0:i),c=this.ranges[s+t],d=this.ranges[s+o];e(l,l+c,a,a+d),i+=d-c}}invert(){return new me(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?me.empty:new me(e<0?[0,-e,0]:[0,0,e])}}me.empty=new me([]);class Xt{constructor(e=[],t,o=0,s=e.length){this.maps=e,this.mirror=t,this.from=o,this.to=s}slice(e=0,t=this.maps.length){return new Xt(this.maps,this.mirror,e,t)}copy(){return new Xt(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,o=this.maps.length;t<e.maps.length;t++){let s=e.getMirror(t);this.appendMap(e.maps[t],s!=null&&s<t?o+s: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,o=this.maps.length+e.maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e.maps[t].invert(),s!=null&&s>t?o-s-1:void 0)}}invert(){let e=new Xt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let o=this.from;o<this.to;o++)e=this.maps[o].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,o){let s=0;for(let i=this.from;i<this.to;i++){let r=this.maps[i],l=r.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this.maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return o?e:new zs(e,s,null)}}const Vs=Object.create(null);class oe{getMap(){return me.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let o=Vs[t.stepType];if(!o)throw new RangeError(`No step type ${t.stepType} defined`);return o.fromJSON(e,t)}static jsonID(e,t){if(e in Vs)throw new RangeError("Duplicate use of step JSON ID "+e);return Vs[e]=t,t.prototype.jsonID=e,t}}class K{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new K(e,null)}static fail(e){return new K(null,e)}static fromReplace(e,t,o,s){try{return K.ok(e.replace(t,o,s))}catch(i){if(i instanceof xo)return K.fail(i.message);throw i}}}function $s(n,e,t){let o=[];for(let s=0;s<n.childCount;s++){let i=n.child(s);i.content.size&&(i=i.copy($s(i.content,e,i))),i.isInline&&(i=e(i,t,s)),o.push(i)}return k.fromArray(o)}class Ue extends oe{constructor(e,t,o){super(),this.from=e,this.to=t,this.mark=o}apply(e){let t=e.slice(this.from,this.to),o=e.resolve(this.from),s=o.node(o.sharedDepth(this.to)),i=new E($s(t.content,(r,l)=>!r.isAtom||!l.type.allowsMarkType(this.mark.type)?r:r.mark(this.mark.addToSet(r.marks)),s),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,i)}invert(){return new Ne(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deleted&&o.deleted||t.pos>=o.pos?null:new Ue(t.pos,o.pos,this.mark)}merge(e){return e instanceof Ue&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ue(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 Ue(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("addMark",Ue);class Ne extends oe{constructor(e,t,o){super(),this.from=e,this.to=t,this.mark=o}apply(e){let t=e.slice(this.from,this.to),o=new E($s(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,o)}invert(){return new Ue(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deleted&&o.deleted||t.pos>=o.pos?null:new Ne(t.pos,o.pos,this.mark)}merge(e){return e instanceof Ne&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ne(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 Ne(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("removeMark",Ne);class Je extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return K.fromReplace(e,this.pos,this.pos+1,new E(k.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let o=this.mark.addToSet(t.marks);if(o.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(o))return new Je(this.pos,t.marks[s]);return new Je(this.pos,this.mark)}}return new Qt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Je(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 Je(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("addNodeMark",Je);class Qt extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return K.fromReplace(e,this.pos,this.pos+1,new E(k.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Je(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Qt(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 Qt(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("removeNodeMark",Qt);class se extends oe{constructor(e,t,o,s=!1){super(),this.from=e,this.to=t,this.slice=o,this.structure=s}apply(e){return this.structure&&Bs(e,this.from,this.to)?K.fail("Structure replace would overwrite content"):K.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new me([this.from,this.to-this.from,this.slice.size])}invert(e){return new se(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deletedAcross&&o.deletedAcross?null:new se(t.pos,Math.max(t.pos,o.pos),this.slice)}merge(e){if(!(e instanceof se)||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?E.empty:new E(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new se(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?E.empty:new E(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new se(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 se(t.from,t.to,E.fromJSON(e,t.slice),!!t.structure)}}oe.jsonID("replace",se);class X extends oe{constructor(e,t,o,s,i,r,l=!1){super(),this.from=e,this.to=t,this.gapFrom=o,this.gapTo=s,this.slice=i,this.insert=r,this.structure=l}apply(e){if(this.structure&&(Bs(e,this.from,this.gapFrom)||Bs(e,this.gapTo,this.to)))return K.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return K.fail("Gap is not a flat range");let o=this.slice.insertAt(this.insert,t.content);return o?K.fromReplace(e,this.from,this.to,o):K.fail("Content does not fit in gap")}getMap(){return new me([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 X(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),o=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?o.pos:e.map(this.gapTo,1);return t.deletedAcross&&o.deletedAcross||s<t.pos||i>o.pos?null:new X(t.pos,o.pos,s,i,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 X(t.from,t.to,t.gapFrom,t.gapTo,E.fromJSON(e,t.slice),t.insert,!!t.structure)}}oe.jsonID("replaceAround",X);function Bs(n,e,t){let o=n.resolve(e),s=t-e,i=o.depth;for(;s>0&&i>0&&o.indexAfter(i)==o.node(i).childCount;)i--,s--;if(s>0){let r=o.node(i).maybeChild(o.indexAfter(i));for(;s>0;){if(!r||r.isLeaf)return!0;r=r.firstChild,s--}}return!1}function Np(n,e,t,o){let s=[],i=[],r,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!o.isInSet(u)&&d.type.allowsMarkType(o.type)){let h=Math.max(c,e),p=Math.min(c+a.nodeSize,t),f=o.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(f)||(r&&r.to==h&&r.mark.eq(u[m])?r.to=p:s.push(r=new Ne(h,p,u[m])));l&&l.to==h?l.to=p:i.push(l=new Ue(h,p,o))}}),s.forEach(a=>n.step(a)),i.forEach(a=>n.step(a))}function Op(n,e,t,o){let s=[],i=0;n.doc.nodesBetween(e,t,(r,l)=>{if(!r.isInline)return;i++;let a=null;if(o instanceof ko){let c=r.marks,d;for(;d=o.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else o?o.isInSet(r.marks)&&(a=[o]):a=r.marks;if(a&&a.length){let c=Math.min(l+r.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],h;for(let p=0;p<s.length;p++){let f=s[p];f.step==i-1&&u.eq(s[p].style)&&(h=f)}h?(h.to=c,h.step=i):s.push({style:u,from:Math.max(l,e),to:c,step:i})}}}),s.forEach(r=>n.step(new Ne(r.from,r.to,r.style)))}function Hs(n,e,t,o=t.contentMatch,s=!0){let i=n.doc.nodeAt(e),r=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),d=l+c.nodeSize,u=o.matchType(c.type);if(!u)r.push(new se(l,d,E.empty));else{o=u;for(let h=0;h<c.marks.length;h++)t.allowsMarkType(c.marks[h].type)||n.step(new Ne(l,d,c.marks[h]));if(s&&c.isText&&t.whitespace!="pre"){let h,p=/\r?\n|\r/g,f;for(;h=p.exec(c.text);)f||(f=new E(k.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),r.push(new se(l+h.index,l+h.index+h[0].length,f))}}l=d}if(!o.validEnd){let a=o.fillBefore(k.empty,!0);n.replace(l,l,new E(a,0,0))}for(let a=r.length-1;a>=0;a--)n.step(r[a])}function Pp(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Oo(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let o=n.depth;;--o){let s=n.$from.node(o),i=n.$from.index(o),r=n.$to.indexAfter(o);if(o<n.depth&&s.canReplace(i,r,t))return o;if(o==0||s.type.spec.isolating||!Pp(s,i,r))break}return null}function Ip(n,e,t){let{$from:o,$to:s,depth:i}=e,r=o.before(i+1),l=s.after(i+1),a=r,c=l,d=k.empty,u=0;for(let f=i,m=!1;f>t;f--)m||o.index(f)>0?(m=!0,d=k.from(o.node(f).copy(d)),u++):a--;let h=k.empty,p=0;for(let f=i,m=!1;f>t;f--)m||s.after(f+1)<s.end(f)?(m=!0,h=k.from(s.node(f).copy(h)),p++):c++;n.step(new X(a,c,r,l,new E(d.append(h),u,p),d.size-u,!0))}function zl(n,e,t=null,o=n){let s=Rp(n,e),i=s&&Dp(o,e);return i?s.map(Vl).concat({type:e,attrs:t}).concat(i.map(Vl)):null}function Vl(n){return{type:n,attrs:null}}function Rp(n,e){let{parent:t,startIndex:o,endIndex:s}=n,i=t.contentMatchAt(o).findWrapping(e);if(!i)return null;let r=i.length?i[0]:e;return t.canReplaceWith(o,s,r)?i:null}function Dp(n,e){let{parent:t,startIndex:o,endIndex:s}=n,i=t.child(o),r=e.contentMatch.findWrapping(i.type);if(!r)return null;let a=(r.length?r[r.length-1]:e).contentMatch;for(let c=o;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:r}function Lp(n,e,t){let o=k.empty;for(let r=t.length-1;r>=0;r--){if(o.size){let l=t[r].type.contentMatch.matchFragment(o);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=k.from(t[r].type.create(t[r].attrs,o))}let s=e.start,i=e.end;n.step(new X(s,i,s,i,new E(o,0,0),t.length,!0))}function zp(n,e,t,o,s){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(r,l)=>{let a=typeof s=="function"?s(r):s;if(r.isTextblock&&!r.hasMarkup(o,a)&&Vp(n.doc,n.mapping.slice(i).map(l),o)){let c=null;if(o.schema.linebreakReplacement){let p=o.whitespace=="pre",f=!!o.contentMatch.matchType(o.schema.linebreakReplacement);p&&!f?c=!1:!p&&f&&(c=!0)}c===!1&&Bl(n,r,l,i),Hs(n,n.mapping.slice(i).map(l,1),o,void 0,c===null);let d=n.mapping.slice(i),u=d.map(l,1),h=d.map(l+r.nodeSize,1);return n.step(new X(u,h,u+1,h-1,new E(k.from(o.create(a,null,r.marks)),0,0),1,!0)),c===!0&&$l(n,r,l,i),!1}})}function $l(n,e,t,o){e.forEach((s,i)=>{if(s.isText){let r,l=/\r?\n|\r/g;for(;r=l.exec(s.text);){let a=n.mapping.slice(o).map(t+1+i+r.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Bl(n,e,t,o){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let r=n.mapping.slice(o).map(t+1+i);n.replaceWith(r,r+1,e.type.schema.text(`
|
|
297
|
-
`))}})}function Vp(n,e,t){let o=n.resolve(e),s=o.index();return o.parent.canReplaceWith(s,s+1,t)}function $p(n,e,t,o,s){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let r=t.create(o,null,s||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,r);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new X(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new E(k.from(r),0,0),1,!0))}function en(n,e,t=1,o){let s=n.resolve(e),i=s.depth-t,r=o&&o[o.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!r.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=t-2;c>i;c--,d--){let u=s.node(c),h=s.index(c);if(u.type.spec.isolating)return!1;let p=u.content.cutByIndex(h,u.childCount),f=o&&o[d+1];f&&(p=p.replaceChild(0,f.type.create(f.attrs)));let m=o&&o[d]||u;if(!u.canReplace(h+1,u.childCount)||!m.type.validContent(p))return!1}let l=s.indexAfter(i),a=o&&o[0];return s.node(i).canReplaceWith(l,l,a?a.type:s.node(i+1).type)}function Bp(n,e,t=1,o){let s=n.doc.resolve(e),i=k.empty,r=k.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){i=k.from(s.node(l).copy(i));let d=o&&o[c];r=k.from(d?d.type.create(d.attrs,r):s.node(l).copy(r))}n.step(new se(e,e,new E(i.append(r),t,t),!0))}function Po(n,e){let t=n.resolve(e),o=t.index();return Fp(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(o,o+1)}function Hp(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:o}=n.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),r=i.type==o?n.type.schema.nodes.text:i.type;if(t=t.matchType(r),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function Fp(n,e){return!!(n&&e&&!n.isLeaf&&Hp(n,e))}function _p(n,e,t){let o=null,{linebreakReplacement:s}=n.doc.type.schema,i=n.doc.resolve(e-t),r=i.node().type;if(s&&r.inlineContent){let d=r.whitespace=="pre",u=!!r.contentMatch.matchType(s);d&&!u?o=!1:!d&&u&&(o=!0)}let l=n.steps.length;if(o===!1){let d=n.doc.resolve(e+t);Bl(n,d.node(),d.before(),l)}r.inlineContent&&Hs(n,e+t-1,r,i.node().contentMatchAt(i.index()),o==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new se(c,a.map(e+t,-1),E.empty,!0)),o===!0){let d=n.doc.resolve(c);$l(n,d.node(),d.before(),n.steps.length)}return n}function Gp(n,e,t){let o=n.resolve(e);if(o.parent.canReplaceWith(o.index(),o.index(),t))return e;if(o.parentOffset==0)for(let s=o.depth-1;s>=0;s--){let i=o.index(s);if(o.node(s).canReplaceWith(i,i,t))return o.before(s+1);if(i>0)return null}if(o.parentOffset==o.parent.content.size)for(let s=o.depth-1;s>=0;s--){let i=o.indexAfter(s);if(o.node(s).canReplaceWith(i,i,t))return o.after(s+1);if(i<o.node(s).childCount)return null}return null}function Wp(n,e,t){let o=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let i=0;i<t.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let r=o.depth;r>=0;r--){let l=r==o.depth?0:o.pos<=(o.start(r+1)+o.end(r+1))/2?-1:1,a=o.index(r)+(l>0?1:0),c=o.node(r),d=!1;if(i==1)d=c.canReplace(a,a,s);else{let u=c.contentMatchAt(a).findWrapping(s.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?o.pos:l<0?o.before(r+1):o.after(r+1)}return null}function Fs(n,e,t=e,o=E.empty){if(e==t&&!o.size)return null;let s=n.resolve(e),i=n.resolve(t);return Hl(s,i,o)?new se(e,t,o):new jp(s,i,o).fit()}function Hl(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class jp{constructor(e,t,o){this.$from=e,this.$to=t,this.unplaced=o,this.frontier=[],this.placed=k.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=k.from(e.node(s).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,o=this.$from,s=this.close(e<0?this.$to:o.doc.resolve(e));if(!s)return null;let i=this.placed,r=o.depth,l=s.depth;for(;r&&l&&i.childCount==1;)i=i.firstChild.content,r--,l--;let a=new E(i,r,l);return e>-1?new X(o.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||o.pos!=this.$to.pos?new se(o.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,o=0,s=this.unplaced.openEnd;o<e;o++){let i=t.firstChild;if(t.childCount>1&&(s=0),i.type.spec.isolating&&s<=o){e=o;break}t=i.content}for(let t=1;t<=2;t++)for(let o=t==1?e:this.unplaced.openStart;o>=0;o--){let s,i=null;o?(i=_s(this.unplaced.content,o-1).firstChild,s=i.content):s=this.unplaced.content;let r=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(r?c.matchType(r.type)||(u=c.fillBefore(k.from(r),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:o,frontierDepth:l,parent:i,inject:u};if(t==2&&r&&(d=c.findWrapping(r.type)))return{sliceDepth:o,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:o}=this.unplaced,s=_s(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new E(e,t+1,Math.max(o,s.size+t>=e.size-o?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:o}=this.unplaced,s=_s(e,t);if(s.childCount<=1&&t>0){let i=e.size-t<=t+s.size;this.unplaced=new E(kn(e,t-1,1),t-1,i?t-1:o)}else this.unplaced=new E(kn(e,t,1),t,o)}placeNodes({sliceDepth:e,frontierDepth:t,parent:o,inject:s,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let r=this.unplaced,l=o?o.content:r.content,a=r.openStart-e,c=0,d=[],{match:u,type:h}=this.frontier[t];if(s){for(let m=0;m<s.childCount;m++)d.push(s.child(m));u=u.matchFragment(s)}let p=l.size+e-(r.content.size-r.openEnd);for(;c<l.childCount;){let m=l.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(u=g,d.push(Fl(m.mark(h.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?p:-1)))}let f=c==l.childCount;f||(p=-1),this.placed=Tn(this.placed,t,k.from(d)),this.frontier[t].match=u,f&&p<0&&o&&o.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<p;m++){let b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=f?e==0?E.empty:new E(kn(r.content,e-1,1),e-1,p<0?r.openEnd:e-1):new E(kn(r.content,e,c),r.openStart,r.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Gs(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:o}=this.$to,s=this.$to.after(o);for(;o>1&&s==this.$to.end(--o);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:o,type:s}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),r=Gs(e,t,s,o,i);if(r){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=Gs(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:r,move:i?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=Tn(this.placed,t.depth,t.fit)),e=t.move;for(let o=t.depth+1;o<=e.depth;o++){let s=e.node(o),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(o));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,t=null,o){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Tn(this.placed,this.depth,k.from(e.create(t,o))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(k.empty,!0);t.childCount&&(this.placed=Tn(this.placed,this.frontier.length,t))}}function kn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(kn(n.firstChild.content,e-1,t)))}function Tn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Tn(n.lastChild.content,e-1,t)))}function _s(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Fl(n,e,t){if(e<=0)return n;let o=n.content;return e>1&&(o=o.replaceChild(0,Fl(o.firstChild,e-1,o.childCount==1?t-1:0))),e>0&&(o=n.type.contentMatch.fillBefore(o).append(o),t<=0&&(o=o.append(n.type.contentMatch.matchFragment(o).fillBefore(k.empty,!0)))),n.copy(o)}function Gs(n,e,t,o,s){let i=n.node(e),r=s?n.indexAfter(e):n.index(e);if(r==i.childCount&&!t.compatibleContent(i.type))return null;let l=o.fillBefore(i.content,!0,r);return l&&!qp(t,i.content,r)?l:null}function qp(n,e,t){for(let o=t;o<e.childCount;o++)if(!n.allowsMarks(e.child(o).marks))return!0;return!1}function Kp(n){return n.spec.defining||n.spec.definingForContent}function Up(n,e,t,o){if(!o.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),i=n.doc.resolve(t);if(Hl(s,i,o))return n.step(new se(e,t,o));let r=Gl(s,n.doc.resolve(t));r[r.length-1]==0&&r.pop();let l=-(s.depth+1);r.unshift(l);for(let h=s.depth,p=s.pos-1;h>0;h--,p--){let f=s.node(h).type.spec;if(f.defining||f.definingAsContext||f.isolating)break;r.indexOf(h)>-1?l=h:s.before(h)==p&&r.splice(1,0,-h)}let a=r.indexOf(l),c=[],d=o.openStart;for(let h=o.content,p=0;;p++){let f=h.firstChild;if(c.push(f),p==o.openStart)break;h=f.content}for(let h=d-1;h>=0;h--){let p=c[h],f=Kp(p.type);if(f&&!p.sameMarkup(s.node(Math.abs(l)-1)))d=h;else if(f||!p.type.isTextblock)break}for(let h=o.openStart;h>=0;h--){let p=(h+d+1)%(o.openStart+1),f=c[p];if(f)for(let m=0;m<r.length;m++){let g=r[(m+a)%r.length],b=!0;g<0&&(b=!1,g=-g);let w=s.node(g-1),y=s.index(g-1);if(w.canReplaceWith(y,y,f.type,f.marks))return n.replace(s.before(g),b?i.after(g):t,new E(_l(o.content,0,o.openStart,p),p,o.openEnd))}}let u=n.steps.length;for(let h=r.length-1;h>=0&&(n.replace(e,t,o),!(n.steps.length>u));h--){let p=r[h];p<0||(e=s.before(p),t=i.after(p))}}function _l(n,e,t,o,s){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(_l(i.content,e+1,t,o,i)))}if(e>o){let i=s.contentMatchAt(0),r=i.fillBefore(n).append(n);n=r.append(i.matchFragment(r).fillBefore(k.empty,!0))}return n}function Jp(n,e,t,o){if(!o.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=Gp(n.doc,e,o.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new E(k.from(o),0,0))}function Yp(n,e,t){let o=n.doc.resolve(e),s=n.doc.resolve(t),i=Gl(o,s);for(let r=0;r<i.length;r++){let l=i[r],a=r==i.length-1;if(a&&l==0||o.node(l).type.contentMatch.validEnd)return n.delete(o.start(l),s.end(l));if(l>0&&(a||o.node(l-1).canReplace(o.index(l-1),s.indexAfter(l-1))))return n.delete(o.before(l),s.after(l))}for(let r=1;r<=o.depth&&r<=s.depth;r++)if(e-o.start(r)==o.depth-r&&t>o.end(r)&&s.end(r)-t!=s.depth-r&&o.start(r-1)==s.start(r-1)&&o.node(r-1).canReplace(o.index(r-1),s.index(r-1)))return n.delete(o.before(r),t);n.delete(e,t)}function Gl(n,e){let t=[],o=Math.min(n.depth,e.depth);for(let s=o;s>=0;s--){let i=n.start(s);if(i<n.pos-(n.depth-s)||e.end(s)>e.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&t.push(s)}return t}class tn extends oe{constructor(e,t,o){super(),this.pos=e,this.attr=t,this.value=o}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at attribute step's position");let o=Object.create(null);for(let i in t.attrs)o[i]=t.attrs[i];o[this.attr]=this.value;let s=t.type.create(o,null,t.marks);return K.fromReplace(e,this.pos,this.pos+1,new E(k.from(s),0,t.isLeaf?0:1))}getMap(){return me.empty}invert(e){return new tn(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 tn(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 tn(t.pos,t.attr,t.value)}}oe.jsonID("attr",tn);class Mn extends oe{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let o=e.type.create(t,e.content,e.marks);return K.ok(o)}getMap(){return me.empty}invert(e){return new Mn(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 Mn(t.attr,t.value)}}oe.jsonID("docAttr",Mn);let nn=class extends Error{};nn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},nn.prototype=Object.create(Error.prototype),nn.prototype.constructor=nn,nn.prototype.name="TransformError";class Wl{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Xt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new nn(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,o=E.empty){let s=Fs(this.doc,e,t,o);return s&&this.step(s),this}replaceWith(e,t,o){return this.replace(e,t,new E(k.from(o),0,0))}delete(e,t){return this.replace(e,t,E.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,o){return Up(this,e,t,o),this}replaceRangeWith(e,t,o){return Jp(this,e,t,o),this}deleteRange(e,t){return Yp(this,e,t),this}lift(e,t){return Ip(this,e,t),this}join(e,t=1){return _p(this,e,t),this}wrap(e,t){return Lp(this,e,t),this}setBlockType(e,t=e,o,s=null){return zp(this,e,t,o,s),this}setNodeMarkup(e,t,o=null,s){return $p(this,e,t,o,s),this}setNodeAttribute(e,t,o){return this.step(new tn(e,t,o)),this}setDocAttribute(e,t){return this.step(new Mn(e,t)),this}addNodeMark(e,t){return this.step(new Je(e,t)),this}removeNodeMark(e,t){if(!(t instanceof B)){let o=this.doc.nodeAt(e);if(!o)throw new RangeError("No node at position "+e);if(t=t.isInSet(o.marks),!t)return this}return this.step(new Qt(e,t)),this}split(e,t=1,o){return Bp(this,e,t,o),this}addMark(e,t,o){return Np(this,e,t,o),this}removeMark(e,t,o){return Op(this,e,t,o),this}clearIncompatible(e,t,o){return Hs(this,e,t,o),this}}const Ws=Object.create(null);class D{constructor(e,t,o){this.$anchor=e,this.$head=t,this.ranges=o||[new jl(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=E.empty){let o=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=o,o=o.lastChild;let i=e.steps.length,r=this.ranges;for(let l=0;l<r.length;l++){let{$from:a,$to:c}=r[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(c.pos),l?E.empty:t),l==0&&Ul(e,i,(o?o.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let o=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:r,$to:l}=s[i],a=e.mapping.slice(o),c=a.map(r.pos),d=a.map(l.pos);i?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),Ul(e,o,t.isInline?-1:1))}}static findFrom(e,t,o=!1){let s=e.parent.inlineContent?new L(e):on(e.node(0),e.parent,e.pos,e.index(),t,o);if(s)return s;for(let i=e.depth-1;i>=0;i--){let r=t<0?on(e.node(0),e.node(i),e.before(i+1),e.index(i),t,o):on(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,o);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ge(e.node(0))}static atStart(e){return on(e,e,0,0,1)||new ge(e)}static atEnd(e){return on(e,e,e.content.size,e.childCount,-1)||new ge(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let o=Ws[t.type];if(!o)throw new RangeError(`No selection type ${t.type} defined`);return o.fromJSON(e,t)}static jsonID(e,t){if(e in Ws)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ws[e]=t,t.prototype.jsonID=e,t}getBookmark(){return L.between(this.$anchor,this.$head).getBookmark()}}D.prototype.visible=!0;class jl{constructor(e,t){this.$from=e,this.$to=t}}let ql=!1;function Kl(n){!ql&&!n.parent.inlineContent&&(ql=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class L extends D{constructor(e,t=e){Kl(e),Kl(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let o=e.resolve(t.map(this.head));if(!o.parent.inlineContent)return D.near(o);let s=e.resolve(t.map(this.anchor));return new L(s.parent.inlineContent?s:o,o)}replace(e,t=E.empty){if(super.replace(e,t),t==E.empty){let o=this.$from.marksAcross(this.$to);o&&e.ensureMarks(o)}}eq(e){return e instanceof L&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Io(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 L(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){let s=e.resolve(t);return new this(s,o==t?s:e.resolve(o))}static between(e,t,o){let s=e.pos-t.pos;if((!o||s)&&(o=s>=0?1:-1),!t.parent.inlineContent){let i=D.findFrom(t,o,!0)||D.findFrom(t,-o,!0);if(i)t=i.$head;else return D.near(t,o)}return e.parent.inlineContent||(s==0?e=t:(e=(D.findFrom(e,-o,!0)||D.findFrom(e,o,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new L(e,t)}}D.jsonID("text",L);class Io{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Io(e.map(this.anchor),e.map(this.head))}resolve(e){return L.between(e.resolve(this.anchor),e.resolve(this.head))}}class R extends D{constructor(e){let t=e.nodeAfter,o=e.node(0).resolve(e.pos+t.nodeSize);super(e,o),this.node=t}map(e,t){let{deleted:o,pos:s}=t.mapResult(this.anchor),i=e.resolve(s);return o?D.near(i):new R(i)}content(){return new E(k.from(this.node),0,0)}eq(e){return e instanceof R&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new js(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new R(e.resolve(t.anchor))}static create(e,t){return new R(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}R.prototype.visible=!1,D.jsonID("node",R);class js{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:o}=e.mapResult(this.anchor);return t?new Io(o,o):new js(o)}resolve(e){let t=e.resolve(this.anchor),o=t.nodeAfter;return o&&R.isSelectable(o)?new R(t):D.near(t)}}class ge extends D{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=E.empty){if(t==E.empty){e.delete(0,e.doc.content.size);let o=D.atStart(e.doc);o.eq(e.selection)||e.setSelection(o)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ge(e)}map(e){return new ge(e)}eq(e){return e instanceof ge}getBookmark(){return Zp}}D.jsonID("all",ge);const Zp={map(){return this},resolve(n){return new ge(n)}};function on(n,e,t,o,s,i=!1){if(e.inlineContent)return L.create(n,t);for(let r=o-(s>0?0:1);s>0?r<e.childCount:r>=0;r+=s){let l=e.child(r);if(l.isAtom){if(!i&&R.isSelectable(l))return R.create(n,t-(s<0?l.nodeSize:0))}else{let a=on(n,l,t+s,s<0?l.childCount:0,s,i);if(a)return a}t+=l.nodeSize*s}return null}function Ul(n,e,t){let o=n.steps.length-1;if(o<e)return;let s=n.steps[o];if(!(s instanceof se||s instanceof X))return;let i=n.mapping.maps[o],r;i.forEach((l,a,c,d)=>{r==null&&(r=d)}),n.setSelection(D.near(n.doc.resolve(r),t))}const Jl=1,Ro=2,Yl=4;class Xp extends Wl{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|Jl)&~Ro,this.storedMarks=null,this}get selectionSet(){return(this.updated&Jl)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Ro,this}ensureMarks(e){return B.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&Ro)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Ro,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let o=this.selection;return t&&(e=e.mark(this.storedMarks||(o.empty?o.$from.marks():o.$from.marksAcross(o.$to)||B.none))),o.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,o){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(o==null&&(o=t),o=o??t,!e)return this.deleteRange(t,o);let i=this.storedMarks;if(!i){let r=this.doc.resolve(t);i=o==t?r.marks():r.marksAcross(this.doc.resolve(o))}return this.replaceRangeWith(t,o,s.text(e,i)),this.selection.empty||this.setSelection(D.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|=Yl,this}get scrolledIntoView(){return(this.updated&Yl)>0}}function Zl(n,e){return!e||!n?n:n.bind(e)}class An{constructor(e,t,o){this.name=e,this.init=Zl(t.init,o),this.apply=Zl(t.apply,o)}}const Qp=[new An("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new An("selection",{init(n,e){return n.selection||D.atStart(e.doc)},apply(n){return n.selection}}),new An("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,o){return o.selection.$cursor?n.storedMarks:null}}),new An("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class qs{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Qp.slice(),t&&t.forEach(o=>{if(this.pluginsByKey[o.key])throw new RangeError("Adding different instances of a keyed plugin ("+o.key+")");this.plugins.push(o),this.pluginsByKey[o.key]=o,o.spec.state&&this.fields.push(new An(o.key,o.spec.state,o))})}}class sn{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 o=0;o<this.config.plugins.length;o++)if(o!=t){let s=this.config.plugins[o];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],o=this.applyInner(e),s=null;for(;;){let i=!1;for(let r=0;r<this.config.plugins.length;r++){let l=this.config.plugins[r];if(l.spec.appendTransaction){let a=s?s[r].n:0,c=s?s[r].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,o);if(d&&o.filterTransaction(d,r)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let u=0;u<this.config.plugins.length;u++)s.push(u<r?{state:o,n:t.length}:{state:this,n:0})}t.push(d),o=o.applyInner(d),i=!0}s&&(s[r]={state:o,n:t.length})}}if(!i)return{state:o,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new sn(this.config),o=this.config.fields;for(let s=0;s<o.length;s++){let i=o[s];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new Xp(this)}static create(e){let t=new qs(e.doc?e.doc.type.schema:e.schema,e.plugins),o=new sn(t);for(let s=0;s<t.fields.length;s++)o[t.fields[s].name]=t.fields[s].init(e,o);return o}reconfigure(e){let t=new qs(this.schema,e.plugins),o=t.fields,s=new sn(t);for(let i=0;i<o.length;i++){let r=o[i].name;s[r]=this.hasOwnProperty(r)?this[r]:o[i].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(o=>o.toJSON())),e&&typeof e=="object")for(let o in e){if(o=="doc"||o=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[o],i=s.spec.state;i&&i.toJSON&&(t[o]=i.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,o){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new qs(e.schema,e.plugins),i=new sn(s);return s.fields.forEach(r=>{if(r.name=="doc")i.doc=St.fromJSON(e.schema,t.doc);else if(r.name=="selection")i.selection=D.fromJSON(i.doc,t.selection);else if(r.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(o)for(let l in o){let a=o[l],c=a.spec.state;if(a.key==r.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[r.name]=c.fromJSON.call(a,e,t[l],i);return}}i[r.name]=r.init(e,i)}}),i}}function Xl(n,e,t){for(let o in n){let s=n[o];s instanceof Function?s=s.bind(e):o=="handleDOMEvents"&&(s=Xl(s,e,{})),t[o]=s}return t}class En{constructor(e){this.spec=e,this.props={},e.props&&Xl(e.props,this,this.props),this.key=e.key?e.key.key:Ql("plugin")}getState(e){return e[this.key]}}const Ks=Object.create(null);function Ql(n){return n in Ks?n+"$"+ ++Ks[n]:(Ks[n]=0,n+"$")}class Nn{constructor(e="key"){this.key=Ql(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ea=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function ef(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const tf=(n,e,t)=>{let o=ef(n,t);if(!o)return!1;let s=ta(o);if(!s){let r=o.blockRange(),l=r&&Oo(r);return l==null?!1:(e&&e(n.tr.lift(r,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(la(n,s,e,-1))return!0;if(o.parent.content.size==0&&(rn(i,"end")||R.isSelectable(i)))for(let r=o.depth;;r--){let l=Fs(n.doc,o.before(r),o.after(r),E.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(rn(i,"end")?D.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):R.create(a.doc,s.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(r==1||o.node(r-1).childCount>1)break}return i.isAtom&&s.depth==o.depth-1?(e&&e(n.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1};function rn(n,e,t=!1){for(let o=n;o;o=e=="start"?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(t&&o.childCount!=1)return!1}return!1}const nf=(n,e,t)=>{let{$head:o,empty:s}=n.selection,i=o;if(!s)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):o.parentOffset>0)return!1;i=ta(o)}let r=i&&i.nodeBefore;return!r||!R.isSelectable(r)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,i.pos-r.nodeSize)).scrollIntoView()),!0)};function ta(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 of(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const sf=(n,e,t)=>{let o=of(n,t);if(!o)return!1;let s=na(o);if(!s)return!1;let i=s.nodeAfter;if(la(n,s,e,1))return!0;if(o.parent.content.size==0&&(rn(i,"start")||R.isSelectable(i))){let r=Fs(n.doc,o.before(),o.after(),E.empty);if(r&&r.slice.size<r.to-r.from){if(e){let l=n.tr.step(r);l.setSelection(rn(i,"start")?D.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):R.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&s.depth==o.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},rf=(n,e,t)=>{let{$head:o,empty:s}=n.selection,i=o;if(!s)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):o.parentOffset<o.parent.content.size)return!1;i=na(o)}let r=i&&i.nodeAfter;return!r||!R.isSelectable(r)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,i.pos)).scrollIntoView()),!0)};function na(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 lf=(n,e)=>{let{$head:t,$anchor:o}=n.selection;return!t.parent.type.spec.code||!t.sameParent(o)?!1:(e&&e(n.tr.insertText(`
|
|
298
|
-
`).scrollIntoView()),!0)};function Us(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 oa=(n,e)=>{let{$head:t,$anchor:o}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(o))return!1;let s=t.node(-1),i=t.indexAfter(-1),r=Us(s.contentMatchAt(i));if(!r||!s.canReplaceWith(i,i,r))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,r.createAndFill());a.setSelection(D.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},af=(n,e)=>{let t=n.selection,{$from:o,$to:s}=t;if(t instanceof ge||o.parent.inlineContent||s.parent.inlineContent)return!1;let i=Us(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let r=(!o.parentOffset&&s.index()<s.parent.childCount?o:s).pos,l=n.tr.insert(r,i.createAndFill());l.setSelection(L.create(l.doc,r+1)),e(l.scrollIntoView())}return!0},sa=(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 i=t.before();if(en(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let o=t.blockRange(),s=o&&Oo(o);return s==null?!1:(e&&e(n.tr.lift(o,s).scrollIntoView()),!0)};function ia(n){return(e,t)=>{let{$from:o,$to:s}=e.selection;if(e.selection instanceof R&&e.selection.node.isBlock)return!o.parentOffset||!en(e.doc,o.pos)?!1:(t&&t(e.tr.split(o.pos).scrollIntoView()),!0);if(!o.depth)return!1;let i=[],r,l,a=!1,c=!1;for(let p=o.depth;;p--)if(o.node(p).isBlock){a=o.end(p)==o.pos+(o.depth-p),c=o.start(p)==o.pos-(o.depth-p),l=Us(o.node(p-1).contentMatchAt(o.indexAfter(p-1)));let m=n&&n(s.parent,a,o);i.unshift(m||(a&&l?{type:l}:null)),r=p;break}else{if(p==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof L||e.selection instanceof ge)&&d.deleteSelection();let u=d.mapping.map(o.pos),h=en(d.doc,u,i.length,i);if(h||(i[0]=l?{type:l}:null,h=en(d.doc,u,i.length,i)),d.split(u,i.length,i),!a&&c&&o.node(r).type!=l){let p=d.mapping.map(o.before(r)),f=d.doc.resolve(p);l&&o.node(r-1).canReplaceWith(f.index(),f.index()+1,l)&&d.setNodeMarkup(d.mapping.map(o.before(r)),l)}return t&&t(d.scrollIntoView()),!0}}const cf=ia(),ra=(n,e)=>(e&&e(n.tr.setSelection(new ge(n.doc))),!0);function df(n,e,t){let o=e.nodeBefore,s=e.nodeAfter,i=e.index();return!o||!s||!o.type.compatibleContent(s.type)?!1:!o.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-o.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||Po(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function la(n,e,t,o){let s=e.nodeBefore,i=e.nodeAfter,r,l,a=s.type.spec.isolating||i.type.spec.isolating;if(!a&&df(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(r=(l=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&l.matchType(r[0]||i.type).validEnd){if(t){let p=e.pos+i.nodeSize,f=k.empty;for(let b=r.length-1;b>=0;b--)f=k.from(r[b].create(null,f));f=k.from(s.copy(f));let m=n.tr.step(new X(e.pos-1,p,e.pos,p,new E(f,1,0),r.length,!0)),g=m.doc.resolve(p+2*r.length);g.nodeAfter&&g.nodeAfter.type==s.type&&Po(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=i.type.spec.isolating||o>0&&a?null:D.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),h=u&&Oo(u);if(h!=null&&h>=e.depth)return t&&t(n.tr.lift(u,h).scrollIntoView()),!0;if(c&&rn(i,"start",!0)&&rn(s,"end")){let p=s,f=[];for(;f.push(p),!p.isTextblock;)p=p.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,m.content)){if(t){let b=k.empty;for(let y=f.length-1;y>=0;y--)b=k.from(f[y].copy(b));let w=n.tr.step(new X(e.pos-f.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new E(b,f.length,0),0,!0));t(w.scrollIntoView())}return!0}}return!1}function aa(n){return function(e,t){let o=e.selection,s=n<0?o.$from:o.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(t&&t(e.tr.setSelection(L.create(e.doc,n<0?s.start(i):s.end(i)))),!0):!1}}const uf=aa(-1),hf=aa(1);function pf(n,e=null){return function(t,o){let s=!1;for(let i=0;i<t.selection.ranges.length&&!s;i++){let{$from:{pos:r},$to:{pos:l}}=t.selection.ranges[i];t.doc.nodesBetween(r,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)s=!0;else{let d=t.doc.resolve(c),u=d.index();s=d.parent.canReplaceWith(u,u+1,n)}})}if(!s)return!1;if(o){let i=t.tr;for(let r=0;r<t.selection.ranges.length;r++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[r];i.setBlockType(l,a,n,e)}o(i.scrollIntoView())}return!0}}function ff(n,e,t,o){for(let s=0;s<e.length;s++){let{$from:i,$to:r}=e[s],l=i.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(i.pos,r.pos,(a,c)=>{if(l||!o)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function kt(n,e=null,t){let o=t!==!1;return function(s,i){let{empty:r,$cursor:l,ranges:a}=s.selection;if(r&&!l||!ff(s.doc,a,n,o))return!1;if(i)if(l)n.isInSet(s.storedMarks||l.marks())?i(s.tr.removeStoredMark(n)):i(s.tr.addStoredMark(n.create(e)));else{let c,d=s.tr;c=!a.some(u=>s.doc.rangeHasMark(u.$from.pos,u.$to.pos,n));for(let u=0;u<a.length;u++){let{$from:h,$to:p}=a[u];if(!c)d.removeMark(h.pos,p.pos,n);else{let f=h.pos,m=p.pos,g=h.nodeAfter,b=p.nodeBefore,w=g&&g.isText?/^\s*/.exec(g.text)[0].length:0,y=b&&b.isText?/\s*$/.exec(b.text)[0].length:0;f+w<m&&(f+=w,m-=y),d.addMark(f,m,n.create(e))}}i(d.scrollIntoView())}return!0}}function On(...n){return function(e,t,o){for(let s=0;s<n.length;s++)if(n[s](e,t,o))return!0;return!1}}let Js=On(ea,tf,nf),ca=On(ea,sf,rf);const Ve={Enter:On(lf,af,sa,cf),"Mod-Enter":oa,Backspace:Js,"Mod-Backspace":Js,"Shift-Backspace":Js,Delete:ca,"Mod-Delete":ca,"Mod-a":ra},da={"Ctrl-h":Ve.Backspace,"Alt-Backspace":Ve["Mod-Backspace"],"Ctrl-d":Ve.Delete,"Ctrl-Alt-Backspace":Ve["Mod-Delete"],"Alt-Delete":Ve["Mod-Delete"],"Alt-d":Ve["Mod-Delete"],"Ctrl-a":uf,"Ctrl-e":hf};for(let n in Ve)da[n]=Ve[n];const mf=(typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1)?da:Ve;var Do=200,J=function(){};J.prototype.append=function(e){return e.length?(e=J.from(e),!this.length&&e||e.length<Do&&this.leafAppend(e)||this.length<Do&&e.leafPrepend(this)||this.appendInner(e)):this},J.prototype.prepend=function(e){return e.length?J.from(e).append(this):this},J.prototype.appendInner=function(e){return new gf(this,e)},J.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?J.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},J.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},J.prototype.forEach=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length),t<=o?this.forEachInner(e,t,o,0):this.forEachInvertedInner(e,t,o,0)},J.prototype.map=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length);var s=[];return this.forEach(function(i,r){return s.push(e(i,r))},t,o),s},J.from=function(e){return e instanceof J?e:e&&e.length?new ua(e):J.empty};var ua=function(n){function e(o){n.call(this),this.values=o}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(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,r,l){for(var a=i;a<r;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,r,l){for(var a=i-1;a>=r;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Do)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Do)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(J);J.empty=new ua([]);var gf=function(n){function e(t,o){n.call(this),this.left=t,this.right=o,this.length=t.length+o.length,this.depth=Math.max(t.depth,o.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(o){return o<this.left.length?this.left.get(o):this.right.get(o-this.left.length)},e.prototype.forEachInner=function(o,s,i,r){var l=this.left.length;if(s<l&&this.left.forEachInner(o,s,Math.min(i,l),r)===!1||i>l&&this.right.forEachInner(o,Math.max(s-l,0),Math.min(this.length,i)-l,r+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,i,r){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(o,s-l,Math.max(i,l)-l,r+l)===!1||i<l&&this.left.forEachInvertedInner(o,Math.min(s,l),i,r)===!1)return!1},e.prototype.sliceInner=function(o,s){if(o==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(o,s):o>=i?this.right.slice(o-i,s-i):this.left.slice(o,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(o){var s=this.right.leafAppend(o);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(o){var s=this.left.leafPrepend(o);if(s)return new e(s,this.right)},e.prototype.appendInner=function(o){return this.left.depth>=Math.max(this.right.depth,o.depth)+1?new e(this.left,new e(this.right,o)):new e(this,o)},e}(J);const yf=500;class Ce{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}let s,i;t&&(s=this.remapping(o,this.items.length),i=s.maps.length);let r=e.tr,l,a,c=[],d=[];return this.items.forEach((u,h)=>{if(!u.step){s||(s=this.remapping(o,h+1),i=s.maps.length),i--,d.push(u);return}if(s){d.push(new Oe(u.map));let p=u.step.map(s.slice(i)),f;p&&r.maybeStep(p).doc&&(f=r.mapping.maps[r.mapping.maps.length-1],c.push(new Oe(f,void 0,void 0,c.length+d.length))),i--,f&&s.appendMap(f,i)}else r.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(i)):u.selection,a=new Ce(this.items.slice(0,o).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:r,selection:l}}addTransform(e,t,o,s){let i=[],r=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),h=new Oe(e.mapping.maps[d],u,t),p;(p=a&&a.merge(h))&&(h=p,d?i.pop():l=l.slice(0,l.length-1)),i.push(h),t&&(r++,t=void 0),s||(a=h)}let c=r-o.depth;return c>vf&&(l=bf(l,c),r-=c),new Ce(l.append(i),r)}remapping(e,t){let o=new Xt;return this.items.forEach((s,i)=>{let r=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?o.maps.length-s.mirrorOffset:void 0;o.appendMap(s.map,r)},e,t),o}addMaps(e){return this.eventCount==0?this:new Ce(this.items.append(e.map(t=>new Oe(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let o=[],s=Math.max(0,this.items.length-t),i=e.mapping,r=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},s);let a=t;this.items.forEach(h=>{let p=i.getMirror(--a);if(p==null)return;r=Math.min(r,p);let f=i.maps[p];if(h.step){let m=e.steps[p].invert(e.docs[p]),g=h.selection&&h.selection.map(i.slice(a+1,p));g&&l++,o.push(new Oe(f,m,g))}else o.push(new Oe(f))},s);let c=[];for(let h=t;h<r;h++)c.push(new Oe(i.maps[h]));let d=this.items.slice(0,s).append(c).append(o),u=new Ce(d,l);return u.emptyItemCount()>yf&&(u=u.compress(this.items.length-o.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),o=t.maps.length,s=[],i=0;return this.items.forEach((r,l)=>{if(l>=e)s.push(r),r.selection&&i++;else if(r.step){let a=r.step.map(t.slice(o)),c=a&&a.getMap();if(o--,c&&t.appendMap(c,o),a){let d=r.selection&&r.selection.map(t.slice(o));d&&i++;let u=new Oe(c.invert(),a,d),h,p=s.length-1;(h=s.length&&s[p].merge(u))?s[p]=h:s.push(u)}}else r.map&&o--},this.items.length,0),new Ce(J.from(s.reverse()),i)}}Ce.empty=new Ce(J.empty,0);function bf(n,e){let t;return n.forEach((o,s)=>{if(o.selection&&e--==0)return t=s,!1}),n.slice(t)}class Oe{constructor(e,t,o,s){this.map=e,this.step=t,this.selection=o,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Oe(t.getMap().invert(),t,this.selection)}}}class Ye{constructor(e,t,o,s,i){this.done=e,this.undone=t,this.prevRanges=o,this.prevTime=s,this.prevComposition=i}}const vf=20;function xf(n,e,t,o){let s=t.getMeta(Tt),i;if(s)return s.historyState;t.getMeta(Cf)&&(n=new Ye(n.done,n.undone,null,0,-1));let r=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(r&&r.getMeta(Tt))return r.getMeta(Tt).redo?new Ye(n.done.addTransform(t,void 0,o,Lo(e)),n.undone,ha(t.mapping.maps),n.prevTime,n.prevComposition):new Ye(n.done,n.undone.addTransform(t,void 0,o,Lo(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(r&&r.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!r&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-o.newGroupDelay||!Sf(t,n.prevRanges)),c=r?Ys(n.prevRanges,t.mapping):ha(t.mapping.maps);return new Ye(n.done.addTransform(t,a?e.selection.getBookmark():void 0,o,Lo(e)),Ce.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new Ye(n.done.rebased(t,i),n.undone.rebased(t,i),Ys(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Ye(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Ys(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Sf(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((o,s)=>{for(let i=0;i<e.length;i+=2)o<=e[i+1]&&s>=e[i]&&(t=!0)}),t}function ha(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((o,s,i,r)=>e.push(i,r));return e}function Ys(n,e){if(!n)return null;let t=[];for(let o=0;o<n.length;o+=2){let s=e.map(n[o],1),i=e.map(n[o+1],-1);s<=i&&t.push(s,i)}return t}function wf(n,e,t){let o=Lo(e),s=Tt.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,o);if(!i)return null;let r=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),s,o),a=new Ye(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(r).setMeta(Tt,{redo:t,historyState:a})}let Zs=!1,pa=null;function Lo(n){let e=n.plugins;if(pa!=e){Zs=!1,pa=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Zs=!0;break}}return Zs}const Tt=new Nn("history"),Cf=new Nn("closeHistory");function kf(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new En({key:Tt,state:{init(){return new Ye(Ce.empty,Ce.empty,null,0,-1)},apply(e,t,o){return xf(t,o,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let o=t.inputType,s=o=="historyUndo"?ma:o=="historyRedo"?Xs:null;return s?(t.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function fa(n,e){return(t,o)=>{let s=Tt.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(o){let i=wf(s,t,n);i&&o(e?i.scrollIntoView():i)}return!0}}const ma=fa(!1,!0),Xs=fa(!0,!0);for(var Ze={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:"'"},zo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Tf=typeof navigator<"u"&&/Mac/.test(navigator.platform),Mf=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Q=0;Q<10;Q++)Ze[48+Q]=Ze[96+Q]=String(Q);for(var Q=1;Q<=24;Q++)Ze[Q+111]="F"+Q;for(var Q=65;Q<=90;Q++)Ze[Q]=String.fromCharCode(Q+32),zo[Q]=String.fromCharCode(Q);for(var Qs in Ze)zo.hasOwnProperty(Qs)||(zo[Qs]=Ze[Qs]);function Af(n){var e=Tf&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Mf&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?zo:Ze)[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 Ef=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Nf(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let o,s,i,r;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))r=!0;else if(/^a(lt)?$/i.test(a))o=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Ef?r=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return o&&(t="Alt-"+t),s&&(t="Ctrl-"+t),r&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function Of(n){let e=Object.create(null);for(let t in n)e[Nf(t)]=n[t];return e}function ei(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 ti(n){return new En({props:{handleKeyDown:ga(n)}})}function ga(n){let e=Of(n);return function(t,o){let s=Af(o),i,r=e[ei(s,o)];if(r&&r(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(o.shiftKey){let l=e[ei(s,o,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((o.shiftKey||o.altKey||o.metaKey||s.charCodeAt(0)>127)&&(i=Ze[o.keyCode])&&i!=s){let l=e[ei(i,o)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}function ya(n,e=null){return function(t,o){let{$from:s,$to:i}=t.selection,r=s.blockRange(i),l=!1,a=r;if(!r)return!1;if(r.depth>=2&&s.node(r.depth-1).type.compatibleContent(n)&&r.startIndex==0){if(s.index(r.depth-1)==0)return!1;let d=t.doc.resolve(r.start-2);a=new wo(d,d,r.depth),r.endIndex<r.parent.childCount&&(r=new wo(s,t.doc.resolve(i.end(r.depth)),r.depth)),l=!0}let c=zl(a,n,e,r);return c?(o&&o(Pf(t.tr,r,c,l,n).scrollIntoView()),!0):!1}}function Pf(n,e,t,o,s){let i=k.empty;for(let d=t.length-1;d>=0;d--)i=k.from(t[d].type.create(t[d].attrs,i));n.step(new X(e.start-(o?2:0),e.end,e.start,e.end,new E(i,0,0),t.length,!0));let r=0;for(let d=0;d<t.length;d++)t[d].type==s&&(r=d+1);let l=t.length-r,a=e.start+t.length-(o?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,h=!0;d<u;d++,h=!1)!h&&en(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function If(n,e){return function(t,o){let{$from:s,$to:i,node:r}=t.selection;if(r&&r.isBlock||s.depth<2||!s.sameParent(i))return!1;let l=s.node(-1);if(l.type!=n)return!1;if(s.parent.content.size==0&&s.node(-1).childCount==s.indexAfter(-1)){if(s.depth==3||s.node(-3).type!=n||s.index(-2)!=s.node(-2).childCount-1)return!1;if(o){let u=k.empty,h=s.index(-1)?1:s.index(-2)?2:3;for(let b=s.depth-h;b>=s.depth-3;b--)u=k.from(s.node(b).copy(u));let p=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3;u=u.append(k.from(n.createAndFill()));let f=s.before(s.depth-(h-1)),m=t.tr.replace(f,s.after(-p),new E(u,4-h,0)),g=-1;m.doc.nodesBetween(f,m.doc.content.size,(b,w)=>{if(g>-1)return!1;b.isTextblock&&b.content.size==0&&(g=w+1)}),g>-1&&m.setSelection(D.near(m.doc.resolve(g))),o(m.scrollIntoView())}return!0}let a=i.pos==s.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(s.pos,i.pos),d=a?[null,{type:a}]:void 0;return en(c.doc,s.pos,2,d)?(o&&o(c.split(s.pos,2,d).scrollIntoView()),!0):!1}}function ni(n){return function(e,t){let{$from:o,$to:s}=e.selection,i=o.blockRange(s,r=>r.childCount>0&&r.firstChild.type==n);return i?t?o.node(i.depth-1).type==n?Rf(e,t,n,i):Df(e,t,i):!0:!1}}function Rf(n,e,t,o){let s=n.tr,i=o.end,r=o.$to.end(o.depth);i<r&&(s.step(new X(i-1,r,i,r,new E(k.from(t.create(null,o.parent.copy())),1,0),1,!0)),o=new wo(s.doc.resolve(o.$from.pos),s.doc.resolve(r),o.depth));const l=Oo(o);if(l==null)return!1;s.lift(o,l);let a=s.mapping.map(i,-1)-1;return Po(s.doc,a)&&s.join(a),e(s.scrollIntoView()),!0}function Df(n,e,t){let o=n.tr,s=t.parent;for(let p=t.end,f=t.endIndex-1,m=t.startIndex;f>m;f--)p-=s.child(f).nodeSize,o.delete(p-1,p+1);let i=o.doc.resolve(t.start),r=i.nodeAfter;if(o.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,r.content.append(a?k.empty:k.from(s))))return!1;let u=i.pos,h=u+r.nodeSize;return o.step(new X(u-(l?1:0),h+(a?1:0),u+1,h-1,new E((l?k.empty:k.from(s.copy(k.empty))).append(a?k.empty:k.from(s.copy(k.empty))),l?0:1,a?0:1),l?0:1)),e(o.scrollIntoView()),!0}function Lf(n){return function(e,t){let{$from:o,$to:s}=e.selection,i=o.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!i)return!1;let r=i.startIndex;if(r==0)return!1;let l=i.parent,a=l.child(r-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=k.from(c?n.create():null),u=new E(k.from(n.create(null,k.from(l.type.create(null,d)))),c?3:1,0),h=i.start,p=i.end;t(e.tr.step(new X(h-(c?3:1),p,h,p,u,1,!0)).scrollIntoView())}return!0}}const ee=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Pn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let oi=null;const $e=function(n,e,t){let o=oi||(oi=document.createRange());return o.setEnd(n,t??n.nodeValue.length),o.setStart(n,e||0),o},zf=function(){oi=null},Mt=function(n,e,t,o){return t&&(ba(n,e,t,o,-1)||ba(n,e,t,o,1))},Vf=/^(img|br|input|textarea|hr)$/i;function ba(n,e,t,o,s){for(;;){if(n==t&&e==o)return!0;if(e==(s<0?0:be(n))){let i=n.parentNode;if(!i||i.nodeType!=1||In(n)||Vf.test(n.nodeName)||n.contentEditable=="false")return!1;e=ee(n)+(s<0?0:1),n=i}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.contentEditable=="false")return!1;e=s<0?be(n):0}else return!1}}function be(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function $f(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=be(n)}else if(n.parentNode&&!In(n))e=ee(n),n=n.parentNode;else return null}}function Bf(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&&!In(n))e=ee(n)+1,n=n.parentNode;else return null}}function Hf(n,e,t){for(let o=e==0,s=e==be(n);o||s;){if(n==t)return!0;let i=ee(n);if(n=n.parentNode,!n)return!1;o=o&&i==0,s=s&&i==be(n)}}function In(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 Vo=function(n){return n.focusNode&&Mt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function At(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Ff(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function _f(n,e,t){if(n.caretPositionFromPoint)try{let o=n.caretPositionFromPoint(e,t);if(o)return{node:o.offsetNode,offset:Math.min(be(o.offsetNode),o.offset)}}catch{}if(n.caretRangeFromPoint){let o=n.caretRangeFromPoint(e,t);if(o)return{node:o.startContainer,offset:Math.min(be(o.startContainer),o.startOffset)}}}const Pe=typeof navigator<"u"?navigator:null,va=typeof document<"u"?document:null,Xe=Pe&&Pe.userAgent||"",si=/Edge\/(\d+)/.exec(Xe),xa=/MSIE \d/.exec(Xe),ii=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Xe),pe=!!(xa||ii||si),Qe=xa?document.documentMode:ii?+ii[1]:si?+si[1]:0,ke=!pe&&/gecko\/(\d+)/i.test(Xe);ke&&+(/Firefox\/(\d+)/.exec(Xe)||[0,0])[1];const ri=!pe&&/Chrome\/(\d+)/.exec(Xe),ie=!!ri,Sa=ri?+ri[1]:0,ae=!pe&&!!Pe&&/Apple Computer/.test(Pe.vendor),ln=ae&&(/Mobile\/\w+/.test(Xe)||!!Pe&&Pe.maxTouchPoints>2),ve=ln||(Pe?/Mac/.test(Pe.platform):!1),Gf=Pe?/Win/.test(Pe.platform):!1,Te=/Android \d/.test(Xe),Rn=!!va&&"webkitFontSmoothing"in va.documentElement.style,Wf=Rn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function jf(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 Be(n,e){return typeof n=="number"?n:n[e]}function qf(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,o=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*o}}function wa(n,e,t){let o=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let r=t||n.dom;r;r=Pn(r)){if(r.nodeType!=1)continue;let l=r,a=l==i.body,c=a?jf(i):qf(l),d=0,u=0;if(e.top<c.top+Be(o,"top")?u=-(c.top-e.top+Be(s,"top")):e.bottom>c.bottom-Be(o,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+Be(s,"top")-c.top:e.bottom-c.bottom+Be(s,"bottom")),e.left<c.left+Be(o,"left")?d=-(c.left-e.left+Be(s,"left")):e.right>c.right-Be(o,"right")&&(d=e.right-c.right+Be(s,"right")),d||u)if(a)i.defaultView.scrollBy(d,u);else{let h=l.scrollLeft,p=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let f=l.scrollLeft-h,m=l.scrollTop-p;e={left:e.left-f,top:e.top-m,right:e.right-f,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(r).position))break}}function Kf(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),o,s;for(let i=(e.left+e.right)/2,r=t+1;r<Math.min(innerHeight,e.bottom);r+=5){let l=n.root.elementFromPoint(i,r);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){o=l,s=a.top;break}}return{refDOM:o,refTop:s,stack:Ca(n.dom)}}function Ca(n){let e=[],t=n.ownerDocument;for(let o=n;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),n!=t);o=Pn(o));return e}function Uf({refDOM:n,refTop:e,stack:t}){let o=n?n.getBoundingClientRect().top:0;ka(t,o==0?0:o-e)}function ka(n,e){for(let t=0;t<n.length;t++){let{dom:o,top:s,left:i}=n[t];o.scrollTop!=s+e&&(o.scrollTop=s+e),o.scrollLeft!=i&&(o.scrollLeft=i)}}let an=null;function Jf(n){if(n.setActive)return n.setActive();if(an)return n.focus(an);let e=Ca(n);n.focus(an==null?{get preventScroll(){return an={preventScroll:!0},!0}}:void 0),an||(an=!1,ka(e,0))}function Ta(n,e){let t,o=2e8,s,i=0,r=e.top,l=e.top,a,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let h;if(d.nodeType==1)h=d.getClientRects();else if(d.nodeType==3)h=$e(d).getClientRects();else continue;for(let p=0;p<h.length;p++){let f=h[p];if(f.top<=r&&f.bottom>=l){r=Math.max(f.bottom,r),l=Math.min(f.top,l);let m=f.left>e.left?f.left-e.left:f.right<e.left?e.left-f.right:0;if(m<o){t=d,o=m,s=m&&t.nodeType==3?{left:f.right<e.left?f.right:f.left,top:e.top}:e,d.nodeType==1&&m&&(i=u+(e.left>=(f.left+f.right)/2?1:0));continue}}else f.top>e.top&&!a&&f.left<=e.left&&f.right>=e.left&&(a=d,c={left:Math.max(f.left,Math.min(f.right,e.left)),top:f.top});!t&&(e.left>=f.right&&e.top>=f.top||e.left>=f.left&&e.top>=f.bottom)&&(i=u+1)}}return!t&&a&&(t=a,s=c,o=0),t&&t.nodeType==3?Yf(t,s):!t||o&&t.nodeType==1?{node:n,offset:i}:Ta(t,s)}function Yf(n,e){let t=n.nodeValue.length,o=document.createRange();for(let s=0;s<t;s++){o.setEnd(n,s+1),o.setStart(n,s);let i=et(o,1);if(i.top!=i.bottom&&li(e,i))return{node:n,offset:s+(e.left>=(i.left+i.right)/2?1:0)}}return{node:n,offset:0}}function li(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Zf(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Xf(n,e,t){let{node:o,offset:s}=Ta(e,t),i=-1;if(o.nodeType==1&&!o.firstChild){let r=o.getBoundingClientRect();i=r.left!=r.right&&t.left>(r.left+r.right)/2?1:-1}return n.docView.posFromDOM(o,s,i)}function Qf(n,e,t,o){let s=-1;for(let i=e,r=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!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&&(!r&&a.left>o.left||a.top>o.top?s=l.posBefore:(!r&&a.right<o.left||a.bottom<o.top)&&(s=l.posAfter),r=!0),!l.contentDOM&&s<0&&!l.node.isText)return(l.node.isBlock?o.top<(a.top+a.bottom)/2:o.left<(a.left+a.right)/2)?l.posBefore:l.posAfter}i=l.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function Ma(n,e,t){let o=n.childNodes.length;if(o&&t.top<t.bottom)for(let s=Math.max(0,Math.min(o-1,Math.floor(o*(e.top-t.top)/(t.bottom-t.top))-2)),i=s;;){let r=n.childNodes[i];if(r.nodeType==1){let l=r.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(li(e,c))return Ma(r,e,c)}}if((i=(i+1)%o)==s)break}return n}function em(n,e){let t=n.dom.ownerDocument,o,s=0,i=_f(t,e.left,e.top);i&&({node:o,offset:s}=i);let r=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!r||!n.dom.contains(r.nodeType!=1?r.parentNode:r)){let c=n.dom.getBoundingClientRect();if(!li(e,c)||(r=Ma(n.dom,e,c),!r))return null}if(ae)for(let c=r;o&&c;c=Pn(c))c.draggable&&(o=void 0);if(r=Zf(r,e),o){if(ke&&o.nodeType==1&&(s=Math.min(s,o.childNodes.length),s<o.childNodes.length)){let d=o.childNodes[s],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&s++}let c;Rn&&s&&o.nodeType==1&&(c=o.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,o==n.dom&&s==o.childNodes.length-1&&o.lastChild.nodeType==1&&e.top>o.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(s==0||o.nodeType!=1||o.childNodes[s-1].nodeName!="BR")&&(l=Qf(n,o,s,e))}l==null&&(l=Xf(n,r,e));let a=n.docView.nearestDesc(r,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Aa(n){return n.top<n.bottom||n.left<n.right}function et(n,e){let t=n.getClientRects();if(t.length){let o=t[e<0?0:t.length-1];if(Aa(o))return o}return Array.prototype.find.call(t,Aa)||n.getBoundingClientRect()}const tm=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ea(n,e,t){let{node:o,offset:s,atom:i}=n.docView.domFromPos(e,t<0?-1:1),r=Rn||ke;if(o.nodeType==3)if(r&&(tm.test(o.nodeValue)||(t<0?!s:s==o.nodeValue.length))){let a=et($e(o,s,s),t);if(ke&&s&&/\s/.test(o.nodeValue[s-1])&&s<o.nodeValue.length){let c=et($e(o,s-1,s-1),-1);if(c.top==a.top){let d=et($e(o,s,s+1),-1);if(d.top!=a.top)return Dn(d,d.left<c.left)}}return a}else{let a=s,c=s,d=t<0?1:-1;return t<0&&!s?(c++,d=-1):t>=0&&s==o.nodeValue.length?(a--,d=1):t<0?a--:c++,Dn(et($e(o,a,c),d),d<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(t<0||s==be(o))){let a=o.childNodes[s-1];if(a.nodeType==1)return ai(a.getBoundingClientRect(),!1)}if(i==null&&s<be(o)){let a=o.childNodes[s];if(a.nodeType==1)return ai(a.getBoundingClientRect(),!0)}return ai(o.getBoundingClientRect(),t>=0)}if(i==null&&s&&(t<0||s==be(o))){let a=o.childNodes[s-1],c=a.nodeType==3?$e(a,be(a)-(r?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Dn(et(c,1),!1)}if(i==null&&s<be(o)){let a=o.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?$e(a,0,r?0:1):a.nodeType==1?a:null:null;if(c)return Dn(et(c,-1),!0)}return Dn(et(o.nodeType==3?$e(o):o,-t),t>=0)}function Dn(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 ai(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 Na(n,e,t){let o=n.state,s=n.root.activeElement;o!=e&&n.updateState(e),s!=n.dom&&n.focus();try{return t()}finally{o!=e&&n.updateState(o),s!=n.dom&&s&&s.focus()}}function nm(n,e,t){let o=e.selection,s=t=="up"?o.$from:o.$to;return Na(n,e,()=>{let{node:i}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let r=Ea(n,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=$e(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?r.top-d.top>(d.bottom-r.top)*2:d.bottom-r.bottom>(r.bottom-d.top)*2))return!1}}return!0})}const om=/[\u0590-\u08ac]/;function sm(n,e,t){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let s=o.parentOffset,i=!s,r=s==o.parent.content.size,l=n.domSelection();return l?!om.test(o.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:r:Na(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",t,"character");let p=o.depth?n.docView.domAfterPos(o.before()):n.dom,{focusNode:f,focusOffset:m}=n.domSelectionRange(),g=f&&!p.contains(f.nodeType==1?f:f.parentNode)||a==f&&c==m;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return h!=null&&(l.caretBidiLevel=h),g}):o.pos==o.start()||o.pos==o.end()}let Oa=null,Pa=null,Ia=!1;function im(n,e,t){return Oa==e&&Pa==t?Ia:(Oa=e,Pa=t,Ia=t=="up"||t=="down"?nm(n,e,t):sm(n,e,t))}const xe=0,Ra=1,Et=2,Ie=3;class Ln{constructor(e,t,o,s){this.parent=e,this.children=t,this.dom=o,this.contentDOM=s,this.dirty=xe,o.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,o){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,o=this.posAtStart;;t++){let s=this.children[t];if(s==e)return o;o+=s.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,o){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(o<0){let i,r;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((r=i.pmViewDesc)&&r.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(r)+r.size:this.posAtStart}else{let i,r;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((r=i.pmViewDesc)&&r.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(r):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>ee(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??o>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let o=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),r;if(i&&(!t||i.node))if(o&&(r=i.nodeDOM)&&!(r.nodeType==1?r.contains(e.nodeType==1?e:e.parentNode):r==e))o=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let o=t;o;o=o.parent)if(o==this)return t}posFromDOM(e,t,o){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,t,o)}return-1}descAt(e){for(let t=0,o=0;t<this.children.length;t++){let s=this.children[t],i=o+s.size;if(o==e&&i!=o){for(;!s.border&&s.children.length;)s=s.children[0];return s}if(e<i)return s.descAt(e-o-s.border);o=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let o=0,s=0;for(let i=0;o<this.children.length;o++){let r=this.children[o],l=i+r.size;if(l>e||r instanceof za){s=e-i;break}i=l}if(s)return this.children[o].domFromPos(s-this.children[o].border,t);for(let i;o&&!(i=this.children[o-1]).size&&i instanceof Da&&i.side>=0;o--);if(t<=0){let i,r=!0;for(;i=o?this.children[o-1]:null,!(!i||i.dom.parentNode==this.contentDOM);o--,r=!1);return i&&t&&r&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?ee(i.dom)+1:0}}else{let i,r=!0;for(;i=o<this.children.length?this.children[o]:null,!(!i||i.dom.parentNode==this.contentDOM);o++,r=!1);return i&&r&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?ee(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,o=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let r=o,l=0;;l++){let a=this.children[l],c=r+a.size;if(s==-1&&e<=c){let d=r+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=r;for(let u=l;u>0;u--){let h=this.children[u-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){s=ee(h.dom)+1;break}e-=h.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){i=ee(u.dom);break}t+=u.size}i==-1&&(i=this.contentDOM.childNodes.length);break}r=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:i}}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:o}=this.domFromPos(e,0);if(t.nodeType!=1||o==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[o]}setSelection(e,t,o,s=!1){let i=Math.min(e,t),r=Math.max(e,t);for(let p=0,f=0;p<this.children.length;p++){let m=this.children[p],g=f+m.size;if(i>f&&r<g)return m.setSelection(e-f-m.border,t-f-m.border,o,s);f=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=o.root.getSelection(),d=o.domSelectionRange(),u=!1;if((ke||ae)&&e==t){let{node:p,offset:f}=l;if(p.nodeType==3){if(u=!!(f&&p.nodeValue[f-1]==`
|
|
299
|
-
`),u&&f==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:ee(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=p.childNodes[f-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(ke&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(s=!0)}if(!(s||u&&ae)&&Mt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Mt(a.node,a.offset,d.focusNode,d.focusOffset))return;let h=!1;if((c.extend||e==t)&&!u){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),h=!0}catch{}}if(!h){if(e>t){let f=l;l=a,a=f}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 o=0,s=0;s<this.children.length;s++){let i=this.children[s],r=o+i.size;if(o==r?e<=r&&t>=o:e<r&&t>o){let l=o+i.border,a=r-i.border;if(e>=l&&t<=a){this.dirty=e==o||t==r?Et:Ra,e==l&&t==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Ie:i.markDirty(e-l,t-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Et:Ie}o=r}this.dirty=Et}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let o=e==1?Et:Ra;t.dirty<o&&(t.dirty=o)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class Da extends Ln{constructor(e,t,o,s){let i,r=t.type.toDOM;if(typeof r=="function"&&(r=r(o,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(r.nodeType!=1){let l=document.createElement("span");l.appendChild(r),r=l}r.contentEditable="false",r.classList.add("ProseMirror-widget")}super(e,[],r,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==xe&&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 rm extends Ln{constructor(e,t,o,s){super(e,[],t,null),this.textDOM=o,this.text=s}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 Nt extends Ln{constructor(e,t,o,s,i){super(e,[],o,s),this.mark=t,this.spec=i}static create(e,t,o,s){let i=s.nodeViews[t.type.name],r=i&&i(t,s,o);return(!r||!r.dom)&&(r=Ct.renderSpec(document,t.type.spec.toDOM(t,o),null,t.attrs)),new Nt(e,t,r.dom,r.contentDOM||r.dom,r)}parseRule(){return this.dirty&Ie||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ie&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=xe){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=xe}}slice(e,t,o){let s=Nt.create(this.parent,this.mark,!0,o),i=this.children,r=this.size;t<r&&(i=di(i,t,r,o)),e>0&&(i=di(i,0,e,o));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class tt extends Ln{constructor(e,t,o,s,i,r,l,a,c){super(e,[],i,r),this.node=t,this.outerDeco=o,this.innerDeco=s,this.nodeDOM=l}static create(e,t,o,s,i,r){let l=i.nodeViews[t.type.name],a,c=l&&l(t,i,()=>{if(!a)return r;if(a.parent)return a.parent.posBeforeChild(a)},o,s),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Ct.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let h=d;return d=Ba(d,o,t),c?a=new lm(e,t,o,s,d,u||null,h,c,i,r+1):t.isText?new $o(e,t,o,s,d,h,i):new tt(e,t,o,s,d,u||null,h,i,r+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 o=this.children[t];if(this.dom.contains(o.dom.parentNode)){e.contentElement=o.dom.parentNode;break}}e.contentElement||(e.getContent=()=>k.empty)}return e}matchesNode(e,t,o){return this.dirty==xe&&e.eq(this.node)&&Bo(t,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let o=this.node.inlineContent,s=t,i=e.composing?this.localCompositionInfo(e,t):null,r=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new cm(this,r&&r.node,e);hm(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,o,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?B.none:this.node.child(d).marks,o,e),a.placeWidget(c,e,s)},(c,d,u,h)=>{a.syncToMarks(c.marks,o,e);let p;a.findNodeMatch(c,d,u,h)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(p=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,d,u,p,e)||a.updateNextNode(c,d,u,e,h,s)||a.addNode(c,d,u,e,s),s+=c.nodeSize}),a.syncToMarks([],o,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Et)&&(r&&this.protectLocalComposition(e,r),Va(this.contentDOM,this.children,e),ln&&pm(this.dom))}localCompositionInfo(e,t){let{from:o,to:s}=e.state.selection;if(!(e.state.selection instanceof L)||o<t||s>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let r=i.nodeValue,l=fm(this.node.content,r,o-t,s-t);return l<0?null:{node:i,pos:l,text:r}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:o,text:s}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let r=new rm(this,i,t,s);e.input.compositionNodes.push(r),this.children=di(this.children,o,o+s.length,e,r)}update(e,t,o,s){return this.dirty==Ie||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,o,s),!0)}updateInner(e,t,o,s){this.updateOuterDeco(t),this.node=e,this.innerDeco=o,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=xe}updateOuterDeco(e){if(Bo(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,o=this.dom;this.dom=$a(this.dom,this.nodeDOM,ci(this.outerDeco,this.node,t),ci(e,this.node,t)),this.dom!=o&&(o.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 La(n,e,t,o,s){Ba(o,e,n);let i=new tt(void 0,n,e,t,o,o,o,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class $o extends tt{constructor(e,t,o,s,i,r,l){super(e,t,o,s,i,null,r,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,o,s){return this.dirty==Ie||this.dirty!=xe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=xe||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=xe,!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,o){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,o)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,o){let s=this.node.cut(e,t),i=document.createTextNode(s.text);return new $o(this.parent,s,this.outerDeco,this.innerDeco,i,i,o)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ie)}get domAtom(){return!1}isText(e){return this.node.text==e}}class za extends Ln{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==xe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class lm extends tt{constructor(e,t,o,s,i,r,l,a,c,d){super(e,t,o,s,i,r,l,c,d),this.spec=a}update(e,t,o,s){if(this.dirty==Ie)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,o);return i&&this.updateInner(e,t,o,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,o,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,o,s){this.spec.setSelection?this.spec.setSelection(e,t,o.root):super.setSelection(e,t,o,s)}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 Va(n,e,t){let o=n.firstChild,s=!1;for(let i=0;i<e.length;i++){let r=e[i],l=r.dom;if(l.parentNode==n){for(;l!=o;)o=Ha(o),s=!0;o=o.nextSibling}else s=!0,n.insertBefore(l,o);if(r instanceof Nt){let a=o?o.previousSibling:n.lastChild;Va(r.contentDOM,r.children,t),o=a?a.nextSibling:n.firstChild}}for(;o;)o=Ha(o),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const zn=function(n){n&&(this.nodeName=n)};zn.prototype=Object.create(null);const Ot=[new zn];function ci(n,e,t){if(n.length==0)return Ot;let o=t?Ot[0]:new zn,s=[o];for(let i=0;i<n.length;i++){let r=n[i].type.attrs;if(r){r.nodeName&&s.push(o=new zn(r.nodeName));for(let l in r){let a=r[l];a!=null&&(t&&s.length==1&&s.push(o=new zn(e.isInline?"span":"div")),l=="class"?o.class=(o.class?o.class+" ":"")+a:l=="style"?o.style=(o.style?o.style+";":"")+a:l!="nodeName"&&(o[l]=a))}}}return s}function $a(n,e,t,o){if(t==Ot&&o==Ot)return e;let s=e;for(let i=0;i<o.length;i++){let r=o[i],l=t[i];if(i){let a;l&&l.nodeName==r.nodeName&&s!=n&&(a=s.parentNode)&&a.nodeName.toLowerCase()==r.nodeName||(a=document.createElement(r.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=Ot[0]),s=a}am(s,l||Ot[0],r)}return s}function am(n,e,t){for(let o in e)o!="class"&&o!="style"&&o!="nodeName"&&!(o in t)&&n.removeAttribute(o);for(let o in t)o!="class"&&o!="style"&&o!="nodeName"&&t[o]!=e[o]&&n.setAttribute(o,t[o]);if(e.class!=t.class){let o=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<o.length;i++)s.indexOf(o[i])==-1&&n.classList.remove(o[i]);for(let i=0;i<s.length;i++)o.indexOf(s[i])==-1&&n.classList.add(s[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=o.exec(e.style);)n.style.removeProperty(s[1])}t.style&&(n.style.cssText+=t.style)}}function Ba(n,e,t){return $a(n,n,Ot,ci(e,t,n.nodeType!=1))}function Bo(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 Ha(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class cm{constructor(e,t,o){this.lock=t,this.view=o,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=dm(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let o=e;o<t;o++)this.top.children[o].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,o){let s=0,i=this.stack.length>>1,r=Math.min(i,e.length);for(;s<r&&(s==i-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<i;)this.destroyRest(),this.top.dirty=xe,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<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[i])&&!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=Nt.create(this.top,e[i],t,o);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,o,s){let i=-1,r;if(s>=this.preMatch.index&&(r=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&r.matchesNode(e,t,o))i=this.top.children.indexOf(r,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,o)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,o,s,i){let r=this.top.children[s];return r.dirty==Ie&&r.dom==r.contentDOM&&(r.dirty=Et),r.update(e,t,o,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let o=e.pmViewDesc;if(o){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==o)return s}return-1}e=t}}updateNextNode(e,t,o,s,i,r){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof tt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let d=a.dom,u,h=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Ie&&Bo(t,a.outerDeco));if(!h&&a.update(e,t,o,s))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(u=this.recreateWrapper(a,e,t,o,s,r)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=Et,u.updateChildren(s,r+1),u.dirty=xe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,o,s,i,r){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Bo(o,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=tt.create(this.top,t,o,s,i,r);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,o,s,i){let r=tt.create(this.top,e,t,o,s,i);r.contentDOM&&r.updateChildren(s,i+1),this.top.children.splice(this.index++,0,r),this.changed=!0}placeWidget(e,t,o){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new Da(this.top,e,t,o);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Nt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof $o)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ae||ie)&&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 o=document.createElement(e);e=="IMG"&&(o.className="ProseMirror-separator",o.alt=""),e=="BR"&&(o.className="ProseMirror-trailingBreak");let s=new za(this.top,[],o,null);t!=this.top?t.children.push(s):t.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function dm(n,e){let t=e,o=t.children.length,s=n.childCount,i=new Map,r=[];e:for(;s>0;){let l;for(;;)if(o){let c=t.children[o-1];if(c instanceof Nt)t=c,o=c.children.length;else{l=c,o--;break}}else{if(t==e)break e;o=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(s-1))break;--s,i.set(l,s),r.push(l)}}return{index:s,matched:i,matches:r.reverse()}}function um(n,e){return n.type.side-e.type.side}function hm(n,e,t,o){let s=e.locals(n),i=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);o(d,s,e.forChild(i,d),c),i+=d.nodeSize}return}let r=0,l=[],a=null;for(let c=0;;){let d,u;for(;r<s.length&&s[r].to==i;){let g=s[r++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(um);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let h,p;if(a)p=-1,h=a,a=null;else if(c<n.childCount)p=c,h=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;r<s.length&&s[r].from<=i&&s[r].to>i;)l.push(s[r++]);let f=i+h.nodeSize;if(h.isText){let g=f;r<s.length&&s[r].from<g&&(g=s[r].from);for(let b=0;b<l.length;b++)l[b].to<g&&(g=l[b].to);g<f&&(a=h.cut(g-i),h=h.cut(0,g-i),f=g,p=-1)}else for(;r<s.length&&s[r].to<f;)r++;let m=h.isInline&&!h.isLeaf?l.filter(g=>!g.inline):l.slice();o(h,m,e.forChild(i,h),p),i=f}}function pm(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 fm(n,e,t,o){for(let s=0,i=0;s<n.childCount&&i<=o;){let r=n.child(s++),l=i;if(i+=r.nodeSize,!r.isText)continue;let a=r.text;for(;s<n.childCount;){let c=n.child(s++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=t){if(i>=o&&a.slice(o-e.length-l,o-l)==e)return o-e.length;let c=l<o?a.lastIndexOf(e,o-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==o&&a.length>=o+e.length-l&&a.slice(o-l,o-l+e.length)==e)return o}}return-1}function di(n,e,t,o,s){let i=[];for(let r=0,l=0;r<n.length;r++){let a=n[r],c=l,d=l+=a.size;c>=t||d<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,o)),s&&(i.push(s),s=void 0),d>t&&i.push(a.slice(t-c,a.size,o)))}return i}function ui(n,e=null){let t=n.domSelectionRange(),o=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),i=s&&s.size==0,r=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(r<0)return null;let l=o.resolve(r),a,c;if(Vo(t)){for(a=r;s&&!s.node;)s=s.parent;let u=s.node;if(s&&u.isAtom&&R.isSelectable(u)&&s.parent&&!(u.isInline&&Hf(t.focusNode,t.focusOffset,s.dom))){let h=s.posBefore;c=new R(r==h?l:o.resolve(h))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=r,h=r;for(let p=0;p<t.rangeCount;p++){let f=t.getRangeAt(p);u=Math.min(u,n.docView.posFromDOM(f.startContainer,f.startOffset,1)),h=Math.max(h,n.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(u<0)return null;[a,r]=h==n.state.selection.anchor?[h,u]:[u,h],l=o.resolve(r)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=o.resolve(a);if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=pi(n,d,l,u)}return c}function Fa(n){return n.editable?n.hasFocus():Ua(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function He(n,e=!1){let t=n.state.selection;if(ja(n,t),!!Fa(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&ie){let o=n.domSelectionRange(),s=n.domObserver.currentSelection;if(o.anchorNode&&s.anchorNode&&Mt(o.anchorNode,o.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)gm(n);else{let{anchor:o,head:s}=t,i,r;_a&&!(t instanceof L)&&(t.$from.parent.inlineContent||(i=Ga(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(r=Ga(n,t.to))),n.docView.setSelection(o,s,n,e),_a&&(i&&Wa(i),r&&Wa(r)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&mm(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const _a=ae||ie&&Sa<63;function Ga(n,e){let{node:t,offset:o}=n.docView.domFromPos(e,0),s=o<t.childNodes.length?t.childNodes[o]:null,i=o?t.childNodes[o-1]:null;if(ae&&s&&s.contentEditable=="false")return hi(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return hi(s);if(i)return hi(i)}}function hi(n){return n.contentEditable="true",ae&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Wa(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function mm(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),o=t.anchorNode,s=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=o||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Fa(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function gm(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let o=n.cursorWrapper.dom,s=o.nodeName=="IMG";s?t.setStart(o.parentNode,ee(o)+1):t.setStart(o,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!s&&!n.state.selection.visible&&pe&&Qe<=11&&(o.disabled=!0,o.disabled=!1)}function ja(n,e){if(e instanceof R){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(qa(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else qa(n)}function qa(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function pi(n,e,t,o){return n.someProp("createSelectionBetween",s=>s(n,e,t))||L.between(e,t,o)}function Ka(n){return n.editable&&!n.hasFocus()?!1:Ua(n)}function Ua(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 ym(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Mt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function fi(n,e){let{$anchor:t,$head:o}=n.selection,s=e>0?t.max(o):t.min(o),i=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return i&&D.findFrom(i,e)}function nt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Ja(n,e,t){let o=n.state.selection;if(o instanceof L)if(t.indexOf("s")>-1){let{$head:s}=o,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let r=n.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return nt(n,new L(o.$anchor,r))}else if(o.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=fi(n.state,e);return s&&s instanceof R?nt(n,s):!1}else if(!(ve&&t.indexOf("m")>-1)){let s=o.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,r;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(r=n.docView.descAt(l))&&!r.contentDOM?R.isSelectable(i)?nt(n,new R(e<0?n.state.doc.resolve(s.pos-i.nodeSize):s)):Rn?nt(n,new L(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(o instanceof R&&o.node.isInline)return nt(n,new L(e>0?o.$to:o.$from));{let s=fi(n.state,e);return s?nt(n,s):!1}}}function Ho(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Vn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function cn(n,e){return e<0?bm(n):vm(n)}function bm(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s,i,r=!1;for(ke&&t.nodeType==1&&o<Ho(t)&&Vn(t.childNodes[o],-1)&&(r=!0);;)if(o>0){if(t.nodeType!=1)break;{let l=t.childNodes[o-1];if(Vn(l,-1))s=t,i=--o;else if(l.nodeType==3)t=l,o=t.nodeValue.length;else break}}else{if(Ya(t))break;{let l=t.previousSibling;for(;l&&Vn(l,-1);)s=t.parentNode,i=ee(l),l=l.previousSibling;if(l)t=l,o=Ho(t);else{if(t=t.parentNode,t==n.dom)break;o=0}}}r?mi(n,t,o):s&&mi(n,s,i)}function vm(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s=Ho(t),i,r;for(;;)if(o<s){if(t.nodeType!=1)break;let l=t.childNodes[o];if(Vn(l,1))i=t,r=++o;else break}else{if(Ya(t))break;{let l=t.nextSibling;for(;l&&Vn(l,1);)i=l.parentNode,r=ee(l)+1,l=l.nextSibling;if(l)t=l,o=0,s=Ho(t);else{if(t=t.parentNode,t==n.dom)break;o=s=0}}}i&&mi(n,i,r)}function Ya(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function xm(n,e){for(;n&&e==n.childNodes.length&&!In(n);)e=ee(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 Sm(n,e){for(;n&&!e&&!In(n);)e=ee(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 mi(n,e,t){if(e.nodeType!=3){let i,r;(r=xm(e,t))?(e=r,t=0):(i=Sm(e,t))&&(e=i,t=i.nodeValue.length)}let o=n.domSelection();if(!o)return;if(Vo(o)){let i=document.createRange();i.setEnd(e,t),i.setStart(e,t),o.removeAllRanges(),o.addRange(i)}else o.extend&&o.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&He(n)},50)}function Za(n,e){let t=n.state.doc.resolve(e);if(!(ie||Gf)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),r=(i.top+i.bottom)/2;if(r>s.top&&r<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<t.end()){let i=n.coordsAtPos(e+1),r=(i.top+i.bottom)/2;if(r>s.top&&r<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Xa(n,e,t){let o=n.state.selection;if(o instanceof L&&!o.empty||t.indexOf("s")>-1||ve&&t.indexOf("m")>-1)return!1;let{$from:s,$to:i}=o;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let r=fi(n.state,e);if(r&&r instanceof R)return nt(n,r)}if(!s.parent.inlineContent){let r=e<0?s:i,l=o instanceof ge?D.near(r,e):D.findFrom(r,e);return l?nt(n,l):!1}return!1}function Qa(n,e){if(!(n.state.selection instanceof L))return!0;let{$head:t,$anchor:o,empty:s}=n.state.selection;if(!t.sameParent(o))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let r=n.state.tr;return e<0?r.delete(t.pos-i.nodeSize,t.pos):r.delete(t.pos,t.pos+i.nodeSize),n.dispatch(r),!0}return!1}function ec(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function wm(n){if(!ae||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 o=e.firstChild;ec(n,o,"true"),setTimeout(()=>ec(n,o,"false"),20)}return!1}function Cm(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function km(n,e){let t=e.keyCode,o=Cm(e);if(t==8||ve&&t==72&&o=="c")return Qa(n,-1)||cn(n,-1);if(t==46&&!e.shiftKey||ve&&t==68&&o=="c")return Qa(n,1)||cn(n,1);if(t==13||t==27)return!0;if(t==37||ve&&t==66&&o=="c"){let s=t==37?Za(n,n.state.selection.from)=="ltr"?-1:1:-1;return Ja(n,s,o)||cn(n,s)}else if(t==39||ve&&t==70&&o=="c"){let s=t==39?Za(n,n.state.selection.from)=="ltr"?1:-1:1;return Ja(n,s,o)||cn(n,s)}else{if(t==38||ve&&t==80&&o=="c")return Xa(n,-1,o)||cn(n,-1);if(t==40||ve&&t==78&&o=="c")return wm(n)||Xa(n,1,o)||cn(n,1);if(o==(ve?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function tc(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:o,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&o.childCount==1&&o.firstChild.childCount==1;){s--,i--;let p=o.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),o=p.content}let r=n.someProp("clipboardSerializer")||Ct.fromSchema(n.state.schema),l=cc(),a=l.createElement("div");a.appendChild(r.serializeFragment(o,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=lc[c.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let f=l.createElement(d[p]);for(;a.firstChild;)f.appendChild(a.firstChild);a.appendChild(f),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${u?` -${u}`:""} ${JSON.stringify(t)}`);let h=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,`
|
|
293
|
+
}`,Ls=new WeakMap,lh=(n,e)=>{Ls.set(n,e)},ah=n=>{Ls.delete(n)},zs=n=>Ls.get(n),vo=n=>{const e=n.target,t=e.closest(".tox"),o=e.matches(".ephox-snooker-resizer-bar");(t||o)&&n.stopPropagation()},cl=n=>{n.stopPropagation(),n.preventDefault()},ch=(n,e)=>{const t=n.getDoc(),o=n.getWin();if(e!=null&&e.event){const{event:s}=e,{clientX:r,clientY:i}=s;let l;if(t.caretRangeFromPoint)l=t.caretRangeFromPoint(r,i);else if(t.caretPositionFromPoint){const a=t.caretPositionFromPoint(r,i);l=t.createRange(),l==null||l.setStart(a.offsetNode,a.offset)}if(l){const a=o.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(l),n.selection.setRng(l)}}else n.execCommand("SelectAll")},dh=n=>{var c,d;const{el:e,editor:t,componentView:o}=n,s=t.runCommand(_.getStateTheme),r=o.model,i={target:e,inline:!0,skin:(s==null?void 0:s.theme)===ii.dark?"oxide-dark":"oxide",menubar:!1,image_advtab:!0,paste_data_images:!0,statusbar:!1,branding:!1,forced_root_block:"div",plugins:"advlist autolink lists link image media table",toolbar_mode:"sliding",toolbar:"bold italic underline strikethrough forecolor backcolor alignleft aligncenter alignright alignjustify link image | fontfamily fontsize bullist numlist outdent indent table"},l=((d=(c=n.pluginOpts)==null?void 0:c.loadConfig)==null?void 0:d.call(c,{config:i,editor:t,componentView:o,component:r}))||{};return{...i,...l}},dl=(n,e=document)=>new Promise((t,o)=>{const s=Array.isArray(n)?[...n]:[n],{head:r}=e,i=l=>{if(l.length){const a=e.createElement("script");a.src=l.shift(),a.onload=i.bind(null,l),a.onerror=o,r.appendChild(a)}else t()};i(s)}),uh=G(function(n,e={}){const t={cdnScript:"https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",...e},{cdnScript:o}=t,s=n.Canvas.events,r=!t.skipCustomTheme,i="gs-plg-tinymce-studio-theme",l=async(d,u)=>{const p=d.ownerDocument,h=p.defaultView,f=u==null?void 0:u.view;if(!h||!f){console.warn("Missing required data",{win:h,componentView:f});return}const m=dh({el:d,editor:n,componentView:f,pluginOpts:t}),v=(await h.tinymce.init(m))[0];if(!v)return;const y=(await window.tinymce.init({...m,target:document.createElement("div")}))[0];return v.ui.show(),p.body.addEventListener("mousedown",vo),document.body.addEventListener("mousedown",vo),v.on("Change",()=>nh(d)),v.on("blur",()=>v.ui.show()),v.on("OpenWindow",function(){var S;const b=(S=p.querySelector(".tox-dialog"))==null?void 0:S.closest(".tox");b&&(b==null?void 0:b.ownerDocument)!==document&&(document.body.appendChild(b),v.once("CloseWindow",()=>{b&&b.ownerDocument===document&&p.body.appendChild(b)}))}),d.addEventListener("dragstart",cl,{capture:!0}),n.runCommand(_.setStateContextMenu,{enabled:!1}),ch(v,u),{rteEditor:v,rteEditorShallow:y}},a=(d,u)=>{d.ownerDocument.body.removeEventListener("mousedown",vo),document.body.removeEventListener("mousedown",vo),d.removeEventListener("dragstart",cl,{capture:!0}),n.runCommand(_.setStateContextMenu,{enabled:!0}),u.rteEditor.destroy(),u.rteEditorShallow.destroy()};n.on(s.frameLoad,async({window:d})=>{const u=d.document;dl(o,u)}),n.onReady(()=>{dl(o,document),r&&cs(i,ih,{target:document.body})}),n.setCustomRte({parseContent:!0,async enable(d,u,p){const h=zs(d);if(h)return h.rteEditor;const f=await l(d,p);return f&&lh(d,f),f==null?void 0:f.rteEditor},disable(d){const u=zs(d);u&&(ah(d),a(d,u))},getContent(d){var p,h;const u=zs(d);return u?(h=(p=u.rteEditor).getContent)==null?void 0:h.call(p):d.innerHTML}});const c=oh(n,t.enableOnClick);W({editor:n,licenseKey:t.licenseKey,plan:rh,pluginName:sh,cleanup:()=>{n.RichTextEditor.customRte=void 0,c()}})});function Z(n){this.content=n}Z.prototype={constructor:Z,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 o=t&&t!=n?this.remove(t):this,s=o.find(n),r=o.content.slice();return s==-1?r.push(t||n,e):(r[s+1]=e,t&&(r[s]=t)),new Z(r)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Z(t)},addToStart:function(n,e){return new Z([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Z(t)},addBefore:function(n,e,t){var o=this.remove(e),s=o.content.slice(),r=o.find(n);return s.splice(r==-1?s.length:r,0,e,t),new Z(s)},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=Z.from(n),n.size?new Z(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Z.from(n),n.size?new Z(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Z.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}},Z.from=function(n){if(n instanceof Z)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Z(e)};function ul(n,e,t){for(let o=0;;o++){if(o==n.childCount||o==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(o),r=e.child(o);if(s==r){t+=s.nodeSize;continue}if(!s.sameMarkup(r))return t;if(s.isText&&s.text!=r.text){for(let i=0;s.text[i]==r.text[i];i++)t++;return t}if(s.content.size||r.content.size){let i=ul(s.content,r.content,t+1);if(i!=null)return i}t+=s.nodeSize}}function pl(n,e,t,o){for(let s=n.childCount,r=e.childCount;;){if(s==0||r==0)return s==r?null:{a:t,b:o};let i=n.child(--s),l=e.child(--r),a=i.nodeSize;if(i==l){t-=a,o-=a;continue}if(!i.sameMarkup(l))return{a:t,b:o};if(i.isText&&i.text!=l.text){let c=0,d=Math.min(i.text.length,l.text.length);for(;c<d&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,o--;return{a:t,b:o}}if(i.content.size||l.content.size){let c=pl(i.content,l.content,t-1,o-1);if(c)return c}t-=a,o-=a}}class k{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let o=0;o<e.length;o++)this.size+=e[o].nodeSize}nodesBetween(e,t,o,s=0,r){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&o(a,s+l,r||null,i)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),o,s+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,o,s){let r="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&o&&(i?i=!1:r+=o),r+=c},0),r}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,o=e.firstChild,s=this.content.slice(),r=0;for(t.isText&&t.sameMarkup(o)&&(s[s.length-1]=t.withText(t.text+o.text),r=1);r<e.content.length;r++)s.push(e.content[r]);return new k(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let o=[],s=0;if(t>e)for(let r=0,i=0;i<t;r++){let l=this.content[r],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),o.push(l),s+=l.nodeSize),i=a}return new k(o,s)}cutByIndex(e,t){return e==t?k.empty:e==0&&t==this.content.length?this:new k(this.content.slice(e,t))}replaceChild(e,t){let o=this.content[e];if(o==t)return this;let s=this.content.slice(),r=this.size+t.nodeSize-o.nodeSize;return s[e]=t,new k(s,r)}addToStart(e){return new k([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new k(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,o=0;t<this.content.length;t++){let s=this.content[t];e(s,o,t),o+=s.nodeSize}}findDiffStart(e,t=0){return ul(this,e,t)}findDiffEnd(e,t=this.size,o=e.size){return pl(this,e,t,o)}findIndex(e,t=-1){if(e==0)return xo(0,e);if(e==this.size)return xo(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let o=0,s=0;;o++){let r=this.child(o),i=s+r.nodeSize;if(i>=e)return i==e||t>0?xo(o+1,i):xo(o,s);s=i}}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 k.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new k(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return k.empty;let t,o=0;for(let s=0;s<e.length;s++){let r=e[s];o+=r.nodeSize,s&&r.isText&&e[s-1].sameMarkup(r)?(t||(t=e.slice(0,s)),t[t.length-1]=r.withText(t[t.length-1].text+r.text)):t&&t.push(r)}return new k(t||e,o)}static from(e){if(!e)return k.empty;if(e instanceof k)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new k([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}k.empty=new k([],0);const $s={index:0,offset:0};function xo(n,e){return $s.index=n,$s.offset=e,$s}function So(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 o=0;o<n.length;o++)if(!So(n[o],e[o]))return!1}else{for(let o in n)if(!(o in e)||!So(n[o],e[o]))return!1;for(let o in e)if(!(o in n))return!1}return!0}class B{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,o=!1;for(let s=0;s<e.length;s++){let r=e[s];if(this.eq(r))return e;if(this.type.excludes(r.type))t||(t=e.slice(0,s));else{if(r.type.excludes(this.type))return e;!o&&r.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),o=!0),t&&t.push(r)}}return t||(t=e.slice()),o||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&&So(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 o=e.marks[t.type];if(!o)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=o.create(t.attrs);return o.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let o=0;o<e.length;o++)if(!e[o].eq(t[o]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return B.none;if(e instanceof B)return[e];let t=e.slice();return t.sort((o,s)=>o.type.rank-s.type.rank),t}}B.none=[];class wo extends Error{}class A{constructor(e,t,o){this.content=e,this.openStart=t,this.openEnd=o}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let o=fl(this.content,e+this.openStart,t);return o&&new A(o,this.openStart,this.openEnd)}removeBetween(e,t){return new A(hl(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 A.empty;let o=t.openStart||0,s=t.openEnd||0;if(typeof o!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new A(k.fromJSON(e,t.content),o,s)}static maxOpen(e,t=!0){let o=0,s=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)o++;for(let r=e.lastChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.lastChild)s++;return new A(e,o,s)}}A.empty=new A(k.empty,0,0);function hl(n,e,t){let{index:o,offset:s}=n.findIndex(e),r=n.maybeChild(o),{index:i,offset:l}=n.findIndex(t);if(s==e||r.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(o!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(o,r.copy(hl(r.content,e-s-1,t-s-1)))}function fl(n,e,t,o){let{index:s,offset:r}=n.findIndex(e),i=n.maybeChild(s);if(r==e||i.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=fl(i.content,e-r-1,t);return l&&n.replaceChild(s,i.copy(l))}function ph(n,e,t){if(t.openStart>n.depth)throw new wo("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new wo("Inconsistent open depths");return ml(n,e,t,0)}function ml(n,e,t,o){let s=n.index(o),r=n.node(o);if(s==e.index(o)&&o<n.depth-t.openStart){let i=ml(n,e,t,o+1);return r.copy(r.content.replaceChild(s,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==o&&e.depth==o){let i=n.parent,l=i.content;return xt(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=hh(t,n);return xt(r,yl(n,i,l,e,o))}else return xt(r,Co(n,e,o))}function gl(n,e){if(!e.type.compatibleContent(n.type))throw new wo("Cannot join "+e.type.name+" onto "+n.type.name)}function Vs(n,e,t){let o=n.node(t);return gl(o,e.node(t)),o}function vt(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 wn(n,e,t,o){let s=(e||n).node(t),r=0,i=e?e.index(t):s.childCount;n&&(r=n.index(t),n.depth>t?r++:n.textOffset&&(vt(n.nodeAfter,o),r++));for(let l=r;l<i;l++)vt(s.child(l),o);e&&e.depth==t&&e.textOffset&&vt(e.nodeBefore,o)}function xt(n,e){return n.type.checkContent(e),n.copy(e)}function yl(n,e,t,o,s){let r=n.depth>s&&Vs(n,e,s+1),i=o.depth>s&&Vs(t,o,s+1),l=[];return wn(null,n,s,l),r&&i&&e.index(s)==t.index(s)?(gl(r,i),vt(xt(r,yl(n,e,t,o,s+1)),l)):(r&&vt(xt(r,Co(n,e,s+1)),l),wn(e,t,s,l),i&&vt(xt(i,Co(t,o,s+1)),l)),wn(o,null,s,l),new k(l)}function Co(n,e,t){let o=[];if(wn(null,n,t,o),n.depth>t){let s=Vs(n,e,t+1);vt(xt(s,Co(n,e,t+1)),o)}return wn(e,null,t,o),new k(o)}function hh(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let r=t-1;r>=0;r--)s=e.node(r).copy(k.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class Cn{constructor(e,t,o){this.pos=e,this.path=t,this.parentOffset=o,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 o=this.pos-this.path[this.path.length-1],s=e.child(t);return o?e.child(t).cut(o):s}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 o=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let r=0;r<e;r++)s+=o.child(r).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return B.none;if(this.textOffset)return e.child(t).marks;let o=e.maybeChild(t-1),s=e.maybeChild(t);if(!o){let l=o;o=s,s=l}let r=o.marks;for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let o=t.marks,s=e.parent.maybeChild(e.index());for(var r=0;r<o.length;r++)o[r].type.spec.inclusive===!1&&(!s||!o[r].isInSet(s.marks))&&(o=o[r--].removeFromSet(o));return o}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 o=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);o>=0;o--)if(e.pos<=this.end(o)&&(!t||t(this.node(o))))return new ko(this,e,o);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 o=[],s=0,r=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(r),c=r-a;if(o.push(i,l,s+a),!c||(i=i.child(l),i.isText))break;r=c-1,s+=a+1}return new Cn(t,o,r)}static resolveCached(e,t){let o=bl.get(e);if(o)for(let r=0;r<o.elts.length;r++){let i=o.elts[r];if(i.pos==t)return i}else bl.set(e,o=new fh);let s=o.elts[o.i]=Cn.resolve(e,t);return o.i=(o.i+1)%mh,s}}class fh{constructor(){this.elts=[],this.i=0}}const mh=12,bl=new WeakMap;class ko{constructor(e,t,o){this.$from=e,this.$to=t,this.depth=o}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 gh=Object.create(null);let St=class ei{constructor(e,t,o,s=B.none){this.type=e,this.attrs=t,this.marks=s,this.content=o||k.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,o,s=0){this.content.nodesBetween(e,t,o,s,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,o,s){return this.content.textBetween(e,t,o,s)}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,o){return this.type==e&&So(this.attrs,t||e.defaultAttrs||gh)&&B.sameSet(this.marks,o||B.none)}copy(e=null){return e==this.content?this:new ei(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ei(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,o=!1){if(e==t)return A.empty;let s=this.resolve(e),r=this.resolve(t),i=o?0:s.sharedDepth(t),l=s.start(i),c=s.node(i).content.cut(s.pos-l,r.pos-l);return new A(c,s.depth-i,r.depth-i)}replace(e,t,o){return ph(this.resolve(e),this.resolve(t),o)}nodeAt(e){for(let t=this;;){let{index:o,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(o),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:o}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:o}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:o}=this.content.findIndex(e);if(o<e)return{node:this.content.child(t),index:t,offset:o};let s=this.content.child(t-1);return{node:s,index:t-1,offset:o-s.nodeSize}}resolve(e){return Cn.resolveCached(this,e)}resolveNoCache(e){return Cn.resolve(this,e)}rangeHasMark(e,t,o){let s=!1;return t>e&&this.nodesBetween(e,t,r=>(o.isInSet(r.marks)&&(s=!0),!s)),s}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()+")"),vl(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,o=k.empty,s=0,r=o.childCount){let i=this.contentMatchAt(e).matchFragment(o,s,r),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<r;a++)if(!this.type.allowsMarks(o.child(a).marks))return!1;return!0}canReplaceWith(e,t,o,s){if(s&&!this.type.allowsMarks(s))return!1;let r=this.contentMatchAt(e).matchType(o),i=r&&r.matchFragment(this.content,t);return i?i.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=B.none;for(let t=0;t<this.marks.length;t++){let o=this.marks[t];o.type.checkAttrs(o.attrs),e=o.addToSet(e)}if(!B.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 o;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");o=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,o)}let s=k.fromJSON(e,t.content),r=e.nodeType(t.type).create(t.attrs,s,o);return r.type.checkAttrs(r.attrs),r}};St.prototype.text=void 0;class To extends St{constructor(e,t,o,s){if(super(e,t,null,s),!o)throw new RangeError("Empty text nodes are not allowed");this.text=o}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):vl(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 To(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new To(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 vl(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class wt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let o=new yh(e,t);if(o.next==null)return wt.empty;let s=xl(o);o.next&&o.err("Unexpected trailing text");let r=kh(Ch(s));return Th(r,o),r}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,o=e.childCount){let s=this;for(let r=t;s&&r<o;r++)s=s.matchType(e.child(r).type);return s}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 o=0;o<e.next.length;o++)if(this.next[t].type==e.next[o].type)return!0;return!1}fillBefore(e,t=!1,o=0){let s=[this];function r(i,l){let a=i.matchFragment(e,o);if(a&&(!t||a.validEnd))return k.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:d,next:u}=i.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(u)==-1){s.push(u);let p=r(u,l.concat(d));if(p)return p}}return null}return r(this,[])}findWrapping(e){for(let o=0;o<this.wrapCache.length;o+=2)if(this.wrapCache[o]==e)return this.wrapCache[o+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),o=[{match:this,type:null,via:null}];for(;o.length;){let s=o.shift(),r=s.match;if(r.matchType(e)){let i=[];for(let l=s;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<r.next.length;i++){let{type:l,next:a}=r.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(o.push({match:l.contentMatch,type:l,via:s}),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(o){e.push(o);for(let s=0;s<o.next.length;s++)e.indexOf(o.next[s].next)==-1&&t(o.next[s].next)}return t(this),e.map((o,s)=>{let r=s+(o.validEnd?"*":" ")+" ";for(let i=0;i<o.next.length;i++)r+=(i?", ":"")+o.next[i].type.name+"->"+e.indexOf(o.next[i].next);return r}).join(`
|
|
294
|
+
`)}}wt.empty=new wt(!0);class yh{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 xl(n){let e=[];do e.push(bh(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function bh(n){let e=[];do e.push(vh(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function vh(n){let e=wh(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=xh(n,e);else break;return e}function Sl(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function xh(n,e){let t=Sl(n),o=t;return n.eat(",")&&(n.next!="}"?o=Sl(n):o=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:o,expr:e}}function Sh(n,e){let t=n.nodeTypes,o=t[e];if(o)return[o];let s=[];for(let r in t){let i=t[r];i.isInGroup(e)&&s.push(i)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function wh(n){if(n.eat("(")){let e=xl(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=Sh(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 Ch(n){let e=[[]];return s(r(n,0),t()),e;function t(){return e.push([])-1}function o(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function s(i,l){i.forEach(a=>a.to=l)}function r(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(r(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=r(i.exprs[a],l);if(a==i.exprs.length-1)return c;s(c,l=t())}else if(i.type=="star"){let a=t();return o(l,a),s(r(i.expr,a),a),[o(a)]}else if(i.type=="plus"){let a=t();return s(r(i.expr,l),a),s(r(i.expr,a),a),[o(a)]}else{if(i.type=="opt")return[o(l)].concat(r(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let d=t();s(r(i.expr,a),d),a=d}if(i.max==-1)s(r(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let d=t();o(a,d),s(r(i.expr,a),d),a=d}return[o(a)]}else{if(i.type=="name")return[o(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function wl(n,e){return e-n}function Cl(n,e){let t=[];return o(e),t.sort(wl);function o(s){let r=n[s];if(r.length==1&&!r[0].term)return o(r[0].to);t.push(s);for(let i=0;i<r.length;i++){let{term:l,to:a}=r[i];!l&&t.indexOf(a)==-1&&o(a)}}}function kh(n){let e=Object.create(null);return t(Cl(n,0));function t(o){let s=[];o.forEach(i=>{n[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<s.length;d++)s[d][0]==l&&(c=s[d][1]);Cl(n,a).forEach(d=>{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let r=e[o.join(",")]=new wt(o.indexOf(n.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(wl);r.next.push({type:s[i][0],next:e[l.join(",")]||t(l)})}return r}}function Th(n,e){for(let t=0,o=[n];t<o.length;t++){let s=o[t],r=!s.validEnd,i=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];i.push(a.name),r&&!(a.isText||a.hasRequiredAttrs())&&(r=!1),o.indexOf(c)==-1&&o.push(c)}r&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function kl(n){let e=Object.create(null);for(let t in n){let o=n[t];if(!o.hasDefault)return null;e[t]=o.default}return e}function Tl(n,e){let t=Object.create(null);for(let o in n){let s=e&&e[o];if(s===void 0){let r=n[o];if(r.hasDefault)s=r.default;else throw new RangeError("No value supplied for attribute "+o)}t[o]=s}return t}function Ml(n,e,t,o){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let r=n[s];r.validate&&r.validate(e[s])}}function El(n,e){let t=Object.create(null);if(e)for(let o in e)t[o]=new Eh(n,o,e[o]);return t}let Al=class Hd{constructor(e,t,o){this.name=e,this.schema=t,this.spec=o,this.markSet=null,this.groups=o.group?o.group.split(" "):[],this.attrs=El(e,o.attrs),this.defaultAttrs=kl(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(o.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==wt.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:Tl(this.attrs,e)}create(e=null,t,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new St(this,this.computeAttrs(e),k.from(t),B.setFrom(o))}createChecked(e=null,t,o){return t=k.from(t),this.checkContent(t),new St(this,this.computeAttrs(e),t,B.setFrom(o))}createAndFill(e=null,t,o){if(e=this.computeAttrs(e),t=k.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let s=this.contentMatch.matchFragment(t),r=s&&s.fillBefore(k.empty,!0);return r?new St(this,e,t.append(r),B.setFrom(o)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let o=0;o<e.childCount;o++)if(!this.allowsMarks(e.child(o).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){Ml(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 o=0;o<e.length;o++)this.allowsMarkType(e[o].type)?t&&t.push(e[o]):t||(t=e.slice(0,o));return t?t.length?t:B.none:e}static compile(e,t){let o=Object.create(null);e.forEach((r,i)=>o[r]=new Hd(r,t,i));let s=t.spec.topNode||"doc";if(!o[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let r in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};function Mh(n,e,t){let o=t.split("|");return s=>{let r=s===null?"null":typeof s;if(o.indexOf(r)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${n}, got ${r}`)}}class Eh{constructor(e,t,o){this.hasDefault=Object.prototype.hasOwnProperty.call(o,"default"),this.default=o.default,this.validate=typeof o.validate=="string"?Mh(e,t,o.validate):o.validate}get isRequired(){return!this.hasDefault}}class Mo{constructor(e,t,o,s){this.name=e,this.rank=t,this.schema=o,this.spec=s,this.attrs=El(e,s.attrs),this.excluded=null;let r=kl(this.attrs);this.instance=r?new B(this,r):null}create(e=null){return!e&&this.instance?this.instance:new B(this,Tl(this.attrs,e))}static compile(e,t){let o=Object.create(null),s=0;return e.forEach((r,i)=>o[r]=new Mo(r,s++,t,i)),o}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){Ml(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Ah{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=Z.from(e.nodes),t.marks=Z.from(e.marks||{}),this.nodes=Al.compile(this.spec.nodes,this),this.marks=Mo.compile(this.spec.marks,this);let o=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let r=this.nodes[s],i=r.spec.content||"",l=r.spec.marks;if(r.contentMatch=o[i]||(o[i]=wt.parse(i,this.nodes)),r.inlineContent=r.contentMatch.inlineContent,r.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!r.isInline||!r.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=r}r.markSet=l=="_"?null:l?Pl(this,l.split(" ")):l==""||!r.inlineContent?[]:null}for(let s in this.marks){let r=this.marks[s],i=r.spec.excludes;r.excluded=i==null?[r]:i==""?[]:Pl(this,i.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,o,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Al){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,o,s)}text(e,t){let o=this.nodes.text;return new To(o,o.defaultAttrs,e,B.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 B.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Pl(n,e){let t=[];for(let o=0;o<e.length;o++){let s=e[o],r=n.marks[s],i=r;if(r)t.push(r);else for(let l in n.marks){let a=n.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return t}function Ph(n){return n.tag!=null}function Nh(n){return n.style!=null}class Xt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let o=this.matchedStyles=[];t.forEach(s=>{if(Ph(s))this.tags.push(s);else if(Nh(s)){let r=/[^=]*/.exec(s.style)[0];o.indexOf(r)<0&&o.push(r),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let r=e.nodes[s.node];return r.contentMatch.matchType(r)})}parse(e,t={}){let o=new Rl(this,t,!1);return o.addAll(e,B.none,t.from,t.to),o.finish()}parseSlice(e,t={}){let o=new Rl(this,t,!0);return o.addAll(e,B.none,t.from,t.to),A.maxOpen(o.finish())}matchTag(e,t,o){for(let s=o?this.tags.indexOf(o)+1:0;s<this.tags.length;s++){let r=this.tags[s];if(Rh(e,r.tag)&&(r.namespace===void 0||e.namespaceURI==r.namespace)&&(!r.context||t.matchesContext(r.context))){if(r.getAttrs){let i=r.getAttrs(e);if(i===!1)continue;r.attrs=i||void 0}return r}}}matchStyle(e,t,o,s){for(let r=s?this.styles.indexOf(s)+1:0;r<this.styles.length;r++){let i=this.styles[r],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!o.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function o(s){let r=s.priority==null?50:s.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<r)break}t.splice(i,0,s)}for(let s in e.marks){let r=e.marks[s].spec.parseDOM;r&&r.forEach(i=>{o(i=Dl(i)),i.mark||i.ignore||i.clearMark||(i.mark=s)})}for(let s in e.nodes){let r=e.nodes[s].spec.parseDOM;r&&r.forEach(i=>{o(i=Dl(i)),i.node||i.ignore||i.mark||(i.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Xt(e,Xt.schemaRules(e)))}}const Nl={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},Oh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ol={ol:!0,ul:!0},Eo=1,Ao=2,kn=4;function Il(n,e,t){return e!=null?(e?Eo:0)|(e==="full"?Ao:0):n&&n.whitespace=="pre"?Eo|Ao:t&~kn}class Po{constructor(e,t,o,s,r,i){this.type=e,this.attrs=t,this.marks=o,this.solid=s,this.options=i,this.content=[],this.activeMarks=B.none,this.match=r||(i&kn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(k.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let o=this.type.contentMatch,s;return(s=o.findWrapping(e.type))?(this.match=o,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Eo)){let o=this.content[this.content.length-1],s;if(o&&o.isText&&(s=/[ \t\r\n\u000c]+$/.exec(o.text))){let r=o;o.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-s[0].length))}}let t=k.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(k.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&&!Nl.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Rl{constructor(e,t,o){this.parser=e,this.options=t,this.isOpen=o,this.open=0;let s=t.topNode,r,i=Il(null,t.preserveWhitespace,0)|(o?kn:0);s?r=new Po(s.type,s.attrs,B.none,!0,t.topMatch||s.type.contentMatch,i):o?r=new Po(null,null,B.none,!0,null,i):r=new Po(e.schema.topNodeType,null,B.none,!0,null,i),this.nodes=[r],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 o=e.nodeValue,s=this.top;if(s.options&Ao||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(o)){if(s.options&Eo)s.options&Ao?o=o.replace(/\r\n?/g,`
|
|
295
|
+
`):o=o.replace(/\r?\n|\r/g," ");else if(o=o.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(o)&&this.open==this.nodes.length-1){let r=s.content[s.content.length-1],i=e.previousSibling;(!r||i&&i.nodeName=="BR"||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(o=o.slice(1))}o&&this.insertNode(this.parser.schema.text(o),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,o){let s=e.nodeName.toLowerCase(),r;Ol.hasOwnProperty(s)&&this.parser.normalizeLists&&Ih(e);let i=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(r=this.parser.matchTag(e,this,o));if(i?i.ignore:Oh.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!i||i.skip||i.closeParent){i&&i.closeParent?this.open=Math.max(0,this.open-1):i&&i.skip.nodeType&&(e=i.skip);let l,a=this.top,c=this.needsBlock;if(Nl.hasOwnProperty(s))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 d=i&&i.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),l&&this.sync(a),this.needsBlock=c}else{let l=this.readStyles(e,t);l&&this.addElementByRule(e,i,l,i.consuming===!1?r:void 0)}}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
296
|
+
`),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 o=e.style;if(o&&o.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let r=this.parser.matchedStyles[s],i=o.getPropertyValue(r);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(r,i,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,o,s){let r,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),o)||this.leafFallback(e,o);else{let a=this.enter(i,t.attrs||null,o,t.preserveWhitespace);a&&(r=!0,o=a)}else{let a=this.parser.schema.marks[t.mark];o=o.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(s)this.addElement(e,o,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,o));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,o),this.findAround(e,a,!1)}r&&this.sync(l)&&this.open--}addAll(e,t,o,s){let r=o||0;for(let i=o?e.childNodes[o]:e.firstChild,l=s==null?null:e.childNodes[s];i!=l;i=i.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(i,t);this.findAtPoint(e,r)}findPlace(e,t){let o,s;for(let r=this.open;r>=0;r--){let i=this.nodes[r],l=i.findWrapping(e);if(l&&(!o||o.length>l.length)&&(o=l,s=i,!l.length)||i.solid)break}if(!o)return null;this.sync(s);for(let r=0;r<o.length;r++)t=this.enterInner(o[r],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let o=this.findPlace(e,t);if(o){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let r=B.none;for(let i of o.concat(e.marks))(s.type?s.type.allowsMarkType(i.type):Ll(i.type,e.type))&&(r=i.addToSet(r));return s.content.push(e.mark(r)),!0}return!1}enter(e,t,o,s){let r=this.findPlace(e.create(t),o);return r&&(r=this.enterInner(e,t,o,!0,s)),r}enterInner(e,t,o,s=!1,r){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=Il(e,r,i.options);i.options&kn&&i.content.length==0&&(l|=kn);let a=B.none;return o=o.filter(c=>(i.type?i.type.allowsMarkType(c.type):Ll(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Po(e,t,a,s,null,l)),this.open++,o}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 o=this.nodes[t].content;for(let s=o.length-1;s>=0;s--)e+=o[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let o=0;o<this.find.length;o++)this.find[o].node==e&&this.find[o].offset==t&&(this.find[o].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,o){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(o?2:4)&&(this.find[s].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("/"),o=this.options.context,s=!this.isOpen&&(!o||o.parent.type==this.nodes[0].type),r=-(o?o.depth+1:0)+(s?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=r;a--)if(i(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:o&&a>=r?o.node(a-r).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(o&&o.isTextblock&&o.defaultAttrs)return o}for(let t in this.parser.schema.nodes){let o=this.parser.schema.nodes[t];if(o.isTextblock&&o.defaultAttrs)return o}}}function Ih(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&Ol.hasOwnProperty(o)&&t?(t.appendChild(e),e=t):o=="li"?t=e:o&&(t=null)}}function Rh(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Dl(n){let e={};for(let t in n)e[t]=n[t];return e}function Ll(n,e){let t=e.schema.nodes;for(let o in t){let s=t[o];if(!s.allowsMarkType(n))continue;let r=[],i=l=>{r.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||r.indexOf(d)<0&&i(d))return!0}};if(i(s.contentMatch))return!0}}class Ct{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},o){o||(o=Bs(t).createDocumentFragment());let s=o,r=[];return e.forEach(i=>{if(r.length||i.marks.length){let l=0,a=0;for(;l<r.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(r[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<r.length;)s=r.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],d=this.serializeMark(c,i.isInline,t);d&&(r.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(i,t))}),o}serializeNodeInner(e,t){let{dom:o,contentDOM:s}=No(Bs(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return o}serializeNode(e,t={}){let o=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let r=this.serializeMark(e.marks[s],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(o),o=r.dom)}return o}serializeMark(e,t,o={}){let s=this.marks[e.type.name];return s&&No(Bs(o),s(e,t),null,e.attrs)}static renderSpec(e,t,o=null,s){return No(e,t,o,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ct(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=zl(e.nodes);return t.text||(t.text=o=>o.text),t}static marksFromSchema(e){return zl(e.marks)}}function zl(n){let e={};for(let t in n){let o=n[t].spec.toDOM;o&&(e[t]=o)}return e}function Bs(n){return n.document||window.document}const $l=new WeakMap;function Dh(n){let e=$l.get(n);return e===void 0&&$l.set(n,e=Lh(n)),e}function Lh(n){let e=null;function t(o){if(o&&typeof o=="object")if(Array.isArray(o))if(typeof o[0]=="string")e||(e=[]),e.push(o);else for(let s=0;s<o.length;s++)t(o[s]);else for(let s in o)t(o[s])}return t(n),e}function No(n,e,t,o){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 s=e[0],r;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(o&&(r=Dh(o))&&r.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 i=s.indexOf(" ");i>0&&(t=s.slice(0,i),s=s.slice(i+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let p=u.indexOf(" ");p>0?a.setAttributeNS(u.slice(0,p),u.slice(p+1),c[u]):a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let p=e[u];if(p===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:f}=No(n,p,t,o);if(a.appendChild(h),f){if(l)throw new RangeError("Multiple content holes");l=f}}}return{dom:a,contentDOM:l}}const Vl=65535,Bl=Math.pow(2,16);function zh(n,e){return n+e*Bl}function Hl(n){return n&Vl}function $h(n){return(n-(n&Vl))/Bl}const Fl=1,_l=2,Oo=4,Gl=8;class Hs{constructor(e,t,o){this.pos=e,this.delInfo=t,this.recover=o}get deleted(){return(this.delInfo&Gl)>0}get deletedBefore(){return(this.delInfo&(Fl|Oo))>0}get deletedAfter(){return(this.delInfo&(_l|Oo))>0}get deletedAcross(){return(this.delInfo&Oo)>0}}class me{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&me.empty)return me.empty}recover(e){let t=0,o=Hl(e);if(!this.inverted)for(let s=0;s<o;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[o*3]+t+$h(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,o){let s=0,r=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+r],d=this.ranges[l+i],u=a+c;if(e<=u){let p=c?e==a?-1:e==u?1:t:t,h=a+s+(p<0?0:d);if(o)return h;let f=e==(t<0?a:u)?null:zh(l/3,e-a),m=e==a?_l:e==u?Fl:Oo;return(t<0?e!=a:e!=u)&&(m|=Gl),new Hs(h,m,f)}s+=d-c}return o?e+s:new Hs(e+s,0,null)}touches(e,t){let o=0,s=Hl(t),r=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+r],d=a+c;if(e<=d&&l==s*3)return!0;o+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,o=this.inverted?1:2;for(let s=0,r=0;s<this.ranges.length;s+=3){let i=this.ranges[s],l=i-(this.inverted?r:0),a=i+(this.inverted?0:r),c=this.ranges[s+t],d=this.ranges[s+o];e(l,l+c,a,a+d),r+=d-c}}invert(){return new me(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?me.empty:new me(e<0?[0,-e,0]:[0,0,e])}}me.empty=new me([]);class Qt{constructor(e=[],t,o=0,s=e.length){this.maps=e,this.mirror=t,this.from=o,this.to=s}slice(e=0,t=this.maps.length){return new Qt(this.maps,this.mirror,e,t)}copy(){return new Qt(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,o=this.maps.length;t<e.maps.length;t++){let s=e.getMirror(t);this.appendMap(e.maps[t],s!=null&&s<t?o+s: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,o=this.maps.length+e.maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e.maps[t].invert(),s!=null&&s>t?o-s-1:void 0)}}invert(){let e=new Qt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let o=this.from;o<this.to;o++)e=this.maps[o].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,o){let s=0;for(let r=this.from;r<this.to;r++){let i=this.maps[r],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(r);if(a!=null&&a>r&&a<this.to){r=a,e=this.maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return o?e:new Hs(e,s,null)}}const Fs=Object.create(null);class oe{getMap(){return me.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let o=Fs[t.stepType];if(!o)throw new RangeError(`No step type ${t.stepType} defined`);return o.fromJSON(e,t)}static jsonID(e,t){if(e in Fs)throw new RangeError("Duplicate use of step JSON ID "+e);return Fs[e]=t,t.prototype.jsonID=e,t}}class K{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new K(e,null)}static fail(e){return new K(null,e)}static fromReplace(e,t,o,s){try{return K.ok(e.replace(t,o,s))}catch(r){if(r instanceof wo)return K.fail(r.message);throw r}}}function _s(n,e,t){let o=[];for(let s=0;s<n.childCount;s++){let r=n.child(s);r.content.size&&(r=r.copy(_s(r.content,e,r))),r.isInline&&(r=e(r,t,s)),o.push(r)}return k.fromArray(o)}class Je extends oe{constructor(e,t,o){super(),this.from=e,this.to=t,this.mark=o}apply(e){let t=e.slice(this.from,this.to),o=e.resolve(this.from),s=o.node(o.sharedDepth(this.to)),r=new A(_s(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,r)}invert(){return new Ne(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deleted&&o.deleted||t.pos>=o.pos?null:new Je(t.pos,o.pos,this.mark)}merge(e){return e instanceof Je&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Je(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 Je(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("addMark",Je);class Ne extends oe{constructor(e,t,o){super(),this.from=e,this.to=t,this.mark=o}apply(e){let t=e.slice(this.from,this.to),o=new A(_s(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,o)}invert(){return new Je(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deleted&&o.deleted||t.pos>=o.pos?null:new Ne(t.pos,o.pos,this.mark)}merge(e){return e instanceof Ne&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ne(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 Ne(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("removeMark",Ne);class Ye extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return K.fromReplace(e,this.pos,this.pos+1,new A(k.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let o=this.mark.addToSet(t.marks);if(o.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(o))return new Ye(this.pos,t.marks[s]);return new Ye(this.pos,this.mark)}}return new en(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ye(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 Ye(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("addNodeMark",Ye);class en extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return K.fromReplace(e,this.pos,this.pos+1,new A(k.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Ye(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new en(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 en(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("removeNodeMark",en);class se extends oe{constructor(e,t,o,s=!1){super(),this.from=e,this.to=t,this.slice=o,this.structure=s}apply(e){return this.structure&&Gs(e,this.from,this.to)?K.fail("Structure replace would overwrite content"):K.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new me([this.from,this.to-this.from,this.slice.size])}invert(e){return new se(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deletedAcross&&o.deletedAcross?null:new se(t.pos,Math.max(t.pos,o.pos),this.slice)}merge(e){if(!(e instanceof se)||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?A.empty:new A(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new se(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?A.empty:new A(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new se(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 se(t.from,t.to,A.fromJSON(e,t.slice),!!t.structure)}}oe.jsonID("replace",se);class X extends oe{constructor(e,t,o,s,r,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=o,this.gapTo=s,this.slice=r,this.insert=i,this.structure=l}apply(e){if(this.structure&&(Gs(e,this.from,this.gapFrom)||Gs(e,this.gapTo,this.to)))return K.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return K.fail("Gap is not a flat range");let o=this.slice.insertAt(this.insert,t.content);return o?K.fromReplace(e,this.from,this.to,o):K.fail("Content does not fit in gap")}getMap(){return new me([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 X(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),o=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),r=this.to==this.gapTo?o.pos:e.map(this.gapTo,1);return t.deletedAcross&&o.deletedAcross||s<t.pos||r>o.pos?null:new X(t.pos,o.pos,s,r,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 X(t.from,t.to,t.gapFrom,t.gapTo,A.fromJSON(e,t.slice),t.insert,!!t.structure)}}oe.jsonID("replaceAround",X);function Gs(n,e,t){let o=n.resolve(e),s=t-e,r=o.depth;for(;s>0&&r>0&&o.indexAfter(r)==o.node(r).childCount;)r--,s--;if(s>0){let i=o.node(r).maybeChild(o.indexAfter(r));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}function Vh(n,e,t,o){let s=[],r=[],i,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!o.isInSet(u)&&d.type.allowsMarkType(o.type)){let p=Math.max(c,e),h=Math.min(c+a.nodeSize,t),f=o.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(f)||(i&&i.to==p&&i.mark.eq(u[m])?i.to=h:s.push(i=new Ne(p,h,u[m])));l&&l.to==p?l.to=h:r.push(l=new Je(p,h,o))}}),s.forEach(a=>n.step(a)),r.forEach(a=>n.step(a))}function Bh(n,e,t,o){let s=[],r=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;r++;let a=null;if(o instanceof Mo){let c=i.marks,d;for(;d=o.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else o?o.isInSet(i.marks)&&(a=[o]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],p;for(let h=0;h<s.length;h++){let f=s[h];f.step==r-1&&u.eq(s[h].style)&&(p=f)}p?(p.to=c,p.step=r):s.push({style:u,from:Math.max(l,e),to:c,step:r})}}}),s.forEach(i=>n.step(new Ne(i.from,i.to,i.style)))}function Ws(n,e,t,o=t.contentMatch,s=!0){let r=n.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<r.childCount;a++){let c=r.child(a),d=l+c.nodeSize,u=o.matchType(c.type);if(!u)i.push(new se(l,d,A.empty));else{o=u;for(let p=0;p<c.marks.length;p++)t.allowsMarkType(c.marks[p].type)||n.step(new Ne(l,d,c.marks[p]));if(s&&c.isText&&t.whitespace!="pre"){let p,h=/\r?\n|\r/g,f;for(;p=h.exec(c.text);)f||(f=new A(k.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new se(l+p.index,l+p.index+p[0].length,f))}}l=d}if(!o.validEnd){let a=o.fillBefore(k.empty,!0);n.replace(l,l,new A(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function Hh(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Io(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let o=n.depth;;--o){let s=n.$from.node(o),r=n.$from.index(o),i=n.$to.indexAfter(o);if(o<n.depth&&s.canReplace(r,i,t))return o;if(o==0||s.type.spec.isolating||!Hh(s,r,i))break}return null}function Fh(n,e,t){let{$from:o,$to:s,depth:r}=e,i=o.before(r+1),l=s.after(r+1),a=i,c=l,d=k.empty,u=0;for(let f=r,m=!1;f>t;f--)m||o.index(f)>0?(m=!0,d=k.from(o.node(f).copy(d)),u++):a--;let p=k.empty,h=0;for(let f=r,m=!1;f>t;f--)m||s.after(f+1)<s.end(f)?(m=!0,p=k.from(s.node(f).copy(p)),h++):c++;n.step(new X(a,c,i,l,new A(d.append(p),u,h),d.size-u,!0))}function Wl(n,e,t=null,o=n){let s=_h(n,e),r=s&&Gh(o,e);return r?s.map(jl).concat({type:e,attrs:t}).concat(r.map(jl)):null}function jl(n){return{type:n,attrs:null}}function _h(n,e){let{parent:t,startIndex:o,endIndex:s}=n,r=t.contentMatchAt(o).findWrapping(e);if(!r)return null;let i=r.length?r[0]:e;return t.canReplaceWith(o,s,i)?r:null}function Gh(n,e){let{parent:t,startIndex:o,endIndex:s}=n,r=t.child(o),i=e.contentMatch.findWrapping(r.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=o;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function Wh(n,e,t){let o=k.empty;for(let i=t.length-1;i>=0;i--){if(o.size){let l=t[i].type.contentMatch.matchFragment(o);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=k.from(t[i].type.create(t[i].attrs,o))}let s=e.start,r=e.end;n.step(new X(s,r,s,r,new A(o,0,0),t.length,!0))}function jh(n,e,t,o,s){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let r=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{let a=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(o,a)&&qh(n.doc,n.mapping.slice(r).map(l),o)){let c=null;if(o.schema.linebreakReplacement){let h=o.whitespace=="pre",f=!!o.contentMatch.matchType(o.schema.linebreakReplacement);h&&!f?c=!1:!h&&f&&(c=!0)}c===!1&&Kl(n,i,l,r),Ws(n,n.mapping.slice(r).map(l,1),o,void 0,c===null);let d=n.mapping.slice(r),u=d.map(l,1),p=d.map(l+i.nodeSize,1);return n.step(new X(u,p,u+1,p-1,new A(k.from(o.create(a,null,i.marks)),0,0),1,!0)),c===!0&&ql(n,i,l,r),!1}})}function ql(n,e,t,o){e.forEach((s,r)=>{if(s.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(s.text);){let a=n.mapping.slice(o).map(t+1+r+i.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Kl(n,e,t,o){e.forEach((s,r)=>{if(s.type==s.type.schema.linebreakReplacement){let i=n.mapping.slice(o).map(t+1+r);n.replaceWith(i,i+1,e.type.schema.text(`
|
|
297
|
+
`))}})}function qh(n,e,t){let o=n.resolve(e),s=o.index();return o.parent.canReplaceWith(s,s+1,t)}function Kh(n,e,t,o,s){let r=n.doc.nodeAt(e);if(!r)throw new RangeError("No node at given position");t||(t=r.type);let i=t.create(o,null,s||r.marks);if(r.isLeaf)return n.replaceWith(e,e+r.nodeSize,i);if(!t.validContent(r.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new X(e,e+r.nodeSize,e+1,e+r.nodeSize-1,new A(k.from(i),0,0),1,!0))}function tn(n,e,t=1,o){let s=n.resolve(e),r=s.depth-t,i=o&&o[o.length-1]||s.parent;if(r<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!i.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=t-2;c>r;c--,d--){let u=s.node(c),p=s.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(p,u.childCount),f=o&&o[d+1];f&&(h=h.replaceChild(0,f.type.create(f.attrs)));let m=o&&o[d]||u;if(!u.canReplace(p+1,u.childCount)||!m.type.validContent(h))return!1}let l=s.indexAfter(r),a=o&&o[0];return s.node(r).canReplaceWith(l,l,a?a.type:s.node(r+1).type)}function Uh(n,e,t=1,o){let s=n.doc.resolve(e),r=k.empty,i=k.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){r=k.from(s.node(l).copy(r));let d=o&&o[c];i=k.from(d?d.type.create(d.attrs,i):s.node(l).copy(i))}n.step(new se(e,e,new A(r.append(i),t,t),!0))}function Ro(n,e){let t=n.resolve(e),o=t.index();return Yh(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(o,o+1)}function Jh(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:o}=n.type.schema;for(let s=0;s<e.childCount;s++){let r=e.child(s),i=r.type==o?n.type.schema.nodes.text:r.type;if(t=t.matchType(i),!t||!n.type.allowsMarks(r.marks))return!1}return t.validEnd}function Yh(n,e){return!!(n&&e&&!n.isLeaf&&Jh(n,e))}function Zh(n,e,t){let o=null,{linebreakReplacement:s}=n.doc.type.schema,r=n.doc.resolve(e-t),i=r.node().type;if(s&&i.inlineContent){let d=i.whitespace=="pre",u=!!i.contentMatch.matchType(s);d&&!u?o=!1:!d&&u&&(o=!0)}let l=n.steps.length;if(o===!1){let d=n.doc.resolve(e+t);Kl(n,d.node(),d.before(),l)}i.inlineContent&&Ws(n,e+t-1,i,r.node().contentMatchAt(r.index()),o==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new se(c,a.map(e+t,-1),A.empty,!0)),o===!0){let d=n.doc.resolve(c);ql(n,d.node(),d.before(),n.steps.length)}return n}function Xh(n,e,t){let o=n.resolve(e);if(o.parent.canReplaceWith(o.index(),o.index(),t))return e;if(o.parentOffset==0)for(let s=o.depth-1;s>=0;s--){let r=o.index(s);if(o.node(s).canReplaceWith(r,r,t))return o.before(s+1);if(r>0)return null}if(o.parentOffset==o.parent.content.size)for(let s=o.depth-1;s>=0;s--){let r=o.indexAfter(s);if(o.node(s).canReplaceWith(r,r,t))return o.after(s+1);if(r<o.node(s).childCount)return null}return null}function Qh(n,e,t){let o=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let r=0;r<t.openStart;r++)s=s.firstChild.content;for(let r=1;r<=(t.openStart==0&&t.size?2:1);r++)for(let i=o.depth;i>=0;i--){let l=i==o.depth?0:o.pos<=(o.start(i+1)+o.end(i+1))/2?-1:1,a=o.index(i)+(l>0?1:0),c=o.node(i),d=!1;if(r==1)d=c.canReplace(a,a,s);else{let u=c.contentMatchAt(a).findWrapping(s.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?o.pos:l<0?o.before(i+1):o.after(i+1)}return null}function js(n,e,t=e,o=A.empty){if(e==t&&!o.size)return null;let s=n.resolve(e),r=n.resolve(t);return Ul(s,r,o)?new se(e,t,o):new ef(s,r,o).fit()}function Ul(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class ef{constructor(e,t,o){this.$from=e,this.$to=t,this.unplaced=o,this.frontier=[],this.placed=k.empty;for(let s=0;s<=e.depth;s++){let r=e.node(s);this.frontier.push({type:r.type,match:r.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=k.from(e.node(s).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,o=this.$from,s=this.close(e<0?this.$to:o.doc.resolve(e));if(!s)return null;let r=this.placed,i=o.depth,l=s.depth;for(;i&&l&&r.childCount==1;)r=r.firstChild.content,i--,l--;let a=new A(r,i,l);return e>-1?new X(o.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||o.pos!=this.$to.pos?new se(o.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,o=0,s=this.unplaced.openEnd;o<e;o++){let r=t.firstChild;if(t.childCount>1&&(s=0),r.type.spec.isolating&&s<=o){e=o;break}t=r.content}for(let t=1;t<=2;t++)for(let o=t==1?e:this.unplaced.openStart;o>=0;o--){let s,r=null;o?(r=qs(this.unplaced.content,o-1).firstChild,s=r.content):s=this.unplaced.content;let i=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(i?c.matchType(i.type)||(u=c.fillBefore(k.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:o,frontierDepth:l,parent:r,inject:u};if(t==2&&i&&(d=c.findWrapping(i.type)))return{sliceDepth:o,frontierDepth:l,parent:r,wrap:d};if(r&&c.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:o}=this.unplaced,s=qs(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new A(e,t+1,Math.max(o,s.size+t>=e.size-o?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:o}=this.unplaced,s=qs(e,t);if(s.childCount<=1&&t>0){let r=e.size-t<=t+s.size;this.unplaced=new A(Tn(e,t-1,1),t-1,r?t-1:o)}else this.unplaced=new A(Tn(e,t,1),t,o)}placeNodes({sliceDepth:e,frontierDepth:t,parent:o,inject:s,wrap:r}){for(;this.depth>t;)this.closeFrontierNode();if(r)for(let m=0;m<r.length;m++)this.openFrontierNode(r[m]);let i=this.unplaced,l=o?o.content:i.content,a=i.openStart-e,c=0,d=[],{match:u,type:p}=this.frontier[t];if(s){for(let m=0;m<s.childCount;m++)d.push(s.child(m));u=u.matchFragment(s)}let h=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let m=l.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(u=g,d.push(Jl(m.mark(p.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let f=c==l.childCount;f||(h=-1),this.placed=Mn(this.placed,t,k.from(d)),this.frontier[t].match=u,f&&h<0&&o&&o.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let v=g.lastChild;this.frontier.push({type:v.type,match:v.contentMatchAt(v.childCount)}),g=v.content}this.unplaced=f?e==0?A.empty:new A(Tn(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new A(Tn(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Ks(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:o}=this.$to,s=this.$to.after(o);for(;o>1&&s==this.$to.end(--o);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:o,type:s}=this.frontier[t],r=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=Ks(e,t,s,o,r);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=Ks(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:i,move:r?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=Mn(this.placed,t.depth,t.fit)),e=t.move;for(let o=t.depth+1;o<=e.depth;o++){let s=e.node(o),r=s.type.contentMatch.fillBefore(s.content,!0,e.index(o));this.openFrontierNode(s.type,s.attrs,r)}return e}openFrontierNode(e,t=null,o){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Mn(this.placed,this.depth,k.from(e.create(t,o))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(k.empty,!0);t.childCount&&(this.placed=Mn(this.placed,this.frontier.length,t))}}function Tn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Tn(n.firstChild.content,e-1,t)))}function Mn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Mn(n.lastChild.content,e-1,t)))}function qs(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Jl(n,e,t){if(e<=0)return n;let o=n.content;return e>1&&(o=o.replaceChild(0,Jl(o.firstChild,e-1,o.childCount==1?t-1:0))),e>0&&(o=n.type.contentMatch.fillBefore(o).append(o),t<=0&&(o=o.append(n.type.contentMatch.matchFragment(o).fillBefore(k.empty,!0)))),n.copy(o)}function Ks(n,e,t,o,s){let r=n.node(e),i=s?n.indexAfter(e):n.index(e);if(i==r.childCount&&!t.compatibleContent(r.type))return null;let l=o.fillBefore(r.content,!0,i);return l&&!tf(t,r.content,i)?l:null}function tf(n,e,t){for(let o=t;o<e.childCount;o++)if(!n.allowsMarks(e.child(o).marks))return!0;return!1}function nf(n){return n.spec.defining||n.spec.definingForContent}function of(n,e,t,o){if(!o.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),r=n.doc.resolve(t);if(Ul(s,r,o))return n.step(new se(e,t,o));let i=Zl(s,n.doc.resolve(t));i[i.length-1]==0&&i.pop();let l=-(s.depth+1);i.unshift(l);for(let p=s.depth,h=s.pos-1;p>0;p--,h--){let f=s.node(p).type.spec;if(f.defining||f.definingAsContext||f.isolating)break;i.indexOf(p)>-1?l=p:s.before(p)==h&&i.splice(1,0,-p)}let a=i.indexOf(l),c=[],d=o.openStart;for(let p=o.content,h=0;;h++){let f=p.firstChild;if(c.push(f),h==o.openStart)break;p=f.content}for(let p=d-1;p>=0;p--){let h=c[p],f=nf(h.type);if(f&&!h.sameMarkup(s.node(Math.abs(l)-1)))d=p;else if(f||!h.type.isTextblock)break}for(let p=o.openStart;p>=0;p--){let h=(p+d+1)%(o.openStart+1),f=c[h];if(f)for(let m=0;m<i.length;m++){let g=i[(m+a)%i.length],v=!0;g<0&&(v=!1,g=-g);let w=s.node(g-1),y=s.index(g-1);if(w.canReplaceWith(y,y,f.type,f.marks))return n.replace(s.before(g),v?r.after(g):t,new A(Yl(o.content,0,o.openStart,h),h,o.openEnd))}}let u=n.steps.length;for(let p=i.length-1;p>=0&&(n.replace(e,t,o),!(n.steps.length>u));p--){let h=i[p];h<0||(e=s.before(h),t=r.after(h))}}function Yl(n,e,t,o,s){if(e<t){let r=n.firstChild;n=n.replaceChild(0,r.copy(Yl(r.content,e+1,t,o,r)))}if(e>o){let r=s.contentMatchAt(0),i=r.fillBefore(n).append(n);n=i.append(r.matchFragment(i).fillBefore(k.empty,!0))}return n}function sf(n,e,t,o){if(!o.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=Xh(n.doc,e,o.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new A(k.from(o),0,0))}function rf(n,e,t){let o=n.doc.resolve(e),s=n.doc.resolve(t),r=Zl(o,s);for(let i=0;i<r.length;i++){let l=r[i],a=i==r.length-1;if(a&&l==0||o.node(l).type.contentMatch.validEnd)return n.delete(o.start(l),s.end(l));if(l>0&&(a||o.node(l-1).canReplace(o.index(l-1),s.indexAfter(l-1))))return n.delete(o.before(l),s.after(l))}for(let i=1;i<=o.depth&&i<=s.depth;i++)if(e-o.start(i)==o.depth-i&&t>o.end(i)&&s.end(i)-t!=s.depth-i&&o.start(i-1)==s.start(i-1)&&o.node(i-1).canReplace(o.index(i-1),s.index(i-1)))return n.delete(o.before(i),t);n.delete(e,t)}function Zl(n,e){let t=[],o=Math.min(n.depth,e.depth);for(let s=o;s>=0;s--){let r=n.start(s);if(r<n.pos-(n.depth-s)||e.end(s)>e.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(r==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==r-1)&&t.push(s)}return t}class nn extends oe{constructor(e,t,o){super(),this.pos=e,this.attr=t,this.value=o}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at attribute step's position");let o=Object.create(null);for(let r in t.attrs)o[r]=t.attrs[r];o[this.attr]=this.value;let s=t.type.create(o,null,t.marks);return K.fromReplace(e,this.pos,this.pos+1,new A(k.from(s),0,t.isLeaf?0:1))}getMap(){return me.empty}invert(e){return new nn(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 nn(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 nn(t.pos,t.attr,t.value)}}oe.jsonID("attr",nn);class En extends oe{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let o=e.type.create(t,e.content,e.marks);return K.ok(o)}getMap(){return me.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)}}oe.jsonID("docAttr",En);let on=class extends Error{};on=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},on.prototype=Object.create(Error.prototype),on.prototype.constructor=on,on.prototype.name="TransformError";class Xl{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Qt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new on(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,o=A.empty){let s=js(this.doc,e,t,o);return s&&this.step(s),this}replaceWith(e,t,o){return this.replace(e,t,new A(k.from(o),0,0))}delete(e,t){return this.replace(e,t,A.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,o){return of(this,e,t,o),this}replaceRangeWith(e,t,o){return sf(this,e,t,o),this}deleteRange(e,t){return rf(this,e,t),this}lift(e,t){return Fh(this,e,t),this}join(e,t=1){return Zh(this,e,t),this}wrap(e,t){return Wh(this,e,t),this}setBlockType(e,t=e,o,s=null){return jh(this,e,t,o,s),this}setNodeMarkup(e,t,o=null,s){return Kh(this,e,t,o,s),this}setNodeAttribute(e,t,o){return this.step(new nn(e,t,o)),this}setDocAttribute(e,t){return this.step(new En(e,t)),this}addNodeMark(e,t){return this.step(new Ye(e,t)),this}removeNodeMark(e,t){if(!(t instanceof B)){let o=this.doc.nodeAt(e);if(!o)throw new RangeError("No node at position "+e);if(t=t.isInSet(o.marks),!t)return this}return this.step(new en(e,t)),this}split(e,t=1,o){return Uh(this,e,t,o),this}addMark(e,t,o){return Vh(this,e,t,o),this}removeMark(e,t,o){return Bh(this,e,t,o),this}clearIncompatible(e,t,o){return Ws(this,e,t,o),this}}const Us=Object.create(null);class D{constructor(e,t,o){this.$anchor=e,this.$head=t,this.ranges=o||[new Ql(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=A.empty){let o=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=o,o=o.lastChild;let r=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],d=e.mapping.slice(r);e.replaceRange(d.map(a.pos),d.map(c.pos),l?A.empty:t),l==0&&na(e,r,(o?o.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let o=e.steps.length,s=this.ranges;for(let r=0;r<s.length;r++){let{$from:i,$to:l}=s[r],a=e.mapping.slice(o),c=a.map(i.pos),d=a.map(l.pos);r?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),na(e,o,t.isInline?-1:1))}}static findFrom(e,t,o=!1){let s=e.parent.inlineContent?new L(e):sn(e.node(0),e.parent,e.pos,e.index(),t,o);if(s)return s;for(let r=e.depth-1;r>=0;r--){let i=t<0?sn(e.node(0),e.node(r),e.before(r+1),e.index(r),t,o):sn(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,o);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ge(e.node(0))}static atStart(e){return sn(e,e,0,0,1)||new ge(e)}static atEnd(e){return sn(e,e,e.content.size,e.childCount,-1)||new ge(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let o=Us[t.type];if(!o)throw new RangeError(`No selection type ${t.type} defined`);return o.fromJSON(e,t)}static jsonID(e,t){if(e in Us)throw new RangeError("Duplicate use of selection JSON ID "+e);return Us[e]=t,t.prototype.jsonID=e,t}getBookmark(){return L.between(this.$anchor,this.$head).getBookmark()}}D.prototype.visible=!0;class Ql{constructor(e,t){this.$from=e,this.$to=t}}let ea=!1;function ta(n){!ea&&!n.parent.inlineContent&&(ea=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class L extends D{constructor(e,t=e){ta(e),ta(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let o=e.resolve(t.map(this.head));if(!o.parent.inlineContent)return D.near(o);let s=e.resolve(t.map(this.anchor));return new L(s.parent.inlineContent?s:o,o)}replace(e,t=A.empty){if(super.replace(e,t),t==A.empty){let o=this.$from.marksAcross(this.$to);o&&e.ensureMarks(o)}}eq(e){return e instanceof L&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Do(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 L(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){let s=e.resolve(t);return new this(s,o==t?s:e.resolve(o))}static between(e,t,o){let s=e.pos-t.pos;if((!o||s)&&(o=s>=0?1:-1),!t.parent.inlineContent){let r=D.findFrom(t,o,!0)||D.findFrom(t,-o,!0);if(r)t=r.$head;else return D.near(t,o)}return e.parent.inlineContent||(s==0?e=t:(e=(D.findFrom(e,-o,!0)||D.findFrom(e,o,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new L(e,t)}}D.jsonID("text",L);class Do{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Do(e.map(this.anchor),e.map(this.head))}resolve(e){return L.between(e.resolve(this.anchor),e.resolve(this.head))}}class R extends D{constructor(e){let t=e.nodeAfter,o=e.node(0).resolve(e.pos+t.nodeSize);super(e,o),this.node=t}map(e,t){let{deleted:o,pos:s}=t.mapResult(this.anchor),r=e.resolve(s);return o?D.near(r):new R(r)}content(){return new A(k.from(this.node),0,0)}eq(e){return e instanceof R&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Js(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new R(e.resolve(t.anchor))}static create(e,t){return new R(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}R.prototype.visible=!1,D.jsonID("node",R);class Js{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:o}=e.mapResult(this.anchor);return t?new Do(o,o):new Js(o)}resolve(e){let t=e.resolve(this.anchor),o=t.nodeAfter;return o&&R.isSelectable(o)?new R(t):D.near(t)}}class ge extends D{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=A.empty){if(t==A.empty){e.delete(0,e.doc.content.size);let o=D.atStart(e.doc);o.eq(e.selection)||e.setSelection(o)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ge(e)}map(e){return new ge(e)}eq(e){return e instanceof ge}getBookmark(){return lf}}D.jsonID("all",ge);const lf={map(){return this},resolve(n){return new ge(n)}};function sn(n,e,t,o,s,r=!1){if(e.inlineContent)return L.create(n,t);for(let i=o-(s>0?0:1);s>0?i<e.childCount:i>=0;i+=s){let l=e.child(i);if(l.isAtom){if(!r&&R.isSelectable(l))return R.create(n,t-(s<0?l.nodeSize:0))}else{let a=sn(n,l,t+s,s<0?l.childCount:0,s,r);if(a)return a}t+=l.nodeSize*s}return null}function na(n,e,t){let o=n.steps.length-1;if(o<e)return;let s=n.steps[o];if(!(s instanceof se||s instanceof X))return;let r=n.mapping.maps[o],i;r.forEach((l,a,c,d)=>{i==null&&(i=d)}),n.setSelection(D.near(n.doc.resolve(i),t))}const oa=1,Lo=2,sa=4;class af extends Xl{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|oa)&~Lo,this.storedMarks=null,this}get selectionSet(){return(this.updated&oa)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Lo,this}ensureMarks(e){return B.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&Lo)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Lo,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let o=this.selection;return t&&(e=e.mark(this.storedMarks||(o.empty?o.$from.marks():o.$from.marksAcross(o.$to)||B.none))),o.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,o){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(o==null&&(o=t),o=o??t,!e)return this.deleteRange(t,o);let r=this.storedMarks;if(!r){let i=this.doc.resolve(t);r=o==t?i.marks():i.marksAcross(this.doc.resolve(o))}return this.replaceRangeWith(t,o,s.text(e,r)),this.selection.empty||this.setSelection(D.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|=sa,this}get scrolledIntoView(){return(this.updated&sa)>0}}function ra(n,e){return!e||!n?n:n.bind(e)}class An{constructor(e,t,o){this.name=e,this.init=ra(t.init,o),this.apply=ra(t.apply,o)}}const cf=[new An("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new An("selection",{init(n,e){return n.selection||D.atStart(e.doc)},apply(n){return n.selection}}),new An("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,o){return o.selection.$cursor?n.storedMarks:null}}),new An("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Ys{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=cf.slice(),t&&t.forEach(o=>{if(this.pluginsByKey[o.key])throw new RangeError("Adding different instances of a keyed plugin ("+o.key+")");this.plugins.push(o),this.pluginsByKey[o.key]=o,o.spec.state&&this.fields.push(new An(o.key,o.spec.state,o))})}}class rn{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 o=0;o<this.config.plugins.length;o++)if(o!=t){let s=this.config.plugins[o];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],o=this.applyInner(e),s=null;for(;;){let r=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=s?s[i].n:0,c=s?s[i].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,o);if(d&&o.filterTransaction(d,i)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let u=0;u<this.config.plugins.length;u++)s.push(u<i?{state:o,n:t.length}:{state:this,n:0})}t.push(d),o=o.applyInner(d),r=!0}s&&(s[i]={state:o,n:t.length})}}if(!r)return{state:o,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new rn(this.config),o=this.config.fields;for(let s=0;s<o.length;s++){let r=o[s];t[r.name]=r.apply(e,this[r.name],this,t)}return t}get tr(){return new af(this)}static create(e){let t=new Ys(e.doc?e.doc.type.schema:e.schema,e.plugins),o=new rn(t);for(let s=0;s<t.fields.length;s++)o[t.fields[s].name]=t.fields[s].init(e,o);return o}reconfigure(e){let t=new Ys(this.schema,e.plugins),o=t.fields,s=new rn(t);for(let r=0;r<o.length;r++){let i=o[r].name;s[i]=this.hasOwnProperty(i)?this[i]:o[r].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(o=>o.toJSON())),e&&typeof e=="object")for(let o in e){if(o=="doc"||o=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[o],r=s.spec.state;r&&r.toJSON&&(t[o]=r.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,o){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Ys(e.schema,e.plugins),r=new rn(s);return s.fields.forEach(i=>{if(i.name=="doc")r.doc=St.fromJSON(e.schema,t.doc);else if(i.name=="selection")r.selection=D.fromJSON(r.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(r.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(o)for(let l in o){let a=o[l],c=a.spec.state;if(a.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){r[i.name]=c.fromJSON.call(a,e,t[l],r);return}}r[i.name]=i.init(e,r)}}),r}}function ia(n,e,t){for(let o in n){let s=n[o];s instanceof Function?s=s.bind(e):o=="handleDOMEvents"&&(s=ia(s,e,{})),t[o]=s}return t}class Pn{constructor(e){this.spec=e,this.props={},e.props&&ia(e.props,this,this.props),this.key=e.key?e.key.key:la("plugin")}getState(e){return e[this.key]}}const Zs=Object.create(null);function la(n){return n in Zs?n+"$"+ ++Zs[n]:(Zs[n]=0,n+"$")}class Nn{constructor(e="key"){this.key=la(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const aa=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function df(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const uf=(n,e,t)=>{let o=df(n,t);if(!o)return!1;let s=ca(o);if(!s){let i=o.blockRange(),l=i&&Io(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let r=s.nodeBefore;if(ma(n,s,e,-1))return!0;if(o.parent.content.size==0&&(ln(r,"end")||R.isSelectable(r)))for(let i=o.depth;;i--){let l=js(n.doc,o.before(i),o.after(i),A.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(ln(r,"end")?D.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):R.create(a.doc,s.pos-r.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||o.node(i-1).childCount>1)break}return r.isAtom&&s.depth==o.depth-1?(e&&e(n.tr.delete(s.pos-r.nodeSize,s.pos).scrollIntoView()),!0):!1};function ln(n,e,t=!1){for(let o=n;o;o=e=="start"?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(t&&o.childCount!=1)return!1}return!1}const pf=(n,e,t)=>{let{$head:o,empty:s}=n.selection,r=o;if(!s)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):o.parentOffset>0)return!1;r=ca(o)}let i=r&&r.nodeBefore;return!i||!R.isSelectable(i)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,r.pos-i.nodeSize)).scrollIntoView()),!0)};function ca(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 hf(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const ff=(n,e,t)=>{let o=hf(n,t);if(!o)return!1;let s=da(o);if(!s)return!1;let r=s.nodeAfter;if(ma(n,s,e,1))return!0;if(o.parent.content.size==0&&(ln(r,"start")||R.isSelectable(r))){let i=js(n.doc,o.before(),o.after(),A.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(ln(r,"start")?D.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):R.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return r.isAtom&&s.depth==o.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+r.nodeSize).scrollIntoView()),!0):!1},mf=(n,e,t)=>{let{$head:o,empty:s}=n.selection,r=o;if(!s)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):o.parentOffset<o.parent.content.size)return!1;r=da(o)}let i=r&&r.nodeAfter;return!i||!R.isSelectable(i)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,r.pos)).scrollIntoView()),!0)};function da(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 gf=(n,e)=>{let{$head:t,$anchor:o}=n.selection;return!t.parent.type.spec.code||!t.sameParent(o)?!1:(e&&e(n.tr.insertText(`
|
|
298
|
+
`).scrollIntoView()),!0)};function Xs(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 ua=(n,e)=>{let{$head:t,$anchor:o}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(o))return!1;let s=t.node(-1),r=t.indexAfter(-1),i=Xs(s.contentMatchAt(r));if(!i||!s.canReplaceWith(r,r,i))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,i.createAndFill());a.setSelection(D.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},yf=(n,e)=>{let t=n.selection,{$from:o,$to:s}=t;if(t instanceof ge||o.parent.inlineContent||s.parent.inlineContent)return!1;let r=Xs(s.parent.contentMatchAt(s.indexAfter()));if(!r||!r.isTextblock)return!1;if(e){let i=(!o.parentOffset&&s.index()<s.parent.childCount?o:s).pos,l=n.tr.insert(i,r.createAndFill());l.setSelection(L.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},pa=(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 r=t.before();if(tn(n.doc,r))return e&&e(n.tr.split(r).scrollIntoView()),!0}let o=t.blockRange(),s=o&&Io(o);return s==null?!1:(e&&e(n.tr.lift(o,s).scrollIntoView()),!0)};function ha(n){return(e,t)=>{let{$from:o,$to:s}=e.selection;if(e.selection instanceof R&&e.selection.node.isBlock)return!o.parentOffset||!tn(e.doc,o.pos)?!1:(t&&t(e.tr.split(o.pos).scrollIntoView()),!0);if(!o.depth)return!1;let r=[],i,l,a=!1,c=!1;for(let h=o.depth;;h--)if(o.node(h).isBlock){a=o.end(h)==o.pos+(o.depth-h),c=o.start(h)==o.pos-(o.depth-h),l=Xs(o.node(h-1).contentMatchAt(o.indexAfter(h-1)));let m=n&&n(s.parent,a,o);r.unshift(m||(a&&l?{type:l}:null)),i=h;break}else{if(h==1)return!1;r.unshift(null)}let d=e.tr;(e.selection instanceof L||e.selection instanceof ge)&&d.deleteSelection();let u=d.mapping.map(o.pos),p=tn(d.doc,u,r.length,r);if(p||(r[0]=l?{type:l}:null,p=tn(d.doc,u,r.length,r)),d.split(u,r.length,r),!a&&c&&o.node(i).type!=l){let h=d.mapping.map(o.before(i)),f=d.doc.resolve(h);l&&o.node(i-1).canReplaceWith(f.index(),f.index()+1,l)&&d.setNodeMarkup(d.mapping.map(o.before(i)),l)}return t&&t(d.scrollIntoView()),!0}}const bf=ha(),fa=(n,e)=>(e&&e(n.tr.setSelection(new ge(n.doc))),!0);function vf(n,e,t){let o=e.nodeBefore,s=e.nodeAfter,r=e.index();return!o||!s||!o.type.compatibleContent(s.type)?!1:!o.content.size&&e.parent.canReplace(r-1,r)?(t&&t(n.tr.delete(e.pos-o.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(r,r+1)||!(s.isTextblock||Ro(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function ma(n,e,t,o){let s=e.nodeBefore,r=e.nodeAfter,i,l,a=s.type.spec.isolating||r.type.spec.isolating;if(!a&&vf(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=s.contentMatchAt(s.childCount)).findWrapping(r.type))&&l.matchType(i[0]||r.type).validEnd){if(t){let h=e.pos+r.nodeSize,f=k.empty;for(let v=i.length-1;v>=0;v--)f=k.from(i[v].create(null,f));f=k.from(s.copy(f));let m=n.tr.step(new X(e.pos-1,h,e.pos,h,new A(f,1,0),i.length,!0)),g=m.doc.resolve(h+2*i.length);g.nodeAfter&&g.nodeAfter.type==s.type&&Ro(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=r.type.spec.isolating||o>0&&a?null:D.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),p=u&&Io(u);if(p!=null&&p>=e.depth)return t&&t(n.tr.lift(u,p).scrollIntoView()),!0;if(c&&ln(r,"start",!0)&&ln(s,"end")){let h=s,f=[];for(;f.push(h),!h.isTextblock;)h=h.lastChild;let m=r,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let v=k.empty;for(let y=f.length-1;y>=0;y--)v=k.from(f[y].copy(v));let w=n.tr.step(new X(e.pos-f.length,e.pos+r.nodeSize,e.pos+g,e.pos+r.nodeSize-g,new A(v,f.length,0),0,!0));t(w.scrollIntoView())}return!0}}return!1}function ga(n){return function(e,t){let o=e.selection,s=n<0?o.$from:o.$to,r=s.depth;for(;s.node(r).isInline;){if(!r)return!1;r--}return s.node(r).isTextblock?(t&&t(e.tr.setSelection(L.create(e.doc,n<0?s.start(r):s.end(r)))),!0):!1}}const xf=ga(-1),Sf=ga(1);function wf(n,e=null){return function(t,o){let s=!1;for(let r=0;r<t.selection.ranges.length&&!s;r++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[r];t.doc.nodesBetween(i,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)s=!0;else{let d=t.doc.resolve(c),u=d.index();s=d.parent.canReplaceWith(u,u+1,n)}})}if(!s)return!1;if(o){let r=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];r.setBlockType(l,a,n,e)}o(r.scrollIntoView())}return!0}}function Cf(n,e,t,o){for(let s=0;s<e.length;s++){let{$from:r,$to:i}=e[s],l=r.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(r.pos,i.pos,(a,c)=>{if(l||!o)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function kt(n,e=null,t){let o=t!==!1;return function(s,r){let{empty:i,$cursor:l,ranges:a}=s.selection;if(i&&!l||!Cf(s.doc,a,n,o))return!1;if(r)if(l)n.isInSet(s.storedMarks||l.marks())?r(s.tr.removeStoredMark(n)):r(s.tr.addStoredMark(n.create(e)));else{let c,d=s.tr;c=!a.some(u=>s.doc.rangeHasMark(u.$from.pos,u.$to.pos,n));for(let u=0;u<a.length;u++){let{$from:p,$to:h}=a[u];if(!c)d.removeMark(p.pos,h.pos,n);else{let f=p.pos,m=h.pos,g=p.nodeAfter,v=h.nodeBefore,w=g&&g.isText?/^\s*/.exec(g.text)[0].length:0,y=v&&v.isText?/\s*$/.exec(v.text)[0].length:0;f+w<m&&(f+=w,m-=y),d.addMark(f,m,n.create(e))}}r(d.scrollIntoView())}return!0}}function On(...n){return function(e,t,o){for(let s=0;s<n.length;s++)if(n[s](e,t,o))return!0;return!1}}let Qs=On(aa,uf,pf),ya=On(aa,ff,mf);const Ve={Enter:On(gf,yf,pa,bf),"Mod-Enter":ua,Backspace:Qs,"Mod-Backspace":Qs,"Shift-Backspace":Qs,Delete:ya,"Mod-Delete":ya,"Mod-a":fa},ba={"Ctrl-h":Ve.Backspace,"Alt-Backspace":Ve["Mod-Backspace"],"Ctrl-d":Ve.Delete,"Ctrl-Alt-Backspace":Ve["Mod-Delete"],"Alt-Delete":Ve["Mod-Delete"],"Alt-d":Ve["Mod-Delete"],"Ctrl-a":xf,"Ctrl-e":Sf};for(let n in Ve)ba[n]=Ve[n];const kf=(typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1)?ba:Ve;var zo=200,J=function(){};J.prototype.append=function(e){return e.length?(e=J.from(e),!this.length&&e||e.length<zo&&this.leafAppend(e)||this.length<zo&&e.leafPrepend(this)||this.appendInner(e)):this},J.prototype.prepend=function(e){return e.length?J.from(e).append(this):this},J.prototype.appendInner=function(e){return new Tf(this,e)},J.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?J.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},J.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},J.prototype.forEach=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length),t<=o?this.forEachInner(e,t,o,0):this.forEachInvertedInner(e,t,o,0)},J.prototype.map=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length);var s=[];return this.forEach(function(r,i){return s.push(e(r,i))},t,o),s},J.from=function(e){return e instanceof J?e:e&&e.length?new va(e):J.empty};var va=function(n){function e(o){n.call(this),this.values=o}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(s,r){return s==0&&r==this.length?this:new e(this.values.slice(s,r))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,r,i,l){for(var a=r;a<i;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,r,i,l){for(var a=r-1;a>=i;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=zo)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=zo)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(J);J.empty=new va([]);var Tf=function(n){function e(t,o){n.call(this),this.left=t,this.right=o,this.length=t.length+o.length,this.depth=Math.max(t.depth,o.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(o){return o<this.left.length?this.left.get(o):this.right.get(o-this.left.length)},e.prototype.forEachInner=function(o,s,r,i){var l=this.left.length;if(s<l&&this.left.forEachInner(o,s,Math.min(r,l),i)===!1||r>l&&this.right.forEachInner(o,Math.max(s-l,0),Math.min(this.length,r)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,r,i){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(o,s-l,Math.max(r,l)-l,i+l)===!1||r<l&&this.left.forEachInvertedInner(o,Math.min(s,l),r,i)===!1)return!1},e.prototype.sliceInner=function(o,s){if(o==0&&s==this.length)return this;var r=this.left.length;return s<=r?this.left.slice(o,s):o>=r?this.right.slice(o-r,s-r):this.left.slice(o,r).append(this.right.slice(0,s-r))},e.prototype.leafAppend=function(o){var s=this.right.leafAppend(o);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(o){var s=this.left.leafPrepend(o);if(s)return new e(s,this.right)},e.prototype.appendInner=function(o){return this.left.depth>=Math.max(this.right.depth,o.depth)+1?new e(this.left,new e(this.right,o)):new e(this,o)},e}(J);const Mf=500;class Ce{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}let s,r;t&&(s=this.remapping(o,this.items.length),r=s.maps.length);let i=e.tr,l,a,c=[],d=[];return this.items.forEach((u,p)=>{if(!u.step){s||(s=this.remapping(o,p+1),r=s.maps.length),r--,d.push(u);return}if(s){d.push(new Oe(u.map));let h=u.step.map(s.slice(r)),f;h&&i.maybeStep(h).doc&&(f=i.mapping.maps[i.mapping.maps.length-1],c.push(new Oe(f,void 0,void 0,c.length+d.length))),r--,f&&s.appendMap(f,r)}else i.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(r)):u.selection,a=new Ce(this.items.slice(0,o).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,o,s){let r=[],i=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),p=new Oe(e.mapping.maps[d],u,t),h;(h=a&&a.merge(p))&&(p=h,d?r.pop():l=l.slice(0,l.length-1)),r.push(p),t&&(i++,t=void 0),s||(a=p)}let c=i-o.depth;return c>Af&&(l=Ef(l,c),i-=c),new Ce(l.append(r),i)}remapping(e,t){let o=new Qt;return this.items.forEach((s,r)=>{let i=s.mirrorOffset!=null&&r-s.mirrorOffset>=e?o.maps.length-s.mirrorOffset:void 0;o.appendMap(s.map,i)},e,t),o}addMaps(e){return this.eventCount==0?this:new Ce(this.items.append(e.map(t=>new Oe(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let o=[],s=Math.max(0,this.items.length-t),r=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},s);let a=t;this.items.forEach(p=>{let h=r.getMirror(--a);if(h==null)return;i=Math.min(i,h);let f=r.maps[h];if(p.step){let m=e.steps[h].invert(e.docs[h]),g=p.selection&&p.selection.map(r.slice(a+1,h));g&&l++,o.push(new Oe(f,m,g))}else o.push(new Oe(f))},s);let c=[];for(let p=t;p<i;p++)c.push(new Oe(r.maps[p]));let d=this.items.slice(0,s).append(c).append(o),u=new Ce(d,l);return u.emptyItemCount()>Mf&&(u=u.compress(this.items.length-o.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),o=t.maps.length,s=[],r=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&r++;else if(i.step){let a=i.step.map(t.slice(o)),c=a&&a.getMap();if(o--,c&&t.appendMap(c,o),a){let d=i.selection&&i.selection.map(t.slice(o));d&&r++;let u=new Oe(c.invert(),a,d),p,h=s.length-1;(p=s.length&&s[h].merge(u))?s[h]=p:s.push(u)}}else i.map&&o--},this.items.length,0),new Ce(J.from(s.reverse()),r)}}Ce.empty=new Ce(J.empty,0);function Ef(n,e){let t;return n.forEach((o,s)=>{if(o.selection&&e--==0)return t=s,!1}),n.slice(t)}class Oe{constructor(e,t,o,s){this.map=e,this.step=t,this.selection=o,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Oe(t.getMap().invert(),t,this.selection)}}}class Ze{constructor(e,t,o,s,r){this.done=e,this.undone=t,this.prevRanges=o,this.prevTime=s,this.prevComposition=r}}const Af=20;function Pf(n,e,t,o){let s=t.getMeta(Tt),r;if(s)return s.historyState;t.getMeta(If)&&(n=new Ze(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(Tt))return i.getMeta(Tt).redo?new Ze(n.done.addTransform(t,void 0,o,$o(e)),n.undone,xa(t.mapping.maps),n.prevTime,n.prevComposition):new Ze(n.done,n.undone.addTransform(t,void 0,o,$o(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-o.newGroupDelay||!Nf(t,n.prevRanges)),c=i?er(n.prevRanges,t.mapping):xa(t.mapping.maps);return new Ze(n.done.addTransform(t,a?e.selection.getBookmark():void 0,o,$o(e)),Ce.empty,c,t.time,l??n.prevComposition)}else return(r=t.getMeta("rebased"))?new Ze(n.done.rebased(t,r),n.undone.rebased(t,r),er(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Ze(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),er(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Nf(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((o,s)=>{for(let r=0;r<e.length;r+=2)o<=e[r+1]&&s>=e[r]&&(t=!0)}),t}function xa(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((o,s,r,i)=>e.push(r,i));return e}function er(n,e){if(!n)return null;let t=[];for(let o=0;o<n.length;o+=2){let s=e.map(n[o],1),r=e.map(n[o+1],-1);s<=r&&t.push(s,r)}return t}function Of(n,e,t){let o=$o(e),s=Tt.get(e).spec.config,r=(t?n.undone:n.done).popEvent(e,o);if(!r)return null;let i=r.selection.resolve(r.transform.doc),l=(t?n.done:n.undone).addTransform(r.transform,e.selection.getBookmark(),s,o),a=new Ze(t?l:r.remaining,t?r.remaining:l,null,0,-1);return r.transform.setSelection(i).setMeta(Tt,{redo:t,historyState:a})}let tr=!1,Sa=null;function $o(n){let e=n.plugins;if(Sa!=e){tr=!1,Sa=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){tr=!0;break}}return tr}const Tt=new Nn("history"),If=new Nn("closeHistory");function Rf(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new Pn({key:Tt,state:{init(){return new Ze(Ce.empty,Ce.empty,null,0,-1)},apply(e,t,o){return Pf(t,o,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let o=t.inputType,s=o=="historyUndo"?Ca:o=="historyRedo"?nr:null;return s?(t.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function wa(n,e){return(t,o)=>{let s=Tt.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(o){let r=Of(s,t,n);r&&o(e?r.scrollIntoView():r)}return!0}}const Ca=wa(!1,!0),nr=wa(!0,!0);for(var Xe={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:"'"},Vo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Df=typeof navigator<"u"&&/Mac/.test(navigator.platform),Lf=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Q=0;Q<10;Q++)Xe[48+Q]=Xe[96+Q]=String(Q);for(var Q=1;Q<=24;Q++)Xe[Q+111]="F"+Q;for(var Q=65;Q<=90;Q++)Xe[Q]=String.fromCharCode(Q+32),Vo[Q]=String.fromCharCode(Q);for(var or in Xe)Vo.hasOwnProperty(or)||(Vo[or]=Xe[or]);function zf(n){var e=Df&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Lf&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Vo:Xe)[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 $f=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Vf(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let o,s,r,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))o=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))r=!0;else if(/^mod$/i.test(a))$f?i=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return o&&(t="Alt-"+t),s&&(t="Ctrl-"+t),i&&(t="Meta-"+t),r&&(t="Shift-"+t),t}function Bf(n){let e=Object.create(null);for(let t in n)e[Vf(t)]=n[t];return e}function sr(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 rr(n){return new Pn({props:{handleKeyDown:ka(n)}})}function ka(n){let e=Bf(n);return function(t,o){let s=zf(o),r,i=e[sr(s,o)];if(i&&i(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(o.shiftKey){let l=e[sr(s,o,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((o.shiftKey||o.altKey||o.metaKey||s.charCodeAt(0)>127)&&(r=Xe[o.keyCode])&&r!=s){let l=e[sr(r,o)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}function Ta(n,e=null){return function(t,o){let{$from:s,$to:r}=t.selection,i=s.blockRange(r),l=!1,a=i;if(!i)return!1;if(i.depth>=2&&s.node(i.depth-1).type.compatibleContent(n)&&i.startIndex==0){if(s.index(i.depth-1)==0)return!1;let d=t.doc.resolve(i.start-2);a=new ko(d,d,i.depth),i.endIndex<i.parent.childCount&&(i=new ko(s,t.doc.resolve(r.end(i.depth)),i.depth)),l=!0}let c=Wl(a,n,e,i);return c?(o&&o(Hf(t.tr,i,c,l,n).scrollIntoView()),!0):!1}}function Hf(n,e,t,o,s){let r=k.empty;for(let d=t.length-1;d>=0;d--)r=k.from(t[d].type.create(t[d].attrs,r));n.step(new X(e.start-(o?2:0),e.end,e.start,e.end,new A(r,0,0),t.length,!0));let i=0;for(let d=0;d<t.length;d++)t[d].type==s&&(i=d+1);let l=t.length-i,a=e.start+t.length-(o?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,p=!0;d<u;d++,p=!1)!p&&tn(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function Ff(n,e){return function(t,o){let{$from:s,$to:r,node:i}=t.selection;if(i&&i.isBlock||s.depth<2||!s.sameParent(r))return!1;let l=s.node(-1);if(l.type!=n)return!1;if(s.parent.content.size==0&&s.node(-1).childCount==s.indexAfter(-1)){if(s.depth==3||s.node(-3).type!=n||s.index(-2)!=s.node(-2).childCount-1)return!1;if(o){let u=k.empty,p=s.index(-1)?1:s.index(-2)?2:3;for(let v=s.depth-p;v>=s.depth-3;v--)u=k.from(s.node(v).copy(u));let h=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3;u=u.append(k.from(n.createAndFill()));let f=s.before(s.depth-(p-1)),m=t.tr.replace(f,s.after(-h),new A(u,4-p,0)),g=-1;m.doc.nodesBetween(f,m.doc.content.size,(v,w)=>{if(g>-1)return!1;v.isTextblock&&v.content.size==0&&(g=w+1)}),g>-1&&m.setSelection(D.near(m.doc.resolve(g))),o(m.scrollIntoView())}return!0}let a=r.pos==s.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(s.pos,r.pos),d=a?[null,{type:a}]:void 0;return tn(c.doc,s.pos,2,d)?(o&&o(c.split(s.pos,2,d).scrollIntoView()),!0):!1}}function ir(n){return function(e,t){let{$from:o,$to:s}=e.selection,r=o.blockRange(s,i=>i.childCount>0&&i.firstChild.type==n);return r?t?o.node(r.depth-1).type==n?_f(e,t,n,r):Gf(e,t,r):!0:!1}}function _f(n,e,t,o){let s=n.tr,r=o.end,i=o.$to.end(o.depth);r<i&&(s.step(new X(r-1,i,r,i,new A(k.from(t.create(null,o.parent.copy())),1,0),1,!0)),o=new ko(s.doc.resolve(o.$from.pos),s.doc.resolve(i),o.depth));const l=Io(o);if(l==null)return!1;s.lift(o,l);let a=s.mapping.map(r,-1)-1;return Ro(s.doc,a)&&s.join(a),e(s.scrollIntoView()),!0}function Gf(n,e,t){let o=n.tr,s=t.parent;for(let h=t.end,f=t.endIndex-1,m=t.startIndex;f>m;f--)h-=s.child(f).nodeSize,o.delete(h-1,h+1);let r=o.doc.resolve(t.start),i=r.nodeAfter;if(o.mapping.map(t.end)!=t.start+r.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=r.node(-1),d=r.index(-1);if(!c.canReplace(d+(l?0:1),d+1,i.content.append(a?k.empty:k.from(s))))return!1;let u=r.pos,p=u+i.nodeSize;return o.step(new X(u-(l?1:0),p+(a?1:0),u+1,p-1,new A((l?k.empty:k.from(s.copy(k.empty))).append(a?k.empty:k.from(s.copy(k.empty))),l?0:1,a?0:1),l?0:1)),e(o.scrollIntoView()),!0}function Wf(n){return function(e,t){let{$from:o,$to:s}=e.selection,r=o.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!r)return!1;let i=r.startIndex;if(i==0)return!1;let l=r.parent,a=l.child(i-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=k.from(c?n.create():null),u=new A(k.from(n.create(null,k.from(l.type.create(null,d)))),c?3:1,0),p=r.start,h=r.end;t(e.tr.step(new X(p-(c?3:1),h,p,h,u,1,!0)).scrollIntoView())}return!0}}const ee=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},In=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let lr=null;const Be=function(n,e,t){let o=lr||(lr=document.createRange());return o.setEnd(n,t??n.nodeValue.length),o.setStart(n,e||0),o},jf=function(){lr=null},Mt=function(n,e,t,o){return t&&(Ma(n,e,t,o,-1)||Ma(n,e,t,o,1))},qf=/^(img|br|input|textarea|hr)$/i;function Ma(n,e,t,o,s){for(;;){if(n==t&&e==o)return!0;if(e==(s<0?0:be(n))){let r=n.parentNode;if(!r||r.nodeType!=1||Rn(n)||qf.test(n.nodeName)||n.contentEditable=="false")return!1;e=ee(n)+(s<0?0:1),n=r}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.contentEditable=="false")return!1;e=s<0?be(n):0}else return!1}}function be(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Kf(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=be(n)}else if(n.parentNode&&!Rn(n))e=ee(n),n=n.parentNode;else return null}}function Uf(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&&!Rn(n))e=ee(n)+1,n=n.parentNode;else return null}}function Jf(n,e,t){for(let o=e==0,s=e==be(n);o||s;){if(n==t)return!0;let r=ee(n);if(n=n.parentNode,!n)return!1;o=o&&r==0,s=s&&r==be(n)}}function Rn(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 Bo=function(n){return n.focusNode&&Mt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Et(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Yf(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Zf(n,e,t){if(n.caretPositionFromPoint)try{let o=n.caretPositionFromPoint(e,t);if(o)return{node:o.offsetNode,offset:Math.min(be(o.offsetNode),o.offset)}}catch{}if(n.caretRangeFromPoint){let o=n.caretRangeFromPoint(e,t);if(o)return{node:o.startContainer,offset:Math.min(be(o.startContainer),o.startOffset)}}}const Ie=typeof navigator<"u"?navigator:null,Ea=typeof document<"u"?document:null,Qe=Ie&&Ie.userAgent||"",ar=/Edge\/(\d+)/.exec(Qe),Aa=/MSIE \d/.exec(Qe),cr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Qe),he=!!(Aa||cr||ar),et=Aa?document.documentMode:cr?+cr[1]:ar?+ar[1]:0,ke=!he&&/gecko\/(\d+)/i.test(Qe);ke&&+(/Firefox\/(\d+)/.exec(Qe)||[0,0])[1];const dr=!he&&/Chrome\/(\d+)/.exec(Qe),re=!!dr,Pa=dr?+dr[1]:0,ae=!he&&!!Ie&&/Apple Computer/.test(Ie.vendor),an=ae&&(/Mobile\/\w+/.test(Qe)||!!Ie&&Ie.maxTouchPoints>2),ve=an||(Ie?/Mac/.test(Ie.platform):!1),Xf=Ie?/Win/.test(Ie.platform):!1,Te=/Android \d/.test(Qe),Dn=!!Ea&&"webkitFontSmoothing"in Ea.documentElement.style,Qf=Dn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function em(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 He(n,e){return typeof n=="number"?n:n[e]}function tm(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,o=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*o}}function Na(n,e,t){let o=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,r=n.dom.ownerDocument;for(let i=t||n.dom;i;i=In(i)){if(i.nodeType!=1)continue;let l=i,a=l==r.body,c=a?em(r):tm(l),d=0,u=0;if(e.top<c.top+He(o,"top")?u=-(c.top-e.top+He(s,"top")):e.bottom>c.bottom-He(o,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+He(s,"top")-c.top:e.bottom-c.bottom+He(s,"bottom")),e.left<c.left+He(o,"left")?d=-(c.left-e.left+He(s,"left")):e.right>c.right-He(o,"right")&&(d=e.right-c.right+He(s,"right")),d||u)if(a)r.defaultView.scrollBy(d,u);else{let p=l.scrollLeft,h=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let f=l.scrollLeft-p,m=l.scrollTop-h;e={left:e.left-f,top:e.top-m,right:e.right-f,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(i).position))break}}function nm(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),o,s;for(let r=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=n.root.elementFromPoint(r,i);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){o=l,s=a.top;break}}return{refDOM:o,refTop:s,stack:Oa(n.dom)}}function Oa(n){let e=[],t=n.ownerDocument;for(let o=n;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),n!=t);o=In(o));return e}function om({refDOM:n,refTop:e,stack:t}){let o=n?n.getBoundingClientRect().top:0;Ia(t,o==0?0:o-e)}function Ia(n,e){for(let t=0;t<n.length;t++){let{dom:o,top:s,left:r}=n[t];o.scrollTop!=s+e&&(o.scrollTop=s+e),o.scrollLeft!=r&&(o.scrollLeft=r)}}let cn=null;function sm(n){if(n.setActive)return n.setActive();if(cn)return n.focus(cn);let e=Oa(n);n.focus(cn==null?{get preventScroll(){return cn={preventScroll:!0},!0}}:void 0),cn||(cn=!1,Ia(e,0))}function Ra(n,e){let t,o=2e8,s,r=0,i=e.top,l=e.top,a,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let p;if(d.nodeType==1)p=d.getClientRects();else if(d.nodeType==3)p=Be(d).getClientRects();else continue;for(let h=0;h<p.length;h++){let f=p[h];if(f.top<=i&&f.bottom>=l){i=Math.max(f.bottom,i),l=Math.min(f.top,l);let m=f.left>e.left?f.left-e.left:f.right<e.left?e.left-f.right:0;if(m<o){t=d,o=m,s=m&&t.nodeType==3?{left:f.right<e.left?f.right:f.left,top:e.top}:e,d.nodeType==1&&m&&(r=u+(e.left>=(f.left+f.right)/2?1:0));continue}}else f.top>e.top&&!a&&f.left<=e.left&&f.right>=e.left&&(a=d,c={left:Math.max(f.left,Math.min(f.right,e.left)),top:f.top});!t&&(e.left>=f.right&&e.top>=f.top||e.left>=f.left&&e.top>=f.bottom)&&(r=u+1)}}return!t&&a&&(t=a,s=c,o=0),t&&t.nodeType==3?rm(t,s):!t||o&&t.nodeType==1?{node:n,offset:r}:Ra(t,s)}function rm(n,e){let t=n.nodeValue.length,o=document.createRange();for(let s=0;s<t;s++){o.setEnd(n,s+1),o.setStart(n,s);let r=tt(o,1);if(r.top!=r.bottom&&ur(e,r))return{node:n,offset:s+(e.left>=(r.left+r.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 im(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function lm(n,e,t){let{node:o,offset:s}=Ra(e,t),r=-1;if(o.nodeType==1&&!o.firstChild){let i=o.getBoundingClientRect();r=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(o,s,r)}function am(n,e,t,o){let s=-1;for(let r=e,i=!1;r!=n.dom;){let l=n.docView.nearestDesc(r,!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&&(!i&&a.left>o.left||a.top>o.top?s=l.posBefore:(!i&&a.right<o.left||a.bottom<o.top)&&(s=l.posAfter),i=!0),!l.contentDOM&&s<0&&!l.node.isText)return(l.node.isBlock?o.top<(a.top+a.bottom)/2:o.left<(a.left+a.right)/2)?l.posBefore:l.posAfter}r=l.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function Da(n,e,t){let o=n.childNodes.length;if(o&&t.top<t.bottom)for(let s=Math.max(0,Math.min(o-1,Math.floor(o*(e.top-t.top)/(t.bottom-t.top))-2)),r=s;;){let i=n.childNodes[r];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(ur(e,c))return Da(i,e,c)}}if((r=(r+1)%o)==s)break}return n}function cm(n,e){let t=n.dom.ownerDocument,o,s=0,r=Zf(t,e.left,e.top);r&&({node:o,offset:s}=r);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=n.dom.getBoundingClientRect();if(!ur(e,c)||(i=Da(n.dom,e,c),!i))return null}if(ae)for(let c=i;o&&c;c=In(c))c.draggable&&(o=void 0);if(i=im(i,e),o){if(ke&&o.nodeType==1&&(s=Math.min(s,o.childNodes.length),s<o.childNodes.length)){let d=o.childNodes[s],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&s++}let c;Dn&&s&&o.nodeType==1&&(c=o.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,o==n.dom&&s==o.childNodes.length-1&&o.lastChild.nodeType==1&&e.top>o.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(s==0||o.nodeType!=1||o.childNodes[s-1].nodeName!="BR")&&(l=am(n,o,s,e))}l==null&&(l=lm(n,i,e));let a=n.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function La(n){return n.top<n.bottom||n.left<n.right}function tt(n,e){let t=n.getClientRects();if(t.length){let o=t[e<0?0:t.length-1];if(La(o))return o}return Array.prototype.find.call(t,La)||n.getBoundingClientRect()}const dm=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function za(n,e,t){let{node:o,offset:s,atom:r}=n.docView.domFromPos(e,t<0?-1:1),i=Dn||ke;if(o.nodeType==3)if(i&&(dm.test(o.nodeValue)||(t<0?!s:s==o.nodeValue.length))){let a=tt(Be(o,s,s),t);if(ke&&s&&/\s/.test(o.nodeValue[s-1])&&s<o.nodeValue.length){let c=tt(Be(o,s-1,s-1),-1);if(c.top==a.top){let d=tt(Be(o,s,s+1),-1);if(d.top!=a.top)return Ln(d,d.left<c.left)}}return a}else{let a=s,c=s,d=t<0?1:-1;return t<0&&!s?(c++,d=-1):t>=0&&s==o.nodeValue.length?(a--,d=1):t<0?a--:c++,Ln(tt(Be(o,a,c),d),d<0)}if(!n.state.doc.resolve(e-(r||0)).parent.inlineContent){if(r==null&&s&&(t<0||s==be(o))){let a=o.childNodes[s-1];if(a.nodeType==1)return pr(a.getBoundingClientRect(),!1)}if(r==null&&s<be(o)){let a=o.childNodes[s];if(a.nodeType==1)return pr(a.getBoundingClientRect(),!0)}return pr(o.getBoundingClientRect(),t>=0)}if(r==null&&s&&(t<0||s==be(o))){let a=o.childNodes[s-1],c=a.nodeType==3?Be(a,be(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Ln(tt(c,1),!1)}if(r==null&&s<be(o)){let a=o.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Be(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return Ln(tt(c,-1),!0)}return Ln(tt(o.nodeType==3?Be(o):o,-t),t>=0)}function Ln(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 pr(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 $a(n,e,t){let o=n.state,s=n.root.activeElement;o!=e&&n.updateState(e),s!=n.dom&&n.focus();try{return t()}finally{o!=e&&n.updateState(o),s!=n.dom&&s&&s.focus()}}function um(n,e,t){let o=e.selection,s=t=="up"?o.$from:o.$to;return $a(n,e,()=>{let{node:r}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(r,!0);if(!l)break;if(l.node.isBlock){r=l.contentDOM||l.dom;break}r=l.dom.parentNode}let i=za(n,s.pos,1);for(let l=r.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Be(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?i.top-d.top>(d.bottom-i.top)*2:d.bottom-i.bottom>(i.bottom-d.top)*2))return!1}}return!0})}const pm=/[\u0590-\u08ac]/;function hm(n,e,t){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let s=o.parentOffset,r=!s,i=s==o.parent.content.size,l=n.domSelection();return l?!pm.test(o.parent.textContent)||!l.modify?t=="left"||t=="backward"?r:i:$a(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",t,"character");let h=o.depth?n.docView.domAfterPos(o.before()):n.dom,{focusNode:f,focusOffset:m}=n.domSelectionRange(),g=f&&!h.contains(f.nodeType==1?f:f.parentNode)||a==f&&c==m;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return p!=null&&(l.caretBidiLevel=p),g}):o.pos==o.start()||o.pos==o.end()}let Va=null,Ba=null,Ha=!1;function fm(n,e,t){return Va==e&&Ba==t?Ha:(Va=e,Ba=t,Ha=t=="up"||t=="down"?um(n,e,t):hm(n,e,t))}const xe=0,Fa=1,At=2,Re=3;class zn{constructor(e,t,o,s){this.parent=e,this.children=t,this.dom=o,this.contentDOM=s,this.dirty=xe,o.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,o){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,o=this.posAtStart;;t++){let s=this.children[t];if(s==e)return o;o+=s.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,o){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(o<0){let r,i;if(e==this.contentDOM)r=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.previousSibling}for(;r&&!((i=r.pmViewDesc)&&i.parent==this);)r=r.previousSibling;return r?this.posBeforeChild(i)+i.size:this.posAtStart}else{let r,i;if(e==this.contentDOM)r=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.nextSibling}for(;r&&!((i=r.pmViewDesc)&&i.parent==this);)r=r.nextSibling;return r?this.posBeforeChild(i):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>ee(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let r=e;;r=r.parentNode){if(r==this.dom){s=!1;break}if(r.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let r=e;;r=r.parentNode){if(r==this.dom){s=!0;break}if(r.nextSibling)break}}return s??o>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let o=!0,s=e;s;s=s.parentNode){let r=this.getDesc(s),i;if(r&&(!t||r.node))if(o&&(i=r.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))o=!1;else return r}}getDesc(e){let t=e.pmViewDesc;for(let o=t;o;o=o.parent)if(o==this)return t}posFromDOM(e,t,o){for(let s=e;s;s=s.parentNode){let r=this.getDesc(s);if(r)return r.localPosFromDOM(e,t,o)}return-1}descAt(e){for(let t=0,o=0;t<this.children.length;t++){let s=this.children[t],r=o+s.size;if(o==e&&r!=o){for(;!s.border&&s.children.length;)s=s.children[0];return s}if(e<r)return s.descAt(e-o-s.border);o=r}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let o=0,s=0;for(let r=0;o<this.children.length;o++){let i=this.children[o],l=r+i.size;if(l>e||i instanceof Wa){s=e-r;break}r=l}if(s)return this.children[o].domFromPos(s-this.children[o].border,t);for(let r;o&&!(r=this.children[o-1]).size&&r instanceof _a&&r.side>=0;o--);if(t<=0){let r,i=!0;for(;r=o?this.children[o-1]:null,!(!r||r.dom.parentNode==this.contentDOM);o--,i=!1);return r&&t&&i&&!r.border&&!r.domAtom?r.domFromPos(r.size,t):{node:this.contentDOM,offset:r?ee(r.dom)+1:0}}else{let r,i=!0;for(;r=o<this.children.length?this.children[o]:null,!(!r||r.dom.parentNode==this.contentDOM);o++,i=!1);return r&&i&&!r.border&&!r.domAtom?r.domFromPos(0,t):{node:this.contentDOM,offset:r?ee(r.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,o=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,r=-1;for(let i=o,l=0;;l++){let a=this.children[l],c=i+a.size;if(s==-1&&e<=c){let d=i+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=i;for(let u=l;u>0;u--){let p=this.children[u-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){s=ee(p.dom)+1;break}e-=p.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){r=ee(u.dom);break}t+=u.size}r==-1&&(r=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:r}}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:o}=this.domFromPos(e,0);if(t.nodeType!=1||o==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[o]}setSelection(e,t,o,s=!1){let r=Math.min(e,t),i=Math.max(e,t);for(let h=0,f=0;h<this.children.length;h++){let m=this.children[h],g=f+m.size;if(r>f&&i<g)return m.setSelection(e-f-m.border,t-f-m.border,o,s);f=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=o.root.getSelection(),d=o.domSelectionRange(),u=!1;if((ke||ae)&&e==t){let{node:h,offset:f}=l;if(h.nodeType==3){if(u=!!(f&&h.nodeValue[f-1]==`
|
|
299
|
+
`),u&&f==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:ee(g)+1});break}let v=m.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let m=h.childNodes[f-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(ke&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||u&&ae)&&Mt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Mt(a.node,a.offset,d.focusNode,d.focusOffset))return;let p=!1;if((c.extend||e==t)&&!u){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),p=!0}catch{}}if(!p){if(e>t){let f=l;l=a,a=f}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}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 o=0,s=0;s<this.children.length;s++){let r=this.children[s],i=o+r.size;if(o==i?e<=i&&t>=o:e<i&&t>o){let l=o+r.border,a=i-r.border;if(e>=l&&t<=a){this.dirty=e==o||t==i?At:Fa,e==l&&t==a&&(r.contentLost||r.dom.parentNode!=this.contentDOM)?r.dirty=Re:r.markDirty(e-l,t-l);return}else r.dirty=r.dom==r.contentDOM&&r.dom.parentNode==this.contentDOM&&!r.children.length?At:Re}o=i}this.dirty=At}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let o=e==1?At:Fa;t.dirty<o&&(t.dirty=o)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class _a extends zn{constructor(e,t,o,s){let r,i=t.type.toDOM;if(typeof i=="function"&&(i=i(o,()=>{if(!r)return s;if(r.parent)return r.parent.posBeforeChild(r)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return this.dirty==xe&&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 mm extends zn{constructor(e,t,o,s){super(e,[],t,null),this.textDOM=o,this.text=s}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 Pt extends zn{constructor(e,t,o,s,r){super(e,[],o,s),this.mark=t,this.spec=r}static create(e,t,o,s){let r=s.nodeViews[t.type.name],i=r&&r(t,s,o);return(!i||!i.dom)&&(i=Ct.renderSpec(document,t.type.spec.toDOM(t,o),null,t.attrs)),new Pt(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&Re||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Re&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=xe){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=xe}}slice(e,t,o){let s=Pt.create(this.parent,this.mark,!0,o),r=this.children,i=this.size;t<i&&(r=fr(r,t,i,o)),e>0&&(r=fr(r,0,e,o));for(let l=0;l<r.length;l++)r[l].parent=s;return s.children=r,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class nt extends zn{constructor(e,t,o,s,r,i,l,a,c){super(e,[],r,i),this.node=t,this.outerDeco=o,this.innerDeco=s,this.nodeDOM=l}static create(e,t,o,s,r,i){let l=r.nodeViews[t.type.name],a,c=l&&l(t,r,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},o,s),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Ct.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let p=d;return d=Ka(d,o,t),c?a=new gm(e,t,o,s,d,u||null,p,c,r,i+1):t.isText?new Ho(e,t,o,s,d,p,r):new nt(e,t,o,s,d,u||null,p,r,i+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 o=this.children[t];if(this.dom.contains(o.dom.parentNode)){e.contentElement=o.dom.parentNode;break}}e.contentElement||(e.getContent=()=>k.empty)}return e}matchesNode(e,t,o){return this.dirty==xe&&e.eq(this.node)&&Fo(t,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let o=this.node.inlineContent,s=t,r=e.composing?this.localCompositionInfo(e,t):null,i=r&&r.pos>-1?r:null,l=r&&r.pos<0,a=new bm(this,i&&i.node,e);Sm(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,o,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?B.none:this.node.child(d).marks,o,e),a.placeWidget(c,e,s)},(c,d,u,p)=>{a.syncToMarks(c.marks,o,e);let h;a.findNodeMatch(c,d,u,p)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(r.node))>-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,p,s)||a.addNode(c,d,u,e,s),s+=c.nodeSize}),a.syncToMarks([],o,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==At)&&(i&&this.protectLocalComposition(e,i),ja(this.contentDOM,this.children,e),an&&wm(this.dom))}localCompositionInfo(e,t){let{from:o,to:s}=e.state.selection;if(!(e.state.selection instanceof L)||o<t||s>t+this.node.content.size)return null;let r=e.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let i=r.nodeValue,l=Cm(this.node.content,i,o-t,s-t);return l<0?null:{node:r,pos:l,text:i}}else return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:o,text:s}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let i=new mm(this,r,t,s);e.input.compositionNodes.push(i),this.children=fr(this.children,o,o+s.length,e,i)}update(e,t,o,s){return this.dirty==Re||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,o,s),!0)}updateInner(e,t,o,s){this.updateOuterDeco(t),this.node=e,this.innerDeco=o,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=xe}updateOuterDeco(e){if(Fo(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,o=this.dom;this.dom=qa(this.dom,this.nodeDOM,hr(this.outerDeco,this.node,t),hr(e,this.node,t)),this.dom!=o&&(o.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 Ga(n,e,t,o,s){Ka(o,e,n);let r=new nt(void 0,n,e,t,o,o,o,s,0);return r.contentDOM&&r.updateChildren(s,0),r}class Ho extends nt{constructor(e,t,o,s,r,i,l){super(e,t,o,s,r,null,i,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,o,s){return this.dirty==Re||this.dirty!=xe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=xe||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=xe,!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,o){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,o)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,o){let s=this.node.cut(e,t),r=document.createTextNode(s.text);return new Ho(this.parent,s,this.outerDeco,this.innerDeco,r,r,o)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Re)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Wa extends zn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==xe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class gm extends nt{constructor(e,t,o,s,r,i,l,a,c,d){super(e,t,o,s,r,i,l,c,d),this.spec=a}update(e,t,o,s){if(this.dirty==Re)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,o);return r&&this.updateInner(e,t,o,s),r}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,o,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,o,s){this.spec.setSelection?this.spec.setSelection(e,t,o.root):super.setSelection(e,t,o,s)}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 ja(n,e,t){let o=n.firstChild,s=!1;for(let r=0;r<e.length;r++){let i=e[r],l=i.dom;if(l.parentNode==n){for(;l!=o;)o=Ua(o),s=!0;o=o.nextSibling}else s=!0,n.insertBefore(l,o);if(i instanceof Pt){let a=o?o.previousSibling:n.lastChild;ja(i.contentDOM,i.children,t),o=a?a.nextSibling:n.firstChild}}for(;o;)o=Ua(o),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const $n=function(n){n&&(this.nodeName=n)};$n.prototype=Object.create(null);const Nt=[new $n];function hr(n,e,t){if(n.length==0)return Nt;let o=t?Nt[0]:new $n,s=[o];for(let r=0;r<n.length;r++){let i=n[r].type.attrs;if(i){i.nodeName&&s.push(o=new $n(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&s.length==1&&s.push(o=new $n(e.isInline?"span":"div")),l=="class"?o.class=(o.class?o.class+" ":"")+a:l=="style"?o.style=(o.style?o.style+";":"")+a:l!="nodeName"&&(o[l]=a))}}}return s}function qa(n,e,t,o){if(t==Nt&&o==Nt)return e;let s=e;for(let r=0;r<o.length;r++){let i=o[r],l=t[r];if(r){let a;l&&l.nodeName==i.nodeName&&s!=n&&(a=s.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=Nt[0]),s=a}ym(s,l||Nt[0],i)}return s}function ym(n,e,t){for(let o in e)o!="class"&&o!="style"&&o!="nodeName"&&!(o in t)&&n.removeAttribute(o);for(let o in t)o!="class"&&o!="style"&&o!="nodeName"&&t[o]!=e[o]&&n.setAttribute(o,t[o]);if(e.class!=t.class){let o=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let r=0;r<o.length;r++)s.indexOf(o[r])==-1&&n.classList.remove(o[r]);for(let r=0;r<s.length;r++)o.indexOf(s[r])==-1&&n.classList.add(s[r]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=o.exec(e.style);)n.style.removeProperty(s[1])}t.style&&(n.style.cssText+=t.style)}}function Ka(n,e,t){return qa(n,n,Nt,hr(e,t,n.nodeType!=1))}function Fo(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 Ua(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class bm{constructor(e,t,o){this.lock=t,this.view=o,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=vm(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let o=e;o<t;o++)this.top.children[o].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,o){let s=0,r=this.stack.length>>1,i=Math.min(r,e.length);for(;s<i&&(s==r-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<r;)this.destroyRest(),this.top.dirty=xe,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<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[r])&&!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=Pt.create(this.top,e[r],t,o);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,r++}}findNodeMatch(e,t,o,s){let r=-1,i;if(s>=this.preMatch.index&&(i=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,o))r=this.top.children.indexOf(i,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,o)&&!this.preMatch.matched.has(c)){r=l;break}}return r<0?!1:(this.destroyBetween(this.index,r),this.index++,!0)}updateNodeAt(e,t,o,s,r){let i=this.top.children[s];return i.dirty==Re&&i.dom==i.contentDOM&&(i.dirty=At),i.update(e,t,o,r)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let o=e.pmViewDesc;if(o){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==o)return s}return-1}e=t}}updateNextNode(e,t,o,s,r,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof nt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=r)return!1;let d=a.dom,u,p=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Re&&Fo(t,a.outerDeco));if(!p&&a.update(e,t,o,s))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!p&&(u=this.recreateWrapper(a,e,t,o,s,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=At,u.updateChildren(s,i+1),u.dirty=xe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,o,s,r,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Fo(o,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=nt.create(this.top,t,o,s,r,i);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,o,s,r){let i=nt.create(this.top,e,t,o,s,r);i.contentDOM&&i.updateChildren(s,r+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,o){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let r=new _a(this.top,e,t,o);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Pt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Ho)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ae||re)&&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 o=document.createElement(e);e=="IMG"&&(o.className="ProseMirror-separator",o.alt=""),e=="BR"&&(o.className="ProseMirror-trailingBreak");let s=new Wa(this.top,[],o,null);t!=this.top?t.children.push(s):t.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function vm(n,e){let t=e,o=t.children.length,s=n.childCount,r=new Map,i=[];e:for(;s>0;){let l;for(;;)if(o){let c=t.children[o-1];if(c instanceof Pt)t=c,o=c.children.length;else{l=c,o--;break}}else{if(t==e)break e;o=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(s-1))break;--s,r.set(l,s),i.push(l)}}return{index:s,matched:r,matches:i.reverse()}}function xm(n,e){return n.type.side-e.type.side}function Sm(n,e,t,o){let s=e.locals(n),r=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);o(d,s,e.forChild(r,d),c),r+=d.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let d,u;for(;i<s.length&&s[i].to==r;){let g=s[i++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(xm);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let p,h;if(a)h=-1,p=a,a=null;else if(c<n.childCount)h=c,p=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=r&&l.splice(g--,1);for(;i<s.length&&s[i].from<=r&&s[i].to>r;)l.push(s[i++]);let f=r+p.nodeSize;if(p.isText){let g=f;i<s.length&&s[i].from<g&&(g=s[i].from);for(let v=0;v<l.length;v++)l[v].to<g&&(g=l[v].to);g<f&&(a=p.cut(g-r),p=p.cut(0,g-r),f=g,h=-1)}else for(;i<s.length&&s[i].to<f;)i++;let m=p.isInline&&!p.isLeaf?l.filter(g=>!g.inline):l.slice();o(p,m,e.forChild(r,p),h),r=f}}function wm(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 Cm(n,e,t,o){for(let s=0,r=0;s<n.childCount&&r<=o;){let i=n.child(s++),l=r;if(r+=i.nodeSize,!i.isText)continue;let a=i.text;for(;s<n.childCount;){let c=n.child(s++);if(r+=c.nodeSize,!c.isText)break;a+=c.text}if(r>=t){if(r>=o&&a.slice(o-e.length-l,o-l)==e)return o-e.length;let c=l<o?a.lastIndexOf(e,o-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==o&&a.length>=o+e.length-l&&a.slice(o-l,o-l+e.length)==e)return o}}return-1}function fr(n,e,t,o,s){let r=[];for(let i=0,l=0;i<n.length;i++){let a=n[i],c=l,d=l+=a.size;c>=t||d<=e?r.push(a):(c<e&&r.push(a.slice(0,e-c,o)),s&&(r.push(s),s=void 0),d>t&&r.push(a.slice(t-c,a.size,o)))}return r}function mr(n,e=null){let t=n.domSelectionRange(),o=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),r=s&&s.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=o.resolve(i),a,c;if(Bo(t)){for(a=i;s&&!s.node;)s=s.parent;let u=s.node;if(s&&u.isAtom&&R.isSelectable(u)&&s.parent&&!(u.isInline&&Jf(t.focusNode,t.focusOffset,s.dom))){let p=s.posBefore;c=new R(i==p?l:o.resolve(p))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=i,p=i;for(let h=0;h<t.rangeCount;h++){let f=t.getRangeAt(h);u=Math.min(u,n.docView.posFromDOM(f.startContainer,f.startOffset,1)),p=Math.max(p,n.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(u<0)return null;[a,i]=p==n.state.selection.anchor?[p,u]:[u,p],l=o.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=o.resolve(a);if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!r?1:-1;c=yr(n,d,l,u)}return c}function Ja(n){return n.editable?n.hasFocus():nc(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Fe(n,e=!1){let t=n.state.selection;if(Qa(n,t),!!Ja(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&re){let o=n.domSelectionRange(),s=n.domObserver.currentSelection;if(o.anchorNode&&s.anchorNode&&Mt(o.anchorNode,o.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Tm(n);else{let{anchor:o,head:s}=t,r,i;Ya&&!(t instanceof L)&&(t.$from.parent.inlineContent||(r=Za(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=Za(n,t.to))),n.docView.setSelection(o,s,n,e),Ya&&(r&&Xa(r),i&&Xa(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&km(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Ya=ae||re&&Pa<63;function Za(n,e){let{node:t,offset:o}=n.docView.domFromPos(e,0),s=o<t.childNodes.length?t.childNodes[o]:null,r=o?t.childNodes[o-1]:null;if(ae&&s&&s.contentEditable=="false")return gr(s);if((!s||s.contentEditable=="false")&&(!r||r.contentEditable=="false")){if(s)return gr(s);if(r)return gr(r)}}function gr(n){return n.contentEditable="true",ae&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Xa(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function km(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),o=t.anchorNode,s=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=o||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Ja(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Tm(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let o=n.cursorWrapper.dom,s=o.nodeName=="IMG";s?t.setStart(o.parentNode,ee(o)+1):t.setStart(o,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!s&&!n.state.selection.visible&&he&&et<=11&&(o.disabled=!0,o.disabled=!1)}function Qa(n,e){if(e instanceof R){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ec(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ec(n)}function ec(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function yr(n,e,t,o){return n.someProp("createSelectionBetween",s=>s(n,e,t))||L.between(e,t,o)}function tc(n){return n.editable&&!n.hasFocus()?!1:nc(n)}function nc(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 Mm(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Mt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function br(n,e){let{$anchor:t,$head:o}=n.selection,s=e>0?t.max(o):t.min(o),r=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return r&&D.findFrom(r,e)}function ot(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function oc(n,e,t){let o=n.state.selection;if(o instanceof L)if(t.indexOf("s")>-1){let{$head:s}=o,r=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let i=n.state.doc.resolve(s.pos+r.nodeSize*(e<0?-1:1));return ot(n,new L(o.$anchor,i))}else if(o.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=br(n.state,e);return s&&s instanceof R?ot(n,s):!1}else if(!(ve&&t.indexOf("m")>-1)){let s=o.$head,r=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,i;if(!r||r.isText)return!1;let l=e<0?s.pos-r.nodeSize:s.pos;return r.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?R.isSelectable(r)?ot(n,new R(e<0?n.state.doc.resolve(s.pos-r.nodeSize):s)):Dn?ot(n,new L(n.state.doc.resolve(e<0?l:l+r.nodeSize))):!1:!1}}else return!1;else{if(o instanceof R&&o.node.isInline)return ot(n,new L(e>0?o.$to:o.$from));{let s=br(n.state,e);return s?ot(n,s):!1}}}function _o(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Vn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function dn(n,e){return e<0?Em(n):Am(n)}function Em(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s,r,i=!1;for(ke&&t.nodeType==1&&o<_o(t)&&Vn(t.childNodes[o],-1)&&(i=!0);;)if(o>0){if(t.nodeType!=1)break;{let l=t.childNodes[o-1];if(Vn(l,-1))s=t,r=--o;else if(l.nodeType==3)t=l,o=t.nodeValue.length;else break}}else{if(sc(t))break;{let l=t.previousSibling;for(;l&&Vn(l,-1);)s=t.parentNode,r=ee(l),l=l.previousSibling;if(l)t=l,o=_o(t);else{if(t=t.parentNode,t==n.dom)break;o=0}}}i?vr(n,t,o):s&&vr(n,s,r)}function Am(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s=_o(t),r,i;for(;;)if(o<s){if(t.nodeType!=1)break;let l=t.childNodes[o];if(Vn(l,1))r=t,i=++o;else break}else{if(sc(t))break;{let l=t.nextSibling;for(;l&&Vn(l,1);)r=l.parentNode,i=ee(l)+1,l=l.nextSibling;if(l)t=l,o=0,s=_o(t);else{if(t=t.parentNode,t==n.dom)break;o=s=0}}}r&&vr(n,r,i)}function sc(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Pm(n,e){for(;n&&e==n.childNodes.length&&!Rn(n);)e=ee(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 Nm(n,e){for(;n&&!e&&!Rn(n);)e=ee(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 vr(n,e,t){if(e.nodeType!=3){let r,i;(i=Pm(e,t))?(e=i,t=0):(r=Nm(e,t))&&(e=r,t=r.nodeValue.length)}let o=n.domSelection();if(!o)return;if(Bo(o)){let r=document.createRange();r.setEnd(e,t),r.setStart(e,t),o.removeAllRanges(),o.addRange(r)}else o.extend&&o.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&Fe(n)},50)}function rc(n,e){let t=n.state.doc.resolve(e);if(!(re||Xf)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let r=n.coordsAtPos(e-1),i=(r.top+r.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(r.left-s.left)>1)return r.left<s.left?"ltr":"rtl"}if(e<t.end()){let r=n.coordsAtPos(e+1),i=(r.top+r.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(r.left-s.left)>1)return r.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function ic(n,e,t){let o=n.state.selection;if(o instanceof L&&!o.empty||t.indexOf("s")>-1||ve&&t.indexOf("m")>-1)return!1;let{$from:s,$to:r}=o;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=br(n.state,e);if(i&&i instanceof R)return ot(n,i)}if(!s.parent.inlineContent){let i=e<0?s:r,l=o instanceof ge?D.near(i,e):D.findFrom(i,e);return l?ot(n,l):!1}return!1}function lc(n,e){if(!(n.state.selection instanceof L))return!0;let{$head:t,$anchor:o,empty:s}=n.state.selection;if(!t.sameParent(o))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let r=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(r&&!r.isText){let i=n.state.tr;return e<0?i.delete(t.pos-r.nodeSize,t.pos):i.delete(t.pos,t.pos+r.nodeSize),n.dispatch(i),!0}return!1}function ac(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Om(n){if(!ae||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 o=e.firstChild;ac(n,o,"true"),setTimeout(()=>ac(n,o,"false"),20)}return!1}function Im(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Rm(n,e){let t=e.keyCode,o=Im(e);if(t==8||ve&&t==72&&o=="c")return lc(n,-1)||dn(n,-1);if(t==46&&!e.shiftKey||ve&&t==68&&o=="c")return lc(n,1)||dn(n,1);if(t==13||t==27)return!0;if(t==37||ve&&t==66&&o=="c"){let s=t==37?rc(n,n.state.selection.from)=="ltr"?-1:1:-1;return oc(n,s,o)||dn(n,s)}else if(t==39||ve&&t==70&&o=="c"){let s=t==39?rc(n,n.state.selection.from)=="ltr"?1:-1:1;return oc(n,s,o)||dn(n,s)}else{if(t==38||ve&&t==80&&o=="c")return ic(n,-1,o)||dn(n,-1);if(t==40||ve&&t==78&&o=="c")return Om(n)||ic(n,1,o)||dn(n,1);if(o==(ve?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function cc(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:o,openStart:s,openEnd:r}=e;for(;s>1&&r>1&&o.childCount==1&&o.firstChild.childCount==1;){s--,r--;let h=o.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),o=h.content}let i=n.someProp("clipboardSerializer")||Ct.fromSchema(n.state.schema),l=yc(),a=l.createElement("div");a.appendChild(i.serializeFragment(o,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=mc[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let f=l.createElement(d[h]);for(;a.firstChild;)f.appendChild(a.firstChild);a.appendChild(f),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${r}${u?` -${u}`:""} ${JSON.stringify(t)}`);let p=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
|
|
300
300
|
|
|
301
|
-
`);return{dom:a,text:
|
|
302
|
-
`))),0,0):E.empty;let u=n.someProp("clipboardTextParser",h=>h(e,s,o,n));if(u)l=u;else{let h=s.marks(),{schema:p}=n.state,f=Ct.fromSchema(p);r=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=r.appendChild(document.createElement("p"));m&&g.appendChild(f.serializeNode(p.text(m,h)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),r=Em(t),Rn&&Nm(r);let c=r&&r.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let h=r.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;r=h}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Zt.fromSchema(n.state.schema)).parseSlice(r,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!Tm.test(h.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Om(rc(l,+d[1],+d[2]),d[4]);else if(l=E.maxOpen(Mm(l.content,s),!0),l.openStart||l.openEnd){let u=0,h=0;for(let p=l.content.firstChild;u<l.openStart&&!p.type.spec.isolating;u++,p=p.firstChild);for(let p=l.content.lastChild;h<l.openEnd&&!p.type.spec.isolating;h++,p=p.lastChild);l=rc(l,u,h)}return n.someProp("transformPasted",u=>{l=u(l,n)}),l}const Tm=/^(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 Mm(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),i,r=[];if(n.forEach(l=>{if(!r)return;let a=s.findWrapping(l.type),c;if(!a)return r=null;if(c=r.length&&i.length&&sc(a,i,l,r[r.length-1],0))r[r.length-1]=c;else{r.length&&(r[r.length-1]=ic(r[r.length-1],i.length));let d=oc(l,a);r.push(d),s=s.matchType(d.type),i=a}}),r)return k.from(r)}return n}function oc(n,e,t=0){for(let o=e.length-1;o>=t;o--)n=e[o].create(null,k.from(n));return n}function sc(n,e,t,o,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let i=sc(n,e,t,o.lastChild,s+1);if(i)return o.copy(o.content.replaceChild(o.childCount-1,i));if(o.contentMatchAt(o.childCount).matchType(s==n.length-1?t.type:n[s+1]))return o.copy(o.content.append(k.from(oc(t,n,s+1))))}}function ic(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,ic(n.lastChild,e-1)),o=n.contentMatchAt(n.childCount).fillBefore(k.empty,!0);return n.copy(t.append(o))}function gi(n,e,t,o,s,i){let r=e<0?n.firstChild:n.lastChild,l=r.content;return n.childCount>1&&(i=0),s<o-1&&(l=gi(l,e,t,o,s+1,i)),s>=t&&(l=e<0?r.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(r.contentMatchAt(r.childCount).fillBefore(k.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,r.copy(l))}function rc(n,e,t){return e<n.openStart&&(n=new E(gi(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new E(gi(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const lc={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 ac=null;function cc(){return ac||(ac=document.implementation.createHTMLDocument("title"))}let yi=null;function Am(n){let e=window.trustedTypes;return e?(yi||(yi=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),yi.createHTML(n)):n}function Em(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=cc().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(n),s;if((s=o&&lc[o[1].toLowerCase()])&&(n=s.map(i=>"<"+i+">").join("")+n+s.map(i=>"</"+i+">").reverse().join("")),t.innerHTML=Am(n),s)for(let i=0;i<s.length;i++)t=t.querySelector(s[i])||t;return t}function Nm(n){let e=n.querySelectorAll(ie?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let o=e[t];o.childNodes.length==1&&o.textContent==" "&&o.parentNode&&o.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),o)}}function Om(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,o;try{o=JSON.parse(e)}catch{return n}let{content:s,openStart:i,openEnd:r}=n;for(let l=o.length-2;l>=0;l-=2){let a=t.nodes[o[l]];if(!a||a.hasRequiredAttrs())break;s=k.from(a.create(o[l+1],s)),i++,r++}return new E(s,i,r)}const ce={},de={},Pm={touchstart:!0,touchmove:!0};class Im{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 Rm(n){for(let e in ce){let t=ce[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=o=>{Lm(n,o)&&!vi(n,o)&&(n.editable||!(o.type in de))&&t(n,o)},Pm[e]?{passive:!0}:void 0)}ae&&n.dom.addEventListener("input",()=>null),bi(n)}function ot(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Dm(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 bi(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=o=>vi(n,o))})}function vi(n,e){return n.someProp("handleDOMEvents",t=>{let o=t[e.type];return o?o(n,e)||e.defaultPrevented:!1})}function Lm(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 zm(n,e){!vi(n,e)&&ce[e.type]&&(n.editable||!(e.type in de))&&ce[e.type](n,e)}de.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!uc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Te&&ie&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),ln&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let o=Date.now();n.input.lastIOSEnter=o,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==o&&(n.someProp("handleKeyDown",s=>s(n,At(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",o=>o(n,t))||km(n,t)?t.preventDefault():ot(n,"key")},de.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},de.keypress=(n,e)=>{let t=e;if(uc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ve&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let o=n.state.selection;if(!(o instanceof L)||!o.$from.sameParent(o.$to)){let s=String.fromCharCode(t.charCode);!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",i=>i(n,o.$from.pos,o.$to.pos,s))&&n.dispatch(n.state.tr.insertText(s).scrollIntoView()),t.preventDefault()}};function Fo(n){return{left:n.clientX,top:n.clientY}}function Vm(n,e){let t=e.x-n.clientX,o=e.y-n.clientY;return t*t+o*o<100}function xi(n,e,t,o,s){if(o==-1)return!1;let i=n.state.doc.resolve(o);for(let r=i.depth+1;r>0;r--)if(n.someProp(e,l=>r>i.depth?l(n,t,i.nodeAfter,i.before(r),s,!0):l(n,t,i.node(r),i.before(r),s,!1)))return!0;return!1}function dn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let o=n.state.tr.setSelection(e);o.setMeta("pointer",!0),n.dispatch(o)}function $m(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),o=t.nodeAfter;return o&&o.isAtom&&R.isSelectable(o)?(dn(n,new R(t)),!0):!1}function Bm(n,e){if(e==-1)return!1;let t=n.state.selection,o,s;t instanceof R&&(o=t.node);let i=n.state.doc.resolve(e);for(let r=i.depth+1;r>0;r--){let l=r>i.depth?i.nodeAfter:i.node(r);if(R.isSelectable(l)){o&&t.$from.depth>0&&r>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?s=i.before(t.$from.depth):s=i.before(r);break}}return s!=null?(dn(n,R.create(n.state.doc,s)),!0):!1}function Hm(n,e,t,o,s){return xi(n,"handleClickOn",e,t,o)||n.someProp("handleClick",i=>i(n,e,o))||(s?Bm(n,t):$m(n,t))}function Fm(n,e,t,o){return xi(n,"handleDoubleClickOn",e,t,o)||n.someProp("handleDoubleClick",s=>s(n,e,o))}function _m(n,e,t,o){return xi(n,"handleTripleClickOn",e,t,o)||n.someProp("handleTripleClick",s=>s(n,e,o))||Gm(n,t,o)}function Gm(n,e,t){if(t.button!=0)return!1;let o=n.state.doc;if(e==-1)return o.inlineContent?(dn(n,L.create(o,0,o.content.size)),!0):!1;let s=o.resolve(e);for(let i=s.depth+1;i>0;i--){let r=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(r.inlineContent)dn(n,L.create(o,l+1,l+1+r.content.size));else if(R.isSelectable(r))dn(n,R.create(o,l));else continue;return!0}}function Si(n){return _o(n)}const dc=ve?"metaKey":"ctrlKey";ce.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let o=Si(n),s=Date.now(),i="singleClick";s-n.input.lastClick.time<500&&Vm(t,n.input.lastClick)&&!t[dc]&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:i};let r=n.posAtCoords(Fo(t));r&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Wm(n,r,t,!!o)):(i=="doubleClick"?Fm:_m)(n,r.pos,r.inside,t)?t.preventDefault():ot(n,"pointer"))};class Wm{constructor(e,t,o,s){this.view=e,this.pos=t,this.event=o,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!o[dc],this.allowDefault=o.shiftKey;let i,r;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),r=t.inside;else{let d=e.state.doc.resolve(t.pos);i=d.parent,r=d.depth?d.before():0}const l=s?null:o.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(o.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof R&&c.from<=r&&c.to>r)&&(this.mightDrag={node:i,pos:r,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ke&&!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)),ot(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(()=>He(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(Fo(e))),this.updateAllowDefault(e),this.allowDefault||!t?ot(this.view,"pointer"):Hm(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ae&&this.mightDrag&&!this.mightDrag.node.isAtom||ie&&!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)?(dn(this.view,D.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):ot(this.view,"pointer")}move(e){this.updateAllowDefault(e),ot(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)}}ce.touchstart=n=>{n.input.lastTouch=Date.now(),Si(n),ot(n,"pointer")},ce.touchmove=n=>{n.input.lastTouch=Date.now(),ot(n,"pointer")},ce.contextmenu=n=>Si(n);function uc(n,e){return n.composing?!0:ae&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const jm=Te?5e3:-1;de.compositionstart=de.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof L&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(o=>o.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),_o(n,!0),n.markCursor=null;else if(_o(n,!e.selection.empty),ke&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let o=n.domSelectionRange();for(let s=o.focusNode,i=o.focusOffset;s&&s.nodeType==1&&i!=0;){let r=i<0?s.lastChild:s.childNodes[i-1];if(!r)break;if(r.nodeType==3){let l=n.domSelection();l&&l.collapse(r,r.nodeValue.length);break}else s=r,i=-1}}n.input.composing=!0}hc(n,jm)},de.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++,hc(n,20))};function hc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>_o(n),e))}function pc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Km());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function qm(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=$f(e.focusNode,e.focusOffset),o=Bf(e.focusNode,e.focusOffset);if(t&&o&&t!=o){let s=o.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||o==i)return i;if(!s||!s.isText(o.nodeValue))return o;if(n.input.compositionNode==o){let r=t.pmViewDesc;if(!(!r||!r.isText(t.nodeValue)))return o}}return t||o}function Km(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function _o(n,e=!1){if(!(Te&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),pc(n),e||n.docView&&n.docView.dirty){let t=ui(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 Um(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 o=getSelection(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),o.removeAllRanges(),o.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const $n=pe&&Qe<15||ln&&Wf<604;ce.copy=de.cut=(n,e)=>{let t=e,o=n.state.selection,s=t.type=="cut";if(o.empty)return;let i=$n?null:t.clipboardData,r=o.content(),{dom:l,text:a}=tc(n,r);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):Um(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Jm(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Ym(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,o=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let s=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),o.parentNode&&o.parentNode.removeChild(o),t?Bn(n,o.value,null,s,e):Bn(n,o.textContent,o.innerHTML,s,e)},50)}function Bn(n,e,t,o,s){let i=nc(n,e,t,o,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,i||E.empty)))return!0;if(!i)return!1;let r=Jm(i),l=r?n.state.tr.replaceSelectionWith(r,o):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function fc(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," "):""}de.paste=(n,e)=>{let t=e;if(n.composing&&!Te)return;let o=$n?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;o&&Bn(n,fc(o),o.getData("text/html"),s,t)?t.preventDefault():Ym(n,t)};class mc{constructor(e,t,o){this.slice=e,this.move=t,this.node=o}}const gc=ve?"altKey":"ctrlKey";ce.dragstart=(n,e)=>{let t=e,o=n.input.mouseDown;if(o&&o.done(),!t.dataTransfer)return;let s=n.state.selection,i=s.empty?null:n.posAtCoords(Fo(t)),r;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof R?s.to-1:s.to))){if(o&&o.mightDrag)r=R.create(n.state.doc,o.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(r=R.create(n.state.doc,u.posBefore))}}let l=(r||n.state.selection).content(),{dom:a,text:c,slice:d}=tc(n,l);(!t.dataTransfer.files.length||!ie||Sa>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData($n?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",$n||t.dataTransfer.setData("text/plain",c),n.dragging=new mc(d,!t[gc],r)},ce.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},de.dragover=de.dragenter=(n,e)=>e.preventDefault(),de.drop=(n,e)=>{let t=e,o=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let s=n.posAtCoords(Fo(t));if(!s)return;let i=n.state.doc.resolve(s.pos),r=o&&o.slice;r?n.someProp("transformPasted",f=>{r=f(r,n)}):r=nc(n,fc(t.dataTransfer),$n?null:t.dataTransfer.getData("text/html"),!1,i);let l=!!(o&&!t[gc]);if(n.someProp("handleDrop",f=>f(n,t,r||E.empty,l))){t.preventDefault();return}if(!r)return;t.preventDefault();let a=r?Wp(n.state.doc,i.pos,r):i.pos;a==null&&(a=i.pos);let c=n.state.tr;if(l){let{node:f}=o;f?f.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=r.openStart==0&&r.openEnd==0&&r.content.childCount==1,h=c.doc;if(u?c.replaceRangeWith(d,d,r.content.firstChild):c.replaceRange(d,d,r),c.doc.eq(h))return;let p=c.doc.resolve(d);if(u&&R.isSelectable(r.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(r.content.firstChild))c.setSelection(new R(p));else{let f=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,w)=>f=w),c.setSelection(pi(n,p,c.doc.resolve(f)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},ce.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())&&He(n)},20))},ce.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)},ce.beforeinput=(n,e)=>{if(ie&&Te&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:o}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=o||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,At(8,"Backspace")))))return;let{$cursor:s}=n.state.selection;s&&s.pos>0&&n.dispatch(n.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let n in de)ce[n]=de[n];function Hn(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 Go{constructor(e,t){this.toDOM=e,this.spec=t||Pt,this.side=this.spec.side||0}map(e,t,o,s){let{pos:i,deleted:r}=e.mapResult(t.from+s,this.side<0?-1:1);return r?null:new fe(i-o,i-o,this)}valid(){return!0}eq(e){return this==e||e instanceof Go&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Hn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class st{constructor(e,t){this.attrs=e,this.spec=t||Pt}map(e,t,o,s){let i=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-o,r=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-o;return i>=r?null:new fe(i,r,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof st&&Hn(this.attrs,e.attrs)&&Hn(this.spec,e.spec)}static is(e){return e.type instanceof st}destroy(){}}class wi{constructor(e,t){this.attrs=e,this.spec=t||Pt}map(e,t,o,s){let i=e.mapResult(t.from+s,1);if(i.deleted)return null;let r=e.mapResult(t.to+s,-1);return r.deleted||r.pos<=i.pos?null:new fe(i.pos-o,r.pos-o,this)}valid(e,t){let{index:o,offset:s}=e.content.findIndex(t.from),i;return s==t.from&&!(i=e.child(o)).isText&&s+i.nodeSize==t.to}eq(e){return this==e||e instanceof wi&&Hn(this.attrs,e.attrs)&&Hn(this.spec,e.spec)}destroy(){}}class fe{constructor(e,t,o){this.from=e,this.to=t,this.type=o}copy(e,t){return new fe(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,o){return this.type.map(e,this,t,o)}static widget(e,t,o){return new fe(e,e,new Go(t,o))}static inline(e,t,o,s){return new fe(e,t,new st(o,s))}static node(e,t,o,s){return new fe(e,t,new wi(o,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof st}get widget(){return this.type instanceof Go}}const un=[],Pt={};class q{constructor(e,t){this.local=e.length?e:un,this.children=t.length?t:un}static create(e,t){return t.length?Wo(t,e,0,Pt):re}find(e,t,o){let s=[];return this.findInner(e??0,t??1e9,s,0,o),s}findInner(e,t,o,s,i){for(let r=0;r<this.local.length;r++){let l=this.local[r];l.from<=t&&l.to>=e&&(!i||i(l.spec))&&o.push(l.copy(l.from+s,l.to+s))}for(let r=0;r<this.children.length;r+=3)if(this.children[r]<t&&this.children[r+1]>e){let l=this.children[r]+1;this.children[r+2].findInner(e-l,t-l,o,s+l,i)}}map(e,t,o){return this==re||e.maps.length==0?this:this.mapInner(e,t,0,0,o||Pt)}mapInner(e,t,o,s,i){let r;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,o,s);a&&a.type.valid(t,a)?(r||(r=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?Zm(this.children,r||[],e,t,o,s,i):r?new q(r.sort(It),un):re}add(e,t){return t.length?this==re?q.create(e,t):this.addInner(e,t,0):this}addInner(e,t,o){let s,i=0;e.forEach((l,a)=>{let c=a+o,d;if(d=bc(t,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,d,c+1):s.splice(i,0,a,a+l.nodeSize,Wo(d,l,c+1,Pt)),i+=3}});let r=yc(i?vc(t):t,-o);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||r.splice(l--,1);return new q(r.length?this.local.concat(r).sort(It):this.local,s||this.children)}remove(e){return e.length==0||this==re?this:this.removeInner(e,0)}removeInner(e,t){let o=this.children,s=this.local;for(let i=0;i<o.length;i+=3){let r,l=o[i]+t,a=o[i+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(r||(r=[])).push(u));if(!r)continue;o==this.children&&(o=this.children.slice());let c=o[i+2].removeInner(r,l+1);c!=re?o[i+2]=c:(o.splice(i,3),i-=3)}if(s.length){for(let i=0,r;i<e.length;i++)if(r=e[i])for(let l=0;l<s.length;l++)s[l].eq(r,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return o==this.children&&s==this.local?this:s.length||o.length?new q(s,o):re}forChild(e,t){if(this==re)return this;if(t.isLeaf)return q.empty;let o,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(o=this.children[l+2]);break}let i=e+1,r=i+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<r&&a.to>i&&a.type instanceof st){let c=Math.max(i,a.from)-i,d=Math.min(r,a.to)-i;c<d&&(s||(s=[])).push(a.copy(c,d))}}if(s){let l=new q(s.sort(It),un);return o?new it([l,o]):l}return o||re}eq(e){if(this==e)return!0;if(!(e instanceof q)||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 Ci(this.localsInner(e))}localsInner(e){if(this==re)return un;if(e.inlineContent||!this.local.some(st.is))return this.local;let t=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof st||t.push(this.local[o]);return t}forEachSet(e){e(this)}}q.empty=new q([],[]),q.removeOverlap=Ci;const re=q.empty;class it{constructor(e){this.members=e}map(e,t){const o=this.members.map(s=>s.map(e,t,Pt));return it.from(o)}forChild(e,t){if(t.isLeaf)return q.empty;let o=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,t);i!=re&&(i instanceof it?o=o.concat(i.members):o.push(i))}return it.from(o)}eq(e){if(!(e instanceof it)||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,o=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!t)t=i;else{o&&(t=t.slice(),o=!1);for(let r=0;r<i.length;r++)t.push(i[r])}}return t?Ci(o?t:t.sort(It)):un}static from(e){switch(e.length){case 0:return re;case 1:return e[0];default:return new it(e.every(t=>t instanceof q)?e:e.reduce((t,o)=>t.concat(o instanceof q?o:o.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Zm(n,e,t,o,s,i,r){let l=n.slice();for(let c=0,d=i;c<t.maps.length;c++){let u=0;t.maps[c].forEach((h,p,f,m)=>{let g=m-f-(p-h);for(let b=0;b<l.length;b+=3){let w=l[b+1];if(w<0||h>w+d-u)continue;let y=l[b]+d-u;p>=y?l[b+1]=h<=y?-2:-1:h>=d&&g&&(l[b]+=g,l[b+1]+=g)}u+=g}),d=t.maps[c].map(d,-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 d=t.map(n[c]+i),u=d-s;if(u<0||u>=o.content.size){a=!0;continue}let h=t.map(n[c+1]+i,-1),p=h-s,{index:f,offset:m}=o.content.findIndex(u),g=o.maybeChild(f);if(g&&m==u&&m+g.nodeSize==p){let b=l[c+2].mapInner(t,g,d+1,n[c]+i+1,r);b!=re?(l[c]=u,l[c+1]=p,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Xm(l,n,e,t,s,i,r),d=Wo(c,o,0,r);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,h=0;u<d.children.length;u+=3){let p=d.children[u];for(;h<l.length&&l[h]<p;)h+=3;l.splice(h,0,d.children[u],d.children[u+1],d.children[u+2])}}return new q(e.sort(It),l)}function yc(n,e){if(!e||!n.length)return n;let t=[];for(let o=0;o<n.length;o++){let s=n[o];t.push(new fe(s.from+e,s.to+e,s.type))}return t}function Xm(n,e,t,o,s,i,r){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(o,s,c);u?t.push(u):r.onRemove&&r.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+i+1);return t}function bc(n,e,t){if(e.isLeaf)return null;let o=t+e.nodeSize,s=null;for(let i=0,r;i<n.length;i++)(r=n[i])&&r.from>t&&r.to<o&&((s||(s=[])).push(r),n[i]=null);return s}function vc(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Wo(n,e,t,o){let s=[],i=!1;e.forEach((l,a)=>{let c=bc(n,l,a+t);if(c){i=!0;let d=Wo(c,l,t+a+1,o);d!=re&&s.push(a,a+l.nodeSize,d)}});let r=yc(i?vc(n):n,-t).sort(It);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||(o.onRemove&&o.onRemove(r[l].spec),r.splice(l--,1));return r.length||s.length?new q(r,s):re}function It(n,e){return n.from-e.from||n.to-e.to}function Ci(n){let e=n;for(let t=0;t<e.length-1;t++){let o=e[t];if(o.from!=o.to)for(let s=t+1;s<e.length;s++){let i=e[s];if(i.from==o.from){i.to!=o.to&&(e==n&&(e=n.slice()),e[s]=i.copy(i.from,o.to),xc(e,s+1,i.copy(o.to,i.to)));continue}else{i.from<o.to&&(e==n&&(e=n.slice()),e[t]=o.copy(o.from,i.from),xc(e,s,o.copy(i.from,o.to)));break}}}return e}function xc(n,e,t){for(;e<n.length&&It(t,n[e])>0;)e++;n.splice(e,0,t)}function ki(n){let e=[];return n.someProp("decorations",t=>{let o=t(n.state);o&&o!=re&&e.push(o)}),n.cursorWrapper&&e.push(q.create(n.state.doc,[n.cursorWrapper.deco])),it.from(e)}const Qm={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},eg=pe&&Qe<=11;class tg{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 ng{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new tg,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(o=>{for(let s=0;s<o.length;s++)this.queue.push(o[s]);pe&&Qe<=11&&o.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),eg&&(this.onCharData=o=>{this.queue.push({target:o.target,type:"characterData",oldValue:o.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,Qm)),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(Ka(this.view)){if(this.suppressingSelectionUpdates)return He(this.view);if(pe&&Qe<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Mt(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,o;for(let i=e.focusNode;i;i=Pn(i))t.add(i);for(let i=e.anchorNode;i;i=Pn(i))if(t.has(i)){o=i;break}let s=o&&this.view.docView.nearestDesc(o);if(s&&s.ignoreMutation({type:"selection",target:o.nodeType==3?o.parentNode:o}))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 o=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(o)&&Ka(e)&&!this.ignoreSelectionChange(o),i=-1,r=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(i=i<0?u.from:Math.min(u.from,i),r=r<0?u.to:Math.max(u.to,r),u.typeOver&&(l=!0))}if(ke&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,h]=d;u.parentNode&&u.parentNode.parentNode==h.parentNode?h.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let h of d){let p=h.parentNode;p&&p.nodeName=="LI"&&(!u||ig(e,u)!=p)&&h.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Vo(o)&&(c=ui(e))&&c.eq(D.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,He(e),this.currentSelection.set(o),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,r),og(e)),this.handleDOMChange(i,r,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(o)||He(e),this.currentSelection.set(o))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let o=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(o==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!o||o.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(e.target))return{from:o.posBefore,to:o.posAfter};let s=e.previousSibling,i=e.nextSibling;if(pe&&Qe<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:h}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h)}let r=s&&s.parentNode==e.target?ee(s)+1:0,l=o.localPosFromDOM(e.target,r,-1),a=i&&i.parentNode==e.target?ee(i):e.target.childNodes.length,c=o.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}:(this.lastChangedTextNode=e.target,{from:o.posAtStart,to:o.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Sc=new WeakMap,wc=!1;function og(n){if(!Sc.has(n)&&(Sc.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=ke,wc)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."),wc=!0}}function Cc(n,e){let t=e.startContainer,o=e.startOffset,s=e.endContainer,i=e.endOffset,r=n.domAtPos(n.state.selection.anchor);return Mt(r.node,r.offset,s,i)&&([t,o,s,i]=[s,i,t,o]),{anchorNode:t,anchorOffset:o,focusNode:s,focusOffset:i}}function sg(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return Cc(n,s)}let t;function o(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",o,!0),t?Cc(n,t):null}function ig(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let o=n.docView.nearestDesc(t,!0);if(o&&o.node.isBlock)return t}return null}function rg(n,e,t){let{node:o,fromOffset:s,toOffset:i,from:r,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],Vo(a)||c.push({node:a.focusNode,offset:a.focusOffset})),ie&&n.input.lastKeyCode===8)for(let g=i;g>s;g--){let b=o.childNodes[g-1],w=b.pmViewDesc;if(b.nodeName=="BR"&&!w){i=g;break}if(!w||w.size)break}let u=n.state.doc,h=n.someProp("domParser")||Zt.fromSchema(n.state.schema),p=u.resolve(r),f=null,m=h.parse(o,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:s,to:i,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:lg,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),f={anchor:g+r,head:b+r}}return{doc:m,sel:f,from:r,to:l}}function lg(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(ae&&/^(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||ae&&/^(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 ag=/^(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 cg(n,e,t,o,s){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let T=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,M=ui(n,T);if(M&&!n.state.selection.eq(M)){if(ie&&Te&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",I=>I(n,At(13,"Enter"))))return;let N=n.state.tr.setSelection(M);T=="pointer"?N.setMeta("pointer",!0):T=="key"&&N.scrollIntoView(),i&&N.setMeta("composition",i),n.dispatch(N)}return}let r=n.state.doc.resolve(e),l=r.sharedDepth(t);e=r.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=rg(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),h,p;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(h=n.state.selection.to,p="end"):(h=n.state.selection.from,p="start"),n.input.lastKeyCode=null;let f=hg(u.content,c.doc.content,c.from,h,p);if(f&&n.input.domChangeCount++,(ln&&n.input.lastIOSEnter>Date.now()-225||Te)&&s.some(T=>T.nodeType==1&&!ag.test(T.nodeName))&&(!f||f.endA>=f.endB)&&n.someProp("handleKeyDown",T=>T(n,At(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!f)if(o&&a instanceof L&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))f={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let T=kc(n,n.state.doc,c.sel);if(T&&!T.eq(n.state.selection)){let M=n.state.tr.setSelection(T);i&&M.setMeta("composition",i),n.dispatch(M)}}return}n.state.selection.from<n.state.selection.to&&f.start==f.endB&&n.state.selection instanceof L&&(f.start>n.state.selection.from&&f.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?f.start=n.state.selection.from:f.endA<n.state.selection.to&&f.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(f.endB+=n.state.selection.to-f.endA,f.endA=n.state.selection.to)),pe&&Qe<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>c.from&&c.doc.textBetween(f.start-c.from-1,f.start-c.from+1)==" "&&(f.start--,f.endA--,f.endB--);let m=c.doc.resolveNoCache(f.start-c.from),g=c.doc.resolveNoCache(f.endB-c.from),b=d.resolve(f.start),w=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=f.endA,y;if((ln&&n.input.lastIOSEnter>Date.now()-225&&(!w||s.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!w&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(y=D.findFrom(c.doc.resolve(m.pos+1),1,!0))&&y.head==g.pos)&&n.someProp("handleKeyDown",T=>T(n,At(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>f.start&&ug(d,f.start,f.endA,m,g)&&n.someProp("handleKeyDown",T=>T(n,At(8,"Backspace")))){Te&&ie&&n.domObserver.suppressSelectionUpdates();return}ie&&Te&&f.endB==f.start&&(n.input.lastAndroidDelete=Date.now()),Te&&!w&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==f.endA&&(f.endB-=2,g=c.doc.resolveNoCache(f.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(T){return T(n,At(13,"Enter"))})},20));let v=f.start,x=f.endA,S,C,A;if(w){if(m.pos==g.pos)pe&&Qe<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>He(n),20)),S=n.state.tr.delete(v,x),C=d.resolve(f.start).marksAcross(d.resolve(f.endA));else if(f.endA==f.endB&&(A=dg(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,f.endA-b.start()))))S=n.state.tr,A.type=="add"?S.addMark(v,x,A.mark):S.removeMark(v,x,A.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let T=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",M=>M(n,v,x,T)))return;S=n.state.tr.insertText(T,v,x)}}if(S||(S=n.state.tr.replace(v,x,c.doc.slice(f.start-c.from,f.endB-c.from))),c.sel){let T=kc(n,S.doc,c.sel);T&&!(ie&&Te&&n.composing&&T.empty&&(f.start!=f.endB||n.input.lastAndroidDelete<Date.now()-100)&&(T.head==v||T.head==S.mapping.map(x)-1)||pe&&T.empty&&T.head==v)&&S.setSelection(T)}C&&S.ensureMarks(C),i&&S.setMeta("composition",i),n.dispatch(S.scrollIntoView())}function kc(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:pi(n,e.resolve(t.anchor),e.resolve(t.head))}function dg(n,e){let t=n.firstChild.marks,o=e.firstChild.marks,s=t,i=o,r,l,a;for(let d=0;d<o.length;d++)s=o[d].removeFromSet(s);for(let d=0;d<t.length;d++)i=t[d].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],r="add",a=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&i.length==1)l=i[0],r="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(k.from(c).eq(n))return{mark:l,type:r}}function ug(n,e,t,o,s){if(t-e<=s.pos-o.pos||Ti(o,!0,!1)<s.pos)return!1;let i=n.resolve(e);if(!o.parent.isTextblock){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let r=n.resolve(Ti(i,!0,!0));return!r.parent.isTextblock||r.pos>t||Ti(r,!0,!1)<t?!1:o.parent.content.cut(o.parentOffset).eq(r.parent.content)}function Ti(n,e,t){let o=n.depth,s=e?n.end():n.pos;for(;o>0&&(e||n.indexAfter(o)==n.node(o).childCount);)o--,s++,e=!1;if(t){let i=n.node(o).maybeChild(n.indexAfter(o));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function hg(n,e,t,o,s){let i=n.findDiffStart(e,t);if(i==null)return null;let{a:r,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,i-Math.min(r,l));o-=r+a-i}if(r<i&&n.size<e.size){let a=o<=i&&o>=r?i-o:0;i-=a,i&&i<e.size&&Tc(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-r),r=i}else if(l<i){let a=o<=i&&o>=l?i-o:0;i-=a,i&&i<n.size&&Tc(n.textBetween(i-1,i+1))&&(i+=a?1:-1),r=i+(r-l),l=i}return{start:i,endA:r,endB:l}}function Tc(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 pg{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 Im,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Oc),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=Ec(this),Ac(this),this.nodeViews=Nc(this),this.docView=La(this.state.doc,Mc(this),ki(this),this.dom,this),this.domObserver=new ng(this,(o,s,i,r)=>cg(this,o,s,i,r)),this.domObserver.start(),Rm(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&&bi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Oc),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let o in this._props)t[o]=this._props[o];t.state=this.state;for(let o in e)t[o]=e[o];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var o;let s=this.state,i=!1,r=!1;e.storedMarks&&this.composing&&(pc(this),r=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=Nc(this);mg(p,this.nodeViews)&&(this.nodeViews=p,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&bi(this),this.editable=Ec(this),Ac(this);let a=ki(this),c=Mc(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(s.selection))&&(r=!0);let h=d=="preserve"&&r&&this.dom.style.overflowAnchor==null&&Kf(this);if(r){this.domObserver.stop();let p=u&&(pe||ie)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&fg(s.selection,e.selection);if(u){let f=ie?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=qm(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=La(e.doc,c,a,this.dom,this)),f&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&ym(this))?He(this,p):(ja(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((o=this.dragging)===null||o===void 0)&&o.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():h&&Uf(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof R){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&wa(this,t.getBoundingClientRect(),e)}else wa(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 o=this.directPlugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let o=this.state.plugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let o=this.pluginViews[t];o.update&&o.update(this,e)}}updateDraggedNode(e,t){let o=e.node,s=-1;if(this.state.doc.nodeAt(o.from)==o.node)s=o.from;else{let i=o.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==o.node&&(s=i)}this.dragging=new mc(e.slice,e.move,s<0?void 0:R.create(this.state.doc,s))}someProp(e,t){let o=this._props&&this._props[e],s;if(o!=null&&(s=t?t(o):o))return s;for(let r=0;r<this.directPlugins.length;r++){let l=this.directPlugins[r].props[e];if(l!=null&&(s=t?t(l):l))return s}let i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let l=i[r].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(pe){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&&Jf(this.dom),He(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 em(this,e)}coordsAtPos(e,t=1){return Ea(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,o=-1){let s=this.docView.posFromDOM(e,t,o);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,t){return im(this,t||this.state,e)}pasteHTML(e,t){return Bn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Bn(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Dm(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ki(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,zf())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return zm(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?ae&&this.root.nodeType===11&&Ff(this.dom.ownerDocument)==this.dom&&sg(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Mc(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 o in t)o=="class"?e.class+=" "+t[o]:o=="style"?e.style=(e.style?e.style+";":"")+t[o]:!e[o]&&o!="contenteditable"&&o!="nodeName"&&(e[o]=String(t[o]))}),e.translate||(e.translate="no"),[fe.node(0,n.state.doc.content.size,e)]}function Ac(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:fe.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Ec(n){return!n.someProp("editable",e=>e(n.state)===!1)}function fg(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 Nc(n){let e=Object.create(null);function t(o){for(let s in o)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=o[s])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function mg(n,e){let t=0,o=0;for(let s in n){if(n[s]!=e[s])return!0;t++}for(let s in e)o++;return t!=o}function Oc(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 Mi,Ai;if(typeof WeakMap<"u"){let n=new WeakMap;Mi=e=>n.get(e),Ai=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Mi=o=>{for(let s=0;s<n.length;s+=2)if(n[s]==o)return n[s+1]},Ai=(o,s)=>(t==10&&(t=0),n[t++]=o,n[t++]=s)}var U=class{constructor(n,e,t,o){this.width=n,this.height=e,this.map=t,this.problems=o}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const o=e%this.width,s=e/this.width|0;let i=o+1,r=s+1;for(let l=1;i<this.width&&this.map[e+l]==t;l++)i++;for(let l=1;r<this.height&&this.map[e+this.width*l]==t;l++)r++;return{left:o,top:s,right:i,bottom:r}}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:o,right:s,top:i,bottom:r}=this.findCell(n);return e=="horiz"?(t<0?o==0:s==this.width)?null:this.map[i*this.width+(t<0?o-1:s)]:(t<0?i==0:r==this.height)?null:this.map[o+this.width*(t<0?i-1:r)]}rectBetween(n,e){const{left:t,right:o,top:s,bottom:i}=this.findCell(n),{left:r,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,r),top:Math.min(s,a),right:Math.max(o,l),bottom:Math.max(i,c)}}cellsInRect(n){const e=[],t={};for(let o=n.top;o<n.bottom;o++)for(let s=n.left;s<n.right;s++){const i=o*this.width+s,r=this.map[i];t[r]||(t[r]=!0,!(s==n.left&&s&&this.map[i-1]==r||o==n.top&&o&&this.map[i-this.width]==r)&&e.push(r))}return e}positionAt(n,e,t){for(let o=0,s=0;;o++){const i=s+t.child(o).nodeSize;if(o==n){let r=e+n*this.width;const l=(n+1)*this.width;for(;r<l&&this.map[r]<s;)r++;return r==l?i-1:this.map[r]}s=i}}static get(n){return Mi(n)||Ai(n,gg(n))}};function gg(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=yg(n),t=n.childCount,o=[];let s=0,i=null;const r=[];for(let c=0,d=e*t;c<d;c++)o[c]=0;for(let c=0,d=0;c<t;c++){const u=n.child(c);d++;for(let f=0;;f++){for(;s<o.length&&o[s]!=0;)s++;if(f==u.childCount)break;const m=u.child(f),{colspan:g,rowspan:b,colwidth:w}=m.attrs;for(let y=0;y<b;y++){if(y+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:b-y});break}const v=s+y*e;for(let x=0;x<g;x++){o[v+x]==0?o[v+x]=d:(i||(i=[])).push({type:"collision",row:c,pos:d,n:g-x});const S=w&&w[x];if(S){const C=(v+x)%e*2,A=r[C];A==null||A!=S&&r[C+1]==1?(r[C]=S,r[C+1]=1):A==S&&r[C+1]++}}}s+=g,d+=m.nodeSize}const h=(c+1)*e;let p=0;for(;s<h;)o[s++]==0&&p++;p&&(i||(i=[])).push({type:"missing",row:c,n:p}),d++}const l=new U(e,t,o,i);let a=!1;for(let c=0;!a&&c<r.length;c+=2)r[c]!=null&&r[c+1]<t&&(a=!0);return a&&bg(l,r,n),l}function yg(n){let e=-1,t=!1;for(let o=0;o<n.childCount;o++){const s=n.child(o);let i=0;if(t)for(let r=0;r<o;r++){const l=n.child(r);for(let a=0;a<l.childCount;a++){const c=l.child(a);r+c.attrs.rowspan>o&&(i+=c.attrs.colspan)}}for(let r=0;r<s.childCount;r++){const l=s.child(r);i+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function bg(n,e,t){n.problems||(n.problems=[]);const o={};for(let s=0;s<n.map.length;s++){const i=n.map[s];if(o[i])continue;o[i]=!0;const r=t.nodeAt(i);if(!r)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=r.attrs;for(let c=0;c<a.colspan;c++){const d=(s+c)%n.width,u=e[d*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=vg(a)))[c]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function vg(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Pc(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),o=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(r=>Number(r)):null,s=Number(n.getAttribute("colspan")||1),i={colspan:s,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:o&&o.length==s?o:null};for(const r in e){const l=e[r].getFromDOM,a=l&&l(n);a!=null&&(i[r]=a)}return i}function Ic(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 o in e){const s=e[o].setDOMAttr;s&&s(n.attrs[o],t)}return t}function xg(n){const e=n.cellAttributes||{},t={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const o in e)t[o]={default:e[o].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:o=>Pc(o,e)}],toDOM(o){return["td",Ic(o,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:o=>Pc(o,e)}],toDOM(o){return["th",Ic(o,e),0]}}}}function Re(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const o=n.nodes[t],s=o.spec.tableRole;s&&(e[s]=o)}}return e}var rt=new Nn("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 jo(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 Ei(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)||Sg(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Sg(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const o=e.type.spec.tableRole;if(o=="cell"||o=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const o=e.type.spec.tableRole;if(o=="cell"||o=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function Ni(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function wg(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Oi(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Rc(n,e,t){const o=n.node(-1),s=U.get(o),i=n.start(-1),r=s.nextCell(n.pos-i,e,t);return r==null?null:n.node(0).resolve(i+r)}function hn(n,e,t=1){const o={...n,colspan:n.colspan-t};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(e,t),o.colwidth.some(s=>s>0)||(o.colwidth=null)),o}var Y=class We extends D{constructor(e,t=e){const o=e.node(-1),s=U.get(o),i=e.start(-1),r=s.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=s.cellsInRect(r).filter(d=>d!=t.pos-i);a.unshift(t.pos-i);const c=a.map(d=>{const u=o.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);const h=i+d+1;return new jl(l.resolve(h),l.resolve(h+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const o=e.resolve(t.map(this.$anchorCell.pos)),s=e.resolve(t.map(this.$headCell.pos));if(Ni(o)&&Ni(s)&&Oi(o,s)){const i=this.$anchorCell.node(-1)!=o.node(-1);return i&&this.isRowSelection()?We.rowSelection(o,s):i&&this.isColSelection()?We.colSelection(o,s):new We(o,s)}return L.between(o,s)}content(){const e=this.$anchorCell.node(-1),t=U.get(e),o=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),i={},r=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let d=a*t.width+s.left,u=s.left;u<s.right;u++,d++){const h=t.map[d];if(i[h])continue;i[h]=!0;const p=t.findCell(h);let f=e.nodeAt(h);if(!f)throw RangeError(`No cell with offset ${h} found`);const m=s.left-p.left,g=p.right-s.right;if(m>0||g>0){let b=f.attrs;if(m>0&&(b=hn(b,0,m)),g>0&&(b=hn(b,b.colspan-g,g)),p.left<s.left){if(f=f.type.createAndFill(b),!f)throw RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else f=f.type.create(b,f.content)}if(p.top<s.top||p.bottom>s.bottom){const b={...f.attrs,rowspan:Math.min(p.bottom,s.bottom)-Math.max(p.top,s.top)};p.top<s.top?f=f.type.createAndFill(b):f=f.type.create(b,f.content)}c.push(f)}r.push(e.child(a).copy(k.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:r;return new E(k.from(l),1,1)}replace(e,t=E.empty){const o=e.steps.length,s=this.ranges;for(let r=0;r<s.length;r++){const{$from:l,$to:a}=s[r],c=e.mapping.slice(o);e.replace(c.map(l.pos),c.map(a.pos),r?E.empty:t)}const i=D.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new E(k.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),o=U.get(t),s=this.$anchorCell.start(-1),i=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let r=0;r<i.length;r++)e(t.nodeAt(i[r]),s+i[r])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const o=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const o=e.node(-1),s=U.get(o),i=e.start(-1),r=s.findCell(e.pos-i),l=s.findCell(t.pos-i),a=e.node(0);return r.top<=l.top?(r.top>0&&(e=a.resolve(i+s.map[r.left])),l.bottom<s.height&&(t=a.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(i+s.map[l.left])),r.bottom<s.height&&(e=a.resolve(i+s.map[s.width*(s.height-1)+r.right-1]))),new We(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=U.get(e),o=this.$anchorCell.start(-1),s=t.colCount(this.$anchorCell.pos-o),i=t.colCount(this.$headCell.pos-o);if(Math.min(s,i)>0)return!1;const r=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(r,l)==t.width}eq(e){return e instanceof We&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const o=e.node(-1),s=U.get(o),i=e.start(-1),r=s.findCell(e.pos-i),l=s.findCell(t.pos-i),a=e.node(0);return r.left<=l.left?(r.left>0&&(e=a.resolve(i+s.map[r.top*s.width])),l.right<s.width&&(t=a.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(i+s.map[l.top*s.width])),r.right<s.width&&(e=a.resolve(i+s.map[s.width*(r.top+1)-1]))),new We(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new We(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){return new We(e.resolve(t),e.resolve(o))}getBookmark(){return new Cg(this.$anchorCell.pos,this.$headCell.pos)}};Y.prototype.visible=!1,D.jsonID("cell",Y);var Cg=class Id{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Id(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),o=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&o.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&o.index()<o.parent.childCount&&Oi(t,o)?new Y(t,o):D.near(o,1)}};function kg(n){if(!(n.selection instanceof Y))return null;const e=[];return n.selection.forEachCell((t,o)=>{e.push(fe.node(o,o+t.nodeSize,{class:"selectedCell"}))}),q.create(n.doc,e)}function Tg({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,o=e.pos,s=n.depth;for(;s>=0&&!(n.after(s+1)<n.end(s));s--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,o--);return t==o&&/row|table/.test(n.node(s).type.spec.tableRole)}function Mg({$from:n,$to:e}){let t,o;for(let s=n.depth;s>0;s--){const i=n.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){o=i;break}}return t!==o&&e.parentOffset===0}function Ag(n,e,t){const o=(e||n).selection,s=(e||n).doc;let i,r;if(o instanceof R&&(r=o.node.type.spec.tableRole)){if(r=="cell"||r=="header_cell")i=Y.create(s,o.from);else if(r=="row"){const l=s.resolve(o.from+1);i=Y.rowSelection(l,l)}else if(!t){const l=U.get(o.node),a=o.from+1,c=a+l.map[l.width*l.height-1];i=Y.create(s,a+1,c)}}else o instanceof L&&Tg(o)?i=L.create(s,o.from):o instanceof L&&Mg(o)&&(i=L.create(s,o.$from.start(),o.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}var Eg=new Nn("fix-tables");function Dc(n,e,t,o){const s=n.childCount,i=e.childCount;e:for(let r=0,l=0;r<i;r++){const a=e.child(r);for(let c=l,d=Math.min(s,r+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}o(a,t),l<s&&n.child(l).sameMarkup(a)?Dc(n.child(l),a,t+1,o):a.nodesBetween(0,a.content.size,o,t+1),t+=a.nodeSize}}function Ng(n,e){let t;const o=(s,i)=>{s.type.spec.tableRole=="table"&&(t=Og(n,s,i,t))};return e?e.doc!=n.doc&&Dc(e.doc,n.doc,0,o):n.doc.descendants(o),t}function Og(n,e,t,o){const s=U.get(e);if(!s.problems)return o;o||(o=n.tr);const i=[];for(let a=0;a<s.height;a++)i.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let h=0;h<u.rowspan;h++)i[c.row+h]+=c.n;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,hn(u,u.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}}let r,l;for(let a=0;a<i.length;a++)i[a]&&(r==null&&(r=a),l=a);for(let a=0,c=t+1;a<s.height;a++){const d=e.child(a),u=c+d.nodeSize,h=i[a];if(h>0){let p="cell";d.firstChild&&(p=d.firstChild.type.spec.tableRole);const f=[];for(let g=0;g<h;g++){const b=Re(n.schema)[p].createAndFill();b&&f.push(b)}const m=(a==0||r==a-1)&&l==a?c+1:u-1;o.insert(o.mapping.map(m),f)}c=u}return o.setMeta(Eg,{fixTables:!0})}function Lc(n){const e=n.selection,t=Ei(n),o=t.node(-1),s=t.start(-1),i=U.get(o);return{...e instanceof Y?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(t.pos-s),tableStart:s,map:i,table:o}}function Pg(n){return function(e,t){if(!jo(e))return!1;if(t){const o=Re(e.schema),s=Lc(e),i=e.tr,r=s.map.cellsInRect(n=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:n=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=r.map(a=>s.table.nodeAt(a));for(let a=0;a<r.length;a++)l[a].type==o.header_cell&&i.setNodeMarkup(s.tableStart+r[a],o.cell,l[a].attrs);if(i.steps.length==0)for(let a=0;a<r.length;a++)i.setNodeMarkup(s.tableStart+r[a],o.header_cell,l[a].attrs);t(i)}return!0}}function zc(n,e,t){const o=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let s=0;s<o.length;s++){const i=e.table.nodeAt(o[s]);if(i&&i.type!==t.header_cell)return!1}return!0}function Pi(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Pg(n):function(t,o){if(!jo(t))return!1;if(o){const s=Re(t.schema),i=Lc(t),r=t.tr,l=zc("row",i,s),a=zc("column",i,s),d=(n==="column"?l:n==="row"?a:!1)?1:0,u=n=="column"?{left:0,top:d,right:1,bottom:i.map.height}:n=="row"?{left:d,top:0,right:i.map.width,bottom:1}:i,h=n=="column"?a?s.cell:s.header_cell:n=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(u).forEach(p=>{const f=p+i.tableStart,m=r.doc.nodeAt(f);m&&r.setNodeMarkup(f,h,m.attrs)}),o(r)}return!0}}Pi("row",{useDeprecatedLogic:!0}),Pi("column",{useDeprecatedLogic:!0}),Pi("cell",{useDeprecatedLogic:!0});function Ig(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let o=n.index(-1)-1,s=n.before();o>=0;o--){const i=n.node(-1).child(o),r=i.lastChild;if(r)return s-1-r.nodeSize;s-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let o=n.indexAfter(-1),s=n.after();o<t.childCount;o++){const i=t.child(o);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function Vc(n){return function(e,t){if(!jo(e))return!1;const o=Ig(Ei(e),n);if(o==null)return!1;if(t){const s=e.doc.resolve(o);t(e.tr.setSelection(L.between(s,wg(s))).scrollIntoView())}return!0}}function qo(n,e){const t=n.selection;if(!(t instanceof Y))return!1;if(e){const o=n.tr,s=Re(n.schema).cell.createAndFill().content;t.forEachCell((i,r)=>{i.content.eq(s)||o.replace(o.mapping.map(r+1),o.mapping.map(r+i.nodeSize-1),new E(s,0,0))}),o.docChanged&&e(o)}return!0}function Rg(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:o}=n;for(;e.childCount==1&&(t>0&&o>0||e.child(0).type.spec.tableRole=="table");)t--,o--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,r=s.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),u=a<e.childCount-1?0:Math.max(0,o-1);(d||u)&&(c=Ii(Re(r).row,new E(c,d,u)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||o?Ii(Re(r).row,new E(e,t,o)).content:e);else return null;return Dg(r,l)}function Dg(n,e){const t=[];for(let s=0;s<e.length;s++){const i=e[s];for(let r=i.childCount-1;r>=0;r--){const{rowspan:l,colspan:a}=i.child(r).attrs;for(let c=s;c<s+l;c++)t[c]=(t[c]||0)+a}}let o=0;for(let s=0;s<t.length;s++)o=Math.max(o,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(k.empty),t[s]<o){const i=Re(n).cell.createAndFill(),r=[];for(let l=t[s];l<o;l++)r.push(i);e[s]=e[s].append(k.from(r))}return{height:e.length,width:o,rows:e}}function Ii(n,e){const t=n.createAndFill();return new Wl(t).replace(0,t.content.size,e).doc}function Lg({width:n,height:e,rows:t},o,s){if(n!=o){const i=[],r=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=i[l]||0,u=0;d<o;u++){let h=a.child(u%a.childCount);d+h.attrs.colspan>o&&(h=h.type.createChecked(hn(h.attrs,h.attrs.colspan,d+h.attrs.colspan-o),h.content)),c.push(h),d+=h.attrs.colspan;for(let p=1;p<h.attrs.rowspan;p++)i[l+p]=(i[l+p]||0)+h.attrs.colspan}r.push(k.from(c))}t=r,n=o}if(e!=s){const i=[];for(let r=0,l=0;r<s;r++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);r+u.attrs.rowspan>s&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,s-u.attrs.rowspan)},u.content)),a.push(u)}i.push(k.from(a))}t=i,e=s}return{width:n,height:e,rows:t}}function zg(n,e,t,o,s,i,r){const l=n.doc.type.schema,a=Re(l);let c,d;if(s>e.width)for(let u=0,h=0;u<e.height;u++){const p=t.child(u);h+=p.nodeSize;const f=[];let m;p.lastChild==null||p.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=d||(d=a.header_cell.createAndFill());for(let g=e.width;g<s;g++)f.push(m);n.insert(n.mapping.slice(r).map(h-1+o),f)}if(i>e.height){const u=[];for(let f=0,m=(e.height-1)*e.width;f<Math.max(e.width,s);f++){const g=f>=e.width?!1:t.nodeAt(e.map[m+f]).type==a.header_cell;u.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const h=a.row.create(null,k.from(u)),p=[];for(let f=e.height;f<i;f++)p.push(h);n.insert(n.mapping.slice(r).map(o+t.nodeSize-2),p)}return!!(c||d)}function $c(n,e,t,o,s,i,r,l){if(r==0||r==e.height)return!1;let a=!1;for(let c=s;c<i;c++){const d=r*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){a=!0;const h=t.nodeAt(u),{top:p,left:f}=e.findCell(u);n.setNodeMarkup(n.mapping.slice(l).map(u+o),null,{...h.attrs,rowspan:r-p}),n.insert(n.mapping.slice(l).map(e.positionAt(r,f,t)),h.type.createAndFill({...h.attrs,rowspan:p+h.attrs.rowspan-r})),c+=h.attrs.colspan-1}}return a}function Bc(n,e,t,o,s,i,r,l){if(r==0||r==e.width)return!1;let a=!1;for(let c=s;c<i;c++){const d=c*e.width+r,u=e.map[d];if(e.map[d-1]==u){a=!0;const h=t.nodeAt(u),p=e.colCount(u),f=n.mapping.slice(l).map(u+o);n.setNodeMarkup(f,null,hn(h.attrs,r-p,h.attrs.colspan-(r-p))),n.insert(f+h.nodeSize,h.type.createAndFill(hn(h.attrs,0,r-p))),c+=h.attrs.rowspan-1}}return a}function Hc(n,e,t,o,s){let i=t?n.doc.nodeAt(t-1):n.doc;if(!i)throw new Error("No table found");let r=U.get(i);const{top:l,left:a}=o,c=a+s.width,d=l+s.height,u=n.tr;let h=0;function p(){if(i=t?u.doc.nodeAt(t-1):u.doc,!i)throw new Error("No table found");r=U.get(i),h=u.mapping.maps.length}zg(u,r,i,t,c,d,h)&&p(),$c(u,r,i,t,a,c,l,h)&&p(),$c(u,r,i,t,a,c,d,h)&&p(),Bc(u,r,i,t,l,d,a,h)&&p(),Bc(u,r,i,t,l,d,c,h)&&p();for(let f=l;f<d;f++){const m=r.positionAt(f,a,i),g=r.positionAt(f,c,i);u.replace(u.mapping.slice(h).map(m+t),u.mapping.slice(h).map(g+t),new E(s.rows[f-l],0,0))}p(),u.setSelection(new Y(u.doc.resolve(t+r.positionAt(l,a,i)),u.doc.resolve(t+r.positionAt(d-1,c-1,i)))),e(u)}var Vg=ga({ArrowLeft:Uo("horiz",-1),ArrowRight:Uo("horiz",1),ArrowUp:Uo("vert",-1),ArrowDown:Uo("vert",1),"Shift-ArrowLeft":Jo("horiz",-1),"Shift-ArrowRight":Jo("horiz",1),"Shift-ArrowUp":Jo("vert",-1),"Shift-ArrowDown":Jo("vert",1),Backspace:qo,"Mod-Backspace":qo,Delete:qo,"Mod-Delete":qo});function Ko(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Uo(n,e){return(t,o,s)=>{if(!s)return!1;const i=t.selection;if(i instanceof Y)return Ko(t,o,D.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;const r=Fc(s,n,e);if(r==null)return!1;if(n=="horiz")return Ko(t,o,D.near(t.doc.resolve(i.head+e),e));{const l=t.doc.resolve(r),a=Rc(l,n,e);let c;return a?c=D.near(a,1):e<0?c=D.near(t.doc.resolve(l.before(-1)),-1):c=D.near(t.doc.resolve(l.after(-1)),1),Ko(t,o,c)}}}function Jo(n,e){return(t,o,s)=>{if(!s)return!1;const i=t.selection;let r;if(i instanceof Y)r=i;else{const a=Fc(s,n,e);if(a==null)return!1;r=new Y(t.doc.resolve(a))}const l=Rc(r.$headCell,n,e);return l?Ko(t,o,new Y(r.$anchorCell,l)):!1}}function $g(n,e){const t=n.state.doc,o=Fn(t.resolve(e));return o?(n.dispatch(n.state.tr.setSelection(new Y(o))),!0):!1}function Bg(n,e,t){if(!jo(n.state))return!1;let o=Rg(t);const s=n.state.selection;if(s instanceof Y){o||(o={width:1,height:1,rows:[k.from(Ii(Re(n.state.schema).cell,t))]});const i=s.$anchorCell.node(-1),r=s.$anchorCell.start(-1),l=U.get(i).rectBetween(s.$anchorCell.pos-r,s.$headCell.pos-r);return o=Lg(o,l.right-l.left,l.bottom-l.top),Hc(n.state,n.dispatch,r,l,o),!0}else if(o){const i=Ei(n.state),r=i.start(-1);return Hc(n.state,n.dispatch,r,U.get(i.node(-1)).findCell(i.pos-r),o),!0}else return!1}function Hg(n,e){var t;if(e.ctrlKey||e.metaKey)return;const o=_c(n,e.target);let s;if(e.shiftKey&&n.state.selection instanceof Y)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(s=Fn(n.state.selection.$anchor))!=null&&((t=Ri(n,e))==null?void 0:t.pos)!=s.pos)i(s,e),e.preventDefault();else if(!o)return;function i(a,c){let d=Ri(n,c);const u=rt.getState(n.state)==null;if(!d||!Oi(a,d))if(u)d=a;else return;const h=new Y(a,d);if(u||!n.state.selection.eq(h)){const p=n.state.tr.setSelection(h);u&&p.setMeta(rt,a.pos),n.dispatch(p)}}function r(){n.root.removeEventListener("mouseup",r),n.root.removeEventListener("dragstart",r),n.root.removeEventListener("mousemove",l),rt.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(rt,-1))}function l(a){const c=a,d=rt.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(_c(n,c.target)!=o&&(u=Ri(n,e),!u))return r();u&&i(u,c)}n.root.addEventListener("mouseup",r),n.root.addEventListener("dragstart",r),n.root.addEventListener("mousemove",l)}function Fc(n,e,t){if(!(n.state.selection instanceof L))return null;const{$head:o}=n.state.selection;for(let s=o.depth-1;s>=0;s--){const i=o.node(s);if((t<0?o.index(s):o.indexAfter(s))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=o.before(s),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function _c(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Ri(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Fn(n.state.doc.resolve(t.pos)):null}var Fg=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")),Di(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,Di(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function Di(n,e,t,o,s,i){var r;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let u=0,h=0;u<d.childCount;u++){const{colspan:p,colwidth:f}=d.child(u).attrs;for(let m=0;m<p;m++,h++){const g=s==h?i:f&&f[m],b=g?g+"px":"";if(l+=g||o,g||(a=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const w=document.createElement("col");w.style.width=b,e.appendChild(w)}}}for(;c;){const u=c.nextSibling;(r=c.parentNode)==null||r.removeChild(c),c=u}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var ye=new Nn("tableColumnResizing");function _g({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:o=Fg,lastColumnResizable:s=!0}={}){const i=new En({key:ye,state:{init(r,l){var a,c;const d=(c=(a=i.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,u=Re(l.schema).table.name;return o&&d&&(d[u]=(h,p)=>new o(h,t,p)),new Gg(-1,!1)},apply(r,l){return l.apply(r)}},props:{attributes:r=>{const l=ye.getState(r);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(r,l)=>{Wg(r,l,n,s)},mouseleave:r=>{jg(r)},mousedown:(r,l)=>{qg(r,l,e,t)}},decorations:r=>{const l=ye.getState(r);if(l&&l.activeHandle>-1)return Zg(r,l.activeHandle)},nodeViews:{}}});return i}var Gg=class ns{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,o=e.getMeta(ye);if(o&&o.setHandle!=null)return new ns(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new ns(t.activeHandle,o.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);return Ni(e.doc.resolve(s))||(s=-1),new ns(s,t.dragging)}return t}};function Wg(n,e,t,o){const s=ye.getState(n.state);if(s&&!s.dragging){const i=Ug(e.target);let r=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?r=Gc(n,e,"left",t):a-e.clientX<=t&&(r=Gc(n,e,"right",t))}if(r!=s.activeHandle){if(!o&&r!==-1){const l=n.state.doc.resolve(r),a=l.node(-1),c=U.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}jc(n,r)}}}function jg(n){const e=ye.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&jc(n,-1)}function qg(n,e,t,o){var s;const i=(s=n.dom.ownerDocument.defaultView)!=null?s:window,r=ye.getState(n.state);if(!r||r.activeHandle==-1||r.dragging)return!1;const l=n.state.doc.nodeAt(r.activeHandle),a=Kg(n,r.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(ye,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const h=ye.getState(n.state);h!=null&&h.dragging&&(Jg(n,h.activeHandle,Wc(h.dragging,u,t)),n.dispatch(n.state.tr.setMeta(ye,{setDragging:null})))}function d(u){if(!u.which)return c(u);const h=ye.getState(n.state);if(h&&h.dragging){const p=Wc(h.dragging,u,t);qc(n,h.activeHandle,p,o)}}return qc(n,r.activeHandle,a,o),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function Kg(n,e,{colspan:t,colwidth:o}){const s=o&&o[o.length-1];if(s)return s;const i=n.domAtPos(e);let l=i.node.childNodes[i.offset].offsetWidth,a=t;if(o)for(let c=0;c<t;c++)o[c]&&(l-=o[c],a--);return l/a}function Ug(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Gc(n,e,t,o){const s=t=="right"?-o:o,i=n.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:r}=i,l=Fn(n.state.doc.resolve(r));if(!l)return-1;if(t=="right")return l.pos;const a=U.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function Wc(n,e,t){const o=e.clientX-n.startX;return Math.max(t,n.startWidth+o)}function jc(n,e){n.dispatch(n.state.tr.setMeta(ye,{setHandle:e}))}function Jg(n,e,t){const o=n.state.doc.resolve(e),s=o.node(-1),i=U.get(s),r=o.start(-1),l=i.colCount(o.pos-r)+o.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<i.height;c++){const d=c*i.width+l;if(c&&i.map[d]==i.map[d-i.width])continue;const u=i.map[d],h=s.nodeAt(u).attrs,p=h.colspan==1?0:l-i.colCount(u);if(h.colwidth&&h.colwidth[p]==t)continue;const f=h.colwidth?h.colwidth.slice():Yg(h.colspan);f[p]=t,a.setNodeMarkup(r+u,null,{...h,colwidth:f})}a.docChanged&&n.dispatch(a)}function qc(n,e,t,o){const s=n.state.doc.resolve(e),i=s.node(-1),r=s.start(-1),l=U.get(i).colCount(s.pos-r)+s.nodeAfter.attrs.colspan-1;let a=n.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Di(i,a.firstChild,a,o,l,t)}function Yg(n){return Array(n).fill(0)}function Zg(n,e){var t;const o=[],s=n.doc.resolve(e),i=s.node(-1);if(!i)return q.empty;const r=U.get(i),l=s.start(-1),a=r.colCount(s.pos-l)+s.nodeAfter.attrs.colspan-1;for(let c=0;c<r.height;c++){const d=a+c*r.width;if((a==r.width-1||r.map[d]!=r.map[d+1])&&(c==0||r.map[d]!=r.map[d-r.width])){const u=r.map[d],h=l+u+i.nodeAt(u).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",(t=ye.getState(n))!=null&&t.dragging&&o.push(fe.node(l+u,l+u+i.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),o.push(fe.widget(h,p))}}return q.create(n.doc,o)}function Xg({allowTableNodeSelection:n=!1}={}){return new En({key:rt,state:{init(){return null},apply(e,t){const o=e.getMeta(rt);if(o!=null)return o==-1?null:o;if(t==null||!e.docChanged)return t;const{deleted:s,pos:i}=e.mapping.mapResult(t);return s?null:i}},props:{decorations:kg,handleDOMEvents:{mousedown:Hg},createSelectionBetween(e){return rt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:$g,handleKeyDown:Vg,handlePaste:Bg},appendTransaction(e,t,o){return Ag(o,Ng(o,t),n)}})}const _n=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},Kc="data-gs-mrk-fs",Uc="data-gs-ib",Yo="data-gs-ifrg",Fe="attrs",Jc={[Fe]:{default:"{}"}},_e={[Fe]:{default:{}}},Yc=n=>({[Fe]:JSON.stringify(_n(n))}),Ge=n=>({attrs:_n(n)}),Gn=n=>e=>[n,e.attrs.attrs,0],lt=n=>n.attrs[Fe]?JSON.parse(n.attrs[Fe]):{},Qg={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${Yo}]`,getAttrs:Ge}],toDOM:()=>["span",{[Yo]:""},0]},div:{group:"block",content:"inline*",attrs:_e,parseDOM:[{tag:"div",getAttrs:Ge}],toDOM:Gn("div")},paragraph:{group:"block",content:"inline*",attrs:_e,parseDOM:[{tag:"p",getAttrs:Ge}],toDOM:Gn("p")},orderedList:{group:"block",content:"listItem+",attrs:_e,parseDOM:[{tag:"ol",getAttrs:Ge}],toDOM:Gn("ol")},bulletList:{group:"block",content:"listItem+",attrs:_e,parseDOM:[{tag:"ul",getAttrs:Ge}],toDOM:Gn("ul")},listItem:{content:"block*",group:"block",attrs:_e,parseDOM:[{tag:"li",getAttrs:Ge}],toDOM:Gn("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:_e,parseDOM:[{tag:"pre",getAttrs:Ge}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:_e,parseDOM:[{tag:"img[src]",getAttrs:Ge}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${Uc}]`}],toDOM(){return["br",{[Uc]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:_e,parseDOM:[{tag:"br",getAttrs:Ge}],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:_n(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...xg({tableGroup:"block",cellContent:"block+",cellAttributes:{[Fe]:{default:_e[Fe].default,getFromDOM:_n,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:_n(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},Wn=(n,e)=>({attrs:Jc,parseDOM:n.map(t=>({tag:t,getAttrs:Yc})),toDOM:e}),e1={strong:Wn(["strong","b"],n=>["b",lt(n)]),link:Wn(["a"],n=>["a",lt(n),0]),em:Wn(["em","i"],n=>["em",lt(n)]),underline:Wn(["u"],n=>["u",lt(n),0]),strikethrough:Wn(["s"],n=>["s",lt(n),0]),font_size:{attrs:{...Jc,size:{default:null}},parseDOM:[{tag:`span[${Kc}]`,getAttrs:n=>({...Yc(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...lt(n),[Kc]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},Zc=new vp({nodes:Qg,marks:e1}),Zo=new WeakMap,Li=new WeakMap,t1=(n,e)=>{Zo.set(n,e),Li.set(e,n)},n1=(n,e)=>{Zo.delete(n),Li.delete(e)},zi=n=>Zo.get(n),o1=n=>Li.get(n),Xc=n=>{var t;const e=o1(n);return(t=e==null?void 0:e.__gjsv)==null?void 0:t.model},s1=n=>n.dispatchEvent(new CustomEvent("input"));function i1(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(Yo)){if(t.getAttribute("style")){t.removeAttribute(Yo);return}const o=t.parentElement;if(o){for(;t.firstChild;)o.insertBefore(t.firstChild,t);o.removeChild(t)}}else Array.from(t.children).forEach(o=>e(o))};e(n)}function r1(n,e={}){if(!e.enableOnClick)return()=>{};const t=n.Components.events,o=d=>n.getSelectedAll().includes(d),s=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),i=d=>d.isChildOf("text"),r=d=>n.getEditing()===d,l=(d,u={})=>{d.trigger("focus",u.event)},a=(d,u)=>{o(d)&&s(d)&&!r(d)&&l(d,u)},c=(d,u)=>{if(o(d)&&!s(d)&&i(d)){const h=d.parents().find(p=>p.isInstanceOf("text"));h&&(l(h,u),setTimeout(()=>n.select(h),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const l1=(n,e)=>{const t=a1(n);return t&&y1(t)?c1(n,e):t?ia(()=>({type:n.schema.nodes.div}))(n,e):!1};function a1(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 c1(n,e){const{selection:t,schema:o,tr:s}=n;s.split(t.from,1);const i=t.from+1,r=s.doc.nodeAt(i),l={...r.attrs.attrs,id:void 0},a=r.textContent.length>0,c=r.textContent.length||0,d=r.textContent||" ",u=o.text(d),h=o.nodes.div.create(l,a?u:[],[]);return s.replaceRangeWith(i,i+c+2,h),s.setSelection(L.create(s.doc,i+1)),e==null||e(s.scrollIntoView()),!0}function d1(n,e,t){const{state:o,dispatch:s}=n,{selection:i,tr:r}=o,l=(a,c,d)=>{const u={};return a.split(";").forEach(h=>{const[p,f]=h.split(":").map(m=>m.trim());p&&(u[p]=f)}),u[c]=d,Object.entries(u).map(([h,p])=>`${h}: ${p}`).join("; ")};if(!i.empty||t)r.doc.nodesBetween(i.from,i.to,(a,c)=>{var d,u;if(a.type===o.schema.nodes.image){const h=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:h}})}else if(a.type.isBlock){const h=l(((u=a.attrs.attrs)==null?void 0:u.style)||"","text-align",e);Qc(a)?r.setBlockType(i.from,void 0,o.schema.nodes.div,{attrs:{style:h}}):r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:h}})}});else{const a=o.doc.resolve(i.from),c=a.start(a.depth),d=o.doc.nodeAt(c);if(d!=null&&d.type.isBlock){const u=l(d.attrs.style||"","text-align",e);r.setNodeMarkup(c,void 0,{...d.attrs,style:u})}}r.docChanged&&s(r.scrollIntoView())}const jn=(n,e)=>{const{from:t,to:o}=n.selection;let s=!1;return n.doc.nodesBetween(t,o,i=>{if(s)return!1;i.marks.some(r=>r.type===e)&&(s=!0)}),s};function u1(n,e,t="_blank"){const{state:o,dispatch:s}=n,{schema:i,selection:r,tr:l}=o,a=i.marks.link;try{const c=a.create({[Fe]:JSON.stringify({href:e,target:t})});l.addMark(r.from,r.to,c),s(l.scrollIntoView())}catch(c){console.error("Error applying link mark:",c)}}function h1(n,e){const{state:t,dispatch:o}=n,{selection:s,tr:i}=t;if(s.empty)return;const r=t.schema.marks.font_size;if(!r){console.error("Font size mark is not defined in the schema.");return}i.addMark(s.from,s.to,r.create({size:e})),o(i.scrollIntoView())}const Rt=(n,e)=>{const{doc:t,selection:o}=n.state,s=t.resolve(o.from);for(let i=s.depth;i>0;i--){const r=s.node(i);if(e(r))return{pos:i>0?s.before(i):0,start:s.start(i),depth:i,node:r}}},p1=n=>(n||"").split(";").map(e=>e.split(":")).reduce((e,[t,o])=>(t=t.replace(/-./g,s=>s.toUpperCase()[1]).trim(),e[t]=`${o}`.trim(),e),{});function f1(...n){return(e,t)=>{const o=r=>{e=e.apply(r),t==null||t(r)},s=n.pop();return n.reduce((r,l)=>r||l(e,o),!1)&&s!==void 0&&s(e,t)}}const m1=(n,e)=>{const{state:t,dispatch:o}=n;if(e!=null&&e.event){const{event:s}=e,i=n.posAtCoords({left:s.clientX,top:s.clientY});i!=null&&i.pos&&o(t.tr.setSelection(L.create(t.doc,i.pos)))}else ra(t,o);setTimeout(()=>setTimeout(()=>n.focus()))},Vi=n=>n.isBlock,Qc=n=>n.type.name==="inlineFragment",g1=n=>Vi(n)&&!Qc(n),ed=n=>n.type.name==="bulletList",td=n=>n.type.name==="orderedList",y1=n=>n.type.name==="heading",b1=n=>ed(n)||td(n),nd=(n,e)=>{var i,r;const t=(i=Rt(n,l=>l.type===e))==null?void 0:i.node,o=n.state.schema.nodes.listItem;let s;return t?s=ni(o):(r=Rt(n,b1))!=null&&r.node?s=f1(ni(o),ya(e)):s=ya(e),s(n.state,n.dispatch)},od=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(o=>o.type.name===e)},v1=n=>{var r;const{view:e,prop:t,editor:o,propCSS:s}=n,i=(r=Rt(e,g1))==null?void 0:r.node;if(i){const l=i.attrs.attrs||{},a=p1(l.style);if(t in a)return a[t]||"";if(l.id){const c=o.Components.getById(l.id);return((c==null?void 0:c.getStyle())||{})[s]||""}}return""},x1=n=>{const{view:e,prop:t,markName:o,editor:s,propCSS:i}=n,r=od(e,o);if(r){const l=r.attrs;if(l[t])return l[t];if(l[Fe]){const a=lt(r).id;if(a){const c=s.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[i]||""}}}return""},sd=(n,e)=>{const{dispatch:t}=n,{nodes:o,marks:s}=n.state.schema;return{text:{selected:()=>{const{selection:i,doc:r}=n.state;return r.textBetween(i.from,i.to," ")},replace:(i,r={})=>{const{state:l}=n,{from:a}=l.selection;let c=l.tr.replaceSelectionWith(l.schema.text(i));r.select&&(c=c.setSelection(L.create(c.doc,a,a+i.length))),t==null||t(c)}},bold:{toggle:()=>kt(s.strong)(n.state,t),isActive:()=>jn(n.state,s.strong)},italic:{toggle:()=>kt(s.em)(n.state,t),isActive:()=>jn(n.state,s.em)},underline:{toggle:()=>kt(s.underline)(n.state,t),isActive:()=>jn(n.state,s.underline)},strikethrough:{toggle:()=>kt(s.strikethrough)(n.state,t),isActive:()=>jn(n.state,s.strikethrough)},link:{get:()=>{const i=Xc(n);if(i!=null&&i.is("link"))return i.getAttributes();{const r=od(n,"link");return r?lt(r):{}}},toggle:()=>kt(s.link)(n.state,t),isActive:()=>jn(n.state,s.link),create:i=>{const r=Xc(n);r!=null&&r.is("link")?(r.addAttributes({href:i.url,target:i.target}),n.focus()):u1(n,i.url,i.target)}},alignText:{get:()=>v1({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:i=>d1(n,i.value,!0)},fontSize:{get:()=>x1({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:i=>h1(n,i.value)},image:{open(){const i="assetLayout",{state:r,dispatch:l}=n,{selection:a,doc:c}=r,d=c.textBetween(a.from,a.to," "),u={id:i,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:h=>{const p={alt:d,src:h.asset.getSrc()};l(r.tr.replaceSelectionWith(o.image.createAndFill({attrs:p})))}}};e.runCommand(_.layoutToggle,u)}},heading:{get:()=>{var r;const i=(r=Rt(n,Vi))==null?void 0:r.node;return`${(i==null?void 0:i.attrs.level)||""}`},set:({value:i})=>{var a;const{state:r}=n,l=(a=Rt(n,Vi))==null?void 0:a.node;pf(r.schema.nodes.heading,{attrs:l==null?void 0:l.attrs.attrs,level:i?parseInt(i,10):0})(r,t)}},listBullet:{isActive:()=>{var i;return!!((i=Rt(n,ed))!=null&&i.node)},toggle:()=>nd(n,o.bulletList)},listOrdered:{isActive:()=>{var i;return!!((i=Rt(n,td))!=null&&i.node)},toggle:()=>nd(n,o.orderedList)}}};class at{constructor(e,t,o={}){this.match=e,this.match=e,this.handler=typeof t=="string"?S1(t):t,this.undoable=o.undoable!==!1,this.inCode=o.inCode||!1}}function S1(n){return function(e,t,o,s){let i=n;if(t[1]){let r=t[0].lastIndexOf(t[1]);i+=t[0].slice(r+t[1].length),o+=r;let l=o-s;l>0&&(i=t[0].slice(r-l,r)+i,o=s)}return e.tr.insertText(i,o,s)}}const w1=500;function C1({rules:n}){let e=new En({state:{init(){return null},apply(t,o){let s=t.getMeta(this);return s||(t.selectionSet||t.docChanged?null:o)}},props:{handleTextInput(t,o,s,i){return id(t,o,s,i,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:o}=t.state.selection;o&&id(t,o.pos,o.pos,"",n,e)})}}},isInputRules:!0});return e}function id(n,e,t,o,s,i){if(n.composing)return!1;let r=n.state,l=r.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-w1),l.parentOffset,null,"")+o;for(let c=0;c<s.length;c++){let d=s[c];if(l.parent.type.spec.code){if(!d.inCode)continue}else if(d.inCode==="only")continue;let u=d.match.exec(a),h=u&&d.handler(r,u,e-(u[0].length-o.length),t);if(h)return d.undoable&&h.setMeta(i,{transform:h,from:e,to:t,text:o}),n.dispatch(h),!0}return!1}const k1=new at(/--$/,"—"),T1=new at(/\.\.\.$/,"…"),M1=new at(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),A1=new at(/"$/,"”"),E1=new at(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),N1=new at(/'$/,"’"),O1=[M1,A1,E1,N1];function $i(n,e,t=null,o){return new at(n,(s,i,r,l)=>{let a=t instanceof Function?t(i):t,c=s.tr.delete(r,l),d=c.doc.resolve(r),u=d.blockRange(),h=u&&zl(u,e,a);if(!h)return null;c.wrap(u,h);let p=c.doc.resolve(r-1).nodeBefore;return p&&p.type==e&&Po(c.doc,r-1)&&(!o||o(i,p))&&c.join(r-1),c})}function rd(n,e,t=null){return new at(n,(o,s,i,r)=>{let l=o.doc.resolve(i),a=t instanceof Function?t(s):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?o.tr.delete(i,r).setBlockType(i,i,e,a):null})}function P1(n){return $i(/^\s*>\s$/,n)}function I1(n){return $i(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function R1(n){return $i(/^\s*([-+*])\s$/,n)}function D1(n){return rd(/^```$/,n)}function L1(n,e){return rd(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function z1(n){const e=O1.concat(T1,k1);let t;return(t=n.nodes.blockquote)&&e.push(P1(t)),(t=n.nodes.orderedList)&&e.push(I1(t)),(t=n.nodes.bulletList)&&e.push(R1(t)),(t=n.nodes.codeBlock)&&e.push(D1(t)),(t=n.nodes.heading)&&e.push(L1(t,6)),C1({rules:e})}const V1="rteProseMirror",$1=F.free,Me="rte:selectionchange",Se={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>'},B1=(n,e)=>{var a;const{editor:t,el:o}=n,s=Zo.get(o),i=sd(s,t),r={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},bold:{id:"bold",icon:Se.bold,size:"s",type:"button",editorEvents:{[Me]:({setState:c})=>{c({active:i.bold.isActive()})}},onClick:({setState:c})=>{i.bold.toggle(),c({active:i.bold.isActive()})}},italic:{id:"italic",icon:Se.italic,size:"s",type:"button",editorEvents:{[Me]:({setState:c})=>{c({active:i.italic.isActive()})}},onClick:({setState:c})=>{i.italic.toggle(),c({active:i.italic.isActive()})}},underline:{id:"underline",icon:Se.underline,size:"s",type:"button",editorEvents:{[Me]:({setState:c})=>{c({active:i.underline.isActive()})}},onClick:({setState:c})=>{i.underline.toggle(),c({active:i.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:Se.strikethrough,size:"s",type:"button",editorEvents:{[Me]:({setState:c})=>{c({active:i.strikethrough.isActive()})}},onClick:({setState:c})=>{i.strikethrough.toggle(),c({active:i.strikethrough.isActive()})}},image:{id:"image",icon:Se.image,size:"s",type:"button",onClick:()=>i.image.open()},link:{id:"link",icon:Se.link,size:"s",type:"button",editorEvents:{[Me]:({setState:c})=>{c({active:i.link.isActive(),disabled:s.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,{x:u,y:h,width:p,height:f}=d.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(_.layoutRemove,{id:m}),b=i.link.get(),w={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:u,y:h,w:p,h:f},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:y=>{y.preventDefault();const v=new FormData(y.currentTarget);i.link.create({url:v.get("url"),target:v.get("target")}),g()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(b==null?void 0:b.href)||"",onChange:({value:y,setState:v})=>v({value:y})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(b==null?void 0:b.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:y,setState:v})=>v({value:y})},{type:"row",style:{gap:10,justifyContent:"end"},children:[i.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{i.link.toggle(),g()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(_.layoutToggle,w)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:Se.alignTextLeft},{id:"center",icon:Se.alignTextCenter},{id:"right",icon:Se.alignTextRight},{id:"justify",icon:Se.alignTextJustify}],editorEvents:{[Me]:({setState:c})=>{c({value:i.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:Se.listBullet,size:"s",type:"button",editorEvents:{[Me]:({setState:c})=>{c({active:i.listBullet.isActive()})}},onClick:({setState:c})=>{i.listBullet.toggle(),c({active:i.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:Se.listOrdered,size:"s",type:"button",editorEvents:{[Me]:({setState:c})=>{c({active:i.listOrdered.isActive()})}},onClick:({setState:c})=>{i.listOrdered.toggle(),c({active:i.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:{[Me]:({setState:c})=>{c({value:i.heading.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.heading.set({value:c}),s.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:{[Me]:({setState:c})=>{c({value:i.fontSize.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.fontSize.set({value:c}),s.focus()}}},l=[r.bold,r.italic,r.underline,r.strikethrough,r.image,r.link,r.listBullet,r.listOrdered,r.alignText,r.heading,r.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:i,layouts:r,proseMirror:{view:s},items:l}))||l};class H1{constructor(e,t,o){this.editor=o,this.node=e,this.dom=document.createElement("img"),this.view=t,Object.keys(e.attrs.attrs).forEach(s=>{this.dom.setAttribute(s,e.attrs.attrs[s])}),this.dom.addEventListener("dblclick",s=>this.handleDoubleClick(s))}handleDoubleClick(e){const{editor:t,view:o}=this;sd(o,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=""}}const F1=G(function(n,e={}){const t={plugins:r=>r.plugins,...e},o=(r,l)=>{var f,m;const a=((f=t.schema)==null?void 0:f.call(t,{editor:n,schema:Zc}))||Zc,{nodes:c,marks:d}=a,u=Zt.fromSchema(a).parse(r),h=sn.create({doc:u,schema:a,plugins:(m=t.plugins)==null?void 0:m.call(t,{editor:n,plugins:[_g(),Xg(),z1(a),kf(),ti({Tab:Vc(1),"Shift-Tab":Vc(-1)}),ti({Enter:On(sa,If(c.listItem),l1),"Shift-Enter":On(oa,(g,b)=>(b&&b(g.tr.replaceSelectionWith(c.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":ma,"Mod-y":Xs,"Mod-Shift-z":Xs,"Mod-b":kt(d.strong),"Mod-i":kt(d.em),"Shift-Tab":ni(c.listItem),Tab:Lf(c.listItem)}),ti(mf)]})}),p=new pg({mount:r},{state:h,dispatchTransaction(g){var x;const{state:b}=p,w=b.apply(g),y=!b.doc.eq(w.doc);p.updateState(w);const v=!b.selection.eq(w.selection);y&&(s1(((x=l==null?void 0:l.view)==null?void 0:x.el)||r),p.focus()),(v||y)&&n.trigger(Me)}});return r.__rteView=p,p.setProps({nodeViews:{image(g){return new H1(g,p,n)}}}),p},s=r=>B1(r,t);n.setCustomRte({toolbar:s,parseContent:!0,async enable(r,l,a){const c=zi(r);if(c)return c;const d=o(r,a);return t1(r,d),m1(d,a),d},disable(r){const l=zi(r);if(l)return n1(r,l),l.destroy(),{forceSync:!0}},getContent(r){const l=zi(r);if(l){const{schema:a,doc:c}=l.state,d=document.createElement("div"),u=Ct.fromSchema(a).serializeFragment(c.content);return u.childNodes.forEach(h=>{h.nodeType===Node.ELEMENT_NODE&&h.innerHTML===""&&(h.innerHTML="<br/>")}),d.appendChild(u),i1(d),r.classList.remove("ProseMirror-focused"),d.innerHTML}return r.innerHTML}});const i=r1(n,t);W({editor:n,licenseKey:t.licenseKey,plan:$1,pluginName:V1,cleanup:()=>{n.RichTextEditor.customRte=void 0,i()}})}),_1="canvasEmptyState",G1=F.startup,W1=G(function(n,e={}){const t=new WeakMap,o=new WeakMap,s=new WeakMap,i=new Set,r=new WeakMap,l={emptyStates:[],...e},a=(y,v)=>{let x=!1;const{isValid:S}=v;return Array.isArray(S)?x=S.some(C=>y.is(C)):zt(S)?x=S({component:y,editor:n}):x=y.is(S),x},c=y=>{const v=t.get(y);t.delete(y),v==null||v()},d=y=>{y.views.forEach(v=>c(v)),s.delete(y)},u=y=>{if(!(!y||i.has(y)))try{i.add(y);const v=y.components().length>0,x=s.get(y);if(v&&x)d(y);else if(!v&&!x){const S=r.has(y)?r.get(y):l.emptyStates.find(C=>a(y,C));if(r.set(y,S),!S)return;y.views.forEach(C=>{const A=S.render({editor:n,component:y,componentView:C,mount:T=>{o.set(C,T),s.set(y,!0);const M=C.getChildrenContainer();M==null||M.appendChild(T)},unmount:()=>c(C)});t.set(C,()=>{A==null||A();const T=o.get(C);T==null||T.remove()})})}}finally{i.delete(y)}},h=y=>{s.has(y)&&d(y)},p=({model:y})=>{u(y.getComponent())},f=n.Components.events,m=`${f.update}:components`,g="component:mount",b=n.Canvas.events.frameLoadBody,w=f.removed;n.on(m,u),n.on(g,u),n.on(w,h),n.on(b,p),W({editor:n,licenseKey:l.licenseKey,plan:G1,pluginName:_1,cleanup:()=>{n.off(m,u),n.off(g,u),n.off(w,h),n.off(b,p)}})}),ld="canvasFullSize",j1=F.startup,q1=G(function(n,e={}){const{Canvas:t,Commands:o,Devices:s}=n,i={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...e},{canvasOffsetY:r,canvasOffsetX:l,canvasTransition:a,deviceMaxWidth:c,deviceMinHeigth:d,frameBorderRadius:u,frameTransition:h}=i,p=`${d}px`,f=t.events,m="core:preview",g=`${o.events.stopCommand}${m}`,b=t.getConfig(),w=`${ld}:disable`,y=s.getAll().map(x=>({...x.attributes}));b.scrollableCanvas=!0,s.getAll().map(x=>{!x.get("width")&&x.set("width",`${c}px`),!x.get("height")&&x.set("height","auto"),!x.get("minHeight")&&x.set("minHeight",p)});const v=x=>{const S="data-gs-plg-full-size",C=document.querySelector(`style[${S}]`);if(x&&C)return C.remove();const A=C||document.createElement("style"),T=t.getZoomMultiplier();A.setAttribute(S,"true"),A.innerHTML=`
|
|
303
|
-
.gjs-frame-wrapper { transition: width ${
|
|
304
|
-
.gjs-frame-wrapper__bottom { height: ${
|
|
301
|
+
`);return{dom:a,text:p,slice:e}}function dc(n,e,t,o,s){let r=s.parent.type.spec.code,i,l;if(!t&&!e)return null;let a=e&&(o||r||!t);if(a){if(n.someProp("transformPastedText",p=>{e=p(e,r||o,n)}),r)return e?new A(k.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
302
|
+
`))),0,0):A.empty;let u=n.someProp("clipboardTextParser",p=>p(e,s,o,n));if(u)l=u;else{let p=s.marks(),{schema:h}=n.state,f=Ct.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=i.appendChild(document.createElement("p"));m&&g.appendChild(f.serializeNode(h.text(m,p)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),i=$m(t),Dn&&Vm(i);let c=i&&i.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let p=i.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;i=p}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Xt.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!Dm.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Bm(fc(l,+d[1],+d[2]),d[4]);else if(l=A.maxOpen(Lm(l.content,s),!0),l.openStart||l.openEnd){let u=0,p=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;p<l.openEnd&&!h.type.spec.isolating;p++,h=h.lastChild);l=fc(l,u,p)}return n.someProp("transformPasted",u=>{l=u(l,n)}),l}const Dm=/^(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 Lm(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),r,i=[];if(n.forEach(l=>{if(!i)return;let a=s.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&r.length&&pc(a,r,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=hc(i[i.length-1],r.length));let d=uc(l,a);i.push(d),s=s.matchType(d.type),r=a}}),i)return k.from(i)}return n}function uc(n,e,t=0){for(let o=e.length-1;o>=t;o--)n=e[o].create(null,k.from(n));return n}function pc(n,e,t,o,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let r=pc(n,e,t,o.lastChild,s+1);if(r)return o.copy(o.content.replaceChild(o.childCount-1,r));if(o.contentMatchAt(o.childCount).matchType(s==n.length-1?t.type:n[s+1]))return o.copy(o.content.append(k.from(uc(t,n,s+1))))}}function hc(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,hc(n.lastChild,e-1)),o=n.contentMatchAt(n.childCount).fillBefore(k.empty,!0);return n.copy(t.append(o))}function xr(n,e,t,o,s,r){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(r=0),s<o-1&&(l=xr(l,e,t,o,s+1,r)),s>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,r<=s).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(k.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function fc(n,e,t){return e<n.openStart&&(n=new A(xr(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new A(xr(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const mc={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 gc=null;function yc(){return gc||(gc=document.implementation.createHTMLDocument("title"))}let Sr=null;function zm(n){let e=window.trustedTypes;return e?(Sr||(Sr=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Sr.createHTML(n)):n}function $m(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=yc().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(n),s;if((s=o&&mc[o[1].toLowerCase()])&&(n=s.map(r=>"<"+r+">").join("")+n+s.map(r=>"</"+r+">").reverse().join("")),t.innerHTML=zm(n),s)for(let r=0;r<s.length;r++)t=t.querySelector(s[r])||t;return t}function Vm(n){let e=n.querySelectorAll(re?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let o=e[t];o.childNodes.length==1&&o.textContent==" "&&o.parentNode&&o.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),o)}}function Bm(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,o;try{o=JSON.parse(e)}catch{return n}let{content:s,openStart:r,openEnd:i}=n;for(let l=o.length-2;l>=0;l-=2){let a=t.nodes[o[l]];if(!a||a.hasRequiredAttrs())break;s=k.from(a.create(o[l+1],s)),r++,i++}return new A(s,r,i)}const ce={},de={},Hm={touchstart:!0,touchmove:!0};class Fm{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 _m(n){for(let e in ce){let t=ce[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=o=>{Wm(n,o)&&!Cr(n,o)&&(n.editable||!(o.type in de))&&t(n,o)},Hm[e]?{passive:!0}:void 0)}ae&&n.dom.addEventListener("input",()=>null),wr(n)}function st(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Gm(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 wr(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=o=>Cr(n,o))})}function Cr(n,e){return n.someProp("handleDOMEvents",t=>{let o=t[e.type];return o?o(n,e)||e.defaultPrevented:!1})}function Wm(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 jm(n,e){!Cr(n,e)&&ce[e.type]&&(n.editable||!(e.type in de))&&ce[e.type](n,e)}de.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!vc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Te&&re&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),an&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let o=Date.now();n.input.lastIOSEnter=o,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==o&&(n.someProp("handleKeyDown",s=>s(n,Et(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",o=>o(n,t))||Rm(n,t)?t.preventDefault():st(n,"key")},de.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},de.keypress=(n,e)=>{let t=e;if(vc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ve&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let o=n.state.selection;if(!(o instanceof L)||!o.$from.sameParent(o.$to)){let s=String.fromCharCode(t.charCode);!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",r=>r(n,o.$from.pos,o.$to.pos,s))&&n.dispatch(n.state.tr.insertText(s).scrollIntoView()),t.preventDefault()}};function Go(n){return{left:n.clientX,top:n.clientY}}function qm(n,e){let t=e.x-n.clientX,o=e.y-n.clientY;return t*t+o*o<100}function kr(n,e,t,o,s){if(o==-1)return!1;let r=n.state.doc.resolve(o);for(let i=r.depth+1;i>0;i--)if(n.someProp(e,l=>i>r.depth?l(n,t,r.nodeAfter,r.before(i),s,!0):l(n,t,r.node(i),r.before(i),s,!1)))return!0;return!1}function un(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let o=n.state.tr.setSelection(e);o.setMeta("pointer",!0),n.dispatch(o)}function Km(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),o=t.nodeAfter;return o&&o.isAtom&&R.isSelectable(o)?(un(n,new R(t)),!0):!1}function Um(n,e){if(e==-1)return!1;let t=n.state.selection,o,s;t instanceof R&&(o=t.node);let r=n.state.doc.resolve(e);for(let i=r.depth+1;i>0;i--){let l=i>r.depth?r.nodeAfter:r.node(i);if(R.isSelectable(l)){o&&t.$from.depth>0&&i>=t.$from.depth&&r.before(t.$from.depth+1)==t.$from.pos?s=r.before(t.$from.depth):s=r.before(i);break}}return s!=null?(un(n,R.create(n.state.doc,s)),!0):!1}function Jm(n,e,t,o,s){return kr(n,"handleClickOn",e,t,o)||n.someProp("handleClick",r=>r(n,e,o))||(s?Um(n,t):Km(n,t))}function Ym(n,e,t,o){return kr(n,"handleDoubleClickOn",e,t,o)||n.someProp("handleDoubleClick",s=>s(n,e,o))}function Zm(n,e,t,o){return kr(n,"handleTripleClickOn",e,t,o)||n.someProp("handleTripleClick",s=>s(n,e,o))||Xm(n,t,o)}function Xm(n,e,t){if(t.button!=0)return!1;let o=n.state.doc;if(e==-1)return o.inlineContent?(un(n,L.create(o,0,o.content.size)),!0):!1;let s=o.resolve(e);for(let r=s.depth+1;r>0;r--){let i=r>s.depth?s.nodeAfter:s.node(r),l=s.before(r);if(i.inlineContent)un(n,L.create(o,l+1,l+1+i.content.size));else if(R.isSelectable(i))un(n,R.create(o,l));else continue;return!0}}function Tr(n){return Wo(n)}const bc=ve?"metaKey":"ctrlKey";ce.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let o=Tr(n),s=Date.now(),r="singleClick";s-n.input.lastClick.time<500&&qm(t,n.input.lastClick)&&!t[bc]&&(n.input.lastClick.type=="singleClick"?r="doubleClick":n.input.lastClick.type=="doubleClick"&&(r="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:r};let i=n.posAtCoords(Go(t));i&&(r=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Qm(n,i,t,!!o)):(r=="doubleClick"?Ym:Zm)(n,i.pos,i.inside,t)?t.preventDefault():st(n,"pointer"))};class Qm{constructor(e,t,o,s){this.view=e,this.pos=t,this.event=o,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!o[bc],this.allowDefault=o.shiftKey;let r,i;if(t.inside>-1)r=e.state.doc.nodeAt(t.inside),i=t.inside;else{let d=e.state.doc.resolve(t.pos);r=d.parent,i=d.depth?d.before():0}const l=s?null:o.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(o.button==0&&r.type.spec.draggable&&r.type.spec.selectable!==!1||c instanceof R&&c.from<=i&&c.to>i)&&(this.mightDrag={node:r,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ke&&!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)),st(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(()=>Fe(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(Go(e))),this.updateAllowDefault(e),this.allowDefault||!t?st(this.view,"pointer"):Jm(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ae&&this.mightDrag&&!this.mightDrag.node.isAtom||re&&!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)?(un(this.view,D.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):st(this.view,"pointer")}move(e){this.updateAllowDefault(e),st(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)}}ce.touchstart=n=>{n.input.lastTouch=Date.now(),Tr(n),st(n,"pointer")},ce.touchmove=n=>{n.input.lastTouch=Date.now(),st(n,"pointer")},ce.contextmenu=n=>Tr(n);function vc(n,e){return n.composing?!0:ae&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const eg=Te?5e3:-1;de.compositionstart=de.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof L&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(o=>o.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Wo(n,!0),n.markCursor=null;else if(Wo(n,!e.selection.empty),ke&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let o=n.domSelectionRange();for(let s=o.focusNode,r=o.focusOffset;s&&s.nodeType==1&&r!=0;){let i=r<0?s.lastChild:s.childNodes[r-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else s=i,r=-1}}n.input.composing=!0}xc(n,eg)},de.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++,xc(n,20))};function xc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Wo(n),e))}function Sc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=ng());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function tg(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Kf(e.focusNode,e.focusOffset),o=Uf(e.focusNode,e.focusOffset);if(t&&o&&t!=o){let s=o.pmViewDesc,r=n.domObserver.lastChangedTextNode;if(t==r||o==r)return r;if(!s||!s.isText(o.nodeValue))return o;if(n.input.compositionNode==o){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return o}}return t||o}function ng(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Wo(n,e=!1){if(!(Te&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Sc(n),e||n.docView&&n.docView.dirty){let t=mr(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 og(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 o=getSelection(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),o.removeAllRanges(),o.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Bn=he&&et<15||an&&Qf<604;ce.copy=de.cut=(n,e)=>{let t=e,o=n.state.selection,s=t.type=="cut";if(o.empty)return;let r=Bn?null:t.clipboardData,i=o.content(),{dom:l,text:a}=cc(n,i);r?(t.preventDefault(),r.clearData(),r.setData("text/html",l.innerHTML),r.setData("text/plain",a)):og(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function sg(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function rg(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,o=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let s=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),o.parentNode&&o.parentNode.removeChild(o),t?Hn(n,o.value,null,s,e):Hn(n,o.textContent,o.innerHTML,s,e)},50)}function Hn(n,e,t,o,s){let r=dc(n,e,t,o,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,r||A.empty)))return!0;if(!r)return!1;let i=sg(r),l=i?n.state.tr.replaceSelectionWith(i,o):n.state.tr.replaceSelection(r);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function wc(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," "):""}de.paste=(n,e)=>{let t=e;if(n.composing&&!Te)return;let o=Bn?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;o&&Hn(n,wc(o),o.getData("text/html"),s,t)?t.preventDefault():rg(n,t)};class Cc{constructor(e,t,o){this.slice=e,this.move=t,this.node=o}}const kc=ve?"altKey":"ctrlKey";ce.dragstart=(n,e)=>{let t=e,o=n.input.mouseDown;if(o&&o.done(),!t.dataTransfer)return;let s=n.state.selection,r=s.empty?null:n.posAtCoords(Go(t)),i;if(!(r&&r.pos>=s.from&&r.pos<=(s instanceof R?s.to-1:s.to))){if(o&&o.mightDrag)i=R.create(n.state.doc,o.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(i=R.create(n.state.doc,u.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:d}=cc(n,l);(!t.dataTransfer.files.length||!re||Pa>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Bn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Bn||t.dataTransfer.setData("text/plain",c),n.dragging=new Cc(d,!t[kc],i)},ce.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},de.dragover=de.dragenter=(n,e)=>e.preventDefault(),de.drop=(n,e)=>{let t=e,o=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let s=n.posAtCoords(Go(t));if(!s)return;let r=n.state.doc.resolve(s.pos),i=o&&o.slice;i?n.someProp("transformPasted",f=>{i=f(i,n)}):i=dc(n,wc(t.dataTransfer),Bn?null:t.dataTransfer.getData("text/html"),!1,r);let l=!!(o&&!t[kc]);if(n.someProp("handleDrop",f=>f(n,t,i||A.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?Qh(n.state.doc,r.pos,i):r.pos;a==null&&(a=r.pos);let c=n.state.tr;if(l){let{node:f}=o;f?f.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,p=c.doc;if(u?c.replaceRangeWith(d,d,i.content.firstChild):c.replaceRange(d,d,i),c.doc.eq(p))return;let h=c.doc.resolve(d);if(u&&R.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new R(h));else{let f=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,v,w)=>f=w),c.setSelection(yr(n,h,c.doc.resolve(f)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},ce.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())&&Fe(n)},20))},ce.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)},ce.beforeinput=(n,e)=>{if(re&&Te&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:o}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=o||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",r=>r(n,Et(8,"Backspace")))))return;let{$cursor:s}=n.state.selection;s&&s.pos>0&&n.dispatch(n.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let n in de)ce[n]=de[n];function Fn(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 jo{constructor(e,t){this.toDOM=e,this.spec=t||Ot,this.side=this.spec.side||0}map(e,t,o,s){let{pos:r,deleted:i}=e.mapResult(t.from+s,this.side<0?-1:1);return i?null:new fe(r-o,r-o,this)}valid(){return!0}eq(e){return this==e||e instanceof jo&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Fn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class rt{constructor(e,t){this.attrs=e,this.spec=t||Ot}map(e,t,o,s){let r=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-o,i=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-o;return r>=i?null:new fe(r,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof rt&&Fn(this.attrs,e.attrs)&&Fn(this.spec,e.spec)}static is(e){return e.type instanceof rt}destroy(){}}class Mr{constructor(e,t){this.attrs=e,this.spec=t||Ot}map(e,t,o,s){let r=e.mapResult(t.from+s,1);if(r.deleted)return null;let i=e.mapResult(t.to+s,-1);return i.deleted||i.pos<=r.pos?null:new fe(r.pos-o,i.pos-o,this)}valid(e,t){let{index:o,offset:s}=e.content.findIndex(t.from),r;return s==t.from&&!(r=e.child(o)).isText&&s+r.nodeSize==t.to}eq(e){return this==e||e instanceof Mr&&Fn(this.attrs,e.attrs)&&Fn(this.spec,e.spec)}destroy(){}}class fe{constructor(e,t,o){this.from=e,this.to=t,this.type=o}copy(e,t){return new fe(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,o){return this.type.map(e,this,t,o)}static widget(e,t,o){return new fe(e,e,new jo(t,o))}static inline(e,t,o,s){return new fe(e,t,new rt(o,s))}static node(e,t,o,s){return new fe(e,t,new Mr(o,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof rt}get widget(){return this.type instanceof jo}}const pn=[],Ot={};class q{constructor(e,t){this.local=e.length?e:pn,this.children=t.length?t:pn}static create(e,t){return t.length?qo(t,e,0,Ot):ie}find(e,t,o){let s=[];return this.findInner(e??0,t??1e9,s,0,o),s}findInner(e,t,o,s,r){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!r||r(l.spec))&&o.push(l.copy(l.from+s,l.to+s))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,o,s+l,r)}}map(e,t,o){return this==ie||e.maps.length==0?this:this.mapInner(e,t,0,0,o||Ot)}mapInner(e,t,o,s,r){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,o,s);a&&a.type.valid(t,a)?(i||(i=[])).push(a):r.onRemove&&r.onRemove(this.local[l].spec)}return this.children.length?ig(this.children,i||[],e,t,o,s,r):i?new q(i.sort(It),pn):ie}add(e,t){return t.length?this==ie?q.create(e,t):this.addInner(e,t,0):this}addInner(e,t,o){let s,r=0;e.forEach((l,a)=>{let c=a+o,d;if(d=Mc(t,l,c)){for(s||(s=this.children.slice());r<s.length&&s[r]<a;)r+=3;s[r]==a?s[r+2]=s[r+2].addInner(l,d,c+1):s.splice(r,0,a,a+l.nodeSize,qo(d,l,c+1,Ot)),r+=3}});let i=Tc(r?Ec(t):t,-o);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new q(i.length?this.local.concat(i).sort(It):this.local,s||this.children)}remove(e){return e.length==0||this==ie?this:this.removeInner(e,0)}removeInner(e,t){let o=this.children,s=this.local;for(let r=0;r<o.length;r+=3){let i,l=o[r]+t,a=o[r+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(i||(i=[])).push(u));if(!i)continue;o==this.children&&(o=this.children.slice());let c=o[r+2].removeInner(i,l+1);c!=ie?o[r+2]=c:(o.splice(r,3),r-=3)}if(s.length){for(let r=0,i;r<e.length;r++)if(i=e[r])for(let l=0;l<s.length;l++)s[l].eq(i,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return o==this.children&&s==this.local?this:s.length||o.length?new q(s,o):ie}forChild(e,t){if(this==ie)return this;if(t.isLeaf)return q.empty;let o,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(o=this.children[l+2]);break}let r=e+1,i=r+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>r&&a.type instanceof rt){let c=Math.max(r,a.from)-r,d=Math.min(i,a.to)-r;c<d&&(s||(s=[])).push(a.copy(c,d))}}if(s){let l=new q(s.sort(It),pn);return o?new it([l,o]):l}return o||ie}eq(e){if(this==e)return!0;if(!(e instanceof q)||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 Er(this.localsInner(e))}localsInner(e){if(this==ie)return pn;if(e.inlineContent||!this.local.some(rt.is))return this.local;let t=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof rt||t.push(this.local[o]);return t}forEachSet(e){e(this)}}q.empty=new q([],[]),q.removeOverlap=Er;const ie=q.empty;class it{constructor(e){this.members=e}map(e,t){const o=this.members.map(s=>s.map(e,t,Ot));return it.from(o)}forChild(e,t){if(t.isLeaf)return q.empty;let o=[];for(let s=0;s<this.members.length;s++){let r=this.members[s].forChild(e,t);r!=ie&&(r instanceof it?o=o.concat(r.members):o.push(r))}return it.from(o)}eq(e){if(!(e instanceof it)||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,o=!0;for(let s=0;s<this.members.length;s++){let r=this.members[s].localsInner(e);if(r.length)if(!t)t=r;else{o&&(t=t.slice(),o=!1);for(let i=0;i<r.length;i++)t.push(r[i])}}return t?Er(o?t:t.sort(It)):pn}static from(e){switch(e.length){case 0:return ie;case 1:return e[0];default:return new it(e.every(t=>t instanceof q)?e:e.reduce((t,o)=>t.concat(o instanceof q?o:o.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function ig(n,e,t,o,s,r,i){let l=n.slice();for(let c=0,d=r;c<t.maps.length;c++){let u=0;t.maps[c].forEach((p,h,f,m)=>{let g=m-f-(h-p);for(let v=0;v<l.length;v+=3){let w=l[v+1];if(w<0||p>w+d-u)continue;let y=l[v]+d-u;h>=y?l[v+1]=p<=y?-2:-1:p>=d&&g&&(l[v]+=g,l[v+1]+=g)}u+=g}),d=t.maps[c].map(d,-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 d=t.map(n[c]+r),u=d-s;if(u<0||u>=o.content.size){a=!0;continue}let p=t.map(n[c+1]+r,-1),h=p-s,{index:f,offset:m}=o.content.findIndex(u),g=o.maybeChild(f);if(g&&m==u&&m+g.nodeSize==h){let v=l[c+2].mapInner(t,g,d+1,n[c]+r+1,i);v!=ie?(l[c]=u,l[c+1]=h,l[c+2]=v):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=lg(l,n,e,t,s,r,i),d=qo(c,o,0,i);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,p=0;u<d.children.length;u+=3){let h=d.children[u];for(;p<l.length&&l[p]<h;)p+=3;l.splice(p,0,d.children[u],d.children[u+1],d.children[u+2])}}return new q(e.sort(It),l)}function Tc(n,e){if(!e||!n.length)return n;let t=[];for(let o=0;o<n.length;o++){let s=n[o];t.push(new fe(s.from+e,s.to+e,s.type))}return t}function lg(n,e,t,o,s,r,i){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(o,s,c);u?t.push(u):i.onRemove&&i.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+r+1);return t}function Mc(n,e,t){if(e.isLeaf)return null;let o=t+e.nodeSize,s=null;for(let r=0,i;r<n.length;r++)(i=n[r])&&i.from>t&&i.to<o&&((s||(s=[])).push(i),n[r]=null);return s}function Ec(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function qo(n,e,t,o){let s=[],r=!1;e.forEach((l,a)=>{let c=Mc(n,l,a+t);if(c){r=!0;let d=qo(c,l,t+a+1,o);d!=ie&&s.push(a,a+l.nodeSize,d)}});let i=Tc(r?Ec(n):n,-t).sort(It);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(o.onRemove&&o.onRemove(i[l].spec),i.splice(l--,1));return i.length||s.length?new q(i,s):ie}function It(n,e){return n.from-e.from||n.to-e.to}function Er(n){let e=n;for(let t=0;t<e.length-1;t++){let o=e[t];if(o.from!=o.to)for(let s=t+1;s<e.length;s++){let r=e[s];if(r.from==o.from){r.to!=o.to&&(e==n&&(e=n.slice()),e[s]=r.copy(r.from,o.to),Ac(e,s+1,r.copy(o.to,r.to)));continue}else{r.from<o.to&&(e==n&&(e=n.slice()),e[t]=o.copy(o.from,r.from),Ac(e,s,o.copy(r.from,o.to)));break}}}return e}function Ac(n,e,t){for(;e<n.length&&It(t,n[e])>0;)e++;n.splice(e,0,t)}function Ar(n){let e=[];return n.someProp("decorations",t=>{let o=t(n.state);o&&o!=ie&&e.push(o)}),n.cursorWrapper&&e.push(q.create(n.state.doc,[n.cursorWrapper.deco])),it.from(e)}const ag={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},cg=he&&et<=11;class dg{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 ug{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new dg,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(o=>{for(let s=0;s<o.length;s++)this.queue.push(o[s]);he&&et<=11&&o.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),cg&&(this.onCharData=o=>{this.queue.push({target:o.target,type:"characterData",oldValue:o.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,ag)),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(tc(this.view)){if(this.suppressingSelectionUpdates)return Fe(this.view);if(he&&et<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Mt(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,o;for(let r=e.focusNode;r;r=In(r))t.add(r);for(let r=e.anchorNode;r;r=In(r))if(t.has(r)){o=r;break}let s=o&&this.view.docView.nearestDesc(o);if(s&&s.ignoreMutation({type:"selection",target:o.nodeType==3?o.parentNode:o}))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 o=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(o)&&tc(e)&&!this.ignoreSelectionChange(o),r=-1,i=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(r=r<0?u.from:Math.min(u.from,r),i=i<0?u.to:Math.max(u.to,i),u.typeOver&&(l=!0))}if(ke&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,p]=d;u.parentNode&&u.parentNode.parentNode==p.parentNode?p.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let p of d){let h=p.parentNode;h&&h.nodeName=="LI"&&(!u||fg(e,u)!=h)&&p.remove()}}}let c=null;r<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Bo(o)&&(c=mr(e))&&c.eq(D.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Fe(e),this.currentSelection.set(o),e.scrollToSelection()):(r>-1||s)&&(r>-1&&(e.docView.markDirty(r,i),pg(e)),this.handleDOMChange(r,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(o)||Fe(e),this.currentSelection.set(o))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let o=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(o==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!o||o.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(e.target))return{from:o.posBefore,to:o.posAfter};let s=e.previousSibling,r=e.nextSibling;if(he&&et<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:p}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(r=p)}let i=s&&s.parentNode==e.target?ee(s)+1:0,l=o.localPosFromDOM(e.target,i,-1),a=r&&r.parentNode==e.target?ee(r):e.target.childNodes.length,c=o.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}:(this.lastChangedTextNode=e.target,{from:o.posAtStart,to:o.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Pc=new WeakMap,Nc=!1;function pg(n){if(!Pc.has(n)&&(Pc.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=ke,Nc)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."),Nc=!0}}function Oc(n,e){let t=e.startContainer,o=e.startOffset,s=e.endContainer,r=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return Mt(i.node,i.offset,s,r)&&([t,o,s,r]=[s,r,t,o]),{anchorNode:t,anchorOffset:o,focusNode:s,focusOffset:r}}function hg(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return Oc(n,s)}let t;function o(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",o,!0),t?Oc(n,t):null}function fg(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let o=n.docView.nearestDesc(t,!0);if(o&&o.node.isBlock)return t}return null}function mg(n,e,t){let{node:o,fromOffset:s,toOffset:r,from:i,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],Bo(a)||c.push({node:a.focusNode,offset:a.focusOffset})),re&&n.input.lastKeyCode===8)for(let g=r;g>s;g--){let v=o.childNodes[g-1],w=v.pmViewDesc;if(v.nodeName=="BR"&&!w){r=g;break}if(!w||w.size)break}let u=n.state.doc,p=n.someProp("domParser")||Xt.fromSchema(n.state.schema),h=u.resolve(i),f=null,m=p.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:r,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:gg,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,v=c[1]&&c[1].pos;v==null&&(v=g),f={anchor:g+i,head:v+i}}return{doc:m,sel:f,from:i,to:l}}function gg(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(ae&&/^(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||ae&&/^(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 yg=/^(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 bg(n,e,t,o,s){let r=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let T=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,M=mr(n,T);if(M&&!n.state.selection.eq(M)){if(re&&Te&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",I=>I(n,Et(13,"Enter"))))return;let P=n.state.tr.setSelection(M);T=="pointer"?P.setMeta("pointer",!0):T=="key"&&P.scrollIntoView(),r&&P.setMeta("composition",r),n.dispatch(P)}return}let i=n.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=mg(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),p,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(p=n.state.selection.to,h="end"):(p=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let f=Sg(u.content,c.doc.content,c.from,p,h);if(f&&n.input.domChangeCount++,(an&&n.input.lastIOSEnter>Date.now()-225||Te)&&s.some(T=>T.nodeType==1&&!yg.test(T.nodeName))&&(!f||f.endA>=f.endB)&&n.someProp("handleKeyDown",T=>T(n,Et(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!f)if(o&&a instanceof L&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))f={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let T=Ic(n,n.state.doc,c.sel);if(T&&!T.eq(n.state.selection)){let M=n.state.tr.setSelection(T);r&&M.setMeta("composition",r),n.dispatch(M)}}return}n.state.selection.from<n.state.selection.to&&f.start==f.endB&&n.state.selection instanceof L&&(f.start>n.state.selection.from&&f.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?f.start=n.state.selection.from:f.endA<n.state.selection.to&&f.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(f.endB+=n.state.selection.to-f.endA,f.endA=n.state.selection.to)),he&&et<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>c.from&&c.doc.textBetween(f.start-c.from-1,f.start-c.from+1)==" "&&(f.start--,f.endA--,f.endB--);let m=c.doc.resolveNoCache(f.start-c.from),g=c.doc.resolveNoCache(f.endB-c.from),v=d.resolve(f.start),w=m.sameParent(g)&&m.parent.inlineContent&&v.end()>=f.endA,y;if((an&&n.input.lastIOSEnter>Date.now()-225&&(!w||s.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!w&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(y=D.findFrom(c.doc.resolve(m.pos+1),1,!0))&&y.head==g.pos)&&n.someProp("handleKeyDown",T=>T(n,Et(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>f.start&&xg(d,f.start,f.endA,m,g)&&n.someProp("handleKeyDown",T=>T(n,Et(8,"Backspace")))){Te&&re&&n.domObserver.suppressSelectionUpdates();return}re&&Te&&f.endB==f.start&&(n.input.lastAndroidDelete=Date.now()),Te&&!w&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==f.endA&&(f.endB-=2,g=c.doc.resolveNoCache(f.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(T){return T(n,Et(13,"Enter"))})},20));let b=f.start,x=f.endA,S,C,E;if(w){if(m.pos==g.pos)he&&et<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Fe(n),20)),S=n.state.tr.delete(b,x),C=d.resolve(f.start).marksAcross(d.resolve(f.endA));else if(f.endA==f.endB&&(E=vg(m.parent.content.cut(m.parentOffset,g.parentOffset),v.parent.content.cut(v.parentOffset,f.endA-v.start()))))S=n.state.tr,E.type=="add"?S.addMark(b,x,E.mark):S.removeMark(b,x,E.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let T=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",M=>M(n,b,x,T)))return;S=n.state.tr.insertText(T,b,x)}}if(S||(S=n.state.tr.replace(b,x,c.doc.slice(f.start-c.from,f.endB-c.from))),c.sel){let T=Ic(n,S.doc,c.sel);T&&!(re&&Te&&n.composing&&T.empty&&(f.start!=f.endB||n.input.lastAndroidDelete<Date.now()-100)&&(T.head==b||T.head==S.mapping.map(x)-1)||he&&T.empty&&T.head==b)&&S.setSelection(T)}C&&S.ensureMarks(C),r&&S.setMeta("composition",r),n.dispatch(S.scrollIntoView())}function Ic(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:yr(n,e.resolve(t.anchor),e.resolve(t.head))}function vg(n,e){let t=n.firstChild.marks,o=e.firstChild.marks,s=t,r=o,i,l,a;for(let d=0;d<o.length;d++)s=o[d].removeFromSet(s);for(let d=0;d<t.length;d++)r=t[d].removeFromSet(r);if(s.length==1&&r.length==0)l=s[0],i="add",a=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&r.length==1)l=r[0],i="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(k.from(c).eq(n))return{mark:l,type:i}}function xg(n,e,t,o,s){if(t-e<=s.pos-o.pos||Pr(o,!0,!1)<s.pos)return!1;let r=n.resolve(e);if(!o.parent.isTextblock){let l=r.nodeAfter;return l!=null&&t==e+l.nodeSize}if(r.parentOffset<r.parent.content.size||!r.parent.isTextblock)return!1;let i=n.resolve(Pr(r,!0,!0));return!i.parent.isTextblock||i.pos>t||Pr(i,!0,!1)<t?!1:o.parent.content.cut(o.parentOffset).eq(i.parent.content)}function Pr(n,e,t){let o=n.depth,s=e?n.end():n.pos;for(;o>0&&(e||n.indexAfter(o)==n.node(o).childCount);)o--,s++,e=!1;if(t){let r=n.node(o).maybeChild(n.indexAfter(o));for(;r&&!r.isLeaf;)r=r.firstChild,s++}return s}function Sg(n,e,t,o,s){let r=n.findDiffStart(e,t);if(r==null)return null;let{a:i,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,r-Math.min(i,l));o-=i+a-r}if(i<r&&n.size<e.size){let a=o<=r&&o>=i?r-o:0;r-=a,r&&r<e.size&&Rc(e.textBetween(r-1,r+1))&&(r+=a?1:-1),l=r+(l-i),i=r}else if(l<r){let a=o<=r&&o>=l?r-o:0;r-=a,r&&r<n.size&&Rc(n.textBetween(r-1,r+1))&&(r+=a?1:-1),i=r+(i-l),l=r}return{start:r,endA:i,endB:l}}function Rc(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 wg{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 Fm,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Vc),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=zc(this),Lc(this),this.nodeViews=$c(this),this.docView=Ga(this.state.doc,Dc(this),Ar(this),this.dom,this),this.domObserver=new ug(this,(o,s,r,i)=>bg(this,o,s,r,i)),this.domObserver.start(),_m(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&&wr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Vc),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let o in this._props)t[o]=this._props[o];t.state=this.state;for(let o in e)t[o]=e[o];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var o;let s=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(Sc(this),i=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=$c(this);kg(h,this.nodeViews)&&(this.nodeViews=h,r=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&wr(this),this.editable=zc(this),Lc(this);let a=Ar(this),c=Dc(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=r||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(s.selection))&&(i=!0);let p=d=="preserve"&&i&&this.dom.style.overflowAnchor==null&&nm(this);if(i){this.domObserver.stop();let h=u&&(he||re)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&Cg(s.selection,e.selection);if(u){let f=re?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=tg(this)),(r||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Ga(e.doc,c,a,this.dom,this)),f&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Mm(this))?Fe(this,h):(Qa(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((o=this.dragging)===null||o===void 0)&&o.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():p&&om(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof R){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Na(this,t.getBoundingClientRect(),e)}else Na(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 o=this.directPlugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let o=this.state.plugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let o=this.pluginViews[t];o.update&&o.update(this,e)}}updateDraggedNode(e,t){let o=e.node,s=-1;if(this.state.doc.nodeAt(o.from)==o.node)s=o.from;else{let r=o.from+(this.state.doc.content.size-t.doc.content.size);(r>0&&this.state.doc.nodeAt(r))==o.node&&(s=r)}this.dragging=new Cc(e.slice,e.move,s<0?void 0:R.create(this.state.doc,s))}someProp(e,t){let o=this._props&&this._props[e],s;if(o!=null&&(s=t?t(o):o))return s;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(s=t?t(l):l))return s}let r=this.state.plugins;if(r)for(let i=0;i<r.length;i++){let l=r[i].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(he){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&&sm(this.dom),Fe(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 cm(this,e)}coordsAtPos(e,t=1){return za(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,o=-1){let s=this.docView.posFromDOM(e,t,o);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,t){return fm(this,t||this.state,e)}pasteHTML(e,t){return Hn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Hn(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Gm(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ar(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,jf())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return jm(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?ae&&this.root.nodeType===11&&Yf(this.dom.ownerDocument)==this.dom&&hg(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Dc(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 o in t)o=="class"?e.class+=" "+t[o]:o=="style"?e.style=(e.style?e.style+";":"")+t[o]:!e[o]&&o!="contenteditable"&&o!="nodeName"&&(e[o]=String(t[o]))}),e.translate||(e.translate="no"),[fe.node(0,n.state.doc.content.size,e)]}function Lc(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:fe.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function zc(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Cg(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 $c(n){let e=Object.create(null);function t(o){for(let s in o)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=o[s])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function kg(n,e){let t=0,o=0;for(let s in n){if(n[s]!=e[s])return!0;t++}for(let s in e)o++;return t!=o}function Vc(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 Nr,Or;if(typeof WeakMap<"u"){let n=new WeakMap;Nr=e=>n.get(e),Or=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Nr=o=>{for(let s=0;s<n.length;s+=2)if(n[s]==o)return n[s+1]},Or=(o,s)=>(t==10&&(t=0),n[t++]=o,n[t++]=s)}var U=class{constructor(n,e,t,o){this.width=n,this.height=e,this.map=t,this.problems=o}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const o=e%this.width,s=e/this.width|0;let r=o+1,i=s+1;for(let l=1;r<this.width&&this.map[e+l]==t;l++)r++;for(let l=1;i<this.height&&this.map[e+this.width*l]==t;l++)i++;return{left:o,top:s,right:r,bottom:i}}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:o,right:s,top:r,bottom:i}=this.findCell(n);return e=="horiz"?(t<0?o==0:s==this.width)?null:this.map[r*this.width+(t<0?o-1:s)]:(t<0?r==0:i==this.height)?null:this.map[o+this.width*(t<0?r-1:i)]}rectBetween(n,e){const{left:t,right:o,top:s,bottom:r}=this.findCell(n),{left:i,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,i),top:Math.min(s,a),right:Math.max(o,l),bottom:Math.max(r,c)}}cellsInRect(n){const e=[],t={};for(let o=n.top;o<n.bottom;o++)for(let s=n.left;s<n.right;s++){const r=o*this.width+s,i=this.map[r];t[i]||(t[i]=!0,!(s==n.left&&s&&this.map[r-1]==i||o==n.top&&o&&this.map[r-this.width]==i)&&e.push(i))}return e}positionAt(n,e,t){for(let o=0,s=0;;o++){const r=s+t.child(o).nodeSize;if(o==n){let i=e+n*this.width;const l=(n+1)*this.width;for(;i<l&&this.map[i]<s;)i++;return i==l?r-1:this.map[i]}s=r}}static get(n){return Nr(n)||Or(n,Tg(n))}};function Tg(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=Mg(n),t=n.childCount,o=[];let s=0,r=null;const i=[];for(let c=0,d=e*t;c<d;c++)o[c]=0;for(let c=0,d=0;c<t;c++){const u=n.child(c);d++;for(let f=0;;f++){for(;s<o.length&&o[s]!=0;)s++;if(f==u.childCount)break;const m=u.child(f),{colspan:g,rowspan:v,colwidth:w}=m.attrs;for(let y=0;y<v;y++){if(y+c>=t){(r||(r=[])).push({type:"overlong_rowspan",pos:d,n:v-y});break}const b=s+y*e;for(let x=0;x<g;x++){o[b+x]==0?o[b+x]=d:(r||(r=[])).push({type:"collision",row:c,pos:d,n:g-x});const S=w&&w[x];if(S){const C=(b+x)%e*2,E=i[C];E==null||E!=S&&i[C+1]==1?(i[C]=S,i[C+1]=1):E==S&&i[C+1]++}}}s+=g,d+=m.nodeSize}const p=(c+1)*e;let h=0;for(;s<p;)o[s++]==0&&h++;h&&(r||(r=[])).push({type:"missing",row:c,n:h}),d++}const l=new U(e,t,o,r);let a=!1;for(let c=0;!a&&c<i.length;c+=2)i[c]!=null&&i[c+1]<t&&(a=!0);return a&&Eg(l,i,n),l}function Mg(n){let e=-1,t=!1;for(let o=0;o<n.childCount;o++){const s=n.child(o);let r=0;if(t)for(let i=0;i<o;i++){const l=n.child(i);for(let a=0;a<l.childCount;a++){const c=l.child(a);i+c.attrs.rowspan>o&&(r+=c.attrs.colspan)}}for(let i=0;i<s.childCount;i++){const l=s.child(i);r+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=r:e!=r&&(e=Math.max(e,r))}return e}function Eg(n,e,t){n.problems||(n.problems=[]);const o={};for(let s=0;s<n.map.length;s++){const r=n.map[s];if(o[r])continue;o[r]=!0;const i=t.nodeAt(r);if(!i)throw new RangeError(`No cell with offset ${r} found`);let l=null;const a=i.attrs;for(let c=0;c<a.colspan;c++){const d=(s+c)%n.width,u=e[d*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=Ag(a)))[c]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:r,colwidth:l})}}function Ag(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Bc(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),o=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(i=>Number(i)):null,s=Number(n.getAttribute("colspan")||1),r={colspan:s,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:o&&o.length==s?o:null};for(const i in e){const l=e[i].getFromDOM,a=l&&l(n);a!=null&&(r[i]=a)}return r}function Hc(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 o in e){const s=e[o].setDOMAttr;s&&s(n.attrs[o],t)}return t}function Pg(n){const e=n.cellAttributes||{},t={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const o in e)t[o]={default:e[o].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:o=>Bc(o,e)}],toDOM(o){return["td",Hc(o,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:o=>Bc(o,e)}],toDOM(o){return["th",Hc(o,e),0]}}}}function De(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const o=n.nodes[t],s=o.spec.tableRole;s&&(e[s]=o)}}return e}var lt=new Nn("selectingCells");function _n(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 Ko(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 Ir(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=_n(e.$head)||Ng(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Ng(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const o=e.type.spec.tableRole;if(o=="cell"||o=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const o=e.type.spec.tableRole;if(o=="cell"||o=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function Rr(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function Og(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Dr(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Fc(n,e,t){const o=n.node(-1),s=U.get(o),r=n.start(-1),i=s.nextCell(n.pos-r,e,t);return i==null?null:n.node(0).resolve(r+i)}function hn(n,e,t=1){const o={...n,colspan:n.colspan-t};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(e,t),o.colwidth.some(s=>s>0)||(o.colwidth=null)),o}var Y=class je extends D{constructor(e,t=e){const o=e.node(-1),s=U.get(o),r=e.start(-1),i=s.rectBetween(e.pos-r,t.pos-r),l=e.node(0),a=s.cellsInRect(i).filter(d=>d!=t.pos-r);a.unshift(t.pos-r);const c=a.map(d=>{const u=o.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);const p=r+d+1;return new Ql(l.resolve(p),l.resolve(p+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const o=e.resolve(t.map(this.$anchorCell.pos)),s=e.resolve(t.map(this.$headCell.pos));if(Rr(o)&&Rr(s)&&Dr(o,s)){const r=this.$anchorCell.node(-1)!=o.node(-1);return r&&this.isRowSelection()?je.rowSelection(o,s):r&&this.isColSelection()?je.colSelection(o,s):new je(o,s)}return L.between(o,s)}content(){const e=this.$anchorCell.node(-1),t=U.get(e),o=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),r={},i=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let d=a*t.width+s.left,u=s.left;u<s.right;u++,d++){const p=t.map[d];if(r[p])continue;r[p]=!0;const h=t.findCell(p);let f=e.nodeAt(p);if(!f)throw RangeError(`No cell with offset ${p} found`);const m=s.left-h.left,g=h.right-s.right;if(m>0||g>0){let v=f.attrs;if(m>0&&(v=hn(v,0,m)),g>0&&(v=hn(v,v.colspan-g,g)),h.left<s.left){if(f=f.type.createAndFill(v),!f)throw RangeError(`Could not create cell with attrs ${JSON.stringify(v)}`)}else f=f.type.create(v,f.content)}if(h.top<s.top||h.bottom>s.bottom){const v={...f.attrs,rowspan:Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top)};h.top<s.top?f=f.type.createAndFill(v):f=f.type.create(v,f.content)}c.push(f)}i.push(e.child(a).copy(k.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new A(k.from(l),1,1)}replace(e,t=A.empty){const o=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){const{$from:l,$to:a}=s[i],c=e.mapping.slice(o);e.replace(c.map(l.pos),c.map(a.pos),i?A.empty:t)}const r=D.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,t){this.replace(e,new A(k.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),o=U.get(t),s=this.$anchorCell.start(-1),r=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let i=0;i<r.length;i++)e(t.nodeAt(r[i]),s+r[i])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const o=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const o=e.node(-1),s=U.get(o),r=e.start(-1),i=s.findCell(e.pos-r),l=s.findCell(t.pos-r),a=e.node(0);return i.top<=l.top?(i.top>0&&(e=a.resolve(r+s.map[i.left])),l.bottom<s.height&&(t=a.resolve(r+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(r+s.map[l.left])),i.bottom<s.height&&(e=a.resolve(r+s.map[s.width*(s.height-1)+i.right-1]))),new je(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=U.get(e),o=this.$anchorCell.start(-1),s=t.colCount(this.$anchorCell.pos-o),r=t.colCount(this.$headCell.pos-o);if(Math.min(s,r)>0)return!1;const i=s+this.$anchorCell.nodeAfter.attrs.colspan,l=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==t.width}eq(e){return e instanceof je&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const o=e.node(-1),s=U.get(o),r=e.start(-1),i=s.findCell(e.pos-r),l=s.findCell(t.pos-r),a=e.node(0);return i.left<=l.left?(i.left>0&&(e=a.resolve(r+s.map[i.top*s.width])),l.right<s.width&&(t=a.resolve(r+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(r+s.map[l.top*s.width])),i.right<s.width&&(e=a.resolve(r+s.map[s.width*(i.top+1)-1]))),new je(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new je(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){return new je(e.resolve(t),e.resolve(o))}getBookmark(){return new Ig(this.$anchorCell.pos,this.$headCell.pos)}};Y.prototype.visible=!1,D.jsonID("cell",Y);var Ig=class Fd{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Fd(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),o=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&o.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&o.index()<o.parent.childCount&&Dr(t,o)?new Y(t,o):D.near(o,1)}};function Rg(n){if(!(n.selection instanceof Y))return null;const e=[];return n.selection.forEachCell((t,o)=>{e.push(fe.node(o,o+t.nodeSize,{class:"selectedCell"}))}),q.create(n.doc,e)}function Dg({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,o=e.pos,s=n.depth;for(;s>=0&&!(n.after(s+1)<n.end(s));s--,t++);for(let r=e.depth;r>=0&&!(e.before(r+1)>e.start(r));r--,o--);return t==o&&/row|table/.test(n.node(s).type.spec.tableRole)}function Lg({$from:n,$to:e}){let t,o;for(let s=n.depth;s>0;s--){const r=n.node(s);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){t=r;break}}for(let s=e.depth;s>0;s--){const r=e.node(s);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){o=r;break}}return t!==o&&e.parentOffset===0}function zg(n,e,t){const o=(e||n).selection,s=(e||n).doc;let r,i;if(o instanceof R&&(i=o.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")r=Y.create(s,o.from);else if(i=="row"){const l=s.resolve(o.from+1);r=Y.rowSelection(l,l)}else if(!t){const l=U.get(o.node),a=o.from+1,c=a+l.map[l.width*l.height-1];r=Y.create(s,a+1,c)}}else o instanceof L&&Dg(o)?r=L.create(s,o.from):o instanceof L&&Lg(o)&&(r=L.create(s,o.$from.start(),o.$from.end()));return r&&(e||(e=n.tr)).setSelection(r),e}var $g=new Nn("fix-tables");function _c(n,e,t,o){const s=n.childCount,r=e.childCount;e:for(let i=0,l=0;i<r;i++){const a=e.child(i);for(let c=l,d=Math.min(s,i+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}o(a,t),l<s&&n.child(l).sameMarkup(a)?_c(n.child(l),a,t+1,o):a.nodesBetween(0,a.content.size,o,t+1),t+=a.nodeSize}}function Vg(n,e){let t;const o=(s,r)=>{s.type.spec.tableRole=="table"&&(t=Bg(n,s,r,t))};return e?e.doc!=n.doc&&_c(e.doc,n.doc,0,o):n.doc.descendants(o),t}function Bg(n,e,t,o){const s=U.get(e);if(!s.problems)return o;o||(o=n.tr);const r=[];for(let a=0;a<s.height;a++)r.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let p=0;p<u.rowspan;p++)r[c.row+p]+=c.n;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,hn(u,u.colspan-c.n,c.n))}else if(c.type=="missing")r[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}}let i,l;for(let a=0;a<r.length;a++)r[a]&&(i==null&&(i=a),l=a);for(let a=0,c=t+1;a<s.height;a++){const d=e.child(a),u=c+d.nodeSize,p=r[a];if(p>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const f=[];for(let g=0;g<p;g++){const v=De(n.schema)[h].createAndFill();v&&f.push(v)}const m=(a==0||i==a-1)&&l==a?c+1:u-1;o.insert(o.mapping.map(m),f)}c=u}return o.setMeta($g,{fixTables:!0})}function Gc(n){const e=n.selection,t=Ir(n),o=t.node(-1),s=t.start(-1),r=U.get(o);return{...e instanceof Y?r.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):r.findCell(t.pos-s),tableStart:s,map:r,table:o}}function Hg(n){return function(e,t){if(!Ko(e))return!1;if(t){const o=De(e.schema),s=Gc(e),r=e.tr,i=s.map.cellsInRect(n=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:n=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=i.map(a=>s.table.nodeAt(a));for(let a=0;a<i.length;a++)l[a].type==o.header_cell&&r.setNodeMarkup(s.tableStart+i[a],o.cell,l[a].attrs);if(r.steps.length==0)for(let a=0;a<i.length;a++)r.setNodeMarkup(s.tableStart+i[a],o.header_cell,l[a].attrs);t(r)}return!0}}function Wc(n,e,t){const o=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let s=0;s<o.length;s++){const r=e.table.nodeAt(o[s]);if(r&&r.type!==t.header_cell)return!1}return!0}function Lr(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Hg(n):function(t,o){if(!Ko(t))return!1;if(o){const s=De(t.schema),r=Gc(t),i=t.tr,l=Wc("row",r,s),a=Wc("column",r,s),d=(n==="column"?l:n==="row"?a:!1)?1:0,u=n=="column"?{left:0,top:d,right:1,bottom:r.map.height}:n=="row"?{left:d,top:0,right:r.map.width,bottom:1}:r,p=n=="column"?a?s.cell:s.header_cell:n=="row"?l?s.cell:s.header_cell:s.cell;r.map.cellsInRect(u).forEach(h=>{const f=h+r.tableStart,m=i.doc.nodeAt(f);m&&i.setNodeMarkup(f,p,m.attrs)}),o(i)}return!0}}Lr("row",{useDeprecatedLogic:!0}),Lr("column",{useDeprecatedLogic:!0}),Lr("cell",{useDeprecatedLogic:!0});function Fg(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let o=n.index(-1)-1,s=n.before();o>=0;o--){const r=n.node(-1).child(o),i=r.lastChild;if(i)return s-1-i.nodeSize;s-=r.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let o=n.indexAfter(-1),s=n.after();o<t.childCount;o++){const r=t.child(o);if(r.childCount)return s+1;s+=r.nodeSize}}return null}function jc(n){return function(e,t){if(!Ko(e))return!1;const o=Fg(Ir(e),n);if(o==null)return!1;if(t){const s=e.doc.resolve(o);t(e.tr.setSelection(L.between(s,Og(s))).scrollIntoView())}return!0}}function Uo(n,e){const t=n.selection;if(!(t instanceof Y))return!1;if(e){const o=n.tr,s=De(n.schema).cell.createAndFill().content;t.forEachCell((r,i)=>{r.content.eq(s)||o.replace(o.mapping.map(i+1),o.mapping.map(i+r.nodeSize-1),new A(s,0,0))}),o.docChanged&&e(o)}return!0}function _g(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:o}=n;for(;e.childCount==1&&(t>0&&o>0||e.child(0).type.spec.tableRole=="table");)t--,o--,e=e.child(0).content;const s=e.child(0),r=s.type.spec.tableRole,i=s.type.schema,l=[];if(r=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),u=a<e.childCount-1?0:Math.max(0,o-1);(d||u)&&(c=zr(De(i).row,new A(c,d,u)).content),l.push(c)}else if(r=="cell"||r=="header_cell")l.push(t||o?zr(De(i).row,new A(e,t,o)).content:e);else return null;return Gg(i,l)}function Gg(n,e){const t=[];for(let s=0;s<e.length;s++){const r=e[s];for(let i=r.childCount-1;i>=0;i--){const{rowspan:l,colspan:a}=r.child(i).attrs;for(let c=s;c<s+l;c++)t[c]=(t[c]||0)+a}}let o=0;for(let s=0;s<t.length;s++)o=Math.max(o,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(k.empty),t[s]<o){const r=De(n).cell.createAndFill(),i=[];for(let l=t[s];l<o;l++)i.push(r);e[s]=e[s].append(k.from(i))}return{height:e.length,width:o,rows:e}}function zr(n,e){const t=n.createAndFill();return new Xl(t).replace(0,t.content.size,e).doc}function Wg({width:n,height:e,rows:t},o,s){if(n!=o){const r=[],i=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=r[l]||0,u=0;d<o;u++){let p=a.child(u%a.childCount);d+p.attrs.colspan>o&&(p=p.type.createChecked(hn(p.attrs,p.attrs.colspan,d+p.attrs.colspan-o),p.content)),c.push(p),d+=p.attrs.colspan;for(let h=1;h<p.attrs.rowspan;h++)r[l+h]=(r[l+h]||0)+p.attrs.colspan}i.push(k.from(c))}t=i,n=o}if(e!=s){const r=[];for(let i=0,l=0;i<s;i++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);i+u.attrs.rowspan>s&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,s-u.attrs.rowspan)},u.content)),a.push(u)}r.push(k.from(a))}t=r,e=s}return{width:n,height:e,rows:t}}function jg(n,e,t,o,s,r,i){const l=n.doc.type.schema,a=De(l);let c,d;if(s>e.width)for(let u=0,p=0;u<e.height;u++){const h=t.child(u);p+=h.nodeSize;const f=[];let m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=d||(d=a.header_cell.createAndFill());for(let g=e.width;g<s;g++)f.push(m);n.insert(n.mapping.slice(i).map(p-1+o),f)}if(r>e.height){const u=[];for(let f=0,m=(e.height-1)*e.width;f<Math.max(e.width,s);f++){const g=f>=e.width?!1:t.nodeAt(e.map[m+f]).type==a.header_cell;u.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const p=a.row.create(null,k.from(u)),h=[];for(let f=e.height;f<r;f++)h.push(p);n.insert(n.mapping.slice(i).map(o+t.nodeSize-2),h)}return!!(c||d)}function qc(n,e,t,o,s,r,i,l){if(i==0||i==e.height)return!1;let a=!1;for(let c=s;c<r;c++){const d=i*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){a=!0;const p=t.nodeAt(u),{top:h,left:f}=e.findCell(u);n.setNodeMarkup(n.mapping.slice(l).map(u+o),null,{...p.attrs,rowspan:i-h}),n.insert(n.mapping.slice(l).map(e.positionAt(i,f,t)),p.type.createAndFill({...p.attrs,rowspan:h+p.attrs.rowspan-i})),c+=p.attrs.colspan-1}}return a}function Kc(n,e,t,o,s,r,i,l){if(i==0||i==e.width)return!1;let a=!1;for(let c=s;c<r;c++){const d=c*e.width+i,u=e.map[d];if(e.map[d-1]==u){a=!0;const p=t.nodeAt(u),h=e.colCount(u),f=n.mapping.slice(l).map(u+o);n.setNodeMarkup(f,null,hn(p.attrs,i-h,p.attrs.colspan-(i-h))),n.insert(f+p.nodeSize,p.type.createAndFill(hn(p.attrs,0,i-h))),c+=p.attrs.rowspan-1}}return a}function Uc(n,e,t,o,s){let r=t?n.doc.nodeAt(t-1):n.doc;if(!r)throw new Error("No table found");let i=U.get(r);const{top:l,left:a}=o,c=a+s.width,d=l+s.height,u=n.tr;let p=0;function h(){if(r=t?u.doc.nodeAt(t-1):u.doc,!r)throw new Error("No table found");i=U.get(r),p=u.mapping.maps.length}jg(u,i,r,t,c,d,p)&&h(),qc(u,i,r,t,a,c,l,p)&&h(),qc(u,i,r,t,a,c,d,p)&&h(),Kc(u,i,r,t,l,d,a,p)&&h(),Kc(u,i,r,t,l,d,c,p)&&h();for(let f=l;f<d;f++){const m=i.positionAt(f,a,r),g=i.positionAt(f,c,r);u.replace(u.mapping.slice(p).map(m+t),u.mapping.slice(p).map(g+t),new A(s.rows[f-l],0,0))}h(),u.setSelection(new Y(u.doc.resolve(t+i.positionAt(l,a,r)),u.doc.resolve(t+i.positionAt(d-1,c-1,r)))),e(u)}var qg=ka({ArrowLeft:Yo("horiz",-1),ArrowRight:Yo("horiz",1),ArrowUp:Yo("vert",-1),ArrowDown:Yo("vert",1),"Shift-ArrowLeft":Zo("horiz",-1),"Shift-ArrowRight":Zo("horiz",1),"Shift-ArrowUp":Zo("vert",-1),"Shift-ArrowDown":Zo("vert",1),Backspace:Uo,"Mod-Backspace":Uo,Delete:Uo,"Mod-Delete":Uo});function Jo(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Yo(n,e){return(t,o,s)=>{if(!s)return!1;const r=t.selection;if(r instanceof Y)return Jo(t,o,D.near(r.$headCell,e));if(n!="horiz"&&!r.empty)return!1;const i=Jc(s,n,e);if(i==null)return!1;if(n=="horiz")return Jo(t,o,D.near(t.doc.resolve(r.head+e),e));{const l=t.doc.resolve(i),a=Fc(l,n,e);let c;return a?c=D.near(a,1):e<0?c=D.near(t.doc.resolve(l.before(-1)),-1):c=D.near(t.doc.resolve(l.after(-1)),1),Jo(t,o,c)}}}function Zo(n,e){return(t,o,s)=>{if(!s)return!1;const r=t.selection;let i;if(r instanceof Y)i=r;else{const a=Jc(s,n,e);if(a==null)return!1;i=new Y(t.doc.resolve(a))}const l=Fc(i.$headCell,n,e);return l?Jo(t,o,new Y(i.$anchorCell,l)):!1}}function Kg(n,e){const t=n.state.doc,o=_n(t.resolve(e));return o?(n.dispatch(n.state.tr.setSelection(new Y(o))),!0):!1}function Ug(n,e,t){if(!Ko(n.state))return!1;let o=_g(t);const s=n.state.selection;if(s instanceof Y){o||(o={width:1,height:1,rows:[k.from(zr(De(n.state.schema).cell,t))]});const r=s.$anchorCell.node(-1),i=s.$anchorCell.start(-1),l=U.get(r).rectBetween(s.$anchorCell.pos-i,s.$headCell.pos-i);return o=Wg(o,l.right-l.left,l.bottom-l.top),Uc(n.state,n.dispatch,i,l,o),!0}else if(o){const r=Ir(n.state),i=r.start(-1);return Uc(n.state,n.dispatch,i,U.get(r.node(-1)).findCell(r.pos-i),o),!0}else return!1}function Jg(n,e){var t;if(e.ctrlKey||e.metaKey)return;const o=Yc(n,e.target);let s;if(e.shiftKey&&n.state.selection instanceof Y)r(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(s=_n(n.state.selection.$anchor))!=null&&((t=$r(n,e))==null?void 0:t.pos)!=s.pos)r(s,e),e.preventDefault();else if(!o)return;function r(a,c){let d=$r(n,c);const u=lt.getState(n.state)==null;if(!d||!Dr(a,d))if(u)d=a;else return;const p=new Y(a,d);if(u||!n.state.selection.eq(p)){const h=n.state.tr.setSelection(p);u&&h.setMeta(lt,a.pos),n.dispatch(h)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",l),lt.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(lt,-1))}function l(a){const c=a,d=lt.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(Yc(n,c.target)!=o&&(u=$r(n,e),!u))return i();u&&r(u,c)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",l)}function Jc(n,e,t){if(!(n.state.selection instanceof L))return null;const{$head:o}=n.state.selection;for(let s=o.depth-1;s>=0;s--){const r=o.node(s);if((t<0?o.index(s):o.indexAfter(s))!=(t<0?0:r.childCount))return null;if(r.type.spec.tableRole=="cell"||r.type.spec.tableRole=="header_cell"){const l=o.before(s),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Yc(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function $r(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?_n(n.state.doc.resolve(t.pos)):null}var Yg=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")),Vr(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,Vr(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function Vr(n,e,t,o,s,r){var i;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let u=0,p=0;u<d.childCount;u++){const{colspan:h,colwidth:f}=d.child(u).attrs;for(let m=0;m<h;m++,p++){const g=s==p?r:f&&f[m],v=g?g+"px":"";if(l+=g||o,g||(a=!1),c)c.style.width!=v&&(c.style.width=v),c=c.nextSibling;else{const w=document.createElement("col");w.style.width=v,e.appendChild(w)}}}for(;c;){const u=c.nextSibling;(i=c.parentNode)==null||i.removeChild(c),c=u}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var ye=new Nn("tableColumnResizing");function Zg({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:o=Yg,lastColumnResizable:s=!0}={}){const r=new Pn({key:ye,state:{init(i,l){var a,c;const d=(c=(a=r.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,u=De(l.schema).table.name;return o&&d&&(d[u]=(p,h)=>new o(p,t,h)),new Xg(-1,!1)},apply(i,l){return l.apply(i)}},props:{attributes:i=>{const l=ye.getState(i);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(i,l)=>{Qg(i,l,n,s)},mouseleave:i=>{e1(i)},mousedown:(i,l)=>{t1(i,l,e,t)}},decorations:i=>{const l=ye.getState(i);if(l&&l.activeHandle>-1)return i1(i,l.activeHandle)},nodeViews:{}}});return r}var Xg=class is{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,o=e.getMeta(ye);if(o&&o.setHandle!=null)return new is(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new is(t.activeHandle,o.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);return Rr(e.doc.resolve(s))||(s=-1),new is(s,t.dragging)}return t}};function Qg(n,e,t,o){const s=ye.getState(n.state);if(s&&!s.dragging){const r=o1(e.target);let i=-1;if(r){const{left:l,right:a}=r.getBoundingClientRect();e.clientX-l<=t?i=Zc(n,e,"left",t):a-e.clientX<=t&&(i=Zc(n,e,"right",t))}if(i!=s.activeHandle){if(!o&&i!==-1){const l=n.state.doc.resolve(i),a=l.node(-1),c=U.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Qc(n,i)}}}function e1(n){const e=ye.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Qc(n,-1)}function t1(n,e,t,o){var s;const r=(s=n.dom.ownerDocument.defaultView)!=null?s:window,i=ye.getState(n.state);if(!i||i.activeHandle==-1||i.dragging)return!1;const l=n.state.doc.nodeAt(i.activeHandle),a=n1(n,i.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(ye,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){r.removeEventListener("mouseup",c),r.removeEventListener("mousemove",d);const p=ye.getState(n.state);p!=null&&p.dragging&&(s1(n,p.activeHandle,Xc(p.dragging,u,t)),n.dispatch(n.state.tr.setMeta(ye,{setDragging:null})))}function d(u){if(!u.which)return c(u);const p=ye.getState(n.state);if(p&&p.dragging){const h=Xc(p.dragging,u,t);ed(n,p.activeHandle,h,o)}}return ed(n,i.activeHandle,a,o),r.addEventListener("mouseup",c),r.addEventListener("mousemove",d),e.preventDefault(),!0}function n1(n,e,{colspan:t,colwidth:o}){const s=o&&o[o.length-1];if(s)return s;const r=n.domAtPos(e);let l=r.node.childNodes[r.offset].offsetWidth,a=t;if(o)for(let c=0;c<t;c++)o[c]&&(l-=o[c],a--);return l/a}function o1(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Zc(n,e,t,o){const s=t=="right"?-o:o,r=n.posAtCoords({left:e.clientX+s,top:e.clientY});if(!r)return-1;const{pos:i}=r,l=_n(n.state.doc.resolve(i));if(!l)return-1;if(t=="right")return l.pos;const a=U.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function Xc(n,e,t){const o=e.clientX-n.startX;return Math.max(t,n.startWidth+o)}function Qc(n,e){n.dispatch(n.state.tr.setMeta(ye,{setHandle:e}))}function s1(n,e,t){const o=n.state.doc.resolve(e),s=o.node(-1),r=U.get(s),i=o.start(-1),l=r.colCount(o.pos-i)+o.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<r.height;c++){const d=c*r.width+l;if(c&&r.map[d]==r.map[d-r.width])continue;const u=r.map[d],p=s.nodeAt(u).attrs,h=p.colspan==1?0:l-r.colCount(u);if(p.colwidth&&p.colwidth[h]==t)continue;const f=p.colwidth?p.colwidth.slice():r1(p.colspan);f[h]=t,a.setNodeMarkup(i+u,null,{...p,colwidth:f})}a.docChanged&&n.dispatch(a)}function ed(n,e,t,o){const s=n.state.doc.resolve(e),r=s.node(-1),i=s.start(-1),l=U.get(r).colCount(s.pos-i)+s.nodeAfter.attrs.colspan-1;let a=n.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Vr(r,a.firstChild,a,o,l,t)}function r1(n){return Array(n).fill(0)}function i1(n,e){var t;const o=[],s=n.doc.resolve(e),r=s.node(-1);if(!r)return q.empty;const i=U.get(r),l=s.start(-1),a=i.colCount(s.pos-l)+s.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){const d=a+c*i.width;if((a==i.width-1||i.map[d]!=i.map[d+1])&&(c==0||i.map[d]!=i.map[d-i.width])){const u=i.map[d],p=l+u+r.nodeAt(u).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",(t=ye.getState(n))!=null&&t.dragging&&o.push(fe.node(l+u,l+u+r.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),o.push(fe.widget(p,h))}}return q.create(n.doc,o)}function l1({allowTableNodeSelection:n=!1}={}){return new Pn({key:lt,state:{init(){return null},apply(e,t){const o=e.getMeta(lt);if(o!=null)return o==-1?null:o;if(t==null||!e.docChanged)return t;const{deleted:s,pos:r}=e.mapping.mapResult(t);return s?null:r}},props:{decorations:Rg,handleDOMEvents:{mousedown:Jg},createSelectionBetween(e){return lt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Kg,handleKeyDown:qg,handlePaste:Ug},appendTransaction(e,t,o){return zg(o,Vg(o,t),n)}})}const Gn=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},td="data-gs-mrk-fs",nd="data-gs-ib",Xo="data-gs-ifrg",_e="attrs",od={[_e]:{default:"{}"}},Ge={[_e]:{default:{}}},sd=n=>({[_e]:JSON.stringify(Gn(n))}),We=n=>({attrs:Gn(n)}),Wn=n=>e=>[n,e.attrs.attrs,0],at=n=>n.attrs[_e]?JSON.parse(n.attrs[_e]):{},a1={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${Xo}]`,getAttrs:We}],toDOM:()=>["span",{[Xo]:""},0]},div:{group:"block",content:"inline*",attrs:Ge,parseDOM:[{tag:"div",getAttrs:We}],toDOM:Wn("div")},paragraph:{group:"block",content:"inline*",attrs:Ge,parseDOM:[{tag:"p",getAttrs:We}],toDOM:Wn("p")},orderedList:{group:"block",content:"listItem+",attrs:Ge,parseDOM:[{tag:"ol",getAttrs:We}],toDOM:Wn("ol")},bulletList:{group:"block",content:"listItem+",attrs:Ge,parseDOM:[{tag:"ul",getAttrs:We}],toDOM:Wn("ul")},listItem:{content:"block*",group:"block",attrs:Ge,parseDOM:[{tag:"li",getAttrs:We}],toDOM:Wn("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:Ge,parseDOM:[{tag:"pre",getAttrs:We}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:Ge,parseDOM:[{tag:"img[src]",getAttrs:We}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${nd}]`}],toDOM(){return["br",{[nd]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:Ge,parseDOM:[{tag:"br",getAttrs:We}],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:Gn(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...Pg({tableGroup:"block",cellContent:"block+",cellAttributes:{[_e]:{default:Ge[_e].default,getFromDOM:Gn,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:Gn(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},jn=(n,e)=>({attrs:od,parseDOM:n.map(t=>({tag:t,getAttrs:sd})),toDOM:e}),c1={strong:jn(["strong","b"],n=>["b",at(n)]),link:jn(["a"],n=>["a",at(n),0]),em:jn(["em","i"],n=>["em",at(n)]),underline:jn(["u"],n=>["u",at(n),0]),strikethrough:jn(["s"],n=>["s",at(n),0]),font_size:{attrs:{...od,size:{default:null}},parseDOM:[{tag:`span[${td}]`,getAttrs:n=>({...sd(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...at(n),[td]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},rd=new Ah({nodes:a1,marks:c1}),Qo=new WeakMap,Br=new WeakMap,d1=(n,e)=>{Qo.set(n,e),Br.set(e,n)},u1=(n,e)=>{Qo.delete(n),Br.delete(e)},Hr=n=>Qo.get(n),p1=n=>Br.get(n),id=n=>{var t;const e=p1(n);return(t=e==null?void 0:e.__gjsv)==null?void 0:t.model},h1=n=>n.dispatchEvent(new CustomEvent("input"));function f1(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(Xo)){if(t.getAttribute("style")){t.removeAttribute(Xo);return}const o=t.parentElement;if(o){for(;t.firstChild;)o.insertBefore(t.firstChild,t);o.removeChild(t)}}else Array.from(t.children).forEach(o=>e(o))};e(n)}function m1(n,e={}){if(!e.enableOnClick)return()=>{};const t=n.Components.events,o=d=>n.getSelectedAll().includes(d),s=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),r=d=>d.isChildOf("text"),i=d=>n.getEditing()===d,l=(d,u={})=>{d.trigger("focus",u.event)},a=(d,u)=>{o(d)&&s(d)&&!i(d)&&l(d,u)},c=(d,u)=>{if(o(d)&&!s(d)&&r(d)){const p=d.parents().find(h=>h.isInstanceOf("text"));p&&(l(p,u),setTimeout(()=>n.select(p),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const g1=(n,e)=>{const t=y1(n);return t&&M1(t)?b1(n,e):t?ha(()=>({type:n.schema.nodes.div}))(n,e):!1};function y1(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 b1(n,e){const{selection:t,schema:o,tr:s}=n;s.split(t.from,1);const r=t.from+1,i=s.doc.nodeAt(r),l={...i.attrs.attrs,id:void 0},a=i.textContent.length>0,c=i.textContent.length||0,d=i.textContent||" ",u=o.text(d),p=o.nodes.div.create(l,a?u:[],[]);return s.replaceRangeWith(r,r+c+2,p),s.setSelection(L.create(s.doc,r+1)),e==null||e(s.scrollIntoView()),!0}function v1(n,e,t){const{state:o,dispatch:s}=n,{selection:r,tr:i}=o,l=(a,c,d)=>{const u={};return a.split(";").forEach(p=>{const[h,f]=p.split(":").map(m=>m.trim());h&&(u[h]=f)}),u[c]=d,Object.entries(u).map(([p,h])=>`${p}: ${h}`).join("; ")};if(!r.empty||t)i.doc.nodesBetween(r.from,r.to,(a,c)=>{var d,u;if(a.type===o.schema.nodes.image){const p=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);i.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:p}})}else if(a.type.isBlock){const p=l(((u=a.attrs.attrs)==null?void 0:u.style)||"","text-align",e);ld(a)?i.setBlockType(r.from,void 0,o.schema.nodes.div,{attrs:{style:p}}):i.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:p}})}});else{const a=o.doc.resolve(r.from),c=a.start(a.depth),d=o.doc.nodeAt(c);if(d!=null&&d.type.isBlock){const u=l(d.attrs.style||"","text-align",e);i.setNodeMarkup(c,void 0,{...d.attrs,style:u})}}i.docChanged&&s(i.scrollIntoView())}const qn=(n,e)=>{const{from:t,to:o}=n.selection;let s=!1;return n.doc.nodesBetween(t,o,r=>{if(s)return!1;r.marks.some(i=>i.type===e)&&(s=!0)}),s};function x1(n,e,t="_blank"){const{state:o,dispatch:s}=n,{schema:r,selection:i,tr:l}=o,a=r.marks.link;try{const c=a.create({[_e]:JSON.stringify({href:e,target:t})});l.addMark(i.from,i.to,c),s(l.scrollIntoView())}catch(c){console.error("Error applying link mark:",c)}}function S1(n,e){const{state:t,dispatch:o}=n,{selection:s,tr:r}=t;if(s.empty)return;const i=t.schema.marks.font_size;if(!i){console.error("Font size mark is not defined in the schema.");return}r.addMark(s.from,s.to,i.create({size:e})),o(r.scrollIntoView())}const Rt=(n,e)=>{const{doc:t,selection:o}=n.state,s=t.resolve(o.from);for(let r=s.depth;r>0;r--){const i=s.node(r);if(e(i))return{pos:r>0?s.before(r):0,start:s.start(r),depth:r,node:i}}},w1=n=>(n||"").split(";").map(e=>e.split(":")).reduce((e,[t,o])=>(t=t.replace(/-./g,s=>s.toUpperCase()[1]).trim(),e[t]=`${o}`.trim(),e),{});function C1(...n){return(e,t)=>{const o=i=>{e=e.apply(i),t==null||t(i)},s=n.pop();return n.reduce((i,l)=>i||l(e,o),!1)&&s!==void 0&&s(e,t)}}const k1=(n,e)=>{const{state:t,dispatch:o}=n;if(e!=null&&e.event){const{event:s}=e,r=n.posAtCoords({left:s.clientX,top:s.clientY});r!=null&&r.pos&&o(t.tr.setSelection(L.create(t.doc,r.pos)))}else fa(t,o);setTimeout(()=>setTimeout(()=>n.focus()))},Fr=n=>n.isBlock,ld=n=>n.type.name==="inlineFragment",T1=n=>Fr(n)&&!ld(n),ad=n=>n.type.name==="bulletList",cd=n=>n.type.name==="orderedList",M1=n=>n.type.name==="heading",E1=n=>ad(n)||cd(n),dd=(n,e)=>{var r,i;const t=(r=Rt(n,l=>l.type===e))==null?void 0:r.node,o=n.state.schema.nodes.listItem;let s;return t?s=ir(o):(i=Rt(n,E1))!=null&&i.node?s=C1(ir(o),Ta(e)):s=Ta(e),s(n.state,n.dispatch)},ud=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(o=>o.type.name===e)},A1=n=>{var i;const{view:e,prop:t,editor:o,propCSS:s}=n,r=(i=Rt(e,T1))==null?void 0:i.node;if(r){const l=r.attrs.attrs||{},a=w1(l.style);if(t in a)return a[t]||"";if(l.id){const c=o.Components.getById(l.id);return((c==null?void 0:c.getStyle())||{})[s]||""}}return""},P1=n=>{const{view:e,prop:t,markName:o,editor:s,propCSS:r}=n,i=ud(e,o);if(i){const l=i.attrs;if(l[t])return l[t];if(l[_e]){const a=at(i).id;if(a){const c=s.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[r]||""}}}return""},pd=(n,e)=>{const{dispatch:t}=n,{nodes:o,marks:s}=n.state.schema;return{text:{selected:()=>{const{selection:r,doc:i}=n.state;return i.textBetween(r.from,r.to," ")},replace:(r,i={})=>{const{state:l}=n,{from:a}=l.selection;let c=l.tr.replaceSelectionWith(l.schema.text(r));i.select&&(c=c.setSelection(L.create(c.doc,a,a+r.length))),t==null||t(c)}},bold:{toggle:()=>kt(s.strong)(n.state,t),isActive:()=>qn(n.state,s.strong)},italic:{toggle:()=>kt(s.em)(n.state,t),isActive:()=>qn(n.state,s.em)},underline:{toggle:()=>kt(s.underline)(n.state,t),isActive:()=>qn(n.state,s.underline)},strikethrough:{toggle:()=>kt(s.strikethrough)(n.state,t),isActive:()=>qn(n.state,s.strikethrough)},link:{get:()=>{const r=id(n);if(r!=null&&r.is("link"))return r.getAttributes();{const i=ud(n,"link");return i?at(i):{}}},toggle:()=>kt(s.link)(n.state,t),isActive:()=>qn(n.state,s.link),create:r=>{const i=id(n);i!=null&&i.is("link")?(i.addAttributes({href:r.url,target:r.target}),n.focus()):x1(n,r.url,r.target)}},alignText:{get:()=>A1({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:r=>v1(n,r.value,!0)},fontSize:{get:()=>P1({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:r=>S1(n,r.value)},image:{open(){const r="assetLayout",{state:i,dispatch:l}=n,{selection:a,doc:c}=i,d=c.textBetween(a.from,a.to," "),u={id:r,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:p=>{const h={alt:d,src:p.asset.getSrc()};l(i.tr.replaceSelectionWith(o.image.createAndFill({attrs:h})))}}};e.runCommand(_.layoutToggle,u)}},heading:{get:()=>{var i;const r=(i=Rt(n,Fr))==null?void 0:i.node;return`${(r==null?void 0:r.attrs.level)||""}`},set:({value:r})=>{var a;const{state:i}=n,l=(a=Rt(n,Fr))==null?void 0:a.node;wf(i.schema.nodes.heading,{attrs:l==null?void 0:l.attrs.attrs,level:r?parseInt(r,10):0})(i,t)}},listBullet:{isActive:()=>{var r;return!!((r=Rt(n,ad))!=null&&r.node)},toggle:()=>dd(n,o.bulletList)},listOrdered:{isActive:()=>{var r;return!!((r=Rt(n,cd))!=null&&r.node)},toggle:()=>dd(n,o.orderedList)}}};class ct{constructor(e,t,o={}){this.match=e,this.match=e,this.handler=typeof t=="string"?N1(t):t,this.undoable=o.undoable!==!1,this.inCode=o.inCode||!1}}function N1(n){return function(e,t,o,s){let r=n;if(t[1]){let i=t[0].lastIndexOf(t[1]);r+=t[0].slice(i+t[1].length),o+=i;let l=o-s;l>0&&(r=t[0].slice(i-l,i)+r,o=s)}return e.tr.insertText(r,o,s)}}const O1=500;function I1({rules:n}){let e=new Pn({state:{init(){return null},apply(t,o){let s=t.getMeta(this);return s||(t.selectionSet||t.docChanged?null:o)}},props:{handleTextInput(t,o,s,r){return hd(t,o,s,r,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:o}=t.state.selection;o&&hd(t,o.pos,o.pos,"",n,e)})}}},isInputRules:!0});return e}function hd(n,e,t,o,s,r){if(n.composing)return!1;let i=n.state,l=i.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-O1),l.parentOffset,null,"")+o;for(let c=0;c<s.length;c++){let d=s[c];if(l.parent.type.spec.code){if(!d.inCode)continue}else if(d.inCode==="only")continue;let u=d.match.exec(a),p=u&&d.handler(i,u,e-(u[0].length-o.length),t);if(p)return d.undoable&&p.setMeta(r,{transform:p,from:e,to:t,text:o}),n.dispatch(p),!0}return!1}const R1=new ct(/--$/,"—"),D1=new ct(/\.\.\.$/,"…"),L1=new ct(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),z1=new ct(/"$/,"”"),$1=new ct(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),V1=new ct(/'$/,"’"),B1=[L1,z1,$1,V1];function _r(n,e,t=null,o){return new ct(n,(s,r,i,l)=>{let a=t instanceof Function?t(r):t,c=s.tr.delete(i,l),d=c.doc.resolve(i),u=d.blockRange(),p=u&&Wl(u,e,a);if(!p)return null;c.wrap(u,p);let h=c.doc.resolve(i-1).nodeBefore;return h&&h.type==e&&Ro(c.doc,i-1)&&(!o||o(r,h))&&c.join(i-1),c})}function fd(n,e,t=null){return new ct(n,(o,s,r,i)=>{let l=o.doc.resolve(r),a=t instanceof Function?t(s):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?o.tr.delete(r,i).setBlockType(r,r,e,a):null})}function H1(n){return _r(/^\s*>\s$/,n)}function F1(n){return _r(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function _1(n){return _r(/^\s*([-+*])\s$/,n)}function G1(n){return fd(/^```$/,n)}function W1(n,e){return fd(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function j1(n){const e=B1.concat(D1,R1);let t;return(t=n.nodes.blockquote)&&e.push(H1(t)),(t=n.nodes.orderedList)&&e.push(F1(t)),(t=n.nodes.bulletList)&&e.push(_1(t)),(t=n.nodes.codeBlock)&&e.push(G1(t)),(t=n.nodes.heading)&&e.push(W1(t,6)),I1({rules:e})}const q1="rteProseMirror",K1=F.free,Me="rte:selectionchange",Se={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>'},U1=(n,e)=>{var a;const{editor:t,el:o}=n,s=Qo.get(o),r=pd(s,t),i={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},bold:{id:"bold",icon:Se.bold,size:"s",type:"button",editorEvents:{[Me]:({setState:c})=>{c({active:r.bold.isActive()})}},onClick:({setState:c})=>{r.bold.toggle(),c({active:r.bold.isActive()})}},italic:{id:"italic",icon:Se.italic,size:"s",type:"button",editorEvents:{[Me]:({setState:c})=>{c({active:r.italic.isActive()})}},onClick:({setState:c})=>{r.italic.toggle(),c({active:r.italic.isActive()})}},underline:{id:"underline",icon:Se.underline,size:"s",type:"button",editorEvents:{[Me]:({setState:c})=>{c({active:r.underline.isActive()})}},onClick:({setState:c})=>{r.underline.toggle(),c({active:r.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:Se.strikethrough,size:"s",type:"button",editorEvents:{[Me]:({setState:c})=>{c({active:r.strikethrough.isActive()})}},onClick:({setState:c})=>{r.strikethrough.toggle(),c({active:r.strikethrough.isActive()})}},image:{id:"image",icon:Se.image,size:"s",type:"button",onClick:()=>r.image.open()},link:{id:"link",icon:Se.link,size:"s",type:"button",editorEvents:{[Me]:({setState:c})=>{c({active:r.link.isActive(),disabled:s.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,{x:u,y:p,width:h,height:f}=d.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(_.layoutRemove,{id:m}),v=r.link.get(),w={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:u,y:p,w:h,h:f},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:y=>{y.preventDefault();const b=new FormData(y.currentTarget);r.link.create({url:b.get("url"),target:b.get("target")}),g()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(v==null?void 0:v.href)||"",onChange:({value:y,setState:b})=>b({value:y})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(v==null?void 0:v.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:y,setState:b})=>b({value:y})},{type:"row",style:{gap:10,justifyContent:"end"},children:[r.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{r.link.toggle(),g()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(_.layoutToggle,w)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:Se.alignTextLeft},{id:"center",icon:Se.alignTextCenter},{id:"right",icon:Se.alignTextRight},{id:"justify",icon:Se.alignTextJustify}],editorEvents:{[Me]:({setState:c})=>{c({value:r.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:Se.listBullet,size:"s",type:"button",editorEvents:{[Me]:({setState:c})=>{c({active:r.listBullet.isActive()})}},onClick:({setState:c})=>{r.listBullet.toggle(),c({active:r.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:Se.listOrdered,size:"s",type:"button",editorEvents:{[Me]:({setState:c})=>{c({active:r.listOrdered.isActive()})}},onClick:({setState:c})=>{r.listOrdered.toggle(),c({active:r.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:{[Me]:({setState:c})=>{c({value:r.heading.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.heading.set({value:c}),s.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:{[Me]:({setState:c})=>{c({value:r.fontSize.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.fontSize.set({value:c}),s.focus()}}},l=[i.bold,i.italic,i.underline,i.strikethrough,i.image,i.link,i.listBullet,i.listOrdered,i.alignText,i.heading,i.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:r,layouts:i,proseMirror:{view:s},items:l}))||l};class J1{constructor(e,t,o){this.editor=o,this.node=e,this.dom=document.createElement("img"),this.view=t,Object.keys(e.attrs.attrs).forEach(s=>{this.dom.setAttribute(s,e.attrs.attrs[s])}),this.dom.addEventListener("dblclick",s=>this.handleDoubleClick(s))}handleDoubleClick(e){const{editor:t,view:o}=this;pd(o,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=""}}const Y1=G(function(n,e={}){const t={plugins:i=>i.plugins,...e},o=(i,l)=>{var f,m;const a=((f=t.schema)==null?void 0:f.call(t,{editor:n,schema:rd}))||rd,{nodes:c,marks:d}=a,u=Xt.fromSchema(a).parse(i),p=rn.create({doc:u,schema:a,plugins:(m=t.plugins)==null?void 0:m.call(t,{editor:n,plugins:[Zg(),l1(),j1(a),Rf(),rr({Tab:jc(1),"Shift-Tab":jc(-1)}),rr({Enter:On(pa,Ff(c.listItem),g1),"Shift-Enter":On(ua,(g,v)=>(v&&v(g.tr.replaceSelectionWith(c.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":Ca,"Mod-y":nr,"Mod-Shift-z":nr,"Mod-b":kt(d.strong),"Mod-i":kt(d.em),"Shift-Tab":ir(c.listItem),Tab:Wf(c.listItem)}),rr(kf)]})}),h=new wg({mount:i},{state:p,dispatchTransaction(g){var x;const{state:v}=h,w=v.apply(g),y=!v.doc.eq(w.doc);h.updateState(w);const b=!v.selection.eq(w.selection);y&&(h1(((x=l==null?void 0:l.view)==null?void 0:x.el)||i),h.focus()),(b||y)&&n.trigger(Me)}});return i.__rteView=h,h.setProps({nodeViews:{image(g){return new J1(g,h,n)}}}),h},s=i=>U1(i,t);n.setCustomRte({toolbar:s,parseContent:!0,async enable(i,l,a){const c=Hr(i);if(c)return c;const d=o(i,a);return d1(i,d),k1(d,a),d},disable(i){const l=Hr(i);if(l)return u1(i,l),l.destroy(),{forceSync:!0}},getContent(i){const l=Hr(i);if(l){const{schema:a,doc:c}=l.state,d=document.createElement("div"),u=Ct.fromSchema(a).serializeFragment(c.content);return u.childNodes.forEach(p=>{p.nodeType===Node.ELEMENT_NODE&&p.innerHTML===""&&(p.innerHTML="<br/>")}),d.appendChild(u),f1(d),i.classList.remove("ProseMirror-focused"),d.innerHTML}return i.innerHTML}});const r=m1(n,t);W({editor:n,licenseKey:t.licenseKey,plan:K1,pluginName:q1,cleanup:()=>{n.RichTextEditor.customRte=void 0,r()}})}),Z1="canvasEmptyState",X1=F.startup,Q1=G(function(n,e={}){const t=new WeakMap,o=new WeakMap,s=new WeakMap,r=new Set,i=new WeakMap,l={emptyStates:[],...e},a=(y,b)=>{let x=!1;const{isValid:S}=b;return Array.isArray(S)?x=S.some(C=>y.is(C)):$t(S)?x=S({component:y,editor:n}):x=y.is(S),x},c=y=>{const b=t.get(y);t.delete(y),b==null||b()},d=y=>{y.views.forEach(b=>c(b)),s.delete(y)},u=y=>{if(!(!y||r.has(y)))try{r.add(y);const b=y.components().length>0,x=s.get(y);if(b&&x)d(y);else if(!b&&!x){const S=i.has(y)?i.get(y):l.emptyStates.find(C=>a(y,C));if(i.set(y,S),!S)return;y.views.forEach(C=>{const E=S.render({editor:n,component:y,componentView:C,mount:T=>{o.set(C,T),s.set(y,!0);const M=C.getChildrenContainer();M==null||M.appendChild(T)},unmount:()=>c(C)});t.set(C,()=>{E==null||E();const T=o.get(C);T==null||T.remove()})})}}finally{r.delete(y)}},p=y=>{s.has(y)&&d(y)},h=({model:y})=>{u(y.getComponent())},f=n.Components.events,m=`${f.update}:components`,g="component:mount",v=n.Canvas.events.frameLoadBody,w=f.removed;n.on(m,u),n.on(g,u),n.on(w,p),n.on(v,h),W({editor:n,licenseKey:l.licenseKey,plan:X1,pluginName:Z1,cleanup:()=>{n.off(m,u),n.off(g,u),n.off(w,p),n.off(v,h)}})}),md="canvasFullSize",e0=F.startup,t0=G(function(n,e={}){const{Canvas:t,Commands:o,Devices:s}=n,r={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...e},{canvasOffsetY:i,canvasOffsetX:l,canvasTransition:a,deviceMaxWidth:c,deviceMinHeigth:d,frameBorderRadius:u,frameTransition:p}=r,h=`${d}px`,f=t.events,m="core:preview",g=`${o.events.stopCommand}${m}`,v=t.getConfig(),w=`${md}:disable`,y=s.getAll().map(x=>({...x.attributes}));v.scrollableCanvas=!0,s.getAll().map(x=>{!x.get("width")&&x.set("width",`${c}px`),!x.get("height")&&x.set("height","auto"),!x.get("minHeight")&&x.set("minHeight",h)});const b=x=>{const S="data-gs-plg-full-size",C=document.querySelector(`style[${S}]`);if(x&&C)return C.remove();const E=C||document.createElement("style"),T=t.getZoomMultiplier();E.setAttribute(S,"true"),E.innerHTML=`
|
|
303
|
+
.gjs-frame-wrapper { transition: width ${p}s !important; }
|
|
304
|
+
.gjs-frame-wrapper__bottom { height: ${i*T}px }
|
|
305
305
|
.gjs-frame { border-radius: ${u}px }
|
|
306
|
-
`,!C&&document.body.appendChild(
|
|
307
|
-
[data-gjs-type="wrapper"] { min-height: ${
|
|
308
|
-
[data-gjs-type="mjml"] { min-height: ${
|
|
309
|
-
[data-gjs-type="mj-body"] { min-height: ${
|
|
310
|
-
`,!
|
|
311
|
-
.${
|
|
306
|
+
`,!C&&document.body.appendChild(E)};n.on(f.frameLoadHead,x=>{if(!v.scrollableCanvas)return;const{window:S}=x,C=S.document,E=C.head,T="data-gs-plg-wrapper-style",M=E.querySelector(`style[${T}]`)||C.createElement("style");M.setAttribute(T,"true"),M.innerHTML=`
|
|
307
|
+
[data-gjs-type="wrapper"] { min-height: ${h}; }
|
|
308
|
+
[data-gjs-type="mjml"] { min-height: ${h} !important; }
|
|
309
|
+
[data-gjs-type="mj-body"] { min-height: ${h} !important; }
|
|
310
|
+
`,!E.contains(M)&&E.appendChild(M)}),n.onReady(()=>{const x=t.getSpotsEl(),S=t.getElement(),C=t.getFramesEl(),E=a*1e3,T=S.style;T.overflowX="hidden",C.style.transition=`transform ${a}s`;const M={x:l,y:i};b();const P=()=>x.style.display="none",I=()=>x.style.display="",N=no(()=>{t.fitViewport({zoom:ne=>ne>100?100:ne,ignoreHeight:!0,gap:M}),b(),setTimeout(()=>{var Ee,Bd;const{em:ne}=n;ne.destroyed||((Bd=(Ee=n.getSelected())==null?void 0:Ee.getEl())==null||Bd.scrollIntoView({block:"nearest"}),n.refresh({tools:!0}),I(),o.isActive(m)?ne.stopDefault():ne.runDefault())},E)},100),z=new ResizeObserver(()=>{P(),N()});z.observe(S.parentElement);const V=()=>{P(),N()},te=(ne={})=>{ne.options&&ne.options.from!=="fitViewport"&&t.fitViewport({zoom:t.getZoom(),ignoreHeight:!0,gap:M})},Lt=()=>{T.overflowX="hidden",T.overflowY="auto"},Qn=()=>{z.disconnect(),N.clear()};n.on(s.events.select,V),n.on(f.zoom,te),n.on(g,Lt),n.on(n.events.destroy,Qn),N(),o.add(w,()=>{s.devices.reset(y),v.scrollableCanvas=!1,t.getModel().updateDevice(),t.setZoom(100),t.setCoords(0,0),T.overflowY="hidden",b(!0),n.off(s.events.select,V),n.off(f.zoom,te),n.off(g,Lt),Qn(),o.run("studio:canvasReload")})}),W({editor:n,licenseKey:r.licenseKey,plan:e0,pluginName:md,cleanup:()=>{n.runCommand(w)}})}),Gr="canvasGridMode",n0=F.startup,Wr="component-grid-mode",Kn="grid-mode",Un="gjs-drag-grid-spot",gd=`${Un}__grid-item`,yd=`${Un}__grid-target`,bd=`${Un}__snapped`,o0=`${Un}__container`,s0=()=>{const n="data-gjs-drag-grid-style",e=document,t="var(--gs-theme-cl-cmp-bg1, var(--gjs-color-highlight))",o="var(--gs-theme-cl-cmp-bg2, var(--gjs-color-blue))",s=e.querySelector(`style[${n}]`)||e.createElement("style");s.setAttribute(n,"true"),s.innerHTML=`
|
|
311
|
+
.${gd} {
|
|
312
312
|
outline: 2px solid ${o};
|
|
313
313
|
background: ${t};
|
|
314
314
|
outline-offset: -2px;
|
|
@@ -317,14 +317,14 @@
|
|
|
317
317
|
height: 100%;
|
|
318
318
|
opacity: 0.1;
|
|
319
319
|
}
|
|
320
|
-
.${
|
|
320
|
+
.${bd} {
|
|
321
321
|
width: 100%;
|
|
322
322
|
height: 100%;
|
|
323
323
|
outline: 2px solid ${o};
|
|
324
324
|
outline-offset: -2px;
|
|
325
325
|
position: absolute;
|
|
326
326
|
}
|
|
327
|
-
.${
|
|
327
|
+
.${yd} {
|
|
328
328
|
position: absolute;
|
|
329
329
|
z-index: -1;
|
|
330
330
|
background: ${t};
|
|
@@ -332,18 +332,37 @@
|
|
|
332
332
|
outline-offset: -1px;
|
|
333
333
|
opacity: 0.35;
|
|
334
334
|
}
|
|
335
|
-
`,e.head.appendChild(s)};function ud(n){const{editor:e,type:t}=n,o=e0(e,n.component),s=Fi(e,o.component);if(!t0(e,o,s,t))return{target:o,container:s,startScroll:_i(e).scroll,shadowContainerEl:document.createElement("div"),shadowSnappedEl:document.createElement("div"),shadowTargetEl:document.createElement("div"),spot:e.Canvas.addSpot({type:qn,component:s.component})}}function hd(n){const{editor:e,shadowTargetEl:t,shadowSnappedEl:o,shadowContainerEl:s,spotEl:i,target:r,container:l}=n,{Canvas:a}=e,c=e.config.stylePrefix;i==null||i.appendChild(s),s==null||s.appendChild(t),s==null||s.appendChild(o),Y1(s,l),Z1(t,r,l),X1(o,r),Q1(s,l.el),r.el.style.opacity="0";const d=a.getSpots().filter(u=>u.type!==qn);e.em.stopDefault({preserveSelected:!0}),a.removeSpots(d),a.startAutoscroll(),a.getBody().classList.add(`${c}is__grabbing`)}function pd(n){const{editor:e,shadowSnappedEl:t,shadowContainerEl:o,target:s,cancelled:i}=n,{Canvas:r}=e,l=e.config.stylePrefix,{component:a}=s;if(!i){const c=window.getComputedStyle(t);a.addStyle({"grid-area":c.gridArea,width:"",height:""})}s.el.style.opacity="",o.contains(t)&&(o==null||o.removeChild(t)),e.getModel().runDefault({preserveSelected:1}),r.stopAutoscroll(),r.getBody().classList.remove(`${l}is__grabbing`),r.removeSpots({type:qn}),e.select(a)}function Y1(n,{rows:e,columns:t}){const o=[];for(let s=0;s<t.length;s++){o[s]=[];for(let i=0;i<e.length;i++){const r=document.createElement("div");r.className=ad,r.style.gridArea=`${i+1} / ${s+1}`,o[s][i]=r,n.appendChild(r)}}return o}function Z1(n,e,t){return n.className=cd,n.style.top=`${e.offset.top-t.offset.top}px`,n.style.left=`${e.offset.left-t.offset.left}px`,n.style.width=`${e.offset.width+e.margin.left+e.margin.right}px`,n.style.height=`${e.offset.height+e.margin.top+e.margin.bottom}px`,n}function X1(n,e){const t=gd(e.el,e.computedStyles);return n.className=dd,n.style.gridArea=`${t.row.start} / ${t.column.start} / ${t.row.end} / ${t.column.end}`,n}function Q1(n,e){const t=window.getComputedStyle(e);n.className=U1,n.style.position="relative",n.style.display=t.display,n.style.gap=t.gap,n.style.padding=t.padding,n.style.border=t.border,n.style.gridTemplateColumns=t.gridTemplateColumns,n.style.gridTemplateRows=t.gridTemplateRows}function fd(n,e){if(e){if(Array.isArray(e))return[...e].pop()}else return[...n.getSelectedAll()].pop();return e}function e0(n,e){const t=fd(n,e),o=t.getEl(),s=window.getComputedStyle(o);return{component:t,el:o,offset:n.Canvas.offset(o),margin:{top:parseFloat(s.marginTop),right:parseFloat(s.marginRight),bottom:parseFloat(s.marginBottom),left:parseFloat(s.marginLeft)},computedStyles:s}}function Fi(n,e){const t=e.parent(),o=t.getEl(),s=window.getComputedStyle(o);return{component:t,el:o,offset:n.Canvas.offset(o),computedStyles:s,padding:{top:parseFloat(s.paddingTop),right:parseFloat(s.paddingRight),bottom:parseFloat(s.paddingBottom),left:parseFloat(s.paddingLeft)},columns:s.gridTemplateColumns.split(" ").map(r=>parseFloat(r)),rows:s.gridTemplateRows.split(" ").map(r=>parseFloat(r)),gap:{column:parseInt(s.columnGap),row:parseInt(s.rowGap)}}}function ct(n,e,t,o,s=1){let i=0;for(let r=e;r<=n.length;r++){if(i+(n[r-1]+o)*s>t)return r;i+=o+n[r-1]}return n.length+1}function _i(n){const{scrollY:e,scrollX:t}=n.Canvas.getWindow();return{scroll:{top:e,left:t}}}function t0(n,e,t,o){const s=i=>n.em.logWarning(i);return o==="draggable"&&e.component.get(o)===!1?(s(`[${Bi}] The element is not ${o}`),!0):t.computedStyles.display!=="grid"?(s(`[${Bi}] The container does not have style display:grid`),!0):!1}function Gi(n,e,t={}){const o=fd(n,e),s=o==null?void 0:o.parent(),i=s==null?void 0:s.getEl();if(!s||!i)return!1;const{enableGrid:r}=t,l=window.getComputedStyle(i).display==="grid";return zt(r)?r({component:o,parent:s,isParentGrid:l}):l}const md=n=>n.split(" ").map(e=>parseFloat(e));function gd(n,e){const t=n.ownerDocument.defaultView,o=e||t.getComputedStyle(n),s=o.gridArea.split("/").some(x=>isNaN(parseInt(x.trim()))),i={isComputed:s,raw:o.gridArea};if(!s)return{...i,row:{start:parseInt(o.gridRowStart),end:parseInt(o.gridRowEnd)},column:{start:parseInt(o.gridColumnStart),end:parseInt(o.gridColumnEnd)}};const r=n.parentElement,l=t.getComputedStyle(r),a=parseFloat(l.columnGap)||0,c=parseFloat(l.rowGap)||0,d=md(l.gridTemplateColumns),u=md(l.gridTemplateRows),h=parseFloat(l.paddingLeft)||0,p=parseFloat(l.paddingTop)||0,f=r.getBoundingClientRect(),m=n.getBoundingClientRect(),g=(x,S,C,A,T)=>{let M=1,N=A+T;for(let I=0;I<S.length;I++){const O=S[I],z=N+O;if(x>=N&&x<z)return M;N=z+C,M++}return-1},b=g(m.left,d,a,f.left,h),w=g(m.right-1,d,a,f.left,h)+1,y=g(m.top,u,c,f.top,p),v=g(m.bottom-1,u,c,f.top,p)+1;return{...i,row:{start:y,end:v},column:{start:b,end:w}}}function n0(n){n.Commands.add(Hi,{stop(){},run(e,t,o={}){const s=ud({editor:e,component:o.target,type:"draggable"});if(!s){this.stopCommand();return}const{spot:i,target:r,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c,startScroll:d}=s;let{container:u}=s,h;new e.Utils.Dragger({doc:r.el.ownerDocument,onStart:()=>{h=setTimeout(()=>{hd({editor:e,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:i.attributes.spotEl,target:r,container:u}),u=Fi(e,r.component)},10)},onEnd:(f,m,{cancelled:g})=>{clearTimeout(h),pd({editor:e,shadowSnappedEl:a,shadowContainerEl:l,target:r,cancelled:g}),this.stopCommand(),e.em.set("_cmpDrag",1)},setPosition:({x:f,y:m})=>{const{scroll:g}=_i(e),{columns:b,rows:w,gap:y,offset:v,padding:x}=u,{offset:S,margin:C}=r,A=S.top-v.top-x.top-C.top+m-d.top+g.top,T=S.left-v.left-x.left-C.left+f-d.left+g.left,M=Math.min(ct(b,1,T,y.column,.5),b.length),N=Math.min(ct(w,1,A,y.row,.5),w.length),I=Math.min(ct(b,M,S.width,y.column)+1,b.length+1),O=Math.min(ct(w,N,S.height,y.row)+1,w.length+1);a.style.gridArea=`${N} / ${M} / ${O} / ${I}`,c.style.top=`${A+x.top}px`,c.style.left=`${T+x.left}px`}}).start(o.event)}})}function o0(n,e){const t=ud({editor:n,component:e.target,type:"resizable"});if(!t)return;const{onMove:o,onEnd:s}=e.options||{},{spot:i,target:r,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c}=t;let{container:d}=t,u="",h;return{onStart:p=>{u=p.target.dataset.gjsHandler||"",h=setTimeout(()=>{hd({editor:n,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:i.attributes.spotEl,target:r,container:d}),d=Fi(n,r.component)},10),n.trigger("component:resize",{...r,type:"start"})},onEnd:(p,f)=>{const{startDim:m,rectDim:g}=f.resizer,b=JSON.stringify(m)===JSON.stringify(g);clearTimeout(h),pd({editor:n,shadowSnappedEl:a,shadowContainerEl:l,target:r,cancelled:b}),s==null||s(p,f)},onMove:p=>{var te;const f=p;if(((te=f.target)==null?void 0:te.nodeName)==="I")return;const{scroll:m}=_i(n),g=gd(a);let b=0,w=0,y=0,v=0;const x=r.margin.left,S=r.margin.top,C=r.margin.bottom,A=r.margin.right,{width:T,top:M,left:N,height:I}=r.offset,O=f.clientX,z=f.clientY,$={t:M-S,l:N-x,h:I+S+C,w:T+x+A};u.startsWith("t")?($.t=z-S,$.h=M+I+S+C-z):u.startsWith("b")&&($.h=z-M+S+C),u.endsWith("l")?($.l=O-x,$.w=N+T+x+A-O):u.endsWith("r")&&($.w=O-N+x+A),u.endsWith("l")&&(y=m.left,g.column.start=ct(d.columns,1,$.l-d.offset.left-y-d.padding.left,d.gap.column,.5)),u.startsWith("t")&&(b=m.top,g.row.start=ct(d.rows,1,$.t-d.offset.top+b-d.padding.top,d.gap.row,.5)),u.endsWith("r")&&(v=m.left,g.column.end=Math.max(ct(d.columns,g.column.start,$.w-v,d.gap.column,.5),g.column.start+1)),u.startsWith("b")&&(w=m.top,g.row.end=Math.max(ct(d.rows,g.row.start,$.h+w,d.gap.row,.5),g.row.start+1)),a.style.gridArea=`${g.row.start} / ${g.column.start} / ${g.row.end} / ${g.column.end}`,c.style.width=`${$.w+v+y}px`,c.style.height=`${$.h+w-b}px`,c.style.left=`${$.l-d.offset.left-y}px`,c.style.top=`${$.t-d.offset.top+b}px`,o==null||o(p)}}}const yd=["px","%","em","rem","vw","vh"],s0=(n,e)=>{const t=n.Styles.getSectors().find(o=>!!o.getProperty(e));return{sector:t,property:t?t.getProperty(e):void 0}},i0=(n,e)=>s0(n,e),r0=(n,{x:e,y:t,mergable:o}={})=>{const s={property:`${n}-x`,type:"integer",units:yd,...e},i={property:`${n}-y`,type:"integer",units:yd,...t};return{property:n,type:"composite",properties:[s,i],...o&&{fromStyle(r,{name:l,separator:a,property:c}){const[d,u]=c.getProperties(),[h,p]=(r[l]||"").split(a);return{[d.getId()]:r[d.getName()]||h||"",[u.getId()]:r[u.getName()]||p||h||""}},toStyle(r,{name:l,property:a}){const[c,d]=a.getProperties(),u=r[c.getId()],h=r[d.getId()];return{[l]:u===h?u:`${u} ${h}`}}}}},Wi={display:["grid"]};function l0(n=""){const e=/^repeat\(\s*(\d+)\s*,\s*(.+)\s*\)$/i,t=/^minmax\(\s*(.+?)\s*,\s*(.+?)\s*\)$/i,o=n.match(e);if(!o)return null;const s=parseInt(o[1],10),i=o[2];let r=i,l=i;const a=i.match(t);return a&&(r=a[1],l=a[2]),{total:s,min:r===l?"":r,max:l}}function a0(n={}){let e="",t="",o="",s="";const i=m=>m.split("/").map(g=>g.trim()).filter(Boolean),r=n["grid-area"]||"",l=n["grid-column"]||"",a=n["grid-row"]||"",c=i(r),d=i(l),u=i(a),h=c.length,p=d.length,f=u.length;return h===4?(o=c[0],e=c[1],s=c[2],t=c[3]):h===3?(o=c[0],e=c[1],s=c[2]):h===2?(o=c[0],e=c[1]):h===1&&(o=c[0]),p===2?(e=d[0],t=d[1]):p===1&&(e=d[0]),f===2?(o=u[0],s=u[1]):f===1&&(o=u[0]),{columnStart:e,columnEnd:t,rowStart:o,rowEnd:s}}function bd(n){const{property:e,label:t}=n,o="1",s="1fr";return{property:e,label:t,type:"composite",requires:Wi,generic:!0,properties:[{name:" ",property:`${e}-repeat`,type:"number",full:!0,min:1,default:"1"},{label:"Min size",property:`${e}-min`,type:"number",min:0,units:["px","%"],default:"0"},{label:"Max size",property:`${e}-max`,type:"number",min:1,units:["fr","px","%"],default:"1"}],fromStyle(i,r){const{name:l,property:a}=r,[c,d,u]=a.getProperties(),h=i[l],p=l0(h),f=(p==null?void 0:p.max)??s;return{[c.id]:(p==null?void 0:p.total)??o,[d.id]:(p==null?void 0:p.min)??"",[u.id]:f===s?"":f}},toStyle(i,{name:r,property:l}){const[a,c,d]=l.getProperties(),u=i[a.id],h=i[c.id],p=i[d.id]||s,f=h&&p?`minmax(${h}, ${p})`:p;return{[r]:`repeat(${u||o}, ${f})`}}}}function c0(n,e){if(!e.styleableGrid)return;const{property:t,...o}=i0(n,"display");if(!t)return;const s=t.getOption("grid"),i=o.sector;s||t.addOption({id:"grid",label:"Grid"}),i.addProperty(bd({label:"Columns",property:"grid-template-columns"}),{}),i.addProperty(bd({label:"Rows",property:"grid-template-rows"}),{}),i.addProperty({id:"grid-gap",requires:Wi,...r0("gap",{x:{id:"grid-row-gap",label:"Row",property:"row-gap",min:0,default:"0"},y:{id:"grid-column-gap",label:"Column",property:"column-gap",min:0,default:"0"},mergable:!0})},{}),i.addProperty({type:"composite",property:"grid-area",label:"Grid area",requiresParent:Wi,generic:!0,properties:[{label:"Row start",property:"grid-row-start",type:"integer",default:"auto"},{label:"Row end",property:"grid-row-end",type:"integer",default:"auto"},{label:"Column start",property:"grid-column-start",type:"integer",default:"auto"},{label:"Column end",property:"grid-column-end",type:"integer",default:"auto"}],fromStyle(r){const l=a0(r);return{"grid-column-start":r["grid-column-start"]||l.columnStart,"grid-column-end":r["grid-column-end"]||l.columnEnd,"grid-row-start":r["grid-row-start"]||l.rowStart,"grid-row-end":r["grid-row-end"]||l.rowEnd}},toStyle(r,{name:l}){const a=r["grid-row-start"]||"auto",c=r["grid-row-end"]||"auto",d=r["grid-column-start"]||"auto",u=r["grid-column-end"]||"auto";return{[l]:`${a} / ${d} / ${c} / ${u}`}}},{})}const d0=G(function(n,e={}){const t={itemResizable:!0,...e},{Canvas:o,Commands:s,Components:i}=n,{itemResizable:r}=t,l=o.events,a=s.events,c=i.events,d=`${a.runBeforeCommand}tlb-move`,u=`${a.runBeforeCommand}resize`;let h;n0(n);const p=({options:y})=>{Gi(n,y.target,t)&&(n.runCommand(Hi,{...y}),y.abort=!0)},f=({options:y})=>{Gi(n,y.target,t)&&Object.assign(y.options,o0(n,y))},m=()=>{const y=o.getSpots({type:qn}).pop();if(!y)return;let v=y.attributes.spotEl;v||(v=document.createElement("div"),v.className=Kn,y.set({spotEl:v})),Object.entries(y.getStyle()).forEach(([x,S])=>v.style.setProperty(x,S)),h==null||h.appendChild(v)},g=({spot:y})=>{const v=y.attributes.spotEl;y.type!==qn||!v||h==null||h.removeChild(v)};if(r){const y=v=>{const x=zt(r)?r({component:v}):r;return typeof x=="boolean"?x:{tl:!1,tc:!1,tr:!1,cl:!1,cr:!1,bl:!1,bc:!1,br:!1,...x}};n.on(c.resizeInit,v=>{const{component:x}=v;if(Gi(n,x,t)){const S=y(x);v.resizable=S}})}const b=[[d,p],[u,f],[l.spot,m],[l.spotRemove,g]];b.forEach(([y,v])=>{n.on(y,v)}),n.onReady(()=>{h=o.getSpotsEl(),J1(),c0(n,t)});const w=()=>{delete n.Commands.commands[Hi],b.forEach(([y,v])=>{n.off(y,v)})};W({editor:n,licenseKey:t.licenseKey,plan:K1,pluginName:Bi,cleanup:w})});var De=(n=>(n.panelBlocks="panelBlocks",n.panelPagesLayers="panelPagesLayers",n.panelGlobalStyles="panelGlobalStyles",n.panelSidebarTabs="panelSidebarTabs",n.panelAssets="panelAssets",n))(De||{});const vd="sidebarButtonsTarget",Xo=n=>{const{id:e,icon:t,label:o,tooltip:s,className:i,skipSelfClose:r,removeLayouts:l,layoutComponent:a,layoutCommand:c}=n,d=e;return{id:xd(e),type:"button",icon:t,tooltip:o||s,className:i,editorEvents:{[`${Yi.layoutToggleId}${d}`]:({fromEvent:u,setState:h,editor:p})=>{h({active:u.isOpen}),setTimeout(()=>p.refresh({tools:!0}),20)}},onClick:({editor:u,state:h})=>{if(h.active&&r)return;const p=(c==null?void 0:c.placer)||{type:"static",layoutId:vd},f={...p,skipCleanup:p.type==="static"},m=l||Object.keys(De).filter(b=>b!==d);Sd(u,{removeLayouts:m,layout:{placer:f}});const g={id:d,placer:p,header:(c==null?void 0:c.header)??{label:o,close:!r},layout:a,style:{width:280,height:"100%",borderRightWidth:1,...c==null?void 0:c.style}};u.runCommand(_.layoutToggle,g)}}},xd=n=>`button__${n}`,Sd=(n,e={})=>{(e.removeLayouts||Object.keys(De)).forEach(o=>n.runCommand(_.layoutRemove,{id:o,layout:e.layout}))},wd=n=>{const e=(n==null?void 0:n.breakpointTablet)??1024,t=(n==null?void 0:n.breakpointMobile)??768,o={breakpointTablet:e,breakpointMobile:t},s={},i=[{id:De.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:De.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:De.panelGlobalStyles,icon:'<svg viewBox="0 0 24 24"> <path d="M20 14H6c-2.2 0-4 1.8-4 4s1.8 4 4 4h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2M6 20c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m.3-8L13 5.3a2 2 0 0 1 2.8 0l2.8 2.8c.8.8.8 2 0 2.8l-.9 1.1H6.3M2 13.5V4c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v1.5l-8 8Z"/></svg>',label:"Global Styles",layoutComponent:{type:"panelGlobalStyles"}},{id:De.panelAssets,icon:'<svg viewBox="0 0 24 24"><path d="M22,16V4A2,2 0 0,0 20,2H8A2,2 0 0,0 6,4V16A2,2 0 0,0 8,18H20A2,2 0 0,0 22,16M11,12L13.03,14.71L16,11L20,16H8M2,6V20A2,2 0 0,0 4,22H18V20H4V6" /></svg>',label:"Assets",layoutComponent:{type:"panelAssets",content:{itemsPerRow:2,header:{addUrl:!1}},style:{padding:7},onSelect:({assetProps:p,editor:f})=>{var b;const m=f.getSelected(),g={type:"image",src:p.src};if(m!=null&&m.is("image"))return m.set("src",p.src);if(m&&f.Components.canMove(m,g)){const w=m.append(g)[0];w&&f.select(w)}else if(!m){const w=(b=f.getWrapper())==null?void 0:b.append(g)[0];w&&f.select(w)}}}}],r=[...i,{id:De.panelSidebarTabs,layoutCommand:{header:!1},icon:'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 0 1-1.5-1.5A1.5 1.5 0 0 1 17.5 9a1.5 1.5 0 0 1 1.5 1.5 1.5 1.5 0 0 1-1.5 1.5m-3-4A1.5 1.5 0 0 1 13 6.5 1.5 1.5 0 0 1 14.5 5 1.5 1.5 0 0 1 16 6.5 1.5 1.5 0 0 1 14.5 8m-5 0A1.5 1.5 0 0 1 8 6.5 1.5 1.5 0 0 1 9.5 5 1.5 1.5 0 0 1 11 6.5 1.5 1.5 0 0 1 9.5 8m-3 4A1.5 1.5 0 0 1 5 10.5 1.5 1.5 0 0 1 6.5 9 1.5 1.5 0 0 1 8 10.5 1.5 1.5 0 0 1 6.5 12M12 3a9 9 0 0 0-9 9 9 9 0 0 0 9 9 1.5 1.5 0 0 0 1.5-1.5c0-.4-.2-.7-.4-1-.2-.3-.4-.6-.4-1a1.5 1.5 0 0 1 1.5-1.5H16a5 5 0 0 0 5-5c0-4.4-4-8-9-8Z"/></svg>',label:"Styles & Props",layoutComponent:{type:"panelSidebarTabs"}}],l={id:vd,type:"column",style:{overflow:"hidden"}},a={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},c={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}},d=(p,f)=>{const m=p.map(b=>{const w=Xo(b);return n!=null&&n.sidebarButton?n.sidebarButton({id:b.id,buttonIds:De,breakpoint:f,buttonProps:w,sidebarButtonProps:b,...o,createSidebarButton:y=>Xo({...b,...y})}):w}).filter(Boolean);return(n!=null&&n.sidebarButtons?n==null?void 0:n.sidebarButtons({buttonIds:De,breakpoint:f,sidebarButtons:m,...o,createSidebarButton:b=>Xo({...b})}):m).filter(Boolean)},u=(p,f,m)=>{var g;return((g=n==null?void 0:n.rootLayout)==null?void 0:g.call(n,{breakpoint:m,sidebarButtons:f,rootLayout:p,layoutSidebarLeft:a,layoutSidebarTarget:l,...o,createSidebarButton:b=>Xo({...b})}))??p};if(e){const p=d(r,e);s[e]=u({type:"row",style:{height:"100%"},children:[{...a,children:p},l,c]},p,e)}if(t){const p=r.map(m=>({...m,layoutCommand:{placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}}})),f=d(p,t);s[t]=u({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas"},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:f}]},f,t)}const h=d(i,0);return{default:u({type:"row",style:{height:"100%"},children:[{...a,children:h},l,c,{type:"sidebarRight"}]},h,0),responsive:s}},Cd="layoutSidebarButtons",u0=F.free,kd=G(function(n,e={}){const{Commands:t}=n,o=t.events,s={...e};(()=>{if(n.runCommand(_.layoutConfigGet)||s.skipLayoutConfig===!0)return;const l=wd(s);n.runCommand(_.layoutConfigSet,{...l})})(),t.add(`${Cd}:toggleButton`,(r,l,a)=>{const c=document.getElementById(xd(a==null?void 0:a.id));c==null||c.click()}),n.on(`${o.runCommand}core:preview`,()=>{Sd(n)}),W({editor:n,licenseKey:s.licenseKey,plan:u0,pluginName:Cd,cleanup:()=>{n.runCommand(_.layoutConfigSet)}})});kd.createLayoutConfig=n=>wd(n);function h0(n,e){const o={mm:3.7795275590551185,cm:37.79527559055118,in:96,pt:1.3333333333333333,pc:16};return o[e]?n*o[e]:null}const p0=(n,e)=>{const{name:t,id:o,width:s,height:i,unit:r}=n,{fixedHeight:l}=e,a=`${s}${r}`,c=`${i}${r}`;return{id:o||t.toLowerCase().replace(/\s/g,"-"),name:`${t} (${a} x ${c})`,sizeH:i,sizeW:s,sizeUnit:r,widthMedia:"",width:a,minHeight:l?"0":`${h0(i,r)}px`,height:l?c:void 0}},f0="presetPrintable",m0=G(function(n,e={}){const t={selectedDevice:"a4",...e},{Canvas:o,Devices:s}=n,i=t.selectedDevice||s.getConfig().default,l=[{name:"A5",width:148,height:210,unit:"mm"},{name:"A5 Portrait",width:210,height:148,unit:"mm"},{name:"A4",width:210,height:297,unit:"mm"},{name:"A3",width:297,height:420,unit:"mm"},{name:"B5",width:176,height:250,unit:"mm"},{name:"B4",width:250,height:353,unit:"mm"},{name:"Letter",width:8.5,height:11,unit:"in"},{name:"Legal",width:8.5,height:14,unit:"in"},{name:"Ledger",width:11,height:17,unit:"in"}].map(p=>p0(p,t));s.devices.reset(l);const a=i&&s.get(i)||s.getAll().at(0);s.select(a);const c=()=>{const p="page-rule",{rules:f}=n.Css,{width:m,height:g,minHeight:b}=s.getSelected().attributes,w=g&&g!=="auto"?g:b;(f.where({id:p}).pop()||f.add({id:p,selectors:[],selectorsAdd:"@page"},{at:0})).setStyle({size:`${m} ${w}`,margin:"0"})},d=p=>{const f=p.document,{minHeight:m}=s.getSelected().attributes,b=`
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
335
|
+
`,e.head.appendChild(s)};function vd(n){const{editor:e,type:t}=n,o=c0(e,n.component),s=jr(e,o.component);if(!d0(e,o,s,t))return{target:o,container:s,startScroll:qr(e).scroll,shadowContainerEl:document.createElement("div"),shadowSnappedEl:document.createElement("div"),shadowTargetEl:document.createElement("div"),spot:e.Canvas.addSpot({type:Kn,component:s.component})}}function xd(n){const{editor:e,shadowTargetEl:t,shadowSnappedEl:o,shadowContainerEl:s,spotEl:r,target:i,container:l}=n,{Canvas:a}=e,c=e.config.stylePrefix;r==null||r.appendChild(s),s==null||s.appendChild(t),s==null||s.appendChild(o),r0(s,l),i0(t,i,l),l0(o,i),a0(s,l.el),i.el.style.opacity="0";const d=a.getSpots().filter(u=>u.type!==Kn);e.em.stopDefault({preserveSelected:!0}),a.removeSpots(d),a.startAutoscroll(),a.getBody().classList.add(`${c}is__grabbing`)}function Sd(n){const{editor:e,shadowSnappedEl:t,shadowContainerEl:o,target:s,cancelled:r}=n,{Canvas:i}=e,l=e.config.stylePrefix,{component:a}=s;if(!r){const c=window.getComputedStyle(t);a.addStyle({"grid-area":c.gridArea,width:"",height:""})}s.el.style.opacity="",o.contains(t)&&(o==null||o.removeChild(t)),e.getModel().runDefault({preserveSelected:1}),i.stopAutoscroll(),i.getBody().classList.remove(`${l}is__grabbing`),i.removeSpots({type:Kn}),e.select(a)}function r0(n,{rows:e,columns:t}){const o=[];for(let s=0;s<t.length;s++){o[s]=[];for(let r=0;r<e.length;r++){const i=document.createElement("div");i.className=gd,i.style.gridArea=`${r+1} / ${s+1}`,o[s][r]=i,n.appendChild(i)}}return o}function i0(n,e,t){return n.className=yd,n.style.top=`${e.offset.top-t.offset.top}px`,n.style.left=`${e.offset.left-t.offset.left}px`,n.style.width=`${e.offset.width+e.margin.left+e.margin.right}px`,n.style.height=`${e.offset.height+e.margin.top+e.margin.bottom}px`,n}function l0(n,e){const t=kd(e.el,e.computedStyles);return n.className=bd,n.style.gridArea=`${t.row.start} / ${t.column.start} / ${t.row.end} / ${t.column.end}`,n}function a0(n,e){const t=window.getComputedStyle(e);n.className=o0,n.style.position="relative",n.style.display=t.display,n.style.gap=t.gap,n.style.padding=t.padding,n.style.border=t.border,n.style.gridTemplateColumns=t.gridTemplateColumns,n.style.gridTemplateRows=t.gridTemplateRows}function wd(n,e){if(e){if(Array.isArray(e))return[...e].pop()}else return[...n.getSelectedAll()].pop();return e}function c0(n,e){const t=wd(n,e),o=t.getEl(),s=window.getComputedStyle(o);return{component:t,el:o,offset:n.Canvas.offset(o),margin:{top:parseFloat(s.marginTop),right:parseFloat(s.marginRight),bottom:parseFloat(s.marginBottom),left:parseFloat(s.marginLeft)},computedStyles:s}}function jr(n,e){const t=e.parent(),o=t.getEl(),s=window.getComputedStyle(o);return{component:t,el:o,offset:n.Canvas.offset(o),computedStyles:s,padding:{top:parseFloat(s.paddingTop),right:parseFloat(s.paddingRight),bottom:parseFloat(s.paddingBottom),left:parseFloat(s.paddingLeft)},columns:s.gridTemplateColumns.split(" ").map(i=>parseFloat(i)),rows:s.gridTemplateRows.split(" ").map(i=>parseFloat(i)),gap:{column:parseInt(s.columnGap),row:parseInt(s.rowGap)}}}function dt(n,e,t,o,s=1){let r=0;for(let i=e;i<=n.length;i++){if(r+(n[i-1]+o)*s>t)return i;r+=o+n[i-1]}return n.length+1}function qr(n){const{scrollY:e,scrollX:t}=n.Canvas.getWindow();return{scroll:{top:e,left:t}}}function d0(n,e,t,o){const s=r=>n.em.logWarning(r);return o==="draggable"&&e.component.get(o)===!1?(s(`[${Gr}] The element is not ${o}`),!0):t.computedStyles.display!=="grid"?(s(`[${Gr}] The container does not have style display:grid`),!0):!1}function Kr(n,e,t={}){const o=wd(n,e),s=o==null?void 0:o.parent(),r=s==null?void 0:s.getEl();if(!s||!r)return!1;const{enableGrid:i}=t,l=window.getComputedStyle(r).display==="grid";return $t(i)?i({component:o,parent:s,isParentGrid:l}):l}const Cd=n=>n.split(" ").map(e=>parseFloat(e));function kd(n,e){const t=n.ownerDocument.defaultView,o=e||t.getComputedStyle(n),s=o.gridArea.split("/").some(x=>isNaN(parseInt(x.trim()))),r={isComputed:s,raw:o.gridArea};if(!s)return{...r,row:{start:parseInt(o.gridRowStart),end:parseInt(o.gridRowEnd)},column:{start:parseInt(o.gridColumnStart),end:parseInt(o.gridColumnEnd)}};const i=n.parentElement,l=t.getComputedStyle(i),a=parseFloat(l.columnGap)||0,c=parseFloat(l.rowGap)||0,d=Cd(l.gridTemplateColumns),u=Cd(l.gridTemplateRows),p=parseFloat(l.paddingLeft)||0,h=parseFloat(l.paddingTop)||0,f=i.getBoundingClientRect(),m=n.getBoundingClientRect(),g=(x,S,C,E,T)=>{let M=1,P=E+T;for(let I=0;I<S.length;I++){const N=S[I],z=P+N;if(x>=P&&x<z)return M;P=z+C,M++}return-1},v=g(m.left,d,a,f.left,p),w=g(m.right-1,d,a,f.left,p)+1,y=g(m.top,u,c,f.top,h),b=g(m.bottom-1,u,c,f.top,h)+1;return{...r,row:{start:y,end:b},column:{start:v,end:w}}}function u0(n){n.Commands.add(Wr,{stop(){},run(e,t,o={}){const s=vd({editor:e,component:o.target,type:"draggable"});if(!s){this.stopCommand();return}const{spot:r,target:i,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c,startScroll:d}=s;let{container:u}=s,p;new e.Utils.Dragger({doc:i.el.ownerDocument,onStart:()=>{p=setTimeout(()=>{xd({editor:e,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:r.attributes.spotEl,target:i,container:u}),u=jr(e,i.component)},10)},onEnd:(f,m,{cancelled:g})=>{clearTimeout(p),Sd({editor:e,shadowSnappedEl:a,shadowContainerEl:l,target:i,cancelled:g}),this.stopCommand(),e.em.set("_cmpDrag",1)},setPosition:({x:f,y:m})=>{const{scroll:g}=qr(e),{columns:v,rows:w,gap:y,offset:b,padding:x}=u,{offset:S,margin:C}=i,E=S.top-b.top-x.top-C.top+m-d.top+g.top,T=S.left-b.left-x.left-C.left+f-d.left+g.left,M=Math.min(dt(v,1,T,y.column,.5),v.length),P=Math.min(dt(w,1,E,y.row,.5),w.length),I=Math.min(dt(v,M,S.width,y.column)+1,v.length+1),N=Math.min(dt(w,P,S.height,y.row)+1,w.length+1);a.style.gridArea=`${P} / ${M} / ${N} / ${I}`,c.style.top=`${E+x.top}px`,c.style.left=`${T+x.left}px`}}).start(o.event)}})}function p0(n,e){const t=vd({editor:n,component:e.target,type:"resizable"});if(!t)return;const{onMove:o,onEnd:s}=e.options||{},{spot:r,target:i,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c}=t;let{container:d}=t,u="",p;return{onStart:h=>{u=h.target.dataset.gjsHandler||"",p=setTimeout(()=>{xd({editor:n,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:r.attributes.spotEl,target:i,container:d}),d=jr(n,i.component)},10),n.trigger("component:resize",{...i,type:"start"})},onEnd:(h,f)=>{const{startDim:m,rectDim:g}=f.resizer,v=JSON.stringify(m)===JSON.stringify(g);clearTimeout(p),Sd({editor:n,shadowSnappedEl:a,shadowContainerEl:l,target:i,cancelled:v}),s==null||s(h,f)},onMove:h=>{var te;const f=h;if(((te=f.target)==null?void 0:te.nodeName)==="I")return;const{scroll:m}=qr(n),g=kd(a);let v=0,w=0,y=0,b=0;const x=i.margin.left,S=i.margin.top,C=i.margin.bottom,E=i.margin.right,{width:T,top:M,left:P,height:I}=i.offset,N=f.clientX,z=f.clientY,V={t:M-S,l:P-x,h:I+S+C,w:T+x+E};u.startsWith("t")?(V.t=z-S,V.h=M+I+S+C-z):u.startsWith("b")&&(V.h=z-M+S+C),u.endsWith("l")?(V.l=N-x,V.w=P+T+x+E-N):u.endsWith("r")&&(V.w=N-P+x+E),u.endsWith("l")&&(y=m.left,g.column.start=dt(d.columns,1,V.l-d.offset.left-y-d.padding.left,d.gap.column,.5)),u.startsWith("t")&&(v=m.top,g.row.start=dt(d.rows,1,V.t-d.offset.top+v-d.padding.top,d.gap.row,.5)),u.endsWith("r")&&(b=m.left,g.column.end=Math.max(dt(d.columns,g.column.start,V.w-b,d.gap.column,.5),g.column.start+1)),u.startsWith("b")&&(w=m.top,g.row.end=Math.max(dt(d.rows,g.row.start,V.h+w,d.gap.row,.5),g.row.start+1)),a.style.gridArea=`${g.row.start} / ${g.column.start} / ${g.row.end} / ${g.column.end}`,c.style.width=`${V.w+b+y}px`,c.style.height=`${V.h+w-v}px`,c.style.left=`${V.l-d.offset.left-y}px`,c.style.top=`${V.t-d.offset.top+v}px`,o==null||o(h)}}}const Td=["px","%","em","rem","vw","vh"],h0=(n,e)=>{const t=n.Styles.getSectors().find(o=>!!o.getProperty(e));return{sector:t,property:t?t.getProperty(e):void 0}},f0=(n,e)=>h0(n,e),m0=(n,{x:e,y:t,mergable:o}={})=>{const s={property:`${n}-x`,type:"integer",units:Td,...e},r={property:`${n}-y`,type:"integer",units:Td,...t};return{property:n,type:"composite",properties:[s,r],...o&&{fromStyle(i,{name:l,separator:a,property:c}){const[d,u]=c.getProperties(),[p,h]=(i[l]||"").split(a);return{[d.getId()]:i[d.getName()]||p||"",[u.getId()]:i[u.getName()]||h||p||""}},toStyle(i,{name:l,property:a}){const[c,d]=a.getProperties(),u=i[c.getId()],p=i[d.getId()];return{[l]:u===p?u:`${u} ${p}`}}}}},Ur={display:["grid"]};function g0(n=""){const e=/^repeat\(\s*(\d+)\s*,\s*(.+)\s*\)$/i,t=/^minmax\(\s*(.+?)\s*,\s*(.+?)\s*\)$/i,o=n.match(e);if(!o)return null;const s=parseInt(o[1],10),r=o[2];let i=r,l=r;const a=r.match(t);return a&&(i=a[1],l=a[2]),{total:s,min:i===l?"":i,max:l}}function y0(n={}){let e="",t="",o="",s="";const r=m=>m.split("/").map(g=>g.trim()).filter(Boolean),i=n["grid-area"]||"",l=n["grid-column"]||"",a=n["grid-row"]||"",c=r(i),d=r(l),u=r(a),p=c.length,h=d.length,f=u.length;return p===4?(o=c[0],e=c[1],s=c[2],t=c[3]):p===3?(o=c[0],e=c[1],s=c[2]):p===2?(o=c[0],e=c[1]):p===1&&(o=c[0]),h===2?(e=d[0],t=d[1]):h===1&&(e=d[0]),f===2?(o=u[0],s=u[1]):f===1&&(o=u[0]),{columnStart:e,columnEnd:t,rowStart:o,rowEnd:s}}function Md(n){const{property:e,label:t}=n,o="1",s="1fr";return{property:e,label:t,type:"composite",requires:Ur,generic:!0,properties:[{name:" ",property:`${e}-repeat`,type:"number",full:!0,min:1,default:"1"},{label:"Min size",property:`${e}-min`,type:"number",min:0,units:["px","%"],default:"0"},{label:"Max size",property:`${e}-max`,type:"number",min:1,units:["fr","px","%"],default:"1"}],fromStyle(r,i){const{name:l,property:a}=i,[c,d,u]=a.getProperties(),p=r[l],h=g0(p),f=(h==null?void 0:h.max)??s;return{[c.id]:(h==null?void 0:h.total)??o,[d.id]:(h==null?void 0:h.min)??"",[u.id]:f===s?"":f}},toStyle(r,{name:i,property:l}){const[a,c,d]=l.getProperties(),u=r[a.id],p=r[c.id],h=r[d.id]||s,f=p&&h?`minmax(${p}, ${h})`:h;return{[i]:`repeat(${u||o}, ${f})`}}}}function b0(n,e){if(!e.styleableGrid)return;const{property:t,...o}=f0(n,"display");if(!t)return;const s=t.getOption("grid"),r=o.sector;s||t.addOption({id:"grid",label:"Grid"}),r.addProperty(Md({label:"Columns",property:"grid-template-columns"}),{}),r.addProperty(Md({label:"Rows",property:"grid-template-rows"}),{}),r.addProperty({id:"grid-gap",requires:Ur,...m0("gap",{x:{id:"grid-row-gap",label:"Row",property:"row-gap",min:0,default:"0"},y:{id:"grid-column-gap",label:"Column",property:"column-gap",min:0,default:"0"},mergable:!0})},{}),r.addProperty({type:"composite",property:"grid-area",label:"Grid area",requiresParent:Ur,generic:!0,properties:[{label:"Row start",property:"grid-row-start",type:"integer",default:"auto"},{label:"Row end",property:"grid-row-end",type:"integer",default:"auto"},{label:"Column start",property:"grid-column-start",type:"integer",default:"auto"},{label:"Column end",property:"grid-column-end",type:"integer",default:"auto"}],fromStyle(i){const l=y0(i);return{"grid-column-start":i["grid-column-start"]||l.columnStart,"grid-column-end":i["grid-column-end"]||l.columnEnd,"grid-row-start":i["grid-row-start"]||l.rowStart,"grid-row-end":i["grid-row-end"]||l.rowEnd}},toStyle(i,{name:l}){const a=i["grid-row-start"]||"auto",c=i["grid-row-end"]||"auto",d=i["grid-column-start"]||"auto",u=i["grid-column-end"]||"auto";return{[l]:`${a} / ${d} / ${c} / ${u}`}}},{})}const v0=G(function(n,e={}){const t={itemResizable:!0,...e},{Canvas:o,Commands:s,Components:r}=n,{itemResizable:i}=t,l=o.events,a=s.events,c=r.events,d=`${a.runBeforeCommand}tlb-move`,u=`${a.runBeforeCommand}resize`;let p;u0(n);const h=({options:y})=>{Kr(n,y.target,t)&&(n.runCommand(Wr,{...y}),y.abort=!0)},f=({options:y})=>{Kr(n,y.target,t)&&Object.assign(y.options,p0(n,y))},m=()=>{const y=o.getSpots({type:Kn}).pop();if(!y)return;let b=y.attributes.spotEl;b||(b=document.createElement("div"),b.className=Un,y.set({spotEl:b})),Object.entries(y.getStyle()).forEach(([x,S])=>b.style.setProperty(x,S)),p==null||p.appendChild(b)},g=({spot:y})=>{const b=y.attributes.spotEl;y.type!==Kn||!b||p==null||p.removeChild(b)};if(i){const y=b=>{const x=$t(i)?i({component:b}):i;return typeof x=="boolean"?x:{tl:!1,tc:!1,tr:!1,cl:!1,cr:!1,bl:!1,bc:!1,br:!1,...x}};n.on(c.resizeInit,b=>{const{component:x}=b;if(Kr(n,x,t)){const S=y(x);b.resizable=S}})}const v=[[d,h],[u,f],[l.spot,m],[l.spotRemove,g]];v.forEach(([y,b])=>{n.on(y,b)}),n.onReady(()=>{p=o.getSpotsEl(),s0(),b0(n,t)});const w=()=>{delete n.Commands.commands[Wr],v.forEach(([y,b])=>{n.off(y,b)})};W({editor:n,licenseKey:t.licenseKey,plan:n0,pluginName:Gr,cleanup:w})});var Le=(n=>(n.panelBlocks="panelBlocks",n.panelPagesLayers="panelPagesLayers",n.panelGlobalStyles="panelGlobalStyles",n.panelSidebarTabs="panelSidebarTabs",n.panelAssets="panelAssets",n))(Le||{});const Ed="sidebarButtonsTarget",es=n=>{const{id:e,icon:t,label:o,tooltip:s,className:r,skipSelfClose:i,removeLayouts:l,layoutComponent:a,layoutCommand:c}=n,d=e;return{id:Ad(e),type:"button",icon:t,tooltip:o||s,className:r,editorEvents:{[`${ri.layoutToggleId}${d}`]:({fromEvent:u,setState:p,editor:h})=>{p({active:u.isOpen}),setTimeout(()=>h.refresh({tools:!0}),20)}},onClick:({editor:u,state:p})=>{if(p.active&&i)return;const h=(c==null?void 0:c.placer)||{type:"static",layoutId:Ed},f={...h,skipCleanup:h.type==="static"},m=l||Object.keys(Le).filter(v=>v!==d);Pd(u,{removeLayouts:m,layout:{placer:f}});const g={id:d,placer:h,header:(c==null?void 0:c.header)??{label:o,close:!i},layout:a,style:{width:280,height:"100%",borderRightWidth:1,...c==null?void 0:c.style}};u.runCommand(_.layoutToggle,g)}}},Ad=n=>`button__${n}`,Pd=(n,e={})=>{(e.removeLayouts||Object.keys(Le)).forEach(o=>n.runCommand(_.layoutRemove,{id:o,layout:e.layout}))},Nd=n=>{const e=(n==null?void 0:n.breakpointTablet)??1024,t=(n==null?void 0:n.breakpointMobile)??768,o={breakpointTablet:e,breakpointMobile:t},s={},r=[{id:Le.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:Le.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:Le.panelGlobalStyles,icon:'<svg viewBox="0 0 24 24"> <path d="M20 14H6c-2.2 0-4 1.8-4 4s1.8 4 4 4h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2M6 20c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m.3-8L13 5.3a2 2 0 0 1 2.8 0l2.8 2.8c.8.8.8 2 0 2.8l-.9 1.1H6.3M2 13.5V4c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v1.5l-8 8Z"/></svg>',label:"Global Styles",layoutComponent:{type:"panelGlobalStyles"}},{id:Le.panelAssets,icon:'<svg viewBox="0 0 24 24"><path d="M22,16V4A2,2 0 0,0 20,2H8A2,2 0 0,0 6,4V16A2,2 0 0,0 8,18H20A2,2 0 0,0 22,16M11,12L13.03,14.71L16,11L20,16H8M2,6V20A2,2 0 0,0 4,22H18V20H4V6" /></svg>',label:"Assets",layoutComponent:{type:"panelAssets",content:{itemsPerRow:2,header:{addUrl:!1}},style:{padding:7},onSelect:({assetProps:h,editor:f})=>{var v;const m=f.getSelected(),g={type:"image",src:h.src};if(m!=null&&m.is("image"))return m.set("src",h.src);if(m&&f.Components.canMove(m,g)){const w=m.append(g)[0];w&&f.select(w)}else if(!m){const w=(v=f.getWrapper())==null?void 0:v.append(g)[0];w&&f.select(w)}}}}],i=[...r,{id:Le.panelSidebarTabs,layoutCommand:{header:!1},icon:'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 0 1-1.5-1.5A1.5 1.5 0 0 1 17.5 9a1.5 1.5 0 0 1 1.5 1.5 1.5 1.5 0 0 1-1.5 1.5m-3-4A1.5 1.5 0 0 1 13 6.5 1.5 1.5 0 0 1 14.5 5 1.5 1.5 0 0 1 16 6.5 1.5 1.5 0 0 1 14.5 8m-5 0A1.5 1.5 0 0 1 8 6.5 1.5 1.5 0 0 1 9.5 5 1.5 1.5 0 0 1 11 6.5 1.5 1.5 0 0 1 9.5 8m-3 4A1.5 1.5 0 0 1 5 10.5 1.5 1.5 0 0 1 6.5 9 1.5 1.5 0 0 1 8 10.5 1.5 1.5 0 0 1 6.5 12M12 3a9 9 0 0 0-9 9 9 9 0 0 0 9 9 1.5 1.5 0 0 0 1.5-1.5c0-.4-.2-.7-.4-1-.2-.3-.4-.6-.4-1a1.5 1.5 0 0 1 1.5-1.5H16a5 5 0 0 0 5-5c0-4.4-4-8-9-8Z"/></svg>',label:"Styles & Props",layoutComponent:{type:"panelSidebarTabs"}}],l={id:Ed,type:"column",style:{overflow:"hidden"}},a={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},c={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}},d=(h,f)=>{const m=h.map(v=>{const w=es(v);return n!=null&&n.sidebarButton?n.sidebarButton({id:v.id,buttonIds:Le,breakpoint:f,buttonProps:w,sidebarButtonProps:v,...o,createSidebarButton:y=>es({...v,...y})}):w}).filter(Boolean);return(n!=null&&n.sidebarButtons?n==null?void 0:n.sidebarButtons({buttonIds:Le,breakpoint:f,sidebarButtons:m,...o,createSidebarButton:v=>es({...v})}):m).filter(Boolean)},u=(h,f,m)=>{var g;return((g=n==null?void 0:n.rootLayout)==null?void 0:g.call(n,{breakpoint:m,sidebarButtons:f,rootLayout:h,layoutSidebarLeft:a,layoutSidebarTarget:l,...o,createSidebarButton:v=>es({...v})}))??h};if(e){const h=d(i,e);s[e]=u({type:"row",style:{height:"100%"},children:[{...a,children:h},l,c]},h,e)}if(t){const h=i.map(m=>({...m,layoutCommand:{placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}}})),f=d(h,t);s[t]=u({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas"},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:f}]},f,t)}const p=d(r,0);return{default:u({type:"row",style:{height:"100%"},children:[{...a,children:p},l,c,{type:"sidebarRight"}]},p,0),responsive:s}},Od="layoutSidebarButtons",x0=F.free,Id=G(function(n,e={}){const{Commands:t}=n,o=t.events,s={...e};(()=>{if(n.runCommand(_.layoutConfigGet)||s.skipLayoutConfig===!0)return;const l=Nd(s);n.runCommand(_.layoutConfigSet,{...l})})(),t.add(`${Od}:toggleButton`,(i,l,a)=>{const c=document.getElementById(Ad(a==null?void 0:a.id));c==null||c.click()}),n.on(`${o.runCommand}core:preview`,()=>{Pd(n)}),W({editor:n,licenseKey:s.licenseKey,plan:x0,pluginName:Od,cleanup:()=>{n.runCommand(_.layoutConfigSet)}})});Id.createLayoutConfig=n=>Nd(n);const Dt="page-break";function Jr(n,e){const o={mm:3.7795275590551185,cm:37.79527559055118,in:96,pt:1.3333333333333333,pc:16};return o[e]?n*o[e]:null}const S0=(n,e)=>{const{name:t,id:o,width:s,height:r,unit:i}=n,{fixedHeight:l}=e,a=`${s}${i}`,c=`${r}${i}`;return{id:o||t.toLowerCase().replace(/\s/g,"-"),name:`${t} (${a} x ${c})`,sizeH:r,sizeW:s,sizeUnit:i,widthMedia:"",width:a,minHeight:l?"0":`${Jr(r,i)}px`,height:l?c:void 0}},Yr="page-breaks",ts="gjs-page-breaks-spot",Zr=n=>n.type===Yr;function w0(n){const{Devices:e}=n,{height:t,minHeight:o}=e.getSelected().attributes,r=parseFloat(`${t&&t!=="auto"?t:o}`),i=n.getWrapper(),l=i==null?void 0:i.getEl(),a=[];if(!i||!l)return a;const c=l.getBoundingClientRect().height,u=i.findType(Dt).map(h=>h.getEl()).filter(Boolean).map(h=>({top:h.offsetTop,height:h.offsetHeight}));let p=0;for(;p<c;){const h=u.find(f=>f.top>p&&f.top<p+r);h?(p=h.top+h.height,a.push(h.top)):(p+=r,p<c&&a.push(p))}return a}function C0(n,e){const{Canvas:t}=n,o=t.events,s=n.events;let r;const i=()=>{cs(`${di}preset-printable-spots`,`.${ts} {
|
|
336
|
+
position: absolute;
|
|
337
|
+
left: 0;
|
|
338
|
+
width: 100%;
|
|
339
|
+
border-top: 1px dashed var(--gs-theme-cl-cmp-bg2, var(--gjs-color-blue));
|
|
339
340
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
341
|
+
.${ts}::after {
|
|
342
|
+
background-color: var(--gs-theme-cl-cmp-bg1, var(--gjs-color-highlight));
|
|
343
|
+
content: attr(data-page-number);
|
|
344
|
+
display: block;
|
|
345
|
+
padding: 0 0.5rem;
|
|
346
|
+
border-radius: 2px;
|
|
347
|
+
position: absolute;
|
|
348
|
+
top: -2px;
|
|
349
|
+
right: 0;
|
|
350
|
+
transform: translate(100%, -50%);
|
|
344
351
|
}
|
|
352
|
+
`,{target:window.document.head})},l=()=>{if(e.enablePageBreaksSpot===!1)return;const f={id:Yr,type:Yr,component:n.getWrapper()};return t.getSpots(f).pop()||t.addSpot(f)},a=({spot:f})=>{const{spotEl:m}=f.attributes;!Zr(f)||!m||!r||r.removeChild(m)},c=({spot:f})=>{if(!Zr(f)||!r)return;let{spotEl:m}=f.attributes;m||(m=document.createElement("div"),m.className=`${ts}__items`,f.set({spotEl:m})),r.appendChild(m)},d=({spot:f})=>{const{spotEl:m,pageBreaks:g=[]}=f.attributes;!Zr(f)||!m||!r||(Object.entries(f.getStyle()).forEach(([v,w])=>m.style.setProperty(v,w)),m.innerHTML="",g.forEach((v,w)=>{const y=document.createElement("div");y.setAttribute("data-page-number",`${w+2}`),y.className=ts,y.style.top=`${v}px`,m.appendChild(y)}))},u=no(()=>{const f=l();f&&f.set({pageBreaks:w0(n),up:(f.attributes.up||0)+1})},150),p=()=>{r=t.getSpotsEl(),l()},h=[["component:input",u],[s.update,u],[o.spotAdd,c],[o.spotUpdate,d],[o.spotRemove,a],[o.frameLoadBody,p]];return h.forEach(([f,m])=>n.on(f,m)),n.onReady(()=>{i()}),()=>{h.forEach(([f,m])=>n.off(f,m)),u.clear()}}var Xr=(n=>(n.print="presetPrintable:print",n))(Xr||{});const Rd=n=>new Promise(e=>{const t=document.createElement("iframe");t.style.cssText="position: absolute; width: 0; height: 0; border: 0; opacity: 0; pointer-events: none;",t.srcdoc=n.content,t.onload=()=>e(t),document.body.appendChild(t)});function k0(n,e){const{Commands:t,Pages:o}=n;return t.add(Xr.print,async(s,r,i={})=>{const l={page:i.allPages?void 0:o.getSelected(),styles:"inline"},c=(await t.run(_.projectFiles,l)).filter(p=>p.filename.endsWith(".html")),d=c.map(p=>p.content).join('<div style="break-before: page;"></div>'),u=[];if(i.separatePrints)for(const p of c)u.push(await Rd(p));else u.push(await Rd({content:d,filename:"",mimeType:""}));for(const p of u){const h=p.contentWindow;h.focus(),h.print()}setTimeout(()=>u.forEach(p=>p.remove()),1e3)}),t.add("presetPrintable:exp",async s=>{await oi("https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"),await oi("https://cdn.jsdelivr.net/npm/jspdf@3.0.0/dist/jspdf.umd.min.js");const{Devices:r,Canvas:i}=s,{sizeW:l,sizeH:a,sizeUnit:c}=r.getSelected().attributes,d=i.getFrameEl().contentDocument,u="px",p=[Jr(l,c),Jr(a,c)],h=new window.jspdf.jsPDF({unit:u,format:p}),f=d.body;h.html(f,{callback:m=>m.save()})}),()=>{delete n.Commands.commands[Xr.print]}}function T0(n,e){const{blockPageBreak:t={}}=e,{Components:o,Blocks:s}=n,r="Page Break",i=`${Ae}${Dt}`;return o.addType(Dt,{block:t&&{label:r,media:'<svg viewBox="0 0 24 24"><path d="M18 20H6v-2H4v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2h-2v2M14 2H6a2 2 0 0 0-2 2v8h2V4h8v4h4v4h2V8l-6-6m-3 14H8v-2h3v2m5 0h-3v-2h3v2M3 14h3v2H3v-2m18 2h-3v-2h3v2Z"/></svg>',category:"Extra",select:!0,...t},isComponent:qe(Dt),model:{defaults:{name:r,classes:i,attributes:{[ze]:Dt},emptyState:!0,stylable:!1,droppable:!1,draggable:as("wrapper"),styles:`.${i} { break-before: page; }`,traits:[]}}}),()=>{o.removeType(Dt),s.remove(Dt)}}const M0="presetPrintable",E0=G(function(n,e={}){const t={selectedDevice:"a4",...e},{Canvas:o,Devices:s}=n,r=o.events,i=n.events,l=t.selectedDevice||s.getConfig().default,c=[{name:"A5",width:148,height:210,unit:"mm"},{name:"A5 Portrait",width:210,height:148,unit:"mm"},{name:"A4",width:210,height:297,unit:"mm"},{name:"A3",width:297,height:420,unit:"mm"},{name:"B5",width:176,height:250,unit:"mm"},{name:"B4",width:250,height:353,unit:"mm"},{name:"Letter",width:8.5,height:11,unit:"in"},{name:"Legal",width:8.5,height:14,unit:"in"},{name:"Ledger",width:11,height:17,unit:"in"}].map(y=>S0(y,t));s.devices.reset(c);const d=l&&s.get(l)||s.getAll().at(0);s.select(d);const u=()=>{const y="page-rule",{rules:b}=n.Css,{width:x,height:S,minHeight:C}=s.getSelected().attributes,E=S&&S!=="auto"?S:C;(b.where({id:y}).pop()||b.add({id:y,selectors:[],selectorsAdd:"@page"},{at:0})).setStyle({size:`${x} ${E}`,margin:"0"})},p=y=>{const b=y.document,{minHeight:x}=s.getSelected().attributes,C=`
|
|
353
|
+
${!!parseFloat(`${x}`)?`
|
|
354
|
+
[data-gjs-type="wrapper"] { min-height: ${x}; }
|
|
355
|
+
`:`
|
|
356
|
+
body {
|
|
357
|
+
overflow: hidden;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
[data-gjs-type="wrapper"] {
|
|
361
|
+
overflow: hidden;
|
|
362
|
+
height: 100dvh;
|
|
363
|
+
}
|
|
345
364
|
`}
|
|
346
|
-
`;
|
|
365
|
+
`;cs(`${di}preset-printable`,C,{doc:b,target:b.head}),u()};n.on(r.frameLoadBody,y=>{const b=y.window;if(p(b),t.fixedHeight){const S=y.model.getComponent().getEl();S==null||S.addEventListener("scroll",C=>{const E=C.target;E.scrollTop>0&&E.scrollTo(0,0)})}}),n.on(s.events.select,()=>{var b;const y=(b=o.getFrameEl().contentDocument)==null?void 0:b.defaultView;y&&p(y)});const h=()=>{const b=n.Css.getRules().filter(x=>x.selectorsToString()==="body").pop();b==null||b.addStyle({"margin-top":"","margin-right":"","margin-bottom":"","margin-left":"",margin:"0"})},f=[[i.projectLoad,h]];f.forEach(([y,b])=>n.on(y,b));const m=C0(n,t),g=k0(n),v=T0(n,t);n.onReady(()=>{n.UndoManager.clear()});const w=()=>{f.forEach(([y,b])=>n.off(y,b)),m(),g(),v()};W({editor:n,licenseKey:t.licenseKey,plan:F.startup,pluginName:M0,cleanup:w})});class A0{getHelperId(){}getVariableSyntax({collectionId:e,variableType:t,path:o,defaultValue:s}){let r=o;return e&&(r=[this._sanitizeVariableName(e),t,o].filter(Boolean).join(".")),s?`<%= ${r} || \`${s}\` %>`:`<%= ${r} %>`}getCollectionStartSyntax(e){const{collectionId:t,dataSource:o,startIndex:s,endIndex:r}=e,i=(o==null?void 0:o.path)||t||"",l=this._sanitizeVariableName(t);let a="";if(s!==void 0||r!==void 0){const c=s??0,d=r!==void 0?r:"";a=`.slice(${c}${d!==""?`, ${d}`:""})`}return`<% ${i}${a}.forEach(function(currentItem, index, arr) {
|
|
347
366
|
const startIndex = parseInt(${s??0}, 10);
|
|
348
367
|
const endIndex = startIndex + arr.length;
|
|
349
|
-
const ${l}={ currentItem, currentIndex: startIndex + index, remainingItems: endIndex - (startIndex + index)} %>`}_sanitizeVariableName(e){return e.replace(/[^a-zA-Z0-9_$]/g,"_")}getCollectionEndSyntax(){return"<% }) %>"}getConditionalStartSyntax(e){return e?e.logicalOperator==="and"||e.logicalOperator==="or"?`<% if (${e.statements.map(o=>this._parseCondition(o)).join(` ${e.logicalOperator} `)}) { %>`:`<% if (${this._parseCondition(e)}) { %>`:""}_parseCondition(e){if(!e)return"";if(e.operator==="and"||e.operator==="or")return`(${e.statements.map(o=>this._parseCondition(o)).join(` ${e.operator} `)})`;{const t=this._parseValue(e.left),o=this._parseValue(e.right);switch(e.operator){case"equals":return`${t} === ${o}`;case">":case"<":case">=":case"<=":case"=":case"!=":return`${t} ${e.operator} ${o}`;case"contains":return`${t}?.includes(${o})`;case"startsWith":return`${t}?.startsWith(${o})`;case"endsWith":return`${t}?.endsWith(${o})`;case"equalsIgnoreCase":return`${t}?.toLowerCase() === ${o}?.toLowerCase()`;case"trimEquals":return`${t}?.trim() === ${o}?.trim()`;case"isTruthy":return`!!${t}`;case"isFalsy":return`!${t}`;case"isDefined":return`${t} !== undefined`;case"isNull":return`${t} === null`;case"isUndefined":return`${t} === undefined`;case"isArray":return`Array.isArray(${t})`;case"isObject":return`typeof ${t} === 'object' && ${t} !== null && !Array.isArray(${t})`;case"isString":return`typeof ${t} === 'string'`;case"isNumber":return`typeof ${t} === 'number' && !isNaN(${t})`;case"isBoolean":return`typeof ${t} === 'boolean'`;default:return`${t} ${e.operator} ${o}`}}}_parseValue(e){return typeof e=="object"?this.getVariableSyntax(e):typeof e=="string"?`'${e.replace(/'/g,"\\'")}'`:String(e)}getConditionElseSyntax(){return"<% } else { %>"}getConditionalEndSyntax(){return"<% } %>"}}const y0="dataSourceEjs",b0=G(function(n,e={}){const t=({options:s})=>{s.exportConfig.exportPreset==="ejs"&&(s.exportConfig={...s.exportConfig,exportStrategy:new g0})},o=`${n.Commands.events.runBeforeCommand}${_.projectFiles}`;n.on(o,t),W({editor:n,licenseKey:e.licenseKey,plan:F.startup,pluginName:y0,cleanup:()=>{n.off(o,t)}})});class v0{getHelperId(e,t){return{equals:`${t==="string"?"str":t==="number"?"num":"any"}Equals`,isTruthy:"isTruthy",isFalsy:"isFalsy",isDefined:"isDefined",isNull:"isNull",isUndefined:"isUndefined",isArray:"isArray",isObject:"isObject",isString:"isString",isNumber:"isNumber",isBoolean:"isBoolean",isDefaultValue:"isDefaultValue",">":"numGt","<":"numLt",">=":"numGte","<=":"numLte","=":"numEq","!=":"numNeq",contains:"strContains",startsWith:"strStartsWith",endsWith:"strEndsWith",equalsIgnoreCase:"strEqualsIgnoreCase",trimEquals:"strTrimEquals"}[e]||e}getVariableSyntax({collectionId:e,variableType:t,path:o,defaultValue:s}){let i=o;return e&&(i=[this._sanitizeVariableName(e),t,o].filter(Boolean).join(".")),s?`{{#if ${o}}}{{{${i}}}}{{else}}${s}{{/if}}`:`{{{${i}}}}`}getCollectionStartSyntax(e){const{collectionId:t,dataSource:o}=e,s=o==null?void 0:o.path;let i="";if(e.startIndex!==void 0||e.endIndex!==void 0){const c=e.startIndex??0,d=e.endIndex!==void 0?e.endIndex:"";d!==""?i=` (slice ${s} ${c} ${d})`:i=` (slice ${s} ${c})`}const l=` as |${this._sanitizeVariableName(t)}|`;return`{{#each ${i||s}${l}}}`}getCollectionEndSyntax(){return"{{/each}}"}getConditionalStartSyntax(e){if(!e)return"";if(e.logicalOperator==="and"||e.logicalOperator==="or"){const t=this.getHelperId(e.logicalOperator),o=e.statements.map(s=>this._parseCondition(s)).join(", ");return`{{#if (${t} ${o})}}`}else return`{{#if ${this._parseCondition(e)}}}`}_parseCondition(e){if(!e)return"";if(e.operator==="and"||e.operator==="or"){const t=this.getHelperId(e.operator),o=e.statements.map(s=>this._parseCondition(s)).join(" ");return`(${t} ${o})`}else{const t=this.getHelperId(e.operator,this._getTypeHint(e)),o=this._parseValue(e.left),s=this._parseValue(e.right);return`(${t} ${o} ${s})`}}_getTypeHint(e){return["contains","startsWith","endsWith","equalsIgnoreCase","trimEquals"].includes(e.operator)?"string":[">","<",">=","<=","=","!="].includes(e.operator)?"number":"any"}_parseValue(e){return typeof e=="object"?this.getVariableSyntax(e):typeof e=="string"?`'${e.replace(/'/g,"\\'")}'`:String(e)}_sanitizeVariableName(e){return e.replace(/[^a-zA-Z0-9_$]/g,"_")}getConditionElseSyntax(){return"{{else}}"}getConditionalEndSyntax(){return"{{/if}}"}}const x0="dataSourceHandlebars",S0=G(function(n,e={}){const t=({options:s})=>{const i=s.exportConfig;i.exportPreset==="handlebarsjs"&&(s.exportConfig={...i,exportStrategy:new v0})},o=`${n.Commands.events.runBeforeCommand}${_.projectFiles}`;n.on(o,t),W({editor:n,licenseKey:e.licenseKey,plan:F.startup,pluginName:x0,cleanup:()=>{n.off(o,t)}})}),w0=n=>{const e={};for(const t of Object.keys(n)){let o=n[t];o&&(Array.isArray(o)?o=o.map(s=>s.toString()).join(","):o=o.toString(),e[t]=o)}return new URLSearchParams(e)},Td="youtube-video",C0=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:o="high"}=n,s=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=w0(l);return`${c}?${d}`},i=l=>{var a,c,d;return((a=l[o])==null?void 0:a.url)||((c=l.high)==null?void 0:c.url)||((d=l.medium)==null?void 0:d.url)||l.default.url},r=l=>{const a=i(l.snippet.thumbnails);return{id:l.id.videoId,src:`https://www.youtube.com/watch?v=${l.id.videoId}`,name:l.snippet.title,type:Td,customData:{thumbnailUrl:a,videoItem:l}}};return{id:"youtube",types:[Td],label:({editor:l})=>l.I18n.t("youtubeAssetProvider.providerLabel"),search:{reloadOnInput:!0,debounceMs:1e3},async onLoad({searchValue:l,pageCustomData:a}){var m;const c={maxResults:25,q:l,pageToken:a==null?void 0:a.token,type:["video"],key:e},d=t==null?void 0:t({searchValue:l}),u={...c,...d};u.part?u.part.includes("snippet")||u.part.push("snippet"):u.part=["snippet"];const p=await(await fetch(s(u))).json();return(m=p.items)!=null&&m.length?{items:p.items.map(r),nextPageCustomData:{token:p.nextPageToken},isLastPage:!p.nextPageToken}:{items:[],isLastPage:!0}},itemLayout:({assetProps:l,onSelect:a})=>({type:"column",onClick:()=>a(l),htmlAttrs:{title:l.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"custom",render:()=>{var c;return`<img src="${(c=l.customData)==null?void 0:c.thumbnailUrl}" alt="${l.name}" style="width: 100%; height: 100px; object-fit: cover">`}},{type:"text",content:l.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingLeft:8,paddingRight:8}}]})}},k0={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},T0="youtubeAssetProvider",M0=F.startup,A0=G(function(n,e){var c;const{skipVideoComponent:t,i18n:o={}}=e,s=C0(e);n.runCommand(_.assetProviderAdd,{provider:s});const i="search-on-youtube",r="video",l=(c=n.Components.getType(r))==null?void 0:c.model.prototype,a=d=>{n.Assets.open({modalTitle:n.I18n.t("youtubeAssetProvider.modalTitle"),providerId:s.id,providers:[],types:[],select:u=>{n.Assets.close(),d.set({videoId:u.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})};!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){const[d,...u]=l.getYoutubeTraits.apply(this);return[d,{id:i,type:"button",label:n.I18n.t("youtubeAssetProvider.searchBtn"),command:()=>a(this)},...u]}},view:{events:()=>({dblclick:"onActive"}),onActive(){const{model:d}=this,u=d.get("provider")||"";u!=null&&u.startsWith("yt")&&a(d)}}}),n.I18n.addMessages({en:k0,...o}),W({editor:n,licenseKey:e.licenseKey,plan:M0,pluginName:T0,cleanup:()=>{n.runCommand(_.assetProviderRemove,{id:s.id}),!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){return l.getYoutubeTraits.apply(this).filter(d=>d.id!==i)}}})}})}),Md=(n,e)=>{var r;const t=n.menuVariant??((r=Object.values(n.variants))==null?void 0:r[0]);if(!t)return"Arial, Helvetica, sans-serif";const{family:o,source:s,descriptors:i}=t;if(!e){const l=new FontFace(o,`url("${s}")`,i);document.fonts.add(l),l.load().catch(()=>{})}return o},E0=n=>{const{family:e,menu:t,axes:o}=n,s=!!o,i=Object.assign({},...n.variants.map(r=>{var d,u;let l,a;if(s){const h=o.find(p=>p.tag==="wght");if(h){const{start:p,end:f}=h;l=`${p} ${f}`}}return l||(l=((d=r.match(/\d+/))==null?void 0:d[0])??"400"),a=((u=r.match(/[a-zA-Z]+/))==null?void 0:u[0])==="italic"?"italic":void 0,{[r]:{family:e,source:n.files[r],variant:r,descriptors:{style:a,weight:l}}}}));return{family:e,menuVariant:{family:`menuFont-${e}`,source:t,variant:"menu"},variants:i}},N0=n=>({id:`${n.family}/${n.version}`,type:"font",src:n.menu,name:n.family,customData:{font:E0(n),needsLoading:!0}}),O0=n=>{const{font:e}=n.customData;return n.customData.needsLoading?(n.customData.needsLoading=!1,Md(e)):Md(e,!0)};let Un;const P0=n=>{const e=[];for(const t of Object.keys(n)){let o=n[t];o&&(Array.isArray(o)?e.push(...o.map(s=>[t,s.toString()])):(o=o.toString(),e.push([t,o])))}return new URLSearchParams(e)},I0=n=>{const{apiKey:e,searchParams:t}=n,o=(s={})=>{const i="https://www.googleapis.com/webfonts/v1/webfonts",r=P0(s);return`${i}?${r}`};return{id:"google-fonts",types:["font"],label:({editor:s})=>s.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var c;if(Un)return Un;const s={key:e,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},i=t==null?void 0:t(),r={...s,...i},a=await(await fetch(o(r))).json();return(c=a.items)!=null&&c.length?(Un=a.items.map(N0),Un):[]},itemLayout:s=>{const i=Un.find(l=>l.id===s.assetProps.id),r=O0(i);return{type:"column",onClick:()=>s.onSelect(i),htmlAttrs:{title:i.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:i.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:r,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}},{type:"text",content:i.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"16px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},R0={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},D0="googleFontsAssetProvider",L0=G(function(n,e){const{i18n:t={}}=e,o=I0(e);n.runCommand(_.assetProviderAdd,{provider:o}),n.I18n.addMessages({en:R0,...t}),W({editor:n,licenseKey:e.licenseKey,plan:F.startup,pluginName:D0,cleanup:()=>{n.runCommand(_.assetProviderRemove,{id:o.id})}})}),z0="canvasAbsoluteMode",V0=F.startup;function Qo({guideMatched:n,canvasView:e}){const t=n.guide.x===void 0?"y":"x";let o=0,s=0,i=0,r=0;const{guide:l,matched:a}=n,c=e.getElBoxRect(l.componentView.el),d=e.getElBoxRect(a.componentView.el),u=c.y,h=c.y+c.height,p=c.x,f=c.x+c.width,m=d.y,g=d.y+d.height,b=d.x,w=d.x+d.width,y=Math.max(0,u-g),v=Math.max(0,m-h),x=Math.max(0,p-w),S=Math.max(0,b-f),C=y>v,A=x>S,T=l.type;return t==="x"&&(T==="l"?(o=p,C?(s=g,i=y):(s=h,i=v)):T==="r"?(o=f,C?(s=g,i=y):(s=h,i=v)):T==="x"&&(o=p-(p-f)/2,C?(s=g,i=y):(s=h,i=v))),t==="y"&&(T==="t"?(s=u,A?(o=w,r=x):(o=f,r=S)):T==="b"?(s=h,A?(o=w,r=x):(o=f,r=S)):T==="y"&&(s=u-(u-h)/2,A?(o=w,r=x):(o=f,r=S))),{axis:t,x:o,y:s,width:r,height:i}}function $0({guideMatched:n,component:e,canvasView:t}){const o=n.guide.x===void 0?"x":"y",{guide:s,matched:i}=n,r=s.type,l=i.type,a=t.getElementPos(s.componentView.el).rect,c=t.getElementPos(i.componentView.el).rect;if(o==="x"){const d=a.height,u=c.top,h=c.top+c.height;let p=0;r==="t"?l==="t"?p=u-d:l==="b"?p=h-d:l==="y"&&(p=u-d-(u-h)/2):r==="b"?l==="t"?p=u-d*2:l==="b"?p=h-d*2:l==="y"&&(p=u-d*2-(u-h)/2):r==="y"&&(l==="t"?p=u-d*1.5:l==="b"?p=h-d*1.5:l==="y"&&(p=u-d*1.5-(u-h)/2)),e.addStyle({top:`${p-5}px`},{partial:!0})}if(o==="y"){const d=a.width,u=c.left,h=c.left+c.width;let p=0;r==="l"?l==="l"?p=u:l==="r"?p=h:l==="x"&&(p=u-(u-h)/2):r==="r"?l==="l"?p=u-d:l==="r"?p=h-d:l==="x"&&(p=u-d-(u-h)/2):r==="x"&&(l==="l"?p=u-d/2:l==="r"&&(p=h-d/2)),e.addStyle({left:`${p}px`},{partial:!0})}}function Ad({snapping:n,editor:e,props:t}){var N,I;const{command:o,guidesMatched:s}=t,i=t.component,r=i.getEl(),l=e.Canvas.getCanvasView(),{x:a,y:c}=n??{x:10,y:10},d=o.opts.event,u=d.clientX,h=d.clientY;if(!i.__lastSnappedPosition){const O=l.getElBoxRect(r),z=u-O.x,$=h-O.y;i.__lastSnappedPosition={left:O.x,top:O.y},i.__dragOffset={x:z,y:$}}const p=((N=i.__dragOffset)==null?void 0:N.x)||0,f=((I=i.__dragOffset)==null?void 0:I.y)||0,m=i.__lastSnappedPosition,g=u-m.left-p,b=h-m.top-f;let w=m.left,y=m.top;const v=s==null?void 0:s[0],x=(v==null?void 0:v.guide.type)==="l",S=(v==null?void 0:v.guide.type)==="x",C=(v==null?void 0:v.guide.type)==="r",A=(v==null?void 0:v.guide.type)==="t",T=(v==null?void 0:v.guide.type)==="b",M=(v==null?void 0:v.guide.type)==="y";if(v){const{x:O,y:z}=Qo({guideMatched:v,canvasView:l}),$=r.offsetWidth,te=r.offsetHeight;x?w=O:C?w=O-$:S?w=O-$/2:A?y=z:T?y=z-te:M&&(y=z-te/2),i.__lastSnappedGuideMatched=v}else Math.abs(g)>=a&&(w=Math.round((m.left+g)/a)*a,i.__lastSnappedGuideMatched=null),Math.abs(b)>=c&&(y=Math.round((m.top+b)/c)*c,i.__lastSnappedGuideMatched=null);return i.addStyle({left:`${w}px`,top:`${y}px`},{partial:!0}),i.__lastSnappedPosition={left:w,top:y},{x:w,y,guideMatched:i.__lastSnappedGuideMatched}}function B0({snapping:n,props:e,editor:t}){const{x:o,y:s}=Ad({snapping:n,props:e,editor:t}),i=e.component;i.addStyle({left:`${o}px`,top:`${s}px`}),delete i.__lastSnappedPosition,delete i.__lastSnappedGuideMatched}const H0="core:component-drag",F0="studio:setDragAbsolute",_0="dmode:start",Ed="dmode:move",Nd="dmode:end",ji="dragAbsolute",G0="select",W0="hover",j0="spacing",q0=G(function(n,e={}){const t=n.Commands.getConfig().defaultOptions??{};t[H0]={run:g=>({...g,skipGuidesRender:!0})};const{snapping:o,locking:s}=e,i=!!(o!=null&&o.x||o!=null&&o.y),r=!!(s!=null&&s.x||s!=null&&s.y),{Canvas:l}=n;let a=null;const c=g=>{const{component:b,guidesMatched:w,command:y}=g,v=b.view,x=n.Canvas.getCanvasView(),S=b.getEl();let C=w.map(M=>M.matched.componentEl),A=w.map(M=>Qo({guideMatched:M,canvasView:x}));if(i){const{guideMatched:M}=Ad({snapping:o,props:g,editor:n});M?(C=[M.matched.componentEl],A=[Qo({guideMatched:M,canvasView:x})]):(C=[],A=[])}if(r)if(y.opts.event.shiftKey)if(!a)a=w[0];else{const N=a,I=N.guide.x===void 0?"x":"y";(I==="x"&&(s==null?void 0:s.x)||I==="y"&&(s==null?void 0:s.y))&&($0({guideMatched:N,component:b,canvasView:x}),C=[N.matched.componentEl],A=[Qo({guideMatched:N,canvasView:x})])}else a=null;const T={id:ji,type:ji,component:b,componentView:v,originComponent:S,matchedComponents:C,originMatchedDistances:A};l.addSpot(T)},d=({enabled:g})=>{n.runCommand(F0,{enabled:g})},u=({type:g})=>{l.removeSpots({type:g})},h=()=>{u({type:G0}),u({type:W0}),u({type:j0})},p=g=>{d({enabled:!0}),c(g),h()},f=g=>{c(g),h()},m=g=>{u({type:ji}),i&&B0({snapping:o,props:g,editor:n}),d({enabled:!1})};n.on(_0,g=>{p(g),n.on(Ed,f);const b=()=>{m(g),n.off(Ed,f),n.off(Nd,b)};n.on(Nd,b)}),W({editor:n,licenseKey:e.licenseKey,plan:V0,pluginName:z0,cleanup:()=>d({enabled:!1})})});H.accordionComponent=Th,H.canvasAbsoluteMode=q0,H.canvasEmptyState=W1,H.canvasFullSize=q1,H.canvasGridMode=d0,H.dataSourceEjs=b0,H.dataSourceHandlebars=S0,H.dialogComponent=Ud,H.flexComponent=qh,H.fsLightboxComponent=ju,H.googleFontsAssetProvider=L0,H.iconifyComponent=cu,H.layoutSidebarButtons=kd,H.lightGalleryComponent=th,H.listPagesComponent=Fu,H.presetPrintable=m0,H.rteProseMirror=F1,H.rteTinyMce=np,H.swiperComponent=gh,H.tableComponent=Du,H.youtubeAssetProvider=A0,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});
|
|
368
|
+
const ${l}={ currentItem, currentIndex: startIndex + index, remainingItems: endIndex - (startIndex + index)} %>`}_sanitizeVariableName(e){return e.replace(/[^a-zA-Z0-9_$]/g,"_")}getCollectionEndSyntax(){return"<% }) %>"}getConditionalStartSyntax(e){return e?e.logicalOperator==="and"||e.logicalOperator==="or"?`<% if (${e.statements.map(o=>this._parseCondition(o)).join(` ${e.logicalOperator} `)}) { %>`:`<% if (${this._parseCondition(e)}) { %>`:""}_parseCondition(e){if(!e)return"";if(e.operator==="and"||e.operator==="or")return`(${e.statements.map(o=>this._parseCondition(o)).join(` ${e.operator} `)})`;{const t=this._parseValue(e.left),o=this._parseValue(e.right);switch(e.operator){case"equals":return`${t} === ${o}`;case">":case"<":case">=":case"<=":case"=":case"!=":return`${t} ${e.operator} ${o}`;case"contains":return`${t}?.includes(${o})`;case"startsWith":return`${t}?.startsWith(${o})`;case"endsWith":return`${t}?.endsWith(${o})`;case"equalsIgnoreCase":return`${t}?.toLowerCase() === ${o}?.toLowerCase()`;case"trimEquals":return`${t}?.trim() === ${o}?.trim()`;case"isTruthy":return`!!${t}`;case"isFalsy":return`!${t}`;case"isDefined":return`${t} !== undefined`;case"isNull":return`${t} === null`;case"isUndefined":return`${t} === undefined`;case"isArray":return`Array.isArray(${t})`;case"isObject":return`typeof ${t} === 'object' && ${t} !== null && !Array.isArray(${t})`;case"isString":return`typeof ${t} === 'string'`;case"isNumber":return`typeof ${t} === 'number' && !isNaN(${t})`;case"isBoolean":return`typeof ${t} === 'boolean'`;default:return`${t} ${e.operator} ${o}`}}}_parseValue(e){return typeof e=="object"?this.getVariableSyntax(e):typeof e=="string"?`'${e.replace(/'/g,"\\'")}'`:String(e)}getConditionElseSyntax(){return"<% } else { %>"}getConditionalEndSyntax(){return"<% } %>"}}const P0="dataSourceEjs",N0=G(function(n,e={}){const t=({options:s})=>{s.exportConfig.exportPreset==="ejs"&&(s.exportConfig={...s.exportConfig,exportStrategy:new A0})},o=`${n.Commands.events.runBeforeCommand}${_.projectFiles}`;n.on(o,t),W({editor:n,licenseKey:e.licenseKey,plan:F.startup,pluginName:P0,cleanup:()=>{n.off(o,t)}})});class O0{getHelperId(e,t){return{equals:`${t==="string"?"str":t==="number"?"num":"any"}Equals`,isTruthy:"isTruthy",isFalsy:"isFalsy",isDefined:"isDefined",isNull:"isNull",isUndefined:"isUndefined",isArray:"isArray",isObject:"isObject",isString:"isString",isNumber:"isNumber",isBoolean:"isBoolean",isDefaultValue:"isDefaultValue",">":"numGt","<":"numLt",">=":"numGte","<=":"numLte","=":"numEq","!=":"numNeq",contains:"strContains",startsWith:"strStartsWith",endsWith:"strEndsWith",equalsIgnoreCase:"strEqualsIgnoreCase",trimEquals:"strTrimEquals"}[e]||e}getVariableSyntax({collectionId:e,variableType:t,path:o,defaultValue:s}){let r=o;return e&&(r=[this._sanitizeVariableName(e),t,o].filter(Boolean).join(".")),s?`{{#if ${o}}}{{{${r}}}}{{else}}${s}{{/if}}`:`{{{${r}}}}`}getCollectionStartSyntax(e){const{collectionId:t,dataSource:o}=e,s=o==null?void 0:o.path;let r="";if(e.startIndex!==void 0||e.endIndex!==void 0){const c=e.startIndex??0,d=e.endIndex!==void 0?e.endIndex:"";d!==""?r=` (slice ${s} ${c} ${d})`:r=` (slice ${s} ${c})`}const l=` as |${this._sanitizeVariableName(t)}|`;return`{{#each ${r||s}${l}}}`}getCollectionEndSyntax(){return"{{/each}}"}getConditionalStartSyntax(e){if(!e)return"";if(e.logicalOperator==="and"||e.logicalOperator==="or"){const t=this.getHelperId(e.logicalOperator),o=e.statements.map(s=>this._parseCondition(s)).join(", ");return`{{#if (${t} ${o})}}`}else return`{{#if ${this._parseCondition(e)}}}`}_parseCondition(e){if(!e)return"";if(e.operator==="and"||e.operator==="or"){const t=this.getHelperId(e.operator),o=e.statements.map(s=>this._parseCondition(s)).join(" ");return`(${t} ${o})`}else{const t=this.getHelperId(e.operator,this._getTypeHint(e)),o=this._parseValue(e.left),s=this._parseValue(e.right);return`(${t} ${o} ${s})`}}_getTypeHint(e){return["contains","startsWith","endsWith","equalsIgnoreCase","trimEquals"].includes(e.operator)?"string":[">","<",">=","<=","=","!="].includes(e.operator)?"number":"any"}_parseValue(e){return typeof e=="object"?this.getVariableSyntax(e):typeof e=="string"?`'${e.replace(/'/g,"\\'")}'`:String(e)}_sanitizeVariableName(e){return e.replace(/[^a-zA-Z0-9_$]/g,"_")}getConditionElseSyntax(){return"{{else}}"}getConditionalEndSyntax(){return"{{/if}}"}}const I0="dataSourceHandlebars",R0=G(function(n,e={}){const t=({options:s})=>{const r=s.exportConfig;r.exportPreset==="handlebarsjs"&&(s.exportConfig={...r,exportStrategy:new O0})},o=`${n.Commands.events.runBeforeCommand}${_.projectFiles}`;n.on(o,t),W({editor:n,licenseKey:e.licenseKey,plan:F.startup,pluginName:I0,cleanup:()=>{n.off(o,t)}})}),D0=n=>{const e={};for(const t of Object.keys(n)){let o=n[t];o&&(Array.isArray(o)?o=o.map(s=>s.toString()).join(","):o=o.toString(),e[t]=o)}return new URLSearchParams(e)},Dd="youtube-video",L0=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:o="high"}=n,s=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=D0(l);return`${c}?${d}`},r=l=>{var a,c,d;return((a=l[o])==null?void 0:a.url)||((c=l.high)==null?void 0:c.url)||((d=l.medium)==null?void 0:d.url)||l.default.url},i=l=>{const a=r(l.snippet.thumbnails);return{id:l.id.videoId,src:`https://www.youtube.com/watch?v=${l.id.videoId}`,name:l.snippet.title,type:Dd,customData:{thumbnailUrl:a,videoItem:l}}};return{id:"youtube",types:[Dd],label:({editor:l})=>l.I18n.t("youtubeAssetProvider.providerLabel"),search:{reloadOnInput:!0,debounceMs:1e3},async onLoad({searchValue:l,pageCustomData:a}){var m;const c={maxResults:25,q:l,pageToken:a==null?void 0:a.token,type:["video"],key:e},d=t==null?void 0:t({searchValue:l}),u={...c,...d};u.part?u.part.includes("snippet")||u.part.push("snippet"):u.part=["snippet"];const h=await(await fetch(s(u))).json();return(m=h.items)!=null&&m.length?{items:h.items.map(i),nextPageCustomData:{token:h.nextPageToken},isLastPage:!h.nextPageToken}:{items:[],isLastPage:!0}},itemLayout:({assetProps:l,onSelect:a})=>({type:"column",onClick:()=>a(l),htmlAttrs:{title:l.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"custom",render:()=>{var c;return`<img src="${(c=l.customData)==null?void 0:c.thumbnailUrl}" alt="${l.name}" style="width: 100%; height: 100px; object-fit: cover">`}},{type:"text",content:l.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingLeft:8,paddingRight:8}}]})}},z0={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},$0="youtubeAssetProvider",V0=F.startup,B0=G(function(n,e){var c;const{skipVideoComponent:t,i18n:o={}}=e,s=L0(e);n.runCommand(_.assetProviderAdd,{provider:s});const r="search-on-youtube",i="video",l=(c=n.Components.getType(i))==null?void 0:c.model.prototype,a=d=>{n.Assets.open({modalTitle:n.I18n.t("youtubeAssetProvider.modalTitle"),providerId:s.id,providers:[],types:[],select:u=>{n.Assets.close(),d.set({videoId:u.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})};!t&&l&&n.Components.addType(i,{model:{getYoutubeTraits(){const[d,...u]=l.getYoutubeTraits.apply(this);return[d,{id:r,type:"button",label:n.I18n.t("youtubeAssetProvider.searchBtn"),command:()=>a(this)},...u]}},view:{events:()=>({dblclick:"onActive"}),onActive(){const{model:d}=this,u=d.get("provider")||"";u!=null&&u.startsWith("yt")&&a(d)}}}),n.I18n.addMessages({en:z0,...o}),W({editor:n,licenseKey:e.licenseKey,plan:V0,pluginName:$0,cleanup:()=>{n.runCommand(_.assetProviderRemove,{id:s.id}),!t&&l&&n.Components.addType(i,{model:{getYoutubeTraits(){return l.getYoutubeTraits.apply(this).filter(d=>d.id!==r)}}})}})}),Ld=(n,e)=>{var i;const t=n.menuVariant??((i=Object.values(n.variants))==null?void 0:i[0]);if(!t)return"Arial, Helvetica, sans-serif";const{family:o,source:s,descriptors:r}=t;if(!e){const l=new FontFace(o,`url("${s}")`,r);document.fonts.add(l),l.load().catch(()=>{})}return o},H0=n=>{const{family:e,menu:t,axes:o}=n,s=!!o,r=Object.assign({},...n.variants.map(i=>{var d,u;let l,a;if(s){const p=o.find(h=>h.tag==="wght");if(p){const{start:h,end:f}=p;l=`${h} ${f}`}}return l||(l=((d=i.match(/\d+/))==null?void 0:d[0])??"400"),a=((u=i.match(/[a-zA-Z]+/))==null?void 0:u[0])==="italic"?"italic":void 0,{[i]:{family:e,source:n.files[i],variant:i,descriptors:{style:a,weight:l}}}}));return{family:e,menuVariant:{family:`menuFont-${e}`,source:t,variant:"menu"},variants:r}},F0=n=>({id:`${n.family}/${n.version}`,type:"font",src:n.menu,name:n.family,customData:{font:H0(n),needsLoading:!0}}),_0=n=>{const{font:e}=n.customData;return n.customData.needsLoading?(n.customData.needsLoading=!1,Ld(e)):Ld(e,!0)};let Jn;const G0=n=>{const e=[];for(const t of Object.keys(n)){let o=n[t];o&&(Array.isArray(o)?e.push(...o.map(s=>[t,s.toString()])):(o=o.toString(),e.push([t,o])))}return new URLSearchParams(e)},W0=n=>{const{apiKey:e,searchParams:t}=n,o=(s={})=>{const r="https://www.googleapis.com/webfonts/v1/webfonts",i=G0(s);return`${r}?${i}`};return{id:"google-fonts",types:["font"],label:({editor:s})=>s.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var c;if(Jn)return Jn;const s={key:e,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},r=t==null?void 0:t(),i={...s,...r},a=await(await fetch(o(i))).json();return(c=a.items)!=null&&c.length?(Jn=a.items.map(F0),Jn):[]},itemLayout:s=>{const r=Jn.find(l=>l.id===s.assetProps.id),i=_0(r);return{type:"column",onClick:()=>s.onSelect(r),htmlAttrs:{title:r.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:r.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:i,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}},{type:"text",content:r.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"16px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},j0={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},q0="googleFontsAssetProvider",K0=G(function(n,e){const{i18n:t={}}=e,o=W0(e);n.runCommand(_.assetProviderAdd,{provider:o}),n.I18n.addMessages({en:j0,...t}),W({editor:n,licenseKey:e.licenseKey,plan:F.startup,pluginName:q0,cleanup:()=>{n.runCommand(_.assetProviderRemove,{id:o.id})}})}),U0="canvasAbsoluteMode",J0=F.startup;function ns({guideMatched:n,canvasView:e}){const t=n.guide.x===void 0?"y":"x";let o=0,s=0,r=0,i=0;const{guide:l,matched:a}=n,c=e.getElBoxRect(l.componentView.el),d=e.getElBoxRect(a.componentView.el),u=c.y,p=c.y+c.height,h=c.x,f=c.x+c.width,m=d.y,g=d.y+d.height,v=d.x,w=d.x+d.width,y=Math.max(0,u-g),b=Math.max(0,m-p),x=Math.max(0,h-w),S=Math.max(0,v-f),C=y>b,E=x>S,T=l.type;return t==="x"&&(T==="l"?(o=h,C?(s=g,r=y):(s=p,r=b)):T==="r"?(o=f,C?(s=g,r=y):(s=p,r=b)):T==="x"&&(o=h-(h-f)/2,C?(s=g,r=y):(s=p,r=b))),t==="y"&&(T==="t"?(s=u,E?(o=w,i=x):(o=f,i=S)):T==="b"?(s=p,E?(o=w,i=x):(o=f,i=S)):T==="y"&&(s=u-(u-p)/2,E?(o=w,i=x):(o=f,i=S))),{axis:t,x:o,y:s,width:i,height:r}}function Y0({guideMatched:n,component:e,canvasView:t}){const o=n.guide.x===void 0?"x":"y",{guide:s,matched:r}=n,i=s.type,l=r.type,a=t.getElementPos(s.componentView.el).rect,c=t.getElementPos(r.componentView.el).rect;if(o==="x"){const d=a.height,u=c.top,p=c.top+c.height;let h=0;i==="t"?l==="t"?h=u-d:l==="b"?h=p-d:l==="y"&&(h=u-d-(u-p)/2):i==="b"?l==="t"?h=u-d*2:l==="b"?h=p-d*2:l==="y"&&(h=u-d*2-(u-p)/2):i==="y"&&(l==="t"?h=u-d*1.5:l==="b"?h=p-d*1.5:l==="y"&&(h=u-d*1.5-(u-p)/2)),e.addStyle({top:`${h-5}px`},{partial:!0})}if(o==="y"){const d=a.width,u=c.left,p=c.left+c.width;let h=0;i==="l"?l==="l"?h=u:l==="r"?h=p:l==="x"&&(h=u-(u-p)/2):i==="r"?l==="l"?h=u-d:l==="r"?h=p-d:l==="x"&&(h=u-d-(u-p)/2):i==="x"&&(l==="l"?h=u-d/2:l==="r"&&(h=p-d/2)),e.addStyle({left:`${h}px`},{partial:!0})}}function zd({snapping:n,editor:e,props:t}){var P,I;const{command:o,guidesMatched:s}=t,r=t.component,i=r.getEl(),l=e.Canvas.getCanvasView(),{x:a,y:c}=n??{x:10,y:10},d=o.opts.event,u=d.clientX,p=d.clientY;if(!r.__lastSnappedPosition){const N=l.getElBoxRect(i),z=u-N.x,V=p-N.y;r.__lastSnappedPosition={left:N.x,top:N.y},r.__dragOffset={x:z,y:V}}const h=((P=r.__dragOffset)==null?void 0:P.x)||0,f=((I=r.__dragOffset)==null?void 0:I.y)||0,m=r.__lastSnappedPosition,g=u-m.left-h,v=p-m.top-f;let w=m.left,y=m.top;const b=s==null?void 0:s[0],x=(b==null?void 0:b.guide.type)==="l",S=(b==null?void 0:b.guide.type)==="x",C=(b==null?void 0:b.guide.type)==="r",E=(b==null?void 0:b.guide.type)==="t",T=(b==null?void 0:b.guide.type)==="b",M=(b==null?void 0:b.guide.type)==="y";if(b){const{x:N,y:z}=ns({guideMatched:b,canvasView:l}),V=i.offsetWidth,te=i.offsetHeight;x?w=N:C?w=N-V:S?w=N-V/2:E?y=z:T?y=z-te:M&&(y=z-te/2),r.__lastSnappedGuideMatched=b}else Math.abs(g)>=a&&(w=Math.round((m.left+g)/a)*a,r.__lastSnappedGuideMatched=null),Math.abs(v)>=c&&(y=Math.round((m.top+v)/c)*c,r.__lastSnappedGuideMatched=null);return r.addStyle({left:`${w}px`,top:`${y}px`},{partial:!0}),r.__lastSnappedPosition={left:w,top:y},{x:w,y,guideMatched:r.__lastSnappedGuideMatched}}function Z0({snapping:n,props:e,editor:t}){const{x:o,y:s}=zd({snapping:n,props:e,editor:t}),r=e.component;r.addStyle({left:`${o}px`,top:`${s}px`}),delete r.__lastSnappedPosition,delete r.__lastSnappedGuideMatched}const X0="core:component-drag",Q0="studio:setDragAbsolute",ey="dmode:start",$d="dmode:move",Vd="dmode:end",Qr="dragAbsolute",ty="select",ny="hover",oy="spacing",sy=G(function(n,e={}){const t=n.Commands.getConfig().defaultOptions??{};t[X0]={run:g=>({...g,skipGuidesRender:!0})};const{snapping:o,locking:s}=e,r=!!(o!=null&&o.x||o!=null&&o.y),i=!!(s!=null&&s.x||s!=null&&s.y),{Canvas:l}=n;let a=null;const c=g=>{const{component:v,guidesMatched:w,command:y}=g,b=v.view,x=n.Canvas.getCanvasView(),S=v.getEl();let C=w.map(M=>M.matched.componentEl),E=w.map(M=>ns({guideMatched:M,canvasView:x}));if(r){const{guideMatched:M}=zd({snapping:o,props:g,editor:n});M?(C=[M.matched.componentEl],E=[ns({guideMatched:M,canvasView:x})]):(C=[],E=[])}if(i)if(y.opts.event.shiftKey)if(!a)a=w[0];else{const P=a,I=P.guide.x===void 0?"x":"y";(I==="x"&&(s==null?void 0:s.x)||I==="y"&&(s==null?void 0:s.y))&&(Y0({guideMatched:P,component:v,canvasView:x}),C=[P.matched.componentEl],E=[ns({guideMatched:P,canvasView:x})])}else a=null;const T={id:Qr,type:Qr,component:v,componentView:b,originComponent:S,matchedComponents:C,originMatchedDistances:E};l.addSpot(T)},d=({enabled:g})=>{n.runCommand(Q0,{enabled:g})},u=({type:g})=>{l.removeSpots({type:g})},p=()=>{u({type:ty}),u({type:ny}),u({type:oy})},h=g=>{d({enabled:!0}),c(g),p()},f=g=>{c(g),p()},m=g=>{u({type:Qr}),r&&Z0({snapping:o,props:g,editor:n}),d({enabled:!1})};n.on(ey,g=>{h(g),n.on($d,f);const v=()=>{m(g),n.off($d,f),n.off(Vd,v)};n.on(Vd,v)}),W({editor:n,licenseKey:e.licenseKey,plan:J0,pluginName:U0,cleanup:()=>d({enabled:!1})})});H.accordionComponent=Dp,H.canvasAbsoluteMode=sy,H.canvasEmptyState=Q1,H.canvasFullSize=t0,H.canvasGridMode=v0,H.dataSourceEjs=N0,H.dataSourceHandlebars=R0,H.dialogComponent=ou,H.flexComponent=th,H.fsLightboxComponent=ep,H.googleFontsAssetProvider=K0,H.iconifyComponent=bu,H.layoutSidebarButtons=Id,H.lightGalleryComponent=dp,H.listPagesComponent=Yu,H.presetPrintable=E0,H.rteProseMirror=Y1,H.rteTinyMce=uh,H.swiperComponent=Tp,H.tableComponent=Gu,H.youtubeAssetProvider=B0,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});
|