@grapesjs/studio-sdk-plugins 1.0.31 → 1.0.32
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/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +12 -12
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +1 -1
- package/dist/iconifyComponent/index.es.js +7 -7
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +68 -68
- package/dist/index.es.js +165 -165
- package/dist/index.umd.js +24 -24
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +18 -18
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/layoutSidebarButtons/types.d.ts +1 -1
- package/dist/presetPrintable/index.cjs.js +5 -5
- package/dist/presetPrintable/index.es.js +132 -132
- package/dist/presetPrintable/index.umd.js +6 -6
- package/dist/presetPrintable/types.d.ts +3 -0
- package/dist/prosemirror/index.cjs.js +1 -1
- package/dist/prosemirror/index.es.js +1 -1
- package/dist/prosemirror/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +1 -1
- package/dist/rteTinyMce/index.es.js +5 -5
- package/dist/rteTinyMce/index.umd.js +1 -1
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +13 -13
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +41 -41
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const wp=require("handlebars/dist/cjs/handlebars"),Ia="app.grapesjs.com",Oa="app-stage.grapesjs.com",Cp="app2.grapesjs.com",kp="app-stage2.grapesjs.com",wr=[Ia,Cp,Oa,kp,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],Ep="license:check:start",Tp="license:check:end",Mp=()=>typeof window<"u",
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const wp=require("handlebars/dist/cjs/handlebars"),Ia="app.grapesjs.com",Oa="app-stage.grapesjs.com",Cp="app2.grapesjs.com",kp="app-stage2.grapesjs.com",wr=[Ia,Cp,Oa,kp,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],Ep="license:check:start",Tp="license:check:end",Mp=()=>typeof window<"u",Qs=(n,e={})=>{const t=Dp(n)?{id:n,src:n}:n;return new Promise((o,s)=>{var u,h;const{loadedScripts:i}=e,{id:r,src:l}=t,a=document.querySelector(`script[src="${l}"]`);if(a){if((u=e.onScript)==null||u.call(e,a),i&&!i.get(l)){a.addEventListener("load",()=>o(r)),a.addEventListener("error",()=>s(r));return}return o(r)}const c=window.define;window.define=void 0;const d=()=>{i==null||i.set(l,!0),window.define=c},p=document.createElement("script");p.src=l,p.onload=()=>{o(r),d()},p.onerror=()=>{s(r),d()},document.head.appendChild(p),(h=e.onScript)==null||h.call(e,p)})},Ap=n=>{const e=n.map(t=>Qs(t));return Promise.allSettled(e)},Pp=async n=>{const e=window.define;window.define=void 0;const t=await Ap(n);return window.define=e,t},Np=({isDev:n,isStage:e})=>`${n?"":`https://${e?Oa:Ia}`}/api`,Ip=()=>{const n=Mp()&&window.location.hostname;return!!n&&(wr.includes(n)||wr.some(e=>n.endsWith(e)))},Op=n=>n.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,t)=>(t?"-":"")+e.toLowerCase()),Rp=n=>typeof n<"u",Dp=n=>typeof n=="string";function _t(n){return typeof n=="function"}async function Lp({path:n,baseApiUrl:e,method:t="GET",headers:o={},params:s,body:i}){const l=`${e||Np({isDev:!1,isStage:!1})}${n}`,a={method:t,headers:{"Content-Type":"application/json",...o}};i&&(a.body=JSON.stringify(i));const c=s?new URLSearchParams(s).toString():"",d=c?`?${c}`:"",p=await fetch(`${l}${d}`,a);if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);return p.json()}var H=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(H||{}),Ra=(n=>(n.Info="info",n.Error="error",n.Success="success",n.Warning="warning",n))(Ra||{}),W=(n=>(n.toastAdd="studio:toastAdd",n.toastRemove="studio:toastRemove",n.dialogOpen="studio:dialogOpen",n.dialogClose="studio:dialogClose",n.dialogExportCode="studio:dialogExportCode",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.clearPage="studio:clearPage",n.projectFiles="studio:projectFiles",n.validateCode="studio:validateCode",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.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",n.dataSourceSetImporter="studio:dataSourceSetImporter",n.dataSourceSetExporter="studio:dataSourceSetExporter",n.setDragAbsolute="studio:setDragAbsolute",n))(W||{}),Da=(n=>(n.layoutToggleId="studio:layoutToggle:",n.toggleBlocksPanel="studio:toggleBlocksPanel",n.pageSettingsUpdate="studio:pageSettingsUpdate",n.toggleDataSourcesPreview="studio:toggleDataSourcesPreview",n))(Da||{}),La=(n=>(n.dark="dark",n.light="light",n.auto="auto",n))(La||{}),$a=(n=>(n.web="web",n.email="email",n.document="document",n.react="react",n))($a||{});const Cr={[H.free]:0,[H.startup]:10,[H.business]:20,[H.enterprise]:30};function $p(n){const e=n;return e.init=t=>o=>n(o,t),e}const _=n=>$p(n);async function G({editor:n,plan:e,pluginName:t,licenseKey:o,cleanup:s}){let i="",r=!1;const l=Ip(),a=d=>{console.warn("Cleanup plugin:",t,"Reason:",d),s()},c=(d={})=>{var m;const{error:p,sdkLicense:u}=d,h=(m=d.plan)==null?void 0:m.category;if(!(u||d.license)||p)a(p||"Invalid license");else if(h){const g=Cr[e],b=Cr[h];g>b&&a({pluginRequiredPlan:e,licensePlan:h})}};n.on(Ep,d=>{i=d==null?void 0:d.baseApiUrl,r=!0}),n.on(Tp,d=>{c(d)}),setTimeout(async()=>{if(!r){if(l)return;if(o){const d=await zp({licenseKey:o,pluginName:t,baseApiUrl:i});d&&c(d)}else a("The `licenseKey` option not provided")}},2e3)}async function zp(n){const{licenseKey:e,pluginName:t,baseApiUrl:o}=n;try{return(await Lp({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 Po=(n,e)=>{var t;return!!((t=n==null?void 0:n.hasAttribute)!=null&&t.call(n,e))},gt=(n,e)=>{var t;return!!((t=n==null?void 0:n.classList)!=null&&t.contains(e))},Fe=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,Re))===n},cs=(...n)=>e=>n.some(t=>e.is(t)),qi=(...n)=>(e,t)=>n.some(o=>t.is(o)),Vp=(n,e={})=>{var i;const t={},o=[],s=[];for(const r in n){const{value:l,...a}=n[r];o.push({id:r,name:r,changeProp:!0,category:e.category,...a}),t[r]=l,!Rp(l)&&s.push(r);const{subTraits:c={}}=a;for(const d in a.subTraits)(i=c[d])==null||i.forEach(p=>{const u=p.id||p.name;t[u]=p.value})}return{propKeys:Object.keys(t),propsNoValues:s,props:t,traits:o}},Bp=(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,()=>kr(n,o)),kr(n,o)}})},kr=(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})},Ui=(n,e,t)=>{const{doc:o=document}=t,s=t.target||o.head,i=s.querySelector(`style[${n}]`)||o.createElement("style");i.setAttribute(n,"true"),i.innerHTML=e,!s.contains(i)&&s.appendChild(i)},Hp=(n,e)=>{e.forEach(t=>{const o=Op(t);o!==t&&n.has(o)&&n.set({[t]:n.get(o),[o]:void 0})})},Me="gjs-plg-",Bo="data-gs-plg-",Re="data-type-role",Er=(...n)=>n.map(e=>`[data-gjs-type="${e}"]`).join(","),Fp="dialogComponent",_p=function(n,e={}){const{Blocks:t,Components:o}=n,{licenseKey:s}=e,i="gjs-plg-dialog",r="gjs-plg-dialog-overlay",l="gjs-plg-dialog-content",a="gjs-plg-dialog-close",c="gjs-plg-dialog-title",d="gjs-plg-dialog-body",p="gjs-plg-dialog-description",u="gjs-plg-dialog-placeholder";t.add(i,{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:i},activate:!0,...e.block}),
|
|
5
|
+
`,category:"Extra",content:{type:i},activate:!0,...e.block}),o.addType(i,{model:{defaults:{tagName:"div",attributes:{class:i,"data-type-role":i},components:[{type:r},{type:u}],draggable:Er("wrapper"),droppable:Er(i),styles:`
|
|
6
6
|
.${i} {
|
|
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(v){const w=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'),S=m.querySelector('[data-type-role="gjs-plg-dialog-close"]');function x(){w.style.display="none"}v?(m._onCloseWhenPressingX=x,S.addEventListener("click",m._onCloseWhenPressingX)):(S.removeEventListener("click",m._onCloseWhenPressingX),m._onCloseWhenPressingX=null)}function b(v){const w=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function S(x){x.key==="Escape"&&(w.style.display="none")}v?(m._onCloseWhenPressingEsc=S,m.addEventListener("keydown",m._onCloseWhenPressingEsc)):(m.removeEventListener("keydown",m._onCloseWhenPressingEsc),m._onCloseWhenPressingEsc=null)}function C(v){const w=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function S(){w.style.display="flex"}v?(m._onOpenWhenLeavingWindow=S,document.addEventListener("mouseleave",m._onOpenWhenLeavingWindow)):(document.removeEventListener("mouseleave",m._onOpenWhenLeavingWindow),m._onOpenWhenLeavingWindow=null)}function y(v){const w=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function S(){const x=document.documentElement.scrollTop;v&&x>=Number(v)&&(w.style.display="flex")}v?(m._onOpenWhenScrollingToLevel=S,document.addEventListener("scroll",m._onOpenWhenScrollingToLevel)):(document.removeEventListener("scroll",m._onOpenWhenScrollingToLevel),m._onOpenWhenScrollingToLevel=null)}g(f.closeWhenPressingX),b(f.closeWhenPressingEsc),C(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"}}}),
|
|
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(v){const w=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'),S=m.querySelector('[data-type-role="gjs-plg-dialog-close"]');function x(){w.style.display="none"}v?(m._onCloseWhenPressingX=x,S.addEventListener("click",m._onCloseWhenPressingX)):(S.removeEventListener("click",m._onCloseWhenPressingX),m._onCloseWhenPressingX=null)}function b(v){const w=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function S(x){x.key==="Escape"&&(w.style.display="none")}v?(m._onCloseWhenPressingEsc=S,m.addEventListener("keydown",m._onCloseWhenPressingEsc)):(m.removeEventListener("keydown",m._onCloseWhenPressingEsc),m._onCloseWhenPressingEsc=null)}function C(v){const w=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function S(){w.style.display="flex"}v?(m._onOpenWhenLeavingWindow=S,document.addEventListener("mouseleave",m._onOpenWhenLeavingWindow)):(document.removeEventListener("mouseleave",m._onOpenWhenLeavingWindow),m._onOpenWhenLeavingWindow=null)}function y(v){const w=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function S(){const x=document.documentElement.scrollTop;v&&x>=Number(v)&&(w.style.display="flex")}v?(m._onOpenWhenScrollingToLevel=S,document.addEventListener("scroll",m._onOpenWhenScrollingToLevel)):(document.removeEventListener("scroll",m._onOpenWhenScrollingToLevel),m._onOpenWhenScrollingToLevel=null)}g(f.closeWhenPressingX),b(f.closeWhenPressingEsc),C(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(r,{model:{defaults:{tagName:"div",attributes:{class:r,"data-type-role":r},components:{type:l},droppable:!1,draggable:!1,styles:`
|
|
11
11
|
.${r} {
|
|
12
12
|
position: fixed;
|
|
13
13
|
top: 0;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
justify-content: center;
|
|
20
20
|
background-color: rgba(0, 0, 0, 0.5);
|
|
21
21
|
}
|
|
22
|
-
`}}}),
|
|
22
|
+
`}}}),o.addType(l,{model:{defaults:{tagName:"div",attributes:{class:l,"data-type-role":l},components:[{type:a},{type:c},{type:d}],droppable:!1,draggable:!1,styles:`
|
|
23
23
|
.${l} {
|
|
24
24
|
position: relative;
|
|
25
25
|
background-color: #fff;
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
height: 600px;
|
|
31
31
|
box-sizing: border-box;
|
|
32
32
|
}
|
|
33
|
-
`}}}),
|
|
33
|
+
`}}}),o.addType(a,{model:{defaults:{tagName:"button",attributes:{class:a,"data-type-role":a},components:"×",droppable:!1,draggable:!1,styles:`
|
|
34
34
|
.${a} {
|
|
35
35
|
position: absolute;
|
|
36
36
|
top: 10px;
|
|
@@ -42,38 +42,38 @@
|
|
|
42
42
|
font-size: 20px;
|
|
43
43
|
cursor: pointer;
|
|
44
44
|
}
|
|
45
|
-
`}}}),
|
|
45
|
+
`}}}),o.addType(c,{model:{defaults:{tagName:"h2",attributes:{class:c,"data-type-role":c},components:"Dialog Title",editable:!0,droppable:!1,draggable:!1,styles:`
|
|
46
46
|
.${c} {
|
|
47
47
|
margin: 0;
|
|
48
48
|
padding: 0 40px 20px 0;
|
|
49
49
|
}
|
|
50
|
-
`}}}),
|
|
50
|
+
`}}}),o.addType(d,{model:{defaults:{tagName:"div",attributes:{class:d,"data-type-role":d},components:[{type:p}],styles:`
|
|
51
51
|
.${d} {
|
|
52
52
|
height: 90%;
|
|
53
53
|
overflow: auto;
|
|
54
54
|
}
|
|
55
|
-
`}}}),
|
|
55
|
+
`}}}),o.addType(p,{model:{defaults:{tagName:"p",attributes:{class:p,"data-type-role":p},components:"This is a customizable dialog!",editable:!0,styles:`
|
|
56
56
|
.${p} {
|
|
57
57
|
margin: 0;
|
|
58
58
|
}
|
|
59
|
-
`}}}),
|
|
59
|
+
`}}}),o.addType(u,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:u,"data-type-role":u},components:"Dialog (click me to open)",droppable:!1,draggable:!1}},view:{init(){const{em:f,el:m}=this,g="core:preview",b=f.Commands.events;this.listenTo(f,`${b.runCommand}${g}`,()=>{m.style.display="none"}),this.listenTo(f,`${b.stopCommand}${g}`,()=>{m.style.display=""})}}}),G({editor:n,licenseKey:s,plan:H.startup,pluginName:Fp,cleanup:()=>{t.remove(i),o.removeType(i)}})},Gp=_(_p),Wp="iconifyComponent",jp=H.startup,qp={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},ws=`<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>`,za="layout-icon-picker",Up="icons-layout-",Va="icons-list-layout",Ba="gs-iconify-picker",Ki="__iconify_collection",Kp="https://api.iconify.design",Co=new Map;let fs;const Jp=({collectionId:n})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${n}@latest/icons.json`;async function Ha({collectionId:n,editor:e}){try{if(Co.has(n))return Co.get(n);const t=await fetch(Jp({collectionId:n}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const s=await t.json();return Co.set(n,s),s}catch(t){console.error("Error fetching collection",t),e.runCommand(W.toastAdd,tu());return}}async function Zp({collectionIds:n,editor:e}){try{if(fs)return fs;const t=n?`?prefixes=${n.join(",")}`:"",s=await fetch(`${Kp}/collections${t}`);if(!s.ok)throw new Error(`Failed to fetch collections: ${s.statusText}`);return fs=await s.json(),fs}catch(t){console.error("Error fetching collections",t),e.runCommand(W.toastAdd,_a());return}}function Tr(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(n){var e;(e=n.getSelected())==null||e.trigger("active")}}}async function Yp({collectionIds:n,editor:e,component:t}){const s=await Zp({collectionIds:n,editor:e});if(!s)return;const o=({icon:a,collectionId:c,iconId:d})=>{t.components(a),t.set({collectionId:c,iconId:d})},i=Object.entries(s).map(([a,c])=>({id:a,...c})).sort((a,c)=>a.name.localeCompare(c.name)),r=t.get("collectionId")??i[0].id;e.runCommand(W.layoutToggle,{id:za,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[Qp({collectionsList:i,collectionId:r,editor:e,handleClick:o}),{id:Va,type:"column",grow:!0}]}});const l=await Ha({collectionId:r,editor:e});l&&(Fa({editor:e,collection:l}),ei({editor:e,collection:l,handleClick:o,collectionId:r}))}function Fa({editor:n,collection:e}){n.em.set(Ki,e)}function Xp(n){return n.em.get(Ki)}function ei(n){const{editor:e}=n;e.runCommand(W.layoutUpdate,{id:Up,layout:eu(n),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:Va}})}function Qp(n){const{collectionsList:e,collectionId:t,editor:s,handleClick:o}=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:`${Ba}__header`,children:[{type:"selectField",value:t,options:i,emptyState:"Select an icon collection",onChange:async({setState:r,value:l})=>{const a=await Ha({collectionId:l,editor:s});a&&(r({value:l}),Fa({editor:s,collection:a}),ei({editor:s,collection:a,handleClick:o,collectionId:l}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${Ki}`]:({setState:r})=>r({value:""})},onInput:({setState:r,value:l,editor:a})=>{const c=Xp(a);if(!c)return;const d=Object.fromEntries(Object.entries(c.icons).filter(([p])=>p.includes(l)));r({value:l}),ei({editor:a,collection:c,handleClick:o,collectionId:t,collectionFiltered:{...c,icons:d}})}}]}}function eu({collection:n,collectionFiltered:e,handleClick:t}){const{height:s=24,width:o=24,icons:i,prefix:r}=e||n,l=Object.entries(i).map(([a,c])=>({name:a,...c}),{});return{type:"column",className:`${Ba}__content`,style:{height:"100%"},children:{type:"virtualList",items:l,itemLayout:({item:a})=>({type:"custom",render:c=>{const{editor:d,addEl:p,removeEl:u}=c,h=document.createElementNS("http://www.w3.org/2000/svg","svg");h.setAttribute("xmlns","http://www.w3.org/2000/svg"),h.innerHTML=a.body;const f=a.width||o,m=a.height||s;h.setAttribute("viewBox",`0 0 ${f} ${m}`),h.style.cssText="width: 48px; height: 48px; cursor: pointer; border-radius: 4px; transition: padding 0.1s ease-in-out;";const g=[["click",()=>{const b=h.cloneNode(!0);b.removeAttribute("style");const C=b.outerHTML;t({icon:C,collectionId:r,iconId:a.name}),d==null||d.runCommand(W.layoutRemove,{id:za})}],["pointerover",()=>{h.style.border="2px solid currentColor",h.style.padding="4px"}],["pointerout",()=>{h.style.border="",h.style.padding=""}]];return g.forEach(([b,C])=>h.addEventListener(b,C)),p(h),()=>{g.forEach(([b,C])=>h.removeEventListener(b,C)),u(h)}}})}}}function _a(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:Ra.Error}}function tu(){return{..._a(),id:"toast-error-getCollection",content:"Error fetching collection"}}const nu=function(n,e={}){var h;const{Components:t,Blocks:s}=n,{collections:o,extendIconComponent:i=!0,licenseKey:r,block:l={}}=e,a="icon",c="iconify",d="Iconify",p="data-type-iconify",u={events:()=>({dblclick:"onActive"}),onActive(){Yp({collectionIds:o,editor:n,component:this.model})}};if(t.addType(c,{block:l&&{label:d,media:wo,content:{type:c},category:"Extra",activate:!0,...l},isComponent:f=>Ps(f,p),model:{defaults:{name:d,icon:wo,droppable:!1,attributes:{[p]:!0},resizable:qp,components:wo,style:{width:"50px",height:"50px"},traits:[Tr()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(f=>f.set({layerable:!1,locked:!0}))}},view:u}),i){const f=(h=t.getType(a))==null?void 0:h.model,[m,g,...b]=f.getDefaults().traits;t.addType(a,{model:{defaults:{traits:[m,g,Tr(),...b]}},view:u})}_({editor:n,licenseKey:r,plan:jp,pluginName:Wp,cleanup:()=>{s.remove(c),t.removeType(c)}})},su=F(nu);function jn(n,e,t){let s,o,i,r,l;const a=e===void 0?100:e;function c(){const p=Date.now()-r;p<a&&p>=0?s=setTimeout(c,a-p):(s=null,l=n.apply(i,o),i=o=null)}const d=function(){return i=this,o=arguments,r=Date.now(),s||(s=setTimeout(c,a)),l};return d.clear=function(){s&&(clearTimeout(s),s=null)},d.flush=function(){s&&(l=n.apply(i,o),i=o=null,clearTimeout(s),s=null)},d}const ou="tableComponent",iu=H.startup;var I=(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))(I||{});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>'},He="table",Ga="thead",Wa="tfoot",ti="tbody",ge="row",q="cell",Ji="clipboardTable",ru=[He,Ga,Wa,ti,ge,q],co=n=>n.em.get(Ji)||[],lu=n=>n.every(e=>e.is(q)),Zi=(n,e)=>{const{editor:t,event:s,opts:o}=n,i=s.currentTarget||s.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};_t(o.openSettings)?o.openSettings({...n,layoutProps:d}):t.runCommand(W.layoutToggle,d)},au=(n,{rows:e=1,cells:t=5,text:s}={})=>({type:n,components:Array.from(Array(e).keys()).map(o=>({type:ge,components:Array.from(Array(t).keys()).map(i=>({type:q,components:s?{type:"text",content:_t(s)?s({y:o,x:i}):s}:void 0}))}))}),ja="Table settings",qa=n=>{const{component:e}=n;return e.is(He)?e:e.closestType(He)},cu=n=>{var e;(e=qa(n))==null||e.remove(n.opts)},du=n=>{const e=qa(n);e&&(n.editor.select(e),Zi(n,{id:"tableSettings",header:{label:ja}}))},Ua=n=>[{id:I.table,icon:V[I.table],label:"Table",items:[{id:I.tableSettings,label:ja,icon:V[I.tableSettings],onClick:({event:t})=>du({...n,event:t})},{id:I.tableDelete,label:"Delete table",icon:V[I.tableDelete],onClick:()=>cu(n)}]}],Ka=({editor:n})=>{const e=co(n);return e.length&&lu(e)},Mr=({component:n,editor:e,after:t})=>{if(!n.is(q))return;const s=n.closestType(He),o=n.closestType(ge),i=n.index()+(t?1:0);s==null||s.findType(ge).forEach(l=>l.append({type:q},{at:i}));const r=o==null?void 0:o.components().at(i);r&&e.select(r)},Ja=({component:n,opts:e})=>{if(!n.is(q))return;const t=n.closestType(He),s=n.index();t==null||t.findType(ge).forEach(o=>{var i;return(i=o.components().at(s))==null?void 0:i.remove(e)})},Za=({component:n,editor:e})=>{if(!n.is(q))return;const t=n.closestType(He),s=n.index(),o=(t==null?void 0:t.findType(ge).map(i=>i.components().at(s)))||[];o.length&&e.em.set(Ji,o)},Ar=n=>{const{component:e,editor:t,after:s}=n;if(!e.is(q)||!Ka(n))return;const o=co(t),i=e.closestType(He),r=e.index()+(s?1:0);i==null||i.findType(ge).forEach((l,a)=>{const c=o[a],d=(c==null?void 0:c.clone())||{type:q};l.append(d,{at:r})})},pu=n=>{const{component:e}=n;e.is(q)&&(Za(n),Ja({...n,opts:{temporary:!0}}))},uu=n=>{const e=Ka(n);return[{id:I.tableColumnItems,icon:V[I.tableColumn],label:"Column",items:[{id:I.tableColumnInsertBefore,label:"Insert column before",icon:V[I.tableColumnInsertBefore],onClick:()=>Mr(n)},{id:I.tableColumnInsertAfter,label:"Insert column after",icon:V[I.tableColumnInsertAfter],onClick:()=>Mr({...n,after:!0})},{id:I.tableColumnDelete,label:"Delete column",icon:V[I.tableColumnDelete],onClick:()=>Ja(n)},{id:I.tableColumnCut,label:"Cut column",icon:V[I.tableColumnCut],onClick:()=>pu(n)},{id:I.tableColumnCopy,label:"Copy column",icon:V[I.tableColumnCopy],onClick:()=>Za(n)},{id:I.tableColumnPasteBefore,label:"Paste column before",icon:V[I.tableColumnPasteBefore],disabled:!e,onClick:()=>Ar(n)},{id:I.tableColumnPasteAfter,label:"Paste column after",icon:V[I.tableColumnPasteAfter],disabled:!e,onClick:()=>Ar({...n,after:!0})}]}]},Ya="Row settings",hu=n=>n.every(e=>e.is(ge)),Sn=n=>{const{component:e}=n,t=e.is(q),s=e.is(ge);if(!(!t&&!s))return s?e:e.closestType(ge)},Pr=n=>{const{component:e,editor:t,after:s}=n,o=Sn(n);if(!o)return;const i=o.index()+(s?1:0),r=o.components().length,l=Array.from(Array(r).keys()).map(()=>({type:q})),a=o.parent();if(a){const c=a.append({type:ge,components:l},{at:i})[0];if(e.is(q)&&c){const d=e.index(),p=c.components().at(d);p&&t.select(p)}}},Xa=n=>{var e;(e=Sn(n))==null||e.remove(n.opts)},Qa=n=>{const e=Sn(n);e&&n.editor.em.set(Ji,[e])},Nr=n=>{var l;const{editor:e,after:t}=n,s=Sn(n);if(!s||!ec(n))return;const i=co(e)[0],r=s.index()+(t?1:0);i&&((l=s.parent())==null||l.append(i.clone(),{at:r}))},fu=n=>{Sn(n)&&(Qa(n),Xa({...n,opts:{temporary:!0}}))},ec=({editor:n})=>{const e=co(n);return e.length&&hu(e)},mu=n=>{const e=Sn(n);e&&(n.editor.select(e),Zi(n,{id:"tableRowSettings",header:{label:Ya}}))},tc=n=>{const e=ec(n);return[{id:I.tableRowItems,icon:V[I.tableRowProperties],label:"Row",items:[{id:I.tableRowInsertBefore,label:"Insert row before",icon:V[I.tableRowInsertBefore],onClick:()=>Pr(n)},{id:I.tableRowInsertAfter,label:"Insert row after",icon:V[I.tableRowInsertAfter],onClick:()=>Pr({...n,after:!0})},{id:I.tableRowDelete,label:"Delete row",icon:V[I.tableRowDelete],onClick:()=>Xa(n)},{id:I.tableRowProperties,label:Ya,icon:V[I.tableRowProperties],onClick:({event:s})=>mu({...n,event:s})},{id:I.tableRowCut,label:"Cut row",icon:V[I.tableRowCut],onClick:()=>fu(n)},{id:I.tableRowCopy,label:"Copy row",icon:V[I.tableRowCopy],onClick:()=>Qa(n)},{id:I.tableRowPasteBefore,label:"Paste row before",icon:V[I.tableRowPasteBefore],disabled:!e,onClick:()=>Nr(n)},{id:I.tableRowPasteAfter,label:"Paste row after",icon:V[I.tableRowPasteAfter],disabled:!e,onClick:()=>Nr({...n,after:!0})}]},...Ua(n)]},Yi=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),s=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:s}};function nc(n){const e=[];return n.components().forEach((t,s)=>{t.components().each((o,i)=>{const{rowspan:r,colspan:l}=Yi(o);if(e[s])for(;e[s][i];)i++;for(let a=s;a<s+r;a++){e[a]||(e[a]=[]);for(let c=i;c<i+l;c++)e[a][c]={real:a===s&&c===i,cell:o,rowspan:r,colspan:l}}})}),e}function en(n,e,t){var s;return(s=n[t])==null?void 0:s[e]}const ni=n=>n.closestType(ge);function gu(n,{x:e,y:t,rows:s,cols:o}){var l;let i=ni(n[t][e].cell),r;for(let a=1;a<=s;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=ni(c);if(d===i){for(let p=1;p<=o;p++){const u=c.index();d.append({type:q},{at:u+1})}break}}if(r===-1){const d=i.components().at(0).index();for(let p=1;p<=o;p++)i.append({type:q},{at:d})}}}function sc(n){for(let e=0;e<n.length;e++)for(let t=0;t<n[e].length;t++){const o=n[e][t].cell;if(o.em.selected.hasComponent(o)){const{rowspan:i,colspan:r}=Yi(o);if(r>1||i>1){o.addAttributes({colspan:1,rowspan:1});for(let l=0;l<r-1;l++){const a=o.index();ni(o).append({type:q},{at:a+1})}gu(n,{x:t,y:e,rows:i-1,cols:r})}}}}function yu(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const po=(n,e={})=>{var r;const t=nc(n),{em:s}=n;let o,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)||s.selected.hasComponent(c.cell)){const d={x:a,y:l};o||(o=d),i=d}}return{grid:t,startPos:o,endPos:i}};function bu(n,e={}){const t=po(n),{startPos:s,endPos:o}=t;let{grid:i}=t;const{em:r}=n;if(!s||!o)return;const l=s.x,a=s.y,c=o.x,d=o.y,p=en(i,l,a),u=en(i,c,d);if(p&&u){sc(i),i=nc(n);const h=[],f=en(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=en(i,g,m);if(!b)continue;const{cell:C}=b;C!==f&&h.push(C)}h.forEach(m=>{e.mergeContent&&f.append(m.components().models),m.remove()}),r.setSelected(f),yu(n)}}const oc="Cell settings",vu="Merge cells",Su="Split cell",xu=n=>n.closestType(ge),hn=n=>{var e;return(e=xu(n))==null?void 0:e.parent()},wu=n=>{const e=n.editor.getSelectedAll(),t=hn(e[0]),s=e[0];if(!t||!(s!=null&&s.is(q))||e.length>1)return!1;const{rowspan:o,colspan:i}=Yi(s);return!(i<2&&o<2)},Cu=n=>{const t=n.editor.getSelectedAll()[0],s=hn(t),{grid:o}=po(s);sc(o)},ic=n=>{const e=n.editor.getSelectedAll(),t=hn(e[0]);if(!t||e.length<2||e.some(l=>!l.is(q)||hn(l)!==t))return!1;const{grid:s,startPos:o,endPos:i}=po(t),{em:r}=t;if(!o||!i)return!1;for(let l=o.y;l<=i.y;l++)for(let a=o.x;a<=i.x;a++){const c=en(s,a,l);if(!c||!r.selected.hasComponent(c.cell))return!1}return!0},ku=n=>{const{editor:e}=n;if(!ic(n))return;const t=e.getSelectedAll(),s=hn(t[0]);bu(s,{mergeContent:!0})},Eu=n=>{Zi(n,{id:"tableCellSettings",header:{label:oc}})},Tu=n=>[{id:I.tableCellItems,icon:V[I.tableCellProperties],label:"Cell",items:[{id:I.tableCellProperties,label:oc,icon:V[I.tableCellProperties],onClick:({event:t})=>Eu({...n,event:t})},{id:I.tableCellMerge,label:vu,icon:V[I.tableCellMerge],onClick:()=>ku(n),disabled:!ic(n)},{id:I.tableCellSplit,label:Su,icon:V[I.tableCellSplit],onClick:()=>Cu(n),disabled:!wu(n)}]},...uu(n),...tc(n)],Mu=n=>{const e=n[0]&&hn(n[0]);if(!e)return;const{grid:t,startPos:s,endPos:o}=po(e,{selected:n});if(!s||!o)return;const i=[];for(let r=s.y;r<=o.y;r++)for(let l=s.x;l<=o.x;l++){const a=en(t,l,r);a&&i.push(a.cell)}i.length&&e.em.setSelected(i,{fromCell:!0})},Au=function(n,e={}){const t={block:{},...e},{Components:s}=n,o={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"]};s.addType(He,{block:t.block&&{label:"Table",media:V.table,category:"Extra",content:{type:He,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:au(ti,{rows:5}),contextMenu:({items:r,editor:l,component:a})=>[...Ua({editor:l,component:a,opts:t}),...r]}}}),s.addType(Ga,{model:{defaults:{icon:V.tableHead,...o}}}),s.addType(Wa,{model:{defaults:{icon:V.tableFoot,...o}}}),s.addType(ti,{model:{defaults:{icon:V.tableRowProperties,...o}}}),s.addType(ge,{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})=>[...tc({editor:l,component:a,opts:t}),...r]}}}),s.addType(q,{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})=>[...Tu({editor:l,component:a,opts:t}),...r]}}});const i=jn((r,l)=>{var p;const a=n.getSelectedAll(),c=!!((p=l==null?void 0:l.event)!=null&&p.shiftKey);if(a.length<2||!c||l.fromCell)return;const d=a.map(u=>u.is(q)?u:u.closestType(q)).filter(Boolean);d.length===a.length&&Mu(d)},0);n.on("component:select",i),_({editor:n,plan:iu,pluginName:ou,licenseKey:t.licenseKey,cleanup:()=>{n.off("component:select",i),n.Blocks.remove(He),ru.forEach(r=>s.removeType(r))}})},Pu=F(Au),Nu="listPagesComponent",Iu=H.startup,Ir="page://",St="list-pages",jt="list-pages-item",xt="list-pages-link",Ou=n=>n.components().reduce((e,t)=>{var r;const s=t.findFirstType(xt),o=(r=s==null?void 0:s.attributes.attributes)==null?void 0:r.href,i=o!=null&&o.startsWith(Ir)?o.replace(Ir,""):"";if(i&&s){const l=e[i];l?l.push(s):e[i]=[s]}return e},{}),Ns="data-type-role",Ru="page_root",Du=n=>e=>e.is(n),Lu=n=>(e,t)=>t.is(n),ko=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,Ns))===n},$u=function(n,e={}){const{Blocks:t,Components:s,Pages:o}=n,{licenseKey:i,block:r={}}=e,l="List Pages",a="List Pages Item",c="Link",d=`${Me}${St}`,p=`${Me}${xt}`,u='<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>';s.addType(St,{block:r&&{label:l,media:u,category:"Extra",select:!0,...e.block},isComponent:ko(St),model:{defaults:{tagName:"ul",name:l,[Ru]:"",classes:d,attributes:{[Ns]:St,role:"navigation"},droppable:Du(jt),styles:`
|
|
61
|
+
</svg>`,za="layout-icon-picker",Up="icons-layout-",Va="icons-list-layout",Ba="gs-iconify-picker",Ki="__iconify_collection",Kp="https://api.iconify.design",Cs=new Map;let fo;const Jp=({collectionId:n})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${n}@latest/icons.json`;async function Ha({collectionId:n,editor:e}){try{if(Cs.has(n))return Cs.get(n);const t=await fetch(Jp({collectionId:n}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const o=await t.json();return Cs.set(n,o),o}catch(t){console.error("Error fetching collection",t),e.runCommand(W.toastAdd,tu());return}}async function Zp({collectionIds:n,editor:e}){try{if(fo)return fo;const t=n?`?prefixes=${n.join(",")}`:"",o=await fetch(`${Kp}/collections${t}`);if(!o.ok)throw new Error(`Failed to fetch collections: ${o.statusText}`);return fo=await o.json(),fo}catch(t){console.error("Error fetching collections",t),e.runCommand(W.toastAdd,_a());return}}function Tr(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(n){var e;(e=n.getSelected())==null||e.trigger("active")}}}async function Yp({collectionIds:n,editor:e,component:t}){const o=await Zp({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(W.layoutToggle,{id:za,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[Qp({collectionsList:i,collectionId:r,editor:e,handleClick:s}),{id:Va,type:"column",grow:!0}]}});const l=await Ha({collectionId:r,editor:e});l&&(Fa({editor:e,collection:l}),ei({editor:e,collection:l,handleClick:s,collectionId:r}))}function Fa({editor:n,collection:e}){n.em.set(Ki,e)}function Xp(n){return n.em.get(Ki)}function ei(n){const{editor:e}=n;e.runCommand(W.layoutUpdate,{id:Up,layout:eu(n),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:Va}})}function Qp(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:`${Ba}__header`,children:[{type:"selectField",value:t,options:i,emptyState:"Select an icon collection",onChange:async({setState:r,value:l})=>{const a=await Ha({collectionId:l,editor:o});a&&(r({value:l}),Fa({editor:o,collection:a}),ei({editor:o,collection:a,handleClick:s,collectionId:l}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${Ki}`]:({setState:r})=>r({value:""})},onInput:({setState:r,value:l,editor:a})=>{const c=Xp(a);if(!c)return;const d=Object.fromEntries(Object.entries(c.icons).filter(([p])=>p.includes(l)));r({value:l}),ei({editor:a,collection:c,handleClick:s,collectionId:t,collectionFiltered:{...c,icons:d}})}}]}}function eu({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,c])=>({name:a,...c}),{});return{type:"column",className:`${Ba}__content`,style:{height:"100%"},children:{type:"virtualList",items:l,itemLayout:({item:a})=>({type:"custom",render:c=>{const{editor:d,addEl:p,removeEl:u}=c,h=document.createElementNS("http://www.w3.org/2000/svg","svg");h.setAttribute("xmlns","http://www.w3.org/2000/svg"),h.innerHTML=a.body;const f=a.width||s,m=a.height||o;h.setAttribute("viewBox",`0 0 ${f} ${m}`),h.style.cssText="width: 48px; height: 48px; cursor: pointer; border-radius: 4px; transition: padding 0.1s ease-in-out;";const g=[["click",()=>{const b=h.cloneNode(!0);b.removeAttribute("style");const C=b.outerHTML;t({icon:C,collectionId:r,iconId:a.name}),d==null||d.runCommand(W.layoutRemove,{id:za})}],["pointerover",()=>{h.style.border="2px solid currentColor",h.style.padding="4px"}],["pointerout",()=>{h.style.border="",h.style.padding=""}]];return g.forEach(([b,C])=>h.addEventListener(b,C)),p(h),()=>{g.forEach(([b,C])=>h.removeEventListener(b,C)),u(h)}}})}}}function _a(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:Ra.Error}}function tu(){return{..._a(),id:"toast-error-getCollection",content:"Error fetching collection"}}const nu=function(n,e={}){var h;const{Components:t,Blocks:o}=n,{collections:s,extendIconComponent:i=!0,licenseKey:r,block:l={}}=e,a="icon",c="iconify",d="Iconify",p="data-type-iconify",u={events:()=>({dblclick:"onActive"}),onActive(){Yp({collectionIds:s,editor:n,component:this.model})}};if(t.addType(c,{block:l&&{label:d,media:ws,content:{type:c},category:"Extra",activate:!0,...l},isComponent:f=>Po(f,p),model:{defaults:{name:d,icon:ws,droppable:!1,attributes:{[p]:!0},resizable:qp,components:ws,style:{width:"50px",height:"50px"},traits:[Tr()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(f=>f.set({layerable:!1,locked:!0}))}},view:u}),i){const f=(h=t.getType(a))==null?void 0:h.model,[m,g,...b]=f.getDefaults().traits;t.addType(a,{model:{defaults:{traits:[m,g,Tr(),...b]}},view:u})}G({editor:n,licenseKey:r,plan:jp,pluginName:Wp,cleanup:()=>{o.remove(c),t.removeType(c)}})},ou=_(nu);function jn(n,e,t){let o,s,i,r,l;const a=e===void 0?100:e;function c(){const p=Date.now()-r;p<a&&p>=0?o=setTimeout(c,a-p):(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 su="tableComponent",iu=H.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 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>'},He="table",Ga="thead",Wa="tfoot",ti="tbody",ge="row",q="cell",Ji="clipboardTable",ru=[He,Ga,Wa,ti,ge,q],ds=n=>n.em.get(Ji)||[],lu=n=>n.every(e=>e.is(q)),Zi=(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};_t(s.openSettings)?s.openSettings({...n,layoutProps:d}):t.runCommand(W.layoutToggle,d)},au=(n,{rows:e=1,cells:t=5,text:o}={})=>({type:n,components:Array.from(Array(e).keys()).map(s=>({type:ge,components:Array.from(Array(t).keys()).map(i=>({type:q,components:o?{type:"text",content:_t(o)?o({y:s,x:i}):o}:void 0}))}))}),ja="Table settings",qa=n=>{const{component:e}=n;return e.is(He)?e:e.closestType(He)},cu=n=>{var e;(e=qa(n))==null||e.remove(n.opts)},du=n=>{const e=qa(n);e&&(n.editor.select(e),Zi(n,{id:"tableSettings",header:{label:ja}}))},Ua=n=>[{id:O.table,icon:V[O.table],label:"Table",items:[{id:O.tableSettings,label:ja,icon:V[O.tableSettings],onClick:({event:t})=>du({...n,event:t})},{id:O.tableDelete,label:"Delete table",icon:V[O.tableDelete],onClick:()=>cu(n)}]}],Ka=({editor:n})=>{const e=ds(n);return e.length&&lu(e)},Mr=({component:n,editor:e,after:t})=>{if(!n.is(q))return;const o=n.closestType(He),s=n.closestType(ge),i=n.index()+(t?1:0);o==null||o.findType(ge).forEach(l=>l.append({type:q},{at:i}));const r=s==null?void 0:s.components().at(i);r&&e.select(r)},Ja=({component:n,opts:e})=>{if(!n.is(q))return;const t=n.closestType(He),o=n.index();t==null||t.findType(ge).forEach(s=>{var i;return(i=s.components().at(o))==null?void 0:i.remove(e)})},Za=({component:n,editor:e})=>{if(!n.is(q))return;const t=n.closestType(He),o=n.index(),s=(t==null?void 0:t.findType(ge).map(i=>i.components().at(o)))||[];s.length&&e.em.set(Ji,s)},Ar=n=>{const{component:e,editor:t,after:o}=n;if(!e.is(q)||!Ka(n))return;const s=ds(t),i=e.closestType(He),r=e.index()+(o?1:0);i==null||i.findType(ge).forEach((l,a)=>{const c=s[a],d=(c==null?void 0:c.clone())||{type:q};l.append(d,{at:r})})},pu=n=>{const{component:e}=n;e.is(q)&&(Za(n),Ja({...n,opts:{temporary:!0}}))},uu=n=>{const e=Ka(n);return[{id:O.tableColumnItems,icon:V[O.tableColumn],label:"Column",items:[{id:O.tableColumnInsertBefore,label:"Insert column before",icon:V[O.tableColumnInsertBefore],onClick:()=>Mr(n)},{id:O.tableColumnInsertAfter,label:"Insert column after",icon:V[O.tableColumnInsertAfter],onClick:()=>Mr({...n,after:!0})},{id:O.tableColumnDelete,label:"Delete column",icon:V[O.tableColumnDelete],onClick:()=>Ja(n)},{id:O.tableColumnCut,label:"Cut column",icon:V[O.tableColumnCut],onClick:()=>pu(n)},{id:O.tableColumnCopy,label:"Copy column",icon:V[O.tableColumnCopy],onClick:()=>Za(n)},{id:O.tableColumnPasteBefore,label:"Paste column before",icon:V[O.tableColumnPasteBefore],disabled:!e,onClick:()=>Ar(n)},{id:O.tableColumnPasteAfter,label:"Paste column after",icon:V[O.tableColumnPasteAfter],disabled:!e,onClick:()=>Ar({...n,after:!0})}]}]},Ya="Row settings",hu=n=>n.every(e=>e.is(ge)),Sn=n=>{const{component:e}=n,t=e.is(q),o=e.is(ge);if(!(!t&&!o))return o?e:e.closestType(ge)},Pr=n=>{const{component:e,editor:t,after:o}=n,s=Sn(n);if(!s)return;const i=s.index()+(o?1:0),r=s.components().length,l=Array.from(Array(r).keys()).map(()=>({type:q})),a=s.parent();if(a){const c=a.append({type:ge,components:l},{at:i})[0];if(e.is(q)&&c){const d=e.index(),p=c.components().at(d);p&&t.select(p)}}},Xa=n=>{var e;(e=Sn(n))==null||e.remove(n.opts)},Qa=n=>{const e=Sn(n);e&&n.editor.em.set(Ji,[e])},Nr=n=>{var l;const{editor:e,after:t}=n,o=Sn(n);if(!o||!ec(n))return;const i=ds(e)[0],r=o.index()+(t?1:0);i&&((l=o.parent())==null||l.append(i.clone(),{at:r}))},fu=n=>{Sn(n)&&(Qa(n),Xa({...n,opts:{temporary:!0}}))},ec=({editor:n})=>{const e=ds(n);return e.length&&hu(e)},mu=n=>{const e=Sn(n);e&&(n.editor.select(e),Zi(n,{id:"tableRowSettings",header:{label:Ya}}))},tc=n=>{const e=ec(n);return[{id:O.tableRowItems,icon:V[O.tableRowProperties],label:"Row",items:[{id:O.tableRowInsertBefore,label:"Insert row before",icon:V[O.tableRowInsertBefore],onClick:()=>Pr(n)},{id:O.tableRowInsertAfter,label:"Insert row after",icon:V[O.tableRowInsertAfter],onClick:()=>Pr({...n,after:!0})},{id:O.tableRowDelete,label:"Delete row",icon:V[O.tableRowDelete],onClick:()=>Xa(n)},{id:O.tableRowProperties,label:Ya,icon:V[O.tableRowProperties],onClick:({event:o})=>mu({...n,event:o})},{id:O.tableRowCut,label:"Cut row",icon:V[O.tableRowCut],onClick:()=>fu(n)},{id:O.tableRowCopy,label:"Copy row",icon:V[O.tableRowCopy],onClick:()=>Qa(n)},{id:O.tableRowPasteBefore,label:"Paste row before",icon:V[O.tableRowPasteBefore],disabled:!e,onClick:()=>Nr(n)},{id:O.tableRowPasteAfter,label:"Paste row after",icon:V[O.tableRowPasteAfter],disabled:!e,onClick:()=>Nr({...n,after:!0})}]},...Ua(n)]},Yi=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),o=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:o}};function nc(n){const e=[];return n.components().forEach((t,o)=>{t.components().each((s,i)=>{const{rowspan:r,colspan:l}=Yi(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 en(n,e,t){var o;return(o=n[t])==null?void 0:o[e]}const ni=n=>n.closestType(ge);function gu(n,{x:e,y:t,rows:o,cols:s}){var l;let i=ni(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=ni(c);if(d===i){for(let p=1;p<=s;p++){const u=c.index();d.append({type:q},{at:u+1})}break}}if(r===-1){const d=i.components().at(0).index();for(let p=1;p<=s;p++)i.append({type:q},{at:d})}}}function oc(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}=Yi(s);if(r>1||i>1){s.addAttributes({colspan:1,rowspan:1});for(let l=0;l<r-1;l++){const a=s.index();ni(s).append({type:q},{at:a+1})}gu(n,{x:t,y:e,rows:i-1,cols:r})}}}}function yu(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const ps=(n,e={})=>{var r;const t=nc(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 bu(n,e={}){const t=ps(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,p=en(i,l,a),u=en(i,c,d);if(p&&u){oc(i),i=nc(n);const h=[],f=en(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=en(i,g,m);if(!b)continue;const{cell:C}=b;C!==f&&h.push(C)}h.forEach(m=>{e.mergeContent&&f.append(m.components().models),m.remove()}),r.setSelected(f),yu(n)}}const sc="Cell settings",vu="Merge cells",Su="Split cell",xu=n=>n.closestType(ge),hn=n=>{var e;return(e=xu(n))==null?void 0:e.parent()},wu=n=>{const e=n.editor.getSelectedAll(),t=hn(e[0]),o=e[0];if(!t||!(o!=null&&o.is(q))||e.length>1)return!1;const{rowspan:s,colspan:i}=Yi(o);return!(i<2&&s<2)},Cu=n=>{const t=n.editor.getSelectedAll()[0],o=hn(t),{grid:s}=ps(o);oc(s)},ic=n=>{const e=n.editor.getSelectedAll(),t=hn(e[0]);if(!t||e.length<2||e.some(l=>!l.is(q)||hn(l)!==t))return!1;const{grid:o,startPos:s,endPos:i}=ps(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=en(o,a,l);if(!c||!r.selected.hasComponent(c.cell))return!1}return!0},ku=n=>{const{editor:e}=n;if(!ic(n))return;const t=e.getSelectedAll(),o=hn(t[0]);bu(o,{mergeContent:!0})},Eu=n=>{Zi(n,{id:"tableCellSettings",header:{label:sc}})},Tu=n=>[{id:O.tableCellItems,icon:V[O.tableCellProperties],label:"Cell",items:[{id:O.tableCellProperties,label:sc,icon:V[O.tableCellProperties],onClick:({event:t})=>Eu({...n,event:t})},{id:O.tableCellMerge,label:vu,icon:V[O.tableCellMerge],onClick:()=>ku(n),disabled:!ic(n)},{id:O.tableCellSplit,label:Su,icon:V[O.tableCellSplit],onClick:()=>Cu(n),disabled:!wu(n)}]},...uu(n),...tc(n)],Mu=n=>{const e=n[0]&&hn(n[0]);if(!e)return;const{grid:t,startPos:o,endPos:s}=ps(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=en(t,l,r);a&&i.push(a.cell)}i.length&&e.em.setSelected(i,{fromCell:!0})},Au=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(He,{block:t.block&&{label:"Table",media:V.table,category:"Extra",content:{type:He,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:au(ti,{rows:5}),contextMenu:({items:r,editor:l,component:a})=>[...Ua({editor:l,component:a,opts:t}),...r]}}}),o.addType(Ga,{model:{defaults:{icon:V.tableHead,...s}}}),o.addType(Wa,{model:{defaults:{icon:V.tableFoot,...s}}}),o.addType(ti,{model:{defaults:{icon:V.tableRowProperties,...s}}}),o.addType(ge,{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})=>[...tc({editor:l,component:a,opts:t}),...r]}}}),o.addType(q,{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})=>[...Tu({editor:l,component:a,opts:t}),...r]}}});const i=jn((r,l)=>{var p;const a=n.getSelectedAll(),c=!!((p=l==null?void 0:l.event)!=null&&p.shiftKey);if(a.length<2||!c||l.fromCell)return;const d=a.map(u=>u.is(q)?u:u.closestType(q)).filter(Boolean);d.length===a.length&&Mu(d)},0);n.on("component:select",i),G({editor:n,plan:iu,pluginName:su,licenseKey:t.licenseKey,cleanup:()=>{n.off("component:select",i),n.Blocks.remove(He),ru.forEach(r=>o.removeType(r))}})},Pu=_(Au),Nu="listPagesComponent",Iu=H.startup,Ir="page://",St="list-pages",jt="list-pages-item",xt="list-pages-link",Ou=n=>n.components().reduce((e,t)=>{var r;const o=t.findFirstType(xt),s=(r=o==null?void 0:o.attributes.attributes)==null?void 0:r.href,i=s!=null&&s.startsWith(Ir)?s.replace(Ir,""):"";if(i&&o){const l=e[i];l?l.push(o):e[i]=[o]}return e},{}),No="data-type-role",Ru="page_root",Du=n=>e=>e.is(n),Lu=n=>(e,t)=>t.is(n),ks=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,No))===n},$u=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=`${Me}${St}`,p=`${Me}${xt}`,u='<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(St,{block:r&&{label:l,media:u,category:"Extra",select:!0,...e.block},isComponent:ks(St),model:{defaults:{tagName:"ul",name:l,[Ru]:"",classes:d,attributes:{[No]:St,role:"navigation"},droppable:Du(jt),styles:`
|
|
62
62
|
.${d} {
|
|
63
63
|
list-style: none;
|
|
64
64
|
margin: 0;
|
|
65
65
|
padding: 0;
|
|
66
66
|
}
|
|
67
|
-
`},init(){this.syncPageItems=jn(this.syncPageItems.bind(this),0),this.listenTo(this.em,
|
|
67
|
+
`},init(){this.syncPageItems=jn(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=Ou(this);f.forEach((b,C)=>{const y=b.id,v=b.getName(),w=g[y];w?w==null||w.forEach(S=>{S.getInnerHTML()!==v&&S.components(v)}):m.add({type:jt,components:[{type:xt,attributes:{href:`page://${y}`},components:{type:"textnode",content:v}}]},{at:C})})}}}),o.addType(jt,{isComponent:ks(jt),model:{defaults:{name:a,tagName:"li",icon:h,attributes:{[No]:jt},components:{type:xt},draggable:Lu(St)}}}),o.addType(xt,{extend:"link",isComponent:ks(xt),model:{defaults:{removable:!1,copyable:!1,delegate:{move:f=>f.closestType(jt)},name:c,classes:p,attributes:{[No]:xt},components:{type:"textnode",content:"Item"},styles:`
|
|
68
68
|
.${p} {
|
|
69
69
|
text-decoration: none;
|
|
70
70
|
}
|
|
71
|
-
`}}}),
|
|
71
|
+
`}}}),G({editor:n,licenseKey:i,plan:Iu,pluginName:Nu,cleanup:()=>{t.remove(St),o.removeType(St)}})},zu=_($u),Vu="fsLightboxComponent",Bu=H.startup,mo="data-fslightbox",go="data-type",Hu="fslightbox-open",qt="fslightbox",Ut={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>'},Fu=function(n,e={}){const{Blocks:t,Components:o}=n,s="Lightbox",i=`${Me}${qt}`,r={toolbarIconOpen:Ut.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}=r,d=function(C){const y=this,v="data-fslightbox",w=window,S=()=>{var M;const x=w.refreshFsLightbox;x==null||x();const k=y.getAttribute(v);if((M=w.fsLightboxInstances)==null||M[k],!w._isEditor)return;Array.from(document.querySelectorAll(`[${v}]`)).forEach(P=>{const N=P.onclick;P.onclick=function(I){I.preventDefault();const R=P;!R.__skipLb&&(N==null||N(I)),R.__skipLb=!0}})};if(w.refreshFsLightbox)S();else{const x=document.createElement("script");x.src=C.cdnScript,x.onload=S,document.head.appendChild(x)}},p=C=>({id:`${qt}-open-lb`,label:a,command:()=>{const y=C.getView();y==null||y.toggleLightbox()}}),u="source-type",h={type:"radio",name:u,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:Ut.image},{id:"video",label:"Video",icon:Ut.video},{id:"el",label:"Custom Element",icon:Ut.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"},b={image:[f],video:[m],el:[g]};o.addType(qt,{block:l&&{label:s,media:Ut.imageLightbox,category:"Extra",select:!0,...r.block},isComponent:C=>{var y;return(y=C.hasAttribute)==null?void 0:y.call(C,mo)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:s,icon:Ut.imageLightbox,classes:i,draggable:(C,y)=>!y.is(qt),attributes:{[mo]:"lightbox",[go]:"image",href:c},components:{type:"image",src:c},script:d,cdnScript:r.cdnScript,"script-props":["attributes","cdnScript"],[u]:"image",traits:[h,{name:mo,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(C,y){var w;const v=(w=y.target)==null?void 0:w.getView();v==null||v.toggleLightbox()}}],styles:`
|
|
72
72
|
.${i} {
|
|
73
73
|
display: inline-block;
|
|
74
74
|
padding: 10px;
|
|
75
75
|
}
|
|
76
|
-
`},init(){const C=[u].map(y=>`change:${y}`).join(" ");this.on(C,this.updateTraits),this.on(`change:${u}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(C,y,v){if(v.adjust)return;const S=this.get(u)==="video"?"video":"image";this.addAttributes({[gs]:S,href:""})},adjustSourceType(){const C=this.get(u),y=this.getAttributes().href||"",v={adjust:!0};if(C==="video"){const w=y.includes("youtube.com")?"youtube":"video";this.addAttributes({[gs]:w},v)}else C!=="el"&&y.startsWith("#")?this.set(u,"el",v):C==="image"&&this.addAttributes({[gs]:"image"},v)},updateTraits(C={}){const{changed:y}=this,{init:v}=C;if(y[h.name]||v){this.removeTrait([f.name,m.name,g.name]);const w=this.get(u)||"image",S=this.getTraitIndex(u)+1;this.addTrait(b[w],{at:S})}},initToolbar(){if(!a)return;const{toolbar:C}=this,y=p(this);!C.find(w=>w.id===y.id)&&(C==null||C.unshift(y))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var P;const{em:C,el:y,model:v}=this,{Canvas:w}=C,S=v.getAttributes()[ms],{defaultView:x,documentElement:k}=y.ownerDocument,E=(P=x.fsLightboxInstances)==null?void 0:P[S];if(k.classList.contains(Hu))E.close();else{y.__skipLb=!1;let N;E.props.onOpen=()=>{N=w.getSpots(),setTimeout(()=>w.removeSpots())},E.props.onClose=()=>{N.forEach(O=>w.addSpot(O.attributes))},y.click()}}}}),_({editor:n,plan:Bu,licenseKey:r.licenseKey,pluginName:Vu,cleanup:()=>{t.remove(qt),s.removeType(qt)}})},_u=F(Fu),Gu="lightGalleryComponent",Wu=H.startup;var Yt=(n=>(n.image="image",n.video="video",n.external="external",n))(Yt||{});const Ct="lightGallery",Or=`${Ct}-item`,Is="data-lightgallery",Rr=`${Is}-item`,Hs="toggle",Tt={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>'},Eo={propKeys:[],props:{},traits:[]},Cn=(n,e={})=>{var o;const t={},s=[];for(const i in n){const{value:r,...l}=n[i];s.push({id:i,name:i,changeProp:!0,category:e.category,...l}),t[i]=r;const{subTraits:a={}}=l;for(const c in l.subTraits)(o=a[c])==null||o.forEach(d=>{const p=d.id||d.name;t[p]=d.value})}return{propKeys:Object.keys(t),props:t,traits:s}},si=(n,e)=>{const t=n.getTrait(e),s=t.get("category"),o=t.get("subTraits")||{},r=(Object.values(o).flat()||[]).map(c=>c.id||c.name);n.removeTrait(r);const l=o[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:s,...c})),{at:a})},To=(n,e)=>{e.forEach(t=>{const s=n.getTrait(t);if(!s||!s.get("subTraits"))return;const o=s.changeProp?`change:${t}`:`change:attributes:${t}`;n.on(o,()=>si(n,t)),si(n,t)})},ju=(n,e,t)=>{const o=n.getTrait(e).get("subTraits")||{},r=(Object.values(o).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)},qu={[Hs]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var t,s;return(s=(t=e.target)==null?void 0:t.getView())==null?void 0:s.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}},Uu={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"}]}}},Ku={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}]}}},Ju={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}]}}},nt="sourceType",ys="data-iframe",oi={name:"href",type:"file",label:"Image Source"},Fs={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},ii={name:"data-poster",label:"Video Poster",type:"file"},Dr={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},rc={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},Zu={[Hs]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var o,i;const t=e.target,s=(o=t==null?void 0:t.closestType(Ct))==null?void 0:o.getView();if(s&&t){const r=((i=s.getLightGallery())==null?void 0:i.items)||[],l=Array.from(r).indexOf(t.getEl());l>=0&&s.toggleGallery(l)}}},[nt]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[oi],video:[Fs,ii],external:[Dr]},options:[{id:"image",label:oi.label||"",icon:Tt.image},{id:"video",label:Fs.label||"",icon:Tt.video},{id:"external",label:Dr.label||"",icon:Tt.external}]},subHtml:rc},Lr="lgThumbnail",Yu="lgVideo",$r="lgAutoplay",zr="lgZoom",Kt="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Xu=function(n,e={}){const{Blocks:t,Components:s}=n,o="LightGallery",i="LightGallery Item",r={toolbarIconOpen:Tt.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[Lr,Yu,$r,zr],cdnScript:[`${Kt}/lightgallery.min.js`,`${Kt}/plugins/thumbnail/lg-thumbnail.min.js`,`${Kt}/plugins/video/lg-video.min.js`,`${Kt}/plugins/autoplay/lg-autoplay.min.js`,`${Kt}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${Kt}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=r,d=function(y){const v=this,w=window,{plugins:S,cdnScript:x,cdnStyle:k,inline:E,lgLicenseKey:M,...P}=y||{},N=R=>isNaN(R)?void 0:parseInt(R,10),O=()=>{var ie;const R={...P,licenseKey:M,speed:N(P.speed),startAnimationDuration:N(P.startAnimationDuration),thumbMargin:N(P.thumbMargin),thumbWidth:N(P.thumbWidth),slideShowInterval:N(P.slideShowInterval),scale:N(P.scale),enableZoomAfter:N(P.enableZoomAfter),plugins:(S||[]).map(re=>w[re])};E&&(R.container=v,R.closable=!1);const G=(ie=w.lightGallery)==null?void 0:ie.call(w,v,R);E&&G.openGallery()};if(w.lightGallery)O();else{const{head:R}=document,G=Array.isArray(x)?[...x]:[x],ie=Array.isArray(k)?[...k]:[k],re=ye=>{if(ye.length){const xe=document.createElement("link");xe.href=ye.shift(),xe.rel="stylesheet",R.appendChild(xe),re(ye)}},je=ye=>{if(ye.length){const xe=document.createElement("script");xe.src=ye.shift(),xe.onerror=xe.onload=je.bind(null,ye),R.appendChild(xe)}else O()};re(ie),je(G)}},p=y=>{const v=y.getTrait(Hs);if(!a||!v)return;const{toolbar:w}=y,S={id:Hs,label:a,command:()=>setTimeout(()=>v.runCommand(),100)};!w.find(k=>k.id===S.id)&&(w==null||w.unshift(S))};let u=[];const h=r.plugins||[],f=Cn(qu),m=h.includes(Lr)?Cn(Uu):Eo,g=h.includes($r)?Cn(Ku):Eo,b=h.includes(zr)?Cn(Ju):Eo;s.addType(Ct,{block:l&&{label:o,media:Tt.gallery,category:"Extra",select:!0,...r.block},isComponent:y=>Ps(y,Is),extendFn:["init","initToolbar"],model:{defaults:{name:o,icon:Tt.gallery,draggable:(y,v)=>!v.is(Ct),attributes:{[Is]:!0},components:{type:Or},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(){To(this,["thumbnail"]),To(this,["autoplay"]),To(this,["zoom"])},initToolbar(){p(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,s.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,w=this.getLightGallery();u=v.getSpots(),setTimeout(()=>v.removeSpots()),w.__lgOpened=!0},onLgClose(){const y=this.getLightGallery();u.forEach(v=>this.em.Canvas.addSpot(v.attributes)),u=[],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 C=Cn(Zu);s.addType(Or,{isComponent:y=>Ps(y,Rr)||y.tagName==="A"&&Ps(y.parentElement,Is),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:i,icon:Tt.galleryItem,attributes:{[Rr]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...C.props,traits:[...C.traits]},init(){const y=[nt].map(v=>`change:${v}`).join(" ");this.initSourceType(),this.on(y,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),ju(this,nt,this.triggerGalleryUpdate)},initToolbar(){p(this)},initScriptUpdate(){const y=[rc.name].map(v=>`change:attributes:${v}`).join(" ");this.on(y,this.triggerGalleryUpdate)},triggerGalleryUpdate(...y){var v;(v=this.closestType(Ct))==null||v.__scriptPropsChange(...y)},updateTraits(y={}){const{changed:v}=this,{init:w}=y;if(v[nt]||w){si(this,nt);const S=this.getTrait(nt).getValue();if(S===Yt.image){this.removeAttributes([Fs.name,ii.name,ys]);const x=this.getTrait(oi.name);x.setValue(x.getValue()||c)}else S===Yt.video?this.removeAttributes([ys]):S===Yt.external&&this.addAttributes({[ys]:!0})}},initSourceType(){const y=this.getAttributes({noClass:!0,noStyle:!0});y[ys]?this.set(nt,Yt.external):(y[Fs.name]||y[ii.name])&&this.set(nt,Yt.video)}}}),_({editor:n,plan:Wu,licenseKey:r.licenseKey,pluginName:Gu,cleanup:()=>{t.remove(Ct),s.removeType(Ct)}})},Qu=F(Xu),Oe="swiper",qn=`${Oe}-slide`,on=`${Oe}-wrapper`,rn=`${Oe}-nav-prev`,_s=`${Oe}-nav-next`,ln=`${Oe}-pagination`,Dn=`${Oe}-scrollbar`,le={slider:`<svg viewBox="0 0 24 24">
|
|
76
|
+
`},init(){const C=[u].map(y=>`change:${y}`).join(" ");this.on(C,this.updateTraits),this.on(`change:${u}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(C,y,v){if(v.adjust)return;const S=this.get(u)==="video"?"video":"image";this.addAttributes({[go]:S,href:""})},adjustSourceType(){const C=this.get(u),y=this.getAttributes().href||"",v={adjust:!0};if(C==="video"){const w=y.includes("youtube.com")?"youtube":"video";this.addAttributes({[go]:w},v)}else C!=="el"&&y.startsWith("#")?this.set(u,"el",v):C==="image"&&this.addAttributes({[go]:"image"},v)},updateTraits(C={}){const{changed:y}=this,{init:v}=C;if(y[h.name]||v){this.removeTrait([f.name,m.name,g.name]);const w=this.get(u)||"image",S=this.getTraitIndex(u)+1;this.addTrait(b[w],{at:S})}},initToolbar(){if(!a)return;const{toolbar:C}=this,y=p(this);!C.find(w=>w.id===y.id)&&(C==null||C.unshift(y))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var P;const{em:C,el:y,model:v}=this,{Canvas:w}=C,S=v.getAttributes()[mo],{defaultView:x,documentElement:k}=y.ownerDocument,E=(P=x.fsLightboxInstances)==null?void 0:P[S];if(k.classList.contains(Hu))E.close();else{y.__skipLb=!1;let N;E.props.onOpen=()=>{N=w.getSpots(),setTimeout(()=>w.removeSpots())},E.props.onClose=()=>{N.forEach(I=>w.addSpot(I.attributes))},y.click()}}}}),G({editor:n,plan:Bu,licenseKey:r.licenseKey,pluginName:Vu,cleanup:()=>{t.remove(qt),o.removeType(qt)}})},_u=_(Fu),Gu="lightGalleryComponent",Wu=H.startup;var Yt=(n=>(n.image="image",n.video="video",n.external="external",n))(Yt||{});const Ct="lightGallery",Or=`${Ct}-item`,Io="data-lightgallery",Rr=`${Io}-item`,Ho="toggle",Tt={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>'},Es={propKeys:[],props:{},traits:[]},Cn=(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 p=d.id||d.name;t[p]=d.value})}return{propKeys:Object.keys(t),props:t,traits:o}},oi=(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})},Ts=(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,()=>oi(n,t)),oi(n,t)})},ju=(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)},qu={[Ho]:{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}},Uu={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"}]}}},Ku={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}]}}},Ju={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}]}}},nt="sourceType",yo="data-iframe",si={name:"href",type:"file",label:"Image Source"},Fo={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},ii={name:"data-poster",label:"Video Poster",type:"file"},Dr={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},rc={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},Zu={[Ho]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var s,i;const t=e.target,o=(s=t==null?void 0:t.closestType(Ct))==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)}}},[nt]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[si],video:[Fo,ii],external:[Dr]},options:[{id:"image",label:si.label||"",icon:Tt.image},{id:"video",label:Fo.label||"",icon:Tt.video},{id:"external",label:Dr.label||"",icon:Tt.external}]},subHtml:rc},Lr="lgThumbnail",Yu="lgVideo",$r="lgAutoplay",zr="lgZoom",Kt="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Xu=function(n,e={}){const{Blocks:t,Components:o}=n,s="LightGallery",i="LightGallery Item",r={toolbarIconOpen:Tt.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[Lr,Yu,$r,zr],cdnScript:[`${Kt}/lightgallery.min.js`,`${Kt}/plugins/thumbnail/lg-thumbnail.min.js`,`${Kt}/plugins/video/lg-video.min.js`,`${Kt}/plugins/autoplay/lg-autoplay.min.js`,`${Kt}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${Kt}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=r,d=function(y){const v=this,w=window,{plugins:S,cdnScript:x,cdnStyle:k,inline:E,lgLicenseKey:M,...P}=y||{},N=R=>isNaN(R)?void 0:parseInt(R,10),I=()=>{var ie;const R={...P,licenseKey:M,speed:N(P.speed),startAnimationDuration:N(P.startAnimationDuration),thumbMargin:N(P.thumbMargin),thumbWidth:N(P.thumbWidth),slideShowInterval:N(P.slideShowInterval),scale:N(P.scale),enableZoomAfter:N(P.enableZoomAfter),plugins:(S||[]).map(re=>w[re])};E&&(R.container=v,R.closable=!1);const F=(ie=w.lightGallery)==null?void 0:ie.call(w,v,R);E&&F.openGallery()};if(w.lightGallery)I();else{const{head:R}=document,F=Array.isArray(x)?[...x]:[x],ie=Array.isArray(k)?[...k]:[k],re=ye=>{if(ye.length){const xe=document.createElement("link");xe.href=ye.shift(),xe.rel="stylesheet",R.appendChild(xe),re(ye)}},je=ye=>{if(ye.length){const xe=document.createElement("script");xe.src=ye.shift(),xe.onerror=xe.onload=je.bind(null,ye),R.appendChild(xe)}else I()};re(ie),je(F)}},p=y=>{const v=y.getTrait(Ho);if(!a||!v)return;const{toolbar:w}=y,S={id:Ho,label:a,command:()=>setTimeout(()=>v.runCommand(),100)};!w.find(k=>k.id===S.id)&&(w==null||w.unshift(S))};let u=[];const h=r.plugins||[],f=Cn(qu),m=h.includes(Lr)?Cn(Uu):Es,g=h.includes($r)?Cn(Ku):Es,b=h.includes(zr)?Cn(Ju):Es;o.addType(Ct,{block:l&&{label:s,media:Tt.gallery,category:"Extra",select:!0,...r.block},isComponent:y=>Po(y,Io),extendFn:["init","initToolbar"],model:{defaults:{name:s,icon:Tt.gallery,draggable:(y,v)=>!v.is(Ct),attributes:{[Io]:!0},components:{type:Or},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(){Ts(this,["thumbnail"]),Ts(this,["autoplay"]),Ts(this,["zoom"])},initToolbar(){p(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,w=this.getLightGallery();u=v.getSpots(),setTimeout(()=>v.removeSpots()),w.__lgOpened=!0},onLgClose(){const y=this.getLightGallery();u.forEach(v=>this.em.Canvas.addSpot(v.attributes)),u=[],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 C=Cn(Zu);o.addType(Or,{isComponent:y=>Po(y,Rr)||y.tagName==="A"&&Po(y.parentElement,Io),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:i,icon:Tt.galleryItem,attributes:{[Rr]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...C.props,traits:[...C.traits]},init(){const y=[nt].map(v=>`change:${v}`).join(" ");this.initSourceType(),this.on(y,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),ju(this,nt,this.triggerGalleryUpdate)},initToolbar(){p(this)},initScriptUpdate(){const y=[rc.name].map(v=>`change:attributes:${v}`).join(" ");this.on(y,this.triggerGalleryUpdate)},triggerGalleryUpdate(...y){var v;(v=this.closestType(Ct))==null||v.__scriptPropsChange(...y)},updateTraits(y={}){const{changed:v}=this,{init:w}=y;if(v[nt]||w){oi(this,nt);const S=this.getTrait(nt).getValue();if(S===Yt.image){this.removeAttributes([Fo.name,ii.name,yo]);const x=this.getTrait(si.name);x.setValue(x.getValue()||c)}else S===Yt.video?this.removeAttributes([yo]):S===Yt.external&&this.addAttributes({[yo]:!0})}},initSourceType(){const y=this.getAttributes({noClass:!0,noStyle:!0});y[yo]?this.set(nt,Yt.external):(y[Fo.name]||y[ii.name])&&this.set(nt,Yt.video)}}}),G({editor:n,plan:Wu,licenseKey:r.licenseKey,pluginName:Gu,cleanup:()=>{t.remove(Ct),o.removeType(Ct)}})},Qu=_(Xu),Oe="swiper",qn=`${Oe}-slide`,sn=`${Oe}-wrapper`,rn=`${Oe}-nav-prev`,_o=`${Oe}-nav-next`,ln=`${Oe}-pagination`,Dn=`${Oe}-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,28 +96,28 @@
|
|
|
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>`},Vr={id:"swiper-responsive",label:"Responsive",icon:le.responsive},Br={id:"swiper-extra",label:"Extra",icon:le.extra},eh={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 s;const t=(s=n.getView())==null?void 0:s.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(rn),setValue:({component:n,value:e})=>{var t,s;e?n.append([{type:rn},{type:_s}]):((t=n.findFirstType(rn))==null||t.remove(),(s=n.findFirstType(_s))==null||s.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:"checkbox",name:"autoplayEditor",label:"Autoplay in editor",tip:"Allow autoplay to run while editing in the canvas. Note: this may make selecting and editing slides difficult as they will automatically change.",changeProp:!0,value:!1},{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(ln)?n.get("pagination")||"bullets":"none",setValue:({component:n,value:e})=>{const t=n.findFirstType(ln);t==null||t.remove(),e!=="none"&&n.append({type:ln}),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(Dn),setValue:({component:n,value:e})=>{const t=n.findFirstType(Dn);t==null||t.remove(),e&&n.append({type:Dn}),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:Vr,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:Vr,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:Br,type:"checkbox",label:"Allow touch move",tip:"Allow touch interactions",value:!0},grabCursor:{category:Br,type:"checkbox",label:"Grab cursor",tip:'If enabled, the user will see the "grab" cursor when hover the slider',value:!1}},Hr="Slider",ri="swiper",xn=`${ri}-`,th=(n,e)=>{const{Components:t,Blocks:s,Commands:o}=n,{block:i}=e,r=Vp(eh),l="core:preview",a=o.events,c=function(u){const h=this,f=window,m=h.__onLoad,g=h.__activeSlide,b=h.__inPreview,C=f._isEditor&&!b?u.autoplayEditor:!0,{cdnScript:y,cdnStyle:v,slidesPerView:w}=u||{},S=k=>isNaN(k)?void 0:parseFloat(k),x=()=>{const k=h.parentElement;k&&(k.style.minWidth="0");const E={loop:u.loop,speed:u.speed,initialSlide:u.initialSlide,direction:u.vertical?"vertical":"horizontal",effect:u.effect,freeMode:u.freeMode,parallax:u.parallax,autoHeight:u.autoHeight,allowTouchMove:u.allowTouchMove,grabCursor:u.grabCursor,simulateTouch:!0,breakpoints:{},slidesPerView:isNaN(w)?w:S(w),slidesPerGroup:S(u.slidesPerGroup),spaceBetween:S(u.spaceBetween),slidesOffsetBefore:S(u.slidesOffsetBefore),slidesOffsetAfter:S(u.slidesOffsetAfter),centeredSlides:u.centeredSlides,fadeEffect:{crossFade:u.crossFade},cubeEffect:{shadow:u.cubeEffectShadow,slideShadows:u.cubeEffectSlideShadows,shadowOffset:S(u.cubeEffectShadowOffset),shadowScale:S(u.cubeEffectShadowScale)},coverflowEffect:{depth:S(u.coverflowEffectDepth),modifier:S(u.coverflowEffectModifier),rotate:S(u.coverflowEffectRotate),scale:S(u.coverflowEffectScale),stretch:S(u.coverflowEffectStretch),slideShadows:u.coverflowEffectSlideShadows},flipEffect:{limitRotation:u.flipEffectLimitRotation,slideShadows:u.flipEffectSlideShadows},cardsEffect:{perSlideOffset:S(u.cardsEffectPerSlideOffset),perSlideRotate:S(u.cardsEffectPerSlideRotate),rotate:u.cardsEffectRotate,slideShadows:u.cardsEffectSlideShadows},navigation:{nextEl:h.querySelector(".swiper-button-next"),prevEl:h.querySelector(".swiper-button-prev")},pagination:{type:u.pagination||"bullets",dynamicBullets:u.dynamicBullets,clickable:u.clickableBullets,progressbarOpposite:u.progressbarOpposite,el:h.querySelector(".swiper-pagination")},scrollbar:{el:h.querySelector(".swiper-scrollbar"),draggable:u.scrollbarDraggable,hide:u.scrollbarHide},autoplay:u.autoplay&&C&&{delay:u.autoplayDelay,disableOnInteraction:u.autoplayDisableOnInteraction,pauseOnMouseEnter:u.autoplayPauseOnMouseEnter,reverseDirection:u.autoplayReverseDirection,stopOnLastSlide:u.autoplayStopOnLastSlide,waitForTransition:u.autoplayWaitForTransition}};if(u.tablet){const{tabletBreakpoint:P,tabletSlidesPerView:N}=u,O=S(P);E.breakpoints[O]={slidesPerView:isNaN(N)?N:S(N),slidesPerGroup:S(u.tabletSlidesPerGroup),spaceBetween:S(u.tabletSpaceBetween)}}if(u.mobile){const{mobileBreakpoint:P,mobileSlidesPerView:N}=u,O=S(P);E.breakpoints[O]={slidesPerView:isNaN(N)?N:S(N),slidesPerGroup:S(u.mobileSlidesPerGroup),spaceBetween:S(u.mobileSpaceBetween)}}m&&!b&&(E.simulateTouch=!1),g&&(E.initialSlide=g);const M=new f.Swiper(h,E);m==null||m(M)};if(f.Swiper)x();else{const{head:k}=document,E=Array.isArray(y)?[...y]:[y],M=Array.isArray(v)?[...v]:[v],P=O=>{if(O.length){const R=document.createElement("link");R.href=O.shift(),R.rel="stylesheet",k.prepend(R),P(O)}},N=O=>{if(O.length){const R=document.createElement("script");R.src=O.shift(),R.onerror=R.onload=N.bind(null,O),k.appendChild(R)}else x()};P(M),N(E)}},d=(u=0)=>({type:qn,style:{padding:"50px"},components:{type:"text",components:{type:"textnode",content:`Slide ${u}`}}}),p=t.getType("default").model;return t.addType(Oe,{block:i&&{label:Hr,media:le.slider,category:"Extra",select:!0,...e.block},isComponent:u=>gt(u,ri),model:{defaults:()=>({name:Hr,icon:le.slider,classes:ri,draggable:(u,h)=>!h.is(Oe),components:[{type:on,components:[d(1),d(2),d(3)]},{type:ln}],script:c,cdnScript:e.cdnScript,cdnStyle:e.cdnStyle,"script-props":["cdnScript","cdnStyle",...r.propKeys],...r.props,traits:[...r.traits]}),init(){const{em:u}=this;Bp(this,r.traits),Hp(this,r.propKeys),this.listenTo(u,`${a.runCommand}${l}`,this.onPreviewOn),this.listenTo(u,`${a.stopCommand}${l}`,this.onPreviewOff)},onPreviewOn(){this.__inPreview=!0,this.reloadSlider()},onPreviewOff(){this.__inPreview=!1,this.reloadSlider()},reloadSlider(){this.trigger("rerender")},addSlide(){const u=this.findFirstType(on);u==null||u.append(this.getNewSlideComponentDef())},getNewSlideComponentDef(){var h;const u=((h=this.findFirstType(on))==null?void 0:h.components().length)||0;return{type:qn,components:{type:"text",components:{type:"textnode",content:`Slide ${u+1}`}}}},toJSON(...u){const h=p.prototype.toJSON.apply(this,u);return r.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 u;(u=this.getSwiper())==null||u.destroy()},onRender(){const u=this.el;u.__onLoad=h=>h.on("slideChange",()=>this.__activeSlide=h.activeIndex),u.__activeSlide=this.__activeSlide,u.__inPreview=this.model.__inPreview}}}),()=>{t.removeType(Oe),s.remove(Oe)}},nh="Nav Prev",sh="Nav Next",bs=`${xn}button-prev`,vs=`${xn}button-next`,oh=n=>{const{Components:e}=n,t=s=>({type:"svg",selectable:!1,hoverable:!1,attributes:{viewBox:"0 0 27 44"},components:{type:"svg-in",tagName:"path",attributes:{d:s,fill:"currentColor"}}});return e.addType(rn,{isComponent:s=>gt(s,bs),model:{defaults:{name:nh,classes:bs,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>`},Vr={id:"swiper-responsive",label:"Responsive",icon:le.responsive},Br={id:"swiper-extra",label:"Extra",icon:le.extra},eh={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(rn),setValue:({component:n,value:e})=>{var t,o;e?n.append([{type:rn},{type:_o}]):((t=n.findFirstType(rn))==null||t.remove(),(o=n.findFirstType(_o))==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:"checkbox",name:"autoplayEditor",label:"Autoplay in editor",tip:"Allow autoplay to run while editing in the canvas. Note: this may make selecting and editing slides difficult as they will automatically change.",changeProp:!0,value:!1},{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(ln)?n.get("pagination")||"bullets":"none",setValue:({component:n,value:e})=>{const t=n.findFirstType(ln);t==null||t.remove(),e!=="none"&&n.append({type:ln}),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(Dn),setValue:({component:n,value:e})=>{const t=n.findFirstType(Dn);t==null||t.remove(),e&&n.append({type:Dn}),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:Vr,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:Vr,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:Br,type:"checkbox",label:"Allow touch move",tip:"Allow touch interactions",value:!0},grabCursor:{category:Br,type:"checkbox",label:"Grab cursor",tip:'If enabled, the user will see the "grab" cursor when hover the slider',value:!1}},Hr="Slider",ri="swiper",xn=`${ri}-`,th=(n,e)=>{const{Components:t,Blocks:o,Commands:s}=n,{block:i}=e,r=Vp(eh),l="core:preview",a=s.events,c=function(u){const h=this,f=window,m=h.__onLoad,g=h.__activeSlide,b=h.__inPreview,C=f._isEditor&&!b?u.autoplayEditor:!0,{cdnScript:y,cdnStyle:v,slidesPerView:w}=u||{},S=k=>isNaN(k)?void 0:parseFloat(k),x=()=>{const k=h.parentElement;k&&(k.style.minWidth="0");const E={loop:u.loop,speed:u.speed,initialSlide:u.initialSlide,direction:u.vertical?"vertical":"horizontal",effect:u.effect,freeMode:u.freeMode,parallax:u.parallax,autoHeight:u.autoHeight,allowTouchMove:u.allowTouchMove,grabCursor:u.grabCursor,simulateTouch:!0,breakpoints:{},slidesPerView:isNaN(w)?w:S(w),slidesPerGroup:S(u.slidesPerGroup),spaceBetween:S(u.spaceBetween),slidesOffsetBefore:S(u.slidesOffsetBefore),slidesOffsetAfter:S(u.slidesOffsetAfter),centeredSlides:u.centeredSlides,fadeEffect:{crossFade:u.crossFade},cubeEffect:{shadow:u.cubeEffectShadow,slideShadows:u.cubeEffectSlideShadows,shadowOffset:S(u.cubeEffectShadowOffset),shadowScale:S(u.cubeEffectShadowScale)},coverflowEffect:{depth:S(u.coverflowEffectDepth),modifier:S(u.coverflowEffectModifier),rotate:S(u.coverflowEffectRotate),scale:S(u.coverflowEffectScale),stretch:S(u.coverflowEffectStretch),slideShadows:u.coverflowEffectSlideShadows},flipEffect:{limitRotation:u.flipEffectLimitRotation,slideShadows:u.flipEffectSlideShadows},cardsEffect:{perSlideOffset:S(u.cardsEffectPerSlideOffset),perSlideRotate:S(u.cardsEffectPerSlideRotate),rotate:u.cardsEffectRotate,slideShadows:u.cardsEffectSlideShadows},navigation:{nextEl:h.querySelector(".swiper-button-next"),prevEl:h.querySelector(".swiper-button-prev")},pagination:{type:u.pagination||"bullets",dynamicBullets:u.dynamicBullets,clickable:u.clickableBullets,progressbarOpposite:u.progressbarOpposite,el:h.querySelector(".swiper-pagination")},scrollbar:{el:h.querySelector(".swiper-scrollbar"),draggable:u.scrollbarDraggable,hide:u.scrollbarHide},autoplay:u.autoplay&&C&&{delay:u.autoplayDelay,disableOnInteraction:u.autoplayDisableOnInteraction,pauseOnMouseEnter:u.autoplayPauseOnMouseEnter,reverseDirection:u.autoplayReverseDirection,stopOnLastSlide:u.autoplayStopOnLastSlide,waitForTransition:u.autoplayWaitForTransition}};if(u.tablet){const{tabletBreakpoint:P,tabletSlidesPerView:N}=u,I=S(P);E.breakpoints[I]={slidesPerView:isNaN(N)?N:S(N),slidesPerGroup:S(u.tabletSlidesPerGroup),spaceBetween:S(u.tabletSpaceBetween)}}if(u.mobile){const{mobileBreakpoint:P,mobileSlidesPerView:N}=u,I=S(P);E.breakpoints[I]={slidesPerView:isNaN(N)?N:S(N),slidesPerGroup:S(u.mobileSlidesPerGroup),spaceBetween:S(u.mobileSpaceBetween)}}m&&!b&&(E.simulateTouch=!1),g&&(E.initialSlide=g);const M=new f.Swiper(h,E);m==null||m(M)};if(f.Swiper)x();else{const{head:k}=document,E=Array.isArray(y)?[...y]:[y],M=Array.isArray(v)?[...v]:[v],P=I=>{if(I.length){const R=document.createElement("link");R.href=I.shift(),R.rel="stylesheet",k.prepend(R),P(I)}},N=I=>{if(I.length){const R=document.createElement("script");R.src=I.shift(),R.onerror=R.onload=N.bind(null,I),k.appendChild(R)}else x()};P(M),N(E)}},d=(u=0)=>({type:qn,style:{padding:"50px"},components:{type:"text",components:{type:"textnode",content:`Slide ${u}`}}}),p=t.getType("default").model;return t.addType(Oe,{block:i&&{label:Hr,media:le.slider,category:"Extra",select:!0,...e.block},isComponent:u=>gt(u,ri),model:{defaults:()=>({name:Hr,icon:le.slider,classes:ri,draggable:(u,h)=>!h.is(Oe),components:[{type:sn,components:[d(1),d(2),d(3)]},{type:ln}],script:c,cdnScript:e.cdnScript,cdnStyle:e.cdnStyle,"script-props":["cdnScript","cdnStyle",...r.propKeys],...r.props,traits:[...r.traits]}),init(){const{em:u}=this;Bp(this,r.traits),Hp(this,r.propKeys),this.listenTo(u,`${a.runCommand}${l}`,this.onPreviewOn),this.listenTo(u,`${a.stopCommand}${l}`,this.onPreviewOff)},onPreviewOn(){this.__inPreview=!0,this.reloadSlider()},onPreviewOff(){this.__inPreview=!1,this.reloadSlider()},reloadSlider(){this.trigger("rerender")},addSlide(){const u=this.findFirstType(sn);u==null||u.append(this.getNewSlideComponentDef())},getNewSlideComponentDef(){var h;const u=((h=this.findFirstType(sn))==null?void 0:h.components().length)||0;return{type:qn,components:{type:"text",components:{type:"textnode",content:`Slide ${u+1}`}}}},toJSON(...u){const h=p.prototype.toJSON.apply(this,u);return r.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 u;(u=this.getSwiper())==null||u.destroy()},onRender(){const u=this.el;u.__onLoad=h=>h.on("slideChange",()=>this.__activeSlide=h.activeIndex),u.__activeSlide=this.__activeSlide,u.__inPreview=this.model.__inPreview}}}),()=>{t.removeType(Oe),o.remove(Oe)}},nh="Nav Prev",oh="Nav Next",bo=`${xn}button-prev`,vo=`${xn}button-next`,sh=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(rn,{isComponent:o=>gt(o,bo),model:{defaults:{name:nh,classes:bo,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
|
+
.${bo} {
|
|
101
101
|
color: inherit;
|
|
102
102
|
}
|
|
103
|
-
.${
|
|
103
|
+
.${bo}:after {
|
|
104
104
|
content: none;
|
|
105
105
|
}
|
|
106
|
-
`}}}),e.addType(
|
|
107
|
-
.${
|
|
106
|
+
`}}}),e.addType(_o,{extend:rn,isComponent:o=>gt(o,vo),model:{defaults:{name:oh,classes:vo,components:t("M27,22L27,22L5,44l-2.1-2.1L22.8,22L2.9,2.1L5,0L27,22L27,22z"),styles:`
|
|
107
|
+
.${vo} {
|
|
108
108
|
color: inherit;
|
|
109
109
|
}
|
|
110
|
-
.${
|
|
110
|
+
.${vo}:after {
|
|
111
111
|
content: none;
|
|
112
112
|
}
|
|
113
|
-
`}}}),()=>{e.removeType(rn),e.removeType(
|
|
113
|
+
`}}}),()=>{e.removeType(rn),e.removeType(_o)}},ih=n=>{const{Components:e}=n,t=`${xn}pagination`;return e.addType(ln,{isComponent:o=>gt(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(ln)}},rh="Scrollbar",Fr=`${xn}scrollbar`,lh=n=>{const{Components:e}=n;return e.addType(Dn,{isComponent:t=>gt(t,Fr),model:{defaults:{name:rh,classes:Fr,copyable:!1,highlightable:!1,removable:!1,selectable:!1,hoverable:!1,layerable:!1,droppable:!1,draggable:!1}}}),()=>{e.removeType(Dn)}},ah="Slide",_r=`${xn}slide`,ch=n=>{const{Components:e}=n;return e.addType(qn,{isComponent:t=>gt(t,_r),model:{defaults:{name:ah,classes:_r,icon:le.slider,draggable:(t,
|
|
120
|
+
`}}}),()=>{e.removeType(ln)}},rh="Scrollbar",Fr=`${xn}scrollbar`,lh=n=>{const{Components:e}=n;return e.addType(Dn,{isComponent:t=>gt(t,Fr),model:{defaults:{name:rh,classes:Fr,copyable:!1,highlightable:!1,removable:!1,selectable:!1,hoverable:!1,layerable:!1,droppable:!1,draggable:!1}}}),()=>{e.removeType(Dn)}},ah="Slide",_r=`${xn}slide`,ch=n=>{const{Components:e}=n;return e.addType(qn,{isComponent:t=>gt(t,_r),model:{defaults:{name:ah,classes:_r,icon:le.slider,draggable:(t,o)=>o.is(sn)}}}),()=>{e.removeType(qn)}},dh="Wrapper",Gr=`${xn}wrapper`,ph=n=>{const{Components:e}=n,{events:t}=e;return e.addType(sn,{isComponent:o=>gt(o,Gr),model:{defaults:{name:dh,icon:le.slider,classes:Gr,copyable:!1,removable:!1,draggable:!1,highlightable:!1,droppable:o=>o.is(qn)},init(){const o=this.components();this.listenTo(o,"add remove",this.updateSlider)},updateSlider(o){const s=this.closestType(Oe);if(s){const i=s.getView();s.reloadSlider(),this.em.once(t.scriptMount,()=>{setTimeout(()=>{var r;return(r=i.getSwiper())==null?void 0:r.slideTo(o.index())},100)})}}}}),()=>{e.removeType(sn)}},uh="swiperComponent",hh=H.startup,fh=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=[th(n,t),sh(n),ph(n),ch(n),ih(n),lh(n)];G({editor:n,plan:hh,licenseKey:t.licenseKey,pluginName:uh,cleanup:()=>{o.forEach(s=>s())}})},mh=_(fh),he="accordion",kn=`${he}-group`,Qe=`${he}-header`,at=`${he}-content`,Mt=`${he}-marker`,Wr=`${Me}${Qe}`,li=`${Me}${Mt}`,gh=`${Me}${at}`,lc=`${li}-open`,zt={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>'},ac=(n,e)=>{const{toolbarIconOpen:t=zt.eye}=e,o=n.is(he)?n:n.closestType(he);if(!t||!o)return;const{toolbar:s}=n,i={id:"accordion-toggle-open",label:t,command:()=>o.toggleOpen()};!s.find(l=>l.id===i.id)&&(s==null||s.unshift(i))},yh=(n,e)=>{const{Components:t,Blocks:o}=n,{block:s={}}=e,i="Accordion",r=`${Me}${he}`,l=function(a={}){const c=this,d=()=>{const{clsMarkerOpen:p}=a,u=c.querySelector('[data-type-role="accordion-marker"]');!u||!p||(c.open?u.classList.add(p):u.classList.remove(p))};c.addEventListener("toggle",()=>{d(),c.dispatchEvent(new CustomEvent("details-toggle",{bubbles:!0}))}),d()};return t.addType(he,{block:s&&{label:i,media:zt.accordion,category:"Extra",select:!0,...s},isComponent:Fe(he),extendFn:["initToolbar"],model:{defaults:{tagName:"details",name:i,classes:r,emptyState:!0,clsMarkerOpen:lc,attributes:{[Re]:he},droppable:cs(Qe,at),components:[{type:Qe},{type:at}],"script-props":["clsMarkerOpen"],script:l,traits:[{type:"checkbox",name:"open",label:"Open"}],styles:`
|
|
121
121
|
.${r}::details-content {
|
|
122
122
|
opacity: 0;
|
|
123
123
|
block-size: 0;
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
transform: translateY(0);
|
|
135
135
|
block-size: auto;
|
|
136
136
|
}
|
|
137
|
-
`},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){ac(this,e)}}}),()=>{
|
|
137
|
+
`},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){ac(this,e)}}}),()=>{o.remove(he),t.removeType(he)}},bh=n=>{const{Components:e}=n;return e.addType(at,{isComponent:Fe(at),model:{defaults:{name:"Accordion Content",removable:!1,copyable:!1,draggable:!1,emptyState:!0,classes:gh,icon:zt.accordionContent,attributes:{[Re]:at},components:"<div>Accordion content</div>"}}}),()=>{e.removeType(at)}},vh=(n,e)=>{const{Components:t,Blocks:o}=n,{blockGroup:s={}}=e,i="Accordion Group",r=function(a={}){if(!a.single)return;const c=this;c.addEventListener("details-toggle",d=>{const p=d.target;if(!a.single||!p||!p.open)return;c.querySelectorAll('[data-type-role="accordion"]').forEach(h=>{p!==h&&h.open&&(h.open=!1)})})},l=(a={})=>({type:he,attributes:{open:a.open},components:[{type:Qe,components:[`<div>${a.header}</div>`,{type:Mt}]},{type:at,components:`<div>${a.content}</div>`}]});return t.addType(kn,{block:s&&{label:i,media:zt.accordionGroup,category:"Extra",select:!0,...s},isComponent:Fe(kn),model:{defaults:{name:i,attributes:{[Re]:kn},droppable:cs(he),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:r}}}),()=>{o.remove(kn),t.removeType(kn)}},Sh=(n,e)=>{const{Components:t}=n;return t.addType(Qe,{isComponent:Fe(Qe),extendFn:["initToolbar"],model:{defaults:{tagName:"summary",name:"Accordion Header",removable:!1,copyable:!1,draggable:!1,emptyState:!0,icon:zt.accordionHeader,classes:Wr,attributes:{[Re]:Qe},components:["<div>Accordion header</div>",{type:Mt}],styles:`
|
|
138
138
|
summary {
|
|
139
139
|
list-style: none;
|
|
140
140
|
}
|
|
@@ -155,19 +155,19 @@
|
|
|
155
155
|
.${lc} {
|
|
156
156
|
transform: rotateZ(180deg);
|
|
157
157
|
}
|
|
158
|
-
`}}}),()=>{e.removeType(Mt)}},wh="accordionComponent",Ch=H.startup,kh=function(n,e={}){const t=[yh(n,e),vh(n,e),Sh(n,e),xh(n),bh(n)];
|
|
158
|
+
`}}}),()=>{e.removeType(Mt)}},wh="accordionComponent",Ch=H.startup,kh=function(n,e={}){const t=[yh(n,e),vh(n,e),Sh(n,e),xh(n),bh(n)];G({editor:n,licenseKey:e.licenseKey,plan:Ch,pluginName:wh,cleanup:()=>{t.forEach(o=>o())}})},Eh=_(kh),_n=class _n{constructor(e){this.config=e}getSize(e){var t;return(t=this.config)!=null&&t.getSize?this.config.getSize(e):Xi(e.componentColumn,_n.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:i}=e;o.addStyle({[_n.CSS_FLEX_BASIS]:s},{partial:i})}}};_n.CSS_FLEX_BASIS="flex-basis";let ai=_n;const Gn=class Gn{constructor(e){this.config=e}isGapSupported(){return!0}getGap(e){var t;return(t=this.config)!=null&&t.getGap?this.config.getGap(e):Xi(e.componentRow,Gn.CSS_GAP)}setGap(e){var t;if((t=this.config)!=null&&t.setGap)this.config.setGap(e);else{const{componentRow:o,gapValue:s,partial:i}=e;o.addStyle({[Gn.CSS_GAP]:s},{partial:i})}}};Gn.CSS_GAP="gap";let ci=Gn;const ls=class ls{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();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=Xi(e.componentRow,ls.CSS_FLEX_DIRECTION,!0);return t==="column"||t==="column-reverse"}};ls.CSS_FLEX_DIRECTION="flex-direction";let di=ls;const Wn=class Wn{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(Wn.MJML_COLUMN_TYPE)){const i=t.getAttributes().width;if(i&&(i.includes("%")||!isNaN(parseFloat(i))))return parseFloat(i);const r=t.parent();return 100/(r?r.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:i}=e;o.is(Wn.MJML_COLUMN_TYPE)&&o.addAttributes({width:`${parseFloat(s)}%`},{partial:i})}}};Wn.MJML_COLUMN_TYPE="mj-column";let pi=Wn;const as=class as{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(as.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)}};as.MJML_SECTION_TYPE="mj-section";let ui=as;class Th{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();if(!s)return 0;let i=s;if(s.tagName!=="TABLE"){const l=s.querySelectorAll("table");l.length&&(i=l[0])}return o?i.clientHeight:i.clientWidth}isLayoutVertical(e){var t;return(t=this.config)!=null&&t.isParentVertical?this.config.isParentVertical(e):!1}}class tn{constructor(){this.handlerCache=new Map}static getInstance(){return tn.instance||(tn.instance=new tn),tn.instance}getHandlers(e){const t=`${e.projectType}-${e.disableGapHandler?"nogap":"gap"}`;return this.handlerCache.has(t)||(fn(e)?this.handlerCache.set(t,{sizeHandler:new pi(e),gapHandler:new ui(e),parentSizeHandler:new Th(e)}):this.handlerCache.set(t,{sizeHandler:new ai(e),gapHandler:new ci(e),parentSizeHandler:new di(e)})),this.handlerCache.get(t)}}function Gt(n){return tn.getInstance().getHandlers(n)}const jr=n=>{n.style.display="none"},qr=n=>{n.style.display="block"},Ln=n=>+parseFloat(`${n}`).toFixed(2),fn=n=>n.projectType===$a.email,Mh=n=>n?["top","bottom"]:["left","right"],Ah=n=>{const e=n.parent();return e?e.components().models.indexOf(n)===0:!1},Ph=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.indexOf(n)===t.length-1},Nh=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.length>1&&n.index()===t.length-1},Ih=(n,e,t,o)=>{const i=n+(t?e==="top"?-1:e==="bottom"?1:0:e==="left"?-1:e==="right"?1:0);return i>=0&&i<o?i:-1},Go=n=>n==="top"||n==="bottom",Oh=(n,e)=>!!(Ah(n)&&(e==="left"||e==="top")||Ph(n)&&(e==="right"||e==="bottom")),Rh=n=>{const e=n.parent();return e?e.components().models.length>1:!1},Ur=(n,e)=>n==="right"||n==="bottom"?e>0:e<0,Xi=(n,e,t=!1)=>{const o=!t,s=n.getEl();if(!s)return o?0:"";const r=window.getComputedStyle(s)[e]||"";if(o){let l;return typeof r=="string"?(l=parseFloat(r.replace(/[^-\d.]/g,"")),isNaN(l)&&(l=0)):l=Number(r)||0,l}return r},Kr=(n,e,t)=>{const o=hi({componentRow:n,isVertical:e},t),s=n.components().models;return o*(s.length-1)},Un=(n,e)=>Gt(e).parentSizeHandler.isLayoutVertical({componentRow:n}),Kn=(n,e)=>Gt(e).sizeHandler.getSize(n),hi=(n,e)=>{if(e!=null&&e.disableGapHandler)return 0;const{gapHandler:t,parentSizeHandler:o}=Gt(e);if(!t.isGapSupported())return 0;const s=t.getGap(n),i=o.getParentSize(n);return s/100*i},fi=(n,e)=>Gt(e).parentSizeHandler.getParentSize(n),$n=(n,e)=>{Gt(e).sizeHandler.setSize(n)},cc=(n,e)=>{const t=Kn(n,e);$n({...n,sizeValue:`${t}%`,partial:!1},e)},dc=(n,e)=>{if(e!=null&&e.disableGapHandler)return;const{gapHandler:t}=Gt(e);t.isGapSupported()&&t.setGap(n)},Dh=(n,e)=>{const t=n.getStyle().gap;if(!t)return;const o=n.components().models,s={componentRow:n,isVertical:Un(n,e)};o.map(i=>cc({...s,componentColumn:i},e)),dc({...s,gapValue:String(t),partial:!1},e)};function Lh(n,e){const{Blocks:t}=n,{typeColumn:o,typeRow:s,blocks:i}=e;if(i===!1||fn(e))return;const r=p=>({type:s,components:p.map(u=>({type:o,style:{"flex-basis":`${u}%`}}))}),l=p=>`<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
|
|
159
159
|
${p.map(u=>`<div style="flex-basis: ${u}%; border-color: currentColor; border-width: 2px; border-radius: 0.12rem;"></div>`).join("")}
|
|
160
|
-
</div>`,a=(p,u)=>({id:`flex-row-${u.join("-")}`,label:p,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:l(u),content:r(u)}),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(i)?i({blocks:c}):c;return d.forEach(p=>t.add(p.id,p)),()=>{d.forEach(p=>t.remove(p.id))}}const $h=(n,e)=>{const{Components:t}=n,{typeRow:
|
|
160
|
+
</div>`,a=(p,u)=>({id:`flex-row-${u.join("-")}`,label:p,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:l(u),content:r(u)}),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(i)?i({blocks:c}):c;return d.forEach(p=>t.add(p.id,p)),()=>{d.forEach(p=>t.remove(p.id))}}const $h=(n,e)=>{const{Components:t}=n,{typeRow:o,typeColumn:s,extendTypeColumn:i}=e,r=`${Me}${s}`,a=!!s&&!!t.getType(s)&&!i;if(!(!s||a||fn(e)))return t.addType(s,{isComponent:Fe(s),model:{defaults:{name:"Column",resizable:!1,emptyState:!0,classes:r,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:qi(o),attributes:{[Re]:s},styles:`
|
|
161
161
|
.${r} {
|
|
162
162
|
flex-grow: 1;
|
|
163
163
|
}
|
|
164
|
-
`}}}),()=>{t.removeType(
|
|
164
|
+
`}}}),()=>{t.removeType(s)}},zh=(n,e)=>{const{Components:t}=n,{typeRow:o,typeColumn:s,extendTypeRow:i}=e,r=`${Me}${o}`,a=!!o&&!!t.getType(o)&&!i;if(!(!o||a||fn(e)))return t.addType(o,{isComponent:Fe(o),model:{defaults:{name:"Row",classes:r,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:{[Re]:o},droppable:cs(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
165
|
.${r} {
|
|
166
166
|
display: flex;
|
|
167
167
|
align-items: stretch;
|
|
168
168
|
flex-wrap: nowrap;
|
|
169
169
|
}
|
|
170
|
-
`}}}),()=>{t.removeType(
|
|
170
|
+
`}}}),()=>{t.removeType(o)}},Vh="flexComponent",Bh=H.startup;class Hh{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 Fh{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,i=this.getState(e);i.direction=t,i.startX=o.clientX,i.startY=o.clientY,i.resizing=!0,i.lastSnappedPercent=void 0;const r=e.parent();if(!r||!this.registry.isValidRelationship(r,e))return;i.snapEnabled=r.get("snap")??s.snapEnabled,i.snapDivisions=r.get("snap-divisions")??s.snapDivisions??12;const l=r.components().models,a=l.findIndex(u=>u.cid===e.cid),c=Un(r,s),d=Ih(a,t,c,l.length);d!==-1&&(i.adjacentIdx=d);const p={componentColumn:e,componentRow:r,isVertical:c};if(i.startPercent=Kn(p,s),typeof i.adjacentIdx<"u"){const u=l[i.adjacentIdx];i.neighborStartPercent=Kn({...p,componentColumn:u},s)}}updateResizeByDelta(e,t,o){const s=this.getState(e),i=e.parent();!s.resizing||!i||(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&&Un(t,this.opts)};o==null||o.forEach(i=>cc({...s,componentColumn:i},this.opts)),this.clearState(e)}updateContinuesResize(e,t,o){const s=this.getState(e),i=e.parent(),{opts:r}=this;if(!i)return;const l=r.minItemPercent??0,a=Go(t),c=fi({componentRow:i,isVertical:a},r),d=Kr(i,a,this.opts),u=100-d/c*100,h=o/(c-d)*u,{startPercent:f=0,neighborStartPercent:m=0}=s,g={componentRow:i,isVertical:a,componentColumn:e,partial:!0},b=Ur(t,o)?f+Math.abs(h):f-Math.abs(h);if(typeof s.adjacentIdx<"u"){const C=i.components().models[s.adjacentIdx],y=f+m,v=y-l,S=Math.min(v,Math.max(l,b)),x=y-S;$n({...g,sizeValue:`${Ln(S)}%`},r),$n({...g,componentColumn:C,sizeValue:`${Ln(x)}%`},r)}else{const C=Math.max(l,Math.min(u,b));$n({...g,sizeValue:`${Ln(C)}%`},r)}}updateSnapResize(e,t,o){const s=this.getState(e),i=e.parent(),r=Go(t),l=fi({componentRow:i,isVertical:r},this.opts),a=Kr(i,r,this.opts),c=l-a,d=o/c*100,p=Ur(t,o),{startPercent:u=0,snapDivisions:h=12}=s,f=p?u+Math.abs(d):u-Math.abs(d),m=100/h,g=Math.floor(f/m)*m,b=Math.ceil(f/m)*m,C=Math.abs(b-f),y=Math.abs(f-g),v=m*.2,w=C<y?b:g;if(w>0&&w<100&&(C<v||y<v)&&s.lastSnappedPercent!==w){s.lastSnappedPercent=w;let k=Math.abs(w-u)/100*c;(p&&(t==="left"||t==="top")||!p&&(t==="right"||t==="bottom"))&&(k=-k),this.updateContinuesResize(e,t,k)}else C>=v&&y>=v&&(s.lastSnappedPercent=void 0)}}class _h{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:i}=this,r=Math.max(0,o+t),l=fi({componentRow:e,isVertical:s},i),a=r/l*100,c=e.components().models,d=c.length-1,p={componentRow:e,isVertical:s},u=c.reduce((v,w)=>v+Kn({...p,componentColumn:w},i),0),f=100-a*d,m=i.minItemPercent||5;if(f<m*c.length)return;const b=100-d*a,C=u-b,y={componentRow:e,isVertical:s,partial:!0};c.map(v=>{const w=Kn({...p,componentColumn:v},i),S=w-w/u*C;$n({...y,componentColumn:v,sizeValue:`${Ln(S)}%`},i)}),dc({...y,gapValue:`${Ln(a)}%`},i)}finishGapAdjust(e){Dh(e,this.opts)}}class Gh{constructor(e,t,o){this.editor=e,this.registry=t,this.opts=o,this.resizeHandler=new Fh(e,t,o),this.gapHandler=new _h(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 Wo="gs-flex-spots",Jr=`${Wo}__handle-size`,Wh=`${Wo}__handle-gap`;function jh(n,e){const{Canvas:t}=n,o="flex-resize-spot";let s,i,r,l,a=null,c=null;const d=new Hh,p=new Gh(n,d,e),u=()=>{var S;s=document.createElement("div"),s.className=Wo,s.style.display="none",i=document.createElement("div"),i.className=`${Wo}__handles`,i.style.position="absolute",i.style.pointerEvents="none",i.style.zIndex="21",r={left:document.createElement("div"),right:document.createElement("div"),top:document.createElement("div"),bottom:document.createElement("div")},Object.entries(r).forEach(([x,k])=>{const E=x,M=Go(E);k.className=`${Jr} ${Jr}-${E} gjs-resizer-h gjs-cv-unscale`,k.style.cssText=`
|
|
171
171
|
pointer-events: all;
|
|
172
172
|
position: absolute;
|
|
173
173
|
z-index: 1;
|
|
@@ -187,8 +187,8 @@
|
|
|
187
187
|
pointer-events: all;
|
|
188
188
|
max-width: 3rem;
|
|
189
189
|
max-height: 3rem;
|
|
190
|
-
`,l.addEventListener("pointerdown",f()),i.appendChild(l)),
|
|
191
|
-
`)},init(){const{em:p}=this;this.addStyle({[Ne.name]:"fadeIn",[Ne.duration]:"1s",[Ne.fillMode]:"both",...e.animationStyle,...this.getStyle()}),this.listenTo(p,l.mount,u=>{var f;if(u!==this)return;((f=this.parent())==null?void 0:f.get("type"))!==nn||c.forEach(m=>this.removeStyle(m))})}},view:{events:()=>({animationstart:"onAnimationStart",animationend:"onAnimationEnd"}),init(){const{model:p}=this;this.listenTo(p,l.styleUpdate,this.handleStyleChange)},onAnimationStart(){var u;if((u=this.cmpSpots)!=null&&u.length)return;const p=
|
|
190
|
+
`,l.addEventListener("pointerdown",f()),i.appendChild(l)),s.append(i),(S=t.getSpotsEl())==null||S.appendChild(s)},h=S=>x=>{if(!a)return;x.stopPropagation(),x.preventDefault(),p.startResize(a,S,x);const k=x.clientX,E=x.clientY;x.target.setPointerCapture(x.pointerId);const M=N=>{const I=n.Canvas.getZoomMultiplier(),R=(N.clientX-k)*I,F=(N.clientY-E)*I,ie=Go(S)?F:R;p.updateResizeByDelta(a,S,ie)},P=()=>{p.finishResize(a),x.target.releasePointerCapture(x.pointerId),document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",P)};document.addEventListener("pointermove",M),document.addEventListener("pointerup",P)},f=()=>S=>{if(!c)return;const x=c;S.stopPropagation(),S.preventDefault();const k=Un(x,e),E=hi({componentRow:x,isVertical:k},e),M=S.clientX,P=S.clientY;S.target.setPointerCapture(S.pointerId);const N=R=>{const F=n.Canvas.getZoomMultiplier(),ie=k?(R.clientY-P)*F:(R.clientX-M)*F;p.updateGapByDelta(x,ie,E,k)},I=()=>{p.finishGapAdjust(x),S.target.releasePointerCapture(S.pointerId),document.removeEventListener("pointermove",N),document.removeEventListener("pointerup",I)};document.addEventListener("pointermove",N),document.addEventListener("pointerup",I)},m=S=>{const x=S.component;if(!x||!s||(a=x,c=x.parent(),!c))return;const k=c;qr(s);const E=S.getStyle();i&&Object.assign(i.style,E);const M=Un(k,e),P=Mh(M);if(Object.values(r).forEach(jr),P.forEach(I=>{if(Oh(x,I))return;const R=r[I];qr(R)}),Gt(e).gapHandler.isGapSupported()&&l&&Rh(x)){const I=hi({componentRow:k,isVertical:M},e);g(I,M,Nh(x))}},g=(S,x,k=!1)=>{const E=e.gapHandleSize,M=l.style;if(x){M.height=`${E}px`;const P=l.offsetHeight;k?(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=`${E}px`;const P=l.offsetWidth;k?(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"}},b=()=>{s&&(jr(s),a=null,c=null)},C=()=>{t.removeSpots({type:o});const S=n.getSelected(),x=S==null?void 0:S.parent();S&&x&&d.isValidRelationship(x,S)?t.addSpot({type:o,component:S}):b()},y=()=>{const S=t.getSpots().filter(x=>x.type===o)[0];S&&m(S)},v=(S,x)=>{d.registerTypeRelationship(S,x)};n.onReady(()=>{u(),fn(e)?v("mj-section","mj-column"):v(e.typeRow,e.typeColumn)});const w="component:toggled";return n.on(t.events.spot,y),n.on(w,C),()=>{n.off(t.events.spot,y),n.off(w,C)}}const qh=function(n,e={}){const t={typeRow:"flex-row",typeColumn:"flex-column",gapHandleSize:3,snapDivisions:12,minItemPercent:5,...e},o=[zh(n,t),$h(n,t)],s=jh(n,t),i=Lh(n,t);G({editor:n,licenseKey:t.licenseKey,plan:Bh,pluginName:Vh,cleanup:()=>{o.forEach(r=>r==null?void 0:r()),s(),i==null||i()}})},Uh=_(qh);var Ne=(n=>(n.name="animation-name",n.duration="animation-duration",n.delay="animation-delay",n.iterationCount="animation-iteration-count",n.timingFunction="animation-timing-function",n.fillMode="animation-fill-mode",n))(Ne||{}),an=(n=>(n.onScroll="--animation-on-scroll",n.threshold="--animation-threshold",n.repeat="--animation-repeat",n))(an||{});const Ve="animation",nn="animation-group",Zr="animation:update",mi="animation-group:update",pc={category:{id:"animations",label:"Animations"},select:!0},us=n=>(n==null?void 0:n.getType())===Ve,hs=n=>(n==null?void 0:n.getType())===nn,uc=n=>us(n)||hs(n),En={isVisible:({component:n})=>us(n)},Kh={isVisible:({component:n})=>hs(n)},Jh={isVisible:({component:n})=>us(n)&&hs(n==null?void 0:n.parent())?!1:uc(n)},Yr={isVisible:({component:n,sector:e})=>{var t;return us(n)&&hs(n==null?void 0:n.parent())?!1:uc(n)&&((t=e.getProperty(an.onScroll))==null?void 0:t.getValue())==="true"}},hc={animation:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M16.5 14a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13"/><path fill="currentColor" d="M17.14 15.98a8.5 8.5 0 0 1-9.12-9.12 6.5 6.5 0 1 0 9.12 9.12"/><path fill="currentColor" d="M12.64 20.48a8.5 8.5 0 0 1-9.12-9.12 6.5 6.5 0 1 0 9.12 9.12"/></svg>',animationGroup:'<svg viewBox="0 0 24 24"><path d="M4 2a2 2 0 0 0-2 2v10h2V4h10V2H4m4 4a2 2 0 0 0-2 2v10h2V8h10V6H8m4 4a2 2 0 0 0-2 2v8c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2v-8a2 2 0 0 0-2-2h-8Z"/></svg>'},Zh=function(n){const e=this;let t=null;const o=()=>{t==null||t.disconnect(),t=null},s=()=>{o();const i=e.style;i.animationName="",requestAnimationFrame(()=>{const r=getComputedStyle(e),l=r.getPropertyValue("animation-name").trim(),a=r.getPropertyValue("--animation-on-scroll").trim()!=="false",c=parseFloat(r.getPropertyValue("--animation-threshold").trim())||.2,d=r.getPropertyValue("--animation-repeat").trim()==="true",p=()=>{i.animationName="none",e.offsetWidth,i.animationName=l,i.animationPlayState="running"};if(!l||l==="none"){i.animationName="none",i.animationPlayState="paused";return}if(!a){p();return}i.animationPlayState="paused",t=new IntersectionObserver(u=>{u.forEach(h=>{h.isIntersecting&&(p(),!d&&o())})},{threshold:c}),t.observe(e)})};e.addEventListener(n.animationUpdateEvent,s),s()},Yh=(n,e)=>{const{Components:t,Blocks:o,Canvas:s}=n,{block:i={},animationList:r=[]}=e,l=n.Components.events,a="Animation",c=Object.values(an),d=Object.values(Ne);return t.addType(Ve,{block:i?{label:a,media:hc.animation,content:{type:Ve},...pc,...i}:void 0,model:{defaults:{emptyState:!0,name:a,traits:[],script:Zh,animationUpdateEvent:Zr,"script-props":["animationUpdateEvent"],styles:r.map(p=>p.css).join(`
|
|
191
|
+
`)},init(){const{em:p}=this;this.addStyle({[Ne.name]:"fadeIn",[Ne.duration]:"1s",[Ne.fillMode]:"both",...e.animationStyle,...this.getStyle()}),this.listenTo(p,l.mount,u=>{var f;if(u!==this)return;((f=this.parent())==null?void 0:f.get("type"))!==nn||c.forEach(m=>this.removeStyle(m))})}},view:{events:()=>({animationstart:"onAnimationStart",animationend:"onAnimationEnd"}),init(){const{model:p}=this;this.listenTo(p,l.styleUpdate,this.handleStyleChange)},onAnimationStart(){var u;if((u=this.cmpSpots)!=null&&u.length)return;const p=s.getSpots({component:this.model});this.cmpSpots=p,s.removeSpots(p),this.el.ownerDocument.body.style.overflowX="hidden"},onAnimationEnd(){const p=this.cmpSpots||[];s.spots.add(p),this.cmpSpots=[],this.el.ownerDocument.body.style.overflowX=""},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(Zr))},handleStyleChange(p,u){Object.keys((u==null?void 0:u.style)||{}).some(m=>d.includes(m)||c.includes(m))&&this.triggerAnimation()},onRender(){this.triggerAnimation()}}}),()=>{o.remove(Ve),t.removeType(Ve)}},Xh=function(n){const e=this,t="--animation-on-scroll",o="--animation-threshold",s="--animation-repeat";let i=null;const r=()=>{i==null||i.disconnect(),i=null},l=()=>{r();const a=getComputedStyle(e),c=a.getPropertyValue(t).trim()!=="false",d=parseFloat(a.getPropertyValue(o).trim())||.2,p=a.getPropertyValue(s).trim()==="true",u=()=>{Array.from(e.children).forEach(h=>{h instanceof HTMLElement&&typeof h.dispatchEvent=="function"&&h.dispatchEvent(new CustomEvent(mi,{bubbles:!1}))})};if(!c){u();return}i=new IntersectionObserver(h=>{h.forEach(f=>{f.isIntersecting?(u(),!p&&r()):p&&Array.from(e.children).forEach(m=>{m instanceof HTMLElement&&getComputedStyle(m).getPropertyValue(t).trim()!=="false"&&(m.style.opacity="0",m.style.animationPlayState="paused")})})},{threshold:d}),i.observe(e)};e.addEventListener(n.animationGroupUpdateEvent,l),l()},Qh=(n,e)=>{const{Components:t,Blocks:o}=n,{blockGroup:s={}}=e,i="Animation Group";return t.addType(nn,{block:s?{label:i,media:hc.animationGroup,content:{type:nn,components:[{type:Ve},{type:Ve},{type:Ve}]},...pc,...s}:void 0,model:{defaults:{name:i,emptyState:!0,traits:[],script:Xh,animationGroupUpdateEvent:mi,"script-props":["animationGroupUpdateEvent"],droppable:cs(Ve)},init(){this.addStyle({...e.animationGroupStyle,...this.getStyle()});const r=this.components();this.listenTo(r,"add remove",this.updateChildrenStaggerStyles),this.updateChildrenStaggerStyles()},updateChildrenStaggerStyles(){this.components().forEach((r,l)=>{r.is(Ve)&&r.addStyle({"--stagger-index":l.toString(),[Ne.delay]:"calc(var(--stagger-index, 0) * var(--stagger-delay, 0.3s))"},{partial:!0})})}},view:{init(){const{model:r}=this;this.listenTo(r,"component:styleUpdate",this.handleStyleChange)},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(mi))},handleStyleChange(){this.triggerAnimation(),this.model.updateChildrenStaggerStyles()},onRender(){this.triggerAnimation()}}}),()=>{o.remove(nn),t.removeType(nn)}},ef="animationComponent",tf=H.startup,Xr=[{id:"flash",name:"Flash",css:`@keyframes flash {
|
|
192
192
|
0%, 50%, to {
|
|
193
193
|
opacity:1
|
|
194
194
|
}
|
|
@@ -705,7 +705,7 @@
|
|
|
705
705
|
transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0);
|
|
706
706
|
animation-timing-function:cubic-bezier(.175, .885, .32, 1)
|
|
707
707
|
}
|
|
708
|
-
}`}],nf=function(n,e={}){var
|
|
708
|
+
}`}],nf=function(n,e={}){var s;const t=((s=e.animations)==null?void 0:s.call(e,{items:Xr}))||Xr,o=[Yh(n,{...e,animationList:t}),Qh(n,e)];n.Styles.addSector("animation",{name:"Animation",properties:[{...En,name:"Type",property:Ne.name,type:"select",full:!0,default:"fadeIn",options:t},{...En,name:"Duration",property:Ne.duration,type:"number",units:["s"],min:.1,max:10,step:.1,default:"1s"},{...En,name:"Delay",property:Ne.delay,type:"number",units:["s"],min:0,max:10,step:.1,default:"1s"},{...En,name:"Iteration Count",property:Ne.iterationCount,type:"select",default:"1",options:[{id:"1",name:"One time"},{id:"infinite",name:"Infinite"}]},{...En,name:"Timing",property:Ne.timingFunction,type:"select",default:"ease",options:[{id:"ease",name:"Ease"},{id:"ease-in",name:"Ease in"},{id:"ease-out",name:"Ease out"},{id:"ease-in-out",name:"Ease in out"},{id:"linear",name:"Linear"}]},{...Kh,name:"Stagger Delay",property:"--stagger-delay",type:"slider",units:["s"],min:.1,max:5,step:.1,default:"0.3s"},{...Jh,name:"Animate on Scroll",property:an.onScroll,type:"radio",default:"true",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]},{...Yr,name:"Scroll Threshold",property:an.threshold,type:"number",full:!0,min:.1,max:1,step:.01,default:"0.2"},{...Yr,name:"Repeat on Scroll",property:an.repeat,type:"radio",default:"false",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]}]}),G({editor:n,licenseKey:e.licenseKey,plan:tf,pluginName:ef,cleanup:()=>{o.forEach(i=>i())}})},of=_(nf),sf="shapeDividerComponent",rf=H.startup,lf=function(n,e={}){const{Components:t,Blocks:o,Selectors:s}=n,i="shape-divider",r=`${i}-cnt`,l=`${Me}${i}`,a=`${Me}${r}`,c=[{id:"tilt",label:"Tilt",value:`<svg preserveAspectRatio="none" viewBox="0 0 240 24">
|
|
709
709
|
<path d="M240 24V0L0 24h240z"/>
|
|
710
710
|
</svg>`},{id:"tilt-split",label:"Tilt split",value:`<svg preserveAspectRatio="none" viewBox="0 0 240 24">
|
|
711
711
|
<path fill-opacity=".3" d="M240 24V0L0 24h240z"/>
|
|
@@ -767,7 +767,7 @@
|
|
|
767
767
|
<path d="M75 38l25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25V.0H0V13l25 25 25-25z"/>
|
|
768
768
|
</svg>`}],d={tl:!1,tc:!1,tr:!1,cl:!1,cr:!1,bl:!1,bc:!1,br:!1},p={...d,bc:!0},u={...d,tc:!0},h="shape",f="flip-y",m="flip-x",g="Shape Divider",b=`<svg viewBox="0 0 22 22">
|
|
769
769
|
<path fill="currentColor" d="M2 2v18h18V2H2zm0-2h18a2 2 0 012 2v18a2 2 0 01-2 2H2a2 2 0 01-2-2V2C0 .9.9 0 2 0zM1 13L2 0h18l1 9-20 4z"/>
|
|
770
|
-
</svg>`,{block:C={}}=e;n.on(
|
|
770
|
+
</svg>`,{block:C={}}=e;n.on(s.events.add,y=>{y.getFullName().startsWith(`.${l}`)&&y.set({private:!0})}),t.addType(i,{isComponent:y=>Fe(i)(y)||gt(y,l),block:C&&{label:g,media:b,category:"Extra",select:!0,...C},model:{defaults:{droppable:!1,highlightable:!1,classes:l,attributes:{[Re]:i},components:{type:r},styles:`.${l} { position: relative; }`,delegate:{select:y=>y.findFirstType(r),layer:y=>y.findFirstType(r)}}},view:{onRender(){this.el.style.height="1px"}}}),t.addType(r,{isComponent:Fe(r),model:{defaults:{droppable:!1,highlightable:!1,classes:a,emptyState:!0,icon:b,name:g,delegate:{remove:y=>y.parent(),move:y=>y.parent(),copy:y=>y.parent()},attributes:{[Re]:r},[h]:c[0].id,resizable:p,stylable:["height","width","color"],styles:`
|
|
771
771
|
.${a} {
|
|
772
772
|
position: absolute;
|
|
773
773
|
width: 100%;
|
|
@@ -801,7 +801,7 @@
|
|
|
801
801
|
.${a}-inv > path {
|
|
802
802
|
transform: scale(-1, -1) translate(-100%, -100%);
|
|
803
803
|
}
|
|
804
|
-
`,traits:[{type:"select",name:h,label:"Shape",changeProp:!0,options:c.map(({id:y,label:v,value:w})=>({id:y,label:v,icon:{icon:w.replace("<svg ",'<svg style="width: 35px; height: 7px; fill: currentColor;"')}}))},{type:"checkbox",name:f,label:"Flip vertically",changeProp:!0},{type:"checkbox",name:m,label:"flip horizontally",changeProp:!0}]},init(){this.on(`change:${h}`,this.onShapeChange),this.on(`change:${m} change:${f}`,this.onFlip),this.onShapeChange()},onShapeChange(){const y=this.get(h),v=c.find(S=>S.id===y),w=(v==null?void 0:v.value)||this.getInnerHTML().trim();this.components(""),w&&this.set("content",w)},onFlip(){const y=this.get(f),v=this.get(m),w=["fl-v","fl-h","fl-v-h"].map(x=>`${a}--${x}`);let S;y&&v?S=w[2]:v?S=w[1]:y&&(S=w[0]),this.removeClass(w),S&&this.addClass(S),this.set("resizable",y?u:p)}}}),
|
|
804
|
+
`,traits:[{type:"select",name:h,label:"Shape",changeProp:!0,options:c.map(({id:y,label:v,value:w})=>({id:y,label:v,icon:{icon:w.replace("<svg ",'<svg style="width: 35px; height: 7px; fill: currentColor;"')}}))},{type:"checkbox",name:f,label:"Flip vertically",changeProp:!0},{type:"checkbox",name:m,label:"flip horizontally",changeProp:!0}]},init(){this.on(`change:${h}`,this.onShapeChange),this.on(`change:${m} change:${f}`,this.onFlip),this.onShapeChange()},onShapeChange(){const y=this.get(h),v=c.find(S=>S.id===y),w=(v==null?void 0:v.value)||this.getInnerHTML().trim();this.components(""),w&&this.set("content",w)},onFlip(){const y=this.get(f),v=this.get(m),w=["fl-v","fl-h","fl-v-h"].map(x=>`${a}--${x}`);let S;y&&v?S=w[2]:v?S=w[1]:y&&(S=w[0]),this.removeClass(w),S&&this.addClass(S),this.set("resizable",y?u:p)}}}),G({editor:n,licenseKey:e.licenseKey,plan:rf,pluginName:sf,cleanup:()=>{t.removeType(i),o.remove(i)}})},af=_(lf),cf=n=>n.dispatchEvent(new CustomEvent("input")),df=(n,e)=>{if(!e)return()=>{};const t="keydown",o=i=>{var r;i.key==="Escape"&&((r=n.getEditing())==null||r.trigger("disable"))},s=()=>document.removeEventListener(t,o);return n.onReady(()=>{document.addEventListener(t,o),n.on(n.events.destroy,s)}),s};function fc(n,e){if(!e)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,p={})=>{d.trigger("focus",p.event)},a=(d,p)=>{o(d)&&s(d)&&!r(d)&&l(d,p)},c=(d,p)=>{if(o(d)&&!s(d)&&i(d)){const u=d.parents().find(h=>h.isInstanceOf("text"));u&&(l(u,p),setTimeout(()=>n.select(u),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const pf="rteTinyMce",uf=H.startup,hf=`
|
|
805
805
|
.tox .tox-toolbar,
|
|
806
806
|
.tox .tox-toolbar__overflow,
|
|
807
807
|
.tox .tox-toolbar__primary,
|
|
@@ -904,27 +904,27 @@
|
|
|
904
904
|
background-color: var(--gs-theme-cl-prm-bg1);
|
|
905
905
|
border-color: var(--gs-theme-cl-prm-bg3);
|
|
906
906
|
opacity: 0.75;
|
|
907
|
-
}`,Qi=new WeakMap,ff=(n,e)=>{Qi.set(n,e)},mf=n=>{Qi.delete(n)},Mo=n=>Qi.get(n),Ss=n=>{const e=n.target,t=e.closest(".tox"),s=e.matches(".ephox-snooker-resizer-bar");(t||s)&&n.stopPropagation()},Qr=n=>{n.stopPropagation(),n.preventDefault()},gf=(n,e)=>{const t=n.getDoc(),s=n.getWin();if(e!=null&&e.event){const{event:o}=e,{clientX:i,clientY:r}=o;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=s.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(l),n.selection.setRng(l)}}else n.execCommand("SelectAll")},yf=n=>{var c,d;const{el:e,editor:t,componentView:s}=n,o=t.runCommand(W.getStateTheme),i=s.model,r={target:e,inline:!0,skin:(o==null?void 0:o.theme)===La.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:s,component:i}))||{};return{...r,...l}},el=(n,e=document)=>new Promise((t,s)=>{const o=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=s,i.appendChild(a)}else t()};r(o)}),bf=function(n,e={}){const t={cdnScript:"https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",...e},{cdnScript:s}=t,o=n.Canvas.events,i=!t.skipCustomTheme,r="gs-plg-tinymce-studio-theme",l=async(d,p)=>{const u=d.ownerDocument,h=u.defaultView,f=p==null?void 0:p.view;if(!h||!f){console.warn("Missing required data",{win:h,componentView:f});return}const m=yf({el:d,editor:n,componentView:f,pluginOpts:t}),b=(await h.tinymce.init(m))[0];if(!b)return;const y=(await window.tinymce.init({...m,target:document.createElement("div")}))[0];return b.ui.show(),u.body.addEventListener("mousedown",Ss),document.body.addEventListener("mousedown",Ss),b.on("Change",()=>cf(d)),b.on("blur",()=>b.ui.show()),b.on("OpenWindow",function(){var S;const v=(S=u.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&&u.body.appendChild(v)}))}),d.addEventListener("dragstart",Qr,{capture:!0}),n.runCommand(W.setStateContextMenu,{enabled:!1}),gf(b,p),{rteEditor:b,rteEditorShallow:y}},a=(d,p)=>{d.ownerDocument.body.removeEventListener("mousedown",Ss),document.body.removeEventListener("mousedown",Ss),d.removeEventListener("dragstart",Qr,{capture:!0}),n.runCommand(W.setStateContextMenu,{enabled:!0}),p.rteEditor.destroy(),p.rteEditorShallow.destroy()};n.on(o.frameLoad,async({window:d})=>{const p=d.document;el(s,p)}),n.onReady(()=>{el(s,document),i&&Ui(r,hf,{target:document.body})}),n.setCustomRte({parseContent:!0,async enable(d,p,u){const h=Mo(d);if(h)return h.rteEditor;const f=await l(d,u);return f&&ff(d,f),f==null?void 0:f.rteEditor},disable(d){const p=Mo(d);p&&(mf(d),a(d,p))},getContent(d,p,u){var m;const h=Mo(d),f=h==null?void 0:h.rteEditor;return f&&!f.isDirty()?u.view.lastContent:f?(m=f.getContent)==null?void 0:m.call(f):d.innerHTML}});const c=fc(n,t.enableOnClick);_({editor:n,licenseKey:t.licenseKey,plan:uf,pluginName:pf,cleanup:()=>{n.RichTextEditor.customRte=void 0,c()}})},vf=F(bf);function Y(n){this.content=n}Y.prototype={constructor:Y,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 s=t&&t!=n?this.remove(t):this,o=s.find(n),i=s.content.slice();return o==-1?i.push(t||n,e):(i[o+1]=e,t&&(i[o]=t)),new Y(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 Y(t)},addToStart:function(n,e){return new Y([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Y(t)},addBefore:function(n,e,t){var s=this.remove(e),o=s.content.slice(),i=s.find(n);return o.splice(i==-1?o.length:i,0,e,t),new Y(o)},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=Y.from(n),n.size?new Y(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Y.from(n),n.size?new Y(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Y.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}};Y.from=function(n){if(n instanceof Y)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Y(e)};function mc(n,e,t){for(let s=0;;s++){if(s==n.childCount||s==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(s),i=e.child(s);if(o==i){t+=o.nodeSize;continue}if(!o.sameMarkup(i))return t;if(o.isText&&o.text!=i.text){for(let r=0;o.text[r]==i.text[r];r++)t++;return t}if(o.content.size||i.content.size){let r=mc(o.content,i.content,t+1);if(r!=null)return r}t+=o.nodeSize}}function gc(n,e,t,s){for(let o=n.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:t,b:s};let r=n.child(--o),l=e.child(--i),a=r.nodeSize;if(r==l){t-=a,s-=a;continue}if(!r.sameMarkup(l))return{a:t,b:s};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--,s--;return{a:t,b:s}}if(r.content.size||l.content.size){let c=gc(r.content,l.content,t-1,s-1);if(c)return c}t-=a,s-=a}}class T{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let s=0;s<e.length;s++)this.size+=e[s].nodeSize}nodesBetween(e,t,s,o=0,i){for(let r=0,l=0;l<t;r++){let a=this.content[r],c=l+a.nodeSize;if(c>e&&s(a,o+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),s,o+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,s,o){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?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&s&&(r?r=!1:i+=s),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,s=e.firstChild,o=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(s)&&(o[o.length-1]=t.withText(t.text+s.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new T(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let s=[],o=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))),s.push(l),o+=l.nodeSize),r=a}return new T(s,o)}cutByIndex(e,t){return e==t?T.empty:e==0&&t==this.content.length?this:new T(this.content.slice(e,t))}replaceChild(e,t){let s=this.content[e];if(s==t)return this;let o=this.content.slice(),i=this.size+t.nodeSize-s.nodeSize;return o[e]=t,new T(o,i)}addToStart(e){return new T([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new T(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,s=0;t<this.content.length;t++){let o=this.content[t];e(o,s,t),s+=o.nodeSize}}findDiffStart(e,t=0){return mc(this,e,t)}findDiffEnd(e,t=this.size,s=e.size){return gc(this,e,t,s)}findIndex(e,t=-1){if(e==0)return xs(0,e);if(e==this.size)return xs(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let s=0,o=0;;s++){let i=this.child(s),r=o+i.nodeSize;if(r>=e)return r==e||t>0?xs(s+1,r):xs(s,o);o=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 T.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new T(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return T.empty;let t,s=0;for(let o=0;o<e.length;o++){let i=e[o];s+=i.nodeSize,o&&i.isText&&e[o-1].sameMarkup(i)?(t||(t=e.slice(0,o)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new T(t||e,s)}static from(e){if(!e)return T.empty;if(e instanceof T)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new T([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}T.empty=new T([],0);const Ao={index:0,offset:0};function xs(n,e){return Ao.index=n,Ao.offset=e,Ao}function js(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 s=0;s<n.length;s++)if(!js(n[s],e[s]))return!1}else{for(let s in n)if(!(s in e)||!js(n[s],e[s]))return!1;for(let s in e)if(!(s in n))return!1}return!0}class B{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,s=!1;for(let o=0;o<e.length;o++){let i=e[o];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,o));else{if(i.type.excludes(this.type))return e;!s&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),s=!0),t&&t.push(i)}}return t||(t=e.slice()),s||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&&js(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 s=e.marks[t.type];if(!s)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=s.create(t.attrs);return s.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let s=0;s<e.length;s++)if(!e[s].eq(t[s]))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((s,o)=>s.type.rank-o.type.rank),t}}B.none=[];class qs extends Error{}class A{constructor(e,t,s){this.content=e,this.openStart=t,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let s=bc(this.content,e+this.openStart,t);return s&&new A(s,this.openStart,this.openEnd)}removeBetween(e,t){return new A(yc(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 s=t.openStart||0,o=t.openEnd||0;if(typeof s!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new A(T.fromJSON(e,t.content),s,o)}static maxOpen(e,t=!0){let s=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)s++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)o++;return new A(e,s,o)}}A.empty=new A(T.empty,0,0);function yc(n,e,t){let{index:s,offset:o}=n.findIndex(e),i=n.maybeChild(s),{index:r,offset:l}=n.findIndex(t);if(o==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(s!=r)throw new RangeError("Removing non-flat range");return n.replaceChild(s,i.copy(yc(i.content,e-o-1,t-o-1)))}function bc(n,e,t,s){let{index:o,offset:i}=n.findIndex(e),r=n.maybeChild(o);if(i==e||r.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=bc(r.content,e-i-1,t);return l&&n.replaceChild(o,r.copy(l))}function Sf(n,e,t){if(t.openStart>n.depth)throw new qs("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new qs("Inconsistent open depths");return vc(n,e,t,0)}function vc(n,e,t,s){let o=n.index(s),i=n.node(s);if(o==e.index(s)&&s<n.depth-t.openStart){let r=vc(n,e,t,s+1);return i.copy(i.content.replaceChild(o,r))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==s&&e.depth==s){let r=n.parent,l=r.content;return Ot(r,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:r,end:l}=xf(t,n);return Ot(i,xc(n,r,l,e,s))}else return Ot(i,Us(n,e,s))}function Sc(n,e){if(!e.type.compatibleContent(n.type))throw new qs("Cannot join "+e.type.name+" onto "+n.type.name)}function gi(n,e,t){let s=n.node(t);return Sc(s,e.node(t)),s}function It(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function zn(n,e,t,s){let o=(e||n).node(t),i=0,r=e?e.index(t):o.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(It(n.nodeAfter,s),i++));for(let l=i;l<r;l++)It(o.child(l),s);e&&e.depth==t&&e.textOffset&&It(e.nodeBefore,s)}function Ot(n,e){return n.type.checkContent(e),n.copy(e)}function xc(n,e,t,s,o){let i=n.depth>o&&gi(n,e,o+1),r=s.depth>o&&gi(t,s,o+1),l=[];return zn(null,n,o,l),i&&r&&e.index(o)==t.index(o)?(Sc(i,r),It(Ot(i,xc(n,e,t,s,o+1)),l)):(i&&It(Ot(i,Us(n,e,o+1)),l),zn(e,t,o,l),r&&It(Ot(r,Us(t,s,o+1)),l)),zn(s,null,o,l),new T(l)}function Us(n,e,t){let s=[];if(zn(null,n,t,s),n.depth>t){let o=gi(n,e,t+1);It(Ot(o,Us(n,e,t+1)),s)}return zn(e,null,t,s),new T(s)}function xf(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)o=e.node(i).copy(T.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}class Jn{constructor(e,t,s){this.pos=e,this.path=t,this.parentOffset=s,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 s=this.pos-this.path[this.path.length-1],o=e.child(t);return s?e.child(t).cut(s):o}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 s=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)o+=s.child(i).nodeSize;return o}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 s=e.maybeChild(t-1),o=e.maybeChild(t);if(!s){let l=s;s=o,o=l}let i=s.marks;for(var r=0;r<i.length;r++)i[r].type.spec.inclusive===!1&&(!o||!i[r].isInSet(o.marks))&&(i=i[r--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let s=t.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<s.length;i++)s[i].type.spec.inclusive===!1&&(!o||!s[i].isInSet(o.marks))&&(s=s[i--].removeFromSet(s));return s}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 s=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);s>=0;s--)if(e.pos<=this.end(s)&&(!t||t(this.node(s))))return new Ks(this,e,s);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 s=[],o=0,i=t;for(let r=e;;){let{index:l,offset:a}=r.content.findIndex(i),c=i-a;if(s.push(r,l,o+a),!c||(r=r.child(l),r.isText))break;i=c-1,o+=a+1}return new Jn(t,s,i)}static resolveCached(e,t){let s=tl.get(e);if(s)for(let i=0;i<s.elts.length;i++){let r=s.elts[i];if(r.pos==t)return r}else tl.set(e,s=new wf);let o=s.elts[s.i]=Jn.resolve(e,t);return s.i=(s.i+1)%Cf,o}}class wf{constructor(){this.elts=[],this.i=0}}const Cf=12,tl=new WeakMap;class Ks{constructor(e,t,s){this.$from=e,this.$to=t,this.depth=s}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 kf=Object.create(null);let Rt=class yi{constructor(e,t,s,o=B.none){this.type=e,this.attrs=t,this.marks=o,this.content=s||T.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,s,o=0){this.content.nodesBetween(e,t,s,o,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,s,o){return this.content.textBetween(e,t,s,o)}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,s){return this.type==e&&js(this.attrs,t||e.defaultAttrs||kf)&&B.sameSet(this.marks,s||B.none)}copy(e=null){return e==this.content?this:new yi(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new yi(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,s=!1){if(e==t)return A.empty;let o=this.resolve(e),i=this.resolve(t),r=s?0:o.sharedDepth(t),l=o.start(r),c=o.node(r).content.cut(o.pos-l,i.pos-l);return new A(c,o.depth-r,i.depth-r)}replace(e,t,s){return Sf(this.resolve(e),this.resolve(t),s)}nodeAt(e){for(let t=this;;){let{index:s,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(s),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:s}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:s}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:s}=this.content.findIndex(e);if(s<e)return{node:this.content.child(t),index:t,offset:s};let o=this.content.child(t-1);return{node:o,index:t-1,offset:s-o.nodeSize}}resolve(e){return Jn.resolveCached(this,e)}resolveNoCache(e){return Jn.resolve(this,e)}rangeHasMark(e,t,s){let o=!1;return t>e&&this.nodesBetween(e,t,i=>(s.isInSet(i.marks)&&(o=!0),!o)),o}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()+")"),wc(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,s=T.empty,o=0,i=s.childCount){let r=this.contentMatchAt(e).matchFragment(s,o,i),l=r&&r.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(s.child(a).marks))return!1;return!0}canReplaceWith(e,t,s,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(s),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 s=this.marks[t];s.type.checkAttrs(s.attrs),e=s.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 s;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");s=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,s)}let o=T.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,o,s);return i.type.checkAttrs(i.attrs),i}};Rt.prototype.text=void 0;class Js extends Rt{constructor(e,t,s,o){if(super(e,t,null,o),!s)throw new RangeError("Empty text nodes are not allowed");this.text=s}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):wc(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 Js(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Js(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 wc(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Vt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let s=new Ef(e,t);if(s.next==null)return Vt.empty;let o=Cc(s);s.next&&s.err("Unexpected trailing text");let i=Of(If(o));return Rf(i,s),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,s=e.childCount){let o=this;for(let i=t;o&&i<s;i++)o=o.matchType(e.child(i).type);return o}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 s=0;s<e.next.length;s++)if(this.next[t].type==e.next[s].type)return!0;return!1}fillBefore(e,t=!1,s=0){let o=[this];function i(r,l){let a=r.matchFragment(e,s);if(a&&(!t||a.validEnd))return T.from(l.map(c=>c.createAndFill()));for(let c=0;c<r.next.length;c++){let{type:d,next:p}=r.next[c];if(!(d.isText||d.hasRequiredAttrs())&&o.indexOf(p)==-1){o.push(p);let u=i(p,l.concat(d));if(u)return u}}return null}return i(this,[])}findWrapping(e){for(let s=0;s<this.wrapCache.length;s+=2)if(this.wrapCache[s]==e)return this.wrapCache[s+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),s=[{match:this,type:null,via:null}];for(;s.length;){let o=s.shift(),i=o.match;if(i.matchType(e)){let r=[];for(let l=o;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)&&(!o.type||a.validEnd)&&(s.push({match:l.contentMatch,type:l,via:o}),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(s){e.push(s);for(let o=0;o<s.next.length;o++)e.indexOf(s.next[o].next)==-1&&t(s.next[o].next)}return t(this),e.map((s,o)=>{let i=o+(s.validEnd?"*":" ")+" ";for(let r=0;r<s.next.length;r++)i+=(r?", ":"")+s.next[r].type.name+"->"+e.indexOf(s.next[r].next);return i}).join(`
|
|
908
|
-
`)}}Vt.empty=new Vt(!0);class Ef{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 Cc(n){let e=[];do e.push(Tf(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Tf(n){let e=[];do e.push(Mf(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Mf(n){let e=Nf(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=Af(n,e);else break;return e}function nl(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Af(n,e){let t=nl(n),s=t;return n.eat(",")&&(n.next!="}"?s=nl(n):s=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:s,expr:e}}function Pf(n,e){let t=n.nodeTypes,s=t[e];if(s)return[s];let o=[];for(let i in t){let r=t[i];r.isInGroup(e)&&o.push(r)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function Nf(n){if(n.eat("(")){let e=Cc(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=Pf(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 If(n){let e=[[]];return o(i(n,0),t()),e;function t(){return e.push([])-1}function s(r,l,a){let c={term:a,to:l};return e[r].push(c),c}function o(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;o(c,l=t())}else if(r.type=="star"){let a=t();return s(l,a),o(i(r.expr,a),a),[s(a)]}else if(r.type=="plus"){let a=t();return o(i(r.expr,l),a),o(i(r.expr,a),a),[s(a)]}else{if(r.type=="opt")return[s(l)].concat(i(r.expr,l));if(r.type=="range"){let a=l;for(let c=0;c<r.min;c++){let d=t();o(i(r.expr,a),d),a=d}if(r.max==-1)o(i(r.expr,a),a);else for(let c=r.min;c<r.max;c++){let d=t();s(a,d),o(i(r.expr,a),d),a=d}return[s(a)]}else{if(r.type=="name")return[s(l,void 0,r.value)];throw new Error("Unknown expr type")}}}}function kc(n,e){return e-n}function sl(n,e){let t=[];return s(e),t.sort(kc);function s(o){let i=n[o];if(i.length==1&&!i[0].term)return s(i[0].to);t.push(o);for(let r=0;r<i.length;r++){let{term:l,to:a}=i[r];!l&&t.indexOf(a)==-1&&s(a)}}}function Of(n){let e=Object.create(null);return t(sl(n,0));function t(s){let o=[];s.forEach(r=>{n[r].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<o.length;d++)o[d][0]==l&&(c=o[d][1]);sl(n,a).forEach(d=>{c||o.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[s.join(",")]=new Vt(s.indexOf(n.length-1)>-1);for(let r=0;r<o.length;r++){let l=o[r][1].sort(kc);i.next.push({type:o[r][0],next:e[l.join(",")]||t(l)})}return i}}function Rf(n,e){for(let t=0,s=[n];t<s.length;t++){let o=s[t],i=!o.validEnd,r=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];r.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),s.indexOf(c)==-1&&s.push(c)}i&&e.err("Only non-generatable nodes ("+r.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ec(n){let e=Object.create(null);for(let t in n){let s=n[t];if(!s.hasDefault)return null;e[t]=s.default}return e}function Tc(n,e){let t=Object.create(null);for(let s in n){let o=e&&e[s];if(o===void 0){let i=n[s];if(i.hasDefault)o=i.default;else throw new RangeError("No value supplied for attribute "+s)}t[s]=o}return t}function Mc(n,e,t,s){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${o}`);for(let o in n){let i=n[o];i.validate&&i.validate(e[o])}}function Ac(n,e){let t=Object.create(null);if(e)for(let s in e)t[s]=new Lf(n,s,e[s]);return t}let ol=class Pc{constructor(e,t,s){this.name=e,this.schema=t,this.spec=s,this.markSet=null,this.groups=s.group?s.group.split(" "):[],this.attrs=Ac(e,s.attrs),this.defaultAttrs=Ec(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(s.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Vt.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:Tc(this.attrs,e)}create(e=null,t,s){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Rt(this,this.computeAttrs(e),T.from(t),B.setFrom(s))}createChecked(e=null,t,s){return t=T.from(t),this.checkContent(t),new Rt(this,this.computeAttrs(e),t,B.setFrom(s))}createAndFill(e=null,t,s){if(e=this.computeAttrs(e),t=T.from(t),t.size){let r=this.contentMatch.fillBefore(t);if(!r)return null;t=r.append(t)}let o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(T.empty,!0);return i?new Rt(this,e,t.append(i),B.setFrom(s)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let s=0;s<e.childCount;s++)if(!this.allowsMarks(e.child(s).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){Mc(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 s=0;s<e.length;s++)this.allowsMarkType(e[s].type)?t&&t.push(e[s]):t||(t=e.slice(0,s));return t?t.length?t:B.none:e}static compile(e,t){let s=Object.create(null);e.forEach((i,r)=>s[i]=new Pc(i,t,r));let o=t.spec.topNode||"doc";if(!s[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!s.text)throw new RangeError("Every schema needs a 'text' type");for(let i in s.text.attrs)throw new RangeError("The text node type should not have attributes");return s}};function Df(n,e,t){let s=t.split("|");return o=>{let i=o===null?"null":typeof o;if(s.indexOf(i)<0)throw new RangeError(`Expected value of type ${s} for attribute ${e} on type ${n}, got ${i}`)}}class Lf{constructor(e,t,s){this.hasDefault=Object.prototype.hasOwnProperty.call(s,"default"),this.default=s.default,this.validate=typeof s.validate=="string"?Df(e,t,s.validate):s.validate}get isRequired(){return!this.hasDefault}}class fo{constructor(e,t,s,o){this.name=e,this.rank=t,this.schema=s,this.spec=o,this.attrs=Ac(e,o.attrs),this.excluded=null;let i=Ec(this.attrs);this.instance=i?new B(this,i):null}create(e=null){return!e&&this.instance?this.instance:new B(this,Tc(this.attrs,e))}static compile(e,t){let s=Object.create(null),o=0;return e.forEach((i,r)=>s[i]=new fo(i,o++,t,r)),s}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){Mc(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class $f{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=Y.from(e.nodes),t.marks=Y.from(e.marks||{}),this.nodes=ol.compile(this.spec.nodes,this),this.marks=fo.compile(this.spec.marks,this);let s=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],r=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=s[r]||(s[r]=Vt.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?il(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],r=i.spec.excludes;i.excluded=r==null?[i]:r==""?[]:il(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,s,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof ol){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,s,o)}text(e,t){let s=this.nodes.text;return new Js(s,s.defaultAttrs,e,B.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Rt.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 il(n,e){let t=[];for(let s=0;s<e.length;s++){let o=e[s],i=n.marks[o],r=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&t.push(r=a)}if(!r)throw new SyntaxError("Unknown mark type: '"+e[s]+"'")}return t}function zf(n){return n.tag!=null}function Vf(n){return n.style!=null}class Bt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let s=this.matchedStyles=[];t.forEach(o=>{if(zf(o))this.tags.push(o);else if(Vf(o)){let i=/[^=]*/.exec(o.style)[0];s.indexOf(i)<0&&s.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let s=new ll(this,t,!1);return s.addAll(e,B.none,t.from,t.to),s.finish()}parseSlice(e,t={}){let s=new ll(this,t,!0);return s.addAll(e,B.none,t.from,t.to),A.maxOpen(s.finish())}matchTag(e,t,s){for(let o=s?this.tags.indexOf(s)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(Ff(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,s,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let r=this.styles[i],l=r.style;if(!(l.indexOf(e)!=0||r.context&&!s.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 s(o){let i=o.priority==null?50:o.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,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(r=>{s(r=al(r)),r.mark||r.ignore||r.clearMark||(r.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(r=>{s(r=al(r)),r.node||r.ignore||r.mark||(r.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Bt(e,Bt.schemaRules(e)))}}const Nc={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},Bf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ic={ol:!0,ul:!0},Zs=1,Ys=2,Vn=4;function rl(n,e,t){return e!=null?(e?Zs:0)|(e==="full"?Ys:0):n&&n.whitespace=="pre"?Zs|Ys:t&~Vn}class ws{constructor(e,t,s,o,i,r){this.type=e,this.attrs=t,this.marks=s,this.solid=o,this.options=r,this.content=[],this.activeMarks=B.none,this.match=i||(r&Vn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(T.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let s=this.type.contentMatch,o;return(o=s.findWrapping(e.type))?(this.match=s,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Zs)){let s=this.content[this.content.length-1],o;if(s&&s.isText&&(o=/[ \t\r\n\u000c]+$/.exec(s.text))){let i=s;s.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let t=T.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(T.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&&!Nc.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ll{constructor(e,t,s){this.parser=e,this.options=t,this.isOpen=s,this.open=0;let o=t.topNode,i,r=rl(null,t.preserveWhitespace,0)|(s?Vn:0);o?i=new ws(o.type,o.attrs,B.none,!0,t.topMatch||o.type.contentMatch,r):s?i=new ws(null,null,B.none,!0,null,r):i=new ws(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 s=e.nodeValue,o=this.top;if(o.options&Ys||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(s)){if(o.options&Zs)o.options&Ys?s=s.replace(/\r\n?/g,`
|
|
909
|
-
`):
|
|
910
|
-
`),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 s=e.style;if(s&&s.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],r=s.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,s,o){let i,r;if(t.node)if(r=this.parser.schema.nodes[t.node],r.isLeaf)this.insertNode(r.create(t.attrs),s)||this.leafFallback(e,s);else{let a=this.enter(r,t.attrs||null,s,t.preserveWhitespace);a&&(i=!0,s=a)}else{let a=this.parser.schema.marks[t.mark];s=s.concat(a.create(t.attrs))}let l=this.top;if(r&&r.isLeaf)this.findInside(e);else if(o)this.addElement(e,s,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,s));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,s),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,s,o){let i=s||0;for(let r=s?e.childNodes[s]:e.firstChild,l=o==null?null:e.childNodes[o];r!=l;r=r.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(r,t);this.findAtPoint(e,i)}findPlace(e,t){let s,o;for(let i=this.open;i>=0;i--){let r=this.nodes[i],l=r.findWrapping(e);if(l&&(!s||s.length>l.length)&&(s=l,o=r,!l.length)||r.solid)break}if(!s)return null;this.sync(o);for(let i=0;i<s.length;i++)t=this.enterInner(s[i],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let s=this.findPlace(e,t);if(s){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let i=B.none;for(let r of s.concat(e.marks))(o.type?o.type.allowsMarkType(r.type):cl(r.type,e.type))&&(i=r.addToSet(i));return o.content.push(e.mark(i)),!0}return!1}enter(e,t,s,o){let i=this.findPlace(e.create(t),s);return i&&(i=this.enterInner(e,t,s,!0,o)),i}enterInner(e,t,s,o=!1,i){this.closeExtra();let r=this.top;r.match=r.match&&r.match.matchType(e);let l=rl(e,i,r.options);r.options&Vn&&r.content.length==0&&(l|=Vn);let a=B.none;return s=s.filter(c=>(r.type?r.type.allowsMarkType(c.type):cl(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new ws(e,t,a,o,null,l)),this.open++,s}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 s=this.nodes[t].content;for(let o=s.length-1;o>=0;o--)e+=s[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let s=0;s<this.find.length;s++)this.find[s].node==e&&this.find[s].offset==t&&(this.find[s].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,s){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(s?2:4)&&(this.find[o].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("/"),s=this.options.context,o=!this.isOpen&&(!s||s.parent.type==this.nodes[0].type),i=-(s?s.depth+1:0)+(o?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&&o?this.nodes[a].type:s&&a>=i?s.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 s=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(s&&s.isTextblock&&s.defaultAttrs)return s}for(let t in this.parser.schema.nodes){let s=this.parser.schema.nodes[t];if(s.isTextblock&&s.defaultAttrs)return s}}}function Hf(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let s=e.nodeType==1?e.nodeName.toLowerCase():null;s&&Ic.hasOwnProperty(s)&&t?(t.appendChild(e),e=t):s=="li"?t=e:s&&(t=null)}}function Ff(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function al(n){let e={};for(let t in n)e[t]=n[t];return e}function cl(n,e){let t=e.schema.nodes;for(let s in t){let o=t[s];if(!o.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(o.contentMatch))return!0}}class Wt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},s){s||(s=Po(t).createDocumentFragment());let o=s,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;)o=i.pop()[1];for(;a<r.marks.length;){let c=r.marks[a++],d=this.serializeMark(c,r.isInline,t);d&&(i.push([c,o]),o.appendChild(d.dom),o=d.contentDOM||d.dom)}}o.appendChild(this.serializeNodeInner(r,t))}),s}serializeNodeInner(e,t){let{dom:s,contentDOM:o}=Os(Po(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return s}serializeNode(e,t={}){let s=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(s),s=i.dom)}return s}serializeMark(e,t,s={}){let o=this.marks[e.type.name];return o&&Os(Po(s),o(e,t),null,e.attrs)}static renderSpec(e,t,s=null,o){return Os(e,t,s,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Wt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=dl(e.nodes);return t.text||(t.text=s=>s.text),t}static marksFromSchema(e){return dl(e.marks)}}function dl(n){let e={};for(let t in n){let s=n[t].spec.toDOM;s&&(e[t]=s)}return e}function Po(n){return n.document||window.document}const pl=new WeakMap;function _f(n){let e=pl.get(n);return e===void 0&&pl.set(n,e=Gf(n)),e}function Gf(n){let e=null;function t(s){if(s&&typeof s=="object")if(Array.isArray(s))if(typeof s[0]=="string")e||(e=[]),e.push(s);else for(let o=0;o<s.length;o++)t(s[o]);else for(let o in s)t(s[o])}return t(n),e}function Os(n,e,t,s){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 o=e[0],i;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(s&&(i=_f(s))&&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=o.indexOf(" ");r>0&&(t=o.slice(0,r),o=o.slice(r+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let p in c)if(c[p]!=null){let u=p.indexOf(" ");u>0?a.setAttributeNS(p.slice(0,u),p.slice(u+1),c[p]):a.setAttribute(p,c[p])}}for(let p=d;p<e.length;p++){let u=e[p];if(u===0){if(p<e.length-1||p>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}=Os(n,u,t,s);if(a.appendChild(h),f){if(l)throw new RangeError("Multiple content holes");l=f}}}return{dom:a,contentDOM:l}}const Oc=65535,Rc=Math.pow(2,16);function Wf(n,e){return n+e*Rc}function ul(n){return n&Oc}function jf(n){return(n-(n&Oc))/Rc}const Dc=1,Lc=2,Rs=4,$c=8;class bi{constructor(e,t,s){this.pos=e,this.delInfo=t,this.recover=s}get deleted(){return(this.delInfo&$c)>0}get deletedBefore(){return(this.delInfo&(Dc|Rs))>0}get deletedAfter(){return(this.delInfo&(Lc|Rs))>0}get deletedAcross(){return(this.delInfo&Rs)>0}}class be{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&be.empty)return be.empty}recover(e){let t=0,s=ul(e);if(!this.inverted)for(let o=0;o<s;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[s*3]+t+jf(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,s){let o=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?o:0);if(a>e)break;let c=this.ranges[l+i],d=this.ranges[l+r],p=a+c;if(e<=p){let u=c?e==a?-1:e==p?1:t:t,h=a+o+(u<0?0:d);if(s)return h;let f=e==(t<0?a:p)?null:Wf(l/3,e-a),m=e==a?Lc:e==p?Dc:Rs;return(t<0?e!=a:e!=p)&&(m|=$c),new bi(h,m,f)}o+=d-c}return s?e+o:new bi(e+o,0,null)}touches(e,t){let s=0,o=ul(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?s:0);if(a>e)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==o*3)return!0;s+=this.ranges[l+r]-c}return!1}forEach(e){let t=this.inverted?2:1,s=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let r=this.ranges[o],l=r-(this.inverted?i:0),a=r+(this.inverted?0:i),c=this.ranges[o+t],d=this.ranges[o+s];e(l,l+c,a,a+d),i+=d-c}}invert(){return new be(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?be.empty:new be(e<0?[0,-e,0]:[0,0,e])}}be.empty=new be([]);class cn{constructor(e=[],t,s=0,o=e.length){this.maps=e,this.mirror=t,this.from=s,this.to=o}slice(e=0,t=this.maps.length){return new cn(this.maps,this.mirror,e,t)}copy(){return new cn(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,s=this.maps.length;t<e.maps.length;t++){let o=e.getMirror(t);this.appendMap(e.maps[t],o!=null&&o<t?s+o: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,s=this.maps.length+e.maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e.maps[t].invert(),o!=null&&o>t?s-o-1:void 0)}}invert(){let e=new cn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let s=this.from;s<this.to;s++)e=this.maps[s].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,s){let o=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}}o|=l.delInfo,e=l.pos}return s?e:new bi(e,o,null)}}const No=Object.create(null);class oe{getMap(){return be.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let s=No[t.stepType];if(!s)throw new RangeError(`No step type ${t.stepType} defined`);return s.fromJSON(e,t)}static jsonID(e,t){if(e in No)throw new RangeError("Duplicate use of step JSON ID "+e);return No[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,s,o){try{return K.ok(e.replace(t,s,o))}catch(i){if(i instanceof qs)return K.fail(i.message);throw i}}}function er(n,e,t){let s=[];for(let o=0;o<n.childCount;o++){let i=n.child(o);i.content.size&&(i=i.copy(er(i.content,e,i))),i.isInline&&(i=e(i,t,o)),s.push(i)}return T.fromArray(s)}class ct extends oe{constructor(e,t,s){super(),this.from=e,this.to=t,this.mark=s}apply(e){let t=e.slice(this.from,this.to),s=e.resolve(this.from),o=s.node(s.sharedDepth(this.to)),i=new A(er(t.content,(r,l)=>!r.isAtom||!l.type.allowsMarkType(this.mark.type)?r:r.mark(this.mark.addToSet(r.marks)),o),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,i)}invert(){return new Be(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return t.deleted&&s.deleted||t.pos>=s.pos?null:new ct(t.pos,s.pos,this.mark)}merge(e){return e instanceof ct&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ct(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 ct(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("addMark",ct);class Be extends oe{constructor(e,t,s){super(),this.from=e,this.to=t,this.mark=s}apply(e){let t=e.slice(this.from,this.to),s=new A(er(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,s)}invert(){return new ct(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return t.deleted&&s.deleted||t.pos>=s.pos?null:new Be(t.pos,s.pos,this.mark)}merge(e){return e instanceof Be&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Be(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"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 Be(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("removeMark",Be);class dt 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 s=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return K.fromReplace(e,this.pos,this.pos+1,new A(T.from(s),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let s=this.mark.addToSet(t.marks);if(s.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(s))return new dt(this.pos,t.marks[o]);return new dt(this.pos,this.mark)}}return new mn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new dt(t.pos,this.mark)}toJSON(){return{stepType:"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 dt(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("addNodeMark",dt);class mn 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 s=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return K.fromReplace(e,this.pos,this.pos+1,new A(T.from(s),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new dt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new mn(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 mn(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("removeNodeMark",mn);class ne extends oe{constructor(e,t,s,o=!1){super(),this.from=e,this.to=t,this.slice=s,this.structure=o}apply(e){return this.structure&&vi(e,this.from,this.to)?K.fail("Structure replace would overwrite content"):K.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new be([this.from,this.to-this.from,this.slice.size])}invert(e){return new ne(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return t.deletedAcross&&s.deletedAcross?null:new ne(t.pos,Math.max(t.pos,s.pos),this.slice)}merge(e){if(!(e instanceof ne)||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 ne(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 ne(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 ne(t.from,t.to,A.fromJSON(e,t.slice),!!t.structure)}}oe.jsonID("replace",ne);class ee extends oe{constructor(e,t,s,o,i,r,l=!1){super(),this.from=e,this.to=t,this.gapFrom=s,this.gapTo=o,this.slice=i,this.insert=r,this.structure=l}apply(e){if(this.structure&&(vi(e,this.from,this.gapFrom)||vi(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 s=this.slice.insertAt(this.insert,t.content);return s?K.fromReplace(e,this.from,this.to,s):K.fail("Content does not fit in gap")}getMap(){return new be([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 ee(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),s=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?s.pos:e.map(this.gapTo,1);return t.deletedAcross&&s.deletedAcross||o<t.pos||i>s.pos?null:new ee(t.pos,s.pos,o,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 ee(t.from,t.to,t.gapFrom,t.gapTo,A.fromJSON(e,t.slice),t.insert,!!t.structure)}}oe.jsonID("replaceAround",ee);function vi(n,e,t){let s=n.resolve(e),o=t-e,i=s.depth;for(;o>0&&i>0&&s.indexAfter(i)==s.node(i).childCount;)i--,o--;if(o>0){let r=s.node(i).maybeChild(s.indexAfter(i));for(;o>0;){if(!r||r.isLeaf)return!0;r=r.firstChild,o--}}return!1}function qf(n,e,t,s){let o=[],i=[],r,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let p=a.marks;if(!s.isInSet(p)&&d.type.allowsMarkType(s.type)){let u=Math.max(c,e),h=Math.min(c+a.nodeSize,t),f=s.addToSet(p);for(let m=0;m<p.length;m++)p[m].isInSet(f)||(r&&r.to==u&&r.mark.eq(p[m])?r.to=h:o.push(r=new Be(u,h,p[m])));l&&l.to==u?l.to=h:i.push(l=new ct(u,h,s))}}),o.forEach(a=>n.step(a)),i.forEach(a=>n.step(a))}function Uf(n,e,t,s){let o=[],i=0;n.doc.nodesBetween(e,t,(r,l)=>{if(!r.isInline)return;i++;let a=null;if(s instanceof fo){let c=r.marks,d;for(;d=s.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else s?s.isInSet(r.marks)&&(a=[s]):a=r.marks;if(a&&a.length){let c=Math.min(l+r.nodeSize,t);for(let d=0;d<a.length;d++){let p=a[d],u;for(let h=0;h<o.length;h++){let f=o[h];f.step==i-1&&p.eq(o[h].style)&&(u=f)}u?(u.to=c,u.step=i):o.push({style:p,from:Math.max(l,e),to:c,step:i})}}}),o.forEach(r=>n.step(new Be(r.from,r.to,r.style)))}function tr(n,e,t,s=t.contentMatch,o=!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,p=s.matchType(c.type);if(!p)r.push(new ne(l,d,A.empty));else{s=p;for(let u=0;u<c.marks.length;u++)t.allowsMarkType(c.marks[u].type)||n.step(new Be(l,d,c.marks[u]));if(o&&c.isText&&t.whitespace!="pre"){let u,h=/\r?\n|\r/g,f;for(;u=h.exec(c.text);)f||(f=new A(T.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),r.push(new ne(l+u.index,l+u.index+u[0].length,f))}}l=d}if(!s.validEnd){let a=s.fillBefore(T.empty,!0);n.replace(l,l,new A(a,0,0))}for(let a=r.length-1;a>=0;a--)n.step(r[a])}function Kf(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function mo(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let s=n.depth;;--s){let o=n.$from.node(s),i=n.$from.index(s),r=n.$to.indexAfter(s);if(s<n.depth&&o.canReplace(i,r,t))return s;if(s==0||o.type.spec.isolating||!Kf(o,i,r))break}return null}function Jf(n,e,t){let{$from:s,$to:o,depth:i}=e,r=s.before(i+1),l=o.after(i+1),a=r,c=l,d=T.empty,p=0;for(let f=i,m=!1;f>t;f--)m||s.index(f)>0?(m=!0,d=T.from(s.node(f).copy(d)),p++):a--;let u=T.empty,h=0;for(let f=i,m=!1;f>t;f--)m||o.after(f+1)<o.end(f)?(m=!0,u=T.from(o.node(f).copy(u)),h++):c++;n.step(new ee(a,c,r,l,new A(d.append(u),p,h),d.size-p,!0))}function zc(n,e,t=null,s=n){let o=Zf(n,e),i=o&&Yf(s,e);return i?o.map(hl).concat({type:e,attrs:t}).concat(i.map(hl)):null}function hl(n){return{type:n,attrs:null}}function Zf(n,e){let{parent:t,startIndex:s,endIndex:o}=n,i=t.contentMatchAt(s).findWrapping(e);if(!i)return null;let r=i.length?i[0]:e;return t.canReplaceWith(s,o,r)?i:null}function Yf(n,e){let{parent:t,startIndex:s,endIndex:o}=n,i=t.child(s),r=e.contentMatch.findWrapping(i.type);if(!r)return null;let a=(r.length?r[r.length-1]:e).contentMatch;for(let c=s;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:r}function Xf(n,e,t){let s=T.empty;for(let r=t.length-1;r>=0;r--){if(s.size){let l=t[r].type.contentMatch.matchFragment(s);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}s=T.from(t[r].type.create(t[r].attrs,s))}let o=e.start,i=e.end;n.step(new ee(o,i,o,i,new A(s,0,0),t.length,!0))}function Qf(n,e,t,s,o){if(!s.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 o=="function"?o(r):o;if(r.isTextblock&&!r.hasMarkup(s,a)&&em(n.doc,n.mapping.slice(i).map(l),s)){let c=null;if(s.schema.linebreakReplacement){let h=s.whitespace=="pre",f=!!s.contentMatch.matchType(s.schema.linebreakReplacement);h&&!f?c=!1:!h&&f&&(c=!0)}c===!1&&Bc(n,r,l,i),tr(n,n.mapping.slice(i).map(l,1),s,void 0,c===null);let d=n.mapping.slice(i),p=d.map(l,1),u=d.map(l+r.nodeSize,1);return n.step(new ee(p,u,p+1,u-1,new A(T.from(s.create(a,null,r.marks)),0,0),1,!0)),c===!0&&Vc(n,r,l,i),!1}})}function Vc(n,e,t,s){e.forEach((o,i)=>{if(o.isText){let r,l=/\r?\n|\r/g;for(;r=l.exec(o.text);){let a=n.mapping.slice(s).map(t+1+i+r.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Bc(n,e,t,s){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let r=n.mapping.slice(s).map(t+1+i);n.replaceWith(r,r+1,e.type.schema.text(`
|
|
911
|
-
`))}})}function em(n,e,t){let s=n.resolve(e),o=s.index();return s.parent.canReplaceWith(o,o+1,t)}function tm(n,e,t,s,o){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let r=t.create(s,null,o||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 ee(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new A(T.from(r),0,0),1,!0))}function dn(n,e,t=1,s){let o=n.resolve(e),i=o.depth-t,r=s&&s[s.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!r.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,d=t-2;c>i;c--,d--){let p=o.node(c),u=o.index(c);if(p.type.spec.isolating)return!1;let h=p.content.cutByIndex(u,p.childCount),f=s&&s[d+1];f&&(h=h.replaceChild(0,f.type.create(f.attrs)));let m=s&&s[d]||p;if(!p.canReplace(u+1,p.childCount)||!m.type.validContent(h))return!1}let l=o.indexAfter(i),a=s&&s[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function nm(n,e,t=1,s){let o=n.doc.resolve(e),i=T.empty,r=T.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){i=T.from(o.node(l).copy(i));let d=s&&s[c];r=T.from(d?d.type.create(d.attrs,r):o.node(l).copy(r))}n.step(new ne(e,e,new A(i.append(r),t,t),!0))}function go(n,e){let t=n.resolve(e),s=t.index();return om(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(s,s+1)}function sm(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:s}=n.type.schema;for(let o=0;o<e.childCount;o++){let i=e.child(o),r=i.type==s?n.type.schema.nodes.text:i.type;if(t=t.matchType(r),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function om(n,e){return!!(n&&e&&!n.isLeaf&&sm(n,e))}function im(n,e,t){let s=null,{linebreakReplacement:o}=n.doc.type.schema,i=n.doc.resolve(e-t),r=i.node().type;if(o&&r.inlineContent){let d=r.whitespace=="pre",p=!!r.contentMatch.matchType(o);d&&!p?s=!1:!d&&p&&(s=!0)}let l=n.steps.length;if(s===!1){let d=n.doc.resolve(e+t);Bc(n,d.node(),d.before(),l)}r.inlineContent&&tr(n,e+t-1,r,i.node().contentMatchAt(i.index()),s==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new ne(c,a.map(e+t,-1),A.empty,!0)),s===!0){let d=n.doc.resolve(c);Vc(n,d.node(),d.before(),n.steps.length)}return n}function rm(n,e,t){let s=n.resolve(e);if(s.parent.canReplaceWith(s.index(),s.index(),t))return e;if(s.parentOffset==0)for(let o=s.depth-1;o>=0;o--){let i=s.index(o);if(s.node(o).canReplaceWith(i,i,t))return s.before(o+1);if(i>0)return null}if(s.parentOffset==s.parent.content.size)for(let o=s.depth-1;o>=0;o--){let i=s.indexAfter(o);if(s.node(o).canReplaceWith(i,i,t))return s.after(o+1);if(i<s.node(o).childCount)return null}return null}function lm(n,e,t){let s=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let i=0;i<t.openStart;i++)o=o.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let r=s.depth;r>=0;r--){let l=r==s.depth?0:s.pos<=(s.start(r+1)+s.end(r+1))/2?-1:1,a=s.index(r)+(l>0?1:0),c=s.node(r),d=!1;if(i==1)d=c.canReplace(a,a,o);else{let p=c.contentMatchAt(a).findWrapping(o.firstChild.type);d=p&&c.canReplaceWith(a,a,p[0])}if(d)return l==0?s.pos:l<0?s.before(r+1):s.after(r+1)}return null}function nr(n,e,t=e,s=A.empty){if(e==t&&!s.size)return null;let o=n.resolve(e),i=n.resolve(t);return Hc(o,i,s)?new ne(e,t,s):new am(o,i,s).fit()}function Hc(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class am{constructor(e,t,s){this.$from=e,this.$to=t,this.unplaced=s,this.frontier=[],this.placed=T.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=T.from(e.node(o).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,s=this.$from,o=this.close(e<0?this.$to:s.doc.resolve(e));if(!o)return null;let i=this.placed,r=s.depth,l=o.depth;for(;r&&l&&i.childCount==1;)i=i.firstChild.content,r--,l--;let a=new A(i,r,l);return e>-1?new ee(s.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||s.pos!=this.$to.pos?new ne(s.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,s=0,o=this.unplaced.openEnd;s<e;s++){let i=t.firstChild;if(t.childCount>1&&(o=0),i.type.spec.isolating&&o<=s){e=s;break}t=i.content}for(let t=1;t<=2;t++)for(let s=t==1?e:this.unplaced.openStart;s>=0;s--){let o,i=null;s?(i=Io(this.unplaced.content,s-1).firstChild,o=i.content):o=this.unplaced.content;let r=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,p=null;if(t==1&&(r?c.matchType(r.type)||(p=c.fillBefore(T.from(r),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:s,frontierDepth:l,parent:i,inject:p};if(t==2&&r&&(d=c.findWrapping(r.type)))return{sliceDepth:s,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:s}=this.unplaced,o=Io(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new A(e,t+1,Math.max(s,o.size+t>=e.size-s?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:s}=this.unplaced,o=Io(e,t);if(o.childCount<=1&&t>0){let i=e.size-t<=t+o.size;this.unplaced=new A(In(e,t-1,1),t-1,i?t-1:s)}else this.unplaced=new A(In(e,t,1),t,s)}placeNodes({sliceDepth:e,frontierDepth:t,parent:s,inject:o,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=s?s.content:r.content,a=r.openStart-e,c=0,d=[],{match:p,type:u}=this.frontier[t];if(o){for(let m=0;m<o.childCount;m++)d.push(o.child(m));p=p.matchFragment(o)}let h=l.size+e-(r.content.size-r.openEnd);for(;c<l.childCount;){let m=l.child(c),g=p.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(p=g,d.push(Fc(m.mark(u.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let f=c==l.childCount;f||(h=-1),this.placed=On(this.placed,t,T.from(d)),this.frontier[t].match=p,f&&h<0&&s&&s.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=f?e==0?A.empty:new A(In(r.content,e-1,1),e-1,h<0?r.openEnd:e-1):new A(In(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||!Oo(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:s}=this.$to,o=this.$to.after(s);for(;s>1&&o==this.$to.end(--s);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:s,type:o}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),r=Oo(e,t,o,s,i);if(r){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=Oo(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=On(this.placed,t.depth,t.fit)),e=t.move;for(let s=t.depth+1;s<=e.depth;s++){let o=e.node(s),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(s));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,t=null,s){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=On(this.placed,this.depth,T.from(e.create(t,s))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(T.empty,!0);t.childCount&&(this.placed=On(this.placed,this.frontier.length,t))}}function In(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(In(n.firstChild.content,e-1,t)))}function On(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(On(n.lastChild.content,e-1,t)))}function Io(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Fc(n,e,t){if(e<=0)return n;let s=n.content;return e>1&&(s=s.replaceChild(0,Fc(s.firstChild,e-1,s.childCount==1?t-1:0))),e>0&&(s=n.type.contentMatch.fillBefore(s).append(s),t<=0&&(s=s.append(n.type.contentMatch.matchFragment(s).fillBefore(T.empty,!0)))),n.copy(s)}function Oo(n,e,t,s,o){let i=n.node(e),r=o?n.indexAfter(e):n.index(e);if(r==i.childCount&&!t.compatibleContent(i.type))return null;let l=s.fillBefore(i.content,!0,r);return l&&!cm(t,i.content,r)?l:null}function cm(n,e,t){for(let s=t;s<e.childCount;s++)if(!n.allowsMarks(e.child(s).marks))return!0;return!1}function dm(n){return n.spec.defining||n.spec.definingForContent}function pm(n,e,t,s){if(!s.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),i=n.doc.resolve(t);if(Hc(o,i,s))return n.step(new ne(e,t,s));let r=Gc(o,n.doc.resolve(t));r[r.length-1]==0&&r.pop();let l=-(o.depth+1);r.unshift(l);for(let u=o.depth,h=o.pos-1;u>0;u--,h--){let f=o.node(u).type.spec;if(f.defining||f.definingAsContext||f.isolating)break;r.indexOf(u)>-1?l=u:o.before(u)==h&&r.splice(1,0,-u)}let a=r.indexOf(l),c=[],d=s.openStart;for(let u=s.content,h=0;;h++){let f=u.firstChild;if(c.push(f),h==s.openStart)break;u=f.content}for(let u=d-1;u>=0;u--){let h=c[u],f=dm(h.type);if(f&&!h.sameMarkup(o.node(Math.abs(l)-1)))d=u;else if(f||!h.type.isTextblock)break}for(let u=s.openStart;u>=0;u--){let h=(u+d+1)%(s.openStart+1),f=c[h];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 C=o.node(g-1),y=o.index(g-1);if(C.canReplaceWith(y,y,f.type,f.marks))return n.replace(o.before(g),b?i.after(g):t,new A(_c(s.content,0,s.openStart,h),h,s.openEnd))}}let p=n.steps.length;for(let u=r.length-1;u>=0&&(n.replace(e,t,s),!(n.steps.length>p));u--){let h=r[u];h<0||(e=o.before(h),t=i.after(h))}}function _c(n,e,t,s,o){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(_c(i.content,e+1,t,s,i)))}if(e>s){let i=o.contentMatchAt(0),r=i.fillBefore(n).append(n);n=r.append(i.matchFragment(r).fillBefore(T.empty,!0))}return n}function um(n,e,t,s){if(!s.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=rm(n.doc,e,s.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new A(T.from(s),0,0))}function hm(n,e,t){let s=n.doc.resolve(e),o=n.doc.resolve(t),i=Gc(s,o);for(let r=0;r<i.length;r++){let l=i[r],a=r==i.length-1;if(a&&l==0||s.node(l).type.contentMatch.validEnd)return n.delete(s.start(l),o.end(l));if(l>0&&(a||s.node(l-1).canReplace(s.index(l-1),o.indexAfter(l-1))))return n.delete(s.before(l),o.after(l))}for(let r=1;r<=s.depth&&r<=o.depth;r++)if(e-s.start(r)==s.depth-r&&t>s.end(r)&&o.end(r)-t!=o.depth-r&&s.start(r-1)==o.start(r-1)&&s.node(r-1).canReplace(s.index(r-1),o.index(r-1)))return n.delete(s.before(r),t);n.delete(e,t)}function Gc(n,e){let t=[],s=Math.min(n.depth,e.depth);for(let o=s;o>=0;o--){let i=n.start(o);if(i<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&t.push(o)}return t}class pn extends oe{constructor(e,t,s){super(),this.pos=e,this.attr=t,this.value=s}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at attribute step's position");let s=Object.create(null);for(let i in t.attrs)s[i]=t.attrs[i];s[this.attr]=this.value;let o=t.type.create(s,null,t.marks);return K.fromReplace(e,this.pos,this.pos+1,new A(T.from(o),0,t.isLeaf?0:1))}getMap(){return be.empty}invert(e){return new pn(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 pn(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 pn(t.pos,t.attr,t.value)}}oe.jsonID("attr",pn);class Zn extends oe{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let s=e.type.create(t,e.content,e.marks);return K.ok(s)}getMap(){return be.empty}invert(e){return new Zn(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 Zn(t.attr,t.value)}}oe.jsonID("docAttr",Zn);let gn=class extends Error{};gn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};gn.prototype=Object.create(Error.prototype);gn.prototype.constructor=gn;gn.prototype.name="TransformError";class Wc{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new cn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new gn(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,s=A.empty){let o=nr(this.doc,e,t,s);return o&&this.step(o),this}replaceWith(e,t,s){return this.replace(e,t,new A(T.from(s),0,0))}delete(e,t){return this.replace(e,t,A.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,s){return pm(this,e,t,s),this}replaceRangeWith(e,t,s){return um(this,e,t,s),this}deleteRange(e,t){return hm(this,e,t),this}lift(e,t){return Jf(this,e,t),this}join(e,t=1){return im(this,e,t),this}wrap(e,t){return Xf(this,e,t),this}setBlockType(e,t=e,s,o=null){return Qf(this,e,t,s,o),this}setNodeMarkup(e,t,s=null,o){return tm(this,e,t,s,o),this}setNodeAttribute(e,t,s){return this.step(new pn(e,t,s)),this}setDocAttribute(e,t){return this.step(new Zn(e,t)),this}addNodeMark(e,t){return this.step(new dt(e,t)),this}removeNodeMark(e,t){if(!(t instanceof B)){let s=this.doc.nodeAt(e);if(!s)throw new RangeError("No node at position "+e);if(t=t.isInSet(s.marks),!t)return this}return this.step(new mn(e,t)),this}split(e,t=1,s){return nm(this,e,t,s),this}addMark(e,t,s){return qf(this,e,t,s),this}removeMark(e,t,s){return Uf(this,e,t,s),this}clearIncompatible(e,t,s){return tr(this,e,t,s),this}}const Ro=Object.create(null);class L{constructor(e,t,s){this.$anchor=e,this.$head=t,this.ranges=s||[new jc(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 s=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=s,s=s.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?A.empty:t),l==0&&gl(e,i,(s?s.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let s=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:r,$to:l}=o[i],a=e.mapping.slice(s),c=a.map(r.pos),d=a.map(l.pos);i?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),gl(e,s,t.isInline?-1:1))}}static findFrom(e,t,s=!1){let o=e.parent.inlineContent?new $(e):Xt(e.node(0),e.parent,e.pos,e.index(),t,s);if(o)return o;for(let i=e.depth-1;i>=0;i--){let r=t<0?Xt(e.node(0),e.node(i),e.before(i+1),e.index(i),t,s):Xt(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,s);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Se(e.node(0))}static atStart(e){return Xt(e,e,0,0,1)||new Se(e)}static atEnd(e){return Xt(e,e,e.content.size,e.childCount,-1)||new Se(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let s=Ro[t.type];if(!s)throw new RangeError(`No selection type ${t.type} defined`);return s.fromJSON(e,t)}static jsonID(e,t){if(e in Ro)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ro[e]=t,t.prototype.jsonID=e,t}getBookmark(){return $.between(this.$anchor,this.$head).getBookmark()}}L.prototype.visible=!0;class jc{constructor(e,t){this.$from=e,this.$to=t}}let fl=!1;function ml(n){!fl&&!n.parent.inlineContent&&(fl=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class $ extends L{constructor(e,t=e){ml(e),ml(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let s=e.resolve(t.map(this.head));if(!s.parent.inlineContent)return L.near(s);let o=e.resolve(t.map(this.anchor));return new $(o.parent.inlineContent?o:s,s)}replace(e,t=A.empty){if(super.replace(e,t),t==A.empty){let s=this.$from.marksAcross(this.$to);s&&e.ensureMarks(s)}}eq(e){return e instanceof $&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new yo(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 $(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,s=t){let o=e.resolve(t);return new this(o,s==t?o:e.resolve(s))}static between(e,t,s){let o=e.pos-t.pos;if((!s||o)&&(s=o>=0?1:-1),!t.parent.inlineContent){let i=L.findFrom(t,s,!0)||L.findFrom(t,-s,!0);if(i)t=i.$head;else return L.near(t,s)}return e.parent.inlineContent||(o==0?e=t:(e=(L.findFrom(e,-s,!0)||L.findFrom(e,s,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new $(e,t)}}L.jsonID("text",$);class yo{constructor(e,t){this.anchor=e,this.head=t}map(e){return new yo(e.map(this.anchor),e.map(this.head))}resolve(e){return $.between(e.resolve(this.anchor),e.resolve(this.head))}}class D extends L{constructor(e){let t=e.nodeAfter,s=e.node(0).resolve(e.pos+t.nodeSize);super(e,s),this.node=t}map(e,t){let{deleted:s,pos:o}=t.mapResult(this.anchor),i=e.resolve(o);return s?L.near(i):new D(i)}content(){return new A(T.from(this.node),0,0)}eq(e){return e instanceof D&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new sr(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new D(e.resolve(t.anchor))}static create(e,t){return new D(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}D.prototype.visible=!1;L.jsonID("node",D);class sr{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:s}=e.mapResult(this.anchor);return t?new yo(s,s):new sr(s)}resolve(e){let t=e.resolve(this.anchor),s=t.nodeAfter;return s&&D.isSelectable(s)?new D(t):L.near(t)}}class Se extends L{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 s=L.atStart(e.doc);s.eq(e.selection)||e.setSelection(s)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Se(e)}map(e){return new Se(e)}eq(e){return e instanceof Se}getBookmark(){return fm}}L.jsonID("all",Se);const fm={map(){return this},resolve(n){return new Se(n)}};function Xt(n,e,t,s,o,i=!1){if(e.inlineContent)return $.create(n,t);for(let r=s-(o>0?0:1);o>0?r<e.childCount:r>=0;r+=o){let l=e.child(r);if(l.isAtom){if(!i&&D.isSelectable(l))return D.create(n,t-(o<0?l.nodeSize:0))}else{let a=Xt(n,l,t+o,o<0?l.childCount:0,o,i);if(a)return a}t+=l.nodeSize*o}return null}function gl(n,e,t){let s=n.steps.length-1;if(s<e)return;let o=n.steps[s];if(!(o instanceof ne||o instanceof ee))return;let i=n.mapping.maps[s],r;i.forEach((l,a,c,d)=>{r==null&&(r=d)}),n.setSelection(L.near(n.doc.resolve(r),t))}const yl=1,Cs=2,bl=4;class mm extends Wc{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|yl)&~Cs,this.storedMarks=null,this}get selectionSet(){return(this.updated&yl)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Cs,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&Cs)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Cs,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let s=this.selection;return t&&(e=e.mark(this.storedMarks||(s.empty?s.$from.marks():s.$from.marksAcross(s.$to)||B.none))),s.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,s){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(s==null&&(s=t),s=s??t,!e)return this.deleteRange(t,s);let i=this.storedMarks;if(!i){let r=this.doc.resolve(t);i=s==t?r.marks():r.marksAcross(this.doc.resolve(s))}return this.replaceRangeWith(t,s,o.text(e,i)),this.selection.empty||this.setSelection(L.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|=bl,this}get scrolledIntoView(){return(this.updated&bl)>0}}function vl(n,e){return!e||!n?n:n.bind(e)}class Rn{constructor(e,t,s){this.name=e,this.init=vl(t.init,s),this.apply=vl(t.apply,s)}}const gm=[new Rn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Rn("selection",{init(n,e){return n.selection||L.atStart(e.doc)},apply(n){return n.selection}}),new Rn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,s){return s.selection.$cursor?n.storedMarks:null}}),new Rn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Do{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=gm.slice(),t&&t.forEach(s=>{if(this.pluginsByKey[s.key])throw new RangeError("Adding different instances of a keyed plugin ("+s.key+")");this.plugins.push(s),this.pluginsByKey[s.key]=s,s.spec.state&&this.fields.push(new Rn(s.key,s.spec.state,s))})}}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 s=0;s<this.config.plugins.length;s++)if(s!=t){let o=this.config.plugins[s];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],s=this.applyInner(e),o=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=o?o[r].n:0,c=o?o[r].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,s);if(d&&s.filterTransaction(d,r)){if(d.setMeta("appendedTransaction",e),!o){o=[];for(let p=0;p<this.config.plugins.length;p++)o.push(p<r?{state:s,n:t.length}:{state:this,n:0})}t.push(d),s=s.applyInner(d),i=!0}o&&(o[r]={state:s,n:t.length})}}if(!i)return{state:s,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new sn(this.config),s=this.config.fields;for(let o=0;o<s.length;o++){let i=s[o];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new mm(this)}static create(e){let t=new Do(e.doc?e.doc.type.schema:e.schema,e.plugins),s=new sn(t);for(let o=0;o<t.fields.length;o++)s[t.fields[o].name]=t.fields[o].init(e,s);return s}reconfigure(e){let t=new Do(this.schema,e.plugins),s=t.fields,o=new sn(t);for(let i=0;i<s.length;i++){let r=s[i].name;o[r]=this.hasOwnProperty(r)?this[r]:s[i].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(s=>s.toJSON())),e&&typeof e=="object")for(let s in e){if(s=="doc"||s=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[s],i=o.spec.state;i&&i.toJSON&&(t[s]=i.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,s){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Do(e.schema,e.plugins),i=new sn(o);return o.fields.forEach(r=>{if(r.name=="doc")i.doc=Rt.fromJSON(e.schema,t.doc);else if(r.name=="selection")i.selection=L.fromJSON(i.doc,t.selection);else if(r.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(s)for(let l in s){let a=s[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 qc(n,e,t){for(let s in n){let o=n[s];o instanceof Function?o=o.bind(e):s=="handleDOMEvents"&&(o=qc(o,e,{})),t[s]=o}return t}class wn{constructor(e){this.spec=e,this.props={},e.props&&qc(e.props,this,this.props),this.key=e.key?e.key.key:Uc("plugin")}getState(e){return e[this.key]}}const Lo=Object.create(null);function Uc(n){return n in Lo?n+"$"+ ++Lo[n]:(Lo[n]=0,n+"$")}class is{constructor(e="key"){this.key=Uc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Kc=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function ym(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const bm=(n,e,t)=>{let s=ym(n,t);if(!s)return!1;let o=Jc(s);if(!o){let r=s.blockRange(),l=r&&mo(r);return l==null?!1:(e&&e(n.tr.lift(r,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(td(n,o,e,-1))return!0;if(s.parent.content.size==0&&(yn(i,"end")||D.isSelectable(i)))for(let r=s.depth;;r--){let l=nr(n.doc,s.before(r),s.after(r),A.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(yn(i,"end")?L.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):D.create(a.doc,o.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(r==1||s.node(r-1).childCount>1)break}return i.isAtom&&o.depth==s.depth-1?(e&&e(n.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1};function yn(n,e,t=!1){for(let s=n;s;s=e=="start"?s.firstChild:s.lastChild){if(s.isTextblock)return!0;if(t&&s.childCount!=1)return!1}return!1}const vm=(n,e,t)=>{let{$head:s,empty:o}=n.selection,i=s;if(!o)return!1;if(s.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):s.parentOffset>0)return!1;i=Jc(s)}let r=i&&i.nodeBefore;return!r||!D.isSelectable(r)?!1:(e&&e(n.tr.setSelection(D.create(n.doc,i.pos-r.nodeSize)).scrollIntoView()),!0)};function Jc(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 Sm(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const xm=(n,e,t)=>{let s=Sm(n,t);if(!s)return!1;let o=Zc(s);if(!o)return!1;let i=o.nodeAfter;if(td(n,o,e,1))return!0;if(s.parent.content.size==0&&(yn(i,"start")||D.isSelectable(i))){let r=nr(n.doc,s.before(),s.after(),A.empty);if(r&&r.slice.size<r.to-r.from){if(e){let l=n.tr.step(r);l.setSelection(yn(i,"start")?L.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):D.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==s.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},wm=(n,e,t)=>{let{$head:s,empty:o}=n.selection,i=s;if(!o)return!1;if(s.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):s.parentOffset<s.parent.content.size)return!1;i=Zc(s)}let r=i&&i.nodeAfter;return!r||!D.isSelectable(r)?!1:(e&&e(n.tr.setSelection(D.create(n.doc,i.pos)).scrollIntoView()),!0)};function Zc(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 Cm=(n,e)=>{let{$head:t,$anchor:s}=n.selection;return!t.parent.type.spec.code||!t.sameParent(s)?!1:(e&&e(n.tr.insertText(`
|
|
912
|
-
`).scrollIntoView()),!0)};function or(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 Yc=(n,e)=>{let{$head:t,$anchor:s}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(s))return!1;let o=t.node(-1),i=t.indexAfter(-1),r=or(o.contentMatchAt(i));if(!r||!o.canReplaceWith(i,i,r))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,r.createAndFill());a.setSelection(L.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},km=(n,e)=>{let t=n.selection,{$from:s,$to:o}=t;if(t instanceof Se||s.parent.inlineContent||o.parent.inlineContent)return!1;let i=or(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let r=(!s.parentOffset&&o.index()<o.parent.childCount?s:o).pos,l=n.tr.insert(r,i.createAndFill());l.setSelection($.create(l.doc,r+1)),e(l.scrollIntoView())}return!0},Xc=(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(dn(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let s=t.blockRange(),o=s&&mo(s);return o==null?!1:(e&&e(n.tr.lift(s,o).scrollIntoView()),!0)};function Qc(n){return(e,t)=>{let{$from:s,$to:o}=e.selection;if(e.selection instanceof D&&e.selection.node.isBlock)return!s.parentOffset||!dn(e.doc,s.pos)?!1:(t&&t(e.tr.split(s.pos).scrollIntoView()),!0);if(!s.depth)return!1;let i=[],r,l,a=!1,c=!1;for(let h=s.depth;;h--)if(s.node(h).isBlock){a=s.end(h)==s.pos+(s.depth-h),c=s.start(h)==s.pos-(s.depth-h),l=or(s.node(h-1).contentMatchAt(s.indexAfter(h-1)));let m=n&&n(o.parent,a,s);i.unshift(m||(a&&l?{type:l}:null)),r=h;break}else{if(h==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof $||e.selection instanceof Se)&&d.deleteSelection();let p=d.mapping.map(s.pos),u=dn(d.doc,p,i.length,i);if(u||(i[0]=l?{type:l}:null,u=dn(d.doc,p,i.length,i)),d.split(p,i.length,i),!a&&c&&s.node(r).type!=l){let h=d.mapping.map(s.before(r)),f=d.doc.resolve(h);l&&s.node(r-1).canReplaceWith(f.index(),f.index()+1,l)&&d.setNodeMarkup(d.mapping.map(s.before(r)),l)}return t&&t(d.scrollIntoView()),!0}}const Em=Qc(),ed=(n,e)=>(e&&e(n.tr.setSelection(new Se(n.doc))),!0);function Tm(n,e,t){let s=e.nodeBefore,o=e.nodeAfter,i=e.index();return!s||!o||!s.type.compatibleContent(o.type)?!1:!s.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-s.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||go(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function td(n,e,t,s){let o=e.nodeBefore,i=e.nodeAfter,r,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&Tm(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(r=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(r[0]||i.type).validEnd){if(t){let h=e.pos+i.nodeSize,f=T.empty;for(let b=r.length-1;b>=0;b--)f=T.from(r[b].create(null,f));f=T.from(o.copy(f));let m=n.tr.step(new ee(e.pos-1,h,e.pos,h,new A(f,1,0),r.length,!0)),g=m.doc.resolve(h+2*r.length);g.nodeAfter&&g.nodeAfter.type==o.type&&go(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=i.type.spec.isolating||s>0&&a?null:L.findFrom(e,1),p=d&&d.$from.blockRange(d.$to),u=p&&mo(p);if(u!=null&&u>=e.depth)return t&&t(n.tr.lift(p,u).scrollIntoView()),!0;if(c&&yn(i,"start",!0)&&yn(o,"end")){let h=o,f=[];for(;f.push(h),!h.isTextblock;)h=h.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let b=T.empty;for(let y=f.length-1;y>=0;y--)b=T.from(f[y].copy(b));let C=n.tr.step(new ee(e.pos-f.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new A(b,f.length,0),0,!0));t(C.scrollIntoView())}return!0}}return!1}function nd(n){return function(e,t){let s=e.selection,o=n<0?s.$from:s.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(t&&t(e.tr.setSelection($.create(e.doc,n<0?o.start(i):o.end(i)))),!0):!1}}const Mm=nd(-1),Am=nd(1);function Pm(n,e=null){return function(t,s){let o=!1;for(let i=0;i<t.selection.ranges.length&&!o;i++){let{$from:{pos:r},$to:{pos:l}}=t.selection.ranges[i];t.doc.nodesBetween(r,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let d=t.doc.resolve(c),p=d.index();o=d.parent.canReplaceWith(p,p+1,n)}})}if(!o)return!1;if(s){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)}s(i.scrollIntoView())}return!0}}function Nm(n,e,t,s){for(let o=0;o<e.length;o++){let{$from:i,$to:r}=e[o],l=i.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(i.pos,r.pos,(a,c)=>{if(l||!s)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function kt(n,e=null,t){let s=t!==!1;return function(o,i){let{empty:r,$cursor:l,ranges:a}=o.selection;if(r&&!l||!Nm(o.doc,a,n,s))return!1;if(i)if(l)n.isInSet(o.storedMarks||l.marks())?i(o.tr.removeStoredMark(n)):i(o.tr.addStoredMark(n.create(e)));else{let c,d=o.tr;c=!a.some(p=>o.doc.rangeHasMark(p.$from.pos,p.$to.pos,n));for(let p=0;p<a.length;p++){let{$from:u,$to:h}=a[p];if(!c)d.removeMark(u.pos,h.pos,n);else{let f=u.pos,m=h.pos,g=u.nodeAfter,b=h.nodeBefore,C=g&&g.isText?/^\s*/.exec(g.text)[0].length:0,y=b&&b.isText?/\s*$/.exec(b.text)[0].length:0;f+C<m&&(f+=C,m-=y),d.addMark(f,m,n.create(e))}}i(d.scrollIntoView())}return!0}}function Yn(...n){return function(e,t,s){for(let o=0;o<n.length;o++)if(n[o](e,t,s))return!0;return!1}}let $o=Yn(Kc,bm,vm),Sl=Yn(Kc,xm,wm);const Ye={Enter:Yn(Cm,km,Xc,Em),"Mod-Enter":Yc,Backspace:$o,"Mod-Backspace":$o,"Shift-Backspace":$o,Delete:Sl,"Mod-Delete":Sl,"Mod-a":ed},sd={"Ctrl-h":Ye.Backspace,"Alt-Backspace":Ye["Mod-Backspace"],"Ctrl-d":Ye.Delete,"Ctrl-Alt-Backspace":Ye["Mod-Delete"],"Alt-Delete":Ye["Mod-Delete"],"Alt-d":Ye["Mod-Delete"],"Ctrl-a":Mm,"Ctrl-e":Am};for(let n in Ye)sd[n]=Ye[n];const Im=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Om=Im?sd:Ye;var Xs=200,J=function(){};J.prototype.append=function(e){return e.length?(e=J.from(e),!this.length&&e||e.length<Xs&&this.leafAppend(e)||this.length<Xs&&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 Rm(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,s){t===void 0&&(t=0),s===void 0&&(s=this.length),t<=s?this.forEachInner(e,t,s,0):this.forEachInvertedInner(e,t,s,0)};J.prototype.map=function(e,t,s){t===void 0&&(t=0),s===void 0&&(s=this.length);var o=[];return this.forEach(function(i,r){return o.push(e(i,r))},t,s),o};J.from=function(e){return e instanceof J?e:e&&e.length?new od(e):J.empty};var od=function(n){function e(s){n.call(this),this.values=s}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(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,r,l){for(var a=i;a<r;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,r,l){for(var a=i-1;a>=r;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Xs)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Xs)return new e(o.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 od([]);var Rm=function(n){function e(t,s){n.call(this),this.left=t,this.right=s,this.length=t.length+s.length,this.depth=Math.max(t.depth,s.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(s){return s<this.left.length?this.left.get(s):this.right.get(s-this.left.length)},e.prototype.forEachInner=function(s,o,i,r){var l=this.left.length;if(o<l&&this.left.forEachInner(s,o,Math.min(i,l),r)===!1||i>l&&this.right.forEachInner(s,Math.max(o-l,0),Math.min(this.length,i)-l,r+l)===!1)return!1},e.prototype.forEachInvertedInner=function(s,o,i,r){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(s,o-l,Math.max(i,l)-l,r+l)===!1||i<l&&this.left.forEachInvertedInner(s,Math.min(o,l),i,r)===!1)return!1},e.prototype.sliceInner=function(s,o){if(s==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(s,o):s>=i?this.right.slice(s-i,o-i):this.left.slice(s,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(s){var o=this.right.leafAppend(s);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(s){var o=this.left.leafPrepend(s);if(o)return new e(o,this.right)},e.prototype.appendInner=function(s){return this.left.depth>=Math.max(this.right.depth,s.depth)+1?new e(this.left,new e(this.right,s)):new e(this,s)},e}(J);const Dm=500;class Ie{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let s=this.items.length;for(;;s--)if(this.items.get(s-1).selection){--s;break}let o,i;t&&(o=this.remapping(s,this.items.length),i=o.maps.length);let r=e.tr,l,a,c=[],d=[];return this.items.forEach((p,u)=>{if(!p.step){o||(o=this.remapping(s,u+1),i=o.maps.length),i--,d.push(p);return}if(o){d.push(new $e(p.map));let h=p.step.map(o.slice(i)),f;h&&r.maybeStep(h).doc&&(f=r.mapping.maps[r.mapping.maps.length-1],c.push(new $e(f,void 0,void 0,c.length+d.length))),i--,f&&o.appendMap(f,i)}else r.maybeStep(p.step);if(p.selection)return l=o?p.selection.map(o.slice(i)):p.selection,a=new Ie(this.items.slice(0,s).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:r,selection:l}}addTransform(e,t,s,o){let i=[],r=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let p=e.steps[d].invert(e.docs[d]),u=new $e(e.mapping.maps[d],p,t),h;(h=a&&a.merge(u))&&(u=h,d?i.pop():l=l.slice(0,l.length-1)),i.push(u),t&&(r++,t=void 0),o||(a=u)}let c=r-s.depth;return c>$m&&(l=Lm(l,c),r-=c),new Ie(l.append(i),r)}remapping(e,t){let s=new cn;return this.items.forEach((o,i)=>{let r=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?s.maps.length-o.mirrorOffset:void 0;s.appendMap(o.map,r)},e,t),s}addMaps(e){return this.eventCount==0?this:new Ie(this.items.append(e.map(t=>new $e(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let s=[],o=Math.max(0,this.items.length-t),i=e.mapping,r=e.steps.length,l=this.eventCount;this.items.forEach(u=>{u.selection&&l--},o);let a=t;this.items.forEach(u=>{let h=i.getMirror(--a);if(h==null)return;r=Math.min(r,h);let f=i.maps[h];if(u.step){let m=e.steps[h].invert(e.docs[h]),g=u.selection&&u.selection.map(i.slice(a+1,h));g&&l++,s.push(new $e(f,m,g))}else s.push(new $e(f))},o);let c=[];for(let u=t;u<r;u++)c.push(new $e(i.maps[u]));let d=this.items.slice(0,o).append(c).append(s),p=new Ie(d,l);return p.emptyItemCount()>Dm&&(p=p.compress(this.items.length-s.length)),p}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),s=t.maps.length,o=[],i=0;return this.items.forEach((r,l)=>{if(l>=e)o.push(r),r.selection&&i++;else if(r.step){let a=r.step.map(t.slice(s)),c=a&&a.getMap();if(s--,c&&t.appendMap(c,s),a){let d=r.selection&&r.selection.map(t.slice(s));d&&i++;let p=new $e(c.invert(),a,d),u,h=o.length-1;(u=o.length&&o[h].merge(p))?o[h]=u:o.push(p)}}else r.map&&s--},this.items.length,0),new Ie(J.from(o.reverse()),i)}}Ie.empty=new Ie(J.empty,0);function Lm(n,e){let t;return n.forEach((s,o)=>{if(s.selection&&e--==0)return t=o,!1}),n.slice(t)}class $e{constructor(e,t,s,o){this.map=e,this.step=t,this.selection=s,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new $e(t.getMap().invert(),t,this.selection)}}}class ot{constructor(e,t,s,o,i){this.done=e,this.undone=t,this.prevRanges=s,this.prevTime=o,this.prevComposition=i}}const $m=20;function zm(n,e,t,s){let o=t.getMeta(Dt),i;if(o)return o.historyState;t.getMeta(Hm)&&(n=new ot(n.done,n.undone,null,0,-1));let r=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(r&&r.getMeta(Dt))return r.getMeta(Dt).redo?new ot(n.done.addTransform(t,void 0,s,Ds(e)),n.undone,xl(t.mapping.maps),n.prevTime,n.prevComposition):new ot(n.done,n.undone.addTransform(t,void 0,s,Ds(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)-s.newGroupDelay||!Vm(t,n.prevRanges)),c=r?zo(n.prevRanges,t.mapping):xl(t.mapping.maps);return new ot(n.done.addTransform(t,a?e.selection.getBookmark():void 0,s,Ds(e)),Ie.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new ot(n.done.rebased(t,i),n.undone.rebased(t,i),zo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new ot(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),zo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Vm(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((s,o)=>{for(let i=0;i<e.length;i+=2)s<=e[i+1]&&o>=e[i]&&(t=!0)}),t}function xl(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((s,o,i,r)=>e.push(i,r));return e}function zo(n,e){if(!n)return null;let t=[];for(let s=0;s<n.length;s+=2){let o=e.map(n[s],1),i=e.map(n[s+1],-1);o<=i&&t.push(o,i)}return t}function Bm(n,e,t){let s=Ds(e),o=Dt.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,s);if(!i)return null;let r=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),o,s),a=new ot(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(r).setMeta(Dt,{redo:t,historyState:a})}let Vo=!1,wl=null;function Ds(n){let e=n.plugins;if(wl!=e){Vo=!1,wl=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Vo=!0;break}}return Vo}const Dt=new is("history"),Hm=new is("closeHistory");function Fm(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new wn({key:Dt,state:{init(){return new ot(Ie.empty,Ie.empty,null,0,-1)},apply(e,t,s){return zm(t,s,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let s=t.inputType,o=s=="historyUndo"?rd:s=="historyRedo"?Si:null;return o?(t.preventDefault(),o(e.state,e.dispatch)):!1}}}})}function id(n,e){return(t,s)=>{let o=Dt.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(s){let i=Bm(o,t,n);i&&s(e?i.scrollIntoView():i)}return!0}}const rd=id(!1,!0),Si=id(!0,!0);var yt={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:"'"},Qs={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},_m=typeof navigator<"u"&&/Mac/.test(navigator.platform),Gm=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var X=0;X<10;X++)yt[48+X]=yt[96+X]=String(X);for(var X=1;X<=24;X++)yt[X+111]="F"+X;for(var X=65;X<=90;X++)yt[X]=String.fromCharCode(X+32),Qs[X]=String.fromCharCode(X);for(var Bo in yt)Qs.hasOwnProperty(Bo)||(Qs[Bo]=yt[Bo]);function Wm(n){var e=_m&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Gm&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Qs:yt)[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 jm=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function qm(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let s,o,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))s=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))jm?r=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return s&&(t="Alt-"+t),o&&(t="Ctrl-"+t),r&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function Um(n){let e=Object.create(null);for(let t in n)e[qm(t)]=n[t];return e}function Ho(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 Fo(n){return new wn({props:{handleKeyDown:ld(n)}})}function ld(n){let e=Um(n);return function(t,s){let o=Wm(s),i,r=e[Ho(o,s)];if(r&&r(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(s.shiftKey){let l=e[Ho(o,s,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((s.shiftKey||s.altKey||s.metaKey||o.charCodeAt(0)>127)&&(i=yt[s.keyCode])&&i!=o){let l=e[Ho(i,s)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}function Cl(n,e=null){return function(t,s){let{$from:o,$to:i}=t.selection,r=o.blockRange(i),l=!1,a=r;if(!r)return!1;if(r.depth>=2&&o.node(r.depth-1).type.compatibleContent(n)&&r.startIndex==0){if(o.index(r.depth-1)==0)return!1;let d=t.doc.resolve(r.start-2);a=new Ks(d,d,r.depth),r.endIndex<r.parent.childCount&&(r=new Ks(o,t.doc.resolve(i.end(r.depth)),r.depth)),l=!0}let c=zc(a,n,e,r);return c?(s&&s(Km(t.tr,r,c,l,n).scrollIntoView()),!0):!1}}function Km(n,e,t,s,o){let i=T.empty;for(let d=t.length-1;d>=0;d--)i=T.from(t[d].type.create(t[d].attrs,i));n.step(new ee(e.start-(s?2:0),e.end,e.start,e.end,new A(i,0,0),t.length,!0));let r=0;for(let d=0;d<t.length;d++)t[d].type==o&&(r=d+1);let l=t.length-r,a=e.start+t.length-(s?2:0),c=e.parent;for(let d=e.startIndex,p=e.endIndex,u=!0;d<p;d++,u=!1)!u&&dn(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function Jm(n,e){return function(t,s){let{$from:o,$to:i,node:r}=t.selection;if(r&&r.isBlock||o.depth<2||!o.sameParent(i))return!1;let l=o.node(-1);if(l.type!=n)return!1;if(o.parent.content.size==0&&o.node(-1).childCount==o.indexAfter(-1)){if(o.depth==3||o.node(-3).type!=n||o.index(-2)!=o.node(-2).childCount-1)return!1;if(s){let p=T.empty,u=o.index(-1)?1:o.index(-2)?2:3;for(let b=o.depth-u;b>=o.depth-3;b--)p=T.from(o.node(b).copy(p));let h=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;p=p.append(T.from(n.createAndFill()));let f=o.before(o.depth-(u-1)),m=t.tr.replace(f,o.after(-h),new A(p,4-u,0)),g=-1;m.doc.nodesBetween(f,m.doc.content.size,(b,C)=>{if(g>-1)return!1;b.isTextblock&&b.content.size==0&&(g=C+1)}),g>-1&&m.setSelection(L.near(m.doc.resolve(g))),s(m.scrollIntoView())}return!0}let a=i.pos==o.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(o.pos,i.pos),d=a?[null,{type:a}]:void 0;return dn(c.doc,o.pos,2,d)?(s&&s(c.split(o.pos,2,d).scrollIntoView()),!0):!1}}function xi(n){return function(e,t){let{$from:s,$to:o}=e.selection,i=s.blockRange(o,r=>r.childCount>0&&r.firstChild.type==n);return i?t?s.node(i.depth-1).type==n?Zm(e,t,n,i):Ym(e,t,i):!0:!1}}function Zm(n,e,t,s){let o=n.tr,i=s.end,r=s.$to.end(s.depth);i<r&&(o.step(new ee(i-1,r,i,r,new A(T.from(t.create(null,s.parent.copy())),1,0),1,!0)),s=new Ks(o.doc.resolve(s.$from.pos),o.doc.resolve(r),s.depth));const l=mo(s);if(l==null)return!1;o.lift(s,l);let a=o.mapping.map(i,-1)-1;return go(o.doc,a)&&o.join(a),e(o.scrollIntoView()),!0}function Ym(n,e,t){let s=n.tr,o=t.parent;for(let h=t.end,f=t.endIndex-1,m=t.startIndex;f>m;f--)h-=o.child(f).nodeSize,s.delete(h-1,h+1);let i=s.doc.resolve(t.start),r=i.nodeAfter;if(s.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,r.content.append(a?T.empty:T.from(o))))return!1;let p=i.pos,u=p+r.nodeSize;return s.step(new ee(p-(l?1:0),u+(a?1:0),p+1,u-1,new A((l?T.empty:T.from(o.copy(T.empty))).append(a?T.empty:T.from(o.copy(T.empty))),l?0:1,a?0:1),l?0:1)),e(s.scrollIntoView()),!0}function Xm(n){return function(e,t){let{$from:s,$to:o}=e.selection,i=s.blockRange(o,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=T.from(c?n.create():null),p=new A(T.from(n.create(null,T.from(l.type.create(null,d)))),c?3:1,0),u=i.start,h=i.end;t(e.tr.step(new ee(u-(c?3:1),h,u,h,p,1,!0)).scrollIntoView())}return!0}}const Q=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Xn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let wi=null;const Ze=function(n,e,t){let s=wi||(wi=document.createRange());return s.setEnd(n,t??n.nodeValue.length),s.setStart(n,e||0),s},Qm=function(){wi=null},Ht=function(n,e,t,s){return t&&(kl(n,e,t,s,-1)||kl(n,e,t,s,1))},eg=/^(img|br|input|textarea|hr)$/i;function kl(n,e,t,s,o){for(;;){if(n==t&&e==s)return!0;if(e==(o<0?0:Ee(n))){let i=n.parentNode;if(!i||i.nodeType!=1||rs(n)||eg.test(n.nodeName)||n.contentEditable=="false")return!1;e=Q(n)+(o<0?0:1),n=i}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?Ee(n):0}else return!1}}function Ee(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function tg(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=Ee(n)}else if(n.parentNode&&!rs(n))e=Q(n),n=n.parentNode;else return null}}function ng(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&&!rs(n))e=Q(n)+1,n=n.parentNode;else return null}}function sg(n,e,t){for(let s=e==0,o=e==Ee(n);s||o;){if(n==t)return!0;let i=Q(n);if(n=n.parentNode,!n)return!1;s=s&&i==0,o=o&&i==Ee(n)}}function rs(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&&Ht(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 og(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function ig(n,e,t){if(n.caretPositionFromPoint)try{let s=n.caretPositionFromPoint(e,t);if(s)return{node:s.offsetNode,offset:Math.min(Ee(s.offsetNode),s.offset)}}catch{}if(n.caretRangeFromPoint){let s=n.caretRangeFromPoint(e,t);if(s)return{node:s.startContainer,offset:Math.min(Ee(s.startContainer),s.startOffset)}}}const _e=typeof navigator<"u"?navigator:null,El=typeof document<"u"?document:null,bt=_e&&_e.userAgent||"",Ci=/Edge\/(\d+)/.exec(bt),ad=/MSIE \d/.exec(bt),ki=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(bt),me=!!(ad||ki||Ci),ht=ad?document.documentMode:ki?+ki[1]:Ci?+Ci[1]:0,De=!me&&/gecko\/(\d+)/i.test(bt);De&&+(/Firefox\/(\d+)/.exec(bt)||[0,0])[1];const Ei=!me&&/Chrome\/(\d+)/.exec(bt),se=!!Ei,cd=Ei?+Ei[1]:0,ae=!me&&!!_e&&/Apple Computer/.test(_e.vendor),bn=ae&&(/Mobile\/\w+/.test(bt)||!!_e&&_e.maxTouchPoints>2),ke=bn||(_e?/Mac/.test(_e.platform):!1),rg=_e?/Win/.test(_e.platform):!1,Pe=/Android \d/.test(bt),ls=!!El&&"webkitFontSmoothing"in El.documentElement.style,lg=ls?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ag(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 qe(n,e){return typeof n=="number"?n:n[e]}function cg(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,s=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*s}}function Tl(n,e,t){let s=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let r=t||n.dom;r;r=Xn(r)){if(r.nodeType!=1)continue;let l=r,a=l==i.body,c=a?ag(i):cg(l),d=0,p=0;if(e.top<c.top+qe(s,"top")?p=-(c.top-e.top+qe(o,"top")):e.bottom>c.bottom-qe(s,"bottom")&&(p=e.bottom-e.top>c.bottom-c.top?e.top+qe(o,"top")-c.top:e.bottom-c.bottom+qe(o,"bottom")),e.left<c.left+qe(s,"left")?d=-(c.left-e.left+qe(o,"left")):e.right>c.right-qe(s,"right")&&(d=e.right-c.right+qe(o,"right")),d||p)if(a)i.defaultView.scrollBy(d,p);else{let u=l.scrollLeft,h=l.scrollTop;p&&(l.scrollTop+=p),d&&(l.scrollLeft+=d);let f=l.scrollLeft-u,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(r).position))break}}function dg(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),s,o;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){s=l,o=a.top;break}}return{refDOM:s,refTop:o,stack:dd(n.dom)}}function dd(n){let e=[],t=n.ownerDocument;for(let s=n;s&&(e.push({dom:s,top:s.scrollTop,left:s.scrollLeft}),n!=t);s=Xn(s));return e}function pg({refDOM:n,refTop:e,stack:t}){let s=n?n.getBoundingClientRect().top:0;pd(t,s==0?0:s-e)}function pd(n,e){for(let t=0;t<n.length;t++){let{dom:s,top:o,left:i}=n[t];s.scrollTop!=o+e&&(s.scrollTop=o+e),s.scrollLeft!=i&&(s.scrollLeft=i)}}let Jt=null;function ug(n){if(n.setActive)return n.setActive();if(Jt)return n.focus(Jt);let e=dd(n);n.focus(Jt==null?{get preventScroll(){return Jt={preventScroll:!0},!0}}:void 0),Jt||(Jt=!1,pd(e,0))}function ud(n,e){let t,s=2e8,o,i=0,r=e.top,l=e.top,a,c;for(let d=n.firstChild,p=0;d;d=d.nextSibling,p++){let u;if(d.nodeType==1)u=d.getClientRects();else if(d.nodeType==3)u=Ze(d).getClientRects();else continue;for(let h=0;h<u.length;h++){let f=u[h];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<s){t=d,s=m,o=m&&t.nodeType==3?{left:f.right<e.left?f.right:f.left,top:e.top}:e,d.nodeType==1&&m&&(i=p+(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=p+1)}}return!t&&a&&(t=a,o=c,s=0),t&&t.nodeType==3?hg(t,o):!t||s&&t.nodeType==1?{node:n,offset:i}:ud(t,o)}function hg(n,e){let t=n.nodeValue.length,s=document.createRange();for(let o=0;o<t;o++){s.setEnd(n,o+1),s.setStart(n,o);let i=st(s,1);if(i.top!=i.bottom&&ir(e,i))return{node:n,offset:o+(e.left>=(i.left+i.right)/2?1:0)}}return{node:n,offset:0}}function ir(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function fg(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function mg(n,e,t){let{node:s,offset:o}=ud(e,t),i=-1;if(s.nodeType==1&&!s.firstChild){let r=s.getBoundingClientRect();i=r.left!=r.right&&t.left>(r.left+r.right)/2?1:-1}return n.docView.posFromDOM(s,o,i)}function gg(n,e,t,s){let o=-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>s.left||a.top>s.top?o=l.posBefore:(!r&&a.right<s.left||a.bottom<s.top)&&(o=l.posAfter),r=!0),!l.contentDOM&&o<0&&!l.node.isText)return(l.node.isBlock?s.top<(a.top+a.bottom)/2:s.left<(a.left+a.right)/2)?l.posBefore:l.posAfter}i=l.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function hd(n,e,t){let s=n.childNodes.length;if(s&&t.top<t.bottom)for(let o=Math.max(0,Math.min(s-1,Math.floor(s*(e.top-t.top)/(t.bottom-t.top))-2)),i=o;;){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(ir(e,c))return hd(r,e,c)}}if((i=(i+1)%s)==o)break}return n}function yg(n,e){let t=n.dom.ownerDocument,s,o=0,i=ig(t,e.left,e.top);i&&({node:s,offset:o}=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(!ir(e,c)||(r=hd(n.dom,e,c),!r))return null}if(ae)for(let c=r;s&&c;c=Xn(c))c.draggable&&(s=void 0);if(r=fg(r,e),s){if(De&&s.nodeType==1&&(o=Math.min(o,s.childNodes.length),o<s.childNodes.length)){let d=s.childNodes[o],p;d.nodeName=="IMG"&&(p=d.getBoundingClientRect()).right<=e.left&&p.bottom>e.top&&o++}let c;ls&&o&&s.nodeType==1&&(c=s.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,s==n.dom&&o==s.childNodes.length-1&&s.lastChild.nodeType==1&&e.top>s.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||s.nodeType!=1||s.childNodes[o-1].nodeName!="BR")&&(l=gg(n,s,o,e))}l==null&&(l=mg(n,r,e));let a=n.docView.nearestDesc(r,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ml(n){return n.top<n.bottom||n.left<n.right}function st(n,e){let t=n.getClientRects();if(t.length){let s=t[e<0?0:t.length-1];if(Ml(s))return s}return Array.prototype.find.call(t,Ml)||n.getBoundingClientRect()}const bg=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function fd(n,e,t){let{node:s,offset:o,atom:i}=n.docView.domFromPos(e,t<0?-1:1),r=ls||De;if(s.nodeType==3)if(r&&(bg.test(s.nodeValue)||(t<0?!o:o==s.nodeValue.length))){let a=st(Ze(s,o,o),t);if(De&&o&&/\s/.test(s.nodeValue[o-1])&&o<s.nodeValue.length){let c=st(Ze(s,o-1,o-1),-1);if(c.top==a.top){let d=st(Ze(s,o,o+1),-1);if(d.top!=a.top)return Tn(d,d.left<c.left)}}return a}else{let a=o,c=o,d=t<0?1:-1;return t<0&&!o?(c++,d=-1):t>=0&&o==s.nodeValue.length?(a--,d=1):t<0?a--:c++,Tn(st(Ze(s,a,c),d),d<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(t<0||o==Ee(s))){let a=s.childNodes[o-1];if(a.nodeType==1)return _o(a.getBoundingClientRect(),!1)}if(i==null&&o<Ee(s)){let a=s.childNodes[o];if(a.nodeType==1)return _o(a.getBoundingClientRect(),!0)}return _o(s.getBoundingClientRect(),t>=0)}if(i==null&&o&&(t<0||o==Ee(s))){let a=s.childNodes[o-1],c=a.nodeType==3?Ze(a,Ee(a)-(r?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Tn(st(c,1),!1)}if(i==null&&o<Ee(s)){let a=s.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Ze(a,0,r?0:1):a.nodeType==1?a:null:null;if(c)return Tn(st(c,-1),!0)}return Tn(st(s.nodeType==3?Ze(s):s,-t),t>=0)}function Tn(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 _o(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 md(n,e,t){let s=n.state,o=n.root.activeElement;s!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{s!=e&&n.updateState(s),o!=n.dom&&o&&o.focus()}}function vg(n,e,t){let s=e.selection,o=t=="up"?s.$from:s.$to;return md(n,e,()=>{let{node:i}=n.docView.domFromPos(o.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=fd(n,o.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=Ze(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 Sg=/[\u0590-\u08ac]/;function xg(n,e,t){let{$head:s}=e.selection;if(!s.parent.isTextblock)return!1;let o=s.parentOffset,i=!o,r=o==s.parent.content.size,l=n.domSelection();return l?!Sg.test(s.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:r:md(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:p}=n.domSelectionRange(),u=l.caretBidiLevel;l.modify("move",t,"character");let h=s.depth?n.docView.domAfterPos(s.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,p),a&&(a!=d||c!=p)&&l.extend&&l.extend(a,c)}catch{}return u!=null&&(l.caretBidiLevel=u),g}):s.pos==s.start()||s.pos==s.end()}let Al=null,Pl=null,Nl=!1;function wg(n,e,t){return Al==e&&Pl==t?Nl:(Al=e,Pl=t,Nl=t=="up"||t=="down"?vg(n,e,t):xg(n,e,t))}const Te=0,Il=1,At=2,Ge=3;class as{constructor(e,t,s,o){this.parent=e,this.children=t,this.dom=s,this.contentDOM=o,this.dirty=Te,s.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,s){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,s=this.posAtStart;;t++){let o=this.children[t];if(o==e)return s;s+=o.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,s){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(s<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 o;if(e==this.dom&&this.contentDOM)o=t>Q(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??s>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let s=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),r;if(i&&(!t||i.node))if(s&&(r=i.nodeDOM)&&!(r.nodeType==1?r.contains(e.nodeType==1?e:e.parentNode):r==e))s=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let s=t;s;s=s.parent)if(s==this)return t}posFromDOM(e,t,s){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,t,s)}return-1}descAt(e){for(let t=0,s=0;t<this.children.length;t++){let o=this.children[t],i=s+o.size;if(s==e&&i!=s){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(e<i)return o.descAt(e-s-o.border);s=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let s=0,o=0;for(let i=0;s<this.children.length;s++){let r=this.children[s],l=i+r.size;if(l>e||r instanceof yd){o=e-i;break}i=l}if(o)return this.children[s].domFromPos(o-this.children[s].border,t);for(let i;s&&!(i=this.children[s-1]).size&&i instanceof gd&&i.side>=0;s--);if(t<=0){let i,r=!0;for(;i=s?this.children[s-1]:null,!(!i||i.dom.parentNode==this.contentDOM);s--,r=!1);return i&&t&&r&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?Q(i.dom)+1:0}}else{let i,r=!0;for(;i=s<this.children.length?this.children[s]:null,!(!i||i.dom.parentNode==this.contentDOM);s++,r=!1);return i&&r&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?Q(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,s=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let r=s,l=0;;l++){let a=this.children[l],c=r+a.size;if(o==-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 p=l;p>0;p--){let u=this.children[p-1];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(1)){o=Q(u.dom)+1;break}e-=u.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let p=this.children[d];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(-1)){i=Q(p.dom);break}t+=p.size}i==-1&&(i=this.contentDOM.childNodes.length);break}r=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,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:s}=this.domFromPos(e,0);if(t.nodeType!=1||s==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[s]}setSelection(e,t,s,o=!1){let i=Math.min(e,t),r=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(i>f&&r<g)return m.setSelection(e-f-m.border,t-f-m.border,s,o);f=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=s.root.getSelection(),d=s.domSelectionRange(),p=!1;if((De||ae)&&e==t){let{node:h,offset:f}=l;if(h.nodeType==3){if(p=!!(f&&h.nodeValue[f-1]==`
|
|
913
|
-
`),p&&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:Q(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=h.childNodes[f-1];p=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(De&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(o=!0)}if(!(o||p&&ae)&&Ht(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Ht(a.node,a.offset,d.focusNode,d.focusOffset))return;let u=!1;if((c.extend||e==t)&&!p){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),u=!0}catch{}}if(!u){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 s=0,o=0;o<this.children.length;o++){let i=this.children[o],r=s+i.size;if(s==r?e<=r&&t>=s:e<r&&t>s){let l=s+i.border,a=r-i.border;if(e>=l&&t<=a){this.dirty=e==s||t==r?At:Il,e==l&&t==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Ge:i.markDirty(e-l,t-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?At:Ge}s=r}this.dirty=At}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let s=e==1?At:Il;t.dirty<s&&(t.dirty=s)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class gd extends as{constructor(e,t,s,o){let i,r=t.type.toDOM;if(typeof r=="function"&&(r=r(s,()=>{if(!i)return o;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==Te&&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 Cg extends as{constructor(e,t,s,o){super(e,[],t,null),this.textDOM=s,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Ft extends as{constructor(e,t,s,o,i){super(e,[],s,o),this.mark=t,this.spec=i}static create(e,t,s,o){let i=o.nodeViews[t.type.name],r=i&&i(t,o,s);return(!r||!r.dom)&&(r=Wt.renderSpec(document,t.type.spec.toDOM(t,s),null,t.attrs)),new Ft(e,t,r.dom,r.contentDOM||r.dom,r)}parseRule(){return this.dirty&Ge||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ge&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Te){let s=this.parent;for(;!s.node;)s=s.parent;s.dirty<this.dirty&&(s.dirty=this.dirty),this.dirty=Te}}slice(e,t,s){let o=Ft.create(this.parent,this.mark,!0,s),i=this.children,r=this.size;t<r&&(i=Mi(i,t,r,s)),e>0&&(i=Mi(i,0,e,s));for(let l=0;l<i.length;l++)i[l].parent=o;return o.children=i,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class ft extends as{constructor(e,t,s,o,i,r,l,a,c){super(e,[],i,r),this.node=t,this.outerDeco=s,this.innerDeco=o,this.nodeDOM=l}static create(e,t,s,o,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)},s,o),d=c&&c.dom,p=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:p}=Wt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!p&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let u=d;return d=Sd(d,s,t),c?a=new kg(e,t,s,o,d,p||null,u,c,i,r+1):t.isText?new vo(e,t,s,o,d,u,i):new ft(e,t,s,o,d,p||null,u,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 s=this.children[t];if(this.dom.contains(s.dom.parentNode)){e.contentElement=s.dom.parentNode;break}}e.contentElement||(e.getContent=()=>T.empty)}return e}matchesNode(e,t,s){return this.dirty==Te&&e.eq(this.node)&&eo(t,this.outerDeco)&&s.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let s=this.node.inlineContent,o=t,i=e.composing?this.localCompositionInfo(e,t):null,r=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Tg(this,r&&r.node,e);Pg(this.node,this.innerDeco,(c,d,p)=>{c.spec.marks?a.syncToMarks(c.spec.marks,s,e):c.type.side>=0&&!p&&a.syncToMarks(d==this.node.childCount?B.none:this.node.child(d).marks,s,e),a.placeWidget(c,e,o)},(c,d,p,u)=>{a.syncToMarks(c.marks,s,e);let h;a.findNodeMatch(c,d,p,u)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(h=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,d,p,h,e)||a.updateNextNode(c,d,p,e,u,o)||a.addNode(c,d,p,e,o),o+=c.nodeSize}),a.syncToMarks([],s,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==At)&&(r&&this.protectLocalComposition(e,r),bd(this.contentDOM,this.children,e),bn&&Ng(this.dom))}localCompositionInfo(e,t){let{from:s,to:o}=e.state.selection;if(!(e.state.selection instanceof $)||s<t||o>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=Ig(this.node.content,r,s-t,o-t);return l<0?null:{node:i,pos:l,text:r}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:s,text:o}){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 Cg(this,i,t,o);e.input.compositionNodes.push(r),this.children=Mi(this.children,s,s+o.length,e,r)}update(e,t,s,o){return this.dirty==Ge||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,s,o),!0)}updateInner(e,t,s,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=s,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=Te}updateOuterDeco(e){if(eo(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,s=this.dom;this.dom=vd(this.dom,this.nodeDOM,Ti(this.outerDeco,this.node,t),Ti(e,this.node,t)),this.dom!=s&&(s.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 Ol(n,e,t,s,o){Sd(s,e,n);let i=new ft(void 0,n,e,t,s,s,s,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class vo extends ft{constructor(e,t,s,o,i,r,l){super(e,t,s,o,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,s,o){return this.dirty==Ge||this.dirty!=Te&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Te||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=Te,!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,s){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,s)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,s){let o=this.node.cut(e,t),i=document.createTextNode(o.text);return new vo(this.parent,o,this.outerDeco,this.innerDeco,i,i,s)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ge)}get domAtom(){return!1}isText(e){return this.node.text==e}}class yd extends as{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Te&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class kg extends ft{constructor(e,t,s,o,i,r,l,a,c,d){super(e,t,s,o,i,r,l,c,d),this.spec=a}update(e,t,s,o){if(this.dirty==Ge)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,s);return i&&this.updateInner(e,t,s,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,s,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,s,o){this.spec.setSelection?this.spec.setSelection(e,t,s.root):super.setSelection(e,t,s,o)}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 bd(n,e,t){let s=n.firstChild,o=!1;for(let i=0;i<e.length;i++){let r=e[i],l=r.dom;if(l.parentNode==n){for(;l!=s;)s=Rl(s),o=!0;s=s.nextSibling}else o=!0,n.insertBefore(l,s);if(r instanceof Ft){let a=s?s.previousSibling:n.lastChild;bd(r.contentDOM,r.children,t),s=a?a.nextSibling:n.firstChild}}for(;s;)s=Rl(s),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}const Bn=function(n){n&&(this.nodeName=n)};Bn.prototype=Object.create(null);const Pt=[new Bn];function Ti(n,e,t){if(n.length==0)return Pt;let s=t?Pt[0]:new Bn,o=[s];for(let i=0;i<n.length;i++){let r=n[i].type.attrs;if(r){r.nodeName&&o.push(s=new Bn(r.nodeName));for(let l in r){let a=r[l];a!=null&&(t&&o.length==1&&o.push(s=new Bn(e.isInline?"span":"div")),l=="class"?s.class=(s.class?s.class+" ":"")+a:l=="style"?s.style=(s.style?s.style+";":"")+a:l!="nodeName"&&(s[l]=a))}}}return o}function vd(n,e,t,s){if(t==Pt&&s==Pt)return e;let o=e;for(let i=0;i<s.length;i++){let r=s[i],l=t[i];if(i){let a;l&&l.nodeName==r.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==r.nodeName||(a=document.createElement(r.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=Pt[0]),o=a}Eg(o,l||Pt[0],r)}return o}function Eg(n,e,t){for(let s in e)s!="class"&&s!="style"&&s!="nodeName"&&!(s in t)&&n.removeAttribute(s);for(let s in t)s!="class"&&s!="style"&&s!="nodeName"&&t[s]!=e[s]&&n.setAttribute(s,t[s]);if(e.class!=t.class){let s=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<s.length;i++)o.indexOf(s[i])==-1&&n.classList.remove(s[i]);for(let i=0;i<o.length;i++)s.indexOf(o[i])==-1&&n.classList.add(o[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let s=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=s.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function Sd(n,e,t){return vd(n,n,Pt,Ti(e,t,n.nodeType!=1))}function eo(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 Rl(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Tg{constructor(e,t,s){this.lock=t,this.view=s,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Mg(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let s=e;s<t;s++)this.top.children[s].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,s){let o=0,i=this.stack.length>>1,r=Math.min(i,e.length);for(;o<r&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<i;)this.destroyRest(),this.top.dirty=Te,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=Ft.create(this.top,e[i],t,s);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,s,o){let i=-1,r;if(o>=this.preMatch.index&&(r=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&r.matchesNode(e,t,s))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,s)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,s,o,i){let r=this.top.children[o];return r.dirty==Ge&&r.dom==r.contentDOM&&(r.dirty=At),r.update(e,t,s,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let s=e.pmViewDesc;if(s){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==s)return o}return-1}e=t}}updateNextNode(e,t,s,o,i,r){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof ft){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let d=a.dom,p,u=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Ge&&eo(t,a.outerDeco));if(!u&&a.update(e,t,s,o))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!u&&(p=this.recreateWrapper(a,e,t,s,o,r)))return this.destroyBetween(this.index,l),this.top.children[this.index]=p,p.contentDOM&&(p.dirty=At,p.updateChildren(o,r+1),p.dirty=Te),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,s,o,i,r){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!eo(s,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=ft.create(this.top,t,s,o,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,s,o,i){let r=ft.create(this.top,e,t,s,o,i);r.contentDOM&&r.updateChildren(o,i+1),this.top.children.splice(this.index++,0,r),this.changed=!0}placeWidget(e,t,s){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new gd(this.top,e,t,s);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 Ft;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof vo)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ae||se)&&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 s=document.createElement(e);e=="IMG"&&(s.className="ProseMirror-separator",s.alt=""),e=="BR"&&(s.className="ProseMirror-trailingBreak");let o=new yd(this.top,[],s,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Mg(n,e){let t=e,s=t.children.length,o=n.childCount,i=new Map,r=[];e:for(;o>0;){let l;for(;;)if(s){let c=t.children[s-1];if(c instanceof Ft)t=c,s=c.children.length;else{l=c,s--;break}}else{if(t==e)break e;s=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(o-1))break;--o,i.set(l,o),r.push(l)}}return{index:o,matched:i,matches:r.reverse()}}function Ag(n,e){return n.type.side-e.type.side}function Pg(n,e,t,s){let o=e.locals(n),i=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);s(d,o,e.forChild(i,d),c),i+=d.nodeSize}return}let r=0,l=[],a=null;for(let c=0;;){let d,p;for(;r<o.length&&o[r].to==i;){let g=o[r++];g.widget&&(d?(p||(p=[d])).push(g):d=g)}if(d)if(p){p.sort(Ag);for(let g=0;g<p.length;g++)t(p[g],c,!!a)}else t(d,c,!!a);let u,h;if(a)h=-1,u=a,a=null;else if(c<n.childCount)h=c,u=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;r<o.length&&o[r].from<=i&&o[r].to>i;)l.push(o[r++]);let f=i+u.nodeSize;if(u.isText){let g=f;r<o.length&&o[r].from<g&&(g=o[r].from);for(let b=0;b<l.length;b++)l[b].to<g&&(g=l[b].to);g<f&&(a=u.cut(g-i),u=u.cut(0,g-i),f=g,h=-1)}else for(;r<o.length&&o[r].to<f;)r++;let m=u.isInline&&!u.isLeaf?l.filter(g=>!g.inline):l.slice();s(u,m,e.forChild(i,u),h),i=f}}function Ng(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 Ig(n,e,t,s){for(let o=0,i=0;o<n.childCount&&i<=s;){let r=n.child(o++),l=i;if(i+=r.nodeSize,!r.isText)continue;let a=r.text;for(;o<n.childCount;){let c=n.child(o++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=t){if(i>=s&&a.slice(s-e.length-l,s-l)==e)return s-e.length;let c=l<s?a.lastIndexOf(e,s-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==s&&a.length>=s+e.length-l&&a.slice(s-l,s-l+e.length)==e)return s}}return-1}function Mi(n,e,t,s,o){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,s)),o&&(i.push(o),o=void 0),d>t&&i.push(a.slice(t-c,a.size,s)))}return i}function rr(n,e=null){let t=n.domSelectionRange(),s=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),i=o&&o.size==0,r=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(r<0)return null;let l=s.resolve(r),a,c;if(bo(t)){for(a=r;o&&!o.node;)o=o.parent;let p=o.node;if(o&&p.isAtom&&D.isSelectable(p)&&o.parent&&!(p.isInline&&sg(t.focusNode,t.focusOffset,o.dom))){let u=o.posBefore;c=new D(r==u?l:s.resolve(u))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let p=r,u=r;for(let h=0;h<t.rangeCount;h++){let f=t.getRangeAt(h);p=Math.min(p,n.docView.posFromDOM(f.startContainer,f.startOffset,1)),u=Math.max(u,n.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(p<0)return null;[a,r]=u==n.state.selection.anchor?[u,p]:[p,u],l=s.resolve(r)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=s.resolve(a);if(!c){let p=e=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=lr(n,d,l,p)}return c}function xd(n){return n.editable?n.hasFocus():Cd(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function et(n,e=!1){let t=n.state.selection;if(wd(n,t),!!xd(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&se){let s=n.domSelectionRange(),o=n.domObserver.currentSelection;if(s.anchorNode&&o.anchorNode&&Ht(s.anchorNode,s.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Rg(n);else{let{anchor:s,head:o}=t,i,r;Dl&&!(t instanceof $)&&(t.$from.parent.inlineContent||(i=Ll(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(r=Ll(n,t.to))),n.docView.setSelection(s,o,n,e),Dl&&(i&&$l(i),r&&$l(r)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Og(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Dl=ae||se&&cd<63;function Ll(n,e){let{node:t,offset:s}=n.docView.domFromPos(e,0),o=s<t.childNodes.length?t.childNodes[s]:null,i=s?t.childNodes[s-1]:null;if(ae&&o&&o.contentEditable=="false")return Go(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return Go(o);if(i)return Go(i)}}function Go(n){return n.contentEditable="true",ae&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function $l(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Og(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),s=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=s||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!xd(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Rg(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let s=n.cursorWrapper.dom,o=s.nodeName=="IMG";o?t.setStart(s.parentNode,Q(s)+1):t.setStart(s,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&me&&ht<=11&&(s.disabled=!0,s.disabled=!1)}function wd(n,e){if(e instanceof D){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(zl(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else zl(n)}function zl(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function lr(n,e,t,s){return n.someProp("createSelectionBetween",o=>o(n,e,t))||$.between(e,t,s)}function Vl(n){return n.editable&&!n.hasFocus()?!1:Cd(n)}function Cd(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 Dg(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Ht(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ai(n,e){let{$anchor:t,$head:s}=n.selection,o=e>0?t.max(s):t.min(s),i=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return i&&L.findFrom(i,e)}function it(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Bl(n,e,t){let s=n.state.selection;if(s instanceof $)if(t.indexOf("s")>-1){let{$head:o}=s,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let r=n.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return it(n,new $(s.$anchor,r))}else if(s.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Ai(n.state,e);return o&&o instanceof D?it(n,o):!1}else if(!(ke&&t.indexOf("m")>-1)){let o=s.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,r;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(r=n.docView.descAt(l))&&!r.contentDOM?D.isSelectable(i)?it(n,new D(e<0?n.state.doc.resolve(o.pos-i.nodeSize):o)):ls?it(n,new $(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(s instanceof D&&s.node.isInline)return it(n,new $(e>0?s.$to:s.$from));{let o=Ai(n.state,e);return o?it(n,o):!1}}}function to(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Hn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Zt(n,e){return e<0?Lg(n):$g(n)}function Lg(n){let e=n.domSelectionRange(),t=e.focusNode,s=e.focusOffset;if(!t)return;let o,i,r=!1;for(De&&t.nodeType==1&&s<to(t)&&Hn(t.childNodes[s],-1)&&(r=!0);;)if(s>0){if(t.nodeType!=1)break;{let l=t.childNodes[s-1];if(Hn(l,-1))o=t,i=--s;else if(l.nodeType==3)t=l,s=t.nodeValue.length;else break}}else{if(kd(t))break;{let l=t.previousSibling;for(;l&&Hn(l,-1);)o=t.parentNode,i=Q(l),l=l.previousSibling;if(l)t=l,s=to(t);else{if(t=t.parentNode,t==n.dom)break;s=0}}}r?Pi(n,t,s):o&&Pi(n,o,i)}function $g(n){let e=n.domSelectionRange(),t=e.focusNode,s=e.focusOffset;if(!t)return;let o=to(t),i,r;for(;;)if(s<o){if(t.nodeType!=1)break;let l=t.childNodes[s];if(Hn(l,1))i=t,r=++s;else break}else{if(kd(t))break;{let l=t.nextSibling;for(;l&&Hn(l,1);)i=l.parentNode,r=Q(l)+1,l=l.nextSibling;if(l)t=l,s=0,o=to(t);else{if(t=t.parentNode,t==n.dom)break;s=o=0}}}i&&Pi(n,i,r)}function kd(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function zg(n,e){for(;n&&e==n.childNodes.length&&!rs(n);)e=Q(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 Vg(n,e){for(;n&&!e&&!rs(n);)e=Q(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 Pi(n,e,t){if(e.nodeType!=3){let i,r;(r=zg(e,t))?(e=r,t=0):(i=Vg(e,t))&&(e=i,t=i.nodeValue.length)}let s=n.domSelection();if(!s)return;if(bo(s)){let i=document.createRange();i.setEnd(e,t),i.setStart(e,t),s.removeAllRanges(),s.addRange(i)}else s.extend&&s.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&et(n)},50)}function Hl(n,e){let t=n.state.doc.resolve(e);if(!(se||rg)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),r=(i.top+i.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(i.left-o.left)>1)return i.left<o.left?"ltr":"rtl"}if(e<t.end()){let i=n.coordsAtPos(e+1),r=(i.top+i.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(i.left-o.left)>1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Fl(n,e,t){let s=n.state.selection;if(s instanceof $&&!s.empty||t.indexOf("s")>-1||ke&&t.indexOf("m")>-1)return!1;let{$from:o,$to:i}=s;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let r=Ai(n.state,e);if(r&&r instanceof D)return it(n,r)}if(!o.parent.inlineContent){let r=e<0?o:i,l=s instanceof Se?L.near(r,e):L.findFrom(r,e);return l?it(n,l):!1}return!1}function _l(n,e){if(!(n.state.selection instanceof $))return!0;let{$head:t,$anchor:s,empty:o}=n.state.selection;if(!t.sameParent(s))return!0;if(!o)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 Gl(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Bg(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 s=e.firstChild;Gl(n,s,"true"),setTimeout(()=>Gl(n,s,"false"),20)}return!1}function Hg(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Fg(n,e){let t=e.keyCode,s=Hg(e);if(t==8||ke&&t==72&&s=="c")return _l(n,-1)||Zt(n,-1);if(t==46&&!e.shiftKey||ke&&t==68&&s=="c")return _l(n,1)||Zt(n,1);if(t==13||t==27)return!0;if(t==37||ke&&t==66&&s=="c"){let o=t==37?Hl(n,n.state.selection.from)=="ltr"?-1:1:-1;return Bl(n,o,s)||Zt(n,o)}else if(t==39||ke&&t==70&&s=="c"){let o=t==39?Hl(n,n.state.selection.from)=="ltr"?1:-1:1;return Bl(n,o,s)||Zt(n,o)}else{if(t==38||ke&&t==80&&s=="c")return Fl(n,-1,s)||Zt(n,-1);if(t==40||ke&&t==78&&s=="c")return Bg(n)||Fl(n,1,s)||Zt(n,1);if(s==(ke?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Ed(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:s,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&s.childCount==1&&s.firstChild.childCount==1;){o--,i--;let h=s.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),s=h.content}let r=n.someProp("clipboardSerializer")||Wt.fromSchema(n.state.schema),l=Id(),a=l.createElement("div");a.appendChild(r.serializeFragment(s,{document:l}));let c=a.firstChild,d,p=0;for(;c&&c.nodeType==1&&(d=Nd[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),p++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${i}${p?` -${p}`:""} ${JSON.stringify(t)}`);let u=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
|
|
914
|
-
|
|
915
|
-
`);return{dom:a,text:u,slice:e}}function Td(n,e,t,s
|
|
916
|
-
`))),0,0):A.empty;let p=n.someProp("clipboardTextParser",u=>u(e,o,s,n));if(p)l=p;else{let u=o.marks(),{schema:h}=n.state,f=Wt.fromSchema(h);r=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=r.appendChild(document.createElement("p"));m&&g.appendChild(f.serializeNode(h.text(m,u)))})}}else n.someProp("transformPastedHTML",p=>{t=p(t,n)}),r=jg(t),ls&&qg(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 p=+d[3];p>0;p--){let u=r.firstChild;for(;u&&u.nodeType!=1;)u=u.nextSibling;if(!u)break;r=u}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Bt.fromSchema(n.state.schema)).parseSlice(r,{preserveWhitespace:!!(a||d),context:o,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!_g.test(u.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Ug(Wl(l,+d[1],+d[2]),d[4]);else if(l=A.maxOpen(Gg(l.content,o),!0),l.openStart||l.openEnd){let p=0,u=0;for(let h=l.content.firstChild;p<l.openStart&&!h.type.spec.isolating;p++,h=h.firstChild);for(let h=l.content.lastChild;u<l.openEnd&&!h.type.spec.isolating;u++,h=h.lastChild);l=Wl(l,p,u)}return n.someProp("transformPasted",p=>{l=p(l,n)}),l}const _g=/^(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 Gg(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),i,r=[];if(n.forEach(l=>{if(!r)return;let a=o.findWrapping(l.type),c;if(!a)return r=null;if(c=r.length&&i.length&&Ad(a,i,l,r[r.length-1],0))r[r.length-1]=c;else{r.length&&(r[r.length-1]=Pd(r[r.length-1],i.length));let d=Md(l,a);r.push(d),o=o.matchType(d.type),i=a}}),r)return T.from(r)}return n}function Md(n,e,t=0){for(let s=e.length-1;s>=t;s--)n=e[s].create(null,T.from(n));return n}function Ad(n,e,t,s,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let i=Ad(n,e,t,s.lastChild,o+1);if(i)return s.copy(s.content.replaceChild(s.childCount-1,i));if(s.contentMatchAt(s.childCount).matchType(o==n.length-1?t.type:n[o+1]))return s.copy(s.content.append(T.from(Md(t,n,o+1))))}}function Pd(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Pd(n.lastChild,e-1)),s=n.contentMatchAt(n.childCount).fillBefore(T.empty,!0);return n.copy(t.append(s))}function Ni(n,e,t,s,o,i){let r=e<0?n.firstChild:n.lastChild,l=r.content;return n.childCount>1&&(i=0),o<s-1&&(l=Ni(l,e,t,s,o+1,i)),o>=t&&(l=e<0?r.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(r.contentMatchAt(r.childCount).fillBefore(T.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,r.copy(l))}function Wl(n,e,t){return e<n.openStart&&(n=new A(Ni(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new A(Ni(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Nd={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 jl=null;function Id(){return jl||(jl=document.implementation.createHTMLDocument("title"))}let Wo=null;function Wg(n){let e=window.trustedTypes;return e?(Wo||(Wo=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Wo.createHTML(n)):n}function jg(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Id().createElement("div"),s=/<([a-z][^>\s]+)/i.exec(n),o;if((o=s&&Nd[s[1].toLowerCase()])&&(n=o.map(i=>"<"+i+">").join("")+n+o.map(i=>"</"+i+">").reverse().join("")),t.innerHTML=Wg(n),o)for(let i=0;i<o.length;i++)t=t.querySelector(o[i])||t;return t}function qg(n){let e=n.querySelectorAll(se?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let s=e[t];s.childNodes.length==1&&s.textContent==" "&&s.parentNode&&s.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),s)}}function Ug(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,s;try{s=JSON.parse(e)}catch{return n}let{content:o,openStart:i,openEnd:r}=n;for(let l=s.length-2;l>=0;l-=2){let a=t.nodes[s[l]];if(!a||a.hasRequiredAttrs())break;o=T.from(a.create(s[l+1],o)),i++,r++}return new A(o,i,r)}const ce={},de={},Kg={touchstart:!0,touchmove:!0};class Jg{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 Zg(n){for(let e in ce){let t=ce[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=s=>{Xg(n,s)&&!ar(n,s)&&(n.editable||!(s.type in de))&&t(n,s)},Kg[e]?{passive:!0}:void 0)}ae&&n.dom.addEventListener("input",()=>null),Ii(n)}function pt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Yg(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 Ii(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=s=>ar(n,s))})}function ar(n,e){return n.someProp("handleDOMEvents",t=>{let s=t[e.type];return s?s(n,e)||e.defaultPrevented:!1})}function Xg(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 Qg(n,e){!ar(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,!Rd(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Pe&&se&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),bn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let s=Date.now();n.input.lastIOSEnter=s,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==s&&(n.someProp("handleKeyDown",o=>o(n,Et(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",s=>s(n,t))||Fg(n,t)?t.preventDefault():pt(n,"key")};de.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};de.keypress=(n,e)=>{let t=e;if(Rd(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ke&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let s=n.state.selection;if(!(s instanceof $)||!s.$from.sameParent(s.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",i=>i(n,s.$from.pos,s.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function So(n){return{left:n.clientX,top:n.clientY}}function e1(n,e){let t=e.x-n.clientX,s=e.y-n.clientY;return t*t+s*s<100}function cr(n,e,t,s,o){if(s==-1)return!1;let i=n.state.doc.resolve(s);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),o,!0):l(n,t,i.node(r),i.before(r),o,!1)))return!0;return!1}function un(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let s=n.state.tr.setSelection(e);s.setMeta("pointer",!0),n.dispatch(s)}function t1(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),s=t.nodeAfter;return s&&s.isAtom&&D.isSelectable(s)?(un(n,new D(t)),!0):!1}function n1(n,e){if(e==-1)return!1;let t=n.state.selection,s,o;t instanceof D&&(s=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(D.isSelectable(l)){s&&t.$from.depth>0&&r>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?o=i.before(t.$from.depth):o=i.before(r);break}}return o!=null?(un(n,D.create(n.state.doc,o)),!0):!1}function s1(n,e,t,s,o){return cr(n,"handleClickOn",e,t,s)||n.someProp("handleClick",i=>i(n,e,s))||(o?n1(n,t):t1(n,t))}function o1(n,e,t,s){return cr(n,"handleDoubleClickOn",e,t,s)||n.someProp("handleDoubleClick",o=>o(n,e,s))}function i1(n,e,t,s){return cr(n,"handleTripleClickOn",e,t,s)||n.someProp("handleTripleClick",o=>o(n,e,s))||r1(n,t,s)}function r1(n,e,t){if(t.button!=0)return!1;let s=n.state.doc;if(e==-1)return s.inlineContent?(un(n,$.create(s,0,s.content.size)),!0):!1;let o=s.resolve(e);for(let i=o.depth+1;i>0;i--){let r=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(r.inlineContent)un(n,$.create(s,l+1,l+1+r.content.size));else if(D.isSelectable(r))un(n,D.create(s,l));else continue;return!0}}function dr(n){return no(n)}const Od=ke?"metaKey":"ctrlKey";ce.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let s=dr(n),o=Date.now(),i="singleClick";o-n.input.lastClick.time<500&&e1(t,n.input.lastClick)&&!t[Od]&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:i};let r=n.posAtCoords(So(t));r&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new l1(n,r,t,!!s)):(i=="doubleClick"?o1:i1)(n,r.pos,r.inside,t)?t.preventDefault():pt(n,"pointer"))};class l1{constructor(e,t,s,o){this.view=e,this.pos=t,this.event=s,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!s[Od],this.allowDefault=s.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=o?null:s.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(s.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof D&&c.from<=r&&c.to>r)&&(this.mightDrag={node:i,pos:r,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&De&&!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)),pt(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(()=>et(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(So(e))),this.updateAllowDefault(e),this.allowDefault||!t?pt(this.view,"pointer"):s1(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ae&&this.mightDrag&&!this.mightDrag.node.isAtom||se&&!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,L.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):pt(this.view,"pointer")}move(e){this.updateAllowDefault(e),pt(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(),dr(n),pt(n,"pointer")};ce.touchmove=n=>{n.input.lastTouch=Date.now(),pt(n,"pointer")};ce.contextmenu=n=>dr(n);function Rd(n,e){return n.composing?!0:ae&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const a1=Pe?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 $&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(s=>s.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),no(n,!0),n.markCursor=null;else if(no(n,!e.selection.empty),De&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let s=n.domSelectionRange();for(let o=s.focusNode,i=s.focusOffset;o&&o.nodeType==1&&i!=0;){let r=i<0?o.lastChild:o.childNodes[i-1];if(!r)break;if(r.nodeType==3){let l=n.domSelection();l&&l.collapse(r,r.nodeValue.length);break}else o=r,i=-1}}n.input.composing=!0}Dd(n,a1)};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++,Dd(n,20))};function Dd(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>no(n),e))}function Ld(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=d1());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function c1(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=tg(e.focusNode,e.focusOffset),s=ng(e.focusNode,e.focusOffset);if(t&&s&&t!=s){let o=s.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||s==i)return i;if(!o||!o.isText(s.nodeValue))return s;if(n.input.compositionNode==s){let r=t.pmViewDesc;if(!(!r||!r.isText(t.nodeValue)))return s}}return t||s}function d1(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function no(n,e=!1){if(!(Pe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ld(n),e||n.docView&&n.docView.dirty){let t=rr(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 p1(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 s=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),s.removeAllRanges(),s.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Qn=me&&ht<15||bn&&lg<604;ce.copy=de.cut=(n,e)=>{let t=e,s=n.state.selection,o=t.type=="cut";if(s.empty)return;let i=Qn?null:t.clipboardData,r=s.content(),{dom:l,text:a}=Ed(n,r);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):p1(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function u1(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function h1(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,s=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(s.contentEditable="true"),s.style.cssText="position: fixed; left: -10000px; top: 10px",s.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),s.parentNode&&s.parentNode.removeChild(s),t?es(n,s.value,null,o,e):es(n,s.textContent,s.innerHTML,o,e)},50)}function es(n,e,t,s,o){let i=Td(n,e,t,s,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,i||A.empty)))return!0;if(!i)return!1;let r=u1(i),l=r?n.state.tr.replaceSelectionWith(r,s):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function $d(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&&!Pe)return;let s=Qn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;s&&es(n,$d(s),s.getData("text/html"),o,t)?t.preventDefault():h1(n,t)};class zd{constructor(e,t,s){this.slice=e,this.move=t,this.node=s}}const Vd=ke?"altKey":"ctrlKey";ce.dragstart=(n,e)=>{let t=e,s=n.input.mouseDown;if(s&&s.done(),!t.dataTransfer)return;let o=n.state.selection,i=o.empty?null:n.posAtCoords(So(t)),r;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof D?o.to-1:o.to))){if(s&&s.mightDrag)r=D.create(n.state.doc,s.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let p=n.docView.nearestDesc(t.target,!0);p&&p.node.type.spec.draggable&&p!=n.docView&&(r=D.create(n.state.doc,p.posBefore))}}let l=(r||n.state.selection).content(),{dom:a,text:c,slice:d}=Ed(n,l);(!t.dataTransfer.files.length||!se||cd>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Qn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Qn||t.dataTransfer.setData("text/plain",c),n.dragging=new zd(d,!t[Vd],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,s=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(So(t));if(!o)return;let i=n.state.doc.resolve(o.pos),r=s&&s.slice;r?n.someProp("transformPasted",f=>{r=f(r,n)}):r=Td(n,$d(t.dataTransfer),Qn?null:t.dataTransfer.getData("text/html"),!1,i);let l=!!(s&&!t[Vd]);if(n.someProp("handleDrop",f=>f(n,t,r||A.empty,l))){t.preventDefault();return}if(!r)return;t.preventDefault();let a=r?lm(n.state.doc,i.pos,r):i.pos;a==null&&(a=i.pos);let c=n.state.tr;if(l){let{node:f}=s;f?f.replace(c):c.deleteSelection()}let d=c.mapping.map(a),p=r.openStart==0&&r.openEnd==0&&r.content.childCount==1,u=c.doc;if(p?c.replaceRangeWith(d,d,r.content.firstChild):c.replaceRange(d,d,r),c.doc.eq(u))return;let h=c.doc.resolve(d);if(p&&D.isSelectable(r.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(r.content.firstChild))c.setSelection(new D(h));else{let f=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,C)=>f=C),c.setSelection(lr(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())&&et(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(se&&Pe&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:s}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=s||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,Et(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in de)ce[n]=de[n];function ts(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 so{constructor(e,t){this.toDOM=e,this.spec=t||Lt,this.side=this.spec.side||0}map(e,t,s,o){let{pos:i,deleted:r}=e.mapResult(t.from+o,this.side<0?-1:1);return r?null:new fe(i-s,i-s,this)}valid(){return!0}eq(e){return this==e||e instanceof so&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ts(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class mt{constructor(e,t){this.attrs=e,this.spec=t||Lt}map(e,t,s,o){let i=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-s,r=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-s;return i>=r?null:new fe(i,r,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof mt&&ts(this.attrs,e.attrs)&&ts(this.spec,e.spec)}static is(e){return e.type instanceof mt}destroy(){}}class pr{constructor(e,t){this.attrs=e,this.spec=t||Lt}map(e,t,s,o){let i=e.mapResult(t.from+o,1);if(i.deleted)return null;let r=e.mapResult(t.to+o,-1);return r.deleted||r.pos<=i.pos?null:new fe(i.pos-s,r.pos-s,this)}valid(e,t){let{index:s,offset:o}=e.content.findIndex(t.from),i;return o==t.from&&!(i=e.child(s)).isText&&o+i.nodeSize==t.to}eq(e){return this==e||e instanceof pr&&ts(this.attrs,e.attrs)&&ts(this.spec,e.spec)}destroy(){}}class fe{constructor(e,t,s){this.from=e,this.to=t,this.type=s}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,s){return this.type.map(e,this,t,s)}static widget(e,t,s){return new fe(e,e,new so(t,s))}static inline(e,t,s,o){return new fe(e,t,new mt(s,o))}static node(e,t,s,o){return new fe(e,t,new pr(s,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof mt}get widget(){return this.type instanceof so}}const Qt=[],Lt={};class j{constructor(e,t){this.local=e.length?e:Qt,this.children=t.length?t:Qt}static create(e,t){return t.length?oo(t,e,0,Lt):te}find(e,t,s){let o=[];return this.findInner(e??0,t??1e9,o,0,s),o}findInner(e,t,s,o,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))&&s.push(l.copy(l.from+o,l.to+o))}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,s,o+l,i)}}map(e,t,s){return this==te||e.maps.length==0?this:this.mapInner(e,t,0,0,s||Lt)}mapInner(e,t,s,o,i){let r;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,s,o);a&&a.type.valid(t,a)?(r||(r=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?f1(this.children,r||[],e,t,s,o,i):r?new j(r.sort($t),Qt):te}add(e,t){return t.length?this==te?j.create(e,t):this.addInner(e,t,0):this}addInner(e,t,s){let o,i=0;e.forEach((l,a)=>{let c=a+s,d;if(d=Hd(t,l,c)){for(o||(o=this.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(l,d,c+1):o.splice(i,0,a,a+l.nodeSize,oo(d,l,c+1,Lt)),i+=3}});let r=Bd(i?Fd(t):t,-s);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||r.splice(l--,1);return new j(r.length?this.local.concat(r).sort($t):this.local,o||this.children)}remove(e){return e.length==0||this==te?this:this.removeInner(e,0)}removeInner(e,t){let s=this.children,o=this.local;for(let i=0;i<s.length;i+=3){let r,l=s[i]+t,a=s[i+1]+t;for(let d=0,p;d<e.length;d++)(p=e[d])&&p.from>l&&p.to<a&&(e[d]=null,(r||(r=[])).push(p));if(!r)continue;s==this.children&&(s=this.children.slice());let c=s[i+2].removeInner(r,l+1);c!=te?s[i+2]=c:(s.splice(i,3),i-=3)}if(o.length){for(let i=0,r;i<e.length;i++)if(r=e[i])for(let l=0;l<o.length;l++)o[l].eq(r,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return s==this.children&&o==this.local?this:o.length||s.length?new j(o,s):te}forChild(e,t){if(this==te)return this;if(t.isLeaf)return j.empty;let s,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(s=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 mt){let c=Math.max(i,a.from)-i,d=Math.min(r,a.to)-i;c<d&&(o||(o=[])).push(a.copy(c,d))}}if(o){let l=new j(o.sort($t),Qt);return s?new rt([l,s]):l}return s||te}eq(e){if(this==e)return!0;if(!(e instanceof j)||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 ur(this.localsInner(e))}localsInner(e){if(this==te)return Qt;if(e.inlineContent||!this.local.some(mt.is))return this.local;let t=[];for(let s=0;s<this.local.length;s++)this.local[s].type instanceof mt||t.push(this.local[s]);return t}forEachSet(e){e(this)}}j.empty=new j([],[]);j.removeOverlap=ur;const te=j.empty;class rt{constructor(e){this.members=e}map(e,t){const s=this.members.map(o=>o.map(e,t,Lt));return rt.from(s)}forChild(e,t){if(t.isLeaf)return j.empty;let s=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,t);i!=te&&(i instanceof rt?s=s.concat(i.members):s.push(i))}return rt.from(s)}eq(e){if(!(e instanceof rt)||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,s=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(e);if(i.length)if(!t)t=i;else{s&&(t=t.slice(),s=!1);for(let r=0;r<i.length;r++)t.push(i[r])}}return t?ur(s?t:t.sort($t)):Qt}static from(e){switch(e.length){case 0:return te;case 1:return e[0];default:return new rt(e.every(t=>t instanceof j)?e:e.reduce((t,s)=>t.concat(s instanceof j?s:s.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function f1(n,e,t,s,o,i,r){let l=n.slice();for(let c=0,d=i;c<t.maps.length;c++){let p=0;t.maps[c].forEach((u,h,f,m)=>{let g=m-f-(h-u);for(let b=0;b<l.length;b+=3){let C=l[b+1];if(C<0||u>C+d-p)continue;let y=l[b]+d-p;h>=y?l[b+1]=u<=y?-2:-1:u>=d&&g&&(l[b]+=g,l[b+1]+=g)}p+=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),p=d-o;if(p<0||p>=s.content.size){a=!0;continue}let u=t.map(n[c+1]+i,-1),h=u-o,{index:f,offset:m}=s.content.findIndex(p),g=s.maybeChild(f);if(g&&m==p&&m+g.nodeSize==h){let b=l[c+2].mapInner(t,g,d+1,n[c]+i+1,r);b!=te?(l[c]=p,l[c+1]=h,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=m1(l,n,e,t,o,i,r),d=oo(c,s,0,r);e=d.local;for(let p=0;p<l.length;p+=3)l[p+1]<0&&(l.splice(p,3),p-=3);for(let p=0,u=0;p<d.children.length;p+=3){let h=d.children[p];for(;u<l.length&&l[u]<h;)u+=3;l.splice(u,0,d.children[p],d.children[p+1],d.children[p+2])}}return new j(e.sort($t),l)}function Bd(n,e){if(!e||!n.length)return n;let t=[];for(let s=0;s<n.length;s++){let o=n[s];t.push(new fe(o.from+e,o.to+e,o.type))}return t}function m1(n,e,t,s,o,i,r){function l(a,c){for(let d=0;d<a.local.length;d++){let p=a.local[d].map(s,o,c);p?t.push(p):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 Hd(n,e,t){if(e.isLeaf)return null;let s=t+e.nodeSize,o=null;for(let i=0,r;i<n.length;i++)(r=n[i])&&r.from>t&&r.to<s&&((o||(o=[])).push(r),n[i]=null);return o}function Fd(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function oo(n,e,t,s){let o=[],i=!1;e.forEach((l,a)=>{let c=Hd(n,l,a+t);if(c){i=!0;let d=oo(c,l,t+a+1,s);d!=te&&o.push(a,a+l.nodeSize,d)}});let r=Bd(i?Fd(n):n,-t).sort($t);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||(s.onRemove&&s.onRemove(r[l].spec),r.splice(l--,1));return r.length||o.length?new j(r,o):te}function $t(n,e){return n.from-e.from||n.to-e.to}function ur(n){let e=n;for(let t=0;t<e.length-1;t++){let s=e[t];if(s.from!=s.to)for(let o=t+1;o<e.length;o++){let i=e[o];if(i.from==s.from){i.to!=s.to&&(e==n&&(e=n.slice()),e[o]=i.copy(i.from,s.to),ql(e,o+1,i.copy(s.to,i.to)));continue}else{i.from<s.to&&(e==n&&(e=n.slice()),e[t]=s.copy(s.from,i.from),ql(e,o,s.copy(i.from,s.to)));break}}}return e}function ql(n,e,t){for(;e<n.length&&$t(t,n[e])>0;)e++;n.splice(e,0,t)}function jo(n){let e=[];return n.someProp("decorations",t=>{let s=t(n.state);s&&s!=te&&e.push(s)}),n.cursorWrapper&&e.push(j.create(n.state.doc,[n.cursorWrapper.deco])),rt.from(e)}const g1={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},y1=me&&ht<=11;class b1{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 v1{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new b1,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(s=>{for(let o=0;o<s.length;o++)this.queue.push(s[o]);me&&ht<=11&&s.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),y1&&(this.onCharData=s=>{this.queue.push({target:s.target,type:"characterData",oldValue:s.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,g1)),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(Vl(this.view)){if(this.suppressingSelectionUpdates)return et(this.view);if(me&&ht<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ht(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,s;for(let i=e.focusNode;i;i=Xn(i))t.add(i);for(let i=e.anchorNode;i;i=Xn(i))if(t.has(i)){s=i;break}let o=s&&this.view.docView.nearestDesc(s);if(o&&o.ignoreMutation({type:"selection",target:s.nodeType==3?s.parentNode:s}))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 s=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(s)&&Vl(e)&&!this.ignoreSelectionChange(s),i=-1,r=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let p=this.registerMutation(t[d],a);p&&(i=i<0?p.from:Math.min(p.from,i),r=r<0?p.to:Math.max(p.to,r),p.typeOver&&(l=!0))}if(De&&a.length){let d=a.filter(p=>p.nodeName=="BR");if(d.length==2){let[p,u]=d;p.parentNode&&p.parentNode.parentNode==u.parentNode?u.remove():p.remove()}else{let{focusNode:p}=this.currentSelection;for(let u of d){let h=u.parentNode;h&&h.nodeName=="LI"&&(!p||w1(e,p)!=h)&&u.remove()}}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&bo(s)&&(c=rr(e))&&c.eq(L.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,et(e),this.currentSelection.set(s),e.scrollToSelection()):(i>-1||o)&&(i>-1&&(e.docView.markDirty(i,r),S1(e)),this.handleDOMChange(i,r,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(s)||et(e),this.currentSelection.set(s))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let s=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(s==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!s||s.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let p=e.addedNodes[d];t.push(p),p.nodeType==3&&(this.lastChangedTextNode=p)}if(s.contentDOM&&s.contentDOM!=s.dom&&!s.contentDOM.contains(e.target))return{from:s.posBefore,to:s.posAfter};let o=e.previousSibling,i=e.nextSibling;if(me&&ht<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:p,nextSibling:u}=e.addedNodes[d];(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(o=p),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(i=u)}let r=o&&o.parentNode==e.target?Q(o)+1:0,l=s.localPosFromDOM(e.target,r,-1),a=i&&i.parentNode==e.target?Q(i):e.target.childNodes.length,c=s.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:s.posAtStart-s.border,to:s.posAtEnd+s.border}:(this.lastChangedTextNode=e.target,{from:s.posAtStart,to:s.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Ul=new WeakMap,Kl=!1;function S1(n){if(!Ul.has(n)&&(Ul.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=De,Kl)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."),Kl=!0}}function Jl(n,e){let t=e.startContainer,s=e.startOffset,o=e.endContainer,i=e.endOffset,r=n.domAtPos(n.state.selection.anchor);return Ht(r.node,r.offset,o,i)&&([t,s,o,i]=[o,i,t,s]),{anchorNode:t,anchorOffset:s,focusNode:o,focusOffset:i}}function x1(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return Jl(n,o)}let t;function s(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",s,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",s,!0),t?Jl(n,t):null}function w1(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let s=n.docView.nearestDesc(t,!0);if(s&&s.node.isBlock)return t}return null}function C1(n,e,t){let{node:s,fromOffset:o,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}],bo(a)||c.push({node:a.focusNode,offset:a.focusOffset})),se&&n.input.lastKeyCode===8)for(let g=i;g>o;g--){let b=s.childNodes[g-1],C=b.pmViewDesc;if(b.nodeName=="BR"&&!C){i=g;break}if(!C||C.size)break}let p=n.state.doc,u=n.someProp("domParser")||Bt.fromSchema(n.state.schema),h=p.resolve(r),f=null,m=u.parse(s,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:o,to:i,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:k1,context:h});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 k1(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 E1=/^(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 T1(n,e,t,s,o){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let E=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,M=rr(n,E);if(M&&!n.state.selection.eq(M)){if(se&&Pe&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",N=>N(n,Et(13,"Enter"))))return;let P=n.state.tr.setSelection(M);E=="pointer"?P.setMeta("pointer",!0):E=="key"&&P.scrollIntoView(),i&&P.setMeta("composition",i),n.dispatch(P)}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=C1(n,e,t),d=n.state.doc,p=d.slice(c.from,c.to),u,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(u=n.state.selection.to,h="end"):(u=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let f=P1(p.content,c.doc.content,c.from,u,h);if(f&&n.input.domChangeCount++,(bn&&n.input.lastIOSEnter>Date.now()-225||Pe)&&o.some(E=>E.nodeType==1&&!E1.test(E.nodeName))&&(!f||f.endA>=f.endB)&&n.someProp("handleKeyDown",E=>E(n,Et(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!f)if(s&&a instanceof $&&!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 E=Zl(n,n.state.doc,c.sel);if(E&&!E.eq(n.state.selection)){let M=n.state.tr.setSelection(E);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 $&&(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)),me&&ht<=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),C=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=f.endA,y;if((bn&&n.input.lastIOSEnter>Date.now()-225&&(!C||o.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!C&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(y=L.findFrom(c.doc.resolve(m.pos+1),1,!0))&&y.head==g.pos)&&n.someProp("handleKeyDown",E=>E(n,Et(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>f.start&&A1(d,f.start,f.endA,m,g)&&n.someProp("handleKeyDown",E=>E(n,Et(8,"Backspace")))){Pe&&se&&n.domObserver.suppressSelectionUpdates();return}se&&Pe&&f.endB==f.start&&(n.input.lastAndroidDelete=Date.now()),Pe&&!C&&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(E){return E(n,Et(13,"Enter"))})},20));let v=f.start,w=f.endA,S,x,k;if(C){if(m.pos==g.pos)me&&ht<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>et(n),20)),S=n.state.tr.delete(v,w),x=d.resolve(f.start).marksAcross(d.resolve(f.endA));else if(f.endA==f.endB&&(k=M1(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,f.endA-b.start()))))S=n.state.tr,k.type=="add"?S.addMark(v,w,k.mark):S.removeMark(v,w,k.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let E=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",M=>M(n,v,w,E)))return;S=n.state.tr.insertText(E,v,w)}}if(S||(S=n.state.tr.replace(v,w,c.doc.slice(f.start-c.from,f.endB-c.from))),c.sel){let E=Zl(n,S.doc,c.sel);E&&!(se&&Pe&&n.composing&&E.empty&&(f.start!=f.endB||n.input.lastAndroidDelete<Date.now()-100)&&(E.head==v||E.head==S.mapping.map(w)-1)||me&&E.empty&&E.head==v)&&S.setSelection(E)}x&&S.ensureMarks(x),i&&S.setMeta("composition",i),n.dispatch(S.scrollIntoView())}function Zl(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:lr(n,e.resolve(t.anchor),e.resolve(t.head))}function M1(n,e){let t=n.firstChild.marks,s=e.firstChild.marks,o=t,i=s,r,l,a;for(let d=0;d<s.length;d++)o=s[d].removeFromSet(o);for(let d=0;d<t.length;d++)i=t[d].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],r="add",a=d=>d.mark(l.addToSet(d.marks));else if(o.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(T.from(c).eq(n))return{mark:l,type:r}}function A1(n,e,t,s,o){if(t-e<=o.pos-s.pos||qo(s,!0,!1)<o.pos)return!1;let i=n.resolve(e);if(!s.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(qo(i,!0,!0));return!r.parent.isTextblock||r.pos>t||qo(r,!0,!1)<t?!1:s.parent.content.cut(s.parentOffset).eq(r.parent.content)}function qo(n,e,t){let s=n.depth,o=e?n.end():n.pos;for(;s>0&&(e||n.indexAfter(s)==n.node(s).childCount);)s--,o++,e=!1;if(t){let i=n.node(s).maybeChild(n.indexAfter(s));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function P1(n,e,t,s,o){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(o=="end"){let a=Math.max(0,i-Math.min(r,l));s-=r+a-i}if(r<i&&n.size<e.size){let a=s<=i&&s>=r?i-s:0;i-=a,i&&i<e.size&&Yl(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-r),r=i}else if(l<i){let a=s<=i&&s>=l?i-s:0;i-=a,i&&i<n.size&&Yl(n.textBetween(i-1,i+1))&&(i+=a?1:-1),r=i+(r-l),l=i}return{start:i,endA:r,endB:l}}function Yl(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 N1{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 Jg,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(na),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=ea(this),Ql(this),this.nodeViews=ta(this),this.docView=Ol(this.state.doc,Xl(this),jo(this),this.dom,this),this.domObserver=new v1(this,(s,o,i,r)=>T1(this,s,o,i,r)),this.domObserver.start(),Zg(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&&Ii(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(na),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let s in this._props)t[s]=this._props[s];t.state=this.state;for(let s in e)t[s]=e[s];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var s;let o=this.state,i=!1,r=!1;e.storedMarks&&this.composing&&(Ld(this),r=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=ta(this);O1(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ii(this),this.editable=ea(this),Ql(this);let a=jo(this),c=Xl(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",p=i||!this.docView.matchesNode(e.doc,c,a);(p||!e.selection.eq(o.selection))&&(r=!0);let u=d=="preserve"&&r&&this.dom.style.overflowAnchor==null&&dg(this);if(r){this.domObserver.stop();let h=p&&(me||se)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&I1(o.selection,e.selection);if(p){let f=se?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=c1(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Ol(e.doc,c,a,this.dom,this)),f&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Dg(this))?et(this,h):(wd(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((s=this.dragging)===null||s===void 0)&&s.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():u&&pg(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof D){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Tl(this,t.getBoundingClientRect(),e)}else Tl(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 s=this.directPlugins[t];s.spec.view&&this.pluginViews.push(s.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let s=this.state.plugins[t];s.spec.view&&this.pluginViews.push(s.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let s=this.pluginViews[t];s.update&&s.update(this,e)}}updateDraggedNode(e,t){let s=e.node,o=-1;if(this.state.doc.nodeAt(s.from)==s.node)o=s.from;else{let i=s.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==s.node&&(o=i)}this.dragging=new zd(e.slice,e.move,o<0?void 0:D.create(this.state.doc,o))}someProp(e,t){let s=this._props&&this._props[e],o;if(s!=null&&(o=t?t(s):s))return o;for(let r=0;r<this.directPlugins.length;r++){let l=this.directPlugins[r].props[e];if(l!=null&&(o=t?t(l):l))return o}let i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let l=i[r].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){if(me){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&&ug(this.dom),et(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 yg(this,e)}coordsAtPos(e,t=1){return fd(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,s=-1){let o=this.docView.posFromDOM(e,t,s);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return wg(this,t||this.state,e)}pasteHTML(e,t){return es(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return es(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Yg(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],jo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Qm())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Qg(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&&og(this.dom.ownerDocument)==this.dom&&x1(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Xl(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 s in t)s=="class"?e.class+=" "+t[s]:s=="style"?e.style=(e.style?e.style+";":"")+t[s]:!e[s]&&s!="contenteditable"&&s!="nodeName"&&(e[s]=String(t[s]))}),e.translate||(e.translate="no"),[fe.node(0,n.state.doc.content.size,e)]}function Ql(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 ea(n){return!n.someProp("editable",e=>e(n.state)===!1)}function I1(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 ta(n){let e=Object.create(null);function t(s){for(let o in s)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=s[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function O1(n,e){let t=0,s=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)s++;return t!=s}function na(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 Oi,Ri;if(typeof WeakMap<"u"){let n=new WeakMap;Oi=e=>n.get(e),Ri=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Oi=s=>{for(let o=0;o<n.length;o+=2)if(n[o]==s)return n[o+1]},Ri=(s,o)=>(t==10&&(t=0),n[t++]=s,n[t++]=o)}var U=class{constructor(n,e,t,s){this.width=n,this.height=e,this.map=t,this.problems=s}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const s=e%this.width,o=e/this.width|0;let i=s+1,r=o+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:s,top:o,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:s,right:o,top:i,bottom:r}=this.findCell(n);return e=="horiz"?(t<0?s==0:o==this.width)?null:this.map[i*this.width+(t<0?s-1:o)]:(t<0?i==0:r==this.height)?null:this.map[s+this.width*(t<0?i-1:r)]}rectBetween(n,e){const{left:t,right:s,top:o,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(o,a),right:Math.max(s,l),bottom:Math.max(i,c)}}cellsInRect(n){const e=[],t={};for(let s=n.top;s<n.bottom;s++)for(let o=n.left;o<n.right;o++){const i=s*this.width+o,r=this.map[i];t[r]||(t[r]=!0,!(o==n.left&&o&&this.map[i-1]==r||s==n.top&&s&&this.map[i-this.width]==r)&&e.push(r))}return e}positionAt(n,e,t){for(let s=0,o=0;;s++){const i=o+t.child(s).nodeSize;if(s==n){let r=e+n*this.width;const l=(n+1)*this.width;for(;r<l&&this.map[r]<o;)r++;return r==l?i-1:this.map[r]}o=i}}static get(n){return Oi(n)||Ri(n,R1(n))}};function R1(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=D1(n),t=n.childCount,s=[];let o=0,i=null;const r=[];for(let c=0,d=e*t;c<d;c++)s[c]=0;for(let c=0,d=0;c<t;c++){const p=n.child(c);d++;for(let f=0;;f++){for(;o<s.length&&s[o]!=0;)o++;if(f==p.childCount)break;const m=p.child(f),{colspan:g,rowspan:b,colwidth:C}=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=o+y*e;for(let w=0;w<g;w++){s[v+w]==0?s[v+w]=d:(i||(i=[])).push({type:"collision",row:c,pos:d,n:g-w});const S=C&&C[w];if(S){const x=(v+w)%e*2,k=r[x];k==null||k!=S&&r[x+1]==1?(r[x]=S,r[x+1]=1):k==S&&r[x+1]++}}}o+=g,d+=m.nodeSize}const u=(c+1)*e;let h=0;for(;o<u;)s[o++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),d++}const l=new U(e,t,s,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&&L1(l,r,n),l}function D1(n){let e=-1,t=!1;for(let s=0;s<n.childCount;s++){const o=n.child(s);let i=0;if(t)for(let r=0;r<s;r++){const l=n.child(r);for(let a=0;a<l.childCount;a++){const c=l.child(a);r+c.attrs.rowspan>s&&(i+=c.attrs.colspan)}}for(let r=0;r<o.childCount;r++){const l=o.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 L1(n,e,t){n.problems||(n.problems=[]);const s={};for(let o=0;o<n.map.length;o++){const i=n.map[o];if(s[i])continue;s[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=(o+c)%n.width,p=e[d*2];p!=null&&(!a.colwidth||a.colwidth[c]!=p)&&((l||(l=$1(a)))[c]=p)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function $1(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function sa(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),s=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(r=>Number(r)):null,o=Number(n.getAttribute("colspan")||1),i={colspan:o,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:s&&s.length==o?s:null};for(const r in e){const l=e[r].getFromDOM,a=l&&l(n);a!=null&&(i[r]=a)}return i}function oa(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 s in e){const o=e[s].setDOMAttr;o&&o(n.attrs[s],t)}return t}function z1(n){const e=n.cellAttributes||{},t={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const s in e)t[s]={default:e[s].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:s=>sa(s,e)}],toDOM(s){return["td",oa(s,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:s=>sa(s,e)}],toDOM(s){return["th",oa(s,e),0]}}}}function We(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const s=n.nodes[t],o=s.spec.tableRole;o&&(e[o]=s)}}return e}var lt=new is("selectingCells");function cs(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 xo(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 hr(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=cs(e.$head)||V1(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function V1(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const s=e.type.spec.tableRole;if(s=="cell"||s=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const s=e.type.spec.tableRole;if(s=="cell"||s=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function Di(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function B1(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function fr(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function _d(n,e,t){const s=n.node(-1),o=U.get(s),i=n.start(-1),r=o.nextCell(n.pos-i,e,t);return r==null?null:n.node(0).resolve(i+r)}function vn(n,e,t=1){const s={...n,colspan:n.colspan-t};return s.colwidth&&(s.colwidth=s.colwidth.slice(),s.colwidth.splice(e,t),s.colwidth.some(o=>o>0)||(s.colwidth=null)),s}var Z=class Je extends L{constructor(e,t=e){const s=e.node(-1),o=U.get(s),i=e.start(-1),r=o.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=o.cellsInRect(r).filter(d=>d!=t.pos-i);a.unshift(t.pos-i);const c=a.map(d=>{const p=s.nodeAt(d);if(!p)throw RangeError(`No cell with offset ${d} found`);const u=i+d+1;return new jc(l.resolve(u),l.resolve(u+p.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const s=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(Di(s)&&Di(o)&&fr(s,o)){const i=this.$anchorCell.node(-1)!=s.node(-1);return i&&this.isRowSelection()?Je.rowSelection(s,o):i&&this.isColSelection()?Je.colSelection(s,o):new Je(s,o)}return $.between(s,o)}content(){const e=this.$anchorCell.node(-1),t=U.get(e),s=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s),i={},r=[];for(let a=o.top;a<o.bottom;a++){const c=[];for(let d=a*t.width+o.left,p=o.left;p<o.right;p++,d++){const u=t.map[d];if(i[u])continue;i[u]=!0;const h=t.findCell(u);let f=e.nodeAt(u);if(!f)throw RangeError(`No cell with offset ${u} found`);const m=o.left-h.left,g=h.right-o.right;if(m>0||g>0){let b=f.attrs;if(m>0&&(b=vn(b,0,m)),g>0&&(b=vn(b,b.colspan-g,g)),h.left<o.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(h.top<o.top||h.bottom>o.bottom){const b={...f.attrs,rowspan:Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top)};h.top<o.top?f=f.type.createAndFill(b):f=f.type.create(b,f.content)}c.push(f)}r.push(e.child(a).copy(T.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:r;return new A(T.from(l),1,1)}replace(e,t=A.empty){const s=e.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){const{$from:l,$to:a}=o[r],c=e.mapping.slice(s);e.replace(c.map(l.pos),c.map(a.pos),r?A.empty:t)}const i=L.findFrom(e.doc.resolve(e.mapping.slice(s).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new A(T.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),s=U.get(t),o=this.$anchorCell.start(-1),i=s.cellsInRect(s.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let r=0;r<i.length;r++)e(t.nodeAt(i[r]),o+i[r])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const s=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(s,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const s=e.node(-1),o=U.get(s),i=e.start(-1),r=o.findCell(e.pos-i),l=o.findCell(t.pos-i),a=e.node(0);return r.top<=l.top?(r.top>0&&(e=a.resolve(i+o.map[r.left])),l.bottom<o.height&&(t=a.resolve(i+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(i+o.map[l.left])),r.bottom<o.height&&(e=a.resolve(i+o.map[o.width*(o.height-1)+r.right-1]))),new Je(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=U.get(e),s=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-s),i=t.colCount(this.$headCell.pos-s);if(Math.min(o,i)>0)return!1;const r=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(r,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 s=e.node(-1),o=U.get(s),i=e.start(-1),r=o.findCell(e.pos-i),l=o.findCell(t.pos-i),a=e.node(0);return r.left<=l.left?(r.left>0&&(e=a.resolve(i+o.map[r.top*o.width])),l.right<o.width&&(t=a.resolve(i+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(i+o.map[l.top*o.width])),r.right<o.width&&(e=a.resolve(i+o.map[o.width*(r.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,s=t){return new Je(e.resolve(t),e.resolve(s))}getBookmark(){return new H1(this.$anchorCell.pos,this.$headCell.pos)}};Z.prototype.visible=!1;L.jsonID("cell",Z);var H1=class Gd{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Gd(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),s=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&s.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&s.index()<s.parent.childCount&&fr(t,s)?new Z(t,s):L.near(s,1)}};function F1(n){if(!(n.selection instanceof Z))return null;const e=[];return n.selection.forEachCell((t,s)=>{e.push(fe.node(s,s+t.nodeSize,{class:"selectedCell"}))}),j.create(n.doc,e)}function _1({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,s=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,s--);return t==s&&/row|table/.test(n.node(o).type.spec.tableRole)}function G1({$from:n,$to:e}){let t,s;for(let o=n.depth;o>0;o--){const i=n.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let o=e.depth;o>0;o--){const i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){s=i;break}}return t!==s&&e.parentOffset===0}function W1(n,e,t){const s=(e||n).selection,o=(e||n).doc;let i,r;if(s instanceof D&&(r=s.node.type.spec.tableRole)){if(r=="cell"||r=="header_cell")i=Z.create(o,s.from);else if(r=="row"){const l=o.resolve(s.from+1);i=Z.rowSelection(l,l)}else if(!t){const l=U.get(s.node),a=s.from+1,c=a+l.map[l.width*l.height-1];i=Z.create(o,a+1,c)}}else s instanceof $&&_1(s)?i=$.create(o,s.from):s instanceof $&&G1(s)&&(i=$.create(o,s.$from.start(),s.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}var j1=new is("fix-tables");function Wd(n,e,t,s){const o=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(o,r+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}s(a,t),l<o&&n.child(l).sameMarkup(a)?Wd(n.child(l),a,t+1,s):a.nodesBetween(0,a.content.size,s,t+1),t+=a.nodeSize}}function q1(n,e){let t;const s=(o,i)=>{o.type.spec.tableRole=="table"&&(t=U1(n,o,i,t))};return e?e.doc!=n.doc&&Wd(e.doc,n.doc,0,s):n.doc.descendants(s),t}function U1(n,e,t,s){const o=U.get(e);if(!o.problems)return s;s||(s=n.tr);const i=[];for(let a=0;a<o.height;a++)i.push(0);for(let a=0;a<o.problems.length;a++){const c=o.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const p=d.attrs;for(let u=0;u<p.rowspan;u++)i[c.row+u]+=c.n;s.setNodeMarkup(s.mapping.map(t+1+c.pos),null,vn(p,p.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;s.setNodeMarkup(s.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;s.setNodeMarkup(s.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<o.height;a++){const d=e.child(a),p=c+d.nodeSize,u=i[a];if(u>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const f=[];for(let g=0;g<u;g++){const b=We(n.schema)[h].createAndFill();b&&f.push(b)}const m=(a==0||r==a-1)&&l==a?c+1:p-1;s.insert(s.mapping.map(m),f)}c=p}return s.setMeta(j1,{fixTables:!0})}function jd(n){const e=n.selection,t=hr(n),s=t.node(-1),o=t.start(-1),i=U.get(s);return{...e instanceof Z?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(t.pos-o),tableStart:o,map:i,table:s}}function K1(n){return function(e,t){if(!xo(e))return!1;if(t){const s=We(e.schema),o=jd(e),i=e.tr,r=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=r.map(a=>o.table.nodeAt(a));for(let a=0;a<r.length;a++)l[a].type==s.header_cell&&i.setNodeMarkup(o.tableStart+r[a],s.cell,l[a].attrs);if(i.steps.length==0)for(let a=0;a<r.length;a++)i.setNodeMarkup(o.tableStart+r[a],s.header_cell,l[a].attrs);t(i)}return!0}}function ia(n,e,t){const s=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let o=0;o<s.length;o++){const i=e.table.nodeAt(s[o]);if(i&&i.type!==t.header_cell)return!1}return!0}function mr(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?K1(n):function(t,s){if(!xo(t))return!1;if(s){const o=We(t.schema),i=jd(t),r=t.tr,l=ia("row",i,o),a=ia("column",i,o),d=(n==="column"?l:n==="row"?a:!1)?1:0,p=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,u=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;i.map.cellsInRect(p).forEach(h=>{const f=h+i.tableStart,m=r.doc.nodeAt(f);m&&r.setNodeMarkup(f,u,m.attrs)}),s(r)}return!0}}mr("row",{useDeprecatedLogic:!0});mr("column",{useDeprecatedLogic:!0});mr("cell",{useDeprecatedLogic:!0});function J1(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let s=n.index(-1)-1,o=n.before();s>=0;s--){const i=n.node(-1).child(s),r=i.lastChild;if(r)return o-1-r.nodeSize;o-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let s=n.indexAfter(-1),o=n.after();s<t.childCount;s++){const i=t.child(s);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function ra(n){return function(e,t){if(!xo(e))return!1;const s=J1(hr(e),n);if(s==null)return!1;if(t){const o=e.doc.resolve(s);t(e.tr.setSelection($.between(o,B1(o))).scrollIntoView())}return!0}}function ks(n,e){const t=n.selection;if(!(t instanceof Z))return!1;if(e){const s=n.tr,o=We(n.schema).cell.createAndFill().content;t.forEachCell((i,r)=>{i.content.eq(o)||s.replace(s.mapping.map(r+1),s.mapping.map(r+i.nodeSize-1),new A(o,0,0))}),s.docChanged&&e(s)}return!0}function Z1(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:s}=n;for(;e.childCount==1&&(t>0&&s>0||e.child(0).type.spec.tableRole=="table");)t--,s--,e=e.child(0).content;const o=e.child(0),i=o.type.spec.tableRole,r=o.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),p=a<e.childCount-1?0:Math.max(0,s-1);(d||p)&&(c=Li(We(r).row,new A(c,d,p)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||s?Li(We(r).row,new A(e,t,s)).content:e);else return null;return Y1(r,l)}function Y1(n,e){const t=[];for(let o=0;o<e.length;o++){const i=e[o];for(let r=i.childCount-1;r>=0;r--){const{rowspan:l,colspan:a}=i.child(r).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let s=0;for(let o=0;o<t.length;o++)s=Math.max(s,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(T.empty),t[o]<s){const i=We(n).cell.createAndFill(),r=[];for(let l=t[o];l<s;l++)r.push(i);e[o]=e[o].append(T.from(r))}return{height:e.length,width:s,rows:e}}function Li(n,e){const t=n.createAndFill();return new Wc(t).replace(0,t.content.size,e).doc}function X1({width:n,height:e,rows:t},s,o){if(n!=s){const i=[],r=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=i[l]||0,p=0;d<s;p++){let u=a.child(p%a.childCount);d+u.attrs.colspan>s&&(u=u.type.createChecked(vn(u.attrs,u.attrs.colspan,d+u.attrs.colspan-s),u.content)),c.push(u),d+=u.attrs.colspan;for(let h=1;h<u.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+u.attrs.colspan}r.push(T.from(c))}t=r,n=s}if(e!=o){const i=[];for(let r=0,l=0;r<o;r++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let p=c.child(d);r+p.attrs.rowspan>o&&(p=p.type.create({...p.attrs,rowspan:Math.max(1,o-p.attrs.rowspan)},p.content)),a.push(p)}i.push(T.from(a))}t=i,e=o}return{width:n,height:e,rows:t}}function Q1(n,e,t,s,o,i,r){const l=n.doc.type.schema,a=We(l);let c,d;if(o>e.width)for(let p=0,u=0;p<e.height;p++){const h=t.child(p);u+=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<o;g++)f.push(m);n.insert(n.mapping.slice(r).map(u-1+s),f)}if(i>e.height){const p=[];for(let f=0,m=(e.height-1)*e.width;f<Math.max(e.width,o);f++){const g=f>=e.width?!1:t.nodeAt(e.map[m+f]).type==a.header_cell;p.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const u=a.row.create(null,T.from(p)),h=[];for(let f=e.height;f<i;f++)h.push(u);n.insert(n.mapping.slice(r).map(s+t.nodeSize-2),h)}return!!(c||d)}function la(n,e,t,s,o,i,r,l){if(r==0||r==e.height)return!1;let a=!1;for(let c=o;c<i;c++){const d=r*e.width+c,p=e.map[d];if(e.map[d-e.width]==p){a=!0;const u=t.nodeAt(p),{top:h,left:f}=e.findCell(p);n.setNodeMarkup(n.mapping.slice(l).map(p+s),null,{...u.attrs,rowspan:r-h}),n.insert(n.mapping.slice(l).map(e.positionAt(r,f,t)),u.type.createAndFill({...u.attrs,rowspan:h+u.attrs.rowspan-r})),c+=u.attrs.colspan-1}}return a}function aa(n,e,t,s,o,i,r,l){if(r==0||r==e.width)return!1;let a=!1;for(let c=o;c<i;c++){const d=c*e.width+r,p=e.map[d];if(e.map[d-1]==p){a=!0;const u=t.nodeAt(p),h=e.colCount(p),f=n.mapping.slice(l).map(p+s);n.setNodeMarkup(f,null,vn(u.attrs,r-h,u.attrs.colspan-(r-h))),n.insert(f+u.nodeSize,u.type.createAndFill(vn(u.attrs,0,r-h))),c+=u.attrs.rowspan-1}}return a}function ca(n,e,t,s,o){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}=s,c=a+o.width,d=l+o.height,p=n.tr;let u=0;function h(){if(i=t?p.doc.nodeAt(t-1):p.doc,!i)throw new Error("No table found");r=U.get(i),u=p.mapping.maps.length}Q1(p,r,i,t,c,d,u)&&h(),la(p,r,i,t,a,c,l,u)&&h(),la(p,r,i,t,a,c,d,u)&&h(),aa(p,r,i,t,l,d,a,u)&&h(),aa(p,r,i,t,l,d,c,u)&&h();for(let f=l;f<d;f++){const m=r.positionAt(f,a,i),g=r.positionAt(f,c,i);p.replace(p.mapping.slice(u).map(m+t),p.mapping.slice(u).map(g+t),new A(o.rows[f-l],0,0))}h(),p.setSelection(new Z(p.doc.resolve(t+r.positionAt(l,a,i)),p.doc.resolve(t+r.positionAt(d-1,c-1,i)))),e(p)}var e0=ld({ArrowLeft:Es("horiz",-1),ArrowRight:Es("horiz",1),ArrowUp:Es("vert",-1),ArrowDown:Es("vert",1),"Shift-ArrowLeft":Ts("horiz",-1),"Shift-ArrowRight":Ts("horiz",1),"Shift-ArrowUp":Ts("vert",-1),"Shift-ArrowDown":Ts("vert",1),Backspace:ks,"Mod-Backspace":ks,Delete:ks,"Mod-Delete":ks});function Ls(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Es(n,e){return(t,s,o)=>{if(!o)return!1;const i=t.selection;if(i instanceof Z)return Ls(t,s,L.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;const r=qd(o,n,e);if(r==null)return!1;if(n=="horiz")return Ls(t,s,L.near(t.doc.resolve(i.head+e),e));{const l=t.doc.resolve(r),a=_d(l,n,e);let c;return a?c=L.near(a,1):e<0?c=L.near(t.doc.resolve(l.before(-1)),-1):c=L.near(t.doc.resolve(l.after(-1)),1),Ls(t,s,c)}}}function Ts(n,e){return(t,s,o)=>{if(!o)return!1;const i=t.selection;let r;if(i instanceof Z)r=i;else{const a=qd(o,n,e);if(a==null)return!1;r=new Z(t.doc.resolve(a))}const l=_d(r.$headCell,n,e);return l?Ls(t,s,new Z(r.$anchorCell,l)):!1}}function t0(n,e){const t=n.state.doc,s=cs(t.resolve(e));return s?(n.dispatch(n.state.tr.setSelection(new Z(s))),!0):!1}function n0(n,e,t){if(!xo(n.state))return!1;let s=Z1(t);const o=n.state.selection;if(o instanceof Z){s||(s={width:1,height:1,rows:[T.from(Li(We(n.state.schema).cell,t))]});const i=o.$anchorCell.node(-1),r=o.$anchorCell.start(-1),l=U.get(i).rectBetween(o.$anchorCell.pos-r,o.$headCell.pos-r);return s=X1(s,l.right-l.left,l.bottom-l.top),ca(n.state,n.dispatch,r,l,s),!0}else if(s){const i=hr(n.state),r=i.start(-1);return ca(n.state,n.dispatch,r,U.get(i.node(-1)).findCell(i.pos-r),s),!0}else return!1}function s0(n,e){var t;if(e.ctrlKey||e.metaKey)return;const s=da(n,e.target);let o;if(e.shiftKey&&n.state.selection instanceof Z)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&s&&(o=cs(n.state.selection.$anchor))!=null&&((t=Uo(n,e))==null?void 0:t.pos)!=o.pos)i(o,e),e.preventDefault();else if(!s)return;function i(a,c){let d=Uo(n,c);const p=lt.getState(n.state)==null;if(!d||!fr(a,d))if(p)d=a;else return;const u=new Z(a,d);if(p||!n.state.selection.eq(u)){const h=n.state.tr.setSelection(u);p&&h.setMeta(lt,a.pos),n.dispatch(h)}}function r(){n.root.removeEventListener("mouseup",r),n.root.removeEventListener("dragstart",r),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 p;if(d!=null)p=n.state.doc.resolve(d);else if(da(n,c.target)!=s&&(p=Uo(n,e),!p))return r();p&&i(p,c)}n.root.addEventListener("mouseup",r),n.root.addEventListener("dragstart",r),n.root.addEventListener("mousemove",l)}function qd(n,e,t){if(!(n.state.selection instanceof $))return null;const{$head:s}=n.state.selection;for(let o=s.depth-1;o>=0;o--){const i=s.node(o);if((t<0?s.index(o):s.indexAfter(o))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=s.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function da(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Uo(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?cs(n.state.doc.resolve(t.pos)):null}var o0=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")),$i(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,$i(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function $i(n,e,t,s,o,i){var r;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let p=0,u=0;p<d.childCount;p++){const{colspan:h,colwidth:f}=d.child(p).attrs;for(let m=0;m<h;m++,u++){const g=o==u?i:f&&f[m],b=g?g+"px":"";if(l+=g||s,g||(a=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const C=document.createElement("col");C.style.width=b,e.appendChild(C)}}}for(;c;){const p=c.nextSibling;(r=c.parentNode)==null||r.removeChild(c),c=p}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var ve=new is("tableColumnResizing");function i0({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:s=o0,lastColumnResizable:o=!0}={}){const i=new wn({key:ve,state:{init(r,l){var a,c;const d=(c=(a=i.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,p=We(l.schema).table.name;return s&&d&&(d[p]=(u,h)=>new s(u,t,h)),new r0(-1,!1)},apply(r,l){return l.apply(r)}},props:{attributes:r=>{const l=ve.getState(r);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(r,l)=>{l0(r,l,n,o)},mouseleave:r=>{a0(r)},mousedown:(r,l)=>{c0(r,l,e,t)}},decorations:r=>{const l=ve.getState(r);if(l&&l.activeHandle>-1)return f0(r,l.activeHandle)},nodeViews:{}}});return i}var r0=class $s{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,s=e.getMeta(ve);if(s&&s.setHandle!=null)return new $s(s.setHandle,!1);if(s&&s.setDragging!==void 0)return new $s(t.activeHandle,s.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);return Di(e.doc.resolve(o))||(o=-1),new $s(o,t.dragging)}return t}};function l0(n,e,t,s){const o=ve.getState(n.state);if(o&&!o.dragging){const i=p0(e.target);let r=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?r=pa(n,e,"left",t):a-e.clientX<=t&&(r=pa(n,e,"right",t))}if(r!=o.activeHandle){if(!s&&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}Ud(n,r)}}}function a0(n){const e=ve.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Ud(n,-1)}function c0(n,e,t,s){var o;const i=(o=n.dom.ownerDocument.defaultView)!=null?o:window,r=ve.getState(n.state);if(!r||r.activeHandle==-1||r.dragging)return!1;const l=n.state.doc.nodeAt(r.activeHandle),a=d0(n,r.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(ve,{setDragging:{startX:e.clientX,startWidth:a}}));function c(p){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const u=ve.getState(n.state);u!=null&&u.dragging&&(u0(n,u.activeHandle,ua(u.dragging,p,t)),n.dispatch(n.state.tr.setMeta(ve,{setDragging:null})))}function d(p){if(!p.which)return c(p);const u=ve.getState(n.state);if(u&&u.dragging){const h=ua(u.dragging,p,t);ha(n,u.activeHandle,h,s)}}return ha(n,r.activeHandle,a,s),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function d0(n,e,{colspan:t,colwidth:s}){const o=s&&s[s.length-1];if(o)return o;const i=n.domAtPos(e);let l=i.node.childNodes[i.offset].offsetWidth,a=t;if(s)for(let c=0;c<t;c++)s[c]&&(l-=s[c],a--);return l/a}function p0(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function pa(n,e,t,s){const o=t=="right"?-s:s,i=n.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;const{pos:r}=i,l=cs(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 ua(n,e,t){const s=e.clientX-n.startX;return Math.max(t,n.startWidth+s)}function Ud(n,e){n.dispatch(n.state.tr.setMeta(ve,{setHandle:e}))}function u0(n,e,t){const s=n.state.doc.resolve(e),o=s.node(-1),i=U.get(o),r=s.start(-1),l=i.colCount(s.pos-r)+s.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 p=i.map[d],u=o.nodeAt(p).attrs,h=u.colspan==1?0:l-i.colCount(p);if(u.colwidth&&u.colwidth[h]==t)continue;const f=u.colwidth?u.colwidth.slice():h0(u.colspan);f[h]=t,a.setNodeMarkup(r+p,null,{...u,colwidth:f})}a.docChanged&&n.dispatch(a)}function ha(n,e,t,s){const o=n.state.doc.resolve(e),i=o.node(-1),r=o.start(-1),l=U.get(i).colCount(o.pos-r)+o.nodeAfter.attrs.colspan-1;let a=n.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&$i(i,a.firstChild,a,s,l,t)}function h0(n){return Array(n).fill(0)}function f0(n,e){var t;const s=[],o=n.doc.resolve(e),i=o.node(-1);if(!i)return j.empty;const r=U.get(i),l=o.start(-1),a=r.colCount(o.pos-l)+o.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 p=r.map[d],u=l+p+i.nodeAt(p).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",(t=ve.getState(n))!=null&&t.dragging&&s.push(fe.node(l+p,l+p+i.nodeAt(p).nodeSize,{class:"column-resize-dragging"})),s.push(fe.widget(u,h))}}return j.create(n.doc,s)}function m0({allowTableNodeSelection:n=!1}={}){return new wn({key:lt,state:{init(){return null},apply(e,t){const s=e.getMeta(lt);if(s!=null)return s==-1?null:s;if(t==null||!e.docChanged)return t;const{deleted:o,pos:i}=e.mapping.mapResult(t);return o?null:i}},props:{decorations:F1,handleDOMEvents:{mousedown:s0},createSelectionBetween(e){return lt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:t0,handleKeyDown:e0,handlePaste:n0},appendTransaction(e,t,s){return W1(s,q1(s,t),n)}})}const Fn=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},fa="data-gs-mrk-fs",ma="data-gs-ib",Kd="data-gs-mrk-wrap",io="data-gs-ifrg",tt="attrs",gr={[tt]:{default:"{}"}},Ue={[tt]:{default:{}}},yr=n=>({[tt]:JSON.stringify(Fn(n))}),Ke=n=>({attrs:Fn(n)}),Mn=n=>e=>[n,e.attrs.attrs,0],Xe=n=>n.attrs[tt]?JSON.parse(n.attrs[tt]):{},g0={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${io}]`,getAttrs:Ke}],toDOM:()=>["span",{[io]:""},0]},div:{group:"block",content:"inline*",attrs:Ue,parseDOM:[{tag:"div",getAttrs:Ke}],toDOM:Mn("div")},paragraph:{group:"block",content:"inline*",attrs:Ue,parseDOM:[{tag:"p",getAttrs:Ke}],toDOM:Mn("p")},orderedList:{group:"block",content:"listItem+",attrs:Ue,parseDOM:[{tag:"ol",getAttrs:Ke}],toDOM:Mn("ol")},bulletList:{group:"block",content:"listItem+",attrs:Ue,parseDOM:[{tag:"ul",getAttrs:Ke}],toDOM:Mn("ul")},listItem:{content:"block*",group:"block",attrs:Ue,parseDOM:[{tag:"li",getAttrs:Ke}],toDOM:Mn("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:Ue,parseDOM:[{tag:"pre",getAttrs:Ke}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:Ue,parseDOM:[{tag:"img[src]",getAttrs:Ke}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${ma}]`}],toDOM(){return["br",{[ma]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:Ue,parseDOM:[{tag:"br",getAttrs:Ke}],toDOM:n=>["br",{...n.attrs.attrs}]},heading:{group:"block",content:"inline*",attrs:{level:{default:1},attrs:{default:{}}},defining:!0,parseDOM:Array.from({length:6},(n,e)=>({tag:`h${e+1}`,getAttrs:t=>({level:e+1,attrs:Fn(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...z1({tableGroup:"block",cellContent:"block+",cellAttributes:{[tt]:{default:Ue[tt].default,getFromDOM:Fn,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:Fn(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},An=(n,e)=>({attrs:gr,parseDOM:n.map(t=>({tag:t,getAttrs:yr})),toDOM:e}),y0=n=>({attrs:{...gr},parseDOM:[{tag:`span[${n}]`,getAttrs:e=>({...yr(e)})}],toDOM(e){return["span",{...Xe(e),[n]:!0},0]}}),b0={strong:An(["strong","b"],n=>["b",Xe(n)]),link:An(["a"],n=>["a",Xe(n),0]),em:An(["em","i"],n=>["em",Xe(n)]),underline:An(["u"],n=>["u",Xe(n),0]),strikethrough:An(["s"],n=>["s",Xe(n),0]),wrapStyle:y0(Kd),font_size:{attrs:{...gr,size:{default:null}},parseDOM:[{tag:`span[${fa}]`,getAttrs:n=>({...yr(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...Xe(n),[fa]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},ga=new $f({nodes:g0,marks:b0}),ds=new WeakMap,br=new WeakMap,v0=(n,e,t)=>{ds.set(n,{view:e,gjsView:t,initialDoc:e.state.doc}),br.set(e,{el:n,gjsView:t})},S0=(n,e)=>{ds.delete(n),br.delete(e)},zs=n=>ds.get(n),Jd=n=>br.get(n),ya=n=>{const e=zs(n),t=e==null?void 0:e.view,s=e==null?void 0:e.initialDoc;return!(t&&s&&s.eq(t.state.doc))},Ko=n=>{var e,t;return(t=(e=Jd(n))==null?void 0:e.gjsView)==null?void 0:t.model},x0=n=>n.dispatchEvent(new CustomEvent("input"));function w0(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(io)){if(t.getAttribute("style")){t.removeAttribute(io);return}const s=t.parentElement;if(s){for(;t.firstChild;)s.insertBefore(t.firstChild,t);s.removeChild(t)}}else Array.from(t.children).forEach(s=>e(s))};e(n)}const C0=(n,e)=>{const t=Zd(n);return t&&R0(t)?E0(n,e):t?Qc(()=>({type:n.schema.nodes.div}))(n,e):!1},k0=(n,e)=>(t,s)=>{var l;const o=Zd(t),i=ds.get(n.el).view,r=(l=e.onEnter)==null?void 0:l.call(e,{...n,node:o,commands:vr(i,n.editor,e),proseMirror:{view:i,dispatch:s}});return r!==void 0?r:C0(t,s)};function Zd(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 E0(n,e){const{selection:t,schema:s,tr:o}=n;o.split(t.from,1);const i=t.from+1,r=o.doc.nodeAt(i),l={...r.attrs.attrs,id:void 0},a=r.textContent.length>0,c=r.textContent.length||0,d=r.textContent||" ",p=s.text(d),u=s.nodes.div.create(l,a?p:[],[]);return o.replaceRangeWith(i,i+c+2,u),o.setSelection($.create(o.doc,i+1)),e==null||e(o.scrollIntoView()),!0}function T0(n,e,t){const{state:s,dispatch:o}=n,{selection:i,tr:r}=s,l=(a,c,d)=>{const p={};return a.split(";").forEach(u=>{const[h,f]=u.split(":").map(m=>m.trim());h&&(p[h]=f)}),p[c]=d,Object.entries(p).map(([u,h])=>`${u}: ${h}`).join("; ")};if(!i.empty||t)r.doc.nodesBetween(i.from,i.to,(a,c)=>{var d,p;if(a.type===s.schema.nodes.image){const u=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}else if(a.type.isBlock){const u=l(((p=a.attrs.attrs)==null?void 0:p.style)||"","text-align",e);Yd(a)?r.setBlockType(i.from,void 0,s.schema.nodes.div,{attrs:{style:u}}):r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}});else{const a=s.doc.resolve(i.from),c=a.start(a.depth),d=s.doc.nodeAt(c);if(d!=null&&d.type.isBlock){const p=l(d.attrs.style||"","text-align",e);r.setNodeMarkup(c,void 0,{...d.attrs,style:p})}}r.docChanged&&o(r.scrollIntoView())}const Pn=(n,e)=>{const{from:t,to:s}=n.selection;let o=!1;return n.doc.nodesBetween(t,s,i=>{if(o)return!1;i.marks.some(r=>r.type===e)&&(o=!0)}),o};function M0(n){var p,u;const{view:e,href:t,options:s,target:o="_blank"}=n,{state:i,dispatch:r}=e,{schema:l,selection:a,tr:c}=i,d=l.marks.link;try{const h={href:t,target:o},f=((u=(p=s.commandAttrs)==null?void 0:p.link)==null?void 0:u.call(p,h))||h,m=d.create({[tt]:JSON.stringify(f)});c.addMark(a.from,a.to,m),r(c.scrollIntoView())}catch(h){console.error("Error applying link mark:",h)}}function A0(n,e){const{state:t,dispatch:s}=n,{selection:o,tr:i}=t;if(o.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(o.from,o.to,r.create({size:e})),s(i.scrollIntoView())}const Nt=(n,e)=>{const{doc:t,selection:s}=n.state,o=t.resolve(s.from);for(let i=o.depth;i>0;i--){const r=o.node(i);if(e(r))return{pos:i>0?o.before(i):0,start:o.start(i),depth:i,node:r}}},P0=n=>(n||"").split(";").map(e=>e.split(":")).reduce((e,[t,s])=>(t=t.replace(/-./g,o=>o.toUpperCase()[1]).trim(),e[t]=`${s}`.trim(),e),{});function N0(...n){return(e,t)=>{const s=r=>{e=e.apply(r),t==null||t(r)},o=n.pop();return n.reduce((r,l)=>r||l(e,s),!1)&&o!==void 0&&o(e,t)}}const I0=(n,e)=>{const{state:t,dispatch:s}=n;if(e!=null&&e.event){const{event:o}=e,i=n.posAtCoords({left:o.clientX,top:o.clientY});i!=null&&i.pos&&s(t.tr.setSelection($.create(t.doc,i.pos)))}else ed(t,s);setTimeout(()=>setTimeout(()=>n.focus()))},zi=n=>n.isBlock,Yd=n=>n.type.name==="inlineFragment",O0=n=>zi(n)&&!Yd(n),Xd=n=>n.type.name==="bulletList",Qd=n=>n.type.name==="orderedList",R0=n=>n.type.name==="heading",D0=n=>Xd(n)||Qd(n),ba=(n,e)=>{var i,r;const t=(i=Nt(n,l=>l.type===e))==null?void 0:i.node,s=n.state.schema.nodes.listItem;let o;return t?o=xi(s):(r=Nt(n,D0))!=null&&r.node?o=N0(xi(s),Cl(e)):o=Cl(e),o(n.state,n.dispatch)},ep=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(s=>s.type.name===e)},L0=n=>{var r;const{view:e,prop:t,editor:s,propCSS:o}=n,i=(r=Nt(e,O0))==null?void 0:r.node;if(i){const l=i.attrs.attrs||{},a=P0(l.style);if(t in a)return a[t]||"";if(l.id){const c=s.Components.getById(l.id);return((c==null?void 0:c.getStyle())||{})[o]||""}}return""},$0=n=>{const{view:e,prop:t,markName:s,editor:o,propCSS:i}=n,r=ep(e,s);if(r){const l=r.attrs;if(l[t])return l[t];if(l[tt]){const a=Xe(r).id;if(a){const c=o.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[i]||""}}}return""},vr=(n,e,t)=>{const{dispatch:s}=n,{nodes:o,marks:i}=n.state.schema,r={text:{selected:()=>{const{selection:l,doc:a}=n.state;return a.textBetween(l.from,l.to," ")},replace:(l,a={})=>{const{state:c}=n,{from:d}=c.selection;let p=c.tr.replaceSelectionWith(c.schema.text(l));a.select&&(p=p.setSelection($.create(p.doc,d,d+l.length))),s==null||s(p)},replaceHtml:l=>{const{schema:a,selection:c,tr:d}=n.state,p=document.createElement("div");p.innerHTML=l;const u=Bt.fromSchema(a).parse(p),{from:h,to:f}=c;return s==null?void 0:s(d.replaceRangeWith(h,f,u).scrollIntoView())},wrapStyle:()=>{const l=Ko(n),a=r.text.selected(),c=`i${e.Components._createId().slice(0,4)}`;r.text.replaceHtml(`<span id="${c}" ${Kd}>${a}</span>`),l==null||l.trigger("disable"),setTimeout(()=>{const d=l==null?void 0:l.find(`#${c}`)[0];d&&e.select(d)})},createBreak:()=>{const{state:l}=n,a=l.tr.replaceSelectionWith(o.inlineBreak.create()).scrollIntoView();return s==null?void 0:s(a)}},bold:{toggle:()=>kt(i.strong)(n.state,s),isActive:()=>Pn(n.state,i.strong)},italic:{toggle:()=>kt(i.em)(n.state,s),isActive:()=>Pn(n.state,i.em)},underline:{toggle:()=>kt(i.underline)(n.state,s),isActive:()=>Pn(n.state,i.underline)},strikethrough:{toggle:()=>kt(i.strikethrough)(n.state,s),isActive:()=>Pn(n.state,i.strikethrough)},link:{get:()=>{const l=Ko(n),a=l==null?void 0:l.getTrait("href");if(l!=null&&l.is("link"))return l.getAttributes();if(a)return{href:a.getValue()};{const c=ep(n,"link");return c?Xe(c):{}}},toggle:()=>kt(i.link)(n.state,s),isActive:()=>Pn(n.state,i.link),create:l=>{const a=Ko(n),c=a==null?void 0:a.getTrait("href"),{url:d,target:p}=l,u=()=>{var f,m;const h=(m=(f=Jd(n))==null?void 0:f.gjsView)==null?void 0:m.el;h&&h.contentEditable!=="true"&&(h.contentEditable="true"),n.focus()};a!=null&&a.is("link")?(a.addAttributes({href:d,target:p}),u()):c?(a==null||a.addAttributes({[c.getName()]:d}),u()):M0({view:n,href:d,target:p,options:t})}},alignText:{get:()=>L0({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:l=>T0(n,l.value,!0)},fontSize:{get:()=>$0({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:l=>A0(n,l.value)},image:{open(){const l="assetLayout",{state:a,dispatch:c}=n,{selection:d,doc:p}=a,u=p.textBetween(d.from,d.to," "),h={id:l,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:f=>{const m={alt:u,src:f.asset.getSrc()};c(a.tr.replaceSelectionWith(o.image.createAndFill({attrs:m})))}}};e.runCommand(W.layoutToggle,h)}},heading:{get:()=>{var a;const l=(a=Nt(n,zi))==null?void 0:a.node;return`${(l==null?void 0:l.attrs.level)||""}`},set:({value:l})=>{var d;const{state:a}=n,c=(d=Nt(n,zi))==null?void 0:d.node;Pm(a.schema.nodes.heading,{attrs:c==null?void 0:c.attrs.attrs,level:l?parseInt(l,10):0})(a,s)}},listBullet:{isActive:()=>{var l;return!!((l=Nt(n,Xd))!=null&&l.node)},toggle:()=>ba(n,o.bulletList)},listOrdered:{isActive:()=>{var l;return!!((l=Nt(n,Qd))!=null&&l.node)},toggle:()=>ba(n,o.orderedList)}};return r};class vt{constructor(e,t,s={}){this.match=e,this.match=e,this.handler=typeof t=="string"?z0(t):t,this.undoable=s.undoable!==!1,this.inCode=s.inCode||!1}}function z0(n){return function(e,t,s,o){let i=n;if(t[1]){let r=t[0].lastIndexOf(t[1]);i+=t[0].slice(r+t[1].length),s+=r;let l=s-o;l>0&&(i=t[0].slice(r-l,r)+i,s=o)}return e.tr.insertText(i,s,o)}}const V0=500;function B0({rules:n}){let e=new wn({state:{init(){return null},apply(t,s){let o=t.getMeta(this);return o||(t.selectionSet||t.docChanged?null:s)}},props:{handleTextInput(t,s,o,i){return va(t,s,o,i,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:s}=t.state.selection;s&&va(t,s.pos,s.pos,"",n,e)})}}},isInputRules:!0});return e}function va(n,e,t,s,o,i){if(n.composing)return!1;let r=n.state,l=r.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-V0),l.parentOffset,null,"")+s;for(let c=0;c<o.length;c++){let d=o[c];if(l.parent.type.spec.code){if(!d.inCode)continue}else if(d.inCode==="only")continue;let p=d.match.exec(a),u=p&&d.handler(r,p,e-(p[0].length-s.length),t);if(u)return d.undoable&&u.setMeta(i,{transform:u,from:e,to:t,text:s}),n.dispatch(u),!0}return!1}const H0=new vt(/--$/,"—"),F0=new vt(/\.\.\.$/,"…"),_0=new vt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),G0=new vt(/"$/,"”"),W0=new vt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),j0=new vt(/'$/,"’"),q0=[_0,G0,W0,j0];function Sr(n,e,t=null,s){return new vt(n,(o,i,r,l)=>{let a=t instanceof Function?t(i):t,c=o.tr.delete(r,l),d=c.doc.resolve(r),p=d.blockRange(),u=p&&zc(p,e,a);if(!u)return null;c.wrap(p,u);let h=c.doc.resolve(r-1).nodeBefore;return h&&h.type==e&&go(c.doc,r-1)&&(!s||s(i,h))&&c.join(r-1),c})}function tp(n,e,t=null){return new vt(n,(s,o,i,r)=>{let l=s.doc.resolve(i),a=t instanceof Function?t(o):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?s.tr.delete(i,r).setBlockType(i,i,e,a):null})}function U0(n){return Sr(/^\s*>\s$/,n)}function K0(n){return Sr(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function J0(n){return Sr(/^\s*([-+*])\s$/,n)}function Z0(n){return tp(/^```$/,n)}function Y0(n,e){return tp(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function X0(n){const e=q0.concat(F0,H0);let t;return(t=n.nodes.blockquote)&&e.push(U0(t)),(t=n.nodes.orderedList)&&e.push(K0(t)),(t=n.nodes.bulletList)&&e.push(J0(t)),(t=n.nodes.codeBlock)&&e.push(Z0(t)),(t=n.nodes.heading)&&e.push(Y0(t,6)),B0({rules:e})}const Q0="rteProseMirror",ey=H.free,Ce="rte:selectionchange",we={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>'},ty=(n,e)=>{var a;const{editor:t,el:s}=n,o=ds.get(s).view,i=vr(o,t,e),r={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},wrapStyle:{id:"wrapper",type:"button",icon:"tag",tooltip:"Wrap for styling",editorEvents:{[Ce]:({setState:c})=>{c({disabled:o.state.selection.empty})}},onClick:()=>i.text.wrapStyle()},bold:{id:"bold",icon:we.bold,size:"s",type:"button",editorEvents:{[Ce]:({setState:c})=>{c({active:i.bold.isActive()})}},onClick:({setState:c})=>{i.bold.toggle(),c({active:i.bold.isActive()})}},italic:{id:"italic",icon:we.italic,size:"s",type:"button",editorEvents:{[Ce]:({setState:c})=>{c({active:i.italic.isActive()})}},onClick:({setState:c})=>{i.italic.toggle(),c({active:i.italic.isActive()})}},underline:{id:"underline",icon:we.underline,size:"s",type:"button",editorEvents:{[Ce]:({setState:c})=>{c({active:i.underline.isActive()})}},onClick:({setState:c})=>{i.underline.toggle(),c({active:i.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:we.strikethrough,size:"s",type:"button",editorEvents:{[Ce]:({setState:c})=>{c({active:i.strikethrough.isActive()})}},onClick:({setState:c})=>{i.strikethrough.toggle(),c({active:i.strikethrough.isActive()})}},image:{id:"image",icon:we.image,size:"s",type:"button",onClick:()=>i.image.open()},link:{id:"link",icon:we.link,size:"s",type:"button",editorEvents:{[Ce]:({setState:c})=>{c({active:i.link.isActive(),disabled:o.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,{x:p,y:u,width:h,height:f}=d.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(W.layoutRemove,{id:m}),b=i.link.get(),C={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:p,y:u,w:h,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(W.layoutToggle,C)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:we.alignTextLeft},{id:"center",icon:we.alignTextCenter},{id:"right",icon:we.alignTextRight},{id:"justify",icon:we.alignTextJustify}],editorEvents:{[Ce]:({setState:c})=>{c({value:i.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:we.listBullet,size:"s",type:"button",editorEvents:{[Ce]:({setState:c})=>{c({active:i.listBullet.isActive()})}},onClick:({setState:c})=>{i.listBullet.toggle(),c({active:i.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:we.listOrdered,size:"s",type:"button",editorEvents:{[Ce]:({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:{[Ce]:({setState:c})=>{c({value:i.heading.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.heading.set({value:c}),o.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:{[Ce]:({setState:c})=>{c({value:i.fontSize.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.fontSize.set({value:c}),o.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:o},items:l}))||l};class ny{constructor(e,t,s){this.editor=s,this.node=e,this.dom=document.createElement("img"),this.view=t,Object.keys(e.attrs.attrs).forEach(o=>{this.dom.setAttribute(o,e.attrs.attrs[o])}),this.dom.addEventListener("dblclick",o=>this.handleDoubleClick(o))}handleDoubleClick(e){const{editor:t,view:s}=this;vr(s,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 sy=function(n,e={}){const t={plugins:l=>l.plugins,...e},s=(l,a)=>{var g,b;const c=((g=t.schema)==null?void 0:g.call(t,{editor:n,schema:ga}))||ga,{nodes:d,marks:p}=c,u={...a,component:a.view.model,editor:n,el:l},h=Bt.fromSchema(c).parse(l),f=sn.create({doc:h,schema:c,plugins:(b=t.plugins)==null?void 0:b.call(t,{editor:n,Plugin:wn,plugins:[i0(),m0(),X0(c),Fm(),Fo({Tab:ra(1),"Shift-Tab":ra(-1)}),Fo({Enter:Yn(Xc,Jm(d.listItem),k0(u,t)),"Shift-Enter":Yn(Yc,(C,y)=>(y&&y(C.tr.replaceSelectionWith(d.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":rd,"Mod-y":Si,"Mod-Shift-z":Si,"Mod-b":kt(p.strong),"Mod-i":kt(p.em),"Shift-Tab":xi(d.listItem),Tab:Xm(d.listItem)}),Fo(Om)]})}),m=new N1({mount:l},{state:f,dispatchTransaction(C){var x;const{state:y}=m,v=y.apply(C),w=!y.doc.eq(v.doc);m.updateState(v);const S=!y.selection.eq(v.selection);w&&(x0(((x=a==null?void 0:a.view)==null?void 0:x.el)||l),m.focus()),(S||w)&&n.trigger(Ce)}});return l.__rteView=m,m.setProps({nodeViews:{image(C){return new ny(C,m,n)}}}),m},o=l=>ty(l,t);n.setCustomRte({toolbar:o,parseContent:!0,async enable(l,a,c){const d=zs(l);if(d)return d;const p=s(l,c);return v0(l,p,c.view),I0(p,c),p},disable(l){const a=zs(l),c=a==null?void 0:a.view;if(c){const d=ya(l);return S0(l,c),d||n.once(n.RichTextEditor.events.disable,()=>{a.gjsView.model.trigger("rerender")}),c.destroy(),{forceSync:d}}},getContent(l,a,c){var p;const d=(p=zs(l))==null?void 0:p.view;if(d){const{schema:u,doc:h}=d.state;if(!ya(l))return c.view.lastContent;const f=document.createElement("div"),m=Wt.fromSchema(u).serializeFragment(h.content);return m.childNodes.forEach(g=>{g.nodeType===Node.ELEMENT_NODE&&g.innerHTML===""&&(g.innerHTML="<br/>")}),f.appendChild(m),w0(f),l.classList.remove("ProseMirror-focused"),f.innerHTML}return l.innerHTML}});const i=fc(n,t.enableOnClick),r=df(n,t.disableOnEsc);_({editor:n,licenseKey:t.licenseKey,plan:ey,pluginName:Q0,cleanup:()=>{n.RichTextEditor.customRte=void 0,i(),r()}})},oy=F(sy),iy="canvasEmptyState",ry=H.startup,ly=function(n,e={}){const t=new WeakMap,s=new WeakMap,o=new WeakMap,i=new Set,r=new WeakMap,l={emptyStates:[],...e},a=(y,v)=>{let w=!1;const{isValid:S}=v;return Array.isArray(S)?w=S.some(x=>y.is(x)):_t(S)?w=S({component:y,editor:n}):w=y.is(S),w},c=y=>{const v=t.get(y);t.delete(y),v==null||v()},d=y=>{y.views.forEach(v=>c(v)),o.delete(y)},p=y=>{if(!(!y||i.has(y)))try{i.add(y);const v=y.components().length>0,w=o.get(y);if(v&&w)d(y);else if(!v&&!w){const S=r.has(y)?r.get(y):l.emptyStates.find(x=>a(y,x));if(r.set(y,S),!S)return;y.views.forEach(x=>{const k=S.render({editor:n,component:y,componentView:x,mount:E=>{s.set(x,E),o.set(y,!0);const M=x.getChildrenContainer();M==null||M.appendChild(E)},unmount:()=>c(x)});t.set(x,()=>{k==null||k();const E=s.get(x);E==null||E.remove()})})}}finally{i.delete(y)}},u=y=>{o.has(y)&&d(y)},h=({model:y})=>{p(y.getComponent())},f=n.Components.events,m=`${f.update}:components`,g="component:mount",b=n.Canvas.events.frameLoadBody,C=f.removed;n.on(m,p),n.on(g,p),n.on(C,u),n.on(b,h),_({editor:n,licenseKey:l.licenseKey,plan:ry,pluginName:iy,cleanup:()=>{n.off(m,p),n.off(g,p),n.off(C,u),n.off(b,h)}})},ay=F(ly),Sa="canvasFullSize",cy=H.startup,dy=(n,e)=>{const{rule:t,ruleView:s}=e,{style:o}=t.attributes;if(o&&o[n]){const i=o[n],r=/([0-9.]+)(vh|dvh|lvh|svh)/g,l=r.test(i),a=s.frameView.model;if(l&&a.hasAutoHeight()){const c=i.replace(r,(p,u)=>`${window.innerHeight*(parseFloat(u)/100)}px`),d=t.toCSS({style:{...o,[n]:c}});e.css=d}}},py=n=>{["height","min-height","max-height"].forEach(e=>dy(e,n))},uy=function(n,e={}){const{Canvas:t,Commands:s,Devices:o,Css:i}=n,r={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...e},{canvasOffsetY:l,canvasOffsetX:a,canvasTransition:c,deviceMaxWidth:d,deviceMinHeigth:p,deviceFixedHeight:u,frameBorderRadius:h,frameTransition:f}=r,m=`${p}px`,g=t.events,b="core:preview",C=`${s.events.stopCommand}${b}`,y=t.getConfig(),v=`${Sa}:disable`,w=o.getAll().map(z=>({...z.attributes})),S=c*1e3,x={x:a,y:l};let k={},E,M;y.scrollableCanvas=!u,o.getAll().map(z=>{!z.get("width")&&z.set("width",`${d}px`),!z.get("height")&&z.set("height",u?"100vh":"auto"),!z.get("minHeight")&&z.set("minHeight",m)});const P=z=>{const pe=`${Bs}canvas-full-size`,ue=document.querySelector(`style[${pe}]`);if(z&&ue)return ue.remove();const Le=ue||document.createElement("style"),us=t.getZoomMultiplier();Le.setAttribute(pe,"true"),Le.innerHTML=`
|
|
907
|
+
}`,Qi=new WeakMap,ff=(n,e)=>{Qi.set(n,e)},mf=n=>{Qi.delete(n)},Ms=n=>Qi.get(n),So=n=>{const e=n.target,t=e.closest(".tox"),o=e.matches(".ephox-snooker-resizer-bar");(t||o)&&n.stopPropagation()},Qr=n=>{n.stopPropagation(),n.preventDefault()},gf=(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")},yf=n=>{var c,d;const{el:e,editor:t,componentView:o}=n,s=t.runCommand(W.getStateTheme),i=o.model,r={target:e,inline:!0,skin:(s==null?void 0:s.theme)===La.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}},el=(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)}),bf=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,p)=>{const u=d.ownerDocument,h=u.defaultView,f=p==null?void 0:p.view;if(!h||!f){console.warn("Missing required data",{win:h,componentView:f});return}const m=yf({el:d,editor:n,componentView:f,pluginOpts:t}),b=(await h.tinymce.init(m))[0];if(!b)return;const y=(await window.tinymce.init({...m,target:document.createElement("div")}))[0];return b.ui.show(),u.body.addEventListener("mousedown",So),document.body.addEventListener("mousedown",So),b.on("Change",()=>cf(d)),b.on("blur",()=>b.ui.show()),b.on("OpenWindow",function(){var S;const v=(S=u.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&&u.body.appendChild(v)}))}),d.addEventListener("dragstart",Qr,{capture:!0}),n.runCommand(W.setStateContextMenu,{enabled:!1}),gf(b,p),{rteEditor:b,rteEditorShallow:y}},a=(d,p)=>{d.ownerDocument.body.removeEventListener("mousedown",So),document.body.removeEventListener("mousedown",So),d.removeEventListener("dragstart",Qr,{capture:!0}),n.runCommand(W.setStateContextMenu,{enabled:!0}),p.rteEditor.destroy(),p.rteEditorShallow.destroy()};n.on(s.frameLoad,async({window:d})=>{const p=d.document;el(o,p)}),n.onReady(()=>{el(o,document),i&&Ui(r,hf,{target:document.body})}),n.setCustomRte({parseContent:!0,async enable(d,p,u){const h=Ms(d);if(h)return h.rteEditor;const f=await l(d,u);return f&&ff(d,f),f==null?void 0:f.rteEditor},disable(d){const p=Ms(d);p&&(mf(d),a(d,p))},getContent(d,p,u){var m;const h=Ms(d),f=h==null?void 0:h.rteEditor;return f&&!f.isDirty()?u.view.lastContent:f?(m=f.getContent)==null?void 0:m.call(f):d.innerHTML}});const c=fc(n,t.enableOnClick);G({editor:n,licenseKey:t.licenseKey,plan:uf,pluginName:pf,cleanup:()=>{n.RichTextEditor.customRte=void 0,c()}})},vf=_(bf);function Y(n){this.content=n}Y.prototype={constructor:Y,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 Y(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 Y(t)},addToStart:function(n,e){return new Y([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Y(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 Y(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=Y.from(n),n.size?new Y(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Y.from(n),n.size?new Y(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Y.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}};Y.from=function(n){if(n instanceof Y)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Y(e)};function mc(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=mc(s.content,i.content,t+1);if(r!=null)return r}t+=s.nodeSize}}function gc(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=gc(r.content,l.content,t-1,o-1);if(c)return c}t-=a,o-=a}}class T{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 T(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 T(o,s)}cutByIndex(e,t){return e==t?T.empty:e==0&&t==this.content.length?this:new T(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 T(s,i)}addToStart(e){return new T([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new T(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 mc(this,e,t)}findDiffEnd(e,t=this.size,o=e.size){return gc(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 i=this.child(o),r=s+i.nodeSize;if(r>=e)return r==e||t>0?xo(o+1,r):xo(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 T.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new T(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return T.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 T(t||e,o)}static from(e){if(!e)return T.empty;if(e instanceof T)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new T([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}T.empty=new T([],0);const As={index:0,offset:0};function xo(n,e){return As.index=n,As.offset=e,As}function jo(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(!jo(n[o],e[o]))return!1}else{for(let o in n)if(!(o in e)||!jo(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&&jo(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 qo 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=bc(this.content,e+this.openStart,t);return o&&new A(o,this.openStart,this.openEnd)}removeBetween(e,t){return new A(yc(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(T.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 A(e,o,s)}}A.empty=new A(T.empty,0,0);function yc(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(yc(i.content,e-s-1,t-s-1)))}function bc(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=bc(r.content,e-i-1,t);return l&&n.replaceChild(s,r.copy(l))}function Sf(n,e,t){if(t.openStart>n.depth)throw new qo("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new qo("Inconsistent open depths");return vc(n,e,t,0)}function vc(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=vc(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 Ot(r,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:r,end:l}=xf(t,n);return Ot(i,xc(n,r,l,e,o))}else return Ot(i,Uo(n,e,o))}function Sc(n,e){if(!e.type.compatibleContent(n.type))throw new qo("Cannot join "+e.type.name+" onto "+n.type.name)}function gi(n,e,t){let o=n.node(t);return Sc(o,e.node(t)),o}function It(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function zn(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&&(It(n.nodeAfter,o),i++));for(let l=i;l<r;l++)It(s.child(l),o);e&&e.depth==t&&e.textOffset&&It(e.nodeBefore,o)}function Ot(n,e){return n.type.checkContent(e),n.copy(e)}function xc(n,e,t,o,s){let i=n.depth>s&&gi(n,e,s+1),r=o.depth>s&&gi(t,o,s+1),l=[];return zn(null,n,s,l),i&&r&&e.index(s)==t.index(s)?(Sc(i,r),It(Ot(i,xc(n,e,t,o,s+1)),l)):(i&&It(Ot(i,Uo(n,e,s+1)),l),zn(e,t,s,l),r&&It(Ot(r,Uo(t,o,s+1)),l)),zn(o,null,s,l),new T(l)}function Uo(n,e,t){let o=[];if(zn(null,n,t,o),n.depth>t){let s=gi(n,e,t+1);It(Ot(s,Uo(n,e,t+1)),o)}return zn(e,null,t,o),new T(o)}function xf(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(T.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class Jn{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 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,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 Jn(t,o,i)}static resolveCached(e,t){let o=tl.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 tl.set(e,o=new wf);let s=o.elts[o.i]=Jn.resolve(e,t);return o.i=(o.i+1)%Cf,s}}class wf{constructor(){this.elts=[],this.i=0}}const Cf=12,tl=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 kf=Object.create(null);let Rt=class yi{constructor(e,t,o,s=B.none){this.type=e,this.attrs=t,this.marks=s,this.content=o||T.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&&jo(this.attrs,t||e.defaultAttrs||kf)&&B.sameSet(this.marks,o||B.none)}copy(e=null){return e==this.content?this:new yi(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new yi(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),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 A(c,s.depth-r,i.depth-r)}replace(e,t,o){return Sf(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 Jn.resolveCached(this,e)}resolveNoCache(e){return Jn.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()+")"),wc(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=T.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=T.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,s,o);return i.type.checkAttrs(i.attrs),i}};Rt.prototype.text=void 0;class Jo extends Rt{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):wc(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 Jo(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Jo(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 wc(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Vt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let o=new Ef(e,t);if(o.next==null)return Vt.empty;let s=Cc(o);o.next&&o.err("Unexpected trailing text");let i=Of(If(s));return Rf(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 T.from(l.map(c=>c.createAndFill()));for(let c=0;c<r.next.length;c++){let{type:d,next:p}=r.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(p)==-1){s.push(p);let u=i(p,l.concat(d));if(u)return u}}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(`
|
|
908
|
+
`)}}Vt.empty=new Vt(!0);class Ef{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 Cc(n){let e=[];do e.push(Tf(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Tf(n){let e=[];do e.push(Mf(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Mf(n){let e=Nf(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=Af(n,e);else break;return e}function nl(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Af(n,e){let t=nl(n),o=t;return n.eat(",")&&(n.next!="}"?o=nl(n):o=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:o,expr:e}}function Pf(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 Nf(n){if(n.eat("(")){let e=Cc(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=Pf(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 If(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 kc(n,e){return e-n}function ol(n,e){let t=[];return o(e),t.sort(kc);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 Of(n){let e=Object.create(null);return t(ol(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]);ol(n,a).forEach(d=>{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[o.join(",")]=new Vt(o.indexOf(n.length-1)>-1);for(let r=0;r<s.length;r++){let l=s[r][1].sort(kc);i.next.push({type:s[r][0],next:e[l.join(",")]||t(l)})}return i}}function Rf(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 Ec(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 Tc(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 Mc(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 Ac(n,e){let t=Object.create(null);if(e)for(let o in e)t[o]=new Lf(n,o,e[o]);return t}let sl=class Pc{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=Ac(e,o.attrs),this.defaultAttrs=Ec(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==Vt.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:Tc(this.attrs,e)}create(e=null,t,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Rt(this,this.computeAttrs(e),T.from(t),B.setFrom(o))}createChecked(e=null,t,o){return t=T.from(t),this.checkContent(t),new Rt(this,this.computeAttrs(e),t,B.setFrom(o))}createAndFill(e=null,t,o){if(e=this.computeAttrs(e),t=T.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(T.empty,!0);return i?new Rt(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){Mc(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 Pc(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 Df(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 Lf{constructor(e,t,o){this.hasDefault=Object.prototype.hasOwnProperty.call(o,"default"),this.default=o.default,this.validate=typeof o.validate=="string"?Df(e,t,o.validate):o.validate}get isRequired(){return!this.hasDefault}}class fs{constructor(e,t,o,s){this.name=e,this.rank=t,this.schema=o,this.spec=s,this.attrs=Ac(e,s.attrs),this.excluded=null;let i=Ec(this.attrs);this.instance=i?new B(this,i):null}create(e=null){return!e&&this.instance?this.instance:new B(this,Tc(this.attrs,e))}static compile(e,t){let o=Object.create(null),s=0;return e.forEach((i,r)=>o[i]=new fs(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){Mc(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class $f{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=Y.from(e.nodes),t.marks=Y.from(e.marks||{}),this.nodes=sl.compile(this.spec.nodes,this),this.marks=fs.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]=Vt.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?il(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==""?[]:il(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 sl){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 Jo(o,o.defaultAttrs,e,B.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Rt.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 il(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 zf(n){return n.tag!=null}function Vf(n){return n.style!=null}class Bt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let o=this.matchedStyles=[];t.forEach(s=>{if(zf(s))this.tags.push(s);else if(Vf(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 ll(this,t,!1);return o.addAll(e,B.none,t.from,t.to),o.finish()}parseSlice(e,t={}){let o=new ll(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 i=this.tags[s];if(Ff(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=al(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=al(r)),r.node||r.ignore||r.mark||(r.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Bt(e,Bt.schemaRules(e)))}}const Nc={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},Bf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ic={ol:!0,ul:!0},Zo=1,Yo=2,Vn=4;function rl(n,e,t){return e!=null?(e?Zo:0)|(e==="full"?Yo:0):n&&n.whitespace=="pre"?Zo|Yo:t&~Vn}class wo{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&Vn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(T.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&Zo)){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=T.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(T.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&&!Nc.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ll{constructor(e,t,o){this.parser=e,this.options=t,this.isOpen=o,this.open=0;let s=t.topNode,i,r=rl(null,t.preserveWhitespace,0)|(o?Vn:0);s?i=new wo(s.type,s.attrs,B.none,!0,t.topMatch||s.type.contentMatch,r):o?i=new wo(null,null,B.none,!0,null,r):i=new wo(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&Yo||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(o)){if(s.options&Zo)s.options&Yo?o=o.replace(/\r\n?/g,`
|
|
909
|
+
`):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 i=s.content[s.content.length-1],r=e.previousSibling;(!i||r&&r.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.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(),i;Ic.hasOwnProperty(s)&&this.parser.normalizeLists&&Hf(e);let r=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,o));if(r?r.ignore:Bf.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!r||r.skip||r.closeParent){r&&r.closeParent?this.open=Math.max(0,this.open-1):r&&r.skip.nodeType&&(e=r.skip);let l,a=this.top,c=this.needsBlock;if(Nc.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=r&&r.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,r,l,r.consuming===!1?i:void 0)}}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
910
|
+
`),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):cl(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=rl(e,i,r.options);r.options&Vn&&r.content.length==0&&(l|=Vn);let a=B.none;return o=o.filter(c=>(r.type?r.type.allowsMarkType(c.type):cl(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new wo(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 Hf(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&Ic.hasOwnProperty(o)&&t?(t.appendChild(e),e=t):o=="li"?t=e:o&&(t=null)}}function Ff(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function al(n){let e={};for(let t in n)e[t]=n[t];return e}function cl(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 Wt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},o){o||(o=Ps(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}=Oo(Ps(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&&Oo(Ps(o),s(e,t),null,e.attrs)}static renderSpec(e,t,o=null,s){return Oo(e,t,o,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Wt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=dl(e.nodes);return t.text||(t.text=o=>o.text),t}static marksFromSchema(e){return dl(e.marks)}}function dl(n){let e={};for(let t in n){let o=n[t].spec.toDOM;o&&(e[t]=o)}return e}function Ps(n){return n.document||window.document}const pl=new WeakMap;function _f(n){let e=pl.get(n);return e===void 0&&pl.set(n,e=Gf(n)),e}function Gf(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 Oo(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=_f(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 p in c)if(c[p]!=null){let u=p.indexOf(" ");u>0?a.setAttributeNS(p.slice(0,u),p.slice(u+1),c[p]):a.setAttribute(p,c[p])}}for(let p=d;p<e.length;p++){let u=e[p];if(u===0){if(p<e.length-1||p>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}=Oo(n,u,t,o);if(a.appendChild(h),f){if(l)throw new RangeError("Multiple content holes");l=f}}}return{dom:a,contentDOM:l}}const Oc=65535,Rc=Math.pow(2,16);function Wf(n,e){return n+e*Rc}function ul(n){return n&Oc}function jf(n){return(n-(n&Oc))/Rc}const Dc=1,Lc=2,Ro=4,$c=8;class bi{constructor(e,t,o){this.pos=e,this.delInfo=t,this.recover=o}get deleted(){return(this.delInfo&$c)>0}get deletedBefore(){return(this.delInfo&(Dc|Ro))>0}get deletedAfter(){return(this.delInfo&(Lc|Ro))>0}get deletedAcross(){return(this.delInfo&Ro)>0}}class be{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&be.empty)return be.empty}recover(e){let t=0,o=ul(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+jf(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],p=a+c;if(e<=p){let u=c?e==a?-1:e==p?1:t:t,h=a+s+(u<0?0:d);if(o)return h;let f=e==(t<0?a:p)?null:Wf(l/3,e-a),m=e==a?Lc:e==p?Dc:Ro;return(t<0?e!=a:e!=p)&&(m|=$c),new bi(h,m,f)}s+=d-c}return o?e+s:new bi(e+s,0,null)}touches(e,t){let o=0,s=ul(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 be(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?be.empty:new be(e<0?[0,-e,0]:[0,0,e])}}be.empty=new be([]);class cn{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 cn(this.maps,this.mirror,e,t)}copy(){return new cn(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 cn;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 bi(e,s,null)}}const Ns=Object.create(null);class se{getMap(){return be.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let o=Ns[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 Ns)throw new RangeError("Duplicate use of step JSON ID "+e);return Ns[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 qo)return K.fail(i.message);throw i}}}function er(n,e,t){let o=[];for(let s=0;s<n.childCount;s++){let i=n.child(s);i.content.size&&(i=i.copy(er(i.content,e,i))),i.isInline&&(i=e(i,t,s)),o.push(i)}return T.fromArray(o)}class ct extends se{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 A(er(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 Be(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 ct(t.pos,o.pos,this.mark)}merge(e){return e instanceof ct&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ct(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 ct(t.from,t.to,e.markFromJSON(t.mark))}}se.jsonID("addMark",ct);class Be extends se{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(er(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 ct(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 Be(t.pos,o.pos,this.mark)}merge(e){return e instanceof Be&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Be(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"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 Be(t.from,t.to,e.markFromJSON(t.mark))}}se.jsonID("removeMark",Be);class dt extends se{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(T.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 dt(this.pos,t.marks[s]);return new dt(this.pos,this.mark)}}return new mn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new dt(t.pos,this.mark)}toJSON(){return{stepType:"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 dt(t.pos,e.markFromJSON(t.mark))}}se.jsonID("addNodeMark",dt);class mn extends se{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(T.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new dt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new mn(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 mn(t.pos,e.markFromJSON(t.mark))}}se.jsonID("removeNodeMark",mn);class ne extends se{constructor(e,t,o,s=!1){super(),this.from=e,this.to=t,this.slice=o,this.structure=s}apply(e){return this.structure&&vi(e,this.from,this.to)?K.fail("Structure replace would overwrite content"):K.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new be([this.from,this.to-this.from,this.slice.size])}invert(e){return new ne(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 ne(t.pos,Math.max(t.pos,o.pos),this.slice)}merge(e){if(!(e instanceof ne)||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 ne(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 ne(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 ne(t.from,t.to,A.fromJSON(e,t.slice),!!t.structure)}}se.jsonID("replace",ne);class ee extends se{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&&(vi(e,this.from,this.gapFrom)||vi(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 be([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 ee(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 ee(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 ee(t.from,t.to,t.gapFrom,t.gapTo,A.fromJSON(e,t.slice),t.insert,!!t.structure)}}se.jsonID("replaceAround",ee);function vi(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 qf(n,e,t,o){let s=[],i=[],r,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let p=a.marks;if(!o.isInSet(p)&&d.type.allowsMarkType(o.type)){let u=Math.max(c,e),h=Math.min(c+a.nodeSize,t),f=o.addToSet(p);for(let m=0;m<p.length;m++)p[m].isInSet(f)||(r&&r.to==u&&r.mark.eq(p[m])?r.to=h:s.push(r=new Be(u,h,p[m])));l&&l.to==u?l.to=h:i.push(l=new ct(u,h,o))}}),s.forEach(a=>n.step(a)),i.forEach(a=>n.step(a))}function Uf(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 fs){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 p=a[d],u;for(let h=0;h<s.length;h++){let f=s[h];f.step==i-1&&p.eq(s[h].style)&&(u=f)}u?(u.to=c,u.step=i):s.push({style:p,from:Math.max(l,e),to:c,step:i})}}}),s.forEach(r=>n.step(new Be(r.from,r.to,r.style)))}function tr(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,p=o.matchType(c.type);if(!p)r.push(new ne(l,d,A.empty));else{o=p;for(let u=0;u<c.marks.length;u++)t.allowsMarkType(c.marks[u].type)||n.step(new Be(l,d,c.marks[u]));if(s&&c.isText&&t.whitespace!="pre"){let u,h=/\r?\n|\r/g,f;for(;u=h.exec(c.text);)f||(f=new A(T.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),r.push(new ne(l+u.index,l+u.index+u[0].length,f))}}l=d}if(!o.validEnd){let a=o.fillBefore(T.empty,!0);n.replace(l,l,new A(a,0,0))}for(let a=r.length-1;a>=0;a--)n.step(r[a])}function Kf(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function ms(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||!Kf(s,i,r))break}return null}function Jf(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=T.empty,p=0;for(let f=i,m=!1;f>t;f--)m||o.index(f)>0?(m=!0,d=T.from(o.node(f).copy(d)),p++):a--;let u=T.empty,h=0;for(let f=i,m=!1;f>t;f--)m||s.after(f+1)<s.end(f)?(m=!0,u=T.from(s.node(f).copy(u)),h++):c++;n.step(new ee(a,c,r,l,new A(d.append(u),p,h),d.size-p,!0))}function zc(n,e,t=null,o=n){let s=Zf(n,e),i=s&&Yf(o,e);return i?s.map(hl).concat({type:e,attrs:t}).concat(i.map(hl)):null}function hl(n){return{type:n,attrs:null}}function Zf(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 Yf(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 Xf(n,e,t){let o=T.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=T.from(t[r].type.create(t[r].attrs,o))}let s=e.start,i=e.end;n.step(new ee(s,i,s,i,new A(o,0,0),t.length,!0))}function Qf(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)&&em(n.doc,n.mapping.slice(i).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&&Bc(n,r,l,i),tr(n,n.mapping.slice(i).map(l,1),o,void 0,c===null);let d=n.mapping.slice(i),p=d.map(l,1),u=d.map(l+r.nodeSize,1);return n.step(new ee(p,u,p+1,u-1,new A(T.from(o.create(a,null,r.marks)),0,0),1,!0)),c===!0&&Vc(n,r,l,i),!1}})}function Vc(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 Bc(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(`
|
|
911
|
+
`))}})}function em(n,e,t){let o=n.resolve(e),s=o.index();return o.parent.canReplaceWith(s,s+1,t)}function tm(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 ee(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new A(T.from(r),0,0),1,!0))}function dn(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 p=s.node(c),u=s.index(c);if(p.type.spec.isolating)return!1;let h=p.content.cutByIndex(u,p.childCount),f=o&&o[d+1];f&&(h=h.replaceChild(0,f.type.create(f.attrs)));let m=o&&o[d]||p;if(!p.canReplace(u+1,p.childCount)||!m.type.validContent(h))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 nm(n,e,t=1,o){let s=n.doc.resolve(e),i=T.empty,r=T.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){i=T.from(s.node(l).copy(i));let d=o&&o[c];r=T.from(d?d.type.create(d.attrs,r):s.node(l).copy(r))}n.step(new ne(e,e,new A(i.append(r),t,t),!0))}function gs(n,e){let t=n.resolve(e),o=t.index();return sm(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(o,o+1)}function om(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 sm(n,e){return!!(n&&e&&!n.isLeaf&&om(n,e))}function im(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",p=!!r.contentMatch.matchType(s);d&&!p?o=!1:!d&&p&&(o=!0)}let l=n.steps.length;if(o===!1){let d=n.doc.resolve(e+t);Bc(n,d.node(),d.before(),l)}r.inlineContent&&tr(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 ne(c,a.map(e+t,-1),A.empty,!0)),o===!0){let d=n.doc.resolve(c);Vc(n,d.node(),d.before(),n.steps.length)}return n}function rm(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 lm(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 p=c.contentMatchAt(a).findWrapping(s.firstChild.type);d=p&&c.canReplaceWith(a,a,p[0])}if(d)return l==0?o.pos:l<0?o.before(r+1):o.after(r+1)}return null}function nr(n,e,t=e,o=A.empty){if(e==t&&!o.size)return null;let s=n.resolve(e),i=n.resolve(t);return Hc(s,i,o)?new ne(e,t,o):new am(s,i,o).fit()}function Hc(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class am{constructor(e,t,o){this.$from=e,this.$to=t,this.unplaced=o,this.frontier=[],this.placed=T.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=T.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 A(i,r,l);return e>-1?new ee(o.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||o.pos!=this.$to.pos?new ne(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=Is(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,p=null;if(t==1&&(r?c.matchType(r.type)||(p=c.fillBefore(T.from(r),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:o,frontierDepth:l,parent:i,inject:p};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=Is(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=Is(e,t);if(s.childCount<=1&&t>0){let i=e.size-t<=t+s.size;this.unplaced=new A(In(e,t-1,1),t-1,i?t-1:o)}else this.unplaced=new A(In(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:p,type:u}=this.frontier[t];if(s){for(let m=0;m<s.childCount;m++)d.push(s.child(m));p=p.matchFragment(s)}let h=l.size+e-(r.content.size-r.openEnd);for(;c<l.childCount;){let m=l.child(c),g=p.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(p=g,d.push(Fc(m.mark(u.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let f=c==l.childCount;f||(h=-1),this.placed=On(this.placed,t,T.from(d)),this.frontier[t].match=p,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 b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=f?e==0?A.empty:new A(In(r.content,e-1,1),e-1,h<0?r.openEnd:e-1):new A(In(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||!Os(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=Os(e,t,s,o,i);if(r){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=Os(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=On(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=On(this.placed,this.depth,T.from(e.create(t,o))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(T.empty,!0);t.childCount&&(this.placed=On(this.placed,this.frontier.length,t))}}function In(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(In(n.firstChild.content,e-1,t)))}function On(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(On(n.lastChild.content,e-1,t)))}function Is(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Fc(n,e,t){if(e<=0)return n;let o=n.content;return e>1&&(o=o.replaceChild(0,Fc(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(T.empty,!0)))),n.copy(o)}function Os(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&&!cm(t,i.content,r)?l:null}function cm(n,e,t){for(let o=t;o<e.childCount;o++)if(!n.allowsMarks(e.child(o).marks))return!0;return!1}function dm(n){return n.spec.defining||n.spec.definingForContent}function pm(n,e,t,o){if(!o.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),i=n.doc.resolve(t);if(Hc(s,i,o))return n.step(new ne(e,t,o));let r=Gc(s,n.doc.resolve(t));r[r.length-1]==0&&r.pop();let l=-(s.depth+1);r.unshift(l);for(let u=s.depth,h=s.pos-1;u>0;u--,h--){let f=s.node(u).type.spec;if(f.defining||f.definingAsContext||f.isolating)break;r.indexOf(u)>-1?l=u:s.before(u)==h&&r.splice(1,0,-u)}let a=r.indexOf(l),c=[],d=o.openStart;for(let u=o.content,h=0;;h++){let f=u.firstChild;if(c.push(f),h==o.openStart)break;u=f.content}for(let u=d-1;u>=0;u--){let h=c[u],f=dm(h.type);if(f&&!h.sameMarkup(s.node(Math.abs(l)-1)))d=u;else if(f||!h.type.isTextblock)break}for(let u=o.openStart;u>=0;u--){let h=(u+d+1)%(o.openStart+1),f=c[h];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 C=s.node(g-1),y=s.index(g-1);if(C.canReplaceWith(y,y,f.type,f.marks))return n.replace(s.before(g),b?i.after(g):t,new A(_c(o.content,0,o.openStart,h),h,o.openEnd))}}let p=n.steps.length;for(let u=r.length-1;u>=0&&(n.replace(e,t,o),!(n.steps.length>p));u--){let h=r[u];h<0||(e=s.before(h),t=i.after(h))}}function _c(n,e,t,o,s){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(_c(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(T.empty,!0))}return n}function um(n,e,t,o){if(!o.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=rm(n.doc,e,o.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new A(T.from(o),0,0))}function hm(n,e,t){let o=n.doc.resolve(e),s=n.doc.resolve(t),i=Gc(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 Gc(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 pn extends se{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 A(T.from(s),0,t.isLeaf?0:1))}getMap(){return be.empty}invert(e){return new pn(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 pn(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 pn(t.pos,t.attr,t.value)}}se.jsonID("attr",pn);class Zn extends se{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 be.empty}invert(e){return new Zn(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 Zn(t.attr,t.value)}}se.jsonID("docAttr",Zn);let gn=class extends Error{};gn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};gn.prototype=Object.create(Error.prototype);gn.prototype.constructor=gn;gn.prototype.name="TransformError";class Wc{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new cn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new gn(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=nr(this.doc,e,t,o);return s&&this.step(s),this}replaceWith(e,t,o){return this.replace(e,t,new A(T.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 pm(this,e,t,o),this}replaceRangeWith(e,t,o){return um(this,e,t,o),this}deleteRange(e,t){return hm(this,e,t),this}lift(e,t){return Jf(this,e,t),this}join(e,t=1){return im(this,e,t),this}wrap(e,t){return Xf(this,e,t),this}setBlockType(e,t=e,o,s=null){return Qf(this,e,t,o,s),this}setNodeMarkup(e,t,o=null,s){return tm(this,e,t,o,s),this}setNodeAttribute(e,t,o){return this.step(new pn(e,t,o)),this}setDocAttribute(e,t){return this.step(new Zn(e,t)),this}addNodeMark(e,t){return this.step(new dt(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 mn(e,t)),this}split(e,t=1,o){return nm(this,e,t,o),this}addMark(e,t,o){return qf(this,e,t,o),this}removeMark(e,t,o){return Uf(this,e,t,o),this}clearIncompatible(e,t,o){return tr(this,e,t,o),this}}const Rs=Object.create(null);class L{constructor(e,t,o){this.$anchor=e,this.$head=t,this.ranges=o||[new jc(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 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?A.empty:t),l==0&&gl(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),gl(e,o,t.isInline?-1:1))}}static findFrom(e,t,o=!1){let s=e.parent.inlineContent?new $(e):Xt(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?Xt(e.node(0),e.node(i),e.before(i+1),e.index(i),t,o):Xt(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 Se(e.node(0))}static atStart(e){return Xt(e,e,0,0,1)||new Se(e)}static atEnd(e){return Xt(e,e,e.content.size,e.childCount,-1)||new Se(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let o=Rs[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 Rs)throw new RangeError("Duplicate use of selection JSON ID "+e);return Rs[e]=t,t.prototype.jsonID=e,t}getBookmark(){return $.between(this.$anchor,this.$head).getBookmark()}}L.prototype.visible=!0;class jc{constructor(e,t){this.$from=e,this.$to=t}}let fl=!1;function ml(n){!fl&&!n.parent.inlineContent&&(fl=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class $ extends L{constructor(e,t=e){ml(e),ml(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 L.near(o);let s=e.resolve(t.map(this.anchor));return new $(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 $&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ys(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 $(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=L.findFrom(t,o,!0)||L.findFrom(t,-o,!0);if(i)t=i.$head;else return L.near(t,o)}return e.parent.inlineContent||(s==0?e=t:(e=(L.findFrom(e,-o,!0)||L.findFrom(e,o,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new $(e,t)}}L.jsonID("text",$);class ys{constructor(e,t){this.anchor=e,this.head=t}map(e){return new ys(e.map(this.anchor),e.map(this.head))}resolve(e){return $.between(e.resolve(this.anchor),e.resolve(this.head))}}class D extends L{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?L.near(i):new D(i)}content(){return new A(T.from(this.node),0,0)}eq(e){return e instanceof D&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new or(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new D(e.resolve(t.anchor))}static create(e,t){return new D(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}D.prototype.visible=!1;L.jsonID("node",D);class or{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:o}=e.mapResult(this.anchor);return t?new ys(o,o):new or(o)}resolve(e){let t=e.resolve(this.anchor),o=t.nodeAfter;return o&&D.isSelectable(o)?new D(t):L.near(t)}}class Se extends L{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=L.atStart(e.doc);o.eq(e.selection)||e.setSelection(o)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Se(e)}map(e){return new Se(e)}eq(e){return e instanceof Se}getBookmark(){return fm}}L.jsonID("all",Se);const fm={map(){return this},resolve(n){return new Se(n)}};function Xt(n,e,t,o,s,i=!1){if(e.inlineContent)return $.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&&D.isSelectable(l))return D.create(n,t-(s<0?l.nodeSize:0))}else{let a=Xt(n,l,t+s,s<0?l.childCount:0,s,i);if(a)return a}t+=l.nodeSize*s}return null}function gl(n,e,t){let o=n.steps.length-1;if(o<e)return;let s=n.steps[o];if(!(s instanceof ne||s instanceof ee))return;let i=n.mapping.maps[o],r;i.forEach((l,a,c,d)=>{r==null&&(r=d)}),n.setSelection(L.near(n.doc.resolve(r),t))}const yl=1,Co=2,bl=4;class mm extends Wc{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|yl)&~Co,this.storedMarks=null,this}get selectionSet(){return(this.updated&yl)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Co,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&Co)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Co,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(L.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|=bl,this}get scrolledIntoView(){return(this.updated&bl)>0}}function vl(n,e){return!e||!n?n:n.bind(e)}class Rn{constructor(e,t,o){this.name=e,this.init=vl(t.init,o),this.apply=vl(t.apply,o)}}const gm=[new Rn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Rn("selection",{init(n,e){return n.selection||L.atStart(e.doc)},apply(n){return n.selection}}),new Rn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,o){return o.selection.$cursor?n.storedMarks:null}}),new Rn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Ds{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=gm.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 Rn(o.key,o.spec.state,o))})}}class on{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 p=0;p<this.config.plugins.length;p++)s.push(p<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 on(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 mm(this)}static create(e){let t=new Ds(e.doc?e.doc.type.schema:e.schema,e.plugins),o=new on(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 Ds(this.schema,e.plugins),o=t.fields,s=new on(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 Ds(e.schema,e.plugins),i=new on(s);return s.fields.forEach(r=>{if(r.name=="doc")i.doc=Rt.fromJSON(e.schema,t.doc);else if(r.name=="selection")i.selection=L.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 qc(n,e,t){for(let o in n){let s=n[o];s instanceof Function?s=s.bind(e):o=="handleDOMEvents"&&(s=qc(s,e,{})),t[o]=s}return t}class wn{constructor(e){this.spec=e,this.props={},e.props&&qc(e.props,this,this.props),this.key=e.key?e.key.key:Uc("plugin")}getState(e){return e[this.key]}}const Ls=Object.create(null);function Uc(n){return n in Ls?n+"$"+ ++Ls[n]:(Ls[n]=0,n+"$")}class so{constructor(e="key"){this.key=Uc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Kc=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function ym(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const bm=(n,e,t)=>{let o=ym(n,t);if(!o)return!1;let s=Jc(o);if(!s){let r=o.blockRange(),l=r&&ms(r);return l==null?!1:(e&&e(n.tr.lift(r,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(td(n,s,e,-1))return!0;if(o.parent.content.size==0&&(yn(i,"end")||D.isSelectable(i)))for(let r=o.depth;;r--){let l=nr(n.doc,o.before(r),o.after(r),A.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(yn(i,"end")?L.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):D.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 yn(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 vm=(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=Jc(o)}let r=i&&i.nodeBefore;return!r||!D.isSelectable(r)?!1:(e&&e(n.tr.setSelection(D.create(n.doc,i.pos-r.nodeSize)).scrollIntoView()),!0)};function Jc(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 Sm(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const xm=(n,e,t)=>{let o=Sm(n,t);if(!o)return!1;let s=Zc(o);if(!s)return!1;let i=s.nodeAfter;if(td(n,s,e,1))return!0;if(o.parent.content.size==0&&(yn(i,"start")||D.isSelectable(i))){let r=nr(n.doc,o.before(),o.after(),A.empty);if(r&&r.slice.size<r.to-r.from){if(e){let l=n.tr.step(r);l.setSelection(yn(i,"start")?L.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):D.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},wm=(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=Zc(o)}let r=i&&i.nodeAfter;return!r||!D.isSelectable(r)?!1:(e&&e(n.tr.setSelection(D.create(n.doc,i.pos)).scrollIntoView()),!0)};function Zc(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 Cm=(n,e)=>{let{$head:t,$anchor:o}=n.selection;return!t.parent.type.spec.code||!t.sameParent(o)?!1:(e&&e(n.tr.insertText(`
|
|
912
|
+
`).scrollIntoView()),!0)};function sr(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 Yc=(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=sr(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(L.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},km=(n,e)=>{let t=n.selection,{$from:o,$to:s}=t;if(t instanceof Se||o.parent.inlineContent||s.parent.inlineContent)return!1;let i=sr(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($.create(l.doc,r+1)),e(l.scrollIntoView())}return!0},Xc=(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(dn(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let o=t.blockRange(),s=o&&ms(o);return s==null?!1:(e&&e(n.tr.lift(o,s).scrollIntoView()),!0)};function Qc(n){return(e,t)=>{let{$from:o,$to:s}=e.selection;if(e.selection instanceof D&&e.selection.node.isBlock)return!o.parentOffset||!dn(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 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=sr(o.node(h-1).contentMatchAt(o.indexAfter(h-1)));let m=n&&n(s.parent,a,o);i.unshift(m||(a&&l?{type:l}:null)),r=h;break}else{if(h==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof $||e.selection instanceof Se)&&d.deleteSelection();let p=d.mapping.map(o.pos),u=dn(d.doc,p,i.length,i);if(u||(i[0]=l?{type:l}:null,u=dn(d.doc,p,i.length,i)),d.split(p,i.length,i),!a&&c&&o.node(r).type!=l){let h=d.mapping.map(o.before(r)),f=d.doc.resolve(h);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 Em=Qc(),ed=(n,e)=>(e&&e(n.tr.setSelection(new Se(n.doc))),!0);function Tm(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||gs(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function td(n,e,t,o){let s=e.nodeBefore,i=e.nodeAfter,r,l,a=s.type.spec.isolating||i.type.spec.isolating;if(!a&&Tm(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 h=e.pos+i.nodeSize,f=T.empty;for(let b=r.length-1;b>=0;b--)f=T.from(r[b].create(null,f));f=T.from(s.copy(f));let m=n.tr.step(new ee(e.pos-1,h,e.pos,h,new A(f,1,0),r.length,!0)),g=m.doc.resolve(h+2*r.length);g.nodeAfter&&g.nodeAfter.type==s.type&&gs(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=i.type.spec.isolating||o>0&&a?null:L.findFrom(e,1),p=d&&d.$from.blockRange(d.$to),u=p&&ms(p);if(u!=null&&u>=e.depth)return t&&t(n.tr.lift(p,u).scrollIntoView()),!0;if(c&&yn(i,"start",!0)&&yn(s,"end")){let h=s,f=[];for(;f.push(h),!h.isTextblock;)h=h.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let b=T.empty;for(let y=f.length-1;y>=0;y--)b=T.from(f[y].copy(b));let C=n.tr.step(new ee(e.pos-f.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new A(b,f.length,0),0,!0));t(C.scrollIntoView())}return!0}}return!1}function nd(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($.create(e.doc,n<0?s.start(i):s.end(i)))),!0):!1}}const Mm=nd(-1),Am=nd(1);function Pm(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),p=d.index();s=d.parent.canReplaceWith(p,p+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 Nm(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||!Nm(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(p=>s.doc.rangeHasMark(p.$from.pos,p.$to.pos,n));for(let p=0;p<a.length;p++){let{$from:u,$to:h}=a[p];if(!c)d.removeMark(u.pos,h.pos,n);else{let f=u.pos,m=h.pos,g=u.nodeAfter,b=h.nodeBefore,C=g&&g.isText?/^\s*/.exec(g.text)[0].length:0,y=b&&b.isText?/\s*$/.exec(b.text)[0].length:0;f+C<m&&(f+=C,m-=y),d.addMark(f,m,n.create(e))}}i(d.scrollIntoView())}return!0}}function Yn(...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 $s=Yn(Kc,bm,vm),Sl=Yn(Kc,xm,wm);const Ye={Enter:Yn(Cm,km,Xc,Em),"Mod-Enter":Yc,Backspace:$s,"Mod-Backspace":$s,"Shift-Backspace":$s,Delete:Sl,"Mod-Delete":Sl,"Mod-a":ed},od={"Ctrl-h":Ye.Backspace,"Alt-Backspace":Ye["Mod-Backspace"],"Ctrl-d":Ye.Delete,"Ctrl-Alt-Backspace":Ye["Mod-Delete"],"Alt-Delete":Ye["Mod-Delete"],"Alt-d":Ye["Mod-Delete"],"Ctrl-a":Mm,"Ctrl-e":Am};for(let n in Ye)od[n]=Ye[n];const Im=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Om=Im?od:Ye;var Xo=200,J=function(){};J.prototype.append=function(e){return e.length?(e=J.from(e),!this.length&&e||e.length<Xo&&this.leafAppend(e)||this.length<Xo&&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 Rm(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 sd(e):J.empty};var sd=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<=Xo)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Xo)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 sd([]);var Rm=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 Dm=500;class Ie{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((p,u)=>{if(!p.step){s||(s=this.remapping(o,u+1),i=s.maps.length),i--,d.push(p);return}if(s){d.push(new $e(p.map));let h=p.step.map(s.slice(i)),f;h&&r.maybeStep(h).doc&&(f=r.mapping.maps[r.mapping.maps.length-1],c.push(new $e(f,void 0,void 0,c.length+d.length))),i--,f&&s.appendMap(f,i)}else r.maybeStep(p.step);if(p.selection)return l=s?p.selection.map(s.slice(i)):p.selection,a=new Ie(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 p=e.steps[d].invert(e.docs[d]),u=new $e(e.mapping.maps[d],p,t),h;(h=a&&a.merge(u))&&(u=h,d?i.pop():l=l.slice(0,l.length-1)),i.push(u),t&&(r++,t=void 0),s||(a=u)}let c=r-o.depth;return c>$m&&(l=Lm(l,c),r-=c),new Ie(l.append(i),r)}remapping(e,t){let o=new cn;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 Ie(this.items.append(e.map(t=>new $e(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(u=>{u.selection&&l--},s);let a=t;this.items.forEach(u=>{let h=i.getMirror(--a);if(h==null)return;r=Math.min(r,h);let f=i.maps[h];if(u.step){let m=e.steps[h].invert(e.docs[h]),g=u.selection&&u.selection.map(i.slice(a+1,h));g&&l++,o.push(new $e(f,m,g))}else o.push(new $e(f))},s);let c=[];for(let u=t;u<r;u++)c.push(new $e(i.maps[u]));let d=this.items.slice(0,s).append(c).append(o),p=new Ie(d,l);return p.emptyItemCount()>Dm&&(p=p.compress(this.items.length-o.length)),p}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 p=new $e(c.invert(),a,d),u,h=s.length-1;(u=s.length&&s[h].merge(p))?s[h]=u:s.push(p)}}else r.map&&o--},this.items.length,0),new Ie(J.from(s.reverse()),i)}}Ie.empty=new Ie(J.empty,0);function Lm(n,e){let t;return n.forEach((o,s)=>{if(o.selection&&e--==0)return t=s,!1}),n.slice(t)}class $e{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 $e(t.getMap().invert(),t,this.selection)}}}class st{constructor(e,t,o,s,i){this.done=e,this.undone=t,this.prevRanges=o,this.prevTime=s,this.prevComposition=i}}const $m=20;function zm(n,e,t,o){let s=t.getMeta(Dt),i;if(s)return s.historyState;t.getMeta(Hm)&&(n=new st(n.done,n.undone,null,0,-1));let r=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(r&&r.getMeta(Dt))return r.getMeta(Dt).redo?new st(n.done.addTransform(t,void 0,o,Do(e)),n.undone,xl(t.mapping.maps),n.prevTime,n.prevComposition):new st(n.done,n.undone.addTransform(t,void 0,o,Do(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||!Vm(t,n.prevRanges)),c=r?zs(n.prevRanges,t.mapping):xl(t.mapping.maps);return new st(n.done.addTransform(t,a?e.selection.getBookmark():void 0,o,Do(e)),Ie.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new st(n.done.rebased(t,i),n.undone.rebased(t,i),zs(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new st(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),zs(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Vm(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 xl(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 zs(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 Bm(n,e,t){let o=Do(e),s=Dt.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 st(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(r).setMeta(Dt,{redo:t,historyState:a})}let Vs=!1,wl=null;function Do(n){let e=n.plugins;if(wl!=e){Vs=!1,wl=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Vs=!0;break}}return Vs}const Dt=new so("history"),Hm=new so("closeHistory");function Fm(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new wn({key:Dt,state:{init(){return new st(Ie.empty,Ie.empty,null,0,-1)},apply(e,t,o){return zm(t,o,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let o=t.inputType,s=o=="historyUndo"?rd:o=="historyRedo"?Si:null;return s?(t.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function id(n,e){return(t,o)=>{let s=Dt.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(o){let i=Bm(s,t,n);i&&o(e?i.scrollIntoView():i)}return!0}}const rd=id(!1,!0),Si=id(!0,!0);var yt={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:"'"},Qo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},_m=typeof navigator<"u"&&/Mac/.test(navigator.platform),Gm=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var X=0;X<10;X++)yt[48+X]=yt[96+X]=String(X);for(var X=1;X<=24;X++)yt[X+111]="F"+X;for(var X=65;X<=90;X++)yt[X]=String.fromCharCode(X+32),Qo[X]=String.fromCharCode(X);for(var Bs in yt)Qo.hasOwnProperty(Bs)||(Qo[Bs]=yt[Bs]);function Wm(n){var e=_m&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Gm&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Qo:yt)[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 jm=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function qm(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))jm?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 Um(n){let e=Object.create(null);for(let t in n)e[qm(t)]=n[t];return e}function Hs(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 Fs(n){return new wn({props:{handleKeyDown:ld(n)}})}function ld(n){let e=Um(n);return function(t,o){let s=Wm(o),i,r=e[Hs(s,o)];if(r&&r(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(o.shiftKey){let l=e[Hs(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=yt[o.keyCode])&&i!=s){let l=e[Hs(i,o)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}function Cl(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 Ko(d,d,r.depth),r.endIndex<r.parent.childCount&&(r=new Ko(s,t.doc.resolve(i.end(r.depth)),r.depth)),l=!0}let c=zc(a,n,e,r);return c?(o&&o(Km(t.tr,r,c,l,n).scrollIntoView()),!0):!1}}function Km(n,e,t,o,s){let i=T.empty;for(let d=t.length-1;d>=0;d--)i=T.from(t[d].type.create(t[d].attrs,i));n.step(new ee(e.start-(o?2:0),e.end,e.start,e.end,new A(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,p=e.endIndex,u=!0;d<p;d++,u=!1)!u&&dn(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function Jm(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 p=T.empty,u=s.index(-1)?1:s.index(-2)?2:3;for(let b=s.depth-u;b>=s.depth-3;b--)p=T.from(s.node(b).copy(p));let h=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3;p=p.append(T.from(n.createAndFill()));let f=s.before(s.depth-(u-1)),m=t.tr.replace(f,s.after(-h),new A(p,4-u,0)),g=-1;m.doc.nodesBetween(f,m.doc.content.size,(b,C)=>{if(g>-1)return!1;b.isTextblock&&b.content.size==0&&(g=C+1)}),g>-1&&m.setSelection(L.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 dn(c.doc,s.pos,2,d)?(o&&o(c.split(s.pos,2,d).scrollIntoView()),!0):!1}}function xi(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?Zm(e,t,n,i):Ym(e,t,i):!0:!1}}function Zm(n,e,t,o){let s=n.tr,i=o.end,r=o.$to.end(o.depth);i<r&&(s.step(new ee(i-1,r,i,r,new A(T.from(t.create(null,o.parent.copy())),1,0),1,!0)),o=new Ko(s.doc.resolve(o.$from.pos),s.doc.resolve(r),o.depth));const l=ms(o);if(l==null)return!1;s.lift(o,l);let a=s.mapping.map(i,-1)-1;return gs(s.doc,a)&&s.join(a),e(s.scrollIntoView()),!0}function Ym(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 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?T.empty:T.from(s))))return!1;let p=i.pos,u=p+r.nodeSize;return o.step(new ee(p-(l?1:0),u+(a?1:0),p+1,u-1,new A((l?T.empty:T.from(s.copy(T.empty))).append(a?T.empty:T.from(s.copy(T.empty))),l?0:1,a?0:1),l?0:1)),e(o.scrollIntoView()),!0}function Xm(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=T.from(c?n.create():null),p=new A(T.from(n.create(null,T.from(l.type.create(null,d)))),c?3:1,0),u=i.start,h=i.end;t(e.tr.step(new ee(u-(c?3:1),h,u,h,p,1,!0)).scrollIntoView())}return!0}}const Q=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Xn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let wi=null;const Ze=function(n,e,t){let o=wi||(wi=document.createRange());return o.setEnd(n,t??n.nodeValue.length),o.setStart(n,e||0),o},Qm=function(){wi=null},Ht=function(n,e,t,o){return t&&(kl(n,e,t,o,-1)||kl(n,e,t,o,1))},eg=/^(img|br|input|textarea|hr)$/i;function kl(n,e,t,o,s){for(;;){if(n==t&&e==o)return!0;if(e==(s<0?0:Ee(n))){let i=n.parentNode;if(!i||i.nodeType!=1||io(n)||eg.test(n.nodeName)||n.contentEditable=="false")return!1;e=Q(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?Ee(n):0}else return!1}}function Ee(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function tg(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=Ee(n)}else if(n.parentNode&&!io(n))e=Q(n),n=n.parentNode;else return null}}function ng(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&&!io(n))e=Q(n)+1,n=n.parentNode;else return null}}function og(n,e,t){for(let o=e==0,s=e==Ee(n);o||s;){if(n==t)return!0;let i=Q(n);if(n=n.parentNode,!n)return!1;o=o&&i==0,s=s&&i==Ee(n)}}function io(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 bs=function(n){return n.focusNode&&Ht(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 sg(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function ig(n,e,t){if(n.caretPositionFromPoint)try{let o=n.caretPositionFromPoint(e,t);if(o)return{node:o.offsetNode,offset:Math.min(Ee(o.offsetNode),o.offset)}}catch{}if(n.caretRangeFromPoint){let o=n.caretRangeFromPoint(e,t);if(o)return{node:o.startContainer,offset:Math.min(Ee(o.startContainer),o.startOffset)}}}const _e=typeof navigator<"u"?navigator:null,El=typeof document<"u"?document:null,bt=_e&&_e.userAgent||"",Ci=/Edge\/(\d+)/.exec(bt),ad=/MSIE \d/.exec(bt),ki=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(bt),me=!!(ad||ki||Ci),ht=ad?document.documentMode:ki?+ki[1]:Ci?+Ci[1]:0,De=!me&&/gecko\/(\d+)/i.test(bt);De&&+(/Firefox\/(\d+)/.exec(bt)||[0,0])[1];const Ei=!me&&/Chrome\/(\d+)/.exec(bt),oe=!!Ei,cd=Ei?+Ei[1]:0,ae=!me&&!!_e&&/Apple Computer/.test(_e.vendor),bn=ae&&(/Mobile\/\w+/.test(bt)||!!_e&&_e.maxTouchPoints>2),ke=bn||(_e?/Mac/.test(_e.platform):!1),rg=_e?/Win/.test(_e.platform):!1,Pe=/Android \d/.test(bt),ro=!!El&&"webkitFontSmoothing"in El.documentElement.style,lg=ro?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ag(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 qe(n,e){return typeof n=="number"?n:n[e]}function cg(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 Tl(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=Xn(r)){if(r.nodeType!=1)continue;let l=r,a=l==i.body,c=a?ag(i):cg(l),d=0,p=0;if(e.top<c.top+qe(o,"top")?p=-(c.top-e.top+qe(s,"top")):e.bottom>c.bottom-qe(o,"bottom")&&(p=e.bottom-e.top>c.bottom-c.top?e.top+qe(s,"top")-c.top:e.bottom-c.bottom+qe(s,"bottom")),e.left<c.left+qe(o,"left")?d=-(c.left-e.left+qe(s,"left")):e.right>c.right-qe(o,"right")&&(d=e.right-c.right+qe(s,"right")),d||p)if(a)i.defaultView.scrollBy(d,p);else{let u=l.scrollLeft,h=l.scrollTop;p&&(l.scrollTop+=p),d&&(l.scrollLeft+=d);let f=l.scrollLeft-u,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(r).position))break}}function dg(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:dd(n.dom)}}function dd(n){let e=[],t=n.ownerDocument;for(let o=n;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),n!=t);o=Xn(o));return e}function pg({refDOM:n,refTop:e,stack:t}){let o=n?n.getBoundingClientRect().top:0;pd(t,o==0?0:o-e)}function pd(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 Jt=null;function ug(n){if(n.setActive)return n.setActive();if(Jt)return n.focus(Jt);let e=dd(n);n.focus(Jt==null?{get preventScroll(){return Jt={preventScroll:!0},!0}}:void 0),Jt||(Jt=!1,pd(e,0))}function ud(n,e){let t,o=2e8,s,i=0,r=e.top,l=e.top,a,c;for(let d=n.firstChild,p=0;d;d=d.nextSibling,p++){let u;if(d.nodeType==1)u=d.getClientRects();else if(d.nodeType==3)u=Ze(d).getClientRects();else continue;for(let h=0;h<u.length;h++){let f=u[h];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=p+(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=p+1)}}return!t&&a&&(t=a,s=c,o=0),t&&t.nodeType==3?hg(t,s):!t||o&&t.nodeType==1?{node:n,offset:i}:ud(t,s)}function hg(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=ot(o,1);if(i.top!=i.bottom&&ir(e,i))return{node:n,offset:s+(e.left>=(i.left+i.right)/2?1:0)}}return{node:n,offset:0}}function ir(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function fg(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function mg(n,e,t){let{node:o,offset:s}=ud(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 gg(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 hd(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(ir(e,c))return hd(r,e,c)}}if((i=(i+1)%o)==s)break}return n}function yg(n,e){let t=n.dom.ownerDocument,o,s=0,i=ig(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(!ir(e,c)||(r=hd(n.dom,e,c),!r))return null}if(ae)for(let c=r;o&&c;c=Xn(c))c.draggable&&(o=void 0);if(r=fg(r,e),o){if(De&&o.nodeType==1&&(s=Math.min(s,o.childNodes.length),s<o.childNodes.length)){let d=o.childNodes[s],p;d.nodeName=="IMG"&&(p=d.getBoundingClientRect()).right<=e.left&&p.bottom>e.top&&s++}let c;ro&&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=gg(n,o,s,e))}l==null&&(l=mg(n,r,e));let a=n.docView.nearestDesc(r,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ml(n){return n.top<n.bottom||n.left<n.right}function ot(n,e){let t=n.getClientRects();if(t.length){let o=t[e<0?0:t.length-1];if(Ml(o))return o}return Array.prototype.find.call(t,Ml)||n.getBoundingClientRect()}const bg=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function fd(n,e,t){let{node:o,offset:s,atom:i}=n.docView.domFromPos(e,t<0?-1:1),r=ro||De;if(o.nodeType==3)if(r&&(bg.test(o.nodeValue)||(t<0?!s:s==o.nodeValue.length))){let a=ot(Ze(o,s,s),t);if(De&&s&&/\s/.test(o.nodeValue[s-1])&&s<o.nodeValue.length){let c=ot(Ze(o,s-1,s-1),-1);if(c.top==a.top){let d=ot(Ze(o,s,s+1),-1);if(d.top!=a.top)return Tn(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++,Tn(ot(Ze(o,a,c),d),d<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(t<0||s==Ee(o))){let a=o.childNodes[s-1];if(a.nodeType==1)return _s(a.getBoundingClientRect(),!1)}if(i==null&&s<Ee(o)){let a=o.childNodes[s];if(a.nodeType==1)return _s(a.getBoundingClientRect(),!0)}return _s(o.getBoundingClientRect(),t>=0)}if(i==null&&s&&(t<0||s==Ee(o))){let a=o.childNodes[s-1],c=a.nodeType==3?Ze(a,Ee(a)-(r?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Tn(ot(c,1),!1)}if(i==null&&s<Ee(o)){let a=o.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Ze(a,0,r?0:1):a.nodeType==1?a:null:null;if(c)return Tn(ot(c,-1),!0)}return Tn(ot(o.nodeType==3?Ze(o):o,-t),t>=0)}function Tn(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 _s(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 md(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 vg(n,e,t){let o=e.selection,s=t=="up"?o.$from:o.$to;return md(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=fd(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=Ze(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 Sg=/[\u0590-\u08ac]/;function xg(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?!Sg.test(o.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:r:md(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:p}=n.domSelectionRange(),u=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,p),a&&(a!=d||c!=p)&&l.extend&&l.extend(a,c)}catch{}return u!=null&&(l.caretBidiLevel=u),g}):o.pos==o.start()||o.pos==o.end()}let Al=null,Pl=null,Nl=!1;function wg(n,e,t){return Al==e&&Pl==t?Nl:(Al=e,Pl=t,Nl=t=="up"||t=="down"?vg(n,e,t):xg(n,e,t))}const Te=0,Il=1,At=2,Ge=3;class lo{constructor(e,t,o,s){this.parent=e,this.children=t,this.dom=o,this.contentDOM=s,this.dirty=Te,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>Q(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 yd){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 gd&&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?Q(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?Q(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 p=l;p>0;p--){let u=this.children[p-1];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(1)){s=Q(u.dom)+1;break}e-=u.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 p=this.children[d];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(-1)){i=Q(p.dom);break}t+=p.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 h=0,f=0;h<this.children.length;h++){let m=this.children[h],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(),p=!1;if((De||ae)&&e==t){let{node:h,offset:f}=l;if(h.nodeType==3){if(p=!!(f&&h.nodeValue[f-1]==`
|
|
913
|
+
`),p&&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:Q(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=h.childNodes[f-1];p=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(De&&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||p&&ae)&&Ht(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Ht(a.node,a.offset,d.focusNode,d.focusOffset))return;let u=!1;if((c.extend||e==t)&&!p){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),u=!0}catch{}}if(!u){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 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?At:Il,e==l&&t==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Ge:i.markDirty(e-l,t-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?At:Ge}o=r}this.dirty=At}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let o=e==1?At:Il;t.dirty<o&&(t.dirty=o)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class gd extends lo{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==Te&&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 Cg extends lo{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 Ft extends lo{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=Wt.renderSpec(document,t.type.spec.toDOM(t,o),null,t.attrs)),new Ft(e,t,r.dom,r.contentDOM||r.dom,r)}parseRule(){return this.dirty&Ge||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ge&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Te){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=Te}}slice(e,t,o){let s=Ft.create(this.parent,this.mark,!0,o),i=this.children,r=this.size;t<r&&(i=Mi(i,t,r,o)),e>0&&(i=Mi(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 ft extends lo{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,p=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:p}=Wt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!p&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let u=d;return d=Sd(d,o,t),c?a=new kg(e,t,o,s,d,p||null,u,c,i,r+1):t.isText?new vs(e,t,o,s,d,u,i):new ft(e,t,o,s,d,p||null,u,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=()=>T.empty)}return e}matchesNode(e,t,o){return this.dirty==Te&&e.eq(this.node)&&es(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 Tg(this,r&&r.node,e);Pg(this.node,this.innerDeco,(c,d,p)=>{c.spec.marks?a.syncToMarks(c.spec.marks,o,e):c.type.side>=0&&!p&&a.syncToMarks(d==this.node.childCount?B.none:this.node.child(d).marks,o,e),a.placeWidget(c,e,s)},(c,d,p,u)=>{a.syncToMarks(c.marks,o,e);let h;a.findNodeMatch(c,d,p,u)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,d,p,h,e)||a.updateNextNode(c,d,p,e,u,s)||a.addNode(c,d,p,e,s),s+=c.nodeSize}),a.syncToMarks([],o,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==At)&&(r&&this.protectLocalComposition(e,r),bd(this.contentDOM,this.children,e),bn&&Ng(this.dom))}localCompositionInfo(e,t){let{from:o,to:s}=e.state.selection;if(!(e.state.selection instanceof $)||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=Ig(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 Cg(this,i,t,s);e.input.compositionNodes.push(r),this.children=Mi(this.children,o,o+s.length,e,r)}update(e,t,o,s){return this.dirty==Ge||!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=Te}updateOuterDeco(e){if(es(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,o=this.dom;this.dom=vd(this.dom,this.nodeDOM,Ti(this.outerDeco,this.node,t),Ti(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 Ol(n,e,t,o,s){Sd(o,e,n);let i=new ft(void 0,n,e,t,o,o,o,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class vs extends ft{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==Ge||this.dirty!=Te&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Te||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=Te,!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 vs(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=Ge)}get domAtom(){return!1}isText(e){return this.node.text==e}}class yd extends lo{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Te&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class kg extends ft{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==Ge)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 bd(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=Rl(o),s=!0;o=o.nextSibling}else s=!0,n.insertBefore(l,o);if(r instanceof Ft){let a=o?o.previousSibling:n.lastChild;bd(r.contentDOM,r.children,t),o=a?a.nextSibling:n.firstChild}}for(;o;)o=Rl(o),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const Bn=function(n){n&&(this.nodeName=n)};Bn.prototype=Object.create(null);const Pt=[new Bn];function Ti(n,e,t){if(n.length==0)return Pt;let o=t?Pt[0]:new Bn,s=[o];for(let i=0;i<n.length;i++){let r=n[i].type.attrs;if(r){r.nodeName&&s.push(o=new Bn(r.nodeName));for(let l in r){let a=r[l];a!=null&&(t&&s.length==1&&s.push(o=new Bn(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 vd(n,e,t,o){if(t==Pt&&o==Pt)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=Pt[0]),s=a}Eg(s,l||Pt[0],r)}return s}function Eg(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 Sd(n,e,t){return vd(n,n,Pt,Ti(e,t,n.nodeType!=1))}function es(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 Rl(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Tg{constructor(e,t,o){this.lock=t,this.view=o,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Mg(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=Te,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=Ft.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==Ge&&r.dom==r.contentDOM&&(r.dirty=At),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 ft){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let d=a.dom,p,u=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Ge&&es(t,a.outerDeco));if(!u&&a.update(e,t,o,s))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!u&&(p=this.recreateWrapper(a,e,t,o,s,r)))return this.destroyBetween(this.index,l),this.top.children[this.index]=p,p.contentDOM&&(p.dirty=At,p.updateChildren(s,r+1),p.dirty=Te),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)||!es(o,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=ft.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=ft.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 gd(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 Ft;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof vs)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ae||oe)&&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 yd(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 Mg(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 Ft)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 Ag(n,e){return n.type.side-e.type.side}function Pg(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,p;for(;r<s.length&&s[r].to==i;){let g=s[r++];g.widget&&(d?(p||(p=[d])).push(g):d=g)}if(d)if(p){p.sort(Ag);for(let g=0;g<p.length;g++)t(p[g],c,!!a)}else t(d,c,!!a);let u,h;if(a)h=-1,u=a,a=null;else if(c<n.childCount)h=c,u=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+u.nodeSize;if(u.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=u.cut(g-i),u=u.cut(0,g-i),f=g,h=-1)}else for(;r<s.length&&s[r].to<f;)r++;let m=u.isInline&&!u.isLeaf?l.filter(g=>!g.inline):l.slice();o(u,m,e.forChild(i,u),h),i=f}}function Ng(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 Ig(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 Mi(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 rr(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(bs(t)){for(a=r;s&&!s.node;)s=s.parent;let p=s.node;if(s&&p.isAtom&&D.isSelectable(p)&&s.parent&&!(p.isInline&&og(t.focusNode,t.focusOffset,s.dom))){let u=s.posBefore;c=new D(r==u?l:o.resolve(u))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let p=r,u=r;for(let h=0;h<t.rangeCount;h++){let f=t.getRangeAt(h);p=Math.min(p,n.docView.posFromDOM(f.startContainer,f.startOffset,1)),u=Math.max(u,n.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(p<0)return null;[a,r]=u==n.state.selection.anchor?[u,p]:[p,u],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 p=e=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=lr(n,d,l,p)}return c}function xd(n){return n.editable?n.hasFocus():Cd(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function et(n,e=!1){let t=n.state.selection;if(wd(n,t),!!xd(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&oe){let o=n.domSelectionRange(),s=n.domObserver.currentSelection;if(o.anchorNode&&s.anchorNode&&Ht(o.anchorNode,o.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Rg(n);else{let{anchor:o,head:s}=t,i,r;Dl&&!(t instanceof $)&&(t.$from.parent.inlineContent||(i=Ll(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(r=Ll(n,t.to))),n.docView.setSelection(o,s,n,e),Dl&&(i&&$l(i),r&&$l(r)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Og(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Dl=ae||oe&&cd<63;function Ll(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 Gs(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Gs(s);if(i)return Gs(i)}}function Gs(n){return n.contentEditable="true",ae&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function $l(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Og(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(()=>{(!xd(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Rg(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,Q(o)+1):t.setStart(o,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!s&&!n.state.selection.visible&&me&&ht<=11&&(o.disabled=!0,o.disabled=!1)}function wd(n,e){if(e instanceof D){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(zl(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else zl(n)}function zl(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function lr(n,e,t,o){return n.someProp("createSelectionBetween",s=>s(n,e,t))||$.between(e,t,o)}function Vl(n){return n.editable&&!n.hasFocus()?!1:Cd(n)}function Cd(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 Dg(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Ht(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ai(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&&L.findFrom(i,e)}function it(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Bl(n,e,t){let o=n.state.selection;if(o instanceof $)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 it(n,new $(o.$anchor,r))}else if(o.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=Ai(n.state,e);return s&&s instanceof D?it(n,s):!1}else if(!(ke&&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?D.isSelectable(i)?it(n,new D(e<0?n.state.doc.resolve(s.pos-i.nodeSize):s)):ro?it(n,new $(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(o instanceof D&&o.node.isInline)return it(n,new $(e>0?o.$to:o.$from));{let s=Ai(n.state,e);return s?it(n,s):!1}}}function ts(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Hn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Zt(n,e){return e<0?Lg(n):$g(n)}function Lg(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s,i,r=!1;for(De&&t.nodeType==1&&o<ts(t)&&Hn(t.childNodes[o],-1)&&(r=!0);;)if(o>0){if(t.nodeType!=1)break;{let l=t.childNodes[o-1];if(Hn(l,-1))s=t,i=--o;else if(l.nodeType==3)t=l,o=t.nodeValue.length;else break}}else{if(kd(t))break;{let l=t.previousSibling;for(;l&&Hn(l,-1);)s=t.parentNode,i=Q(l),l=l.previousSibling;if(l)t=l,o=ts(t);else{if(t=t.parentNode,t==n.dom)break;o=0}}}r?Pi(n,t,o):s&&Pi(n,s,i)}function $g(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s=ts(t),i,r;for(;;)if(o<s){if(t.nodeType!=1)break;let l=t.childNodes[o];if(Hn(l,1))i=t,r=++o;else break}else{if(kd(t))break;{let l=t.nextSibling;for(;l&&Hn(l,1);)i=l.parentNode,r=Q(l)+1,l=l.nextSibling;if(l)t=l,o=0,s=ts(t);else{if(t=t.parentNode,t==n.dom)break;o=s=0}}}i&&Pi(n,i,r)}function kd(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function zg(n,e){for(;n&&e==n.childNodes.length&&!io(n);)e=Q(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 Vg(n,e){for(;n&&!e&&!io(n);)e=Q(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 Pi(n,e,t){if(e.nodeType!=3){let i,r;(r=zg(e,t))?(e=r,t=0):(i=Vg(e,t))&&(e=i,t=i.nodeValue.length)}let o=n.domSelection();if(!o)return;if(bs(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&&et(n)},50)}function Hl(n,e){let t=n.state.doc.resolve(e);if(!(oe||rg)&&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 Fl(n,e,t){let o=n.state.selection;if(o instanceof $&&!o.empty||t.indexOf("s")>-1||ke&&t.indexOf("m")>-1)return!1;let{$from:s,$to:i}=o;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let r=Ai(n.state,e);if(r&&r instanceof D)return it(n,r)}if(!s.parent.inlineContent){let r=e<0?s:i,l=o instanceof Se?L.near(r,e):L.findFrom(r,e);return l?it(n,l):!1}return!1}function _l(n,e){if(!(n.state.selection instanceof $))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 Gl(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Bg(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;Gl(n,o,"true"),setTimeout(()=>Gl(n,o,"false"),20)}return!1}function Hg(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Fg(n,e){let t=e.keyCode,o=Hg(e);if(t==8||ke&&t==72&&o=="c")return _l(n,-1)||Zt(n,-1);if(t==46&&!e.shiftKey||ke&&t==68&&o=="c")return _l(n,1)||Zt(n,1);if(t==13||t==27)return!0;if(t==37||ke&&t==66&&o=="c"){let s=t==37?Hl(n,n.state.selection.from)=="ltr"?-1:1:-1;return Bl(n,s,o)||Zt(n,s)}else if(t==39||ke&&t==70&&o=="c"){let s=t==39?Hl(n,n.state.selection.from)=="ltr"?1:-1:1;return Bl(n,s,o)||Zt(n,s)}else{if(t==38||ke&&t==80&&o=="c")return Fl(n,-1,o)||Zt(n,-1);if(t==40||ke&&t==78&&o=="c")return Bg(n)||Fl(n,1,o)||Zt(n,1);if(o==(ke?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Ed(n,e){n.someProp("transformCopied",h=>{e=h(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 h=o.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),o=h.content}let r=n.someProp("clipboardSerializer")||Wt.fromSchema(n.state.schema),l=Id(),a=l.createElement("div");a.appendChild(r.serializeFragment(o,{document:l}));let c=a.firstChild,d,p=0;for(;c&&c.nodeType==1&&(d=Nd[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),p++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${p?` -${p}`:""} ${JSON.stringify(t)}`);let u=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
|
|
914
|
+
|
|
915
|
+
`);return{dom:a,text:u,slice:e}}function Td(n,e,t,o,s){let i=s.parent.type.spec.code,r,l;if(!t&&!e)return null;let a=e&&(o||i||!t);if(a){if(n.someProp("transformPastedText",u=>{e=u(e,i||o,n)}),i)return e?new A(T.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
916
|
+
`))),0,0):A.empty;let p=n.someProp("clipboardTextParser",u=>u(e,s,o,n));if(p)l=p;else{let u=s.marks(),{schema:h}=n.state,f=Wt.fromSchema(h);r=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=r.appendChild(document.createElement("p"));m&&g.appendChild(f.serializeNode(h.text(m,u)))})}}else n.someProp("transformPastedHTML",p=>{t=p(t,n)}),r=jg(t),ro&&qg(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 p=+d[3];p>0;p--){let u=r.firstChild;for(;u&&u.nodeType!=1;)u=u.nextSibling;if(!u)break;r=u}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Bt.fromSchema(n.state.schema)).parseSlice(r,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!_g.test(u.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Ug(Wl(l,+d[1],+d[2]),d[4]);else if(l=A.maxOpen(Gg(l.content,s),!0),l.openStart||l.openEnd){let p=0,u=0;for(let h=l.content.firstChild;p<l.openStart&&!h.type.spec.isolating;p++,h=h.firstChild);for(let h=l.content.lastChild;u<l.openEnd&&!h.type.spec.isolating;u++,h=h.lastChild);l=Wl(l,p,u)}return n.someProp("transformPasted",p=>{l=p(l,n)}),l}const _g=/^(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 Gg(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&&Ad(a,i,l,r[r.length-1],0))r[r.length-1]=c;else{r.length&&(r[r.length-1]=Pd(r[r.length-1],i.length));let d=Md(l,a);r.push(d),s=s.matchType(d.type),i=a}}),r)return T.from(r)}return n}function Md(n,e,t=0){for(let o=e.length-1;o>=t;o--)n=e[o].create(null,T.from(n));return n}function Ad(n,e,t,o,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let i=Ad(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(T.from(Md(t,n,s+1))))}}function Pd(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Pd(n.lastChild,e-1)),o=n.contentMatchAt(n.childCount).fillBefore(T.empty,!0);return n.copy(t.append(o))}function Ni(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=Ni(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(T.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,r.copy(l))}function Wl(n,e,t){return e<n.openStart&&(n=new A(Ni(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new A(Ni(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Nd={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 jl=null;function Id(){return jl||(jl=document.implementation.createHTMLDocument("title"))}let Ws=null;function Wg(n){let e=window.trustedTypes;return e?(Ws||(Ws=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Ws.createHTML(n)):n}function jg(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Id().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(n),s;if((s=o&&Nd[o[1].toLowerCase()])&&(n=s.map(i=>"<"+i+">").join("")+n+s.map(i=>"</"+i+">").reverse().join("")),t.innerHTML=Wg(n),s)for(let i=0;i<s.length;i++)t=t.querySelector(s[i])||t;return t}function qg(n){let e=n.querySelectorAll(oe?"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 Ug(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=T.from(a.create(o[l+1],s)),i++,r++}return new A(s,i,r)}const ce={},de={},Kg={touchstart:!0,touchmove:!0};class Jg{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 Zg(n){for(let e in ce){let t=ce[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=o=>{Xg(n,o)&&!ar(n,o)&&(n.editable||!(o.type in de))&&t(n,o)},Kg[e]?{passive:!0}:void 0)}ae&&n.dom.addEventListener("input",()=>null),Ii(n)}function pt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Yg(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 Ii(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=o=>ar(n,o))})}function ar(n,e){return n.someProp("handleDOMEvents",t=>{let o=t[e.type];return o?o(n,e)||e.defaultPrevented:!1})}function Xg(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 Qg(n,e){!ar(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,!Rd(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Pe&&oe&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),bn&&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))||Fg(n,t)?t.preventDefault():pt(n,"key")};de.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};de.keypress=(n,e)=>{let t=e;if(Rd(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ke&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let o=n.state.selection;if(!(o instanceof $)||!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 Ss(n){return{left:n.clientX,top:n.clientY}}function e1(n,e){let t=e.x-n.clientX,o=e.y-n.clientY;return t*t+o*o<100}function cr(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 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 t1(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),o=t.nodeAfter;return o&&o.isAtom&&D.isSelectable(o)?(un(n,new D(t)),!0):!1}function n1(n,e){if(e==-1)return!1;let t=n.state.selection,o,s;t instanceof D&&(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(D.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?(un(n,D.create(n.state.doc,s)),!0):!1}function o1(n,e,t,o,s){return cr(n,"handleClickOn",e,t,o)||n.someProp("handleClick",i=>i(n,e,o))||(s?n1(n,t):t1(n,t))}function s1(n,e,t,o){return cr(n,"handleDoubleClickOn",e,t,o)||n.someProp("handleDoubleClick",s=>s(n,e,o))}function i1(n,e,t,o){return cr(n,"handleTripleClickOn",e,t,o)||n.someProp("handleTripleClick",s=>s(n,e,o))||r1(n,t,o)}function r1(n,e,t){if(t.button!=0)return!1;let o=n.state.doc;if(e==-1)return o.inlineContent?(un(n,$.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)un(n,$.create(o,l+1,l+1+r.content.size));else if(D.isSelectable(r))un(n,D.create(o,l));else continue;return!0}}function dr(n){return ns(n)}const Od=ke?"metaKey":"ctrlKey";ce.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let o=dr(n),s=Date.now(),i="singleClick";s-n.input.lastClick.time<500&&e1(t,n.input.lastClick)&&!t[Od]&&(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(Ss(t));r&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new l1(n,r,t,!!o)):(i=="doubleClick"?s1:i1)(n,r.pos,r.inside,t)?t.preventDefault():pt(n,"pointer"))};class l1{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[Od],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 D&&c.from<=r&&c.to>r)&&(this.mightDrag={node:i,pos:r,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&De&&!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)),pt(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(()=>et(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(Ss(e))),this.updateAllowDefault(e),this.allowDefault||!t?pt(this.view,"pointer"):o1(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ae&&this.mightDrag&&!this.mightDrag.node.isAtom||oe&&!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,L.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):pt(this.view,"pointer")}move(e){this.updateAllowDefault(e),pt(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(),dr(n),pt(n,"pointer")};ce.touchmove=n=>{n.input.lastTouch=Date.now(),pt(n,"pointer")};ce.contextmenu=n=>dr(n);function Rd(n,e){return n.composing?!0:ae&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const a1=Pe?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 $&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(o=>o.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),ns(n,!0),n.markCursor=null;else if(ns(n,!e.selection.empty),De&&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}Dd(n,a1)};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++,Dd(n,20))};function Dd(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>ns(n),e))}function Ld(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=d1());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function c1(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=tg(e.focusNode,e.focusOffset),o=ng(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 d1(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function ns(n,e=!1){if(!(Pe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ld(n),e||n.docView&&n.docView.dirty){let t=rr(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 p1(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 Qn=me&&ht<15||bn&&lg<604;ce.copy=de.cut=(n,e)=>{let t=e,o=n.state.selection,s=t.type=="cut";if(o.empty)return;let i=Qn?null:t.clipboardData,r=o.content(),{dom:l,text:a}=Ed(n,r);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):p1(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function u1(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function h1(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?eo(n,o.value,null,s,e):eo(n,o.textContent,o.innerHTML,s,e)},50)}function eo(n,e,t,o,s){let i=Td(n,e,t,o,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,i||A.empty)))return!0;if(!i)return!1;let r=u1(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 $d(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&&!Pe)return;let o=Qn?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;o&&eo(n,$d(o),o.getData("text/html"),s,t)?t.preventDefault():h1(n,t)};class zd{constructor(e,t,o){this.slice=e,this.move=t,this.node=o}}const Vd=ke?"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(Ss(t)),r;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof D?s.to-1:s.to))){if(o&&o.mightDrag)r=D.create(n.state.doc,o.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let p=n.docView.nearestDesc(t.target,!0);p&&p.node.type.spec.draggable&&p!=n.docView&&(r=D.create(n.state.doc,p.posBefore))}}let l=(r||n.state.selection).content(),{dom:a,text:c,slice:d}=Ed(n,l);(!t.dataTransfer.files.length||!oe||cd>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Qn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Qn||t.dataTransfer.setData("text/plain",c),n.dragging=new zd(d,!t[Vd],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(Ss(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=Td(n,$d(t.dataTransfer),Qn?null:t.dataTransfer.getData("text/html"),!1,i);let l=!!(o&&!t[Vd]);if(n.someProp("handleDrop",f=>f(n,t,r||A.empty,l))){t.preventDefault();return}if(!r)return;t.preventDefault();let a=r?lm(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),p=r.openStart==0&&r.openEnd==0&&r.content.childCount==1,u=c.doc;if(p?c.replaceRangeWith(d,d,r.content.firstChild):c.replaceRange(d,d,r),c.doc.eq(u))return;let h=c.doc.resolve(d);if(p&&D.isSelectable(r.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(r.content.firstChild))c.setSelection(new D(h));else{let f=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,C)=>f=C),c.setSelection(lr(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())&&et(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(oe&&Pe&&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,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 to(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 ss{constructor(e,t){this.toDOM=e,this.spec=t||Lt,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 ss&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&to(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class mt{constructor(e,t){this.attrs=e,this.spec=t||Lt}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 mt&&to(this.attrs,e.attrs)&&to(this.spec,e.spec)}static is(e){return e.type instanceof mt}destroy(){}}class pr{constructor(e,t){this.attrs=e,this.spec=t||Lt}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 pr&&to(this.attrs,e.attrs)&&to(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 ss(t,o))}static inline(e,t,o,s){return new fe(e,t,new mt(o,s))}static node(e,t,o,s){return new fe(e,t,new pr(o,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof mt}get widget(){return this.type instanceof ss}}const Qt=[],Lt={};class j{constructor(e,t){this.local=e.length?e:Qt,this.children=t.length?t:Qt}static create(e,t){return t.length?is(t,e,0,Lt):te}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==te||e.maps.length==0?this:this.mapInner(e,t,0,0,o||Lt)}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?f1(this.children,r||[],e,t,o,s,i):r?new j(r.sort($t),Qt):te}add(e,t){return t.length?this==te?j.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=Hd(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,is(d,l,c+1,Lt)),i+=3}});let r=Bd(i?Fd(t):t,-o);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||r.splice(l--,1);return new j(r.length?this.local.concat(r).sort($t):this.local,s||this.children)}remove(e){return e.length==0||this==te?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,p;d<e.length;d++)(p=e[d])&&p.from>l&&p.to<a&&(e[d]=null,(r||(r=[])).push(p));if(!r)continue;o==this.children&&(o=this.children.slice());let c=o[i+2].removeInner(r,l+1);c!=te?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 j(s,o):te}forChild(e,t){if(this==te)return this;if(t.isLeaf)return j.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 mt){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 j(s.sort($t),Qt);return o?new rt([l,o]):l}return o||te}eq(e){if(this==e)return!0;if(!(e instanceof j)||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 ur(this.localsInner(e))}localsInner(e){if(this==te)return Qt;if(e.inlineContent||!this.local.some(mt.is))return this.local;let t=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof mt||t.push(this.local[o]);return t}forEachSet(e){e(this)}}j.empty=new j([],[]);j.removeOverlap=ur;const te=j.empty;class rt{constructor(e){this.members=e}map(e,t){const o=this.members.map(s=>s.map(e,t,Lt));return rt.from(o)}forChild(e,t){if(t.isLeaf)return j.empty;let o=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,t);i!=te&&(i instanceof rt?o=o.concat(i.members):o.push(i))}return rt.from(o)}eq(e){if(!(e instanceof rt)||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?ur(o?t:t.sort($t)):Qt}static from(e){switch(e.length){case 0:return te;case 1:return e[0];default:return new rt(e.every(t=>t instanceof j)?e:e.reduce((t,o)=>t.concat(o instanceof j?o:o.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function f1(n,e,t,o,s,i,r){let l=n.slice();for(let c=0,d=i;c<t.maps.length;c++){let p=0;t.maps[c].forEach((u,h,f,m)=>{let g=m-f-(h-u);for(let b=0;b<l.length;b+=3){let C=l[b+1];if(C<0||u>C+d-p)continue;let y=l[b]+d-p;h>=y?l[b+1]=u<=y?-2:-1:u>=d&&g&&(l[b]+=g,l[b+1]+=g)}p+=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),p=d-s;if(p<0||p>=o.content.size){a=!0;continue}let u=t.map(n[c+1]+i,-1),h=u-s,{index:f,offset:m}=o.content.findIndex(p),g=o.maybeChild(f);if(g&&m==p&&m+g.nodeSize==h){let b=l[c+2].mapInner(t,g,d+1,n[c]+i+1,r);b!=te?(l[c]=p,l[c+1]=h,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=m1(l,n,e,t,s,i,r),d=is(c,o,0,r);e=d.local;for(let p=0;p<l.length;p+=3)l[p+1]<0&&(l.splice(p,3),p-=3);for(let p=0,u=0;p<d.children.length;p+=3){let h=d.children[p];for(;u<l.length&&l[u]<h;)u+=3;l.splice(u,0,d.children[p],d.children[p+1],d.children[p+2])}}return new j(e.sort($t),l)}function Bd(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 m1(n,e,t,o,s,i,r){function l(a,c){for(let d=0;d<a.local.length;d++){let p=a.local[d].map(o,s,c);p?t.push(p):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 Hd(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 Fd(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function is(n,e,t,o){let s=[],i=!1;e.forEach((l,a)=>{let c=Hd(n,l,a+t);if(c){i=!0;let d=is(c,l,t+a+1,o);d!=te&&s.push(a,a+l.nodeSize,d)}});let r=Bd(i?Fd(n):n,-t).sort($t);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 j(r,s):te}function $t(n,e){return n.from-e.from||n.to-e.to}function ur(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),ql(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),ql(e,s,o.copy(i.from,o.to)));break}}}return e}function ql(n,e,t){for(;e<n.length&&$t(t,n[e])>0;)e++;n.splice(e,0,t)}function js(n){let e=[];return n.someProp("decorations",t=>{let o=t(n.state);o&&o!=te&&e.push(o)}),n.cursorWrapper&&e.push(j.create(n.state.doc,[n.cursorWrapper.deco])),rt.from(e)}const g1={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},y1=me&&ht<=11;class b1{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 v1{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new b1,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]);me&&ht<=11&&o.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),y1&&(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,g1)),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(Vl(this.view)){if(this.suppressingSelectionUpdates)return et(this.view);if(me&&ht<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ht(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,o;for(let i=e.focusNode;i;i=Xn(i))t.add(i);for(let i=e.anchorNode;i;i=Xn(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)&&Vl(e)&&!this.ignoreSelectionChange(o),i=-1,r=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let p=this.registerMutation(t[d],a);p&&(i=i<0?p.from:Math.min(p.from,i),r=r<0?p.to:Math.max(p.to,r),p.typeOver&&(l=!0))}if(De&&a.length){let d=a.filter(p=>p.nodeName=="BR");if(d.length==2){let[p,u]=d;p.parentNode&&p.parentNode.parentNode==u.parentNode?u.remove():p.remove()}else{let{focusNode:p}=this.currentSelection;for(let u of d){let h=u.parentNode;h&&h.nodeName=="LI"&&(!p||w1(e,p)!=h)&&u.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&&bs(o)&&(c=rr(e))&&c.eq(L.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,et(e),this.currentSelection.set(o),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,r),S1(e)),this.handleDOMChange(i,r,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(o)||et(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 p=e.addedNodes[d];t.push(p),p.nodeType==3&&(this.lastChangedTextNode=p)}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(me&&ht<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:p,nextSibling:u}=e.addedNodes[d];(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(s=p),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(i=u)}let r=s&&s.parentNode==e.target?Q(s)+1:0,l=o.localPosFromDOM(e.target,r,-1),a=i&&i.parentNode==e.target?Q(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 Ul=new WeakMap,Kl=!1;function S1(n){if(!Ul.has(n)&&(Ul.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=De,Kl)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."),Kl=!0}}function Jl(n,e){let t=e.startContainer,o=e.startOffset,s=e.endContainer,i=e.endOffset,r=n.domAtPos(n.state.selection.anchor);return Ht(r.node,r.offset,s,i)&&([t,o,s,i]=[s,i,t,o]),{anchorNode:t,anchorOffset:o,focusNode:s,focusOffset:i}}function x1(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return Jl(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?Jl(n,t):null}function w1(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 C1(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}],bs(a)||c.push({node:a.focusNode,offset:a.focusOffset})),oe&&n.input.lastKeyCode===8)for(let g=i;g>s;g--){let b=o.childNodes[g-1],C=b.pmViewDesc;if(b.nodeName=="BR"&&!C){i=g;break}if(!C||C.size)break}let p=n.state.doc,u=n.someProp("domParser")||Bt.fromSchema(n.state.schema),h=p.resolve(r),f=null,m=u.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:i,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:k1,context:h});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 k1(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 E1=/^(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 T1(n,e,t,o,s){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let E=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,M=rr(n,E);if(M&&!n.state.selection.eq(M)){if(oe&&Pe&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",N=>N(n,Et(13,"Enter"))))return;let P=n.state.tr.setSelection(M);E=="pointer"?P.setMeta("pointer",!0):E=="key"&&P.scrollIntoView(),i&&P.setMeta("composition",i),n.dispatch(P)}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=C1(n,e,t),d=n.state.doc,p=d.slice(c.from,c.to),u,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(u=n.state.selection.to,h="end"):(u=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let f=P1(p.content,c.doc.content,c.from,u,h);if(f&&n.input.domChangeCount++,(bn&&n.input.lastIOSEnter>Date.now()-225||Pe)&&s.some(E=>E.nodeType==1&&!E1.test(E.nodeName))&&(!f||f.endA>=f.endB)&&n.someProp("handleKeyDown",E=>E(n,Et(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!f)if(o&&a instanceof $&&!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 E=Zl(n,n.state.doc,c.sel);if(E&&!E.eq(n.state.selection)){let M=n.state.tr.setSelection(E);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 $&&(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)),me&&ht<=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),C=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=f.endA,y;if((bn&&n.input.lastIOSEnter>Date.now()-225&&(!C||s.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!C&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(y=L.findFrom(c.doc.resolve(m.pos+1),1,!0))&&y.head==g.pos)&&n.someProp("handleKeyDown",E=>E(n,Et(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>f.start&&A1(d,f.start,f.endA,m,g)&&n.someProp("handleKeyDown",E=>E(n,Et(8,"Backspace")))){Pe&&oe&&n.domObserver.suppressSelectionUpdates();return}oe&&Pe&&f.endB==f.start&&(n.input.lastAndroidDelete=Date.now()),Pe&&!C&&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(E){return E(n,Et(13,"Enter"))})},20));let v=f.start,w=f.endA,S,x,k;if(C){if(m.pos==g.pos)me&&ht<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>et(n),20)),S=n.state.tr.delete(v,w),x=d.resolve(f.start).marksAcross(d.resolve(f.endA));else if(f.endA==f.endB&&(k=M1(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,f.endA-b.start()))))S=n.state.tr,k.type=="add"?S.addMark(v,w,k.mark):S.removeMark(v,w,k.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let E=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",M=>M(n,v,w,E)))return;S=n.state.tr.insertText(E,v,w)}}if(S||(S=n.state.tr.replace(v,w,c.doc.slice(f.start-c.from,f.endB-c.from))),c.sel){let E=Zl(n,S.doc,c.sel);E&&!(oe&&Pe&&n.composing&&E.empty&&(f.start!=f.endB||n.input.lastAndroidDelete<Date.now()-100)&&(E.head==v||E.head==S.mapping.map(w)-1)||me&&E.empty&&E.head==v)&&S.setSelection(E)}x&&S.ensureMarks(x),i&&S.setMeta("composition",i),n.dispatch(S.scrollIntoView())}function Zl(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:lr(n,e.resolve(t.anchor),e.resolve(t.head))}function M1(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(T.from(c).eq(n))return{mark:l,type:r}}function A1(n,e,t,o,s){if(t-e<=s.pos-o.pos||qs(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(qs(i,!0,!0));return!r.parent.isTextblock||r.pos>t||qs(r,!0,!1)<t?!1:o.parent.content.cut(o.parentOffset).eq(r.parent.content)}function qs(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 P1(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&&Yl(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&&Yl(n.textBetween(i-1,i+1))&&(i+=a?1:-1),r=i+(r-l),l=i}return{start:i,endA:r,endB:l}}function Yl(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 N1{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 Jg,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(na),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=ea(this),Ql(this),this.nodeViews=ta(this),this.docView=Ol(this.state.doc,Xl(this),js(this),this.dom,this),this.domObserver=new v1(this,(o,s,i,r)=>T1(this,o,s,i,r)),this.domObserver.start(),Zg(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&&Ii(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(na),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&&(Ld(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 h=ta(this);O1(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ii(this),this.editable=ea(this),Ql(this);let a=js(this),c=Xl(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",p=i||!this.docView.matchesNode(e.doc,c,a);(p||!e.selection.eq(s.selection))&&(r=!0);let u=d=="preserve"&&r&&this.dom.style.overflowAnchor==null&&dg(this);if(r){this.domObserver.stop();let h=p&&(me||oe)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&I1(s.selection,e.selection);if(p){let f=oe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=c1(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Ol(e.doc,c,a,this.dom,this)),f&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Dg(this))?et(this,h):(wd(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():u&&pg(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof D){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Tl(this,t.getBoundingClientRect(),e)}else Tl(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 zd(e.slice,e.move,s<0?void 0:D.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(me){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&&ug(this.dom),et(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 yg(this,e)}coordsAtPos(e,t=1){return fd(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 wg(this,t||this.state,e)}pasteHTML(e,t){return eo(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return eo(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Yg(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],js(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Qm())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Qg(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&&sg(this.dom.ownerDocument)==this.dom&&x1(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Xl(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 Ql(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 ea(n){return!n.someProp("editable",e=>e(n.state)===!1)}function I1(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 ta(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 O1(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 na(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 Oi,Ri;if(typeof WeakMap<"u"){let n=new WeakMap;Oi=e=>n.get(e),Ri=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Oi=o=>{for(let s=0;s<n.length;s+=2)if(n[s]==o)return n[s+1]},Ri=(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 Oi(n)||Ri(n,R1(n))}};function R1(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=D1(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 p=n.child(c);d++;for(let f=0;;f++){for(;s<o.length&&o[s]!=0;)s++;if(f==p.childCount)break;const m=p.child(f),{colspan:g,rowspan:b,colwidth:C}=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 w=0;w<g;w++){o[v+w]==0?o[v+w]=d:(i||(i=[])).push({type:"collision",row:c,pos:d,n:g-w});const S=C&&C[w];if(S){const x=(v+w)%e*2,k=r[x];k==null||k!=S&&r[x+1]==1?(r[x]=S,r[x+1]=1):k==S&&r[x+1]++}}}s+=g,d+=m.nodeSize}const u=(c+1)*e;let h=0;for(;s<u;)o[s++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),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&&L1(l,r,n),l}function D1(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 L1(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,p=e[d*2];p!=null&&(!a.colwidth||a.colwidth[c]!=p)&&((l||(l=$1(a)))[c]=p)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function $1(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function oa(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 sa(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 z1(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=>oa(o,e)}],toDOM(o){return["td",sa(o,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:o=>oa(o,e)}],toDOM(o){return["th",sa(o,e),0]}}}}function We(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 so("selectingCells");function ao(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 xs(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 hr(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=ao(e.$head)||V1(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function V1(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 Di(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function B1(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function fr(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function _d(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 vn(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 Z=class Je extends L{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 p=o.nodeAt(d);if(!p)throw RangeError(`No cell with offset ${d} found`);const u=i+d+1;return new jc(l.resolve(u),l.resolve(u+p.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(Di(o)&&Di(s)&&fr(o,s)){const i=this.$anchorCell.node(-1)!=o.node(-1);return i&&this.isRowSelection()?Je.rowSelection(o,s):i&&this.isColSelection()?Je.colSelection(o,s):new Je(o,s)}return $.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,p=s.left;p<s.right;p++,d++){const u=t.map[d];if(i[u])continue;i[u]=!0;const h=t.findCell(u);let f=e.nodeAt(u);if(!f)throw RangeError(`No cell with offset ${u} found`);const m=s.left-h.left,g=h.right-s.right;if(m>0||g>0){let b=f.attrs;if(m>0&&(b=vn(b,0,m)),g>0&&(b=vn(b,b.colspan-g,g)),h.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(h.top<s.top||h.bottom>s.bottom){const b={...f.attrs,rowspan:Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top)};h.top<s.top?f=f.type.createAndFill(b):f=f.type.create(b,f.content)}c.push(f)}r.push(e.child(a).copy(T.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:r;return new A(T.from(l),1,1)}replace(e,t=A.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?A.empty:t)}const i=L.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new A(T.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 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),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 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),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 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 H1(this.$anchorCell.pos,this.$headCell.pos)}};Z.prototype.visible=!1;L.jsonID("cell",Z);var H1=class Gd{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Gd(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&&fr(t,o)?new Z(t,o):L.near(o,1)}};function F1(n){if(!(n.selection instanceof Z))return null;const e=[];return n.selection.forEachCell((t,o)=>{e.push(fe.node(o,o+t.nodeSize,{class:"selectedCell"}))}),j.create(n.doc,e)}function _1({$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 G1({$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 W1(n,e,t){const o=(e||n).selection,s=(e||n).doc;let i,r;if(o instanceof D&&(r=o.node.type.spec.tableRole)){if(r=="cell"||r=="header_cell")i=Z.create(s,o.from);else if(r=="row"){const l=s.resolve(o.from+1);i=Z.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=Z.create(s,a+1,c)}}else o instanceof $&&_1(o)?i=$.create(s,o.from):o instanceof $&&G1(o)&&(i=$.create(s,o.$from.start(),o.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}var j1=new so("fix-tables");function Wd(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)?Wd(n.child(l),a,t+1,o):a.nodesBetween(0,a.content.size,o,t+1),t+=a.nodeSize}}function q1(n,e){let t;const o=(s,i)=>{s.type.spec.tableRole=="table"&&(t=U1(n,s,i,t))};return e?e.doc!=n.doc&&Wd(e.doc,n.doc,0,o):n.doc.descendants(o),t}function U1(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 p=d.attrs;for(let u=0;u<p.rowspan;u++)i[c.row+u]+=c.n;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,vn(p,p.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),p=c+d.nodeSize,u=i[a];if(u>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const f=[];for(let g=0;g<u;g++){const b=We(n.schema)[h].createAndFill();b&&f.push(b)}const m=(a==0||r==a-1)&&l==a?c+1:p-1;o.insert(o.mapping.map(m),f)}c=p}return o.setMeta(j1,{fixTables:!0})}function jd(n){const e=n.selection,t=hr(n),o=t.node(-1),s=t.start(-1),i=U.get(o);return{...e instanceof Z?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(t.pos-s),tableStart:s,map:i,table:o}}function K1(n){return function(e,t){if(!xs(e))return!1;if(t){const o=We(e.schema),s=jd(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 ia(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 mr(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?K1(n):function(t,o){if(!xs(t))return!1;if(o){const s=We(t.schema),i=jd(t),r=t.tr,l=ia("row",i,s),a=ia("column",i,s),d=(n==="column"?l:n==="row"?a:!1)?1:0,p=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,u=n=="column"?a?s.cell:s.header_cell:n=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(p).forEach(h=>{const f=h+i.tableStart,m=r.doc.nodeAt(f);m&&r.setNodeMarkup(f,u,m.attrs)}),o(r)}return!0}}mr("row",{useDeprecatedLogic:!0});mr("column",{useDeprecatedLogic:!0});mr("cell",{useDeprecatedLogic:!0});function J1(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 ra(n){return function(e,t){if(!xs(e))return!1;const o=J1(hr(e),n);if(o==null)return!1;if(t){const s=e.doc.resolve(o);t(e.tr.setSelection($.between(s,B1(s))).scrollIntoView())}return!0}}function ko(n,e){const t=n.selection;if(!(t instanceof Z))return!1;if(e){const o=n.tr,s=We(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 A(s,0,0))}),o.docChanged&&e(o)}return!0}function Z1(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),p=a<e.childCount-1?0:Math.max(0,o-1);(d||p)&&(c=Li(We(r).row,new A(c,d,p)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||o?Li(We(r).row,new A(e,t,o)).content:e);else return null;return Y1(r,l)}function Y1(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(T.empty),t[s]<o){const i=We(n).cell.createAndFill(),r=[];for(let l=t[s];l<o;l++)r.push(i);e[s]=e[s].append(T.from(r))}return{height:e.length,width:o,rows:e}}function Li(n,e){const t=n.createAndFill();return new Wc(t).replace(0,t.content.size,e).doc}function X1({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,p=0;d<o;p++){let u=a.child(p%a.childCount);d+u.attrs.colspan>o&&(u=u.type.createChecked(vn(u.attrs,u.attrs.colspan,d+u.attrs.colspan-o),u.content)),c.push(u),d+=u.attrs.colspan;for(let h=1;h<u.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+u.attrs.colspan}r.push(T.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 p=c.child(d);r+p.attrs.rowspan>s&&(p=p.type.create({...p.attrs,rowspan:Math.max(1,s-p.attrs.rowspan)},p.content)),a.push(p)}i.push(T.from(a))}t=i,e=s}return{width:n,height:e,rows:t}}function Q1(n,e,t,o,s,i,r){const l=n.doc.type.schema,a=We(l);let c,d;if(s>e.width)for(let p=0,u=0;p<e.height;p++){const h=t.child(p);u+=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(r).map(u-1+o),f)}if(i>e.height){const p=[];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;p.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const u=a.row.create(null,T.from(p)),h=[];for(let f=e.height;f<i;f++)h.push(u);n.insert(n.mapping.slice(r).map(o+t.nodeSize-2),h)}return!!(c||d)}function la(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,p=e.map[d];if(e.map[d-e.width]==p){a=!0;const u=t.nodeAt(p),{top:h,left:f}=e.findCell(p);n.setNodeMarkup(n.mapping.slice(l).map(p+o),null,{...u.attrs,rowspan:r-h}),n.insert(n.mapping.slice(l).map(e.positionAt(r,f,t)),u.type.createAndFill({...u.attrs,rowspan:h+u.attrs.rowspan-r})),c+=u.attrs.colspan-1}}return a}function aa(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,p=e.map[d];if(e.map[d-1]==p){a=!0;const u=t.nodeAt(p),h=e.colCount(p),f=n.mapping.slice(l).map(p+o);n.setNodeMarkup(f,null,vn(u.attrs,r-h,u.attrs.colspan-(r-h))),n.insert(f+u.nodeSize,u.type.createAndFill(vn(u.attrs,0,r-h))),c+=u.attrs.rowspan-1}}return a}function ca(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,p=n.tr;let u=0;function h(){if(i=t?p.doc.nodeAt(t-1):p.doc,!i)throw new Error("No table found");r=U.get(i),u=p.mapping.maps.length}Q1(p,r,i,t,c,d,u)&&h(),la(p,r,i,t,a,c,l,u)&&h(),la(p,r,i,t,a,c,d,u)&&h(),aa(p,r,i,t,l,d,a,u)&&h(),aa(p,r,i,t,l,d,c,u)&&h();for(let f=l;f<d;f++){const m=r.positionAt(f,a,i),g=r.positionAt(f,c,i);p.replace(p.mapping.slice(u).map(m+t),p.mapping.slice(u).map(g+t),new A(s.rows[f-l],0,0))}h(),p.setSelection(new Z(p.doc.resolve(t+r.positionAt(l,a,i)),p.doc.resolve(t+r.positionAt(d-1,c-1,i)))),e(p)}var e0=ld({ArrowLeft:Eo("horiz",-1),ArrowRight:Eo("horiz",1),ArrowUp:Eo("vert",-1),ArrowDown:Eo("vert",1),"Shift-ArrowLeft":To("horiz",-1),"Shift-ArrowRight":To("horiz",1),"Shift-ArrowUp":To("vert",-1),"Shift-ArrowDown":To("vert",1),Backspace:ko,"Mod-Backspace":ko,Delete:ko,"Mod-Delete":ko});function Lo(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Eo(n,e){return(t,o,s)=>{if(!s)return!1;const i=t.selection;if(i instanceof Z)return Lo(t,o,L.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;const r=qd(s,n,e);if(r==null)return!1;if(n=="horiz")return Lo(t,o,L.near(t.doc.resolve(i.head+e),e));{const l=t.doc.resolve(r),a=_d(l,n,e);let c;return a?c=L.near(a,1):e<0?c=L.near(t.doc.resolve(l.before(-1)),-1):c=L.near(t.doc.resolve(l.after(-1)),1),Lo(t,o,c)}}}function To(n,e){return(t,o,s)=>{if(!s)return!1;const i=t.selection;let r;if(i instanceof Z)r=i;else{const a=qd(s,n,e);if(a==null)return!1;r=new Z(t.doc.resolve(a))}const l=_d(r.$headCell,n,e);return l?Lo(t,o,new Z(r.$anchorCell,l)):!1}}function t0(n,e){const t=n.state.doc,o=ao(t.resolve(e));return o?(n.dispatch(n.state.tr.setSelection(new Z(o))),!0):!1}function n0(n,e,t){if(!xs(n.state))return!1;let o=Z1(t);const s=n.state.selection;if(s instanceof Z){o||(o={width:1,height:1,rows:[T.from(Li(We(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=X1(o,l.right-l.left,l.bottom-l.top),ca(n.state,n.dispatch,r,l,o),!0}else if(o){const i=hr(n.state),r=i.start(-1);return ca(n.state,n.dispatch,r,U.get(i.node(-1)).findCell(i.pos-r),o),!0}else return!1}function o0(n,e){var t;if(e.ctrlKey||e.metaKey)return;const o=da(n,e.target);let s;if(e.shiftKey&&n.state.selection instanceof Z)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(s=ao(n.state.selection.$anchor))!=null&&((t=Us(n,e))==null?void 0:t.pos)!=s.pos)i(s,e),e.preventDefault();else if(!o)return;function i(a,c){let d=Us(n,c);const p=lt.getState(n.state)==null;if(!d||!fr(a,d))if(p)d=a;else return;const u=new Z(a,d);if(p||!n.state.selection.eq(u)){const h=n.state.tr.setSelection(u);p&&h.setMeta(lt,a.pos),n.dispatch(h)}}function r(){n.root.removeEventListener("mouseup",r),n.root.removeEventListener("dragstart",r),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 p;if(d!=null)p=n.state.doc.resolve(d);else if(da(n,c.target)!=o&&(p=Us(n,e),!p))return r();p&&i(p,c)}n.root.addEventListener("mouseup",r),n.root.addEventListener("dragstart",r),n.root.addEventListener("mousemove",l)}function qd(n,e,t){if(!(n.state.selection instanceof $))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 da(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Us(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?ao(n.state.doc.resolve(t.pos)):null}var s0=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")),$i(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,$i(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function $i(n,e,t,o,s,i){var r;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let p=0,u=0;p<d.childCount;p++){const{colspan:h,colwidth:f}=d.child(p).attrs;for(let m=0;m<h;m++,u++){const g=s==u?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 C=document.createElement("col");C.style.width=b,e.appendChild(C)}}}for(;c;){const p=c.nextSibling;(r=c.parentNode)==null||r.removeChild(c),c=p}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var ve=new so("tableColumnResizing");function i0({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:o=s0,lastColumnResizable:s=!0}={}){const i=new wn({key:ve,state:{init(r,l){var a,c;const d=(c=(a=i.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,p=We(l.schema).table.name;return o&&d&&(d[p]=(u,h)=>new o(u,t,h)),new r0(-1,!1)},apply(r,l){return l.apply(r)}},props:{attributes:r=>{const l=ve.getState(r);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(r,l)=>{l0(r,l,n,s)},mouseleave:r=>{a0(r)},mousedown:(r,l)=>{c0(r,l,e,t)}},decorations:r=>{const l=ve.getState(r);if(l&&l.activeHandle>-1)return f0(r,l.activeHandle)},nodeViews:{}}});return i}var r0=class $o{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,o=e.getMeta(ve);if(o&&o.setHandle!=null)return new $o(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new $o(t.activeHandle,o.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);return Di(e.doc.resolve(s))||(s=-1),new $o(s,t.dragging)}return t}};function l0(n,e,t,o){const s=ve.getState(n.state);if(s&&!s.dragging){const i=p0(e.target);let r=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?r=pa(n,e,"left",t):a-e.clientX<=t&&(r=pa(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}Ud(n,r)}}}function a0(n){const e=ve.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Ud(n,-1)}function c0(n,e,t,o){var s;const i=(s=n.dom.ownerDocument.defaultView)!=null?s:window,r=ve.getState(n.state);if(!r||r.activeHandle==-1||r.dragging)return!1;const l=n.state.doc.nodeAt(r.activeHandle),a=d0(n,r.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(ve,{setDragging:{startX:e.clientX,startWidth:a}}));function c(p){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const u=ve.getState(n.state);u!=null&&u.dragging&&(u0(n,u.activeHandle,ua(u.dragging,p,t)),n.dispatch(n.state.tr.setMeta(ve,{setDragging:null})))}function d(p){if(!p.which)return c(p);const u=ve.getState(n.state);if(u&&u.dragging){const h=ua(u.dragging,p,t);ha(n,u.activeHandle,h,o)}}return ha(n,r.activeHandle,a,o),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function d0(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 p0(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function pa(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=ao(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 ua(n,e,t){const o=e.clientX-n.startX;return Math.max(t,n.startWidth+o)}function Ud(n,e){n.dispatch(n.state.tr.setMeta(ve,{setHandle:e}))}function u0(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 p=i.map[d],u=s.nodeAt(p).attrs,h=u.colspan==1?0:l-i.colCount(p);if(u.colwidth&&u.colwidth[h]==t)continue;const f=u.colwidth?u.colwidth.slice():h0(u.colspan);f[h]=t,a.setNodeMarkup(r+p,null,{...u,colwidth:f})}a.docChanged&&n.dispatch(a)}function ha(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&&$i(i,a.firstChild,a,o,l,t)}function h0(n){return Array(n).fill(0)}function f0(n,e){var t;const o=[],s=n.doc.resolve(e),i=s.node(-1);if(!i)return j.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 p=r.map[d],u=l+p+i.nodeAt(p).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",(t=ve.getState(n))!=null&&t.dragging&&o.push(fe.node(l+p,l+p+i.nodeAt(p).nodeSize,{class:"column-resize-dragging"})),o.push(fe.widget(u,h))}}return j.create(n.doc,o)}function m0({allowTableNodeSelection:n=!1}={}){return new wn({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:i}=e.mapping.mapResult(t);return s?null:i}},props:{decorations:F1,handleDOMEvents:{mousedown:o0},createSelectionBetween(e){return lt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:t0,handleKeyDown:e0,handlePaste:n0},appendTransaction(e,t,o){return W1(o,q1(o,t),n)}})}const Fn=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},fa="data-gs-mrk-fs",ma="data-gs-ib",Kd="data-gs-mrk-wrap",rs="data-gs-ifrg",tt="attrs",gr={[tt]:{default:"{}"}},Ue={[tt]:{default:{}}},yr=n=>({[tt]:JSON.stringify(Fn(n))}),Ke=n=>({attrs:Fn(n)}),Mn=n=>e=>[n,e.attrs.attrs,0],Xe=n=>n.attrs[tt]?JSON.parse(n.attrs[tt]):{},g0={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${rs}]`,getAttrs:Ke}],toDOM:()=>["span",{[rs]:""},0]},div:{group:"block",content:"inline*",attrs:Ue,parseDOM:[{tag:"div",getAttrs:Ke}],toDOM:Mn("div")},paragraph:{group:"block",content:"inline*",attrs:Ue,parseDOM:[{tag:"p",getAttrs:Ke}],toDOM:Mn("p")},orderedList:{group:"block",content:"listItem+",attrs:Ue,parseDOM:[{tag:"ol",getAttrs:Ke}],toDOM:Mn("ol")},bulletList:{group:"block",content:"listItem+",attrs:Ue,parseDOM:[{tag:"ul",getAttrs:Ke}],toDOM:Mn("ul")},listItem:{content:"block*",group:"block",attrs:Ue,parseDOM:[{tag:"li",getAttrs:Ke}],toDOM:Mn("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:Ue,parseDOM:[{tag:"pre",getAttrs:Ke}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:Ue,parseDOM:[{tag:"img[src]",getAttrs:Ke}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${ma}]`}],toDOM(){return["br",{[ma]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:Ue,parseDOM:[{tag:"br",getAttrs:Ke}],toDOM:n=>["br",{...n.attrs.attrs}]},heading:{group:"block",content:"inline*",attrs:{level:{default:1},attrs:{default:{}}},defining:!0,parseDOM:Array.from({length:6},(n,e)=>({tag:`h${e+1}`,getAttrs:t=>({level:e+1,attrs:Fn(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...z1({tableGroup:"block",cellContent:"block+",cellAttributes:{[tt]:{default:Ue[tt].default,getFromDOM:Fn,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:Fn(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},An=(n,e)=>({attrs:gr,parseDOM:n.map(t=>({tag:t,getAttrs:yr})),toDOM:e}),y0=n=>({attrs:{...gr},parseDOM:[{tag:`span[${n}]`,getAttrs:e=>({...yr(e)})}],toDOM(e){return["span",{...Xe(e),[n]:!0},0]}}),b0={strong:An(["strong","b"],n=>["b",Xe(n)]),link:An(["a"],n=>["a",Xe(n),0]),em:An(["em","i"],n=>["em",Xe(n)]),underline:An(["u"],n=>["u",Xe(n),0]),strikethrough:An(["s"],n=>["s",Xe(n),0]),wrapStyle:y0(Kd),font_size:{attrs:{...gr,size:{default:null}},parseDOM:[{tag:`span[${fa}]`,getAttrs:n=>({...yr(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...Xe(n),[fa]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},ga=new $f({nodes:g0,marks:b0}),co=new WeakMap,br=new WeakMap,v0=(n,e,t)=>{co.set(n,{view:e,gjsView:t,initialDoc:e.state.doc}),br.set(e,{el:n,gjsView:t})},S0=(n,e)=>{co.delete(n),br.delete(e)},zo=n=>co.get(n),Jd=n=>br.get(n),ya=n=>{const e=zo(n),t=e==null?void 0:e.view,o=e==null?void 0:e.initialDoc;return!(t&&o&&o.eq(t.state.doc))},Ks=n=>{var e,t;return(t=(e=Jd(n))==null?void 0:e.gjsView)==null?void 0:t.model},x0=n=>n.dispatchEvent(new CustomEvent("input"));function w0(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(rs)){if(t.getAttribute("style")){t.removeAttribute(rs);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)}const C0=(n,e)=>{const t=Zd(n);return t&&R0(t)?E0(n,e):t?Qc(()=>({type:n.schema.nodes.div}))(n,e):!1},k0=(n,e)=>(t,o)=>{var l;const s=Zd(t),i=co.get(n.el).view,r=(l=e.onEnter)==null?void 0:l.call(e,{...n,node:s,commands:vr(i,n.editor,e),proseMirror:{view:i,dispatch:o}});return r!==void 0?r:C0(t,o)};function Zd(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 E0(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||" ",p=o.text(d),u=o.nodes.div.create(l,a?p:[],[]);return s.replaceRangeWith(i,i+c+2,u),s.setSelection($.create(s.doc,i+1)),e==null||e(s.scrollIntoView()),!0}function T0(n,e,t){const{state:o,dispatch:s}=n,{selection:i,tr:r}=o,l=(a,c,d)=>{const p={};return a.split(";").forEach(u=>{const[h,f]=u.split(":").map(m=>m.trim());h&&(p[h]=f)}),p[c]=d,Object.entries(p).map(([u,h])=>`${u}: ${h}`).join("; ")};if(!i.empty||t)r.doc.nodesBetween(i.from,i.to,(a,c)=>{var d,p;if(a.type===o.schema.nodes.image){const u=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}else if(a.type.isBlock){const u=l(((p=a.attrs.attrs)==null?void 0:p.style)||"","text-align",e);Yd(a)?r.setBlockType(i.from,void 0,o.schema.nodes.div,{attrs:{style:u}}):r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}});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 p=l(d.attrs.style||"","text-align",e);r.setNodeMarkup(c,void 0,{...d.attrs,style:p})}}r.docChanged&&s(r.scrollIntoView())}const Pn=(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 M0(n){var p,u;const{view:e,href:t,options:o,target:s="_blank"}=n,{state:i,dispatch:r}=e,{schema:l,selection:a,tr:c}=i,d=l.marks.link;try{const h={href:t,target:s},f=((u=(p=o.commandAttrs)==null?void 0:p.link)==null?void 0:u.call(p,h))||h,m=d.create({[tt]:JSON.stringify(f)});c.addMark(a.from,a.to,m),r(c.scrollIntoView())}catch(h){console.error("Error applying link mark:",h)}}function A0(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 Nt=(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}}},P0=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 N0(...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 I0=(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($.create(t.doc,i.pos)))}else ed(t,o);setTimeout(()=>setTimeout(()=>n.focus()))},zi=n=>n.isBlock,Yd=n=>n.type.name==="inlineFragment",O0=n=>zi(n)&&!Yd(n),Xd=n=>n.type.name==="bulletList",Qd=n=>n.type.name==="orderedList",R0=n=>n.type.name==="heading",D0=n=>Xd(n)||Qd(n),ba=(n,e)=>{var i,r;const t=(i=Nt(n,l=>l.type===e))==null?void 0:i.node,o=n.state.schema.nodes.listItem;let s;return t?s=xi(o):(r=Nt(n,D0))!=null&&r.node?s=N0(xi(o),Cl(e)):s=Cl(e),s(n.state,n.dispatch)},ep=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(o=>o.type.name===e)},L0=n=>{var r;const{view:e,prop:t,editor:o,propCSS:s}=n,i=(r=Nt(e,O0))==null?void 0:r.node;if(i){const l=i.attrs.attrs||{},a=P0(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""},$0=n=>{const{view:e,prop:t,markName:o,editor:s,propCSS:i}=n,r=ep(e,o);if(r){const l=r.attrs;if(l[t])return l[t];if(l[tt]){const a=Xe(r).id;if(a){const c=s.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[i]||""}}}return""},vr=(n,e,t)=>{const{dispatch:o}=n,{nodes:s,marks:i}=n.state.schema,r={text:{selected:()=>{const{selection:l,doc:a}=n.state;return a.textBetween(l.from,l.to," ")},replace:(l,a={})=>{const{state:c}=n,{from:d}=c.selection;let p=c.tr.replaceSelectionWith(c.schema.text(l));a.select&&(p=p.setSelection($.create(p.doc,d,d+l.length))),o==null||o(p)},replaceHtml:l=>{const{schema:a,selection:c,tr:d}=n.state,p=document.createElement("div");p.innerHTML=l;const u=Bt.fromSchema(a).parse(p),{from:h,to:f}=c;return o==null?void 0:o(d.replaceRangeWith(h,f,u).scrollIntoView())},wrapStyle:()=>{const l=Ks(n),a=r.text.selected(),c=`i${e.Components._createId().slice(0,4)}`;r.text.replaceHtml(`<span id="${c}" ${Kd}>${a}</span>`),l==null||l.trigger("disable"),setTimeout(()=>{const d=l==null?void 0:l.find(`#${c}`)[0];d&&e.select(d)})},createBreak:()=>{const{state:l}=n,a=l.tr.replaceSelectionWith(s.inlineBreak.create()).scrollIntoView();return o==null?void 0:o(a)}},bold:{toggle:()=>kt(i.strong)(n.state,o),isActive:()=>Pn(n.state,i.strong)},italic:{toggle:()=>kt(i.em)(n.state,o),isActive:()=>Pn(n.state,i.em)},underline:{toggle:()=>kt(i.underline)(n.state,o),isActive:()=>Pn(n.state,i.underline)},strikethrough:{toggle:()=>kt(i.strikethrough)(n.state,o),isActive:()=>Pn(n.state,i.strikethrough)},link:{get:()=>{const l=Ks(n),a=l==null?void 0:l.getTrait("href");if(l!=null&&l.is("link"))return l.getAttributes();if(a)return{href:a.getValue()};{const c=ep(n,"link");return c?Xe(c):{}}},toggle:()=>kt(i.link)(n.state,o),isActive:()=>Pn(n.state,i.link),create:l=>{const a=Ks(n),c=a==null?void 0:a.getTrait("href"),{url:d,target:p}=l,u=()=>{var f,m;const h=(m=(f=Jd(n))==null?void 0:f.gjsView)==null?void 0:m.el;h&&h.contentEditable!=="true"&&(h.contentEditable="true"),n.focus()};a!=null&&a.is("link")?(a.addAttributes({href:d,target:p}),u()):c?(a==null||a.addAttributes({[c.getName()]:d}),u()):M0({view:n,href:d,target:p,options:t})}},alignText:{get:()=>L0({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:l=>T0(n,l.value,!0)},fontSize:{get:()=>$0({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:l=>A0(n,l.value)},image:{open(){const l="assetLayout",{state:a,dispatch:c}=n,{selection:d,doc:p}=a,u=p.textBetween(d.from,d.to," "),h={id:l,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:f=>{const m={alt:u,src:f.asset.getSrc()};c(a.tr.replaceSelectionWith(s.image.createAndFill({attrs:m})))}}};e.runCommand(W.layoutToggle,h)}},heading:{get:()=>{var a;const l=(a=Nt(n,zi))==null?void 0:a.node;return`${(l==null?void 0:l.attrs.level)||""}`},set:({value:l})=>{var d;const{state:a}=n,c=(d=Nt(n,zi))==null?void 0:d.node;Pm(a.schema.nodes.heading,{attrs:c==null?void 0:c.attrs.attrs,level:l?parseInt(l,10):0})(a,o)}},listBullet:{isActive:()=>{var l;return!!((l=Nt(n,Xd))!=null&&l.node)},toggle:()=>ba(n,s.bulletList)},listOrdered:{isActive:()=>{var l;return!!((l=Nt(n,Qd))!=null&&l.node)},toggle:()=>ba(n,s.orderedList)}};return r};class vt{constructor(e,t,o={}){this.match=e,this.match=e,this.handler=typeof t=="string"?z0(t):t,this.undoable=o.undoable!==!1,this.inCode=o.inCode||!1}}function z0(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 V0=500;function B0({rules:n}){let e=new wn({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 va(t,o,s,i,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:o}=t.state.selection;o&&va(t,o.pos,o.pos,"",n,e)})}}},isInputRules:!0});return e}function va(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-V0),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 p=d.match.exec(a),u=p&&d.handler(r,p,e-(p[0].length-o.length),t);if(u)return d.undoable&&u.setMeta(i,{transform:u,from:e,to:t,text:o}),n.dispatch(u),!0}return!1}const H0=new vt(/--$/,"—"),F0=new vt(/\.\.\.$/,"…"),_0=new vt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),G0=new vt(/"$/,"”"),W0=new vt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),j0=new vt(/'$/,"’"),q0=[_0,G0,W0,j0];function Sr(n,e,t=null,o){return new vt(n,(s,i,r,l)=>{let a=t instanceof Function?t(i):t,c=s.tr.delete(r,l),d=c.doc.resolve(r),p=d.blockRange(),u=p&&zc(p,e,a);if(!u)return null;c.wrap(p,u);let h=c.doc.resolve(r-1).nodeBefore;return h&&h.type==e&&gs(c.doc,r-1)&&(!o||o(i,h))&&c.join(r-1),c})}function tp(n,e,t=null){return new vt(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 U0(n){return Sr(/^\s*>\s$/,n)}function K0(n){return Sr(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function J0(n){return Sr(/^\s*([-+*])\s$/,n)}function Z0(n){return tp(/^```$/,n)}function Y0(n,e){return tp(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function X0(n){const e=q0.concat(F0,H0);let t;return(t=n.nodes.blockquote)&&e.push(U0(t)),(t=n.nodes.orderedList)&&e.push(K0(t)),(t=n.nodes.bulletList)&&e.push(J0(t)),(t=n.nodes.codeBlock)&&e.push(Z0(t)),(t=n.nodes.heading)&&e.push(Y0(t,6)),B0({rules:e})}const Q0="rteProseMirror",ey=H.free,Ce="rte:selectionchange",we={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>'},ty=(n,e)=>{var a;const{editor:t,el:o}=n,s=co.get(o).view,i=vr(s,t,e),r={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},wrapStyle:{id:"wrapper",type:"button",icon:"tag",tooltip:"Wrap for styling",editorEvents:{[Ce]:({setState:c})=>{c({disabled:s.state.selection.empty})}},onClick:()=>i.text.wrapStyle()},bold:{id:"bold",icon:we.bold,size:"s",type:"button",editorEvents:{[Ce]:({setState:c})=>{c({active:i.bold.isActive()})}},onClick:({setState:c})=>{i.bold.toggle(),c({active:i.bold.isActive()})}},italic:{id:"italic",icon:we.italic,size:"s",type:"button",editorEvents:{[Ce]:({setState:c})=>{c({active:i.italic.isActive()})}},onClick:({setState:c})=>{i.italic.toggle(),c({active:i.italic.isActive()})}},underline:{id:"underline",icon:we.underline,size:"s",type:"button",editorEvents:{[Ce]:({setState:c})=>{c({active:i.underline.isActive()})}},onClick:({setState:c})=>{i.underline.toggle(),c({active:i.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:we.strikethrough,size:"s",type:"button",editorEvents:{[Ce]:({setState:c})=>{c({active:i.strikethrough.isActive()})}},onClick:({setState:c})=>{i.strikethrough.toggle(),c({active:i.strikethrough.isActive()})}},image:{id:"image",icon:we.image,size:"s",type:"button",onClick:()=>i.image.open()},link:{id:"link",icon:we.link,size:"s",type:"button",editorEvents:{[Ce]:({setState:c})=>{c({active:i.link.isActive(),disabled:s.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,{x:p,y:u,width:h,height:f}=d.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(W.layoutRemove,{id:m}),b=i.link.get(),C={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:p,y:u,w:h,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(W.layoutToggle,C)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:we.alignTextLeft},{id:"center",icon:we.alignTextCenter},{id:"right",icon:we.alignTextRight},{id:"justify",icon:we.alignTextJustify}],editorEvents:{[Ce]:({setState:c})=>{c({value:i.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:we.listBullet,size:"s",type:"button",editorEvents:{[Ce]:({setState:c})=>{c({active:i.listBullet.isActive()})}},onClick:({setState:c})=>{i.listBullet.toggle(),c({active:i.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:we.listOrdered,size:"s",type:"button",editorEvents:{[Ce]:({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:{[Ce]:({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:{[Ce]:({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 ny{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;vr(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 oy=function(n,e={}){const t={plugins:l=>l.plugins,...e},o=(l,a)=>{var g,b;const c=((g=t.schema)==null?void 0:g.call(t,{editor:n,schema:ga}))||ga,{nodes:d,marks:p}=c,u={...a,component:a.view.model,editor:n,el:l},h=Bt.fromSchema(c).parse(l),f=on.create({doc:h,schema:c,plugins:(b=t.plugins)==null?void 0:b.call(t,{editor:n,Plugin:wn,plugins:[i0(),m0(),X0(c),Fm(),Fs({Tab:ra(1),"Shift-Tab":ra(-1)}),Fs({Enter:Yn(Xc,Jm(d.listItem),k0(u,t)),"Shift-Enter":Yn(Yc,(C,y)=>(y&&y(C.tr.replaceSelectionWith(d.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":rd,"Mod-y":Si,"Mod-Shift-z":Si,"Mod-b":kt(p.strong),"Mod-i":kt(p.em),"Shift-Tab":xi(d.listItem),Tab:Xm(d.listItem)}),Fs(Om)]})}),m=new N1({mount:l},{state:f,dispatchTransaction(C){var x;const{state:y}=m,v=y.apply(C),w=!y.doc.eq(v.doc);m.updateState(v);const S=!y.selection.eq(v.selection);w&&(x0(((x=a==null?void 0:a.view)==null?void 0:x.el)||l),m.focus()),(S||w)&&n.trigger(Ce)}});return l.__rteView=m,m.setProps({nodeViews:{image(C){return new ny(C,m,n)}}}),m},s=l=>ty(l,t);n.setCustomRte({toolbar:s,parseContent:!0,async enable(l,a,c){const d=zo(l);if(d)return d;const p=o(l,c);return v0(l,p,c.view),I0(p,c),p},disable(l){const a=zo(l),c=a==null?void 0:a.view;if(c){const d=ya(l);return S0(l,c),d||n.once(n.RichTextEditor.events.disable,()=>{a.gjsView.model.trigger("rerender")}),c.destroy(),{forceSync:d}}},getContent(l,a,c){var p;const d=(p=zo(l))==null?void 0:p.view;if(d){const{schema:u,doc:h}=d.state;if(!ya(l))return c.view.lastContent;const f=document.createElement("div"),m=Wt.fromSchema(u).serializeFragment(h.content);return m.childNodes.forEach(g=>{g.nodeType===Node.ELEMENT_NODE&&g.innerHTML===""&&(g.innerHTML="<br/>")}),f.appendChild(m),w0(f),l.classList.remove("ProseMirror-focused"),f.innerHTML}return l.innerHTML}});const i=fc(n,t.enableOnClick),r=df(n,t.disableOnEsc);G({editor:n,licenseKey:t.licenseKey,plan:ey,pluginName:Q0,cleanup:()=>{n.RichTextEditor.customRte=void 0,i(),r()}})},sy=_(oy),iy="canvasEmptyState",ry=H.startup,ly=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 w=!1;const{isValid:S}=v;return Array.isArray(S)?w=S.some(x=>y.is(x)):_t(S)?w=S({component:y,editor:n}):w=y.is(S),w},c=y=>{const v=t.get(y);t.delete(y),v==null||v()},d=y=>{y.views.forEach(v=>c(v)),s.delete(y)},p=y=>{if(!(!y||i.has(y)))try{i.add(y);const v=y.components().length>0,w=s.get(y);if(v&&w)d(y);else if(!v&&!w){const S=r.has(y)?r.get(y):l.emptyStates.find(x=>a(y,x));if(r.set(y,S),!S)return;y.views.forEach(x=>{const k=S.render({editor:n,component:y,componentView:x,mount:E=>{o.set(x,E),s.set(y,!0);const M=x.getChildrenContainer();M==null||M.appendChild(E)},unmount:()=>c(x)});t.set(x,()=>{k==null||k();const E=o.get(x);E==null||E.remove()})})}}finally{i.delete(y)}},u=y=>{s.has(y)&&d(y)},h=({model:y})=>{p(y.getComponent())},f=n.Components.events,m=`${f.update}:components`,g="component:mount",b=n.Canvas.events.frameLoadBody,C=f.removed;n.on(m,p),n.on(g,p),n.on(C,u),n.on(b,h),G({editor:n,licenseKey:l.licenseKey,plan:ry,pluginName:iy,cleanup:()=>{n.off(m,p),n.off(g,p),n.off(C,u),n.off(b,h)}})},ay=_(ly),Sa="canvasFullSize",cy=H.startup,dy=(n,e)=>{const{rule:t,ruleView:o}=e,{style:s}=t.attributes;if(s&&s[n]){const i=s[n],r=/([0-9.]+)(vh|dvh|lvh|svh)/g,l=r.test(i),a=o.frameView.model;if(l&&a.hasAutoHeight()){const c=i.replace(r,(p,u)=>`${window.innerHeight*(parseFloat(u)/100)}px`),d=t.toCSS({style:{...s,[n]:c}});e.css=d}}},py=n=>{["height","min-height","max-height"].forEach(e=>dy(e,n))},uy=function(n,e={}){const{Canvas:t,Commands:o,Devices:s,Css:i}=n,r={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...e},{canvasOffsetY:l,canvasOffsetX:a,canvasTransition:c,deviceMaxWidth:d,deviceMinHeigth:p,deviceFixedHeight:u,frameBorderRadius:h,frameTransition:f}=r,m=`${p}px`,g=t.events,b="core:preview",C=`${o.events.stopCommand}${b}`,y=t.getConfig(),v=`${Sa}:disable`,w=s.getAll().map(z=>({...z.attributes})),S=c*1e3,x={x:a,y:l};let k={},E,M;y.scrollableCanvas=!u,s.getAll().map(z=>{!z.get("width")&&z.set("width",`${d}px`),!z.get("height")&&z.set("height",u?"100vh":"auto"),!z.get("minHeight")&&z.set("minHeight",m)});const P=z=>{const pe=`${Bo}canvas-full-size`,ue=document.querySelector(`style[${pe}]`);if(z&&ue)return ue.remove();const Le=ue||document.createElement("style"),uo=t.getZoomMultiplier();Le.setAttribute(pe,"true"),Le.innerHTML=`
|
|
917
917
|
.gjs-frame-wrapper { transition: width ${f}s !important; }
|
|
918
|
-
.gjs-frame-wrapper__bottom { height: ${l*
|
|
918
|
+
.gjs-frame-wrapper__bottom { height: ${l*uo}px }
|
|
919
919
|
.gjs-frame { border-radius: ${h}px }
|
|
920
|
-
`,!ue&&document.body.appendChild(Le)};n.on(g.frameLoadHead,z=>{if(!y.scrollableCanvas)return;const{window:pe}=z,ue=pe.document,Le=ue.head,
|
|
920
|
+
`,!ue&&document.body.appendChild(Le)};n.on(g.frameLoadHead,z=>{if(!y.scrollableCanvas)return;const{window:pe}=z,ue=pe.document,Le=ue.head,uo=`${Bo}canvas-full-size-wrappers`,ho=Le.querySelector(`style[${uo}]`)||ue.createElement("style");ho.setAttribute(uo,"true"),ho.innerHTML=`
|
|
921
921
|
body { height: auto !important; }
|
|
922
922
|
[data-gjs-type="wrapper"] { min-height: ${m} !important; }
|
|
923
923
|
[data-gjs-type="mjml"] { min-height: ${m} !important; }
|
|
924
924
|
[data-gjs-type="mj-body"] { min-height: ${m} !important; }
|
|
925
|
-
`,!Le.contains(
|
|
925
|
+
`,!Le.contains(ho)&&Le.appendChild(ho)});const N=()=>E.style.display="none",I=()=>E.style.display="",R=()=>{var Le;if(!u)return;const z=t.getZoomMultiplier(),ue=t.getRect().height*z-l*2;(Le=s.getSelected())==null||Le.set("height",`${Math.max(ue,p)}px`),t.fitViewport({zoom:t.getZoom(),gap:x})},F=jn(()=>{t.fitViewport({zoom:z=>z>100?100:z,ignoreHeight:!0,gap:x}),R(),P(),setTimeout(()=>{var pe,ue;const{em:z}=n;z.destroyed||((ue=(pe=n.getSelected())==null?void 0:pe.getEl())==null||ue.scrollIntoView({block:"nearest"}),n.refresh({tools:!0}),I(),o.isActive(b)?z.stopDefault():z.runDefault())},S)},100),ie=(z={})=>{z.options&&z.options.from!=="fitViewport"&&t.fitViewport({zoom:t.getZoom(),ignoreHeight:!0,gap:x})},re=()=>{N(),F()},je=()=>{k.overflowX="hidden",k.overflowY="auto"},ye=()=>{M==null||M.disconnect(),F.clear()},xe=[[s.events.select,re],[g.zoom,ie],[C,je],[n.events.destroy,ye],[i.events.mountBefore,py]];o.add(v,()=>{s.devices.reset(w),y.scrollableCanvas=!1,t.getModel().updateDevice(),t.setZoom(100),t.setCoords(0,0),k.overflowY="hidden",P(!0),xe.forEach(([z,pe])=>n.off(z,pe)),ye(),o.run("studio:canvasReload")}),xe.forEach(([z,pe])=>n.on(z,pe)),n.onReady(()=>{const z=t.getElement(),pe=t.getFramesEl(),ue=t.getCanvasView();E=t.getSpotsEl(),k=z.style,k.overflowX="hidden",pe.style.transition=`transform ${c}s`,document.removeEventListener("keypress",ue.onKeyPress),P(),M=new ResizeObserver(()=>{N(),F()}),M.observe(z.parentElement),F()}),G({editor:n,licenseKey:r.licenseKey,plan:cy,pluginName:Sa,cleanup:()=>{n.runCommand(v)}})},hy=_(uy),Vi="canvasGridMode",fy=H.startup,Bi="component-grid-mode",no="grid-mode",po="gjs-drag-grid-spot",np=`${po}__grid-item`,op=`${po}__grid-target`,sp=`${po}__snapped`,my=`${po}__container`,gy=()=>{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=`
|
|
926
926
|
.${np} {
|
|
927
|
-
outline: 2px solid ${
|
|
927
|
+
outline: 2px solid ${o};
|
|
928
928
|
background: ${t};
|
|
929
929
|
outline-offset: -2px;
|
|
930
930
|
border-radius: 3px;
|
|
@@ -932,29 +932,29 @@
|
|
|
932
932
|
height: 100%;
|
|
933
933
|
opacity: 0.1;
|
|
934
934
|
}
|
|
935
|
-
.${
|
|
935
|
+
.${sp} {
|
|
936
936
|
width: 100%;
|
|
937
937
|
height: 100%;
|
|
938
|
-
outline: 2px solid ${
|
|
938
|
+
outline: 2px solid ${o};
|
|
939
939
|
outline-offset: -2px;
|
|
940
940
|
position: absolute;
|
|
941
941
|
}
|
|
942
|
-
.${
|
|
942
|
+
.${op} {
|
|
943
943
|
position: absolute;
|
|
944
944
|
z-index: -1;
|
|
945
945
|
background: ${t};
|
|
946
|
-
outline: 1px solid ${
|
|
946
|
+
outline: 1px solid ${o};
|
|
947
947
|
outline-offset: -1px;
|
|
948
948
|
opacity: 0.35;
|
|
949
949
|
}
|
|
950
|
-
`,e.head.appendChild(o)};function ip(n){const{editor:e,type:t}=n,s=xy(e,n.component),o=xr(e,s.component);if(!wy(e,s,o,t))return{target:s,container:o,startScroll:cp(e).scroll,shadowContainerEl:document.createElement("div"),shadowSnappedEl:document.createElement("div"),shadowTargetEl:document.createElement("div"),spot:e.Canvas.addSpot({type:ns,component:o.component})}}function rp(n){const{editor:e,shadowTargetEl:t,shadowSnappedEl:s,shadowContainerEl:o,spotEl:i,target:r,container:l}=n,{Canvas:a}=e,c=e.config.stylePrefix;i==null||i.appendChild(o),o==null||o.appendChild(t),o==null||o.appendChild(s),yy(o,l),by(t,r,l),vy(s,r),Sy(o,l.el),r.el.style.opacity="0";const d=a.getSpots().filter(p=>p.type!==ns);e.em.stopDefault({preserveSelected:!0}),a.removeSpots(d),a.startAutoscroll(),a.getBody().classList.add(`${c}is__grabbing`)}function lp(n){const{editor:e,shadowSnappedEl:t,shadowContainerEl:s,target:o,cancelled:i}=n,{Canvas:r}=e,l=e.config.stylePrefix,{component:a}=o;if(!i){const c=window.getComputedStyle(t);a.addStyle({"grid-area":c.gridArea,width:"",height:""})}o.el.style.opacity="",s.contains(t)&&(s==null||s.removeChild(t)),e.getModel().runDefault({preserveSelected:1}),r.stopAutoscroll(),r.getBody().classList.remove(`${l}is__grabbing`),r.removeSpots({type:ns}),e.select(a)}function yy(n,{rows:e,columns:t}){const s=[];for(let o=0;o<t.length;o++){s[o]=[];for(let i=0;i<e.length;i++){const r=document.createElement("div");r.className=np,r.style.gridArea=`${i+1} / ${o+1}`,s[o][i]=r,n.appendChild(r)}}return s}function by(n,e,t){return n.className=sp,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 vy(n,e){const t=dp(e.el,e.computedStyles);return n.className=op,n.style.gridArea=`${t.row.start} / ${t.column.start} / ${t.row.end} / ${t.column.end}`,n}function Sy(n,e){const t=window.getComputedStyle(e);n.className=my,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 ap(n,e){if(e){if(Array.isArray(e))return[...e].pop()}else return[...n.getSelectedAll()].pop();return e}function xy(n,e){const t=ap(n,e),s=t.getEl(),o=window.getComputedStyle(s);return{component:t,el:s,offset:n.Canvas.offset(s),margin:{top:parseFloat(o.marginTop),right:parseFloat(o.marginRight),bottom:parseFloat(o.marginBottom),left:parseFloat(o.marginLeft)},computedStyles:o}}function xr(n,e){const t=e.parent(),s=t.getEl(),o=window.getComputedStyle(s);return{component:t,el:s,offset:n.Canvas.offset(s),computedStyles:o,padding:{top:parseFloat(o.paddingTop),right:parseFloat(o.paddingRight),bottom:parseFloat(o.paddingBottom),left:parseFloat(o.paddingLeft)},columns:o.gridTemplateColumns.split(" ").map(r=>parseFloat(r)),rows:o.gridTemplateRows.split(" ").map(r=>parseFloat(r)),gap:{column:parseInt(o.columnGap),row:parseInt(o.rowGap)}}}function ut(n,e,t,s,o=1){let i=0;for(let r=e;r<=n.length;r++){if(i+(n[r-1]+s)*o>t)return r;i+=s+n[r-1]}return n.length+1}function cp(n){const{scrollY:e,scrollX:t}=n.Canvas.getWindow();return{scroll:{top:e,left:t}}}function wy(n,e,t,s){const o=i=>n.em.logWarning(i);return s==="draggable"&&e.component.get(s)===!1?(o(`[${Vi}] The element is not ${s}`),!0):t.computedStyles.display!=="grid"?(o(`[${Vi}] The container does not have style display:grid`),!0):!1}function Jo(n,e,t={}){const s=ap(n,e),o=s==null?void 0:s.parent(),i=o==null?void 0:o.getEl();if(!o||!i)return!1;const{enableGrid:r}=t,l=window.getComputedStyle(i).display==="grid";return _t(r)?r({component:s,parent:o,isParentGrid:l}):l}const xa=n=>n.split(" ").map(e=>parseFloat(e));function dp(n,e){const t=n.ownerDocument.defaultView,s=e||t.getComputedStyle(n),o=s.gridArea.split("/").some(w=>isNaN(parseInt(w.trim()))),i={isComputed:o,raw:s.gridArea};if(!o)return{...i,row:{start:parseInt(s.gridRowStart),end:parseInt(s.gridRowEnd)},column:{start:parseInt(s.gridColumnStart),end:parseInt(s.gridColumnEnd)}};const r=n.parentElement,l=t.getComputedStyle(r),a=parseFloat(l.columnGap)||0,c=parseFloat(l.rowGap)||0,d=xa(l.gridTemplateColumns),p=xa(l.gridTemplateRows),u=parseFloat(l.paddingLeft)||0,h=parseFloat(l.paddingTop)||0,f=r.getBoundingClientRect(),m=n.getBoundingClientRect(),g=(w,S,x,k,E)=>{let M=1,P=k+E;for(let N=0;N<S.length;N++){const O=S[N],R=P+O;if(w>=P&&w<R)return M;P=R+x,M++}return-1},b=g(m.left,d,a,f.left,u),C=g(m.right-1,d,a,f.left,u)+1,y=g(m.top,p,c,f.top,h),v=g(m.bottom-1,p,c,f.top,h)+1;return{...i,row:{start:y,end:v},column:{start:b,end:C}}}function Cy(n){n.Commands.add(Bi,{stop(){},run(e,t,s={}){const o=ip({editor:e,component:s.target,type:"draggable"});if(!o){this.stopCommand();return}const{spot:i,target:r,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c,startScroll:d}=o;let{container:p}=o,u;new e.Utils.Dragger({doc:r.el.ownerDocument,onStart:()=>{u=setTimeout(()=>{rp({editor:e,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:i.attributes.spotEl,target:r,container:p}),p=xr(e,r.component)},10)},onEnd:(f,m,{cancelled:g})=>{clearTimeout(u),lp({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}=cp(e),{columns:b,rows:C,gap:y,offset:v,padding:w}=p,{offset:S,margin:x}=r,k=S.top-v.top-w.top-x.top+m-d.top+g.top,E=S.left-v.left-w.left-x.left+f-d.left+g.left,M=Math.min(ut(b,1,E,y.column,.5),b.length),P=Math.min(ut(C,1,k,y.row,.5),C.length),N=Math.min(ut(b,M,S.width,y.column)+1,b.length+1),O=Math.min(ut(C,P,S.height,y.row)+1,C.length+1);a.style.gridArea=`${P} / ${M} / ${O} / ${N}`,c.style.top=`${k+w.top}px`,c.style.left=`${E+w.left}px`}}).start(s.event)}})}function ky(n,e){const t=ip({editor:n,component:e.component,type:"resizable"});if(!t)return;const{onMove:s,onEnd:o}=e.options||{},{spot:i,target:r,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c}=t;let{container:d}=t,p="",u;return{onStart:h=>{p=h.target.dataset.gjsHandler||"",u=setTimeout(()=>{rp({editor:n,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:i.attributes.spotEl,target:r,container:d}),d=xr(n,r.component)},10),n.trigger("component:resize",{...r,type:"start"})},onEnd:(h,f)=>{const{startDim:m,rectDim:g}=f.resizer,b=JSON.stringify(m)===JSON.stringify(g);clearTimeout(u),lp({editor:n,shadowSnappedEl:a,shadowContainerEl:l,target:r,cancelled:b}),o==null||o(h,f)},onMove:(h,f)=>{const m=dp(a),g=r.margin.left,b=r.margin.top,C=r.margin.bottom,y=r.margin.right,{w:v,t:w,l:S,h:x}=f.resizer.rectDim,k={t:w-b,l:S-g,h:x+b+C,w:v+g+y};p.endsWith("l")&&(m.column.start=ut(d.columns,1,k.l-d.offset.left-d.padding.left,d.gap.column,.5)),p.startsWith("t")&&(m.row.start=ut(d.rows,1,k.t-d.offset.top-d.padding.top,d.gap.row,.5)),p.endsWith("r")&&(m.column.end=Math.max(ut(d.columns,m.column.start,k.w,d.gap.column,.5),m.column.start+1)),p.startsWith("b")&&(m.row.end=Math.max(ut(d.rows,m.row.start,k.h,d.gap.row,.5),m.row.start+1)),a.style.gridArea=`${m.row.start} / ${m.column.start} / ${m.row.end} / ${m.column.end}`,c.style.width=`${k.w}px`,c.style.height=`${k.h}px`,c.style.left=`${k.l-d.offset.left}px`,c.style.top=`${k.t-d.offset.top}px`,s==null||s(h,f)}}}const wa=["px","%","em","rem","vw","vh"],Ey=(n,e)=>{const t=n.Styles.getSectors().find(s=>!!s.getProperty(e));return{sector:t,property:t?t.getProperty(e):void 0}},Ty=(n,e)=>Ey(n,e),My=(n,{x:e,y:t,mergable:s}={})=>{const o={property:`${n}-x`,type:"integer",units:wa,...e},i={property:`${n}-y`,type:"integer",units:wa,...t};return{property:n,type:"composite",properties:[o,i],...s&&{fromStyle(r,{name:l,separator:a,property:c}){const[d,p]=c.getProperties(),[u,h]=(r[l]||"").split(a);return{[d.getId()]:r[d.getName()]||u||"",[p.getId()]:r[p.getName()]||h||u||""}},toStyle(r,{name:l,property:a}){const[c,d]=a.getProperties(),p=r[c.getId()],u=r[d.getId()];return{[l]:p===u?p:`${p} ${u}`}}}}},Hi={display:["grid"]};function Ay(n=""){const e=/^repeat\(\s*(\d+)\s*,\s*(.+)\s*\)$/i,t=/^minmax\(\s*(.+?)\s*,\s*(.+?)\s*\)$/i,s=n.match(e);if(!s)return null;const o=parseInt(s[1],10),i=s[2];let r=i,l=i;const a=i.match(t);return a&&(r=a[1],l=a[2]),{total:o,min:r===l?"":r,max:l}}function Py(n={}){let e="",t="",s="",o="";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),p=i(a),u=c.length,h=d.length,f=p.length;return u===4?(s=c[0],e=c[1],o=c[2],t=c[3]):u===3?(s=c[0],e=c[1],o=c[2]):u===2?(s=c[0],e=c[1]):u===1&&(s=c[0]),h===2?(e=d[0],t=d[1]):h===1&&(e=d[0]),f===2?(s=p[0],o=p[1]):f===1&&(s=p[0]),{columnStart:e,columnEnd:t,rowStart:s,rowEnd:o}}function Ca(n){const{property:e,label:t}=n,s="1",o="1fr";return{property:e,label:t,type:"composite",requires:Hi,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,p]=a.getProperties(),u=i[l],h=Ay(u),f=(h==null?void 0:h.max)??o;return{[c.id]:(h==null?void 0:h.total)??s,[d.id]:(h==null?void 0:h.min)??"",[p.id]:f===o?"":f}},toStyle(i,{name:r,property:l}){const[a,c,d]=l.getProperties(),p=i[a.id],u=i[c.id],h=i[d.id]||o,f=u&&h?`minmax(${u}, ${h})`:h;return{[r]:`repeat(${p||s}, ${f})`}}}}function Ny(n,e){if(!e.styleableGrid)return;const{property:t,...s}=Ty(n,"display");if(!t)return;const o=t.getOption("grid"),i=s.sector;o||t.addOption({id:"grid",label:"Grid"}),i.addProperty(Ca({label:"Columns",property:"grid-template-columns"}),{}),i.addProperty(Ca({label:"Rows",property:"grid-template-rows"}),{}),i.addProperty({id:"grid-gap",requires:Hi,...My("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:Hi,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=Py(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",p=r["grid-column-end"]||"auto";return{[l]:`${a} / ${d} / ${c} / ${p}`}}},{})}const Iy=function(n,e={}){const t={itemResizable:!0,...e},{Canvas:s,Commands:o,Components:i}=n,{itemResizable:r}=t,l=s.events,a=o.events,c=i.events,d=`${a.runBeforeCommand}tlb-move`,p=`${a.runBeforeCommand}resize`;let u;Cy(n);const h=({options:y})=>{Jo(n,y.target,t)&&(n.runCommand(Bi,{...y}),y.abort=!0)},f=y=>{const{options:v}=y;Jo(n,v.component,t)&&(v.options=Object.assign(v.options||{},ky(n,v)))},m=()=>{const y=s.getSpots({type:ns}).pop();if(!y)return;let v=y.attributes.spotEl;v||(v=document.createElement("div"),v.className=ps,y.set({spotEl:v})),Object.entries(y.getStyle()).forEach(([w,S])=>v.style.setProperty(w,S)),u==null||u.appendChild(v)},g=({spot:y})=>{const v=y.attributes.spotEl;y.type!==ns||!v||u==null||u.removeChild(v)};if(r){const y=v=>{const w=_t(r)?r({component:v}):r;return typeof w=="boolean"?w:{tl:!1,tc:!1,tr:!1,cl:!1,cr:!1,bl:!1,bc:!1,br:!1,...w}};n.on(c.resizeInit,v=>{const{component:w}=v;if(Jo(n,w,t)){const S=y(w);v.resizable=S}})}const b=[[d,h],[p,f],[l.spot,m],[l.spotRemove,g]];b.forEach(([y,v])=>{n.on(y,v)}),n.onReady(()=>{u=s.getSpotsEl(),gy(),Ny(n,t)});const C=()=>{delete n.Commands.commands[Bi],b.forEach(([y,v])=>{n.off(y,v)})};_({editor:n,licenseKey:t.licenseKey,plan:fy,pluginName:Vi,cleanup:C})},Oy=F(Iy),Ry="canvasScreenshot",Dy=H.startup;var pp=(n=>(n.screenshot="studioPlugin:screenshot",n))(pp||{});const Ly=async n=>await Pp([{id:"html-to-image",src:n}]),$y=async(n,e={},t={})=>{const{cdnScript:s}=t;if(!window.htmlToImage){if(!s)return;await Ly(s)}return new Promise((o,i)=>{(async()=>{try{const{canvasWidth:l,canvasHeight:a,width:c,height:d,type:p,quality:u,addOptions:h}=e,f={pixelRatio:1,width:c,height:d,canvasWidth:l,canvasHeight:a},m=(h==null?void 0:h(f))||f,b=await window.htmlToImage.toCanvas(n,m);b.toBlob(C=>{C?o({file:C,canvas:b}):i(new Error("Failed to create file from canvas"))},p,u)}catch(l){i(l)}})()})},Zo=pp.screenshot,zy=function(n,e={}){const{Commands:t,Canvas:s,Storage:o}=n,i=o.events.afterStore,r={cdnScript:"https://cdnjs.cloudflare.com/ajax/libs/html-to-image/1.11.13/html-to-image.min.js",...e};t.add(Zo,async(c,d,p)=>{const{el:u,...h}=p;return await $y(u,h,r)});const l=async()=>{var d;const c=s.getBody();if(!c)return n.log("Canvas element not found");try{const p=await n.runCommand(Zo,{el:c,canvasWidth:400,canvasHeight:225,width:1200,height:675,type:"image/jpeg"});(d=r.screenshotOnSave)==null||d.call(r,{...p,editor:n})}catch(p){console.error("Screenshot error",p)}};r.screenshotOnSave&&n.on(i,l);const a=()=>{delete t.commands[Zo],n.off(i,l)};_({editor:n,licenseKey:e.licenseKey,plan:Dy,pluginName:Ry,cleanup:a})},Vy=F(zy);var ze=(n=>(n.panelBlocks="panelBlocks",n.panelPagesLayers="panelPagesLayers",n.panelGlobalStyles="panelGlobalStyles",n.panelSidebarTabs="panelSidebarTabs",n.panelAssets="panelAssets",n.aiChatPanel="aiChatPanel",n.dataSourceManagerPanel="dataSourceManagerPanel",n))(ze||{});const up="sidebarButtonsTarget",Ms=(n,e)=>{const{id:t,icon:s,label:o,tooltip:i,className:r,skipSelfClose:l,removeLayouts:a,layoutComponent:c,layoutCommand:d}=n,{pluginOpts:p,breakpointProps:u}=e,h=t;return{id:hp(t),type:"button",icon:s,tooltip:o||i,className:r,editorEvents:{[`${Da.layoutToggleId}${h}`]:({fromEvent:f,setState:m,editor:g})=>{m({active:f.isOpen}),setTimeout(()=>g.refresh({tools:!0}),20)}},onClick:({editor:f,state:m})=>{var w;if(m.active&&l)return;const g=(d==null?void 0:d.placer)||{type:"static",layoutId:up},b={...g,skipCleanup:g.type==="static"},C=a||Object.keys(ze).filter(S=>S!==h);fp(f,{removeLayouts:C,layout:{placer:b}});const y={id:h,placer:g,header:(d==null?void 0:d.header)??{label:o,close:!l},layout:c,style:{width:280,height:"100%",borderRightWidth:1,...d==null?void 0:d.style}},v=((w=p==null?void 0:p.sidebarLayoutCommand)==null?void 0:w.call(p,{...u,layoutCommand:y,sidebarButtonProps:n}))||y;f.runCommand(W.layoutToggle,{...v})}}},hp=n=>`button__${n}`,fp=(n,e={})=>{(e.removeLayouts||Object.keys(ze)).forEach(s=>n.runCommand(W.layoutRemove,{id:s,layout:e.layout}))},mp=n=>{const e=(n==null?void 0:n.breakpointTablet)??1024,t=(n==null?void 0:n.breakpointMobile)??768,s={},o=[{id:ze.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:ze.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:ze.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:ze.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 C;const m=f.getSelected(),g={type:"image",src:h.src};let b;if(m!=null&&m.is("image"))return m.set("src",h.src);m&&f.Components.canMove(m,g)?b=m.append(g)[0]:m||(b=(C=f.getWrapper())==null?void 0:C.append(g)[0]),b&&f.select(b,{scroll:!0})}}}],i=[...o,{id:ze.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"}}],r={id:up,type:"column",className:"gs-cmp-layout-sidebar-target",style:{overflow:"hidden"}},l={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},a={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}},c=h=>({breakpoint:h,breakpointTablet:e,breakpointMobile:t}),d=(h,f,m)=>{const g=c(f),b={pluginOpts:n,breakpointProps:g},C=h.map(v=>{const w=Ms(v,b);return n!=null&&n.sidebarButton?n.sidebarButton({id:v.id,buttonIds:ze,buttonProps:w,sidebarButtonProps:v,...g,createSidebarButton:S=>Ms({...v,...S},b)}):w}).filter(Boolean);return(n!=null&&n.sidebarButtons?n==null?void 0:n.sidebarButtons({buttonIds:ze,sidebarButtons:C,...g,createSidebarButton:v=>Ms({...v,layoutCommand:{...m==null?void 0:m.layoutCommand,...v.layoutCommand}},b)}):C).filter(Boolean)},p=(h,f,m)=>{var C;const g=c(m),b={pluginOpts:n,breakpointProps:g};return((C=n==null?void 0:n.rootLayout)==null?void 0:C.call(n,{sidebarButtons:f,rootLayout:h,layoutSidebarLeft:l,layoutSidebarTarget:r,...g,createSidebarButton:y=>Ms({...y},b)}))??h};if(e){const h=d(i,e);s[e]=p({type:"row",style:{height:"100%"},children:[{...l,children:h},r,a]},h,e)}if(t){const h={placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}},f=i.map(g=>({...g,layoutCommand:h})),m=d(f,t,{layoutCommand:h});s[t]=p({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas",grow:!0},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:m}]},m,t)}const u=d(o,0);return{default:p({type:"row",style:{height:"100%"},children:[{...l,children:u},r,a,{type:"sidebarRight"}]},u,0),responsive:s}},ka="layoutSidebarButtons",By=H.free,Hy=function(n,e={}){const{Commands:t}=n,s=t.events,o={...e};(()=>{if(n.runCommand(W.layoutConfigGet)||o.skipLayoutConfig===!0)return;const l=mp(o);n.runCommand(W.layoutConfigSet,{...l})})(),t.add(`${ka}:toggleButton`,(r,l,a)=>{const c=document.getElementById(hp(a==null?void 0:a.id));c==null||c.click()}),n.on(`${s.runCommand}core:preview`,()=>{fp(n)}),_({editor:n,licenseKey:o.licenseKey,plan:By,pluginName:ka,cleanup:()=>{n.runCommand(W.layoutConfigSet)}})},gp=F(Hy);gp.createLayoutConfig=n=>mp(n);const wt="page-break";var Ae=(n=>(n.A5="a5",n.A5Portrait="a5-portrait",n.A4="a4",n.A3="a3",n.B5="b5",n.B4="b4",n.letter="letter",n.legal="legal",n.ledger="ledger",n))(Ae||{});function Fi(n,e){const s={mm:3.7795275590551185,cm:37.79527559055118,in:96,pt:1.3333333333333333,pc:16};return s[e]?n*s[e]:null}const Fy=(n,e)=>{const{name:t,id:s,width:o,height:i,unit:r}=n,{fixedHeight:l}=e,a=`${o}${r}`,c=`${i}${r}`;return{id:s||t.toLowerCase().replace(/\s/g,"-"),name:`${t} (${a} x ${c})`,sizeH:i,sizeW:o,sizeUnit:r,widthMedia:"",width:a,minHeight:l?"0":`${Fi(i,r)}px`,height:l?c:void 0}},_i="page-breaks",As="gjs-page-breaks-spot",Yo=n=>n.type===_i;function _y(n){const{Devices:e}=n,{height:t,minHeight:s}=e.getSelected().attributes,i=parseFloat(`${t&&t!=="auto"?t:s}`),r=n.getWrapper(),l=r==null?void 0:r.getEl(),a=[];if(!r||!l)return a;const c=l.getBoundingClientRect().height,p=r.findType(wt).map(h=>h.getEl()).filter(Boolean).map(h=>({top:h.offsetTop,height:h.offsetHeight}));let u=0;for(;u<c;){const h=p.find(f=>f.top>u&&f.top<u+i);h?(u=h.top+h.height,a.push(h.top)):(u+=i,u<c&&a.push(u))}return a}function Gy(n,e){const{Canvas:t}=n,s=t.events,o=n.events;let i;const r=()=>{Ui(`${Bs}preset-printable-spots`,`.${As} {
|
|
950
|
+
`,e.head.appendChild(s)};function ip(n){const{editor:e,type:t}=n,o=xy(e,n.component),s=xr(e,o.component);if(!wy(e,o,s,t))return{target:o,container:s,startScroll:cp(e).scroll,shadowContainerEl:document.createElement("div"),shadowSnappedEl:document.createElement("div"),shadowTargetEl:document.createElement("div"),spot:e.Canvas.addSpot({type:no,component:s.component})}}function rp(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),yy(s,l),by(t,r,l),vy(o,r),Sy(s,l.el),r.el.style.opacity="0";const d=a.getSpots().filter(p=>p.type!==no);e.em.stopDefault({preserveSelected:!0}),a.removeSpots(d),a.startAutoscroll(),a.getBody().classList.add(`${c}is__grabbing`)}function lp(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:no}),e.select(a)}function yy(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=np,r.style.gridArea=`${i+1} / ${s+1}`,o[s][i]=r,n.appendChild(r)}}return o}function by(n,e,t){return n.className=op,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 vy(n,e){const t=dp(e.el,e.computedStyles);return n.className=sp,n.style.gridArea=`${t.row.start} / ${t.column.start} / ${t.row.end} / ${t.column.end}`,n}function Sy(n,e){const t=window.getComputedStyle(e);n.className=my,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 ap(n,e){if(e){if(Array.isArray(e))return[...e].pop()}else return[...n.getSelectedAll()].pop();return e}function xy(n,e){const t=ap(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 xr(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 ut(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 cp(n){const{scrollY:e,scrollX:t}=n.Canvas.getWindow();return{scroll:{top:e,left:t}}}function wy(n,e,t,o){const s=i=>n.em.logWarning(i);return o==="draggable"&&e.component.get(o)===!1?(s(`[${Vi}] The element is not ${o}`),!0):t.computedStyles.display!=="grid"?(s(`[${Vi}] The container does not have style display:grid`),!0):!1}function Js(n,e,t={}){const o=ap(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 _t(r)?r({component:o,parent:s,isParentGrid:l}):l}const xa=n=>n.split(" ").map(e=>parseFloat(e));function dp(n,e){const t=n.ownerDocument.defaultView,o=e||t.getComputedStyle(n),s=o.gridArea.split("/").some(w=>isNaN(parseInt(w.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=xa(l.gridTemplateColumns),p=xa(l.gridTemplateRows),u=parseFloat(l.paddingLeft)||0,h=parseFloat(l.paddingTop)||0,f=r.getBoundingClientRect(),m=n.getBoundingClientRect(),g=(w,S,x,k,E)=>{let M=1,P=k+E;for(let N=0;N<S.length;N++){const I=S[N],R=P+I;if(w>=P&&w<R)return M;P=R+x,M++}return-1},b=g(m.left,d,a,f.left,u),C=g(m.right-1,d,a,f.left,u)+1,y=g(m.top,p,c,f.top,h),v=g(m.bottom-1,p,c,f.top,h)+1;return{...i,row:{start:y,end:v},column:{start:b,end:C}}}function Cy(n){n.Commands.add(Bi,{stop(){},run(e,t,o={}){const s=ip({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:p}=s,u;new e.Utils.Dragger({doc:r.el.ownerDocument,onStart:()=>{u=setTimeout(()=>{rp({editor:e,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:i.attributes.spotEl,target:r,container:p}),p=xr(e,r.component)},10)},onEnd:(f,m,{cancelled:g})=>{clearTimeout(u),lp({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}=cp(e),{columns:b,rows:C,gap:y,offset:v,padding:w}=p,{offset:S,margin:x}=r,k=S.top-v.top-w.top-x.top+m-d.top+g.top,E=S.left-v.left-w.left-x.left+f-d.left+g.left,M=Math.min(ut(b,1,E,y.column,.5),b.length),P=Math.min(ut(C,1,k,y.row,.5),C.length),N=Math.min(ut(b,M,S.width,y.column)+1,b.length+1),I=Math.min(ut(C,P,S.height,y.row)+1,C.length+1);a.style.gridArea=`${P} / ${M} / ${I} / ${N}`,c.style.top=`${k+w.top}px`,c.style.left=`${E+w.left}px`}}).start(o.event)}})}function ky(n,e){const t=ip({editor:n,component:e.component,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,p="",u;return{onStart:h=>{p=h.target.dataset.gjsHandler||"",u=setTimeout(()=>{rp({editor:n,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:i.attributes.spotEl,target:r,container:d}),d=xr(n,r.component)},10),n.trigger("component:resize",{...r,type:"start"})},onEnd:(h,f)=>{const{startDim:m,rectDim:g}=f.resizer,b=JSON.stringify(m)===JSON.stringify(g);clearTimeout(u),lp({editor:n,shadowSnappedEl:a,shadowContainerEl:l,target:r,cancelled:b}),s==null||s(h,f)},onMove:(h,f)=>{const m=dp(a),g=r.margin.left,b=r.margin.top,C=r.margin.bottom,y=r.margin.right,{w:v,t:w,l:S,h:x}=f.resizer.rectDim,k={t:w-b,l:S-g,h:x+b+C,w:v+g+y};p.endsWith("l")&&(m.column.start=ut(d.columns,1,k.l-d.offset.left-d.padding.left,d.gap.column,.5)),p.startsWith("t")&&(m.row.start=ut(d.rows,1,k.t-d.offset.top-d.padding.top,d.gap.row,.5)),p.endsWith("r")&&(m.column.end=Math.max(ut(d.columns,m.column.start,k.w,d.gap.column,.5),m.column.start+1)),p.startsWith("b")&&(m.row.end=Math.max(ut(d.rows,m.row.start,k.h,d.gap.row,.5),m.row.start+1)),a.style.gridArea=`${m.row.start} / ${m.column.start} / ${m.row.end} / ${m.column.end}`,c.style.width=`${k.w}px`,c.style.height=`${k.h}px`,c.style.left=`${k.l-d.offset.left}px`,c.style.top=`${k.t-d.offset.top}px`,o==null||o(h,f)}}}const wa=["px","%","em","rem","vw","vh"],Ey=(n,e)=>{const t=n.Styles.getSectors().find(o=>!!o.getProperty(e));return{sector:t,property:t?t.getProperty(e):void 0}},Ty=(n,e)=>Ey(n,e),My=(n,{x:e,y:t,mergable:o}={})=>{const s={property:`${n}-x`,type:"integer",units:wa,...e},i={property:`${n}-y`,type:"integer",units:wa,...t};return{property:n,type:"composite",properties:[s,i],...o&&{fromStyle(r,{name:l,separator:a,property:c}){const[d,p]=c.getProperties(),[u,h]=(r[l]||"").split(a);return{[d.getId()]:r[d.getName()]||u||"",[p.getId()]:r[p.getName()]||h||u||""}},toStyle(r,{name:l,property:a}){const[c,d]=a.getProperties(),p=r[c.getId()],u=r[d.getId()];return{[l]:p===u?p:`${p} ${u}`}}}}},Hi={display:["grid"]};function Ay(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 Py(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),p=i(a),u=c.length,h=d.length,f=p.length;return u===4?(o=c[0],e=c[1],s=c[2],t=c[3]):u===3?(o=c[0],e=c[1],s=c[2]):u===2?(o=c[0],e=c[1]):u===1&&(o=c[0]),h===2?(e=d[0],t=d[1]):h===1&&(e=d[0]),f===2?(o=p[0],s=p[1]):f===1&&(o=p[0]),{columnStart:e,columnEnd:t,rowStart:o,rowEnd:s}}function Ca(n){const{property:e,label:t}=n,o="1",s="1fr";return{property:e,label:t,type:"composite",requires:Hi,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,p]=a.getProperties(),u=i[l],h=Ay(u),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)??"",[p.id]:f===s?"":f}},toStyle(i,{name:r,property:l}){const[a,c,d]=l.getProperties(),p=i[a.id],u=i[c.id],h=i[d.id]||s,f=u&&h?`minmax(${u}, ${h})`:h;return{[r]:`repeat(${p||o}, ${f})`}}}}function Ny(n,e){if(!e.styleableGrid)return;const{property:t,...o}=Ty(n,"display");if(!t)return;const s=t.getOption("grid"),i=o.sector;s||t.addOption({id:"grid",label:"Grid"}),i.addProperty(Ca({label:"Columns",property:"grid-template-columns"}),{}),i.addProperty(Ca({label:"Rows",property:"grid-template-rows"}),{}),i.addProperty({id:"grid-gap",requires:Hi,...My("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:Hi,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=Py(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",p=r["grid-column-end"]||"auto";return{[l]:`${a} / ${d} / ${c} / ${p}`}}},{})}const Iy=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`,p=`${a.runBeforeCommand}resize`;let u;Cy(n);const h=({options:y})=>{Js(n,y.target,t)&&(n.runCommand(Bi,{...y}),y.abort=!0)},f=y=>{const{options:v}=y;Js(n,v.component,t)&&(v.options=Object.assign(v.options||{},ky(n,v)))},m=()=>{const y=o.getSpots({type:no}).pop();if(!y)return;let v=y.attributes.spotEl;v||(v=document.createElement("div"),v.className=po,y.set({spotEl:v})),Object.entries(y.getStyle()).forEach(([w,S])=>v.style.setProperty(w,S)),u==null||u.appendChild(v)},g=({spot:y})=>{const v=y.attributes.spotEl;y.type!==no||!v||u==null||u.removeChild(v)};if(r){const y=v=>{const w=_t(r)?r({component:v}):r;return typeof w=="boolean"?w:{tl:!1,tc:!1,tr:!1,cl:!1,cr:!1,bl:!1,bc:!1,br:!1,...w}};n.on(c.resizeInit,v=>{const{component:w}=v;if(Js(n,w,t)){const S=y(w);v.resizable=S}})}const b=[[d,h],[p,f],[l.spot,m],[l.spotRemove,g]];b.forEach(([y,v])=>{n.on(y,v)}),n.onReady(()=>{u=o.getSpotsEl(),gy(),Ny(n,t)});const C=()=>{delete n.Commands.commands[Bi],b.forEach(([y,v])=>{n.off(y,v)})};G({editor:n,licenseKey:t.licenseKey,plan:fy,pluginName:Vi,cleanup:C})},Oy=_(Iy),Ry="canvasScreenshot",Dy=H.startup;var pp=(n=>(n.screenshot="studioPlugin:screenshot",n))(pp||{});const Ly=async n=>await Pp([{id:"html-to-image",src:n}]),$y=async(n,e={},t={})=>{const{cdnScript:o}=t;if(!window.htmlToImage){if(!o)return;await Ly(o)}return new Promise((s,i)=>{(async()=>{try{const{canvasWidth:l,canvasHeight:a,width:c,height:d,type:p,quality:u,addOptions:h}=e,f={pixelRatio:1,width:c,height:d,canvasWidth:l,canvasHeight:a},m=(h==null?void 0:h(f))||f,b=await window.htmlToImage.toCanvas(n,m);b.toBlob(C=>{C?s({file:C,canvas:b}):i(new Error("Failed to create file from canvas"))},p,u)}catch(l){i(l)}})()})},Zs=pp.screenshot,zy=function(n,e={}){const{Commands:t,Canvas:o,Storage:s}=n,i=s.events.afterStore,r={cdnScript:"https://cdnjs.cloudflare.com/ajax/libs/html-to-image/1.11.13/html-to-image.min.js",...e};t.add(Zs,async(c,d,p)=>{const{el:u,...h}=p;return await $y(u,h,r)});const l=async()=>{var d;const c=o.getBody();if(!c)return n.log("Canvas element not found");try{const p=await n.runCommand(Zs,{el:c,canvasWidth:400,canvasHeight:225,width:1200,height:675,type:"image/jpeg"});(d=r.screenshotOnSave)==null||d.call(r,{...p,editor:n})}catch(p){console.error("Screenshot error",p)}};r.screenshotOnSave&&n.on(i,l);const a=()=>{delete t.commands[Zs],n.off(i,l)};G({editor:n,licenseKey:e.licenseKey,plan:Dy,pluginName:Ry,cleanup:a})},Vy=_(zy);var ze=(n=>(n.panelBlocks="panelBlocks",n.panelPagesLayers="panelPagesLayers",n.panelGlobalStyles="panelGlobalStyles",n.panelSidebarTabs="panelSidebarTabs",n.panelAssets="panelAssets",n.aiChatPanel="aiChatPanel",n.panelDataSources="panelDataSources",n))(ze||{});const up="sidebarButtonsTarget",Mo=(n,e)=>{const{id:t,icon:o,label:s,tooltip:i,className:r,skipSelfClose:l,removeLayouts:a,layoutComponent:c,layoutCommand:d}=n,{pluginOpts:p,breakpointProps:u}=e,h=t;return{id:hp(t),type:"button",icon:o,tooltip:s||i,className:r,editorEvents:{[`${Da.layoutToggleId}${h}`]:({fromEvent:f,setState:m,editor:g})=>{m({active:f.isOpen}),setTimeout(()=>g.refresh({tools:!0}),20)}},onClick:({editor:f,state:m})=>{var w;if(m.active&&l)return;const g=(d==null?void 0:d.placer)||{type:"static",layoutId:up},b={...g,skipCleanup:g.type==="static"},C=a||Object.keys(ze).filter(S=>S!==h);fp(f,{removeLayouts:C,layout:{placer:b}});const y={id:h,placer:g,header:(d==null?void 0:d.header)??{label:s,close:!l},layout:c,style:{width:280,height:"100%",borderRightWidth:1,...d==null?void 0:d.style}},v=((w=p==null?void 0:p.sidebarLayoutCommand)==null?void 0:w.call(p,{...u,layoutCommand:y,sidebarButtonProps:n}))||y;f.runCommand(W.layoutToggle,{...v})}}},hp=n=>`button__${n}`,fp=(n,e={})=>{(e.removeLayouts||Object.keys(ze)).forEach(o=>n.runCommand(W.layoutRemove,{id:o,layout:e.layout}))},mp=n=>{const e=(n==null?void 0:n.breakpointTablet)??1024,t=(n==null?void 0:n.breakpointMobile)??768,o={},s=[{id:ze.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:ze.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:ze.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:ze.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 C;const m=f.getSelected(),g={type:"image",src:h.src};let b;if(m!=null&&m.is("image"))return m.set("src",h.src);m&&f.Components.canMove(m,g)?b=m.append(g)[0]:m||(b=(C=f.getWrapper())==null?void 0:C.append(g)[0]),b&&f.select(b,{scroll:!0})}}}],i=[...s,{id:ze.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"}}],r={id:up,type:"column",className:"gs-cmp-layout-sidebar-target",style:{overflow:"hidden"}},l={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},a={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}},c=h=>({breakpoint:h,breakpointTablet:e,breakpointMobile:t}),d=(h,f,m)=>{const g=c(f),b={pluginOpts:n,breakpointProps:g},C=h.map(v=>{const w=Mo(v,b);return n!=null&&n.sidebarButton?n.sidebarButton({id:v.id,buttonIds:ze,buttonProps:w,sidebarButtonProps:v,...g,createSidebarButton:S=>Mo({...v,...S},b)}):w}).filter(Boolean);return(n!=null&&n.sidebarButtons?n==null?void 0:n.sidebarButtons({buttonIds:ze,sidebarButtons:C,...g,createSidebarButton:v=>Mo({...v,layoutCommand:{...m==null?void 0:m.layoutCommand,...v.layoutCommand}},b)}):C).filter(Boolean)},p=(h,f,m)=>{var C;const g=c(m),b={pluginOpts:n,breakpointProps:g};return((C=n==null?void 0:n.rootLayout)==null?void 0:C.call(n,{sidebarButtons:f,rootLayout:h,layoutSidebarLeft:l,layoutSidebarTarget:r,...g,createSidebarButton:y=>Mo({...y},b)}))??h};if(e){const h=d(i,e);o[e]=p({type:"row",style:{height:"100%"},children:[{...l,children:h},r,a]},h,e)}if(t){const h={placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}},f=i.map(g=>({...g,layoutCommand:h})),m=d(f,t,{layoutCommand:h});o[t]=p({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas",grow:!0},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:m}]},m,t)}const u=d(s,0);return{default:p({type:"row",style:{height:"100%"},children:[{...l,children:u},r,a,{type:"sidebarRight"}]},u,0),responsive:o}},ka="layoutSidebarButtons",By=H.free,Hy=function(n,e={}){const{Commands:t}=n,o=t.events,s={...e};(()=>{if(n.runCommand(W.layoutConfigGet)||s.skipLayoutConfig===!0)return;const l=mp(s);n.runCommand(W.layoutConfigSet,{...l})})(),t.add(`${ka}:toggleButton`,(r,l,a)=>{const c=document.getElementById(hp(a==null?void 0:a.id));c==null||c.click()}),n.on(`${o.runCommand}core:preview`,()=>{fp(n)}),G({editor:n,licenseKey:s.licenseKey,plan:By,pluginName:ka,cleanup:()=>{n.runCommand(W.layoutConfigSet)}})},gp=_(Hy);gp.createLayoutConfig=n=>mp(n);const wt="page-break";var Ae=(n=>(n.A5="a5",n.A5Portrait="a5-portrait",n.A4="a4",n.A3="a3",n.B5="b5",n.B4="b4",n.letter="letter",n.legal="legal",n.ledger="ledger",n))(Ae||{});function Fi(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 Fy=(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":`${Fi(i,r)}px`,height:l?c:void 0}},_i="page-breaks",Ao="gjs-page-breaks-spot",Ys=n=>n.type===_i;function _y(n){const{Devices:e}=n,{height:t,minHeight:o}=e.getSelected().attributes,i=parseFloat(`${t&&t!=="auto"?t:o}`),r=n.getWrapper(),l=r==null?void 0:r.getEl(),a=[];if(!r||!l)return a;const c=l.getBoundingClientRect().height,p=r.findType(wt).map(h=>h.getEl()).filter(Boolean).map(h=>({top:h.offsetTop,height:h.offsetHeight}));let u=0;for(;u<c;){const h=p.find(f=>f.top>u&&f.top<u+i);h?(u=h.top+h.height,a.push(h.top)):(u+=i,u<c&&a.push(u))}return a}function Gy(n,e){const{Canvas:t}=n,o=t.events,s=n.events;let i;const r=()=>{Ui(`${Bo}preset-printable-spots`,`.${Ao} {
|
|
951
951
|
position: absolute;
|
|
952
952
|
left: 0;
|
|
953
953
|
width: 100%;
|
|
954
954
|
border-top: 1px dashed var(--gs-theme-cl-cmp-bg2, var(--gjs-color-blue));
|
|
955
955
|
color: var(--gs-theme-cl-prm-txt, var(--gjs-font-color));
|
|
956
956
|
}
|
|
957
|
-
.${
|
|
957
|
+
.${Ao}::after {
|
|
958
958
|
background-color: var(--gs-theme-cl-cmp-bg1, var(--gjs-color-highlight));
|
|
959
959
|
content: attr(data-page-number);
|
|
960
960
|
display: block;
|
|
@@ -965,9 +965,9 @@
|
|
|
965
965
|
right: 0;
|
|
966
966
|
transform: translate(100%, -50%);
|
|
967
967
|
}
|
|
968
|
-
`,{target:window.document.head})},l=()=>{if(e.enablePageBreaksSpot===!1)return;const g={id:_i,type:_i,component:n.getWrapper()};return t.getSpots(g).pop()||t.addSpot(g)},a=({spot:g})=>{const{spotEl:b}=g.attributes;!
|
|
969
|
-
${!!parseFloat(`${
|
|
970
|
-
[data-gjs-type="wrapper"] { min-height: ${
|
|
968
|
+
`,{target:window.document.head})},l=()=>{if(e.enablePageBreaksSpot===!1)return;const g={id:_i,type:_i,component:n.getWrapper()};return t.getSpots(g).pop()||t.addSpot(g)},a=({spot:g})=>{const{spotEl:b}=g.attributes;!Ys(g)||!b||!i||i.removeChild(b)},c=({spot:g})=>{if(!Ys(g)||!i)return;let{spotEl:b}=g.attributes;b||(b=document.createElement("div"),b.className=`${Ao}__items`,g.set({spotEl:b})),i.appendChild(b)},d=({spot:g})=>{const{spotEl:b,pageBreaks:C=[]}=g.attributes;!Ys(g)||!b||!i||(Object.entries(g.getStyle()).forEach(([y,v])=>b.style.setProperty(y,v)),b.innerHTML="",C.forEach((y,v)=>{const w=document.createElement("div");w.setAttribute("data-page-number",`${v+2}`),w.className=Ao,w.style.top=`${y}px`,b.appendChild(w)}))},p=jn(()=>{if(n.em.destroyed)return;const g=l();g&&g.set({pageBreaks:_y(n),up:(g.attributes.up||0)+1})},150),u=jn(p,200),h=()=>{i=t.getSpotsEl(),l()},f=()=>{const g=l();g&&g.set({up:(g.attributes.up||0)+1})},m=[["component:input",p],["frame:scroll",f],[s.update,p],[o.spotAdd,c],[o.spotUpdate,d],[o.spotRemove,a],[o.frameLoadBody,h]];return m.forEach(([g,b])=>n.on(g,b)),n.onReady(()=>{r(),new ResizeObserver(f).observe(t.getElement().parentElement)}),()=>{m.forEach(([g,b])=>n.off(g,b)),p.clear(),u.clear()}}var Gi=(n=>(n.print="presetPrintable:print",n))(Gi||{});const Ea=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 Wy(n,e){const{Commands:t,Pages:o}=n;return t.add(Gi.print,async(s,i,r={})=>{const l={page:r.allPages?void 0:o.getSelected(),styles:"inline",optionsHtml:{exporter:null}},c=(await t.run(W.projectFiles,l)).filter(u=>u.filename.endsWith(".html")),d=c.map(u=>u.content).join('<div style="break-before: page;"></div>'),p=[];if(r.separatePrints)for(const u of c)p.push(await Ea(u));else p.push(await Ea({content:d,filename:"",mimeType:""}));for(const u of p){const h=u.contentWindow;h.focus(),h.print()}setTimeout(()=>p.forEach(u=>u.remove()),1e3)}),t.add("presetPrintable:exp",async s=>{await Qs("https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"),await Qs("https://cdn.jsdelivr.net/npm/jspdf@3.0.0/dist/jspdf.umd.min.js");const{Devices:i,Canvas:r}=s,{sizeW:l,sizeH:a,sizeUnit:c}=i.getSelected().attributes,d=r.getFrameEl().contentDocument,p="px",u=[Fi(l,c),Fi(a,c)],h=new window.jspdf.jsPDF({unit:p,format:u}),f=d.body;h.html(f,{callback:m=>m.save()})}),()=>{delete n.Commands.commands[Gi.print]}}function jy(n,e){const{blockPageBreak:t={}}=e,{Components:o,Blocks:s}=n,i="Page Break",r=`${Me}${wt}`;return o.addType(wt,{block:t&&{label:i,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:Fe(wt),model:{defaults:{name:i,classes:r,attributes:{[Re]:wt},emptyState:!0,stylable:!1,droppable:!1,draggable:qi("wrapper"),styles:`.${r} { break-before: page; }`,traits:[]}}}),()=>{o.removeType(wt),s.remove(wt)}}const qy="presetPrintable",Uy=H.free,Ky=function(n,e={}){var S;const t={selectedDevice:Ae.A4,...e},{Canvas:o,Devices:s,Blocks:i}=n,r=o.events,l=n.events,a=t.selectedDevice||s.getConfig().default,c=[{id:Ae.A5,name:"A5",width:148,height:210,unit:"mm"},{id:Ae.A5Portrait,name:"A5 Portrait",width:210,height:148,unit:"mm"},{id:Ae.A4,name:"A4",width:210,height:297,unit:"mm"},{id:Ae.A3,name:"A3",width:297,height:420,unit:"mm"},{id:Ae.B5,name:"B5",width:176,height:250,unit:"mm"},{id:Ae.B4,name:"B4",width:250,height:353,unit:"mm"},{id:Ae.letter,name:"Letter",width:8.5,height:11,unit:"in"},{id:Ae.legal,name:"Legal",width:8.5,height:14,unit:"in"},{id:Ae.ledger,name:"Ledger",width:11,height:17,unit:"in"}],p=(((S=t.devices)==null?void 0:S.call(t,{items:c}))||c).map(x=>Fy(x,t));s.devices.reset(p);const u=a&&s.get(a)||s.getAll().at(0);s.select(u),["map","video"].forEach(x=>i.remove(x));const f=(x={})=>{const k="page-rule",{rules:E}=n.Css,{width:M,height:P,minHeight:N}=s.getSelected().attributes,I=P&&P!=="auto"?P:N,R=E.where({id:k}).pop(),F=R||E.add({id:k,selectors:[],selectorsAdd:"@page"},{at:0});(x.fromDeviceChange||!R)&&F.addStyle({size:`${M} ${I}`,...!R&&{margin:"0"}})},m=(x,k={})=>{const E=x.document,{minHeight:M}=s.getSelected().attributes,N=`
|
|
969
|
+
${!!parseFloat(`${M}`)?`
|
|
970
|
+
[data-gjs-type="wrapper"] { min-height: ${M}; }
|
|
971
971
|
`:`
|
|
972
972
|
body {
|
|
973
973
|
overflow: hidden;
|
|
@@ -978,33 +978,33 @@
|
|
|
978
978
|
height: 100dvh;
|
|
979
979
|
}
|
|
980
980
|
`}
|
|
981
|
-
`;Ui(`${
|
|
982
|
-
const startIndex = parseInt(${
|
|
981
|
+
`;Ui(`${Bo}preset-printable`,N,{doc:E,target:E.head}),f(k)};n.on(r.frameLoadBody,x=>{const k=x.window;if(m(k),t.fixedHeight){const M=x.model.getComponent().getEl();M==null||M.addEventListener("scroll",P=>{const N=P.target;N.scrollTop>0&&N.scrollTo(0,0)})}}),n.on(s.events.select,()=>{var k;const x=(k=o.getFrameEl().contentDocument)==null?void 0:k.defaultView;x&&m(x,{fromDeviceChange:!0})});const g=()=>{const k=n.Css.getRules().filter(E=>E.selectorsToString()==="body").pop();k==null||k.addStyle({"margin-top":"","margin-right":"","margin-bottom":"","margin-left":"",margin:"0"})},b=[[l.projectLoad,g]];b.forEach(([x,k])=>n.on(x,k));const C=Gy(n,t),y=Wy(n),v=jy(n,t);n.onReady(()=>{n.UndoManager.clear()});const w=()=>{b.forEach(([x,k])=>n.off(x,k)),C(),y(),v()};n.on(l.destroy,w),G({editor:n,licenseKey:t.licenseKey,plan:Uy,pluginName:qy,cleanup:w})},Jy=_(Ky),Zy=n=>{const e=n;return e.logicalOperator==="and"||e.logicalOperator==="or"},yp=(n,e)=>(n.config.optsHtml={...n.config.optsHtml,exporter:e},()=>{n.config.optsHtml.exporter=void 0}),bp=(n,e)=>{const t=s=>{const{input:i}=s,{contains:r}=e;(!r||i.includes(r))&&(s.input=e.importer.import(i))},o=n.Parser.events.htmlBefore;return n.on(o,t),()=>{n.off(o,t)}};class Yy{getVariableSyntax({dataResolver:e}){const{defaultValue:t}=e,o=this.getFullPath(e),s=t?` || \`${t}\``:"";return`<%= ${o}${s} %>`}getCollectionStartSyntax({dataResolver:e}){const{collectionId:t,dataSource:o,startIndex:s,endIndex:i}=e,r=(o==null?void 0:o.path)||t||"",l=this._sanitizeVariableName(t);let a="";if(s!==void 0||i!==void 0){const c=s??0,d=i!==void 0?i:"";a=`.slice(${c}${d!==""?`, ${d}`:""})`}return`<% ${r}${a}.forEach(function(currentItem, index, arr) {
|
|
982
|
+
const startIndex = parseInt(${s??0}, 10);
|
|
983
983
|
const endIndex = startIndex + arr.length;
|
|
984
|
-
const ${l}={ currentItem, currentIndex: startIndex + index, remainingItems: endIndex - (startIndex + index)} %>`}_sanitizeVariableName(e){return e.replace(/[^a-zA-Z0-9_$]/g,"_")}getCollectionEndSyntax(){return"<% }) %>"}getConditionalStartSyntax({dataResolver:e}){return`<% if (${this._parseCondition(e.condition)}) { %>`}getConditionElseSyntax(){return"<% } else { %>"}getConditionalEndSyntax(){return"<% } %>"}getFullPath({collectionId:e,path:t,variableType:
|
|
984
|
+
const ${l}={ currentItem, currentIndex: startIndex + index, remainingItems: endIndex - (startIndex + index)} %>`}_sanitizeVariableName(e){return e.replace(/[^a-zA-Z0-9_$]/g,"_")}getCollectionEndSyntax(){return"<% }) %>"}getConditionalStartSyntax({dataResolver:e}){return`<% if (${this._parseCondition(e.condition)}) { %>`}getConditionElseSyntax(){return"<% } else { %>"}getConditionalEndSyntax(){return"<% } %>"}getFullPath({collectionId:e,path:t,variableType:o}){return(e?[this._sanitizeVariableName(e),o,t].filter(Boolean).join("."):t)||""}_parseCondition(e){if(!e)return"";if(Zy(e)){const t=e.statements.map(i=>this._parseCondition(i)),o=Xy[e.logicalOperator];let s=t.length>1?`(${t.join(`)${o}(`)})`:t[0];return e.logicalOperator==="xor"&&(s=`!!(${s})`),s}else{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.getFullPath(e):typeof e=="string"?`'${e.replace(/'/g,"\\'")}'`:String(e)}}const Xy={and:"&&",or:"||",xor:"^"},Qy=["===","==","!==","!=","<=",">=","<",">","&&","||"],eb={"===":"=","==":"=","!==":"!=","!=":"!=","<=":"<=",">=":">=","<":"<",">":">","&&":"&&","||":"||"};class tb{constructor(){this.messages=[],this.collectionStack=[]}import(e){this.messages=[],this.collectionStack=[];try{const t=this.parseEjsTemplate(e);return this.astToGrapesJS(t)}catch(t){return console.error("Error during import:",t),this.addMessage("error",`Error during import: ${t instanceof Error?t.message:String(t)}`),""}}parseEjsTemplate(e){const t=[];let o=0;for(;o<e.length;){const s=e.indexOf("<%",o);if(s===-1){o<e.length&&t.push(this.createAppendLiteral(e.slice(o)));break}s>o&&t.push(this.createAppendLiteral(e.slice(o,s)));const i=e.indexOf("%>",s);if(i===-1)throw new Error("Unclosed EJS tag");const r=e.slice(s+2,i).trim();if(o=i+2,r.startsWith("=")||r.startsWith("-")){const l=r.slice(1).trim();t.push(this.createAppendExpression(l))}else{if(r.startsWith("#"))continue;if(r.startsWith("if")){const l=this.parseIfStatement(r,e,o);t.push(l),o=l.endPos||o}else if(r.startsWith("for")){const l=this.parseForStatement(r,e,o);t.push(l),o=l.endPos||o}else{const l=r.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);if(l){const a=l[1],c=l[2],d=this.parseForEachStatement(a,c,e,o);t.push(d),o=d.endPos||o}else this.addMessage("info",`Unsupported scriptlet content: ${r}`)}}}return{type:"Program",body:t}}createAppendLiteral(e){return{type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"Identifier",name:"__append"},arguments:[{type:"Literal",value:e}]}}}createAppendExpression(e){return{type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"Identifier",name:"__append"},arguments:[this.parseJsExpression(e)]}}}parseIfStatement(e,t,o){const s=e.match(/if\s*\((.*)\)\s*\{?/);if(!s)throw new Error("Invalid if statement syntax");const i=this.parseJsExpression(s[1]),{body:r,endPos:l}=this.parseTemplateBlock(t,o);let a=null,c=l;const d=t.indexOf("<%",c);if(d===c){const p=t.indexOf("%>",d);if(p!==-1){const u=t.slice(d+2,p).trim(),h=p+2-d;if(u.startsWith("} else if")){c=d+h;const f=u.substring(u.indexOf("if")).trim(),m=this.parseIfStatement(f,t,c);a={type:"IfStatement",test:m.test,consequent:m.consequent,alternate:m.alternate},c=m.endPos}else if(u.startsWith("} else")){c=d+h;const{body:f,endPos:m}=this.parseTemplateBlock(t,c);a={type:"BlockStatement",body:f},c=m;const g=t.indexOf("<%",c),b=t.indexOf("%>",g);g===c&&t.slice(g+2,b).trim()==="}"&&(c=b+2)}else u==="}"&&(c=d+h)}}return{type:"IfStatement",test:i,consequent:{type:"BlockStatement",body:r},alternate:a,endPos:c}}parseForStatement(e,t,o){const s=e.match(/for\s*\((.*)\)\s*\{?/);if(!s)throw new Error("Invalid for statement syntax");const i=s[1].split("of");if(i.length!==2)throw new Error("Only for...of loops are supported");const r=i[0].trim().replace(/^let\s+|^const\s+|^var\s+/,""),l=i[1].trim(),{body:a,endPos:c}=this.parseTemplateBlock(t,o);return{type:"ForStatement",init:{type:"VariableDeclaration",kind:"let",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:r},init:this.parseJsExpression(l)}]},test:null,update:null,body:{type:"BlockStatement",body:a},endPos:(()=>{const d=t.indexOf("<%",c),p=t.indexOf("%>",d);return d===c&&t.slice(d+2,p).trim()==="}"?p+2:c})()}}parseForEachStatement(e,t,o,s){const{body:i,endPos:r}=this.parseTemplateBlock(o,s);return{type:"ForEachStatement",collection:this.parseJsExpression(e),itemIdentifier:{type:"Identifier",name:t},body:{type:"BlockStatement",body:i},endPos:(()=>{const l=o.indexOf("<%",r),a=o.indexOf("%>",l);return l===r&&o.slice(l+2,a).trim()==="}"?a+2:r})()}}parseTemplateBlock(e,t){const o=[];let s=t;for(;s<e.length;){const i=e.indexOf("<%",s);if(i===-1){s<e.length&&o.push(this.createAppendLiteral(e.slice(s))),s=e.length;break}i>s&&o.push(this.createAppendLiteral(e.slice(s,i)));const r=e.indexOf("%>",i);if(r===-1)throw new Error("Unclosed EJS tag within block");const l=e.slice(i+2,r).trim();if(l==="}"||l.startsWith("} else")){s=i;break}if(s=r+2,l.startsWith("=")||l.startsWith("-")){const a=l.slice(1).trim();o.push(this.createAppendExpression(a))}else{if(l.startsWith("#"))continue;if(l.startsWith("if")){const a=this.parseIfStatement(l,e,s);o.push(a),s=a.endPos||s}else if(l.startsWith("for")){const a=this.parseForStatement(l,e,s);o.push(a),s=a.endPos||s}else{const a=l.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);if(a){const c=a[1],d=a[2],p=this.parseForEachStatement(c,d,e,s);o.push(p),s=p.endPos||s}else this.addMessage("info",`Unsupported scriptlet content within block: ${l}`)}}}return{body:o,endPos:s}}parseJsExpression(e){if(/^(['"]).*\1$/.test(e))return{type:"Literal",value:e.slice(1,-1)};if(/^-?\d+$/.test(e))return{type:"Literal",value:parseInt(e,10)};if(/^-?\d+\.\d+$/.test(e))return{type:"Literal",value:parseFloat(e)};if(e==="true"||e==="false")return{type:"Literal",value:e==="true"};for(const s of Qy){const i=e.lastIndexOf(s);if(i>0&&e[i-1]!=="!"&&e[i-1]!=="="&&e[i-1]!=="<"&&e[i-1]!==">")return{type:s==="&&"||s==="||"?"LogicalExpression":"BinaryExpression",operator:eb[s],left:this.parseJsExpression(e.slice(0,i).trim()),right:this.parseJsExpression(e.slice(i+s.length).trim())}}const t=e.indexOf("."),o=e.indexOf("[");if(t>0&&(o===-1||t<o)||o>0&&(t===-1||o<t)){const s=t>0&&(o===-1||t<o)?t:o;let i,r,l=!1;if(s===t)i=e.slice(0,t),r={type:"Identifier",name:e.slice(t+1)},l=!1;else{i=e.slice(0,o);const a=e.indexOf("]",o);if(a===-1)throw new Error("Unclosed bracket in expression");const c=e.slice(o+1,a);r=/^(['"]).*\1$/.test(c)||/^-?\d+(\.\d+)?$/.test(c)?this.parseJsExpression(c):{type:"Identifier",name:c},l=!0}return{type:"MemberExpression",object:this.parseJsExpression(i),property:r,computed:l}}return{type:"Identifier",name:e}}astToGrapesJS(e){switch(e.type){case"Program":return this.handleProgram(e);case"VariableDeclaration":return this.handleVariableDeclaration(e);case"ExpressionStatement":return this.handleExpressionStatement(e);case"IfStatement":return this.handleIfStatement(e);case"ForStatement":return this.handleForStatement(e);case"ForEachStatement":return this.handleForEachStatement(e);case"BlockStatement":return this.handleBlockStatement(e);case"Literal":return this.handleLiteral(e);case"Identifier":return this.handleIdentifier(e);case"MemberExpression":return this.handleMemberExpression(e);case"BinaryExpression":return this.handleBinaryExpression(e);case"LogicalExpression":return this.handleLogicalExpression(e);case"CallExpression":return this.handleCallExpression(e);default:return this.addMessage("warning",`Unsupported node type: ${e.type}`),""}}handleProgram(e){let t="";for(const o of e.body)t+=this.astToGrapesJS(o);return t}handleVariableDeclaration(e){return""}handleExpressionStatement(e){return e.expression.type==="CallExpression"&&e.expression.callee.type==="Identifier"&&e.expression.callee.name==="__append"&&e.expression.arguments.length>0?this.astToGrapesJS(e.expression.arguments[0]):""}handleIfStatement(e){const t=this.getConditionExpression(e.test),o=this.astToGrapesJS(e.consequent);let s="";return e.alternate&&(s=this.astToGrapesJS(e.alternate)),`
|
|
985
985
|
<data-condition data-gjs-data-resolver='${JSON.stringify({condition:t})}'>
|
|
986
|
-
<data-condition-true-content>${
|
|
987
|
-
<data-condition-false-content>${
|
|
986
|
+
<data-condition-true-content>${o}</data-condition-true-content>
|
|
987
|
+
<data-condition-false-content>${s}</data-condition-false-content>
|
|
988
988
|
</data-condition>
|
|
989
|
-
`}handleForStatement(e){var l;if(((l=e.init)==null?void 0:l.type)!=="VariableDeclaration"||e.init.declarations.length===0)return this.addMessage("warning","Unsupported for loop init format"),"";const t=e.init.declarations[0];if(t.id.type!=="Identifier")return this.addMessage("warning","Unsupported for loop variable declaration id"),"";let
|
|
990
|
-
<data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:
|
|
989
|
+
`}handleForStatement(e){var l;if(((l=e.init)==null?void 0:l.type)!=="VariableDeclaration"||e.init.declarations.length===0)return this.addMessage("warning","Unsupported for loop init format"),"";const t=e.init.declarations[0];if(t.id.type!=="Identifier")return this.addMessage("warning","Unsupported for loop variable declaration id"),"";let o="";if(t.init)o=this.getExpressionString(t.init);else return this.addMessage("warning","For loop collection is undefined"),"";const s=t.id.name,i=s;this.collectionStack.push(s);const r=this.astToGrapesJS(e.body);return this.collectionStack.pop(),`
|
|
990
|
+
<data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:o},collectionId:i})}'>
|
|
991
991
|
<data-collection-item>
|
|
992
992
|
${r}
|
|
993
993
|
</data-collection-item>
|
|
994
994
|
</data-collection>
|
|
995
|
-
`}handleForEachStatement(e){const t=this.getExpressionString(e.collection),
|
|
996
|
-
<data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:t},collectionId:
|
|
995
|
+
`}handleForEachStatement(e){const t=this.getExpressionString(e.collection),o=e.itemIdentifier.name,s=o;this.collectionStack.push(o);const i=this.astToGrapesJS(e.body);return this.collectionStack.pop(),`
|
|
996
|
+
<data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:t},collectionId:s})}'>
|
|
997
997
|
<data-collection-item>
|
|
998
998
|
${i}
|
|
999
999
|
</data-collection-item>
|
|
1000
1000
|
</data-collection>
|
|
1001
|
-
`}handleBlockStatement(e){let t="";for(const
|
|
1001
|
+
`}handleBlockStatement(e){let t="";for(const o of e.body)t+=this.astToGrapesJS(o);return t}handleLiteral(e){return String(e.value??"")}handleIdentifier(e){let t={path:e.name};if(this.collectionStack.length>0){const o=this.collectionStack[this.collectionStack.length-1];e.name===o&&(t={collectionId:o,variableType:"currentItem"})}return`<data-variable data-gjs-data-resolver='${JSON.stringify(t)}'></data-variable>`}handleMemberExpression(e,t={}){let s={path:this.getExpressionString(e),...t};if(this.collectionStack.length>0){const i=this.collectionStack[this.collectionStack.length-1];let r=e;const l=[];for(;r.type==="MemberExpression";)r.property.type==="Identifier"&&!r.computed?l.unshift(r.property.name):r.property.type==="Literal"&&r.computed?l.unshift(String(r.property.value)):l.unshift(this.getExpressionString(r.property)),r=r.object;if(r.type==="Identifier"&&r.name===i){const a=l.join(".");s={...t,collectionId:i,variableType:"currentItem",path:a}}}return`<data-variable data-gjs-data-resolver='${JSON.stringify(s)}'></data-variable>`}handleBinaryExpression(e){return`${this.getExpressionString(e.left)} ${e.operator} ${this.getExpressionString(e.right)}`}handleLogicalExpression(e){return e.operator==="||"&&e.right.type==="Literal"?this.handleMemberExpression(e.left,{defaultValue:e.right.value}):`${this.getExpressionString(e.left)} ${e.operator} ${this.getExpressionString(e.right)}`}handleCallExpression(e){var t;if(e.callee.type==="Identifier"&&e.callee.name==="include"){const o=((t=e.arguments[0])==null?void 0:t.type)==="Literal"?String(e.arguments[0].value):"";return this.addMessage("info",`Partial includes are not fully supported: ${o}`),""}return""}getConditionExpression(e){if(e.type==="Identifier")return{logicalOperator:"and",statements:[{left:{type:"data-variable",path:e.name},operator:"isTruthy"}]};if(e.type==="MemberExpression"){let t=this.getExpressionString(e),o="isTruthy";return t.startsWith("!!")?(o="isTruthy",t=t.slice(2)):t.startsWith("!")&&(o="isFalsy",t=t.slice(1)),{logicalOperator:"and",statements:[{left:{type:"data-variable",path:t},operator:o}]}}if(e.type==="BinaryExpression"||e.type==="LogicalExpression"){const t=this.getConditionExpression(e.left),o=this.getConditionExpression(e.right);return`${t} ${e.operator} ${o}`}return e.type==="Literal"?typeof e.value=="string"?`'${e.value}'`:String(e.value??""):this.getExpressionString(e)}getExpressionString(e){switch(e.type){case"Identifier":return e.name;case"Literal":return String(e.value??"");case"MemberExpression":{const t=this.getExpressionString(e.object),o=this.getExpressionString(e.property);return e.computed?`${t}[${o}]`:`${t}.${o}`}case"BinaryExpression":{const t=this.getExpressionString(e.left),o=this.getExpressionString(e.right);return`${t} ${e.operator} ${o}`}case"LogicalExpression":{const t=this.getExpressionString(e.left),o=this.getExpressionString(e.right);return`${t} ${e.operator} ${o}`}default:return this.addMessage("warning",`Unsupported expression type for getExpressionString: ${e.type}`),""}}addMessage(e,t){this.messages.push({type:e,message:t})}}const nb="dataSourceEjs",ob=H.startup,sb=function(n,e={}){const t=yp(n,new Yy),o=bp(n,{contains:"<%",importer:new tb});G({editor:n,licenseKey:e.licenseKey,plan:ob,pluginName:nb,cleanup:()=>{t(),o()}})},ib=_(sb),vp={equals:"equals",isTruthy:"isTruthy",isFalsy:"isFalsy",isDefined:"isDefined",isNull:"isNull",isUndefined:"isUndefined",isArray:"isArray",isObject:"isObject",isString:"isString",isNumber:"isNumber",isBoolean:"isBoolean",isDefaultValue:"isDefaultValue"},rb={">":"numGt","<":"numLt",">=":"numGte","<=":"numLte","=":"numEq","!=":"numNeq"},lb={contains:"strContains",startsWith:"strStartsWith",endsWith:"strEndsWith",equalsIgnoreCase:"strEqualsIgnoreCase",trimEquals:"strTrimEquals"},ab={...vp,...rb,...lb};class cb{getHelperId(e){return ab[e]||e}getFullPath({collectionId:e,path:t}){let o=t;return e&&(o=[this._sanitizeVariableName(e),t].filter(Boolean).join(".")),o||""}getVariableSyntax({dataResolver:e}){const{defaultValue:t}=e,o=this.getFullPath(e);return t?`{{#if ${o}}}{{{${o}}}}{{else}}${t}{{/if}}`:`{{{${o}}}}`}getCollectionStartSyntax({dataResolver: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({dataResolver:e}){const t=e.condition;if(!t)return"";const o=t,s=t;if(s.statements&&s.logicalOperator==="and"||s.logicalOperator==="or"){const{statements:i}=s,r=s.logicalOperator,l=i.map(c=>this._parseCondition(c)).join(" ");return`{{#if ${i.length>1?`(${r} ${l})`:l}}}`}else return`{{#if ${this._parseCondition(o)}}}`}_parseCondition(e){if(!e)return"";const t=e,o=e;if(o.statements&&o.logicalOperator==="and"||o.logicalOperator==="or"){const{statements:s}=o,i=o.logicalOperator,r=o.statements.map(l=>this._parseCondition(l)).join(" ");return s.length>1?`(${i} ${r})`:r}else{const s=t.operator,i=this.getHelperId(s),r=this._parseValue(t.left),l=this._parseValue(t.right);return this.getExpressionStr(i,r,l)}}getExpressionStr(e,t,o){return vp[e]?e==="isTruthy"?t:e==="isFalsy"?`!${t}`:`${e} ${t}`:`(${e} ${t} ${o})`}_parseValue(e){return typeof e=="object"?this.getFullPath(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}}"}}class db{constructor(){this.messages=[],this.collectionStack=[]}import(e){this.messages=[],this.collectionStack=[];const t=this.parse(e);return this.astToGrapesJS(t)}parse(e){try{return wp.parse(e)}catch(t){if(t instanceof Error&&t.message.includes("Parse error")){const o=t.message.match(/line (\d+)/),s=o?parseInt(o[1]):0,i=t.message.match(/column (\d+)/),r=i?parseInt(i[1]):0;throw new Error(`Handlebars syntax error at line ${s}, column ${r}: ${t.message}`)}throw t}}astToGrapesJS(e){switch(e.type){case"Program":return this.handleProgram(e);case"ContentStatement":return this.handleContentStatement(e);case"MustacheStatement":return this.handleMustacheStatement(e);case"BlockStatement":return this.handleBlockStatement(e);case"PartialStatement":return this.handlePartialStatement(e);case"CommentStatement":return this.handleCommentStatement(e);case"ElementNode":return this.handleElementNode(e);case"TextNode":return this.handleTextNode(e);default:return this.addMessage("warning",`Unsupported node type: ${e.type}`,e.loc),""}}handleProgram(e){let t="";if(e.body)for(const o of e.body)t+=this.astToGrapesJS(o);return t}handleContentStatement(e){return e.value||""}handleMustacheStatement(e,t={}){const o=this.getExpressionString(e.path),s={...t};return this.collectionStack.length>0?this.processPathWithCollectionContext(o,s):s.path=o,`<data-variable data-gjs-data-resolver='${JSON.stringify(s)}'></data-variable>`}processPathWithCollectionContext(e,t){e.startsWith("@")?this.handleDirectCollectionReference(e,t):this.handleRelativePathReference(e,t)}handleDirectCollectionReference(e,t){if(this.isSpecialIterationVariable(e)){this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length-1],e,t);return}const[o,...s]=e.substring(1).split("/"),i=s.join(".");this.collectionStack.includes(o)?this.setCurrentItemResolver(o,i,t):this.handleParentReferenceFallback(e,t)}isSpecialIterationVariable(e){return["index","@index","key","@key"].includes(e)}setSpecialVariableResolver(e,t,o){o.collectionId=e;const s={index:"currentIndex","@index":"currentIndex",key:"currentKey","@key":"currentKey"};o.variableType=s[t]}setCurrentItemResolver(e,t,o){o.collectionId=e,o.variableType="currentItem",t&&(o.path=t)}handleRelativePathReference(e,t){const o=Wi(e),{parentLevel:s,remainingPathParts:i}=this.calculateParentLevel(o),r=i.join("."),l=this.collectionStack.length-1-s;l>=0&&l<this.collectionStack.length?this.resolveRelativePath(r,l,t):t.path=i.join(".")}calculateParentLevel(e){const t=this.collectionStack.findLastIndex(i=>i===e[0]);if(t!==-1)return{parentLevel:this.collectionStack.length-1-t,remainingPathParts:e.slice(1)};let o=0;const s=[...e];for(;s[0]==="..";)o++,s.shift();return{parentLevel:o,remainingPathParts:s}}resolveRelativePath(e,t,o){const s=this.collectionStack[t];o.collectionId=s,o.variableType="currentItem",e!=="this"&&(o.path=e.startsWith("this.")?e.split(".").slice(1).join("."):e)}handleParentReferenceFallback(e,t){const o=Wi(e),{parentLevel:s,remainingPathParts:i}=this.calculateParentLevel(o),r=i.join("."),l=this.collectionStack.length-1-s;l>=0&&l<this.collectionStack.length?this.resolveRelativePath(r,l,t):t.path=i.join(".")}handleBlockStatement(e){const t=e.path.original;switch(t){case"if":case"unless":return this.handleConditionalBlock(e,t);case"each":return this.handleEachBlock(e);default:return this.addMessage("warning",`Unsupported block helper: ${t}`,e.loc),this.handleGenericBlock(e)}}handleConditionalBlock(e,t){const i={logicalOperator:"and",statements:[{left:{type:"data-variable",path:this.getExpressionString(e.params[0])},operator:t==="unless"?"isFalsy":"isTruthy"}]},r=this.handleProgram(e.program),l=e.inverse?this.handleProgram(e.inverse):"";return`
|
|
1002
1002
|
<data-condition data-gjs-data-resolver='${JSON.stringify({condition:i})}'>
|
|
1003
1003
|
<data-condition-true-content>${r}</data-condition-true-content>
|
|
1004
1004
|
<data-condition-false-content>${l}</data-condition-false-content>
|
|
1005
1005
|
</data-condition>
|
|
1006
|
-
`}handleEachBlock(e){var i,r,l;const t=this.getExpressionString(e.params[0]);let
|
|
1007
|
-
<data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:t},collectionId:
|
|
1008
|
-
<data-collection-item>${
|
|
1006
|
+
`}handleEachBlock(e){var i,r,l;const t=this.getExpressionString(e.params[0]);let o;e.params.length>=3&&e.params[1]==="as"&&((i=e.params[2])==null?void 0:i.type)==="PathExpression"?o=e.params[2].original:(l=(r=e.program)==null?void 0:r.blockParams)!=null&&l.length?o=e.program.blockParams[0]:o=`collection-${Math.random().toString(36).substring(2,10)}`,this.collectionStack.push(o);const s=this.handleProgram(e.program);return this.collectionStack.pop(),`
|
|
1007
|
+
<data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:t},collectionId:o})}'>
|
|
1008
|
+
<data-collection-item>${s}</data-collection-item>
|
|
1009
1009
|
</data-collection>
|
|
1010
|
-
`}handleCommentStatement(e){return`<!--${e.value}-->`}handleElementNode(e){let t="";if(e.attributes)for(const o of e.attributes)o.value.type==="TextNode"?t+=` ${o.name}="${o.value.chars}"`:(this.addMessage("warning",`Complex attribute values not fully supported: ${o.name}`,e.loc),t+=` ${o.name}="${this.getExpressionString(o.value)}"`);let s="";if(e.children)for(const o of e.children)s+=this.astToGrapesJS(o);return`<${e.tag}${t}>${s}</${e.tag}>`}handleTextNode(e){return e.chars||""}handlePartialStatement(e){return this.addMessage("warning",`Partials are not fully supported: ${e.name.original}`,e.loc),`{{> ${e.name.original}}}`}handleGenericBlock(e){const t=this.handleProgram(e.program);return`<!-- Unsupported block: ${e.path.original} -->${t}`}getExpressionString(e){return e.type==="PathExpression"?e.original:e.type==="StringLiteral"?e.value:e.type==="NumberLiteral"?e.value.toString():e.type==="BooleanLiteral"?e.value?"true":"false":e.type==="SubExpression"?this.getExpressionString(e.params[0]):e.type==="Hash"?`{${e.pairs.map(s=>`${s.key}=${this.getExpressionString(s.value)}`).join(", ")}}`:(this.addMessage("warning",`Complex expression type not fully supported: ${e.type}`,e.loc),"")}addMessage(e,t,s){this.messages.push({type:e,message:t,location:s?{line:s.start.line,column:s.start.column}:void 0})}}const Wi=n=>{if(n==null||n==="")return[];if(n===".")return["this"];if(n===".."||n==="../")return[".."];if(n.startsWith("../")){const r=n.substring(3);return["..",...Wi(r)]}const e=[];let t=0,s=n.replace(/\[(?:(['"])(.*?)\1|([^\]]*))\]/g,(r,l,a,c)=>{const d=a!==void 0?a:c||"";return e[t]=d,`__HANDLEBARS_PLACEHOLDER_${t++}__`});s=s.replace(/\//g,".");const o=s.split("."),i=[];for(const r of o){const l=/^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(r);if(l){const a=parseInt(l[1],10);i.push(e[a])}else r!==""&&i.push(r)}return i},pb="dataSourceHandlebars",ub=H.startup,hb=function(n,e={}){const t=yp(n,new cb),s=bp(n,{contains:"{{",importer:new db});_({editor:n,licenseKey:e.licenseKey,plan:ub,pluginName:pb,cleanup:()=>{t(),s()}})},fb=F(hb),mb=n=>{const e={};for(const t of Object.keys(n)){let s=n[t];s&&(Array.isArray(s)?s=s.map(o=>o.toString()).join(","):s=s.toString(),e[t]=s)}return new URLSearchParams(e)},Ta="youtube-video",gb=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:s="high"}=n,o=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=mb(l);return`${c}?${d}`},i=l=>{var a,c,d;return((a=l[s])==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:Ta,customData:{thumbnailUrl:a,videoItem:l}}};return{id:"youtube",types:[Ta],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}),p={...c,...d};p.part?p.part.includes("snippet")||p.part.push("snippet"):p.part=["snippet"];const h=await(await fetch(o(p))).json();return(m=h.items)!=null&&m.length?{items:h.items.map(r),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}}]})}},yb={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},bb="youtubeAssetProvider",vb=H.startup,Sb=function(n,e){var c;const{skipVideoComponent:t,i18n:s={}}=e,o=gb(e);n.runCommand(W.assetProviderAdd,{provider:o});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:o.id,typeId:o.types[0],providers:[],types:[],select:p=>{n.Assets.close(),d.set({videoId:p.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})};!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){const[d,...p]=l.getYoutubeTraits.apply(this);return[d,{id:i,type:"button",label:n.I18n.t("youtubeAssetProvider.searchBtn"),command:()=>a(this)},...p]}},view:{events:()=>({dblclick:"onActive"}),onActive(){const{model:d}=this,p=d.get("provider")||"";p!=null&&p.startsWith("yt")&&a(d)}}}),n.I18n.addMessages({en:yb,...s}),_({editor:n,licenseKey:e.licenseKey,plan:vb,pluginName:bb,cleanup:()=>{n.runCommand(W.assetProviderRemove,{id:o.id}),!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){return l.getYoutubeTraits.apply(this).filter(d=>d.id!==i)}}})}})},xb=F(Sb),ss=n=>n.replaceAll('"',"").replaceAll("'",""),ji=n=>n.includes(",")?n:/\s/.test(n)?`'${ss(n)}'`:ss(n),Ma=(n,e,t)=>({family:n,variant:e,...t}),Sp=(n,e)=>{n=ji(n);const{menuVariant:t,variants:s}=e;return{family:n,familyLabel:ss(n),menuVariant:t&&Ma(ji(`menuFont-${ss(n)}`),"regular",t),variants:Object.assign({},...Object.entries(s).map(([o,i])=>({[o]:Ma(n,o,i)})))}},Aa=(n,e)=>{var l;const t=Sp(n.family,n),s=t.menuVariant??((l=Object.values(t.variants))==null?void 0:l[0]);if(!s)return"Arial, Helvetica, sans-serif";const{source:o,descriptors:i}=s,r=ss(s.family);if(!e){const a=new FontFace(r,`url("${o}")`,i),c=Array.from(document.fonts.values()).filter(d=>d.family===r);for(const d of c)document.fonts.delete(d);document.fonts.add(a),a.load().catch(()=>{})}return ji(r)},wb=n=>{const{family:e,menu:t,axes:s}=n,o=!!s,i=Object.assign({},...n.variants.map(r=>{var d,p;let l,a;if(o){const u=s.find(h=>h.tag==="wght");if(u){const{start:h,end:f}=u;l=`${h} ${f}`}}return l||(l=((d=r.match(/\d+/))==null?void 0:d[0])??"400"),a=((p=r.match(/[a-zA-Z]+/))==null?void 0:p[0])==="italic"?"italic":void 0,{[r]:{source:n.files[r],descriptors:{style:a,weight:l}}}}));return Sp(e,{menuVariant:{source:t},variants:i})},Cb=n=>({id:`${n.family}/${n.version}`,type:"font",src:n.menu,name:n.family,customData:{font:wb(n),needsLoading:!0}}),kb=n=>{const{font:e}=n.customData;return n.customData.needsLoading?(n.customData.needsLoading=!1,Aa(e)):Aa(e,!0)};let Nn;const Eb=n=>{const e=[];for(const t of Object.keys(n)){let s=n[t];s&&(Array.isArray(s)?e.push(...s.map(o=>[t,o.toString()])):(s=s.toString(),e.push([t,s])))}return new URLSearchParams(e)},Tb=n=>{const{apiKey:e,searchParams:t}=n,s=(o={})=>{const i="https://www.googleapis.com/webfonts/v1/webfonts",r=Eb(o);return`${i}?${r}`};return{id:"google-fonts",types:["font"],label:({editor:o})=>o.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var c;if(Nn)return Nn;const o={key:e,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},i=t==null?void 0:t(),r={...o,...i},a=await(await fetch(s(r))).json();return(c=a.items)!=null&&c.length?(Nn=a.items.map(Cb),Nn):[]},itemLayout:o=>{const i=Nn.find(l=>l.id===o.assetProps.id),r=kb(i);return{type:"column",onClick:()=>o.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"}}]}}}},Mb={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},Ab="googleFontsAssetProvider",Pb=H.startup,Nb=function(n,e){const{i18n:t={}}=e,s=Tb(e);n.runCommand(W.assetProviderAdd,{provider:s}),n.I18n.addMessages({en:Mb,...t}),_({editor:n,licenseKey:e.licenseKey,plan:Pb,pluginName:Ab,cleanup:()=>{n.runCommand(W.assetProviderRemove,{id:s.id})}})},Ib=F(Nb),Ob="canvasAbsoluteMode",Rb=H.startup,Db=(n,e,t)=>{var c,d;const s=t.enableAbsolute??(p=>p.hasAbsolute),i=(Array.isArray(e)?e:e?[e]:[...n.getSelectedAll()])[0],r=((d=(c=i==null?void 0:i.delegate)==null?void 0:c.move)==null?void 0:d.call(c,i))||i;if(!r)return;const l=r.getEl();return{result:_t(s)?s({component:r,hasAbsolute:!!l&&getComputedStyle(l).position==="absolute"}):!1,component:r,dmode:r.get("dmode")}};function Vs({guideMatched:n,canvasView:e}){var M;const t=n.guide.x===void 0?"y":"x";let s=0,o=0,i=0,r=0;const{guide:l,matched:a}=n,c=e.getElBoxRect(l.componentView.el),d=e.getElBoxRect(((M=a.componentView)==null?void 0:M.el)||a.componentEl),p=c.y,u=c.y+c.height,h=c.x,f=c.x+c.width,m=d.y,g=d.y+d.height,b=d.x,C=d.x+d.width,y=Math.max(0,p-g),v=Math.max(0,m-u),w=Math.max(0,h-C),S=Math.max(0,b-f),x=y>v,k=w>S,E=l.type;return t==="x"&&(E==="l"?(s=h,x?(o=g,i=y):(o=u,i=v)):E==="r"?(s=f,x?(o=g,i=y):(o=u,i=v)):E==="x"&&(s=h-(h-f)/2,x?(o=g,i=y):(o=u,i=v))),t==="y"&&(E==="t"?(o=p,k?(s=C,r=w):(s=f,r=S)):E==="b"?(o=u,k?(s=C,r=w):(s=f,r=S)):E==="y"&&(o=p-(p-u)/2,k?(s=C,r=w):(s=f,r=S))),{axis:t,x:s,y:o,width:r,height:i}}function Lb({guideMatched:n,component:e,canvasView:t}){const s=n.guide.x===void 0?"x":"y",{guide:o,matched:i}=n,r=o.type,l=i.type,a=t.getElementPos(o.componentView.el).rect,c=t.getElementPos(i.componentView.el).rect;if(s==="x"){const d=a.height,p=c.top,u=c.top+c.height;let h=0;r==="t"?l==="t"?h=p-d:l==="b"?h=u-d:l==="y"&&(h=p-d-(p-u)/2):r==="b"?l==="t"?h=p-d*2:l==="b"?h=u-d*2:l==="y"&&(h=p-d*2-(p-u)/2):r==="y"&&(l==="t"?h=p-d*1.5:l==="b"?h=u-d*1.5:l==="y"&&(h=p-d*1.5-(p-u)/2)),e.addStyle({top:`${h-5}px`},{partial:!0})}if(s==="y"){const d=a.width,p=c.left,u=c.left+c.width;let h=0;r==="l"?l==="l"?h=p:l==="r"?h=u:l==="x"&&(h=p-(p-u)/2):r==="r"?l==="l"?h=p-d:l==="r"?h=u-d:l==="x"&&(h=p-d-(p-u)/2):r==="x"&&(l==="l"?h=p-d/2:l==="r"&&(h=u-d/2)),e.addStyle({left:`${h}px`},{partial:!0})}}function xp({snapping:n,editor:e,props:t}){var P,N;const{command:s,guidesMatched:o}=t,i=t.component,r=i.getEl(),l=e.Canvas.getCanvasView(),{x:a,y:c}=n??{x:10,y:10},d=s.opts.event,p=d.clientX,u=d.clientY;if(!i.__lastSnappedPosition){const O=l.getElBoxRect(r),R=p-O.x,G=u-O.y;i.__lastSnappedPosition={left:O.x,top:O.y},i.__dragOffset={x:R,y:G}}const h=((P=i.__dragOffset)==null?void 0:P.x)||0,f=((N=i.__dragOffset)==null?void 0:N.y)||0,m=i.__lastSnappedPosition,g=p-m.left-h,b=u-m.top-f;let C=m.left,y=m.top;const v=o==null?void 0:o[0],w=(v==null?void 0:v.guide.type)==="l",S=(v==null?void 0:v.guide.type)==="x",x=(v==null?void 0:v.guide.type)==="r",k=(v==null?void 0:v.guide.type)==="t",E=(v==null?void 0:v.guide.type)==="b",M=(v==null?void 0:v.guide.type)==="y";if(v){const{x:O,y:R}=Vs({guideMatched:v,canvasView:l}),G=r.offsetWidth,ie=r.offsetHeight;w?C=O:x?C=O-G:S?C=O-G/2:k?y=R:E?y=R-ie:M&&(y=R-ie/2),i.__lastSnappedGuideMatched=v}else Math.abs(g)>=a&&(C=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:`${C}px`,top:`${y}px`},{partial:!0}),i.__lastSnappedPosition={left:C,top:y},{x:C,y,guideMatched:i.__lastSnappedGuideMatched}}function $b({snapping:n,props:e,editor:t}){const{x:s,y:o}=xp({snapping:n,props:e,editor:t}),i=e.component;i.addStyle({left:`${s}px`,top:`${o}px`}),delete i.__lastSnappedPosition,delete i.__lastSnappedGuideMatched}const zb="core:component-drag",Vb="studio:setDragAbsolute",Bb="dmode:start",Pa="dmode:move",Na="dmode:end",Xo="dragAbsolute",Hb="select",Fb="hover",_b="spacing",Gb=function(n,e={}){const{Commands:t}=n,s=t.events,o=t.getConfig().defaultOptions??{},i=`${s.runBeforeCommand}tlb-move`;o[zb]={run:x=>({...x,skipGuidesRender:!0})};const{snapping:r,locking:l,globalAbsolute:a=!0}=e;a&&n.setDragMode("absolute");const c=!!(r!=null&&r.x||r!=null&&r.y),d=!!(l!=null&&l.x||l!=null&&l.y),{Canvas:p}=n;let u=null;const h=x=>{const{component:k,guidesMatched:E,command:M}=x,P=k.view,N=n.Canvas.getCanvasView(),O=k.getEl();let R=E.map(re=>re.matched.componentEl),G=E.map(re=>Vs({guideMatched:re,canvasView:N}));if(c){const{guideMatched:re}=xp({snapping:r,props:x,editor:n});re?(R=[re.matched.componentEl],G=[Vs({guideMatched:re,canvasView:N})]):(R=[],G=[])}if(d)if(M.opts.event.shiftKey)if(!u)u=E[0];else{const je=u,ye=je.guide.x===void 0?"x":"y";(ye==="x"&&(l==null?void 0:l.x)||ye==="y"&&(l==null?void 0:l.y))&&(Lb({guideMatched:je,component:k,canvasView:N}),R=[je.matched.componentEl],G=[Vs({guideMatched:je,canvasView:N})])}else u=null;const ie={id:Xo,type:Xo,component:k,componentView:P,originComponent:O,matchedComponents:R,originMatchedDistances:G};p.addSpot(ie)},f=({enabled:x})=>{n.runCommand(Vb,{enabled:x})},m=({type:x})=>{p.removeSpots({type:x})},g=()=>{m({type:Hb}),m({type:Fb}),m({type:_b})},b=x=>{f({enabled:!0}),h(x),g()},C=x=>{h(x),g()},y=x=>{m({type:Xo}),c&&$b({snapping:r,props:x,editor:n}),f({enabled:!1})},S=[[Bb,x=>{b(x),n.on(Pa,C);const k=()=>{y(x),n.off(Pa,C),n.off(Na,k)};n.on(Na,k)}],[i,x=>{if(a)return;const k=x.options.target,E=Db(n,k,e);E!=null&&E.result&&!E.dmode&&(x.options.mode="absolute")}]];S.forEach(([x,k])=>n.on(x,k)),_({editor:n,licenseKey:e.licenseKey,plan:Rb,pluginName:Ob,cleanup:()=>{f({enabled:!1}),S.forEach(([x,k])=>n.off(x,k))}})},Wb=F(Gb);exports.accordionComponent=Eh;exports.animationComponent=sf;exports.canvasAbsoluteMode=Wb;exports.canvasEmptyState=ay;exports.canvasFullSize=hy;exports.canvasGridMode=Oy;exports.canvasScreenshot=Vy;exports.dataSourceEjs=ib;exports.dataSourceHandlebars=fb;exports.dialogComponent=Gp;exports.flexComponent=Uh;exports.fsLightboxComponent=_u;exports.googleFontsAssetProvider=Ib;exports.iconifyComponent=su;exports.layoutSidebarButtons=gp;exports.lightGalleryComponent=Qu;exports.listPagesComponent=zu;exports.presetPrintable=Jy;exports.rteProseMirror=oy;exports.rteTinyMce=vf;exports.shapeDividerComponent=af;exports.swiperComponent=mh;exports.tableComponent=Pu;exports.youtubeAssetProvider=xb;
|
|
1010
|
+
`}handleCommentStatement(e){return`<!--${e.value}-->`}handleElementNode(e){let t="";if(e.attributes)for(const s of e.attributes)s.value.type==="TextNode"?t+=` ${s.name}="${s.value.chars}"`:(this.addMessage("warning",`Complex attribute values not fully supported: ${s.name}`,e.loc),t+=` ${s.name}="${this.getExpressionString(s.value)}"`);let o="";if(e.children)for(const s of e.children)o+=this.astToGrapesJS(s);return`<${e.tag}${t}>${o}</${e.tag}>`}handleTextNode(e){return e.chars||""}handlePartialStatement(e){return this.addMessage("warning",`Partials are not fully supported: ${e.name.original}`,e.loc),`{{> ${e.name.original}}}`}handleGenericBlock(e){const t=this.handleProgram(e.program);return`<!-- Unsupported block: ${e.path.original} -->${t}`}getExpressionString(e){return e.type==="PathExpression"?e.original:e.type==="StringLiteral"?e.value:e.type==="NumberLiteral"?e.value.toString():e.type==="BooleanLiteral"?e.value?"true":"false":e.type==="SubExpression"?this.getExpressionString(e.params[0]):e.type==="Hash"?`{${e.pairs.map(o=>`${o.key}=${this.getExpressionString(o.value)}`).join(", ")}}`:(this.addMessage("warning",`Complex expression type not fully supported: ${e.type}`,e.loc),"")}addMessage(e,t,o){this.messages.push({type:e,message:t,location:o?{line:o.start.line,column:o.start.column}:void 0})}}const Wi=n=>{if(n==null||n==="")return[];if(n===".")return["this"];if(n===".."||n==="../")return[".."];if(n.startsWith("../")){const r=n.substring(3);return["..",...Wi(r)]}const e=[];let t=0,o=n.replace(/\[(?:(['"])(.*?)\1|([^\]]*))\]/g,(r,l,a,c)=>{const d=a!==void 0?a:c||"";return e[t]=d,`__HANDLEBARS_PLACEHOLDER_${t++}__`});o=o.replace(/\//g,".");const s=o.split("."),i=[];for(const r of s){const l=/^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(r);if(l){const a=parseInt(l[1],10);i.push(e[a])}else r!==""&&i.push(r)}return i},pb="dataSourceHandlebars",ub=H.startup,hb=function(n,e={}){const t=yp(n,new cb),o=bp(n,{contains:"{{",importer:new db});G({editor:n,licenseKey:e.licenseKey,plan:ub,pluginName:pb,cleanup:()=>{t(),o()}})},fb=_(hb),mb=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)},Ta="youtube-video",gb=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:o="high"}=n,s=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=mb(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:Ta,customData:{thumbnailUrl:a,videoItem:l}}};return{id:"youtube",types:[Ta],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}),p={...c,...d};p.part?p.part.includes("snippet")||p.part.push("snippet"):p.part=["snippet"];const h=await(await fetch(s(p))).json();return(m=h.items)!=null&&m.length?{items:h.items.map(r),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}}]})}},yb={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},bb="youtubeAssetProvider",vb=H.startup,Sb=function(n,e){var c;const{skipVideoComponent:t,i18n:o={}}=e,s=gb(e);n.runCommand(W.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,typeId:s.types[0],providers:[],types:[],select:p=>{n.Assets.close(),d.set({videoId:p.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})};!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){const[d,...p]=l.getYoutubeTraits.apply(this);return[d,{id:i,type:"button",label:n.I18n.t("youtubeAssetProvider.searchBtn"),command:()=>a(this)},...p]}},view:{events:()=>({dblclick:"onActive"}),onActive(){const{model:d}=this,p=d.get("provider")||"";p!=null&&p.startsWith("yt")&&a(d)}}}),n.I18n.addMessages({en:yb,...o}),G({editor:n,licenseKey:e.licenseKey,plan:vb,pluginName:bb,cleanup:()=>{n.runCommand(W.assetProviderRemove,{id:s.id}),!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){return l.getYoutubeTraits.apply(this).filter(d=>d.id!==i)}}})}})},xb=_(Sb),oo=n=>n.replaceAll('"',"").replaceAll("'",""),ji=n=>n.includes(",")?n:/\s/.test(n)?`'${oo(n)}'`:oo(n),Ma=(n,e,t)=>({family:n,variant:e,...t}),Sp=(n,e)=>{n=ji(n);const{menuVariant:t,variants:o}=e;return{family:n,familyLabel:oo(n),menuVariant:t&&Ma(ji(`menuFont-${oo(n)}`),"regular",t),variants:Object.assign({},...Object.entries(o).map(([s,i])=>({[s]:Ma(n,s,i)})))}},Aa=(n,e)=>{var l;const t=Sp(n.family,n),o=t.menuVariant??((l=Object.values(t.variants))==null?void 0:l[0]);if(!o)return"Arial, Helvetica, sans-serif";const{source:s,descriptors:i}=o,r=oo(o.family);if(!e){const a=new FontFace(r,`url("${s}")`,i),c=Array.from(document.fonts.values()).filter(d=>d.family===r);for(const d of c)document.fonts.delete(d);document.fonts.add(a),a.load().catch(()=>{})}return ji(r)},wb=n=>{const{family:e,menu:t,axes:o}=n,s=!!o,i=Object.assign({},...n.variants.map(r=>{var d,p;let l,a;if(s){const u=o.find(h=>h.tag==="wght");if(u){const{start:h,end:f}=u;l=`${h} ${f}`}}return l||(l=((d=r.match(/\d+/))==null?void 0:d[0])??"400"),a=((p=r.match(/[a-zA-Z]+/))==null?void 0:p[0])==="italic"?"italic":void 0,{[r]:{source:n.files[r],descriptors:{style:a,weight:l}}}}));return Sp(e,{menuVariant:{source:t},variants:i})},Cb=n=>({id:`${n.family}/${n.version}`,type:"font",src:n.menu,name:n.family,customData:{font:wb(n),needsLoading:!0}}),kb=n=>{const{font:e}=n.customData;return n.customData.needsLoading?(n.customData.needsLoading=!1,Aa(e)):Aa(e,!0)};let Nn;const Eb=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)},Tb=n=>{const{apiKey:e,searchParams:t}=n,o=(s={})=>{const i="https://www.googleapis.com/webfonts/v1/webfonts",r=Eb(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(Nn)return Nn;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?(Nn=a.items.map(Cb),Nn):[]},itemLayout:s=>{const i=Nn.find(l=>l.id===s.assetProps.id),r=kb(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"}}]}}}},Mb={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},Ab="googleFontsAssetProvider",Pb=H.startup,Nb=function(n,e){const{i18n:t={}}=e,o=Tb(e);n.runCommand(W.assetProviderAdd,{provider:o}),n.I18n.addMessages({en:Mb,...t}),G({editor:n,licenseKey:e.licenseKey,plan:Pb,pluginName:Ab,cleanup:()=>{n.runCommand(W.assetProviderRemove,{id:o.id})}})},Ib=_(Nb),Ob="canvasAbsoluteMode",Rb=H.startup,Db=(n,e,t)=>{var c,d;const o=t.enableAbsolute??(p=>p.hasAbsolute),i=(Array.isArray(e)?e:e?[e]:[...n.getSelectedAll()])[0],r=((d=(c=i==null?void 0:i.delegate)==null?void 0:c.move)==null?void 0:d.call(c,i))||i;if(!r)return;const l=r.getEl();return{result:_t(o)?o({component:r,hasAbsolute:!!l&&getComputedStyle(l).position==="absolute"}):!1,component:r,dmode:r.get("dmode")}};function Vo({guideMatched:n,canvasView:e}){var M;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(((M=a.componentView)==null?void 0:M.el)||a.componentEl),p=c.y,u=c.y+c.height,h=c.x,f=c.x+c.width,m=d.y,g=d.y+d.height,b=d.x,C=d.x+d.width,y=Math.max(0,p-g),v=Math.max(0,m-u),w=Math.max(0,h-C),S=Math.max(0,b-f),x=y>v,k=w>S,E=l.type;return t==="x"&&(E==="l"?(o=h,x?(s=g,i=y):(s=u,i=v)):E==="r"?(o=f,x?(s=g,i=y):(s=u,i=v)):E==="x"&&(o=h-(h-f)/2,x?(s=g,i=y):(s=u,i=v))),t==="y"&&(E==="t"?(s=p,k?(o=C,r=w):(o=f,r=S)):E==="b"?(s=u,k?(o=C,r=w):(o=f,r=S)):E==="y"&&(s=p-(p-u)/2,k?(o=C,r=w):(o=f,r=S))),{axis:t,x:o,y:s,width:r,height:i}}function Lb({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,p=c.top,u=c.top+c.height;let h=0;r==="t"?l==="t"?h=p-d:l==="b"?h=u-d:l==="y"&&(h=p-d-(p-u)/2):r==="b"?l==="t"?h=p-d*2:l==="b"?h=u-d*2:l==="y"&&(h=p-d*2-(p-u)/2):r==="y"&&(l==="t"?h=p-d*1.5:l==="b"?h=u-d*1.5:l==="y"&&(h=p-d*1.5-(p-u)/2)),e.addStyle({top:`${h-5}px`},{partial:!0})}if(o==="y"){const d=a.width,p=c.left,u=c.left+c.width;let h=0;r==="l"?l==="l"?h=p:l==="r"?h=u:l==="x"&&(h=p-(p-u)/2):r==="r"?l==="l"?h=p-d:l==="r"?h=u-d:l==="x"&&(h=p-d-(p-u)/2):r==="x"&&(l==="l"?h=p-d/2:l==="r"&&(h=u-d/2)),e.addStyle({left:`${h}px`},{partial:!0})}}function xp({snapping:n,editor:e,props:t}){var P,N;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,p=d.clientX,u=d.clientY;if(!i.__lastSnappedPosition){const I=l.getElBoxRect(r),R=p-I.x,F=u-I.y;i.__lastSnappedPosition={left:I.x,top:I.y},i.__dragOffset={x:R,y:F}}const h=((P=i.__dragOffset)==null?void 0:P.x)||0,f=((N=i.__dragOffset)==null?void 0:N.y)||0,m=i.__lastSnappedPosition,g=p-m.left-h,b=u-m.top-f;let C=m.left,y=m.top;const v=s==null?void 0:s[0],w=(v==null?void 0:v.guide.type)==="l",S=(v==null?void 0:v.guide.type)==="x",x=(v==null?void 0:v.guide.type)==="r",k=(v==null?void 0:v.guide.type)==="t",E=(v==null?void 0:v.guide.type)==="b",M=(v==null?void 0:v.guide.type)==="y";if(v){const{x:I,y:R}=Vo({guideMatched:v,canvasView:l}),F=r.offsetWidth,ie=r.offsetHeight;w?C=I:x?C=I-F:S?C=I-F/2:k?y=R:E?y=R-ie:M&&(y=R-ie/2),i.__lastSnappedGuideMatched=v}else Math.abs(g)>=a&&(C=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:`${C}px`,top:`${y}px`},{partial:!0}),i.__lastSnappedPosition={left:C,top:y},{x:C,y,guideMatched:i.__lastSnappedGuideMatched}}function $b({snapping:n,props:e,editor:t}){const{x:o,y:s}=xp({snapping:n,props:e,editor:t}),i=e.component;i.addStyle({left:`${o}px`,top:`${s}px`}),delete i.__lastSnappedPosition,delete i.__lastSnappedGuideMatched}const zb="core:component-drag",Vb="studio:setDragAbsolute",Bb="dmode:start",Pa="dmode:move",Na="dmode:end",Xs="dragAbsolute",Hb="select",Fb="hover",_b="spacing",Gb=function(n,e={}){const{Commands:t}=n,o=t.events,s=t.getConfig().defaultOptions??{},i=`${o.runBeforeCommand}tlb-move`;s[zb]={run:x=>({...x,skipGuidesRender:!0})};const{snapping:r,locking:l,globalAbsolute:a=!0}=e;a&&n.setDragMode("absolute");const c=!!(r!=null&&r.x||r!=null&&r.y),d=!!(l!=null&&l.x||l!=null&&l.y),{Canvas:p}=n;let u=null;const h=x=>{const{component:k,guidesMatched:E,command:M}=x,P=k.view,N=n.Canvas.getCanvasView(),I=k.getEl();let R=E.map(re=>re.matched.componentEl),F=E.map(re=>Vo({guideMatched:re,canvasView:N}));if(c){const{guideMatched:re}=xp({snapping:r,props:x,editor:n});re?(R=[re.matched.componentEl],F=[Vo({guideMatched:re,canvasView:N})]):(R=[],F=[])}if(d)if(M.opts.event.shiftKey)if(!u)u=E[0];else{const je=u,ye=je.guide.x===void 0?"x":"y";(ye==="x"&&(l==null?void 0:l.x)||ye==="y"&&(l==null?void 0:l.y))&&(Lb({guideMatched:je,component:k,canvasView:N}),R=[je.matched.componentEl],F=[Vo({guideMatched:je,canvasView:N})])}else u=null;const ie={id:Xs,type:Xs,component:k,componentView:P,originComponent:I,matchedComponents:R,originMatchedDistances:F};p.addSpot(ie)},f=({enabled:x})=>{n.runCommand(Vb,{enabled:x})},m=({type:x})=>{p.removeSpots({type:x})},g=()=>{m({type:Hb}),m({type:Fb}),m({type:_b})},b=x=>{f({enabled:!0}),h(x),g()},C=x=>{h(x),g()},y=x=>{m({type:Xs}),c&&$b({snapping:r,props:x,editor:n}),f({enabled:!1})},S=[[Bb,x=>{b(x),n.on(Pa,C);const k=()=>{y(x),n.off(Pa,C),n.off(Na,k)};n.on(Na,k)}],[i,x=>{if(a)return;const k=x.options.target,E=Db(n,k,e);E!=null&&E.result&&!E.dmode&&(x.options.mode="absolute")}]];S.forEach(([x,k])=>n.on(x,k)),G({editor:n,licenseKey:e.licenseKey,plan:Rb,pluginName:Ob,cleanup:()=>{f({enabled:!1}),S.forEach(([x,k])=>n.off(x,k))}})},Wb=_(Gb);exports.accordionComponent=Eh;exports.animationComponent=of;exports.canvasAbsoluteMode=Wb;exports.canvasEmptyState=ay;exports.canvasFullSize=hy;exports.canvasGridMode=Oy;exports.canvasScreenshot=Vy;exports.dataSourceEjs=ib;exports.dataSourceHandlebars=fb;exports.dialogComponent=Gp;exports.flexComponent=Uh;exports.fsLightboxComponent=_u;exports.googleFontsAssetProvider=Ib;exports.iconifyComponent=ou;exports.layoutSidebarButtons=gp;exports.lightGalleryComponent=Qu;exports.listPagesComponent=zu;exports.presetPrintable=Jy;exports.rteProseMirror=sy;exports.rteTinyMce=vf;exports.shapeDividerComponent=af;exports.swiperComponent=mh;exports.tableComponent=Pu;exports.youtubeAssetProvider=xb;
|