@grapesjs/studio-sdk-plugins 1.0.21 → 1.0.22-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animationComponent/components/Animation.d.ts +6 -0
- package/dist/animationComponent/components/AnimationGroup.d.ts +4 -0
- package/dist/animationComponent/index.cjs.d.ts +3 -0
- package/dist/animationComponent/index.cjs.js +507 -0
- package/dist/animationComponent/index.d.ts +3 -0
- package/dist/animationComponent/index.es.d.ts +3 -0
- package/dist/animationComponent/index.es.js +1111 -0
- package/dist/animationComponent/index.umd.js +507 -0
- package/dist/animationComponent/shared.d.ts +3 -0
- package/dist/animationComponent/types.d.ts +28 -0
- package/dist/animationComponent/typesSchema.d.ts +48 -0
- package/dist/animationComponent/utils.d.ts +19 -0
- package/dist/dataSourceEjs/EjsExporter.d.ts +13 -0
- package/dist/dataSourceEjs/EjsImporter.d.ts +29 -0
- package/dist/dataSourceEjs/index.cjs.d.ts +2 -2
- package/dist/dataSourceEjs/index.cjs.js +24 -3
- package/dist/dataSourceEjs/index.d.ts +2 -2
- package/dist/dataSourceEjs/index.es.d.ts +2 -2
- package/dist/dataSourceEjs/index.es.js +697 -114
- package/dist/dataSourceEjs/index.umd.js +24 -3
- package/dist/dataSourceEjs/shared.d.ts +3 -0
- package/dist/dataSourceEjs/types.d.ts +2 -2
- package/dist/dataSourceEjs/typesSchema.d.ts +3 -0
- package/dist/dataSourceHandlebars/HandlebarsExporter.d.ts +16 -0
- package/dist/dataSourceHandlebars/HandlebarsImporter.d.ts +20 -0
- package/dist/dataSourceHandlebars/helperImplementations.d.ts +1 -0
- package/dist/dataSourceHandlebars/index.cjs.js +20 -1
- package/dist/dataSourceHandlebars/index.es.js +401 -99
- package/dist/dataSourceHandlebars/index.umd.js +20 -1
- package/dist/dataSourceHandlebars/shared.d.ts +3 -0
- package/dist/dataSourceHandlebars/types.d.ts +2 -2
- package/dist/dataSourceHandlebars/typesSchema.d.ts +3 -0
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +29 -29
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +64 -64
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.d.ts +1 -0
- package/dist/index.cjs.js +587 -51
- package/dist/index.d.ts +1 -0
- package/dist/index.es.d.ts +1 -0
- package/dist/index.es.js +4809 -3046
- package/dist/index.umd.js +584 -48
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +59 -59
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/presetPrintable/index.cjs.js +3 -3
- package/dist/presetPrintable/index.es.js +136 -131
- package/dist/presetPrintable/index.umd.js +4 -4
- 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 +2 -2
- package/dist/rteTinyMce/index.es.js +67 -67
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +14 -14
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/utilsDataSources.d.ts +28 -0
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +26 -26
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +2 -1
- package/dist/dataSourceEjs/EjsStrategy.d.ts +0 -15
- package/dist/dataSourceHandlebars/HandlebarsStrategy.d.ts +0 -17
package/dist/index.cjs.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const uu=require("handlebars/dist/cjs/handlebars"),Ca="app.grapesjs.com",ka="app-stage.grapesjs.com",hi=[Ca,ka,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],pu="license:check:start",hu="license:check:end",fu=()=>typeof window<"u",fi=(n,e={})=>{const t=vu(n)?{id:n,src:n}:n;return new Promise((o,s)=>{var a,c;const r=document.querySelector(`script[src="${t.src}"]`),{id:i}=t;if(r)return(a=e.onScript)==null||a.call(e,r),o(i);const l=document.createElement("script");l.src=t.src,l.onload=()=>o(i),l.onerror=()=>s(i),document.head.appendChild(l),(c=e.onScript)==null||c.call(e,l)})},mu=({isDev:n,isStage:e})=>`${n?"":`https://${e?ka:Ca}`}/api`,gu=()=>{const n=fu()&&window.location.hostname;return!!n&&(hi.includes(n)||hi.some(e=>n.endsWith(e)))},yu=n=>n.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,t)=>(t?"-":"")+e.toLowerCase()),bu=n=>typeof n<"u",vu=n=>typeof n=="string";function zt(n){return typeof n=="function"}async function Su({path:n,baseApiUrl:e,method:t="GET",headers:o={},params:s,body:r}){const l=`${e||mu({isDev:!1,isStage:!1})}${n}`,a={method:t,headers:{"Content-Type":"application/json",...o}};r&&(a.body=JSON.stringify(r));const c=s?new URLSearchParams(s).toString():"",d=c?`?${c}`:"",u=await fetch(`${l}${d}`,a);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return u.json()}var H=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(H||{}),Ta=(n=>(n.Info="info",n.Error="error",n.Success="success",n.Warning="warning",n))(Ta||{}),F=(n=>(n.toastAdd="studio:toastAdd",n.dialogOpen="studio:dialogOpen",n.dialogClose="studio:dialogClose",n.sidebarLeftSet="studio:sidebarLeft:set",n.sidebarLeftGet="studio:sidebarLeft:get",n.sidebarLeftToggle="studio:sidebarLeft:toggle",n.sidebarRightSet="studio:sidebarRight:set",n.sidebarRightGet="studio:sidebarRight:get",n.sidebarRightToggle="studio:sidebarRight:toggle",n.sidebarTopSet="studio:sidebarTop:set",n.sidebarTopGet="studio:sidebarTop:get",n.sidebarTopToggle="studio:sidebarTop:toggle",n.sidebarBottomSet="studio:sidebarBottom:set",n.sidebarBottomGet="studio:sidebarBottom:get",n.sidebarBottomToggle="studio:sidebarBottom:toggle",n.symbolAdd="studio:symbolAdd",n.symbolDetach="studio:symbolDetach",n.symbolOverride="studio:symbolOverride",n.symbolPropagateStyles="studio:propagateStyles",n.getPagesConfig="studio:getPagesConfig",n.setPagesConfig="studio:setPagesConfig",n.getPageSettings="studio:getPageSettings",n.setPageSettings="studio:setPageSettings",n.projectFiles="studio:projectFiles",n.canvasReload="studio:canvasReload",n.getBlocksPanel="studio:getBlocksPanel",n.setBlocksPanel="studio:setBlocksPanel",n.getStateContextMenu="studio:getStateContextMenu",n.setStateContextMenu="studio:setStateContextMenu",n.contextMenuComponent="studio:contextMenuComponent",n.layoutAdd="studio:layoutAdd",n.layoutRemove="studio:layoutRemove",n.layoutToggle="studio:layoutToggle",n.layoutUpdate="studio:layoutUpdate",n.layoutGet="studio:layoutGet",n.layoutConfigGet="studio:layoutConfigGet",n.layoutConfigSet="studio:layoutConfigSet",n.getStateTheme="studio:getStateTheme",n.setStateTheme="studio:setStateTheme",n.assetProviderGet="studio:assetProviderGet",n.assetProviderAdd="studio:assetProviderAdd",n.assetProviderRemove="studio:assetProviderRemove",n.fontGet="studio:fontGet",n.fontAdd="studio:fontAdd",n.fontRemove="studio:fontRemove",n.fontManagerOpen="studio:fontManagerOpen",n.menuFontLoad="studio:menuFontLoad",n.toggleStateDataSource="studio:toggleStateDataSource",n.getStateDataSource="studio:getStateDataSource",n.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",n.dataSourceSetImporter="studio:dataSourceSetImporter",n.dataSourceSetExporter="studio:dataSourceSetExporter",n.setDragAbsolute="studio:setDragAbsolute",n))(F||{}),Ea=(n=>(n.layoutToggleId="studio:layoutToggle:",n.toggleBlocksPanel="studio:toggleBlocksPanel",n.pageSettingsUpdate="studio:pageSettingsUpdate",n.toggleDataSourcesPreview="studio:toggleDataSourcesPreview",n))(Ea||{}),Ma=(n=>(n.dark="dark",n.light="light",n.auto="auto",n))(Ma||{}),Aa=(n=>(n.web="web",n.email="email",n.document="document",n))(Aa||{});const mi={[H.free]:0,[H.startup]:10,[H.business]:20,[H.enterprise]:30};function xu(n){const e=n;return e.init=t=>o=>n(o,t),e}const _=n=>xu(n);async function G({editor:n,plan:e,pluginName:t,licenseKey:o,cleanup:s}){let r="",i=!1;const l=gu(),a=d=>{console.warn("Cleanup plugin:",t,"Reason:",d),s()},c=(d={})=>{var m;const{error:u,sdkLicense:p}=d,h=(m=d.plan)==null?void 0:m.category;if(!(p||d.license)||u)a(u||"Invalid license");else if(h){const g=mi[e],v=mi[h];g>v&&a({pluginRequiredPlan:e,licensePlan:h})}};n.on(pu,d=>{r=d==null?void 0:d.baseApiUrl,i=!0}),n.on(hu,d=>{c(d)}),setTimeout(async()=>{if(!i){if(l)return;if(o){const d=await wu({licenseKey:o,pluginName:t,baseApiUrl:r});d&&c(d)}else a("The `licenseKey` option not provided")}},2e3)}async function wu(n){const{licenseKey:e,pluginName:t,baseApiUrl:o}=n;try{return(await Su({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 Co=(n,e)=>{var t;return!!((t=n==null?void 0:n.hasAttribute)!=null&&t.call(n,e))},Ot=(n,e)=>{var t;return!!((t=n==null?void 0:n.classList)!=null&&t.contains(e))},pt=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,Je))===n},es=(...n)=>e=>n.some(t=>e.is(t)),$r=(...n)=>(e,t)=>n.some(o=>t.is(o)),Cu=(n,e={})=>{var r;const t={},o=[],s=[];for(const i in n){const{value:l,...a}=n[i];o.push({id:i,name:i,changeProp:!0,category:e.category,...a}),t[i]=l,!bu(l)&&s.push(i);const{subTraits:c={}}=a;for(const d in a.subTraits)(r=c[d])==null||r.forEach(u=>{const p=u.id||u.name;t[p]=u.value})}return{propKeys:Object.keys(t),propsNoValues:s,props:t,traits:o}},ku=(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,()=>gi(n,o)),gi(n,o)}})},gi=(n,e)=>{const t=n.getTrait(e),o=t.get("category"),s=t.get("subTraits")||{},i=(Object.values(s).flat()||[]).map(c=>c.id||c.name);n.removeTrait(i);const l=s[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:o,...c})),{at:a})},zr=(n,e,t)=>{const{doc:o=document}=t,s=t.target||o.head,r=s.querySelector(`style[${n}]`)||o.createElement("style");r.setAttribute(n,"true"),r.innerHTML=e,!s.contains(r)&&s.appendChild(r)},Tu=(n,e)=>{e.forEach(t=>{const o=yu(t);o!==t&&n.has(o)&&n.set({[t]:n.get(o),[o]:void 0})})},$e="gjs-plg-",Pa="data-gs-plg-",Je="data-type-role",yi=(...n)=>n.map(e=>`[data-gjs-type="${e}"]`).join(","),Eu="dialogComponent",Mu=function(n,e={}){const{Blocks:t,Components:o}=n,{licenseKey:s}=e,r="gjs-plg-dialog",i="gjs-plg-dialog-overlay",l="gjs-plg-dialog-content",a="gjs-plg-dialog-close",c="gjs-plg-dialog-title",d="gjs-plg-dialog-body",u="gjs-plg-dialog-description",p="gjs-plg-dialog-placeholder";t.add(r,{label:"Dialog",media:`
|
|
2
2
|
<svg viewBox="0 0 24 24">
|
|
3
3
|
<path d="M4 4h16v10H8l-4 4V4z"></path>
|
|
4
4
|
</svg>
|
|
5
|
-
`,category:"Extra",content:{type:r},activate:!0,...e.block}),o.addType(r,{model:{defaults:{tagName:"div",attributes:{class:r,"data-type-role":r},components:[{type:i},{type:p}],draggable:
|
|
5
|
+
`,category:"Extra",content:{type:r},activate:!0,...e.block}),o.addType(r,{model:{defaults:{tagName:"div",attributes:{class:r,"data-type-role":r},components:[{type:i},{type:p}],draggable:yi("wrapper"),droppable:yi(r),styles:`
|
|
6
6
|
.${r} {
|
|
7
7
|
position: relative;
|
|
8
8
|
z-index: 1;
|
|
9
9
|
}
|
|
10
|
-
`,traits:[{type:"button",label:"Open dialog",name:"onActive",changeProp:!0,command(f){var m;(m=f.getSelected())==null||m.trigger("active")}},{type:"checkbox",label:"Close when pressing X",name:"closeWhenPressingX",default:!0,changeProp:!0},{type:"checkbox",label:"Close when pressing ESC",name:"closeWhenPressingEsc",default:!0,changeProp:!0},{type:"checkbox",label:"Open when leaving the window",name:"openWhenLeavingWindow",default:!1,changeProp:!0},{type:"number",label:"Open when scrolling to level",name:"openWhenScrollingToLevel",default:0,changeProp:!0}],"script-props":["closeWhenPressingX","closeWhenPressingEsc","openWhenLeavingWindow","openWhenScrollingToLevel"],script:function(f){const m=this;function g(b){const
|
|
10
|
+
`,traits:[{type:"button",label:"Open dialog",name:"onActive",changeProp:!0,command(f){var m;(m=f.getSelected())==null||m.trigger("active")}},{type:"checkbox",label:"Close when pressing X",name:"closeWhenPressingX",default:!0,changeProp:!0},{type:"checkbox",label:"Close when pressing ESC",name:"closeWhenPressingEsc",default:!0,changeProp:!0},{type:"checkbox",label:"Open when leaving the window",name:"openWhenLeavingWindow",default:!1,changeProp:!0},{type:"number",label:"Open when scrolling to level",name:"openWhenScrollingToLevel",default:0,changeProp:!0}],"script-props":["closeWhenPressingX","closeWhenPressingEsc","openWhenLeavingWindow","openWhenScrollingToLevel"],script:function(f){const m=this;function g(b){const S=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'),x=m.querySelector('[data-type-role="gjs-plg-dialog-close"]');function w(){S.style.display="none"}b?(m._onCloseWhenPressingX=w,x.addEventListener("click",m._onCloseWhenPressingX)):(x.removeEventListener("click",m._onCloseWhenPressingX),m._onCloseWhenPressingX=null)}function v(b){const S=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function x(w){w.key==="Escape"&&(S.style.display="none")}b?(m._onCloseWhenPressingEsc=x,m.addEventListener("keydown",m._onCloseWhenPressingEsc)):(m.removeEventListener("keydown",m._onCloseWhenPressingEsc),m._onCloseWhenPressingEsc=null)}function C(b){const S=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function x(){S.style.display="flex"}b?(m._onOpenWhenLeavingWindow=x,document.addEventListener("mouseleave",m._onOpenWhenLeavingWindow)):(document.removeEventListener("mouseleave",m._onOpenWhenLeavingWindow),m._onOpenWhenLeavingWindow=null)}function y(b){const S=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function x(){const w=document.documentElement.scrollTop;b&&w>=Number(b)&&(S.style.display="flex")}b?(m._onOpenWhenScrollingToLevel=x,document.addEventListener("scroll",m._onOpenWhenScrollingToLevel)):(document.removeEventListener("scroll",m._onOpenWhenScrollingToLevel),m._onOpenWhenScrollingToLevel=null)}g(f.closeWhenPressingX),v(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(i,{model:{defaults:{tagName:"div",attributes:{class:i,"data-type-role":i},components:{type:l},droppable:!1,draggable:!1,styles:`
|
|
11
11
|
.${i} {
|
|
12
12
|
position: fixed;
|
|
13
13
|
top: 0;
|
|
@@ -56,24 +56,24 @@
|
|
|
56
56
|
.${u} {
|
|
57
57
|
margin: 0;
|
|
58
58
|
}
|
|
59
|
-
`}}}),o.addType(p,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:p,"data-type-role":p},components:"Dialog (click me to open)",droppable:!1,draggable:!1}},view:{init(){const{em:f,el:m}=this,g="core:preview",v=f.Commands.events;this.listenTo(f,`${v.runCommand}${g}`,()=>{m.style.display="none"}),this.listenTo(f,`${v.stopCommand}${g}`,()=>{m.style.display=""})}}}),
|
|
59
|
+
`}}}),o.addType(p,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:p,"data-type-role":p},components:"Dialog (click me to open)",droppable:!1,draggable:!1}},view:{init(){const{em:f,el:m}=this,g="core:preview",v=f.Commands.events;this.listenTo(f,`${v.runCommand}${g}`,()=>{m.style.display="none"}),this.listenTo(f,`${v.stopCommand}${g}`,()=>{m.style.display=""})}}}),G({editor:n,licenseKey:s,plan:H.startup,pluginName:Eu,cleanup:()=>{t.remove(r),o.removeType(r)}})},Au=_(Mu),Pu="iconifyComponent",Iu=H.startup,Nu={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},hs=`<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>`,ga="layout-icon-picker",uu="icons-layout-",ya="icons-list-layout",ba="gs-iconify-picker",Pr="__iconify_collection",pu="https://api.iconify.design",ls=new Map;let Qn;const hu=({collectionId:n})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${n}@latest/icons.json`;async function va({collectionId:n,editor:e}){try{if(ls.has(n))return ls.get(n);const t=await fetch(hu({collectionId:n}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const o=await t.json();return ls.set(n,o),o}catch(t){console.error("Error fetching collection",t),e.runCommand(F.toastAdd,Su());return}}async function fu({collectionIds:n,editor:e}){try{if(Qn)return Qn;const t=n?`?prefixes=${n.join(",")}`:"",o=await fetch(`${pu}/collections${t}`);if(!o.ok)throw new Error(`Failed to fetch collections: ${o.statusText}`);return Qn=await o.json(),Qn}catch(t){console.error("Error fetching collections",t),e.runCommand(F.toastAdd,xa());return}}function li(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(n){var e;(e=n.getSelected())==null||e.trigger("active")}}}async function mu({collectionIds:n,editor:e,component:t}){const o=await fu({collectionIds:n,editor:e});if(!o)return;const s=({icon:a,collectionId:c,iconId:d})=>{t.components(a),t.set({collectionId:c,iconId:d})},r=Object.entries(o).map(([a,c])=>({id:a,...c})).sort((a,c)=>a.name.localeCompare(c.name)),i=t.get("collectionId")??r[0].id;e.runCommand(F.layoutToggle,{id:ga,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[bu({collectionsList:r,collectionId:i,editor:e,handleClick:s}),{id:ya,type:"column",grow:!0}]}});const l=await va({collectionId:i,editor:e});l&&zs({editor:e,collection:l,handleClick:s,collectionId:i})}function gu({editor:n,collection:e}){n.em.set(Pr,e)}function yu(n){return n.em.get(Pr)}function zs(n){const{editor:e}=n,t={id:uu,layout:vu(n),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:ya}};e.runCommand(F.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>e.runCommand(F.layoutAdd,t),10)}function bu(n){const{collectionsList:e,collectionId:t,editor:o,handleClick:s}=n,r=e.map(({id:i,name:l,total:a})=>({id:i,label:`${l} (${a})`})).sort((i,l)=>i.label.localeCompare(l.label));return{type:"column",style:{gap:10},className:`${ba}__header`,children:[{type:"selectField",value:t,options:r,emptyState:"Select an icon collection",onChange:async({setState:i,value:l})=>{const a=await va({collectionId:l,editor:o});a&&(i({value:l}),gu({editor:o,collection:a}),zs({editor:o,collection:a,handleClick:s,collectionId:l}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${Pr}`]:({setState:i})=>i({value:""})},onInput:({setState:i,value:l,editor:a})=>{const c=yu(a);if(!c)return;const d=Object.fromEntries(Object.entries(c.icons).filter(([u])=>u.includes(l)));i({value:l}),zs({editor:a,collection:c,handleClick:s,collectionId:l,collectionFiltered:{...c,icons:d}})}}]}}function vu({collection:n,collectionFiltered:e,handleClick:t}){const{height:o=24,width:s=24,icons:r,prefix:i}=e||n,l=Object.entries(r).map(([a,{body:c}])=>({name:a,body:c}),{});return{type:"column",className:`${ba}__content`,style:{height:"100%"},children:{type:"virtualList",items:l,itemLayout:({item:a})=>[{type:"custom",render:c=>{const{editor:d,addEl:u,removeEl:p}=c,h=document.createElementNS("http://www.w3.org/2000/svg","svg");h.setAttribute("xmlns","http://www.w3.org/2000/svg"),h.innerHTML=a.body,h.setAttribute("viewBox",`0 0 ${s} ${o}`);const{cssWidth:f,cssHeight:m}=xu(s,o);h.style.cssText=`width: ${f}px; height: ${m}px; cursor: pointer;`,h.addEventListener("mouseover",()=>{h.style.border="2px solid currentColor",h.style.borderRadius="4px",h.style.padding="4px"}),h.addEventListener("mouseout",()=>{h.style.border="none"});const g=()=>{const v=h.cloneNode(!0);v.removeAttribute("style");const C=v.outerHTML;t({icon:C,collectionId:i,iconId:a.name}),d==null||d.runCommand(F.layoutRemove,{id:ga})};return h.addEventListener("click",g),u(h),()=>{h.removeEventListener("click",g),p(h)}}}]}}}function xu(n,e){const t=n/e;let o=48,s=48;return t>1?s=48/t:t<1&&(o=48*t),{cssWidth:o,cssHeight:s}}function xa(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:ua.Error}}function Su(){return{...xa(),id:"toast-error-getCollection",content:"Error fetching collection"}}const wu=function(n,e={}){var h;const{Components:t,Blocks:o}=n,{collections:s,extendIconComponent:r=!0,licenseKey:i,block:l={}}=e,a="icon",c="iconify",d="Iconify",u="data-type-iconify",p={events:()=>({dblclick:"onActive"}),onActive(){mu({collectionIds:s,editor:n,component:this.model})}};if(t.addType(c,{block:l&&{label:d,media:is,content:{type:c},category:"Extra",activate:!0,...l},isComponent:f=>go(f,u),model:{defaults:{name:d,icon:is,droppable:!1,attributes:{[u]:!0},resizable:du,components:is,style:{width:"50px",height:"50px"},traits:[li()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(f=>f.set({layerable:!1,locked:!0}))}},view:p}),r){const f=(h=t.getType(a))==null?void 0:h.model,[m,g,...v]=f.getDefaults().traits;t.addType(a,{model:{defaults:{traits:[m,g,li(),...v]}},view:p})}j({editor:n,licenseKey:i,plan:cu,pluginName:au,cleanup:()=>{o.remove(c),t.removeType(c)}})},Cu=W(wu);function Ko(n,e,t){let o,s,r,i,l;const a=e===void 0?100:e;function c(){const u=Date.now()-i;u<a&&u>=0?o=setTimeout(c,a-u):(o=null,l=n.apply(r,s),r=s=null)}const d=function(){return r=this,s=arguments,i=Date.now(),o||(o=setTimeout(c,a)),l};return d.clear=function(){o&&(clearTimeout(o),o=null)},d.flush=function(){o&&(l=n.apply(r,s),r=s=null,clearTimeout(o),o=null)},d}const ku="tableComponent",Tu=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 $={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>'},Ie="table",Sa="thead",wa="tfoot",Vs="tbody",fe="row",G="cell",Nr="clipboardTable",Mu=[Ie,Sa,wa,Vs,fe,G],Uo=n=>n.em.get(Nr)||[],Eu=n=>n.every(e=>e.is(G)),Or=(n,e)=>{const{editor:t,event:o,opts:s}=n,r=o.currentTarget||o.target,{x:i,y:l,width:a,height:c}=r.getBoundingClientRect(),d={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:i,y:l,w:a,h:c},layout:{type:"tabs",value:"props",tabs:[{id:"styles",label:"Styles",children:{type:"panelStyles"}},{id:"props",label:"Properties",children:{type:"panelProperties",style:{padding:"14px 7px"}}}]},...e};Dt(s.openSettings)?s.openSettings({...n,layoutProps:d}):t.runCommand(F.layoutToggle,d)},Au=(n,{rows:e=1,cells:t=5,text:o}={})=>({type:n,components:Array.from(Array(e).keys()).map(s=>({type:fe,components:Array.from(Array(t).keys()).map(r=>({type:G,components:o?{type:"text",content:Dt(o)?o({y:s,x:r}):o}:void 0}))}))}),Ca="Table settings",ka=n=>{const{component:e}=n;return e.is(Ie)?e:e.closestType(Ie)},Pu=n=>{var e;(e=ka(n))==null||e.remove(n.opts)},Nu=n=>{const e=ka(n);e&&(n.editor.select(e),Or(n,{id:"tableSettings",header:{label:Ca}}))},Ta=n=>[{id:I.table,icon:$[I.table],label:"Table",items:[{id:I.tableSettings,label:Ca,icon:$[I.tableSettings],onClick:({event:t})=>Nu({...n,event:t})},{id:I.tableDelete,label:"Delete table",icon:$[I.tableDelete],onClick:()=>Pu(n)}]}],Ma=({editor:n})=>{const e=Uo(n);return e.length&&Eu(e)},ai=({component:n,editor:e,after:t})=>{if(!n.is(G))return;const o=n.closestType(Ie),s=n.closestType(fe),r=n.index()+(t?1:0);o==null||o.findType(fe).forEach(l=>l.append({type:G},{at:r}));const i=s==null?void 0:s.components().at(r);i&&e.select(i)},Ea=({component:n,opts:e})=>{if(!n.is(G))return;const t=n.closestType(Ie),o=n.index();t==null||t.findType(fe).forEach(s=>{var r;return(r=s.components().at(o))==null?void 0:r.remove(e)})},Aa=({component:n,editor:e})=>{if(!n.is(G))return;const t=n.closestType(Ie),o=n.index(),s=(t==null?void 0:t.findType(fe).map(r=>r.components().at(o)))||[];s.length&&e.em.set(Nr,s)},ci=n=>{const{component:e,editor:t,after:o}=n;if(!e.is(G)||!Ma(n))return;const s=Uo(t),r=e.closestType(Ie),i=e.index()+(o?1:0);r==null||r.findType(fe).forEach((l,a)=>{const c=s[a],d=(c==null?void 0:c.clone())||{type:G};l.append(d,{at:i})})},Ou=n=>{const{component:e}=n;e.is(G)&&(Aa(n),Ea({...n,opts:{temporary:!0}}))},Iu=n=>{const e=Ma(n);return[{id:I.tableColumnItems,icon:$[I.tableColumn],label:"Column",items:[{id:I.tableColumnInsertBefore,label:"Insert column before",icon:$[I.tableColumnInsertBefore],onClick:()=>ai(n)},{id:I.tableColumnInsertAfter,label:"Insert column after",icon:$[I.tableColumnInsertAfter],onClick:()=>ai({...n,after:!0})},{id:I.tableColumnDelete,label:"Delete column",icon:$[I.tableColumnDelete],onClick:()=>Ea(n)},{id:I.tableColumnCut,label:"Cut column",icon:$[I.tableColumnCut],onClick:()=>Ou(n)},{id:I.tableColumnCopy,label:"Copy column",icon:$[I.tableColumnCopy],onClick:()=>Aa(n)},{id:I.tableColumnPasteBefore,label:"Paste column before",icon:$[I.tableColumnPasteBefore],disabled:!e,onClick:()=>ci(n)},{id:I.tableColumnPasteAfter,label:"Paste column after",icon:$[I.tableColumnPasteAfter],disabled:!e,onClick:()=>ci({...n,after:!0})}]}]},Pa="Row settings",Ru=n=>n.every(e=>e.is(fe)),un=n=>{const{component:e}=n,t=e.is(G),o=e.is(fe);if(!(!t&&!o))return o?e:e.closestType(fe)},di=n=>{const{component:e,editor:t,after:o}=n,s=un(n);if(!s)return;const r=s.index()+(o?1:0),i=s.components().length,l=Array.from(Array(i).keys()).map(()=>({type:G})),a=s.parent();if(a){const c=a.append({type:fe,components:l},{at:r})[0];if(e.is(G)&&c){const d=e.index(),u=c.components().at(d);u&&t.select(u)}}},Na=n=>{var e;(e=un(n))==null||e.remove(n.opts)},Oa=n=>{const e=un(n);e&&n.editor.em.set(Nr,[e])},ui=n=>{var l;const{editor:e,after:t}=n,o=un(n);if(!o||!Ia(n))return;const r=Uo(e)[0],i=o.index()+(t?1:0);r&&((l=o.parent())==null||l.append(r.clone(),{at:i}))},Du=n=>{un(n)&&(Oa(n),Na({...n,opts:{temporary:!0}}))},Ia=({editor:n})=>{const e=Uo(n);return e.length&&Ru(e)},Lu=n=>{const e=un(n);e&&(n.editor.select(e),Or(n,{id:"tableRowSettings",header:{label:Pa}}))},Ra=n=>{const e=Ia(n);return[{id:I.tableRowItems,icon:$[I.tableRowProperties],label:"Row",items:[{id:I.tableRowInsertBefore,label:"Insert row before",icon:$[I.tableRowInsertBefore],onClick:()=>di(n)},{id:I.tableRowInsertAfter,label:"Insert row after",icon:$[I.tableRowInsertAfter],onClick:()=>di({...n,after:!0})},{id:I.tableRowDelete,label:"Delete row",icon:$[I.tableRowDelete],onClick:()=>Na(n)},{id:I.tableRowProperties,label:Pa,icon:$[I.tableRowProperties],onClick:({event:o})=>Lu({...n,event:o})},{id:I.tableRowCut,label:"Cut row",icon:$[I.tableRowCut],onClick:()=>Du(n)},{id:I.tableRowCopy,label:"Copy row",icon:$[I.tableRowCopy],onClick:()=>Oa(n)},{id:I.tableRowPasteBefore,label:"Paste row before",icon:$[I.tableRowPasteBefore],disabled:!e,onClick:()=>ui(n)},{id:I.tableRowPasteAfter,label:"Paste row after",icon:$[I.tableRowPasteAfter],disabled:!e,onClick:()=>ui({...n,after:!0})}]},...Ta(n)]},Ir=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),o=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:o}};function Da(n){const e=[];return n.components().forEach((t,o)=>{t.components().each((s,r)=>{const{rowspan:i,colspan:l}=Ir(s);if(e[o])for(;e[o][r];)r++;for(let a=o;a<o+i;a++){e[a]||(e[a]=[]);for(let c=r;c<r+l;c++)e[a][c]={real:a===o&&c===r,cell:s,rowspan:i,colspan:l}}})}),e}function qt(n,e,t){var o;return(o=n[t])==null?void 0:o[e]}const $s=n=>n.closestType(fe);function zu(n,{x:e,y:t,rows:o,cols:s}){var l;let r=$s(n[t][e].cell),i;for(let a=1;a<=o;a++)if(r=(l=r==null?void 0:r.parent())==null?void 0:l.components().at(r.index()+1),r){for(i=e;i>=0;i--){const{cell:c}=n[t+a][i],d=$s(c);if(d===r){for(let u=1;u<=s;u++){const p=c.index();d.append({type:G},{at:p+1})}break}}if(i===-1){const d=r.components().at(0).index();for(let u=1;u<=s;u++)r.append({type:G},{at:d})}}}function La(n){for(let e=0;e<n.length;e++)for(let t=0;t<n[e].length;t++){const s=n[e][t].cell;if(s.em.selected.hasComponent(s)){const{rowspan:r,colspan:i}=Ir(s);if(i>1||r>1){s.addAttributes({colspan:1,rowspan:1});for(let l=0;l<i-1;l++){const a=s.index();$s(s).append({type:G},{at:a+1})}zu(n,{x:t,y:e,rows:r-1,cols:i})}}}}function Vu(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const Jo=(n,e={})=>{var i;const t=Da(n),{em:o}=n;let s,r;for(let l=0;l<t.length;l++)for(let a=0;a<t[l].length;a++){const c=t[l][a];if((i=e.selected)!=null&&i.includes(c.cell)||o.selected.hasComponent(c.cell)){const d={x:a,y:l};s||(s=d),r=d}}return{grid:t,startPos:s,endPos:r}};function $u(n,e={}){const t=Jo(n),{startPos:o,endPos:s}=t;let{grid:r}=t;const{em:i}=n;if(!o||!s)return;const l=o.x,a=o.y,c=s.x,d=s.y,u=qt(r,l,a),p=qt(r,c,d);if(u&&p){La(r),r=Da(n);const h=[],f=qt(r,l,a).cell;f.addAttributes({colspan:c-l+1,rowspan:d-a+1});for(let m=a;m<=d;m++)for(let g=l;g<=c;g++){const v=qt(r,g,m);if(!v)continue;const{cell:C}=v;C!==f&&h.push(C)}h.forEach(m=>{e.mergeContent&&f.append(m.components().models),m.remove()}),i.setSelected(f),Vu(n)}}const za="Cell settings",Bu="Merge cells",Hu="Split cell",Fu=n=>n.closestType(fe),nn=n=>{var e;return(e=Fu(n))==null?void 0:e.parent()},_u=n=>{const e=n.editor.getSelectedAll(),t=nn(e[0]),o=e[0];if(!t||!(o!=null&&o.is(G))||e.length>1)return!1;const{rowspan:s,colspan:r}=Ir(o);return!(r<2&&s<2)},Gu=n=>{const t=n.editor.getSelectedAll()[0],o=nn(t),{grid:s}=Jo(o);La(s)},Va=n=>{const e=n.editor.getSelectedAll(),t=nn(e[0]);if(!t||e.length<2||e.some(l=>!l.is(G)||nn(l)!==t))return!1;const{grid:o,startPos:s,endPos:r}=Jo(t),{em:i}=t;if(!s||!r)return!1;for(let l=s.y;l<=r.y;l++)for(let a=s.x;a<=r.x;a++){const c=qt(o,a,l);if(!c||!i.selected.hasComponent(c.cell))return!1}return!0},Wu=n=>{const{editor:e}=n;if(!Va(n))return;const t=e.getSelectedAll(),o=nn(t[0]);$u(o,{mergeContent:!0})},ju=n=>{Or(n,{id:"tableCellSettings",header:{label:za}})},qu=n=>[{id:I.tableCellItems,icon:$[I.tableCellProperties],label:"Cell",items:[{id:I.tableCellProperties,label:za,icon:$[I.tableCellProperties],onClick:({event:t})=>ju({...n,event:t})},{id:I.tableCellMerge,label:Bu,icon:$[I.tableCellMerge],onClick:()=>Wu(n),disabled:!Va(n)},{id:I.tableCellSplit,label:Hu,icon:$[I.tableCellSplit],onClick:()=>Gu(n),disabled:!_u(n)}]},...Iu(n),...Ra(n)],Ku=n=>{const e=n[0]&&nn(n[0]);if(!e)return;const{grid:t,startPos:o,endPos:s}=Jo(e,{selected:n});if(!o||!s)return;const r=[];for(let i=o.y;i<=s.y;i++)for(let l=o.x;l<=s.x;l++){const a=qt(t,l,i);a&&r.push(a.cell)}r.length&&e.em.setSelected(r,{fromCell:!0})},Uu=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(Ie,{block:t.block&&{label:"Table",media:$.table,category:"Extra",content:{type:Ie,style:{width:"100%"}},select:!0,...t.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:$.table,stylable:["width","height","margin","font-family","font-size","font-weight","line-height","text-align","background","background-color","border-width","border-style","border-color"],traits:[{type:"number",min:0,name:"cellspacing",label:"Cell spacing"},{type:"number",min:0,name:"cellpadding",label:"Cell padding"},{id:"tableCaption",type:"checkbox",label:"Caption",setValue({component:i,value:l,emitUpdate:a}){const c=i.find("caption")[0];l?!c&&i.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):c==null||c.remove(),a(),n.refresh({tools:!0})},getValue(i){return!!i.component.find("caption")[0]}}],components:Au(Vs,{rows:5}),contextMenu:({items:i,editor:l,component:a})=>[...Ta({editor:l,component:a,opts:t}),...i]}}}),o.addType(Sa,{model:{defaults:{icon:$.tableHead,...s}}}),o.addType(wa,{model:{defaults:{icon:$.tableFoot,...s}}}),o.addType(Vs,{model:{defaults:{icon:$.tableRowProperties,...s}}}),o.addType(fe,{model:{defaults:{icon:$.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:i,editor:l,component:a})=>[...Ra({editor:l,component:a,opts:t}),...i]}}}),o.addType(G,{model:{defaults:{icon:$.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","background","background-color","text-align","vertical-align","border-width","border-style","border-color"],traits:[{id:"tableCellType",type:"select",options:[{value:"td",name:"Cell"},{value:"th",name:"Header Cell"}],label:"Cell type",name:"tagName",changeProp:!0},{id:"tableCellScope",type:"select",options:[{value:!1,name:"None"},{value:"row",name:"Row"},{value:"col",name:"Column"},{value:"rowgroup",name:"Row group"},{value:"colgroup",name:"Column group"}],label:"Scope",name:"scope"}],contextMenu:({items:i,editor:l,component:a})=>[...qu({editor:l,component:a,opts:t}),...i]}}});const r=Ko((i,l)=>{var u;const a=n.getSelectedAll(),c=!!((u=l==null?void 0:l.event)!=null&&u.shiftKey);if(a.length<2||!c||l.fromCell)return;const d=a.map(p=>p.is(G)?p:p.closestType(G)).filter(Boolean);d.length===a.length&&Ku(d)},0);n.on("component:select",r),j({editor:n,plan:Tu,pluginName:ku,licenseKey:t.licenseKey,cleanup:()=>{n.off("component:select",r),n.Blocks.remove(Ie),Mu.forEach(i=>o.removeType(i))}})},Ju=W(Uu),Yu="listPagesComponent",Zu=H.startup,pi="page://",pt="list-pages",Vt="list-pages-item",ht="list-pages-link",Xu=n=>n.components().reduce((e,t)=>{var i;const o=t.findFirstType(ht),s=(i=o==null?void 0:o.attributes.attributes)==null?void 0:i.href,r=s!=null&&s.startsWith(pi)?s.replace(pi,""):"";if(r&&o){const l=e[r];l?l.push(o):e[r]=[o]}return e},{}),yo="data-type-role",Qu="page_root",ep=n=>e=>e.is(n),tp=n=>(e,t)=>t.is(n),as=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,yo))===n},np=function(n,e={}){const{Blocks:t,Components:o,Pages:s}=n,{licenseKey:r,block:i={}}=e,l="List Pages",a="List Pages Item",c="Link",d=`${Re}${pt}`,u=`${Re}${ht}`,p='<svg viewBox="0 0 24 24"><path d="M11 15H17V17H11V15M9 7H7V9H9V7M11 13H17V11H11V13M11 9H17V7H11V9M9 11H7V13H9V11M21 5V19C21 20.1 20.1 21 19 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H19C20.1 3 21 3.9 21 5M19 5H5V19H19V5M9 15H7V17H9V15Z"/></svg>',h='<svg viewBox="0 0 24 24"><path d="M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z" /></svg>';o.addType(pt,{block:i&&{label:l,media:p,category:"Extra",select:!0,...e.block},isComponent:as(pt),model:{defaults:{tagName:"ul",name:l,[Qu]:"",classes:d,attributes:{[yo]:pt,role:"navigation"},droppable:ep(Vt),styles:`
|
|
61
|
+
</svg>`,Ia="layout-icon-picker",Ou="icons-layout-",Na="icons-list-layout",Oa="gs-iconify-picker",Br="__iconify_collection",Ru="https://api.iconify.design",fs=new Map;let ro;const Du=({collectionId:n})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${n}@latest/icons.json`;async function Ra({collectionId:n,editor:e}){try{if(fs.has(n))return fs.get(n);const t=await fetch(Du({collectionId:n}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const o=await t.json();return fs.set(n,o),o}catch(t){console.error("Error fetching collection",t),e.runCommand(F.toastAdd,_u());return}}async function Lu({collectionIds:n,editor:e}){try{if(ro)return ro;const t=n?`?prefixes=${n.join(",")}`:"",o=await fetch(`${Ru}/collections${t}`);if(!o.ok)throw new Error(`Failed to fetch collections: ${o.statusText}`);return ro=await o.json(),ro}catch(t){console.error("Error fetching collections",t),e.runCommand(F.toastAdd,Da());return}}function bi(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(n){var e;(e=n.getSelected())==null||e.trigger("active")}}}async function $u({collectionIds:n,editor:e,component:t}){const o=await Lu({collectionIds:n,editor:e});if(!o)return;const s=({icon:a,collectionId:c,iconId:d})=>{t.components(a),t.set({collectionId:c,iconId:d})},r=Object.entries(o).map(([a,c])=>({id:a,...c})).sort((a,c)=>a.name.localeCompare(c.name)),i=t.get("collectionId")??r[0].id;e.runCommand(F.layoutToggle,{id:Ia,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[Vu({collectionsList:r,collectionId:i,editor:e,handleClick:s}),{id:Na,type:"column",grow:!0}]}});const l=await Ra({collectionId:i,editor:e});l&&js({editor:e,collection:l,handleClick:s,collectionId:i})}function zu({editor:n,collection:e}){n.em.set(Br,e)}function Bu(n){return n.em.get(Br)}function js(n){const{editor:e}=n,t={id:Ou,layout:Hu(n),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:Na}};e.runCommand(F.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>e.runCommand(F.layoutAdd,t),10)}function Vu(n){const{collectionsList:e,collectionId:t,editor:o,handleClick:s}=n,r=e.map(({id:i,name:l,total:a})=>({id:i,label:`${l} (${a})`})).sort((i,l)=>i.label.localeCompare(l.label));return{type:"column",style:{gap:10},className:`${Oa}__header`,children:[{type:"selectField",value:t,options:r,emptyState:"Select an icon collection",onChange:async({setState:i,value:l})=>{const a=await Ra({collectionId:l,editor:o});a&&(i({value:l}),zu({editor:o,collection:a}),js({editor:o,collection:a,handleClick:s,collectionId:l}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${Br}`]:({setState:i})=>i({value:""})},onInput:({setState:i,value:l,editor:a})=>{const c=Bu(a);if(!c)return;const d=Object.fromEntries(Object.entries(c.icons).filter(([u])=>u.includes(l)));i({value:l}),js({editor:a,collection:c,handleClick:s,collectionId:l,collectionFiltered:{...c,icons:d}})}}]}}function Hu({collection:n,collectionFiltered:e,handleClick:t}){const{height:o=24,width:s=24,icons:r,prefix:i}=e||n,l=Object.entries(r).map(([a,{body:c}])=>({name:a,body:c}),{});return{type:"column",className:`${Oa}__content`,style:{height:"100%"},children:{type:"virtualList",items:l,itemLayout:({item:a})=>[{type:"custom",render:c=>{const{editor:d,addEl:u,removeEl:p}=c,h=document.createElementNS("http://www.w3.org/2000/svg","svg");h.setAttribute("xmlns","http://www.w3.org/2000/svg"),h.innerHTML=a.body,h.setAttribute("viewBox",`0 0 ${s} ${o}`);const{cssWidth:f,cssHeight:m}=Fu(s,o);h.style.cssText=`width: ${f}px; height: ${m}px; cursor: pointer;`,h.addEventListener("mouseover",()=>{h.style.border="2px solid currentColor",h.style.borderRadius="4px",h.style.padding="4px"}),h.addEventListener("mouseout",()=>{h.style.border="none"});const g=()=>{const v=h.cloneNode(!0);v.removeAttribute("style");const C=v.outerHTML;t({icon:C,collectionId:i,iconId:a.name}),d==null||d.runCommand(F.layoutRemove,{id:Ia})};return h.addEventListener("click",g),u(h),()=>{h.removeEventListener("click",g),p(h)}}}]}}}function Fu(n,e){const t=n/e;let o=48,s=48;return t>1?s=48/t:t<1&&(o=48*t),{cssWidth:o,cssHeight:s}}function Da(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:Ta.Error}}function _u(){return{...Da(),id:"toast-error-getCollection",content:"Error fetching collection"}}const Gu=function(n,e={}){var h;const{Components:t,Blocks:o}=n,{collections:s,extendIconComponent:r=!0,licenseKey:i,block:l={}}=e,a="icon",c="iconify",d="Iconify",u="data-type-iconify",p={events:()=>({dblclick:"onActive"}),onActive(){$u({collectionIds:s,editor:n,component:this.model})}};if(t.addType(c,{block:l&&{label:d,media:hs,content:{type:c},category:"Extra",activate:!0,...l},isComponent:f=>Co(f,u),model:{defaults:{name:d,icon:hs,droppable:!1,attributes:{[u]:!0},resizable:Nu,components:hs,style:{width:"50px",height:"50px"},traits:[bi()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(f=>f.set({layerable:!1,locked:!0}))}},view:p}),r){const f=(h=t.getType(a))==null?void 0:h.model,[m,g,...v]=f.getDefaults().traits;t.addType(a,{model:{defaults:{traits:[m,g,bi(),...v]}},view:p})}G({editor:n,licenseKey:i,plan:Iu,pluginName:Pu,cleanup:()=>{o.remove(c),t.removeType(c)}})},Wu=_(Gu);function Hn(n,e,t){let o,s,r,i,l;const a=e===void 0?100:e;function c(){const u=Date.now()-i;u<a&&u>=0?o=setTimeout(c,a-u):(o=null,l=n.apply(r,s),r=s=null)}const d=function(){return r=this,s=arguments,i=Date.now(),o||(o=setTimeout(c,a)),l};return d.clear=function(){o&&(clearTimeout(o),o=null)},d.flush=function(){o&&(l=n.apply(r,s),r=s=null,clearTimeout(o),o=null)},d}const ju="tableComponent",qu=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 B={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>'},Le="table",La="thead",$a="tfoot",qs="tbody",fe="row",j="cell",Vr="clipboardTable",Uu=[Le,La,$a,qs,fe,j],ts=n=>n.em.get(Vr)||[],Ku=n=>n.every(e=>e.is(j)),Hr=(n,e)=>{const{editor:t,event:o,opts:s}=n,r=o.currentTarget||o.target,{x:i,y:l,width:a,height:c}=r.getBoundingClientRect(),d={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:i,y:l,w:a,h:c},layout:{type:"tabs",value:"props",tabs:[{id:"styles",label:"Styles",children:{type:"panelStyles"}},{id:"props",label:"Properties",children:{type:"panelProperties",style:{padding:"14px 7px"}}}]},...e};zt(s.openSettings)?s.openSettings({...n,layoutProps:d}):t.runCommand(F.layoutToggle,d)},Ju=(n,{rows:e=1,cells:t=5,text:o}={})=>({type:n,components:Array.from(Array(e).keys()).map(s=>({type:fe,components:Array.from(Array(t).keys()).map(r=>({type:j,components:o?{type:"text",content:zt(o)?o({y:s,x:r}):o}:void 0}))}))}),za="Table settings",Ba=n=>{const{component:e}=n;return e.is(Le)?e:e.closestType(Le)},Zu=n=>{var e;(e=Ba(n))==null||e.remove(n.opts)},Yu=n=>{const e=Ba(n);e&&(n.editor.select(e),Hr(n,{id:"tableSettings",header:{label:za}}))},Va=n=>[{id:O.table,icon:B[O.table],label:"Table",items:[{id:O.tableSettings,label:za,icon:B[O.tableSettings],onClick:({event:t})=>Yu({...n,event:t})},{id:O.tableDelete,label:"Delete table",icon:B[O.tableDelete],onClick:()=>Zu(n)}]}],Ha=({editor:n})=>{const e=ts(n);return e.length&&Ku(e)},vi=({component:n,editor:e,after:t})=>{if(!n.is(j))return;const o=n.closestType(Le),s=n.closestType(fe),r=n.index()+(t?1:0);o==null||o.findType(fe).forEach(l=>l.append({type:j},{at:r}));const i=s==null?void 0:s.components().at(r);i&&e.select(i)},Fa=({component:n,opts:e})=>{if(!n.is(j))return;const t=n.closestType(Le),o=n.index();t==null||t.findType(fe).forEach(s=>{var r;return(r=s.components().at(o))==null?void 0:r.remove(e)})},_a=({component:n,editor:e})=>{if(!n.is(j))return;const t=n.closestType(Le),o=n.index(),s=(t==null?void 0:t.findType(fe).map(r=>r.components().at(o)))||[];s.length&&e.em.set(Vr,s)},Si=n=>{const{component:e,editor:t,after:o}=n;if(!e.is(j)||!Ha(n))return;const s=ts(t),r=e.closestType(Le),i=e.index()+(o?1:0);r==null||r.findType(fe).forEach((l,a)=>{const c=s[a],d=(c==null?void 0:c.clone())||{type:j};l.append(d,{at:i})})},Xu=n=>{const{component:e}=n;e.is(j)&&(_a(n),Fa({...n,opts:{temporary:!0}}))},Qu=n=>{const e=Ha(n);return[{id:O.tableColumnItems,icon:B[O.tableColumn],label:"Column",items:[{id:O.tableColumnInsertBefore,label:"Insert column before",icon:B[O.tableColumnInsertBefore],onClick:()=>vi(n)},{id:O.tableColumnInsertAfter,label:"Insert column after",icon:B[O.tableColumnInsertAfter],onClick:()=>vi({...n,after:!0})},{id:O.tableColumnDelete,label:"Delete column",icon:B[O.tableColumnDelete],onClick:()=>Fa(n)},{id:O.tableColumnCut,label:"Cut column",icon:B[O.tableColumnCut],onClick:()=>Xu(n)},{id:O.tableColumnCopy,label:"Copy column",icon:B[O.tableColumnCopy],onClick:()=>_a(n)},{id:O.tableColumnPasteBefore,label:"Paste column before",icon:B[O.tableColumnPasteBefore],disabled:!e,onClick:()=>Si(n)},{id:O.tableColumnPasteAfter,label:"Paste column after",icon:B[O.tableColumnPasteAfter],disabled:!e,onClick:()=>Si({...n,after:!0})}]}]},Ga="Row settings",ep=n=>n.every(e=>e.is(fe)),mn=n=>{const{component:e}=n,t=e.is(j),o=e.is(fe);if(!(!t&&!o))return o?e:e.closestType(fe)},xi=n=>{const{component:e,editor:t,after:o}=n,s=mn(n);if(!s)return;const r=s.index()+(o?1:0),i=s.components().length,l=Array.from(Array(i).keys()).map(()=>({type:j})),a=s.parent();if(a){const c=a.append({type:fe,components:l},{at:r})[0];if(e.is(j)&&c){const d=e.index(),u=c.components().at(d);u&&t.select(u)}}},Wa=n=>{var e;(e=mn(n))==null||e.remove(n.opts)},ja=n=>{const e=mn(n);e&&n.editor.em.set(Vr,[e])},wi=n=>{var l;const{editor:e,after:t}=n,o=mn(n);if(!o||!qa(n))return;const r=ts(e)[0],i=o.index()+(t?1:0);r&&((l=o.parent())==null||l.append(r.clone(),{at:i}))},tp=n=>{mn(n)&&(ja(n),Wa({...n,opts:{temporary:!0}}))},qa=({editor:n})=>{const e=ts(n);return e.length&&ep(e)},np=n=>{const e=mn(n);e&&(n.editor.select(e),Hr(n,{id:"tableRowSettings",header:{label:Ga}}))},Ua=n=>{const e=qa(n);return[{id:O.tableRowItems,icon:B[O.tableRowProperties],label:"Row",items:[{id:O.tableRowInsertBefore,label:"Insert row before",icon:B[O.tableRowInsertBefore],onClick:()=>xi(n)},{id:O.tableRowInsertAfter,label:"Insert row after",icon:B[O.tableRowInsertAfter],onClick:()=>xi({...n,after:!0})},{id:O.tableRowDelete,label:"Delete row",icon:B[O.tableRowDelete],onClick:()=>Wa(n)},{id:O.tableRowProperties,label:Ga,icon:B[O.tableRowProperties],onClick:({event:o})=>np({...n,event:o})},{id:O.tableRowCut,label:"Cut row",icon:B[O.tableRowCut],onClick:()=>tp(n)},{id:O.tableRowCopy,label:"Copy row",icon:B[O.tableRowCopy],onClick:()=>ja(n)},{id:O.tableRowPasteBefore,label:"Paste row before",icon:B[O.tableRowPasteBefore],disabled:!e,onClick:()=>wi(n)},{id:O.tableRowPasteAfter,label:"Paste row after",icon:B[O.tableRowPasteAfter],disabled:!e,onClick:()=>wi({...n,after:!0})}]},...Va(n)]},Fr=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),o=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:o}};function Ka(n){const e=[];return n.components().forEach((t,o)=>{t.components().each((s,r)=>{const{rowspan:i,colspan:l}=Fr(s);if(e[o])for(;e[o][r];)r++;for(let a=o;a<o+i;a++){e[a]||(e[a]=[]);for(let c=r;c<r+l;c++)e[a][c]={real:a===o&&c===r,cell:s,rowspan:i,colspan:l}}})}),e}function Jt(n,e,t){var o;return(o=n[t])==null?void 0:o[e]}const Us=n=>n.closestType(fe);function op(n,{x:e,y:t,rows:o,cols:s}){var l;let r=Us(n[t][e].cell),i;for(let a=1;a<=o;a++)if(r=(l=r==null?void 0:r.parent())==null?void 0:l.components().at(r.index()+1),r){for(i=e;i>=0;i--){const{cell:c}=n[t+a][i],d=Us(c);if(d===r){for(let u=1;u<=s;u++){const p=c.index();d.append({type:j},{at:p+1})}break}}if(i===-1){const d=r.components().at(0).index();for(let u=1;u<=s;u++)r.append({type:j},{at:d})}}}function Ja(n){for(let e=0;e<n.length;e++)for(let t=0;t<n[e].length;t++){const s=n[e][t].cell;if(s.em.selected.hasComponent(s)){const{rowspan:r,colspan:i}=Fr(s);if(i>1||r>1){s.addAttributes({colspan:1,rowspan:1});for(let l=0;l<i-1;l++){const a=s.index();Us(s).append({type:j},{at:a+1})}op(n,{x:t,y:e,rows:r-1,cols:i})}}}}function sp(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const ns=(n,e={})=>{var i;const t=Ka(n),{em:o}=n;let s,r;for(let l=0;l<t.length;l++)for(let a=0;a<t[l].length;a++){const c=t[l][a];if((i=e.selected)!=null&&i.includes(c.cell)||o.selected.hasComponent(c.cell)){const d={x:a,y:l};s||(s=d),r=d}}return{grid:t,startPos:s,endPos:r}};function rp(n,e={}){const t=ns(n),{startPos:o,endPos:s}=t;let{grid:r}=t;const{em:i}=n;if(!o||!s)return;const l=o.x,a=o.y,c=s.x,d=s.y,u=Jt(r,l,a),p=Jt(r,c,d);if(u&&p){Ja(r),r=Ka(n);const h=[],f=Jt(r,l,a).cell;f.addAttributes({colspan:c-l+1,rowspan:d-a+1});for(let m=a;m<=d;m++)for(let g=l;g<=c;g++){const v=Jt(r,g,m);if(!v)continue;const{cell:C}=v;C!==f&&h.push(C)}h.forEach(m=>{e.mergeContent&&f.append(m.components().models),m.remove()}),i.setSelected(f),sp(n)}}const Za="Cell settings",ip="Merge cells",lp="Split cell",ap=n=>n.closestType(fe),ln=n=>{var e;return(e=ap(n))==null?void 0:e.parent()},cp=n=>{const e=n.editor.getSelectedAll(),t=ln(e[0]),o=e[0];if(!t||!(o!=null&&o.is(j))||e.length>1)return!1;const{rowspan:s,colspan:r}=Fr(o);return!(r<2&&s<2)},dp=n=>{const t=n.editor.getSelectedAll()[0],o=ln(t),{grid:s}=ns(o);Ja(s)},Ya=n=>{const e=n.editor.getSelectedAll(),t=ln(e[0]);if(!t||e.length<2||e.some(l=>!l.is(j)||ln(l)!==t))return!1;const{grid:o,startPos:s,endPos:r}=ns(t),{em:i}=t;if(!s||!r)return!1;for(let l=s.y;l<=r.y;l++)for(let a=s.x;a<=r.x;a++){const c=Jt(o,a,l);if(!c||!i.selected.hasComponent(c.cell))return!1}return!0},up=n=>{const{editor:e}=n;if(!Ya(n))return;const t=e.getSelectedAll(),o=ln(t[0]);rp(o,{mergeContent:!0})},pp=n=>{Hr(n,{id:"tableCellSettings",header:{label:Za}})},hp=n=>[{id:O.tableCellItems,icon:B[O.tableCellProperties],label:"Cell",items:[{id:O.tableCellProperties,label:Za,icon:B[O.tableCellProperties],onClick:({event:t})=>pp({...n,event:t})},{id:O.tableCellMerge,label:ip,icon:B[O.tableCellMerge],onClick:()=>up(n),disabled:!Ya(n)},{id:O.tableCellSplit,label:lp,icon:B[O.tableCellSplit],onClick:()=>dp(n),disabled:!cp(n)}]},...Qu(n),...Ua(n)],fp=n=>{const e=n[0]&&ln(n[0]);if(!e)return;const{grid:t,startPos:o,endPos:s}=ns(e,{selected:n});if(!o||!s)return;const r=[];for(let i=o.y;i<=s.y;i++)for(let l=o.x;l<=s.x;l++){const a=Jt(t,l,i);a&&r.push(a.cell)}r.length&&e.em.setSelected(r,{fromCell:!0})},mp=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(Le,{block:t.block&&{label:"Table",media:B.table,category:"Extra",content:{type:Le,style:{width:"100%"}},select:!0,...t.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:B.table,stylable:["width","height","margin","font-family","font-size","font-weight","line-height","text-align","background","background-color","border-width","border-style","border-color"],traits:[{type:"number",min:0,name:"cellspacing",label:"Cell spacing"},{type:"number",min:0,name:"cellpadding",label:"Cell padding"},{id:"tableCaption",type:"checkbox",label:"Caption",setValue({component:i,value:l,emitUpdate:a}){const c=i.find("caption")[0];l?!c&&i.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):c==null||c.remove(),a(),n.refresh({tools:!0})},getValue(i){return!!i.component.find("caption")[0]}}],components:Ju(qs,{rows:5}),contextMenu:({items:i,editor:l,component:a})=>[...Va({editor:l,component:a,opts:t}),...i]}}}),o.addType(La,{model:{defaults:{icon:B.tableHead,...s}}}),o.addType($a,{model:{defaults:{icon:B.tableFoot,...s}}}),o.addType(qs,{model:{defaults:{icon:B.tableRowProperties,...s}}}),o.addType(fe,{model:{defaults:{icon:B.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:i,editor:l,component:a})=>[...Ua({editor:l,component:a,opts:t}),...i]}}}),o.addType(j,{model:{defaults:{icon:B.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","background","background-color","text-align","vertical-align","border-width","border-style","border-color"],traits:[{id:"tableCellType",type:"select",options:[{value:"td",name:"Cell"},{value:"th",name:"Header Cell"}],label:"Cell type",name:"tagName",changeProp:!0},{id:"tableCellScope",type:"select",options:[{value:!1,name:"None"},{value:"row",name:"Row"},{value:"col",name:"Column"},{value:"rowgroup",name:"Row group"},{value:"colgroup",name:"Column group"}],label:"Scope",name:"scope"}],contextMenu:({items:i,editor:l,component:a})=>[...hp({editor:l,component:a,opts:t}),...i]}}});const r=Hn((i,l)=>{var u;const a=n.getSelectedAll(),c=!!((u=l==null?void 0:l.event)!=null&&u.shiftKey);if(a.length<2||!c||l.fromCell)return;const d=a.map(p=>p.is(j)?p:p.closestType(j)).filter(Boolean);d.length===a.length&&fp(d)},0);n.on("component:select",r),G({editor:n,plan:qu,pluginName:ju,licenseKey:t.licenseKey,cleanup:()=>{n.off("component:select",r),n.Blocks.remove(Le),Uu.forEach(i=>o.removeType(i))}})},gp=_(mp),yp="listPagesComponent",bp=H.startup,Ci="page://",mt="list-pages",Ht="list-pages-item",gt="list-pages-link",vp=n=>n.components().reduce((e,t)=>{var i;const o=t.findFirstType(gt),s=(i=o==null?void 0:o.attributes.attributes)==null?void 0:i.href,r=s!=null&&s.startsWith(Ci)?s.replace(Ci,""):"";if(r&&o){const l=e[r];l?l.push(o):e[r]=[o]}return e},{}),ko="data-type-role",Sp="page_root",xp=n=>e=>e.is(n),wp=n=>(e,t)=>t.is(n),ms=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,ko))===n},Cp=function(n,e={}){const{Blocks:t,Components:o,Pages:s}=n,{licenseKey:r,block:i={}}=e,l="List Pages",a="List Pages Item",c="Link",d=`${$e}${mt}`,u=`${$e}${gt}`,p='<svg viewBox="0 0 24 24"><path d="M11 15H17V17H11V15M9 7H7V9H9V7M11 13H17V11H11V13M11 9H17V7H11V9M9 11H7V13H9V11M21 5V19C21 20.1 20.1 21 19 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H19C20.1 3 21 3.9 21 5M19 5H5V19H19V5M9 15H7V17H9V15Z"/></svg>',h='<svg viewBox="0 0 24 24"><path d="M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z" /></svg>';o.addType(mt,{block:i&&{label:l,media:p,category:"Extra",select:!0,...e.block},isComponent:ms(mt),model:{defaults:{tagName:"ul",name:l,[Sp]:"",classes:d,attributes:{[ko]:mt,role:"navigation"},droppable:xp(Ht),styles:`
|
|
62
62
|
.${d} {
|
|
63
63
|
list-style: none;
|
|
64
64
|
margin: 0;
|
|
65
65
|
padding: 0;
|
|
66
66
|
}
|
|
67
|
-
`},init(){this.syncPageItems=
|
|
67
|
+
`},init(){this.syncPageItems=Hn(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=vp(this);f.forEach((v,C)=>{const y=v.id,b=v.getName(),S=g[y];S?S==null||S.forEach(x=>{x.getInnerHTML()!==b&&x.components(b)}):m.add({type:Ht,components:[{type:gt,attributes:{href:`page://${y}`},components:{type:"textnode",content:b}}]},{at:C})})}}}),o.addType(Ht,{isComponent:ms(Ht),model:{defaults:{name:a,tagName:"li",icon:h,attributes:{[ko]:Ht},components:{type:gt},draggable:wp(mt)}}}),o.addType(gt,{extend:"link",isComponent:ms(gt),model:{defaults:{removable:!1,copyable:!1,delegate:{move:f=>f.closestType(Ht)},name:c,classes:u,attributes:{[ko]:gt},components:{type:"textnode",content:"Item"},styles:`
|
|
68
68
|
.${u} {
|
|
69
69
|
text-decoration: none;
|
|
70
70
|
}
|
|
71
|
-
`}}}),
|
|
71
|
+
`}}}),G({editor:n,licenseKey:r,plan:bp,pluginName:yp,cleanup:()=>{t.remove(mt),o.removeType(mt)}})},kp=_(Cp),Tp="fsLightboxComponent",Ep=H.startup,io="data-fslightbox",lo="data-type",Mp="fslightbox-open",Ft="fslightbox",_t={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>'},Ap=function(n,e={}){const{Blocks:t,Components:o}=n,s="Lightbox",r=`${$e}${Ft}`,i={toolbarIconOpen:_t.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=i,d=function(C){const y=this,b="data-fslightbox",S=window,x=()=>{var M;const w=S.refreshFsLightbox;w==null||w();const E=y.getAttribute(b);if((M=S.fsLightboxInstances)==null||M[E],!S._isEditor)return;Array.from(document.querySelectorAll(`[${b}]`)).forEach(P=>{const N=P.onclick;P.onclick=function(I){I.preventDefault();const D=P;!D.__skipLb&&(N==null||N(I)),D.__skipLb=!0}})};if(S.refreshFsLightbox)x();else{const w=document.createElement("script");w.src=C.cdnScript,w.onload=x,document.head.appendChild(w)}},u=C=>({id:`${Ft}-open-lb`,label:a,command:()=>{const y=C.getView();y==null||y.toggleLightbox()}}),p="source-type",h={type:"radio",name:p,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:_t.image},{id:"video",label:"Video",icon:_t.video},{id:"el",label:"Custom Element",icon:_t.external}],labelToTitle:!0},f={id:"href-image",name:"href",type:"file",label:"Source Image"},m={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},g={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},v={image:[f],video:[m],el:[g]};o.addType(Ft,{block:l&&{label:s,media:_t.imageLightbox,category:"Extra",select:!0,...i.block},isComponent:C=>{var y;return(y=C.hasAttribute)==null?void 0:y.call(C,io)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:s,icon:_t.imageLightbox,classes:r,draggable:(C,y)=>!y.is(Ft),attributes:{[io]:"lightbox",[lo]:"image",href:c},components:{type:"image",src:c},script:d,cdnScript:i.cdnScript,"script-props":["attributes","cdnScript"],[p]:"image",traits:[h,{name:io,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(C,y){var S;const b=(S=y.target)==null?void 0:S.getView();b==null||b.toggleLightbox()}}],styles:`
|
|
72
72
|
.${r} {
|
|
73
73
|
display: inline-block;
|
|
74
74
|
padding: 10px;
|
|
75
75
|
}
|
|
76
|
-
`},init(){const C=[p].map(y=>`change:${y}`).join(" ");this.on(C,this.updateTraits),this.on(`change:${p}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(C,y,b){if(b.adjust)return;const S=this.get(p)==="video"?"video":"image";this.addAttributes({[to]:S,href:""})},adjustSourceType(){const C=this.get(p),y=this.getAttributes().href||"",b={adjust:!0};if(C==="video"){const x=y.includes("youtube.com")?"youtube":"video";this.addAttributes({[to]:x},b)}else C!=="el"&&y.startsWith("#")?this.set(p,"el",b):C==="image"&&this.addAttributes({[to]:"image"},b)},updateTraits(C={}){const{changed:y}=this,{init:b}=C;if(y[h.name]||b){this.removeTrait([f.name,m.name,g.name]);const x=this.get(p)||"image",S=this.getTraitIndex(p)+1;this.addTrait(v[x],{at:S})}},initToolbar(){if(!a)return;const{toolbar:C}=this,y=u(this);!C.find(x=>x.id===y.id)&&(C==null||C.unshift(y))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var P;const{em:C,el:y,model:b}=this,{Canvas:x}=C,S=b.getAttributes()[eo],{defaultView:w,documentElement:M}=y.ownerDocument,k=(P=w.fsLightboxInstances)==null?void 0:P[S];if(M.classList.contains(ip))k.close();else{y.__skipLb=!1;let O;k.props.onOpen=()=>{O=x.getSpots(),setTimeout(()=>x.removeSpots())},k.props.onClose=()=>{O.forEach(N=>x.addSpot(N.attributes))},y.click()}}}}),j({editor:n,plan:rp,licenseKey:i.licenseKey,pluginName:sp,cleanup:()=>{t.remove($t),o.removeType($t)}})},ap=W(lp),cp="lightGalleryComponent",dp=H.startup;var Gt=(n=>(n.image="image",n.video="video",n.external="external",n))(Gt||{});const mt="lightGallery",hi=`${mt}-item`,bo="data-lightgallery",fi=`${bo}-item`,To="toggle",bt={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>'},cs={propKeys:[],props:{},traits:[]},fn=(n,e={})=>{var s;const t={},o=[];for(const r in n){const{value:i,...l}=n[r];o.push({id:r,name:r,changeProp:!0,category:e.category,...l}),t[r]=i;const{subTraits:a={}}=l;for(const c in l.subTraits)(s=a[c])==null||s.forEach(d=>{const u=d.id||d.name;t[u]=d.value})}return{propKeys:Object.keys(t),props:t,traits:o}},Bs=(n,e)=>{const t=n.getTrait(e),o=t.get("category"),s=t.get("subTraits")||{},i=(Object.values(s).flat()||[]).map(c=>c.id||c.name);n.removeTrait(i);const l=s[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:o,...c})),{at:a})},ds=(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,()=>Bs(n,t)),Bs(n,t)})},up=(n,e,t)=>{const s=n.getTrait(e).get("subTraits")||{},i=(Object.values(s).flat()||[]).map(a=>{const c=a.name||a.id;return a.changeProp?`change:${c}`:`change:attributes:${c}`}),l=Array.from(new Set(i));l.length&&n.on(l.join(" "),t)},pp={[To]:{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}},hp={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"}]}}},fp={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}]}}},mp={zoom:{category:{id:"zoom-options",label:"Zoom options"},type:"checkbox",label:"Zoom",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"actualSize",label:"Show actual size icon",changeProp:!0,value:!0},{type:"checkbox",name:"infiniteZoom",label:"Infinte zoom",changeProp:!0,value:!0},{type:"checkbox",name:"showZoomInOutIcons",label:"Show zoom in/out icons",changeProp:!0,value:!1},{type:"number",name:"scale",label:"Scale",tip:"Value of zoom should be incremented/decremented",changeProp:!0,min:0,value:1}]}}},Ke="sourceType",no="data-iframe",Hs={name:"href",type:"file",label:"Image Source"},Mo={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},Fs={name:"data-poster",label:"Video Poster",type:"file"},mi={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},$a={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},gp={[To]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var s,r;const t=e.target,o=(s=t==null?void 0:t.closestType(mt))==null?void 0:s.getView();if(o&&t){const i=((r=o.getLightGallery())==null?void 0:r.items)||[],l=Array.from(i).indexOf(t.getEl());l>=0&&o.toggleGallery(l)}}},[Ke]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[Hs],video:[Mo,Fs],external:[mi]},options:[{id:"image",label:Hs.label||"",icon:bt.image},{id:"video",label:Mo.label||"",icon:bt.video},{id:"external",label:mi.label||"",icon:bt.external}]},subHtml:$a},gi="lgThumbnail",yp="lgVideo",yi="lgAutoplay",bi="lgZoom",Ht="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",bp=function(n,e={}){const{Blocks:t,Components:o}=n,s="LightGallery",r="LightGallery Item",i={toolbarIconOpen:bt.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[gi,yp,yi,bi],cdnScript:[`${Ht}/lightgallery.min.js`,`${Ht}/plugins/thumbnail/lg-thumbnail.min.js`,`${Ht}/plugins/video/lg-video.min.js`,`${Ht}/plugins/autoplay/lg-autoplay.min.js`,`${Ht}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${Ht}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=i,d=function(y){const b=this,x=window,{plugins:S,cdnScript:w,cdnStyle:M,inline:k,lgLicenseKey:E,...P}=y||{},O=D=>isNaN(D)?void 0:parseInt(D,10),N=()=>{var J;const D={...P,licenseKey:E,speed:O(P.speed),startAnimationDuration:O(P.startAnimationDuration),thumbMargin:O(P.thumbMargin),thumbWidth:O(P.thumbWidth),slideShowInterval:O(P.slideShowInterval),scale:O(P.scale),enableZoomAfter:O(P.enableZoomAfter),plugins:(S||[]).map(ne=>x[ne])};k&&(D.container=b,D.closable=!1);const V=(J=x.lightGallery)==null?void 0:J.call(x,b,D);k&&V.openGallery()};if(x.lightGallery)N();else{const{head:D}=document,V=Array.isArray(w)?[...w]:[w],J=Array.isArray(M)?[...M]:[M],ne=q=>{if(q.length){const be=document.createElement("link");be.href=q.shift(),be.rel="stylesheet",D.appendChild(be),ne(q)}},Ae=q=>{if(q.length){const be=document.createElement("script");be.src=q.shift(),be.onerror=be.onload=Ae.bind(null,q),D.appendChild(be)}else N()};ne(J),Ae(V)}},u=y=>{const b=y.getTrait(To);if(!a||!b)return;const{toolbar:x}=y,S={id:To,label:a,command:()=>setTimeout(()=>b.runCommand(),100)};!x.find(M=>M.id===S.id)&&(x==null||x.unshift(S))};let p=[];const h=i.plugins||[],f=fn(pp),m=h.includes(gi)?fn(hp):cs,g=h.includes(yi)?fn(fp):cs,v=h.includes(bi)?fn(mp):cs;o.addType(mt,{block:l&&{label:s,media:bt.gallery,category:"Extra",select:!0,...i.block},isComponent:y=>go(y,bo),extendFn:["init","initToolbar"],model:{defaults:{name:s,icon:bt.gallery,draggable:(y,b)=>!b.is(mt),attributes:{[bo]:!0},components:{type:hi},script:d,selector:"",exThumbImage:"",cdnScript:i.cdnScript,cdnStyle:i.cdnStyle,plugins:i.plugins,lgLicenseKey:i.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...f.propKeys,...m.propKeys,...g.propKeys,...v.propKeys],...f.props,...m.props,...g.props,...v.props,traits:[...f.traits,...m.traits,...g.traits,...v.traits]},init(){ds(this,["thumbnail"]),ds(this,["autoplay"]),ds(this,["zoom"])},initToolbar(){u(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,o.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const y=this.getLightGallery();y==null||y.destroy()},disableLgInCanvas(){const y=this.getLightGallery();y.lgOpened=!0},isInlineGallery(){var b;const y=this.getLightGallery();return((b=y==null?void 0:y.settings)==null?void 0:b.container)===this.el},onLgInit(y){this.el.__lg=y.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:y}=this,{Canvas:b}=y,x=this.getLightGallery();p=b.getSpots(),setTimeout(()=>b.removeSpots()),x.__lgOpened=!0},onLgClose(){const y=this.getLightGallery();p.forEach(b=>this.em.Canvas.addSpot(b.attributes)),p=[],y.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(y){const b=this.getLightGallery();if(b.__lgOpened)return b.closeGallery(!0);b.lgOpened=!1,b.openGallery(y)}}});const C=fn(gp);o.addType(hi,{isComponent:y=>go(y,fi)||y.tagName==="A"&&go(y.parentElement,bo),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:r,icon:bt.galleryItem,attributes:{[fi]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...C.props,traits:[...C.traits]},init(){const y=[Ke].map(b=>`change:${b}`).join(" ");this.initSourceType(),this.on(y,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),up(this,Ke,this.triggerGalleryUpdate)},initToolbar(){u(this)},initScriptUpdate(){const y=[$a.name].map(b=>`change:attributes:${b}`).join(" ");this.on(y,this.triggerGalleryUpdate)},triggerGalleryUpdate(...y){var b;(b=this.closestType(mt))==null||b.__scriptPropsChange(...y)},updateTraits(y={}){const{changed:b}=this,{init:x}=y;if(b[Ke]||x){Bs(this,Ke);const S=this.getTrait(Ke).getValue();if(S===Gt.image){this.removeAttributes([Mo.name,Fs.name,no]);const w=this.getTrait(Hs.name);w.setValue(w.getValue()||c)}else S===Gt.video?this.removeAttributes([no]):S===Gt.external&&this.addAttributes({[no]:!0})}},initSourceType(){const y=this.getAttributes({noClass:!0,noStyle:!0});y[no]?this.set(Ke,Gt.external):(y[Mo.name]||y[Fs.name])&&this.set(Ke,Gt.video)}}}),j({editor:n,plan:dp,licenseKey:i.licenseKey,pluginName:cp,cleanup:()=>{t.remove(mt),o.removeType(mt)}})},vp=W(bp),Me="swiper",Ln=`${Me}-slide`,Jt=`${Me}-wrapper`,Yt=`${Me}-nav-prev`,Eo=`${Me}-nav-next`,Zt=`${Me}-pagination`,kn=`${Me}-scrollbar`,le={slider:`<svg viewBox="0 0 24 24">
|
|
76
|
+
`},init(){const C=[p].map(y=>`change:${y}`).join(" ");this.on(C,this.updateTraits),this.on(`change:${p}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(C,y,b){if(b.adjust)return;const x=this.get(p)==="video"?"video":"image";this.addAttributes({[lo]:x,href:""})},adjustSourceType(){const C=this.get(p),y=this.getAttributes().href||"",b={adjust:!0};if(C==="video"){const S=y.includes("youtube.com")?"youtube":"video";this.addAttributes({[lo]:S},b)}else C!=="el"&&y.startsWith("#")?this.set(p,"el",b):C==="image"&&this.addAttributes({[lo]:"image"},b)},updateTraits(C={}){const{changed:y}=this,{init:b}=C;if(y[h.name]||b){this.removeTrait([f.name,m.name,g.name]);const S=this.get(p)||"image",x=this.getTraitIndex(p)+1;this.addTrait(v[S],{at:x})}},initToolbar(){if(!a)return;const{toolbar:C}=this,y=u(this);!C.find(S=>S.id===y.id)&&(C==null||C.unshift(y))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var P;const{em:C,el:y,model:b}=this,{Canvas:S}=C,x=b.getAttributes()[io],{defaultView:w,documentElement:E}=y.ownerDocument,k=(P=w.fsLightboxInstances)==null?void 0:P[x];if(E.classList.contains(Mp))k.close();else{y.__skipLb=!1;let N;k.props.onOpen=()=>{N=S.getSpots(),setTimeout(()=>S.removeSpots())},k.props.onClose=()=>{N.forEach(I=>S.addSpot(I.attributes))},y.click()}}}}),G({editor:n,plan:Ep,licenseKey:i.licenseKey,pluginName:Tp,cleanup:()=>{t.remove(Ft),o.removeType(Ft)}})},Pp=_(Ap),Ip="lightGalleryComponent",Np=H.startup;var qt=(n=>(n.image="image",n.video="video",n.external="external",n))(qt||{});const bt="lightGallery",ki=`${bt}-item`,To="data-lightgallery",Ti=`${To}-item`,Oo="toggle",xt={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',gallery:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',galleryItem:'<svg viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M8 14H6v-2h2v2m0-3H6V9h2v2m0-3H6V6h2v2m7 6h-5v-2h5v2m3-3h-8V9h8v2m0-3h-8V6h8v2Z"/></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},gs={propKeys:[],props:{},traits:[]},bn=(n,e={})=>{var s;const t={},o=[];for(const r in n){const{value:i,...l}=n[r];o.push({id:r,name:r,changeProp:!0,category:e.category,...l}),t[r]=i;const{subTraits:a={}}=l;for(const c in l.subTraits)(s=a[c])==null||s.forEach(d=>{const u=d.id||d.name;t[u]=d.value})}return{propKeys:Object.keys(t),props:t,traits:o}},Ks=(n,e)=>{const t=n.getTrait(e),o=t.get("category"),s=t.get("subTraits")||{},i=(Object.values(s).flat()||[]).map(c=>c.id||c.name);n.removeTrait(i);const l=s[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:o,...c})),{at:a})},ys=(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,()=>Ks(n,t)),Ks(n,t)})},Op=(n,e,t)=>{const s=n.getTrait(e).get("subTraits")||{},i=(Object.values(s).flat()||[]).map(a=>{const c=a.name||a.id;return a.changeProp?`change:${c}`:`change:attributes:${c}`}),l=Array.from(new Set(i));l.length&&n.on(l.join(" "),t)},Rp={[Oo]:{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}},Dp={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"}]}}},Lp={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}]}}},$p={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}]}}},Ze="sourceType",ao="data-iframe",Js={name:"href",type:"file",label:"Image Source"},Ro={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},Zs={name:"data-poster",label:"Video Poster",type:"file"},Ei={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},Xa={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},zp={[Oo]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var s,r;const t=e.target,o=(s=t==null?void 0:t.closestType(bt))==null?void 0:s.getView();if(o&&t){const i=((r=o.getLightGallery())==null?void 0:r.items)||[],l=Array.from(i).indexOf(t.getEl());l>=0&&o.toggleGallery(l)}}},[Ze]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[Js],video:[Ro,Zs],external:[Ei]},options:[{id:"image",label:Js.label||"",icon:xt.image},{id:"video",label:Ro.label||"",icon:xt.video},{id:"external",label:Ei.label||"",icon:xt.external}]},subHtml:Xa},Mi="lgThumbnail",Bp="lgVideo",Ai="lgAutoplay",Pi="lgZoom",Gt="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Vp=function(n,e={}){const{Blocks:t,Components:o}=n,s="LightGallery",r="LightGallery Item",i={toolbarIconOpen:xt.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[Mi,Bp,Ai,Pi],cdnScript:[`${Gt}/lightgallery.min.js`,`${Gt}/plugins/thumbnail/lg-thumbnail.min.js`,`${Gt}/plugins/video/lg-video.min.js`,`${Gt}/plugins/autoplay/lg-autoplay.min.js`,`${Gt}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${Gt}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=i,d=function(y){const b=this,S=window,{plugins:x,cdnScript:w,cdnStyle:E,inline:k,lgLicenseKey:M,...P}=y||{},N=D=>isNaN(D)?void 0:parseInt(D,10),I=()=>{var J;const D={...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:(x||[]).map(ne=>S[ne])};k&&(D.container=b,D.closable=!1);const z=(J=S.lightGallery)==null?void 0:J.call(S,b,D);k&&z.openGallery()};if(S.lightGallery)I();else{const{head:D}=document,z=Array.isArray(w)?[...w]:[w],J=Array.isArray(E)?[...E]:[E],ne=q=>{if(q.length){const be=document.createElement("link");be.href=q.shift(),be.rel="stylesheet",D.appendChild(be),ne(q)}},Pe=q=>{if(q.length){const be=document.createElement("script");be.src=q.shift(),be.onerror=be.onload=Pe.bind(null,q),D.appendChild(be)}else I()};ne(J),Pe(z)}},u=y=>{const b=y.getTrait(Oo);if(!a||!b)return;const{toolbar:S}=y,x={id:Oo,label:a,command:()=>setTimeout(()=>b.runCommand(),100)};!S.find(E=>E.id===x.id)&&(S==null||S.unshift(x))};let p=[];const h=i.plugins||[],f=bn(Rp),m=h.includes(Mi)?bn(Dp):gs,g=h.includes(Ai)?bn(Lp):gs,v=h.includes(Pi)?bn($p):gs;o.addType(bt,{block:l&&{label:s,media:xt.gallery,category:"Extra",select:!0,...i.block},isComponent:y=>Co(y,To),extendFn:["init","initToolbar"],model:{defaults:{name:s,icon:xt.gallery,draggable:(y,b)=>!b.is(bt),attributes:{[To]:!0},components:{type:ki},script:d,selector:"",exThumbImage:"",cdnScript:i.cdnScript,cdnStyle:i.cdnStyle,plugins:i.plugins,lgLicenseKey:i.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...f.propKeys,...m.propKeys,...g.propKeys,...v.propKeys],...f.props,...m.props,...g.props,...v.props,traits:[...f.traits,...m.traits,...g.traits,...v.traits]},init(){ys(this,["thumbnail"]),ys(this,["autoplay"]),ys(this,["zoom"])},initToolbar(){u(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,o.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const y=this.getLightGallery();y==null||y.destroy()},disableLgInCanvas(){const y=this.getLightGallery();y.lgOpened=!0},isInlineGallery(){var b;const y=this.getLightGallery();return((b=y==null?void 0:y.settings)==null?void 0:b.container)===this.el},onLgInit(y){this.el.__lg=y.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:y}=this,{Canvas:b}=y,S=this.getLightGallery();p=b.getSpots(),setTimeout(()=>b.removeSpots()),S.__lgOpened=!0},onLgClose(){const y=this.getLightGallery();p.forEach(b=>this.em.Canvas.addSpot(b.attributes)),p=[],y.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(y){const b=this.getLightGallery();if(b.__lgOpened)return b.closeGallery(!0);b.lgOpened=!1,b.openGallery(y)}}});const C=bn(zp);o.addType(ki,{isComponent:y=>Co(y,Ti)||y.tagName==="A"&&Co(y.parentElement,To),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:r,icon:xt.galleryItem,attributes:{[Ti]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...C.props,traits:[...C.traits]},init(){const y=[Ze].map(b=>`change:${b}`).join(" ");this.initSourceType(),this.on(y,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),Op(this,Ze,this.triggerGalleryUpdate)},initToolbar(){u(this)},initScriptUpdate(){const y=[Xa.name].map(b=>`change:attributes:${b}`).join(" ");this.on(y,this.triggerGalleryUpdate)},triggerGalleryUpdate(...y){var b;(b=this.closestType(bt))==null||b.__scriptPropsChange(...y)},updateTraits(y={}){const{changed:b}=this,{init:S}=y;if(b[Ze]||S){Ks(this,Ze);const x=this.getTrait(Ze).getValue();if(x===qt.image){this.removeAttributes([Ro.name,Zs.name,ao]);const w=this.getTrait(Js.name);w.setValue(w.getValue()||c)}else x===qt.video?this.removeAttributes([ao]):x===qt.external&&this.addAttributes({[ao]:!0})}},initSourceType(){const y=this.getAttributes({noClass:!0,noStyle:!0});y[ao]?this.set(Ze,qt.external):(y[Ro.name]||y[Zs.name])&&this.set(Ze,qt.video)}}}),G({editor:n,plan:Np,licenseKey:i.licenseKey,pluginName:Ip,cleanup:()=>{t.remove(bt),o.removeType(bt)}})},Hp=_(Vp),Me="swiper",Fn=`${Me}-slide`,Qt=`${Me}-wrapper`,en=`${Me}-nav-prev`,Do=`${Me}-nav-next`,tn=`${Me}-pagination`,An=`${Me}-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>`},vi={id:"swiper-responsive",label:"Responsive",icon:le.responsive},xi={id:"swiper-extra",label:"Extra",icon:le.extra},xp={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(Yt),setValue:({component:n,value:e})=>{var t,o;e?n.append([{type:Yt},{type:Eo}]):((t=n.findFirstType(Yt))==null||t.remove(),(o=n.findFirstType(Eo))==null||o.remove()),n.set({navigation:e})}},initialSlide:{type:"number",label:"Initial slide",min:0,value:"0"},speed:{type:"number",label:"Speed",tip:"Transition duration (in ms)",step:500,min:0,value:300},effect:{category:{id:"swiper-effect",label:"Effects",icon:le.effect},type:"select",label:"Effect Type",value:"slide",options:[{id:"slide",label:"Slide"},{id:"fade",label:"Fade"},{id:"cube",label:"Cube"},{id:"coverflow",label:"Coverflow"},{id:"flip",label:"Flip"},{id:"cards",label:"Cards"}],subTraits:{slide:[{type:"number",name:"slidesPerView",label:"Slides per view",changeProp:!0,min:1,value:1},{type:"number",name:"slidesPerGroup",label:"Slides per group",tip:"Numbers of slides for group sliding",changeProp:!0,min:1,value:1},{type:"number",name:"spaceBetween",label:"Space between",tip:"Distance between slides in px",changeProp:!0,min:0,value:0},{type:"number",name:"slidesOffsetBefore",label:"Slides offset before",tip:"Add additional slide offset in the beginning of the container (in px, before all slides)",changeProp:!0,min:0,value:0},{type:"number",name:"slidesOffsetAfter",label:"Slides offset after",tip:"Add additional slide offset in the end of the container (in px, after all slides)",changeProp:!0,min:0,value:0},{type:"checkbox",name:"centeredSlides",label:"Centered slides",tip:"If enabled, the active slide will be centered",changeProp:!0,value:!1}],fade:[{type:"checkbox",name:"crossFade",tip:"Enables slides cross fade",label:"Cross fade",changeProp:!0,value:!1}],cube:[{type:"checkbox",name:"cubeEffectShadow",label:"Shadow",changeProp:!0,value:!0},{type:"checkbox",name:"cubeEffectSlideShadows",label:"Slide shadows",changeProp:!0,value:!0},{type:"number",name:"cubeEffectShadowOffset",label:"Shadow offset",changeProp:!0,value:20},{type:"number",name:"cubeEffectShadowScale",label:"Shadow scale",changeProp:!0,value:.94}],coverflow:[{type:"number",name:"coverflowEffectDepth",tip:"Depth offset in px (slides translate in Z axis)",label:"Depth",changeProp:!0,min:0,value:100},{type:"number",name:"coverflowEffectModifier",tip:"Effect multiplier",label:"Modifier",changeProp:!0,step:.1,min:0,value:1},{type:"number",name:"coverflowEffectRotate",tip:"Slide rotate in degrees",label:"Rotate",changeProp:!0,min:0,value:50},{type:"number",name:"coverflowEffectScale",tip:"Slide scale effect",label:"Scale",changeProp:!0,min:0,step:.1,value:1},{type:"number",name:"coverflowEffectStretch",tip:"Stretch space between slides (in px)",label:"Stretch",changeProp:!0,min:0,value:0},{type:"checkbox",name:"coverflowEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadow",changeProp:!0,value:!0}],flip:[{type:"checkbox",name:"flipEffectLimitRotation",tip:"Limit edge slides rotation",label:"Limit rotation",changeProp:!0,value:!0},{type:"checkbox",name:"flipEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadows",changeProp:!0,value:!0}],cards:[{type:"number",name:"cardsEffectPerSlideOffset",tip:"Offset distance per slide (in px)",label:"Slide offset",changeProp:!0,min:0,value:8},{type:"number",name:"cardsEffectPerSlideRotate",tip:"Rotate angle per slide (in degrees)",label:"Slide rotate",changeProp:!0,min:0,value:2},{type:"checkbox",name:"cardsEffectRotate",tip:"Enables cards rotation",label:"Rotate",changeProp:!0,value:!0},{type:"checkbox",name:"cardsEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadows",changeProp:!0,value:!0}]}},autoplay:{category:{id:"swiper-autoplay",label:"Autoplay",icon:le.autoplay},type:"checkbox",label:"Enable Autoplay",value:!1,subTraits:{true:[{type:"number",name:"autoplayDelay",label:"Delay",changeProp:!0,value:3e3},{type:"checkbox",name:"autoplayDisableOnInteraction",label:"Disable on interaction",changeProp:!0,value:!0},{type:"checkbox",name:"autoplayWaitForTransition",label:"Wait for transition",changeProp:!0,value:!0},{type:"checkbox",name:"autoplayPauseOnMouseEnter",label:"Pause on mouse enter",changeProp:!0,value:!1},{type:"checkbox",name:"autoplayReverseDirection",label:"Reverse direction",changeProp:!0,value:!1},{type:"checkbox",name:"autoplayStopOnLastSlide",label:"Stop on last slide",changeProp:!0,value:!1}]}},pagination:{category:{id:"swiper-pagination",label:"Pagination",icon:le.pagination},type:"select",label:"Pagination Type",options:[{id:"none",label:"None"},{id:"bullets",label:"Bullets"},{id:"progressbar",label:"Progressbar"},{id:"fraction",label:"Fraction"}],getValue:({component:n})=>n.findFirstType(Zt)?n.get("pagination")||"bullets":"none",setValue:({component:n,value:e})=>{const t=n.findFirstType(Zt);t==null||t.remove(),e!=="none"&&n.append({type:Zt}),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(kn),setValue:({component:n,value:e})=>{const t=n.findFirstType(kn);t==null||t.remove(),e&&n.append({type:kn}),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:vi,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:vi,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:xi,type:"checkbox",label:"Allow touch move",tip:"Allow touch interactions",value:!0},grabCursor:{category:xi,type:"checkbox",label:"Grab cursor",tip:'If enabled, the user will see the "grab" cursor when hover the slider',value:!1}},Si="Slider",_s="swiper",pn=`${_s}-`,Sp=(n,e)=>{const{Components:t,Blocks:o,Commands:s}=n,{block:r}=e,i=nu(xp),l="core:preview",a=s.events,c=function(p){const h=this,f=window,m=h.__onLoad,g=h.__activeSlide,v=h.__inPreview,{cdnScript:C,cdnStyle:y,slidesPerView:b}=p||{},x=w=>isNaN(w)?void 0:parseFloat(w),S=()=>{const w={loop:p.loop,speed:p.speed,initialSlide:p.initialSlide,direction:p.vertical?"vertical":"horizontal",effect:p.effect,freeMode:p.freeMode,parallax:p.parallax,autoHeight:p.autoHeight,allowTouchMove:p.allowTouchMove,grabCursor:p.grabCursor,simulateTouch:!0,breakpoints:{},slidesPerView:isNaN(b)?b:x(b),slidesPerGroup:x(p.slidesPerGroup),spaceBetween:x(p.spaceBetween),slidesOffsetBefore:x(p.slidesOffsetBefore),slidesOffsetAfter:x(p.slidesOffsetAfter),centeredSlides:p.centeredSlides,fadeEffect:{crossFade:p.crossFade},cubeEffect:{shadow:p.cubeEffectShadow,slideShadows:p.cubeEffectSlideShadows,shadowOffset:x(p.cubeEffectShadowOffset),shadowScale:x(p.cubeEffectShadowScale)},coverflowEffect:{depth:x(p.coverflowEffectDepth),modifier:x(p.coverflowEffectModifier),rotate:x(p.coverflowEffectRotate),scale:x(p.coverflowEffectScale),stretch:x(p.coverflowEffectStretch),slideShadows:p.coverflowEffectSlideShadows},flipEffect:{limitRotation:p.flipEffectLimitRotation,slideShadows:p.flipEffectSlideShadows},cardsEffect:{perSlideOffset:x(p.cardsEffectPerSlideOffset),perSlideRotate:x(p.cardsEffectPerSlideRotate),rotate:p.cardsEffectRotate,slideShadows:p.cardsEffectSlideShadows},navigation:{nextEl:h.querySelector(".swiper-button-next"),prevEl:h.querySelector(".swiper-button-prev")},pagination:{type:p.pagination||"bullets",dynamicBullets:p.dynamicBullets,clickable:p.clickableBullets,progressbarOpposite:p.progressbarOpposite,el:h.querySelector(".swiper-pagination")},scrollbar:{el:h.querySelector(".swiper-scrollbar"),draggable:p.scrollbarDraggable,hide:p.scrollbarHide},autoplay:p.autoplay&&{delay:p.autoplayDelay,disableOnInteraction:p.autoplayDisableOnInteraction,pauseOnMouseEnter:p.autoplayPauseOnMouseEnter,reverseDirection:p.autoplayReverseDirection,stopOnLastSlide:p.autoplayStopOnLastSlide,waitForTransition:p.autoplayWaitForTransition}};if(p.tablet){const{tabletBreakpoint:k,tabletSlidesPerView:E}=p,P=x(k);w.breakpoints[P]={slidesPerView:isNaN(E)?E:x(E),slidesPerGroup:x(p.tabletSlidesPerGroup),spaceBetween:x(p.tabletSpaceBetween)}}if(p.mobile){const{mobileBreakpoint:k,mobileSlidesPerView:E}=p,P=x(k);w.breakpoints[P]={slidesPerView:isNaN(E)?E:x(E),slidesPerGroup:x(p.mobileSlidesPerGroup),spaceBetween:x(p.mobileSpaceBetween)}}m&&!v&&(w.simulateTouch=!1),g&&(w.initialSlide=g);const M=new f.Swiper(h,w);m==null||m(M)};if(f.Swiper)S();else{const{head:w}=document,M=Array.isArray(C)?[...C]:[C],k=Array.isArray(y)?[...y]:[y],E=O=>{if(O.length){const N=document.createElement("link");N.href=O.shift(),N.rel="stylesheet",w.appendChild(N),E(O)}},P=O=>{if(O.length){const N=document.createElement("script");N.src=O.shift(),N.onerror=N.onload=P.bind(null,O),w.appendChild(N)}else S()};E(k),P(M)}},d=(p=0)=>({type:Ln,style:{padding:"50px"},components:{type:"text",components:{type:"textnode",content:`Slide ${p}`}}}),u=t.getType("default").model;return t.addType(Me,{block:r&&{label:Si,media:le.slider,category:"Extra",select:!0,...e.block},isComponent:p=>Pt(p,_s),model:{defaults:()=>({name:Si,icon:le.slider,classes:_s,draggable:(p,h)=>!h.is(Me),components:[{type:Jt,components:[d(1),d(2),d(3)]},{type:Zt}],script:c,cdnScript:e.cdnScript,cdnStyle:e.cdnStyle,"script-props":["cdnScript","cdnStyle",...i.propKeys],...i.props,traits:[...i.traits]}),init(){const{em:p}=this;ou(this,i.traits),su(this,i.propKeys),this.listenTo(p,`${a.runCommand}${l}`,this.onPreviewOn),this.listenTo(p,`${a.stopCommand}${l}`,this.onPreviewOff)},onPreviewOn(){this.__inPreview=!0,this.reloadSlider()},onPreviewOff(){this.__inPreview=!1,this.reloadSlider()},reloadSlider(){this.trigger("rerender")},addSlide(){const p=this.findFirstType(Jt);p==null||p.append(this.getNewSlideComponentDef())},getNewSlideComponentDef(){var h;const p=((h=this.findFirstType(Jt))==null?void 0:h.components().length)||0;return{type:Ln,components:{type:"text",components:{type:"textnode",content:`Slide ${p+1}`}}}},toJSON(...p){const h=u.prototype.toJSON.apply(this,p);return i.propsNoValues.forEach(f=>delete h[f]),delete h["script-props"],h}},view:{init(){this.listenTo(this.model,t.events.scriptUnmount,this.destroySwiper)},getSwiper(){return this.el.swiper},destroySwiper(){var p;(p=this.getSwiper())==null||p.destroy()},onRender(){const p=this.el;p.__onLoad=h=>h.on("slideChange",()=>this.__activeSlide=h.activeIndex),p.__activeSlide=this.__activeSlide,p.__inPreview=this.model.__inPreview}}}),()=>{t.removeType(Me),o.remove(Me)}},wp="Nav Prev",Cp="Nav Next",oo=`${pn}button-prev`,so=`${pn}button-next`,kp=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(Yt,{isComponent:o=>Pt(o,oo),model:{defaults:{name:wp,classes:oo,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>`},Ii={id:"swiper-responsive",label:"Responsive",icon:le.responsive},Ni={id:"swiper-extra",label:"Extra",icon:le.extra},Fp={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(en),setValue:({component:n,value:e})=>{var t,o;e?n.append([{type:en},{type:Do}]):((t=n.findFirstType(en))==null||t.remove(),(o=n.findFirstType(Do))==null||o.remove()),n.set({navigation:e})}},initialSlide:{type:"number",label:"Initial slide",min:0,value:"0"},speed:{type:"number",label:"Speed",tip:"Transition duration (in ms)",step:500,min:0,value:300},effect:{category:{id:"swiper-effect",label:"Effects",icon:le.effect},type:"select",label:"Effect Type",value:"slide",options:[{id:"slide",label:"Slide"},{id:"fade",label:"Fade"},{id:"cube",label:"Cube"},{id:"coverflow",label:"Coverflow"},{id:"flip",label:"Flip"},{id:"cards",label:"Cards"}],subTraits:{slide:[{type:"number",name:"slidesPerView",label:"Slides per view",changeProp:!0,min:1,value:1},{type:"number",name:"slidesPerGroup",label:"Slides per group",tip:"Numbers of slides for group sliding",changeProp:!0,min:1,value:1},{type:"number",name:"spaceBetween",label:"Space between",tip:"Distance between slides in px",changeProp:!0,min:0,value:0},{type:"number",name:"slidesOffsetBefore",label:"Slides offset before",tip:"Add additional slide offset in the beginning of the container (in px, before all slides)",changeProp:!0,min:0,value:0},{type:"number",name:"slidesOffsetAfter",label:"Slides offset after",tip:"Add additional slide offset in the end of the container (in px, after all slides)",changeProp:!0,min:0,value:0},{type:"checkbox",name:"centeredSlides",label:"Centered slides",tip:"If enabled, the active slide will be centered",changeProp:!0,value:!1}],fade:[{type:"checkbox",name:"crossFade",tip:"Enables slides cross fade",label:"Cross fade",changeProp:!0,value:!1}],cube:[{type:"checkbox",name:"cubeEffectShadow",label:"Shadow",changeProp:!0,value:!0},{type:"checkbox",name:"cubeEffectSlideShadows",label:"Slide shadows",changeProp:!0,value:!0},{type:"number",name:"cubeEffectShadowOffset",label:"Shadow offset",changeProp:!0,value:20},{type:"number",name:"cubeEffectShadowScale",label:"Shadow scale",changeProp:!0,value:.94}],coverflow:[{type:"number",name:"coverflowEffectDepth",tip:"Depth offset in px (slides translate in Z axis)",label:"Depth",changeProp:!0,min:0,value:100},{type:"number",name:"coverflowEffectModifier",tip:"Effect multiplier",label:"Modifier",changeProp:!0,step:.1,min:0,value:1},{type:"number",name:"coverflowEffectRotate",tip:"Slide rotate in degrees",label:"Rotate",changeProp:!0,min:0,value:50},{type:"number",name:"coverflowEffectScale",tip:"Slide scale effect",label:"Scale",changeProp:!0,min:0,step:.1,value:1},{type:"number",name:"coverflowEffectStretch",tip:"Stretch space between slides (in px)",label:"Stretch",changeProp:!0,min:0,value:0},{type:"checkbox",name:"coverflowEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadow",changeProp:!0,value:!0}],flip:[{type:"checkbox",name:"flipEffectLimitRotation",tip:"Limit edge slides rotation",label:"Limit rotation",changeProp:!0,value:!0},{type:"checkbox",name:"flipEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadows",changeProp:!0,value:!0}],cards:[{type:"number",name:"cardsEffectPerSlideOffset",tip:"Offset distance per slide (in px)",label:"Slide offset",changeProp:!0,min:0,value:8},{type:"number",name:"cardsEffectPerSlideRotate",tip:"Rotate angle per slide (in degrees)",label:"Slide rotate",changeProp:!0,min:0,value:2},{type:"checkbox",name:"cardsEffectRotate",tip:"Enables cards rotation",label:"Rotate",changeProp:!0,value:!0},{type:"checkbox",name:"cardsEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadows",changeProp:!0,value:!0}]}},autoplay:{category:{id:"swiper-autoplay",label:"Autoplay",icon:le.autoplay},type:"checkbox",label:"Enable Autoplay",value:!1,subTraits:{true:[{type:"number",name:"autoplayDelay",label:"Delay",changeProp:!0,value:3e3},{type:"checkbox",name:"autoplayDisableOnInteraction",label:"Disable on interaction",changeProp:!0,value:!0},{type:"checkbox",name:"autoplayWaitForTransition",label:"Wait for transition",changeProp:!0,value:!0},{type:"checkbox",name:"autoplayPauseOnMouseEnter",label:"Pause on mouse enter",changeProp:!0,value:!1},{type:"checkbox",name:"autoplayReverseDirection",label:"Reverse direction",changeProp:!0,value:!1},{type:"checkbox",name:"autoplayStopOnLastSlide",label:"Stop on last slide",changeProp:!0,value:!1}]}},pagination:{category:{id:"swiper-pagination",label:"Pagination",icon:le.pagination},type:"select",label:"Pagination Type",options:[{id:"none",label:"None"},{id:"bullets",label:"Bullets"},{id:"progressbar",label:"Progressbar"},{id:"fraction",label:"Fraction"}],getValue:({component:n})=>n.findFirstType(tn)?n.get("pagination")||"bullets":"none",setValue:({component:n,value:e})=>{const t=n.findFirstType(tn);t==null||t.remove(),e!=="none"&&n.append({type:tn}),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(An),setValue:({component:n,value:e})=>{const t=n.findFirstType(An);t==null||t.remove(),e&&n.append({type:An}),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:Ii,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:Ii,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:Ni,type:"checkbox",label:"Allow touch move",tip:"Allow touch interactions",value:!0},grabCursor:{category:Ni,type:"checkbox",label:"Grab cursor",tip:'If enabled, the user will see the "grab" cursor when hover the slider',value:!1}},Oi="Slider",Ys="swiper",gn=`${Ys}-`,_p=(n,e)=>{const{Components:t,Blocks:o,Commands:s}=n,{block:r}=e,i=Cu(Fp),l="core:preview",a=s.events,c=function(p){const h=this,f=window,m=h.__onLoad,g=h.__activeSlide,v=h.__inPreview,{cdnScript:C,cdnStyle:y,slidesPerView:b}=p||{},S=w=>isNaN(w)?void 0:parseFloat(w),x=()=>{const w={loop:p.loop,speed:p.speed,initialSlide:p.initialSlide,direction:p.vertical?"vertical":"horizontal",effect:p.effect,freeMode:p.freeMode,parallax:p.parallax,autoHeight:p.autoHeight,allowTouchMove:p.allowTouchMove,grabCursor:p.grabCursor,simulateTouch:!0,breakpoints:{},slidesPerView:isNaN(b)?b:S(b),slidesPerGroup:S(p.slidesPerGroup),spaceBetween:S(p.spaceBetween),slidesOffsetBefore:S(p.slidesOffsetBefore),slidesOffsetAfter:S(p.slidesOffsetAfter),centeredSlides:p.centeredSlides,fadeEffect:{crossFade:p.crossFade},cubeEffect:{shadow:p.cubeEffectShadow,slideShadows:p.cubeEffectSlideShadows,shadowOffset:S(p.cubeEffectShadowOffset),shadowScale:S(p.cubeEffectShadowScale)},coverflowEffect:{depth:S(p.coverflowEffectDepth),modifier:S(p.coverflowEffectModifier),rotate:S(p.coverflowEffectRotate),scale:S(p.coverflowEffectScale),stretch:S(p.coverflowEffectStretch),slideShadows:p.coverflowEffectSlideShadows},flipEffect:{limitRotation:p.flipEffectLimitRotation,slideShadows:p.flipEffectSlideShadows},cardsEffect:{perSlideOffset:S(p.cardsEffectPerSlideOffset),perSlideRotate:S(p.cardsEffectPerSlideRotate),rotate:p.cardsEffectRotate,slideShadows:p.cardsEffectSlideShadows},navigation:{nextEl:h.querySelector(".swiper-button-next"),prevEl:h.querySelector(".swiper-button-prev")},pagination:{type:p.pagination||"bullets",dynamicBullets:p.dynamicBullets,clickable:p.clickableBullets,progressbarOpposite:p.progressbarOpposite,el:h.querySelector(".swiper-pagination")},scrollbar:{el:h.querySelector(".swiper-scrollbar"),draggable:p.scrollbarDraggable,hide:p.scrollbarHide},autoplay:p.autoplay&&{delay:p.autoplayDelay,disableOnInteraction:p.autoplayDisableOnInteraction,pauseOnMouseEnter:p.autoplayPauseOnMouseEnter,reverseDirection:p.autoplayReverseDirection,stopOnLastSlide:p.autoplayStopOnLastSlide,waitForTransition:p.autoplayWaitForTransition}};if(p.tablet){const{tabletBreakpoint:k,tabletSlidesPerView:M}=p,P=S(k);w.breakpoints[P]={slidesPerView:isNaN(M)?M:S(M),slidesPerGroup:S(p.tabletSlidesPerGroup),spaceBetween:S(p.tabletSpaceBetween)}}if(p.mobile){const{mobileBreakpoint:k,mobileSlidesPerView:M}=p,P=S(k);w.breakpoints[P]={slidesPerView:isNaN(M)?M:S(M),slidesPerGroup:S(p.mobileSlidesPerGroup),spaceBetween:S(p.mobileSpaceBetween)}}m&&!v&&(w.simulateTouch=!1),g&&(w.initialSlide=g);const E=new f.Swiper(h,w);m==null||m(E)};if(f.Swiper)x();else{const{head:w}=document,E=Array.isArray(C)?[...C]:[C],k=Array.isArray(y)?[...y]:[y],M=N=>{if(N.length){const I=document.createElement("link");I.href=N.shift(),I.rel="stylesheet",w.appendChild(I),M(N)}},P=N=>{if(N.length){const I=document.createElement("script");I.src=N.shift(),I.onerror=I.onload=P.bind(null,N),w.appendChild(I)}else x()};M(k),P(E)}},d=(p=0)=>({type:Fn,style:{padding:"50px"},components:{type:"text",components:{type:"textnode",content:`Slide ${p}`}}}),u=t.getType("default").model;return t.addType(Me,{block:r&&{label:Oi,media:le.slider,category:"Extra",select:!0,...e.block},isComponent:p=>Ot(p,Ys),model:{defaults:()=>({name:Oi,icon:le.slider,classes:Ys,draggable:(p,h)=>!h.is(Me),components:[{type:Qt,components:[d(1),d(2),d(3)]},{type:tn}],script:c,cdnScript:e.cdnScript,cdnStyle:e.cdnStyle,"script-props":["cdnScript","cdnStyle",...i.propKeys],...i.props,traits:[...i.traits]}),init(){const{em:p}=this;ku(this,i.traits),Tu(this,i.propKeys),this.listenTo(p,`${a.runCommand}${l}`,this.onPreviewOn),this.listenTo(p,`${a.stopCommand}${l}`,this.onPreviewOff)},onPreviewOn(){this.__inPreview=!0,this.reloadSlider()},onPreviewOff(){this.__inPreview=!1,this.reloadSlider()},reloadSlider(){this.trigger("rerender")},addSlide(){const p=this.findFirstType(Qt);p==null||p.append(this.getNewSlideComponentDef())},getNewSlideComponentDef(){var h;const p=((h=this.findFirstType(Qt))==null?void 0:h.components().length)||0;return{type:Fn,components:{type:"text",components:{type:"textnode",content:`Slide ${p+1}`}}}},toJSON(...p){const h=u.prototype.toJSON.apply(this,p);return i.propsNoValues.forEach(f=>delete h[f]),delete h["script-props"],h}},view:{init(){this.listenTo(this.model,t.events.scriptUnmount,this.destroySwiper)},getSwiper(){return this.el.swiper},destroySwiper(){var p;(p=this.getSwiper())==null||p.destroy()},onRender(){const p=this.el;p.__onLoad=h=>h.on("slideChange",()=>this.__activeSlide=h.activeIndex),p.__activeSlide=this.__activeSlide,p.__inPreview=this.model.__inPreview}}}),()=>{t.removeType(Me),o.remove(Me)}},Gp="Nav Prev",Wp="Nav Next",co=`${gn}button-prev`,uo=`${gn}button-next`,jp=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(en,{isComponent:o=>Ot(o,co),model:{defaults:{name:Gp,classes:co,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
|
+
.${co} {
|
|
101
101
|
color: inherit;
|
|
102
102
|
}
|
|
103
|
-
.${
|
|
103
|
+
.${co}:after {
|
|
104
104
|
content: none;
|
|
105
105
|
}
|
|
106
|
-
`}}}),e.addType(
|
|
107
|
-
.${
|
|
106
|
+
`}}}),e.addType(Do,{extend:en,isComponent:o=>Ot(o,uo),model:{defaults:{name:Wp,classes:uo,components:t("M27,22L27,22L5,44l-2.1-2.1L22.8,22L2.9,2.1L5,0L27,22L27,22z"),styles:`
|
|
107
|
+
.${uo} {
|
|
108
108
|
color: inherit;
|
|
109
109
|
}
|
|
110
|
-
.${
|
|
110
|
+
.${uo}:after {
|
|
111
111
|
content: none;
|
|
112
112
|
}
|
|
113
|
-
`}}}),()=>{e.removeType(
|
|
113
|
+
`}}}),()=>{e.removeType(en),e.removeType(Do)}},qp=n=>{const{Components:e}=n,t=`${gn}pagination`;return e.addType(tn,{isComponent:o=>Ot(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(
|
|
120
|
+
`}}}),()=>{e.removeType(tn)}},Up="Scrollbar",Ri=`${gn}scrollbar`,Kp=n=>{const{Components:e}=n;return e.addType(An,{isComponent:t=>Ot(t,Ri),model:{defaults:{name:Up,classes:Ri,copyable:!1,highlightable:!1,removable:!1,selectable:!1,hoverable:!1,layerable:!1,droppable:!1,draggable:!1}}}),()=>{e.removeType(An)}},Jp="Slide",Di=`${gn}slide`,Zp=n=>{const{Components:e}=n;return e.addType(Fn,{isComponent:t=>Ot(t,Di),model:{defaults:{name:Jp,classes:Di,icon:le.slider,draggable:(t,o)=>o.is(Qt)}}}),()=>{e.removeType(Fn)}},Yp="Wrapper",Li=`${gn}wrapper`,Xp=n=>{const{Components:e}=n,{events:t}=e;return e.addType(Qt,{isComponent:o=>Ot(o,Li),model:{defaults:{name:Yp,icon:le.slider,classes:Li,copyable:!1,removable:!1,draggable:!1,highlightable:!1,droppable:o=>o.is(Fn)},init(){const o=this.components();this.listenTo(o,"add remove",this.updateSlider)},updateSlider(o){const s=this.closestType(Me);if(s){const r=s.getView();s.reloadSlider(),this.em.once(t.scriptMount,()=>{setTimeout(()=>{var i;return(i=r.getSwiper())==null?void 0:i.slideTo(o.index())},100)})}}}}),()=>{e.removeType(Qt)}},Qp="swiperComponent",eh=H.startup,th=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=[_p(n,t),jp(n),Xp(n),Zp(n),qp(n),Kp(n)];G({editor:n,plan:eh,licenseKey:t.licenseKey,pluginName:Qp,cleanup:()=>{o.forEach(s=>s())}})},nh=_(th),ue="accordion",vn=`${ue}-group`,qe=`${ue}-header`,ot=`${ue}-content`,wt=`${ue}-marker`,$i=`${$e}${qe}`,Xs=`${$e}${wt}`,oh=`${$e}${ot}`,Qa=`${Xs}-open`,Rt={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>'},ec=(n,e)=>{const{toolbarIconOpen:t=Rt.eye}=e,o=n.is(ue)?n:n.closestType(ue);if(!t||!o)return;const{toolbar:s}=n,r={id:"accordion-toggle-open",label:t,command:()=>o.toggleOpen()};!s.find(l=>l.id===r.id)&&(s==null||s.unshift(r))},sh=(n,e)=>{const{Components:t,Blocks:o}=n,{block:s={}}=e,r="Accordion",i=`${$e}${ue}`,l=function(a={}){const c=this,d=()=>{const{clsMarkerOpen:u}=a,p=c.querySelector('[data-type-role="accordion-marker"]');!p||!u||(c.open?p.classList.add(u):p.classList.remove(u))};c.addEventListener("toggle",()=>{d(),c.dispatchEvent(new CustomEvent("details-toggle",{bubbles:!0}))}),d()};return t.addType(ue,{block:s&&{label:r,media:Rt.accordion,category:"Extra",select:!0,...s},isComponent:pt(ue),extendFn:["initToolbar"],model:{defaults:{tagName:"details",name:r,classes:i,emptyState:!0,clsMarkerOpen:Qa,attributes:{[Je]:ue},droppable:es(qe,ot),components:[{type:qe},{type:ot}],"script-props":["clsMarkerOpen"],script:l,traits:[{type:"checkbox",name:"open",label:"Open"}],styles:`
|
|
121
121
|
.${i}::details-content {
|
|
122
122
|
opacity: 0;
|
|
123
123
|
block-size: 0;
|
|
@@ -134,50 +134,50 @@
|
|
|
134
134
|
transform: translateY(0);
|
|
135
135
|
block-size: auto;
|
|
136
136
|
}
|
|
137
|
-
`},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){
|
|
137
|
+
`},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){ec(this,e)}}}),()=>{o.remove(ue),t.removeType(ue)}},rh=n=>{const{Components:e}=n;return e.addType(ot,{isComponent:pt(ot),model:{defaults:{name:"Accordion Content",removable:!1,copyable:!1,draggable:!1,emptyState:!0,classes:oh,icon:Rt.accordionContent,attributes:{[Je]:ot},components:"<div>Accordion content</div>"}}}),()=>{e.removeType(ot)}},ih=(n,e)=>{const{Components:t,Blocks:o}=n,{blockGroup:s={}}=e,r="Accordion Group",i=function(a={}){if(!a.single)return;const c=this;c.addEventListener("details-toggle",d=>{const u=d.target;if(!a.single||!u||!u.open)return;c.querySelectorAll('[data-type-role="accordion"]').forEach(h=>{u!==h&&h.open&&(h.open=!1)})})},l=(a={})=>({type:ue,attributes:{open:a.open},components:[{type:qe,components:[`<div>${a.header}</div>`,{type:wt}]},{type:ot,components:`<div>${a.content}</div>`}]});return t.addType(vn,{block:s&&{label:r,media:Rt.accordionGroup,category:"Extra",select:!0,...s},isComponent:pt(vn),model:{defaults:{name:r,attributes:{[Je]:vn},droppable:es(ue),single:!0,emptyState:!0,components:Array(3).fill(0).map((a,c)=>l({open:c===0,header:`Accordion header ${c+1}`,content:`Accordion content ${c+1}`})),traits:[{type:"checkbox",name:"single",changeProp:!0,tip:"Only one accordion can be open at a time",label:"Single open"}],"script-props":["single"],script:i}}}),()=>{o.remove(vn),t.removeType(vn)}},lh=(n,e)=>{const{Components:t}=n;return t.addType(qe,{isComponent:pt(qe),extendFn:["initToolbar"],model:{defaults:{tagName:"summary",name:"Accordion Header",removable:!1,copyable:!1,draggable:!1,emptyState:!0,icon:Rt.accordionHeader,classes:$i,attributes:{[Je]:qe},components:["<div>Accordion header</div>",{type:wt}],styles:`
|
|
138
138
|
summary {
|
|
139
139
|
list-style: none;
|
|
140
140
|
}
|
|
141
|
-
.${
|
|
141
|
+
.${$i} {
|
|
142
142
|
cursor: pointer;
|
|
143
143
|
display: flex;
|
|
144
144
|
align-items: center;
|
|
145
145
|
justify-content: space-between;
|
|
146
146
|
gap: 1rem;
|
|
147
147
|
}
|
|
148
|
-
`},initToolbar(){
|
|
149
|
-
.${
|
|
148
|
+
`},initToolbar(){ec(this,e)}}}),()=>{t.removeType(qe)}},ah=n=>{const{Components:e}=n;return e.addType(wt,{extend:"icon",isComponent:pt(wt),model:{defaults:{name:"Accordion Marker",icon:Rt.accordionMarker,classes:Xs,attributes:{[Je]:wt},components:Rt.caret,droppable:!1,draggable:$r(qe),styles:`
|
|
149
|
+
.${Xs} {
|
|
150
150
|
min-width: 24px;
|
|
151
151
|
width: 24px;
|
|
152
152
|
height: 24px;
|
|
153
153
|
transition: transform 0.2s ease-in-out;
|
|
154
154
|
}
|
|
155
|
-
.${
|
|
155
|
+
.${Qa} {
|
|
156
156
|
transform: rotateZ(180deg);
|
|
157
157
|
}
|
|
158
|
-
`}}}),()=>{e.removeType(
|
|
158
|
+
`}}}),()=>{e.removeType(wt)}},ch="accordionComponent",dh=H.startup,uh=function(n,e={}){const t=[sh(n,e),ih(n,e),lh(n,e),ah(n),rh(n)];G({editor:n,licenseKey:e.licenseKey,plan:dh,pluginName:ch,cleanup:()=>{t.forEach(o=>o())}})},ph=_(uh),zn=class zn{constructor(e){this.config=e}getSize(e){var t;return(t=this.config)!=null&&t.getSize?this.config.getSize(e):_r(e.componentColumn,zn.CSS_FLEX_BASIS)}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:o,sizeValue:s,partial:r}=e;o.addStyle({[zn.CSS_FLEX_BASIS]:s},{partial:r})}}};zn.CSS_FLEX_BASIS="flex-basis";let Qs=zn;const Bn=class Bn{constructor(e){this.config=e}isGapSupported(){return!0}getGap(e){var t;return(t=this.config)!=null&&t.getGap?this.config.getGap(e):_r(e.componentRow,Bn.CSS_GAP)}setGap(e){var t;if((t=this.config)!=null&&t.setGap)this.config.setGap(e);else{const{componentRow:o,gapValue:s,partial:r}=e;o.addStyle({[Bn.CSS_GAP]:s},{partial:r})}}};Bn.CSS_GAP="gap";let er=Bn;const Xo=class Xo{constructor(e){this.config=e}getParentSize(e){var r;if((r=this.config)!=null&&r.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:o}=e,s=t.getEl();return s?o?s.clientHeight:s.clientWidth:0}isLayoutVertical(e){var o;if((o=this.config)!=null&&o.isParentVertical)return this.config.isParentVertical(e);const t=_r(e.componentRow,Xo.CSS_FLEX_DIRECTION,!0);return t==="column"||t==="column-reverse"}};Xo.CSS_FLEX_DIRECTION="flex-direction";let tr=Xo;const Vn=class Vn{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(Vn.MJML_COLUMN_TYPE)){const r=t.getAttributes().width;if(r&&(r.includes("%")||!isNaN(parseFloat(r))))return parseFloat(r);const i=t.parent();return 100/(i?i.components().length:1)}return 0}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:o,sizeValue:s,partial:r}=e;o.is(Vn.MJML_COLUMN_TYPE)&&o.addAttributes({width:`${parseFloat(s)}%`},{partial:r})}}};Vn.MJML_COLUMN_TYPE="mj-column";let nr=Vn;const Qo=class Qo{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(Qo.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)}};Qo.MJML_SECTION_TYPE="mj-section";let or=Qo;class hh{constructor(e){this.config=e}getParentSize(e){var i;if((i=this.config)!=null&&i.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:o}=e,s=t.getEl();if(!s)return 0;let r=s;if(s.tagName!=="TABLE"){const l=s.querySelectorAll("table");l.length&&(r=l[0])}return o?r.clientHeight:r.clientWidth}isLayoutVertical(e){var t;return(t=this.config)!=null&&t.isParentVertical?this.config.isParentVertical(e):!1}}class Zt{constructor(){this.handlerCache=new Map}static getInstance(){return Zt.instance||(Zt.instance=new Zt),Zt.instance}getHandlers(e){const t=`${e.projectType}-${e.disableGapHandler?"nogap":"gap"}`;return this.handlerCache.has(t)||(an(e)?this.handlerCache.set(t,{sizeHandler:new nr(e),gapHandler:new or(e),parentSizeHandler:new hh(e)}):this.handlerCache.set(t,{sizeHandler:new Qs(e),gapHandler:new er(e),parentSizeHandler:new tr(e)})),this.handlerCache.get(t)}}function Bt(n){return Zt.getInstance().getHandlers(n)}const zi=n=>{n.style.display="none"},Bi=n=>{n.style.display="block"},Pn=n=>+parseFloat(`${n}`).toFixed(2),an=n=>n.projectType===Aa.email,po=(n,e)=>{const t=n.Canvas.getFramesEl();t&&(t.style.pointerEvents=e?"none":"")},fh=n=>n?["top","bottom"]:["left","right"],mh=n=>{const e=n.parent();return e?e.components().models.indexOf(n)===0:!1},gh=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.indexOf(n)===t.length-1},yh=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.length>1&&n.index()===t.length-1},bh=(n,e,t,o)=>{const r=n+(t?e==="top"?-1:e==="bottom"?1:0:e==="left"?-1:e==="right"?1:0);return r>=0&&r<o?r:-1},Lo=n=>n==="top"||n==="bottom",vh=(n,e)=>!!(mh(n)&&(e==="left"||e==="top")||gh(n)&&(e==="right"||e==="bottom")),Sh=n=>{const e=n.parent();return e?e.components().models.length>1:!1},Vi=(n,e)=>n==="right"||n==="bottom"?e>0:e<0,_r=(n,e,t=!1)=>{const o=!t,s=n.getEl();if(!s)return o?0:"";const i=window.getComputedStyle(s)[e]||"";if(o){let l;return typeof i=="string"?(l=parseFloat(i.replace(/[^-\d.]/g,"")),isNaN(l)&&(l=0)):l=Number(i)||0,l}return i},Hi=(n,e,t)=>{const o=sr({componentRow:n,isVertical:e},t),s=n.components().models;return o*(s.length-1)},_n=(n,e)=>Bt(e).parentSizeHandler.isLayoutVertical({componentRow:n}),Gn=(n,e)=>Bt(e).sizeHandler.getSize(n),sr=(n,e)=>{if(e!=null&&e.disableGapHandler)return 0;const{gapHandler:t,parentSizeHandler:o}=Bt(e);if(!t.isGapSupported())return 0;const s=t.getGap(n),r=o.getParentSize(n);return s/100*r},rr=(n,e)=>Bt(e).parentSizeHandler.getParentSize(n),In=(n,e)=>{Bt(e).sizeHandler.setSize(n)},tc=(n,e)=>{const t=Gn(n,e);In({...n,sizeValue:`${t}%`,partial:!1},e)},nc=(n,e)=>{if(e!=null&&e.disableGapHandler)return;const{gapHandler:t}=Bt(e);t.isGapSupported()&&t.setGap(n)},xh=(n,e)=>{const t=n.getStyle().gap;if(!t)return;const o=n.components().models,s={componentRow:n,isVertical:_n(n,e)};o.map(r=>tc({...s,componentColumn:r},e)),nc({...s,gapValue:String(t),partial:!1},e)};function wh(n,e){const{Blocks:t}=n,{typeColumn:o,typeRow:s,blocks:r}=e;if(r===!1||an(e))return;const i=u=>({type:s,components:u.map(p=>({type:o,style:{"flex-basis":`${p}%`}}))}),l=u=>`<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
|
|
159
159
|
${u.map(p=>`<div style="flex-basis: ${p}%; border-color: currentColor; border-width: 2px; border-radius: 0.12rem;"></div>`).join("")}
|
|
160
|
-
</div>`,a=(u,p)=>({id:`flex-row-${p.join("-")}`,label:u,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:l(p),content:i(p)}),c=[a("1 Column",[100]),a("2 Columns 50/50",[50,50]),a("2 Columns 25/75",[25,75]),a("2 Columns 75/25",[75,25]),a("3 Columns",[33.33,33.33,33.33]),a("3 Columns 50/25/25",[50,25,25]),a("3 Columns 25/50/25",[25,50,25]),a("3 Columns 25/25/50",[25,25,50]),a("4 Columns",[25,25,25,25]),a("5 Columns",[20,20,20,20,20])],d=
|
|
160
|
+
</div>`,a=(u,p)=>({id:`flex-row-${p.join("-")}`,label:u,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:l(p),content:i(p)}),c=[a("1 Column",[100]),a("2 Columns 50/50",[50,50]),a("2 Columns 25/75",[25,75]),a("2 Columns 75/25",[75,25]),a("3 Columns",[33.33,33.33,33.33]),a("3 Columns 50/25/25",[50,25,25]),a("3 Columns 25/50/25",[25,50,25]),a("3 Columns 25/25/50",[25,25,50]),a("4 Columns",[25,25,25,25]),a("5 Columns",[20,20,20,20,20])],d=zt(r)?r({blocks:c}):c;return d.forEach(u=>t.add(u.id,u)),()=>{d.forEach(u=>t.remove(u.id))}}const Ch=(n,e)=>{const{Components:t}=n,{typeRow:o,typeColumn:s,extendTypeColumn:r}=e,i=`${$e}${s}`,a=!!s&&!!t.getType(s)&&!r;if(!(!s||a||an(e)))return t.addType(s,{isComponent:pt(s),model:{defaults:{name:"Column",resizable:!1,emptyState:!0,classes:i,icon:'<svg viewBox="0 0 24 24"><path d="M14.5 2.3A1.8 1.8 0 0 0 12.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8zm-8 0A1.8 1.8 0 0 0 4.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',draggable:$r(o),attributes:{[Je]:s},styles:`
|
|
161
161
|
.${i} {
|
|
162
162
|
flex-grow: 1;
|
|
163
163
|
}
|
|
164
|
-
`}}}),()=>{t.removeType(s)}},
|
|
164
|
+
`}}}),()=>{t.removeType(s)}},kh=(n,e)=>{const{Components:t}=n,{typeRow:o,typeColumn:s,extendTypeRow:r}=e,i=`${$e}${o}`,a=!!o&&!!t.getType(o)&&!r;if(!(!o||a||an(e)))return t.addType(o,{isComponent:pt(o),model:{defaults:{name:"Row",classes:i,icon:'<svg viewBox="0 0 24 24"><path d="M4 4.8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3A1.8 1.8 0 0 0 20 4.7zm0 8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',emptyState:{styleIn:"width: 100%"},attributes:{[Je]:o},droppable:es(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
|
.${i} {
|
|
166
166
|
display: flex;
|
|
167
167
|
align-items: stretch;
|
|
168
168
|
flex-wrap: nowrap;
|
|
169
169
|
}
|
|
170
|
-
`}}}),()=>{t.removeType(o)}},
|
|
170
|
+
`}}}),()=>{t.removeType(o)}},Th="flexComponent",Eh=H.startup;class Mh{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 Ah{constructor(e,t,o){this.editor=e,this.registry=t,this.opts=o,this.resizeState=new WeakMap}getState(e){return this.resizeState.has(e)||this.resizeState.set(e,{}),this.resizeState.get(e)}clearState(e){return this.resizeState.delete(e)}startResize(e,t,o){const{opts:s}=this,r=this.getState(e);r.direction=t,r.startX=o.clientX,r.startY=o.clientY,r.resizing=!0,r.lastSnappedPercent=void 0;const i=e.parent();if(!i||!this.registry.isValidRelationship(i,e))return;r.snapEnabled=i.get("snap")??s.snapEnabled,r.snapDivisions=i.get("snap-divisions")??s.snapDivisions??12;const l=i.components().models,a=l.findIndex(p=>p.cid===e.cid),c=_n(i,s),d=bh(a,t,c,l.length);d!==-1&&(r.adjacentIdx=d);const u={componentColumn:e,componentRow:i,isVertical:c};if(r.startPercent=Gn(u,s),typeof r.adjacentIdx<"u"){const p=l[r.adjacentIdx];r.neighborStartPercent=Gn({...u,componentColumn:p},s)}}updateResizeByDelta(e,t,o){const s=this.getState(e),r=e.parent();!s.resizing||!r||(s.snapEnabled?this.updateSnapResize(e,t,o):this.updateContinuesResize(e,t,o))}finishResize(e){const t=e.parent(),o=t==null?void 0:t.components().models,s={componentRow:t,isVertical:!!t&&_n(t,this.opts)};o==null||o.forEach(r=>tc({...s,componentColumn:r},this.opts)),this.clearState(e)}updateContinuesResize(e,t,o){const s=this.getState(e),r=e.parent(),{opts:i}=this;if(!r)return;const l=i.minItemPercent??0,a=Lo(t),c=rr({componentRow:r,isVertical:a},i),d=Hi(r,a,this.opts),p=100-d/c*100,h=o/(c-d)*p,{startPercent:f=0,neighborStartPercent:m=0}=s,g={componentRow:r,isVertical:a,componentColumn:e,partial:!0},v=Vi(t,o)?f+Math.abs(h):f-Math.abs(h);if(typeof s.adjacentIdx<"u"){const C=r.components().models[s.adjacentIdx],y=f+m,b=y-l,x=Math.min(b,Math.max(l,v)),w=y-x;In({...g,sizeValue:`${Pn(x)}%`},i),In({...g,componentColumn:C,sizeValue:`${Pn(w)}%`},i)}else{const C=Math.max(l,Math.min(p,v));In({...g,sizeValue:`${Pn(C)}%`},i)}}updateSnapResize(e,t,o){const s=this.getState(e),r=e.parent(),i=Lo(t),l=rr({componentRow:r,isVertical:i},this.opts),a=Hi(r,i,this.opts),c=l-a,d=o/c*100,u=Vi(t,o),{startPercent:p=0,snapDivisions:h=12}=s,f=u?p+Math.abs(d):p-Math.abs(d),m=100/h,g=Math.floor(f/m)*m,v=Math.ceil(f/m)*m,C=Math.abs(v-f),y=Math.abs(f-g),b=m*.2,S=C<y?v:g;if(S>0&&S<100&&(C<b||y<b)&&s.lastSnappedPercent!==S){s.lastSnappedPercent=S;let E=Math.abs(S-p)/100*c;(u&&(t==="left"||t==="top")||!u&&(t==="right"||t==="bottom"))&&(E=-E),this.updateContinuesResize(e,t,E)}else C>=b&&y>=b&&(s.lastSnappedPercent=void 0)}}class Ph{constructor(e,t,o){this.editor=e,this.registry=t,this.opts=o}updateGapByDelta(e,t,o,s){if(!this.registry.isGapAdjustableParent(e))return;const{opts:r}=this,i=Math.max(0,o+t),l=rr({componentRow:e,isVertical:s},r),a=i/l*100,c=e.components().models,d=c.length-1,u={componentRow:e,isVertical:s},p=c.reduce((b,S)=>b+Gn({...u,componentColumn:S},r),0),f=100-a*d,m=r.minItemPercent||5;if(f<m*c.length)return;const v=100-d*a,C=p-v,y={componentRow:e,isVertical:s,partial:!0};c.map(b=>{const S=Gn({...u,componentColumn:b},r),x=S-S/p*C;In({...y,componentColumn:b,sizeValue:`${Pn(x)}%`},r)}),nc({...y,gapValue:`${Pn(a)}%`},r)}finishGapAdjust(e){xh(e,this.opts)}}class Ih{constructor(e,t,o){this.editor=e,this.registry=t,this.opts=o,this.resizeHandler=new Ah(e,t,o),this.gapHandler=new Ph(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 $o="gs-flex-spots",Fi=`${$o}__handle-size`,Nh=`${$o}__handle-gap`;function Oh(n,e){const{Canvas:t}=n,o="flex-resize-spot";let s,r,i,l,a=null,c=null;const d=new Mh,u=new Ih(n,d,e),p=()=>{var x;s=document.createElement("div"),s.className=$o,s.style.display="none",r=document.createElement("div"),r.className=`${$o}__handles`,r.style.position="absolute",r.style.pointerEvents="none",r.style.zIndex="21",i={left:document.createElement("div"),right:document.createElement("div"),top:document.createElement("div"),bottom:document.createElement("div")},Object.entries(i).forEach(([w,E])=>{const k=w,M=Lo(k);E.className=`${Fi} ${Fi}-${k} gjs-resizer-h gjs-cv-unscale`,E.style.cssText=`
|
|
171
171
|
pointer-events: all;
|
|
172
172
|
position: absolute;
|
|
173
173
|
z-index: 1;
|
|
174
|
-
cursor: ${
|
|
175
|
-
${
|
|
174
|
+
cursor: ${M?"ns-resize":"ew-resize"};
|
|
175
|
+
${M?"left: 50%;":"top: 50%;"}
|
|
176
176
|
${k==="left"?"left: 0px;":""}
|
|
177
177
|
${k==="right"?"right: 0px;":""}
|
|
178
178
|
${k==="top"?"top: 0px;":""}
|
|
179
179
|
${k==="bottom"?"bottom: 0px;":""}
|
|
180
|
-
`,
|
|
180
|
+
`,E.addEventListener("pointerdown",h(k)),r.appendChild(E)}),!e.disableGapHandler&&!an(e)&&(l=document.createElement("div"),l.className=Nh,l.style.cssText=`
|
|
181
181
|
position: absolute;
|
|
182
182
|
background-color: var(--gs-theme-cl-cmp-bg1, #3b97e3);
|
|
183
183
|
border-width: 2px;
|
|
@@ -187,7 +187,513 @@
|
|
|
187
187
|
pointer-events: all;
|
|
188
188
|
max-width: 3rem;
|
|
189
189
|
max-height: 3rem;
|
|
190
|
-
`,l.addEventListener("pointerdown",f()),r.appendChild(l)),s.append(r),(
|
|
190
|
+
`,l.addEventListener("pointerdown",f()),r.appendChild(l)),s.append(r),(x=t.getSpotsEl())==null||x.appendChild(s)},h=x=>w=>{if(!a)return;po(n,!0),w.stopPropagation(),w.preventDefault(),u.startResize(a,x,w);const E=w.clientX,k=w.clientY;w.target.setPointerCapture(w.pointerId);const M=N=>{const I=n.Canvas.getZoomMultiplier(),D=(N.clientX-E)*I,z=(N.clientY-k)*I,J=Lo(x)?z:D;u.updateResizeByDelta(a,x,J)},P=()=>{po(n,!1),u.finishResize(a),w.target.releasePointerCapture(w.pointerId),document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",P)};document.addEventListener("pointermove",M),document.addEventListener("pointerup",P)},f=()=>x=>{if(!c)return;const w=c;po(n,!0),x.stopPropagation(),x.preventDefault();const E=_n(w,e),k=sr({componentRow:w,isVertical:E},e),M=x.clientX,P=x.clientY;x.target.setPointerCapture(x.pointerId);const N=D=>{const z=n.Canvas.getZoomMultiplier(),J=E?(D.clientY-P)*z:(D.clientX-M)*z;u.updateGapByDelta(w,J,k,E)},I=()=>{po(n,!1),u.finishGapAdjust(w),x.target.releasePointerCapture(x.pointerId),document.removeEventListener("pointermove",N),document.removeEventListener("pointerup",I)};document.addEventListener("pointermove",N),document.addEventListener("pointerup",I)},m=x=>{const w=x.component;if(!w||!s||(a=w,c=w.parent(),!c))return;const E=c;Bi(s);const k=x.getStyle();r&&Object.assign(r.style,k);const M=_n(E,e),P=fh(M);if(Object.values(i).forEach(zi),P.forEach(I=>{if(vh(w,I))return;const D=i[I];Bi(D)}),Bt(e).gapHandler.isGapSupported()&&l&&Sh(w)){const I=sr({componentRow:E,isVertical:M},e);g(I,M,yh(w))}},g=(x,w,E=!1)=>{const k=e.gapHandleSize,M=l.style;if(w){M.height=`${k}px`;const P=l.offsetHeight;E?(M.top=`-${(x+P)/2}px`,M.bottom=""):(M.bottom=`-${(x+P)/2}px`,M.top=""),M.width="50%",M.left="50%",M.transform="translateX(-50%)",M.cursor="row-resize"}else{M.width=`${k}px`;const P=l.offsetWidth;E?(M.left=`-${(x+P)/2}px`,M.right=""):(M.right=`-${(x+P)/2}px`,M.left=""),M.height="50%",M.top="50%",M.transform="translateY(-50%)",M.cursor="col-resize"}},v=()=>{s&&(zi(s),a=null,c=null)},C=()=>{t.removeSpots({type:o});const x=n.getSelected(),w=x==null?void 0:x.parent();x&&w&&d.isValidRelationship(w,x)?t.addSpot({type:o,component:x}):v()},y=()=>{const x=t.getSpots().filter(w=>w.type===o)[0];x&&m(x)},b=(x,w)=>{d.registerTypeRelationship(x,w)};n.onReady(()=>{p(),an(e)?b("mj-section","mj-column"):b(e.typeRow,e.typeColumn)});const S="component:toggled";return n.on(t.events.spot,y),n.on(S,C),()=>{n.off(t.events.spot,y),n.off(S,C)}}const Rh=function(n,e={}){const t={typeRow:"flex-row",typeColumn:"flex-column",gapHandleSize:3,snapDivisions:12,minItemPercent:5,...e},o=[kh(n,t),Ch(n,t)],s=Oh(n,t),r=wh(n,t);G({editor:n,licenseKey:t.licenseKey,plan:Eh,pluginName:Th,cleanup:()=>{o.forEach(i=>i==null?void 0:i()),s(),r==null||r()}})},Dh=_(Rh);var Oe=(n=>(n.name="animation-name",n.duration="animation-duration",n.delay="animation-delay",n.fillMode="animation-fill-mode",n))(Oe||{}),oc=(n=>(n.staggerDelay="--stagger-delay",n))(oc||{}),we=(n=>(n.onScroll="--animation-on-scroll",n.threshold="--animation-threshold",n.repeat="--animation-repeat",n))(we||{});const Re="animation",Yt="animation-group",_i="animation:update",ir="animation-group:update",sc={category:{id:"animations",label:"Animations"},select:!0},Gr=n=>(n==null?void 0:n.type)===Re,Wr=n=>(n==null?void 0:n.type)===Yt,rc=n=>Gr(n)||Wr(n),Lh={isVisible:({component:n})=>rc(n)},bs={isVisible:({component:n})=>Gr(n)},$h={isVisible:({component:n})=>Wr(n)},Gi={isVisible:({component:n,sector:e})=>{var t;return Gr(n)&&Wr(n==null?void 0:n.parent())?!1:rc(n)&&((t=e.getProperty(we.onScroll))==null?void 0:t.getValue())==="true"}},ic={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>'},Wi=[{id:"bounce",name:"Bounce",css:`@keyframes bounce {
|
|
191
|
+
0%, 20%, 53%, 80%, to {
|
|
192
|
+
animation-timing-function: cubic-bezier(.215, .61, .355, 1);
|
|
193
|
+
transform:translateZ(0)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
40%, 43% {
|
|
197
|
+
animation-timing-function: cubic-bezier(.755, .05, .855, .06);
|
|
198
|
+
transform:translate3d(0, -30px, 0)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
70% {
|
|
202
|
+
animation-timing-function: cubic-bezier(.755, .05, .855, .06);
|
|
203
|
+
transform:translate3d(0, -15px, 0)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
90% {
|
|
207
|
+
transform:translate3d(0, -4px, 0)
|
|
208
|
+
}
|
|
209
|
+
}`},{id:"flash",name:"Flash",css:`@keyframes flash {
|
|
210
|
+
0%, 50%, to {
|
|
211
|
+
opacity:1
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
25%, 75% {
|
|
215
|
+
opacity:0
|
|
216
|
+
}
|
|
217
|
+
}`},{id:"pulse",name:"Pulse",css:`@keyframes pulse {
|
|
218
|
+
0% {
|
|
219
|
+
transform:scaleX(1)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
50% {
|
|
223
|
+
transform:scale3d(1.05, 1.05, 1.05)
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
to {
|
|
227
|
+
transform:scaleX(1)
|
|
228
|
+
}
|
|
229
|
+
}`},{id:"shake",name:"Shake",css:`@keyframes shake {
|
|
230
|
+
0%, to {
|
|
231
|
+
transform:translateZ(0)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
10%, 30%, 50%, 70%, 90% {
|
|
235
|
+
transform:translate3d(-10px, 0, 0)
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
20%, 40%, 60%, 80% {
|
|
239
|
+
transform:translate3d(10px, 0, 0)
|
|
240
|
+
}
|
|
241
|
+
}`},{id:"tada",name:"Tada",css:`@keyframes tada {
|
|
242
|
+
0% {
|
|
243
|
+
transform:scaleX(1)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
10%, 20% {
|
|
247
|
+
transform:scale3d(.9, .9, .9) rotate(-3deg)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
30%, 50%, 70%, 90% {
|
|
251
|
+
transform:scale3d(1.1, 1.1, 1.1) rotate(3deg)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
40%, 60%, 80% {
|
|
255
|
+
transform:scale3d(1.1, 1.1, 1.1) rotate(-3deg)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
to {
|
|
259
|
+
transform:scaleX(1)
|
|
260
|
+
}
|
|
261
|
+
}`},{id:"heartBeat",name:"Heart Beat",css:`@keyframes heartBeat {
|
|
262
|
+
0% {
|
|
263
|
+
transform:scale(1)
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
14% {
|
|
267
|
+
transform:scale(1.3)
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
28% {
|
|
271
|
+
transform:scale(1)
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
42% {
|
|
275
|
+
transform:scale(1.3)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
70% {
|
|
279
|
+
transform:scale(1)
|
|
280
|
+
}
|
|
281
|
+
}`},{id:"bounceIn",name:"Bounce In",css:`@keyframes bounceIn {
|
|
282
|
+
0%, 20%, 40%, 60%, 80%, to {
|
|
283
|
+
animation-timing-function:cubic-bezier(.215, .61, .355, 1)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
0% {
|
|
287
|
+
opacity: 0;
|
|
288
|
+
transform:scale3d(.3, .3, .3)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
20% {
|
|
292
|
+
transform:scale3d(1.1, 1.1, 1.1)
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
40% {
|
|
296
|
+
transform:scale3d(.9, .9, .9)
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
60% {
|
|
300
|
+
opacity: 1;
|
|
301
|
+
transform:scale3d(1.03, 1.03, 1.03)
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
80% {
|
|
305
|
+
transform:scale3d(.97, .97, .97)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
to {
|
|
309
|
+
opacity: 1;
|
|
310
|
+
transform:scaleX(1)
|
|
311
|
+
}
|
|
312
|
+
}`},{id:"bounceInDown",name:"Bounce In Down",css:`@keyframes bounceInDown {
|
|
313
|
+
0%, 60%, 75%, 90%, to {
|
|
314
|
+
animation-timing-function:cubic-bezier(.215, .61, .355, 1)
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
0% {
|
|
318
|
+
opacity: 0;
|
|
319
|
+
transform:translate3d(0, -100%, 0)
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
60% {
|
|
323
|
+
opacity: 1;
|
|
324
|
+
transform:translate3d(0, 25px, 0)
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
75% {
|
|
328
|
+
transform:translate3d(0, -10px, 0)
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
90% {
|
|
332
|
+
transform:translate3d(0, 5px, 0)
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
to {
|
|
336
|
+
transform:translateZ(0)
|
|
337
|
+
}
|
|
338
|
+
}`},{id:"bounceInLeft",name:"Bounce In Left",css:`@keyframes bounceInLeft {
|
|
339
|
+
0%, 1%, 60%, 75%, 90%, to {
|
|
340
|
+
animation-timing-function:cubic-bezier(.215, .61, .355, .1)
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
0% {
|
|
344
|
+
opacity: 0;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
1% {
|
|
348
|
+
transform:translate3d(-100%, 0, 0)
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
60% {
|
|
352
|
+
opacity: 1;
|
|
353
|
+
transform:translate3d(25px, 0, 0)
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
75% {
|
|
357
|
+
transform:translate3d(-10px, 0, 0)
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
90% {
|
|
361
|
+
transform:translate3d(5px, 0, 0)
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
to {
|
|
365
|
+
transform:translateZ(0)
|
|
366
|
+
}
|
|
367
|
+
}`},{id:"bounceInRight",name:"Bounce In Right",css:`@keyframes bounceInRight {
|
|
368
|
+
0%, 1%, 60%, 75%, 90%, to {
|
|
369
|
+
animation-timing-function:cubic-bezier(.215, .61, .355, .1)
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
0% {
|
|
373
|
+
opacity: 0;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
1% {
|
|
377
|
+
transform:translate3d(100%, 0, 0)
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
60% {
|
|
381
|
+
opacity: 1;
|
|
382
|
+
transform:translate3d(-25px, 0, 0)
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
75% {
|
|
386
|
+
transform:translate3d(10px, 0, 0)
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
90% {
|
|
390
|
+
transform:translate3d(-5px, 0, 0)
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
to {
|
|
394
|
+
transform:translateZ(0)
|
|
395
|
+
}
|
|
396
|
+
}`},{id:"bounceInUp",name:"Bounce In Up",css:`@keyframes bounceInUp {
|
|
397
|
+
0%, 60%, 75%, 90%, to {
|
|
398
|
+
animation-timing-function:cubic-bezier(.215, .61, .355, .1)
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
0% {
|
|
402
|
+
opacity: 0;
|
|
403
|
+
transform:translate3d(0, 100%, 0)
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
60% {
|
|
407
|
+
opacity: 1;
|
|
408
|
+
transform:translate3d(0, -20px, 0)
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
75% {
|
|
412
|
+
transform:translate3d(0, 10px, 0)
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
90% {
|
|
416
|
+
transform:translate3d(0, -5px, 0)
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
to {
|
|
420
|
+
transform:translateZ(0)
|
|
421
|
+
}
|
|
422
|
+
}`},{id:"fadeIn",name:"Fade In",css:`@keyframes fadeIn {
|
|
423
|
+
0% {
|
|
424
|
+
opacity:0
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
to {
|
|
428
|
+
opacity:1
|
|
429
|
+
}
|
|
430
|
+
}`},{id:"fadeInDown",name:"Fade In Down",css:`@keyframes fadeInDown {
|
|
431
|
+
0% {
|
|
432
|
+
opacity: 0;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
1% {
|
|
436
|
+
transform:translate3d(0, -100%, 0)
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
to {
|
|
440
|
+
opacity: 1;
|
|
441
|
+
transform:translateZ(0)
|
|
442
|
+
}
|
|
443
|
+
}`},{id:"fadeInLeft",name:"Fade In Left",css:`@keyframes fadeInLeft {
|
|
444
|
+
0% {
|
|
445
|
+
opacity: 0;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
1% {
|
|
449
|
+
transform:translate3d(-100%, 0, 0)
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
to {
|
|
453
|
+
opacity: 1;
|
|
454
|
+
transform:translateZ(0)
|
|
455
|
+
}
|
|
456
|
+
}`},{id:"fadeInRight",name:"Fade In Right",css:`@keyframes fadeInRight {
|
|
457
|
+
0% {
|
|
458
|
+
opacity: 0;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
1% {
|
|
462
|
+
transform:translate3d(100%, 0, 0)
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
to {
|
|
466
|
+
opacity: 1;
|
|
467
|
+
transform:translateZ(0)
|
|
468
|
+
}
|
|
469
|
+
}`},{id:"fadeInUp",name:"Fade In Up",css:`@keyframes fadeInUp {
|
|
470
|
+
0% {
|
|
471
|
+
opacity: 0;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
1% {
|
|
475
|
+
transform:translate3d(0, 100%, 0)
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
to {
|
|
479
|
+
opacity: 1;
|
|
480
|
+
transform:translateZ(0)
|
|
481
|
+
}
|
|
482
|
+
}`},{id:"flipInX",name:"Flip In X",css:`@keyframes flipInX {
|
|
483
|
+
0% {
|
|
484
|
+
transform: perspective(400px) rotateX(90deg);
|
|
485
|
+
animation-timing-function: ease-in;
|
|
486
|
+
opacity:0
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
40% {
|
|
490
|
+
transform: perspective(400px) rotateX(-20deg);
|
|
491
|
+
animation-timing-function:ease-in
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
60% {
|
|
495
|
+
transform: perspective(400px) rotateX(10deg);
|
|
496
|
+
opacity:1
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
80% {
|
|
500
|
+
transform:perspective(400px) rotateX(-5deg)
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
to {
|
|
504
|
+
transform:perspective(400px)
|
|
505
|
+
}
|
|
506
|
+
}`},{id:"flipInY",name:"Flip In Y",css:`@keyframes flipInY {
|
|
507
|
+
0% {
|
|
508
|
+
transform: perspective(400px) rotateY(90deg);
|
|
509
|
+
animation-timing-function: ease-in;
|
|
510
|
+
opacity:0
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
40% {
|
|
514
|
+
transform: perspective(400px) rotateY(-20deg);
|
|
515
|
+
animation-timing-function:ease-in
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
60% {
|
|
519
|
+
transform: perspective(400px) rotateY(10deg);
|
|
520
|
+
opacity:1
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
80% {
|
|
524
|
+
transform:perspective(400px) rotateY(-5deg)
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
to {
|
|
528
|
+
transform:perspective(400px)
|
|
529
|
+
}
|
|
530
|
+
}`},{id:"rotateIn",name:"Rotate In",css:`@keyframes rotateIn {
|
|
531
|
+
0% {
|
|
532
|
+
transform-origin: center;
|
|
533
|
+
transform: rotate(-200deg);
|
|
534
|
+
opacity:0
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
to {
|
|
538
|
+
transform-origin: center;
|
|
539
|
+
transform: translateZ(0);
|
|
540
|
+
opacity:1
|
|
541
|
+
}
|
|
542
|
+
}`},{id:"rotateInDownLeft",name:"Rotate In Down Left",css:`@keyframes rotateInDownLeft {
|
|
543
|
+
0% {
|
|
544
|
+
transform-origin: left bottom;
|
|
545
|
+
transform: rotate(-45deg);
|
|
546
|
+
opacity:0
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
to {
|
|
550
|
+
transform-origin: left bottom;
|
|
551
|
+
transform: translateZ(0);
|
|
552
|
+
opacity:1
|
|
553
|
+
}
|
|
554
|
+
}`},{id:"rotateInDownRight",name:"Rotate In Down Right",css:`@keyframes rotateInDownRight {
|
|
555
|
+
0% {
|
|
556
|
+
transform-origin: right bottom;
|
|
557
|
+
transform: rotate(45deg);
|
|
558
|
+
opacity:0
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
to {
|
|
562
|
+
transform-origin: right bottom;
|
|
563
|
+
transform: translateZ(0);
|
|
564
|
+
opacity:1
|
|
565
|
+
}
|
|
566
|
+
}`},{id:"rotateInUpLeft",name:"Rotate In Up Left",css:`@keyframes rotateInUpLeft {
|
|
567
|
+
0% {
|
|
568
|
+
transform-origin: left bottom;
|
|
569
|
+
transform: rotate(45deg);
|
|
570
|
+
opacity:0
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
to {
|
|
574
|
+
transform-origin: left bottom;
|
|
575
|
+
transform: translateZ(0);
|
|
576
|
+
opacity:1
|
|
577
|
+
}
|
|
578
|
+
}`},{id:"rotateInUpRight",name:"Rotate In Up Right",css:`@keyframes rotateInUpRight {
|
|
579
|
+
0% {
|
|
580
|
+
transform-origin: right bottom;
|
|
581
|
+
transform: rotate(-90deg);
|
|
582
|
+
opacity:0
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
to {
|
|
586
|
+
transform-origin: right bottom;
|
|
587
|
+
transform: translateZ(0);
|
|
588
|
+
opacity:1
|
|
589
|
+
}
|
|
590
|
+
}`},{id:"slideInDown",name:"Slide In Down",css:`@keyframes slideInDown {
|
|
591
|
+
0% {
|
|
592
|
+
visibility:visible
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
1% {
|
|
596
|
+
transform: translate3d(0, -100%, 0);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
to {
|
|
600
|
+
transform:translateZ(0)
|
|
601
|
+
}
|
|
602
|
+
}`},{id:"slideInLeft",name:"Slide In Left",css:`@keyframes slideInLeft {
|
|
603
|
+
0% {
|
|
604
|
+
visibility:visible
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
1% {
|
|
608
|
+
transform: translate3d(-100%, 0, 0);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
to {
|
|
612
|
+
transform:translateZ(0)
|
|
613
|
+
}
|
|
614
|
+
}`},{id:"slideInRight",name:"Slide In Right",css:`@keyframes slideInRight {
|
|
615
|
+
0% {
|
|
616
|
+
visibility:visible
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
1% {
|
|
620
|
+
transform: translate3d(100%, 0, 0);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
to {
|
|
624
|
+
transform:translateZ(0)
|
|
625
|
+
}
|
|
626
|
+
}`},{id:"slideInUp",name:"Slide In Up",css:`@keyframes slideInUp {
|
|
627
|
+
0% {
|
|
628
|
+
visibility:visible
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
1% {
|
|
632
|
+
transform: translate3d(0, 100%, 0);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
to {
|
|
636
|
+
transform:translateZ(0)
|
|
637
|
+
}
|
|
638
|
+
}`},{id:"zoomIn",name:"Zoom In",css:`@keyframes zoomIn {
|
|
639
|
+
0% {
|
|
640
|
+
opacity: 0;
|
|
641
|
+
transform:scale3d(.3, .3, .3)
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
50% {
|
|
645
|
+
opacity:1
|
|
646
|
+
}
|
|
647
|
+
}`},{id:"zoomInDown",name:"Zoom In Down",css:`@keyframes zoomInDown {
|
|
648
|
+
0% {
|
|
649
|
+
opacity: 0;
|
|
650
|
+
transform: scale3d(.1, .1, .1) translate3d(0, -1000px, 0);
|
|
651
|
+
animation-timing-function:cubic-bezier(.55, .055, .675, .19)
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
60% {
|
|
655
|
+
opacity: 1;
|
|
656
|
+
transform: scale3d(.475, .475, .475) translate3d(0, 60px, 0);
|
|
657
|
+
animation-timing-function:cubic-bezier(.175, .885, .32, 1)
|
|
658
|
+
}
|
|
659
|
+
}`},{id:"zoomInLeft",name:"Zoom In Left",css:`@keyframes zoomInLeft {
|
|
660
|
+
0% {
|
|
661
|
+
opacity: 0;
|
|
662
|
+
transform: scale3d(.1, .1, .1) translate3d(-1000px, 0, 0);
|
|
663
|
+
animation-timing-function:cubic-bezier(.55, .055, .675, .19)
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
60% {
|
|
667
|
+
opacity: 1;
|
|
668
|
+
transform: scale3d(.475, .475, .475) translate3d(10px, 0, 0);
|
|
669
|
+
animation-timing-function:cubic-bezier(.175, .885, .32, 1)
|
|
670
|
+
}
|
|
671
|
+
}`},{id:"zoomInRight",name:"Zoom In Right",css:`@keyframes zoomInRight {
|
|
672
|
+
0% {
|
|
673
|
+
opacity: 0;
|
|
674
|
+
transform: scale3d(.1, .1, .1) translate3d(1000px, 0, 0);
|
|
675
|
+
animation-timing-function:cubic-bezier(.55, .055, .675, .19)
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
60% {
|
|
679
|
+
opacity: 1;
|
|
680
|
+
transform: scale3d(.475, .475, .475) translate3d(-10px, 0, 0);
|
|
681
|
+
animation-timing-function:cubic-bezier(.175, .885, .32, 1)
|
|
682
|
+
}
|
|
683
|
+
}`},{id:"zoomInUp",name:"Zoom In Up",css:`@keyframes zoomInUp {
|
|
684
|
+
0% {
|
|
685
|
+
opacity: 0;
|
|
686
|
+
transform: scale3d(.1, .1, .1) translate3d(0, 1000px, 0);
|
|
687
|
+
animation-timing-function:cubic-bezier(.55, .055, .675, .19)
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
60% {
|
|
691
|
+
opacity: 1;
|
|
692
|
+
transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0);
|
|
693
|
+
animation-timing-function:cubic-bezier(.175, .885, .32, 1)
|
|
694
|
+
}
|
|
695
|
+
}`}],zh=function(n){const e=this;let t=null;const o=()=>{t==null||t.disconnect(),t=null},s=()=>{o();const r=e.style;r.animationName="",requestAnimationFrame(()=>{const i=getComputedStyle(e),l=i.getPropertyValue("animation-name").trim(),a=i.getPropertyValue("--animation-on-scroll").trim()!=="false",c=parseFloat(i.getPropertyValue("--animation-threshold").trim())||.2,d=i.getPropertyValue("--animation-repeat").trim()==="true",u=()=>{r.animationName="none",e.offsetWidth,r.animationName=l,r.animationPlayState="running"};if(!l||l==="none"){r.animationName="none",r.animationPlayState="paused";return}if(!a){u();return}r.animationPlayState="paused",t=new IntersectionObserver(p=>{p.forEach(h=>{h.isIntersecting&&(u(),!d&&o())})},{threshold:c}),t.observe(e)})};e.addEventListener(n.animationUpdateEvent,s),s()},Bh=(n,e)=>{const{Components:t,Blocks:o,Canvas:s}=n,{block:r={},animationList:i=[]}=e,l="Animation",a=Object.values(we),c=Object.values(Oe);return t.addType(Re,{block:r?{label:l,media:ic.animation,content:{type:Re},...sc,...r}:void 0,model:{defaults:{emptyState:!0,name:l,traits:[],script:zh,animationUpdateEvent:_i,"script-props":["animationUpdateEvent"],styles:i.map(d=>d.css).join(`
|
|
696
|
+
`),style:{[Oe.name]:"fadeIn",[Oe.duration]:"1s",[Oe.delay]:"0s",[Oe.fillMode]:"both",[we.onScroll]:"true",[we.threshold]:"0.2",[we.repeat]:"false",...e.animationStyle}},init(){const{em:d}=this;this.listenTo(d,"component:mount",u=>{var h;if(u!==this)return;((h=this.parent())==null?void 0:h.get("type"))!==Yt||a.forEach(f=>this.removeStyle(f))})}},view:{events:()=>({animationstart:"onAnimationStart",animationend:"onAnimationEnd"}),init(){const{model:d}=this;this.listenTo(d,"component:styleUpdate",this.handleStyleChange)},onAnimationStart(){var u;if((u=this.cmpSpots)!=null&&u.length)return;const d=s.getSpots({component:this.model});this.cmpSpots=d,s.removeSpots(d),this.el.ownerDocument.body.style.overflowX="hidden"},onAnimationEnd(){const d=this.cmpSpots||[];s.spots.add(d),this.cmpSpots=[],this.el.ownerDocument.body.style.overflowX=""},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(_i))},handleStyleChange(d,u){Object.keys((u==null?void 0:u.style)||{}).some(f=>c.includes(f)||a.includes(f))&&this.triggerAnimation()},onRender(){this.triggerAnimation()}}}),()=>{o.remove(Re),t.removeType(Re)}},Vh=function(n){const e=this,t="--animation-on-scroll",o="--animation-threshold",s="--animation-repeat";let r=null;const i=()=>{r==null||r.disconnect(),r=null},l=()=>{i();const a=getComputedStyle(e),c=a.getPropertyValue(t).trim()!=="false",d=parseFloat(a.getPropertyValue(o).trim())||.2,u=a.getPropertyValue(s).trim()==="true",p=()=>{Array.from(e.children).forEach(h=>{h instanceof HTMLElement&&typeof h.dispatchEvent=="function"&&h.dispatchEvent(new CustomEvent(ir,{bubbles:!1}))})};if(!c){p();return}r=new IntersectionObserver(h=>{h.forEach(f=>{f.isIntersecting?(p(),!u&&i()):u&&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}),r.observe(e)};e.addEventListener(n.animationGroupUpdateEvent,l),l()},Hh=(n,e)=>{const{Components:t,Blocks:o}=n,{blockGroup:s={}}=e,r="Animation Group";return t.addType(Yt,{block:s?{label:r,media:ic.animationGroup,content:{type:Yt,components:[{type:Re},{type:Re},{type:Re}]},...sc,...s}:void 0,model:{defaults:{name:r,emptyState:!0,traits:[],script:Vh,animationGroupUpdateEvent:ir,"script-props":["animationGroupUpdateEvent"],droppable:es(Re),style:{[oc.staggerDelay]:"0.3s",[we.onScroll]:"true",[we.threshold]:"0.2",[we.repeat]:"false",...e.animationGroupStyle}},init(){const i=this.components();this.listenTo(i,"add remove",this.updateChildrenStaggerStyles),this.updateChildrenStaggerStyles()},updateChildrenStaggerStyles(){this.components().forEach((i,l)=>{i.is(Re)&&i.addStyle({"--stagger-index":l.toString(),[Oe.delay]:"calc(var(--stagger-index, 0) * var(--stagger-delay, 0s))"},{partial:!0})})}},view:{init(){const{model:i}=this;this.listenTo(i,"component:styleUpdate",this.handleStyleChange)},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(ir))},handleStyleChange(){this.triggerAnimation(),this.model.updateChildrenStaggerStyles()},onRender(){this.triggerAnimation()}}}),()=>{o.remove(Yt),t.removeType(Yt)}},Fh="animationComponent",_h=H.startup,Gh=function(n,e={}){var s;const t=((s=e.animations)==null?void 0:s.call(e,{items:Wi}))||Wi,o=[Bh(n,{...e,animationList:t}),Hh(n,e)];n.Styles.addSector("animation",{name:"Animation",properties:[{...bs,name:"Type",property:Oe.name,type:"select",full:!0,default:"fadeIn",options:t},{...bs,name:"Duration",property:Oe.duration,type:"number",units:["s"],min:.1,max:10,step:.1,default:"1s"},{...bs,name:"Fill Mode",property:Oe.fillMode,type:"select",default:"both",options:[{name:"None",id:"none"},{name:"Forwards",id:"forwards"},{name:"Backwards",id:"backwards"},{name:"Both",id:"both"}]},{...$h,name:"Stagger Delay",property:"--stagger-delay",type:"slider",units:["s"],min:.1,max:5,step:.1,default:"0.1s"},{...Lh,name:"Animate on Scroll",property:we.onScroll,type:"radio",default:"true",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]},{...Gi,name:"Scroll Threshold",property:we.threshold,type:"number",full:!0,min:.1,max:1,step:.01,default:"0.2"},{...Gi,name:"Repeat on Scroll",property:we.repeat,type:"radio",default:"false",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]}]}),G({editor:n,licenseKey:e.licenseKey,plan:_h,pluginName:Fh,cleanup:()=>{o.forEach(r=>r())}})},Wh=_(Gh),jh=n=>n.dispatchEvent(new CustomEvent("input"));function qh(n,e){if(!e)return()=>{};const t=n.Components.events,o=d=>n.getSelectedAll().includes(d),s=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),r=d=>d.isChildOf("text"),i=d=>n.getEditing()===d,l=(d,u={})=>{d.trigger("focus",u.event)},a=(d,u)=>{o(d)&&s(d)&&!i(d)&&l(d,u)},c=(d,u)=>{if(o(d)&&!s(d)&&r(d)){const p=d.parents().find(h=>h.isInstanceOf("text"));p&&(l(p,u),setTimeout(()=>n.select(p),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const Uh="rteTinyMce",Kh=H.startup,Jh=`
|
|
191
697
|
.tox .tox-toolbar,
|
|
192
698
|
.tox .tox-toolbar__overflow,
|
|
193
699
|
.tox .tox-toolbar__primary,
|
|
@@ -290,25 +796,25 @@
|
|
|
290
796
|
background-color: var(--gs-theme-cl-prm-bg1);
|
|
291
797
|
border-color: var(--gs-theme-cl-prm-bg3);
|
|
292
798
|
opacity: 0.75;
|
|
293
|
-
}`,Dr=new WeakMap,vh=(n,e)=>{Dr.set(n,e)},xh=n=>{Dr.delete(n)},us=n=>Dr.get(n),io=n=>{const e=n.target,t=e.closest(".tox"),o=e.matches(".ephox-snooker-resizer-bar");(t||o)&&n.stopPropagation()},Oi=n=>{n.stopPropagation(),n.preventDefault()},Sh=(n,e)=>{const t=n.getDoc(),o=n.getWin();if(e!=null&&e.event){const{event:s}=e,{clientX:r,clientY:i}=s;let l;if(t.caretRangeFromPoint)l=t.caretRangeFromPoint(r,i);else if(t.caretPositionFromPoint){const a=t.caretPositionFromPoint(r,i);l=t.createRange(),l==null||l.setStart(a.offsetNode,a.offset)}if(l){const a=o.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(l),n.selection.setRng(l)}}else n.execCommand("SelectAll")},wh=n=>{var c,d;const{el:e,editor:t,componentView:o}=n,s=t.runCommand(F.getStateTheme),r=o.model,i={target:e,inline:!0,skin:(s==null?void 0:s.theme)===ha.dark?"oxide-dark":"oxide",menubar:!1,image_advtab:!0,paste_data_images:!0,statusbar:!1,branding:!1,forced_root_block:"div",plugins:"advlist autolink lists link image media table",toolbar_mode:"sliding",toolbar:"bold italic underline strikethrough forecolor backcolor alignleft aligncenter alignright alignjustify link image | fontfamily fontsize bullist numlist outdent indent table"},l=((d=(c=n.pluginOpts)==null?void 0:c.loadConfig)==null?void 0:d.call(c,{config:i,editor:t,componentView:o,component:r}))||{};return{...i,...l}},Ii=(n,e=document)=>new Promise((t,o)=>{const s=Array.isArray(n)?[...n]:[n],{head:r}=e,i=l=>{if(l.length){const a=e.createElement("script");a.src=l.shift(),a.onload=i.bind(null,l),a.onerror=o,r.appendChild(a)}else t()};i(s)}),Ch=function(n,e={}){const t={cdnScript:"https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",...e},{cdnScript:o}=t,s=n.Canvas.events,r=!t.skipCustomTheme,i="gs-plg-tinymce-studio-theme",l=async(d,u)=>{const p=d.ownerDocument,h=p.defaultView,f=u==null?void 0:u.view;if(!h||!f){console.warn("Missing required data",{win:h,componentView:f});return}const m=wh({el:d,editor:n,componentView:f,pluginOpts:t}),v=(await h.tinymce.init(m))[0];if(!v)return;const y=(await window.tinymce.init({...m,target:document.createElement("div")}))[0];return v.ui.show(),p.body.addEventListener("mousedown",io),document.body.addEventListener("mousedown",io),v.on("Change",()=>fh(d)),v.on("blur",()=>v.ui.show()),v.on("OpenWindow",function(){var S;const b=(S=p.querySelector(".tox-dialog"))==null?void 0:S.closest(".tox");b&&(b==null?void 0:b.ownerDocument)!==document&&(document.body.appendChild(b),v.once("CloseWindow",()=>{b&&b.ownerDocument===document&&p.body.appendChild(b)}))}),d.addEventListener("dragstart",Oi,{capture:!0}),n.runCommand(F.setStateContextMenu,{enabled:!1}),Sh(v,u),{rteEditor:v,rteEditorShallow:y}},a=(d,u)=>{d.ownerDocument.body.removeEventListener("mousedown",io),document.body.removeEventListener("mousedown",io),d.removeEventListener("dragstart",Oi,{capture:!0}),n.runCommand(F.setStateContextMenu,{enabled:!0}),u.rteEditor.destroy(),u.rteEditorShallow.destroy()};n.on(s.frameLoad,async({window:d})=>{const u=d.document;Ii(o,u)}),n.onReady(()=>{Ii(o,document),r&&Ar(i,bh,{target:document.body})}),n.setCustomRte({parseContent:!0,async enable(d,u,p){const h=us(d);if(h)return h.rteEditor;const f=await l(d,p);return f&&vh(d,f),f==null?void 0:f.rteEditor},disable(d){const u=us(d);u&&(xh(d),a(d,u))},getContent(d){var p,h;const u=us(d);return u?(h=(p=u.rteEditor).getContent)==null?void 0:h.call(p):d.innerHTML}});const c=mh(n,t.enableOnClick);j({editor:n,licenseKey:t.licenseKey,plan:yh,pluginName:gh,cleanup:()=>{n.RichTextEditor.customRte=void 0,c()}})},kh=W(Ch);function X(n){this.content=n}X.prototype={constructor:X,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var o=t&&t!=n?this.remove(t):this,s=o.find(n),r=o.content.slice();return s==-1?r.push(t||n,e):(r[s+1]=e,t&&(r[s]=t)),new X(r)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new X(t)},addToStart:function(n,e){return new X([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new X(t)},addBefore:function(n,e,t){var o=this.remove(e),s=o.content.slice(),r=o.find(n);return s.splice(r==-1?s.length:r,0,e,t),new X(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=X.from(n),n.size?new X(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=X.from(n),n.size?new X(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=X.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}};X.from=function(n){if(n instanceof X)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new X(e)};function Ga(n,e,t){for(let o=0;;o++){if(o==n.childCount||o==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(o),r=e.child(o);if(s==r){t+=s.nodeSize;continue}if(!s.sameMarkup(r))return t;if(s.isText&&s.text!=r.text){for(let i=0;s.text[i]==r.text[i];i++)t++;return t}if(s.content.size||r.content.size){let i=Ga(s.content,r.content,t+1);if(i!=null)return i}t+=s.nodeSize}}function Wa(n,e,t,o){for(let s=n.childCount,r=e.childCount;;){if(s==0||r==0)return s==r?null:{a:t,b:o};let i=n.child(--s),l=e.child(--r),a=i.nodeSize;if(i==l){t-=a,o-=a;continue}if(!i.sameMarkup(l))return{a:t,b:o};if(i.isText&&i.text!=l.text){let c=0,d=Math.min(i.text.length,l.text.length);for(;c<d&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,o--;return{a:t,b:o}}if(i.content.size||l.content.size){let c=Wa(i.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,r){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&o(a,s+l,r||null,i)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),o,s+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,o,s){let r="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&o&&(i?i=!1:r+=o),r+=c},0),r}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,o=e.firstChild,s=this.content.slice(),r=0;for(t.isText&&t.sameMarkup(o)&&(s[s.length-1]=t.withText(t.text+o.text),r=1);r<e.content.length;r++)s.push(e.content[r]);return new 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 r=0,i=0;i<t;r++){let l=this.content[r],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),o.push(l),s+=l.nodeSize),i=a}return new 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(),r=this.size+t.nodeSize-o.nodeSize;return s[e]=t,new T(s,r)}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 Ga(this,e,t)}findDiffEnd(e,t=this.size,o=e.size){return Wa(this,e,t,o)}findIndex(e,t=-1){if(e==0)return lo(0,e);if(e==this.size)return lo(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let o=0,s=0;;o++){let r=this.child(o),i=s+r.nodeSize;if(i>=e)return i==e||t>0?lo(o+1,i):lo(o,s);s=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return 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 r=e[s];o+=r.nodeSize,s&&r.isText&&e[s-1].sameMarkup(r)?(t||(t=e.slice(0,s)),t[t.length-1]=r.withText(t[t.length-1].text+r.text)):t&&t.push(r)}return new 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 ps={index:0,offset:0};function lo(n,e){return ps.index=n,ps.offset=e,ps}function No(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(!No(n[o],e[o]))return!1}else{for(let o in n)if(!(o in e)||!No(n[o],e[o]))return!1;for(let o in e)if(!(o in n))return!1}return!0}class B{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,o=!1;for(let s=0;s<e.length;s++){let r=e[s];if(this.eq(r))return e;if(this.type.excludes(r.type))t||(t=e.slice(0,s));else{if(r.type.excludes(this.type))return e;!o&&r.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),o=!0),t&&t.push(r)}}return t||(t=e.slice()),o||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&No(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 Oo 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=qa(this.content,e+this.openStart,t);return o&&new A(o,this.openStart,this.openEnd)}removeBetween(e,t){return new A(ja(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 r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)o++;for(let r=e.lastChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.lastChild)s++;return new A(e,o,s)}}A.empty=new A(T.empty,0,0);function ja(n,e,t){let{index:o,offset:s}=n.findIndex(e),r=n.maybeChild(o),{index:i,offset:l}=n.findIndex(t);if(s==e||r.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(o!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(o,r.copy(ja(r.content,e-s-1,t-s-1)))}function qa(n,e,t,o){let{index:s,offset:r}=n.findIndex(e),i=n.maybeChild(s);if(r==e||i.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=qa(i.content,e-r-1,t);return l&&n.replaceChild(s,i.copy(l))}function Th(n,e,t){if(t.openStart>n.depth)throw new Oo("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Oo("Inconsistent open depths");return Ka(n,e,t,0)}function Ka(n,e,t,o){let s=n.index(o),r=n.node(o);if(s==e.index(o)&&o<n.depth-t.openStart){let i=Ka(n,e,t,o+1);return r.copy(r.content.replaceChild(s,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==o&&e.depth==o){let i=n.parent,l=i.content;return kt(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=Mh(t,n);return kt(r,Ja(n,i,l,e,o))}else return kt(r,Io(n,e,o))}function Ua(n,e){if(!e.type.compatibleContent(n.type))throw new Oo("Cannot join "+e.type.name+" onto "+n.type.name)}function Zs(n,e,t){let o=n.node(t);return Ua(o,e.node(t)),o}function Ct(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 En(n,e,t,o){let s=(e||n).node(t),r=0,i=e?e.index(t):s.childCount;n&&(r=n.index(t),n.depth>t?r++:n.textOffset&&(Ct(n.nodeAfter,o),r++));for(let l=r;l<i;l++)Ct(s.child(l),o);e&&e.depth==t&&e.textOffset&&Ct(e.nodeBefore,o)}function kt(n,e){return n.type.checkContent(e),n.copy(e)}function Ja(n,e,t,o,s){let r=n.depth>s&&Zs(n,e,s+1),i=o.depth>s&&Zs(t,o,s+1),l=[];return En(null,n,s,l),r&&i&&e.index(s)==t.index(s)?(Ua(r,i),Ct(kt(r,Ja(n,e,t,o,s+1)),l)):(r&&Ct(kt(r,Io(n,e,s+1)),l),En(e,t,s,l),i&&Ct(kt(i,Io(t,o,s+1)),l)),En(o,null,s,l),new T(l)}function Io(n,e,t){let o=[];if(En(null,n,t,o),n.depth>t){let s=Zs(n,e,t+1);Ct(kt(s,Io(n,e,t+1)),o)}return En(e,null,t,o),new T(o)}function Mh(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let r=t-1;r>=0;r--)s=e.node(r).copy(T.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class $n{constructor(e,t,o){this.pos=e,this.path=t,this.parentOffset=o,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let o=this.pos-this.path[this.path.length-1],s=e.child(t);return o?e.child(t).cut(o):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let o=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let r=0;r<e;r++)s+=o.child(r).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return B.none;if(this.textOffset)return e.child(t).marks;let o=e.maybeChild(t-1),s=e.maybeChild(t);if(!o){let l=o;o=s,s=l}let r=o.marks;for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let o=t.marks,s=e.parent.maybeChild(e.index());for(var r=0;r<o.length;r++)o[r].type.spec.inclusive===!1&&(!s||!o[r].isInSet(s.marks))&&(o=o[r--].removeFromSet(o));return o}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let o=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);o>=0;o--)if(e.pos<=this.end(o)&&(!t||t(this.node(o))))return new Ro(this,e,o);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let o=[],s=0,r=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(r),c=r-a;if(o.push(i,l,s+a),!c||(i=i.child(l),i.isText))break;r=c-1,s+=a+1}return new $n(t,o,r)}static resolveCached(e,t){let o=Ri.get(e);if(o)for(let r=0;r<o.elts.length;r++){let i=o.elts[r];if(i.pos==t)return i}else Ri.set(e,o=new Eh);let s=o.elts[o.i]=$n.resolve(e,t);return o.i=(o.i+1)%Ah,s}}class Eh{constructor(){this.elts=[],this.i=0}}const Ah=12,Ri=new WeakMap;class Ro{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 Ph=Object.create(null);let Tt=class Xs{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&&No(this.attrs,t||e.defaultAttrs||Ph)&&B.sameSet(this.marks,o||B.none)}copy(e=null){return e==this.content?this:new Xs(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Xs(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,o=!1){if(e==t)return A.empty;let s=this.resolve(e),r=this.resolve(t),i=o?0:s.sharedDepth(t),l=s.start(i),c=s.node(i).content.cut(s.pos-l,r.pos-l);return new A(c,s.depth-i,r.depth-i)}replace(e,t,o){return Th(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 $n.resolveCached(this,e)}resolveNoCache(e){return $n.resolve(this,e)}rangeHasMark(e,t,o){let s=!1;return t>e&&this.nodesBetween(e,t,r=>(o.isInSet(r.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Ya(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,r=o.childCount){let i=this.contentMatchAt(e).matchFragment(o,s,r),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<r;a++)if(!this.type.allowsMarks(o.child(a).marks))return!1;return!0}canReplaceWith(e,t,o,s){if(s&&!this.type.allowsMarks(s))return!1;let r=this.contentMatchAt(e).matchType(o),i=r&&r.matchFragment(this.content,t);return i?i.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=B.none;for(let t=0;t<this.marks.length;t++){let o=this.marks[t];o.type.checkAttrs(o.attrs),e=o.addToSet(e)}if(!B.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let o;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");o=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,o)}let s=T.fromJSON(e,t.content),r=e.nodeType(t.type).create(t.attrs,s,o);return r.type.checkAttrs(r.attrs),r}};Tt.prototype.text=void 0;class Do extends Tt{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):Ya(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 Do(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Do(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 Ya(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Ot{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let o=new Nh(e,t);if(o.next==null)return Ot.empty;let s=Za(o);o.next&&o.err("Unexpected trailing text");let r=Vh(zh(s));return $h(r,o),r}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,o=e.childCount){let s=this;for(let r=t;s&&r<o;r++)s=s.matchType(e.child(r).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let o=0;o<e.next.length;o++)if(this.next[t].type==e.next[o].type)return!0;return!1}fillBefore(e,t=!1,o=0){let s=[this];function r(i,l){let a=i.matchFragment(e,o);if(a&&(!t||a.validEnd))return T.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:d,next:u}=i.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(u)==-1){s.push(u);let p=r(u,l.concat(d));if(p)return p}}return null}return r(this,[])}findWrapping(e){for(let o=0;o<this.wrapCache.length;o+=2)if(this.wrapCache[o]==e)return this.wrapCache[o+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),o=[{match:this,type:null,via:null}];for(;o.length;){let s=o.shift(),r=s.match;if(r.matchType(e)){let i=[];for(let l=s;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<r.next.length;i++){let{type:l,next:a}=r.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(o.push({match:l.contentMatch,type:l,via:s}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(o){e.push(o);for(let s=0;s<o.next.length;s++)e.indexOf(o.next[s].next)==-1&&t(o.next[s].next)}return t(this),e.map((o,s)=>{let r=s+(o.validEnd?"*":" ")+" ";for(let i=0;i<o.next.length;i++)r+=(i?", ":"")+o.next[i].type.name+"->"+e.indexOf(o.next[i].next);return r}).join(`
|
|
294
|
-
`)}}Ot.empty=new Ot(!0);class Nh{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 Za(n){let e=[];do e.push(Oh(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Oh(n){let e=[];do e.push(Ih(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Ih(n){let e=Lh(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=Rh(n,e);else break;return e}function Di(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Rh(n,e){let t=Di(n),o=t;return n.eat(",")&&(n.next!="}"?o=Di(n):o=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:o,expr:e}}function Dh(n,e){let t=n.nodeTypes,o=t[e];if(o)return[o];let s=[];for(let r in t){let i=t[r];i.isInGroup(e)&&s.push(i)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function Lh(n){if(n.eat("(")){let e=Za(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=Dh(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 zh(n){let e=[[]];return s(r(n,0),t()),e;function t(){return e.push([])-1}function o(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function s(i,l){i.forEach(a=>a.to=l)}function r(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(r(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=r(i.exprs[a],l);if(a==i.exprs.length-1)return c;s(c,l=t())}else if(i.type=="star"){let a=t();return o(l,a),s(r(i.expr,a),a),[o(a)]}else if(i.type=="plus"){let a=t();return s(r(i.expr,l),a),s(r(i.expr,a),a),[o(a)]}else{if(i.type=="opt")return[o(l)].concat(r(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let d=t();s(r(i.expr,a),d),a=d}if(i.max==-1)s(r(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let d=t();o(a,d),s(r(i.expr,a),d),a=d}return[o(a)]}else{if(i.type=="name")return[o(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function Xa(n,e){return e-n}function Li(n,e){let t=[];return o(e),t.sort(Xa);function o(s){let r=n[s];if(r.length==1&&!r[0].term)return o(r[0].to);t.push(s);for(let i=0;i<r.length;i++){let{term:l,to:a}=r[i];!l&&t.indexOf(a)==-1&&o(a)}}}function Vh(n){let e=Object.create(null);return t(Li(n,0));function t(o){let s=[];o.forEach(i=>{n[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<s.length;d++)s[d][0]==l&&(c=s[d][1]);Li(n,a).forEach(d=>{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let r=e[o.join(",")]=new Ot(o.indexOf(n.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(Xa);r.next.push({type:s[i][0],next:e[l.join(",")]||t(l)})}return r}}function $h(n,e){for(let t=0,o=[n];t<o.length;t++){let s=o[t],r=!s.validEnd,i=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];i.push(a.name),r&&!(a.isText||a.hasRequiredAttrs())&&(r=!1),o.indexOf(c)==-1&&o.push(c)}r&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Qa(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 ec(n,e){let t=Object.create(null);for(let o in n){let s=e&&e[o];if(s===void 0){let r=n[o];if(r.hasDefault)s=r.default;else throw new RangeError("No value supplied for attribute "+o)}t[o]=s}return t}function tc(n,e,t,o){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let r=n[s];r.validate&&r.validate(e[s])}}function nc(n,e){let t=Object.create(null);if(e)for(let o in e)t[o]=new Hh(n,o,e[o]);return t}let zi=class oc{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=nc(e,o.attrs),this.defaultAttrs=Qa(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==Ot.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:ec(this.attrs,e)}create(e=null,t,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Tt(this,this.computeAttrs(e),T.from(t),B.setFrom(o))}createChecked(e=null,t,o){return t=T.from(t),this.checkContent(t),new Tt(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 i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let s=this.contentMatch.matchFragment(t),r=s&&s.fillBefore(T.empty,!0);return r?new Tt(this,e,t.append(r),B.setFrom(o)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let o=0;o<e.childCount;o++)if(!this.allowsMarks(e.child(o).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){tc(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let o=0;o<e.length;o++)this.allowsMarkType(e[o].type)?t&&t.push(e[o]):t||(t=e.slice(0,o));return t?t.length?t:B.none:e}static compile(e,t){let o=Object.create(null);e.forEach((r,i)=>o[r]=new oc(r,t,i));let s=t.spec.topNode||"doc";if(!o[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let r in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};function Bh(n,e,t){let o=t.split("|");return s=>{let r=s===null?"null":typeof s;if(o.indexOf(r)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${n}, got ${r}`)}}class Hh{constructor(e,t,o){this.hasDefault=Object.prototype.hasOwnProperty.call(o,"default"),this.default=o.default,this.validate=typeof o.validate=="string"?Bh(e,t,o.validate):o.validate}get isRequired(){return!this.hasDefault}}class Yo{constructor(e,t,o,s){this.name=e,this.rank=t,this.schema=o,this.spec=s,this.attrs=nc(e,s.attrs),this.excluded=null;let r=Qa(this.attrs);this.instance=r?new B(this,r):null}create(e=null){return!e&&this.instance?this.instance:new B(this,ec(this.attrs,e))}static compile(e,t){let o=Object.create(null),s=0;return e.forEach((r,i)=>o[r]=new Yo(r,s++,t,i)),o}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){tc(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Fh{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=X.from(e.nodes),t.marks=X.from(e.marks||{}),this.nodes=zi.compile(this.spec.nodes,this),this.marks=Yo.compile(this.spec.marks,this);let o=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let r=this.nodes[s],i=r.spec.content||"",l=r.spec.marks;if(r.contentMatch=o[i]||(o[i]=Ot.parse(i,this.nodes)),r.inlineContent=r.contentMatch.inlineContent,r.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!r.isInline||!r.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=r}r.markSet=l=="_"?null:l?Vi(this,l.split(" ")):l==""||!r.inlineContent?[]:null}for(let s in this.marks){let r=this.marks[s],i=r.spec.excludes;r.excluded=i==null?[r]:i==""?[]:Vi(this,i.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,o,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof zi){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 Do(o,o.defaultAttrs,e,B.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Tt.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 Vi(n,e){let t=[];for(let o=0;o<e.length;o++){let s=e[o],r=n.marks[s],i=r;if(r)t.push(r);else for(let l in n.marks){let a=n.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return t}function _h(n){return n.tag!=null}function Gh(n){return n.style!=null}class sn{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let o=this.matchedStyles=[];t.forEach(s=>{if(_h(s))this.tags.push(s);else if(Gh(s)){let r=/[^=]*/.exec(s.style)[0];o.indexOf(r)<0&&o.push(r),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let r=e.nodes[s.node];return r.contentMatch.matchType(r)})}parse(e,t={}){let o=new Bi(this,t,!1);return o.addAll(e,B.none,t.from,t.to),o.finish()}parseSlice(e,t={}){let o=new Bi(this,t,!0);return o.addAll(e,B.none,t.from,t.to),A.maxOpen(o.finish())}matchTag(e,t,o){for(let s=o?this.tags.indexOf(o)+1:0;s<this.tags.length;s++){let r=this.tags[s];if(qh(e,r.tag)&&(r.namespace===void 0||e.namespaceURI==r.namespace)&&(!r.context||t.matchesContext(r.context))){if(r.getAttrs){let i=r.getAttrs(e);if(i===!1)continue;r.attrs=i||void 0}return r}}}matchStyle(e,t,o,s){for(let r=s?this.styles.indexOf(s)+1:0;r<this.styles.length;r++){let i=this.styles[r],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!o.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function o(s){let r=s.priority==null?50:s.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<r)break}t.splice(i,0,s)}for(let s in e.marks){let r=e.marks[s].spec.parseDOM;r&&r.forEach(i=>{o(i=Hi(i)),i.mark||i.ignore||i.clearMark||(i.mark=s)})}for(let s in e.nodes){let r=e.nodes[s].spec.parseDOM;r&&r.forEach(i=>{o(i=Hi(i)),i.node||i.ignore||i.mark||(i.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new sn(e,sn.schemaRules(e)))}}const sc={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},Wh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},rc={ol:!0,ul:!0},Lo=1,zo=2,An=4;function $i(n,e,t){return e!=null?(e?Lo:0)|(e==="full"?zo:0):n&&n.whitespace=="pre"?Lo|zo:t&~An}class ao{constructor(e,t,o,s,r,i){this.type=e,this.attrs=t,this.marks=o,this.solid=s,this.options=i,this.content=[],this.activeMarks=B.none,this.match=r||(i&An?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&Lo)){let o=this.content[this.content.length-1],s;if(o&&o.isText&&(s=/[ \t\r\n\u000c]+$/.exec(o.text))){let r=o;o.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-s[0].length))}}let t=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&&!sc.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Bi{constructor(e,t,o){this.parser=e,this.options=t,this.isOpen=o,this.open=0;let s=t.topNode,r,i=$i(null,t.preserveWhitespace,0)|(o?An:0);s?r=new ao(s.type,s.attrs,B.none,!0,t.topMatch||s.type.contentMatch,i):o?r=new ao(null,null,B.none,!0,null,i):r=new ao(e.schema.topNodeType,null,B.none,!0,null,i),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let o=e.nodeValue,s=this.top;if(s.options&zo||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(o)){if(s.options&Lo)s.options&zo?o=o.replace(/\r\n?/g,`
|
|
295
|
-
`):o=o.replace(/\r?\n|\r/g," ");else if(o=o.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(o)&&this.open==this.nodes.length-1){let r=s.content[s.content.length-1],i=e.previousSibling;(!r||i&&i.nodeName=="BR"||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(o=o.slice(1))}o&&this.insertNode(this.parser.schema.text(o),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,o){let s=e.nodeName.toLowerCase(),r;
|
|
296
|
-
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let o=e.style;if(o&&o.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let r=this.parser.matchedStyles[s],i=o.getPropertyValue(r);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(r,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,o,s){let r,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),o)||this.leafFallback(e,o);else{let a=this.enter(i,t.attrs||null,o,t.preserveWhitespace);a&&(r=!0,o=a)}else{let a=this.parser.schema.marks[t.mark];o=o.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(s)this.addElement(e,o,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,o));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,o),this.findAround(e,a,!1)}r&&this.sync(l)&&this.open--}addAll(e,t,o,s){let r=o||0;for(let i=o?e.childNodes[o]:e.firstChild,l=s==null?null:e.childNodes[s];i!=l;i=i.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(i,t);this.findAtPoint(e,r)}findPlace(e,t){let o,s;for(let r=this.open;r>=0;r--){let i=this.nodes[r],l=i.findWrapping(e);if(l&&(!o||o.length>l.length)&&(o=l,s=i,!l.length)||i.solid)break}if(!o)return null;this.sync(s);for(let r=0;r<o.length;r++)t=this.enterInner(o[r],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let o=this.findPlace(e,t);if(o){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let r=B.none;for(let i of o.concat(e.marks))(s.type?s.type.allowsMarkType(i.type):Fi(i.type,e.type))&&(r=i.addToSet(r));return s.content.push(e.mark(r)),!0}return!1}enter(e,t,o,s){let r=this.findPlace(e.create(t),o);return r&&(r=this.enterInner(e,t,o,!0,s)),r}enterInner(e,t,o,s=!1,r){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=$i(e,r,i.options);i.options&An&&i.content.length==0&&(l|=An);let a=B.none;return o=o.filter(c=>(i.type?i.type.allowsMarkType(c.type):Fi(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new ao(e,t,a,s,null,l)),this.open++,o}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let o=this.nodes[t].content;for(let s=o.length-1;s>=0;s--)e+=o[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let o=0;o<this.find.length;o++)this.find[o].node==e&&this.find[o].offset==t&&(this.find[o].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,o){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(o?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),o=this.options.context,s=!this.isOpen&&(!o||o.parent.type==this.nodes[0].type),r=-(o?o.depth+1:0)+(s?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=r;a--)if(i(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:o&&a>=r?o.node(a-r).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(o&&o.isTextblock&&o.defaultAttrs)return o}for(let t in this.parser.schema.nodes){let o=this.parser.schema.nodes[t];if(o.isTextblock&&o.defaultAttrs)return o}}}function jh(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&rc.hasOwnProperty(o)&&t?(t.appendChild(e),e=t):o=="li"?t=e:o&&(t=null)}}function qh(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Hi(n){let e={};for(let t in n)e[t]=n[t];return e}function Fi(n,e){let t=e.schema.nodes;for(let o in t){let s=t[o];if(!s.allowsMarkType(n))continue;let r=[],i=l=>{r.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||r.indexOf(d)<0&&i(d))return!0}};if(i(s.contentMatch))return!0}}class zt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},o){o||(o=hs(t).createDocumentFragment());let s=o,r=[];return e.forEach(i=>{if(r.length||i.marks.length){let l=0,a=0;for(;l<r.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(r[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<r.length;)s=r.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],d=this.serializeMark(c,i.isInline,t);d&&(r.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(i,t))}),o}serializeNodeInner(e,t){let{dom:o,contentDOM:s}=vo(hs(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return o}serializeNode(e,t={}){let o=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let r=this.serializeMark(e.marks[s],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(o),o=r.dom)}return o}serializeMark(e,t,o={}){let s=this.marks[e.type.name];return s&&vo(hs(o),s(e,t),null,e.attrs)}static renderSpec(e,t,o=null,s){return vo(e,t,o,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new zt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=_i(e.nodes);return t.text||(t.text=o=>o.text),t}static marksFromSchema(e){return _i(e.marks)}}function _i(n){let e={};for(let t in n){let o=n[t].spec.toDOM;o&&(e[t]=o)}return e}function hs(n){return n.document||window.document}const Gi=new WeakMap;function Kh(n){let e=Gi.get(n);return e===void 0&&Gi.set(n,e=Uh(n)),e}function Uh(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 vo(n,e,t,o){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],r;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(o&&(r=Kh(o))&&r.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=s.indexOf(" ");i>0&&(t=s.slice(0,i),s=s.slice(i+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let p=u.indexOf(" ");p>0?a.setAttributeNS(u.slice(0,p),u.slice(p+1),c[u]):a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let p=e[u];if(p===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:f}=vo(n,p,t,o);if(a.appendChild(h),f){if(l)throw new RangeError("Multiple content holes");l=f}}}return{dom:a,contentDOM:l}}const ic=65535,lc=Math.pow(2,16);function Jh(n,e){return n+e*lc}function Wi(n){return n&ic}function Yh(n){return(n-(n&ic))/lc}const ac=1,cc=2,xo=4,dc=8;class Qs{constructor(e,t,o){this.pos=e,this.delInfo=t,this.recover=o}get deleted(){return(this.delInfo&dc)>0}get deletedBefore(){return(this.delInfo&(ac|xo))>0}get deletedAfter(){return(this.delInfo&(cc|xo))>0}get deletedAcross(){return(this.delInfo&xo)>0}}class me{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&me.empty)return me.empty}recover(e){let t=0,o=Wi(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+Yh(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,o){let s=0,r=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+r],d=this.ranges[l+i],u=a+c;if(e<=u){let p=c?e==a?-1:e==u?1:t:t,h=a+s+(p<0?0:d);if(o)return h;let f=e==(t<0?a:u)?null:Jh(l/3,e-a),m=e==a?cc:e==u?ac:xo;return(t<0?e!=a:e!=u)&&(m|=dc),new Qs(h,m,f)}s+=d-c}return o?e+s:new Qs(e+s,0,null)}touches(e,t){let o=0,s=Wi(t),r=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+r],d=a+c;if(e<=d&&l==s*3)return!0;o+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,o=this.inverted?1:2;for(let s=0,r=0;s<this.ranges.length;s+=3){let i=this.ranges[s],l=i-(this.inverted?r:0),a=i+(this.inverted?0:r),c=this.ranges[s+t],d=this.ranges[s+o];e(l,l+c,a,a+d),r+=d-c}}invert(){return new me(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?me.empty:new me(e<0?[0,-e,0]:[0,0,e])}}me.empty=new me([]);class Xt{constructor(e=[],t,o=0,s=e.length){this.maps=e,this.mirror=t,this.from=o,this.to=s}slice(e=0,t=this.maps.length){return new Xt(this.maps,this.mirror,e,t)}copy(){return new Xt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,o=this.maps.length;t<e.maps.length;t++){let s=e.getMirror(t);this.appendMap(e.maps[t],s!=null&&s<t?o+s:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,o=this.maps.length+e.maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e.maps[t].invert(),s!=null&&s>t?o-s-1:void 0)}}invert(){let e=new Xt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let o=this.from;o<this.to;o++)e=this.maps[o].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,o){let s=0;for(let r=this.from;r<this.to;r++){let i=this.maps[r],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(r);if(a!=null&&a>r&&a<this.to){r=a,e=this.maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return o?e:new Qs(e,s,null)}}const fs=Object.create(null);class ie{getMap(){return me.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let o=fs[t.stepType];if(!o)throw new RangeError(`No step type ${t.stepType} defined`);return o.fromJSON(e,t)}static jsonID(e,t){if(e in fs)throw new RangeError("Duplicate use of step JSON ID "+e);return fs[e]=t,t.prototype.jsonID=e,t}}class U{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new U(e,null)}static fail(e){return new U(null,e)}static fromReplace(e,t,o,s){try{return U.ok(e.replace(t,o,s))}catch(r){if(r instanceof Oo)return U.fail(r.message);throw r}}}function Lr(n,e,t){let o=[];for(let s=0;s<n.childCount;s++){let r=n.child(s);r.content.size&&(r=r.copy(Lr(r.content,e,r))),r.isInline&&(r=e(r,t,s)),o.push(r)}return T.fromArray(o)}class tt extends ie{constructor(e,t,o){super(),this.from=e,this.to=t,this.mark=o}apply(e){let t=e.slice(this.from,this.to),o=e.resolve(this.from),s=o.node(o.sharedDepth(this.to)),r=new A(Lr(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),t.openStart,t.openEnd);return U.fromReplace(e,this.from,this.to,r)}invert(){return new Oe(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 tt(t.pos,o.pos,this.mark)}merge(e){return e instanceof tt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new tt(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 tt(t.from,t.to,e.markFromJSON(t.mark))}}ie.jsonID("addMark",tt);class Oe extends ie{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(Lr(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return U.fromReplace(e,this.from,this.to,o)}invert(){return new tt(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 Oe(t.pos,o.pos,this.mark)}merge(e){return e instanceof Oe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Oe(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 Oe(t.from,t.to,e.markFromJSON(t.mark))}}ie.jsonID("removeMark",Oe);class nt extends ie{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return U.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return U.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 nt(this.pos,t.marks[s]);return new nt(this.pos,this.mark)}}return new rn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new nt(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 nt(t.pos,e.markFromJSON(t.mark))}}ie.jsonID("addNodeMark",nt);class rn extends ie{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return U.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return U.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 nt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new rn(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 rn(t.pos,e.markFromJSON(t.mark))}}ie.jsonID("removeNodeMark",rn);class se extends ie{constructor(e,t,o,s=!1){super(),this.from=e,this.to=t,this.slice=o,this.structure=s}apply(e){return this.structure&&er(e,this.from,this.to)?U.fail("Structure replace would overwrite content"):U.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new me([this.from,this.to-this.from,this.slice.size])}invert(e){return new se(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deletedAcross&&o.deletedAcross?null:new se(t.pos,Math.max(t.pos,o.pos),this.slice)}merge(e){if(!(e instanceof se)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?A.empty:new A(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new se(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?A.empty:new A(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new se(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new se(t.from,t.to,A.fromJSON(e,t.slice),!!t.structure)}}ie.jsonID("replace",se);class te extends ie{constructor(e,t,o,s,r,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=o,this.gapTo=s,this.slice=r,this.insert=i,this.structure=l}apply(e){if(this.structure&&(er(e,this.from,this.gapFrom)||er(e,this.gapTo,this.to)))return U.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return U.fail("Gap is not a flat range");let o=this.slice.insertAt(this.insert,t.content);return o?U.fromReplace(e,this.from,this.to,o):U.fail("Content does not fit in gap")}getMap(){return new me([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new te(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),r=this.to==this.gapTo?o.pos:e.map(this.gapTo,1);return t.deletedAcross&&o.deletedAcross||s<t.pos||r>o.pos?null:new te(t.pos,o.pos,s,r,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new te(t.from,t.to,t.gapFrom,t.gapTo,A.fromJSON(e,t.slice),t.insert,!!t.structure)}}ie.jsonID("replaceAround",te);function er(n,e,t){let o=n.resolve(e),s=t-e,r=o.depth;for(;s>0&&r>0&&o.indexAfter(r)==o.node(r).childCount;)r--,s--;if(s>0){let i=o.node(r).maybeChild(o.indexAfter(r));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}function Zh(n,e,t,o){let s=[],r=[],i,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!o.isInSet(u)&&d.type.allowsMarkType(o.type)){let p=Math.max(c,e),h=Math.min(c+a.nodeSize,t),f=o.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(f)||(i&&i.to==p&&i.mark.eq(u[m])?i.to=h:s.push(i=new Oe(p,h,u[m])));l&&l.to==p?l.to=h:r.push(l=new tt(p,h,o))}}),s.forEach(a=>n.step(a)),r.forEach(a=>n.step(a))}function Xh(n,e,t,o){let s=[],r=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;r++;let a=null;if(o instanceof Yo){let c=i.marks,d;for(;d=o.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else o?o.isInSet(i.marks)&&(a=[o]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],p;for(let h=0;h<s.length;h++){let f=s[h];f.step==r-1&&u.eq(s[h].style)&&(p=f)}p?(p.to=c,p.step=r):s.push({style:u,from:Math.max(l,e),to:c,step:r})}}}),s.forEach(i=>n.step(new Oe(i.from,i.to,i.style)))}function zr(n,e,t,o=t.contentMatch,s=!0){let r=n.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<r.childCount;a++){let c=r.child(a),d=l+c.nodeSize,u=o.matchType(c.type);if(!u)i.push(new se(l,d,A.empty));else{o=u;for(let p=0;p<c.marks.length;p++)t.allowsMarkType(c.marks[p].type)||n.step(new Oe(l,d,c.marks[p]));if(s&&c.isText&&t.whitespace!="pre"){let p,h=/\r?\n|\r/g,f;for(;p=h.exec(c.text);)f||(f=new A(T.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new se(l+p.index,l+p.index+p[0].length,f))}}l=d}if(!o.validEnd){let a=o.fillBefore(T.empty,!0);n.replace(l,l,new A(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function Qh(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Zo(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let o=n.depth;;--o){let s=n.$from.node(o),r=n.$from.index(o),i=n.$to.indexAfter(o);if(o<n.depth&&s.canReplace(r,i,t))return o;if(o==0||s.type.spec.isolating||!Qh(s,r,i))break}return null}function ef(n,e,t){let{$from:o,$to:s,depth:r}=e,i=o.before(r+1),l=s.after(r+1),a=i,c=l,d=T.empty,u=0;for(let f=r,m=!1;f>t;f--)m||o.index(f)>0?(m=!0,d=T.from(o.node(f).copy(d)),u++):a--;let p=T.empty,h=0;for(let f=r,m=!1;f>t;f--)m||s.after(f+1)<s.end(f)?(m=!0,p=T.from(s.node(f).copy(p)),h++):c++;n.step(new te(a,c,i,l,new A(d.append(p),u,h),d.size-u,!0))}function uc(n,e,t=null,o=n){let s=tf(n,e),r=s&&nf(o,e);return r?s.map(ji).concat({type:e,attrs:t}).concat(r.map(ji)):null}function ji(n){return{type:n,attrs:null}}function tf(n,e){let{parent:t,startIndex:o,endIndex:s}=n,r=t.contentMatchAt(o).findWrapping(e);if(!r)return null;let i=r.length?r[0]:e;return t.canReplaceWith(o,s,i)?r:null}function nf(n,e){let{parent:t,startIndex:o,endIndex:s}=n,r=t.child(o),i=e.contentMatch.findWrapping(r.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=o;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function of(n,e,t){let o=T.empty;for(let i=t.length-1;i>=0;i--){if(o.size){let l=t[i].type.contentMatch.matchFragment(o);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=T.from(t[i].type.create(t[i].attrs,o))}let s=e.start,r=e.end;n.step(new te(s,r,s,r,new A(o,0,0),t.length,!0))}function sf(n,e,t,o,s){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let r=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{let a=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(o,a)&&rf(n.doc,n.mapping.slice(r).map(l),o)){let c=null;if(o.schema.linebreakReplacement){let h=o.whitespace=="pre",f=!!o.contentMatch.matchType(o.schema.linebreakReplacement);h&&!f?c=!1:!h&&f&&(c=!0)}c===!1&&hc(n,i,l,r),zr(n,n.mapping.slice(r).map(l,1),o,void 0,c===null);let d=n.mapping.slice(r),u=d.map(l,1),p=d.map(l+i.nodeSize,1);return n.step(new te(u,p,u+1,p-1,new A(T.from(o.create(a,null,i.marks)),0,0),1,!0)),c===!0&&pc(n,i,l,r),!1}})}function pc(n,e,t,o){e.forEach((s,r)=>{if(s.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(s.text);){let a=n.mapping.slice(o).map(t+1+r+i.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function hc(n,e,t,o){e.forEach((s,r)=>{if(s.type==s.type.schema.linebreakReplacement){let i=n.mapping.slice(o).map(t+1+r);n.replaceWith(i,i+1,e.type.schema.text(`
|
|
297
|
-
`))}})}function rf(n,e,t){let o=n.resolve(e),s=o.index();return o.parent.canReplaceWith(s,s+1,t)}function lf(n,e,t,o,s){let r=n.doc.nodeAt(e);if(!r)throw new RangeError("No node at given position");t||(t=r.type);let i=t.create(o,null,s||r.marks);if(r.isLeaf)return n.replaceWith(e,e+r.nodeSize,i);if(!t.validContent(r.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new te(e,e+r.nodeSize,e+1,e+r.nodeSize-1,new A(T.from(i),0,0),1,!0))}function Qt(n,e,t=1,o){let s=n.resolve(e),r=s.depth-t,i=o&&o[o.length-1]||s.parent;if(r<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!i.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=t-2;c>r;c--,d--){let u=s.node(c),p=s.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(p,u.childCount),f=o&&o[d+1];f&&(h=h.replaceChild(0,f.type.create(f.attrs)));let m=o&&o[d]||u;if(!u.canReplace(p+1,u.childCount)||!m.type.validContent(h))return!1}let l=s.indexAfter(r),a=o&&o[0];return s.node(r).canReplaceWith(l,l,a?a.type:s.node(r+1).type)}function af(n,e,t=1,o){let s=n.doc.resolve(e),r=T.empty,i=T.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){r=T.from(s.node(l).copy(r));let d=o&&o[c];i=T.from(d?d.type.create(d.attrs,i):s.node(l).copy(i))}n.step(new se(e,e,new A(r.append(i),t,t),!0))}function Xo(n,e){let t=n.resolve(e),o=t.index();return df(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(o,o+1)}function cf(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:o}=n.type.schema;for(let s=0;s<e.childCount;s++){let r=e.child(s),i=r.type==o?n.type.schema.nodes.text:r.type;if(t=t.matchType(i),!t||!n.type.allowsMarks(r.marks))return!1}return t.validEnd}function df(n,e){return!!(n&&e&&!n.isLeaf&&cf(n,e))}function uf(n,e,t){let o=null,{linebreakReplacement:s}=n.doc.type.schema,r=n.doc.resolve(e-t),i=r.node().type;if(s&&i.inlineContent){let d=i.whitespace=="pre",u=!!i.contentMatch.matchType(s);d&&!u?o=!1:!d&&u&&(o=!0)}let l=n.steps.length;if(o===!1){let d=n.doc.resolve(e+t);hc(n,d.node(),d.before(),l)}i.inlineContent&&zr(n,e+t-1,i,r.node().contentMatchAt(r.index()),o==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new se(c,a.map(e+t,-1),A.empty,!0)),o===!0){let d=n.doc.resolve(c);pc(n,d.node(),d.before(),n.steps.length)}return n}function pf(n,e,t){let o=n.resolve(e);if(o.parent.canReplaceWith(o.index(),o.index(),t))return e;if(o.parentOffset==0)for(let s=o.depth-1;s>=0;s--){let r=o.index(s);if(o.node(s).canReplaceWith(r,r,t))return o.before(s+1);if(r>0)return null}if(o.parentOffset==o.parent.content.size)for(let s=o.depth-1;s>=0;s--){let r=o.indexAfter(s);if(o.node(s).canReplaceWith(r,r,t))return o.after(s+1);if(r<o.node(s).childCount)return null}return null}function hf(n,e,t){let o=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let r=0;r<t.openStart;r++)s=s.firstChild.content;for(let r=1;r<=(t.openStart==0&&t.size?2:1);r++)for(let i=o.depth;i>=0;i--){let l=i==o.depth?0:o.pos<=(o.start(i+1)+o.end(i+1))/2?-1:1,a=o.index(i)+(l>0?1:0),c=o.node(i),d=!1;if(r==1)d=c.canReplace(a,a,s);else{let u=c.contentMatchAt(a).findWrapping(s.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?o.pos:l<0?o.before(i+1):o.after(i+1)}return null}function Vr(n,e,t=e,o=A.empty){if(e==t&&!o.size)return null;let s=n.resolve(e),r=n.resolve(t);return fc(s,r,o)?new se(e,t,o):new ff(s,r,o).fit()}function fc(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class ff{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 r=e.node(s);this.frontier.push({type:r.type,match:r.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=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 r=this.placed,i=o.depth,l=s.depth;for(;i&&l&&r.childCount==1;)r=r.firstChild.content,i--,l--;let a=new A(r,i,l);return e>-1?new te(o.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||o.pos!=this.$to.pos?new se(o.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,o=0,s=this.unplaced.openEnd;o<e;o++){let r=t.firstChild;if(t.childCount>1&&(s=0),r.type.spec.isolating&&s<=o){e=o;break}t=r.content}for(let t=1;t<=2;t++)for(let o=t==1?e:this.unplaced.openStart;o>=0;o--){let s,r=null;o?(r=ms(this.unplaced.content,o-1).firstChild,s=r.content):s=this.unplaced.content;let i=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(i?c.matchType(i.type)||(u=c.fillBefore(T.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:o,frontierDepth:l,parent:r,inject:u};if(t==2&&i&&(d=c.findWrapping(i.type)))return{sliceDepth:o,frontierDepth:l,parent:r,wrap:d};if(r&&c.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:o}=this.unplaced,s=ms(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=ms(e,t);if(s.childCount<=1&&t>0){let r=e.size-t<=t+s.size;this.unplaced=new A(Sn(e,t-1,1),t-1,r?t-1:o)}else this.unplaced=new A(Sn(e,t,1),t,o)}placeNodes({sliceDepth:e,frontierDepth:t,parent:o,inject:s,wrap:r}){for(;this.depth>t;)this.closeFrontierNode();if(r)for(let m=0;m<r.length;m++)this.openFrontierNode(r[m]);let i=this.unplaced,l=o?o.content:i.content,a=i.openStart-e,c=0,d=[],{match:u,type:p}=this.frontier[t];if(s){for(let m=0;m<s.childCount;m++)d.push(s.child(m));u=u.matchFragment(s)}let h=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let m=l.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(u=g,d.push(mc(m.mark(p.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let f=c==l.childCount;f||(h=-1),this.placed=wn(this.placed,t,T.from(d)),this.frontier[t].match=u,f&&h<0&&o&&o.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let v=g.lastChild;this.frontier.push({type:v.type,match:v.contentMatchAt(v.childCount)}),g=v.content}this.unplaced=f?e==0?A.empty:new A(Sn(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new A(Sn(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!gs(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:o}=this.$to,s=this.$to.after(o);for(;o>1&&s==this.$to.end(--o);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:o,type:s}=this.frontier[t],r=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=gs(e,t,s,o,r);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=gs(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:i,move:r?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=wn(this.placed,t.depth,t.fit)),e=t.move;for(let o=t.depth+1;o<=e.depth;o++){let s=e.node(o),r=s.type.contentMatch.fillBefore(s.content,!0,e.index(o));this.openFrontierNode(s.type,s.attrs,r)}return e}openFrontierNode(e,t=null,o){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=wn(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=wn(this.placed,this.frontier.length,t))}}function Sn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Sn(n.firstChild.content,e-1,t)))}function wn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(wn(n.lastChild.content,e-1,t)))}function ms(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function mc(n,e,t){if(e<=0)return n;let o=n.content;return e>1&&(o=o.replaceChild(0,mc(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 gs(n,e,t,o,s){let r=n.node(e),i=s?n.indexAfter(e):n.index(e);if(i==r.childCount&&!t.compatibleContent(r.type))return null;let l=o.fillBefore(r.content,!0,i);return l&&!mf(t,r.content,i)?l:null}function mf(n,e,t){for(let o=t;o<e.childCount;o++)if(!n.allowsMarks(e.child(o).marks))return!0;return!1}function gf(n){return n.spec.defining||n.spec.definingForContent}function yf(n,e,t,o){if(!o.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),r=n.doc.resolve(t);if(fc(s,r,o))return n.step(new se(e,t,o));let i=yc(s,n.doc.resolve(t));i[i.length-1]==0&&i.pop();let l=-(s.depth+1);i.unshift(l);for(let p=s.depth,h=s.pos-1;p>0;p--,h--){let f=s.node(p).type.spec;if(f.defining||f.definingAsContext||f.isolating)break;i.indexOf(p)>-1?l=p:s.before(p)==h&&i.splice(1,0,-p)}let a=i.indexOf(l),c=[],d=o.openStart;for(let p=o.content,h=0;;h++){let f=p.firstChild;if(c.push(f),h==o.openStart)break;p=f.content}for(let p=d-1;p>=0;p--){let h=c[p],f=gf(h.type);if(f&&!h.sameMarkup(s.node(Math.abs(l)-1)))d=p;else if(f||!h.type.isTextblock)break}for(let p=o.openStart;p>=0;p--){let h=(p+d+1)%(o.openStart+1),f=c[h];if(f)for(let m=0;m<i.length;m++){let g=i[(m+a)%i.length],v=!0;g<0&&(v=!1,g=-g);let 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),v?r.after(g):t,new A(gc(o.content,0,o.openStart,h),h,o.openEnd))}}let u=n.steps.length;for(let p=i.length-1;p>=0&&(n.replace(e,t,o),!(n.steps.length>u));p--){let h=i[p];h<0||(e=s.before(h),t=r.after(h))}}function gc(n,e,t,o,s){if(e<t){let r=n.firstChild;n=n.replaceChild(0,r.copy(gc(r.content,e+1,t,o,r)))}if(e>o){let r=s.contentMatchAt(0),i=r.fillBefore(n).append(n);n=i.append(r.matchFragment(i).fillBefore(T.empty,!0))}return n}function bf(n,e,t,o){if(!o.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=pf(n.doc,e,o.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new A(T.from(o),0,0))}function vf(n,e,t){let o=n.doc.resolve(e),s=n.doc.resolve(t),r=yc(o,s);for(let i=0;i<r.length;i++){let l=r[i],a=i==r.length-1;if(a&&l==0||o.node(l).type.contentMatch.validEnd)return n.delete(o.start(l),s.end(l));if(l>0&&(a||o.node(l-1).canReplace(o.index(l-1),s.indexAfter(l-1))))return n.delete(o.before(l),s.after(l))}for(let i=1;i<=o.depth&&i<=s.depth;i++)if(e-o.start(i)==o.depth-i&&t>o.end(i)&&s.end(i)-t!=s.depth-i&&o.start(i-1)==s.start(i-1)&&o.node(i-1).canReplace(o.index(i-1),s.index(i-1)))return n.delete(o.before(i),t);n.delete(e,t)}function yc(n,e){let t=[],o=Math.min(n.depth,e.depth);for(let s=o;s>=0;s--){let r=n.start(s);if(r<n.pos-(n.depth-s)||e.end(s)>e.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(r==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==r-1)&&t.push(s)}return t}class en extends ie{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 U.fail("No node at attribute step's position");let o=Object.create(null);for(let r in t.attrs)o[r]=t.attrs[r];o[this.attr]=this.value;let s=t.type.create(o,null,t.marks);return U.fromReplace(e,this.pos,this.pos+1,new A(T.from(s),0,t.isLeaf?0:1))}getMap(){return me.empty}invert(e){return new en(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 en(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 en(t.pos,t.attr,t.value)}}ie.jsonID("attr",en);class Bn extends ie{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 U.ok(o)}getMap(){return me.empty}invert(e){return new Bn(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 Bn(t.attr,t.value)}}ie.jsonID("docAttr",Bn);let ln=class extends Error{};ln=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};ln.prototype=Object.create(Error.prototype);ln.prototype.constructor=ln;ln.prototype.name="TransformError";class bc{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Xt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new ln(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=Vr(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 yf(this,e,t,o),this}replaceRangeWith(e,t,o){return bf(this,e,t,o),this}deleteRange(e,t){return vf(this,e,t),this}lift(e,t){return ef(this,e,t),this}join(e,t=1){return uf(this,e,t),this}wrap(e,t){return of(this,e,t),this}setBlockType(e,t=e,o,s=null){return sf(this,e,t,o,s),this}setNodeMarkup(e,t,o=null,s){return lf(this,e,t,o,s),this}setNodeAttribute(e,t,o){return this.step(new en(e,t,o)),this}setDocAttribute(e,t){return this.step(new Bn(e,t)),this}addNodeMark(e,t){return this.step(new nt(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 rn(e,t)),this}split(e,t=1,o){return af(this,e,t,o),this}addMark(e,t,o){return Zh(this,e,t,o),this}removeMark(e,t,o){return Xh(this,e,t,o),this}clearIncompatible(e,t,o){return zr(this,e,t,o),this}}const ys=Object.create(null);class L{constructor(e,t,o){this.$anchor=e,this.$head=t,this.ranges=o||[new vc(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=A.empty){let o=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=o,o=o.lastChild;let r=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],d=e.mapping.slice(r);e.replaceRange(d.map(a.pos),d.map(c.pos),l?A.empty:t),l==0&&Ui(e,r,(o?o.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let o=e.steps.length,s=this.ranges;for(let r=0;r<s.length;r++){let{$from:i,$to:l}=s[r],a=e.mapping.slice(o),c=a.map(i.pos),d=a.map(l.pos);r?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),Ui(e,o,t.isInline?-1:1))}}static findFrom(e,t,o=!1){let s=e.parent.inlineContent?new z(e):Wt(e.node(0),e.parent,e.pos,e.index(),t,o);if(s)return s;for(let r=e.depth-1;r>=0;r--){let i=t<0?Wt(e.node(0),e.node(r),e.before(r+1),e.index(r),t,o):Wt(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,o);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ye(e.node(0))}static atStart(e){return Wt(e,e,0,0,1)||new ye(e)}static atEnd(e){return Wt(e,e,e.content.size,e.childCount,-1)||new ye(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let o=ys[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 ys)throw new RangeError("Duplicate use of selection JSON ID "+e);return ys[e]=t,t.prototype.jsonID=e,t}getBookmark(){return z.between(this.$anchor,this.$head).getBookmark()}}L.prototype.visible=!0;class vc{constructor(e,t){this.$from=e,this.$to=t}}let qi=!1;function Ki(n){!qi&&!n.parent.inlineContent&&(qi=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class z extends L{constructor(e,t=e){Ki(e),Ki(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 z(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 z&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Qo(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 z(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){let s=e.resolve(t);return new this(s,o==t?s:e.resolve(o))}static between(e,t,o){let s=e.pos-t.pos;if((!o||s)&&(o=s>=0?1:-1),!t.parent.inlineContent){let r=L.findFrom(t,o,!0)||L.findFrom(t,-o,!0);if(r)t=r.$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 z(e,t)}}L.jsonID("text",z);class Qo{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Qo(e.map(this.anchor),e.map(this.head))}resolve(e){return z.between(e.resolve(this.anchor),e.resolve(this.head))}}class R 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),r=e.resolve(s);return o?L.near(r):new R(r)}content(){return new A(T.from(this.node),0,0)}eq(e){return e instanceof R&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new $r(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new R(e.resolve(t.anchor))}static create(e,t){return new R(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}R.prototype.visible=!1;L.jsonID("node",R);class $r{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:o}=e.mapResult(this.anchor);return t?new Qo(o,o):new $r(o)}resolve(e){let t=e.resolve(this.anchor),o=t.nodeAfter;return o&&R.isSelectable(o)?new R(t):L.near(t)}}class ye 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 ye(e)}map(e){return new ye(e)}eq(e){return e instanceof ye}getBookmark(){return xf}}L.jsonID("all",ye);const xf={map(){return this},resolve(n){return new ye(n)}};function Wt(n,e,t,o,s,r=!1){if(e.inlineContent)return z.create(n,t);for(let i=o-(s>0?0:1);s>0?i<e.childCount:i>=0;i+=s){let l=e.child(i);if(l.isAtom){if(!r&&R.isSelectable(l))return R.create(n,t-(s<0?l.nodeSize:0))}else{let a=Wt(n,l,t+s,s<0?l.childCount:0,s,r);if(a)return a}t+=l.nodeSize*s}return null}function Ui(n,e,t){let o=n.steps.length-1;if(o<e)return;let s=n.steps[o];if(!(s instanceof se||s instanceof te))return;let r=n.mapping.maps[o],i;r.forEach((l,a,c,d)=>{i==null&&(i=d)}),n.setSelection(L.near(n.doc.resolve(i),t))}const Ji=1,co=2,Yi=4;class Sf extends bc{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|Ji)&~co,this.storedMarks=null,this}get selectionSet(){return(this.updated&Ji)>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 r=this.storedMarks;if(!r){let i=this.doc.resolve(t);r=o==t?i.marks():i.marksAcross(this.doc.resolve(o))}return this.replaceRangeWith(t,o,s.text(e,r)),this.selection.empty||this.setSelection(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|=Yi,this}get scrolledIntoView(){return(this.updated&Yi)>0}}function Zi(n,e){return!e||!n?n:n.bind(e)}class Cn{constructor(e,t,o){this.name=e,this.init=Zi(t.init,o),this.apply=Zi(t.apply,o)}}const wf=[new Cn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Cn("selection",{init(n,e){return n.selection||L.atStart(e.doc)},apply(n){return n.selection}}),new Cn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,o){return o.selection.$cursor?n.storedMarks:null}}),new Cn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class bs{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=wf.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 Cn(o.key,o.spec.state,o))})}}class Ut{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let o=0;o<this.config.plugins.length;o++)if(o!=t){let s=this.config.plugins[o];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],o=this.applyInner(e),s=null;for(;;){let r=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=s?s[i].n:0,c=s?s[i].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,o);if(d&&o.filterTransaction(d,i)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let u=0;u<this.config.plugins.length;u++)s.push(u<i?{state:o,n:t.length}:{state:this,n:0})}t.push(d),o=o.applyInner(d),r=!0}s&&(s[i]={state:o,n:t.length})}}if(!r)return{state:o,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Ut(this.config),o=this.config.fields;for(let s=0;s<o.length;s++){let r=o[s];t[r.name]=r.apply(e,this[r.name],this,t)}return t}get tr(){return new Sf(this)}static create(e){let t=new bs(e.doc?e.doc.type.schema:e.schema,e.plugins),o=new Ut(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 bs(this.schema,e.plugins),o=t.fields,s=new Ut(t);for(let r=0;r<o.length;r++){let i=o[r].name;s[i]=this.hasOwnProperty(i)?this[i]:o[r].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(o=>o.toJSON())),e&&typeof e=="object")for(let o in e){if(o=="doc"||o=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[o],r=s.spec.state;r&&r.toJSON&&(t[o]=r.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,o){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new bs(e.schema,e.plugins),r=new Ut(s);return s.fields.forEach(i=>{if(i.name=="doc")r.doc=Tt.fromJSON(e.schema,t.doc);else if(i.name=="selection")r.selection=L.fromJSON(r.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(r.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(o)for(let l in o){let a=o[l],c=a.spec.state;if(a.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){r[i.name]=c.fromJSON.call(a,e,t[l],r);return}}r[i.name]=i.init(e,r)}}),r}}function xc(n,e,t){for(let o in n){let s=n[o];s instanceof Function?s=s.bind(e):o=="handleDOMEvents"&&(s=xc(s,e,{})),t[o]=s}return t}class hn{constructor(e){this.spec=e,this.props={},e.props&&xc(e.props,this,this.props),this.key=e.key?e.key.key:Sc("plugin")}getState(e){return e[this.key]}}const vs=Object.create(null);function Sc(n){return n in vs?n+"$"+ ++vs[n]:(vs[n]=0,n+"$")}class Kn{constructor(e="key"){this.key=Sc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const wc=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Cf(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const kf=(n,e,t)=>{let o=Cf(n,t);if(!o)return!1;let s=Cc(o);if(!s){let i=o.blockRange(),l=i&&Zo(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let r=s.nodeBefore;if(Pc(n,s,e,-1))return!0;if(o.parent.content.size==0&&(an(r,"end")||R.isSelectable(r)))for(let i=o.depth;;i--){let l=Vr(n.doc,o.before(i),o.after(i),A.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(an(r,"end")?L.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):R.create(a.doc,s.pos-r.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||o.node(i-1).childCount>1)break}return r.isAtom&&s.depth==o.depth-1?(e&&e(n.tr.delete(s.pos-r.nodeSize,s.pos).scrollIntoView()),!0):!1};function an(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 Tf=(n,e,t)=>{let{$head:o,empty:s}=n.selection,r=o;if(!s)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):o.parentOffset>0)return!1;r=Cc(o)}let i=r&&r.nodeBefore;return!i||!R.isSelectable(i)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,r.pos-i.nodeSize)).scrollIntoView()),!0)};function Cc(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 Mf(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Ef=(n,e,t)=>{let o=Mf(n,t);if(!o)return!1;let s=kc(o);if(!s)return!1;let r=s.nodeAfter;if(Pc(n,s,e,1))return!0;if(o.parent.content.size==0&&(an(r,"start")||R.isSelectable(r))){let i=Vr(n.doc,o.before(),o.after(),A.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(an(r,"start")?L.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):R.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return r.isAtom&&s.depth==o.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+r.nodeSize).scrollIntoView()),!0):!1},Af=(n,e,t)=>{let{$head:o,empty:s}=n.selection,r=o;if(!s)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):o.parentOffset<o.parent.content.size)return!1;r=kc(o)}let i=r&&r.nodeAfter;return!i||!R.isSelectable(i)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,r.pos)).scrollIntoView()),!0)};function kc(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 Pf=(n,e)=>{let{$head:t,$anchor:o}=n.selection;return!t.parent.type.spec.code||!t.sameParent(o)?!1:(e&&e(n.tr.insertText(`
|
|
298
|
-
`).scrollIntoView()),!0)};function Br(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 Tc=(n,e)=>{let{$head:t,$anchor:o}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(o))return!1;let s=t.node(-1),r=t.indexAfter(-1),i=Br(s.contentMatchAt(r));if(!i||!s.canReplaceWith(r,r,i))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,i.createAndFill());a.setSelection(L.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Nf=(n,e)=>{let t=n.selection,{$from:o,$to:s}=t;if(t instanceof ye||o.parent.inlineContent||s.parent.inlineContent)return!1;let r=Br(s.parent.contentMatchAt(s.indexAfter()));if(!r||!r.isTextblock)return!1;if(e){let i=(!o.parentOffset&&s.index()<s.parent.childCount?o:s).pos,l=n.tr.insert(i,r.createAndFill());l.setSelection(z.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},Mc=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let r=t.before();if(Qt(n.doc,r))return e&&e(n.tr.split(r).scrollIntoView()),!0}let o=t.blockRange(),s=o&&Zo(o);return s==null?!1:(e&&e(n.tr.lift(o,s).scrollIntoView()),!0)};function Ec(n){return(e,t)=>{let{$from:o,$to:s}=e.selection;if(e.selection instanceof R&&e.selection.node.isBlock)return!o.parentOffset||!Qt(e.doc,o.pos)?!1:(t&&t(e.tr.split(o.pos).scrollIntoView()),!0);if(!o.depth)return!1;let r=[],i,l,a=!1,c=!1;for(let h=o.depth;;h--)if(o.node(h).isBlock){a=o.end(h)==o.pos+(o.depth-h),c=o.start(h)==o.pos-(o.depth-h),l=Br(o.node(h-1).contentMatchAt(o.indexAfter(h-1)));let m=n&&n(s.parent,a,o);r.unshift(m||(a&&l?{type:l}:null)),i=h;break}else{if(h==1)return!1;r.unshift(null)}let d=e.tr;(e.selection instanceof z||e.selection instanceof ye)&&d.deleteSelection();let u=d.mapping.map(o.pos),p=Qt(d.doc,u,r.length,r);if(p||(r[0]=l?{type:l}:null,p=Qt(d.doc,u,r.length,r)),d.split(u,r.length,r),!a&&c&&o.node(i).type!=l){let h=d.mapping.map(o.before(i)),f=d.doc.resolve(h);l&&o.node(i-1).canReplaceWith(f.index(),f.index()+1,l)&&d.setNodeMarkup(d.mapping.map(o.before(i)),l)}return t&&t(d.scrollIntoView()),!0}}const Of=Ec(),Ac=(n,e)=>(e&&e(n.tr.setSelection(new ye(n.doc))),!0);function If(n,e,t){let o=e.nodeBefore,s=e.nodeAfter,r=e.index();return!o||!s||!o.type.compatibleContent(s.type)?!1:!o.content.size&&e.parent.canReplace(r-1,r)?(t&&t(n.tr.delete(e.pos-o.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(r,r+1)||!(s.isTextblock||Xo(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Pc(n,e,t,o){let s=e.nodeBefore,r=e.nodeAfter,i,l,a=s.type.spec.isolating||r.type.spec.isolating;if(!a&&If(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=s.contentMatchAt(s.childCount)).findWrapping(r.type))&&l.matchType(i[0]||r.type).validEnd){if(t){let h=e.pos+r.nodeSize,f=T.empty;for(let v=i.length-1;v>=0;v--)f=T.from(i[v].create(null,f));f=T.from(s.copy(f));let m=n.tr.step(new te(e.pos-1,h,e.pos,h,new A(f,1,0),i.length,!0)),g=m.doc.resolve(h+2*i.length);g.nodeAfter&&g.nodeAfter.type==s.type&&Xo(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=r.type.spec.isolating||o>0&&a?null:L.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),p=u&&Zo(u);if(p!=null&&p>=e.depth)return t&&t(n.tr.lift(u,p).scrollIntoView()),!0;if(c&&an(r,"start",!0)&&an(s,"end")){let h=s,f=[];for(;f.push(h),!h.isTextblock;)h=h.lastChild;let m=r,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let v=T.empty;for(let y=f.length-1;y>=0;y--)v=T.from(f[y].copy(v));let C=n.tr.step(new te(e.pos-f.length,e.pos+r.nodeSize,e.pos+g,e.pos+r.nodeSize-g,new A(v,f.length,0),0,!0));t(C.scrollIntoView())}return!0}}return!1}function Nc(n){return function(e,t){let o=e.selection,s=n<0?o.$from:o.$to,r=s.depth;for(;s.node(r).isInline;){if(!r)return!1;r--}return s.node(r).isTextblock?(t&&t(e.tr.setSelection(z.create(e.doc,n<0?s.start(r):s.end(r)))),!0):!1}}const Rf=Nc(-1),Df=Nc(1);function Lf(n,e=null){return function(t,o){let s=!1;for(let r=0;r<t.selection.ranges.length&&!s;r++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[r];t.doc.nodesBetween(i,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)s=!0;else{let d=t.doc.resolve(c),u=d.index();s=d.parent.canReplaceWith(u,u+1,n)}})}if(!s)return!1;if(o){let r=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];r.setBlockType(l,a,n,e)}o(r.scrollIntoView())}return!0}}function zf(n,e,t,o){for(let s=0;s<e.length;s++){let{$from:r,$to:i}=e[s],l=r.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(r.pos,i.pos,(a,c)=>{if(l||!o)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function gt(n,e=null,t){let o=t!==!1;return function(s,r){let{empty:i,$cursor:l,ranges:a}=s.selection;if(i&&!l||!zf(s.doc,a,n,o))return!1;if(r)if(l)n.isInSet(s.storedMarks||l.marks())?r(s.tr.removeStoredMark(n)):r(s.tr.addStoredMark(n.create(e)));else{let c,d=s.tr;c=!a.some(u=>s.doc.rangeHasMark(u.$from.pos,u.$to.pos,n));for(let u=0;u<a.length;u++){let{$from:p,$to:h}=a[u];if(!c)d.removeMark(p.pos,h.pos,n);else{let f=p.pos,m=h.pos,g=p.nodeAfter,v=h.nodeBefore,C=g&&g.isText?/^\s*/.exec(g.text)[0].length:0,y=v&&v.isText?/\s*$/.exec(v.text)[0].length:0;f+C<m&&(f+=C,m-=y),d.addMark(f,m,n.create(e))}}r(d.scrollIntoView())}return!0}}function Hn(...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 xs=Hn(wc,kf,Tf),Xi=Hn(wc,Ef,Af);const _e={Enter:Hn(Pf,Nf,Mc,Of),"Mod-Enter":Tc,Backspace:xs,"Mod-Backspace":xs,"Shift-Backspace":xs,Delete:Xi,"Mod-Delete":Xi,"Mod-a":Ac},Oc={"Ctrl-h":_e.Backspace,"Alt-Backspace":_e["Mod-Backspace"],"Ctrl-d":_e.Delete,"Ctrl-Alt-Backspace":_e["Mod-Delete"],"Alt-Delete":_e["Mod-Delete"],"Alt-d":_e["Mod-Delete"],"Ctrl-a":Rf,"Ctrl-e":Df};for(let n in _e)Oc[n]=_e[n];const Vf=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,$f=Vf?Oc:_e;var Vo=200,Y=function(){};Y.prototype.append=function(e){return e.length?(e=Y.from(e),!this.length&&e||e.length<Vo&&this.leafAppend(e)||this.length<Vo&&e.leafPrepend(this)||this.appendInner(e)):this};Y.prototype.prepend=function(e){return e.length?Y.from(e).append(this):this};Y.prototype.appendInner=function(e){return new Bf(this,e)};Y.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Y.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};Y.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Y.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)};Y.prototype.map=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length);var s=[];return this.forEach(function(r,i){return s.push(e(r,i))},t,o),s};Y.from=function(e){return e instanceof Y?e:e&&e.length?new Ic(e):Y.empty};var Ic=function(n){function e(o){n.call(this),this.values=o}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,r){return s==0&&r==this.length?this:new e(this.values.slice(s,r))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,r,i,l){for(var a=r;a<i;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,r,i,l){for(var a=r-1;a>=i;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Vo)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Vo)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}(Y);Y.empty=new Ic([]);var Bf=function(n){function e(t,o){n.call(this),this.left=t,this.right=o,this.length=t.length+o.length,this.depth=Math.max(t.depth,o.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(o){return o<this.left.length?this.left.get(o):this.right.get(o-this.left.length)},e.prototype.forEachInner=function(o,s,r,i){var l=this.left.length;if(s<l&&this.left.forEachInner(o,s,Math.min(r,l),i)===!1||r>l&&this.right.forEachInner(o,Math.max(s-l,0),Math.min(this.length,r)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,r,i){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(o,s-l,Math.max(r,l)-l,i+l)===!1||r<l&&this.left.forEachInvertedInner(o,Math.min(s,l),r,i)===!1)return!1},e.prototype.sliceInner=function(o,s){if(o==0&&s==this.length)return this;var r=this.left.length;return s<=r?this.left.slice(o,s):o>=r?this.right.slice(o-r,s-r):this.left.slice(o,r).append(this.right.slice(0,s-r))},e.prototype.leafAppend=function(o){var s=this.right.leafAppend(o);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(o){var s=this.left.leafPrepend(o);if(s)return new e(s,this.right)},e.prototype.appendInner=function(o){return this.left.depth>=Math.max(this.right.depth,o.depth)+1?new e(this.left,new e(this.right,o)):new e(this,o)},e}(Y);const Hf=500;class Te{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}let s,r;t&&(s=this.remapping(o,this.items.length),r=s.maps.length);let i=e.tr,l,a,c=[],d=[];return this.items.forEach((u,p)=>{if(!u.step){s||(s=this.remapping(o,p+1),r=s.maps.length),r--,d.push(u);return}if(s){d.push(new Pe(u.map));let h=u.step.map(s.slice(r)),f;h&&i.maybeStep(h).doc&&(f=i.mapping.maps[i.mapping.maps.length-1],c.push(new Pe(f,void 0,void 0,c.length+d.length))),r--,f&&s.appendMap(f,r)}else i.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(r)):u.selection,a=new Te(this.items.slice(0,o).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,o,s){let r=[],i=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),p=new Pe(e.mapping.maps[d],u,t),h;(h=a&&a.merge(p))&&(p=h,d?r.pop():l=l.slice(0,l.length-1)),r.push(p),t&&(i++,t=void 0),s||(a=p)}let c=i-o.depth;return c>_f&&(l=Ff(l,c),i-=c),new Te(l.append(r),i)}remapping(e,t){let o=new Xt;return this.items.forEach((s,r)=>{let i=s.mirrorOffset!=null&&r-s.mirrorOffset>=e?o.maps.length-s.mirrorOffset:void 0;o.appendMap(s.map,i)},e,t),o}addMaps(e){return this.eventCount==0?this:new Te(this.items.append(e.map(t=>new Pe(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let o=[],s=Math.max(0,this.items.length-t),r=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},s);let a=t;this.items.forEach(p=>{let h=r.getMirror(--a);if(h==null)return;i=Math.min(i,h);let f=r.maps[h];if(p.step){let m=e.steps[h].invert(e.docs[h]),g=p.selection&&p.selection.map(r.slice(a+1,h));g&&l++,o.push(new Pe(f,m,g))}else o.push(new Pe(f))},s);let c=[];for(let p=t;p<i;p++)c.push(new Pe(r.maps[p]));let d=this.items.slice(0,s).append(c).append(o),u=new Te(d,l);return u.emptyItemCount()>Hf&&(u=u.compress(this.items.length-o.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),o=t.maps.length,s=[],r=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&r++;else if(i.step){let a=i.step.map(t.slice(o)),c=a&&a.getMap();if(o--,c&&t.appendMap(c,o),a){let d=i.selection&&i.selection.map(t.slice(o));d&&r++;let u=new Pe(c.invert(),a,d),p,h=s.length-1;(p=s.length&&s[h].merge(u))?s[h]=p:s.push(u)}}else i.map&&o--},this.items.length,0),new Te(Y.from(s.reverse()),r)}}Te.empty=new Te(Y.empty,0);function Ff(n,e){let t;return n.forEach((o,s)=>{if(o.selection&&e--==0)return t=s,!1}),n.slice(t)}class Pe{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 Pe(t.getMap().invert(),t,this.selection)}}}class Je{constructor(e,t,o,s,r){this.done=e,this.undone=t,this.prevRanges=o,this.prevTime=s,this.prevComposition=r}}const _f=20;function Gf(n,e,t,o){let s=t.getMeta(Mt),r;if(s)return s.historyState;t.getMeta(qf)&&(n=new Je(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(Mt))return i.getMeta(Mt).redo?new Je(n.done.addTransform(t,void 0,o,So(e)),n.undone,Qi(t.mapping.maps),n.prevTime,n.prevComposition):new Je(n.done,n.undone.addTransform(t,void 0,o,So(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-o.newGroupDelay||!Wf(t,n.prevRanges)),c=i?Ss(n.prevRanges,t.mapping):Qi(t.mapping.maps);return new Je(n.done.addTransform(t,a?e.selection.getBookmark():void 0,o,So(e)),Te.empty,c,t.time,l??n.prevComposition)}else return(r=t.getMeta("rebased"))?new Je(n.done.rebased(t,r),n.undone.rebased(t,r),Ss(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Je(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Ss(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Wf(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((o,s)=>{for(let r=0;r<e.length;r+=2)o<=e[r+1]&&s>=e[r]&&(t=!0)}),t}function Qi(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((o,s,r,i)=>e.push(r,i));return e}function Ss(n,e){if(!n)return null;let t=[];for(let o=0;o<n.length;o+=2){let s=e.map(n[o],1),r=e.map(n[o+1],-1);s<=r&&t.push(s,r)}return t}function jf(n,e,t){let o=So(e),s=Mt.get(e).spec.config,r=(t?n.undone:n.done).popEvent(e,o);if(!r)return null;let i=r.selection.resolve(r.transform.doc),l=(t?n.done:n.undone).addTransform(r.transform,e.selection.getBookmark(),s,o),a=new Je(t?l:r.remaining,t?r.remaining:l,null,0,-1);return r.transform.setSelection(i).setMeta(Mt,{redo:t,historyState:a})}let ws=!1,el=null;function So(n){let e=n.plugins;if(el!=e){ws=!1,el=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){ws=!0;break}}return ws}const Mt=new Kn("history"),qf=new Kn("closeHistory");function Kf(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new hn({key:Mt,state:{init(){return new Je(Te.empty,Te.empty,null,0,-1)},apply(e,t,o){return Gf(t,o,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let o=t.inputType,s=o=="historyUndo"?Dc:o=="historyRedo"?tr:null;return s?(t.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function Rc(n,e){return(t,o)=>{let s=Mt.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(o){let r=jf(s,t,n);r&&o(e?r.scrollIntoView():r)}return!0}}const Dc=Rc(!1,!0),tr=Rc(!0,!0);var at={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:"'"},$o={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Uf=typeof navigator<"u"&&/Mac/.test(navigator.platform),Jf=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Q=0;Q<10;Q++)at[48+Q]=at[96+Q]=String(Q);for(var Q=1;Q<=24;Q++)at[Q+111]="F"+Q;for(var Q=65;Q<=90;Q++)at[Q]=String.fromCharCode(Q+32),$o[Q]=String.fromCharCode(Q);for(var Cs in at)$o.hasOwnProperty(Cs)||($o[Cs]=at[Cs]);function Yf(n){var e=Uf&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Jf&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?$o:at)[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 Zf=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Xf(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let o,s,r,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))o=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))r=!0;else if(/^mod$/i.test(a))Zf?i=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return o&&(t="Alt-"+t),s&&(t="Ctrl-"+t),i&&(t="Meta-"+t),r&&(t="Shift-"+t),t}function Qf(n){let e=Object.create(null);for(let t in n)e[Xf(t)]=n[t];return e}function ks(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 Ts(n){return new hn({props:{handleKeyDown:Lc(n)}})}function Lc(n){let e=Qf(n);return function(t,o){let s=Yf(o),r,i=e[ks(s,o)];if(i&&i(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(o.shiftKey){let l=e[ks(s,o,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((o.shiftKey||o.altKey||o.metaKey||s.charCodeAt(0)>127)&&(r=at[o.keyCode])&&r!=s){let l=e[ks(r,o)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}function tl(n,e=null){return function(t,o){let{$from:s,$to:r}=t.selection,i=s.blockRange(r),l=!1,a=i;if(!i)return!1;if(i.depth>=2&&s.node(i.depth-1).type.compatibleContent(n)&&i.startIndex==0){if(s.index(i.depth-1)==0)return!1;let d=t.doc.resolve(i.start-2);a=new Ro(d,d,i.depth),i.endIndex<i.parent.childCount&&(i=new Ro(s,t.doc.resolve(r.end(i.depth)),i.depth)),l=!0}let c=uc(a,n,e,i);return c?(o&&o(em(t.tr,i,c,l,n).scrollIntoView()),!0):!1}}function em(n,e,t,o,s){let r=T.empty;for(let d=t.length-1;d>=0;d--)r=T.from(t[d].type.create(t[d].attrs,r));n.step(new te(e.start-(o?2:0),e.end,e.start,e.end,new A(r,0,0),t.length,!0));let i=0;for(let d=0;d<t.length;d++)t[d].type==s&&(i=d+1);let l=t.length-i,a=e.start+t.length-(o?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,p=!0;d<u;d++,p=!1)!p&&Qt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function tm(n,e){return function(t,o){let{$from:s,$to:r,node:i}=t.selection;if(i&&i.isBlock||s.depth<2||!s.sameParent(r))return!1;let l=s.node(-1);if(l.type!=n)return!1;if(s.parent.content.size==0&&s.node(-1).childCount==s.indexAfter(-1)){if(s.depth==3||s.node(-3).type!=n||s.index(-2)!=s.node(-2).childCount-1)return!1;if(o){let u=T.empty,p=s.index(-1)?1:s.index(-2)?2:3;for(let v=s.depth-p;v>=s.depth-3;v--)u=T.from(s.node(v).copy(u));let h=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3;u=u.append(T.from(n.createAndFill()));let f=s.before(s.depth-(p-1)),m=t.tr.replace(f,s.after(-h),new A(u,4-p,0)),g=-1;m.doc.nodesBetween(f,m.doc.content.size,(v,C)=>{if(g>-1)return!1;v.isTextblock&&v.content.size==0&&(g=C+1)}),g>-1&&m.setSelection(L.near(m.doc.resolve(g))),o(m.scrollIntoView())}return!0}let a=r.pos==s.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(s.pos,r.pos),d=a?[null,{type:a}]:void 0;return Qt(c.doc,s.pos,2,d)?(o&&o(c.split(s.pos,2,d).scrollIntoView()),!0):!1}}function nr(n){return function(e,t){let{$from:o,$to:s}=e.selection,r=o.blockRange(s,i=>i.childCount>0&&i.firstChild.type==n);return r?t?o.node(r.depth-1).type==n?nm(e,t,n,r):om(e,t,r):!0:!1}}function nm(n,e,t,o){let s=n.tr,r=o.end,i=o.$to.end(o.depth);r<i&&(s.step(new te(r-1,i,r,i,new A(T.from(t.create(null,o.parent.copy())),1,0),1,!0)),o=new Ro(s.doc.resolve(o.$from.pos),s.doc.resolve(i),o.depth));const l=Zo(o);if(l==null)return!1;s.lift(o,l);let a=s.mapping.map(r,-1)-1;return Xo(s.doc,a)&&s.join(a),e(s.scrollIntoView()),!0}function om(n,e,t){let o=n.tr,s=t.parent;for(let h=t.end,f=t.endIndex-1,m=t.startIndex;f>m;f--)h-=s.child(f).nodeSize,o.delete(h-1,h+1);let r=o.doc.resolve(t.start),i=r.nodeAfter;if(o.mapping.map(t.end)!=t.start+r.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=r.node(-1),d=r.index(-1);if(!c.canReplace(d+(l?0:1),d+1,i.content.append(a?T.empty:T.from(s))))return!1;let u=r.pos,p=u+i.nodeSize;return o.step(new te(u-(l?1:0),p+(a?1:0),u+1,p-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 sm(n){return function(e,t){let{$from:o,$to:s}=e.selection,r=o.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!r)return!1;let i=r.startIndex;if(i==0)return!1;let l=r.parent,a=l.child(i-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=T.from(c?n.create():null),u=new A(T.from(n.create(null,T.from(l.type.create(null,d)))),c?3:1,0),p=r.start,h=r.end;t(e.tr.step(new te(p-(c?3:1),h,p,h,u,1,!0)).scrollIntoView())}return!0}}const ee=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Fn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let or=null;const Fe=function(n,e,t){let o=or||(or=document.createRange());return o.setEnd(n,t??n.nodeValue.length),o.setStart(n,e||0),o},rm=function(){or=null},It=function(n,e,t,o){return t&&(nl(n,e,t,o,-1)||nl(n,e,t,o,1))},im=/^(img|br|input|textarea|hr)$/i;function nl(n,e,t,o,s){for(;;){if(n==t&&e==o)return!0;if(e==(s<0?0:Se(n))){let r=n.parentNode;if(!r||r.nodeType!=1||Un(n)||im.test(n.nodeName)||n.contentEditable=="false")return!1;e=ee(n)+(s<0?0:1),n=r}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.contentEditable=="false")return!1;e=s<0?Se(n):0}else return!1}}function Se(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function lm(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=Se(n)}else if(n.parentNode&&!Un(n))e=ee(n),n=n.parentNode;else return null}}function am(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&&!Un(n))e=ee(n)+1,n=n.parentNode;else return null}}function cm(n,e,t){for(let o=e==0,s=e==Se(n);o||s;){if(n==t)return!0;let r=ee(n);if(n=n.parentNode,!n)return!1;o=o&&r==0,s=s&&r==Se(n)}}function Un(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 es=function(n){return n.focusNode&&It(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function yt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function dm(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function um(n,e,t){if(n.caretPositionFromPoint)try{let o=n.caretPositionFromPoint(e,t);if(o)return{node:o.offsetNode,offset:Math.min(Se(o.offsetNode),o.offset)}}catch{}if(n.caretRangeFromPoint){let o=n.caretRangeFromPoint(e,t);if(o)return{node:o.startContainer,offset:Math.min(Se(o.startContainer),o.startOffset)}}}const De=typeof navigator<"u"?navigator:null,ol=typeof document<"u"?document:null,dt=De&&De.userAgent||"",sr=/Edge\/(\d+)/.exec(dt),zc=/MSIE \d/.exec(dt),rr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(dt),he=!!(zc||rr||sr),rt=zc?document.documentMode:rr?+rr[1]:sr?+sr[1]:0,Ee=!he&&/gecko\/(\d+)/i.test(dt);Ee&&+(/Firefox\/(\d+)/.exec(dt)||[0,0])[1];const ir=!he&&/Chrome\/(\d+)/.exec(dt),re=!!ir,Vc=ir?+ir[1]:0,ae=!he&&!!De&&/Apple Computer/.test(De.vendor),cn=ae&&(/Mobile\/\w+/.test(dt)||!!De&&De.maxTouchPoints>2),xe=cn||(De?/Mac/.test(De.platform):!1),pm=De?/Win/.test(De.platform):!1,ke=/Android \d/.test(dt),Jn=!!ol&&"webkitFontSmoothing"in ol.documentElement.style,hm=Jn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function fm(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 Ve(n,e){return typeof n=="number"?n:n[e]}function mm(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 sl(n,e,t){let o=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,r=n.dom.ownerDocument;for(let i=t||n.dom;i;i=Fn(i)){if(i.nodeType!=1)continue;let l=i,a=l==r.body,c=a?fm(r):mm(l),d=0,u=0;if(e.top<c.top+Ve(o,"top")?u=-(c.top-e.top+Ve(s,"top")):e.bottom>c.bottom-Ve(o,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+Ve(s,"top")-c.top:e.bottom-c.bottom+Ve(s,"bottom")),e.left<c.left+Ve(o,"left")?d=-(c.left-e.left+Ve(s,"left")):e.right>c.right-Ve(o,"right")&&(d=e.right-c.right+Ve(s,"right")),d||u)if(a)r.defaultView.scrollBy(d,u);else{let p=l.scrollLeft,h=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let f=l.scrollLeft-p,m=l.scrollTop-h;e={left:e.left-f,top:e.top-m,right:e.right-f,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(i).position))break}}function gm(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),o,s;for(let r=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=n.root.elementFromPoint(r,i);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){o=l,s=a.top;break}}return{refDOM:o,refTop:s,stack:$c(n.dom)}}function $c(n){let e=[],t=n.ownerDocument;for(let o=n;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),n!=t);o=Fn(o));return e}function ym({refDOM:n,refTop:e,stack:t}){let o=n?n.getBoundingClientRect().top:0;Bc(t,o==0?0:o-e)}function Bc(n,e){for(let t=0;t<n.length;t++){let{dom:o,top:s,left:r}=n[t];o.scrollTop!=s+e&&(o.scrollTop=s+e),o.scrollLeft!=r&&(o.scrollLeft=r)}}let Ft=null;function bm(n){if(n.setActive)return n.setActive();if(Ft)return n.focus(Ft);let e=$c(n);n.focus(Ft==null?{get preventScroll(){return Ft={preventScroll:!0},!0}}:void 0),Ft||(Ft=!1,Bc(e,0))}function Hc(n,e){let t,o=2e8,s,r=0,i=e.top,l=e.top,a,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let p;if(d.nodeType==1)p=d.getClientRects();else if(d.nodeType==3)p=Fe(d).getClientRects();else continue;for(let h=0;h<p.length;h++){let f=p[h];if(f.top<=i&&f.bottom>=l){i=Math.max(f.bottom,i),l=Math.min(f.top,l);let m=f.left>e.left?f.left-e.left:f.right<e.left?e.left-f.right:0;if(m<o){t=d,o=m,s=m&&t.nodeType==3?{left:f.right<e.left?f.right:f.left,top:e.top}:e,d.nodeType==1&&m&&(r=u+(e.left>=(f.left+f.right)/2?1:0));continue}}else f.top>e.top&&!a&&f.left<=e.left&&f.right>=e.left&&(a=d,c={left:Math.max(f.left,Math.min(f.right,e.left)),top:f.top});!t&&(e.left>=f.right&&e.top>=f.top||e.left>=f.left&&e.top>=f.bottom)&&(r=u+1)}}return!t&&a&&(t=a,s=c,o=0),t&&t.nodeType==3?vm(t,s):!t||o&&t.nodeType==1?{node:n,offset:r}:Hc(t,s)}function vm(n,e){let t=n.nodeValue.length,o=document.createRange();for(let s=0;s<t;s++){o.setEnd(n,s+1),o.setStart(n,s);let r=Ue(o,1);if(r.top!=r.bottom&&Hr(e,r))return{node:n,offset:s+(e.left>=(r.left+r.right)/2?1:0)}}return{node:n,offset:0}}function Hr(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function xm(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Sm(n,e,t){let{node:o,offset:s}=Hc(e,t),r=-1;if(o.nodeType==1&&!o.firstChild){let i=o.getBoundingClientRect();r=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(o,s,r)}function wm(n,e,t,o){let s=-1;for(let r=e,i=!1;r!=n.dom;){let l=n.docView.nearestDesc(r,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!i&&a.left>o.left||a.top>o.top?s=l.posBefore:(!i&&a.right<o.left||a.bottom<o.top)&&(s=l.posAfter),i=!0),!l.contentDOM&&s<0&&!l.node.isText)return(l.node.isBlock?o.top<(a.top+a.bottom)/2:o.left<(a.left+a.right)/2)?l.posBefore:l.posAfter}r=l.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function Fc(n,e,t){let o=n.childNodes.length;if(o&&t.top<t.bottom)for(let s=Math.max(0,Math.min(o-1,Math.floor(o*(e.top-t.top)/(t.bottom-t.top))-2)),r=s;;){let i=n.childNodes[r];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Hr(e,c))return Fc(i,e,c)}}if((r=(r+1)%o)==s)break}return n}function Cm(n,e){let t=n.dom.ownerDocument,o,s=0,r=um(t,e.left,e.top);r&&({node:o,offset:s}=r);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=n.dom.getBoundingClientRect();if(!Hr(e,c)||(i=Fc(n.dom,e,c),!i))return null}if(ae)for(let c=i;o&&c;c=Fn(c))c.draggable&&(o=void 0);if(i=xm(i,e),o){if(Ee&&o.nodeType==1&&(s=Math.min(s,o.childNodes.length),s<o.childNodes.length)){let d=o.childNodes[s],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&s++}let c;Jn&&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=wm(n,o,s,e))}l==null&&(l=Sm(n,i,e));let a=n.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function rl(n){return n.top<n.bottom||n.left<n.right}function Ue(n,e){let t=n.getClientRects();if(t.length){let o=t[e<0?0:t.length-1];if(rl(o))return o}return Array.prototype.find.call(t,rl)||n.getBoundingClientRect()}const km=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function _c(n,e,t){let{node:o,offset:s,atom:r}=n.docView.domFromPos(e,t<0?-1:1),i=Jn||Ee;if(o.nodeType==3)if(i&&(km.test(o.nodeValue)||(t<0?!s:s==o.nodeValue.length))){let a=Ue(Fe(o,s,s),t);if(Ee&&s&&/\s/.test(o.nodeValue[s-1])&&s<o.nodeValue.length){let c=Ue(Fe(o,s-1,s-1),-1);if(c.top==a.top){let d=Ue(Fe(o,s,s+1),-1);if(d.top!=a.top)return gn(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++,gn(Ue(Fe(o,a,c),d),d<0)}if(!n.state.doc.resolve(e-(r||0)).parent.inlineContent){if(r==null&&s&&(t<0||s==Se(o))){let a=o.childNodes[s-1];if(a.nodeType==1)return Ms(a.getBoundingClientRect(),!1)}if(r==null&&s<Se(o)){let a=o.childNodes[s];if(a.nodeType==1)return Ms(a.getBoundingClientRect(),!0)}return Ms(o.getBoundingClientRect(),t>=0)}if(r==null&&s&&(t<0||s==Se(o))){let a=o.childNodes[s-1],c=a.nodeType==3?Fe(a,Se(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return gn(Ue(c,1),!1)}if(r==null&&s<Se(o)){let a=o.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Fe(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return gn(Ue(c,-1),!0)}return gn(Ue(o.nodeType==3?Fe(o):o,-t),t>=0)}function gn(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 Ms(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 Gc(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 Tm(n,e,t){let o=e.selection,s=t=="up"?o.$from:o.$to;return Gc(n,e,()=>{let{node:r}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(r,!0);if(!l)break;if(l.node.isBlock){r=l.contentDOM||l.dom;break}r=l.dom.parentNode}let i=_c(n,s.pos,1);for(let l=r.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Fe(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?i.top-d.top>(d.bottom-i.top)*2:d.bottom-i.bottom>(i.bottom-d.top)*2))return!1}}return!0})}const Mm=/[\u0590-\u08ac]/;function Em(n,e,t){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let s=o.parentOffset,r=!s,i=s==o.parent.content.size,l=n.domSelection();return l?!Mm.test(o.parent.textContent)||!l.modify?t=="left"||t=="backward"?r:i:Gc(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",t,"character");let h=o.depth?n.docView.domAfterPos(o.before()):n.dom,{focusNode:f,focusOffset:m}=n.domSelectionRange(),g=f&&!h.contains(f.nodeType==1?f:f.parentNode)||a==f&&c==m;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return p!=null&&(l.caretBidiLevel=p),g}):o.pos==o.start()||o.pos==o.end()}let il=null,ll=null,al=!1;function Am(n,e,t){return il==e&&ll==t?al:(il=e,ll=t,al=t=="up"||t=="down"?Tm(n,e,t):Em(n,e,t))}const we=0,cl=1,xt=2,Le=3;class Yn{constructor(e,t,o,s){this.parent=e,this.children=t,this.dom=o,this.contentDOM=s,this.dirty=we,o.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,o){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,o=this.posAtStart;;t++){let s=this.children[t];if(s==e)return o;o+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,o){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(o<0){let r,i;if(e==this.contentDOM)r=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.previousSibling}for(;r&&!((i=r.pmViewDesc)&&i.parent==this);)r=r.previousSibling;return r?this.posBeforeChild(i)+i.size:this.posAtStart}else{let r,i;if(e==this.contentDOM)r=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.nextSibling}for(;r&&!((i=r.pmViewDesc)&&i.parent==this);)r=r.nextSibling;return r?this.posBeforeChild(i):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>ee(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let r=e;;r=r.parentNode){if(r==this.dom){s=!1;break}if(r.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let r=e;;r=r.parentNode){if(r==this.dom){s=!0;break}if(r.nextSibling)break}}return s??o>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let o=!0,s=e;s;s=s.parentNode){let r=this.getDesc(s),i;if(r&&(!t||r.node))if(o&&(i=r.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))o=!1;else return r}}getDesc(e){let t=e.pmViewDesc;for(let o=t;o;o=o.parent)if(o==this)return t}posFromDOM(e,t,o){for(let s=e;s;s=s.parentNode){let r=this.getDesc(s);if(r)return r.localPosFromDOM(e,t,o)}return-1}descAt(e){for(let t=0,o=0;t<this.children.length;t++){let s=this.children[t],r=o+s.size;if(o==e&&r!=o){for(;!s.border&&s.children.length;)s=s.children[0];return s}if(e<r)return s.descAt(e-o-s.border);o=r}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let o=0,s=0;for(let r=0;o<this.children.length;o++){let i=this.children[o],l=r+i.size;if(l>e||i instanceof jc){s=e-r;break}r=l}if(s)return this.children[o].domFromPos(s-this.children[o].border,t);for(let r;o&&!(r=this.children[o-1]).size&&r instanceof Wc&&r.side>=0;o--);if(t<=0){let r,i=!0;for(;r=o?this.children[o-1]:null,!(!r||r.dom.parentNode==this.contentDOM);o--,i=!1);return r&&t&&i&&!r.border&&!r.domAtom?r.domFromPos(r.size,t):{node:this.contentDOM,offset:r?ee(r.dom)+1:0}}else{let r,i=!0;for(;r=o<this.children.length?this.children[o]:null,!(!r||r.dom.parentNode==this.contentDOM);o++,i=!1);return r&&i&&!r.border&&!r.domAtom?r.domFromPos(0,t):{node:this.contentDOM,offset:r?ee(r.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,o=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,r=-1;for(let i=o,l=0;;l++){let a=this.children[l],c=i+a.size;if(s==-1&&e<=c){let d=i+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=i;for(let u=l;u>0;u--){let p=this.children[u-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){s=ee(p.dom)+1;break}e-=p.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){r=ee(u.dom);break}t+=u.size}r==-1&&(r=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:r}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:o}=this.domFromPos(e,0);if(t.nodeType!=1||o==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[o]}setSelection(e,t,o,s=!1){let r=Math.min(e,t),i=Math.max(e,t);for(let h=0,f=0;h<this.children.length;h++){let m=this.children[h],g=f+m.size;if(r>f&&i<g)return m.setSelection(e-f-m.border,t-f-m.border,o,s);f=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=o.root.getSelection(),d=o.domSelectionRange(),u=!1;if((Ee||ae)&&e==t){let{node:h,offset:f}=l;if(h.nodeType==3){if(u=!!(f&&h.nodeValue[f-1]==`
|
|
299
|
-
`),u&&f==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:ee(g)+1});break}let v=m.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let m=h.childNodes[f-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Ee&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||u&&ae)&&It(l.node,l.offset,d.anchorNode,d.anchorOffset)&&It(a.node,a.offset,d.focusNode,d.focusOffset))return;let p=!1;if((c.extend||e==t)&&!u){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),p=!0}catch{}}if(!p){if(e>t){let f=l;l=a,a=f}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let o=0,s=0;s<this.children.length;s++){let r=this.children[s],i=o+r.size;if(o==i?e<=i&&t>=o:e<i&&t>o){let l=o+r.border,a=i-r.border;if(e>=l&&t<=a){this.dirty=e==o||t==i?xt:cl,e==l&&t==a&&(r.contentLost||r.dom.parentNode!=this.contentDOM)?r.dirty=Le:r.markDirty(e-l,t-l);return}else r.dirty=r.dom==r.contentDOM&&r.dom.parentNode==this.contentDOM&&!r.children.length?xt:Le}o=i}this.dirty=xt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let o=e==1?xt:cl;t.dirty<o&&(t.dirty=o)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class Wc extends Yn{constructor(e,t,o,s){let r,i=t.type.toDOM;if(typeof i=="function"&&(i=i(o,()=>{if(!r)return s;if(r.parent)return r.parent.posBeforeChild(r)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return this.dirty==we&&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 Pm extends Yn{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 Rt extends Yn{constructor(e,t,o,s,r){super(e,[],o,s),this.mark=t,this.spec=r}static create(e,t,o,s){let r=s.nodeViews[t.type.name],i=r&&r(t,s,o);return(!i||!i.dom)&&(i=zt.renderSpec(document,t.type.spec.toDOM(t,o),null,t.attrs)),new Rt(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&Le||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Le&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=we){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=we}}slice(e,t,o){let s=Rt.create(this.parent,this.mark,!0,o),r=this.children,i=this.size;t<i&&(r=ar(r,t,i,o)),e>0&&(r=ar(r,0,e,o));for(let l=0;l<r.length;l++)r[l].parent=s;return s.children=r,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class it extends Yn{constructor(e,t,o,s,r,i,l,a,c){super(e,[],r,i),this.node=t,this.outerDeco=o,this.innerDeco=s,this.nodeDOM=l}static create(e,t,o,s,r,i){let l=r.nodeViews[t.type.name],a,c=l&&l(t,r,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},o,s),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=zt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let p=d;return d=Uc(d,o,t),c?a=new Nm(e,t,o,s,d,u||null,p,c,r,i+1):t.isText?new ts(e,t,o,s,d,p,r):new it(e,t,o,s,d,u||null,p,r,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let o=this.children[t];if(this.dom.contains(o.dom.parentNode)){e.contentElement=o.dom.parentNode;break}}e.contentElement||(e.getContent=()=>T.empty)}return e}matchesNode(e,t,o){return this.dirty==we&&e.eq(this.node)&&Bo(t,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let o=this.node.inlineContent,s=t,r=e.composing?this.localCompositionInfo(e,t):null,i=r&&r.pos>-1?r:null,l=r&&r.pos<0,a=new Im(this,i&&i.node,e);Lm(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,o,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?B.none:this.node.child(d).marks,o,e),a.placeWidget(c,e,s)},(c,d,u,p)=>{a.syncToMarks(c.marks,o,e);let h;a.findNodeMatch(c,d,u,p)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(r.node))>-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,p,s)||a.addNode(c,d,u,e,s),s+=c.nodeSize}),a.syncToMarks([],o,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==xt)&&(i&&this.protectLocalComposition(e,i),qc(this.contentDOM,this.children,e),cn&&zm(this.dom))}localCompositionInfo(e,t){let{from:o,to:s}=e.state.selection;if(!(e.state.selection instanceof z)||o<t||s>t+this.node.content.size)return null;let r=e.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let i=r.nodeValue,l=Vm(this.node.content,i,o-t,s-t);return l<0?null:{node:r,pos:l,text:i}}else return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:o,text:s}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let i=new Pm(this,r,t,s);e.input.compositionNodes.push(i),this.children=ar(this.children,o,o+s.length,e,i)}update(e,t,o,s){return this.dirty==Le||!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=we}updateOuterDeco(e){if(Bo(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,o=this.dom;this.dom=Kc(this.dom,this.nodeDOM,lr(this.outerDeco,this.node,t),lr(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 dl(n,e,t,o,s){Uc(o,e,n);let r=new it(void 0,n,e,t,o,o,o,s,0);return r.contentDOM&&r.updateChildren(s,0),r}class ts extends it{constructor(e,t,o,s,r,i,l){super(e,t,o,s,r,null,i,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,o,s){return this.dirty==Le||this.dirty!=we&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=we||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=we,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,o){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,o)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,o){let s=this.node.cut(e,t),r=document.createTextNode(s.text);return new ts(this.parent,s,this.outerDeco,this.innerDeco,r,r,o)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Le)}get domAtom(){return!1}isText(e){return this.node.text==e}}class jc extends Yn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==we&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Nm extends it{constructor(e,t,o,s,r,i,l,a,c,d){super(e,t,o,s,r,i,l,c,d),this.spec=a}update(e,t,o,s){if(this.dirty==Le)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,o);return r&&this.updateInner(e,t,o,s),r}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,o,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,o,s){this.spec.setSelection?this.spec.setSelection(e,t,o.root):super.setSelection(e,t,o,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function qc(n,e,t){let o=n.firstChild,s=!1;for(let r=0;r<e.length;r++){let i=e[r],l=i.dom;if(l.parentNode==n){for(;l!=o;)o=ul(o),s=!0;o=o.nextSibling}else s=!0,n.insertBefore(l,o);if(i instanceof Rt){let a=o?o.previousSibling:n.lastChild;qc(i.contentDOM,i.children,t),o=a?a.nextSibling:n.firstChild}}for(;o;)o=ul(o),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const Pn=function(n){n&&(this.nodeName=n)};Pn.prototype=Object.create(null);const St=[new Pn];function lr(n,e,t){if(n.length==0)return St;let o=t?St[0]:new Pn,s=[o];for(let r=0;r<n.length;r++){let i=n[r].type.attrs;if(i){i.nodeName&&s.push(o=new Pn(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&s.length==1&&s.push(o=new Pn(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 Kc(n,e,t,o){if(t==St&&o==St)return e;let s=e;for(let r=0;r<o.length;r++){let i=o[r],l=t[r];if(r){let a;l&&l.nodeName==i.nodeName&&s!=n&&(a=s.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=St[0]),s=a}Om(s,l||St[0],i)}return s}function Om(n,e,t){for(let o in e)o!="class"&&o!="style"&&o!="nodeName"&&!(o in t)&&n.removeAttribute(o);for(let o in t)o!="class"&&o!="style"&&o!="nodeName"&&t[o]!=e[o]&&n.setAttribute(o,t[o]);if(e.class!=t.class){let o=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let r=0;r<o.length;r++)s.indexOf(o[r])==-1&&n.classList.remove(o[r]);for(let r=0;r<s.length;r++)o.indexOf(s[r])==-1&&n.classList.add(s[r]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=o.exec(e.style);)n.style.removeProperty(s[1])}t.style&&(n.style.cssText+=t.style)}}function Uc(n,e,t){return Kc(n,n,St,lr(e,t,n.nodeType!=1))}function Bo(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function ul(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Im{constructor(e,t,o){this.lock=t,this.view=o,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Rm(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let o=e;o<t;o++)this.top.children[o].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,o){let s=0,r=this.stack.length>>1,i=Math.min(r,e.length);for(;s<i&&(s==r-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<r;)this.destroyRest(),this.top.dirty=we,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[r])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Rt.create(this.top,e[r],t,o);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,r++}}findNodeMatch(e,t,o,s){let r=-1,i;if(s>=this.preMatch.index&&(i=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,o))r=this.top.children.indexOf(i,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,o)&&!this.preMatch.matched.has(c)){r=l;break}}return r<0?!1:(this.destroyBetween(this.index,r),this.index++,!0)}updateNodeAt(e,t,o,s,r){let i=this.top.children[s];return i.dirty==Le&&i.dom==i.contentDOM&&(i.dirty=xt),i.update(e,t,o,r)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let o=e.pmViewDesc;if(o){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==o)return s}return-1}e=t}}updateNextNode(e,t,o,s,r,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof it){let c=this.preMatch.matched.get(a);if(c!=null&&c!=r)return!1;let d=a.dom,u,p=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Le&&Bo(t,a.outerDeco));if(!p&&a.update(e,t,o,s))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!p&&(u=this.recreateWrapper(a,e,t,o,s,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=xt,u.updateChildren(s,i+1),u.dirty=we),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,o,s,r,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Bo(o,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=it.create(this.top,t,o,s,r,i);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,o,s,r){let i=it.create(this.top,e,t,o,s,r);i.contentDOM&&i.updateChildren(s,r+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,o){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let r=new Wc(this.top,e,t,o);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Rt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof ts)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ae||re)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let o=document.createElement(e);e=="IMG"&&(o.className="ProseMirror-separator",o.alt=""),e=="BR"&&(o.className="ProseMirror-trailingBreak");let s=new jc(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 Rm(n,e){let t=e,o=t.children.length,s=n.childCount,r=new Map,i=[];e:for(;s>0;){let l;for(;;)if(o){let c=t.children[o-1];if(c instanceof Rt)t=c,o=c.children.length;else{l=c,o--;break}}else{if(t==e)break e;o=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(s-1))break;--s,r.set(l,s),i.push(l)}}return{index:s,matched:r,matches:i.reverse()}}function Dm(n,e){return n.type.side-e.type.side}function Lm(n,e,t,o){let s=e.locals(n),r=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);o(d,s,e.forChild(r,d),c),r+=d.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let d,u;for(;i<s.length&&s[i].to==r;){let g=s[i++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(Dm);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let p,h;if(a)h=-1,p=a,a=null;else if(c<n.childCount)h=c,p=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=r&&l.splice(g--,1);for(;i<s.length&&s[i].from<=r&&s[i].to>r;)l.push(s[i++]);let f=r+p.nodeSize;if(p.isText){let g=f;i<s.length&&s[i].from<g&&(g=s[i].from);for(let v=0;v<l.length;v++)l[v].to<g&&(g=l[v].to);g<f&&(a=p.cut(g-r),p=p.cut(0,g-r),f=g,h=-1)}else for(;i<s.length&&s[i].to<f;)i++;let m=p.isInline&&!p.isLeaf?l.filter(g=>!g.inline):l.slice();o(p,m,e.forChild(r,p),h),r=f}}function zm(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 Vm(n,e,t,o){for(let s=0,r=0;s<n.childCount&&r<=o;){let i=n.child(s++),l=r;if(r+=i.nodeSize,!i.isText)continue;let a=i.text;for(;s<n.childCount;){let c=n.child(s++);if(r+=c.nodeSize,!c.isText)break;a+=c.text}if(r>=t){if(r>=o&&a.slice(o-e.length-l,o-l)==e)return o-e.length;let c=l<o?a.lastIndexOf(e,o-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==o&&a.length>=o+e.length-l&&a.slice(o-l,o-l+e.length)==e)return o}}return-1}function ar(n,e,t,o,s){let r=[];for(let i=0,l=0;i<n.length;i++){let a=n[i],c=l,d=l+=a.size;c>=t||d<=e?r.push(a):(c<e&&r.push(a.slice(0,e-c,o)),s&&(r.push(s),s=void 0),d>t&&r.push(a.slice(t-c,a.size,o)))}return r}function Fr(n,e=null){let t=n.domSelectionRange(),o=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),r=s&&s.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=o.resolve(i),a,c;if(es(t)){for(a=i;s&&!s.node;)s=s.parent;let u=s.node;if(s&&u.isAtom&&R.isSelectable(u)&&s.parent&&!(u.isInline&&cm(t.focusNode,t.focusOffset,s.dom))){let p=s.posBefore;c=new R(i==p?l:o.resolve(p))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=i,p=i;for(let h=0;h<t.rangeCount;h++){let f=t.getRangeAt(h);u=Math.min(u,n.docView.posFromDOM(f.startContainer,f.startOffset,1)),p=Math.max(p,n.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(u<0)return null;[a,i]=p==n.state.selection.anchor?[p,u]:[u,p],l=o.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=o.resolve(a);if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!r?1:-1;c=_r(n,d,l,u)}return c}function Jc(n){return n.editable?n.hasFocus():Zc(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function We(n,e=!1){let t=n.state.selection;if(Yc(n,t),!!Jc(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&re){let o=n.domSelectionRange(),s=n.domObserver.currentSelection;if(o.anchorNode&&s.anchorNode&&It(o.anchorNode,o.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Bm(n);else{let{anchor:o,head:s}=t,r,i;pl&&!(t instanceof z)&&(t.$from.parent.inlineContent||(r=hl(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=hl(n,t.to))),n.docView.setSelection(o,s,n,e),pl&&(r&&fl(r),i&&fl(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&$m(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const pl=ae||re&&Vc<63;function hl(n,e){let{node:t,offset:o}=n.docView.domFromPos(e,0),s=o<t.childNodes.length?t.childNodes[o]:null,r=o?t.childNodes[o-1]:null;if(ae&&s&&s.contentEditable=="false")return Es(s);if((!s||s.contentEditable=="false")&&(!r||r.contentEditable=="false")){if(s)return Es(s);if(r)return Es(r)}}function Es(n){return n.contentEditable="true",ae&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function fl(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function $m(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(()=>{(!Jc(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Bm(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let o=n.cursorWrapper.dom,s=o.nodeName=="IMG";s?t.setStart(o.parentNode,ee(o)+1):t.setStart(o,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!s&&!n.state.selection.visible&&he&&rt<=11&&(o.disabled=!0,o.disabled=!1)}function Yc(n,e){if(e instanceof R){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ml(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ml(n)}function ml(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function _r(n,e,t,o){return n.someProp("createSelectionBetween",s=>s(n,e,t))||z.between(e,t,o)}function gl(n){return n.editable&&!n.hasFocus()?!1:Zc(n)}function Zc(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 Hm(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return It(e.node,e.offset,t.anchorNode,t.anchorOffset)}function cr(n,e){let{$anchor:t,$head:o}=n.selection,s=e>0?t.max(o):t.min(o),r=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return r&&L.findFrom(r,e)}function Ye(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function yl(n,e,t){let o=n.state.selection;if(o instanceof z)if(t.indexOf("s")>-1){let{$head:s}=o,r=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let i=n.state.doc.resolve(s.pos+r.nodeSize*(e<0?-1:1));return Ye(n,new z(o.$anchor,i))}else if(o.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=cr(n.state,e);return s&&s instanceof R?Ye(n,s):!1}else if(!(xe&&t.indexOf("m")>-1)){let s=o.$head,r=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,i;if(!r||r.isText)return!1;let l=e<0?s.pos-r.nodeSize:s.pos;return r.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?R.isSelectable(r)?Ye(n,new R(e<0?n.state.doc.resolve(s.pos-r.nodeSize):s)):Jn?Ye(n,new z(n.state.doc.resolve(e<0?l:l+r.nodeSize))):!1:!1}}else return!1;else{if(o instanceof R&&o.node.isInline)return Ye(n,new z(e>0?o.$to:o.$from));{let s=cr(n.state,e);return s?Ye(n,s):!1}}}function Ho(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Nn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function _t(n,e){return e<0?Fm(n):_m(n)}function Fm(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s,r,i=!1;for(Ee&&t.nodeType==1&&o<Ho(t)&&Nn(t.childNodes[o],-1)&&(i=!0);;)if(o>0){if(t.nodeType!=1)break;{let l=t.childNodes[o-1];if(Nn(l,-1))s=t,r=--o;else if(l.nodeType==3)t=l,o=t.nodeValue.length;else break}}else{if(Xc(t))break;{let l=t.previousSibling;for(;l&&Nn(l,-1);)s=t.parentNode,r=ee(l),l=l.previousSibling;if(l)t=l,o=Ho(t);else{if(t=t.parentNode,t==n.dom)break;o=0}}}i?dr(n,t,o):s&&dr(n,s,r)}function _m(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s=Ho(t),r,i;for(;;)if(o<s){if(t.nodeType!=1)break;let l=t.childNodes[o];if(Nn(l,1))r=t,i=++o;else break}else{if(Xc(t))break;{let l=t.nextSibling;for(;l&&Nn(l,1);)r=l.parentNode,i=ee(l)+1,l=l.nextSibling;if(l)t=l,o=0,s=Ho(t);else{if(t=t.parentNode,t==n.dom)break;o=s=0}}}r&&dr(n,r,i)}function Xc(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Gm(n,e){for(;n&&e==n.childNodes.length&&!Un(n);)e=ee(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function Wm(n,e){for(;n&&!e&&!Un(n);)e=ee(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function dr(n,e,t){if(e.nodeType!=3){let r,i;(i=Gm(e,t))?(e=i,t=0):(r=Wm(e,t))&&(e=r,t=r.nodeValue.length)}let o=n.domSelection();if(!o)return;if(es(o)){let r=document.createRange();r.setEnd(e,t),r.setStart(e,t),o.removeAllRanges(),o.addRange(r)}else o.extend&&o.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&We(n)},50)}function bl(n,e){let t=n.state.doc.resolve(e);if(!(re||pm)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let r=n.coordsAtPos(e-1),i=(r.top+r.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(r.left-s.left)>1)return r.left<s.left?"ltr":"rtl"}if(e<t.end()){let r=n.coordsAtPos(e+1),i=(r.top+r.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(r.left-s.left)>1)return r.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function vl(n,e,t){let o=n.state.selection;if(o instanceof z&&!o.empty||t.indexOf("s")>-1||xe&&t.indexOf("m")>-1)return!1;let{$from:s,$to:r}=o;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=cr(n.state,e);if(i&&i instanceof R)return Ye(n,i)}if(!s.parent.inlineContent){let i=e<0?s:r,l=o instanceof ye?L.near(i,e):L.findFrom(i,e);return l?Ye(n,l):!1}return!1}function xl(n,e){if(!(n.state.selection instanceof z))return!0;let{$head:t,$anchor:o,empty:s}=n.state.selection;if(!t.sameParent(o))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let r=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(r&&!r.isText){let i=n.state.tr;return e<0?i.delete(t.pos-r.nodeSize,t.pos):i.delete(t.pos,t.pos+r.nodeSize),n.dispatch(i),!0}return!1}function Sl(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function jm(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;Sl(n,o,"true"),setTimeout(()=>Sl(n,o,"false"),20)}return!1}function qm(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Km(n,e){let t=e.keyCode,o=qm(e);if(t==8||xe&&t==72&&o=="c")return xl(n,-1)||_t(n,-1);if(t==46&&!e.shiftKey||xe&&t==68&&o=="c")return xl(n,1)||_t(n,1);if(t==13||t==27)return!0;if(t==37||xe&&t==66&&o=="c"){let s=t==37?bl(n,n.state.selection.from)=="ltr"?-1:1:-1;return yl(n,s,o)||_t(n,s)}else if(t==39||xe&&t==70&&o=="c"){let s=t==39?bl(n,n.state.selection.from)=="ltr"?1:-1:1;return yl(n,s,o)||_t(n,s)}else{if(t==38||xe&&t==80&&o=="c")return vl(n,-1,o)||_t(n,-1);if(t==40||xe&&t==78&&o=="c")return jm(n)||vl(n,1,o)||_t(n,1);if(o==(xe?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Qc(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:o,openStart:s,openEnd:r}=e;for(;s>1&&r>1&&o.childCount==1&&o.firstChild.childCount==1;){s--,r--;let h=o.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),o=h.content}let i=n.someProp("clipboardSerializer")||zt.fromSchema(n.state.schema),l=rd(),a=l.createElement("div");a.appendChild(i.serializeFragment(o,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=sd[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let f=l.createElement(d[h]);for(;a.firstChild;)f.appendChild(a.firstChild);a.appendChild(f),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${r}${u?` -${u}`:""} ${JSON.stringify(t)}`);let p=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
|
|
300
|
-
|
|
301
|
-
`);return{dom:a,text:p,slice:e}}function
|
|
302
|
-
`))),0,0):A.empty;let u=n.someProp("clipboardTextParser",p=>p(e,s,o,n));if(u)l=u;else{let p=s.marks(),{schema:h}=n.state,f=zt.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=i.appendChild(document.createElement("p"));m&&g.appendChild(f.serializeNode(h.text(m,p)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),i=Zm(t),Jn&&Xm(i);let c=i&&i.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let p=i.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;i=p}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||sn.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!Um.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Qm(wl(l,+d[1],+d[2]),d[4]);else if(l=A.maxOpen(Jm(l.content,s),!0),l.openStart||l.openEnd){let u=0,p=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;p<l.openEnd&&!h.type.spec.isolating;p++,h=h.lastChild);l=wl(l,u,p)}return n.someProp("transformPasted",u=>{l=u(l,n)}),l}const Um=/^(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 Jm(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),r,i=[];if(n.forEach(l=>{if(!i)return;let a=s.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&r.length&&nd(a,r,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=od(i[i.length-1],r.length));let d=td(l,a);i.push(d),s=s.matchType(d.type),r=a}}),i)return T.from(i)}return n}function td(n,e,t=0){for(let o=e.length-1;o>=t;o--)n=e[o].create(null,T.from(n));return n}function nd(n,e,t,o,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let r=nd(n,e,t,o.lastChild,s+1);if(r)return o.copy(o.content.replaceChild(o.childCount-1,r));if(o.contentMatchAt(o.childCount).matchType(s==n.length-1?t.type:n[s+1]))return o.copy(o.content.append(T.from(td(t,n,s+1))))}}function od(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,od(n.lastChild,e-1)),o=n.contentMatchAt(n.childCount).fillBefore(T.empty,!0);return n.copy(t.append(o))}function ur(n,e,t,o,s,r){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(r=0),s<o-1&&(l=ur(l,e,t,o,s+1,r)),s>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,r<=s).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(T.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function wl(n,e,t){return e<n.openStart&&(n=new A(ur(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new A(ur(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const sd={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 Cl=null;function rd(){return Cl||(Cl=document.implementation.createHTMLDocument("title"))}let As=null;function Ym(n){let e=window.trustedTypes;return e?(As||(As=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),As.createHTML(n)):n}function Zm(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=rd().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(n),s;if((s=o&&sd[o[1].toLowerCase()])&&(n=s.map(r=>"<"+r+">").join("")+n+s.map(r=>"</"+r+">").reverse().join("")),t.innerHTML=Ym(n),s)for(let r=0;r<s.length;r++)t=t.querySelector(s[r])||t;return t}function Xm(n){let e=n.querySelectorAll(re?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let o=e[t];o.childNodes.length==1&&o.textContent==" "&&o.parentNode&&o.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),o)}}function Qm(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,o;try{o=JSON.parse(e)}catch{return n}let{content:s,openStart:r,openEnd:i}=n;for(let l=o.length-2;l>=0;l-=2){let a=t.nodes[o[l]];if(!a||a.hasRequiredAttrs())break;s=T.from(a.create(o[l+1],s)),r++,i++}return new A(s,r,i)}const ce={},de={},eg={touchstart:!0,touchmove:!0};class tg{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 ng(n){for(let e in ce){let t=ce[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=o=>{sg(n,o)&&!Gr(n,o)&&(n.editable||!(o.type in de))&&t(n,o)},eg[e]?{passive:!0}:void 0)}ae&&n.dom.addEventListener("input",()=>null),pr(n)}function ot(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function og(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 pr(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=o=>Gr(n,o))})}function Gr(n,e){return n.someProp("handleDOMEvents",t=>{let o=t[e.type];return o?o(n,e)||e.defaultPrevented:!1})}function sg(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 rg(n,e){!Gr(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,!ld(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ke&&re&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),cn&&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,yt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",o=>o(n,t))||Km(n,t)?t.preventDefault():ot(n,"key")};de.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};de.keypress=(n,e)=>{let t=e;if(ld(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||xe&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let o=n.state.selection;if(!(o instanceof z)||!o.$from.sameParent(o.$to)){let s=String.fromCharCode(t.charCode);!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",r=>r(n,o.$from.pos,o.$to.pos,s))&&n.dispatch(n.state.tr.insertText(s).scrollIntoView()),t.preventDefault()}};function ns(n){return{left:n.clientX,top:n.clientY}}function ig(n,e){let t=e.x-n.clientX,o=e.y-n.clientY;return t*t+o*o<100}function Wr(n,e,t,o,s){if(o==-1)return!1;let r=n.state.doc.resolve(o);for(let i=r.depth+1;i>0;i--)if(n.someProp(e,l=>i>r.depth?l(n,t,r.nodeAfter,r.before(i),s,!0):l(n,t,r.node(i),r.before(i),s,!1)))return!0;return!1}function tn(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 lg(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),o=t.nodeAfter;return o&&o.isAtom&&R.isSelectable(o)?(tn(n,new R(t)),!0):!1}function ag(n,e){if(e==-1)return!1;let t=n.state.selection,o,s;t instanceof R&&(o=t.node);let r=n.state.doc.resolve(e);for(let i=r.depth+1;i>0;i--){let l=i>r.depth?r.nodeAfter:r.node(i);if(R.isSelectable(l)){o&&t.$from.depth>0&&i>=t.$from.depth&&r.before(t.$from.depth+1)==t.$from.pos?s=r.before(t.$from.depth):s=r.before(i);break}}return s!=null?(tn(n,R.create(n.state.doc,s)),!0):!1}function cg(n,e,t,o,s){return Wr(n,"handleClickOn",e,t,o)||n.someProp("handleClick",r=>r(n,e,o))||(s?ag(n,t):lg(n,t))}function dg(n,e,t,o){return Wr(n,"handleDoubleClickOn",e,t,o)||n.someProp("handleDoubleClick",s=>s(n,e,o))}function ug(n,e,t,o){return Wr(n,"handleTripleClickOn",e,t,o)||n.someProp("handleTripleClick",s=>s(n,e,o))||pg(n,t,o)}function pg(n,e,t){if(t.button!=0)return!1;let o=n.state.doc;if(e==-1)return o.inlineContent?(tn(n,z.create(o,0,o.content.size)),!0):!1;let s=o.resolve(e);for(let r=s.depth+1;r>0;r--){let i=r>s.depth?s.nodeAfter:s.node(r),l=s.before(r);if(i.inlineContent)tn(n,z.create(o,l+1,l+1+i.content.size));else if(R.isSelectable(i))tn(n,R.create(o,l));else continue;return!0}}function jr(n){return Fo(n)}const id=xe?"metaKey":"ctrlKey";ce.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let o=jr(n),s=Date.now(),r="singleClick";s-n.input.lastClick.time<500&&ig(t,n.input.lastClick)&&!t[id]&&(n.input.lastClick.type=="singleClick"?r="doubleClick":n.input.lastClick.type=="doubleClick"&&(r="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:r};let i=n.posAtCoords(ns(t));i&&(r=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new hg(n,i,t,!!o)):(r=="doubleClick"?dg:ug)(n,i.pos,i.inside,t)?t.preventDefault():ot(n,"pointer"))};class hg{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[id],this.allowDefault=o.shiftKey;let r,i;if(t.inside>-1)r=e.state.doc.nodeAt(t.inside),i=t.inside;else{let d=e.state.doc.resolve(t.pos);r=d.parent,i=d.depth?d.before():0}const l=s?null:o.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(o.button==0&&r.type.spec.draggable&&r.type.spec.selectable!==!1||c instanceof R&&c.from<=i&&c.to>i)&&(this.mightDrag={node:r,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ee&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),ot(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>We(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(ns(e))),this.updateAllowDefault(e),this.allowDefault||!t?ot(this.view,"pointer"):cg(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ae&&this.mightDrag&&!this.mightDrag.node.isAtom||re&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(tn(this.view,L.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):ot(this.view,"pointer")}move(e){this.updateAllowDefault(e),ot(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}ce.touchstart=n=>{n.input.lastTouch=Date.now(),jr(n),ot(n,"pointer")};ce.touchmove=n=>{n.input.lastTouch=Date.now(),ot(n,"pointer")};ce.contextmenu=n=>jr(n);function ld(n,e){return n.composing?!0:ae&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const fg=ke?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 z&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(o=>o.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Fo(n,!0),n.markCursor=null;else if(Fo(n,!e.selection.empty),Ee&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let o=n.domSelectionRange();for(let s=o.focusNode,r=o.focusOffset;s&&s.nodeType==1&&r!=0;){let i=r<0?s.lastChild:s.childNodes[r-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else s=i,r=-1}}n.input.composing=!0}ad(n,fg)};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++,ad(n,20))};function ad(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Fo(n),e))}function cd(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=gg());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function mg(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=lm(e.focusNode,e.focusOffset),o=am(e.focusNode,e.focusOffset);if(t&&o&&t!=o){let s=o.pmViewDesc,r=n.domObserver.lastChangedTextNode;if(t==r||o==r)return r;if(!s||!s.isText(o.nodeValue))return o;if(n.input.compositionNode==o){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return o}}return t||o}function gg(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Fo(n,e=!1){if(!(ke&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),cd(n),e||n.docView&&n.docView.dirty){let t=Fr(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 yg(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let o=getSelection(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),o.removeAllRanges(),o.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const _n=he&&rt<15||cn&&hm<604;ce.copy=de.cut=(n,e)=>{let t=e,o=n.state.selection,s=t.type=="cut";if(o.empty)return;let r=_n?null:t.clipboardData,i=o.content(),{dom:l,text:a}=Qc(n,i);r?(t.preventDefault(),r.clearData(),r.setData("text/html",l.innerHTML),r.setData("text/plain",a)):yg(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function bg(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function vg(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?Gn(n,o.value,null,s,e):Gn(n,o.textContent,o.innerHTML,s,e)},50)}function Gn(n,e,t,o,s){let r=ed(n,e,t,o,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,r||A.empty)))return!0;if(!r)return!1;let i=bg(r),l=i?n.state.tr.replaceSelectionWith(i,o):n.state.tr.replaceSelection(r);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function dd(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&&!ke)return;let o=_n?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;o&&Gn(n,dd(o),o.getData("text/html"),s,t)?t.preventDefault():vg(n,t)};class ud{constructor(e,t,o){this.slice=e,this.move=t,this.node=o}}const pd=xe?"altKey":"ctrlKey";ce.dragstart=(n,e)=>{let t=e,o=n.input.mouseDown;if(o&&o.done(),!t.dataTransfer)return;let s=n.state.selection,r=s.empty?null:n.posAtCoords(ns(t)),i;if(!(r&&r.pos>=s.from&&r.pos<=(s instanceof R?s.to-1:s.to))){if(o&&o.mightDrag)i=R.create(n.state.doc,o.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(i=R.create(n.state.doc,u.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:d}=Qc(n,l);(!t.dataTransfer.files.length||!re||Vc>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(_n?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",_n||t.dataTransfer.setData("text/plain",c),n.dragging=new ud(d,!t[pd],i)};ce.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};de.dragover=de.dragenter=(n,e)=>e.preventDefault();de.drop=(n,e)=>{let t=e,o=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let s=n.posAtCoords(ns(t));if(!s)return;let r=n.state.doc.resolve(s.pos),i=o&&o.slice;i?n.someProp("transformPasted",f=>{i=f(i,n)}):i=ed(n,dd(t.dataTransfer),_n?null:t.dataTransfer.getData("text/html"),!1,r);let l=!!(o&&!t[pd]);if(n.someProp("handleDrop",f=>f(n,t,i||A.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?hf(n.state.doc,r.pos,i):r.pos;a==null&&(a=r.pos);let c=n.state.tr;if(l){let{node:f}=o;f?f.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,p=c.doc;if(u?c.replaceRangeWith(d,d,i.content.firstChild):c.replaceRange(d,d,i),c.doc.eq(p))return;let h=c.doc.resolve(d);if(u&&R.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new R(h));else{let f=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,v,C)=>f=C),c.setSelection(_r(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())&&We(n)},20))};ce.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};ce.beforeinput=(n,e)=>{if(re&&ke&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:o}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=o||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",r=>r(n,yt(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 Wn(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 _o{constructor(e,t){this.toDOM=e,this.spec=t||Et,this.side=this.spec.side||0}map(e,t,o,s){let{pos:r,deleted:i}=e.mapResult(t.from+s,this.side<0?-1:1);return i?null:new pe(r-o,r-o,this)}valid(){return!0}eq(e){return this==e||e instanceof _o&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Wn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class lt{constructor(e,t){this.attrs=e,this.spec=t||Et}map(e,t,o,s){let r=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-o,i=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-o;return r>=i?null:new pe(r,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof lt&&Wn(this.attrs,e.attrs)&&Wn(this.spec,e.spec)}static is(e){return e.type instanceof lt}destroy(){}}class qr{constructor(e,t){this.attrs=e,this.spec=t||Et}map(e,t,o,s){let r=e.mapResult(t.from+s,1);if(r.deleted)return null;let i=e.mapResult(t.to+s,-1);return i.deleted||i.pos<=r.pos?null:new pe(r.pos-o,i.pos-o,this)}valid(e,t){let{index:o,offset:s}=e.content.findIndex(t.from),r;return s==t.from&&!(r=e.child(o)).isText&&s+r.nodeSize==t.to}eq(e){return this==e||e instanceof qr&&Wn(this.attrs,e.attrs)&&Wn(this.spec,e.spec)}destroy(){}}class pe{constructor(e,t,o){this.from=e,this.to=t,this.type=o}copy(e,t){return new pe(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 pe(e,e,new _o(t,o))}static inline(e,t,o,s){return new pe(e,t,new lt(o,s))}static node(e,t,o,s){return new pe(e,t,new qr(o,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof lt}get widget(){return this.type instanceof _o}}const jt=[],Et={};class _{constructor(e,t){this.local=e.length?e:jt,this.children=t.length?t:jt}static create(e,t){return t.length?Go(t,e,0,Et):oe}find(e,t,o){let s=[];return this.findInner(e??0,t??1e9,s,0,o),s}findInner(e,t,o,s,r){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!r||r(l.spec))&&o.push(l.copy(l.from+s,l.to+s))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,o,s+l,r)}}map(e,t,o){return this==oe||e.maps.length==0?this:this.mapInner(e,t,0,0,o||Et)}mapInner(e,t,o,s,r){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,o,s);a&&a.type.valid(t,a)?(i||(i=[])).push(a):r.onRemove&&r.onRemove(this.local[l].spec)}return this.children.length?xg(this.children,i||[],e,t,o,s,r):i?new _(i.sort(At),jt):oe}add(e,t){return t.length?this==oe?_.create(e,t):this.addInner(e,t,0):this}addInner(e,t,o){let s,r=0;e.forEach((l,a)=>{let c=a+o,d;if(d=fd(t,l,c)){for(s||(s=this.children.slice());r<s.length&&s[r]<a;)r+=3;s[r]==a?s[r+2]=s[r+2].addInner(l,d,c+1):s.splice(r,0,a,a+l.nodeSize,Go(d,l,c+1,Et)),r+=3}});let i=hd(r?md(t):t,-o);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new _(i.length?this.local.concat(i).sort(At):this.local,s||this.children)}remove(e){return e.length==0||this==oe?this:this.removeInner(e,0)}removeInner(e,t){let o=this.children,s=this.local;for(let r=0;r<o.length;r+=3){let i,l=o[r]+t,a=o[r+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(i||(i=[])).push(u));if(!i)continue;o==this.children&&(o=this.children.slice());let c=o[r+2].removeInner(i,l+1);c!=oe?o[r+2]=c:(o.splice(r,3),r-=3)}if(s.length){for(let r=0,i;r<e.length;r++)if(i=e[r])for(let l=0;l<s.length;l++)s[l].eq(i,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return o==this.children&&s==this.local?this:s.length||o.length?new _(s,o):oe}forChild(e,t){if(this==oe)return this;if(t.isLeaf)return _.empty;let o,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(o=this.children[l+2]);break}let r=e+1,i=r+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>r&&a.type instanceof lt){let c=Math.max(r,a.from)-r,d=Math.min(i,a.to)-r;c<d&&(s||(s=[])).push(a.copy(c,d))}}if(s){let l=new _(s.sort(At),jt);return o?new Xe([l,o]):l}return o||oe}eq(e){if(this==e)return!0;if(!(e instanceof _)||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 Kr(this.localsInner(e))}localsInner(e){if(this==oe)return jt;if(e.inlineContent||!this.local.some(lt.is))return this.local;let t=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof lt||t.push(this.local[o]);return t}forEachSet(e){e(this)}}_.empty=new _([],[]);_.removeOverlap=Kr;const oe=_.empty;class Xe{constructor(e){this.members=e}map(e,t){const o=this.members.map(s=>s.map(e,t,Et));return Xe.from(o)}forChild(e,t){if(t.isLeaf)return _.empty;let o=[];for(let s=0;s<this.members.length;s++){let r=this.members[s].forChild(e,t);r!=oe&&(r instanceof Xe?o=o.concat(r.members):o.push(r))}return Xe.from(o)}eq(e){if(!(e instanceof Xe)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,o=!0;for(let s=0;s<this.members.length;s++){let r=this.members[s].localsInner(e);if(r.length)if(!t)t=r;else{o&&(t=t.slice(),o=!1);for(let i=0;i<r.length;i++)t.push(r[i])}}return t?Kr(o?t:t.sort(At)):jt}static from(e){switch(e.length){case 0:return oe;case 1:return e[0];default:return new Xe(e.every(t=>t instanceof _)?e:e.reduce((t,o)=>t.concat(o instanceof _?o:o.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function xg(n,e,t,o,s,r,i){let l=n.slice();for(let c=0,d=r;c<t.maps.length;c++){let u=0;t.maps[c].forEach((p,h,f,m)=>{let g=m-f-(h-p);for(let v=0;v<l.length;v+=3){let C=l[v+1];if(C<0||p>C+d-u)continue;let y=l[v]+d-u;h>=y?l[v+1]=p<=y?-2:-1:p>=d&&g&&(l[v]+=g,l[v+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(n[c]+r),u=d-s;if(u<0||u>=o.content.size){a=!0;continue}let p=t.map(n[c+1]+r,-1),h=p-s,{index:f,offset:m}=o.content.findIndex(u),g=o.maybeChild(f);if(g&&m==u&&m+g.nodeSize==h){let v=l[c+2].mapInner(t,g,d+1,n[c]+r+1,i);v!=oe?(l[c]=u,l[c+1]=h,l[c+2]=v):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Sg(l,n,e,t,s,r,i),d=Go(c,o,0,i);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,p=0;u<d.children.length;u+=3){let h=d.children[u];for(;p<l.length&&l[p]<h;)p+=3;l.splice(p,0,d.children[u],d.children[u+1],d.children[u+2])}}return new _(e.sort(At),l)}function hd(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 pe(s.from+e,s.to+e,s.type))}return t}function Sg(n,e,t,o,s,r,i){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(o,s,c);u?t.push(u):i.onRemove&&i.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+r+1);return t}function fd(n,e,t){if(e.isLeaf)return null;let o=t+e.nodeSize,s=null;for(let r=0,i;r<n.length;r++)(i=n[r])&&i.from>t&&i.to<o&&((s||(s=[])).push(i),n[r]=null);return s}function md(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Go(n,e,t,o){let s=[],r=!1;e.forEach((l,a)=>{let c=fd(n,l,a+t);if(c){r=!0;let d=Go(c,l,t+a+1,o);d!=oe&&s.push(a,a+l.nodeSize,d)}});let i=hd(r?md(n):n,-t).sort(At);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(o.onRemove&&o.onRemove(i[l].spec),i.splice(l--,1));return i.length||s.length?new _(i,s):oe}function At(n,e){return n.from-e.from||n.to-e.to}function Kr(n){let e=n;for(let t=0;t<e.length-1;t++){let o=e[t];if(o.from!=o.to)for(let s=t+1;s<e.length;s++){let r=e[s];if(r.from==o.from){r.to!=o.to&&(e==n&&(e=n.slice()),e[s]=r.copy(r.from,o.to),kl(e,s+1,r.copy(o.to,r.to)));continue}else{r.from<o.to&&(e==n&&(e=n.slice()),e[t]=o.copy(o.from,r.from),kl(e,s,o.copy(r.from,o.to)));break}}}return e}function kl(n,e,t){for(;e<n.length&&At(t,n[e])>0;)e++;n.splice(e,0,t)}function Ps(n){let e=[];return n.someProp("decorations",t=>{let o=t(n.state);o&&o!=oe&&e.push(o)}),n.cursorWrapper&&e.push(_.create(n.state.doc,[n.cursorWrapper.deco])),Xe.from(e)}const wg={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Cg=he&&rt<=11;class kg{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 Tg{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new kg,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(o=>{for(let s=0;s<o.length;s++)this.queue.push(o[s]);he&&rt<=11&&o.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),Cg&&(this.onCharData=o=>{this.queue.push({target:o.target,type:"characterData",oldValue:o.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,wg)),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(gl(this.view)){if(this.suppressingSelectionUpdates)return We(this.view);if(he&&rt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&It(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,o;for(let r=e.focusNode;r;r=Fn(r))t.add(r);for(let r=e.anchorNode;r;r=Fn(r))if(t.has(r)){o=r;break}let s=o&&this.view.docView.nearestDesc(o);if(s&&s.ignoreMutation({type:"selection",target:o.nodeType==3?o.parentNode:o}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let o=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(o)&&gl(e)&&!this.ignoreSelectionChange(o),r=-1,i=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(r=r<0?u.from:Math.min(u.from,r),i=i<0?u.to:Math.max(u.to,i),u.typeOver&&(l=!0))}if(Ee&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,p]=d;u.parentNode&&u.parentNode.parentNode==p.parentNode?p.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let p of d){let h=p.parentNode;h&&h.nodeName=="LI"&&(!u||Ag(e,u)!=h)&&p.remove()}}}let c=null;r<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&es(o)&&(c=Fr(e))&&c.eq(L.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,We(e),this.currentSelection.set(o),e.scrollToSelection()):(r>-1||s)&&(r>-1&&(e.docView.markDirty(r,i),Mg(e)),this.handleDOMChange(r,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(o)||We(e),this.currentSelection.set(o))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let o=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(o==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!o||o.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(e.target))return{from:o.posBefore,to:o.posAfter};let s=e.previousSibling,r=e.nextSibling;if(he&&rt<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:p}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(r=p)}let i=s&&s.parentNode==e.target?ee(s)+1:0,l=o.localPosFromDOM(e.target,i,-1),a=r&&r.parentNode==e.target?ee(r):e.target.childNodes.length,c=o.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}:(this.lastChangedTextNode=e.target,{from:o.posAtStart,to:o.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Tl=new WeakMap,Ml=!1;function Mg(n){if(!Tl.has(n)&&(Tl.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ee,Ml)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."),Ml=!0}}function El(n,e){let t=e.startContainer,o=e.startOffset,s=e.endContainer,r=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return It(i.node,i.offset,s,r)&&([t,o,s,r]=[s,r,t,o]),{anchorNode:t,anchorOffset:o,focusNode:s,focusOffset:r}}function Eg(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return El(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?El(n,t):null}function Ag(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 Pg(n,e,t){let{node:o,fromOffset:s,toOffset:r,from:i,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],es(a)||c.push({node:a.focusNode,offset:a.focusOffset})),re&&n.input.lastKeyCode===8)for(let g=r;g>s;g--){let v=o.childNodes[g-1],C=v.pmViewDesc;if(v.nodeName=="BR"&&!C){r=g;break}if(!C||C.size)break}let u=n.state.doc,p=n.someProp("domParser")||sn.fromSchema(n.state.schema),h=u.resolve(i),f=null,m=p.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:r,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Ng,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,v=c[1]&&c[1].pos;v==null&&(v=g),f={anchor:g+i,head:v+i}}return{doc:m,sel:f,from:i,to:l}}function Ng(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 Og=/^(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 Ig(n,e,t,o,s){let r=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let k=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,E=Fr(n,k);if(E&&!n.state.selection.eq(E)){if(re&&ke&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",O=>O(n,yt(13,"Enter"))))return;let P=n.state.tr.setSelection(E);k=="pointer"?P.setMeta("pointer",!0):k=="key"&&P.scrollIntoView(),r&&P.setMeta("composition",r),n.dispatch(P)}return}let i=n.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Pg(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),p,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(p=n.state.selection.to,h="end"):(p=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let f=Lg(u.content,c.doc.content,c.from,p,h);if(f&&n.input.domChangeCount++,(cn&&n.input.lastIOSEnter>Date.now()-225||ke)&&s.some(k=>k.nodeType==1&&!Og.test(k.nodeName))&&(!f||f.endA>=f.endB)&&n.someProp("handleKeyDown",k=>k(n,yt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!f)if(o&&a instanceof z&&!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 k=Al(n,n.state.doc,c.sel);if(k&&!k.eq(n.state.selection)){let E=n.state.tr.setSelection(k);r&&E.setMeta("composition",r),n.dispatch(E)}}return}n.state.selection.from<n.state.selection.to&&f.start==f.endB&&n.state.selection instanceof z&&(f.start>n.state.selection.from&&f.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?f.start=n.state.selection.from:f.endA<n.state.selection.to&&f.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(f.endB+=n.state.selection.to-f.endA,f.endA=n.state.selection.to)),he&&rt<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>c.from&&c.doc.textBetween(f.start-c.from-1,f.start-c.from+1)==" "&&(f.start--,f.endA--,f.endB--);let m=c.doc.resolveNoCache(f.start-c.from),g=c.doc.resolveNoCache(f.endB-c.from),v=d.resolve(f.start),C=m.sameParent(g)&&m.parent.inlineContent&&v.end()>=f.endA,y;if((cn&&n.input.lastIOSEnter>Date.now()-225&&(!C||s.some(k=>k.nodeName=="DIV"||k.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",k=>k(n,yt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>f.start&&Dg(d,f.start,f.endA,m,g)&&n.someProp("handleKeyDown",k=>k(n,yt(8,"Backspace")))){ke&&re&&n.domObserver.suppressSelectionUpdates();return}re&&ke&&f.endB==f.start&&(n.input.lastAndroidDelete=Date.now()),ke&&!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(k){return k(n,yt(13,"Enter"))})},20));let b=f.start,x=f.endA,S,w,M;if(C){if(m.pos==g.pos)he&&rt<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>We(n),20)),S=n.state.tr.delete(b,x),w=d.resolve(f.start).marksAcross(d.resolve(f.endA));else if(f.endA==f.endB&&(M=Rg(m.parent.content.cut(m.parentOffset,g.parentOffset),v.parent.content.cut(v.parentOffset,f.endA-v.start()))))S=n.state.tr,M.type=="add"?S.addMark(b,x,M.mark):S.removeMark(b,x,M.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let k=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",E=>E(n,b,x,k)))return;S=n.state.tr.insertText(k,b,x)}}if(S||(S=n.state.tr.replace(b,x,c.doc.slice(f.start-c.from,f.endB-c.from))),c.sel){let k=Al(n,S.doc,c.sel);k&&!(re&&ke&&n.composing&&k.empty&&(f.start!=f.endB||n.input.lastAndroidDelete<Date.now()-100)&&(k.head==b||k.head==S.mapping.map(x)-1)||he&&k.empty&&k.head==b)&&S.setSelection(k)}w&&S.ensureMarks(w),r&&S.setMeta("composition",r),n.dispatch(S.scrollIntoView())}function Al(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:_r(n,e.resolve(t.anchor),e.resolve(t.head))}function Rg(n,e){let t=n.firstChild.marks,o=e.firstChild.marks,s=t,r=o,i,l,a;for(let d=0;d<o.length;d++)s=o[d].removeFromSet(s);for(let d=0;d<t.length;d++)r=t[d].removeFromSet(r);if(s.length==1&&r.length==0)l=s[0],i="add",a=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&r.length==1)l=r[0],i="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(T.from(c).eq(n))return{mark:l,type:i}}function Dg(n,e,t,o,s){if(t-e<=s.pos-o.pos||Ns(o,!0,!1)<s.pos)return!1;let r=n.resolve(e);if(!o.parent.isTextblock){let l=r.nodeAfter;return l!=null&&t==e+l.nodeSize}if(r.parentOffset<r.parent.content.size||!r.parent.isTextblock)return!1;let i=n.resolve(Ns(r,!0,!0));return!i.parent.isTextblock||i.pos>t||Ns(i,!0,!1)<t?!1:o.parent.content.cut(o.parentOffset).eq(i.parent.content)}function Ns(n,e,t){let o=n.depth,s=e?n.end():n.pos;for(;o>0&&(e||n.indexAfter(o)==n.node(o).childCount);)o--,s++,e=!1;if(t){let r=n.node(o).maybeChild(n.indexAfter(o));for(;r&&!r.isLeaf;)r=r.firstChild,s++}return s}function Lg(n,e,t,o,s){let r=n.findDiffStart(e,t);if(r==null)return null;let{a:i,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,r-Math.min(i,l));o-=i+a-r}if(i<r&&n.size<e.size){let a=o<=r&&o>=i?r-o:0;r-=a,r&&r<e.size&&Pl(e.textBetween(r-1,r+1))&&(r+=a?1:-1),l=r+(l-i),i=r}else if(l<r){let a=o<=r&&o>=l?r-o:0;r-=a,r&&r<n.size&&Pl(n.textBetween(r-1,r+1))&&(r+=a?1:-1),i=r+(i-l),l=r}return{start:r,endA:i,endB:l}}function Pl(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 zg{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 tg,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Dl),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=Il(this),Ol(this),this.nodeViews=Rl(this),this.docView=dl(this.state.doc,Nl(this),Ps(this),this.dom,this),this.domObserver=new Tg(this,(o,s,r,i)=>Ig(this,o,s,r,i)),this.domObserver.start(),ng(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&&pr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Dl),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let o in this._props)t[o]=this._props[o];t.state=this.state;for(let o in e)t[o]=e[o];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var o;let s=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(cd(this),i=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Rl(this);$g(h,this.nodeViews)&&(this.nodeViews=h,r=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&pr(this),this.editable=Il(this),Ol(this);let a=Ps(this),c=Nl(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=r||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(s.selection))&&(i=!0);let p=d=="preserve"&&i&&this.dom.style.overflowAnchor==null&&gm(this);if(i){this.domObserver.stop();let h=u&&(he||re)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&Vg(s.selection,e.selection);if(u){let f=re?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=mg(this)),(r||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=dl(e.doc,c,a,this.dom,this)),f&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Hm(this))?We(this,h):(Yc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((o=this.dragging)===null||o===void 0)&&o.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():p&&ym(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof R){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&sl(this,t.getBoundingClientRect(),e)}else sl(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let o=this.directPlugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let o=this.state.plugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let o=this.pluginViews[t];o.update&&o.update(this,e)}}updateDraggedNode(e,t){let o=e.node,s=-1;if(this.state.doc.nodeAt(o.from)==o.node)s=o.from;else{let r=o.from+(this.state.doc.content.size-t.doc.content.size);(r>0&&this.state.doc.nodeAt(r))==o.node&&(s=r)}this.dragging=new ud(e.slice,e.move,s<0?void 0:R.create(this.state.doc,s))}someProp(e,t){let o=this._props&&this._props[e],s;if(o!=null&&(s=t?t(o):o))return s;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(s=t?t(l):l))return s}let r=this.state.plugins;if(r)for(let i=0;i<r.length;i++){let l=r[i].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(he){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&bm(this.dom),We(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Cm(this,e)}coordsAtPos(e,t=1){return _c(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 Am(this,t||this.state,e)}pasteHTML(e,t){return Gn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Gn(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(og(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ps(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,rm())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return rg(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&&dm(this.dom.ownerDocument)==this.dom&&Eg(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Nl(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"),[pe.node(0,n.state.doc.content.size,e)]}function Ol(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:pe.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Il(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Vg(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 Rl(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 $g(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 Dl(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 hr,fr;if(typeof WeakMap<"u"){let n=new WeakMap;hr=e=>n.get(e),fr=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;hr=o=>{for(let s=0;s<n.length;s+=2)if(n[s]==o)return n[s+1]},fr=(o,s)=>(t==10&&(t=0),n[t++]=o,n[t++]=s)}var K=class{constructor(n,e,t,o){this.width=n,this.height=e,this.map=t,this.problems=o}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const o=e%this.width,s=e/this.width|0;let r=o+1,i=s+1;for(let l=1;r<this.width&&this.map[e+l]==t;l++)r++;for(let l=1;i<this.height&&this.map[e+this.width*l]==t;l++)i++;return{left:o,top:s,right:r,bottom:i}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:o,right:s,top:r,bottom:i}=this.findCell(n);return e=="horiz"?(t<0?o==0:s==this.width)?null:this.map[r*this.width+(t<0?o-1:s)]:(t<0?r==0:i==this.height)?null:this.map[o+this.width*(t<0?r-1:i)]}rectBetween(n,e){const{left:t,right:o,top:s,bottom:r}=this.findCell(n),{left:i,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,i),top:Math.min(s,a),right:Math.max(o,l),bottom:Math.max(r,c)}}cellsInRect(n){const e=[],t={};for(let o=n.top;o<n.bottom;o++)for(let s=n.left;s<n.right;s++){const r=o*this.width+s,i=this.map[r];t[i]||(t[i]=!0,!(s==n.left&&s&&this.map[r-1]==i||o==n.top&&o&&this.map[r-this.width]==i)&&e.push(i))}return e}positionAt(n,e,t){for(let o=0,s=0;;o++){const r=s+t.child(o).nodeSize;if(o==n){let i=e+n*this.width;const l=(n+1)*this.width;for(;i<l&&this.map[i]<s;)i++;return i==l?r-1:this.map[i]}s=r}}static get(n){return hr(n)||fr(n,Bg(n))}};function Bg(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=Hg(n),t=n.childCount,o=[];let s=0,r=null;const i=[];for(let c=0,d=e*t;c<d;c++)o[c]=0;for(let c=0,d=0;c<t;c++){const u=n.child(c);d++;for(let f=0;;f++){for(;s<o.length&&o[s]!=0;)s++;if(f==u.childCount)break;const m=u.child(f),{colspan:g,rowspan:v,colwidth:C}=m.attrs;for(let y=0;y<v;y++){if(y+c>=t){(r||(r=[])).push({type:"overlong_rowspan",pos:d,n:v-y});break}const b=s+y*e;for(let x=0;x<g;x++){o[b+x]==0?o[b+x]=d:(r||(r=[])).push({type:"collision",row:c,pos:d,n:g-x});const S=C&&C[x];if(S){const w=(b+x)%e*2,M=i[w];M==null||M!=S&&i[w+1]==1?(i[w]=S,i[w+1]=1):M==S&&i[w+1]++}}}s+=g,d+=m.nodeSize}const p=(c+1)*e;let h=0;for(;s<p;)o[s++]==0&&h++;h&&(r||(r=[])).push({type:"missing",row:c,n:h}),d++}const l=new K(e,t,o,r);let a=!1;for(let c=0;!a&&c<i.length;c+=2)i[c]!=null&&i[c+1]<t&&(a=!0);return a&&Fg(l,i,n),l}function Hg(n){let e=-1,t=!1;for(let o=0;o<n.childCount;o++){const s=n.child(o);let r=0;if(t)for(let i=0;i<o;i++){const l=n.child(i);for(let a=0;a<l.childCount;a++){const c=l.child(a);i+c.attrs.rowspan>o&&(r+=c.attrs.colspan)}}for(let i=0;i<s.childCount;i++){const l=s.child(i);r+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=r:e!=r&&(e=Math.max(e,r))}return e}function Fg(n,e,t){n.problems||(n.problems=[]);const o={};for(let s=0;s<n.map.length;s++){const r=n.map[s];if(o[r])continue;o[r]=!0;const i=t.nodeAt(r);if(!i)throw new RangeError(`No cell with offset ${r} found`);let l=null;const a=i.attrs;for(let c=0;c<a.colspan;c++){const d=(s+c)%n.width,u=e[d*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=_g(a)))[c]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:r,colwidth:l})}}function _g(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Ll(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),o=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(i=>Number(i)):null,s=Number(n.getAttribute("colspan")||1),r={colspan:s,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:o&&o.length==s?o:null};for(const i in e){const l=e[i].getFromDOM,a=l&&l(n);a!=null&&(r[i]=a)}return r}function zl(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 Gg(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=>Ll(o,e)}],toDOM(o){return["td",zl(o,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:o=>Ll(o,e)}],toDOM(o){return["th",zl(o,e),0]}}}}function ze(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 Qe=new Kn("selectingCells");function Zn(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 ss(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 Ur(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=Zn(e.$head)||Wg(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Wg(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 mr(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function jg(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Jr(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function gd(n,e,t){const o=n.node(-1),s=K.get(o),r=n.start(-1),i=s.nextCell(n.pos-r,e,t);return i==null?null:n.node(0).resolve(r+i)}function dn(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 He extends L{constructor(e,t=e){const o=e.node(-1),s=K.get(o),r=e.start(-1),i=s.rectBetween(e.pos-r,t.pos-r),l=e.node(0),a=s.cellsInRect(i).filter(d=>d!=t.pos-r);a.unshift(t.pos-r);const c=a.map(d=>{const u=o.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);const p=r+d+1;return new vc(l.resolve(p),l.resolve(p+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const o=e.resolve(t.map(this.$anchorCell.pos)),s=e.resolve(t.map(this.$headCell.pos));if(mr(o)&&mr(s)&&Jr(o,s)){const r=this.$anchorCell.node(-1)!=o.node(-1);return r&&this.isRowSelection()?He.rowSelection(o,s):r&&this.isColSelection()?He.colSelection(o,s):new He(o,s)}return z.between(o,s)}content(){const e=this.$anchorCell.node(-1),t=K.get(e),o=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),r={},i=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let d=a*t.width+s.left,u=s.left;u<s.right;u++,d++){const p=t.map[d];if(r[p])continue;r[p]=!0;const h=t.findCell(p);let f=e.nodeAt(p);if(!f)throw RangeError(`No cell with offset ${p} found`);const m=s.left-h.left,g=h.right-s.right;if(m>0||g>0){let v=f.attrs;if(m>0&&(v=dn(v,0,m)),g>0&&(v=dn(v,v.colspan-g,g)),h.left<s.left){if(f=f.type.createAndFill(v),!f)throw RangeError(`Could not create cell with attrs ${JSON.stringify(v)}`)}else f=f.type.create(v,f.content)}if(h.top<s.top||h.bottom>s.bottom){const v={...f.attrs,rowspan:Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top)};h.top<s.top?f=f.type.createAndFill(v):f=f.type.create(v,f.content)}c.push(f)}i.push(e.child(a).copy(T.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new A(T.from(l),1,1)}replace(e,t=A.empty){const o=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){const{$from:l,$to:a}=s[i],c=e.mapping.slice(o);e.replace(c.map(l.pos),c.map(a.pos),i?A.empty:t)}const r=L.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,t){this.replace(e,new A(T.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),o=K.get(t),s=this.$anchorCell.start(-1),r=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let i=0;i<r.length;i++)e(t.nodeAt(r[i]),s+r[i])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const o=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const o=e.node(-1),s=K.get(o),r=e.start(-1),i=s.findCell(e.pos-r),l=s.findCell(t.pos-r),a=e.node(0);return i.top<=l.top?(i.top>0&&(e=a.resolve(r+s.map[i.left])),l.bottom<s.height&&(t=a.resolve(r+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(r+s.map[l.left])),i.bottom<s.height&&(e=a.resolve(r+s.map[s.width*(s.height-1)+i.right-1]))),new He(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=K.get(e),o=this.$anchorCell.start(-1),s=t.colCount(this.$anchorCell.pos-o),r=t.colCount(this.$headCell.pos-o);if(Math.min(s,r)>0)return!1;const i=s+this.$anchorCell.nodeAfter.attrs.colspan,l=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==t.width}eq(e){return e instanceof He&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const o=e.node(-1),s=K.get(o),r=e.start(-1),i=s.findCell(e.pos-r),l=s.findCell(t.pos-r),a=e.node(0);return i.left<=l.left?(i.left>0&&(e=a.resolve(r+s.map[i.top*s.width])),l.right<s.width&&(t=a.resolve(r+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(r+s.map[l.top*s.width])),i.right<s.width&&(e=a.resolve(r+s.map[s.width*(i.top+1)-1]))),new He(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new He(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){return new He(e.resolve(t),e.resolve(o))}getBookmark(){return new qg(this.$anchorCell.pos,this.$headCell.pos)}};Z.prototype.visible=!1;L.jsonID("cell",Z);var qg=class yd{constructor(e,t){this.anchor=e,this.head=t}map(e){return new yd(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&&Jr(t,o)?new Z(t,o):L.near(o,1)}};function Kg(n){if(!(n.selection instanceof Z))return null;const e=[];return n.selection.forEachCell((t,o)=>{e.push(pe.node(o,o+t.nodeSize,{class:"selectedCell"}))}),_.create(n.doc,e)}function Ug({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,o=e.pos,s=n.depth;for(;s>=0&&!(n.after(s+1)<n.end(s));s--,t++);for(let r=e.depth;r>=0&&!(e.before(r+1)>e.start(r));r--,o--);return t==o&&/row|table/.test(n.node(s).type.spec.tableRole)}function Jg({$from:n,$to:e}){let t,o;for(let s=n.depth;s>0;s--){const r=n.node(s);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){t=r;break}}for(let s=e.depth;s>0;s--){const r=e.node(s);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){o=r;break}}return t!==o&&e.parentOffset===0}function Yg(n,e,t){const o=(e||n).selection,s=(e||n).doc;let r,i;if(o instanceof R&&(i=o.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")r=Z.create(s,o.from);else if(i=="row"){const l=s.resolve(o.from+1);r=Z.rowSelection(l,l)}else if(!t){const l=K.get(o.node),a=o.from+1,c=a+l.map[l.width*l.height-1];r=Z.create(s,a+1,c)}}else o instanceof z&&Ug(o)?r=z.create(s,o.from):o instanceof z&&Jg(o)&&(r=z.create(s,o.$from.start(),o.$from.end()));return r&&(e||(e=n.tr)).setSelection(r),e}var Zg=new Kn("fix-tables");function bd(n,e,t,o){const s=n.childCount,r=e.childCount;e:for(let i=0,l=0;i<r;i++){const a=e.child(i);for(let c=l,d=Math.min(s,i+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}o(a,t),l<s&&n.child(l).sameMarkup(a)?bd(n.child(l),a,t+1,o):a.nodesBetween(0,a.content.size,o,t+1),t+=a.nodeSize}}function Xg(n,e){let t;const o=(s,r)=>{s.type.spec.tableRole=="table"&&(t=Qg(n,s,r,t))};return e?e.doc!=n.doc&&bd(e.doc,n.doc,0,o):n.doc.descendants(o),t}function Qg(n,e,t,o){const s=K.get(e);if(!s.problems)return o;o||(o=n.tr);const r=[];for(let a=0;a<s.height;a++)r.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let p=0;p<u.rowspan;p++)r[c.row+p]+=c.n;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,dn(u,u.colspan-c.n,c.n))}else if(c.type=="missing")r[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}}let i,l;for(let a=0;a<r.length;a++)r[a]&&(i==null&&(i=a),l=a);for(let a=0,c=t+1;a<s.height;a++){const d=e.child(a),u=c+d.nodeSize,p=r[a];if(p>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const f=[];for(let g=0;g<p;g++){const v=ze(n.schema)[h].createAndFill();v&&f.push(v)}const m=(a==0||i==a-1)&&l==a?c+1:u-1;o.insert(o.mapping.map(m),f)}c=u}return o.setMeta(Zg,{fixTables:!0})}function vd(n){const e=n.selection,t=Ur(n),o=t.node(-1),s=t.start(-1),r=K.get(o);return{...e instanceof Z?r.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):r.findCell(t.pos-s),tableStart:s,map:r,table:o}}function e1(n){return function(e,t){if(!ss(e))return!1;if(t){const o=ze(e.schema),s=vd(e),r=e.tr,i=s.map.cellsInRect(n=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:n=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=i.map(a=>s.table.nodeAt(a));for(let a=0;a<i.length;a++)l[a].type==o.header_cell&&r.setNodeMarkup(s.tableStart+i[a],o.cell,l[a].attrs);if(r.steps.length==0)for(let a=0;a<i.length;a++)r.setNodeMarkup(s.tableStart+i[a],o.header_cell,l[a].attrs);t(r)}return!0}}function Vl(n,e,t){const o=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let s=0;s<o.length;s++){const r=e.table.nodeAt(o[s]);if(r&&r.type!==t.header_cell)return!1}return!0}function Yr(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?e1(n):function(t,o){if(!ss(t))return!1;if(o){const s=ze(t.schema),r=vd(t),i=t.tr,l=Vl("row",r,s),a=Vl("column",r,s),d=(n==="column"?l:n==="row"?a:!1)?1:0,u=n=="column"?{left:0,top:d,right:1,bottom:r.map.height}:n=="row"?{left:d,top:0,right:r.map.width,bottom:1}:r,p=n=="column"?a?s.cell:s.header_cell:n=="row"?l?s.cell:s.header_cell:s.cell;r.map.cellsInRect(u).forEach(h=>{const f=h+r.tableStart,m=i.doc.nodeAt(f);m&&i.setNodeMarkup(f,p,m.attrs)}),o(i)}return!0}}Yr("row",{useDeprecatedLogic:!0});Yr("column",{useDeprecatedLogic:!0});Yr("cell",{useDeprecatedLogic:!0});function t1(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let o=n.index(-1)-1,s=n.before();o>=0;o--){const r=n.node(-1).child(o),i=r.lastChild;if(i)return s-1-i.nodeSize;s-=r.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let o=n.indexAfter(-1),s=n.after();o<t.childCount;o++){const r=t.child(o);if(r.childCount)return s+1;s+=r.nodeSize}}return null}function $l(n){return function(e,t){if(!ss(e))return!1;const o=t1(Ur(e),n);if(o==null)return!1;if(t){const s=e.doc.resolve(o);t(e.tr.setSelection(z.between(s,jg(s))).scrollIntoView())}return!0}}function uo(n,e){const t=n.selection;if(!(t instanceof Z))return!1;if(e){const o=n.tr,s=ze(n.schema).cell.createAndFill().content;t.forEachCell((r,i)=>{r.content.eq(s)||o.replace(o.mapping.map(i+1),o.mapping.map(i+r.nodeSize-1),new A(s,0,0))}),o.docChanged&&e(o)}return!0}function n1(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:o}=n;for(;e.childCount==1&&(t>0&&o>0||e.child(0).type.spec.tableRole=="table");)t--,o--,e=e.child(0).content;const s=e.child(0),r=s.type.spec.tableRole,i=s.type.schema,l=[];if(r=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),u=a<e.childCount-1?0:Math.max(0,o-1);(d||u)&&(c=gr(ze(i).row,new A(c,d,u)).content),l.push(c)}else if(r=="cell"||r=="header_cell")l.push(t||o?gr(ze(i).row,new A(e,t,o)).content:e);else return null;return o1(i,l)}function o1(n,e){const t=[];for(let s=0;s<e.length;s++){const r=e[s];for(let i=r.childCount-1;i>=0;i--){const{rowspan:l,colspan:a}=r.child(i).attrs;for(let c=s;c<s+l;c++)t[c]=(t[c]||0)+a}}let o=0;for(let s=0;s<t.length;s++)o=Math.max(o,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(T.empty),t[s]<o){const r=ze(n).cell.createAndFill(),i=[];for(let l=t[s];l<o;l++)i.push(r);e[s]=e[s].append(T.from(i))}return{height:e.length,width:o,rows:e}}function gr(n,e){const t=n.createAndFill();return new bc(t).replace(0,t.content.size,e).doc}function s1({width:n,height:e,rows:t},o,s){if(n!=o){const r=[],i=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=r[l]||0,u=0;d<o;u++){let p=a.child(u%a.childCount);d+p.attrs.colspan>o&&(p=p.type.createChecked(dn(p.attrs,p.attrs.colspan,d+p.attrs.colspan-o),p.content)),c.push(p),d+=p.attrs.colspan;for(let h=1;h<p.attrs.rowspan;h++)r[l+h]=(r[l+h]||0)+p.attrs.colspan}i.push(T.from(c))}t=i,n=o}if(e!=s){const r=[];for(let i=0,l=0;i<s;i++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);i+u.attrs.rowspan>s&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,s-u.attrs.rowspan)},u.content)),a.push(u)}r.push(T.from(a))}t=r,e=s}return{width:n,height:e,rows:t}}function r1(n,e,t,o,s,r,i){const l=n.doc.type.schema,a=ze(l);let c,d;if(s>e.width)for(let u=0,p=0;u<e.height;u++){const h=t.child(u);p+=h.nodeSize;const f=[];let m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=d||(d=a.header_cell.createAndFill());for(let g=e.width;g<s;g++)f.push(m);n.insert(n.mapping.slice(i).map(p-1+o),f)}if(r>e.height){const u=[];for(let f=0,m=(e.height-1)*e.width;f<Math.max(e.width,s);f++){const g=f>=e.width?!1:t.nodeAt(e.map[m+f]).type==a.header_cell;u.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const p=a.row.create(null,T.from(u)),h=[];for(let f=e.height;f<r;f++)h.push(p);n.insert(n.mapping.slice(i).map(o+t.nodeSize-2),h)}return!!(c||d)}function Bl(n,e,t,o,s,r,i,l){if(i==0||i==e.height)return!1;let a=!1;for(let c=s;c<r;c++){const d=i*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){a=!0;const p=t.nodeAt(u),{top:h,left:f}=e.findCell(u);n.setNodeMarkup(n.mapping.slice(l).map(u+o),null,{...p.attrs,rowspan:i-h}),n.insert(n.mapping.slice(l).map(e.positionAt(i,f,t)),p.type.createAndFill({...p.attrs,rowspan:h+p.attrs.rowspan-i})),c+=p.attrs.colspan-1}}return a}function Hl(n,e,t,o,s,r,i,l){if(i==0||i==e.width)return!1;let a=!1;for(let c=s;c<r;c++){const d=c*e.width+i,u=e.map[d];if(e.map[d-1]==u){a=!0;const p=t.nodeAt(u),h=e.colCount(u),f=n.mapping.slice(l).map(u+o);n.setNodeMarkup(f,null,dn(p.attrs,i-h,p.attrs.colspan-(i-h))),n.insert(f+p.nodeSize,p.type.createAndFill(dn(p.attrs,0,i-h))),c+=p.attrs.rowspan-1}}return a}function Fl(n,e,t,o,s){let r=t?n.doc.nodeAt(t-1):n.doc;if(!r)throw new Error("No table found");let i=K.get(r);const{top:l,left:a}=o,c=a+s.width,d=l+s.height,u=n.tr;let p=0;function h(){if(r=t?u.doc.nodeAt(t-1):u.doc,!r)throw new Error("No table found");i=K.get(r),p=u.mapping.maps.length}r1(u,i,r,t,c,d,p)&&h(),Bl(u,i,r,t,a,c,l,p)&&h(),Bl(u,i,r,t,a,c,d,p)&&h(),Hl(u,i,r,t,l,d,a,p)&&h(),Hl(u,i,r,t,l,d,c,p)&&h();for(let f=l;f<d;f++){const m=i.positionAt(f,a,r),g=i.positionAt(f,c,r);u.replace(u.mapping.slice(p).map(m+t),u.mapping.slice(p).map(g+t),new A(s.rows[f-l],0,0))}h(),u.setSelection(new Z(u.doc.resolve(t+i.positionAt(l,a,r)),u.doc.resolve(t+i.positionAt(d-1,c-1,r)))),e(u)}var i1=Lc({ArrowLeft:po("horiz",-1),ArrowRight:po("horiz",1),ArrowUp:po("vert",-1),ArrowDown:po("vert",1),"Shift-ArrowLeft":ho("horiz",-1),"Shift-ArrowRight":ho("horiz",1),"Shift-ArrowUp":ho("vert",-1),"Shift-ArrowDown":ho("vert",1),Backspace:uo,"Mod-Backspace":uo,Delete:uo,"Mod-Delete":uo});function wo(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function po(n,e){return(t,o,s)=>{if(!s)return!1;const r=t.selection;if(r instanceof Z)return wo(t,o,L.near(r.$headCell,e));if(n!="horiz"&&!r.empty)return!1;const i=xd(s,n,e);if(i==null)return!1;if(n=="horiz")return wo(t,o,L.near(t.doc.resolve(r.head+e),e));{const l=t.doc.resolve(i),a=gd(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),wo(t,o,c)}}}function ho(n,e){return(t,o,s)=>{if(!s)return!1;const r=t.selection;let i;if(r instanceof Z)i=r;else{const a=xd(s,n,e);if(a==null)return!1;i=new Z(t.doc.resolve(a))}const l=gd(i.$headCell,n,e);return l?wo(t,o,new Z(i.$anchorCell,l)):!1}}function l1(n,e){const t=n.state.doc,o=Zn(t.resolve(e));return o?(n.dispatch(n.state.tr.setSelection(new Z(o))),!0):!1}function a1(n,e,t){if(!ss(n.state))return!1;let o=n1(t);const s=n.state.selection;if(s instanceof Z){o||(o={width:1,height:1,rows:[T.from(gr(ze(n.state.schema).cell,t))]});const r=s.$anchorCell.node(-1),i=s.$anchorCell.start(-1),l=K.get(r).rectBetween(s.$anchorCell.pos-i,s.$headCell.pos-i);return o=s1(o,l.right-l.left,l.bottom-l.top),Fl(n.state,n.dispatch,i,l,o),!0}else if(o){const r=Ur(n.state),i=r.start(-1);return Fl(n.state,n.dispatch,i,K.get(r.node(-1)).findCell(r.pos-i),o),!0}else return!1}function c1(n,e){var t;if(e.ctrlKey||e.metaKey)return;const o=_l(n,e.target);let s;if(e.shiftKey&&n.state.selection instanceof Z)r(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(s=Zn(n.state.selection.$anchor))!=null&&((t=Os(n,e))==null?void 0:t.pos)!=s.pos)r(s,e),e.preventDefault();else if(!o)return;function r(a,c){let d=Os(n,c);const u=Qe.getState(n.state)==null;if(!d||!Jr(a,d))if(u)d=a;else return;const p=new Z(a,d);if(u||!n.state.selection.eq(p)){const h=n.state.tr.setSelection(p);u&&h.setMeta(Qe,a.pos),n.dispatch(h)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",l),Qe.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Qe,-1))}function l(a){const c=a,d=Qe.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(_l(n,c.target)!=o&&(u=Os(n,e),!u))return i();u&&r(u,c)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",l)}function xd(n,e,t){if(!(n.state.selection instanceof z))return null;const{$head:o}=n.state.selection;for(let s=o.depth-1;s>=0;s--){const r=o.node(s);if((t<0?o.index(s):o.indexAfter(s))!=(t<0?0:r.childCount))return null;if(r.type.spec.tableRole=="cell"||r.type.spec.tableRole=="header_cell"){const l=o.before(s),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function _l(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Os(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Zn(n.state.doc.resolve(t.pos)):null}var d1=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")),yr(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,yr(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function yr(n,e,t,o,s,r){var i;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let u=0,p=0;u<d.childCount;u++){const{colspan:h,colwidth:f}=d.child(u).attrs;for(let m=0;m<h;m++,p++){const g=s==p?r:f&&f[m],v=g?g+"px":"";if(l+=g||o,g||(a=!1),c)c.style.width!=v&&(c.style.width=v),c=c.nextSibling;else{const C=document.createElement("col");C.style.width=v,e.appendChild(C)}}}for(;c;){const u=c.nextSibling;(i=c.parentNode)==null||i.removeChild(c),c=u}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var ge=new Kn("tableColumnResizing");function u1({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:o=d1,lastColumnResizable:s=!0}={}){const r=new hn({key:ge,state:{init(i,l){var a,c;const d=(c=(a=r.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,u=ze(l.schema).table.name;return o&&d&&(d[u]=(p,h)=>new o(p,t,h)),new p1(-1,!1)},apply(i,l){return l.apply(i)}},props:{attributes:i=>{const l=ge.getState(i);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(i,l)=>{h1(i,l,n,s)},mouseleave:i=>{f1(i)},mousedown:(i,l)=>{m1(i,l,e,t)}},decorations:i=>{const l=ge.getState(i);if(l&&l.activeHandle>-1)return x1(i,l.activeHandle)},nodeViews:{}}});return r}var p1=class Co{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,o=e.getMeta(ge);if(o&&o.setHandle!=null)return new Co(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new Co(t.activeHandle,o.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);return mr(e.doc.resolve(s))||(s=-1),new Co(s,t.dragging)}return t}};function h1(n,e,t,o){const s=ge.getState(n.state);if(s&&!s.dragging){const r=y1(e.target);let i=-1;if(r){const{left:l,right:a}=r.getBoundingClientRect();e.clientX-l<=t?i=Gl(n,e,"left",t):a-e.clientX<=t&&(i=Gl(n,e,"right",t))}if(i!=s.activeHandle){if(!o&&i!==-1){const l=n.state.doc.resolve(i),a=l.node(-1),c=K.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Sd(n,i)}}}function f1(n){const e=ge.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Sd(n,-1)}function m1(n,e,t,o){var s;const r=(s=n.dom.ownerDocument.defaultView)!=null?s:window,i=ge.getState(n.state);if(!i||i.activeHandle==-1||i.dragging)return!1;const l=n.state.doc.nodeAt(i.activeHandle),a=g1(n,i.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(ge,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){r.removeEventListener("mouseup",c),r.removeEventListener("mousemove",d);const p=ge.getState(n.state);p!=null&&p.dragging&&(b1(n,p.activeHandle,Wl(p.dragging,u,t)),n.dispatch(n.state.tr.setMeta(ge,{setDragging:null})))}function d(u){if(!u.which)return c(u);const p=ge.getState(n.state);if(p&&p.dragging){const h=Wl(p.dragging,u,t);jl(n,p.activeHandle,h,o)}}return jl(n,i.activeHandle,a,o),r.addEventListener("mouseup",c),r.addEventListener("mousemove",d),e.preventDefault(),!0}function g1(n,e,{colspan:t,colwidth:o}){const s=o&&o[o.length-1];if(s)return s;const r=n.domAtPos(e);let l=r.node.childNodes[r.offset].offsetWidth,a=t;if(o)for(let c=0;c<t;c++)o[c]&&(l-=o[c],a--);return l/a}function y1(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Gl(n,e,t,o){const s=t=="right"?-o:o,r=n.posAtCoords({left:e.clientX+s,top:e.clientY});if(!r)return-1;const{pos:i}=r,l=Zn(n.state.doc.resolve(i));if(!l)return-1;if(t=="right")return l.pos;const a=K.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 Wl(n,e,t){const o=e.clientX-n.startX;return Math.max(t,n.startWidth+o)}function Sd(n,e){n.dispatch(n.state.tr.setMeta(ge,{setHandle:e}))}function b1(n,e,t){const o=n.state.doc.resolve(e),s=o.node(-1),r=K.get(s),i=o.start(-1),l=r.colCount(o.pos-i)+o.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<r.height;c++){const d=c*r.width+l;if(c&&r.map[d]==r.map[d-r.width])continue;const u=r.map[d],p=s.nodeAt(u).attrs,h=p.colspan==1?0:l-r.colCount(u);if(p.colwidth&&p.colwidth[h]==t)continue;const f=p.colwidth?p.colwidth.slice():v1(p.colspan);f[h]=t,a.setNodeMarkup(i+u,null,{...p,colwidth:f})}a.docChanged&&n.dispatch(a)}function jl(n,e,t,o){const s=n.state.doc.resolve(e),r=s.node(-1),i=s.start(-1),l=K.get(r).colCount(s.pos-i)+s.nodeAfter.attrs.colspan-1;let a=n.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&yr(r,a.firstChild,a,o,l,t)}function v1(n){return Array(n).fill(0)}function x1(n,e){var t;const o=[],s=n.doc.resolve(e),r=s.node(-1);if(!r)return _.empty;const i=K.get(r),l=s.start(-1),a=i.colCount(s.pos-l)+s.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){const d=a+c*i.width;if((a==i.width-1||i.map[d]!=i.map[d+1])&&(c==0||i.map[d]!=i.map[d-i.width])){const u=i.map[d],p=l+u+r.nodeAt(u).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",(t=ge.getState(n))!=null&&t.dragging&&o.push(pe.node(l+u,l+u+r.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),o.push(pe.widget(p,h))}}return _.create(n.doc,o)}function S1({allowTableNodeSelection:n=!1}={}){return new hn({key:Qe,state:{init(){return null},apply(e,t){const o=e.getMeta(Qe);if(o!=null)return o==-1?null:o;if(t==null||!e.docChanged)return t;const{deleted:s,pos:r}=e.mapping.mapResult(t);return s?null:r}},props:{decorations:Kg,handleDOMEvents:{mousedown:c1},createSelectionBetween(e){return Qe.getState(e.state)!=null?e.state.selection:null},handleTripleClick:l1,handleKeyDown:i1,handlePaste:a1},appendTransaction(e,t,o){return Yg(o,Xg(o,t),n)}})}const On=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},ql="data-gs-mrk-fs",Kl="data-gs-ib",Wo="data-gs-ifrg",je="attrs",wd={[je]:{default:"{}"}},$e={[je]:{default:{}}},Cd=n=>({[je]:JSON.stringify(On(n))}),Be=n=>({attrs:On(n)}),yn=n=>e=>[n,e.attrs.attrs,0],Ze=n=>n.attrs[je]?JSON.parse(n.attrs[je]):{},w1={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${Wo}]`,getAttrs:Be}],toDOM:()=>["span",{[Wo]:""},0]},div:{group:"block",content:"inline*",attrs:$e,parseDOM:[{tag:"div",getAttrs:Be}],toDOM:yn("div")},paragraph:{group:"block",content:"inline*",attrs:$e,parseDOM:[{tag:"p",getAttrs:Be}],toDOM:yn("p")},orderedList:{group:"block",content:"listItem+",attrs:$e,parseDOM:[{tag:"ol",getAttrs:Be}],toDOM:yn("ol")},bulletList:{group:"block",content:"listItem+",attrs:$e,parseDOM:[{tag:"ul",getAttrs:Be}],toDOM:yn("ul")},listItem:{content:"block*",group:"block",attrs:$e,parseDOM:[{tag:"li",getAttrs:Be}],toDOM:yn("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:$e,parseDOM:[{tag:"pre",getAttrs:Be}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:$e,parseDOM:[{tag:"img[src]",getAttrs:Be}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${Kl}]`}],toDOM(){return["br",{[Kl]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:$e,parseDOM:[{tag:"br",getAttrs:Be}],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:On(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...Gg({tableGroup:"block",cellContent:"block+",cellAttributes:{[je]:{default:$e[je].default,getFromDOM:On,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:On(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},bn=(n,e)=>({attrs:wd,parseDOM:n.map(t=>({tag:t,getAttrs:Cd})),toDOM:e}),C1={strong:bn(["strong","b"],n=>["b",Ze(n)]),link:bn(["a"],n=>["a",Ze(n),0]),em:bn(["em","i"],n=>["em",Ze(n)]),underline:bn(["u"],n=>["u",Ze(n),0]),strikethrough:bn(["s"],n=>["s",Ze(n),0]),font_size:{attrs:{...wd,size:{default:null}},parseDOM:[{tag:`span[${ql}]`,getAttrs:n=>({...Cd(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...Ze(n),[ql]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},Ul=new Fh({nodes:w1,marks:C1}),rs=new WeakMap,Zr=new WeakMap,k1=(n,e)=>{rs.set(n,e),Zr.set(e,n)},T1=(n,e)=>{rs.delete(n),Zr.delete(e)},Is=n=>rs.get(n),M1=n=>Zr.get(n),Jl=n=>{var t;const e=M1(n);return(t=e==null?void 0:e.__gjsv)==null?void 0:t.model},E1=n=>n.dispatchEvent(new CustomEvent("input"));function A1(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(Wo)){if(t.getAttribute("style")){t.removeAttribute(Wo);return}const o=t.parentElement;if(o){for(;t.firstChild;)o.insertBefore(t.firstChild,t);o.removeChild(t)}}else Array.from(t.children).forEach(o=>e(o))};e(n)}function P1(n,e={}){if(!e.enableOnClick)return()=>{};const t=n.Components.events,o=d=>n.getSelectedAll().includes(d),s=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),r=d=>d.isChildOf("text"),i=d=>n.getEditing()===d,l=(d,u={})=>{d.trigger("focus",u.event)},a=(d,u)=>{o(d)&&s(d)&&!i(d)&&l(d,u)},c=(d,u)=>{if(o(d)&&!s(d)&&r(d)){const p=d.parents().find(h=>h.isInstanceOf("text"));p&&(l(p,u),setTimeout(()=>n.select(p),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const N1=(n,e)=>{const t=O1(n);return t&&H1(t)?I1(n,e):t?Ec(()=>({type:n.schema.nodes.div}))(n,e):!1};function O1(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 I1(n,e){const{selection:t,schema:o,tr:s}=n;s.split(t.from,1);const r=t.from+1,i=s.doc.nodeAt(r),l={...i.attrs.attrs,id:void 0},a=i.textContent.length>0,c=i.textContent.length||0,d=i.textContent||" ",u=o.text(d),p=o.nodes.div.create(l,a?u:[],[]);return s.replaceRangeWith(r,r+c+2,p),s.setSelection(z.create(s.doc,r+1)),e==null||e(s.scrollIntoView()),!0}function R1(n,e,t){const{state:o,dispatch:s}=n,{selection:r,tr:i}=o,l=(a,c,d)=>{const u={};return a.split(";").forEach(p=>{const[h,f]=p.split(":").map(m=>m.trim());h&&(u[h]=f)}),u[c]=d,Object.entries(u).map(([p,h])=>`${p}: ${h}`).join("; ")};if(!r.empty||t)i.doc.nodesBetween(r.from,r.to,(a,c)=>{var d,u;if(a.type===o.schema.nodes.image){const p=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);i.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:p}})}else if(a.type.isBlock){const p=l(((u=a.attrs.attrs)==null?void 0:u.style)||"","text-align",e);kd(a)?i.setBlockType(r.from,void 0,o.schema.nodes.div,{attrs:{style:p}}):i.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:p}})}});else{const a=o.doc.resolve(r.from),c=a.start(a.depth),d=o.doc.nodeAt(c);if(d!=null&&d.type.isBlock){const u=l(d.attrs.style||"","text-align",e);i.setNodeMarkup(c,void 0,{...d.attrs,style:u})}}i.docChanged&&s(i.scrollIntoView())}const vn=(n,e)=>{const{from:t,to:o}=n.selection;let s=!1;return n.doc.nodesBetween(t,o,r=>{if(s)return!1;r.marks.some(i=>i.type===e)&&(s=!0)}),s};function D1(n,e,t="_blank"){const{state:o,dispatch:s}=n,{schema:r,selection:i,tr:l}=o,a=r.marks.link;try{const c=a.create({[je]:JSON.stringify({href:e,target:t})});l.addMark(i.from,i.to,c),s(l.scrollIntoView())}catch(c){console.error("Error applying link mark:",c)}}function L1(n,e){const{state:t,dispatch:o}=n,{selection:s,tr:r}=t;if(s.empty)return;const i=t.schema.marks.font_size;if(!i){console.error("Font size mark is not defined in the schema.");return}r.addMark(s.from,s.to,i.create({size:e})),o(r.scrollIntoView())}const wt=(n,e)=>{const{doc:t,selection:o}=n.state,s=t.resolve(o.from);for(let r=s.depth;r>0;r--){const i=s.node(r);if(e(i))return{pos:r>0?s.before(r):0,start:s.start(r),depth:r,node:i}}},z1=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 V1(...n){return(e,t)=>{const o=i=>{e=e.apply(i),t==null||t(i)},s=n.pop();return n.reduce((i,l)=>i||l(e,o),!1)&&s!==void 0&&s(e,t)}}const $1=(n,e)=>{const{state:t,dispatch:o}=n;if(e!=null&&e.event){const{event:s}=e,r=n.posAtCoords({left:s.clientX,top:s.clientY});r!=null&&r.pos&&o(t.tr.setSelection(z.create(t.doc,r.pos)))}else Ac(t,o);setTimeout(()=>setTimeout(()=>n.focus()))},br=n=>n.isBlock,kd=n=>n.type.name==="inlineFragment",B1=n=>br(n)&&!kd(n),Td=n=>n.type.name==="bulletList",Md=n=>n.type.name==="orderedList",H1=n=>n.type.name==="heading",F1=n=>Td(n)||Md(n),Yl=(n,e)=>{var r,i;const t=(r=wt(n,l=>l.type===e))==null?void 0:r.node,o=n.state.schema.nodes.listItem;let s;return t?s=nr(o):(i=wt(n,F1))!=null&&i.node?s=V1(nr(o),tl(e)):s=tl(e),s(n.state,n.dispatch)},Ed=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(o=>o.type.name===e)},_1=n=>{var i;const{view:e,prop:t,editor:o,propCSS:s}=n,r=(i=wt(e,B1))==null?void 0:i.node;if(r){const l=r.attrs.attrs||{},a=z1(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""},G1=n=>{const{view:e,prop:t,markName:o,editor:s,propCSS:r}=n,i=Ed(e,o);if(i){const l=i.attrs;if(l[t])return l[t];if(l[je]){const a=Ze(i).id;if(a){const c=s.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[r]||""}}}return""},Ad=(n,e)=>{const{dispatch:t}=n,{nodes:o,marks:s}=n.state.schema;return{text:{selected:()=>{const{selection:r,doc:i}=n.state;return i.textBetween(r.from,r.to," ")},replace:(r,i={})=>{const{state:l}=n,{from:a}=l.selection;let c=l.tr.replaceSelectionWith(l.schema.text(r));i.select&&(c=c.setSelection(z.create(c.doc,a,a+r.length))),t==null||t(c)}},bold:{toggle:()=>gt(s.strong)(n.state,t),isActive:()=>vn(n.state,s.strong)},italic:{toggle:()=>gt(s.em)(n.state,t),isActive:()=>vn(n.state,s.em)},underline:{toggle:()=>gt(s.underline)(n.state,t),isActive:()=>vn(n.state,s.underline)},strikethrough:{toggle:()=>gt(s.strikethrough)(n.state,t),isActive:()=>vn(n.state,s.strikethrough)},link:{get:()=>{const r=Jl(n);if(r!=null&&r.is("link"))return r.getAttributes();{const i=Ed(n,"link");return i?Ze(i):{}}},toggle:()=>gt(s.link)(n.state,t),isActive:()=>vn(n.state,s.link),create:r=>{const i=Jl(n);i!=null&&i.is("link")?(i.addAttributes({href:r.url,target:r.target}),n.focus()):D1(n,r.url,r.target)}},alignText:{get:()=>_1({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:r=>R1(n,r.value,!0)},fontSize:{get:()=>G1({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:r=>L1(n,r.value)},image:{open(){const r="assetLayout",{state:i,dispatch:l}=n,{selection:a,doc:c}=i,d=c.textBetween(a.from,a.to," "),u={id:r,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:p=>{const h={alt:d,src:p.asset.getSrc()};l(i.tr.replaceSelectionWith(o.image.createAndFill({attrs:h})))}}};e.runCommand(F.layoutToggle,u)}},heading:{get:()=>{var i;const r=(i=wt(n,br))==null?void 0:i.node;return`${(r==null?void 0:r.attrs.level)||""}`},set:({value:r})=>{var a;const{state:i}=n,l=(a=wt(n,br))==null?void 0:a.node;Lf(i.schema.nodes.heading,{attrs:l==null?void 0:l.attrs.attrs,level:r?parseInt(r,10):0})(i,t)}},listBullet:{isActive:()=>{var r;return!!((r=wt(n,Td))!=null&&r.node)},toggle:()=>Yl(n,o.bulletList)},listOrdered:{isActive:()=>{var r;return!!((r=wt(n,Md))!=null&&r.node)},toggle:()=>Yl(n,o.orderedList)}}};class ut{constructor(e,t,o={}){this.match=e,this.match=e,this.handler=typeof t=="string"?W1(t):t,this.undoable=o.undoable!==!1,this.inCode=o.inCode||!1}}function W1(n){return function(e,t,o,s){let r=n;if(t[1]){let i=t[0].lastIndexOf(t[1]);r+=t[0].slice(i+t[1].length),o+=i;let l=o-s;l>0&&(r=t[0].slice(i-l,i)+r,o=s)}return e.tr.insertText(r,o,s)}}const j1=500;function q1({rules:n}){let e=new hn({state:{init(){return null},apply(t,o){let s=t.getMeta(this);return s||(t.selectionSet||t.docChanged?null:o)}},props:{handleTextInput(t,o,s,r){return Zl(t,o,s,r,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:o}=t.state.selection;o&&Zl(t,o.pos,o.pos,"",n,e)})}}},isInputRules:!0});return e}function Zl(n,e,t,o,s,r){if(n.composing)return!1;let i=n.state,l=i.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-j1),l.parentOffset,null,"")+o;for(let c=0;c<s.length;c++){let d=s[c];if(l.parent.type.spec.code){if(!d.inCode)continue}else if(d.inCode==="only")continue;let u=d.match.exec(a),p=u&&d.handler(i,u,e-(u[0].length-o.length),t);if(p)return d.undoable&&p.setMeta(r,{transform:p,from:e,to:t,text:o}),n.dispatch(p),!0}return!1}const K1=new ut(/--$/,"—"),U1=new ut(/\.\.\.$/,"…"),J1=new ut(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),Y1=new ut(/"$/,"”"),Z1=new ut(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),X1=new ut(/'$/,"’"),Q1=[J1,Y1,Z1,X1];function Xr(n,e,t=null,o){return new ut(n,(s,r,i,l)=>{let a=t instanceof Function?t(r):t,c=s.tr.delete(i,l),d=c.doc.resolve(i),u=d.blockRange(),p=u&&uc(u,e,a);if(!p)return null;c.wrap(u,p);let h=c.doc.resolve(i-1).nodeBefore;return h&&h.type==e&&Xo(c.doc,i-1)&&(!o||o(r,h))&&c.join(i-1),c})}function Pd(n,e,t=null){return new ut(n,(o,s,r,i)=>{let l=o.doc.resolve(r),a=t instanceof Function?t(s):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?o.tr.delete(r,i).setBlockType(r,r,e,a):null})}function e0(n){return Xr(/^\s*>\s$/,n)}function t0(n){return Xr(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function n0(n){return Xr(/^\s*([-+*])\s$/,n)}function o0(n){return Pd(/^```$/,n)}function s0(n,e){return Pd(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function r0(n){const e=Q1.concat(U1,K1);let t;return(t=n.nodes.blockquote)&&e.push(e0(t)),(t=n.nodes.orderedList)&&e.push(t0(t)),(t=n.nodes.bulletList)&&e.push(n0(t)),(t=n.nodes.codeBlock)&&e.push(o0(t)),(t=n.nodes.heading)&&e.push(s0(t,6)),q1({rules:e})}const i0="rteProseMirror",l0=H.free,Ce="rte:selectionchange",ve={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>'},a0=(n,e)=>{var a;const{editor:t,el:o}=n,s=rs.get(o),r=Ad(s,t),i={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},bold:{id:"bold",icon:ve.bold,size:"s",type:"button",editorEvents:{[Ce]:({setState:c})=>{c({active:r.bold.isActive()})}},onClick:({setState:c})=>{r.bold.toggle(),c({active:r.bold.isActive()})}},italic:{id:"italic",icon:ve.italic,size:"s",type:"button",editorEvents:{[Ce]:({setState:c})=>{c({active:r.italic.isActive()})}},onClick:({setState:c})=>{r.italic.toggle(),c({active:r.italic.isActive()})}},underline:{id:"underline",icon:ve.underline,size:"s",type:"button",editorEvents:{[Ce]:({setState:c})=>{c({active:r.underline.isActive()})}},onClick:({setState:c})=>{r.underline.toggle(),c({active:r.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:ve.strikethrough,size:"s",type:"button",editorEvents:{[Ce]:({setState:c})=>{c({active:r.strikethrough.isActive()})}},onClick:({setState:c})=>{r.strikethrough.toggle(),c({active:r.strikethrough.isActive()})}},image:{id:"image",icon:ve.image,size:"s",type:"button",onClick:()=>r.image.open()},link:{id:"link",icon:ve.link,size:"s",type:"button",editorEvents:{[Ce]:({setState:c})=>{c({active:r.link.isActive(),disabled:s.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,{x:u,y:p,width:h,height:f}=d.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(F.layoutRemove,{id:m}),v=r.link.get(),C={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:u,y:p,w:h,h:f},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:y=>{y.preventDefault();const b=new FormData(y.currentTarget);r.link.create({url:b.get("url"),target:b.get("target")}),g()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(v==null?void 0:v.href)||"",onChange:({value:y,setState:b})=>b({value:y})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(v==null?void 0:v.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:y,setState:b})=>b({value:y})},{type:"row",style:{gap:10,justifyContent:"end"},children:[r.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{r.link.toggle(),g()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(F.layoutToggle,C)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:ve.alignTextLeft},{id:"center",icon:ve.alignTextCenter},{id:"right",icon:ve.alignTextRight},{id:"justify",icon:ve.alignTextJustify}],editorEvents:{[Ce]:({setState:c})=>{c({value:r.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:ve.listBullet,size:"s",type:"button",editorEvents:{[Ce]:({setState:c})=>{c({active:r.listBullet.isActive()})}},onClick:({setState:c})=>{r.listBullet.toggle(),c({active:r.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:ve.listOrdered,size:"s",type:"button",editorEvents:{[Ce]:({setState:c})=>{c({active:r.listOrdered.isActive()})}},onClick:({setState:c})=>{r.listOrdered.toggle(),c({active:r.listOrdered.isActive()})}},heading:{id:"heading",type:"selectField",size:"s",value:"",emptyState:"Heading",options:[{id:"",label:"Normal"},{id:"1",label:"Heading 1"},{id:"2",label:"Heading 2"},{id:"3",label:"Heading 3"},{id:"4",label:"Heading 4"},{id:"5",label:"Heading 5"},{id:"6",label:"Heading 6"}],editorEvents:{[Ce]:({setState:c})=>{c({value:r.heading.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.heading.set({value:c}),s.focus()}},fontSize:{id:"fontSize",type:"selectField",size:"s",value:"",emptyState:"Font size",options:[{id:"8pt",label:"8pt"},{id:"10pt",label:"10pt"},{id:"12pt",label:"12pt"},{id:"14pt",label:"14pt"},{id:"18pt",label:"18pt"},{id:"24pt",label:"24pt"},{id:"36pt",label:"36pt"}],editorEvents:{[Ce]:({setState:c})=>{c({value:r.fontSize.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.fontSize.set({value:c}),s.focus()}}},l=[i.bold,i.italic,i.underline,i.strikethrough,i.image,i.link,i.listBullet,i.listOrdered,i.alignText,i.heading,i.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:r,layouts:i,proseMirror:{view:s},items:l}))||l};class c0{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;Ad(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 d0=function(n,e={}){const t={plugins:i=>i.plugins,...e},o=(i,l)=>{var f,m;const a=((f=t.schema)==null?void 0:f.call(t,{editor:n,schema:Ul}))||Ul,{nodes:c,marks:d}=a,u=sn.fromSchema(a).parse(i),p=Ut.create({doc:u,schema:a,plugins:(m=t.plugins)==null?void 0:m.call(t,{editor:n,Plugin:hn,plugins:[u1(),S1(),r0(a),Kf(),Ts({Tab:$l(1),"Shift-Tab":$l(-1)}),Ts({Enter:Hn(Mc,tm(c.listItem),N1),"Shift-Enter":Hn(Tc,(g,v)=>(v&&v(g.tr.replaceSelectionWith(c.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":Dc,"Mod-y":tr,"Mod-Shift-z":tr,"Mod-b":gt(d.strong),"Mod-i":gt(d.em),"Shift-Tab":nr(c.listItem),Tab:sm(c.listItem)}),Ts($f)]})}),h=new zg({mount:i},{state:p,dispatchTransaction(g){var x;const{state:v}=h,C=v.apply(g),y=!v.doc.eq(C.doc);h.updateState(C);const b=!v.selection.eq(C.selection);y&&(E1(((x=l==null?void 0:l.view)==null?void 0:x.el)||i),h.focus()),(b||y)&&n.trigger(Ce)}});return i.__rteView=h,h.setProps({nodeViews:{image(g){return new c0(g,h,n)}}}),h},s=i=>a0(i,t);n.setCustomRte({toolbar:s,parseContent:!0,async enable(i,l,a){const c=Is(i);if(c)return c;const d=o(i,a);return k1(i,d),$1(d,a),d},disable(i){const l=Is(i);if(l)return T1(i,l),l.destroy(),{forceSync:!0}},getContent(i){const l=Is(i);if(l){const{schema:a,doc:c}=l.state,d=document.createElement("div"),u=zt.fromSchema(a).serializeFragment(c.content);return u.childNodes.forEach(p=>{p.nodeType===Node.ELEMENT_NODE&&p.innerHTML===""&&(p.innerHTML="<br/>")}),d.appendChild(u),A1(d),i.classList.remove("ProseMirror-focused"),d.innerHTML}return i.innerHTML}});const r=P1(n,t);j({editor:n,licenseKey:t.licenseKey,plan:l0,pluginName:i0,cleanup:()=>{n.RichTextEditor.customRte=void 0,r()}})},u0=W(d0),p0="canvasEmptyState",h0=H.startup,f0=function(n,e={}){const t=new WeakMap,o=new WeakMap,s=new WeakMap,r=new Set,i=new WeakMap,l={emptyStates:[],...e},a=(y,b)=>{let x=!1;const{isValid:S}=b;return Array.isArray(S)?x=S.some(w=>y.is(w)):Dt(S)?x=S({component:y,editor:n}):x=y.is(S),x},c=y=>{const b=t.get(y);t.delete(y),b==null||b()},d=y=>{y.views.forEach(b=>c(b)),s.delete(y)},u=y=>{if(!(!y||r.has(y)))try{r.add(y);const b=y.components().length>0,x=s.get(y);if(b&&x)d(y);else if(!b&&!x){const S=i.has(y)?i.get(y):l.emptyStates.find(w=>a(y,w));if(i.set(y,S),!S)return;y.views.forEach(w=>{const M=S.render({editor:n,component:y,componentView:w,mount:k=>{o.set(w,k),s.set(y,!0);const E=w.getChildrenContainer();E==null||E.appendChild(k)},unmount:()=>c(w)});t.set(w,()=>{M==null||M();const k=o.get(w);k==null||k.remove()})})}}finally{r.delete(y)}},p=y=>{s.has(y)&&d(y)},h=({model:y})=>{u(y.getComponent())},f=n.Components.events,m=`${f.update}:components`,g="component:mount",v=n.Canvas.events.frameLoadBody,C=f.removed;n.on(m,u),n.on(g,u),n.on(C,p),n.on(v,h),j({editor:n,licenseKey:l.licenseKey,plan:h0,pluginName:p0,cleanup:()=>{n.off(m,u),n.off(g,u),n.off(C,p),n.off(v,h)}})},m0=W(f0),Xl="canvasFullSize",g0=H.startup,y0=function(n,e={}){const{Canvas:t,Commands:o,Devices:s}=n,r={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...e},{canvasOffsetY:i,canvasOffsetX:l,canvasTransition:a,deviceMaxWidth:c,deviceMinHeigth:d,frameBorderRadius:u,frameTransition:p}=r,h=`${d}px`,f=t.events,m="core:preview",g=`${o.events.stopCommand}${m}`,v=t.getConfig(),C=`${Xl}:disable`,y=s.getAll().map(x=>({...x.attributes}));v.scrollableCanvas=!0,s.getAll().map(x=>{!x.get("width")&&x.set("width",`${c}px`),!x.get("height")&&x.set("height","auto"),!x.get("minHeight")&&x.set("minHeight",h)});const b=x=>{const S="data-gs-plg-full-size",w=document.querySelector(`style[${S}]`);if(x&&w)return w.remove();const M=w||document.createElement("style"),k=t.getZoomMultiplier();M.setAttribute(S,"true"),M.innerHTML=`
|
|
799
|
+
}`,jr=new WeakMap,Zh=(n,e)=>{jr.set(n,e)},Yh=n=>{jr.delete(n)},vs=n=>jr.get(n),ho=n=>{const e=n.target,t=e.closest(".tox"),o=e.matches(".ephox-snooker-resizer-bar");(t||o)&&n.stopPropagation()},ji=n=>{n.stopPropagation(),n.preventDefault()},Xh=(n,e)=>{const t=n.getDoc(),o=n.getWin();if(e!=null&&e.event){const{event:s}=e,{clientX:r,clientY:i}=s;let l;if(t.caretRangeFromPoint)l=t.caretRangeFromPoint(r,i);else if(t.caretPositionFromPoint){const a=t.caretPositionFromPoint(r,i);l=t.createRange(),l==null||l.setStart(a.offsetNode,a.offset)}if(l){const a=o.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(l),n.selection.setRng(l)}}else n.execCommand("SelectAll")},Qh=n=>{var c,d;const{el:e,editor:t,componentView:o}=n,s=t.runCommand(F.getStateTheme),r=o.model,i={target:e,inline:!0,skin:(s==null?void 0:s.theme)===Ma.dark?"oxide-dark":"oxide",menubar:!1,image_advtab:!0,paste_data_images:!0,statusbar:!1,branding:!1,forced_root_block:"div",plugins:"advlist autolink lists link image media table",toolbar_mode:"sliding",toolbar:"bold italic underline strikethrough forecolor backcolor alignleft aligncenter alignright alignjustify link image | fontfamily fontsize bullist numlist outdent indent table"},l=((d=(c=n.pluginOpts)==null?void 0:c.loadConfig)==null?void 0:d.call(c,{config:i,editor:t,componentView:o,component:r}))||{};return{...i,...l}},qi=(n,e=document)=>new Promise((t,o)=>{const s=Array.isArray(n)?[...n]:[n],{head:r}=e,i=l=>{if(l.length){const a=e.createElement("script");a.src=l.shift(),a.onload=i.bind(null,l),a.onerror=o,r.appendChild(a)}else t()};i(s)}),ef=function(n,e={}){const t={cdnScript:"https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",...e},{cdnScript:o}=t,s=n.Canvas.events,r=!t.skipCustomTheme,i="gs-plg-tinymce-studio-theme",l=async(d,u)=>{const p=d.ownerDocument,h=p.defaultView,f=u==null?void 0:u.view;if(!h||!f){console.warn("Missing required data",{win:h,componentView:f});return}const m=Qh({el:d,editor:n,componentView:f,pluginOpts:t}),v=(await h.tinymce.init(m))[0];if(!v)return;const y=(await window.tinymce.init({...m,target:document.createElement("div")}))[0];return v.ui.show(),p.body.addEventListener("mousedown",ho),document.body.addEventListener("mousedown",ho),v.on("Change",()=>jh(d)),v.on("blur",()=>v.ui.show()),v.on("OpenWindow",function(){var x;const b=(x=p.querySelector(".tox-dialog"))==null?void 0:x.closest(".tox");b&&(b==null?void 0:b.ownerDocument)!==document&&(document.body.appendChild(b),v.once("CloseWindow",()=>{b&&b.ownerDocument===document&&p.body.appendChild(b)}))}),d.addEventListener("dragstart",ji,{capture:!0}),n.runCommand(F.setStateContextMenu,{enabled:!1}),Xh(v,u),{rteEditor:v,rteEditorShallow:y}},a=(d,u)=>{d.ownerDocument.body.removeEventListener("mousedown",ho),document.body.removeEventListener("mousedown",ho),d.removeEventListener("dragstart",ji,{capture:!0}),n.runCommand(F.setStateContextMenu,{enabled:!0}),u.rteEditor.destroy(),u.rteEditorShallow.destroy()};n.on(s.frameLoad,async({window:d})=>{const u=d.document;qi(o,u)}),n.onReady(()=>{qi(o,document),r&&zr(i,Jh,{target:document.body})}),n.setCustomRte({parseContent:!0,async enable(d,u,p){const h=vs(d);if(h)return h.rteEditor;const f=await l(d,p);return f&&Zh(d,f),f==null?void 0:f.rteEditor},disable(d){const u=vs(d);u&&(Yh(d),a(d,u))},getContent(d){var p,h;const u=vs(d);return u?(h=(p=u.rteEditor).getContent)==null?void 0:h.call(p):d.innerHTML}});const c=qh(n,t.enableOnClick);G({editor:n,licenseKey:t.licenseKey,plan:Kh,pluginName:Uh,cleanup:()=>{n.RichTextEditor.customRte=void 0,c()}})},tf=_(ef);function X(n){this.content=n}X.prototype={constructor:X,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var o=t&&t!=n?this.remove(t):this,s=o.find(n),r=o.content.slice();return s==-1?r.push(t||n,e):(r[s+1]=e,t&&(r[s]=t)),new X(r)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new X(t)},addToStart:function(n,e){return new X([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new X(t)},addBefore:function(n,e,t){var o=this.remove(e),s=o.content.slice(),r=o.find(n);return s.splice(r==-1?s.length:r,0,e,t),new X(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=X.from(n),n.size?new X(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=X.from(n),n.size?new X(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=X.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}};X.from=function(n){if(n instanceof X)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new X(e)};function lc(n,e,t){for(let o=0;;o++){if(o==n.childCount||o==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(o),r=e.child(o);if(s==r){t+=s.nodeSize;continue}if(!s.sameMarkup(r))return t;if(s.isText&&s.text!=r.text){for(let i=0;s.text[i]==r.text[i];i++)t++;return t}if(s.content.size||r.content.size){let i=lc(s.content,r.content,t+1);if(i!=null)return i}t+=s.nodeSize}}function ac(n,e,t,o){for(let s=n.childCount,r=e.childCount;;){if(s==0||r==0)return s==r?null:{a:t,b:o};let i=n.child(--s),l=e.child(--r),a=i.nodeSize;if(i==l){t-=a,o-=a;continue}if(!i.sameMarkup(l))return{a:t,b:o};if(i.isText&&i.text!=l.text){let c=0,d=Math.min(i.text.length,l.text.length);for(;c<d&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,o--;return{a:t,b:o}}if(i.content.size||l.content.size){let c=ac(i.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,r){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&o(a,s+l,r||null,i)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),o,s+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,o,s){let r="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&o&&(i?i=!1:r+=o),r+=c},0),r}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,o=e.firstChild,s=this.content.slice(),r=0;for(t.isText&&t.sameMarkup(o)&&(s[s.length-1]=t.withText(t.text+o.text),r=1);r<e.content.length;r++)s.push(e.content[r]);return new 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 r=0,i=0;i<t;r++){let l=this.content[r],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),o.push(l),s+=l.nodeSize),i=a}return new 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(),r=this.size+t.nodeSize-o.nodeSize;return s[e]=t,new T(s,r)}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 lc(this,e,t)}findDiffEnd(e,t=this.size,o=e.size){return ac(this,e,t,o)}findIndex(e,t=-1){if(e==0)return fo(0,e);if(e==this.size)return fo(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let o=0,s=0;;o++){let r=this.child(o),i=s+r.nodeSize;if(i>=e)return i==e||t>0?fo(o+1,i):fo(o,s);s=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return 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 r=e[s];o+=r.nodeSize,s&&r.isText&&e[s-1].sameMarkup(r)?(t||(t=e.slice(0,s)),t[t.length-1]=r.withText(t[t.length-1].text+r.text)):t&&t.push(r)}return new 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 Ss={index:0,offset:0};function fo(n,e){return Ss.index=n,Ss.offset=e,Ss}function zo(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(!zo(n[o],e[o]))return!1}else{for(let o in n)if(!(o in e)||!zo(n[o],e[o]))return!1;for(let o in e)if(!(o in n))return!1}return!0}class V{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,o=!1;for(let s=0;s<e.length;s++){let r=e[s];if(this.eq(r))return e;if(this.type.excludes(r.type))t||(t=e.slice(0,s));else{if(r.type.excludes(this.type))return e;!o&&r.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),o=!0),t&&t.push(r)}}return t||(t=e.slice()),o||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&zo(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 V.none;if(e instanceof V)return[e];let t=e.slice();return t.sort((o,s)=>o.type.rank-s.type.rank),t}}V.none=[];class Bo 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=dc(this.content,e+this.openStart,t);return o&&new A(o,this.openStart,this.openEnd)}removeBetween(e,t){return new A(cc(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 r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)o++;for(let r=e.lastChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.lastChild)s++;return new A(e,o,s)}}A.empty=new A(T.empty,0,0);function cc(n,e,t){let{index:o,offset:s}=n.findIndex(e),r=n.maybeChild(o),{index:i,offset:l}=n.findIndex(t);if(s==e||r.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(o!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(o,r.copy(cc(r.content,e-s-1,t-s-1)))}function dc(n,e,t,o){let{index:s,offset:r}=n.findIndex(e),i=n.maybeChild(s);if(r==e||i.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=dc(i.content,e-r-1,t);return l&&n.replaceChild(s,i.copy(l))}function nf(n,e,t){if(t.openStart>n.depth)throw new Bo("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Bo("Inconsistent open depths");return uc(n,e,t,0)}function uc(n,e,t,o){let s=n.index(o),r=n.node(o);if(s==e.index(o)&&o<n.depth-t.openStart){let i=uc(n,e,t,o+1);return r.copy(r.content.replaceChild(s,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==o&&e.depth==o){let i=n.parent,l=i.content;return Mt(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=of(t,n);return Mt(r,hc(n,i,l,e,o))}else return Mt(r,Vo(n,e,o))}function pc(n,e){if(!e.type.compatibleContent(n.type))throw new Bo("Cannot join "+e.type.name+" onto "+n.type.name)}function lr(n,e,t){let o=n.node(t);return pc(o,e.node(t)),o}function Et(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 Nn(n,e,t,o){let s=(e||n).node(t),r=0,i=e?e.index(t):s.childCount;n&&(r=n.index(t),n.depth>t?r++:n.textOffset&&(Et(n.nodeAfter,o),r++));for(let l=r;l<i;l++)Et(s.child(l),o);e&&e.depth==t&&e.textOffset&&Et(e.nodeBefore,o)}function Mt(n,e){return n.type.checkContent(e),n.copy(e)}function hc(n,e,t,o,s){let r=n.depth>s&&lr(n,e,s+1),i=o.depth>s&&lr(t,o,s+1),l=[];return Nn(null,n,s,l),r&&i&&e.index(s)==t.index(s)?(pc(r,i),Et(Mt(r,hc(n,e,t,o,s+1)),l)):(r&&Et(Mt(r,Vo(n,e,s+1)),l),Nn(e,t,s,l),i&&Et(Mt(i,Vo(t,o,s+1)),l)),Nn(o,null,s,l),new T(l)}function Vo(n,e,t){let o=[];if(Nn(null,n,t,o),n.depth>t){let s=lr(n,e,t+1);Et(Mt(s,Vo(n,e,t+1)),o)}return Nn(e,null,t,o),new T(o)}function of(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let r=t-1;r>=0;r--)s=e.node(r).copy(T.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class Wn{constructor(e,t,o){this.pos=e,this.path=t,this.parentOffset=o,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let o=this.pos-this.path[this.path.length-1],s=e.child(t);return o?e.child(t).cut(o):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let o=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let r=0;r<e;r++)s+=o.child(r).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return V.none;if(this.textOffset)return e.child(t).marks;let o=e.maybeChild(t-1),s=e.maybeChild(t);if(!o){let l=o;o=s,s=l}let r=o.marks;for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let o=t.marks,s=e.parent.maybeChild(e.index());for(var r=0;r<o.length;r++)o[r].type.spec.inclusive===!1&&(!s||!o[r].isInSet(s.marks))&&(o=o[r--].removeFromSet(o));return o}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let o=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);o>=0;o--)if(e.pos<=this.end(o)&&(!t||t(this.node(o))))return new Ho(this,e,o);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let o=[],s=0,r=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(r),c=r-a;if(o.push(i,l,s+a),!c||(i=i.child(l),i.isText))break;r=c-1,s+=a+1}return new Wn(t,o,r)}static resolveCached(e,t){let o=Ui.get(e);if(o)for(let r=0;r<o.elts.length;r++){let i=o.elts[r];if(i.pos==t)return i}else Ui.set(e,o=new sf);let s=o.elts[o.i]=Wn.resolve(e,t);return o.i=(o.i+1)%rf,s}}class sf{constructor(){this.elts=[],this.i=0}}const rf=12,Ui=new WeakMap;class Ho{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 lf=Object.create(null);let At=class ar{constructor(e,t,o,s=V.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&&zo(this.attrs,t||e.defaultAttrs||lf)&&V.sameSet(this.marks,o||V.none)}copy(e=null){return e==this.content?this:new ar(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ar(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,o=!1){if(e==t)return A.empty;let s=this.resolve(e),r=this.resolve(t),i=o?0:s.sharedDepth(t),l=s.start(i),c=s.node(i).content.cut(s.pos-l,r.pos-l);return new A(c,s.depth-i,r.depth-i)}replace(e,t,o){return nf(this.resolve(e),this.resolve(t),o)}nodeAt(e){for(let t=this;;){let{index:o,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(o),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:o}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:o}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:o}=this.content.findIndex(e);if(o<e)return{node:this.content.child(t),index:t,offset:o};let s=this.content.child(t-1);return{node:s,index:t-1,offset:o-s.nodeSize}}resolve(e){return Wn.resolveCached(this,e)}resolveNoCache(e){return Wn.resolve(this,e)}rangeHasMark(e,t,o){let s=!1;return t>e&&this.nodesBetween(e,t,r=>(o.isInSet(r.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),fc(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,r=o.childCount){let i=this.contentMatchAt(e).matchFragment(o,s,r),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<r;a++)if(!this.type.allowsMarks(o.child(a).marks))return!1;return!0}canReplaceWith(e,t,o,s){if(s&&!this.type.allowsMarks(s))return!1;let r=this.contentMatchAt(e).matchType(o),i=r&&r.matchFragment(this.content,t);return i?i.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=V.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(!V.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),r=e.nodeType(t.type).create(t.attrs,s,o);return r.type.checkAttrs(r.attrs),r}};At.prototype.text=void 0;class Fo extends At{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):fc(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 Fo(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Fo(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 fc(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Dt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let o=new af(e,t);if(o.next==null)return Dt.empty;let s=mc(o);o.next&&o.err("Unexpected trailing text");let r=mf(ff(s));return gf(r,o),r}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,o=e.childCount){let s=this;for(let r=t;s&&r<o;r++)s=s.matchType(e.child(r).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let o=0;o<e.next.length;o++)if(this.next[t].type==e.next[o].type)return!0;return!1}fillBefore(e,t=!1,o=0){let s=[this];function r(i,l){let a=i.matchFragment(e,o);if(a&&(!t||a.validEnd))return T.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:d,next:u}=i.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(u)==-1){s.push(u);let p=r(u,l.concat(d));if(p)return p}}return null}return r(this,[])}findWrapping(e){for(let o=0;o<this.wrapCache.length;o+=2)if(this.wrapCache[o]==e)return this.wrapCache[o+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),o=[{match:this,type:null,via:null}];for(;o.length;){let s=o.shift(),r=s.match;if(r.matchType(e)){let i=[];for(let l=s;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<r.next.length;i++){let{type:l,next:a}=r.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(o.push({match:l.contentMatch,type:l,via:s}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(o){e.push(o);for(let s=0;s<o.next.length;s++)e.indexOf(o.next[s].next)==-1&&t(o.next[s].next)}return t(this),e.map((o,s)=>{let r=s+(o.validEnd?"*":" ")+" ";for(let i=0;i<o.next.length;i++)r+=(i?", ":"")+o.next[i].type.name+"->"+e.indexOf(o.next[i].next);return r}).join(`
|
|
800
|
+
`)}}Dt.empty=new Dt(!0);class af{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 mc(n){let e=[];do e.push(cf(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function cf(n){let e=[];do e.push(df(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function df(n){let e=hf(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=uf(n,e);else break;return e}function Ki(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function uf(n,e){let t=Ki(n),o=t;return n.eat(",")&&(n.next!="}"?o=Ki(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 r in t){let i=t[r];i.isInGroup(e)&&s.push(i)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function hf(n){if(n.eat("(")){let e=mc(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 ff(n){let e=[[]];return s(r(n,0),t()),e;function t(){return e.push([])-1}function o(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function s(i,l){i.forEach(a=>a.to=l)}function r(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(r(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=r(i.exprs[a],l);if(a==i.exprs.length-1)return c;s(c,l=t())}else if(i.type=="star"){let a=t();return o(l,a),s(r(i.expr,a),a),[o(a)]}else if(i.type=="plus"){let a=t();return s(r(i.expr,l),a),s(r(i.expr,a),a),[o(a)]}else{if(i.type=="opt")return[o(l)].concat(r(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let d=t();s(r(i.expr,a),d),a=d}if(i.max==-1)s(r(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let d=t();o(a,d),s(r(i.expr,a),d),a=d}return[o(a)]}else{if(i.type=="name")return[o(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function gc(n,e){return e-n}function Ji(n,e){let t=[];return o(e),t.sort(gc);function o(s){let r=n[s];if(r.length==1&&!r[0].term)return o(r[0].to);t.push(s);for(let i=0;i<r.length;i++){let{term:l,to:a}=r[i];!l&&t.indexOf(a)==-1&&o(a)}}}function mf(n){let e=Object.create(null);return t(Ji(n,0));function t(o){let s=[];o.forEach(i=>{n[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<s.length;d++)s[d][0]==l&&(c=s[d][1]);Ji(n,a).forEach(d=>{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let r=e[o.join(",")]=new Dt(o.indexOf(n.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(gc);r.next.push({type:s[i][0],next:e[l.join(",")]||t(l)})}return r}}function gf(n,e){for(let t=0,o=[n];t<o.length;t++){let s=o[t],r=!s.validEnd,i=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];i.push(a.name),r&&!(a.isText||a.hasRequiredAttrs())&&(r=!1),o.indexOf(c)==-1&&o.push(c)}r&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function yc(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 bc(n,e){let t=Object.create(null);for(let o in n){let s=e&&e[o];if(s===void 0){let r=n[o];if(r.hasDefault)s=r.default;else throw new RangeError("No value supplied for attribute "+o)}t[o]=s}return t}function vc(n,e,t,o){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let r=n[s];r.validate&&r.validate(e[s])}}function Sc(n,e){let t=Object.create(null);if(e)for(let o in e)t[o]=new bf(n,o,e[o]);return t}let Zi=class xc{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=Sc(e,o.attrs),this.defaultAttrs=yc(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==Dt.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:bc(this.attrs,e)}create(e=null,t,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new At(this,this.computeAttrs(e),T.from(t),V.setFrom(o))}createChecked(e=null,t,o){return t=T.from(t),this.checkContent(t),new At(this,this.computeAttrs(e),t,V.setFrom(o))}createAndFill(e=null,t,o){if(e=this.computeAttrs(e),t=T.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let s=this.contentMatch.matchFragment(t),r=s&&s.fillBefore(T.empty,!0);return r?new At(this,e,t.append(r),V.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){vc(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:V.none:e}static compile(e,t){let o=Object.create(null);e.forEach((r,i)=>o[r]=new xc(r,t,i));let s=t.spec.topNode||"doc";if(!o[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let r in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};function yf(n,e,t){let o=t.split("|");return s=>{let r=s===null?"null":typeof s;if(o.indexOf(r)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${n}, got ${r}`)}}class bf{constructor(e,t,o){this.hasDefault=Object.prototype.hasOwnProperty.call(o,"default"),this.default=o.default,this.validate=typeof o.validate=="string"?yf(e,t,o.validate):o.validate}get isRequired(){return!this.hasDefault}}class ss{constructor(e,t,o,s){this.name=e,this.rank=t,this.schema=o,this.spec=s,this.attrs=Sc(e,s.attrs),this.excluded=null;let r=yc(this.attrs);this.instance=r?new V(this,r):null}create(e=null){return!e&&this.instance?this.instance:new V(this,bc(this.attrs,e))}static compile(e,t){let o=Object.create(null),s=0;return e.forEach((r,i)=>o[r]=new ss(r,s++,t,i)),o}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){vc(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class vf{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=X.from(e.nodes),t.marks=X.from(e.marks||{}),this.nodes=Zi.compile(this.spec.nodes,this),this.marks=ss.compile(this.spec.marks,this);let o=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let r=this.nodes[s],i=r.spec.content||"",l=r.spec.marks;if(r.contentMatch=o[i]||(o[i]=Dt.parse(i,this.nodes)),r.inlineContent=r.contentMatch.inlineContent,r.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!r.isInline||!r.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=r}r.markSet=l=="_"?null:l?Yi(this,l.split(" ")):l==""||!r.inlineContent?[]:null}for(let s in this.marks){let r=this.marks[s],i=r.spec.excludes;r.excluded=i==null?[r]:i==""?[]:Yi(this,i.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,o,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Zi){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 Fo(o,o.defaultAttrs,e,V.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return At.fromJSON(this,e)}markFromJSON(e){return V.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Yi(n,e){let t=[];for(let o=0;o<e.length;o++){let s=e[o],r=n.marks[s],i=r;if(r)t.push(r);else for(let l in n.marks){let a=n.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return t}function Sf(n){return n.tag!=null}function xf(n){return n.style!=null}class cn{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let o=this.matchedStyles=[];t.forEach(s=>{if(Sf(s))this.tags.push(s);else if(xf(s)){let r=/[^=]*/.exec(s.style)[0];o.indexOf(r)<0&&o.push(r),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let r=e.nodes[s.node];return r.contentMatch.matchType(r)})}parse(e,t={}){let o=new Qi(this,t,!1);return o.addAll(e,V.none,t.from,t.to),o.finish()}parseSlice(e,t={}){let o=new Qi(this,t,!0);return o.addAll(e,V.none,t.from,t.to),A.maxOpen(o.finish())}matchTag(e,t,o){for(let s=o?this.tags.indexOf(o)+1:0;s<this.tags.length;s++){let r=this.tags[s];if(kf(e,r.tag)&&(r.namespace===void 0||e.namespaceURI==r.namespace)&&(!r.context||t.matchesContext(r.context))){if(r.getAttrs){let i=r.getAttrs(e);if(i===!1)continue;r.attrs=i||void 0}return r}}}matchStyle(e,t,o,s){for(let r=s?this.styles.indexOf(s)+1:0;r<this.styles.length;r++){let i=this.styles[r],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!o.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function o(s){let r=s.priority==null?50:s.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<r)break}t.splice(i,0,s)}for(let s in e.marks){let r=e.marks[s].spec.parseDOM;r&&r.forEach(i=>{o(i=el(i)),i.mark||i.ignore||i.clearMark||(i.mark=s)})}for(let s in e.nodes){let r=e.nodes[s].spec.parseDOM;r&&r.forEach(i=>{o(i=el(i)),i.node||i.ignore||i.mark||(i.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new cn(e,cn.schemaRules(e)))}}const wc={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},wf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Cc={ol:!0,ul:!0},_o=1,Go=2,On=4;function Xi(n,e,t){return e!=null?(e?_o:0)|(e==="full"?Go:0):n&&n.whitespace=="pre"?_o|Go:t&~On}class mo{constructor(e,t,o,s,r,i){this.type=e,this.attrs=t,this.marks=o,this.solid=s,this.options=i,this.content=[],this.activeMarks=V.none,this.match=r||(i&On?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&_o)){let o=this.content[this.content.length-1],s;if(o&&o.isText&&(s=/[ \t\r\n\u000c]+$/.exec(o.text))){let r=o;o.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-s[0].length))}}let t=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&&!wc.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Qi{constructor(e,t,o){this.parser=e,this.options=t,this.isOpen=o,this.open=0;let s=t.topNode,r,i=Xi(null,t.preserveWhitespace,0)|(o?On:0);s?r=new mo(s.type,s.attrs,V.none,!0,t.topMatch||s.type.contentMatch,i):o?r=new mo(null,null,V.none,!0,null,i):r=new mo(e.schema.topNodeType,null,V.none,!0,null,i),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let o=e.nodeValue,s=this.top;if(s.options&Go||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(o)){if(s.options&_o)s.options&Go?o=o.replace(/\r\n?/g,`
|
|
801
|
+
`):o=o.replace(/\r?\n|\r/g," ");else if(o=o.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(o)&&this.open==this.nodes.length-1){let r=s.content[s.content.length-1],i=e.previousSibling;(!r||i&&i.nodeName=="BR"||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(o=o.slice(1))}o&&this.insertNode(this.parser.schema.text(o),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,o){let s=e.nodeName.toLowerCase(),r;Cc.hasOwnProperty(s)&&this.parser.normalizeLists&&Cf(e);let i=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(r=this.parser.matchTag(e,this,o));if(i?i.ignore:wf.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!i||i.skip||i.closeParent){i&&i.closeParent?this.open=Math.max(0,this.open-1):i&&i.skip.nodeType&&(e=i.skip);let l,a=this.top,c=this.needsBlock;if(wc.hasOwnProperty(s))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),l=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);return}let d=i&&i.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),l&&this.sync(a),this.needsBlock=c}else{let l=this.readStyles(e,t);l&&this.addElementByRule(e,i,l,i.consuming===!1?r:void 0)}}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
802
|
+
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let o=e.style;if(o&&o.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let r=this.parser.matchedStyles[s],i=o.getPropertyValue(r);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(r,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,o,s){let r,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),o)||this.leafFallback(e,o);else{let a=this.enter(i,t.attrs||null,o,t.preserveWhitespace);a&&(r=!0,o=a)}else{let a=this.parser.schema.marks[t.mark];o=o.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(s)this.addElement(e,o,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,o));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,o),this.findAround(e,a,!1)}r&&this.sync(l)&&this.open--}addAll(e,t,o,s){let r=o||0;for(let i=o?e.childNodes[o]:e.firstChild,l=s==null?null:e.childNodes[s];i!=l;i=i.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(i,t);this.findAtPoint(e,r)}findPlace(e,t){let o,s;for(let r=this.open;r>=0;r--){let i=this.nodes[r],l=i.findWrapping(e);if(l&&(!o||o.length>l.length)&&(o=l,s=i,!l.length)||i.solid)break}if(!o)return null;this.sync(s);for(let r=0;r<o.length;r++)t=this.enterInner(o[r],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let o=this.findPlace(e,t);if(o){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let r=V.none;for(let i of o.concat(e.marks))(s.type?s.type.allowsMarkType(i.type):tl(i.type,e.type))&&(r=i.addToSet(r));return s.content.push(e.mark(r)),!0}return!1}enter(e,t,o,s){let r=this.findPlace(e.create(t),o);return r&&(r=this.enterInner(e,t,o,!0,s)),r}enterInner(e,t,o,s=!1,r){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=Xi(e,r,i.options);i.options&On&&i.content.length==0&&(l|=On);let a=V.none;return o=o.filter(c=>(i.type?i.type.allowsMarkType(c.type):tl(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new mo(e,t,a,s,null,l)),this.open++,o}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let o=this.nodes[t].content;for(let s=o.length-1;s>=0;s--)e+=o[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let o=0;o<this.find.length;o++)this.find[o].node==e&&this.find[o].offset==t&&(this.find[o].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,o){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(o?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),o=this.options.context,s=!this.isOpen&&(!o||o.parent.type==this.nodes[0].type),r=-(o?o.depth+1:0)+(s?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=r;a--)if(i(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:o&&a>=r?o.node(a-r).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(o&&o.isTextblock&&o.defaultAttrs)return o}for(let t in this.parser.schema.nodes){let o=this.parser.schema.nodes[t];if(o.isTextblock&&o.defaultAttrs)return o}}}function Cf(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&Cc.hasOwnProperty(o)&&t?(t.appendChild(e),e=t):o=="li"?t=e:o&&(t=null)}}function kf(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function el(n){let e={};for(let t in n)e[t]=n[t];return e}function tl(n,e){let t=e.schema.nodes;for(let o in t){let s=t[o];if(!s.allowsMarkType(n))continue;let r=[],i=l=>{r.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||r.indexOf(d)<0&&i(d))return!0}};if(i(s.contentMatch))return!0}}class Vt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},o){o||(o=xs(t).createDocumentFragment());let s=o,r=[];return e.forEach(i=>{if(r.length||i.marks.length){let l=0,a=0;for(;l<r.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(r[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<r.length;)s=r.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],d=this.serializeMark(c,i.isInline,t);d&&(r.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(i,t))}),o}serializeNodeInner(e,t){let{dom:o,contentDOM:s}=Eo(xs(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return o}serializeNode(e,t={}){let o=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let r=this.serializeMark(e.marks[s],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(o),o=r.dom)}return o}serializeMark(e,t,o={}){let s=this.marks[e.type.name];return s&&Eo(xs(o),s(e,t),null,e.attrs)}static renderSpec(e,t,o=null,s){return Eo(e,t,o,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Vt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=nl(e.nodes);return t.text||(t.text=o=>o.text),t}static marksFromSchema(e){return nl(e.marks)}}function nl(n){let e={};for(let t in n){let o=n[t].spec.toDOM;o&&(e[t]=o)}return e}function xs(n){return n.document||window.document}const ol=new WeakMap;function Tf(n){let e=ol.get(n);return e===void 0&&ol.set(n,e=Ef(n)),e}function Ef(n){let e=null;function t(o){if(o&&typeof o=="object")if(Array.isArray(o))if(typeof o[0]=="string")e||(e=[]),e.push(o);else for(let s=0;s<o.length;s++)t(o[s]);else for(let s in o)t(o[s])}return t(n),e}function Eo(n,e,t,o){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],r;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(o&&(r=Tf(o))&&r.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=s.indexOf(" ");i>0&&(t=s.slice(0,i),s=s.slice(i+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let p=u.indexOf(" ");p>0?a.setAttributeNS(u.slice(0,p),u.slice(p+1),c[u]):a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let p=e[u];if(p===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:f}=Eo(n,p,t,o);if(a.appendChild(h),f){if(l)throw new RangeError("Multiple content holes");l=f}}}return{dom:a,contentDOM:l}}const kc=65535,Tc=Math.pow(2,16);function Mf(n,e){return n+e*Tc}function sl(n){return n&kc}function Af(n){return(n-(n&kc))/Tc}const Ec=1,Mc=2,Mo=4,Ac=8;class cr{constructor(e,t,o){this.pos=e,this.delInfo=t,this.recover=o}get deleted(){return(this.delInfo&Ac)>0}get deletedBefore(){return(this.delInfo&(Ec|Mo))>0}get deletedAfter(){return(this.delInfo&(Mc|Mo))>0}get deletedAcross(){return(this.delInfo&Mo)>0}}class me{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&me.empty)return me.empty}recover(e){let t=0,o=sl(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+Af(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,o){let s=0,r=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+r],d=this.ranges[l+i],u=a+c;if(e<=u){let p=c?e==a?-1:e==u?1:t:t,h=a+s+(p<0?0:d);if(o)return h;let f=e==(t<0?a:u)?null:Mf(l/3,e-a),m=e==a?Mc:e==u?Ec:Mo;return(t<0?e!=a:e!=u)&&(m|=Ac),new cr(h,m,f)}s+=d-c}return o?e+s:new cr(e+s,0,null)}touches(e,t){let o=0,s=sl(t),r=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+r],d=a+c;if(e<=d&&l==s*3)return!0;o+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,o=this.inverted?1:2;for(let s=0,r=0;s<this.ranges.length;s+=3){let i=this.ranges[s],l=i-(this.inverted?r:0),a=i+(this.inverted?0:r),c=this.ranges[s+t],d=this.ranges[s+o];e(l,l+c,a,a+d),r+=d-c}}invert(){return new me(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?me.empty:new me(e<0?[0,-e,0]:[0,0,e])}}me.empty=new me([]);class nn{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 nn(this.maps,this.mirror,e,t)}copy(){return new nn(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 nn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let o=this.from;o<this.to;o++)e=this.maps[o].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,o){let s=0;for(let r=this.from;r<this.to;r++){let i=this.maps[r],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(r);if(a!=null&&a>r&&a<this.to){r=a,e=this.maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return o?e:new cr(e,s,null)}}const ws=Object.create(null);class ie{getMap(){return me.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let o=ws[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 ws)throw new RangeError("Duplicate use of step JSON ID "+e);return ws[e]=t,t.prototype.jsonID=e,t}}class K{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new K(e,null)}static fail(e){return new K(null,e)}static fromReplace(e,t,o,s){try{return K.ok(e.replace(t,o,s))}catch(r){if(r instanceof Bo)return K.fail(r.message);throw r}}}function qr(n,e,t){let o=[];for(let s=0;s<n.childCount;s++){let r=n.child(s);r.content.size&&(r=r.copy(qr(r.content,e,r))),r.isInline&&(r=e(r,t,s)),o.push(r)}return T.fromArray(o)}class st extends ie{constructor(e,t,o){super(),this.from=e,this.to=t,this.mark=o}apply(e){let t=e.slice(this.from,this.to),o=e.resolve(this.from),s=o.node(o.sharedDepth(this.to)),r=new A(qr(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,r)}invert(){return new De(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 st(t.pos,o.pos,this.mark)}merge(e){return e instanceof st&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new st(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 st(t.from,t.to,e.markFromJSON(t.mark))}}ie.jsonID("addMark",st);class De extends ie{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(qr(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 st(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 De(t.pos,o.pos,this.mark)}merge(e){return e instanceof De&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new De(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 De(t.from,t.to,e.markFromJSON(t.mark))}}ie.jsonID("removeMark",De);class rt extends ie{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 rt(this.pos,t.marks[s]);return new rt(this.pos,this.mark)}}return new dn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new rt(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 rt(t.pos,e.markFromJSON(t.mark))}}ie.jsonID("addNodeMark",rt);class dn extends ie{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 rt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new dn(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 dn(t.pos,e.markFromJSON(t.mark))}}ie.jsonID("removeNodeMark",dn);class se extends ie{constructor(e,t,o,s=!1){super(),this.from=e,this.to=t,this.slice=o,this.structure=s}apply(e){return this.structure&&dr(e,this.from,this.to)?K.fail("Structure replace would overwrite content"):K.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new me([this.from,this.to-this.from,this.slice.size])}invert(e){return new se(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deletedAcross&&o.deletedAcross?null:new se(t.pos,Math.max(t.pos,o.pos),this.slice)}merge(e){if(!(e instanceof se)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?A.empty:new A(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new se(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?A.empty:new A(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new se(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new se(t.from,t.to,A.fromJSON(e,t.slice),!!t.structure)}}ie.jsonID("replace",se);class te extends ie{constructor(e,t,o,s,r,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=o,this.gapTo=s,this.slice=r,this.insert=i,this.structure=l}apply(e){if(this.structure&&(dr(e,this.from,this.gapFrom)||dr(e,this.gapTo,this.to)))return K.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return K.fail("Gap is not a flat range");let o=this.slice.insertAt(this.insert,t.content);return o?K.fromReplace(e,this.from,this.to,o):K.fail("Content does not fit in gap")}getMap(){return new me([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new te(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),r=this.to==this.gapTo?o.pos:e.map(this.gapTo,1);return t.deletedAcross&&o.deletedAcross||s<t.pos||r>o.pos?null:new te(t.pos,o.pos,s,r,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new te(t.from,t.to,t.gapFrom,t.gapTo,A.fromJSON(e,t.slice),t.insert,!!t.structure)}}ie.jsonID("replaceAround",te);function dr(n,e,t){let o=n.resolve(e),s=t-e,r=o.depth;for(;s>0&&r>0&&o.indexAfter(r)==o.node(r).childCount;)r--,s--;if(s>0){let i=o.node(r).maybeChild(o.indexAfter(r));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}function Pf(n,e,t,o){let s=[],r=[],i,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!o.isInSet(u)&&d.type.allowsMarkType(o.type)){let p=Math.max(c,e),h=Math.min(c+a.nodeSize,t),f=o.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(f)||(i&&i.to==p&&i.mark.eq(u[m])?i.to=h:s.push(i=new De(p,h,u[m])));l&&l.to==p?l.to=h:r.push(l=new st(p,h,o))}}),s.forEach(a=>n.step(a)),r.forEach(a=>n.step(a))}function If(n,e,t,o){let s=[],r=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;r++;let a=null;if(o instanceof ss){let c=i.marks,d;for(;d=o.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else o?o.isInSet(i.marks)&&(a=[o]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],p;for(let h=0;h<s.length;h++){let f=s[h];f.step==r-1&&u.eq(s[h].style)&&(p=f)}p?(p.to=c,p.step=r):s.push({style:u,from:Math.max(l,e),to:c,step:r})}}}),s.forEach(i=>n.step(new De(i.from,i.to,i.style)))}function Ur(n,e,t,o=t.contentMatch,s=!0){let r=n.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<r.childCount;a++){let c=r.child(a),d=l+c.nodeSize,u=o.matchType(c.type);if(!u)i.push(new se(l,d,A.empty));else{o=u;for(let p=0;p<c.marks.length;p++)t.allowsMarkType(c.marks[p].type)||n.step(new De(l,d,c.marks[p]));if(s&&c.isText&&t.whitespace!="pre"){let p,h=/\r?\n|\r/g,f;for(;p=h.exec(c.text);)f||(f=new A(T.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new se(l+p.index,l+p.index+p[0].length,f))}}l=d}if(!o.validEnd){let a=o.fillBefore(T.empty,!0);n.replace(l,l,new A(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function Nf(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function rs(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let o=n.depth;;--o){let s=n.$from.node(o),r=n.$from.index(o),i=n.$to.indexAfter(o);if(o<n.depth&&s.canReplace(r,i,t))return o;if(o==0||s.type.spec.isolating||!Nf(s,r,i))break}return null}function Of(n,e,t){let{$from:o,$to:s,depth:r}=e,i=o.before(r+1),l=s.after(r+1),a=i,c=l,d=T.empty,u=0;for(let f=r,m=!1;f>t;f--)m||o.index(f)>0?(m=!0,d=T.from(o.node(f).copy(d)),u++):a--;let p=T.empty,h=0;for(let f=r,m=!1;f>t;f--)m||s.after(f+1)<s.end(f)?(m=!0,p=T.from(s.node(f).copy(p)),h++):c++;n.step(new te(a,c,i,l,new A(d.append(p),u,h),d.size-u,!0))}function Pc(n,e,t=null,o=n){let s=Rf(n,e),r=s&&Df(o,e);return r?s.map(rl).concat({type:e,attrs:t}).concat(r.map(rl)):null}function rl(n){return{type:n,attrs:null}}function Rf(n,e){let{parent:t,startIndex:o,endIndex:s}=n,r=t.contentMatchAt(o).findWrapping(e);if(!r)return null;let i=r.length?r[0]:e;return t.canReplaceWith(o,s,i)?r:null}function Df(n,e){let{parent:t,startIndex:o,endIndex:s}=n,r=t.child(o),i=e.contentMatch.findWrapping(r.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=o;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function Lf(n,e,t){let o=T.empty;for(let i=t.length-1;i>=0;i--){if(o.size){let l=t[i].type.contentMatch.matchFragment(o);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=T.from(t[i].type.create(t[i].attrs,o))}let s=e.start,r=e.end;n.step(new te(s,r,s,r,new A(o,0,0),t.length,!0))}function $f(n,e,t,o,s){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let r=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{let a=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(o,a)&&zf(n.doc,n.mapping.slice(r).map(l),o)){let c=null;if(o.schema.linebreakReplacement){let h=o.whitespace=="pre",f=!!o.contentMatch.matchType(o.schema.linebreakReplacement);h&&!f?c=!1:!h&&f&&(c=!0)}c===!1&&Nc(n,i,l,r),Ur(n,n.mapping.slice(r).map(l,1),o,void 0,c===null);let d=n.mapping.slice(r),u=d.map(l,1),p=d.map(l+i.nodeSize,1);return n.step(new te(u,p,u+1,p-1,new A(T.from(o.create(a,null,i.marks)),0,0),1,!0)),c===!0&&Ic(n,i,l,r),!1}})}function Ic(n,e,t,o){e.forEach((s,r)=>{if(s.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(s.text);){let a=n.mapping.slice(o).map(t+1+r+i.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Nc(n,e,t,o){e.forEach((s,r)=>{if(s.type==s.type.schema.linebreakReplacement){let i=n.mapping.slice(o).map(t+1+r);n.replaceWith(i,i+1,e.type.schema.text(`
|
|
803
|
+
`))}})}function zf(n,e,t){let o=n.resolve(e),s=o.index();return o.parent.canReplaceWith(s,s+1,t)}function Bf(n,e,t,o,s){let r=n.doc.nodeAt(e);if(!r)throw new RangeError("No node at given position");t||(t=r.type);let i=t.create(o,null,s||r.marks);if(r.isLeaf)return n.replaceWith(e,e+r.nodeSize,i);if(!t.validContent(r.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new te(e,e+r.nodeSize,e+1,e+r.nodeSize-1,new A(T.from(i),0,0),1,!0))}function on(n,e,t=1,o){let s=n.resolve(e),r=s.depth-t,i=o&&o[o.length-1]||s.parent;if(r<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!i.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=t-2;c>r;c--,d--){let u=s.node(c),p=s.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(p,u.childCount),f=o&&o[d+1];f&&(h=h.replaceChild(0,f.type.create(f.attrs)));let m=o&&o[d]||u;if(!u.canReplace(p+1,u.childCount)||!m.type.validContent(h))return!1}let l=s.indexAfter(r),a=o&&o[0];return s.node(r).canReplaceWith(l,l,a?a.type:s.node(r+1).type)}function Vf(n,e,t=1,o){let s=n.doc.resolve(e),r=T.empty,i=T.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){r=T.from(s.node(l).copy(r));let d=o&&o[c];i=T.from(d?d.type.create(d.attrs,i):s.node(l).copy(i))}n.step(new se(e,e,new A(r.append(i),t,t),!0))}function is(n,e){let t=n.resolve(e),o=t.index();return Ff(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(o,o+1)}function Hf(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:o}=n.type.schema;for(let s=0;s<e.childCount;s++){let r=e.child(s),i=r.type==o?n.type.schema.nodes.text:r.type;if(t=t.matchType(i),!t||!n.type.allowsMarks(r.marks))return!1}return t.validEnd}function Ff(n,e){return!!(n&&e&&!n.isLeaf&&Hf(n,e))}function _f(n,e,t){let o=null,{linebreakReplacement:s}=n.doc.type.schema,r=n.doc.resolve(e-t),i=r.node().type;if(s&&i.inlineContent){let d=i.whitespace=="pre",u=!!i.contentMatch.matchType(s);d&&!u?o=!1:!d&&u&&(o=!0)}let l=n.steps.length;if(o===!1){let d=n.doc.resolve(e+t);Nc(n,d.node(),d.before(),l)}i.inlineContent&&Ur(n,e+t-1,i,r.node().contentMatchAt(r.index()),o==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new se(c,a.map(e+t,-1),A.empty,!0)),o===!0){let d=n.doc.resolve(c);Ic(n,d.node(),d.before(),n.steps.length)}return n}function Gf(n,e,t){let o=n.resolve(e);if(o.parent.canReplaceWith(o.index(),o.index(),t))return e;if(o.parentOffset==0)for(let s=o.depth-1;s>=0;s--){let r=o.index(s);if(o.node(s).canReplaceWith(r,r,t))return o.before(s+1);if(r>0)return null}if(o.parentOffset==o.parent.content.size)for(let s=o.depth-1;s>=0;s--){let r=o.indexAfter(s);if(o.node(s).canReplaceWith(r,r,t))return o.after(s+1);if(r<o.node(s).childCount)return null}return null}function Wf(n,e,t){let o=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let r=0;r<t.openStart;r++)s=s.firstChild.content;for(let r=1;r<=(t.openStart==0&&t.size?2:1);r++)for(let i=o.depth;i>=0;i--){let l=i==o.depth?0:o.pos<=(o.start(i+1)+o.end(i+1))/2?-1:1,a=o.index(i)+(l>0?1:0),c=o.node(i),d=!1;if(r==1)d=c.canReplace(a,a,s);else{let u=c.contentMatchAt(a).findWrapping(s.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?o.pos:l<0?o.before(i+1):o.after(i+1)}return null}function Kr(n,e,t=e,o=A.empty){if(e==t&&!o.size)return null;let s=n.resolve(e),r=n.resolve(t);return Oc(s,r,o)?new se(e,t,o):new jf(s,r,o).fit()}function Oc(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class jf{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 r=e.node(s);this.frontier.push({type:r.type,match:r.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=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 r=this.placed,i=o.depth,l=s.depth;for(;i&&l&&r.childCount==1;)r=r.firstChild.content,i--,l--;let a=new A(r,i,l);return e>-1?new te(o.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||o.pos!=this.$to.pos?new se(o.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,o=0,s=this.unplaced.openEnd;o<e;o++){let r=t.firstChild;if(t.childCount>1&&(s=0),r.type.spec.isolating&&s<=o){e=o;break}t=r.content}for(let t=1;t<=2;t++)for(let o=t==1?e:this.unplaced.openStart;o>=0;o--){let s,r=null;o?(r=Cs(this.unplaced.content,o-1).firstChild,s=r.content):s=this.unplaced.content;let i=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(i?c.matchType(i.type)||(u=c.fillBefore(T.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:o,frontierDepth:l,parent:r,inject:u};if(t==2&&i&&(d=c.findWrapping(i.type)))return{sliceDepth:o,frontierDepth:l,parent:r,wrap:d};if(r&&c.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:o}=this.unplaced,s=Cs(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=Cs(e,t);if(s.childCount<=1&&t>0){let r=e.size-t<=t+s.size;this.unplaced=new A(Tn(e,t-1,1),t-1,r?t-1:o)}else this.unplaced=new A(Tn(e,t,1),t,o)}placeNodes({sliceDepth:e,frontierDepth:t,parent:o,inject:s,wrap:r}){for(;this.depth>t;)this.closeFrontierNode();if(r)for(let m=0;m<r.length;m++)this.openFrontierNode(r[m]);let i=this.unplaced,l=o?o.content:i.content,a=i.openStart-e,c=0,d=[],{match:u,type:p}=this.frontier[t];if(s){for(let m=0;m<s.childCount;m++)d.push(s.child(m));u=u.matchFragment(s)}let h=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let m=l.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(u=g,d.push(Rc(m.mark(p.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let f=c==l.childCount;f||(h=-1),this.placed=En(this.placed,t,T.from(d)),this.frontier[t].match=u,f&&h<0&&o&&o.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let v=g.lastChild;this.frontier.push({type:v.type,match:v.contentMatchAt(v.childCount)}),g=v.content}this.unplaced=f?e==0?A.empty:new A(Tn(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new A(Tn(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!ks(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:o}=this.$to,s=this.$to.after(o);for(;o>1&&s==this.$to.end(--o);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:o,type:s}=this.frontier[t],r=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=ks(e,t,s,o,r);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=ks(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:i,move:r?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=En(this.placed,t.depth,t.fit)),e=t.move;for(let o=t.depth+1;o<=e.depth;o++){let s=e.node(o),r=s.type.contentMatch.fillBefore(s.content,!0,e.index(o));this.openFrontierNode(s.type,s.attrs,r)}return e}openFrontierNode(e,t=null,o){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=En(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=En(this.placed,this.frontier.length,t))}}function Tn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Tn(n.firstChild.content,e-1,t)))}function En(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(En(n.lastChild.content,e-1,t)))}function Cs(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Rc(n,e,t){if(e<=0)return n;let o=n.content;return e>1&&(o=o.replaceChild(0,Rc(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 ks(n,e,t,o,s){let r=n.node(e),i=s?n.indexAfter(e):n.index(e);if(i==r.childCount&&!t.compatibleContent(r.type))return null;let l=o.fillBefore(r.content,!0,i);return l&&!qf(t,r.content,i)?l:null}function qf(n,e,t){for(let o=t;o<e.childCount;o++)if(!n.allowsMarks(e.child(o).marks))return!0;return!1}function Uf(n){return n.spec.defining||n.spec.definingForContent}function Kf(n,e,t,o){if(!o.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),r=n.doc.resolve(t);if(Oc(s,r,o))return n.step(new se(e,t,o));let i=Lc(s,n.doc.resolve(t));i[i.length-1]==0&&i.pop();let l=-(s.depth+1);i.unshift(l);for(let p=s.depth,h=s.pos-1;p>0;p--,h--){let f=s.node(p).type.spec;if(f.defining||f.definingAsContext||f.isolating)break;i.indexOf(p)>-1?l=p:s.before(p)==h&&i.splice(1,0,-p)}let a=i.indexOf(l),c=[],d=o.openStart;for(let p=o.content,h=0;;h++){let f=p.firstChild;if(c.push(f),h==o.openStart)break;p=f.content}for(let p=d-1;p>=0;p--){let h=c[p],f=Uf(h.type);if(f&&!h.sameMarkup(s.node(Math.abs(l)-1)))d=p;else if(f||!h.type.isTextblock)break}for(let p=o.openStart;p>=0;p--){let h=(p+d+1)%(o.openStart+1),f=c[h];if(f)for(let m=0;m<i.length;m++){let g=i[(m+a)%i.length],v=!0;g<0&&(v=!1,g=-g);let 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),v?r.after(g):t,new A(Dc(o.content,0,o.openStart,h),h,o.openEnd))}}let u=n.steps.length;for(let p=i.length-1;p>=0&&(n.replace(e,t,o),!(n.steps.length>u));p--){let h=i[p];h<0||(e=s.before(h),t=r.after(h))}}function Dc(n,e,t,o,s){if(e<t){let r=n.firstChild;n=n.replaceChild(0,r.copy(Dc(r.content,e+1,t,o,r)))}if(e>o){let r=s.contentMatchAt(0),i=r.fillBefore(n).append(n);n=i.append(r.matchFragment(i).fillBefore(T.empty,!0))}return n}function Jf(n,e,t,o){if(!o.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=Gf(n.doc,e,o.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new A(T.from(o),0,0))}function Zf(n,e,t){let o=n.doc.resolve(e),s=n.doc.resolve(t),r=Lc(o,s);for(let i=0;i<r.length;i++){let l=r[i],a=i==r.length-1;if(a&&l==0||o.node(l).type.contentMatch.validEnd)return n.delete(o.start(l),s.end(l));if(l>0&&(a||o.node(l-1).canReplace(o.index(l-1),s.indexAfter(l-1))))return n.delete(o.before(l),s.after(l))}for(let i=1;i<=o.depth&&i<=s.depth;i++)if(e-o.start(i)==o.depth-i&&t>o.end(i)&&s.end(i)-t!=s.depth-i&&o.start(i-1)==s.start(i-1)&&o.node(i-1).canReplace(o.index(i-1),s.index(i-1)))return n.delete(o.before(i),t);n.delete(e,t)}function Lc(n,e){let t=[],o=Math.min(n.depth,e.depth);for(let s=o;s>=0;s--){let r=n.start(s);if(r<n.pos-(n.depth-s)||e.end(s)>e.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(r==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==r-1)&&t.push(s)}return t}class sn extends ie{constructor(e,t,o){super(),this.pos=e,this.attr=t,this.value=o}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at attribute step's position");let o=Object.create(null);for(let r in t.attrs)o[r]=t.attrs[r];o[this.attr]=this.value;let s=t.type.create(o,null,t.marks);return K.fromReplace(e,this.pos,this.pos+1,new A(T.from(s),0,t.isLeaf?0:1))}getMap(){return me.empty}invert(e){return new sn(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 sn(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 sn(t.pos,t.attr,t.value)}}ie.jsonID("attr",sn);class jn extends ie{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let o=e.type.create(t,e.content,e.marks);return K.ok(o)}getMap(){return me.empty}invert(e){return new jn(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 jn(t.attr,t.value)}}ie.jsonID("docAttr",jn);let un=class extends Error{};un=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};un.prototype=Object.create(Error.prototype);un.prototype.constructor=un;un.prototype.name="TransformError";class $c{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new nn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new un(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=Kr(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 Kf(this,e,t,o),this}replaceRangeWith(e,t,o){return Jf(this,e,t,o),this}deleteRange(e,t){return Zf(this,e,t),this}lift(e,t){return Of(this,e,t),this}join(e,t=1){return _f(this,e,t),this}wrap(e,t){return Lf(this,e,t),this}setBlockType(e,t=e,o,s=null){return $f(this,e,t,o,s),this}setNodeMarkup(e,t,o=null,s){return Bf(this,e,t,o,s),this}setNodeAttribute(e,t,o){return this.step(new sn(e,t,o)),this}setDocAttribute(e,t){return this.step(new jn(e,t)),this}addNodeMark(e,t){return this.step(new rt(e,t)),this}removeNodeMark(e,t){if(!(t instanceof V)){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 dn(e,t)),this}split(e,t=1,o){return Vf(this,e,t,o),this}addMark(e,t,o){return Pf(this,e,t,o),this}removeMark(e,t,o){return If(this,e,t,o),this}clearIncompatible(e,t,o){return Ur(this,e,t,o),this}}const Ts=Object.create(null);class L{constructor(e,t,o){this.$anchor=e,this.$head=t,this.ranges=o||[new zc(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=A.empty){let o=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=o,o=o.lastChild;let r=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],d=e.mapping.slice(r);e.replaceRange(d.map(a.pos),d.map(c.pos),l?A.empty:t),l==0&&al(e,r,(o?o.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let o=e.steps.length,s=this.ranges;for(let r=0;r<s.length;r++){let{$from:i,$to:l}=s[r],a=e.mapping.slice(o),c=a.map(i.pos),d=a.map(l.pos);r?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),al(e,o,t.isInline?-1:1))}}static findFrom(e,t,o=!1){let s=e.parent.inlineContent?new $(e):Ut(e.node(0),e.parent,e.pos,e.index(),t,o);if(s)return s;for(let r=e.depth-1;r>=0;r--){let i=t<0?Ut(e.node(0),e.node(r),e.before(r+1),e.index(r),t,o):Ut(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,o);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ye(e.node(0))}static atStart(e){return Ut(e,e,0,0,1)||new ye(e)}static atEnd(e){return Ut(e,e,e.content.size,e.childCount,-1)||new ye(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let o=Ts[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 Ts)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ts[e]=t,t.prototype.jsonID=e,t}getBookmark(){return $.between(this.$anchor,this.$head).getBookmark()}}L.prototype.visible=!0;class zc{constructor(e,t){this.$from=e,this.$to=t}}let il=!1;function ll(n){!il&&!n.parent.inlineContent&&(il=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class $ extends L{constructor(e,t=e){ll(e),ll(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 ls(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 r=L.findFrom(t,o,!0)||L.findFrom(t,-o,!0);if(r)t=r.$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 ls{constructor(e,t){this.anchor=e,this.head=t}map(e){return new ls(e.map(this.anchor),e.map(this.head))}resolve(e){return $.between(e.resolve(this.anchor),e.resolve(this.head))}}class R 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),r=e.resolve(s);return o?L.near(r):new R(r)}content(){return new A(T.from(this.node),0,0)}eq(e){return e instanceof R&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Jr(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new R(e.resolve(t.anchor))}static create(e,t){return new R(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}R.prototype.visible=!1;L.jsonID("node",R);class Jr{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:o}=e.mapResult(this.anchor);return t?new ls(o,o):new Jr(o)}resolve(e){let t=e.resolve(this.anchor),o=t.nodeAfter;return o&&R.isSelectable(o)?new R(t):L.near(t)}}class ye 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 ye(e)}map(e){return new ye(e)}eq(e){return e instanceof ye}getBookmark(){return Yf}}L.jsonID("all",ye);const Yf={map(){return this},resolve(n){return new ye(n)}};function Ut(n,e,t,o,s,r=!1){if(e.inlineContent)return $.create(n,t);for(let i=o-(s>0?0:1);s>0?i<e.childCount:i>=0;i+=s){let l=e.child(i);if(l.isAtom){if(!r&&R.isSelectable(l))return R.create(n,t-(s<0?l.nodeSize:0))}else{let a=Ut(n,l,t+s,s<0?l.childCount:0,s,r);if(a)return a}t+=l.nodeSize*s}return null}function al(n,e,t){let o=n.steps.length-1;if(o<e)return;let s=n.steps[o];if(!(s instanceof se||s instanceof te))return;let r=n.mapping.maps[o],i;r.forEach((l,a,c,d)=>{i==null&&(i=d)}),n.setSelection(L.near(n.doc.resolve(i),t))}const cl=1,go=2,dl=4;class Xf extends $c{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|cl)&~go,this.storedMarks=null,this}get selectionSet(){return(this.updated&cl)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=go,this}ensureMarks(e){return V.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&go)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~go,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)||V.none))),o.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,o){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(o==null&&(o=t),o=o??t,!e)return this.deleteRange(t,o);let r=this.storedMarks;if(!r){let i=this.doc.resolve(t);r=o==t?i.marks():i.marksAcross(this.doc.resolve(o))}return this.replaceRangeWith(t,o,s.text(e,r)),this.selection.empty||this.setSelection(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|=dl,this}get scrolledIntoView(){return(this.updated&dl)>0}}function ul(n,e){return!e||!n?n:n.bind(e)}class Mn{constructor(e,t,o){this.name=e,this.init=ul(t.init,o),this.apply=ul(t.apply,o)}}const Qf=[new Mn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Mn("selection",{init(n,e){return n.selection||L.atStart(e.doc)},apply(n){return n.selection}}),new Mn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,o){return o.selection.$cursor?n.storedMarks:null}}),new Mn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Es{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Qf.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 Mn(o.key,o.spec.state,o))})}}class Xt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let o=0;o<this.config.plugins.length;o++)if(o!=t){let s=this.config.plugins[o];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],o=this.applyInner(e),s=null;for(;;){let r=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=s?s[i].n:0,c=s?s[i].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,o);if(d&&o.filterTransaction(d,i)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let u=0;u<this.config.plugins.length;u++)s.push(u<i?{state:o,n:t.length}:{state:this,n:0})}t.push(d),o=o.applyInner(d),r=!0}s&&(s[i]={state:o,n:t.length})}}if(!r)return{state:o,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Xt(this.config),o=this.config.fields;for(let s=0;s<o.length;s++){let r=o[s];t[r.name]=r.apply(e,this[r.name],this,t)}return t}get tr(){return new Xf(this)}static create(e){let t=new Es(e.doc?e.doc.type.schema:e.schema,e.plugins),o=new Xt(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 Es(this.schema,e.plugins),o=t.fields,s=new Xt(t);for(let r=0;r<o.length;r++){let i=o[r].name;s[i]=this.hasOwnProperty(i)?this[i]:o[r].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(o=>o.toJSON())),e&&typeof e=="object")for(let o in e){if(o=="doc"||o=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[o],r=s.spec.state;r&&r.toJSON&&(t[o]=r.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,o){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Es(e.schema,e.plugins),r=new Xt(s);return s.fields.forEach(i=>{if(i.name=="doc")r.doc=At.fromJSON(e.schema,t.doc);else if(i.name=="selection")r.selection=L.fromJSON(r.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(r.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(o)for(let l in o){let a=o[l],c=a.spec.state;if(a.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){r[i.name]=c.fromJSON.call(a,e,t[l],r);return}}r[i.name]=i.init(e,r)}}),r}}function Bc(n,e,t){for(let o in n){let s=n[o];s instanceof Function?s=s.bind(e):o=="handleDOMEvents"&&(s=Bc(s,e,{})),t[o]=s}return t}class yn{constructor(e){this.spec=e,this.props={},e.props&&Bc(e.props,this,this.props),this.key=e.key?e.key.key:Vc("plugin")}getState(e){return e[this.key]}}const Ms=Object.create(null);function Vc(n){return n in Ms?n+"$"+ ++Ms[n]:(Ms[n]=0,n+"$")}class Qn{constructor(e="key"){this.key=Vc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Hc=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function em(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const tm=(n,e,t)=>{let o=em(n,t);if(!o)return!1;let s=Fc(o);if(!s){let i=o.blockRange(),l=i&&rs(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let r=s.nodeBefore;if(Uc(n,s,e,-1))return!0;if(o.parent.content.size==0&&(pn(r,"end")||R.isSelectable(r)))for(let i=o.depth;;i--){let l=Kr(n.doc,o.before(i),o.after(i),A.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(pn(r,"end")?L.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):R.create(a.doc,s.pos-r.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||o.node(i-1).childCount>1)break}return r.isAtom&&s.depth==o.depth-1?(e&&e(n.tr.delete(s.pos-r.nodeSize,s.pos).scrollIntoView()),!0):!1};function pn(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 nm=(n,e,t)=>{let{$head:o,empty:s}=n.selection,r=o;if(!s)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):o.parentOffset>0)return!1;r=Fc(o)}let i=r&&r.nodeBefore;return!i||!R.isSelectable(i)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,r.pos-i.nodeSize)).scrollIntoView()),!0)};function Fc(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 om(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const sm=(n,e,t)=>{let o=om(n,t);if(!o)return!1;let s=_c(o);if(!s)return!1;let r=s.nodeAfter;if(Uc(n,s,e,1))return!0;if(o.parent.content.size==0&&(pn(r,"start")||R.isSelectable(r))){let i=Kr(n.doc,o.before(),o.after(),A.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(pn(r,"start")?L.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):R.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return r.isAtom&&s.depth==o.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+r.nodeSize).scrollIntoView()),!0):!1},rm=(n,e,t)=>{let{$head:o,empty:s}=n.selection,r=o;if(!s)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):o.parentOffset<o.parent.content.size)return!1;r=_c(o)}let i=r&&r.nodeAfter;return!i||!R.isSelectable(i)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,r.pos)).scrollIntoView()),!0)};function _c(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 im=(n,e)=>{let{$head:t,$anchor:o}=n.selection;return!t.parent.type.spec.code||!t.sameParent(o)?!1:(e&&e(n.tr.insertText(`
|
|
804
|
+
`).scrollIntoView()),!0)};function Zr(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 Gc=(n,e)=>{let{$head:t,$anchor:o}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(o))return!1;let s=t.node(-1),r=t.indexAfter(-1),i=Zr(s.contentMatchAt(r));if(!i||!s.canReplaceWith(r,r,i))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,i.createAndFill());a.setSelection(L.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},lm=(n,e)=>{let t=n.selection,{$from:o,$to:s}=t;if(t instanceof ye||o.parent.inlineContent||s.parent.inlineContent)return!1;let r=Zr(s.parent.contentMatchAt(s.indexAfter()));if(!r||!r.isTextblock)return!1;if(e){let i=(!o.parentOffset&&s.index()<s.parent.childCount?o:s).pos,l=n.tr.insert(i,r.createAndFill());l.setSelection($.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},Wc=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let r=t.before();if(on(n.doc,r))return e&&e(n.tr.split(r).scrollIntoView()),!0}let o=t.blockRange(),s=o&&rs(o);return s==null?!1:(e&&e(n.tr.lift(o,s).scrollIntoView()),!0)};function jc(n){return(e,t)=>{let{$from:o,$to:s}=e.selection;if(e.selection instanceof R&&e.selection.node.isBlock)return!o.parentOffset||!on(e.doc,o.pos)?!1:(t&&t(e.tr.split(o.pos).scrollIntoView()),!0);if(!o.depth)return!1;let r=[],i,l,a=!1,c=!1;for(let h=o.depth;;h--)if(o.node(h).isBlock){a=o.end(h)==o.pos+(o.depth-h),c=o.start(h)==o.pos-(o.depth-h),l=Zr(o.node(h-1).contentMatchAt(o.indexAfter(h-1)));let m=n&&n(s.parent,a,o);r.unshift(m||(a&&l?{type:l}:null)),i=h;break}else{if(h==1)return!1;r.unshift(null)}let d=e.tr;(e.selection instanceof $||e.selection instanceof ye)&&d.deleteSelection();let u=d.mapping.map(o.pos),p=on(d.doc,u,r.length,r);if(p||(r[0]=l?{type:l}:null,p=on(d.doc,u,r.length,r)),d.split(u,r.length,r),!a&&c&&o.node(i).type!=l){let h=d.mapping.map(o.before(i)),f=d.doc.resolve(h);l&&o.node(i-1).canReplaceWith(f.index(),f.index()+1,l)&&d.setNodeMarkup(d.mapping.map(o.before(i)),l)}return t&&t(d.scrollIntoView()),!0}}const am=jc(),qc=(n,e)=>(e&&e(n.tr.setSelection(new ye(n.doc))),!0);function cm(n,e,t){let o=e.nodeBefore,s=e.nodeAfter,r=e.index();return!o||!s||!o.type.compatibleContent(s.type)?!1:!o.content.size&&e.parent.canReplace(r-1,r)?(t&&t(n.tr.delete(e.pos-o.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(r,r+1)||!(s.isTextblock||is(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Uc(n,e,t,o){let s=e.nodeBefore,r=e.nodeAfter,i,l,a=s.type.spec.isolating||r.type.spec.isolating;if(!a&&cm(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=s.contentMatchAt(s.childCount)).findWrapping(r.type))&&l.matchType(i[0]||r.type).validEnd){if(t){let h=e.pos+r.nodeSize,f=T.empty;for(let v=i.length-1;v>=0;v--)f=T.from(i[v].create(null,f));f=T.from(s.copy(f));let m=n.tr.step(new te(e.pos-1,h,e.pos,h,new A(f,1,0),i.length,!0)),g=m.doc.resolve(h+2*i.length);g.nodeAfter&&g.nodeAfter.type==s.type&&is(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=r.type.spec.isolating||o>0&&a?null:L.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),p=u&&rs(u);if(p!=null&&p>=e.depth)return t&&t(n.tr.lift(u,p).scrollIntoView()),!0;if(c&&pn(r,"start",!0)&&pn(s,"end")){let h=s,f=[];for(;f.push(h),!h.isTextblock;)h=h.lastChild;let m=r,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let v=T.empty;for(let y=f.length-1;y>=0;y--)v=T.from(f[y].copy(v));let C=n.tr.step(new te(e.pos-f.length,e.pos+r.nodeSize,e.pos+g,e.pos+r.nodeSize-g,new A(v,f.length,0),0,!0));t(C.scrollIntoView())}return!0}}return!1}function Kc(n){return function(e,t){let o=e.selection,s=n<0?o.$from:o.$to,r=s.depth;for(;s.node(r).isInline;){if(!r)return!1;r--}return s.node(r).isTextblock?(t&&t(e.tr.setSelection($.create(e.doc,n<0?s.start(r):s.end(r)))),!0):!1}}const dm=Kc(-1),um=Kc(1);function pm(n,e=null){return function(t,o){let s=!1;for(let r=0;r<t.selection.ranges.length&&!s;r++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[r];t.doc.nodesBetween(i,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)s=!0;else{let d=t.doc.resolve(c),u=d.index();s=d.parent.canReplaceWith(u,u+1,n)}})}if(!s)return!1;if(o){let r=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];r.setBlockType(l,a,n,e)}o(r.scrollIntoView())}return!0}}function hm(n,e,t,o){for(let s=0;s<e.length;s++){let{$from:r,$to:i}=e[s],l=r.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(r.pos,i.pos,(a,c)=>{if(l||!o)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function vt(n,e=null,t){let o=t!==!1;return function(s,r){let{empty:i,$cursor:l,ranges:a}=s.selection;if(i&&!l||!hm(s.doc,a,n,o))return!1;if(r)if(l)n.isInSet(s.storedMarks||l.marks())?r(s.tr.removeStoredMark(n)):r(s.tr.addStoredMark(n.create(e)));else{let c,d=s.tr;c=!a.some(u=>s.doc.rangeHasMark(u.$from.pos,u.$to.pos,n));for(let u=0;u<a.length;u++){let{$from:p,$to:h}=a[u];if(!c)d.removeMark(p.pos,h.pos,n);else{let f=p.pos,m=h.pos,g=p.nodeAfter,v=h.nodeBefore,C=g&&g.isText?/^\s*/.exec(g.text)[0].length:0,y=v&&v.isText?/\s*$/.exec(v.text)[0].length:0;f+C<m&&(f+=C,m-=y),d.addMark(f,m,n.create(e))}}r(d.scrollIntoView())}return!0}}function qn(...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 As=qn(Hc,tm,nm),pl=qn(Hc,sm,rm);const je={Enter:qn(im,lm,Wc,am),"Mod-Enter":Gc,Backspace:As,"Mod-Backspace":As,"Shift-Backspace":As,Delete:pl,"Mod-Delete":pl,"Mod-a":qc},Jc={"Ctrl-h":je.Backspace,"Alt-Backspace":je["Mod-Backspace"],"Ctrl-d":je.Delete,"Ctrl-Alt-Backspace":je["Mod-Delete"],"Alt-Delete":je["Mod-Delete"],"Alt-d":je["Mod-Delete"],"Ctrl-a":dm,"Ctrl-e":um};for(let n in je)Jc[n]=je[n];const fm=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,mm=fm?Jc:je;var Wo=200,Z=function(){};Z.prototype.append=function(e){return e.length?(e=Z.from(e),!this.length&&e||e.length<Wo&&this.leafAppend(e)||this.length<Wo&&e.leafPrepend(this)||this.appendInner(e)):this};Z.prototype.prepend=function(e){return e.length?Z.from(e).append(this):this};Z.prototype.appendInner=function(e){return new gm(this,e)};Z.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Z.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};Z.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Z.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)};Z.prototype.map=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length);var s=[];return this.forEach(function(r,i){return s.push(e(r,i))},t,o),s};Z.from=function(e){return e instanceof Z?e:e&&e.length?new Zc(e):Z.empty};var Zc=function(n){function e(o){n.call(this),this.values=o}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,r){return s==0&&r==this.length?this:new e(this.values.slice(s,r))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,r,i,l){for(var a=r;a<i;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,r,i,l){for(var a=r-1;a>=i;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Wo)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Wo)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}(Z);Z.empty=new Zc([]);var gm=function(n){function e(t,o){n.call(this),this.left=t,this.right=o,this.length=t.length+o.length,this.depth=Math.max(t.depth,o.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(o){return o<this.left.length?this.left.get(o):this.right.get(o-this.left.length)},e.prototype.forEachInner=function(o,s,r,i){var l=this.left.length;if(s<l&&this.left.forEachInner(o,s,Math.min(r,l),i)===!1||r>l&&this.right.forEachInner(o,Math.max(s-l,0),Math.min(this.length,r)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,r,i){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(o,s-l,Math.max(r,l)-l,i+l)===!1||r<l&&this.left.forEachInvertedInner(o,Math.min(s,l),r,i)===!1)return!1},e.prototype.sliceInner=function(o,s){if(o==0&&s==this.length)return this;var r=this.left.length;return s<=r?this.left.slice(o,s):o>=r?this.right.slice(o-r,s-r):this.left.slice(o,r).append(this.right.slice(0,s-r))},e.prototype.leafAppend=function(o){var s=this.right.leafAppend(o);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(o){var s=this.left.leafPrepend(o);if(s)return new e(s,this.right)},e.prototype.appendInner=function(o){return this.left.depth>=Math.max(this.right.depth,o.depth)+1?new e(this.left,new e(this.right,o)):new e(this,o)},e}(Z);const ym=500;class Ee{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}let s,r;t&&(s=this.remapping(o,this.items.length),r=s.maps.length);let i=e.tr,l,a,c=[],d=[];return this.items.forEach((u,p)=>{if(!u.step){s||(s=this.remapping(o,p+1),r=s.maps.length),r--,d.push(u);return}if(s){d.push(new Ie(u.map));let h=u.step.map(s.slice(r)),f;h&&i.maybeStep(h).doc&&(f=i.mapping.maps[i.mapping.maps.length-1],c.push(new Ie(f,void 0,void 0,c.length+d.length))),r--,f&&s.appendMap(f,r)}else i.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(r)):u.selection,a=new Ee(this.items.slice(0,o).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,o,s){let r=[],i=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),p=new Ie(e.mapping.maps[d],u,t),h;(h=a&&a.merge(p))&&(p=h,d?r.pop():l=l.slice(0,l.length-1)),r.push(p),t&&(i++,t=void 0),s||(a=p)}let c=i-o.depth;return c>vm&&(l=bm(l,c),i-=c),new Ee(l.append(r),i)}remapping(e,t){let o=new nn;return this.items.forEach((s,r)=>{let i=s.mirrorOffset!=null&&r-s.mirrorOffset>=e?o.maps.length-s.mirrorOffset:void 0;o.appendMap(s.map,i)},e,t),o}addMaps(e){return this.eventCount==0?this:new Ee(this.items.append(e.map(t=>new Ie(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let o=[],s=Math.max(0,this.items.length-t),r=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},s);let a=t;this.items.forEach(p=>{let h=r.getMirror(--a);if(h==null)return;i=Math.min(i,h);let f=r.maps[h];if(p.step){let m=e.steps[h].invert(e.docs[h]),g=p.selection&&p.selection.map(r.slice(a+1,h));g&&l++,o.push(new Ie(f,m,g))}else o.push(new Ie(f))},s);let c=[];for(let p=t;p<i;p++)c.push(new Ie(r.maps[p]));let d=this.items.slice(0,s).append(c).append(o),u=new Ee(d,l);return u.emptyItemCount()>ym&&(u=u.compress(this.items.length-o.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),o=t.maps.length,s=[],r=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&r++;else if(i.step){let a=i.step.map(t.slice(o)),c=a&&a.getMap();if(o--,c&&t.appendMap(c,o),a){let d=i.selection&&i.selection.map(t.slice(o));d&&r++;let u=new Ie(c.invert(),a,d),p,h=s.length-1;(p=s.length&&s[h].merge(u))?s[h]=p:s.push(u)}}else i.map&&o--},this.items.length,0),new Ee(Z.from(s.reverse()),r)}}Ee.empty=new Ee(Z.empty,0);function bm(n,e){let t;return n.forEach((o,s)=>{if(o.selection&&e--==0)return t=s,!1}),n.slice(t)}class Ie{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 Ie(t.getMap().invert(),t,this.selection)}}}class Xe{constructor(e,t,o,s,r){this.done=e,this.undone=t,this.prevRanges=o,this.prevTime=s,this.prevComposition=r}}const vm=20;function Sm(n,e,t,o){let s=t.getMeta(Pt),r;if(s)return s.historyState;t.getMeta(Cm)&&(n=new Xe(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(Pt))return i.getMeta(Pt).redo?new Xe(n.done.addTransform(t,void 0,o,Ao(e)),n.undone,hl(t.mapping.maps),n.prevTime,n.prevComposition):new Xe(n.done,n.undone.addTransform(t,void 0,o,Ao(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-o.newGroupDelay||!xm(t,n.prevRanges)),c=i?Ps(n.prevRanges,t.mapping):hl(t.mapping.maps);return new Xe(n.done.addTransform(t,a?e.selection.getBookmark():void 0,o,Ao(e)),Ee.empty,c,t.time,l??n.prevComposition)}else return(r=t.getMeta("rebased"))?new Xe(n.done.rebased(t,r),n.undone.rebased(t,r),Ps(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Xe(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Ps(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function xm(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((o,s)=>{for(let r=0;r<e.length;r+=2)o<=e[r+1]&&s>=e[r]&&(t=!0)}),t}function hl(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((o,s,r,i)=>e.push(r,i));return e}function Ps(n,e){if(!n)return null;let t=[];for(let o=0;o<n.length;o+=2){let s=e.map(n[o],1),r=e.map(n[o+1],-1);s<=r&&t.push(s,r)}return t}function wm(n,e,t){let o=Ao(e),s=Pt.get(e).spec.config,r=(t?n.undone:n.done).popEvent(e,o);if(!r)return null;let i=r.selection.resolve(r.transform.doc),l=(t?n.done:n.undone).addTransform(r.transform,e.selection.getBookmark(),s,o),a=new Xe(t?l:r.remaining,t?r.remaining:l,null,0,-1);return r.transform.setSelection(i).setMeta(Pt,{redo:t,historyState:a})}let Is=!1,fl=null;function Ao(n){let e=n.plugins;if(fl!=e){Is=!1,fl=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Is=!0;break}}return Is}const Pt=new Qn("history"),Cm=new Qn("closeHistory");function km(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new yn({key:Pt,state:{init(){return new Xe(Ee.empty,Ee.empty,null,0,-1)},apply(e,t,o){return Sm(t,o,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let o=t.inputType,s=o=="historyUndo"?Xc:o=="historyRedo"?ur:null;return s?(t.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function Yc(n,e){return(t,o)=>{let s=Pt.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(o){let r=wm(s,t,n);r&&o(e?r.scrollIntoView():r)}return!0}}const Xc=Yc(!1,!0),ur=Yc(!0,!0);var ut={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:"'"},jo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Tm=typeof navigator<"u"&&/Mac/.test(navigator.platform),Em=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Q=0;Q<10;Q++)ut[48+Q]=ut[96+Q]=String(Q);for(var Q=1;Q<=24;Q++)ut[Q+111]="F"+Q;for(var Q=65;Q<=90;Q++)ut[Q]=String.fromCharCode(Q+32),jo[Q]=String.fromCharCode(Q);for(var Ns in ut)jo.hasOwnProperty(Ns)||(jo[Ns]=ut[Ns]);function Mm(n){var e=Tm&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Em&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?jo:ut)[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 Am=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Pm(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let o,s,r,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))o=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))r=!0;else if(/^mod$/i.test(a))Am?i=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return o&&(t="Alt-"+t),s&&(t="Ctrl-"+t),i&&(t="Meta-"+t),r&&(t="Shift-"+t),t}function Im(n){let e=Object.create(null);for(let t in n)e[Pm(t)]=n[t];return e}function Os(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 Rs(n){return new yn({props:{handleKeyDown:Qc(n)}})}function Qc(n){let e=Im(n);return function(t,o){let s=Mm(o),r,i=e[Os(s,o)];if(i&&i(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(o.shiftKey){let l=e[Os(s,o,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((o.shiftKey||o.altKey||o.metaKey||s.charCodeAt(0)>127)&&(r=ut[o.keyCode])&&r!=s){let l=e[Os(r,o)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}function ml(n,e=null){return function(t,o){let{$from:s,$to:r}=t.selection,i=s.blockRange(r),l=!1,a=i;if(!i)return!1;if(i.depth>=2&&s.node(i.depth-1).type.compatibleContent(n)&&i.startIndex==0){if(s.index(i.depth-1)==0)return!1;let d=t.doc.resolve(i.start-2);a=new Ho(d,d,i.depth),i.endIndex<i.parent.childCount&&(i=new Ho(s,t.doc.resolve(r.end(i.depth)),i.depth)),l=!0}let c=Pc(a,n,e,i);return c?(o&&o(Nm(t.tr,i,c,l,n).scrollIntoView()),!0):!1}}function Nm(n,e,t,o,s){let r=T.empty;for(let d=t.length-1;d>=0;d--)r=T.from(t[d].type.create(t[d].attrs,r));n.step(new te(e.start-(o?2:0),e.end,e.start,e.end,new A(r,0,0),t.length,!0));let i=0;for(let d=0;d<t.length;d++)t[d].type==s&&(i=d+1);let l=t.length-i,a=e.start+t.length-(o?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,p=!0;d<u;d++,p=!1)!p&&on(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function Om(n,e){return function(t,o){let{$from:s,$to:r,node:i}=t.selection;if(i&&i.isBlock||s.depth<2||!s.sameParent(r))return!1;let l=s.node(-1);if(l.type!=n)return!1;if(s.parent.content.size==0&&s.node(-1).childCount==s.indexAfter(-1)){if(s.depth==3||s.node(-3).type!=n||s.index(-2)!=s.node(-2).childCount-1)return!1;if(o){let u=T.empty,p=s.index(-1)?1:s.index(-2)?2:3;for(let v=s.depth-p;v>=s.depth-3;v--)u=T.from(s.node(v).copy(u));let h=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3;u=u.append(T.from(n.createAndFill()));let f=s.before(s.depth-(p-1)),m=t.tr.replace(f,s.after(-h),new A(u,4-p,0)),g=-1;m.doc.nodesBetween(f,m.doc.content.size,(v,C)=>{if(g>-1)return!1;v.isTextblock&&v.content.size==0&&(g=C+1)}),g>-1&&m.setSelection(L.near(m.doc.resolve(g))),o(m.scrollIntoView())}return!0}let a=r.pos==s.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(s.pos,r.pos),d=a?[null,{type:a}]:void 0;return on(c.doc,s.pos,2,d)?(o&&o(c.split(s.pos,2,d).scrollIntoView()),!0):!1}}function pr(n){return function(e,t){let{$from:o,$to:s}=e.selection,r=o.blockRange(s,i=>i.childCount>0&&i.firstChild.type==n);return r?t?o.node(r.depth-1).type==n?Rm(e,t,n,r):Dm(e,t,r):!0:!1}}function Rm(n,e,t,o){let s=n.tr,r=o.end,i=o.$to.end(o.depth);r<i&&(s.step(new te(r-1,i,r,i,new A(T.from(t.create(null,o.parent.copy())),1,0),1,!0)),o=new Ho(s.doc.resolve(o.$from.pos),s.doc.resolve(i),o.depth));const l=rs(o);if(l==null)return!1;s.lift(o,l);let a=s.mapping.map(r,-1)-1;return is(s.doc,a)&&s.join(a),e(s.scrollIntoView()),!0}function Dm(n,e,t){let o=n.tr,s=t.parent;for(let h=t.end,f=t.endIndex-1,m=t.startIndex;f>m;f--)h-=s.child(f).nodeSize,o.delete(h-1,h+1);let r=o.doc.resolve(t.start),i=r.nodeAfter;if(o.mapping.map(t.end)!=t.start+r.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=r.node(-1),d=r.index(-1);if(!c.canReplace(d+(l?0:1),d+1,i.content.append(a?T.empty:T.from(s))))return!1;let u=r.pos,p=u+i.nodeSize;return o.step(new te(u-(l?1:0),p+(a?1:0),u+1,p-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 Lm(n){return function(e,t){let{$from:o,$to:s}=e.selection,r=o.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!r)return!1;let i=r.startIndex;if(i==0)return!1;let l=r.parent,a=l.child(i-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=T.from(c?n.create():null),u=new A(T.from(n.create(null,T.from(l.type.create(null,d)))),c?3:1,0),p=r.start,h=r.end;t(e.tr.step(new te(p-(c?3:1),h,p,h,u,1,!0)).scrollIntoView())}return!0}}const ee=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Un=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let hr=null;const We=function(n,e,t){let o=hr||(hr=document.createRange());return o.setEnd(n,t??n.nodeValue.length),o.setStart(n,e||0),o},$m=function(){hr=null},Lt=function(n,e,t,o){return t&&(gl(n,e,t,o,-1)||gl(n,e,t,o,1))},zm=/^(img|br|input|textarea|hr)$/i;function gl(n,e,t,o,s){for(;;){if(n==t&&e==o)return!0;if(e==(s<0?0:xe(n))){let r=n.parentNode;if(!r||r.nodeType!=1||eo(n)||zm.test(n.nodeName)||n.contentEditable=="false")return!1;e=ee(n)+(s<0?0:1),n=r}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.contentEditable=="false")return!1;e=s<0?xe(n):0}else return!1}}function xe(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Bm(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=xe(n)}else if(n.parentNode&&!eo(n))e=ee(n),n=n.parentNode;else return null}}function Vm(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&&!eo(n))e=ee(n)+1,n=n.parentNode;else return null}}function Hm(n,e,t){for(let o=e==0,s=e==xe(n);o||s;){if(n==t)return!0;let r=ee(n);if(n=n.parentNode,!n)return!1;o=o&&r==0,s=s&&r==xe(n)}}function eo(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 as=function(n){return n.focusNode&&Lt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function St(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Fm(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function _m(n,e,t){if(n.caretPositionFromPoint)try{let o=n.caretPositionFromPoint(e,t);if(o)return{node:o.offsetNode,offset:Math.min(xe(o.offsetNode),o.offset)}}catch{}if(n.caretRangeFromPoint){let o=n.caretRangeFromPoint(e,t);if(o)return{node:o.startContainer,offset:Math.min(xe(o.startContainer),o.startOffset)}}}const ze=typeof navigator<"u"?navigator:null,yl=typeof document<"u"?document:null,ht=ze&&ze.userAgent||"",fr=/Edge\/(\d+)/.exec(ht),ed=/MSIE \d/.exec(ht),mr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ht),he=!!(ed||mr||fr),at=ed?document.documentMode:mr?+mr[1]:fr?+fr[1]:0,Ae=!he&&/gecko\/(\d+)/i.test(ht);Ae&&+(/Firefox\/(\d+)/.exec(ht)||[0,0])[1];const gr=!he&&/Chrome\/(\d+)/.exec(ht),re=!!gr,td=gr?+gr[1]:0,ae=!he&&!!ze&&/Apple Computer/.test(ze.vendor),hn=ae&&(/Mobile\/\w+/.test(ht)||!!ze&&ze.maxTouchPoints>2),Se=hn||(ze?/Mac/.test(ze.platform):!1),Gm=ze?/Win/.test(ze.platform):!1,Te=/Android \d/.test(ht),to=!!yl&&"webkitFontSmoothing"in yl.documentElement.style,Wm=to?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function jm(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function He(n,e){return typeof n=="number"?n:n[e]}function qm(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 bl(n,e,t){let o=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,r=n.dom.ownerDocument;for(let i=t||n.dom;i;i=Un(i)){if(i.nodeType!=1)continue;let l=i,a=l==r.body,c=a?jm(r):qm(l),d=0,u=0;if(e.top<c.top+He(o,"top")?u=-(c.top-e.top+He(s,"top")):e.bottom>c.bottom-He(o,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+He(s,"top")-c.top:e.bottom-c.bottom+He(s,"bottom")),e.left<c.left+He(o,"left")?d=-(c.left-e.left+He(s,"left")):e.right>c.right-He(o,"right")&&(d=e.right-c.right+He(s,"right")),d||u)if(a)r.defaultView.scrollBy(d,u);else{let p=l.scrollLeft,h=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let f=l.scrollLeft-p,m=l.scrollTop-h;e={left:e.left-f,top:e.top-m,right:e.right-f,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(i).position))break}}function Um(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),o,s;for(let r=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=n.root.elementFromPoint(r,i);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){o=l,s=a.top;break}}return{refDOM:o,refTop:s,stack:nd(n.dom)}}function nd(n){let e=[],t=n.ownerDocument;for(let o=n;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),n!=t);o=Un(o));return e}function Km({refDOM:n,refTop:e,stack:t}){let o=n?n.getBoundingClientRect().top:0;od(t,o==0?0:o-e)}function od(n,e){for(let t=0;t<n.length;t++){let{dom:o,top:s,left:r}=n[t];o.scrollTop!=s+e&&(o.scrollTop=s+e),o.scrollLeft!=r&&(o.scrollLeft=r)}}let Wt=null;function Jm(n){if(n.setActive)return n.setActive();if(Wt)return n.focus(Wt);let e=nd(n);n.focus(Wt==null?{get preventScroll(){return Wt={preventScroll:!0},!0}}:void 0),Wt||(Wt=!1,od(e,0))}function sd(n,e){let t,o=2e8,s,r=0,i=e.top,l=e.top,a,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let p;if(d.nodeType==1)p=d.getClientRects();else if(d.nodeType==3)p=We(d).getClientRects();else continue;for(let h=0;h<p.length;h++){let f=p[h];if(f.top<=i&&f.bottom>=l){i=Math.max(f.bottom,i),l=Math.min(f.top,l);let m=f.left>e.left?f.left-e.left:f.right<e.left?e.left-f.right:0;if(m<o){t=d,o=m,s=m&&t.nodeType==3?{left:f.right<e.left?f.right:f.left,top:e.top}:e,d.nodeType==1&&m&&(r=u+(e.left>=(f.left+f.right)/2?1:0));continue}}else f.top>e.top&&!a&&f.left<=e.left&&f.right>=e.left&&(a=d,c={left:Math.max(f.left,Math.min(f.right,e.left)),top:f.top});!t&&(e.left>=f.right&&e.top>=f.top||e.left>=f.left&&e.top>=f.bottom)&&(r=u+1)}}return!t&&a&&(t=a,s=c,o=0),t&&t.nodeType==3?Zm(t,s):!t||o&&t.nodeType==1?{node:n,offset:r}:sd(t,s)}function Zm(n,e){let t=n.nodeValue.length,o=document.createRange();for(let s=0;s<t;s++){o.setEnd(n,s+1),o.setStart(n,s);let r=Ye(o,1);if(r.top!=r.bottom&&Yr(e,r))return{node:n,offset:s+(e.left>=(r.left+r.right)/2?1:0)}}return{node:n,offset:0}}function Yr(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Ym(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Xm(n,e,t){let{node:o,offset:s}=sd(e,t),r=-1;if(o.nodeType==1&&!o.firstChild){let i=o.getBoundingClientRect();r=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(o,s,r)}function Qm(n,e,t,o){let s=-1;for(let r=e,i=!1;r!=n.dom;){let l=n.docView.nearestDesc(r,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!i&&a.left>o.left||a.top>o.top?s=l.posBefore:(!i&&a.right<o.left||a.bottom<o.top)&&(s=l.posAfter),i=!0),!l.contentDOM&&s<0&&!l.node.isText)return(l.node.isBlock?o.top<(a.top+a.bottom)/2:o.left<(a.left+a.right)/2)?l.posBefore:l.posAfter}r=l.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function rd(n,e,t){let o=n.childNodes.length;if(o&&t.top<t.bottom)for(let s=Math.max(0,Math.min(o-1,Math.floor(o*(e.top-t.top)/(t.bottom-t.top))-2)),r=s;;){let i=n.childNodes[r];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Yr(e,c))return rd(i,e,c)}}if((r=(r+1)%o)==s)break}return n}function eg(n,e){let t=n.dom.ownerDocument,o,s=0,r=_m(t,e.left,e.top);r&&({node:o,offset:s}=r);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=n.dom.getBoundingClientRect();if(!Yr(e,c)||(i=rd(n.dom,e,c),!i))return null}if(ae)for(let c=i;o&&c;c=Un(c))c.draggable&&(o=void 0);if(i=Ym(i,e),o){if(Ae&&o.nodeType==1&&(s=Math.min(s,o.childNodes.length),s<o.childNodes.length)){let d=o.childNodes[s],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&s++}let c;to&&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=Qm(n,o,s,e))}l==null&&(l=Xm(n,i,e));let a=n.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function vl(n){return n.top<n.bottom||n.left<n.right}function Ye(n,e){let t=n.getClientRects();if(t.length){let o=t[e<0?0:t.length-1];if(vl(o))return o}return Array.prototype.find.call(t,vl)||n.getBoundingClientRect()}const tg=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function id(n,e,t){let{node:o,offset:s,atom:r}=n.docView.domFromPos(e,t<0?-1:1),i=to||Ae;if(o.nodeType==3)if(i&&(tg.test(o.nodeValue)||(t<0?!s:s==o.nodeValue.length))){let a=Ye(We(o,s,s),t);if(Ae&&s&&/\s/.test(o.nodeValue[s-1])&&s<o.nodeValue.length){let c=Ye(We(o,s-1,s-1),-1);if(c.top==a.top){let d=Ye(We(o,s,s+1),-1);if(d.top!=a.top)return Sn(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++,Sn(Ye(We(o,a,c),d),d<0)}if(!n.state.doc.resolve(e-(r||0)).parent.inlineContent){if(r==null&&s&&(t<0||s==xe(o))){let a=o.childNodes[s-1];if(a.nodeType==1)return Ds(a.getBoundingClientRect(),!1)}if(r==null&&s<xe(o)){let a=o.childNodes[s];if(a.nodeType==1)return Ds(a.getBoundingClientRect(),!0)}return Ds(o.getBoundingClientRect(),t>=0)}if(r==null&&s&&(t<0||s==xe(o))){let a=o.childNodes[s-1],c=a.nodeType==3?We(a,xe(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Sn(Ye(c,1),!1)}if(r==null&&s<xe(o)){let a=o.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?We(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return Sn(Ye(c,-1),!0)}return Sn(Ye(o.nodeType==3?We(o):o,-t),t>=0)}function Sn(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 Ds(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 ld(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 ng(n,e,t){let o=e.selection,s=t=="up"?o.$from:o.$to;return ld(n,e,()=>{let{node:r}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(r,!0);if(!l)break;if(l.node.isBlock){r=l.contentDOM||l.dom;break}r=l.dom.parentNode}let i=id(n,s.pos,1);for(let l=r.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=We(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?i.top-d.top>(d.bottom-i.top)*2:d.bottom-i.bottom>(i.bottom-d.top)*2))return!1}}return!0})}const og=/[\u0590-\u08ac]/;function sg(n,e,t){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let s=o.parentOffset,r=!s,i=s==o.parent.content.size,l=n.domSelection();return l?!og.test(o.parent.textContent)||!l.modify?t=="left"||t=="backward"?r:i:ld(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",t,"character");let h=o.depth?n.docView.domAfterPos(o.before()):n.dom,{focusNode:f,focusOffset:m}=n.domSelectionRange(),g=f&&!h.contains(f.nodeType==1?f:f.parentNode)||a==f&&c==m;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return p!=null&&(l.caretBidiLevel=p),g}):o.pos==o.start()||o.pos==o.end()}let Sl=null,xl=null,wl=!1;function rg(n,e,t){return Sl==e&&xl==t?wl:(Sl=e,xl=t,wl=t=="up"||t=="down"?ng(n,e,t):sg(n,e,t))}const Ce=0,Cl=1,Ct=2,Be=3;class no{constructor(e,t,o,s){this.parent=e,this.children=t,this.dom=o,this.contentDOM=s,this.dirty=Ce,o.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,o){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,o=this.posAtStart;;t++){let s=this.children[t];if(s==e)return o;o+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,o){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(o<0){let r,i;if(e==this.contentDOM)r=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.previousSibling}for(;r&&!((i=r.pmViewDesc)&&i.parent==this);)r=r.previousSibling;return r?this.posBeforeChild(i)+i.size:this.posAtStart}else{let r,i;if(e==this.contentDOM)r=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.nextSibling}for(;r&&!((i=r.pmViewDesc)&&i.parent==this);)r=r.nextSibling;return r?this.posBeforeChild(i):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>ee(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let r=e;;r=r.parentNode){if(r==this.dom){s=!1;break}if(r.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let r=e;;r=r.parentNode){if(r==this.dom){s=!0;break}if(r.nextSibling)break}}return s??o>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let o=!0,s=e;s;s=s.parentNode){let r=this.getDesc(s),i;if(r&&(!t||r.node))if(o&&(i=r.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))o=!1;else return r}}getDesc(e){let t=e.pmViewDesc;for(let o=t;o;o=o.parent)if(o==this)return t}posFromDOM(e,t,o){for(let s=e;s;s=s.parentNode){let r=this.getDesc(s);if(r)return r.localPosFromDOM(e,t,o)}return-1}descAt(e){for(let t=0,o=0;t<this.children.length;t++){let s=this.children[t],r=o+s.size;if(o==e&&r!=o){for(;!s.border&&s.children.length;)s=s.children[0];return s}if(e<r)return s.descAt(e-o-s.border);o=r}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let o=0,s=0;for(let r=0;o<this.children.length;o++){let i=this.children[o],l=r+i.size;if(l>e||i instanceof cd){s=e-r;break}r=l}if(s)return this.children[o].domFromPos(s-this.children[o].border,t);for(let r;o&&!(r=this.children[o-1]).size&&r instanceof ad&&r.side>=0;o--);if(t<=0){let r,i=!0;for(;r=o?this.children[o-1]:null,!(!r||r.dom.parentNode==this.contentDOM);o--,i=!1);return r&&t&&i&&!r.border&&!r.domAtom?r.domFromPos(r.size,t):{node:this.contentDOM,offset:r?ee(r.dom)+1:0}}else{let r,i=!0;for(;r=o<this.children.length?this.children[o]:null,!(!r||r.dom.parentNode==this.contentDOM);o++,i=!1);return r&&i&&!r.border&&!r.domAtom?r.domFromPos(0,t):{node:this.contentDOM,offset:r?ee(r.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,o=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,r=-1;for(let i=o,l=0;;l++){let a=this.children[l],c=i+a.size;if(s==-1&&e<=c){let d=i+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=i;for(let u=l;u>0;u--){let p=this.children[u-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){s=ee(p.dom)+1;break}e-=p.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){r=ee(u.dom);break}t+=u.size}r==-1&&(r=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:r}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:o}=this.domFromPos(e,0);if(t.nodeType!=1||o==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[o]}setSelection(e,t,o,s=!1){let r=Math.min(e,t),i=Math.max(e,t);for(let h=0,f=0;h<this.children.length;h++){let m=this.children[h],g=f+m.size;if(r>f&&i<g)return m.setSelection(e-f-m.border,t-f-m.border,o,s);f=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=o.root.getSelection(),d=o.domSelectionRange(),u=!1;if((Ae||ae)&&e==t){let{node:h,offset:f}=l;if(h.nodeType==3){if(u=!!(f&&h.nodeValue[f-1]==`
|
|
805
|
+
`),u&&f==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:ee(g)+1});break}let v=m.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let m=h.childNodes[f-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Ae&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||u&&ae)&&Lt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Lt(a.node,a.offset,d.focusNode,d.focusOffset))return;let p=!1;if((c.extend||e==t)&&!u){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),p=!0}catch{}}if(!p){if(e>t){let f=l;l=a,a=f}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let o=0,s=0;s<this.children.length;s++){let r=this.children[s],i=o+r.size;if(o==i?e<=i&&t>=o:e<i&&t>o){let l=o+r.border,a=i-r.border;if(e>=l&&t<=a){this.dirty=e==o||t==i?Ct:Cl,e==l&&t==a&&(r.contentLost||r.dom.parentNode!=this.contentDOM)?r.dirty=Be:r.markDirty(e-l,t-l);return}else r.dirty=r.dom==r.contentDOM&&r.dom.parentNode==this.contentDOM&&!r.children.length?Ct:Be}o=i}this.dirty=Ct}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let o=e==1?Ct:Cl;t.dirty<o&&(t.dirty=o)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class ad extends no{constructor(e,t,o,s){let r,i=t.type.toDOM;if(typeof i=="function"&&(i=i(o,()=>{if(!r)return s;if(r.parent)return r.parent.posBeforeChild(r)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return this.dirty==Ce&&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 ig extends no{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 $t extends no{constructor(e,t,o,s,r){super(e,[],o,s),this.mark=t,this.spec=r}static create(e,t,o,s){let r=s.nodeViews[t.type.name],i=r&&r(t,s,o);return(!i||!i.dom)&&(i=Vt.renderSpec(document,t.type.spec.toDOM(t,o),null,t.attrs)),new $t(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&Be||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Be&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ce){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=Ce}}slice(e,t,o){let s=$t.create(this.parent,this.mark,!0,o),r=this.children,i=this.size;t<i&&(r=br(r,t,i,o)),e>0&&(r=br(r,0,e,o));for(let l=0;l<r.length;l++)r[l].parent=s;return s.children=r,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class ct extends no{constructor(e,t,o,s,r,i,l,a,c){super(e,[],r,i),this.node=t,this.outerDeco=o,this.innerDeco=s,this.nodeDOM=l}static create(e,t,o,s,r,i){let l=r.nodeViews[t.type.name],a,c=l&&l(t,r,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},o,s),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Vt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let p=d;return d=pd(d,o,t),c?a=new lg(e,t,o,s,d,u||null,p,c,r,i+1):t.isText?new cs(e,t,o,s,d,p,r):new ct(e,t,o,s,d,u||null,p,r,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let o=this.children[t];if(this.dom.contains(o.dom.parentNode)){e.contentElement=o.dom.parentNode;break}}e.contentElement||(e.getContent=()=>T.empty)}return e}matchesNode(e,t,o){return this.dirty==Ce&&e.eq(this.node)&&qo(t,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let o=this.node.inlineContent,s=t,r=e.composing?this.localCompositionInfo(e,t):null,i=r&&r.pos>-1?r:null,l=r&&r.pos<0,a=new cg(this,i&&i.node,e);pg(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,o,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?V.none:this.node.child(d).marks,o,e),a.placeWidget(c,e,s)},(c,d,u,p)=>{a.syncToMarks(c.marks,o,e);let h;a.findNodeMatch(c,d,u,p)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(r.node))>-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,p,s)||a.addNode(c,d,u,e,s),s+=c.nodeSize}),a.syncToMarks([],o,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Ct)&&(i&&this.protectLocalComposition(e,i),dd(this.contentDOM,this.children,e),hn&&hg(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 r=e.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let i=r.nodeValue,l=fg(this.node.content,i,o-t,s-t);return l<0?null:{node:r,pos:l,text:i}}else return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:o,text:s}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let i=new ig(this,r,t,s);e.input.compositionNodes.push(i),this.children=br(this.children,o,o+s.length,e,i)}update(e,t,o,s){return this.dirty==Be||!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=Ce}updateOuterDeco(e){if(qo(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,o=this.dom;this.dom=ud(this.dom,this.nodeDOM,yr(this.outerDeco,this.node,t),yr(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 kl(n,e,t,o,s){pd(o,e,n);let r=new ct(void 0,n,e,t,o,o,o,s,0);return r.contentDOM&&r.updateChildren(s,0),r}class cs extends ct{constructor(e,t,o,s,r,i,l){super(e,t,o,s,r,null,i,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,o,s){return this.dirty==Be||this.dirty!=Ce&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ce||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=Ce,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,o){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,o)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,o){let s=this.node.cut(e,t),r=document.createTextNode(s.text);return new cs(this.parent,s,this.outerDeco,this.innerDeco,r,r,o)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Be)}get domAtom(){return!1}isText(e){return this.node.text==e}}class cd extends no{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ce&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class lg extends ct{constructor(e,t,o,s,r,i,l,a,c,d){super(e,t,o,s,r,i,l,c,d),this.spec=a}update(e,t,o,s){if(this.dirty==Be)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,o);return r&&this.updateInner(e,t,o,s),r}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,o,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,o,s){this.spec.setSelection?this.spec.setSelection(e,t,o.root):super.setSelection(e,t,o,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function dd(n,e,t){let o=n.firstChild,s=!1;for(let r=0;r<e.length;r++){let i=e[r],l=i.dom;if(l.parentNode==n){for(;l!=o;)o=Tl(o),s=!0;o=o.nextSibling}else s=!0,n.insertBefore(l,o);if(i instanceof $t){let a=o?o.previousSibling:n.lastChild;dd(i.contentDOM,i.children,t),o=a?a.nextSibling:n.firstChild}}for(;o;)o=Tl(o),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const Rn=function(n){n&&(this.nodeName=n)};Rn.prototype=Object.create(null);const kt=[new Rn];function yr(n,e,t){if(n.length==0)return kt;let o=t?kt[0]:new Rn,s=[o];for(let r=0;r<n.length;r++){let i=n[r].type.attrs;if(i){i.nodeName&&s.push(o=new Rn(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&s.length==1&&s.push(o=new Rn(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 ud(n,e,t,o){if(t==kt&&o==kt)return e;let s=e;for(let r=0;r<o.length;r++){let i=o[r],l=t[r];if(r){let a;l&&l.nodeName==i.nodeName&&s!=n&&(a=s.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=kt[0]),s=a}ag(s,l||kt[0],i)}return s}function ag(n,e,t){for(let o in e)o!="class"&&o!="style"&&o!="nodeName"&&!(o in t)&&n.removeAttribute(o);for(let o in t)o!="class"&&o!="style"&&o!="nodeName"&&t[o]!=e[o]&&n.setAttribute(o,t[o]);if(e.class!=t.class){let o=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let r=0;r<o.length;r++)s.indexOf(o[r])==-1&&n.classList.remove(o[r]);for(let r=0;r<s.length;r++)o.indexOf(s[r])==-1&&n.classList.add(s[r]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=o.exec(e.style);)n.style.removeProperty(s[1])}t.style&&(n.style.cssText+=t.style)}}function pd(n,e,t){return ud(n,n,kt,yr(e,t,n.nodeType!=1))}function qo(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 Tl(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class cg{constructor(e,t,o){this.lock=t,this.view=o,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=dg(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let o=e;o<t;o++)this.top.children[o].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,o){let s=0,r=this.stack.length>>1,i=Math.min(r,e.length);for(;s<i&&(s==r-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<r;)this.destroyRest(),this.top.dirty=Ce,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[r])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=$t.create(this.top,e[r],t,o);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,r++}}findNodeMatch(e,t,o,s){let r=-1,i;if(s>=this.preMatch.index&&(i=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,o))r=this.top.children.indexOf(i,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,o)&&!this.preMatch.matched.has(c)){r=l;break}}return r<0?!1:(this.destroyBetween(this.index,r),this.index++,!0)}updateNodeAt(e,t,o,s,r){let i=this.top.children[s];return i.dirty==Be&&i.dom==i.contentDOM&&(i.dirty=Ct),i.update(e,t,o,r)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let o=e.pmViewDesc;if(o){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==o)return s}return-1}e=t}}updateNextNode(e,t,o,s,r,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof ct){let c=this.preMatch.matched.get(a);if(c!=null&&c!=r)return!1;let d=a.dom,u,p=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Be&&qo(t,a.outerDeco));if(!p&&a.update(e,t,o,s))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!p&&(u=this.recreateWrapper(a,e,t,o,s,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=Ct,u.updateChildren(s,i+1),u.dirty=Ce),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,o,s,r,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!qo(o,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=ct.create(this.top,t,o,s,r,i);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,o,s,r){let i=ct.create(this.top,e,t,o,s,r);i.contentDOM&&i.updateChildren(s,r+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,o){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let r=new ad(this.top,e,t,o);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof $t;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof cs)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ae||re)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let o=document.createElement(e);e=="IMG"&&(o.className="ProseMirror-separator",o.alt=""),e=="BR"&&(o.className="ProseMirror-trailingBreak");let s=new cd(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 dg(n,e){let t=e,o=t.children.length,s=n.childCount,r=new Map,i=[];e:for(;s>0;){let l;for(;;)if(o){let c=t.children[o-1];if(c instanceof $t)t=c,o=c.children.length;else{l=c,o--;break}}else{if(t==e)break e;o=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(s-1))break;--s,r.set(l,s),i.push(l)}}return{index:s,matched:r,matches:i.reverse()}}function ug(n,e){return n.type.side-e.type.side}function pg(n,e,t,o){let s=e.locals(n),r=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);o(d,s,e.forChild(r,d),c),r+=d.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let d,u;for(;i<s.length&&s[i].to==r;){let g=s[i++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(ug);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let p,h;if(a)h=-1,p=a,a=null;else if(c<n.childCount)h=c,p=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=r&&l.splice(g--,1);for(;i<s.length&&s[i].from<=r&&s[i].to>r;)l.push(s[i++]);let f=r+p.nodeSize;if(p.isText){let g=f;i<s.length&&s[i].from<g&&(g=s[i].from);for(let v=0;v<l.length;v++)l[v].to<g&&(g=l[v].to);g<f&&(a=p.cut(g-r),p=p.cut(0,g-r),f=g,h=-1)}else for(;i<s.length&&s[i].to<f;)i++;let m=p.isInline&&!p.isLeaf?l.filter(g=>!g.inline):l.slice();o(p,m,e.forChild(r,p),h),r=f}}function hg(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 fg(n,e,t,o){for(let s=0,r=0;s<n.childCount&&r<=o;){let i=n.child(s++),l=r;if(r+=i.nodeSize,!i.isText)continue;let a=i.text;for(;s<n.childCount;){let c=n.child(s++);if(r+=c.nodeSize,!c.isText)break;a+=c.text}if(r>=t){if(r>=o&&a.slice(o-e.length-l,o-l)==e)return o-e.length;let c=l<o?a.lastIndexOf(e,o-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==o&&a.length>=o+e.length-l&&a.slice(o-l,o-l+e.length)==e)return o}}return-1}function br(n,e,t,o,s){let r=[];for(let i=0,l=0;i<n.length;i++){let a=n[i],c=l,d=l+=a.size;c>=t||d<=e?r.push(a):(c<e&&r.push(a.slice(0,e-c,o)),s&&(r.push(s),s=void 0),d>t&&r.push(a.slice(t-c,a.size,o)))}return r}function Xr(n,e=null){let t=n.domSelectionRange(),o=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),r=s&&s.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=o.resolve(i),a,c;if(as(t)){for(a=i;s&&!s.node;)s=s.parent;let u=s.node;if(s&&u.isAtom&&R.isSelectable(u)&&s.parent&&!(u.isInline&&Hm(t.focusNode,t.focusOffset,s.dom))){let p=s.posBefore;c=new R(i==p?l:o.resolve(p))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=i,p=i;for(let h=0;h<t.rangeCount;h++){let f=t.getRangeAt(h);u=Math.min(u,n.docView.posFromDOM(f.startContainer,f.startOffset,1)),p=Math.max(p,n.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(u<0)return null;[a,i]=p==n.state.selection.anchor?[p,u]:[u,p],l=o.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=o.resolve(a);if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!r?1:-1;c=Qr(n,d,l,u)}return c}function hd(n){return n.editable?n.hasFocus():md(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Ue(n,e=!1){let t=n.state.selection;if(fd(n,t),!!hd(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&re){let o=n.domSelectionRange(),s=n.domObserver.currentSelection;if(o.anchorNode&&s.anchorNode&&Lt(o.anchorNode,o.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)gg(n);else{let{anchor:o,head:s}=t,r,i;El&&!(t instanceof $)&&(t.$from.parent.inlineContent||(r=Ml(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=Ml(n,t.to))),n.docView.setSelection(o,s,n,e),El&&(r&&Al(r),i&&Al(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&mg(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const El=ae||re&&td<63;function Ml(n,e){let{node:t,offset:o}=n.docView.domFromPos(e,0),s=o<t.childNodes.length?t.childNodes[o]:null,r=o?t.childNodes[o-1]:null;if(ae&&s&&s.contentEditable=="false")return Ls(s);if((!s||s.contentEditable=="false")&&(!r||r.contentEditable=="false")){if(s)return Ls(s);if(r)return Ls(r)}}function Ls(n){return n.contentEditable="true",ae&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Al(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function mg(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(()=>{(!hd(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function gg(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let o=n.cursorWrapper.dom,s=o.nodeName=="IMG";s?t.setStart(o.parentNode,ee(o)+1):t.setStart(o,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!s&&!n.state.selection.visible&&he&&at<=11&&(o.disabled=!0,o.disabled=!1)}function fd(n,e){if(e instanceof R){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Pl(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Pl(n)}function Pl(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Qr(n,e,t,o){return n.someProp("createSelectionBetween",s=>s(n,e,t))||$.between(e,t,o)}function Il(n){return n.editable&&!n.hasFocus()?!1:md(n)}function md(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 yg(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Lt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function vr(n,e){let{$anchor:t,$head:o}=n.selection,s=e>0?t.max(o):t.min(o),r=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return r&&L.findFrom(r,e)}function Qe(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Nl(n,e,t){let o=n.state.selection;if(o instanceof $)if(t.indexOf("s")>-1){let{$head:s}=o,r=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let i=n.state.doc.resolve(s.pos+r.nodeSize*(e<0?-1:1));return Qe(n,new $(o.$anchor,i))}else if(o.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=vr(n.state,e);return s&&s instanceof R?Qe(n,s):!1}else if(!(Se&&t.indexOf("m")>-1)){let s=o.$head,r=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,i;if(!r||r.isText)return!1;let l=e<0?s.pos-r.nodeSize:s.pos;return r.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?R.isSelectable(r)?Qe(n,new R(e<0?n.state.doc.resolve(s.pos-r.nodeSize):s)):to?Qe(n,new $(n.state.doc.resolve(e<0?l:l+r.nodeSize))):!1:!1}}else return!1;else{if(o instanceof R&&o.node.isInline)return Qe(n,new $(e>0?o.$to:o.$from));{let s=vr(n.state,e);return s?Qe(n,s):!1}}}function Uo(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Dn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function jt(n,e){return e<0?bg(n):vg(n)}function bg(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s,r,i=!1;for(Ae&&t.nodeType==1&&o<Uo(t)&&Dn(t.childNodes[o],-1)&&(i=!0);;)if(o>0){if(t.nodeType!=1)break;{let l=t.childNodes[o-1];if(Dn(l,-1))s=t,r=--o;else if(l.nodeType==3)t=l,o=t.nodeValue.length;else break}}else{if(gd(t))break;{let l=t.previousSibling;for(;l&&Dn(l,-1);)s=t.parentNode,r=ee(l),l=l.previousSibling;if(l)t=l,o=Uo(t);else{if(t=t.parentNode,t==n.dom)break;o=0}}}i?Sr(n,t,o):s&&Sr(n,s,r)}function vg(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s=Uo(t),r,i;for(;;)if(o<s){if(t.nodeType!=1)break;let l=t.childNodes[o];if(Dn(l,1))r=t,i=++o;else break}else{if(gd(t))break;{let l=t.nextSibling;for(;l&&Dn(l,1);)r=l.parentNode,i=ee(l)+1,l=l.nextSibling;if(l)t=l,o=0,s=Uo(t);else{if(t=t.parentNode,t==n.dom)break;o=s=0}}}r&&Sr(n,r,i)}function gd(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Sg(n,e){for(;n&&e==n.childNodes.length&&!eo(n);)e=ee(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function xg(n,e){for(;n&&!e&&!eo(n);)e=ee(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Sr(n,e,t){if(e.nodeType!=3){let r,i;(i=Sg(e,t))?(e=i,t=0):(r=xg(e,t))&&(e=r,t=r.nodeValue.length)}let o=n.domSelection();if(!o)return;if(as(o)){let r=document.createRange();r.setEnd(e,t),r.setStart(e,t),o.removeAllRanges(),o.addRange(r)}else o.extend&&o.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&Ue(n)},50)}function Ol(n,e){let t=n.state.doc.resolve(e);if(!(re||Gm)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let r=n.coordsAtPos(e-1),i=(r.top+r.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(r.left-s.left)>1)return r.left<s.left?"ltr":"rtl"}if(e<t.end()){let r=n.coordsAtPos(e+1),i=(r.top+r.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(r.left-s.left)>1)return r.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Rl(n,e,t){let o=n.state.selection;if(o instanceof $&&!o.empty||t.indexOf("s")>-1||Se&&t.indexOf("m")>-1)return!1;let{$from:s,$to:r}=o;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=vr(n.state,e);if(i&&i instanceof R)return Qe(n,i)}if(!s.parent.inlineContent){let i=e<0?s:r,l=o instanceof ye?L.near(i,e):L.findFrom(i,e);return l?Qe(n,l):!1}return!1}function Dl(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 r=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(r&&!r.isText){let i=n.state.tr;return e<0?i.delete(t.pos-r.nodeSize,t.pos):i.delete(t.pos,t.pos+r.nodeSize),n.dispatch(i),!0}return!1}function Ll(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function wg(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;Ll(n,o,"true"),setTimeout(()=>Ll(n,o,"false"),20)}return!1}function Cg(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function kg(n,e){let t=e.keyCode,o=Cg(e);if(t==8||Se&&t==72&&o=="c")return Dl(n,-1)||jt(n,-1);if(t==46&&!e.shiftKey||Se&&t==68&&o=="c")return Dl(n,1)||jt(n,1);if(t==13||t==27)return!0;if(t==37||Se&&t==66&&o=="c"){let s=t==37?Ol(n,n.state.selection.from)=="ltr"?-1:1:-1;return Nl(n,s,o)||jt(n,s)}else if(t==39||Se&&t==70&&o=="c"){let s=t==39?Ol(n,n.state.selection.from)=="ltr"?1:-1:1;return Nl(n,s,o)||jt(n,s)}else{if(t==38||Se&&t==80&&o=="c")return Rl(n,-1,o)||jt(n,-1);if(t==40||Se&&t==78&&o=="c")return wg(n)||Rl(n,1,o)||jt(n,1);if(o==(Se?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function yd(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:o,openStart:s,openEnd:r}=e;for(;s>1&&r>1&&o.childCount==1&&o.firstChild.childCount==1;){s--,r--;let h=o.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),o=h.content}let i=n.someProp("clipboardSerializer")||Vt.fromSchema(n.state.schema),l=Cd(),a=l.createElement("div");a.appendChild(i.serializeFragment(o,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=wd[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let f=l.createElement(d[h]);for(;a.firstChild;)f.appendChild(a.firstChild);a.appendChild(f),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${r}${u?` -${u}`:""} ${JSON.stringify(t)}`);let p=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
|
|
806
|
+
|
|
807
|
+
`);return{dom:a,text:p,slice:e}}function bd(n,e,t,o,s){let r=s.parent.type.spec.code,i,l;if(!t&&!e)return null;let a=e&&(o||r||!t);if(a){if(n.someProp("transformPastedText",p=>{e=p(e,r||o,n)}),r)return e?new A(T.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
808
|
+
`))),0,0):A.empty;let u=n.someProp("clipboardTextParser",p=>p(e,s,o,n));if(u)l=u;else{let p=s.marks(),{schema:h}=n.state,f=Vt.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=i.appendChild(document.createElement("p"));m&&g.appendChild(f.serializeNode(h.text(m,p)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),i=Ag(t),to&&Pg(i);let c=i&&i.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let p=i.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;i=p}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||cn.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!Tg.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Ig($l(l,+d[1],+d[2]),d[4]);else if(l=A.maxOpen(Eg(l.content,s),!0),l.openStart||l.openEnd){let u=0,p=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;p<l.openEnd&&!h.type.spec.isolating;p++,h=h.lastChild);l=$l(l,u,p)}return n.someProp("transformPasted",u=>{l=u(l,n)}),l}const Tg=/^(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 Eg(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),r,i=[];if(n.forEach(l=>{if(!i)return;let a=s.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&r.length&&Sd(a,r,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=xd(i[i.length-1],r.length));let d=vd(l,a);i.push(d),s=s.matchType(d.type),r=a}}),i)return T.from(i)}return n}function vd(n,e,t=0){for(let o=e.length-1;o>=t;o--)n=e[o].create(null,T.from(n));return n}function Sd(n,e,t,o,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let r=Sd(n,e,t,o.lastChild,s+1);if(r)return o.copy(o.content.replaceChild(o.childCount-1,r));if(o.contentMatchAt(o.childCount).matchType(s==n.length-1?t.type:n[s+1]))return o.copy(o.content.append(T.from(vd(t,n,s+1))))}}function xd(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,xd(n.lastChild,e-1)),o=n.contentMatchAt(n.childCount).fillBefore(T.empty,!0);return n.copy(t.append(o))}function xr(n,e,t,o,s,r){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(r=0),s<o-1&&(l=xr(l,e,t,o,s+1,r)),s>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,r<=s).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(T.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function $l(n,e,t){return e<n.openStart&&(n=new A(xr(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new A(xr(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const wd={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 zl=null;function Cd(){return zl||(zl=document.implementation.createHTMLDocument("title"))}let $s=null;function Mg(n){let e=window.trustedTypes;return e?($s||($s=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),$s.createHTML(n)):n}function Ag(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Cd().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(n),s;if((s=o&&wd[o[1].toLowerCase()])&&(n=s.map(r=>"<"+r+">").join("")+n+s.map(r=>"</"+r+">").reverse().join("")),t.innerHTML=Mg(n),s)for(let r=0;r<s.length;r++)t=t.querySelector(s[r])||t;return t}function Pg(n){let e=n.querySelectorAll(re?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let o=e[t];o.childNodes.length==1&&o.textContent==" "&&o.parentNode&&o.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),o)}}function Ig(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,o;try{o=JSON.parse(e)}catch{return n}let{content:s,openStart:r,openEnd:i}=n;for(let l=o.length-2;l>=0;l-=2){let a=t.nodes[o[l]];if(!a||a.hasRequiredAttrs())break;s=T.from(a.create(o[l+1],s)),r++,i++}return new A(s,r,i)}const ce={},de={},Ng={touchstart:!0,touchmove:!0};class Og{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 Rg(n){for(let e in ce){let t=ce[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=o=>{Lg(n,o)&&!ei(n,o)&&(n.editable||!(o.type in de))&&t(n,o)},Ng[e]?{passive:!0}:void 0)}ae&&n.dom.addEventListener("input",()=>null),wr(n)}function it(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Dg(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function wr(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=o=>ei(n,o))})}function ei(n,e){return n.someProp("handleDOMEvents",t=>{let o=t[e.type];return o?o(n,e)||e.defaultPrevented:!1})}function Lg(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 $g(n,e){!ei(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,!Td(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Te&&re&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),hn&&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,St(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",o=>o(n,t))||kg(n,t)?t.preventDefault():it(n,"key")};de.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};de.keypress=(n,e)=>{let t=e;if(Td(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Se&&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",r=>r(n,o.$from.pos,o.$to.pos,s))&&n.dispatch(n.state.tr.insertText(s).scrollIntoView()),t.preventDefault()}};function ds(n){return{left:n.clientX,top:n.clientY}}function zg(n,e){let t=e.x-n.clientX,o=e.y-n.clientY;return t*t+o*o<100}function ti(n,e,t,o,s){if(o==-1)return!1;let r=n.state.doc.resolve(o);for(let i=r.depth+1;i>0;i--)if(n.someProp(e,l=>i>r.depth?l(n,t,r.nodeAfter,r.before(i),s,!0):l(n,t,r.node(i),r.before(i),s,!1)))return!0;return!1}function rn(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 Bg(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),o=t.nodeAfter;return o&&o.isAtom&&R.isSelectable(o)?(rn(n,new R(t)),!0):!1}function Vg(n,e){if(e==-1)return!1;let t=n.state.selection,o,s;t instanceof R&&(o=t.node);let r=n.state.doc.resolve(e);for(let i=r.depth+1;i>0;i--){let l=i>r.depth?r.nodeAfter:r.node(i);if(R.isSelectable(l)){o&&t.$from.depth>0&&i>=t.$from.depth&&r.before(t.$from.depth+1)==t.$from.pos?s=r.before(t.$from.depth):s=r.before(i);break}}return s!=null?(rn(n,R.create(n.state.doc,s)),!0):!1}function Hg(n,e,t,o,s){return ti(n,"handleClickOn",e,t,o)||n.someProp("handleClick",r=>r(n,e,o))||(s?Vg(n,t):Bg(n,t))}function Fg(n,e,t,o){return ti(n,"handleDoubleClickOn",e,t,o)||n.someProp("handleDoubleClick",s=>s(n,e,o))}function _g(n,e,t,o){return ti(n,"handleTripleClickOn",e,t,o)||n.someProp("handleTripleClick",s=>s(n,e,o))||Gg(n,t,o)}function Gg(n,e,t){if(t.button!=0)return!1;let o=n.state.doc;if(e==-1)return o.inlineContent?(rn(n,$.create(o,0,o.content.size)),!0):!1;let s=o.resolve(e);for(let r=s.depth+1;r>0;r--){let i=r>s.depth?s.nodeAfter:s.node(r),l=s.before(r);if(i.inlineContent)rn(n,$.create(o,l+1,l+1+i.content.size));else if(R.isSelectable(i))rn(n,R.create(o,l));else continue;return!0}}function ni(n){return Ko(n)}const kd=Se?"metaKey":"ctrlKey";ce.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let o=ni(n),s=Date.now(),r="singleClick";s-n.input.lastClick.time<500&&zg(t,n.input.lastClick)&&!t[kd]&&(n.input.lastClick.type=="singleClick"?r="doubleClick":n.input.lastClick.type=="doubleClick"&&(r="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:r};let i=n.posAtCoords(ds(t));i&&(r=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Wg(n,i,t,!!o)):(r=="doubleClick"?Fg:_g)(n,i.pos,i.inside,t)?t.preventDefault():it(n,"pointer"))};class Wg{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[kd],this.allowDefault=o.shiftKey;let r,i;if(t.inside>-1)r=e.state.doc.nodeAt(t.inside),i=t.inside;else{let d=e.state.doc.resolve(t.pos);r=d.parent,i=d.depth?d.before():0}const l=s?null:o.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(o.button==0&&r.type.spec.draggable&&r.type.spec.selectable!==!1||c instanceof R&&c.from<=i&&c.to>i)&&(this.mightDrag={node:r,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ae&&!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)),it(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(()=>Ue(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(ds(e))),this.updateAllowDefault(e),this.allowDefault||!t?it(this.view,"pointer"):Hg(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ae&&this.mightDrag&&!this.mightDrag.node.isAtom||re&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(rn(this.view,L.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):it(this.view,"pointer")}move(e){this.updateAllowDefault(e),it(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(),ni(n),it(n,"pointer")};ce.touchmove=n=>{n.input.lastTouch=Date.now(),it(n,"pointer")};ce.contextmenu=n=>ni(n);function Td(n,e){return n.composing?!0:ae&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const jg=Te?5e3:-1;de.compositionstart=de.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof $&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(o=>o.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Ko(n,!0),n.markCursor=null;else if(Ko(n,!e.selection.empty),Ae&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let o=n.domSelectionRange();for(let s=o.focusNode,r=o.focusOffset;s&&s.nodeType==1&&r!=0;){let i=r<0?s.lastChild:s.childNodes[r-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else s=i,r=-1}}n.input.composing=!0}Ed(n,jg)};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++,Ed(n,20))};function Ed(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Ko(n),e))}function Md(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Ug());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function qg(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Bm(e.focusNode,e.focusOffset),o=Vm(e.focusNode,e.focusOffset);if(t&&o&&t!=o){let s=o.pmViewDesc,r=n.domObserver.lastChangedTextNode;if(t==r||o==r)return r;if(!s||!s.isText(o.nodeValue))return o;if(n.input.compositionNode==o){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return o}}return t||o}function Ug(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Ko(n,e=!1){if(!(Te&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Md(n),e||n.docView&&n.docView.dirty){let t=Xr(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 Kg(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 Kn=he&&at<15||hn&&Wm<604;ce.copy=de.cut=(n,e)=>{let t=e,o=n.state.selection,s=t.type=="cut";if(o.empty)return;let r=Kn?null:t.clipboardData,i=o.content(),{dom:l,text:a}=yd(n,i);r?(t.preventDefault(),r.clearData(),r.setData("text/html",l.innerHTML),r.setData("text/plain",a)):Kg(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Jg(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Zg(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?Jn(n,o.value,null,s,e):Jn(n,o.textContent,o.innerHTML,s,e)},50)}function Jn(n,e,t,o,s){let r=bd(n,e,t,o,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,r||A.empty)))return!0;if(!r)return!1;let i=Jg(r),l=i?n.state.tr.replaceSelectionWith(i,o):n.state.tr.replaceSelection(r);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ad(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}de.paste=(n,e)=>{let t=e;if(n.composing&&!Te)return;let o=Kn?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;o&&Jn(n,Ad(o),o.getData("text/html"),s,t)?t.preventDefault():Zg(n,t)};class Pd{constructor(e,t,o){this.slice=e,this.move=t,this.node=o}}const Id=Se?"altKey":"ctrlKey";ce.dragstart=(n,e)=>{let t=e,o=n.input.mouseDown;if(o&&o.done(),!t.dataTransfer)return;let s=n.state.selection,r=s.empty?null:n.posAtCoords(ds(t)),i;if(!(r&&r.pos>=s.from&&r.pos<=(s instanceof R?s.to-1:s.to))){if(o&&o.mightDrag)i=R.create(n.state.doc,o.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(i=R.create(n.state.doc,u.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:d}=yd(n,l);(!t.dataTransfer.files.length||!re||td>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Kn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Kn||t.dataTransfer.setData("text/plain",c),n.dragging=new Pd(d,!t[Id],i)};ce.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};de.dragover=de.dragenter=(n,e)=>e.preventDefault();de.drop=(n,e)=>{let t=e,o=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let s=n.posAtCoords(ds(t));if(!s)return;let r=n.state.doc.resolve(s.pos),i=o&&o.slice;i?n.someProp("transformPasted",f=>{i=f(i,n)}):i=bd(n,Ad(t.dataTransfer),Kn?null:t.dataTransfer.getData("text/html"),!1,r);let l=!!(o&&!t[Id]);if(n.someProp("handleDrop",f=>f(n,t,i||A.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?Wf(n.state.doc,r.pos,i):r.pos;a==null&&(a=r.pos);let c=n.state.tr;if(l){let{node:f}=o;f?f.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,p=c.doc;if(u?c.replaceRangeWith(d,d,i.content.firstChild):c.replaceRange(d,d,i),c.doc.eq(p))return;let h=c.doc.resolve(d);if(u&&R.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new R(h));else{let f=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,v,C)=>f=C),c.setSelection(Qr(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())&&Ue(n)},20))};ce.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};ce.beforeinput=(n,e)=>{if(re&&Te&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:o}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=o||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",r=>r(n,St(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 Zn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Jo{constructor(e,t){this.toDOM=e,this.spec=t||It,this.side=this.spec.side||0}map(e,t,o,s){let{pos:r,deleted:i}=e.mapResult(t.from+s,this.side<0?-1:1);return i?null:new pe(r-o,r-o,this)}valid(){return!0}eq(e){return this==e||e instanceof Jo&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Zn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class dt{constructor(e,t){this.attrs=e,this.spec=t||It}map(e,t,o,s){let r=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-o,i=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-o;return r>=i?null:new pe(r,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof dt&&Zn(this.attrs,e.attrs)&&Zn(this.spec,e.spec)}static is(e){return e.type instanceof dt}destroy(){}}class oi{constructor(e,t){this.attrs=e,this.spec=t||It}map(e,t,o,s){let r=e.mapResult(t.from+s,1);if(r.deleted)return null;let i=e.mapResult(t.to+s,-1);return i.deleted||i.pos<=r.pos?null:new pe(r.pos-o,i.pos-o,this)}valid(e,t){let{index:o,offset:s}=e.content.findIndex(t.from),r;return s==t.from&&!(r=e.child(o)).isText&&s+r.nodeSize==t.to}eq(e){return this==e||e instanceof oi&&Zn(this.attrs,e.attrs)&&Zn(this.spec,e.spec)}destroy(){}}class pe{constructor(e,t,o){this.from=e,this.to=t,this.type=o}copy(e,t){return new pe(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 pe(e,e,new Jo(t,o))}static inline(e,t,o,s){return new pe(e,t,new dt(o,s))}static node(e,t,o,s){return new pe(e,t,new oi(o,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof dt}get widget(){return this.type instanceof Jo}}const Kt=[],It={};class W{constructor(e,t){this.local=e.length?e:Kt,this.children=t.length?t:Kt}static create(e,t){return t.length?Zo(t,e,0,It):oe}find(e,t,o){let s=[];return this.findInner(e??0,t??1e9,s,0,o),s}findInner(e,t,o,s,r){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!r||r(l.spec))&&o.push(l.copy(l.from+s,l.to+s))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,o,s+l,r)}}map(e,t,o){return this==oe||e.maps.length==0?this:this.mapInner(e,t,0,0,o||It)}mapInner(e,t,o,s,r){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,o,s);a&&a.type.valid(t,a)?(i||(i=[])).push(a):r.onRemove&&r.onRemove(this.local[l].spec)}return this.children.length?Yg(this.children,i||[],e,t,o,s,r):i?new W(i.sort(Nt),Kt):oe}add(e,t){return t.length?this==oe?W.create(e,t):this.addInner(e,t,0):this}addInner(e,t,o){let s,r=0;e.forEach((l,a)=>{let c=a+o,d;if(d=Od(t,l,c)){for(s||(s=this.children.slice());r<s.length&&s[r]<a;)r+=3;s[r]==a?s[r+2]=s[r+2].addInner(l,d,c+1):s.splice(r,0,a,a+l.nodeSize,Zo(d,l,c+1,It)),r+=3}});let i=Nd(r?Rd(t):t,-o);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new W(i.length?this.local.concat(i).sort(Nt):this.local,s||this.children)}remove(e){return e.length==0||this==oe?this:this.removeInner(e,0)}removeInner(e,t){let o=this.children,s=this.local;for(let r=0;r<o.length;r+=3){let i,l=o[r]+t,a=o[r+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(i||(i=[])).push(u));if(!i)continue;o==this.children&&(o=this.children.slice());let c=o[r+2].removeInner(i,l+1);c!=oe?o[r+2]=c:(o.splice(r,3),r-=3)}if(s.length){for(let r=0,i;r<e.length;r++)if(i=e[r])for(let l=0;l<s.length;l++)s[l].eq(i,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return o==this.children&&s==this.local?this:s.length||o.length?new W(s,o):oe}forChild(e,t){if(this==oe)return this;if(t.isLeaf)return W.empty;let o,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(o=this.children[l+2]);break}let r=e+1,i=r+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>r&&a.type instanceof dt){let c=Math.max(r,a.from)-r,d=Math.min(i,a.to)-r;c<d&&(s||(s=[])).push(a.copy(c,d))}}if(s){let l=new W(s.sort(Nt),Kt);return o?new tt([l,o]):l}return o||oe}eq(e){if(this==e)return!0;if(!(e instanceof W)||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 si(this.localsInner(e))}localsInner(e){if(this==oe)return Kt;if(e.inlineContent||!this.local.some(dt.is))return this.local;let t=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof dt||t.push(this.local[o]);return t}forEachSet(e){e(this)}}W.empty=new W([],[]);W.removeOverlap=si;const oe=W.empty;class tt{constructor(e){this.members=e}map(e,t){const o=this.members.map(s=>s.map(e,t,It));return tt.from(o)}forChild(e,t){if(t.isLeaf)return W.empty;let o=[];for(let s=0;s<this.members.length;s++){let r=this.members[s].forChild(e,t);r!=oe&&(r instanceof tt?o=o.concat(r.members):o.push(r))}return tt.from(o)}eq(e){if(!(e instanceof tt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,o=!0;for(let s=0;s<this.members.length;s++){let r=this.members[s].localsInner(e);if(r.length)if(!t)t=r;else{o&&(t=t.slice(),o=!1);for(let i=0;i<r.length;i++)t.push(r[i])}}return t?si(o?t:t.sort(Nt)):Kt}static from(e){switch(e.length){case 0:return oe;case 1:return e[0];default:return new tt(e.every(t=>t instanceof W)?e:e.reduce((t,o)=>t.concat(o instanceof W?o:o.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Yg(n,e,t,o,s,r,i){let l=n.slice();for(let c=0,d=r;c<t.maps.length;c++){let u=0;t.maps[c].forEach((p,h,f,m)=>{let g=m-f-(h-p);for(let v=0;v<l.length;v+=3){let C=l[v+1];if(C<0||p>C+d-u)continue;let y=l[v]+d-u;h>=y?l[v+1]=p<=y?-2:-1:p>=d&&g&&(l[v]+=g,l[v+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(n[c]+r),u=d-s;if(u<0||u>=o.content.size){a=!0;continue}let p=t.map(n[c+1]+r,-1),h=p-s,{index:f,offset:m}=o.content.findIndex(u),g=o.maybeChild(f);if(g&&m==u&&m+g.nodeSize==h){let v=l[c+2].mapInner(t,g,d+1,n[c]+r+1,i);v!=oe?(l[c]=u,l[c+1]=h,l[c+2]=v):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Xg(l,n,e,t,s,r,i),d=Zo(c,o,0,i);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,p=0;u<d.children.length;u+=3){let h=d.children[u];for(;p<l.length&&l[p]<h;)p+=3;l.splice(p,0,d.children[u],d.children[u+1],d.children[u+2])}}return new W(e.sort(Nt),l)}function Nd(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 pe(s.from+e,s.to+e,s.type))}return t}function Xg(n,e,t,o,s,r,i){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(o,s,c);u?t.push(u):i.onRemove&&i.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+r+1);return t}function Od(n,e,t){if(e.isLeaf)return null;let o=t+e.nodeSize,s=null;for(let r=0,i;r<n.length;r++)(i=n[r])&&i.from>t&&i.to<o&&((s||(s=[])).push(i),n[r]=null);return s}function Rd(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Zo(n,e,t,o){let s=[],r=!1;e.forEach((l,a)=>{let c=Od(n,l,a+t);if(c){r=!0;let d=Zo(c,l,t+a+1,o);d!=oe&&s.push(a,a+l.nodeSize,d)}});let i=Nd(r?Rd(n):n,-t).sort(Nt);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(o.onRemove&&o.onRemove(i[l].spec),i.splice(l--,1));return i.length||s.length?new W(i,s):oe}function Nt(n,e){return n.from-e.from||n.to-e.to}function si(n){let e=n;for(let t=0;t<e.length-1;t++){let o=e[t];if(o.from!=o.to)for(let s=t+1;s<e.length;s++){let r=e[s];if(r.from==o.from){r.to!=o.to&&(e==n&&(e=n.slice()),e[s]=r.copy(r.from,o.to),Bl(e,s+1,r.copy(o.to,r.to)));continue}else{r.from<o.to&&(e==n&&(e=n.slice()),e[t]=o.copy(o.from,r.from),Bl(e,s,o.copy(r.from,o.to)));break}}}return e}function Bl(n,e,t){for(;e<n.length&&Nt(t,n[e])>0;)e++;n.splice(e,0,t)}function zs(n){let e=[];return n.someProp("decorations",t=>{let o=t(n.state);o&&o!=oe&&e.push(o)}),n.cursorWrapper&&e.push(W.create(n.state.doc,[n.cursorWrapper.deco])),tt.from(e)}const Qg={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},e1=he&&at<=11;class t1{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 n1{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new t1,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(o=>{for(let s=0;s<o.length;s++)this.queue.push(o[s]);he&&at<=11&&o.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),e1&&(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,Qg)),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(Il(this.view)){if(this.suppressingSelectionUpdates)return Ue(this.view);if(he&&at<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Lt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,o;for(let r=e.focusNode;r;r=Un(r))t.add(r);for(let r=e.anchorNode;r;r=Un(r))if(t.has(r)){o=r;break}let s=o&&this.view.docView.nearestDesc(o);if(s&&s.ignoreMutation({type:"selection",target:o.nodeType==3?o.parentNode:o}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let o=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(o)&&Il(e)&&!this.ignoreSelectionChange(o),r=-1,i=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(r=r<0?u.from:Math.min(u.from,r),i=i<0?u.to:Math.max(u.to,i),u.typeOver&&(l=!0))}if(Ae&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,p]=d;u.parentNode&&u.parentNode.parentNode==p.parentNode?p.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let p of d){let h=p.parentNode;h&&h.nodeName=="LI"&&(!u||r1(e,u)!=h)&&p.remove()}}}let c=null;r<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&as(o)&&(c=Xr(e))&&c.eq(L.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ue(e),this.currentSelection.set(o),e.scrollToSelection()):(r>-1||s)&&(r>-1&&(e.docView.markDirty(r,i),o1(e)),this.handleDOMChange(r,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(o)||Ue(e),this.currentSelection.set(o))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let o=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(o==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!o||o.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(e.target))return{from:o.posBefore,to:o.posAfter};let s=e.previousSibling,r=e.nextSibling;if(he&&at<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:p}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(r=p)}let i=s&&s.parentNode==e.target?ee(s)+1:0,l=o.localPosFromDOM(e.target,i,-1),a=r&&r.parentNode==e.target?ee(r):e.target.childNodes.length,c=o.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}:(this.lastChangedTextNode=e.target,{from:o.posAtStart,to:o.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Vl=new WeakMap,Hl=!1;function o1(n){if(!Vl.has(n)&&(Vl.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ae,Hl)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."),Hl=!0}}function Fl(n,e){let t=e.startContainer,o=e.startOffset,s=e.endContainer,r=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return Lt(i.node,i.offset,s,r)&&([t,o,s,r]=[s,r,t,o]),{anchorNode:t,anchorOffset:o,focusNode:s,focusOffset:r}}function s1(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return Fl(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?Fl(n,t):null}function r1(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 i1(n,e,t){let{node:o,fromOffset:s,toOffset:r,from:i,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],as(a)||c.push({node:a.focusNode,offset:a.focusOffset})),re&&n.input.lastKeyCode===8)for(let g=r;g>s;g--){let v=o.childNodes[g-1],C=v.pmViewDesc;if(v.nodeName=="BR"&&!C){r=g;break}if(!C||C.size)break}let u=n.state.doc,p=n.someProp("domParser")||cn.fromSchema(n.state.schema),h=u.resolve(i),f=null,m=p.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:r,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:l1,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,v=c[1]&&c[1].pos;v==null&&(v=g),f={anchor:g+i,head:v+i}}return{doc:m,sel:f,from:i,to:l}}function l1(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 a1=/^(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 c1(n,e,t,o,s){let r=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let k=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,M=Xr(n,k);if(M&&!n.state.selection.eq(M)){if(re&&Te&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",N=>N(n,St(13,"Enter"))))return;let P=n.state.tr.setSelection(M);k=="pointer"?P.setMeta("pointer",!0):k=="key"&&P.scrollIntoView(),r&&P.setMeta("composition",r),n.dispatch(P)}return}let i=n.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=i1(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),p,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(p=n.state.selection.to,h="end"):(p=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let f=p1(u.content,c.doc.content,c.from,p,h);if(f&&n.input.domChangeCount++,(hn&&n.input.lastIOSEnter>Date.now()-225||Te)&&s.some(k=>k.nodeType==1&&!a1.test(k.nodeName))&&(!f||f.endA>=f.endB)&&n.someProp("handleKeyDown",k=>k(n,St(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 k=_l(n,n.state.doc,c.sel);if(k&&!k.eq(n.state.selection)){let M=n.state.tr.setSelection(k);r&&M.setMeta("composition",r),n.dispatch(M)}}return}n.state.selection.from<n.state.selection.to&&f.start==f.endB&&n.state.selection instanceof $&&(f.start>n.state.selection.from&&f.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?f.start=n.state.selection.from:f.endA<n.state.selection.to&&f.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(f.endB+=n.state.selection.to-f.endA,f.endA=n.state.selection.to)),he&&at<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>c.from&&c.doc.textBetween(f.start-c.from-1,f.start-c.from+1)==" "&&(f.start--,f.endA--,f.endB--);let m=c.doc.resolveNoCache(f.start-c.from),g=c.doc.resolveNoCache(f.endB-c.from),v=d.resolve(f.start),C=m.sameParent(g)&&m.parent.inlineContent&&v.end()>=f.endA,y;if((hn&&n.input.lastIOSEnter>Date.now()-225&&(!C||s.some(k=>k.nodeName=="DIV"||k.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",k=>k(n,St(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>f.start&&u1(d,f.start,f.endA,m,g)&&n.someProp("handleKeyDown",k=>k(n,St(8,"Backspace")))){Te&&re&&n.domObserver.suppressSelectionUpdates();return}re&&Te&&f.endB==f.start&&(n.input.lastAndroidDelete=Date.now()),Te&&!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(k){return k(n,St(13,"Enter"))})},20));let b=f.start,S=f.endA,x,w,E;if(C){if(m.pos==g.pos)he&&at<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ue(n),20)),x=n.state.tr.delete(b,S),w=d.resolve(f.start).marksAcross(d.resolve(f.endA));else if(f.endA==f.endB&&(E=d1(m.parent.content.cut(m.parentOffset,g.parentOffset),v.parent.content.cut(v.parentOffset,f.endA-v.start()))))x=n.state.tr,E.type=="add"?x.addMark(b,S,E.mark):x.removeMark(b,S,E.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let k=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",M=>M(n,b,S,k)))return;x=n.state.tr.insertText(k,b,S)}}if(x||(x=n.state.tr.replace(b,S,c.doc.slice(f.start-c.from,f.endB-c.from))),c.sel){let k=_l(n,x.doc,c.sel);k&&!(re&&Te&&n.composing&&k.empty&&(f.start!=f.endB||n.input.lastAndroidDelete<Date.now()-100)&&(k.head==b||k.head==x.mapping.map(S)-1)||he&&k.empty&&k.head==b)&&x.setSelection(k)}w&&x.ensureMarks(w),r&&x.setMeta("composition",r),n.dispatch(x.scrollIntoView())}function _l(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Qr(n,e.resolve(t.anchor),e.resolve(t.head))}function d1(n,e){let t=n.firstChild.marks,o=e.firstChild.marks,s=t,r=o,i,l,a;for(let d=0;d<o.length;d++)s=o[d].removeFromSet(s);for(let d=0;d<t.length;d++)r=t[d].removeFromSet(r);if(s.length==1&&r.length==0)l=s[0],i="add",a=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&r.length==1)l=r[0],i="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(T.from(c).eq(n))return{mark:l,type:i}}function u1(n,e,t,o,s){if(t-e<=s.pos-o.pos||Bs(o,!0,!1)<s.pos)return!1;let r=n.resolve(e);if(!o.parent.isTextblock){let l=r.nodeAfter;return l!=null&&t==e+l.nodeSize}if(r.parentOffset<r.parent.content.size||!r.parent.isTextblock)return!1;let i=n.resolve(Bs(r,!0,!0));return!i.parent.isTextblock||i.pos>t||Bs(i,!0,!1)<t?!1:o.parent.content.cut(o.parentOffset).eq(i.parent.content)}function Bs(n,e,t){let o=n.depth,s=e?n.end():n.pos;for(;o>0&&(e||n.indexAfter(o)==n.node(o).childCount);)o--,s++,e=!1;if(t){let r=n.node(o).maybeChild(n.indexAfter(o));for(;r&&!r.isLeaf;)r=r.firstChild,s++}return s}function p1(n,e,t,o,s){let r=n.findDiffStart(e,t);if(r==null)return null;let{a:i,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,r-Math.min(i,l));o-=i+a-r}if(i<r&&n.size<e.size){let a=o<=r&&o>=i?r-o:0;r-=a,r&&r<e.size&&Gl(e.textBetween(r-1,r+1))&&(r+=a?1:-1),l=r+(l-i),i=r}else if(l<r){let a=o<=r&&o>=l?r-o:0;r-=a,r&&r<n.size&&Gl(n.textBetween(r-1,r+1))&&(r+=a?1:-1),i=r+(i-l),l=r}return{start:r,endA:i,endB:l}}function Gl(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 h1{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 Og,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Kl),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=ql(this),jl(this),this.nodeViews=Ul(this),this.docView=kl(this.state.doc,Wl(this),zs(this),this.dom,this),this.domObserver=new n1(this,(o,s,r,i)=>c1(this,o,s,r,i)),this.domObserver.start(),Rg(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&wr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Kl),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let o in this._props)t[o]=this._props[o];t.state=this.state;for(let o in e)t[o]=e[o];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var o;let s=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(Md(this),i=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Ul(this);m1(h,this.nodeViews)&&(this.nodeViews=h,r=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&wr(this),this.editable=ql(this),jl(this);let a=zs(this),c=Wl(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=r||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(s.selection))&&(i=!0);let p=d=="preserve"&&i&&this.dom.style.overflowAnchor==null&&Um(this);if(i){this.domObserver.stop();let h=u&&(he||re)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&f1(s.selection,e.selection);if(u){let f=re?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=qg(this)),(r||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=kl(e.doc,c,a,this.dom,this)),f&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&yg(this))?Ue(this,h):(fd(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((o=this.dragging)===null||o===void 0)&&o.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():p&&Km(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof R){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&bl(this,t.getBoundingClientRect(),e)}else bl(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let o=this.directPlugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let o=this.state.plugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let o=this.pluginViews[t];o.update&&o.update(this,e)}}updateDraggedNode(e,t){let o=e.node,s=-1;if(this.state.doc.nodeAt(o.from)==o.node)s=o.from;else{let r=o.from+(this.state.doc.content.size-t.doc.content.size);(r>0&&this.state.doc.nodeAt(r))==o.node&&(s=r)}this.dragging=new Pd(e.slice,e.move,s<0?void 0:R.create(this.state.doc,s))}someProp(e,t){let o=this._props&&this._props[e],s;if(o!=null&&(s=t?t(o):o))return s;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(s=t?t(l):l))return s}let r=this.state.plugins;if(r)for(let i=0;i<r.length;i++){let l=r[i].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(he){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Jm(this.dom),Ue(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 eg(this,e)}coordsAtPos(e,t=1){return id(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 rg(this,t||this.state,e)}pasteHTML(e,t){return Jn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Jn(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Dg(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],zs(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,$m())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return $g(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&&Fm(this.dom.ownerDocument)==this.dom&&s1(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Wl(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"),[pe.node(0,n.state.doc.content.size,e)]}function jl(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:pe.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function ql(n){return!n.someProp("editable",e=>e(n.state)===!1)}function f1(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 Ul(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 m1(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 Kl(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 Cr,kr;if(typeof WeakMap<"u"){let n=new WeakMap;Cr=e=>n.get(e),kr=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Cr=o=>{for(let s=0;s<n.length;s+=2)if(n[s]==o)return n[s+1]},kr=(o,s)=>(t==10&&(t=0),n[t++]=o,n[t++]=s)}var U=class{constructor(n,e,t,o){this.width=n,this.height=e,this.map=t,this.problems=o}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const o=e%this.width,s=e/this.width|0;let r=o+1,i=s+1;for(let l=1;r<this.width&&this.map[e+l]==t;l++)r++;for(let l=1;i<this.height&&this.map[e+this.width*l]==t;l++)i++;return{left:o,top:s,right:r,bottom:i}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:o,right:s,top:r,bottom:i}=this.findCell(n);return e=="horiz"?(t<0?o==0:s==this.width)?null:this.map[r*this.width+(t<0?o-1:s)]:(t<0?r==0:i==this.height)?null:this.map[o+this.width*(t<0?r-1:i)]}rectBetween(n,e){const{left:t,right:o,top:s,bottom:r}=this.findCell(n),{left:i,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,i),top:Math.min(s,a),right:Math.max(o,l),bottom:Math.max(r,c)}}cellsInRect(n){const e=[],t={};for(let o=n.top;o<n.bottom;o++)for(let s=n.left;s<n.right;s++){const r=o*this.width+s,i=this.map[r];t[i]||(t[i]=!0,!(s==n.left&&s&&this.map[r-1]==i||o==n.top&&o&&this.map[r-this.width]==i)&&e.push(i))}return e}positionAt(n,e,t){for(let o=0,s=0;;o++){const r=s+t.child(o).nodeSize;if(o==n){let i=e+n*this.width;const l=(n+1)*this.width;for(;i<l&&this.map[i]<s;)i++;return i==l?r-1:this.map[i]}s=r}}static get(n){return Cr(n)||kr(n,g1(n))}};function g1(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=y1(n),t=n.childCount,o=[];let s=0,r=null;const i=[];for(let c=0,d=e*t;c<d;c++)o[c]=0;for(let c=0,d=0;c<t;c++){const u=n.child(c);d++;for(let f=0;;f++){for(;s<o.length&&o[s]!=0;)s++;if(f==u.childCount)break;const m=u.child(f),{colspan:g,rowspan:v,colwidth:C}=m.attrs;for(let y=0;y<v;y++){if(y+c>=t){(r||(r=[])).push({type:"overlong_rowspan",pos:d,n:v-y});break}const b=s+y*e;for(let S=0;S<g;S++){o[b+S]==0?o[b+S]=d:(r||(r=[])).push({type:"collision",row:c,pos:d,n:g-S});const x=C&&C[S];if(x){const w=(b+S)%e*2,E=i[w];E==null||E!=x&&i[w+1]==1?(i[w]=x,i[w+1]=1):E==x&&i[w+1]++}}}s+=g,d+=m.nodeSize}const p=(c+1)*e;let h=0;for(;s<p;)o[s++]==0&&h++;h&&(r||(r=[])).push({type:"missing",row:c,n:h}),d++}const l=new U(e,t,o,r);let a=!1;for(let c=0;!a&&c<i.length;c+=2)i[c]!=null&&i[c+1]<t&&(a=!0);return a&&b1(l,i,n),l}function y1(n){let e=-1,t=!1;for(let o=0;o<n.childCount;o++){const s=n.child(o);let r=0;if(t)for(let i=0;i<o;i++){const l=n.child(i);for(let a=0;a<l.childCount;a++){const c=l.child(a);i+c.attrs.rowspan>o&&(r+=c.attrs.colspan)}}for(let i=0;i<s.childCount;i++){const l=s.child(i);r+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=r:e!=r&&(e=Math.max(e,r))}return e}function b1(n,e,t){n.problems||(n.problems=[]);const o={};for(let s=0;s<n.map.length;s++){const r=n.map[s];if(o[r])continue;o[r]=!0;const i=t.nodeAt(r);if(!i)throw new RangeError(`No cell with offset ${r} found`);let l=null;const a=i.attrs;for(let c=0;c<a.colspan;c++){const d=(s+c)%n.width,u=e[d*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=v1(a)))[c]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:r,colwidth:l})}}function v1(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Jl(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),o=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(i=>Number(i)):null,s=Number(n.getAttribute("colspan")||1),r={colspan:s,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:o&&o.length==s?o:null};for(const i in e){const l=e[i].getFromDOM,a=l&&l(n);a!=null&&(r[i]=a)}return r}function Zl(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 S1(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=>Jl(o,e)}],toDOM(o){return["td",Zl(o,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:o=>Jl(o,e)}],toDOM(o){return["th",Zl(o,e),0]}}}}function Ve(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 nt=new Qn("selectingCells");function oo(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 us(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 ri(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=oo(e.$head)||x1(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function x1(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 Tr(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function w1(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function ii(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Dd(n,e,t){const o=n.node(-1),s=U.get(o),r=n.start(-1),i=s.nextCell(n.pos-r,e,t);return i==null?null:n.node(0).resolve(r+i)}function fn(n,e,t=1){const o={...n,colspan:n.colspan-t};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(e,t),o.colwidth.some(s=>s>0)||(o.colwidth=null)),o}var Y=class Ge extends L{constructor(e,t=e){const o=e.node(-1),s=U.get(o),r=e.start(-1),i=s.rectBetween(e.pos-r,t.pos-r),l=e.node(0),a=s.cellsInRect(i).filter(d=>d!=t.pos-r);a.unshift(t.pos-r);const c=a.map(d=>{const u=o.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);const p=r+d+1;return new zc(l.resolve(p),l.resolve(p+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const o=e.resolve(t.map(this.$anchorCell.pos)),s=e.resolve(t.map(this.$headCell.pos));if(Tr(o)&&Tr(s)&&ii(o,s)){const r=this.$anchorCell.node(-1)!=o.node(-1);return r&&this.isRowSelection()?Ge.rowSelection(o,s):r&&this.isColSelection()?Ge.colSelection(o,s):new Ge(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),r={},i=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let d=a*t.width+s.left,u=s.left;u<s.right;u++,d++){const p=t.map[d];if(r[p])continue;r[p]=!0;const h=t.findCell(p);let f=e.nodeAt(p);if(!f)throw RangeError(`No cell with offset ${p} found`);const m=s.left-h.left,g=h.right-s.right;if(m>0||g>0){let v=f.attrs;if(m>0&&(v=fn(v,0,m)),g>0&&(v=fn(v,v.colspan-g,g)),h.left<s.left){if(f=f.type.createAndFill(v),!f)throw RangeError(`Could not create cell with attrs ${JSON.stringify(v)}`)}else f=f.type.create(v,f.content)}if(h.top<s.top||h.bottom>s.bottom){const v={...f.attrs,rowspan:Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top)};h.top<s.top?f=f.type.createAndFill(v):f=f.type.create(v,f.content)}c.push(f)}i.push(e.child(a).copy(T.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new A(T.from(l),1,1)}replace(e,t=A.empty){const o=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){const{$from:l,$to:a}=s[i],c=e.mapping.slice(o);e.replace(c.map(l.pos),c.map(a.pos),i?A.empty:t)}const r=L.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);r&&e.setSelection(r)}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),r=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let i=0;i<r.length;i++)e(t.nodeAt(r[i]),s+r[i])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const o=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const o=e.node(-1),s=U.get(o),r=e.start(-1),i=s.findCell(e.pos-r),l=s.findCell(t.pos-r),a=e.node(0);return i.top<=l.top?(i.top>0&&(e=a.resolve(r+s.map[i.left])),l.bottom<s.height&&(t=a.resolve(r+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(r+s.map[l.left])),i.bottom<s.height&&(e=a.resolve(r+s.map[s.width*(s.height-1)+i.right-1]))),new Ge(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=U.get(e),o=this.$anchorCell.start(-1),s=t.colCount(this.$anchorCell.pos-o),r=t.colCount(this.$headCell.pos-o);if(Math.min(s,r)>0)return!1;const i=s+this.$anchorCell.nodeAfter.attrs.colspan,l=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==t.width}eq(e){return e instanceof Ge&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const o=e.node(-1),s=U.get(o),r=e.start(-1),i=s.findCell(e.pos-r),l=s.findCell(t.pos-r),a=e.node(0);return i.left<=l.left?(i.left>0&&(e=a.resolve(r+s.map[i.top*s.width])),l.right<s.width&&(t=a.resolve(r+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(r+s.map[l.top*s.width])),i.right<s.width&&(e=a.resolve(r+s.map[s.width*(i.top+1)-1]))),new Ge(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Ge(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){return new Ge(e.resolve(t),e.resolve(o))}getBookmark(){return new C1(this.$anchorCell.pos,this.$headCell.pos)}};Y.prototype.visible=!1;L.jsonID("cell",Y);var C1=class Ld{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Ld(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&&ii(t,o)?new Y(t,o):L.near(o,1)}};function k1(n){if(!(n.selection instanceof Y))return null;const e=[];return n.selection.forEachCell((t,o)=>{e.push(pe.node(o,o+t.nodeSize,{class:"selectedCell"}))}),W.create(n.doc,e)}function T1({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,o=e.pos,s=n.depth;for(;s>=0&&!(n.after(s+1)<n.end(s));s--,t++);for(let r=e.depth;r>=0&&!(e.before(r+1)>e.start(r));r--,o--);return t==o&&/row|table/.test(n.node(s).type.spec.tableRole)}function E1({$from:n,$to:e}){let t,o;for(let s=n.depth;s>0;s--){const r=n.node(s);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){t=r;break}}for(let s=e.depth;s>0;s--){const r=e.node(s);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){o=r;break}}return t!==o&&e.parentOffset===0}function M1(n,e,t){const o=(e||n).selection,s=(e||n).doc;let r,i;if(o instanceof R&&(i=o.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")r=Y.create(s,o.from);else if(i=="row"){const l=s.resolve(o.from+1);r=Y.rowSelection(l,l)}else if(!t){const l=U.get(o.node),a=o.from+1,c=a+l.map[l.width*l.height-1];r=Y.create(s,a+1,c)}}else o instanceof $&&T1(o)?r=$.create(s,o.from):o instanceof $&&E1(o)&&(r=$.create(s,o.$from.start(),o.$from.end()));return r&&(e||(e=n.tr)).setSelection(r),e}var A1=new Qn("fix-tables");function $d(n,e,t,o){const s=n.childCount,r=e.childCount;e:for(let i=0,l=0;i<r;i++){const a=e.child(i);for(let c=l,d=Math.min(s,i+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}o(a,t),l<s&&n.child(l).sameMarkup(a)?$d(n.child(l),a,t+1,o):a.nodesBetween(0,a.content.size,o,t+1),t+=a.nodeSize}}function P1(n,e){let t;const o=(s,r)=>{s.type.spec.tableRole=="table"&&(t=I1(n,s,r,t))};return e?e.doc!=n.doc&&$d(e.doc,n.doc,0,o):n.doc.descendants(o),t}function I1(n,e,t,o){const s=U.get(e);if(!s.problems)return o;o||(o=n.tr);const r=[];for(let a=0;a<s.height;a++)r.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let p=0;p<u.rowspan;p++)r[c.row+p]+=c.n;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,fn(u,u.colspan-c.n,c.n))}else if(c.type=="missing")r[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}}let i,l;for(let a=0;a<r.length;a++)r[a]&&(i==null&&(i=a),l=a);for(let a=0,c=t+1;a<s.height;a++){const d=e.child(a),u=c+d.nodeSize,p=r[a];if(p>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const f=[];for(let g=0;g<p;g++){const v=Ve(n.schema)[h].createAndFill();v&&f.push(v)}const m=(a==0||i==a-1)&&l==a?c+1:u-1;o.insert(o.mapping.map(m),f)}c=u}return o.setMeta(A1,{fixTables:!0})}function zd(n){const e=n.selection,t=ri(n),o=t.node(-1),s=t.start(-1),r=U.get(o);return{...e instanceof Y?r.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):r.findCell(t.pos-s),tableStart:s,map:r,table:o}}function N1(n){return function(e,t){if(!us(e))return!1;if(t){const o=Ve(e.schema),s=zd(e),r=e.tr,i=s.map.cellsInRect(n=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:n=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=i.map(a=>s.table.nodeAt(a));for(let a=0;a<i.length;a++)l[a].type==o.header_cell&&r.setNodeMarkup(s.tableStart+i[a],o.cell,l[a].attrs);if(r.steps.length==0)for(let a=0;a<i.length;a++)r.setNodeMarkup(s.tableStart+i[a],o.header_cell,l[a].attrs);t(r)}return!0}}function Yl(n,e,t){const o=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let s=0;s<o.length;s++){const r=e.table.nodeAt(o[s]);if(r&&r.type!==t.header_cell)return!1}return!0}function li(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?N1(n):function(t,o){if(!us(t))return!1;if(o){const s=Ve(t.schema),r=zd(t),i=t.tr,l=Yl("row",r,s),a=Yl("column",r,s),d=(n==="column"?l:n==="row"?a:!1)?1:0,u=n=="column"?{left:0,top:d,right:1,bottom:r.map.height}:n=="row"?{left:d,top:0,right:r.map.width,bottom:1}:r,p=n=="column"?a?s.cell:s.header_cell:n=="row"?l?s.cell:s.header_cell:s.cell;r.map.cellsInRect(u).forEach(h=>{const f=h+r.tableStart,m=i.doc.nodeAt(f);m&&i.setNodeMarkup(f,p,m.attrs)}),o(i)}return!0}}li("row",{useDeprecatedLogic:!0});li("column",{useDeprecatedLogic:!0});li("cell",{useDeprecatedLogic:!0});function O1(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let o=n.index(-1)-1,s=n.before();o>=0;o--){const r=n.node(-1).child(o),i=r.lastChild;if(i)return s-1-i.nodeSize;s-=r.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let o=n.indexAfter(-1),s=n.after();o<t.childCount;o++){const r=t.child(o);if(r.childCount)return s+1;s+=r.nodeSize}}return null}function Xl(n){return function(e,t){if(!us(e))return!1;const o=O1(ri(e),n);if(o==null)return!1;if(t){const s=e.doc.resolve(o);t(e.tr.setSelection($.between(s,w1(s))).scrollIntoView())}return!0}}function yo(n,e){const t=n.selection;if(!(t instanceof Y))return!1;if(e){const o=n.tr,s=Ve(n.schema).cell.createAndFill().content;t.forEachCell((r,i)=>{r.content.eq(s)||o.replace(o.mapping.map(i+1),o.mapping.map(i+r.nodeSize-1),new A(s,0,0))}),o.docChanged&&e(o)}return!0}function R1(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:o}=n;for(;e.childCount==1&&(t>0&&o>0||e.child(0).type.spec.tableRole=="table");)t--,o--,e=e.child(0).content;const s=e.child(0),r=s.type.spec.tableRole,i=s.type.schema,l=[];if(r=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),u=a<e.childCount-1?0:Math.max(0,o-1);(d||u)&&(c=Er(Ve(i).row,new A(c,d,u)).content),l.push(c)}else if(r=="cell"||r=="header_cell")l.push(t||o?Er(Ve(i).row,new A(e,t,o)).content:e);else return null;return D1(i,l)}function D1(n,e){const t=[];for(let s=0;s<e.length;s++){const r=e[s];for(let i=r.childCount-1;i>=0;i--){const{rowspan:l,colspan:a}=r.child(i).attrs;for(let c=s;c<s+l;c++)t[c]=(t[c]||0)+a}}let o=0;for(let s=0;s<t.length;s++)o=Math.max(o,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(T.empty),t[s]<o){const r=Ve(n).cell.createAndFill(),i=[];for(let l=t[s];l<o;l++)i.push(r);e[s]=e[s].append(T.from(i))}return{height:e.length,width:o,rows:e}}function Er(n,e){const t=n.createAndFill();return new $c(t).replace(0,t.content.size,e).doc}function L1({width:n,height:e,rows:t},o,s){if(n!=o){const r=[],i=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=r[l]||0,u=0;d<o;u++){let p=a.child(u%a.childCount);d+p.attrs.colspan>o&&(p=p.type.createChecked(fn(p.attrs,p.attrs.colspan,d+p.attrs.colspan-o),p.content)),c.push(p),d+=p.attrs.colspan;for(let h=1;h<p.attrs.rowspan;h++)r[l+h]=(r[l+h]||0)+p.attrs.colspan}i.push(T.from(c))}t=i,n=o}if(e!=s){const r=[];for(let i=0,l=0;i<s;i++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);i+u.attrs.rowspan>s&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,s-u.attrs.rowspan)},u.content)),a.push(u)}r.push(T.from(a))}t=r,e=s}return{width:n,height:e,rows:t}}function $1(n,e,t,o,s,r,i){const l=n.doc.type.schema,a=Ve(l);let c,d;if(s>e.width)for(let u=0,p=0;u<e.height;u++){const h=t.child(u);p+=h.nodeSize;const f=[];let m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=d||(d=a.header_cell.createAndFill());for(let g=e.width;g<s;g++)f.push(m);n.insert(n.mapping.slice(i).map(p-1+o),f)}if(r>e.height){const u=[];for(let f=0,m=(e.height-1)*e.width;f<Math.max(e.width,s);f++){const g=f>=e.width?!1:t.nodeAt(e.map[m+f]).type==a.header_cell;u.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const p=a.row.create(null,T.from(u)),h=[];for(let f=e.height;f<r;f++)h.push(p);n.insert(n.mapping.slice(i).map(o+t.nodeSize-2),h)}return!!(c||d)}function Ql(n,e,t,o,s,r,i,l){if(i==0||i==e.height)return!1;let a=!1;for(let c=s;c<r;c++){const d=i*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){a=!0;const p=t.nodeAt(u),{top:h,left:f}=e.findCell(u);n.setNodeMarkup(n.mapping.slice(l).map(u+o),null,{...p.attrs,rowspan:i-h}),n.insert(n.mapping.slice(l).map(e.positionAt(i,f,t)),p.type.createAndFill({...p.attrs,rowspan:h+p.attrs.rowspan-i})),c+=p.attrs.colspan-1}}return a}function ea(n,e,t,o,s,r,i,l){if(i==0||i==e.width)return!1;let a=!1;for(let c=s;c<r;c++){const d=c*e.width+i,u=e.map[d];if(e.map[d-1]==u){a=!0;const p=t.nodeAt(u),h=e.colCount(u),f=n.mapping.slice(l).map(u+o);n.setNodeMarkup(f,null,fn(p.attrs,i-h,p.attrs.colspan-(i-h))),n.insert(f+p.nodeSize,p.type.createAndFill(fn(p.attrs,0,i-h))),c+=p.attrs.rowspan-1}}return a}function ta(n,e,t,o,s){let r=t?n.doc.nodeAt(t-1):n.doc;if(!r)throw new Error("No table found");let i=U.get(r);const{top:l,left:a}=o,c=a+s.width,d=l+s.height,u=n.tr;let p=0;function h(){if(r=t?u.doc.nodeAt(t-1):u.doc,!r)throw new Error("No table found");i=U.get(r),p=u.mapping.maps.length}$1(u,i,r,t,c,d,p)&&h(),Ql(u,i,r,t,a,c,l,p)&&h(),Ql(u,i,r,t,a,c,d,p)&&h(),ea(u,i,r,t,l,d,a,p)&&h(),ea(u,i,r,t,l,d,c,p)&&h();for(let f=l;f<d;f++){const m=i.positionAt(f,a,r),g=i.positionAt(f,c,r);u.replace(u.mapping.slice(p).map(m+t),u.mapping.slice(p).map(g+t),new A(s.rows[f-l],0,0))}h(),u.setSelection(new Y(u.doc.resolve(t+i.positionAt(l,a,r)),u.doc.resolve(t+i.positionAt(d-1,c-1,r)))),e(u)}var z1=Qc({ArrowLeft:bo("horiz",-1),ArrowRight:bo("horiz",1),ArrowUp:bo("vert",-1),ArrowDown:bo("vert",1),"Shift-ArrowLeft":vo("horiz",-1),"Shift-ArrowRight":vo("horiz",1),"Shift-ArrowUp":vo("vert",-1),"Shift-ArrowDown":vo("vert",1),Backspace:yo,"Mod-Backspace":yo,Delete:yo,"Mod-Delete":yo});function Po(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function bo(n,e){return(t,o,s)=>{if(!s)return!1;const r=t.selection;if(r instanceof Y)return Po(t,o,L.near(r.$headCell,e));if(n!="horiz"&&!r.empty)return!1;const i=Bd(s,n,e);if(i==null)return!1;if(n=="horiz")return Po(t,o,L.near(t.doc.resolve(r.head+e),e));{const l=t.doc.resolve(i),a=Dd(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),Po(t,o,c)}}}function vo(n,e){return(t,o,s)=>{if(!s)return!1;const r=t.selection;let i;if(r instanceof Y)i=r;else{const a=Bd(s,n,e);if(a==null)return!1;i=new Y(t.doc.resolve(a))}const l=Dd(i.$headCell,n,e);return l?Po(t,o,new Y(i.$anchorCell,l)):!1}}function B1(n,e){const t=n.state.doc,o=oo(t.resolve(e));return o?(n.dispatch(n.state.tr.setSelection(new Y(o))),!0):!1}function V1(n,e,t){if(!us(n.state))return!1;let o=R1(t);const s=n.state.selection;if(s instanceof Y){o||(o={width:1,height:1,rows:[T.from(Er(Ve(n.state.schema).cell,t))]});const r=s.$anchorCell.node(-1),i=s.$anchorCell.start(-1),l=U.get(r).rectBetween(s.$anchorCell.pos-i,s.$headCell.pos-i);return o=L1(o,l.right-l.left,l.bottom-l.top),ta(n.state,n.dispatch,i,l,o),!0}else if(o){const r=ri(n.state),i=r.start(-1);return ta(n.state,n.dispatch,i,U.get(r.node(-1)).findCell(r.pos-i),o),!0}else return!1}function H1(n,e){var t;if(e.ctrlKey||e.metaKey)return;const o=na(n,e.target);let s;if(e.shiftKey&&n.state.selection instanceof Y)r(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(s=oo(n.state.selection.$anchor))!=null&&((t=Vs(n,e))==null?void 0:t.pos)!=s.pos)r(s,e),e.preventDefault();else if(!o)return;function r(a,c){let d=Vs(n,c);const u=nt.getState(n.state)==null;if(!d||!ii(a,d))if(u)d=a;else return;const p=new Y(a,d);if(u||!n.state.selection.eq(p)){const h=n.state.tr.setSelection(p);u&&h.setMeta(nt,a.pos),n.dispatch(h)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",l),nt.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(nt,-1))}function l(a){const c=a,d=nt.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(na(n,c.target)!=o&&(u=Vs(n,e),!u))return i();u&&r(u,c)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",l)}function Bd(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 r=o.node(s);if((t<0?o.index(s):o.indexAfter(s))!=(t<0?0:r.childCount))return null;if(r.type.spec.tableRole=="cell"||r.type.spec.tableRole=="header_cell"){const l=o.before(s),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function na(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Vs(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?oo(n.state.doc.resolve(t.pos)):null}var F1=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")),Mr(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,Mr(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function Mr(n,e,t,o,s,r){var i;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let u=0,p=0;u<d.childCount;u++){const{colspan:h,colwidth:f}=d.child(u).attrs;for(let m=0;m<h;m++,p++){const g=s==p?r:f&&f[m],v=g?g+"px":"";if(l+=g||o,g||(a=!1),c)c.style.width!=v&&(c.style.width=v),c=c.nextSibling;else{const C=document.createElement("col");C.style.width=v,e.appendChild(C)}}}for(;c;){const u=c.nextSibling;(i=c.parentNode)==null||i.removeChild(c),c=u}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var ge=new Qn("tableColumnResizing");function _1({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:o=F1,lastColumnResizable:s=!0}={}){const r=new yn({key:ge,state:{init(i,l){var a,c;const d=(c=(a=r.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,u=Ve(l.schema).table.name;return o&&d&&(d[u]=(p,h)=>new o(p,t,h)),new G1(-1,!1)},apply(i,l){return l.apply(i)}},props:{attributes:i=>{const l=ge.getState(i);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(i,l)=>{W1(i,l,n,s)},mouseleave:i=>{j1(i)},mousedown:(i,l)=>{q1(i,l,e,t)}},decorations:i=>{const l=ge.getState(i);if(l&&l.activeHandle>-1)return Y1(i,l.activeHandle)},nodeViews:{}}});return r}var G1=class Io{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,o=e.getMeta(ge);if(o&&o.setHandle!=null)return new Io(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new Io(t.activeHandle,o.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);return Tr(e.doc.resolve(s))||(s=-1),new Io(s,t.dragging)}return t}};function W1(n,e,t,o){const s=ge.getState(n.state);if(s&&!s.dragging){const r=K1(e.target);let i=-1;if(r){const{left:l,right:a}=r.getBoundingClientRect();e.clientX-l<=t?i=oa(n,e,"left",t):a-e.clientX<=t&&(i=oa(n,e,"right",t))}if(i!=s.activeHandle){if(!o&&i!==-1){const l=n.state.doc.resolve(i),a=l.node(-1),c=U.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Vd(n,i)}}}function j1(n){const e=ge.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Vd(n,-1)}function q1(n,e,t,o){var s;const r=(s=n.dom.ownerDocument.defaultView)!=null?s:window,i=ge.getState(n.state);if(!i||i.activeHandle==-1||i.dragging)return!1;const l=n.state.doc.nodeAt(i.activeHandle),a=U1(n,i.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(ge,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){r.removeEventListener("mouseup",c),r.removeEventListener("mousemove",d);const p=ge.getState(n.state);p!=null&&p.dragging&&(J1(n,p.activeHandle,sa(p.dragging,u,t)),n.dispatch(n.state.tr.setMeta(ge,{setDragging:null})))}function d(u){if(!u.which)return c(u);const p=ge.getState(n.state);if(p&&p.dragging){const h=sa(p.dragging,u,t);ra(n,p.activeHandle,h,o)}}return ra(n,i.activeHandle,a,o),r.addEventListener("mouseup",c),r.addEventListener("mousemove",d),e.preventDefault(),!0}function U1(n,e,{colspan:t,colwidth:o}){const s=o&&o[o.length-1];if(s)return s;const r=n.domAtPos(e);let l=r.node.childNodes[r.offset].offsetWidth,a=t;if(o)for(let c=0;c<t;c++)o[c]&&(l-=o[c],a--);return l/a}function K1(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function oa(n,e,t,o){const s=t=="right"?-o:o,r=n.posAtCoords({left:e.clientX+s,top:e.clientY});if(!r)return-1;const{pos:i}=r,l=oo(n.state.doc.resolve(i));if(!l)return-1;if(t=="right")return l.pos;const a=U.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function sa(n,e,t){const o=e.clientX-n.startX;return Math.max(t,n.startWidth+o)}function Vd(n,e){n.dispatch(n.state.tr.setMeta(ge,{setHandle:e}))}function J1(n,e,t){const o=n.state.doc.resolve(e),s=o.node(-1),r=U.get(s),i=o.start(-1),l=r.colCount(o.pos-i)+o.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<r.height;c++){const d=c*r.width+l;if(c&&r.map[d]==r.map[d-r.width])continue;const u=r.map[d],p=s.nodeAt(u).attrs,h=p.colspan==1?0:l-r.colCount(u);if(p.colwidth&&p.colwidth[h]==t)continue;const f=p.colwidth?p.colwidth.slice():Z1(p.colspan);f[h]=t,a.setNodeMarkup(i+u,null,{...p,colwidth:f})}a.docChanged&&n.dispatch(a)}function ra(n,e,t,o){const s=n.state.doc.resolve(e),r=s.node(-1),i=s.start(-1),l=U.get(r).colCount(s.pos-i)+s.nodeAfter.attrs.colspan-1;let a=n.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Mr(r,a.firstChild,a,o,l,t)}function Z1(n){return Array(n).fill(0)}function Y1(n,e){var t;const o=[],s=n.doc.resolve(e),r=s.node(-1);if(!r)return W.empty;const i=U.get(r),l=s.start(-1),a=i.colCount(s.pos-l)+s.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){const d=a+c*i.width;if((a==i.width-1||i.map[d]!=i.map[d+1])&&(c==0||i.map[d]!=i.map[d-i.width])){const u=i.map[d],p=l+u+r.nodeAt(u).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",(t=ge.getState(n))!=null&&t.dragging&&o.push(pe.node(l+u,l+u+r.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),o.push(pe.widget(p,h))}}return W.create(n.doc,o)}function X1({allowTableNodeSelection:n=!1}={}){return new yn({key:nt,state:{init(){return null},apply(e,t){const o=e.getMeta(nt);if(o!=null)return o==-1?null:o;if(t==null||!e.docChanged)return t;const{deleted:s,pos:r}=e.mapping.mapResult(t);return s?null:r}},props:{decorations:k1,handleDOMEvents:{mousedown:H1},createSelectionBetween(e){return nt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:B1,handleKeyDown:z1,handlePaste:V1},appendTransaction(e,t,o){return M1(o,P1(o,t),n)}})}const Ln=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},ia="data-gs-mrk-fs",la="data-gs-ib",Yo="data-gs-ifrg",Ke="attrs",Hd={[Ke]:{default:"{}"}},Fe={[Ke]:{default:{}}},Fd=n=>({[Ke]:JSON.stringify(Ln(n))}),_e=n=>({attrs:Ln(n)}),xn=n=>e=>[n,e.attrs.attrs,0],et=n=>n.attrs[Ke]?JSON.parse(n.attrs[Ke]):{},Q1={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${Yo}]`,getAttrs:_e}],toDOM:()=>["span",{[Yo]:""},0]},div:{group:"block",content:"inline*",attrs:Fe,parseDOM:[{tag:"div",getAttrs:_e}],toDOM:xn("div")},paragraph:{group:"block",content:"inline*",attrs:Fe,parseDOM:[{tag:"p",getAttrs:_e}],toDOM:xn("p")},orderedList:{group:"block",content:"listItem+",attrs:Fe,parseDOM:[{tag:"ol",getAttrs:_e}],toDOM:xn("ol")},bulletList:{group:"block",content:"listItem+",attrs:Fe,parseDOM:[{tag:"ul",getAttrs:_e}],toDOM:xn("ul")},listItem:{content:"block*",group:"block",attrs:Fe,parseDOM:[{tag:"li",getAttrs:_e}],toDOM:xn("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:Fe,parseDOM:[{tag:"pre",getAttrs:_e}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:Fe,parseDOM:[{tag:"img[src]",getAttrs:_e}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${la}]`}],toDOM(){return["br",{[la]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:Fe,parseDOM:[{tag:"br",getAttrs:_e}],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:Ln(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...S1({tableGroup:"block",cellContent:"block+",cellAttributes:{[Ke]:{default:Fe[Ke].default,getFromDOM:Ln,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:Ln(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},wn=(n,e)=>({attrs:Hd,parseDOM:n.map(t=>({tag:t,getAttrs:Fd})),toDOM:e}),e0={strong:wn(["strong","b"],n=>["b",et(n)]),link:wn(["a"],n=>["a",et(n),0]),em:wn(["em","i"],n=>["em",et(n)]),underline:wn(["u"],n=>["u",et(n),0]),strikethrough:wn(["s"],n=>["s",et(n),0]),font_size:{attrs:{...Hd,size:{default:null}},parseDOM:[{tag:`span[${ia}]`,getAttrs:n=>({...Fd(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...et(n),[ia]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},aa=new vf({nodes:Q1,marks:e0}),ps=new WeakMap,ai=new WeakMap,t0=(n,e)=>{ps.set(n,e),ai.set(e,n)},n0=(n,e)=>{ps.delete(n),ai.delete(e)},Hs=n=>ps.get(n),o0=n=>ai.get(n),ca=n=>{var t;const e=o0(n);return(t=e==null?void 0:e.__gjsv)==null?void 0:t.model},s0=n=>n.dispatchEvent(new CustomEvent("input"));function r0(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(Yo)){if(t.getAttribute("style")){t.removeAttribute(Yo);return}const o=t.parentElement;if(o){for(;t.firstChild;)o.insertBefore(t.firstChild,t);o.removeChild(t)}}else Array.from(t.children).forEach(o=>e(o))};e(n)}function i0(n,e={}){if(!e.enableOnClick)return()=>{};const t=n.Components.events,o=d=>n.getSelectedAll().includes(d),s=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),r=d=>d.isChildOf("text"),i=d=>n.getEditing()===d,l=(d,u={})=>{d.trigger("focus",u.event)},a=(d,u)=>{o(d)&&s(d)&&!i(d)&&l(d,u)},c=(d,u)=>{if(o(d)&&!s(d)&&r(d)){const p=d.parents().find(h=>h.isInstanceOf("text"));p&&(l(p,u),setTimeout(()=>n.select(p),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const l0=(n,e)=>{const t=a0(n);return t&&y0(t)?c0(n,e):t?jc(()=>({type:n.schema.nodes.div}))(n,e):!1};function a0(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 c0(n,e){const{selection:t,schema:o,tr:s}=n;s.split(t.from,1);const r=t.from+1,i=s.doc.nodeAt(r),l={...i.attrs.attrs,id:void 0},a=i.textContent.length>0,c=i.textContent.length||0,d=i.textContent||" ",u=o.text(d),p=o.nodes.div.create(l,a?u:[],[]);return s.replaceRangeWith(r,r+c+2,p),s.setSelection($.create(s.doc,r+1)),e==null||e(s.scrollIntoView()),!0}function d0(n,e,t){const{state:o,dispatch:s}=n,{selection:r,tr:i}=o,l=(a,c,d)=>{const u={};return a.split(";").forEach(p=>{const[h,f]=p.split(":").map(m=>m.trim());h&&(u[h]=f)}),u[c]=d,Object.entries(u).map(([p,h])=>`${p}: ${h}`).join("; ")};if(!r.empty||t)i.doc.nodesBetween(r.from,r.to,(a,c)=>{var d,u;if(a.type===o.schema.nodes.image){const p=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);i.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:p}})}else if(a.type.isBlock){const p=l(((u=a.attrs.attrs)==null?void 0:u.style)||"","text-align",e);_d(a)?i.setBlockType(r.from,void 0,o.schema.nodes.div,{attrs:{style:p}}):i.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:p}})}});else{const a=o.doc.resolve(r.from),c=a.start(a.depth),d=o.doc.nodeAt(c);if(d!=null&&d.type.isBlock){const u=l(d.attrs.style||"","text-align",e);i.setNodeMarkup(c,void 0,{...d.attrs,style:u})}}i.docChanged&&s(i.scrollIntoView())}const Cn=(n,e)=>{const{from:t,to:o}=n.selection;let s=!1;return n.doc.nodesBetween(t,o,r=>{if(s)return!1;r.marks.some(i=>i.type===e)&&(s=!0)}),s};function u0(n,e,t="_blank"){const{state:o,dispatch:s}=n,{schema:r,selection:i,tr:l}=o,a=r.marks.link;try{const c=a.create({[Ke]:JSON.stringify({href:e,target:t})});l.addMark(i.from,i.to,c),s(l.scrollIntoView())}catch(c){console.error("Error applying link mark:",c)}}function p0(n,e){const{state:t,dispatch:o}=n,{selection:s,tr:r}=t;if(s.empty)return;const i=t.schema.marks.font_size;if(!i){console.error("Font size mark is not defined in the schema.");return}r.addMark(s.from,s.to,i.create({size:e})),o(r.scrollIntoView())}const Tt=(n,e)=>{const{doc:t,selection:o}=n.state,s=t.resolve(o.from);for(let r=s.depth;r>0;r--){const i=s.node(r);if(e(i))return{pos:r>0?s.before(r):0,start:s.start(r),depth:r,node:i}}},h0=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 f0(...n){return(e,t)=>{const o=i=>{e=e.apply(i),t==null||t(i)},s=n.pop();return n.reduce((i,l)=>i||l(e,o),!1)&&s!==void 0&&s(e,t)}}const m0=(n,e)=>{const{state:t,dispatch:o}=n;if(e!=null&&e.event){const{event:s}=e,r=n.posAtCoords({left:s.clientX,top:s.clientY});r!=null&&r.pos&&o(t.tr.setSelection($.create(t.doc,r.pos)))}else qc(t,o);setTimeout(()=>setTimeout(()=>n.focus()))},Ar=n=>n.isBlock,_d=n=>n.type.name==="inlineFragment",g0=n=>Ar(n)&&!_d(n),Gd=n=>n.type.name==="bulletList",Wd=n=>n.type.name==="orderedList",y0=n=>n.type.name==="heading",b0=n=>Gd(n)||Wd(n),da=(n,e)=>{var r,i;const t=(r=Tt(n,l=>l.type===e))==null?void 0:r.node,o=n.state.schema.nodes.listItem;let s;return t?s=pr(o):(i=Tt(n,b0))!=null&&i.node?s=f0(pr(o),ml(e)):s=ml(e),s(n.state,n.dispatch)},jd=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(o=>o.type.name===e)},v0=n=>{var i;const{view:e,prop:t,editor:o,propCSS:s}=n,r=(i=Tt(e,g0))==null?void 0:i.node;if(r){const l=r.attrs.attrs||{},a=h0(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""},S0=n=>{const{view:e,prop:t,markName:o,editor:s,propCSS:r}=n,i=jd(e,o);if(i){const l=i.attrs;if(l[t])return l[t];if(l[Ke]){const a=et(i).id;if(a){const c=s.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[r]||""}}}return""},qd=(n,e)=>{const{dispatch:t}=n,{nodes:o,marks:s}=n.state.schema;return{text:{selected:()=>{const{selection:r,doc:i}=n.state;return i.textBetween(r.from,r.to," ")},replace:(r,i={})=>{const{state:l}=n,{from:a}=l.selection;let c=l.tr.replaceSelectionWith(l.schema.text(r));i.select&&(c=c.setSelection($.create(c.doc,a,a+r.length))),t==null||t(c)}},bold:{toggle:()=>vt(s.strong)(n.state,t),isActive:()=>Cn(n.state,s.strong)},italic:{toggle:()=>vt(s.em)(n.state,t),isActive:()=>Cn(n.state,s.em)},underline:{toggle:()=>vt(s.underline)(n.state,t),isActive:()=>Cn(n.state,s.underline)},strikethrough:{toggle:()=>vt(s.strikethrough)(n.state,t),isActive:()=>Cn(n.state,s.strikethrough)},link:{get:()=>{const r=ca(n);if(r!=null&&r.is("link"))return r.getAttributes();{const i=jd(n,"link");return i?et(i):{}}},toggle:()=>vt(s.link)(n.state,t),isActive:()=>Cn(n.state,s.link),create:r=>{const i=ca(n);i!=null&&i.is("link")?(i.addAttributes({href:r.url,target:r.target}),n.focus()):u0(n,r.url,r.target)}},alignText:{get:()=>v0({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:r=>d0(n,r.value,!0)},fontSize:{get:()=>S0({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:r=>p0(n,r.value)},image:{open(){const r="assetLayout",{state:i,dispatch:l}=n,{selection:a,doc:c}=i,d=c.textBetween(a.from,a.to," "),u={id:r,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:p=>{const h={alt:d,src:p.asset.getSrc()};l(i.tr.replaceSelectionWith(o.image.createAndFill({attrs:h})))}}};e.runCommand(F.layoutToggle,u)}},heading:{get:()=>{var i;const r=(i=Tt(n,Ar))==null?void 0:i.node;return`${(r==null?void 0:r.attrs.level)||""}`},set:({value:r})=>{var a;const{state:i}=n,l=(a=Tt(n,Ar))==null?void 0:a.node;pm(i.schema.nodes.heading,{attrs:l==null?void 0:l.attrs.attrs,level:r?parseInt(r,10):0})(i,t)}},listBullet:{isActive:()=>{var r;return!!((r=Tt(n,Gd))!=null&&r.node)},toggle:()=>da(n,o.bulletList)},listOrdered:{isActive:()=>{var r;return!!((r=Tt(n,Wd))!=null&&r.node)},toggle:()=>da(n,o.orderedList)}}};class ft{constructor(e,t,o={}){this.match=e,this.match=e,this.handler=typeof t=="string"?x0(t):t,this.undoable=o.undoable!==!1,this.inCode=o.inCode||!1}}function x0(n){return function(e,t,o,s){let r=n;if(t[1]){let i=t[0].lastIndexOf(t[1]);r+=t[0].slice(i+t[1].length),o+=i;let l=o-s;l>0&&(r=t[0].slice(i-l,i)+r,o=s)}return e.tr.insertText(r,o,s)}}const w0=500;function C0({rules:n}){let e=new yn({state:{init(){return null},apply(t,o){let s=t.getMeta(this);return s||(t.selectionSet||t.docChanged?null:o)}},props:{handleTextInput(t,o,s,r){return ua(t,o,s,r,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:o}=t.state.selection;o&&ua(t,o.pos,o.pos,"",n,e)})}}},isInputRules:!0});return e}function ua(n,e,t,o,s,r){if(n.composing)return!1;let i=n.state,l=i.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-w0),l.parentOffset,null,"")+o;for(let c=0;c<s.length;c++){let d=s[c];if(l.parent.type.spec.code){if(!d.inCode)continue}else if(d.inCode==="only")continue;let u=d.match.exec(a),p=u&&d.handler(i,u,e-(u[0].length-o.length),t);if(p)return d.undoable&&p.setMeta(r,{transform:p,from:e,to:t,text:o}),n.dispatch(p),!0}return!1}const k0=new ft(/--$/,"—"),T0=new ft(/\.\.\.$/,"…"),E0=new ft(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),M0=new ft(/"$/,"”"),A0=new ft(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),P0=new ft(/'$/,"’"),I0=[E0,M0,A0,P0];function ci(n,e,t=null,o){return new ft(n,(s,r,i,l)=>{let a=t instanceof Function?t(r):t,c=s.tr.delete(i,l),d=c.doc.resolve(i),u=d.blockRange(),p=u&&Pc(u,e,a);if(!p)return null;c.wrap(u,p);let h=c.doc.resolve(i-1).nodeBefore;return h&&h.type==e&&is(c.doc,i-1)&&(!o||o(r,h))&&c.join(i-1),c})}function Ud(n,e,t=null){return new ft(n,(o,s,r,i)=>{let l=o.doc.resolve(r),a=t instanceof Function?t(s):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?o.tr.delete(r,i).setBlockType(r,r,e,a):null})}function N0(n){return ci(/^\s*>\s$/,n)}function O0(n){return ci(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function R0(n){return ci(/^\s*([-+*])\s$/,n)}function D0(n){return Ud(/^```$/,n)}function L0(n,e){return Ud(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function $0(n){const e=I0.concat(T0,k0);let t;return(t=n.nodes.blockquote)&&e.push(N0(t)),(t=n.nodes.orderedList)&&e.push(O0(t)),(t=n.nodes.bulletList)&&e.push(R0(t)),(t=n.nodes.codeBlock)&&e.push(D0(t)),(t=n.nodes.heading)&&e.push(L0(t,6)),C0({rules:e})}const z0="rteProseMirror",B0=H.free,ke="rte:selectionchange",ve={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>'},V0=(n,e)=>{var a;const{editor:t,el:o}=n,s=ps.get(o),r=qd(s,t),i={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},bold:{id:"bold",icon:ve.bold,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:r.bold.isActive()})}},onClick:({setState:c})=>{r.bold.toggle(),c({active:r.bold.isActive()})}},italic:{id:"italic",icon:ve.italic,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:r.italic.isActive()})}},onClick:({setState:c})=>{r.italic.toggle(),c({active:r.italic.isActive()})}},underline:{id:"underline",icon:ve.underline,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:r.underline.isActive()})}},onClick:({setState:c})=>{r.underline.toggle(),c({active:r.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:ve.strikethrough,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:r.strikethrough.isActive()})}},onClick:({setState:c})=>{r.strikethrough.toggle(),c({active:r.strikethrough.isActive()})}},image:{id:"image",icon:ve.image,size:"s",type:"button",onClick:()=>r.image.open()},link:{id:"link",icon:ve.link,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:r.link.isActive(),disabled:s.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,{x:u,y:p,width:h,height:f}=d.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(F.layoutRemove,{id:m}),v=r.link.get(),C={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:u,y:p,w:h,h:f},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:y=>{y.preventDefault();const b=new FormData(y.currentTarget);r.link.create({url:b.get("url"),target:b.get("target")}),g()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(v==null?void 0:v.href)||"",onChange:({value:y,setState:b})=>b({value:y})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(v==null?void 0:v.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:y,setState:b})=>b({value:y})},{type:"row",style:{gap:10,justifyContent:"end"},children:[r.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{r.link.toggle(),g()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(F.layoutToggle,C)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:ve.alignTextLeft},{id:"center",icon:ve.alignTextCenter},{id:"right",icon:ve.alignTextRight},{id:"justify",icon:ve.alignTextJustify}],editorEvents:{[ke]:({setState:c})=>{c({value:r.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:ve.listBullet,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:r.listBullet.isActive()})}},onClick:({setState:c})=>{r.listBullet.toggle(),c({active:r.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:ve.listOrdered,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:r.listOrdered.isActive()})}},onClick:({setState:c})=>{r.listOrdered.toggle(),c({active:r.listOrdered.isActive()})}},heading:{id:"heading",type:"selectField",size:"s",value:"",emptyState:"Heading",options:[{id:"",label:"Normal"},{id:"1",label:"Heading 1"},{id:"2",label:"Heading 2"},{id:"3",label:"Heading 3"},{id:"4",label:"Heading 4"},{id:"5",label:"Heading 5"},{id:"6",label:"Heading 6"}],editorEvents:{[ke]:({setState:c})=>{c({value:r.heading.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.heading.set({value:c}),s.focus()}},fontSize:{id:"fontSize",type:"selectField",size:"s",value:"",emptyState:"Font size",options:[{id:"8pt",label:"8pt"},{id:"10pt",label:"10pt"},{id:"12pt",label:"12pt"},{id:"14pt",label:"14pt"},{id:"18pt",label:"18pt"},{id:"24pt",label:"24pt"},{id:"36pt",label:"36pt"}],editorEvents:{[ke]:({setState:c})=>{c({value:r.fontSize.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.fontSize.set({value:c}),s.focus()}}},l=[i.bold,i.italic,i.underline,i.strikethrough,i.image,i.link,i.listBullet,i.listOrdered,i.alignText,i.heading,i.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:r,layouts:i,proseMirror:{view:s},items:l}))||l};class H0{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;qd(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 F0=function(n,e={}){const t={plugins:i=>i.plugins,...e},o=(i,l)=>{var f,m;const a=((f=t.schema)==null?void 0:f.call(t,{editor:n,schema:aa}))||aa,{nodes:c,marks:d}=a,u=cn.fromSchema(a).parse(i),p=Xt.create({doc:u,schema:a,plugins:(m=t.plugins)==null?void 0:m.call(t,{editor:n,Plugin:yn,plugins:[_1(),X1(),$0(a),km(),Rs({Tab:Xl(1),"Shift-Tab":Xl(-1)}),Rs({Enter:qn(Wc,Om(c.listItem),l0),"Shift-Enter":qn(Gc,(g,v)=>(v&&v(g.tr.replaceSelectionWith(c.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":Xc,"Mod-y":ur,"Mod-Shift-z":ur,"Mod-b":vt(d.strong),"Mod-i":vt(d.em),"Shift-Tab":pr(c.listItem),Tab:Lm(c.listItem)}),Rs(mm)]})}),h=new h1({mount:i},{state:p,dispatchTransaction(g){var S;const{state:v}=h,C=v.apply(g),y=!v.doc.eq(C.doc);h.updateState(C);const b=!v.selection.eq(C.selection);y&&(s0(((S=l==null?void 0:l.view)==null?void 0:S.el)||i),h.focus()),(b||y)&&n.trigger(ke)}});return i.__rteView=h,h.setProps({nodeViews:{image(g){return new H0(g,h,n)}}}),h},s=i=>V0(i,t);n.setCustomRte({toolbar:s,parseContent:!0,async enable(i,l,a){const c=Hs(i);if(c)return c;const d=o(i,a);return t0(i,d),m0(d,a),d},disable(i){const l=Hs(i);if(l)return n0(i,l),l.destroy(),{forceSync:!0}},getContent(i){const l=Hs(i);if(l){const{schema:a,doc:c}=l.state,d=document.createElement("div"),u=Vt.fromSchema(a).serializeFragment(c.content);return u.childNodes.forEach(p=>{p.nodeType===Node.ELEMENT_NODE&&p.innerHTML===""&&(p.innerHTML="<br/>")}),d.appendChild(u),r0(d),i.classList.remove("ProseMirror-focused"),d.innerHTML}return i.innerHTML}});const r=i0(n,t);G({editor:n,licenseKey:t.licenseKey,plan:B0,pluginName:z0,cleanup:()=>{n.RichTextEditor.customRte=void 0,r()}})},_0=_(F0),G0="canvasEmptyState",W0=H.startup,j0=function(n,e={}){const t=new WeakMap,o=new WeakMap,s=new WeakMap,r=new Set,i=new WeakMap,l={emptyStates:[],...e},a=(y,b)=>{let S=!1;const{isValid:x}=b;return Array.isArray(x)?S=x.some(w=>y.is(w)):zt(x)?S=x({component:y,editor:n}):S=y.is(x),S},c=y=>{const b=t.get(y);t.delete(y),b==null||b()},d=y=>{y.views.forEach(b=>c(b)),s.delete(y)},u=y=>{if(!(!y||r.has(y)))try{r.add(y);const b=y.components().length>0,S=s.get(y);if(b&&S)d(y);else if(!b&&!S){const x=i.has(y)?i.get(y):l.emptyStates.find(w=>a(y,w));if(i.set(y,x),!x)return;y.views.forEach(w=>{const E=x.render({editor:n,component:y,componentView:w,mount:k=>{o.set(w,k),s.set(y,!0);const M=w.getChildrenContainer();M==null||M.appendChild(k)},unmount:()=>c(w)});t.set(w,()=>{E==null||E();const k=o.get(w);k==null||k.remove()})})}}finally{r.delete(y)}},p=y=>{s.has(y)&&d(y)},h=({model:y})=>{u(y.getComponent())},f=n.Components.events,m=`${f.update}:components`,g="component:mount",v=n.Canvas.events.frameLoadBody,C=f.removed;n.on(m,u),n.on(g,u),n.on(C,p),n.on(v,h),G({editor:n,licenseKey:l.licenseKey,plan:W0,pluginName:G0,cleanup:()=>{n.off(m,u),n.off(g,u),n.off(C,p),n.off(v,h)}})},q0=_(j0),pa="canvasFullSize",U0=H.startup,K0=function(n,e={}){const{Canvas:t,Commands:o,Devices:s}=n,r={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...e},{canvasOffsetY:i,canvasOffsetX:l,canvasTransition:a,deviceMaxWidth:c,deviceMinHeigth:d,frameBorderRadius:u,frameTransition:p}=r,h=`${d}px`,f=t.events,m="core:preview",g=`${o.events.stopCommand}${m}`,v=t.getConfig(),C=`${pa}:disable`,y=s.getAll().map(S=>({...S.attributes}));v.scrollableCanvas=!0,s.getAll().map(S=>{!S.get("width")&&S.set("width",`${c}px`),!S.get("height")&&S.set("height","auto"),!S.get("minHeight")&&S.set("minHeight",h)});const b=S=>{const x="data-gs-plg-full-size",w=document.querySelector(`style[${x}]`);if(S&&w)return w.remove();const E=w||document.createElement("style"),k=t.getZoomMultiplier();E.setAttribute(x,"true"),E.innerHTML=`
|
|
303
809
|
.gjs-frame-wrapper { transition: width ${p}s !important; }
|
|
304
810
|
.gjs-frame-wrapper__bottom { height: ${i*k}px }
|
|
305
811
|
.gjs-frame { border-radius: ${u}px }
|
|
306
|
-
`,!w&&document.body.appendChild(
|
|
812
|
+
`,!w&&document.body.appendChild(E)};n.on(f.frameLoadHead,S=>{if(!v.scrollableCanvas)return;const{window:x}=S,w=x.document,E=w.head,k="data-gs-plg-wrapper-style",M=E.querySelector(`style[${k}]`)||w.createElement("style");M.setAttribute(k,"true"),M.innerHTML=`
|
|
307
813
|
[data-gjs-type="wrapper"] { min-height: ${h}; }
|
|
308
814
|
[data-gjs-type="mjml"] { min-height: ${h} !important; }
|
|
309
815
|
[data-gjs-type="mj-body"] { min-height: ${h} !important; }
|
|
310
|
-
`,!
|
|
311
|
-
.${
|
|
816
|
+
`,!E.contains(M)&&E.appendChild(M)}),n.onReady(()=>{const S=t.getSpotsEl(),x=t.getElement(),w=t.getFramesEl(),E=a*1e3,k=x.style;k.overflowX="hidden",w.style.transition=`transform ${a}s`;const M={x:l,y:i};b();const P=()=>S.style.display="none",N=()=>S.style.display="",I=Hn(()=>{t.fitViewport({zoom:q=>q>100?100:q,ignoreHeight:!0,gap:M}),b(),setTimeout(()=>{var be,pi;const{em:q}=n;q.destroyed||((pi=(be=n.getSelected())==null?void 0:be.getEl())==null||pi.scrollIntoView({block:"nearest"}),n.refresh({tools:!0}),N(),o.isActive(m)?q.stopDefault():q.runDefault())},E)},100),D=new ResizeObserver(()=>{P(),I()});D.observe(x.parentElement);const z=()=>{P(),I()},J=(q={})=>{q.options&&q.options.from!=="fitViewport"&&t.fitViewport({zoom:t.getZoom(),ignoreHeight:!0,gap:M})},ne=()=>{k.overflowX="hidden",k.overflowY="auto"},Pe=()=>{D.disconnect(),I.clear()};n.on(s.events.select,z),n.on(f.zoom,J),n.on(g,ne),n.on(n.events.destroy,Pe),I(),o.add(C,()=>{s.devices.reset(y),v.scrollableCanvas=!1,t.getModel().updateDevice(),t.setZoom(100),t.setCoords(0,0),k.overflowY="hidden",b(!0),n.off(s.events.select,z),n.off(f.zoom,J),n.off(g,ne),Pe(),o.run("studio:canvasReload")})}),G({editor:n,licenseKey:r.licenseKey,plan:U0,pluginName:pa,cleanup:()=>{n.runCommand(C)}})},J0=_(K0),Pr="canvasGridMode",Z0=H.startup,Ir="component-grid-mode",Yn="grid-mode",so="gjs-drag-grid-spot",Kd=`${so}__grid-item`,Jd=`${so}__grid-target`,Zd=`${so}__snapped`,Y0=`${so}__container`,X0=()=>{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=`
|
|
817
|
+
.${Kd} {
|
|
312
818
|
outline: 2px solid ${o};
|
|
313
819
|
background: ${t};
|
|
314
820
|
outline-offset: -2px;
|
|
@@ -317,14 +823,14 @@
|
|
|
317
823
|
height: 100%;
|
|
318
824
|
opacity: 0.1;
|
|
319
825
|
}
|
|
320
|
-
.${
|
|
826
|
+
.${Zd} {
|
|
321
827
|
width: 100%;
|
|
322
828
|
height: 100%;
|
|
323
829
|
outline: 2px solid ${o};
|
|
324
830
|
outline-offset: -2px;
|
|
325
831
|
position: absolute;
|
|
326
832
|
}
|
|
327
|
-
.${
|
|
833
|
+
.${Jd} {
|
|
328
834
|
position: absolute;
|
|
329
835
|
z-index: -1;
|
|
330
836
|
background: ${t};
|
|
@@ -332,13 +838,13 @@
|
|
|
332
838
|
outline-offset: -1px;
|
|
333
839
|
opacity: 0.35;
|
|
334
840
|
}
|
|
335
|
-
`,e.head.appendChild(s)};function Rd(n){const{editor:e,type:t}=n,o=M0(e,n.component),s=Qr(e,o.component);if(!E0(e,o,s,t))return{target:o,container:s,startScroll:ei(e).scroll,shadowContainerEl:document.createElement("div"),shadowSnappedEl:document.createElement("div"),shadowTargetEl:document.createElement("div"),spot:e.Canvas.addSpot({type:jn,component:s.component})}}function Dd(n){const{editor:e,shadowTargetEl:t,shadowSnappedEl:o,shadowContainerEl:s,spotEl:r,target:i,container:l}=n,{Canvas:a}=e,c=e.config.stylePrefix;r==null||r.appendChild(s),s==null||s.appendChild(t),s==null||s.appendChild(o),w0(s,l),C0(t,i,l),k0(o,i),T0(s,l.el),i.el.style.opacity="0";const d=a.getSpots().filter(u=>u.type!==jn);e.em.stopDefault({preserveSelected:!0}),a.removeSpots(d),a.startAutoscroll(),a.getBody().classList.add(`${c}is__grabbing`)}function Ld(n){const{editor:e,shadowSnappedEl:t,shadowContainerEl:o,target:s,cancelled:r}=n,{Canvas:i}=e,l=e.config.stylePrefix,{component:a}=s;if(!r){const c=window.getComputedStyle(t);a.addStyle({"grid-area":c.gridArea,width:"",height:""})}s.el.style.opacity="",o.contains(t)&&(o==null||o.removeChild(t)),e.getModel().runDefault({preserveSelected:1}),i.stopAutoscroll(),i.getBody().classList.remove(`${l}is__grabbing`),i.removeSpots({type:jn}),e.select(a)}function w0(n,{rows:e,columns:t}){const o=[];for(let s=0;s<t.length;s++){o[s]=[];for(let r=0;r<e.length;r++){const i=document.createElement("div");i.className=Nd,i.style.gridArea=`${r+1} / ${s+1}`,o[s][r]=i,n.appendChild(i)}}return o}function C0(n,e,t){return n.className=Od,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 k0(n,e){const t=Vd(e.el,e.computedStyles);return n.className=Id,n.style.gridArea=`${t.row.start} / ${t.column.start} / ${t.row.end} / ${t.column.end}`,n}function T0(n,e){const t=window.getComputedStyle(e);n.className=x0,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 zd(n,e){if(e){if(Array.isArray(e))return[...e].pop()}else return[...n.getSelectedAll()].pop();return e}function M0(n,e){const t=zd(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 Qr(n,e){const t=e.parent(),o=t.getEl(),s=window.getComputedStyle(o);return{component:t,el:o,offset:n.Canvas.offset(o),computedStyles:s,padding:{top:parseFloat(s.paddingTop),right:parseFloat(s.paddingRight),bottom:parseFloat(s.paddingBottom),left:parseFloat(s.paddingLeft)},columns:s.gridTemplateColumns.split(" ").map(i=>parseFloat(i)),rows:s.gridTemplateRows.split(" ").map(i=>parseFloat(i)),gap:{column:parseInt(s.columnGap),row:parseInt(s.rowGap)}}}function st(n,e,t,o,s=1){let r=0;for(let i=e;i<=n.length;i++){if(r+(n[i-1]+o)*s>t)return i;r+=o+n[i-1]}return n.length+1}function ei(n){const{scrollY:e,scrollX:t}=n.Canvas.getWindow();return{scroll:{top:e,left:t}}}function E0(n,e,t,o){const s=r=>n.em.logWarning(r);return o==="draggable"&&e.component.get(o)===!1?(s(`[${vr}] The element is not ${o}`),!0):t.computedStyles.display!=="grid"?(s(`[${vr}] The container does not have style display:grid`),!0):!1}function Rs(n,e,t={}){const o=zd(n,e),s=o==null?void 0:o.parent(),r=s==null?void 0:s.getEl();if(!s||!r)return!1;const{enableGrid:i}=t,l=window.getComputedStyle(r).display==="grid";return Dt(i)?i({component:o,parent:s,isParentGrid:l}):l}const Ql=n=>n.split(" ").map(e=>parseFloat(e));function Vd(n,e){const t=n.ownerDocument.defaultView,o=e||t.getComputedStyle(n),s=o.gridArea.split("/").some(x=>isNaN(parseInt(x.trim()))),r={isComputed:s,raw:o.gridArea};if(!s)return{...r,row:{start:parseInt(o.gridRowStart),end:parseInt(o.gridRowEnd)},column:{start:parseInt(o.gridColumnStart),end:parseInt(o.gridColumnEnd)}};const i=n.parentElement,l=t.getComputedStyle(i),a=parseFloat(l.columnGap)||0,c=parseFloat(l.rowGap)||0,d=Ql(l.gridTemplateColumns),u=Ql(l.gridTemplateRows),p=parseFloat(l.paddingLeft)||0,h=parseFloat(l.paddingTop)||0,f=i.getBoundingClientRect(),m=n.getBoundingClientRect(),g=(x,S,w,M,k)=>{let E=1,P=M+k;for(let O=0;O<S.length;O++){const N=S[O],D=P+N;if(x>=P&&x<D)return E;P=D+w,E++}return-1},v=g(m.left,d,a,f.left,p),C=g(m.right-1,d,a,f.left,p)+1,y=g(m.top,u,c,f.top,h),b=g(m.bottom-1,u,c,f.top,h)+1;return{...r,row:{start:y,end:b},column:{start:v,end:C}}}function A0(n){n.Commands.add(xr,{stop(){},run(e,t,o={}){const s=Rd({editor:e,component:o.target,type:"draggable"});if(!s){this.stopCommand();return}const{spot:r,target:i,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c,startScroll:d}=s;let{container:u}=s,p;new e.Utils.Dragger({doc:i.el.ownerDocument,onStart:()=>{p=setTimeout(()=>{Dd({editor:e,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:r.attributes.spotEl,target:i,container:u}),u=Qr(e,i.component)},10)},onEnd:(f,m,{cancelled:g})=>{clearTimeout(p),Ld({editor:e,shadowSnappedEl:a,shadowContainerEl:l,target:i,cancelled:g}),this.stopCommand(),e.em.set("_cmpDrag",1)},setPosition:({x:f,y:m})=>{const{scroll:g}=ei(e),{columns:v,rows:C,gap:y,offset:b,padding:x}=u,{offset:S,margin:w}=i,M=S.top-b.top-x.top-w.top+m-d.top+g.top,k=S.left-b.left-x.left-w.left+f-d.left+g.left,E=Math.min(st(v,1,k,y.column,.5),v.length),P=Math.min(st(C,1,M,y.row,.5),C.length),O=Math.min(st(v,E,S.width,y.column)+1,v.length+1),N=Math.min(st(C,P,S.height,y.row)+1,C.length+1);a.style.gridArea=`${P} / ${E} / ${N} / ${O}`,c.style.top=`${M+x.top}px`,c.style.left=`${k+x.left}px`}}).start(o.event)}})}function P0(n,e){const t=Rd({editor:n,component:e.target,type:"resizable"});if(!t)return;const{onMove:o,onEnd:s}=e.options||{},{spot:r,target:i,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c}=t;let{container:d}=t,u="",p;return{onStart:h=>{u=h.target.dataset.gjsHandler||"",p=setTimeout(()=>{Dd({editor:n,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:r.attributes.spotEl,target:i,container:d}),d=Qr(n,i.component)},10),n.trigger("component:resize",{...i,type:"start"})},onEnd:(h,f)=>{const{startDim:m,rectDim:g}=f.resizer,v=JSON.stringify(m)===JSON.stringify(g);clearTimeout(p),Ld({editor:n,shadowSnappedEl:a,shadowContainerEl:l,target:i,cancelled:v}),s==null||s(h,f)},onMove:h=>{var J;const f=h;if(((J=f.target)==null?void 0:J.nodeName)==="I")return;const{scroll:m}=ei(n),g=Vd(a);let v=0,C=0,y=0,b=0;const x=i.margin.left,S=i.margin.top,w=i.margin.bottom,M=i.margin.right,{width:k,top:E,left:P,height:O}=i.offset,N=f.clientX,D=f.clientY,V={t:E-S,l:P-x,h:O+S+w,w:k+x+M};u.startsWith("t")?(V.t=D-S,V.h=E+O+S+w-D):u.startsWith("b")&&(V.h=D-E+S+w),u.endsWith("l")?(V.l=N-x,V.w=P+k+x+M-N):u.endsWith("r")&&(V.w=N-P+x+M),u.endsWith("l")&&(y=m.left,g.column.start=st(d.columns,1,V.l-d.offset.left-y-d.padding.left,d.gap.column,.5)),u.startsWith("t")&&(v=m.top,g.row.start=st(d.rows,1,V.t-d.offset.top+v-d.padding.top,d.gap.row,.5)),u.endsWith("r")&&(b=m.left,g.column.end=Math.max(st(d.columns,g.column.start,V.w-b,d.gap.column,.5),g.column.start+1)),u.startsWith("b")&&(C=m.top,g.row.end=Math.max(st(d.rows,g.row.start,V.h+C,d.gap.row,.5),g.row.start+1)),a.style.gridArea=`${g.row.start} / ${g.column.start} / ${g.row.end} / ${g.column.end}`,c.style.width=`${V.w+b+y}px`,c.style.height=`${V.h+C-v}px`,c.style.left=`${V.l-d.offset.left-y}px`,c.style.top=`${V.t-d.offset.top+v}px`,o==null||o(h)}}}const ea=["px","%","em","rem","vw","vh"],N0=(n,e)=>{const t=n.Styles.getSectors().find(o=>!!o.getProperty(e));return{sector:t,property:t?t.getProperty(e):void 0}},O0=(n,e)=>N0(n,e),I0=(n,{x:e,y:t,mergable:o}={})=>{const s={property:`${n}-x`,type:"integer",units:ea,...e},r={property:`${n}-y`,type:"integer",units:ea,...t};return{property:n,type:"composite",properties:[s,r],...o&&{fromStyle(i,{name:l,separator:a,property:c}){const[d,u]=c.getProperties(),[p,h]=(i[l]||"").split(a);return{[d.getId()]:i[d.getName()]||p||"",[u.getId()]:i[u.getName()]||h||p||""}},toStyle(i,{name:l,property:a}){const[c,d]=a.getProperties(),u=i[c.getId()],p=i[d.getId()];return{[l]:u===p?u:`${u} ${p}`}}}}},Sr={display:["grid"]};function R0(n=""){const e=/^repeat\(\s*(\d+)\s*,\s*(.+)\s*\)$/i,t=/^minmax\(\s*(.+?)\s*,\s*(.+?)\s*\)$/i,o=n.match(e);if(!o)return null;const s=parseInt(o[1],10),r=o[2];let i=r,l=r;const a=r.match(t);return a&&(i=a[1],l=a[2]),{total:s,min:i===l?"":i,max:l}}function D0(n={}){let e="",t="",o="",s="";const r=m=>m.split("/").map(g=>g.trim()).filter(Boolean),i=n["grid-area"]||"",l=n["grid-column"]||"",a=n["grid-row"]||"",c=r(i),d=r(l),u=r(a),p=c.length,h=d.length,f=u.length;return p===4?(o=c[0],e=c[1],s=c[2],t=c[3]):p===3?(o=c[0],e=c[1],s=c[2]):p===2?(o=c[0],e=c[1]):p===1&&(o=c[0]),h===2?(e=d[0],t=d[1]):h===1&&(e=d[0]),f===2?(o=u[0],s=u[1]):f===1&&(o=u[0]),{columnStart:e,columnEnd:t,rowStart:o,rowEnd:s}}function ta(n){const{property:e,label:t}=n,o="1",s="1fr";return{property:e,label:t,type:"composite",requires:Sr,generic:!0,properties:[{name:" ",property:`${e}-repeat`,type:"number",full:!0,min:1,default:"1"},{label:"Min size",property:`${e}-min`,type:"number",min:0,units:["px","%"],default:"0"},{label:"Max size",property:`${e}-max`,type:"number",min:1,units:["fr","px","%"],default:"1"}],fromStyle(r,i){const{name:l,property:a}=i,[c,d,u]=a.getProperties(),p=r[l],h=R0(p),f=(h==null?void 0:h.max)??s;return{[c.id]:(h==null?void 0:h.total)??o,[d.id]:(h==null?void 0:h.min)??"",[u.id]:f===s?"":f}},toStyle(r,{name:i,property:l}){const[a,c,d]=l.getProperties(),u=r[a.id],p=r[c.id],h=r[d.id]||s,f=p&&h?`minmax(${p}, ${h})`:h;return{[i]:`repeat(${u||o}, ${f})`}}}}function L0(n,e){if(!e.styleableGrid)return;const{property:t,...o}=O0(n,"display");if(!t)return;const s=t.getOption("grid"),r=o.sector;s||t.addOption({id:"grid",label:"Grid"}),r.addProperty(ta({label:"Columns",property:"grid-template-columns"}),{}),r.addProperty(ta({label:"Rows",property:"grid-template-rows"}),{}),r.addProperty({id:"grid-gap",requires:Sr,...I0("gap",{x:{id:"grid-row-gap",label:"Row",property:"row-gap",min:0,default:"0"},y:{id:"grid-column-gap",label:"Column",property:"column-gap",min:0,default:"0"},mergable:!0})},{}),r.addProperty({type:"composite",property:"grid-area",label:"Grid area",requiresParent:Sr,generic:!0,properties:[{label:"Row start",property:"grid-row-start",type:"integer",default:"auto"},{label:"Row end",property:"grid-row-end",type:"integer",default:"auto"},{label:"Column start",property:"grid-column-start",type:"integer",default:"auto"},{label:"Column end",property:"grid-column-end",type:"integer",default:"auto"}],fromStyle(i){const l=D0(i);return{"grid-column-start":i["grid-column-start"]||l.columnStart,"grid-column-end":i["grid-column-end"]||l.columnEnd,"grid-row-start":i["grid-row-start"]||l.rowStart,"grid-row-end":i["grid-row-end"]||l.rowEnd}},toStyle(i,{name:l}){const a=i["grid-row-start"]||"auto",c=i["grid-row-end"]||"auto",d=i["grid-column-start"]||"auto",u=i["grid-column-end"]||"auto";return{[l]:`${a} / ${d} / ${c} / ${u}`}}},{})}const z0=function(n,e={}){const t={itemResizable:!0,...e},{Canvas:o,Commands:s,Components:r}=n,{itemResizable:i}=t,l=o.events,a=s.events,c=r.events,d=`${a.runBeforeCommand}tlb-move`,u=`${a.runBeforeCommand}resize`;let p;A0(n);const h=({options:y})=>{Rs(n,y.target,t)&&(n.runCommand(xr,{...y}),y.abort=!0)},f=({options:y})=>{Rs(n,y.target,t)&&Object.assign(y.options,P0(n,y))},m=()=>{const y=o.getSpots({type:jn}).pop();if(!y)return;let b=y.attributes.spotEl;b||(b=document.createElement("div"),b.className=Xn,y.set({spotEl:b})),Object.entries(y.getStyle()).forEach(([x,S])=>b.style.setProperty(x,S)),p==null||p.appendChild(b)},g=({spot:y})=>{const b=y.attributes.spotEl;y.type!==jn||!b||p==null||p.removeChild(b)};if(i){const y=b=>{const x=Dt(i)?i({component:b}):i;return typeof x=="boolean"?x:{tl:!1,tc:!1,tr:!1,cl:!1,cr:!1,bl:!1,bc:!1,br:!1,...x}};n.on(c.resizeInit,b=>{const{component:x}=b;if(Rs(n,x,t)){const S=y(x);b.resizable=S}})}const v=[[d,h],[u,f],[l.spot,m],[l.spotRemove,g]];v.forEach(([y,b])=>{n.on(y,b)}),n.onReady(()=>{p=o.getSpotsEl(),S0(),L0(n,t)});const C=()=>{delete n.Commands.commands[xr],v.forEach(([y,b])=>{n.off(y,b)})};j({editor:n,licenseKey:t.licenseKey,plan:v0,pluginName:vr,cleanup:C})},V0=W(z0);var Ne=(n=>(n.panelBlocks="panelBlocks",n.panelPagesLayers="panelPagesLayers",n.panelGlobalStyles="panelGlobalStyles",n.panelSidebarTabs="panelSidebarTabs",n.panelAssets="panelAssets",n))(Ne||{});const $d="sidebarButtonsTarget",fo=n=>{const{id:e,icon:t,label:o,tooltip:s,className:r,skipSelfClose:i,removeLayouts:l,layoutComponent:a,layoutCommand:c}=n,d=e;return{id:Bd(e),type:"button",icon:t,tooltip:o||s,className:r,editorEvents:{[`${pa.layoutToggleId}${d}`]:({fromEvent:u,setState:p,editor:h})=>{p({active:u.isOpen}),setTimeout(()=>h.refresh({tools:!0}),20)}},onClick:({editor:u,state:p})=>{if(p.active&&i)return;const h=(c==null?void 0:c.placer)||{type:"static",layoutId:$d},f={...h,skipCleanup:h.type==="static"},m=l||Object.keys(Ne).filter(v=>v!==d);Hd(u,{removeLayouts:m,layout:{placer:f}});const g={id:d,placer:h,header:(c==null?void 0:c.header)??{label:o,close:!i},layout:a,style:{width:280,height:"100%",borderRightWidth:1,...c==null?void 0:c.style}};u.runCommand(F.layoutToggle,g)}}},Bd=n=>`button__${n}`,Hd=(n,e={})=>{(e.removeLayouts||Object.keys(Ne)).forEach(o=>n.runCommand(F.layoutRemove,{id:o,layout:e.layout}))},Fd=n=>{const e=(n==null?void 0:n.breakpointTablet)??1024,t=(n==null?void 0:n.breakpointMobile)??768,o={breakpointTablet:e,breakpointMobile:t},s={},r=[{id:Ne.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:Ne.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:Ne.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:Ne.panelAssets,icon:'<svg viewBox="0 0 24 24"><path d="M22,16V4A2,2 0 0,0 20,2H8A2,2 0 0,0 6,4V16A2,2 0 0,0 8,18H20A2,2 0 0,0 22,16M11,12L13.03,14.71L16,11L20,16H8M2,6V20A2,2 0 0,0 4,22H18V20H4V6" /></svg>',label:"Assets",layoutComponent:{type:"panelAssets",content:{itemsPerRow:2,header:{addUrl:!1}},style:{padding:7},onSelect:({assetProps:h,editor:f})=>{var v;const m=f.getSelected(),g={type:"image",src:h.src};if(m!=null&&m.is("image"))return m.set("src",h.src);if(m&&f.Components.canMove(m,g)){const C=m.append(g)[0];C&&f.select(C)}else if(!m){const C=(v=f.getWrapper())==null?void 0:v.append(g)[0];C&&f.select(C)}}}}],i=[...r,{id:Ne.panelSidebarTabs,layoutCommand:{header:!1},icon:'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 0 1-1.5-1.5A1.5 1.5 0 0 1 17.5 9a1.5 1.5 0 0 1 1.5 1.5 1.5 1.5 0 0 1-1.5 1.5m-3-4A1.5 1.5 0 0 1 13 6.5 1.5 1.5 0 0 1 14.5 5 1.5 1.5 0 0 1 16 6.5 1.5 1.5 0 0 1 14.5 8m-5 0A1.5 1.5 0 0 1 8 6.5 1.5 1.5 0 0 1 9.5 5 1.5 1.5 0 0 1 11 6.5 1.5 1.5 0 0 1 9.5 8m-3 4A1.5 1.5 0 0 1 5 10.5 1.5 1.5 0 0 1 6.5 9 1.5 1.5 0 0 1 8 10.5 1.5 1.5 0 0 1 6.5 12M12 3a9 9 0 0 0-9 9 9 9 0 0 0 9 9 1.5 1.5 0 0 0 1.5-1.5c0-.4-.2-.7-.4-1-.2-.3-.4-.6-.4-1a1.5 1.5 0 0 1 1.5-1.5H16a5 5 0 0 0 5-5c0-4.4-4-8-9-8Z"/></svg>',label:"Styles & Props",layoutComponent:{type:"panelSidebarTabs"}}],l={id:$d,type:"column",style:{overflow:"hidden"}},a={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},c={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}},d=(h,f)=>{const m=h.map(v=>{const C=fo(v);return n!=null&&n.sidebarButton?n.sidebarButton({id:v.id,buttonIds:Ne,breakpoint:f,buttonProps:C,sidebarButtonProps:v,...o,createSidebarButton:y=>fo({...v,...y})}):C}).filter(Boolean);return(n!=null&&n.sidebarButtons?n==null?void 0:n.sidebarButtons({buttonIds:Ne,breakpoint:f,sidebarButtons:m,...o,createSidebarButton:v=>fo({...v})}):m).filter(Boolean)},u=(h,f,m)=>{var g;return((g=n==null?void 0:n.rootLayout)==null?void 0:g.call(n,{breakpoint:m,sidebarButtons:f,rootLayout:h,layoutSidebarLeft:a,layoutSidebarTarget:l,...o,createSidebarButton:v=>fo({...v})}))??h};if(e){const h=d(i,e);s[e]=u({type:"row",style:{height:"100%"},children:[{...a,children:h},l,c]},h,e)}if(t){const h=i.map(m=>({...m,layoutCommand:{placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}}})),f=d(h,t);s[t]=u({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas"},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:f}]},f,t)}const p=d(r,0);return{default:u({type:"row",style:{height:"100%"},children:[{...a,children:p},l,c,{type:"sidebarRight"}]},p,0),responsive:s}},na="layoutSidebarButtons",$0=H.free,B0=function(n,e={}){const{Commands:t}=n,o=t.events,s={...e};(()=>{if(n.runCommand(F.layoutConfigGet)||s.skipLayoutConfig===!0)return;const l=Fd(s);n.runCommand(F.layoutConfigSet,{...l})})(),t.add(`${na}:toggleButton`,(i,l,a)=>{const c=document.getElementById(Bd(a==null?void 0:a.id));c==null||c.click()}),n.on(`${o.runCommand}core:preview`,()=>{Hd(n)}),j({editor:n,licenseKey:s.licenseKey,plan:$0,pluginName:na,cleanup:()=>{n.runCommand(F.layoutConfigSet)}})},_d=W(B0);_d.createLayoutConfig=n=>Fd(n);const ft="page-break";function wr(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 H0=(n,e)=>{const{name:t,id:o,width:s,height:r,unit:i}=n,{fixedHeight:l}=e,a=`${s}${i}`,c=`${r}${i}`;return{id:o||t.toLowerCase().replace(/\s/g,"-"),name:`${t} (${a} x ${c})`,sizeH:r,sizeW:s,sizeUnit:i,widthMedia:"",width:a,minHeight:l?"0":`${wr(r,i)}px`,height:l?c:void 0}},Cr="page-breaks",mo="gjs-page-breaks-spot",Ds=n=>n.type===Cr;function F0(n){const{Devices:e}=n,{height:t,minHeight:o}=e.getSelected().attributes,r=parseFloat(`${t&&t!=="auto"?t:o}`),i=n.getWrapper(),l=i==null?void 0:i.getEl(),a=[];if(!i||!l)return a;const c=l.getBoundingClientRect().height,u=i.findType(ft).map(h=>h.getEl()).filter(Boolean).map(h=>({top:h.offsetTop,height:h.offsetHeight}));let p=0;for(;p<c;){const h=u.find(f=>f.top>p&&f.top<p+r);h?(p=h.top+h.height,a.push(h.top)):(p+=r,p<c&&a.push(p))}return a}function _0(n,e){const{Canvas:t}=n,o=t.events,s=n.events;let r;const i=()=>{Ar(`${ma}preset-printable-spots`,`.${mo} {
|
|
841
|
+
`,e.head.appendChild(s)};function Yd(n){const{editor:e,type:t}=n,o=oy(e,n.component),s=di(e,o.component);if(!sy(e,o,s,t))return{target:o,container:s,startScroll:ui(e).scroll,shadowContainerEl:document.createElement("div"),shadowSnappedEl:document.createElement("div"),shadowTargetEl:document.createElement("div"),spot:e.Canvas.addSpot({type:Yn,component:s.component})}}function Xd(n){const{editor:e,shadowTargetEl:t,shadowSnappedEl:o,shadowContainerEl:s,spotEl:r,target:i,container:l}=n,{Canvas:a}=e,c=e.config.stylePrefix;r==null||r.appendChild(s),s==null||s.appendChild(t),s==null||s.appendChild(o),Q0(s,l),ey(t,i,l),ty(o,i),ny(s,l.el),i.el.style.opacity="0";const d=a.getSpots().filter(u=>u.type!==Yn);e.em.stopDefault({preserveSelected:!0}),a.removeSpots(d),a.startAutoscroll(),a.getBody().classList.add(`${c}is__grabbing`)}function Qd(n){const{editor:e,shadowSnappedEl:t,shadowContainerEl:o,target:s,cancelled:r}=n,{Canvas:i}=e,l=e.config.stylePrefix,{component:a}=s;if(!r){const c=window.getComputedStyle(t);a.addStyle({"grid-area":c.gridArea,width:"",height:""})}s.el.style.opacity="",o.contains(t)&&(o==null||o.removeChild(t)),e.getModel().runDefault({preserveSelected:1}),i.stopAutoscroll(),i.getBody().classList.remove(`${l}is__grabbing`),i.removeSpots({type:Yn}),e.select(a)}function Q0(n,{rows:e,columns:t}){const o=[];for(let s=0;s<t.length;s++){o[s]=[];for(let r=0;r<e.length;r++){const i=document.createElement("div");i.className=Kd,i.style.gridArea=`${r+1} / ${s+1}`,o[s][r]=i,n.appendChild(i)}}return o}function ey(n,e,t){return n.className=Jd,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 ty(n,e){const t=tu(e.el,e.computedStyles);return n.className=Zd,n.style.gridArea=`${t.row.start} / ${t.column.start} / ${t.row.end} / ${t.column.end}`,n}function ny(n,e){const t=window.getComputedStyle(e);n.className=Y0,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 eu(n,e){if(e){if(Array.isArray(e))return[...e].pop()}else return[...n.getSelectedAll()].pop();return e}function oy(n,e){const t=eu(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 di(n,e){const t=e.parent(),o=t.getEl(),s=window.getComputedStyle(o);return{component:t,el:o,offset:n.Canvas.offset(o),computedStyles:s,padding:{top:parseFloat(s.paddingTop),right:parseFloat(s.paddingRight),bottom:parseFloat(s.paddingBottom),left:parseFloat(s.paddingLeft)},columns:s.gridTemplateColumns.split(" ").map(i=>parseFloat(i)),rows:s.gridTemplateRows.split(" ").map(i=>parseFloat(i)),gap:{column:parseInt(s.columnGap),row:parseInt(s.rowGap)}}}function lt(n,e,t,o,s=1){let r=0;for(let i=e;i<=n.length;i++){if(r+(n[i-1]+o)*s>t)return i;r+=o+n[i-1]}return n.length+1}function ui(n){const{scrollY:e,scrollX:t}=n.Canvas.getWindow();return{scroll:{top:e,left:t}}}function sy(n,e,t,o){const s=r=>n.em.logWarning(r);return o==="draggable"&&e.component.get(o)===!1?(s(`[${Pr}] The element is not ${o}`),!0):t.computedStyles.display!=="grid"?(s(`[${Pr}] The container does not have style display:grid`),!0):!1}function Fs(n,e,t={}){const o=eu(n,e),s=o==null?void 0:o.parent(),r=s==null?void 0:s.getEl();if(!s||!r)return!1;const{enableGrid:i}=t,l=window.getComputedStyle(r).display==="grid";return zt(i)?i({component:o,parent:s,isParentGrid:l}):l}const ha=n=>n.split(" ").map(e=>parseFloat(e));function tu(n,e){const t=n.ownerDocument.defaultView,o=e||t.getComputedStyle(n),s=o.gridArea.split("/").some(S=>isNaN(parseInt(S.trim()))),r={isComputed:s,raw:o.gridArea};if(!s)return{...r,row:{start:parseInt(o.gridRowStart),end:parseInt(o.gridRowEnd)},column:{start:parseInt(o.gridColumnStart),end:parseInt(o.gridColumnEnd)}};const i=n.parentElement,l=t.getComputedStyle(i),a=parseFloat(l.columnGap)||0,c=parseFloat(l.rowGap)||0,d=ha(l.gridTemplateColumns),u=ha(l.gridTemplateRows),p=parseFloat(l.paddingLeft)||0,h=parseFloat(l.paddingTop)||0,f=i.getBoundingClientRect(),m=n.getBoundingClientRect(),g=(S,x,w,E,k)=>{let M=1,P=E+k;for(let N=0;N<x.length;N++){const I=x[N],D=P+I;if(S>=P&&S<D)return M;P=D+w,M++}return-1},v=g(m.left,d,a,f.left,p),C=g(m.right-1,d,a,f.left,p)+1,y=g(m.top,u,c,f.top,h),b=g(m.bottom-1,u,c,f.top,h)+1;return{...r,row:{start:y,end:b},column:{start:v,end:C}}}function ry(n){n.Commands.add(Ir,{stop(){},run(e,t,o={}){const s=Yd({editor:e,component:o.target,type:"draggable"});if(!s){this.stopCommand();return}const{spot:r,target:i,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c,startScroll:d}=s;let{container:u}=s,p;new e.Utils.Dragger({doc:i.el.ownerDocument,onStart:()=>{p=setTimeout(()=>{Xd({editor:e,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:r.attributes.spotEl,target:i,container:u}),u=di(e,i.component)},10)},onEnd:(f,m,{cancelled:g})=>{clearTimeout(p),Qd({editor:e,shadowSnappedEl:a,shadowContainerEl:l,target:i,cancelled:g}),this.stopCommand(),e.em.set("_cmpDrag",1)},setPosition:({x:f,y:m})=>{const{scroll:g}=ui(e),{columns:v,rows:C,gap:y,offset:b,padding:S}=u,{offset:x,margin:w}=i,E=x.top-b.top-S.top-w.top+m-d.top+g.top,k=x.left-b.left-S.left-w.left+f-d.left+g.left,M=Math.min(lt(v,1,k,y.column,.5),v.length),P=Math.min(lt(C,1,E,y.row,.5),C.length),N=Math.min(lt(v,M,x.width,y.column)+1,v.length+1),I=Math.min(lt(C,P,x.height,y.row)+1,C.length+1);a.style.gridArea=`${P} / ${M} / ${I} / ${N}`,c.style.top=`${E+S.top}px`,c.style.left=`${k+S.left}px`}}).start(o.event)}})}function iy(n,e){const t=Yd({editor:n,component:e.target,type:"resizable"});if(!t)return;const{onMove:o,onEnd:s}=e.options||{},{spot:r,target:i,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c}=t;let{container:d}=t,u="",p;return{onStart:h=>{u=h.target.dataset.gjsHandler||"",p=setTimeout(()=>{Xd({editor:n,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:r.attributes.spotEl,target:i,container:d}),d=di(n,i.component)},10),n.trigger("component:resize",{...i,type:"start"})},onEnd:(h,f)=>{const{startDim:m,rectDim:g}=f.resizer,v=JSON.stringify(m)===JSON.stringify(g);clearTimeout(p),Qd({editor:n,shadowSnappedEl:a,shadowContainerEl:l,target:i,cancelled:v}),s==null||s(h,f)},onMove:h=>{var J;const f=h;if(((J=f.target)==null?void 0:J.nodeName)==="I")return;const{scroll:m}=ui(n),g=tu(a);let v=0,C=0,y=0,b=0;const S=i.margin.left,x=i.margin.top,w=i.margin.bottom,E=i.margin.right,{width:k,top:M,left:P,height:N}=i.offset,I=f.clientX,D=f.clientY,z={t:M-x,l:P-S,h:N+x+w,w:k+S+E};u.startsWith("t")?(z.t=D-x,z.h=M+N+x+w-D):u.startsWith("b")&&(z.h=D-M+x+w),u.endsWith("l")?(z.l=I-S,z.w=P+k+S+E-I):u.endsWith("r")&&(z.w=I-P+S+E),u.endsWith("l")&&(y=m.left,g.column.start=lt(d.columns,1,z.l-d.offset.left-y-d.padding.left,d.gap.column,.5)),u.startsWith("t")&&(v=m.top,g.row.start=lt(d.rows,1,z.t-d.offset.top+v-d.padding.top,d.gap.row,.5)),u.endsWith("r")&&(b=m.left,g.column.end=Math.max(lt(d.columns,g.column.start,z.w-b,d.gap.column,.5),g.column.start+1)),u.startsWith("b")&&(C=m.top,g.row.end=Math.max(lt(d.rows,g.row.start,z.h+C,d.gap.row,.5),g.row.start+1)),a.style.gridArea=`${g.row.start} / ${g.column.start} / ${g.row.end} / ${g.column.end}`,c.style.width=`${z.w+b+y}px`,c.style.height=`${z.h+C-v}px`,c.style.left=`${z.l-d.offset.left-y}px`,c.style.top=`${z.t-d.offset.top+v}px`,o==null||o(h)}}}const fa=["px","%","em","rem","vw","vh"],ly=(n,e)=>{const t=n.Styles.getSectors().find(o=>!!o.getProperty(e));return{sector:t,property:t?t.getProperty(e):void 0}},ay=(n,e)=>ly(n,e),cy=(n,{x:e,y:t,mergable:o}={})=>{const s={property:`${n}-x`,type:"integer",units:fa,...e},r={property:`${n}-y`,type:"integer",units:fa,...t};return{property:n,type:"composite",properties:[s,r],...o&&{fromStyle(i,{name:l,separator:a,property:c}){const[d,u]=c.getProperties(),[p,h]=(i[l]||"").split(a);return{[d.getId()]:i[d.getName()]||p||"",[u.getId()]:i[u.getName()]||h||p||""}},toStyle(i,{name:l,property:a}){const[c,d]=a.getProperties(),u=i[c.getId()],p=i[d.getId()];return{[l]:u===p?u:`${u} ${p}`}}}}},Nr={display:["grid"]};function dy(n=""){const e=/^repeat\(\s*(\d+)\s*,\s*(.+)\s*\)$/i,t=/^minmax\(\s*(.+?)\s*,\s*(.+?)\s*\)$/i,o=n.match(e);if(!o)return null;const s=parseInt(o[1],10),r=o[2];let i=r,l=r;const a=r.match(t);return a&&(i=a[1],l=a[2]),{total:s,min:i===l?"":i,max:l}}function uy(n={}){let e="",t="",o="",s="";const r=m=>m.split("/").map(g=>g.trim()).filter(Boolean),i=n["grid-area"]||"",l=n["grid-column"]||"",a=n["grid-row"]||"",c=r(i),d=r(l),u=r(a),p=c.length,h=d.length,f=u.length;return p===4?(o=c[0],e=c[1],s=c[2],t=c[3]):p===3?(o=c[0],e=c[1],s=c[2]):p===2?(o=c[0],e=c[1]):p===1&&(o=c[0]),h===2?(e=d[0],t=d[1]):h===1&&(e=d[0]),f===2?(o=u[0],s=u[1]):f===1&&(o=u[0]),{columnStart:e,columnEnd:t,rowStart:o,rowEnd:s}}function ma(n){const{property:e,label:t}=n,o="1",s="1fr";return{property:e,label:t,type:"composite",requires:Nr,generic:!0,properties:[{name:" ",property:`${e}-repeat`,type:"number",full:!0,min:1,default:"1"},{label:"Min size",property:`${e}-min`,type:"number",min:0,units:["px","%"],default:"0"},{label:"Max size",property:`${e}-max`,type:"number",min:1,units:["fr","px","%"],default:"1"}],fromStyle(r,i){const{name:l,property:a}=i,[c,d,u]=a.getProperties(),p=r[l],h=dy(p),f=(h==null?void 0:h.max)??s;return{[c.id]:(h==null?void 0:h.total)??o,[d.id]:(h==null?void 0:h.min)??"",[u.id]:f===s?"":f}},toStyle(r,{name:i,property:l}){const[a,c,d]=l.getProperties(),u=r[a.id],p=r[c.id],h=r[d.id]||s,f=p&&h?`minmax(${p}, ${h})`:h;return{[i]:`repeat(${u||o}, ${f})`}}}}function py(n,e){if(!e.styleableGrid)return;const{property:t,...o}=ay(n,"display");if(!t)return;const s=t.getOption("grid"),r=o.sector;s||t.addOption({id:"grid",label:"Grid"}),r.addProperty(ma({label:"Columns",property:"grid-template-columns"}),{}),r.addProperty(ma({label:"Rows",property:"grid-template-rows"}),{}),r.addProperty({id:"grid-gap",requires:Nr,...cy("gap",{x:{id:"grid-row-gap",label:"Row",property:"row-gap",min:0,default:"0"},y:{id:"grid-column-gap",label:"Column",property:"column-gap",min:0,default:"0"},mergable:!0})},{}),r.addProperty({type:"composite",property:"grid-area",label:"Grid area",requiresParent:Nr,generic:!0,properties:[{label:"Row start",property:"grid-row-start",type:"integer",default:"auto"},{label:"Row end",property:"grid-row-end",type:"integer",default:"auto"},{label:"Column start",property:"grid-column-start",type:"integer",default:"auto"},{label:"Column end",property:"grid-column-end",type:"integer",default:"auto"}],fromStyle(i){const l=uy(i);return{"grid-column-start":i["grid-column-start"]||l.columnStart,"grid-column-end":i["grid-column-end"]||l.columnEnd,"grid-row-start":i["grid-row-start"]||l.rowStart,"grid-row-end":i["grid-row-end"]||l.rowEnd}},toStyle(i,{name:l}){const a=i["grid-row-start"]||"auto",c=i["grid-row-end"]||"auto",d=i["grid-column-start"]||"auto",u=i["grid-column-end"]||"auto";return{[l]:`${a} / ${d} / ${c} / ${u}`}}},{})}const hy=function(n,e={}){const t={itemResizable:!0,...e},{Canvas:o,Commands:s,Components:r}=n,{itemResizable:i}=t,l=o.events,a=s.events,c=r.events,d=`${a.runBeforeCommand}tlb-move`,u=`${a.runBeforeCommand}resize`;let p;ry(n);const h=({options:y})=>{Fs(n,y.target,t)&&(n.runCommand(Ir,{...y}),y.abort=!0)},f=({options:y})=>{Fs(n,y.target,t)&&Object.assign(y.options,iy(n,y))},m=()=>{const y=o.getSpots({type:Yn}).pop();if(!y)return;let b=y.attributes.spotEl;b||(b=document.createElement("div"),b.className=so,y.set({spotEl:b})),Object.entries(y.getStyle()).forEach(([S,x])=>b.style.setProperty(S,x)),p==null||p.appendChild(b)},g=({spot:y})=>{const b=y.attributes.spotEl;y.type!==Yn||!b||p==null||p.removeChild(b)};if(i){const y=b=>{const S=zt(i)?i({component:b}):i;return typeof S=="boolean"?S:{tl:!1,tc:!1,tr:!1,cl:!1,cr:!1,bl:!1,bc:!1,br:!1,...S}};n.on(c.resizeInit,b=>{const{component:S}=b;if(Fs(n,S,t)){const x=y(S);b.resizable=x}})}const v=[[d,h],[u,f],[l.spot,m],[l.spotRemove,g]];v.forEach(([y,b])=>{n.on(y,b)}),n.onReady(()=>{p=o.getSpotsEl(),X0(),py(n,t)});const C=()=>{delete n.Commands.commands[Ir],v.forEach(([y,b])=>{n.off(y,b)})};G({editor:n,licenseKey:t.licenseKey,plan:Z0,pluginName:Pr,cleanup:C})},fy=_(hy);var Ne=(n=>(n.panelBlocks="panelBlocks",n.panelPagesLayers="panelPagesLayers",n.panelGlobalStyles="panelGlobalStyles",n.panelSidebarTabs="panelSidebarTabs",n.panelAssets="panelAssets",n))(Ne||{});const nu="sidebarButtonsTarget",So=n=>{const{id:e,icon:t,label:o,tooltip:s,className:r,skipSelfClose:i,removeLayouts:l,layoutComponent:a,layoutCommand:c}=n,d=e;return{id:ou(e),type:"button",icon:t,tooltip:o||s,className:r,editorEvents:{[`${Ea.layoutToggleId}${d}`]:({fromEvent:u,setState:p,editor:h})=>{p({active:u.isOpen}),setTimeout(()=>h.refresh({tools:!0}),20)}},onClick:({editor:u,state:p})=>{if(p.active&&i)return;const h=(c==null?void 0:c.placer)||{type:"static",layoutId:nu},f={...h,skipCleanup:h.type==="static"},m=l||Object.keys(Ne).filter(v=>v!==d);su(u,{removeLayouts:m,layout:{placer:f}});const g={id:d,placer:h,header:(c==null?void 0:c.header)??{label:o,close:!i},layout:a,style:{width:280,height:"100%",borderRightWidth:1,...c==null?void 0:c.style}};u.runCommand(F.layoutToggle,g)}}},ou=n=>`button__${n}`,su=(n,e={})=>{(e.removeLayouts||Object.keys(Ne)).forEach(o=>n.runCommand(F.layoutRemove,{id:o,layout:e.layout}))},ru=n=>{const e=(n==null?void 0:n.breakpointTablet)??1024,t=(n==null?void 0:n.breakpointMobile)??768,o={breakpointTablet:e,breakpointMobile:t},s={},r=[{id:Ne.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:Ne.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:Ne.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:Ne.panelAssets,icon:'<svg viewBox="0 0 24 24"><path d="M22,16V4A2,2 0 0,0 20,2H8A2,2 0 0,0 6,4V16A2,2 0 0,0 8,18H20A2,2 0 0,0 22,16M11,12L13.03,14.71L16,11L20,16H8M2,6V20A2,2 0 0,0 4,22H18V20H4V6" /></svg>',label:"Assets",layoutComponent:{type:"panelAssets",content:{itemsPerRow:2,header:{addUrl:!1}},style:{padding:7},onSelect:({assetProps:h,editor:f})=>{var v;const m=f.getSelected(),g={type:"image",src:h.src};if(m!=null&&m.is("image"))return m.set("src",h.src);if(m&&f.Components.canMove(m,g)){const C=m.append(g)[0];C&&f.select(C)}else if(!m){const C=(v=f.getWrapper())==null?void 0:v.append(g)[0];C&&f.select(C)}}}}],i=[...r,{id:Ne.panelSidebarTabs,layoutCommand:{header:!1},icon:'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 0 1-1.5-1.5A1.5 1.5 0 0 1 17.5 9a1.5 1.5 0 0 1 1.5 1.5 1.5 1.5 0 0 1-1.5 1.5m-3-4A1.5 1.5 0 0 1 13 6.5 1.5 1.5 0 0 1 14.5 5 1.5 1.5 0 0 1 16 6.5 1.5 1.5 0 0 1 14.5 8m-5 0A1.5 1.5 0 0 1 8 6.5 1.5 1.5 0 0 1 9.5 5 1.5 1.5 0 0 1 11 6.5 1.5 1.5 0 0 1 9.5 8m-3 4A1.5 1.5 0 0 1 5 10.5 1.5 1.5 0 0 1 6.5 9 1.5 1.5 0 0 1 8 10.5 1.5 1.5 0 0 1 6.5 12M12 3a9 9 0 0 0-9 9 9 9 0 0 0 9 9 1.5 1.5 0 0 0 1.5-1.5c0-.4-.2-.7-.4-1-.2-.3-.4-.6-.4-1a1.5 1.5 0 0 1 1.5-1.5H16a5 5 0 0 0 5-5c0-4.4-4-8-9-8Z"/></svg>',label:"Styles & Props",layoutComponent:{type:"panelSidebarTabs"}}],l={id:nu,type:"column",style:{overflow:"hidden"}},a={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},c={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}},d=(h,f)=>{const m=h.map(v=>{const C=So(v);return n!=null&&n.sidebarButton?n.sidebarButton({id:v.id,buttonIds:Ne,breakpoint:f,buttonProps:C,sidebarButtonProps:v,...o,createSidebarButton:y=>So({...v,...y})}):C}).filter(Boolean);return(n!=null&&n.sidebarButtons?n==null?void 0:n.sidebarButtons({buttonIds:Ne,breakpoint:f,sidebarButtons:m,...o,createSidebarButton:v=>So({...v})}):m).filter(Boolean)},u=(h,f,m)=>{var g;return((g=n==null?void 0:n.rootLayout)==null?void 0:g.call(n,{breakpoint:m,sidebarButtons:f,rootLayout:h,layoutSidebarLeft:a,layoutSidebarTarget:l,...o,createSidebarButton:v=>So({...v})}))??h};if(e){const h=d(i,e);s[e]=u({type:"row",style:{height:"100%"},children:[{...a,children:h},l,c]},h,e)}if(t){const h=i.map(m=>({...m,layoutCommand:{placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}}})),f=d(h,t);s[t]=u({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas"},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:f}]},f,t)}const p=d(r,0);return{default:u({type:"row",style:{height:"100%"},children:[{...a,children:p},l,c,{type:"sidebarRight"}]},p,0),responsive:s}},ga="layoutSidebarButtons",my=H.free,gy=function(n,e={}){const{Commands:t}=n,o=t.events,s={...e};(()=>{if(n.runCommand(F.layoutConfigGet)||s.skipLayoutConfig===!0)return;const l=ru(s);n.runCommand(F.layoutConfigSet,{...l})})(),t.add(`${ga}:toggleButton`,(i,l,a)=>{const c=document.getElementById(ou(a==null?void 0:a.id));c==null||c.click()}),n.on(`${o.runCommand}core:preview`,()=>{su(n)}),G({editor:n,licenseKey:s.licenseKey,plan:my,pluginName:ga,cleanup:()=>{n.runCommand(F.layoutConfigSet)}})},iu=_(gy);iu.createLayoutConfig=n=>ru(n);const yt="page-break";function Or(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 yy=(n,e)=>{const{name:t,id:o,width:s,height:r,unit:i}=n,{fixedHeight:l}=e,a=`${s}${i}`,c=`${r}${i}`;return{id:o||t.toLowerCase().replace(/\s/g,"-"),name:`${t} (${a} x ${c})`,sizeH:r,sizeW:s,sizeUnit:i,widthMedia:"",width:a,minHeight:l?"0":`${Or(r,i)}px`,height:l?c:void 0}},Rr="page-breaks",xo="gjs-page-breaks-spot",_s=n=>n.type===Rr;function by(n){const{Devices:e}=n,{height:t,minHeight:o}=e.getSelected().attributes,r=parseFloat(`${t&&t!=="auto"?t:o}`),i=n.getWrapper(),l=i==null?void 0:i.getEl(),a=[];if(!i||!l)return a;const c=l.getBoundingClientRect().height,u=i.findType(yt).map(h=>h.getEl()).filter(Boolean).map(h=>({top:h.offsetTop,height:h.offsetHeight}));let p=0;for(;p<c;){const h=u.find(f=>f.top>p&&f.top<p+r);h?(p=h.top+h.height,a.push(h.top)):(p+=r,p<c&&a.push(p))}return a}function vy(n,e){const{Canvas:t}=n,o=t.events,s=n.events;let r;const i=()=>{zr(`${Pa}preset-printable-spots`,`.${xo} {
|
|
336
842
|
position: absolute;
|
|
337
843
|
left: 0;
|
|
338
844
|
width: 100%;
|
|
339
845
|
border-top: 1px dashed var(--gs-theme-cl-cmp-bg2, var(--gjs-color-blue));
|
|
340
846
|
}
|
|
341
|
-
.${
|
|
847
|
+
.${xo}::after {
|
|
342
848
|
background-color: var(--gs-theme-cl-cmp-bg1, var(--gjs-color-highlight));
|
|
343
849
|
content: attr(data-page-number);
|
|
344
850
|
display: block;
|
|
@@ -349,9 +855,9 @@
|
|
|
349
855
|
right: 0;
|
|
350
856
|
transform: translate(100%, -50%);
|
|
351
857
|
}
|
|
352
|
-
`,{target:window.document.head})},l=()=>{if(e.enablePageBreaksSpot===!1)return;const
|
|
353
|
-
${!!parseFloat(`${
|
|
354
|
-
[data-gjs-type="wrapper"] { min-height: ${
|
|
858
|
+
`,{target:window.document.head})},l=()=>{if(e.enablePageBreaksSpot===!1)return;const m={id:Rr,type:Rr,component:n.getWrapper()};return t.getSpots(m).pop()||t.addSpot(m)},a=({spot:m})=>{const{spotEl:g}=m.attributes;!_s(m)||!g||!r||r.removeChild(g)},c=({spot:m})=>{if(!_s(m)||!r)return;let{spotEl:g}=m.attributes;g||(g=document.createElement("div"),g.className=`${xo}__items`,m.set({spotEl:g})),r.appendChild(g)},d=({spot:m})=>{const{spotEl:g,pageBreaks:v=[]}=m.attributes;!_s(m)||!g||!r||(Object.entries(m.getStyle()).forEach(([C,y])=>g.style.setProperty(C,y)),g.innerHTML="",v.forEach((C,y)=>{const b=document.createElement("div");b.setAttribute("data-page-number",`${y+2}`),b.className=xo,b.style.top=`${C}px`,g.appendChild(b)}))},u=Hn(()=>{if(n.em.destroyed)return;const m=l();m&&m.set({pageBreaks:by(n),up:(m.attributes.up||0)+1})},150),p=Hn(u,200),h=()=>{r=t.getSpotsEl(),l()},f=[["component:input",u],[s.update,u],[o.spotAdd,c],[o.spotUpdate,d],[o.spotRemove,a],[o.frameLoadBody,h]];return f.forEach(([m,g])=>n.on(m,g)),n.onReady(()=>{i(),new ResizeObserver(p).observe(t.getElement().parentElement)}),()=>{f.forEach(([m,g])=>n.off(m,g)),u.clear(),p.clear()}}var Dr=(n=>(n.print="presetPrintable:print",n))(Dr||{});const ya=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 Sy(n,e){const{Commands:t,Pages:o}=n;return t.add(Dr.print,async(s,r,i={})=>{const l={page:i.allPages?void 0:o.getSelected(),styles:"inline",optionsHtml:{exporter:null}},c=(await t.run(F.projectFiles,l)).filter(p=>p.filename.endsWith(".html")),d=c.map(p=>p.content).join('<div style="break-before: page;"></div>'),u=[];if(i.separatePrints)for(const p of c)u.push(await ya(p));else u.push(await ya({content:d,filename:"",mimeType:""}));for(const p of u){const h=p.contentWindow;h.focus(),h.print()}setTimeout(()=>u.forEach(p=>p.remove()),1e3)}),t.add("presetPrintable:exp",async s=>{await fi("https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"),await fi("https://cdn.jsdelivr.net/npm/jspdf@3.0.0/dist/jspdf.umd.min.js");const{Devices:r,Canvas:i}=s,{sizeW:l,sizeH:a,sizeUnit:c}=r.getSelected().attributes,d=i.getFrameEl().contentDocument,u="px",p=[Or(l,c),Or(a,c)],h=new window.jspdf.jsPDF({unit:u,format:p}),f=d.body;h.html(f,{callback:m=>m.save()})}),()=>{delete n.Commands.commands[Dr.print]}}function xy(n,e){const{blockPageBreak:t={}}=e,{Components:o,Blocks:s}=n,r="Page Break",i=`${$e}${yt}`;return o.addType(yt,{block:t&&{label:r,media:'<svg viewBox="0 0 24 24"><path d="M18 20H6v-2H4v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2h-2v2M14 2H6a2 2 0 0 0-2 2v8h2V4h8v4h4v4h2V8l-6-6m-3 14H8v-2h3v2m5 0h-3v-2h3v2M3 14h3v2H3v-2m18 2h-3v-2h3v2Z"/></svg>',category:"Extra",select:!0,...t},isComponent:pt(yt),model:{defaults:{name:r,classes:i,attributes:{[Je]:yt},emptyState:!0,stylable:!1,droppable:!1,draggable:$r("wrapper"),styles:`.${i} { break-before: page; }`,traits:[]}}}),()=>{o.removeType(yt),s.remove(yt)}}const wy="presetPrintable",Cy=function(n,e={}){const t={selectedDevice:"a4",...e},{Canvas:o,Devices:s}=n,r=o.events,i=n.events,l=t.selectedDevice||s.getConfig().default,c=[{name:"A5",width:148,height:210,unit:"mm"},{name:"A5 Portrait",width:210,height:148,unit:"mm"},{name:"A4",width:210,height:297,unit:"mm"},{name:"A3",width:297,height:420,unit:"mm"},{name:"B5",width:176,height:250,unit:"mm"},{name:"B4",width:250,height:353,unit:"mm"},{name:"Letter",width:8.5,height:11,unit:"in"},{name:"Legal",width:8.5,height:14,unit:"in"},{name:"Ledger",width:11,height:17,unit:"in"}].map(y=>yy(y,t));s.devices.reset(c);const d=l&&s.get(l)||s.getAll().at(0);s.select(d);const u=()=>{const y="page-rule",{rules:b}=n.Css,{width:S,height:x,minHeight:w}=s.getSelected().attributes,E=x&&x!=="auto"?x:w;(b.where({id:y}).pop()||b.add({id:y,selectors:[],selectorsAdd:"@page"},{at:0})).setStyle({size:`${S} ${E}`,margin:"0"})},p=y=>{const b=y.document,{minHeight:S}=s.getSelected().attributes,w=`
|
|
859
|
+
${!!parseFloat(`${S}`)?`
|
|
860
|
+
[data-gjs-type="wrapper"] { min-height: ${S}; }
|
|
355
861
|
`:`
|
|
356
862
|
body {
|
|
357
863
|
overflow: hidden;
|
|
@@ -362,7 +868,37 @@
|
|
|
362
868
|
height: 100dvh;
|
|
363
869
|
}
|
|
364
870
|
`}
|
|
365
|
-
`;
|
|
871
|
+
`;zr(`${Pa}preset-printable`,w,{doc:b,target:b.head}),u()};n.on(r.frameLoadBody,y=>{const b=y.window;if(p(b),t.fixedHeight){const x=y.model.getComponent().getEl();x==null||x.addEventListener("scroll",w=>{const E=w.target;E.scrollTop>0&&E.scrollTo(0,0)})}}),n.on(s.events.select,()=>{var b;const y=(b=o.getFrameEl().contentDocument)==null?void 0:b.defaultView;y&&p(y)});const h=()=>{const b=n.Css.getRules().filter(S=>S.selectorsToString()==="body").pop();b==null||b.addStyle({"margin-top":"","margin-right":"","margin-bottom":"","margin-left":"",margin:"0"})},f=[[i.projectLoad,h]];f.forEach(([y,b])=>n.on(y,b));const m=vy(n,t),g=Sy(n),v=xy(n,t);n.onReady(()=>{n.UndoManager.clear()});const C=()=>{f.forEach(([y,b])=>n.off(y,b)),m(),g(),v()};n.on(i.destroy,C),G({editor:n,licenseKey:t.licenseKey,plan:H.startup,pluginName:wy,cleanup:C})},ky=_(Cy);var $n=(n=>(n.variable="data-variable",n.condition="data-condition",n.conditionTrue="data-condition-true-content",n.conditionFalse="data-condition-false-content",n.collection="data-collection",n.collectionItem="data-collection-item",n))($n||{});class Ty{constructor(e){this.strategy=e,this.requiredHelpers=new Set,this.helperLibrary={}}registerHelper(e){this.helperLibrary[e]&&this.requiredHelpers.add(e)}generateVariable(e){return this.strategy.getVariableSyntax(e)}generateCollectionStart(e){return this.registerHelper("slice"),this.strategy.getCollectionStartSyntax(e)}generateCollectionEnd(){return this.strategy.getCollectionEndSyntax()}generateConditionalStart(e){return this.strategy.getConditionalStartSyntax(e)}generateConditionElse(){return this.strategy.getConditionElseSyntax()}generateConditionalEnd(){return this.strategy.getConditionalEndSyntax()}reset(){this.requiredHelpers.clear()}}function Ey(n){return typeof n=="object"&&n.type===$n.variable}function wo({component:n,value:e,getCustomPath:t}){if(Ey(e)&&!e.collectionId&&t){const o=e.path??"",s=o.split(".");return{...e,path:t({component:n,path:o,paths:s})}}return e}const My=n=>{Gs(n,$n.variable,{toHTML(e){var i;const t=this.tagName,o=this.__attrToString(e),s=(i=this.getDataResolver)==null?void 0:i.call(this),r=wo({component:this,value:s,getCustomPath:e==null?void 0:e.getCustomPath});return`<${t}${o?` ${o}`:""}>${e.exporter.generateVariable(r)}</${t}>`}}),Gs(n,$n.condition,{toHTML(e){var c,d;const t=e.exporter,o=e==null?void 0:e.getCustomPath,s=this.components(),[r,i]=(s==null?void 0:s.models)??[],l=(c=this.getDataResolver)==null?void 0:c.call(this),a=((d=this.resolveCondition)==null?void 0:d.call(this,l==null?void 0:l.condition,o))??{};return`
|
|
872
|
+
${t.generateConditionalStart(a)}
|
|
873
|
+
${(r==null?void 0:r.toHTML(e))??""}
|
|
874
|
+
${t.generateConditionElse()}
|
|
875
|
+
${(i==null?void 0:i.toHTML(e))??""}
|
|
876
|
+
${t.generateConditionalEnd()}
|
|
877
|
+
`},resolveCondition(e,t){var s,r;if(!e)return{};if(e.operator==="and"||e.operator==="or")return{operator:e.operator,statements:((r=(s=e.statements)==null?void 0:s.map)==null?void 0:r.call(s,i=>{var l;return((l=this.resolveCondition)==null?void 0:l.call(this,i,t))??{}}))??[]};const o={component:this,getCustomPath:t};return{...e,left:wo({...o,value:e.left}),right:wo({...o,value:e.right})}}}),Gs(n,$n.collection,{toHTML(e){const t=e.exporter,o=this.tagName,s=this.__attrToString(e),r=this.getDataResolver(),i={...r,dataSource:wo({component:this,value:r==null?void 0:r.dataSource,getCustomPath:e==null?void 0:e.getCustomPath})},l=this.components().at(0);return`
|
|
878
|
+
<${o}${s?` ${s}`:""}>${t.generateCollectionStart(i)}
|
|
879
|
+
${(l==null?void 0:l.toHTML(e))??""}
|
|
880
|
+
${t.generateCollectionEnd()}</${o}>
|
|
881
|
+
`}})},Gs=(n,e,t)=>{const o=n.Components.getType(e);if(!o){console.warn(`Component type ${e} not found`);return}const{model:s}=o;n.Components.addType(e,{model:{...t,toHTML(r={}){var l;const{exporter:i}=r;return i?i.export?i.export({component:this}):((l=t.toHTML)==null?void 0:l.call(this,r))??"":s.prototype.toHTML.call(this,r)??""}}})},Ay=n=>{const e=n;return e.logicalOperator==="and"||e.logicalOperator==="or"},lu=(n,e)=>(n.config.optsHtml={...n.config.optsHtml,exporter:new Ty(e)},My(n),()=>{n.config.optsHtml.exporter=void 0}),au=(n,e)=>{const t=s=>{const{input:r}=s,{contains:i}=e;(!i||r.includes(i))&&(s.input=e.importer.import(r))},o=n.Parser.events.htmlBefore;return n.on(o,t),()=>{n.off(o,t)}};class Py{getVariableSyntax(e){const{defaultValue:t}=e,o=this.getFullPath(e),s=t?` || \`${t}\``:"";return`<%= ${o}${s} %>`}getCollectionStartSyntax(e){const{collectionId:t,dataSource:o,startIndex:s,endIndex:r}=e,i=(o==null?void 0:o.path)||t||"",l=this._sanitizeVariableName(t);let a="";if(s!==void 0||r!==void 0){const c=s??0,d=r!==void 0?r:"";a=`.slice(${c}${d!==""?`, ${d}`:""})`}return`<% ${i}${a}.forEach(function(currentItem, index, arr) {
|
|
366
882
|
const startIndex = parseInt(${s??0}, 10);
|
|
367
883
|
const endIndex = startIndex + arr.length;
|
|
368
|
-
const ${l}={ currentItem, currentIndex: startIndex + index, remainingItems: endIndex - (startIndex + index)} %>`}_sanitizeVariableName(e){return e.replace(/[^a-zA-Z0-9_$]/g,"_")}getCollectionEndSyntax(){return"<% }) %>"}getConditionalStartSyntax(e){return e?e.logicalOperator==="and"||e.logicalOperator==="or"?`<% if (${e.statements.map(o=>this._parseCondition(o)).join(` ${e.logicalOperator} `)}) { %>`:`<% if (${this._parseCondition(e)}) { %>`:""}_parseCondition(e){if(!e)return"";if(e.operator==="and"||e.operator==="or")return`(${e.statements.map(o=>this._parseCondition(o)).join(` ${e.operator} `)})`;{const t=this._parseValue(e.left),o=this._parseValue(e.right);switch(e.operator){case"equals":return`${t} === ${o}`;case">":case"<":case">=":case"<=":case"=":case"!=":return`${t} ${e.operator} ${o}`;case"contains":return`${t}?.includes(${o})`;case"startsWith":return`${t}?.startsWith(${o})`;case"endsWith":return`${t}?.endsWith(${o})`;case"equalsIgnoreCase":return`${t}?.toLowerCase() === ${o}?.toLowerCase()`;case"trimEquals":return`${t}?.trim() === ${o}?.trim()`;case"isTruthy":return`!!${t}`;case"isFalsy":return`!${t}`;case"isDefined":return`${t} !== undefined`;case"isNull":return`${t} === null`;case"isUndefined":return`${t} === undefined`;case"isArray":return`Array.isArray(${t})`;case"isObject":return`typeof ${t} === 'object' && ${t} !== null && !Array.isArray(${t})`;case"isString":return`typeof ${t} === 'string'`;case"isNumber":return`typeof ${t} === 'number' && !isNaN(${t})`;case"isBoolean":return`typeof ${t} === 'boolean'`;default:return`${t} ${e.operator} ${o}`}}}_parseValue(e){return typeof e=="object"?this.getVariableSyntax(e):typeof e=="string"?`'${e.replace(/'/g,"\\'")}'`:String(e)}getConditionElseSyntax(){return"<% } else { %>"}getConditionalEndSyntax(){return"<% } %>"}}const J0="dataSourceEjs",Y0=function(n,e={}){const t=({options:s})=>{s.exportConfig.exportPreset==="ejs"&&(s.exportConfig={...s.exportConfig,exportStrategy:new U0})},o=`${n.Commands.events.runBeforeCommand}${F.projectFiles}`;n.on(o,t),j({editor:n,licenseKey:e.licenseKey,plan:H.startup,pluginName:J0,cleanup:()=>{n.off(o,t)}})},Z0=W(Y0);class X0{getHelperId(e,t){return{equals:`${t==="string"?"str":t==="number"?"num":"any"}Equals`,isTruthy:"isTruthy",isFalsy:"isFalsy",isDefined:"isDefined",isNull:"isNull",isUndefined:"isUndefined",isArray:"isArray",isObject:"isObject",isString:"isString",isNumber:"isNumber",isBoolean:"isBoolean",isDefaultValue:"isDefaultValue",">":"numGt","<":"numLt",">=":"numGte","<=":"numLte","=":"numEq","!=":"numNeq",contains:"strContains",startsWith:"strStartsWith",endsWith:"strEndsWith",equalsIgnoreCase:"strEqualsIgnoreCase",trimEquals:"strTrimEquals"}[e]||e}getVariableSyntax({collectionId:e,variableType:t,path:o,defaultValue:s}){let r=o;return e&&(r=[this._sanitizeVariableName(e),t,o].filter(Boolean).join(".")),s?`{{#if ${o}}}{{{${r}}}}{{else}}${s}{{/if}}`:`{{{${r}}}}`}getCollectionStartSyntax(e){const{collectionId:t,dataSource:o}=e,s=o==null?void 0:o.path;let r="";if(e.startIndex!==void 0||e.endIndex!==void 0){const c=e.startIndex??0,d=e.endIndex!==void 0?e.endIndex:"";d!==""?r=` (slice ${s} ${c} ${d})`:r=` (slice ${s} ${c})`}const l=` as |${this._sanitizeVariableName(t)}|`;return`{{#each ${r||s}${l}}}`}getCollectionEndSyntax(){return"{{/each}}"}getConditionalStartSyntax(e){if(!e)return"";if(e.logicalOperator==="and"||e.logicalOperator==="or"){const t=this.getHelperId(e.logicalOperator),o=e.statements.map(s=>this._parseCondition(s)).join(", ");return`{{#if (${t} ${o})}}`}else return`{{#if ${this._parseCondition(e)}}}`}_parseCondition(e){if(!e)return"";if(e.operator==="and"||e.operator==="or"){const t=this.getHelperId(e.operator),o=e.statements.map(s=>this._parseCondition(s)).join(" ");return`(${t} ${o})`}else{const t=this.getHelperId(e.operator,this._getTypeHint(e)),o=this._parseValue(e.left),s=this._parseValue(e.right);return`(${t} ${o} ${s})`}}_getTypeHint(e){return["contains","startsWith","endsWith","equalsIgnoreCase","trimEquals"].includes(e.operator)?"string":[">","<",">=","<=","=","!="].includes(e.operator)?"number":"any"}_parseValue(e){return typeof e=="object"?this.getVariableSyntax(e):typeof e=="string"?`'${e.replace(/'/g,"\\'")}'`:String(e)}_sanitizeVariableName(e){return e.replace(/[^a-zA-Z0-9_$]/g,"_")}getConditionElseSyntax(){return"{{else}}"}getConditionalEndSyntax(){return"{{/if}}"}}const Q0="dataSourceHandlebars",ey=function(n,e={}){const t=({options:s})=>{const r=s.exportConfig;r.exportPreset==="handlebarsjs"&&(s.exportConfig={...r,exportStrategy:new X0})},o=`${n.Commands.events.runBeforeCommand}${F.projectFiles}`;n.on(o,t),j({editor:n,licenseKey:e.licenseKey,plan:H.startup,pluginName:Q0,cleanup:()=>{n.off(o,t)}})},ty=W(ey),ny=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)},sa="youtube-video",oy=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:o="high"}=n,s=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=ny(l);return`${c}?${d}`},r=l=>{var a,c,d;return((a=l[o])==null?void 0:a.url)||((c=l.high)==null?void 0:c.url)||((d=l.medium)==null?void 0:d.url)||l.default.url},i=l=>{const a=r(l.snippet.thumbnails);return{id:l.id.videoId,src:`https://www.youtube.com/watch?v=${l.id.videoId}`,name:l.snippet.title,type:sa,customData:{thumbnailUrl:a,videoItem:l}}};return{id:"youtube",types:[sa],label:({editor:l})=>l.I18n.t("youtubeAssetProvider.providerLabel"),search:{reloadOnInput:!0,debounceMs:1e3},async onLoad({searchValue:l,pageCustomData:a}){var m;const c={maxResults:25,q:l,pageToken:a==null?void 0:a.token,type:["video"],key:e},d=t==null?void 0:t({searchValue:l}),u={...c,...d};u.part?u.part.includes("snippet")||u.part.push("snippet"):u.part=["snippet"];const h=await(await fetch(s(u))).json();return(m=h.items)!=null&&m.length?{items:h.items.map(i),nextPageCustomData:{token:h.nextPageToken},isLastPage:!h.nextPageToken}:{items:[],isLastPage:!0}},itemLayout:({assetProps:l,onSelect:a})=>({type:"column",onClick:()=>a(l),htmlAttrs:{title:l.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"custom",render:()=>{var c;return`<img src="${(c=l.customData)==null?void 0:c.thumbnailUrl}" alt="${l.name}" style="width: 100%; height: 100px; object-fit: cover">`}},{type:"text",content:l.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingLeft:8,paddingRight:8}}]})}},sy={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},ry="youtubeAssetProvider",iy=H.startup,ly=function(n,e){var c;const{skipVideoComponent:t,i18n:o={}}=e,s=oy(e);n.runCommand(F.assetProviderAdd,{provider:s});const r="search-on-youtube",i="video",l=(c=n.Components.getType(i))==null?void 0:c.model.prototype,a=d=>{n.Assets.open({modalTitle:n.I18n.t("youtubeAssetProvider.modalTitle"),providerId:s.id,providers:[],types:[],select:u=>{n.Assets.close(),d.set({videoId:u.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})};!t&&l&&n.Components.addType(i,{model:{getYoutubeTraits(){const[d,...u]=l.getYoutubeTraits.apply(this);return[d,{id:r,type:"button",label:n.I18n.t("youtubeAssetProvider.searchBtn"),command:()=>a(this)},...u]}},view:{events:()=>({dblclick:"onActive"}),onActive(){const{model:d}=this,u=d.get("provider")||"";u!=null&&u.startsWith("yt")&&a(d)}}}),n.I18n.addMessages({en:sy,...o}),j({editor:n,licenseKey:e.licenseKey,plan:iy,pluginName:ry,cleanup:()=>{n.runCommand(F.assetProviderRemove,{id:s.id}),!t&&l&&n.Components.addType(i,{model:{getYoutubeTraits(){return l.getYoutubeTraits.apply(this).filter(d=>d.id!==r)}}})}})},ay=W(ly),qn=n=>n.replaceAll('"',"").replaceAll("'",""),Tr=n=>n.includes(",")?n:/\s/.test(n)?`"${qn(n)}"`:qn(n),ra=(n,e,t)=>({family:n,variant:e,...t}),Gd=(n,e)=>{n=Tr(n);const{menuVariant:t,variants:o}=e;return{family:n,familyLabel:qn(n),menuVariant:t&&ra(Tr(`menuFont-${qn(n)}`),"regular",t),variants:Object.assign({},...Object.entries(o).map(([s,r])=>({[s]:ra(n,s,r)})))}},ia=(n,e)=>{var l;const t=Gd(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:r}=o,i=qn(o.family);if(!e){const a=new FontFace(i,`url("${s}")`,r),c=Array.from(document.fonts.values()).filter(d=>d.family===i);for(const d of c)document.fonts.delete(d);document.fonts.add(a),a.load().catch(()=>{})}return Tr(i)},cy=n=>{const{family:e,menu:t,axes:o}=n,s=!!o,r=Object.assign({},...n.variants.map(i=>{var d,u;let l,a;if(s){const p=o.find(h=>h.tag==="wght");if(p){const{start:h,end:f}=p;l=`${h} ${f}`}}return l||(l=((d=i.match(/\d+/))==null?void 0:d[0])??"400"),a=((u=i.match(/[a-zA-Z]+/))==null?void 0:u[0])==="italic"?"italic":void 0,{[i]:{source:n.files[i],descriptors:{style:a,weight:l}}}}));return Gd(e,{menuVariant:{source:t},variants:r})},dy=n=>({id:`${n.family}/${n.version}`,type:"font",src:n.menu,name:n.family,customData:{font:cy(n),needsLoading:!0}}),uy=n=>{const{font:e}=n.customData;return n.customData.needsLoading?(n.customData.needsLoading=!1,ia(e)):ia(e,!0)};let xn;const py=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)},hy=n=>{const{apiKey:e,searchParams:t}=n,o=(s={})=>{const r="https://www.googleapis.com/webfonts/v1/webfonts",i=py(s);return`${r}?${i}`};return{id:"google-fonts",types:["font"],label:({editor:s})=>s.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var c;if(xn)return xn;const s={key:e,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},r=t==null?void 0:t(),i={...s,...r},a=await(await fetch(o(i))).json();return(c=a.items)!=null&&c.length?(xn=a.items.map(dy),xn):[]},itemLayout:s=>{const r=xn.find(l=>l.id===s.assetProps.id),i=uy(r);return{type:"column",onClick:()=>s.onSelect(r),htmlAttrs:{title:r.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:r.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:i,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}},{type:"text",content:r.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"16px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},fy={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},my="googleFontsAssetProvider",gy=H.startup,yy=function(n,e){const{i18n:t={}}=e,o=hy(e);n.runCommand(F.assetProviderAdd,{provider:o}),n.I18n.addMessages({en:fy,...t}),j({editor:n,licenseKey:e.licenseKey,plan:gy,pluginName:my,cleanup:()=>{n.runCommand(F.assetProviderRemove,{id:o.id})}})},by=W(yy),vy="canvasAbsoluteMode",xy=H.startup,Sy=(n,e,t)=>{const o=t.enableAbsolute??(a=>a.hasAbsolute),r=(Array.isArray(e)?e:e?[e]:[...n.getSelectedAll()])[0];if(!r)return;const i=r.getEl();return{result:Dt(o)?o({component:r,hasAbsolute:!!i&&getComputedStyle(i).position==="absolute"}):!1,component:r,dmode:r.get("dmode")}};function ko({guideMatched:n,canvasView:e}){var E;const t=n.guide.x===void 0?"y":"x";let o=0,s=0,r=0,i=0;const{guide:l,matched:a}=n,c=e.getElBoxRect(l.componentView.el),d=e.getElBoxRect(((E=a.componentView)==null?void 0:E.el)||a.componentEl),u=c.y,p=c.y+c.height,h=c.x,f=c.x+c.width,m=d.y,g=d.y+d.height,v=d.x,C=d.x+d.width,y=Math.max(0,u-g),b=Math.max(0,m-p),x=Math.max(0,h-C),S=Math.max(0,v-f),w=y>b,M=x>S,k=l.type;return t==="x"&&(k==="l"?(o=h,w?(s=g,r=y):(s=p,r=b)):k==="r"?(o=f,w?(s=g,r=y):(s=p,r=b)):k==="x"&&(o=h-(h-f)/2,w?(s=g,r=y):(s=p,r=b))),t==="y"&&(k==="t"?(s=u,M?(o=C,i=x):(o=f,i=S)):k==="b"?(s=p,M?(o=C,i=x):(o=f,i=S)):k==="y"&&(s=u-(u-p)/2,M?(o=C,i=x):(o=f,i=S))),{axis:t,x:o,y:s,width:i,height:r}}function wy({guideMatched:n,component:e,canvasView:t}){const o=n.guide.x===void 0?"x":"y",{guide:s,matched:r}=n,i=s.type,l=r.type,a=t.getElementPos(s.componentView.el).rect,c=t.getElementPos(r.componentView.el).rect;if(o==="x"){const d=a.height,u=c.top,p=c.top+c.height;let h=0;i==="t"?l==="t"?h=u-d:l==="b"?h=p-d:l==="y"&&(h=u-d-(u-p)/2):i==="b"?l==="t"?h=u-d*2:l==="b"?h=p-d*2:l==="y"&&(h=u-d*2-(u-p)/2):i==="y"&&(l==="t"?h=u-d*1.5:l==="b"?h=p-d*1.5:l==="y"&&(h=u-d*1.5-(u-p)/2)),e.addStyle({top:`${h-5}px`},{partial:!0})}if(o==="y"){const d=a.width,u=c.left,p=c.left+c.width;let h=0;i==="l"?l==="l"?h=u:l==="r"?h=p:l==="x"&&(h=u-(u-p)/2):i==="r"?l==="l"?h=u-d:l==="r"?h=p-d:l==="x"&&(h=u-d-(u-p)/2):i==="x"&&(l==="l"?h=u-d/2:l==="r"&&(h=p-d/2)),e.addStyle({left:`${h}px`},{partial:!0})}}function Wd({snapping:n,editor:e,props:t}){var P,O;const{command:o,guidesMatched:s}=t,r=t.component,i=r.getEl(),l=e.Canvas.getCanvasView(),{x:a,y:c}=n??{x:10,y:10},d=o.opts.event,u=d.clientX,p=d.clientY;if(!r.__lastSnappedPosition){const N=l.getElBoxRect(i),D=u-N.x,V=p-N.y;r.__lastSnappedPosition={left:N.x,top:N.y},r.__dragOffset={x:D,y:V}}const h=((P=r.__dragOffset)==null?void 0:P.x)||0,f=((O=r.__dragOffset)==null?void 0:O.y)||0,m=r.__lastSnappedPosition,g=u-m.left-h,v=p-m.top-f;let C=m.left,y=m.top;const b=s==null?void 0:s[0],x=(b==null?void 0:b.guide.type)==="l",S=(b==null?void 0:b.guide.type)==="x",w=(b==null?void 0:b.guide.type)==="r",M=(b==null?void 0:b.guide.type)==="t",k=(b==null?void 0:b.guide.type)==="b",E=(b==null?void 0:b.guide.type)==="y";if(b){const{x:N,y:D}=ko({guideMatched:b,canvasView:l}),V=i.offsetWidth,J=i.offsetHeight;x?C=N:w?C=N-V:S?C=N-V/2:M?y=D:k?y=D-J:E&&(y=D-J/2),r.__lastSnappedGuideMatched=b}else Math.abs(g)>=a&&(C=Math.round((m.left+g)/a)*a,r.__lastSnappedGuideMatched=null),Math.abs(v)>=c&&(y=Math.round((m.top+v)/c)*c,r.__lastSnappedGuideMatched=null);return r.addStyle({left:`${C}px`,top:`${y}px`},{partial:!0}),r.__lastSnappedPosition={left:C,top:y},{x:C,y,guideMatched:r.__lastSnappedGuideMatched}}function Cy({snapping:n,props:e,editor:t}){const{x:o,y:s}=Wd({snapping:n,props:e,editor:t}),r=e.component;r.addStyle({left:`${o}px`,top:`${s}px`}),delete r.__lastSnappedPosition,delete r.__lastSnappedGuideMatched}const ky="core:component-drag",Ty="studio:setDragAbsolute",My="dmode:start",la="dmode:move",aa="dmode:end",Ls="dragAbsolute",Ey="select",Ay="hover",Py="spacing",Ny=function(n,e={}){const{Commands:t}=n,o=t.events,s=t.getConfig().defaultOptions??{},r=`${o.runBeforeCommand}tlb-move`;s[ky]={run:w=>({...w,skipGuidesRender:!0})};const{snapping:i,locking:l,globalAbsolute:a=!0}=e;a&&n.setDragMode("absolute");const c=!!(i!=null&&i.x||i!=null&&i.y),d=!!(l!=null&&l.x||l!=null&&l.y),{Canvas:u}=n;let p=null;const h=w=>{const{component:M,guidesMatched:k,command:E}=w,P=M.view,O=n.Canvas.getCanvasView(),N=M.getEl();let D=k.map(ne=>ne.matched.componentEl),V=k.map(ne=>ko({guideMatched:ne,canvasView:O}));if(c){const{guideMatched:ne}=Wd({snapping:i,props:w,editor:n});ne?(D=[ne.matched.componentEl],V=[ko({guideMatched:ne,canvasView:O})]):(D=[],V=[])}if(d)if(E.opts.event.shiftKey)if(!p)p=k[0];else{const Ae=p,q=Ae.guide.x===void 0?"x":"y";(q==="x"&&(l==null?void 0:l.x)||q==="y"&&(l==null?void 0:l.y))&&(wy({guideMatched:Ae,component:M,canvasView:O}),D=[Ae.matched.componentEl],V=[ko({guideMatched:Ae,canvasView:O})])}else p=null;const J={id:Ls,type:Ls,component:M,componentView:P,originComponent:N,matchedComponents:D,originMatchedDistances:V};u.addSpot(J)},f=({enabled:w})=>{n.runCommand(Ty,{enabled:w})},m=({type:w})=>{u.removeSpots({type:w})},g=()=>{m({type:Ey}),m({type:Ay}),m({type:Py})},v=w=>{f({enabled:!0}),h(w),g()},C=w=>{h(w),g()},y=w=>{m({type:Ls}),c&&Cy({snapping:i,props:w,editor:n}),f({enabled:!1})},S=[[My,w=>{v(w),n.on(la,C);const M=()=>{y(w),n.off(la,C),n.off(aa,M)};n.on(aa,M)}],[r,w=>{if(a)return;const M=w.options.target,k=Sy(n,M,e);k!=null&&k.result&&!k.dmode&&(k.component.set({dmode:"absolute"}),w.options.mode="absolute")}]];S.forEach(([w,M])=>n.on(w,M)),j({editor:n,licenseKey:e.licenseKey,plan:xy,pluginName:vy,cleanup:()=>{f({enabled:!1}),S.forEach(([w,M])=>n.off(w,M))}})},Oy=W(Ny);exports.accordionComponent=jp;exports.canvasAbsoluteMode=Oy;exports.canvasEmptyState=m0;exports.canvasFullSize=b0;exports.canvasGridMode=V0;exports.dataSourceEjs=Z0;exports.dataSourceHandlebars=ty;exports.dialogComponent=lu;exports.flexComponent=hh;exports.fsLightboxComponent=ap;exports.googleFontsAssetProvider=by;exports.iconifyComponent=Cu;exports.layoutSidebarButtons=_d;exports.lightGalleryComponent=vp;exports.listPagesComponent=op;exports.presetPrintable=K0;exports.rteProseMirror=u0;exports.rteTinyMce=kh;exports.swiperComponent=Lp;exports.tableComponent=Ju;exports.youtubeAssetProvider=ay;
|
|
884
|
+
const ${l}={ currentItem, currentIndex: startIndex + index, remainingItems: endIndex - (startIndex + index)} %>`}_sanitizeVariableName(e){return e.replace(/[^a-zA-Z0-9_$]/g,"_")}getCollectionEndSyntax(){return"<% }) %>"}getConditionalStartSyntax(e){return`<% if (${this._parseCondition(e)}) { %>`}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(Ay(e)){const t=e.statements.map(o=>this._parseCondition(o));return t.length>1?`(${t.join(`) ${e.logicalOperator} (`)})`:t[0]}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 Iy=["===","==","!==","!=","<=",">=","<",">","&&","||"],Ny={"===":"=","==":"=","!==":"!=","!=":"!=","<=":"<=",">=":">=","<":"<",">":">","&&":"&&","||":"||"};class Oy{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 r=e.indexOf("%>",s);if(r===-1)throw new Error("Unclosed EJS tag");const i=e.slice(s+2,r).trim();if(o=r+2,i.startsWith("=")||i.startsWith("-")){const l=i.slice(1).trim();t.push(this.createAppendExpression(l))}else{if(i.startsWith("#"))continue;if(i.startsWith("if")){const l=this.parseIfStatement(i,e,o);t.push(l),o=l.endPos||o}else if(i.startsWith("for")){const l=this.parseForStatement(i,e,o);t.push(l),o=l.endPos||o}else{if(i.startsWith("}")||i.startsWith("} else"))break;this.addMessage("info",`Unsupported scriptlet content: ${i}`)}}}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)]}}}findNextElse(e,t){const o=/<%\s*\}\s*else(?:\s+if\s*\([^)]*\))?\s*\{\s*%>/g;o.lastIndex=t;const s=o.exec(e);return s?{start:s.index,end:e.indexOf("%>",s.index)+2}:null}parseIfStatement(e,t,o){const s=e.match(/if\s*\((.*)\)\s*\{?/);if(!s)throw new Error("Invalid if statement syntax");const r=this.parseJsExpression(s[1]),{body:i,endPos:l}=this.parseTemplateBlock(t,o);let a=null,c=l;const d=this.findNextElse(t,l);if(d){const u=t.slice(d.start,d.end);if(/else\s+if/.test(u)){const p=d.end,h=this.parseIfStatement(u,t,p);a={type:"IfStatement",test:h.test,consequent:h.consequent,alternate:h.alternate},c=h.endPos}else{const p=d.end,{body:h,endPos:f}=this.parseTemplateBlock(t,p);a={type:"BlockStatement",body:h},c=f}}return{type:"IfStatement",test:r,consequent:{type:"BlockStatement",body:i},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 r=s[1].split("of");if(r.length!==2)throw new Error("Only for...of loops are supported");const i=r[0].trim().replace(/^let\s+|^const\s+|^var\s+/,""),l=r[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:i},init:this.parseJsExpression(l)}]},test:null,update:null,body:{type:"BlockStatement",body:a},endPos:c}}parseTemplateBlock(e,t){const o=[];let s=t,r=1;for(;s<e.length&&r>0;){const i=e.indexOf("<%",s);if(i===-1){s<e.length&&o.push(this.createAppendLiteral(e.slice(s)));break}i>s&&o.push(this.createAppendLiteral(e.slice(s,i)));const l=e.indexOf("%>",i);if(l===-1)throw new Error("Unclosed EJS tag");const a=e.slice(i+2,l).trim();if(s=l+2,a==="}"){if(r--,r===0)break}else(a.startsWith("if")||a.startsWith("for"))&&r++;if(a.startsWith("=")||a.startsWith("-")){const c=a.slice(1).trim();o.push(this.createAppendExpression(c))}else{if(a.startsWith("#"))continue;if(a.startsWith("} else")){s=i;break}}}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 Iy){const r=e.indexOf(s);if(r>0)return{type:s==="&&"||s==="||"?"LogicalExpression":"BinaryExpression",operator:Ny[s],left:this.parseJsExpression(e.slice(0,r).trim()),right:this.parseJsExpression(e.slice(r+s.length).trim())}}const t=e.indexOf("."),o=e.indexOf("[");if(t>0||o>0){const s=t>0&&(o===-1||t<o)?t:o;let r,i,l=!1;if(s===t)r=e.slice(0,t),i=this.parseJsExpression(e.slice(t+1));else{r=e.slice(0,o);const a=e.indexOf("]",o);if(a===-1)throw new Error("Unclosed bracket in expression");i=this.parseJsExpression(e.slice(o+1,a)),l=!0}return{type:"MemberExpression",object:this.parseJsExpression(r),property:i,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"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)),`
|
|
885
|
+
<data-condition data-gjs-data-resolver='${JSON.stringify({condition:t})}'>
|
|
886
|
+
<data-condition-true-content>${o}</data-condition-true-content>
|
|
887
|
+
<data-condition-false-content>${s}</data-condition-false-content>
|
|
888
|
+
</data-condition>
|
|
889
|
+
`}handleForStatement(e){var i;if(((i=e.init)==null?void 0:i.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"),"";o.startsWith("data.")||(o=`data.${o}`);const s=`collection-${Math.random().toString(36).substring(2,10)}`;this.collectionStack.push(s);const r=this.astToGrapesJS(e.body);return this.collectionStack.pop(),`
|
|
890
|
+
<data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:o},collectionId:s})}'>
|
|
891
|
+
<data-collection-item>
|
|
892
|
+
${r}
|
|
893
|
+
</data-collection-item>
|
|
894
|
+
</data-collection>
|
|
895
|
+
`}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&&e.name==="item"){const o=this.collectionStack[this.collectionStack.length-1];t={path:e.name,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){let r=e;const i=[];let l=!1;for(;r.type==="MemberExpression";)if(r.property.type==="Identifier"?i.unshift(r.property.name):r.property.type==="Literal"&&r.computed&&i.unshift(`[${r.property.value}]`),r=r.object,r.type==="Identifier"&&r.name==="item"){l=!0;break}if(l&&r.type==="Identifier"&&r.name==="item"){const a=this.collectionStack[this.collectionStack.length-1],c=i.join(".").replace(/\.\[/g,"[");s={...s,collectionId:a,variableType:"currentItem",path:c}}}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 Ry="dataSourceEjs",Dy=H.startup,Ly=function(n,e={}){const t=lu(n,new Py),o=au(n,{contains:"<%",importer:new Oy});G({editor:n,licenseKey:e.licenseKey,plan:Dy,pluginName:Ry,cleanup:()=>{t(),o()}})},$y=_(Ly);class zy{getHelperId(e,t){return{equals:`${t==="string"?"str":t==="number"?"num":"any"}Equals`,isTruthy:"isTruthy",isFalsy:"isFalsy",isDefined:"isDefined",isNull:"isNull",isUndefined:"isUndefined",isArray:"isArray",isObject:"isObject",isString:"isString",isNumber:"isNumber",isBoolean:"isBoolean",isDefaultValue:"isDefaultValue",">":"numGt","<":"numLt",">=":"numGte","<=":"numLte","=":"numEq","!=":"numNeq",contains:"strContains",startsWith:"strStartsWith",endsWith:"strEndsWith",equalsIgnoreCase:"strEqualsIgnoreCase",trimEquals:"strTrimEquals"}[e]||e}getFullPath({collectionId:e,path:t}){let o=t;return e&&(o=[this._sanitizeVariableName(e),t].filter(Boolean).join(".")),o||""}getVariableSyntax(e){const{defaultValue:t}=e,o=this.getFullPath(e);return t?`{{#if ${o}}}{{{${o}}}}{{else}}${t}{{/if}}`:`{{{${o}}}}`}getCollectionStartSyntax(e){const{collectionId:t,dataSource:o}=e,s=o==null?void 0:o.path;let r="";if(e.startIndex!==void 0||e.endIndex!==void 0){const c=e.startIndex??0,d=e.endIndex!==void 0?e.endIndex:"";d!==""?r=` (slice ${s} ${c} ${d})`:r=` (slice ${s} ${c})`}const l=` as |${this._sanitizeVariableName(t)}|`;return`{{#each ${r||s}${l}}}`}getCollectionEndSyntax(){return"{{/each}}"}getConditionalStartSyntax(e){if(!e)return"";const t=e,o=e;if(o.statements&&o.logicalOperator==="and"||o.logicalOperator==="or"){const{statements:s}=o,r=o.logicalOperator,i=s.map(a=>this._parseCondition(a)).join(", ");return`{{#if ${s.length>1?`(${r} ${i})`:i}}}`}else return`{{#if ${this._parseCondition(t)}}}`}_parseCondition(e){if(!e)return"";const t=e,o=e;if(o.statements&&o.logicalOperator==="and"||o.logicalOperator==="or"){const{statements:s}=o,r=o.logicalOperator,i=o.statements.map(l=>this._parseCondition(l)).join(" ");return s.length>1?`(${r} ${i})`:i}else{const s=this.getHelperId(t.operator,this._getTypeHint(e)),r=this._parseValue(t.left),i=this._parseValue(t.right);return`(${s} ${r} ${i})`}}_getTypeHint(e){return["contains","startsWith","endsWith","equalsIgnoreCase","trimEquals"].includes(e.operator)?"string":[">","<",">=","<=","=","!="].includes(e.operator)?"number":"any"}_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 By{constructor(){this.messages=[],this.collectionStack=[]}import(e){this.messages=[],this.collectionStack=[];const t=this.parse(e);return this.astToGrapesJS(t)}parse(e){try{return uu.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,r=t.message.match(/column (\d+)/),i=r?parseInt(r[1]):0;throw new Error(`Handlebars syntax error at line ${s}, column ${i}: ${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;if(this.collectionStack.length>0)if(o.startsWith("@")){const r=o.split("/");let i=0;const l=r[r.length-1];for(let c=0;c<r.length-1;c++)r[c]===".."&&i++;const a=Math.max(0,this.collectionStack.length-1-i);if(a>=0&&a<this.collectionStack.length){const c=this.collectionStack[a];l==="index"||l==="@index"?(s.collectionId=c,s.variableType="currentIndex"):l==="key"||l==="@key"?(s.collectionId=c,s.variableType="currentKey"):l==="first"||l==="@first"?(s.collectionId=c,s.variableType="isFirst"):l==="last"||l==="@last"?(s.collectionId=c,s.variableType="isLast"):s.path=o}else s.path=o}else{const r=o.split("/");let i=0;for(;r[0]==="..";)i++,r.shift();const l=r.join("/"),a=this.collectionStack.length-1-i;if(a>=0&&a<this.collectionStack.length){const c=this.collectionStack[a];l==="this"?(s.collectionId=c,s.variableType="currentItem"):(s.collectionId=c,s.variableType="currentItem",s.path=l.startsWith("this.")?l.split(".").slice(1).join("."):l)}else s.path=`globalData.${r.join(".")}`}else s.path=o;return`<data-variable data-gjs-data-resolver='${JSON.stringify(s)}'></data-variable>`}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 r={logicalOperator:"and",statements:[{left:{type:"data-variable",path:this.getExpressionString(e.params[0])},operator:t==="unless"?"isFalsy":"isTruthy"}]},i=this.handleProgram(e.program),l=e.inverse?this.handleProgram(e.inverse):"";return e.params[0].type==="PathExpression"?this.handleMustacheStatement(e.program.body[0],{defaultValue:l}):`
|
|
896
|
+
<data-condition data-gjs-data-resolver='${JSON.stringify({condition:r})}'>
|
|
897
|
+
<data-condition-true-content>${i}</data-condition-true-content>
|
|
898
|
+
<data-condition-false-content>${l}</data-condition-false-content>
|
|
899
|
+
</data-condition>
|
|
900
|
+
`}handleEachBlock(e){const t=this.getExpressionString(e.params[0]),o=`collection-${Math.random().toString(36).substring(2,10)}`;this.collectionStack.push(o);const s=this.handleProgram(e.program);return this.collectionStack.pop(),`
|
|
901
|
+
<data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:t},collectionId:o})}'>
|
|
902
|
+
<data-collection-item>${s}</data-collection-item>
|
|
903
|
+
</data-collection>
|
|
904
|
+
`}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 Vy="dataSourceHandlebars",Hy=H.startup,Fy=function(n,e={}){const t=lu(n,new zy),o=au(n,{contains:"{{",importer:new By});G({editor:n,licenseKey:e.licenseKey,plan:Hy,pluginName:Vy,cleanup:()=>{t(),o()}})},_y=_(Fy),Gy=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)},ba="youtube-video",Wy=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:o="high"}=n,s=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=Gy(l);return`${c}?${d}`},r=l=>{var a,c,d;return((a=l[o])==null?void 0:a.url)||((c=l.high)==null?void 0:c.url)||((d=l.medium)==null?void 0:d.url)||l.default.url},i=l=>{const a=r(l.snippet.thumbnails);return{id:l.id.videoId,src:`https://www.youtube.com/watch?v=${l.id.videoId}`,name:l.snippet.title,type:ba,customData:{thumbnailUrl:a,videoItem:l}}};return{id:"youtube",types:[ba],label:({editor:l})=>l.I18n.t("youtubeAssetProvider.providerLabel"),search:{reloadOnInput:!0,debounceMs:1e3},async onLoad({searchValue:l,pageCustomData:a}){var m;const c={maxResults:25,q:l,pageToken:a==null?void 0:a.token,type:["video"],key:e},d=t==null?void 0:t({searchValue:l}),u={...c,...d};u.part?u.part.includes("snippet")||u.part.push("snippet"):u.part=["snippet"];const h=await(await fetch(s(u))).json();return(m=h.items)!=null&&m.length?{items:h.items.map(i),nextPageCustomData:{token:h.nextPageToken},isLastPage:!h.nextPageToken}:{items:[],isLastPage:!0}},itemLayout:({assetProps:l,onSelect:a})=>({type:"column",onClick:()=>a(l),htmlAttrs:{title:l.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"custom",render:()=>{var c;return`<img src="${(c=l.customData)==null?void 0:c.thumbnailUrl}" alt="${l.name}" style="width: 100%; height: 100px; object-fit: cover">`}},{type:"text",content:l.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingLeft:8,paddingRight:8}}]})}},jy={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},qy="youtubeAssetProvider",Uy=H.startup,Ky=function(n,e){var c;const{skipVideoComponent:t,i18n:o={}}=e,s=Wy(e);n.runCommand(F.assetProviderAdd,{provider:s});const r="search-on-youtube",i="video",l=(c=n.Components.getType(i))==null?void 0:c.model.prototype,a=d=>{n.Assets.open({modalTitle:n.I18n.t("youtubeAssetProvider.modalTitle"),providerId:s.id,providers:[],types:[],select:u=>{n.Assets.close(),d.set({videoId:u.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})};!t&&l&&n.Components.addType(i,{model:{getYoutubeTraits(){const[d,...u]=l.getYoutubeTraits.apply(this);return[d,{id:r,type:"button",label:n.I18n.t("youtubeAssetProvider.searchBtn"),command:()=>a(this)},...u]}},view:{events:()=>({dblclick:"onActive"}),onActive(){const{model:d}=this,u=d.get("provider")||"";u!=null&&u.startsWith("yt")&&a(d)}}}),n.I18n.addMessages({en:jy,...o}),G({editor:n,licenseKey:e.licenseKey,plan:Uy,pluginName:qy,cleanup:()=>{n.runCommand(F.assetProviderRemove,{id:s.id}),!t&&l&&n.Components.addType(i,{model:{getYoutubeTraits(){return l.getYoutubeTraits.apply(this).filter(d=>d.id!==r)}}})}})},Jy=_(Ky),Xn=n=>n.replaceAll('"',"").replaceAll("'",""),Lr=n=>n.includes(",")?n:/\s/.test(n)?`"${Xn(n)}"`:Xn(n),va=(n,e,t)=>({family:n,variant:e,...t}),cu=(n,e)=>{n=Lr(n);const{menuVariant:t,variants:o}=e;return{family:n,familyLabel:Xn(n),menuVariant:t&&va(Lr(`menuFont-${Xn(n)}`),"regular",t),variants:Object.assign({},...Object.entries(o).map(([s,r])=>({[s]:va(n,s,r)})))}},Sa=(n,e)=>{var l;const t=cu(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:r}=o,i=Xn(o.family);if(!e){const a=new FontFace(i,`url("${s}")`,r),c=Array.from(document.fonts.values()).filter(d=>d.family===i);for(const d of c)document.fonts.delete(d);document.fonts.add(a),a.load().catch(()=>{})}return Lr(i)},Zy=n=>{const{family:e,menu:t,axes:o}=n,s=!!o,r=Object.assign({},...n.variants.map(i=>{var d,u;let l,a;if(s){const p=o.find(h=>h.tag==="wght");if(p){const{start:h,end:f}=p;l=`${h} ${f}`}}return l||(l=((d=i.match(/\d+/))==null?void 0:d[0])??"400"),a=((u=i.match(/[a-zA-Z]+/))==null?void 0:u[0])==="italic"?"italic":void 0,{[i]:{source:n.files[i],descriptors:{style:a,weight:l}}}}));return cu(e,{menuVariant:{source:t},variants:r})},Yy=n=>({id:`${n.family}/${n.version}`,type:"font",src:n.menu,name:n.family,customData:{font:Zy(n),needsLoading:!0}}),Xy=n=>{const{font:e}=n.customData;return n.customData.needsLoading?(n.customData.needsLoading=!1,Sa(e)):Sa(e,!0)};let kn;const Qy=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)},eb=n=>{const{apiKey:e,searchParams:t}=n,o=(s={})=>{const r="https://www.googleapis.com/webfonts/v1/webfonts",i=Qy(s);return`${r}?${i}`};return{id:"google-fonts",types:["font"],label:({editor:s})=>s.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var c;if(kn)return kn;const s={key:e,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},r=t==null?void 0:t(),i={...s,...r},a=await(await fetch(o(i))).json();return(c=a.items)!=null&&c.length?(kn=a.items.map(Yy),kn):[]},itemLayout:s=>{const r=kn.find(l=>l.id===s.assetProps.id),i=Xy(r);return{type:"column",onClick:()=>s.onSelect(r),htmlAttrs:{title:r.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:r.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:i,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}},{type:"text",content:r.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"16px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},tb={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},nb="googleFontsAssetProvider",ob=H.startup,sb=function(n,e){const{i18n:t={}}=e,o=eb(e);n.runCommand(F.assetProviderAdd,{provider:o}),n.I18n.addMessages({en:tb,...t}),G({editor:n,licenseKey:e.licenseKey,plan:ob,pluginName:nb,cleanup:()=>{n.runCommand(F.assetProviderRemove,{id:o.id})}})},rb=_(sb),ib="canvasAbsoluteMode",lb=H.startup,ab=(n,e,t)=>{const o=t.enableAbsolute??(a=>a.hasAbsolute),r=(Array.isArray(e)?e:e?[e]:[...n.getSelectedAll()])[0];if(!r)return;const i=r.getEl();return{result:zt(o)?o({component:r,hasAbsolute:!!i&&getComputedStyle(i).position==="absolute"}):!1,component:r,dmode:r.get("dmode")}};function No({guideMatched:n,canvasView:e}){var M;const t=n.guide.x===void 0?"y":"x";let o=0,s=0,r=0,i=0;const{guide:l,matched:a}=n,c=e.getElBoxRect(l.componentView.el),d=e.getElBoxRect(((M=a.componentView)==null?void 0:M.el)||a.componentEl),u=c.y,p=c.y+c.height,h=c.x,f=c.x+c.width,m=d.y,g=d.y+d.height,v=d.x,C=d.x+d.width,y=Math.max(0,u-g),b=Math.max(0,m-p),S=Math.max(0,h-C),x=Math.max(0,v-f),w=y>b,E=S>x,k=l.type;return t==="x"&&(k==="l"?(o=h,w?(s=g,r=y):(s=p,r=b)):k==="r"?(o=f,w?(s=g,r=y):(s=p,r=b)):k==="x"&&(o=h-(h-f)/2,w?(s=g,r=y):(s=p,r=b))),t==="y"&&(k==="t"?(s=u,E?(o=C,i=S):(o=f,i=x)):k==="b"?(s=p,E?(o=C,i=S):(o=f,i=x)):k==="y"&&(s=u-(u-p)/2,E?(o=C,i=S):(o=f,i=x))),{axis:t,x:o,y:s,width:i,height:r}}function cb({guideMatched:n,component:e,canvasView:t}){const o=n.guide.x===void 0?"x":"y",{guide:s,matched:r}=n,i=s.type,l=r.type,a=t.getElementPos(s.componentView.el).rect,c=t.getElementPos(r.componentView.el).rect;if(o==="x"){const d=a.height,u=c.top,p=c.top+c.height;let h=0;i==="t"?l==="t"?h=u-d:l==="b"?h=p-d:l==="y"&&(h=u-d-(u-p)/2):i==="b"?l==="t"?h=u-d*2:l==="b"?h=p-d*2:l==="y"&&(h=u-d*2-(u-p)/2):i==="y"&&(l==="t"?h=u-d*1.5:l==="b"?h=p-d*1.5:l==="y"&&(h=u-d*1.5-(u-p)/2)),e.addStyle({top:`${h-5}px`},{partial:!0})}if(o==="y"){const d=a.width,u=c.left,p=c.left+c.width;let h=0;i==="l"?l==="l"?h=u:l==="r"?h=p:l==="x"&&(h=u-(u-p)/2):i==="r"?l==="l"?h=u-d:l==="r"?h=p-d:l==="x"&&(h=u-d-(u-p)/2):i==="x"&&(l==="l"?h=u-d/2:l==="r"&&(h=p-d/2)),e.addStyle({left:`${h}px`},{partial:!0})}}function du({snapping:n,editor:e,props:t}){var P,N;const{command:o,guidesMatched:s}=t,r=t.component,i=r.getEl(),l=e.Canvas.getCanvasView(),{x:a,y:c}=n??{x:10,y:10},d=o.opts.event,u=d.clientX,p=d.clientY;if(!r.__lastSnappedPosition){const I=l.getElBoxRect(i),D=u-I.x,z=p-I.y;r.__lastSnappedPosition={left:I.x,top:I.y},r.__dragOffset={x:D,y:z}}const h=((P=r.__dragOffset)==null?void 0:P.x)||0,f=((N=r.__dragOffset)==null?void 0:N.y)||0,m=r.__lastSnappedPosition,g=u-m.left-h,v=p-m.top-f;let C=m.left,y=m.top;const b=s==null?void 0:s[0],S=(b==null?void 0:b.guide.type)==="l",x=(b==null?void 0:b.guide.type)==="x",w=(b==null?void 0:b.guide.type)==="r",E=(b==null?void 0:b.guide.type)==="t",k=(b==null?void 0:b.guide.type)==="b",M=(b==null?void 0:b.guide.type)==="y";if(b){const{x:I,y:D}=No({guideMatched:b,canvasView:l}),z=i.offsetWidth,J=i.offsetHeight;S?C=I:w?C=I-z:x?C=I-z/2:E?y=D:k?y=D-J:M&&(y=D-J/2),r.__lastSnappedGuideMatched=b}else Math.abs(g)>=a&&(C=Math.round((m.left+g)/a)*a,r.__lastSnappedGuideMatched=null),Math.abs(v)>=c&&(y=Math.round((m.top+v)/c)*c,r.__lastSnappedGuideMatched=null);return r.addStyle({left:`${C}px`,top:`${y}px`},{partial:!0}),r.__lastSnappedPosition={left:C,top:y},{x:C,y,guideMatched:r.__lastSnappedGuideMatched}}function db({snapping:n,props:e,editor:t}){const{x:o,y:s}=du({snapping:n,props:e,editor:t}),r=e.component;r.addStyle({left:`${o}px`,top:`${s}px`}),delete r.__lastSnappedPosition,delete r.__lastSnappedGuideMatched}const ub="core:component-drag",pb="studio:setDragAbsolute",hb="dmode:start",xa="dmode:move",wa="dmode:end",Ws="dragAbsolute",fb="select",mb="hover",gb="spacing",yb=function(n,e={}){const{Commands:t}=n,o=t.events,s=t.getConfig().defaultOptions??{},r=`${o.runBeforeCommand}tlb-move`;s[ub]={run:w=>({...w,skipGuidesRender:!0})};const{snapping:i,locking:l,globalAbsolute:a=!0}=e;a&&n.setDragMode("absolute");const c=!!(i!=null&&i.x||i!=null&&i.y),d=!!(l!=null&&l.x||l!=null&&l.y),{Canvas:u}=n;let p=null;const h=w=>{const{component:E,guidesMatched:k,command:M}=w,P=E.view,N=n.Canvas.getCanvasView(),I=E.getEl();let D=k.map(ne=>ne.matched.componentEl),z=k.map(ne=>No({guideMatched:ne,canvasView:N}));if(c){const{guideMatched:ne}=du({snapping:i,props:w,editor:n});ne?(D=[ne.matched.componentEl],z=[No({guideMatched:ne,canvasView:N})]):(D=[],z=[])}if(d)if(M.opts.event.shiftKey)if(!p)p=k[0];else{const Pe=p,q=Pe.guide.x===void 0?"x":"y";(q==="x"&&(l==null?void 0:l.x)||q==="y"&&(l==null?void 0:l.y))&&(cb({guideMatched:Pe,component:E,canvasView:N}),D=[Pe.matched.componentEl],z=[No({guideMatched:Pe,canvasView:N})])}else p=null;const J={id:Ws,type:Ws,component:E,componentView:P,originComponent:I,matchedComponents:D,originMatchedDistances:z};u.addSpot(J)},f=({enabled:w})=>{n.runCommand(pb,{enabled:w})},m=({type:w})=>{u.removeSpots({type:w})},g=()=>{m({type:fb}),m({type:mb}),m({type:gb})},v=w=>{f({enabled:!0}),h(w),g()},C=w=>{h(w),g()},y=w=>{m({type:Ws}),c&&db({snapping:i,props:w,editor:n}),f({enabled:!1})},x=[[hb,w=>{v(w),n.on(xa,C);const E=()=>{y(w),n.off(xa,C),n.off(wa,E)};n.on(wa,E)}],[r,w=>{if(a)return;const E=w.options.target,k=ab(n,E,e);k!=null&&k.result&&!k.dmode&&(k.component.set({dmode:"absolute"}),w.options.mode="absolute")}]];x.forEach(([w,E])=>n.on(w,E)),G({editor:n,licenseKey:e.licenseKey,plan:lb,pluginName:ib,cleanup:()=>{f({enabled:!1}),x.forEach(([w,E])=>n.off(w,E))}})},bb=_(yb);exports.accordionComponent=ph;exports.animationComponent=Wh;exports.canvasAbsoluteMode=bb;exports.canvasEmptyState=q0;exports.canvasFullSize=J0;exports.canvasGridMode=fy;exports.dataSourceEjs=$y;exports.dataSourceHandlebars=_y;exports.dialogComponent=Au;exports.flexComponent=Dh;exports.fsLightboxComponent=Pp;exports.googleFontsAssetProvider=rb;exports.iconifyComponent=Wu;exports.layoutSidebarButtons=iu;exports.lightGalleryComponent=Hp;exports.listPagesComponent=kp;exports.presetPrintable=ky;exports.rteProseMirror=_0;exports.rteTinyMce=tf;exports.swiperComponent=nh;exports.tableComponent=gp;exports.youtubeAssetProvider=Jy;
|