@grapesjs/studio-sdk-plugins 1.0.35 → 1.0.36
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/accordionComponent/index.cjs.js +7 -7
- package/dist/accordionComponent/index.es.js +175 -162
- package/dist/accordionComponent/index.umd.js +7 -7
- package/dist/aiChat/index.cjs.js +64 -64
- package/dist/aiChat/index.es.js +5785 -5757
- package/dist/aiChat/index.js +64 -64
- package/dist/aiChat/index.umd.js +63 -63
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +204 -191
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +183 -170
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +134 -121
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +9 -9
- package/dist/canvasFullSize/index.es.js +165 -152
- package/dist/canvasFullSize/index.umd.js +9 -9
- package/dist/canvasGridMode/index.cjs.js +5 -5
- package/dist/canvasGridMode/index.es.js +245 -232
- package/dist/canvasGridMode/index.umd.js +4 -4
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +155 -142
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/index.cjs.js +9 -9
- package/dist/dataSourceEjs/index.es.js +257 -244
- package/dist/dataSourceEjs/index.umd.js +9 -9
- package/dist/dataSourceHandlebars/index.cjs.js +8 -8
- package/dist/dataSourceHandlebars/index.es.js +216 -203
- package/dist/dataSourceHandlebars/index.umd.js +7 -7
- package/dist/dialogComponent/index.cjs.js +14 -14
- package/dist/dialogComponent/index.es.js +141 -128
- package/dist/dialogComponent/index.umd.js +14 -14
- package/dist/flexComponent/index.cjs.js +13 -13
- package/dist/flexComponent/index.es.js +484 -471
- package/dist/flexComponent/index.umd.js +13 -13
- package/dist/fsLightboxComponent/index.cjs.js +3 -3
- package/dist/fsLightboxComponent/index.es.js +173 -160
- package/dist/fsLightboxComponent/index.umd.js +3 -3
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +160 -147
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +196 -183
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +25 -25
- package/dist/index.es.js +121 -108
- package/dist/index.umd.js +18 -18
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +157 -144
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +245 -232
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +106 -93
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +5 -5
- package/dist/listPagesComponent/index.es.js +157 -144
- package/dist/listPagesComponent/index.umd.js +5 -5
- package/dist/presetPrintable/index.cjs.js +3 -3
- package/dist/presetPrintable/index.es.js +181 -168
- package/dist/presetPrintable/index.umd.js +3 -3
- package/dist/prosemirror/index.cjs.js +7 -7
- package/dist/prosemirror/index.es.js +385 -372
- package/dist/prosemirror/index.umd.js +8 -8
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +200 -187
- package/dist/rendererReact/index.js +1 -1
- package/dist/rendererReact/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +118 -105
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +4 -4
- package/dist/shapeDividerComponent/index.es.js +129 -116
- package/dist/shapeDividerComponent/index.umd.js +4 -4
- package/dist/swiperComponent/index.cjs.js +9 -9
- package/dist/swiperComponent/index.es.js +203 -190
- package/dist/swiperComponent/index.umd.js +7 -7
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +257 -244
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +121 -108
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(V,kn){typeof exports=="object"&&typeof module<"u"?kn(exports,require("handlebars/dist/cjs/handlebars")):typeof define=="function"&&define.amd?define(["exports","handlebars/dist/cjs/handlebars"],kn):(V=typeof globalThis<"u"?globalThis:V||self,kn(V.StudioSdkPlugins={},V.Handlebars))})(this,function(V,kn){"use strict";const Tr="app.grapesjs.com",Mr="app-stage.grapesjs.com",Ar=[Tr,"app2.grapesjs.com",Mr,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],Mp="license:check:
|
|
1
|
+
(function(V,kn){typeof exports=="object"&&typeof module<"u"?kn(exports,require("handlebars/dist/cjs/handlebars")):typeof define=="function"&&define.amd?define(["exports","handlebars/dist/cjs/handlebars"],kn):(V=typeof globalThis<"u"?globalThis:V||self,kn(V.StudioSdkPlugins={},V.Handlebars))})(this,function(V,kn){"use strict";const Tr="app.grapesjs.com",Mr="app-stage.grapesjs.com",Ar=[Tr,"app2.grapesjs.com",Mr,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],Mp="license:check:end",Ap=()=>typeof window<"u",Ts=(n,e={})=>{const t=Lp(n)?{id:n,src:n}:n;return new Promise((o,s)=>{var u,h;const{loadedScripts:i}=e,{id:r,src:l}=t,a=document.querySelector(`script[src="${l}"]`);if(a){if((u=e.onScript)==null||u.call(e,a),i&&!i.get(l)){a.addEventListener("load",()=>o(r)),a.addEventListener("error",()=>s(r));return}return o(r)}const c=window.define;window.define=void 0;const d=()=>{i==null||i.set(l,!0),window.define=c},p=document.createElement("script");p.src=l,p.onload=()=>{o(r),d()},p.onerror=()=>{s(r),d()},document.head.appendChild(p),(h=e.onScript)==null||h.call(e,p)})},Pp=n=>{const e=n.map(t=>Ts(t));return Promise.allSettled(e)},Np=async n=>{const e=window.define;window.define=void 0;const t=await Pp(n);return window.define=e,t},Op=({isDev:n,isStage:e,isPlatform:t})=>`${n?"":`https://${e?Mr:Tr}`}/${t?"platform-api":"api"}`,Ip=()=>{const n=Ap()&&window.location.hostname;return!!n&&(Ar.includes(n)||Ar.some(e=>n.endsWith(e)))},Rp=n=>n.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,t)=>(t?"-":"")+e.toLowerCase()),Dp=n=>typeof n<"u",Lp=n=>typeof n=="string";function xt(n){return typeof n=="function"}async function $p({path:n,baseApiUrl:e,method:t="GET",headers:o={},params:s,body:i}){const l=`${e||Op({isDev:!1,isStage:!1})}${n}`,a={method:t,headers:{"Content-Type":"application/json",...o}};i&&(a.body=JSON.stringify(i));const c=s?new URLSearchParams(s).toString():"",d=c?`?${c}`:"",p=await fetch(`${l}${d}`,a);if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);return p.json()}var F=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(F||{}),Pr=(n=>(n.Info="info",n.Error="error",n.Success="success",n.Warning="warning",n))(Pr||{}),_=(n=>(n.toastAdd="studio:toastAdd",n.toastRemove="studio:toastRemove",n.dialogOpen="studio:dialogOpen",n.dialogClose="studio:dialogClose",n.dialogExportCode="studio:dialogExportCode",n.dialogImportCode="studio:dialogImportCode",n.sidebarLeftSet="studio:sidebarLeft:set",n.sidebarLeftGet="studio:sidebarLeft:get",n.sidebarLeftToggle="studio:sidebarLeft:toggle",n.sidebarRightSet="studio:sidebarRight:set",n.sidebarRightGet="studio:sidebarRight:get",n.sidebarRightToggle="studio:sidebarRight:toggle",n.sidebarTopSet="studio:sidebarTop:set",n.sidebarTopGet="studio:sidebarTop:get",n.sidebarTopToggle="studio:sidebarTop:toggle",n.sidebarBottomSet="studio:sidebarBottom:set",n.sidebarBottomGet="studio:sidebarBottom:get",n.sidebarBottomToggle="studio:sidebarBottom:toggle",n.symbolAdd="studio:symbolAdd",n.symbolDetach="studio:symbolDetach",n.symbolOverride="studio:symbolOverride",n.symbolPropagateStyles="studio:propagateStyles",n.getPagesConfig="studio:getPagesConfig",n.setPagesConfig="studio:setPagesConfig",n.getPageSettings="studio:getPageSettings",n.setPageSettings="studio:setPageSettings",n.clearPage="studio:clearPage",n.projectFiles="studio:projectFiles",n.validateCode="studio:validateCode",n.canvasReload="studio:canvasReload",n.getBlocksPanel="studio:getBlocksPanel",n.setBlocksPanel="studio:setBlocksPanel",n.getStateContextMenu="studio:getStateContextMenu",n.setStateContextMenu="studio:setStateContextMenu",n.contextMenuComponent="studio:contextMenuComponent",n.layoutAdd="studio:layoutAdd",n.layoutRemove="studio:layoutRemove",n.layoutToggle="studio:layoutToggle",n.layoutUpdate="studio:layoutUpdate",n.layoutGet="studio:layoutGet",n.layoutConfigGet="studio:layoutConfigGet",n.layoutConfigSet="studio:layoutConfigSet",n.layoutComponentAdd="studio:layoutComponentAdd",n.layoutComponentGet="studio:layoutComponentGet",n.layoutComponentRemove="studio:layoutComponentRemove",n.layoutComponentRender="studio:layoutComponentRender",n.getStateTheme="studio:getStateTheme",n.setStateTheme="studio:setStateTheme",n.settings="studio:settings",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))(_||{}),Nr=(n=>(n.layoutToggleId="studio:layoutToggle:",n.toggleBlocksPanel="studio:toggleBlocksPanel",n.pageSettingsUpdate="studio:pageSettingsUpdate",n.toggleDataSourcesPreview="studio:toggleDataSourcesPreview",n))(Nr||{}),Or=(n=>(n.dark="dark",n.light="light",n.auto="auto",n))(Or||{}),Ir=(n=>(n.web="web",n.email="email",n.document="document",n.react="react",n))(Ir||{});const Rr={[F.free]:0,[F.startup]:10,[F.business]:20,[F.enterprise]:30};function zp(n){const e=n;return e.init=t=>o=>n(o,t),e}const W=n=>zp(n);async function j({editor:n,plan:e,pluginName:t,licenseKey:o,onLicenseCheckResponse:s,cleanup:i}){let r="",l;const a=p=>{console.warn("Cleanup plugin:",t,"Reason:",p),i()},c=(p={})=>{var g;const{error:u,sdkLicense:h}=p,f=(g=p.plan)==null?void 0:g.category;if(!(h||p.license)||u)a(u||"Invalid license");else if(f){const b=Rr[e],C=Rr[f];b>C&&a({pluginRequiredPlan:e,licensePlan:f})}};n.Commands.has(_.settings)&&(l=n.runCommand(_.settings),r=(l==null?void 0:l.baseUrl)||"");const d=p=>{s==null||s(p),p&&c(p)};if(!l){n.onReady(async()=>{if(!Ip())if(o){const p=await Vp({licenseKey:o,pluginName:t,baseApiUrl:r});d(p)}else a("The `licenseKey` option not provided")});return}if(l.licensePlan||l.licenseError){const p=Bp(l);d(p);return}n.on(Mp,p=>d(p))}const Bp=n=>({sdkLicense:n.license,license:n.license,error:n.licenseError,plan:n.licensePlan});async function Vp(n){const{licenseKey:e,pluginName:t,baseApiUrl:o}=n;try{return(await $p({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 fo=(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))},$e=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,Pe))===n},mo=(...n)=>e=>n.some(t=>e.is(t)),Ms=(...n)=>(e,t)=>n.some(o=>t.is(o)),Hp=(n,e={})=>{var i;const t={},o=[],s=[];for(const r in n){const{value:l,...a}=n[r];o.push({id:r,name:r,changeProp:!0,category:e.category,...a}),t[r]=l,!Dp(l)&&s.push(r);const{subTraits:c={}}=a;for(const d in a.subTraits)(i=c[d])==null||i.forEach(p=>{const u=p.id||p.name;t[u]=p.value})}return{propKeys:Object.keys(t),propsNoValues:s,props:t,traits:o}},Fp=(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,()=>Dr(n,o)),Dr(n,o)}})},Dr=(n,e)=>{const t=n.getTrait(e),o=t.get("category"),s=t.get("subTraits")||{},r=(Object.values(s).flat()||[]).map(c=>c.id||c.name);n.removeTrait(r);const l=s[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:o,...c})),{at:a})},As=(n,e,t)=>{const{doc:o=document}=t,s=t.target||o.head,i=s.querySelector(`style[${n}]`)||o.createElement("style");i.setAttribute(n,"true"),i.innerHTML=e,!s.contains(i)&&s.appendChild(i)},_p=(n,e)=>{e.forEach(t=>{const o=Rp(t);o!==t&&n.has(o)&&n.set({[t]:n.get(o),[o]:void 0})})},ke="gjs-plg-",go="data-gs-plg-",Pe="data-type-role",Lr=(...n)=>n.map(e=>`[data-gjs-type="${e}"]`).join(","),Gp="dialogComponent",Wp=W(function(n,e={}){const{Blocks:t,Components:o}=n,{licenseKey:s}=e,i="gjs-plg-dialog",r="gjs-plg-dialog-overlay",l="gjs-plg-dialog-content",a="gjs-plg-dialog-close",c="gjs-plg-dialog-title",d="gjs-plg-dialog-body",p="gjs-plg-dialog-description",u="gjs-plg-dialog-placeholder";t.add(i,{label:"Dialog",media:`
|
|
2
2
|
<svg viewBox="0 0 24 24">
|
|
3
3
|
<path d="M4 4h16v10H8l-4 4V4z"></path>
|
|
4
4
|
</svg>
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
.${p} {
|
|
57
57
|
margin: 0;
|
|
58
58
|
}
|
|
59
|
-
`}}}),o.addType(u,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:u,"data-type-role":u},components:"Dialog (click me to open)",droppable:!1,draggable:!1}},view:{init(){const{em:f,el:m}=this,g="core:preview",b=f.Commands.events;this.listenTo(f,`${b.runCommand}${g}`,()=>{m.style.display="none"}),this.listenTo(f,`${b.stopCommand}${g}`,()=>{m.style.display=""})}}}),
|
|
59
|
+
`}}}),o.addType(u,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:u,"data-type-role":u},components:"Dialog (click me to open)",droppable:!1,draggable:!1}},view:{init(){const{em:f,el:m}=this,g="core:preview",b=f.Commands.events;this.listenTo(f,`${b.runCommand}${g}`,()=>{m.style.display="none"}),this.listenTo(f,`${b.stopCommand}${g}`,()=>{m.style.display=""})}}}),j({editor:n,licenseKey:s,plan:F.startup,pluginName:Gp,cleanup:()=>{t.remove(i),o.removeType(i)}})}),jp="iconifyComponent",qp=F.startup,Up={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},Ps=`<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>`,$r="layout-icon-picker",Kp="icons-layout-",zr="icons-list-layout",Br="gs-iconify-picker",Ns="__iconify_collection",Jp="https://api.iconify.design",Os=new Map;let yo;const Zp=({collectionId:n})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${n}@latest/icons.json`;async function Vr({collectionId:n,editor:e}){try{if(Os.has(n))return Os.get(n);const t=await fetch(Zp({collectionId:n}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const o=await t.json();return Os.set(n,o),o}catch(t){console.error("Error fetching collection",t),e.runCommand(j.toastAdd,nu());return}}async function Yp({collectionIds:n,editor:e}){try{if(yo)return yo;const t=n?`?prefixes=${n.join(",")}`:"",o=await fetch(`${Jp}/collections${t}`);if(!o.ok)throw new Error(`Failed to fetch collections: ${o.statusText}`);return yo=await o.json(),yo}catch(t){console.error("Error fetching collections",t),e.runCommand(j.toastAdd,_r());return}}function Hr(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(n){var e;(e=n.getSelected())==null||e.trigger("active")}}}async function Xp({collectionIds:n,editor:e,component:t}){const o=await Yp({collectionIds:n,editor:e});if(!o)return;const s=({icon:a,collectionId:c,iconId:d})=>{t.components(a),t.set({collectionId:c,iconId:d})},i=Object.entries(o).map(([a,c])=>({id:a,...c})).sort((a,c)=>a.name.localeCompare(c.name)),r=t.get("collectionId")??i[0].id;e.runCommand(j.layoutToggle,{id:$r,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[eu({collectionsList:i,collectionId:r,editor:e,handleClick:s}),{id:zr,type:"column",grow:!0}]}});const l=await Vr({collectionId:r,editor:e});l&&(Fr({editor:e,collection:l}),Is({editor:e,collection:l,handleClick:s,collectionId:r}))}function Fr({editor:n,collection:e}){n.em.set(Ns,e)}function Qp(n){return n.em.get(Ns)}function Is(n){const{editor:e}=n;e.runCommand(j.layoutUpdate,{id:Kp,layout:tu(n),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:zr}})}function eu(n){const{collectionsList:e,collectionId:t,editor:o,handleClick:s}=n,i=e.map(({id:r,name:l,total:a})=>({id:r,label:`${l} (${a})`})).sort((r,l)=>r.label.localeCompare(l.label));return{type:"column",style:{gap:10},className:`${Br}__header`,children:[{type:"selectField",value:t,options:i,emptyState:"Select an icon collection",onChange:async({setState:r,value:l})=>{const a=await Vr({collectionId:l,editor:o});a&&(r({value:l}),Fr({editor:o,collection:a}),Is({editor:o,collection:a,handleClick:s,collectionId:l}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${Ns}`]:({setState:r})=>r({value:""})},onInput:({setState:r,value:l,editor:a})=>{const c=Qp(a);if(!c)return;const d=Object.fromEntries(Object.entries(c.icons).filter(([p])=>p.includes(l)));r({value:l}),Is({editor:a,collection:c,handleClick:s,collectionId:t,collectionFiltered:{...c,icons:d}})}}]}}function tu({collection:n,collectionFiltered:e,handleClick:t}){const{height:o=24,width:s=24,icons:i,prefix:r}=e||n,l=Object.entries(i).map(([a,c])=>({name:a,...c}),{});return{type:"column",className:`${Br}__content`,style:{height:"100%"},children:{type:"virtualList",items:l,itemLayout:({item:a})=>({type:"custom",render:c=>{const{editor:d,addEl:p,removeEl:u}=c,h=document.createElementNS("http://www.w3.org/2000/svg","svg");h.setAttribute("xmlns","http://www.w3.org/2000/svg"),h.innerHTML=a.body;const f=a.width||s,m=a.height||o;h.setAttribute("viewBox",`0 0 ${f} ${m}`),h.style.cssText="width: 48px; height: 48px; cursor: pointer; border-radius: 4px; transition: padding 0.1s ease-in-out;";const g=[["click",()=>{const b=h.cloneNode(!0);b.removeAttribute("style");const C=b.outerHTML;t({icon:C,collectionId:r,iconId:a.name}),d==null||d.runCommand(j.layoutRemove,{id:$r})}],["pointerover",()=>{h.style.border="2px solid currentColor",h.style.padding="4px"}],["pointerout",()=>{h.style.border="",h.style.padding=""}]];return g.forEach(([b,C])=>h.addEventListener(b,C)),p(h),()=>{g.forEach(([b,C])=>h.removeEventListener(b,C)),u(h)}}})}}}function _r(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:Pr.Error}}function nu(){return{..._r(),id:"toast-error-getCollection",content:"Error fetching collection"}}const ou=G(function(n,e={}){var h;const{Components:t,Blocks:o}=n,{collections:s,extendIconComponent:i=!0,licenseKey:r,block:l={}}=e,a="icon",c="iconify",d="Iconify",p="data-type-iconify",u={events:()=>({dblclick:"onActive"}),onActive(){Xp({collectionIds:s,editor:n,component:this.model})}};if(t.addType(c,{block:l&&{label:d,media:Ps,content:{type:c},category:"Extra",activate:!0,...l},isComponent:f=>fo(f,p),model:{defaults:{name:d,icon:Ps,droppable:!1,attributes:{[p]:!0},resizable:Up,components:Ps,style:{width:"50px",height:"50px"},traits:[Hr()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(f=>f.set({layerable:!1,locked:!0}))}},view:u}),i){const f=(h=t.getType(a))==null?void 0:h.model,[m,g,...b]=f.getDefaults().traits;t.addType(a,{model:{defaults:{traits:[m,g,Hr(),...b]}},view:u})}W({editor:n,licenseKey:r,plan:qp,pluginName:jp,cleanup:()=>{o.remove(c),t.removeType(c)}})});function En(n,e,t){let o,s,i,r,l;const a=e===void 0?100:e;function c(){const p=Date.now()-r;p<a&&p>=0?o=setTimeout(c,a-p):(o=null,l=n.apply(i,s),i=s=null)}const d=function(){return i=this,s=arguments,r=Date.now(),o||(o=setTimeout(c,a)),l};return d.clear=function(){o&&(clearTimeout(o),o=null)},d.flush=function(){o&&(l=n.apply(i,s),i=s=null,clearTimeout(o),o=null)},d}const su="tableComponent",iu=F.startup;var O=(n=>(n.table="table",n.tableSettings="tableSettings",n.tableDelete="tableDelete",n.tableHead="tableHead",n.tableFoot="tableFoot",n.tableCellItems="tableCellItems",n.tableCellProperties="tableCellProperties",n.tableCellMerge="tableCellMerge",n.tableCellSplit="tableCellSplit",n.tableRowItems="tableRowItems",n.tableRowInsertBefore="tableRowInsertBefore",n.tableRowInsertAfter="tableRowInsertAfter",n.tableRowDelete="tableRowDelete",n.tableRowProperties="tableRowProperties",n.tableRowCut="tableRowCut",n.tableRowCopy="tableRowCopy",n.tableRowPasteBefore="tableRowPasteBefore",n.tableRowPasteAfter="tableRowPasteAfter",n.tableColumn="tableColumn",n.tableColumnItems="tableColumnItems",n.tableColumnInsertBefore="tableColumnInsertBefore",n.tableColumnInsertAfter="tableColumnInsertAfter",n.tableColumnDelete="tableColumnDelete",n.tableColumnCut="tableColumnCut",n.tableColumnCopy="tableColumnCopy",n.tableColumnPasteBefore="tableColumnPasteBefore",n.tableColumnPasteAfter="tableColumnPasteAfter",n))(O||{});const z={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>'},ze="table",Gr="thead",Wr="tfoot",Rs="tbody",fe="row",q="cell",Ds="clipboardTable",ru=[ze,Gr,Wr,Rs,fe,q],bo=n=>n.em.get(Ds)||[],lu=n=>n.every(e=>e.is(q)),Ls=(n,e)=>{const{editor:t,event:o,opts:s}=n,i=o.currentTarget||o.target,{x:r,y:l,width:a,height:c}=i.getBoundingClientRect(),d={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:r,y:l,w:a,h:c},layout:{type:"tabs",value:"props",tabs:[{id:"styles",label:"Styles",children:{type:"panelStyles"}},{id:"props",label:"Properties",children:{type:"panelProperties",style:{padding:"14px 7px"}}}]},...e};xt(s.openSettings)?s.openSettings({...n,layoutProps:d}):t.runCommand(j.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(i=>({type:q,components:o?{type:"text",content:xt(o)?o({y:s,x:i}):o}:void 0}))}))}),jr="Table settings",qr=n=>{const{component:e}=n;return e.is(ze)?e:e.closestType(ze)},cu=n=>{var e;(e=qr(n))==null||e.remove(n.opts)},du=n=>{const e=qr(n);e&&(n.editor.select(e),Ls(n,{id:"tableSettings",header:{label:jr}}))},Ur=n=>[{id:O.table,icon:z[O.table],label:"Table",items:[{id:O.tableSettings,label:jr,icon:z[O.tableSettings],onClick:({event:t})=>du({...n,event:t})},{id:O.tableDelete,label:"Delete table",icon:z[O.tableDelete],onClick:()=>cu(n)}]}],Kr=({editor:n})=>{const e=bo(n);return e.length&&lu(e)},Jr=({component:n,editor:e,after:t})=>{if(!n.is(q))return;const o=n.closestType(ze),s=n.closestType(fe),i=n.index()+(t?1:0);o==null||o.findType(fe).forEach(l=>l.append({type:q},{at:i}));const r=s==null?void 0:s.components().at(i);r&&e.select(r)},Zr=({component:n,opts:e})=>{if(!n.is(q))return;const t=n.closestType(ze),o=n.index();t==null||t.findType(fe).forEach(s=>{var i;return(i=s.components().at(o))==null?void 0:i.remove(e)})},Yr=({component:n,editor:e})=>{if(!n.is(q))return;const t=n.closestType(ze),o=n.index(),s=(t==null?void 0:t.findType(fe).map(i=>i.components().at(o)))||[];s.length&&e.em.set(Ds,s)},Xr=n=>{const{component:e,editor:t,after:o}=n;if(!e.is(q)||!Kr(n))return;const s=bo(t),i=e.closestType(ze),r=e.index()+(o?1:0);i==null||i.findType(fe).forEach((l,a)=>{const c=s[a],d=(c==null?void 0:c.clone())||{type:q};l.append(d,{at:r})})},pu=n=>{const{component:e}=n;e.is(q)&&(Yr(n),Zr({...n,opts:{temporary:!0}}))},uu=n=>{const e=Kr(n);return[{id:O.tableColumnItems,icon:z[O.tableColumn],label:"Column",items:[{id:O.tableColumnInsertBefore,label:"Insert column before",icon:z[O.tableColumnInsertBefore],onClick:()=>Jr(n)},{id:O.tableColumnInsertAfter,label:"Insert column after",icon:z[O.tableColumnInsertAfter],onClick:()=>Jr({...n,after:!0})},{id:O.tableColumnDelete,label:"Delete column",icon:z[O.tableColumnDelete],onClick:()=>Zr(n)},{id:O.tableColumnCut,label:"Cut column",icon:z[O.tableColumnCut],onClick:()=>pu(n)},{id:O.tableColumnCopy,label:"Copy column",icon:z[O.tableColumnCopy],onClick:()=>Yr(n)},{id:O.tableColumnPasteBefore,label:"Paste column before",icon:z[O.tableColumnPasteBefore],disabled:!e,onClick:()=>Xr(n)},{id:O.tableColumnPasteAfter,label:"Paste column after",icon:z[O.tableColumnPasteAfter],disabled:!e,onClick:()=>Xr({...n,after:!0})}]}]},Qr="Row settings",hu=n=>n.every(e=>e.is(fe)),qt=n=>{const{component:e}=n,t=e.is(q),o=e.is(fe);if(!(!t&&!o))return o?e:e.closestType(fe)},el=n=>{const{component:e,editor:t,after:o}=n,s=qt(n);if(!s)return;const i=s.index()+(o?1:0),r=s.components().length,l=Array.from(Array(r).keys()).map(()=>({type:q})),a=s.parent();if(a){const c=a.append({type:fe,components:l},{at:i})[0];if(e.is(q)&&c){const d=e.index(),p=c.components().at(d);p&&t.select(p)}}},tl=n=>{var e;(e=qt(n))==null||e.remove(n.opts)},nl=n=>{const e=qt(n);e&&n.editor.em.set(Ds,[e])},ol=n=>{var l;const{editor:e,after:t}=n,o=qt(n);if(!o||!sl(n))return;const i=bo(e)[0],r=o.index()+(t?1:0);i&&((l=o.parent())==null||l.append(i.clone(),{at:r}))},fu=n=>{qt(n)&&(nl(n),tl({...n,opts:{temporary:!0}}))},sl=({editor:n})=>{const e=bo(n);return e.length&&hu(e)},mu=n=>{const e=qt(n);e&&(n.editor.select(e),Ls(n,{id:"tableRowSettings",header:{label:Qr}}))},il=n=>{const e=sl(n);return[{id:O.tableRowItems,icon:z[O.tableRowProperties],label:"Row",items:[{id:O.tableRowInsertBefore,label:"Insert row before",icon:z[O.tableRowInsertBefore],onClick:()=>el(n)},{id:O.tableRowInsertAfter,label:"Insert row after",icon:z[O.tableRowInsertAfter],onClick:()=>el({...n,after:!0})},{id:O.tableRowDelete,label:"Delete row",icon:z[O.tableRowDelete],onClick:()=>tl(n)},{id:O.tableRowProperties,label:Qr,icon:z[O.tableRowProperties],onClick:({event:o})=>mu({...n,event:o})},{id:O.tableRowCut,label:"Cut row",icon:z[O.tableRowCut],onClick:()=>fu(n)},{id:O.tableRowCopy,label:"Copy row",icon:z[O.tableRowCopy],onClick:()=>nl(n)},{id:O.tableRowPasteBefore,label:"Paste row before",icon:z[O.tableRowPasteBefore],disabled:!e,onClick:()=>ol(n)},{id:O.tableRowPasteAfter,label:"Paste row after",icon:z[O.tableRowPasteAfter],disabled:!e,onClick:()=>ol({...n,after:!0})}]},...Ur(n)]},$s=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),o=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:o}};function rl(n){const e=[];return n.components().forEach((t,o)=>{t.components().each((s,i)=>{const{rowspan:r,colspan:l}=$s(s);if(e[o])for(;e[o][i];)i++;for(let a=o;a<o+r;a++){e[a]||(e[a]=[]);for(let c=i;c<i+l;c++)e[a][c]={real:a===o&&c===i,cell:s,rowspan:r,colspan:l}}})}),e}function Ut(n,e,t){var o;return(o=n[t])==null?void 0:o[e]}const zs=n=>n.closestType(fe);function gu(n,{x:e,y:t,rows:o,cols:s}){var l;let i=zs(n[t][e].cell),r;for(let a=1;a<=o;a++)if(i=(l=i==null?void 0:i.parent())==null?void 0:l.components().at(i.index()+1),i){for(r=e;r>=0;r--){const{cell:c}=n[t+a][r],d=zs(c);if(d===i){for(let p=1;p<=s;p++){const u=c.index();d.append({type:q},{at:u+1})}break}}if(r===-1){const d=i.components().at(0).index();for(let p=1;p<=s;p++)i.append({type:q},{at:d})}}}function ll(n){for(let e=0;e<n.length;e++)for(let t=0;t<n[e].length;t++){const s=n[e][t].cell;if(s.em.selected.hasComponent(s)){const{rowspan:i,colspan:r}=$s(s);if(r>1||i>1){s.addAttributes({colspan:1,rowspan:1});for(let l=0;l<r-1;l++){const a=s.index();zs(s).append({type:q},{at:a+1})}gu(n,{x:t,y:e,rows:i-1,cols:r})}}}}function yu(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const vo=(n,e={})=>{var r;const t=rl(n),{em:o}=n;let s,i;for(let l=0;l<t.length;l++)for(let a=0;a<t[l].length;a++){const c=t[l][a];if((r=e.selected)!=null&&r.includes(c.cell)||o.selected.hasComponent(c.cell)){const d={x:a,y:l};s||(s=d),i=d}}return{grid:t,startPos:s,endPos:i}};function bu(n,e={}){const t=vo(n),{startPos:o,endPos:s}=t;let{grid:i}=t;const{em:r}=n;if(!o||!s)return;const l=o.x,a=o.y,c=s.x,d=s.y,p=Ut(i,l,a),u=Ut(i,c,d);if(p&&u){ll(i),i=rl(n);const h=[],f=Ut(i,l,a).cell;f.addAttributes({colspan:c-l+1,rowspan:d-a+1});for(let m=a;m<=d;m++)for(let g=l;g<=c;g++){const b=Ut(i,g,m);if(!b)continue;const{cell:C}=b;C!==f&&h.push(C)}h.forEach(m=>{e.mergeContent&&f.append(m.components().models),m.remove()}),r.setSelected(f),yu(n)}}const al="Cell settings",vu="Merge cells",Su="Split cell",xu=n=>n.closestType(fe),Kt=n=>{var e;return(e=xu(n))==null?void 0:e.parent()},wu=n=>{const e=n.editor.getSelectedAll(),t=Kt(e[0]),o=e[0];if(!t||!(o!=null&&o.is(q))||e.length>1)return!1;const{rowspan:s,colspan:i}=$s(o);return!(i<2&&s<2)},Cu=n=>{const t=n.editor.getSelectedAll()[0],o=Kt(t),{grid:s}=vo(o);ll(s)},cl=n=>{const e=n.editor.getSelectedAll(),t=Kt(e[0]);if(!t||e.length<2||e.some(l=>!l.is(q)||Kt(l)!==t))return!1;const{grid:o,startPos:s,endPos:i}=vo(t),{em:r}=t;if(!s||!i)return!1;for(let l=s.y;l<=i.y;l++)for(let a=s.x;a<=i.x;a++){const c=Ut(o,a,l);if(!c||!r.selected.hasComponent(c.cell))return!1}return!0},ku=n=>{const{editor:e}=n;if(!cl(n))return;const t=e.getSelectedAll(),o=Kt(t[0]);bu(o,{mergeContent:!0})},Eu=n=>{Ls(n,{id:"tableCellSettings",header:{label:al}})},Tu=n=>[{id:O.tableCellItems,icon:z[O.tableCellProperties],label:"Cell",items:[{id:O.tableCellProperties,label:al,icon:z[O.tableCellProperties],onClick:({event:t})=>Eu({...n,event:t})},{id:O.tableCellMerge,label:vu,icon:z[O.tableCellMerge],onClick:()=>ku(n),disabled:!cl(n)},{id:O.tableCellSplit,label:Su,icon:z[O.tableCellSplit],onClick:()=>Cu(n),disabled:!wu(n)}]},...uu(n),...il(n)],Mu=n=>{const e=n[0]&&Kt(n[0]);if(!e)return;const{grid:t,startPos:o,endPos:s}=vo(e,{selected:n});if(!o||!s)return;const i=[];for(let r=o.y;r<=s.y;r++)for(let l=o.x;l<=s.x;l++){const a=Ut(t,l,r);a&&i.push(a.cell)}i.length&&e.em.setSelected(i,{fromCell:!0})},Au=G(function(n,e={}){const t={block:{},...e},{Components:o}=n,s={copyable:!1,emptyState:!0,highlightable:!1,stylable:["color","font-family","font-size","font-weight","line-height","text-align","vertical-align","background-color","border-width","border-style","border-color"]};o.addType(ze,{block:t.block&&{label:"Table",media:z.table,category:"Extra",content:{type:ze,style:{width:"100%"}},select:!0,...t.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:z.table,stylable:["width","height","margin","font-family","font-size","font-weight","line-height","text-align","background","background-color","border-width","border-style","border-color"],traits:[{type:"number",min:0,name:"cellspacing",label:"Cell spacing"},{type:"number",min:0,name:"cellpadding",label:"Cell padding"},{id:"tableCaption",type:"checkbox",label:"Caption",setValue({component:r,value:l,emitUpdate:a}){const c=r.find("caption")[0];l?!c&&r.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):c==null||c.remove(),a(),n.refresh({tools:!0})},getValue(r){return!!r.component.find("caption")[0]}}],components:au(Rs,{rows:5}),contextMenu:({items:r,editor:l,component:a})=>[...Ur({editor:l,component:a,opts:t}),...r]}}}),o.addType(Gr,{model:{defaults:{icon:z.tableHead,...s}}}),o.addType(Wr,{model:{defaults:{icon:z.tableFoot,...s}}}),o.addType(Rs,{model:{defaults:{icon:z.tableRowProperties,...s}}}),o.addType(fe,{model:{defaults:{icon:z.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:r,editor:l,component:a})=>[...il({editor:l,component:a,opts:t}),...r]}}}),o.addType(q,{model:{defaults:{icon:z.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","background","background-color","text-align","vertical-align","border-width","border-style","border-color"],traits:[{id:"tableCellType",type:"select",options:[{value:"td",name:"Cell"},{value:"th",name:"Header Cell"}],label:"Cell type",name:"tagName",changeProp:!0},{id:"tableCellScope",type:"select",options:[{value:!1,name:"None"},{value:"row",name:"Row"},{value:"col",name:"Column"},{value:"rowgroup",name:"Row group"},{value:"colgroup",name:"Column group"}],label:"Scope",name:"scope"}],contextMenu:({items:r,editor:l,component:a})=>[...Tu({editor:l,component:a,opts:t}),...r]}}});const i=En((r,l)=>{var p;const a=n.getSelectedAll(),c=!!((p=l==null?void 0:l.event)!=null&&p.shiftKey);if(a.length<2||!c||l.fromCell)return;const d=a.map(u=>u.is(q)?u:u.closestType(q)).filter(Boolean);d.length===a.length&&Mu(d)},0);n.on("component:select",i),W({editor:n,plan:iu,pluginName:su,licenseKey:t.licenseKey,cleanup:()=>{n.off("component:select",i),n.Blocks.remove(ze),ru.forEach(r=>o.removeType(r))}})}),Pu="listPagesComponent",Nu=F.startup,dl="page://",wt="list-pages",Jt="list-pages-item",Ct="list-pages-link",Ou=n=>n.components().reduce((e,t)=>{var r;const o=t.findFirstType(Ct),s=(r=o==null?void 0:o.attributes.attributes)==null?void 0:r.href,i=s!=null&&s.startsWith(dl)?s.replace(dl,""):"";if(i&&o){const l=e[i];l?l.push(o):e[i]=[o]}return e},{}),So="data-type-role",Iu="page_root",Ru=n=>e=>e.is(n),Du=n=>(e,t)=>t.is(n),Bs=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,So))===n},Lu=G(function(n,e={}){const{Blocks:t,Components:o,Pages:s}=n,{licenseKey:i,block:r={}}=e,l="List Pages",a="List Pages Item",c="Link",d=`${ke}${wt}`,p=`${ke}${Ct}`,u='<svg viewBox="0 0 24 24"><path d="M11 15H17V17H11V15M9 7H7V9H9V7M11 13H17V11H11V13M11 9H17V7H11V9M9 11H7V13H9V11M21 5V19C21 20.1 20.1 21 19 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H19C20.1 3 21 3.9 21 5M19 5H5V19H19V5M9 15H7V17H9V15Z"/></svg>',h='<svg viewBox="0 0 24 24"><path d="M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z" /></svg>';o.addType(wt,{block:r&&{label:l,media:u,category:"Extra",select:!0,...e.block},isComponent:Bs(wt),model:{defaults:{tagName:"ul",name:l,[Iu]:"",classes:d,attributes:{[So]:wt,role:"navigation"},droppable:Ru(Jt),styles:`
|
|
61
|
+
</svg>`,$r="layout-icon-picker",Kp="icons-layout-",zr="icons-list-layout",Br="gs-iconify-picker",Ns="__iconify_collection",Jp="https://api.iconify.design",Os=new Map;let yo;const Zp=({collectionId:n})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${n}@latest/icons.json`;async function Vr({collectionId:n,editor:e}){try{if(Os.has(n))return Os.get(n);const t=await fetch(Zp({collectionId:n}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const o=await t.json();return Os.set(n,o),o}catch(t){console.error("Error fetching collection",t),e.runCommand(_.toastAdd,nu());return}}async function Yp({collectionIds:n,editor:e}){try{if(yo)return yo;const t=n?`?prefixes=${n.join(",")}`:"",o=await fetch(`${Jp}/collections${t}`);if(!o.ok)throw new Error(`Failed to fetch collections: ${o.statusText}`);return yo=await o.json(),yo}catch(t){console.error("Error fetching collections",t),e.runCommand(_.toastAdd,_r());return}}function Hr(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(n){var e;(e=n.getSelected())==null||e.trigger("active")}}}async function Xp({collectionIds:n,editor:e,component:t}){const o=await Yp({collectionIds:n,editor:e});if(!o)return;const s=({icon:a,collectionId:c,iconId:d})=>{t.components(a),t.set({collectionId:c,iconId:d})},i=Object.entries(o).map(([a,c])=>({id:a,...c})).sort((a,c)=>a.name.localeCompare(c.name)),r=t.get("collectionId")??i[0].id;e.runCommand(_.layoutToggle,{id:$r,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[eu({collectionsList:i,collectionId:r,editor:e,handleClick:s}),{id:zr,type:"column",grow:!0}]}});const l=await Vr({collectionId:r,editor:e});l&&(Fr({editor:e,collection:l}),Is({editor:e,collection:l,handleClick:s,collectionId:r}))}function Fr({editor:n,collection:e}){n.em.set(Ns,e)}function Qp(n){return n.em.get(Ns)}function Is(n){const{editor:e}=n;e.runCommand(_.layoutUpdate,{id:Kp,layout:tu(n),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:zr}})}function eu(n){const{collectionsList:e,collectionId:t,editor:o,handleClick:s}=n,i=e.map(({id:r,name:l,total:a})=>({id:r,label:`${l} (${a})`})).sort((r,l)=>r.label.localeCompare(l.label));return{type:"column",style:{gap:10},className:`${Br}__header`,children:[{type:"selectField",value:t,options:i,emptyState:"Select an icon collection",onChange:async({setState:r,value:l})=>{const a=await Vr({collectionId:l,editor:o});a&&(r({value:l}),Fr({editor:o,collection:a}),Is({editor:o,collection:a,handleClick:s,collectionId:l}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${Ns}`]:({setState:r})=>r({value:""})},onInput:({setState:r,value:l,editor:a})=>{const c=Qp(a);if(!c)return;const d=Object.fromEntries(Object.entries(c.icons).filter(([p])=>p.includes(l)));r({value:l}),Is({editor:a,collection:c,handleClick:s,collectionId:t,collectionFiltered:{...c,icons:d}})}}]}}function tu({collection:n,collectionFiltered:e,handleClick:t}){const{height:o=24,width:s=24,icons:i,prefix:r}=e||n,l=Object.entries(i).map(([a,c])=>({name:a,...c}),{});return{type:"column",className:`${Br}__content`,style:{height:"100%"},children:{type:"virtualList",items:l,itemLayout:({item:a})=>({type:"custom",render:c=>{const{editor:d,addEl:p,removeEl:u}=c,h=document.createElementNS("http://www.w3.org/2000/svg","svg");h.setAttribute("xmlns","http://www.w3.org/2000/svg"),h.innerHTML=a.body;const f=a.width||s,m=a.height||o;h.setAttribute("viewBox",`0 0 ${f} ${m}`),h.style.cssText="width: 48px; height: 48px; cursor: pointer; border-radius: 4px; transition: padding 0.1s ease-in-out;";const g=[["click",()=>{const b=h.cloneNode(!0);b.removeAttribute("style");const C=b.outerHTML;t({icon:C,collectionId:r,iconId:a.name}),d==null||d.runCommand(_.layoutRemove,{id:$r})}],["pointerover",()=>{h.style.border="2px solid currentColor",h.style.padding="4px"}],["pointerout",()=>{h.style.border="",h.style.padding=""}]];return g.forEach(([b,C])=>h.addEventListener(b,C)),p(h),()=>{g.forEach(([b,C])=>h.removeEventListener(b,C)),u(h)}}})}}}function _r(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:Pr.Error}}function nu(){return{..._r(),id:"toast-error-getCollection",content:"Error fetching collection"}}const ou=W(function(n,e={}){var h;const{Components:t,Blocks:o}=n,{collections:s,extendIconComponent:i=!0,licenseKey:r,block:l={}}=e,a="icon",c="iconify",d="Iconify",p="data-type-iconify",u={events:()=>({dblclick:"onActive"}),onActive(){Xp({collectionIds:s,editor:n,component:this.model})}};if(t.addType(c,{block:l&&{label:d,media:Ps,content:{type:c},category:"Extra",activate:!0,...l},isComponent:f=>fo(f,p),model:{defaults:{name:d,icon:Ps,droppable:!1,attributes:{[p]:!0},resizable:Up,components:Ps,style:{width:"50px",height:"50px"},traits:[Hr()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(f=>f.set({layerable:!1,locked:!0}))}},view:u}),i){const f=(h=t.getType(a))==null?void 0:h.model,[m,g,...b]=f.getDefaults().traits;t.addType(a,{model:{defaults:{traits:[m,g,Hr(),...b]}},view:u})}j({editor:n,licenseKey:r,plan:qp,pluginName:jp,cleanup:()=>{o.remove(c),t.removeType(c)}})});function En(n,e,t){let o,s,i,r,l;const a=e===void 0?100:e;function c(){const p=Date.now()-r;p<a&&p>=0?o=setTimeout(c,a-p):(o=null,l=n.apply(i,s),i=s=null)}const d=function(){return i=this,s=arguments,r=Date.now(),o||(o=setTimeout(c,a)),l};return d.clear=function(){o&&(clearTimeout(o),o=null)},d.flush=function(){o&&(l=n.apply(i,s),i=s=null,clearTimeout(o),o=null)},d}const su="tableComponent",iu=F.startup;var O=(n=>(n.table="table",n.tableSettings="tableSettings",n.tableDelete="tableDelete",n.tableHead="tableHead",n.tableFoot="tableFoot",n.tableCellItems="tableCellItems",n.tableCellProperties="tableCellProperties",n.tableCellMerge="tableCellMerge",n.tableCellSplit="tableCellSplit",n.tableRowItems="tableRowItems",n.tableRowInsertBefore="tableRowInsertBefore",n.tableRowInsertAfter="tableRowInsertAfter",n.tableRowDelete="tableRowDelete",n.tableRowProperties="tableRowProperties",n.tableRowCut="tableRowCut",n.tableRowCopy="tableRowCopy",n.tableRowPasteBefore="tableRowPasteBefore",n.tableRowPasteAfter="tableRowPasteAfter",n.tableColumn="tableColumn",n.tableColumnItems="tableColumnItems",n.tableColumnInsertBefore="tableColumnInsertBefore",n.tableColumnInsertAfter="tableColumnInsertAfter",n.tableColumnDelete="tableColumnDelete",n.tableColumnCut="tableColumnCut",n.tableColumnCopy="tableColumnCopy",n.tableColumnPasteBefore="tableColumnPasteBefore",n.tableColumnPasteAfter="tableColumnPasteAfter",n))(O||{});const z={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>'},ze="table",Gr="thead",Wr="tfoot",Rs="tbody",fe="row",q="cell",Ds="clipboardTable",ru=[ze,Gr,Wr,Rs,fe,q],bo=n=>n.em.get(Ds)||[],lu=n=>n.every(e=>e.is(q)),Ls=(n,e)=>{const{editor:t,event:o,opts:s}=n,i=o.currentTarget||o.target,{x:r,y:l,width:a,height:c}=i.getBoundingClientRect(),d={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:r,y:l,w:a,h:c},layout:{type:"tabs",value:"props",tabs:[{id:"styles",label:"Styles",children:{type:"panelStyles"}},{id:"props",label:"Properties",children:{type:"panelProperties",style:{padding:"14px 7px"}}}]},...e};xt(s.openSettings)?s.openSettings({...n,layoutProps:d}):t.runCommand(_.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(i=>({type:q,components:o?{type:"text",content:xt(o)?o({y:s,x:i}):o}:void 0}))}))}),jr="Table settings",qr=n=>{const{component:e}=n;return e.is(ze)?e:e.closestType(ze)},cu=n=>{var e;(e=qr(n))==null||e.remove(n.opts)},du=n=>{const e=qr(n);e&&(n.editor.select(e),Ls(n,{id:"tableSettings",header:{label:jr}}))},Ur=n=>[{id:O.table,icon:z[O.table],label:"Table",items:[{id:O.tableSettings,label:jr,icon:z[O.tableSettings],onClick:({event:t})=>du({...n,event:t})},{id:O.tableDelete,label:"Delete table",icon:z[O.tableDelete],onClick:()=>cu(n)}]}],Kr=({editor:n})=>{const e=bo(n);return e.length&&lu(e)},Jr=({component:n,editor:e,after:t})=>{if(!n.is(q))return;const o=n.closestType(ze),s=n.closestType(fe),i=n.index()+(t?1:0);o==null||o.findType(fe).forEach(l=>l.append({type:q},{at:i}));const r=s==null?void 0:s.components().at(i);r&&e.select(r)},Zr=({component:n,opts:e})=>{if(!n.is(q))return;const t=n.closestType(ze),o=n.index();t==null||t.findType(fe).forEach(s=>{var i;return(i=s.components().at(o))==null?void 0:i.remove(e)})},Yr=({component:n,editor:e})=>{if(!n.is(q))return;const t=n.closestType(ze),o=n.index(),s=(t==null?void 0:t.findType(fe).map(i=>i.components().at(o)))||[];s.length&&e.em.set(Ds,s)},Xr=n=>{const{component:e,editor:t,after:o}=n;if(!e.is(q)||!Kr(n))return;const s=bo(t),i=e.closestType(ze),r=e.index()+(o?1:0);i==null||i.findType(fe).forEach((l,a)=>{const c=s[a],d=(c==null?void 0:c.clone())||{type:q};l.append(d,{at:r})})},pu=n=>{const{component:e}=n;e.is(q)&&(Yr(n),Zr({...n,opts:{temporary:!0}}))},uu=n=>{const e=Kr(n);return[{id:O.tableColumnItems,icon:z[O.tableColumn],label:"Column",items:[{id:O.tableColumnInsertBefore,label:"Insert column before",icon:z[O.tableColumnInsertBefore],onClick:()=>Jr(n)},{id:O.tableColumnInsertAfter,label:"Insert column after",icon:z[O.tableColumnInsertAfter],onClick:()=>Jr({...n,after:!0})},{id:O.tableColumnDelete,label:"Delete column",icon:z[O.tableColumnDelete],onClick:()=>Zr(n)},{id:O.tableColumnCut,label:"Cut column",icon:z[O.tableColumnCut],onClick:()=>pu(n)},{id:O.tableColumnCopy,label:"Copy column",icon:z[O.tableColumnCopy],onClick:()=>Yr(n)},{id:O.tableColumnPasteBefore,label:"Paste column before",icon:z[O.tableColumnPasteBefore],disabled:!e,onClick:()=>Xr(n)},{id:O.tableColumnPasteAfter,label:"Paste column after",icon:z[O.tableColumnPasteAfter],disabled:!e,onClick:()=>Xr({...n,after:!0})}]}]},Qr="Row settings",hu=n=>n.every(e=>e.is(fe)),qt=n=>{const{component:e}=n,t=e.is(q),o=e.is(fe);if(!(!t&&!o))return o?e:e.closestType(fe)},el=n=>{const{component:e,editor:t,after:o}=n,s=qt(n);if(!s)return;const i=s.index()+(o?1:0),r=s.components().length,l=Array.from(Array(r).keys()).map(()=>({type:q})),a=s.parent();if(a){const c=a.append({type:fe,components:l},{at:i})[0];if(e.is(q)&&c){const d=e.index(),p=c.components().at(d);p&&t.select(p)}}},tl=n=>{var e;(e=qt(n))==null||e.remove(n.opts)},nl=n=>{const e=qt(n);e&&n.editor.em.set(Ds,[e])},ol=n=>{var l;const{editor:e,after:t}=n,o=qt(n);if(!o||!sl(n))return;const i=bo(e)[0],r=o.index()+(t?1:0);i&&((l=o.parent())==null||l.append(i.clone(),{at:r}))},fu=n=>{qt(n)&&(nl(n),tl({...n,opts:{temporary:!0}}))},sl=({editor:n})=>{const e=bo(n);return e.length&&hu(e)},mu=n=>{const e=qt(n);e&&(n.editor.select(e),Ls(n,{id:"tableRowSettings",header:{label:Qr}}))},il=n=>{const e=sl(n);return[{id:O.tableRowItems,icon:z[O.tableRowProperties],label:"Row",items:[{id:O.tableRowInsertBefore,label:"Insert row before",icon:z[O.tableRowInsertBefore],onClick:()=>el(n)},{id:O.tableRowInsertAfter,label:"Insert row after",icon:z[O.tableRowInsertAfter],onClick:()=>el({...n,after:!0})},{id:O.tableRowDelete,label:"Delete row",icon:z[O.tableRowDelete],onClick:()=>tl(n)},{id:O.tableRowProperties,label:Qr,icon:z[O.tableRowProperties],onClick:({event:o})=>mu({...n,event:o})},{id:O.tableRowCut,label:"Cut row",icon:z[O.tableRowCut],onClick:()=>fu(n)},{id:O.tableRowCopy,label:"Copy row",icon:z[O.tableRowCopy],onClick:()=>nl(n)},{id:O.tableRowPasteBefore,label:"Paste row before",icon:z[O.tableRowPasteBefore],disabled:!e,onClick:()=>ol(n)},{id:O.tableRowPasteAfter,label:"Paste row after",icon:z[O.tableRowPasteAfter],disabled:!e,onClick:()=>ol({...n,after:!0})}]},...Ur(n)]},$s=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),o=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:o}};function rl(n){const e=[];return n.components().forEach((t,o)=>{t.components().each((s,i)=>{const{rowspan:r,colspan:l}=$s(s);if(e[o])for(;e[o][i];)i++;for(let a=o;a<o+r;a++){e[a]||(e[a]=[]);for(let c=i;c<i+l;c++)e[a][c]={real:a===o&&c===i,cell:s,rowspan:r,colspan:l}}})}),e}function Ut(n,e,t){var o;return(o=n[t])==null?void 0:o[e]}const zs=n=>n.closestType(fe);function gu(n,{x:e,y:t,rows:o,cols:s}){var l;let i=zs(n[t][e].cell),r;for(let a=1;a<=o;a++)if(i=(l=i==null?void 0:i.parent())==null?void 0:l.components().at(i.index()+1),i){for(r=e;r>=0;r--){const{cell:c}=n[t+a][r],d=zs(c);if(d===i){for(let p=1;p<=s;p++){const u=c.index();d.append({type:q},{at:u+1})}break}}if(r===-1){const d=i.components().at(0).index();for(let p=1;p<=s;p++)i.append({type:q},{at:d})}}}function ll(n){for(let e=0;e<n.length;e++)for(let t=0;t<n[e].length;t++){const s=n[e][t].cell;if(s.em.selected.hasComponent(s)){const{rowspan:i,colspan:r}=$s(s);if(r>1||i>1){s.addAttributes({colspan:1,rowspan:1});for(let l=0;l<r-1;l++){const a=s.index();zs(s).append({type:q},{at:a+1})}gu(n,{x:t,y:e,rows:i-1,cols:r})}}}}function yu(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const vo=(n,e={})=>{var r;const t=rl(n),{em:o}=n;let s,i;for(let l=0;l<t.length;l++)for(let a=0;a<t[l].length;a++){const c=t[l][a];if((r=e.selected)!=null&&r.includes(c.cell)||o.selected.hasComponent(c.cell)){const d={x:a,y:l};s||(s=d),i=d}}return{grid:t,startPos:s,endPos:i}};function bu(n,e={}){const t=vo(n),{startPos:o,endPos:s}=t;let{grid:i}=t;const{em:r}=n;if(!o||!s)return;const l=o.x,a=o.y,c=s.x,d=s.y,p=Ut(i,l,a),u=Ut(i,c,d);if(p&&u){ll(i),i=rl(n);const h=[],f=Ut(i,l,a).cell;f.addAttributes({colspan:c-l+1,rowspan:d-a+1});for(let m=a;m<=d;m++)for(let g=l;g<=c;g++){const b=Ut(i,g,m);if(!b)continue;const{cell:C}=b;C!==f&&h.push(C)}h.forEach(m=>{e.mergeContent&&f.append(m.components().models),m.remove()}),r.setSelected(f),yu(n)}}const al="Cell settings",vu="Merge cells",Su="Split cell",xu=n=>n.closestType(fe),Kt=n=>{var e;return(e=xu(n))==null?void 0:e.parent()},wu=n=>{const e=n.editor.getSelectedAll(),t=Kt(e[0]),o=e[0];if(!t||!(o!=null&&o.is(q))||e.length>1)return!1;const{rowspan:s,colspan:i}=$s(o);return!(i<2&&s<2)},Cu=n=>{const t=n.editor.getSelectedAll()[0],o=Kt(t),{grid:s}=vo(o);ll(s)},cl=n=>{const e=n.editor.getSelectedAll(),t=Kt(e[0]);if(!t||e.length<2||e.some(l=>!l.is(q)||Kt(l)!==t))return!1;const{grid:o,startPos:s,endPos:i}=vo(t),{em:r}=t;if(!s||!i)return!1;for(let l=s.y;l<=i.y;l++)for(let a=s.x;a<=i.x;a++){const c=Ut(o,a,l);if(!c||!r.selected.hasComponent(c.cell))return!1}return!0},ku=n=>{const{editor:e}=n;if(!cl(n))return;const t=e.getSelectedAll(),o=Kt(t[0]);bu(o,{mergeContent:!0})},Eu=n=>{Ls(n,{id:"tableCellSettings",header:{label:al}})},Tu=n=>[{id:O.tableCellItems,icon:z[O.tableCellProperties],label:"Cell",items:[{id:O.tableCellProperties,label:al,icon:z[O.tableCellProperties],onClick:({event:t})=>Eu({...n,event:t})},{id:O.tableCellMerge,label:vu,icon:z[O.tableCellMerge],onClick:()=>ku(n),disabled:!cl(n)},{id:O.tableCellSplit,label:Su,icon:z[O.tableCellSplit],onClick:()=>Cu(n),disabled:!wu(n)}]},...uu(n),...il(n)],Mu=n=>{const e=n[0]&&Kt(n[0]);if(!e)return;const{grid:t,startPos:o,endPos:s}=vo(e,{selected:n});if(!o||!s)return;const i=[];for(let r=o.y;r<=s.y;r++)for(let l=o.x;l<=s.x;l++){const a=Ut(t,l,r);a&&i.push(a.cell)}i.length&&e.em.setSelected(i,{fromCell:!0})},Au=W(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(ze,{block:t.block&&{label:"Table",media:z.table,category:"Extra",content:{type:ze,style:{width:"100%"}},select:!0,...t.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:z.table,stylable:["width","height","margin","font-family","font-size","font-weight","line-height","text-align","background","background-color","border-width","border-style","border-color"],traits:[{type:"number",min:0,name:"cellspacing",label:"Cell spacing"},{type:"number",min:0,name:"cellpadding",label:"Cell padding"},{id:"tableCaption",type:"checkbox",label:"Caption",setValue({component:r,value:l,emitUpdate:a}){const c=r.find("caption")[0];l?!c&&r.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):c==null||c.remove(),a(),n.refresh({tools:!0})},getValue(r){return!!r.component.find("caption")[0]}}],components:au(Rs,{rows:5}),contextMenu:({items:r,editor:l,component:a})=>[...Ur({editor:l,component:a,opts:t}),...r]}}}),o.addType(Gr,{model:{defaults:{icon:z.tableHead,...s}}}),o.addType(Wr,{model:{defaults:{icon:z.tableFoot,...s}}}),o.addType(Rs,{model:{defaults:{icon:z.tableRowProperties,...s}}}),o.addType(fe,{model:{defaults:{icon:z.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:r,editor:l,component:a})=>[...il({editor:l,component:a,opts:t}),...r]}}}),o.addType(q,{model:{defaults:{icon:z.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","background","background-color","text-align","vertical-align","border-width","border-style","border-color"],traits:[{id:"tableCellType",type:"select",options:[{value:"td",name:"Cell"},{value:"th",name:"Header Cell"}],label:"Cell type",name:"tagName",changeProp:!0},{id:"tableCellScope",type:"select",options:[{value:!1,name:"None"},{value:"row",name:"Row"},{value:"col",name:"Column"},{value:"rowgroup",name:"Row group"},{value:"colgroup",name:"Column group"}],label:"Scope",name:"scope"}],contextMenu:({items:r,editor:l,component:a})=>[...Tu({editor:l,component:a,opts:t}),...r]}}});const i=En((r,l)=>{var p;const a=n.getSelectedAll(),c=!!((p=l==null?void 0:l.event)!=null&&p.shiftKey);if(a.length<2||!c||l.fromCell)return;const d=a.map(u=>u.is(q)?u:u.closestType(q)).filter(Boolean);d.length===a.length&&Mu(d)},0);n.on("component:select",i),j({editor:n,plan:iu,pluginName:su,licenseKey:t.licenseKey,cleanup:()=>{n.off("component:select",i),n.Blocks.remove(ze),ru.forEach(r=>o.removeType(r))}})}),Pu="listPagesComponent",Nu=F.startup,dl="page://",wt="list-pages",Jt="list-pages-item",Ct="list-pages-link",Ou=n=>n.components().reduce((e,t)=>{var r;const o=t.findFirstType(Ct),s=(r=o==null?void 0:o.attributes.attributes)==null?void 0:r.href,i=s!=null&&s.startsWith(dl)?s.replace(dl,""):"";if(i&&o){const l=e[i];l?l.push(o):e[i]=[o]}return e},{}),So="data-type-role",Iu="page_root",Ru=n=>e=>e.is(n),Du=n=>(e,t)=>t.is(n),Bs=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,So))===n},Lu=W(function(n,e={}){const{Blocks:t,Components:o,Pages:s}=n,{licenseKey:i,block:r={}}=e,l="List Pages",a="List Pages Item",c="Link",d=`${ke}${wt}`,p=`${ke}${Ct}`,u='<svg viewBox="0 0 24 24"><path d="M11 15H17V17H11V15M9 7H7V9H9V7M11 13H17V11H11V13M11 9H17V7H11V9M9 11H7V13H9V11M21 5V19C21 20.1 20.1 21 19 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H19C20.1 3 21 3.9 21 5M19 5H5V19H19V5M9 15H7V17H9V15Z"/></svg>',h='<svg viewBox="0 0 24 24"><path d="M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z" /></svg>';o.addType(wt,{block:r&&{label:l,media:u,category:"Extra",select:!0,...e.block},isComponent:Bs(wt),model:{defaults:{tagName:"ul",name:l,[Iu]:"",classes:d,attributes:{[So]:wt,role:"navigation"},droppable:Ru(Jt),styles:`
|
|
62
62
|
.${d} {
|
|
63
63
|
list-style: none;
|
|
64
64
|
margin: 0;
|
|
@@ -68,12 +68,12 @@
|
|
|
68
68
|
.${p} {
|
|
69
69
|
text-decoration: none;
|
|
70
70
|
}
|
|
71
|
-
`}}}),
|
|
71
|
+
`}}}),j({editor:n,licenseKey:i,plan:Nu,pluginName:Pu,cleanup:()=>{t.remove(wt),o.removeType(wt)}})}),$u="fsLightboxComponent",zu=F.startup,xo="data-fslightbox",wo="data-type",Bu="fslightbox-open",Zt="fslightbox",Yt={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>'},Vu=W(function(n,e={}){const{Blocks:t,Components:o}=n,s="Lightbox",i=`${ke}${Zt}`,r={toolbarIconOpen:Yt.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=r,d=function(C){const y=this,v="data-fslightbox",w=window,S=()=>{var M;const x=w.refreshFsLightbox;x==null||x();const k=y.getAttribute(v);if((M=w.fsLightboxInstances)==null||M[k],!w._isEditor)return;Array.from(document.querySelectorAll(`[${v}]`)).forEach(P=>{const N=P.onclick;P.onclick=function(I){I.preventDefault();const R=P;!R.__skipLb&&(N==null||N(I)),R.__skipLb=!0}})};if(w.refreshFsLightbox)S();else{const x=document.createElement("script");x.src=C.cdnScript,x.onload=S,document.head.appendChild(x)}},p=C=>({id:`${Zt}-open-lb`,label:a,command:()=>{const y=C.getView();y==null||y.toggleLightbox()}}),u="source-type",h={type:"radio",name:u,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:Yt.image},{id:"video",label:"Video",icon:Yt.video},{id:"el",label:"Custom Element",icon:Yt.external}],labelToTitle:!0},f={id:"href-image",name:"href",type:"file",label:"Source Image"},m={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},g={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},b={image:[f],video:[m],el:[g]};o.addType(Zt,{block:l&&{label:s,media:Yt.imageLightbox,category:"Extra",select:!0,...r.block},isComponent:C=>{var y;return(y=C.hasAttribute)==null?void 0:y.call(C,xo)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:s,icon:Yt.imageLightbox,classes:i,draggable:(C,y)=>!y.is(Zt),attributes:{[xo]:"lightbox",[wo]:"image",href:c},components:{type:"image",src:c},script:d,cdnScript:r.cdnScript,"script-props":["attributes","cdnScript"],[u]:"image",traits:[h,{name:xo,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(C,y){var w;const v=(w=y.target)==null?void 0:w.getView();v==null||v.toggleLightbox()}}],styles:`
|
|
72
72
|
.${i} {
|
|
73
73
|
display: inline-block;
|
|
74
74
|
padding: 10px;
|
|
75
75
|
}
|
|
76
|
-
`},init(){const C=[u].map(y=>`change:${y}`).join(" ");this.on(C,this.updateTraits),this.on(`change:${u}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(C,y,v){if(v.adjust)return;const S=this.get(u)==="video"?"video":"image";this.addAttributes({[wo]:S,href:""})},adjustSourceType(){const C=this.get(u),y=this.getAttributes().href||"",v={adjust:!0};if(C==="video"){const w=y.includes("youtube.com")?"youtube":"video";this.addAttributes({[wo]:w},v)}else C!=="el"&&y.startsWith("#")?this.set(u,"el",v):C==="image"&&this.addAttributes({[wo]:"image"},v)},updateTraits(C={}){const{changed:y}=this,{init:v}=C;if(y[h.name]||v){this.removeTrait([f.name,m.name,g.name]);const w=this.get(u)||"image",S=this.getTraitIndex(u)+1;this.addTrait(b[w],{at:S})}},initToolbar(){if(!a)return;const{toolbar:C}=this,y=p(this);!C.find(w=>w.id===y.id)&&(C==null||C.unshift(y))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var P;const{em:C,el:y,model:v}=this,{Canvas:w}=C,S=v.getAttributes()[xo],{defaultView:x,documentElement:k}=y.ownerDocument,E=(P=x.fsLightboxInstances)==null?void 0:P[S];if(k.classList.contains(Bu))E.close();else{y.__skipLb=!1;let N;E.props.onOpen=()=>{N=w.getSpots(),setTimeout(()=>w.removeSpots())},E.props.onClose=()=>{N.forEach(I=>w.addSpot(I.attributes))},y.click()}}}}),W({editor:n,plan:zu,licenseKey:r.licenseKey,pluginName:$u,cleanup:()=>{t.remove(Zt),o.removeType(Zt)}})}),Hu="lightGalleryComponent",Fu=F.startup;var Xt=(n=>(n.image="image",n.video="video",n.external="external",n))(Xt||{});const kt="lightGallery",pl=`${kt}-item`,Co="data-lightgallery",ul=`${Co}-item`,ko="toggle",Et={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',gallery:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',galleryItem:'<svg viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M8 14H6v-2h2v2m0-3H6V9h2v2m0-3H6V6h2v2m7 6h-5v-2h5v2m3-3h-8V9h8v2m0-3h-8V6h8v2Z"/></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},Vs={propKeys:[],props:{},traits:[]},Tn=(n,e={})=>{var s;const t={},o=[];for(const i in n){const{value:r,...l}=n[i];o.push({id:i,name:i,changeProp:!0,category:e.category,...l}),t[i]=r;const{subTraits:a={}}=l;for(const c in l.subTraits)(s=a[c])==null||s.forEach(d=>{const p=d.id||d.name;t[p]=d.value})}return{propKeys:Object.keys(t),props:t,traits:o}},Hs=(n,e)=>{const t=n.getTrait(e),o=t.get("category"),s=t.get("subTraits")||{},r=(Object.values(s).flat()||[]).map(c=>c.id||c.name);n.removeTrait(r);const l=s[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:o,...c})),{at:a})},Fs=(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,()=>Hs(n,t)),Hs(n,t)})},_u=(n,e,t)=>{const s=n.getTrait(e).get("subTraits")||{},r=(Object.values(s).flat()||[]).map(a=>{const c=a.name||a.id;return a.changeProp?`change:${c}`:`change:attributes:${c}`}),l=Array.from(new Set(r));l.length&&n.on(l.join(" "),t)},Gu={[ko]:{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}},Wu={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"}]}}},ju={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}]}}},qu={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}]}}},st="sourceType",Eo="data-iframe",_s={name:"href",type:"file",label:"Image Source"},To={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},Gs={name:"data-poster",label:"Video Poster",type:"file"},hl={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},fl={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},Uu={[ko]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var s,i;const t=e.target,o=(s=t==null?void 0:t.closestType(kt))==null?void 0:s.getView();if(o&&t){const r=((i=o.getLightGallery())==null?void 0:i.items)||[],l=Array.from(r).indexOf(t.getEl());l>=0&&o.toggleGallery(l)}}},[st]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[_s],video:[To,Gs],external:[hl]},options:[{id:"image",label:_s.label||"",icon:Et.image},{id:"video",label:To.label||"",icon:Et.video},{id:"external",label:hl.label||"",icon:Et.external}]},subHtml:fl},ml="lgThumbnail",Ku="lgVideo",gl="lgAutoplay",yl="lgZoom",Qt="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Ju=G(function(n,e={}){const{Blocks:t,Components:o}=n,s="LightGallery",i="LightGallery Item",r={toolbarIconOpen:Et.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[ml,Ku,gl,yl],cdnScript:[`${Qt}/lightgallery.min.js`,`${Qt}/plugins/thumbnail/lg-thumbnail.min.js`,`${Qt}/plugins/video/lg-video.min.js`,`${Qt}/plugins/autoplay/lg-autoplay.min.js`,`${Qt}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${Qt}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=r,d=function(y){const v=this,w=window,{plugins:S,cdnScript:x,cdnStyle:k,inline:E,lgLicenseKey:M,...P}=y||{},N=R=>isNaN(R)?void 0:parseInt(R,10),I=()=>{var ue;const R={...P,licenseKey:M,speed:N(P.speed),startAnimationDuration:N(P.startAnimationDuration),thumbMargin:N(P.thumbMargin),thumbWidth:N(P.thumbWidth),slideShowInterval:N(P.slideShowInterval),scale:N(P.scale),enableZoomAfter:N(P.enableZoomAfter),plugins:(S||[]).map(he=>w[he])};E&&(R.container=v,R.closable=!1);const _=(ue=w.lightGallery)==null?void 0:ue.call(w,v,R);E&&_.openGallery()};if(w.lightGallery)I();else{const{head:R}=document,_=Array.isArray(x)?[...x]:[x],ue=Array.isArray(k)?[...k]:[k],he=Ce=>{if(Ce.length){const Ae=document.createElement("link");Ae.href=Ce.shift(),Ae.rel="stylesheet",R.appendChild(Ae),he(Ce)}},tt=Ce=>{if(Ce.length){const Ae=document.createElement("script");Ae.src=Ce.shift(),Ae.onerror=Ae.onload=tt.bind(null,Ce),R.appendChild(Ae)}else I()};he(ue),tt(_)}},p=y=>{const v=y.getTrait(ko);if(!a||!v)return;const{toolbar:w}=y,S={id:ko,label:a,command:()=>setTimeout(()=>v.runCommand(),100)};!w.find(k=>k.id===S.id)&&(w==null||w.unshift(S))};let u=[];const h=r.plugins||[],f=Tn(Gu),m=h.includes(ml)?Tn(Wu):Vs,g=h.includes(gl)?Tn(ju):Vs,b=h.includes(yl)?Tn(qu):Vs;o.addType(kt,{block:l&&{label:s,media:Et.gallery,category:"Extra",select:!0,...r.block},isComponent:y=>fo(y,Co),extendFn:["init","initToolbar"],model:{defaults:{name:s,icon:Et.gallery,draggable:(y,v)=>!v.is(kt),attributes:{[Co]:!0},components:{type:pl},script:d,selector:"",exThumbImage:"",cdnScript:r.cdnScript,cdnStyle:r.cdnStyle,plugins:r.plugins,lgLicenseKey:r.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...f.propKeys,...m.propKeys,...g.propKeys,...b.propKeys],...f.props,...m.props,...g.props,...b.props,traits:[...f.traits,...m.traits,...g.traits,...b.traits]},init(){Fs(this,["thumbnail"]),Fs(this,["autoplay"]),Fs(this,["zoom"])},initToolbar(){p(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,o.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const y=this.getLightGallery();y==null||y.destroy()},disableLgInCanvas(){const y=this.getLightGallery();y.lgOpened=!0},isInlineGallery(){var v;const y=this.getLightGallery();return((v=y==null?void 0:y.settings)==null?void 0:v.container)===this.el},onLgInit(y){this.el.__lg=y.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:y}=this,{Canvas:v}=y,w=this.getLightGallery();u=v.getSpots(),setTimeout(()=>v.removeSpots()),w.__lgOpened=!0},onLgClose(){const y=this.getLightGallery();u.forEach(v=>this.em.Canvas.addSpot(v.attributes)),u=[],y.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(y){const v=this.getLightGallery();if(v.__lgOpened)return v.closeGallery(!0);v.lgOpened=!1,v.openGallery(y)}}});const C=Tn(Uu);o.addType(pl,{isComponent:y=>fo(y,ul)||y.tagName==="A"&&fo(y.parentElement,Co),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:i,icon:Et.galleryItem,attributes:{[ul]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...C.props,traits:[...C.traits]},init(){const y=[st].map(v=>`change:${v}`).join(" ");this.initSourceType(),this.on(y,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),_u(this,st,this.triggerGalleryUpdate)},initToolbar(){p(this)},initScriptUpdate(){const y=[fl.name].map(v=>`change:attributes:${v}`).join(" ");this.on(y,this.triggerGalleryUpdate)},triggerGalleryUpdate(...y){var v;(v=this.closestType(kt))==null||v.__scriptPropsChange(...y)},updateTraits(y={}){const{changed:v}=this,{init:w}=y;if(v[st]||w){Hs(this,st);const S=this.getTrait(st).getValue();if(S===Xt.image){this.removeAttributes([To.name,Gs.name,Eo]);const x=this.getTrait(_s.name);x.setValue(x.getValue()||c)}else S===Xt.video?this.removeAttributes([Eo]):S===Xt.external&&this.addAttributes({[Eo]:!0})}},initSourceType(){const y=this.getAttributes({noClass:!0,noStyle:!0});y[Eo]?this.set(st,Xt.external):(y[To.name]||y[Gs.name])&&this.set(st,Xt.video)}}}),W({editor:n,plan:Fu,licenseKey:r.licenseKey,pluginName:Hu,cleanup:()=>{t.remove(kt),o.removeType(kt)}})}),Ne="swiper",Mn=`${Ne}-slide`,en=`${Ne}-wrapper`,tn=`${Ne}-nav-prev`,Mo=`${Ne}-nav-next`,nn=`${Ne}-pagination`,An=`${Ne}-scrollbar`,le={slider:`<svg viewBox="0 0 24 24">
|
|
76
|
+
`},init(){const C=[u].map(y=>`change:${y}`).join(" ");this.on(C,this.updateTraits),this.on(`change:${u}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(C,y,v){if(v.adjust)return;const S=this.get(u)==="video"?"video":"image";this.addAttributes({[wo]:S,href:""})},adjustSourceType(){const C=this.get(u),y=this.getAttributes().href||"",v={adjust:!0};if(C==="video"){const w=y.includes("youtube.com")?"youtube":"video";this.addAttributes({[wo]:w},v)}else C!=="el"&&y.startsWith("#")?this.set(u,"el",v):C==="image"&&this.addAttributes({[wo]:"image"},v)},updateTraits(C={}){const{changed:y}=this,{init:v}=C;if(y[h.name]||v){this.removeTrait([f.name,m.name,g.name]);const w=this.get(u)||"image",S=this.getTraitIndex(u)+1;this.addTrait(b[w],{at:S})}},initToolbar(){if(!a)return;const{toolbar:C}=this,y=p(this);!C.find(w=>w.id===y.id)&&(C==null||C.unshift(y))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var P;const{em:C,el:y,model:v}=this,{Canvas:w}=C,S=v.getAttributes()[xo],{defaultView:x,documentElement:k}=y.ownerDocument,E=(P=x.fsLightboxInstances)==null?void 0:P[S];if(k.classList.contains(Bu))E.close();else{y.__skipLb=!1;let N;E.props.onOpen=()=>{N=w.getSpots(),setTimeout(()=>w.removeSpots())},E.props.onClose=()=>{N.forEach(I=>w.addSpot(I.attributes))},y.click()}}}}),j({editor:n,plan:zu,licenseKey:r.licenseKey,pluginName:$u,cleanup:()=>{t.remove(Zt),o.removeType(Zt)}})}),Hu="lightGalleryComponent",Fu=F.startup;var Xt=(n=>(n.image="image",n.video="video",n.external="external",n))(Xt||{});const kt="lightGallery",pl=`${kt}-item`,Co="data-lightgallery",ul=`${Co}-item`,ko="toggle",Et={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',gallery:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',galleryItem:'<svg viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M8 14H6v-2h2v2m0-3H6V9h2v2m0-3H6V6h2v2m7 6h-5v-2h5v2m3-3h-8V9h8v2m0-3h-8V6h8v2Z"/></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},Vs={propKeys:[],props:{},traits:[]},Tn=(n,e={})=>{var s;const t={},o=[];for(const i in n){const{value:r,...l}=n[i];o.push({id:i,name:i,changeProp:!0,category:e.category,...l}),t[i]=r;const{subTraits:a={}}=l;for(const c in l.subTraits)(s=a[c])==null||s.forEach(d=>{const p=d.id||d.name;t[p]=d.value})}return{propKeys:Object.keys(t),props:t,traits:o}},Hs=(n,e)=>{const t=n.getTrait(e),o=t.get("category"),s=t.get("subTraits")||{},r=(Object.values(s).flat()||[]).map(c=>c.id||c.name);n.removeTrait(r);const l=s[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:o,...c})),{at:a})},Fs=(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,()=>Hs(n,t)),Hs(n,t)})},_u=(n,e,t)=>{const s=n.getTrait(e).get("subTraits")||{},r=(Object.values(s).flat()||[]).map(a=>{const c=a.name||a.id;return a.changeProp?`change:${c}`:`change:attributes:${c}`}),l=Array.from(new Set(r));l.length&&n.on(l.join(" "),t)},Gu={[ko]:{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}},Wu={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"}]}}},ju={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}]}}},qu={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}]}}},st="sourceType",Eo="data-iframe",_s={name:"href",type:"file",label:"Image Source"},To={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},Gs={name:"data-poster",label:"Video Poster",type:"file"},hl={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},fl={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},Uu={[ko]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var s,i;const t=e.target,o=(s=t==null?void 0:t.closestType(kt))==null?void 0:s.getView();if(o&&t){const r=((i=o.getLightGallery())==null?void 0:i.items)||[],l=Array.from(r).indexOf(t.getEl());l>=0&&o.toggleGallery(l)}}},[st]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[_s],video:[To,Gs],external:[hl]},options:[{id:"image",label:_s.label||"",icon:Et.image},{id:"video",label:To.label||"",icon:Et.video},{id:"external",label:hl.label||"",icon:Et.external}]},subHtml:fl},ml="lgThumbnail",Ku="lgVideo",gl="lgAutoplay",yl="lgZoom",Qt="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Ju=W(function(n,e={}){const{Blocks:t,Components:o}=n,s="LightGallery",i="LightGallery Item",r={toolbarIconOpen:Et.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[ml,Ku,gl,yl],cdnScript:[`${Qt}/lightgallery.min.js`,`${Qt}/plugins/thumbnail/lg-thumbnail.min.js`,`${Qt}/plugins/video/lg-video.min.js`,`${Qt}/plugins/autoplay/lg-autoplay.min.js`,`${Qt}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${Qt}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=r,d=function(y){const v=this,w=window,{plugins:S,cdnScript:x,cdnStyle:k,inline:E,lgLicenseKey:M,...P}=y||{},N=R=>isNaN(R)?void 0:parseInt(R,10),I=()=>{var ue;const R={...P,licenseKey:M,speed:N(P.speed),startAnimationDuration:N(P.startAnimationDuration),thumbMargin:N(P.thumbMargin),thumbWidth:N(P.thumbWidth),slideShowInterval:N(P.slideShowInterval),scale:N(P.scale),enableZoomAfter:N(P.enableZoomAfter),plugins:(S||[]).map(he=>w[he])};E&&(R.container=v,R.closable=!1);const G=(ue=w.lightGallery)==null?void 0:ue.call(w,v,R);E&&G.openGallery()};if(w.lightGallery)I();else{const{head:R}=document,G=Array.isArray(x)?[...x]:[x],ue=Array.isArray(k)?[...k]:[k],he=Ce=>{if(Ce.length){const Ae=document.createElement("link");Ae.href=Ce.shift(),Ae.rel="stylesheet",R.appendChild(Ae),he(Ce)}},tt=Ce=>{if(Ce.length){const Ae=document.createElement("script");Ae.src=Ce.shift(),Ae.onerror=Ae.onload=tt.bind(null,Ce),R.appendChild(Ae)}else I()};he(ue),tt(G)}},p=y=>{const v=y.getTrait(ko);if(!a||!v)return;const{toolbar:w}=y,S={id:ko,label:a,command:()=>setTimeout(()=>v.runCommand(),100)};!w.find(k=>k.id===S.id)&&(w==null||w.unshift(S))};let u=[];const h=r.plugins||[],f=Tn(Gu),m=h.includes(ml)?Tn(Wu):Vs,g=h.includes(gl)?Tn(ju):Vs,b=h.includes(yl)?Tn(qu):Vs;o.addType(kt,{block:l&&{label:s,media:Et.gallery,category:"Extra",select:!0,...r.block},isComponent:y=>fo(y,Co),extendFn:["init","initToolbar"],model:{defaults:{name:s,icon:Et.gallery,draggable:(y,v)=>!v.is(kt),attributes:{[Co]:!0},components:{type:pl},script:d,selector:"",exThumbImage:"",cdnScript:r.cdnScript,cdnStyle:r.cdnStyle,plugins:r.plugins,lgLicenseKey:r.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...f.propKeys,...m.propKeys,...g.propKeys,...b.propKeys],...f.props,...m.props,...g.props,...b.props,traits:[...f.traits,...m.traits,...g.traits,...b.traits]},init(){Fs(this,["thumbnail"]),Fs(this,["autoplay"]),Fs(this,["zoom"])},initToolbar(){p(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,o.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const y=this.getLightGallery();y==null||y.destroy()},disableLgInCanvas(){const y=this.getLightGallery();y.lgOpened=!0},isInlineGallery(){var v;const y=this.getLightGallery();return((v=y==null?void 0:y.settings)==null?void 0:v.container)===this.el},onLgInit(y){this.el.__lg=y.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:y}=this,{Canvas:v}=y,w=this.getLightGallery();u=v.getSpots(),setTimeout(()=>v.removeSpots()),w.__lgOpened=!0},onLgClose(){const y=this.getLightGallery();u.forEach(v=>this.em.Canvas.addSpot(v.attributes)),u=[],y.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(y){const v=this.getLightGallery();if(v.__lgOpened)return v.closeGallery(!0);v.lgOpened=!1,v.openGallery(y)}}});const C=Tn(Uu);o.addType(pl,{isComponent:y=>fo(y,ul)||y.tagName==="A"&&fo(y.parentElement,Co),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:i,icon:Et.galleryItem,attributes:{[ul]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...C.props,traits:[...C.traits]},init(){const y=[st].map(v=>`change:${v}`).join(" ");this.initSourceType(),this.on(y,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),_u(this,st,this.triggerGalleryUpdate)},initToolbar(){p(this)},initScriptUpdate(){const y=[fl.name].map(v=>`change:attributes:${v}`).join(" ");this.on(y,this.triggerGalleryUpdate)},triggerGalleryUpdate(...y){var v;(v=this.closestType(kt))==null||v.__scriptPropsChange(...y)},updateTraits(y={}){const{changed:v}=this,{init:w}=y;if(v[st]||w){Hs(this,st);const S=this.getTrait(st).getValue();if(S===Xt.image){this.removeAttributes([To.name,Gs.name,Eo]);const x=this.getTrait(_s.name);x.setValue(x.getValue()||c)}else S===Xt.video?this.removeAttributes([Eo]):S===Xt.external&&this.addAttributes({[Eo]:!0})}},initSourceType(){const y=this.getAttributes({noClass:!0,noStyle:!0});y[Eo]?this.set(st,Xt.external):(y[To.name]||y[Gs.name])&&this.set(st,Xt.video)}}}),j({editor:n,plan:Fu,licenseKey:r.licenseKey,pluginName:Hu,cleanup:()=>{t.remove(kt),o.removeType(kt)}})}),Ne="swiper",Mn=`${Ne}-slide`,en=`${Ne}-wrapper`,tn=`${Ne}-nav-prev`,Mo=`${Ne}-nav-next`,nn=`${Ne}-pagination`,An=`${Ne}-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">
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
.${t}-progressbar-fill {
|
|
118
118
|
--swiper-pagination-color: currentColor;
|
|
119
119
|
}
|
|
120
|
-
`}}}),()=>{e.removeType(nn)}},nh="Scrollbar",xl=`${on}scrollbar`,oh=n=>{const{Components:e}=n;return e.addType(An,{isComponent:t=>ot(t,xl),model:{defaults:{name:nh,classes:xl,copyable:!1,highlightable:!1,removable:!1,selectable:!1,hoverable:!1,layerable:!1,droppable:!1,draggable:!1}}}),()=>{e.removeType(An)}},sh="Slide",wl=`${on}slide`,ih=n=>{const{Components:e}=n;return e.addType(Mn,{isComponent:t=>ot(t,wl),model:{defaults:{name:sh,classes:wl,icon:le.slider,draggable:(t,o)=>o.is(en)}}}),()=>{e.removeType(Mn)}},rh="Wrapper",Cl=`${on}wrapper`,lh=n=>{const{Components:e}=n,{events:t}=e;return e.addType(en,{isComponent:o=>ot(o,Cl),model:{defaults:{name:rh,icon:le.slider,classes:Cl,copyable:!1,removable:!1,draggable:!1,highlightable:!1,droppable:o=>o.is(Mn)},init(){const o=this.components();this.listenTo(o,"add remove",this.updateSlider)},updateSlider(o){const s=this.closestType(Ne);if(s){const i=s.getView();s.reloadSlider(),this.em.once(t.scriptMount,()=>{setTimeout(()=>{var r;return(r=i.getSwiper())==null?void 0:r.slideTo(o.index())},100)})}}}}),()=>{e.removeType(en)}},ah="swiperComponent",ch=F.startup,dh=
|
|
120
|
+
`}}}),()=>{e.removeType(nn)}},nh="Scrollbar",xl=`${on}scrollbar`,oh=n=>{const{Components:e}=n;return e.addType(An,{isComponent:t=>ot(t,xl),model:{defaults:{name:nh,classes:xl,copyable:!1,highlightable:!1,removable:!1,selectable:!1,hoverable:!1,layerable:!1,droppable:!1,draggable:!1}}}),()=>{e.removeType(An)}},sh="Slide",wl=`${on}slide`,ih=n=>{const{Components:e}=n;return e.addType(Mn,{isComponent:t=>ot(t,wl),model:{defaults:{name:sh,classes:wl,icon:le.slider,draggable:(t,o)=>o.is(en)}}}),()=>{e.removeType(Mn)}},rh="Wrapper",Cl=`${on}wrapper`,lh=n=>{const{Components:e}=n,{events:t}=e;return e.addType(en,{isComponent:o=>ot(o,Cl),model:{defaults:{name:rh,icon:le.slider,classes:Cl,copyable:!1,removable:!1,draggable:!1,highlightable:!1,droppable:o=>o.is(Mn)},init(){const o=this.components();this.listenTo(o,"add remove",this.updateSlider)},updateSlider(o){const s=this.closestType(Ne);if(s){const i=s.getView();s.reloadSlider(),this.em.once(t.scriptMount,()=>{setTimeout(()=>{var r;return(r=i.getSwiper())==null?void 0:r.slideTo(o.index())},100)})}}}}),()=>{e.removeType(en)}},ah="swiperComponent",ch=F.startup,dh=W(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=[Yu(n,t),eh(n),lh(n),ih(n),th(n),oh(n)];j({editor:n,plan:ch,licenseKey:t.licenseKey,pluginName:ah,cleanup:()=>{o.forEach(s=>s())}})}),me="accordion",Pn=`${me}-group`,Je=`${me}-header`,it=`${me}-content`,Tt=`${me}-marker`,kl=`${ke}${Je}`,js=`${ke}${Tt}`,ph=`${ke}${it}`,El=`${js}-open`,Mt={accordion:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M5.616 20q-.691 0-1.153-.462T4 18.384V5.616q0-.691.463-1.153T5.616 4h12.769q.69 0 1.153.463T20 5.616v12.769q0 .69-.462 1.153T18.384 20zm0-1h12.769q.23 0 .423-.192t.192-.424V8.154H5v10.23q0 .232.192.424t.423.192"/></svg>',accordionGroup:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M8.116 16h10.769q.23 0 .423-.192t.192-.423V6h-12v9.385q0 .23.192.423t.423.192m0 1q-.69 0-1.153-.462T6.5 15.385V4.615q0-.69.463-1.153T8.116 3h10.769q.69 0 1.153.462t.462 1.153v10.77q0 .69-.462 1.152T18.884 17zm-3 3q-.69 0-1.153-.462T3.5 18.385V6.615h1v11.77q0 .23.192.423t.423.192h11.77v1zM7.5 4v12z"/></svg>',accordionHeader:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M5.616 20q-.691 0-1.153-.462T4 18.384V5.616q0-.691.463-1.153T5.616 4h12.769q.69 0 1.153.463T20 5.616v12.769q0 .69-.462 1.153T18.384 20zm0-1h12.769q.23 0 .423-.192t.192-.424V5.616q0-.231-.192-.424T18.384 5H5.616q-.231 0-.424.192T5 5.616v12.769q0 .23.192.423t.423.192M5 5v14zm2.616 4.192h6q.413 0 .706-.293q.294-.293.294-.707t-.294-.706q-.293-.294-.706-.294h-6q-.414 0-.707.294t-.293.706t.293.707t.707.293"/></svg>',accordionContent:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M4.616 19q-.691 0-1.153-.462T3 17.384V6.616q0-.691.463-1.153T4.615 5h14.77q.69 0 1.152.463T21 6.616v10.769q0 .69-.463 1.153T19.385 19zm0-1h14.769q.23 0 .423-.192t.192-.424V6.616q0-.231-.192-.424T19.385 6H4.615q-.23 0-.423.192T4 6.616v10.769q0 .23.192.423t.423.192M4 18V6zm2.23-2.116h11.54q.213 0 .356-.143t.143-.357t-.143-.356t-.357-.144H6.231q-.214 0-.357.144q-.143.143-.143.357q0 .213.143.356t.357.144m0-3.385h11.538q.214 0 .357-.143t.143-.357t-.143-.357t-.357-.143H6.231q-.214 0-.357.143T5.731 12t.143.357t.357.143m0-3.384H14q.214 0 .357-.144q.143-.143.143-.356q0-.214-.143-.357T14 8.116H6.23q-.213 0-.356.143t-.143.357t.143.356t.357.144"/></svg>',accordionMarker:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="m12 15.596l3.173-3.192H8.827zM5.616 20q-.672 0-1.144-.472T4 18.385V5.615q0-.67.472-1.143Q4.944 4 5.616 4h12.769q.67 0 1.143.472q.472.472.472 1.144v12.769q0 .67-.472 1.143q-.472.472-1.143.472zM5 9v9.385q0 .23.192.423t.423.192h12.77q.23 0 .423-.192t.192-.423V9z"/></svg>',caret:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m7.4 8.6 4.6 4.6 4.6-4.6L18 10l-6 6-6-6 1.4-1.4Z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},Tl=(n,e)=>{const{toolbarIconOpen:t=Mt.eye}=e,o=n.is(me)?n:n.closestType(me);if(!t||!o)return;const{toolbar:s}=n,i={id:"accordion-toggle-open",label:t,command:()=>o.toggleOpen()};!s.find(l=>l.id===i.id)&&(s==null||s.unshift(i))},uh=(n,e)=>{const{Components:t,Blocks:o}=n,{block:s={}}=e,i="Accordion",r=`${ke}${me}`,l=function(a={}){const c=this,d=()=>{const{clsMarkerOpen:p}=a,u=c.querySelector('[data-type-role="accordion-marker"]');!u||!p||(c.open?u.classList.add(p):u.classList.remove(p))};c.addEventListener("toggle",()=>{d(),c.dispatchEvent(new CustomEvent("details-toggle",{bubbles:!0}))}),d()};return t.addType(me,{block:s&&{label:i,media:Mt.accordion,category:"Extra",select:!0,...s},isComponent:$e(me),extendFn:["initToolbar"],model:{defaults:{tagName:"details",name:i,classes:r,emptyState:!0,clsMarkerOpen:El,attributes:{[Pe]:me},droppable:mo(Je,it),components:[{type:Je},{type:it}],"script-props":["clsMarkerOpen"],script:l,traits:[{type:"checkbox",name:"open",label:"Open"}],styles:`
|
|
121
121
|
.${r}::details-content {
|
|
122
122
|
opacity: 0;
|
|
123
123
|
block-size: 0;
|
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
.${El} {
|
|
156
156
|
transform: rotateZ(180deg);
|
|
157
157
|
}
|
|
158
|
-
`}}}),()=>{e.removeType(Tt)}},yh="accordionComponent",bh=F.startup,vh=
|
|
158
|
+
`}}}),()=>{e.removeType(Tt)}},yh="accordionComponent",bh=F.startup,vh=W(function(n,e={}){const t=[uh(n,e),fh(n,e),mh(n,e),gh(n),hh(n)];j({editor:n,licenseKey:e.licenseKey,plan:bh,pluginName:yh,cleanup:()=>{t.forEach(o=>o())}})}),po=class po{constructor(e){this.config=e}getSize(e){var t;return(t=this.config)!=null&&t.getSize?this.config.getSize(e):Ys(e.componentColumn,po.CSS_FLEX_BASIS)}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:o,sizeValue:s,partial:i}=e;o.addStyle({[po.CSS_FLEX_BASIS]:s},{partial:i})}}};po.CSS_FLEX_BASIS="flex-basis";let qs=po;const uo=class uo{constructor(e){this.config=e}isGapSupported(){return!0}getGap(e){var t;return(t=this.config)!=null&&t.getGap?this.config.getGap(e):Ys(e.componentRow,uo.CSS_GAP)}setGap(e){var t;if((t=this.config)!=null&&t.setGap)this.config.setGap(e);else{const{componentRow:o,gapValue:s,partial:i}=e;o.addStyle({[uo.CSS_GAP]:s},{partial:i})}}};uo.CSS_GAP="gap";let Us=uo;const xs=class xs{constructor(e){this.config=e}getParentSize(e){var i;if((i=this.config)!=null&&i.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:o}=e,s=t.getEl();return s?o?s.clientHeight:s.clientWidth:0}isLayoutVertical(e){var o;if((o=this.config)!=null&&o.isParentVertical)return this.config.isParentVertical(e);const t=Ys(e.componentRow,xs.CSS_FLEX_DIRECTION,!0);return t==="column"||t==="column-reverse"}};xs.CSS_FLEX_DIRECTION="flex-direction";let Ks=xs;const ho=class ho{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(ho.MJML_COLUMN_TYPE)){const i=t.getAttributes().width;if(i&&(i.includes("%")||!isNaN(parseFloat(i))))return parseFloat(i);const r=t.parent();return 100/(r?r.components().length:1)}return 0}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:o,sizeValue:s,partial:i}=e;o.is(ho.MJML_COLUMN_TYPE)&&o.addAttributes({width:`${parseFloat(s)}%`},{partial:i})}}};ho.MJML_COLUMN_TYPE="mj-column";let Js=ho;const ws=class ws{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(ws.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)}};ws.MJML_SECTION_TYPE="mj-section";let Zs=ws;class Sh{constructor(e){this.config=e}getParentSize(e){var r;if((r=this.config)!=null&&r.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:o}=e,s=t.getEl();if(!s)return 0;let i=s;if(s.tagName!=="TABLE"){const l=s.querySelectorAll("table");l.length&&(i=l[0])}return o?i.clientHeight:i.clientWidth}isLayoutVertical(e){var t;return(t=this.config)!=null&&t.isParentVertical?this.config.isParentVertical(e):!1}}class sn{constructor(){this.handlerCache=new Map}static getInstance(){return sn.instance||(sn.instance=new sn),sn.instance}getHandlers(e){const t=`${e.projectType}-${e.disableGapHandler?"nogap":"gap"}`;return this.handlerCache.has(t)||(rn(e)?this.handlerCache.set(t,{sizeHandler:new Js(e),gapHandler:new Zs(e),parentSizeHandler:new Sh(e)}):this.handlerCache.set(t,{sizeHandler:new qs(e),gapHandler:new Us(e),parentSizeHandler:new Ks(e)})),this.handlerCache.get(t)}}function At(n){return sn.getInstance().getHandlers(n)}const Ml=n=>{n.style.display="none"},Al=n=>{n.style.display="block"},Nn=n=>+parseFloat(`${n}`).toFixed(2),rn=n=>n.projectType===Ir.email,xh=n=>n?["top","bottom"]:["left","right"],wh=n=>{const e=n.parent();return e?e.components().models.indexOf(n)===0:!1},Ch=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.indexOf(n)===t.length-1},kh=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.length>1&&n.index()===t.length-1},Eh=(n,e,t,o)=>{const i=n+(t?e==="top"?-1:e==="bottom"?1:0:e==="left"?-1:e==="right"?1:0);return i>=0&&i<o?i:-1},No=n=>n==="top"||n==="bottom",Th=(n,e)=>!!(wh(n)&&(e==="left"||e==="top")||Ch(n)&&(e==="right"||e==="bottom")),Mh=n=>{const e=n.parent();return e?e.components().models.length>1:!1},Pl=(n,e)=>n==="right"||n==="bottom"?e>0:e<0,Ys=(n,e,t=!1)=>{const o=!t,s=n.getEl();if(!s)return o?0:"";const r=window.getComputedStyle(s)[e]||"";if(o){let l;return typeof r=="string"?(l=parseFloat(r.replace(/[^-\d.]/g,"")),isNaN(l)&&(l=0)):l=Number(r)||0,l}return r},Nl=(n,e,t)=>{const o=Xs({componentRow:n,isVertical:e},t),s=n.components().models;return o*(s.length-1)},On=(n,e)=>At(e).parentSizeHandler.isLayoutVertical({componentRow:n}),In=(n,e)=>At(e).sizeHandler.getSize(n),Xs=(n,e)=>{if(e!=null&&e.disableGapHandler)return 0;const{gapHandler:t,parentSizeHandler:o}=At(e);if(!t.isGapSupported())return 0;const s=t.getGap(n),i=o.getParentSize(n);return s/100*i},Qs=(n,e)=>At(e).parentSizeHandler.getParentSize(n),Rn=(n,e)=>{At(e).sizeHandler.setSize(n)},Ol=(n,e)=>{const t=In(n,e);Rn({...n,sizeValue:`${t}%`,partial:!1},e)},Il=(n,e)=>{if(e!=null&&e.disableGapHandler)return;const{gapHandler:t}=At(e);t.isGapSupported()&&t.setGap(n)},Ah=(n,e)=>{const t=n.getStyle().gap;if(!t)return;const o=n.components().models,s={componentRow:n,isVertical:On(n,e)};o.map(i=>Ol({...s,componentColumn:i},e)),Il({...s,gapValue:String(t),partial:!1},e)};function Ph(n,e){const{Blocks:t}=n,{typeColumn:o,typeRow:s,blocks:i}=e;if(i===!1||rn(e))return;const r=p=>({type:s,components:p.map(u=>({type:o,style:{"flex-basis":`${u}%`}}))}),l=p=>`<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
|
|
159
159
|
${p.map(u=>`<div style="flex-basis: ${u}%; border-color: currentColor; border-width: 2px; border-radius: 0.12rem;"></div>`).join("")}
|
|
160
160
|
</div>`,a=(p,u)=>({id:`flex-row-${u.join("-")}`,label:p,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:l(u),content:r(u)}),c=[a("1 Column",[100]),a("2 Columns 50/50",[50,50]),a("2 Columns 25/75",[25,75]),a("2 Columns 75/25",[75,25]),a("3 Columns",[33.33,33.33,33.33]),a("3 Columns 50/25/25",[50,25,25]),a("3 Columns 25/50/25",[25,50,25]),a("3 Columns 25/25/50",[25,25,50]),a("4 Columns",[25,25,25,25]),a("5 Columns",[20,20,20,20,20])],d=xt(i)?i({blocks:c}):c;return d.forEach(p=>t.add(p.id,p)),()=>{d.forEach(p=>t.remove(p.id))}}const Nh=(n,e)=>{const{Components:t}=n,{typeRow:o,typeColumn:s,extendTypeColumn:i}=e,r=`${ke}${s}`,a=!!s&&!!t.getType(s)&&!i;if(!(!s||a||rn(e)))return t.addType(s,{isComponent:$e(s),model:{defaults:{name:"Column",resizable:!1,emptyState:!0,classes:r,icon:'<svg viewBox="0 0 24 24"><path d="M14.5 2.3A1.8 1.8 0 0 0 12.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8zm-8 0A1.8 1.8 0 0 0 4.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',draggable:Ms(o),attributes:{[Pe]:s},styles:`
|
|
161
161
|
.${r} {
|
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
pointer-events: all;
|
|
188
188
|
max-width: 3rem;
|
|
189
189
|
max-height: 3rem;
|
|
190
|
-
`,l.addEventListener("pointerdown",f()),i.appendChild(l)),s.append(i),(S=t.getSpotsEl())==null||S.appendChild(s)},h=S=>x=>{if(!a)return;x.stopPropagation(),x.preventDefault(),p.startResize(a,S,x);const k=x.clientX,E=x.clientY;x.target.setPointerCapture(x.pointerId);const M=N=>{const I=n.Canvas.getZoomMultiplier(),R=(N.clientX-k)*I,
|
|
190
|
+
`,l.addEventListener("pointerdown",f()),i.appendChild(l)),s.append(i),(S=t.getSpotsEl())==null||S.appendChild(s)},h=S=>x=>{if(!a)return;x.stopPropagation(),x.preventDefault(),p.startResize(a,S,x);const k=x.clientX,E=x.clientY;x.target.setPointerCapture(x.pointerId);const M=N=>{const I=n.Canvas.getZoomMultiplier(),R=(N.clientX-k)*I,G=(N.clientY-E)*I,ue=No(S)?G:R;p.updateResizeByDelta(a,S,ue)},P=()=>{p.finishResize(a),x.target.releasePointerCapture(x.pointerId),document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",P)};document.addEventListener("pointermove",M),document.addEventListener("pointerup",P)},f=()=>S=>{if(!c)return;const x=c;S.stopPropagation(),S.preventDefault();const k=On(x,e),E=Xs({componentRow:x,isVertical:k},e),M=S.clientX,P=S.clientY;S.target.setPointerCapture(S.pointerId);const N=R=>{const G=n.Canvas.getZoomMultiplier(),ue=k?(R.clientY-P)*G:(R.clientX-M)*G;p.updateGapByDelta(x,ue,E,k)},I=()=>{p.finishGapAdjust(x),S.target.releasePointerCapture(S.pointerId),document.removeEventListener("pointermove",N),document.removeEventListener("pointerup",I)};document.addEventListener("pointermove",N),document.addEventListener("pointerup",I)},m=S=>{const x=S.component;if(!x||!s||(a=x,c=x.parent(),!c))return;const k=c;Al(s);const E=S.getStyle();i&&Object.assign(i.style,E);const M=On(k,e),P=xh(M);if(Object.values(r).forEach(Ml),P.forEach(I=>{if(Th(x,I))return;const R=r[I];Al(R)}),At(e).gapHandler.isGapSupported()&&l&&Mh(x)){const I=Xs({componentRow:k,isVertical:M},e);g(I,M,kh(x))}},g=(S,x,k=!1)=>{const E=e.gapHandleSize,M=l.style;if(x){M.height=`${E}px`;const P=l.offsetHeight;k?(M.top=`-${(S+P)/2}px`,M.bottom=""):(M.bottom=`-${(S+P)/2}px`,M.top=""),M.width="50%",M.left="50%",M.transform="translateX(-50%)",M.cursor="row-resize"}else{M.width=`${E}px`;const P=l.offsetWidth;k?(M.left=`-${(S+P)/2}px`,M.right=""):(M.right=`-${(S+P)/2}px`,M.left=""),M.height="50%",M.top="50%",M.transform="translateY(-50%)",M.cursor="col-resize"}},b=()=>{s&&(Ml(s),a=null,c=null)},C=()=>{t.removeSpots({type:o});const S=n.getSelected(),x=S==null?void 0:S.parent();S&&x&&d.isValidRelationship(x,S)?t.addSpot({type:o,component:S}):b()},y=()=>{const S=t.getSpots().filter(x=>x.type===o)[0];S&&m(S)},v=(S,x)=>{d.registerTypeRelationship(S,x)};n.onReady(()=>{u(),rn(e)?v("mj-section","mj-column"):v(e.typeRow,e.typeColumn)});const w="component:toggled";return n.on(t.events.spot,y),n.on(w,C),()=>{n.off(t.events.spot,y),n.off(w,C)}}const Hh=W(function(n,e={}){const t={typeRow:"flex-row",typeColumn:"flex-column",gapHandleSize:3,snapDivisions:12,minItemPercent:5,...e},o=[Oh(n,t),Nh(n,t)],s=Vh(n,t),i=Ph(n,t);j({editor:n,licenseKey:t.licenseKey,plan:Rh,pluginName:Ih,cleanup:()=>{o.forEach(r=>r==null?void 0:r()),s(),i==null||i()}})});var Oe=(n=>(n.name="animation-name",n.duration="animation-duration",n.delay="animation-delay",n.iterationCount="animation-iteration-count",n.timingFunction="animation-timing-function",n.fillMode="animation-fill-mode",n))(Oe||{}),ln=(n=>(n.onScroll="--animation-on-scroll",n.threshold="--animation-threshold",n.repeat="--animation-repeat",n))(ln||{});const Be="animation",an="animation-group",Dl="animation:update",ei="animation-group:update",Ll={category:{id:"animations",label:"Animations"},select:!0},Io=n=>(n==null?void 0:n.getType())===Be,Ro=n=>(n==null?void 0:n.getType())===an,$l=n=>Io(n)||Ro(n),Dn={isVisible:({component:n})=>Io(n)},Fh={isVisible:({component:n})=>Ro(n)},_h={isVisible:({component:n})=>Io(n)&&Ro(n==null?void 0:n.parent())?!1:$l(n)},zl={isVisible:({component:n,sector:e})=>{var t;return Io(n)&&Ro(n==null?void 0:n.parent())?!1:$l(n)&&((t=e.getProperty(ln.onScroll))==null?void 0:t.getValue())==="true"}},Bl={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>'},Gh=function(n){const e=this;let t=null;const o=()=>{t==null||t.disconnect(),t=null},s=()=>{o();const i=e.style;i.animationName="",requestAnimationFrame(()=>{const r=getComputedStyle(e),l=r.getPropertyValue("animation-name").trim(),a=r.getPropertyValue("--animation-on-scroll").trim()!=="false",c=parseFloat(r.getPropertyValue("--animation-threshold").trim())||.2,d=r.getPropertyValue("--animation-repeat").trim()==="true",p=()=>{i.animationName="none",e.offsetWidth,i.animationName=l,i.animationPlayState="running"};if(!l||l==="none"){i.animationName="none",i.animationPlayState="paused";return}if(!a){p();return}i.animationPlayState="paused",t=new IntersectionObserver(u=>{u.forEach(h=>{h.isIntersecting&&(p(),!d&&o())})},{threshold:c}),t.observe(e)})};e.addEventListener(n.animationUpdateEvent,s),s()},Wh=(n,e)=>{const{Components:t,Blocks:o,Canvas:s}=n,{block:i={},animationList:r=[]}=e,l=n.Components.events,a="Animation",c=Object.values(ln),d=Object.values(Oe);return t.addType(Be,{block:i?{label:a,media:Bl.animation,content:{type:Be},...Ll,...i}:void 0,model:{defaults:{emptyState:!0,name:a,traits:[],script:Gh,animationUpdateEvent:Dl,"script-props":["animationUpdateEvent"],styles:r.map(p=>p.css).join(`
|
|
191
191
|
`)},init(){const{em:p}=this;this.addStyle({[Oe.name]:"fadeIn",[Oe.duration]:"1s",[Oe.fillMode]:"both",...e.animationStyle,...this.getStyle()}),this.listenTo(p,l.mount,u=>{var f;if(u!==this)return;((f=this.parent())==null?void 0:f.get("type"))!==an||c.forEach(m=>this.removeStyle(m))})}},view:{events:()=>({animationstart:"onAnimationStart",animationend:"onAnimationEnd"}),init(){const{model:p}=this;this.listenTo(p,l.styleUpdate,this.handleStyleChange)},onAnimationStart(){var u;if((u=this.cmpSpots)!=null&&u.length)return;const p=s.getSpots({component:this.model});this.cmpSpots=p,s.removeSpots(p),this.el.ownerDocument.body.style.overflowX="hidden"},onAnimationEnd(){const p=this.cmpSpots||[];s.spots.add(p),this.cmpSpots=[],this.el.ownerDocument.body.style.overflowX=""},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(Dl))},handleStyleChange(p,u){Object.keys((u==null?void 0:u.style)||{}).some(m=>d.includes(m)||c.includes(m))&&this.triggerAnimation()},onRender(){this.triggerAnimation()}}}),()=>{o.remove(Be),t.removeType(Be)}},jh=function(n){const e=this,t="--animation-on-scroll",o="--animation-threshold",s="--animation-repeat";let i=null;const r=()=>{i==null||i.disconnect(),i=null},l=()=>{r();const a=getComputedStyle(e),c=a.getPropertyValue(t).trim()!=="false",d=parseFloat(a.getPropertyValue(o).trim())||.2,p=a.getPropertyValue(s).trim()==="true",u=()=>{Array.from(e.children).forEach(h=>{h instanceof HTMLElement&&typeof h.dispatchEvent=="function"&&h.dispatchEvent(new CustomEvent(ei,{bubbles:!1}))})};if(!c){u();return}i=new IntersectionObserver(h=>{h.forEach(f=>{f.isIntersecting?(u(),!p&&r()):p&&Array.from(e.children).forEach(m=>{m instanceof HTMLElement&&getComputedStyle(m).getPropertyValue(t).trim()!=="false"&&(m.style.opacity="0",m.style.animationPlayState="paused")})})},{threshold:d}),i.observe(e)};e.addEventListener(n.animationGroupUpdateEvent,l),l()},qh=(n,e)=>{const{Components:t,Blocks:o}=n,{blockGroup:s={}}=e,i="Animation Group";return t.addType(an,{block:s?{label:i,media:Bl.animationGroup,content:{type:an,components:[{type:Be},{type:Be},{type:Be}]},...Ll,...s}:void 0,model:{defaults:{name:i,emptyState:!0,traits:[],script:jh,animationGroupUpdateEvent:ei,"script-props":["animationGroupUpdateEvent"],droppable:mo(Be)},init(){this.addStyle({...e.animationGroupStyle,...this.getStyle()});const r=this.components();this.listenTo(r,"add remove",this.updateChildrenStaggerStyles),this.updateChildrenStaggerStyles()},updateChildrenStaggerStyles(){this.components().forEach((r,l)=>{r.is(Be)&&r.addStyle({"--stagger-index":l.toString(),[Oe.delay]:"calc(var(--stagger-index, 0) * var(--stagger-delay, 0.3s))"},{partial:!0})})}},view:{init(){const{model:r}=this;this.listenTo(r,"component:styleUpdate",this.handleStyleChange)},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(ei))},handleStyleChange(){this.triggerAnimation(),this.model.updateChildrenStaggerStyles()},onRender(){this.triggerAnimation()}}}),()=>{o.remove(an),t.removeType(an)}},Uh="animationComponent",Kh=F.startup,Vl=[{id:"flash",name:"Flash",css:`@keyframes flash {
|
|
192
192
|
0%, 50%, to {
|
|
193
193
|
opacity:1
|
|
@@ -705,7 +705,7 @@
|
|
|
705
705
|
transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0);
|
|
706
706
|
animation-timing-function:cubic-bezier(.175, .885, .32, 1)
|
|
707
707
|
}
|
|
708
|
-
}`}],Jh=
|
|
708
|
+
}`}],Jh=W(function(n,e={}){var s;const t=((s=e.animations)==null?void 0:s.call(e,{items:Vl}))||Vl,o=[Wh(n,{...e,animationList:t}),qh(n,e)];n.Styles.addSector("animation",{name:"Animation",properties:[{...Dn,name:"Type",property:Oe.name,type:"select",full:!0,default:"fadeIn",options:t},{...Dn,name:"Duration",property:Oe.duration,type:"number",units:["s"],min:.1,max:10,step:.1,default:"1s"},{...Dn,name:"Delay",property:Oe.delay,type:"number",units:["s"],min:0,max:10,step:.1,default:"1s"},{...Dn,name:"Iteration Count",property:Oe.iterationCount,type:"select",default:"1",options:[{id:"1",name:"One time"},{id:"infinite",name:"Infinite"}]},{...Dn,name:"Timing",property:Oe.timingFunction,type:"select",default:"ease",options:[{id:"ease",name:"Ease"},{id:"ease-in",name:"Ease in"},{id:"ease-out",name:"Ease out"},{id:"ease-in-out",name:"Ease in out"},{id:"linear",name:"Linear"}]},{...Fh,name:"Stagger Delay",property:"--stagger-delay",type:"slider",units:["s"],min:.1,max:5,step:.1,default:"0.3s"},{..._h,name:"Animate on Scroll",property:ln.onScroll,type:"radio",default:"true",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]},{...zl,name:"Scroll Threshold",property:ln.threshold,type:"number",full:!0,min:.1,max:1,step:.01,default:"0.2"},{...zl,name:"Repeat on Scroll",property:ln.repeat,type:"radio",default:"false",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]}]}),j({editor:n,licenseKey:e.licenseKey,plan:Kh,pluginName:Uh,cleanup:()=>{o.forEach(i=>i())}})}),Zh="shapeDividerComponent",Yh=F.startup,Xh=W(function(n,e={}){const{Components:t,Blocks:o,Selectors:s}=n,i="shape-divider",r=`${i}-cnt`,l=`${ke}${i}`,a=`${ke}${r}`,c=[{id:"tilt",label:"Tilt",value:`<svg preserveAspectRatio="none" viewBox="0 0 240 24">
|
|
709
709
|
<path d="M240 24V0L0 24h240z"/>
|
|
710
710
|
</svg>`},{id:"tilt-split",label:"Tilt split",value:`<svg preserveAspectRatio="none" viewBox="0 0 240 24">
|
|
711
711
|
<path fill-opacity=".3" d="M240 24V0L0 24h240z"/>
|
|
@@ -801,7 +801,7 @@
|
|
|
801
801
|
.${a}-inv > path {
|
|
802
802
|
transform: scale(-1, -1) translate(-100%, -100%);
|
|
803
803
|
}
|
|
804
|
-
`,traits:[{type:"select",name:h,label:"Shape",changeProp:!0,options:c.map(({id:y,label:v,value:w})=>({id:y,label:v,icon:{icon:w.replace("<svg ",'<svg style="width: 35px; height: 7px; fill: currentColor;"')}}))},{type:"checkbox",name:f,label:"Flip vertically",changeProp:!0},{type:"checkbox",name:m,label:"flip horizontally",changeProp:!0}]},init(){this.on(`change:${h}`,this.onShapeChange),this.on(`change:${m} change:${f}`,this.onFlip),this.onShapeChange()},onShapeChange(){const y=this.get(h),v=c.find(S=>S.id===y),w=(v==null?void 0:v.value)||this.getInnerHTML().trim();this.components(""),w&&this.set("content",w)},onFlip(){const y=this.get(f),v=this.get(m),w=["fl-v","fl-h","fl-v-h"].map(x=>`${a}--${x}`);let S;y&&v?S=w[2]:v?S=w[1]:y&&(S=w[0]),this.removeClass(w),S&&this.addClass(S),this.set("resizable",y?u:p)}}}),
|
|
804
|
+
`,traits:[{type:"select",name:h,label:"Shape",changeProp:!0,options:c.map(({id:y,label:v,value:w})=>({id:y,label:v,icon:{icon:w.replace("<svg ",'<svg style="width: 35px; height: 7px; fill: currentColor;"')}}))},{type:"checkbox",name:f,label:"Flip vertically",changeProp:!0},{type:"checkbox",name:m,label:"flip horizontally",changeProp:!0}]},init(){this.on(`change:${h}`,this.onShapeChange),this.on(`change:${m} change:${f}`,this.onFlip),this.onShapeChange()},onShapeChange(){const y=this.get(h),v=c.find(S=>S.id===y),w=(v==null?void 0:v.value)||this.getInnerHTML().trim();this.components(""),w&&this.set("content",w)},onFlip(){const y=this.get(f),v=this.get(m),w=["fl-v","fl-h","fl-v-h"].map(x=>`${a}--${x}`);let S;y&&v?S=w[2]:v?S=w[1]:y&&(S=w[0]),this.removeClass(w),S&&this.addClass(S),this.set("resizable",y?u:p)}}}),j({editor:n,licenseKey:e.licenseKey,plan:Yh,pluginName:Zh,cleanup:()=>{t.removeType(i),o.remove(i)}})}),Qh=n=>n.dispatchEvent(new CustomEvent("input")),ef=(n,e)=>{if(!e)return()=>{};const t="keydown",o=i=>{var r;i.key==="Escape"&&((r=n.getEditing())==null||r.trigger("disable"))},s=()=>document.removeEventListener(t,o);return n.onReady(()=>{document.addEventListener(t,o),n.on(n.events.destroy,s)}),s};function Hl(n,e){if(!e)return()=>{};const t=n.Components.events,o=d=>n.getSelectedAll().includes(d),s=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),i=d=>d.isChildOf("text"),r=d=>n.getEditing()===d,l=(d,p={})=>{d.trigger("focus",p.event)},a=(d,p)=>{o(d)&&s(d)&&!r(d)&&l(d,p)},c=(d,p)=>{if(o(d)&&!s(d)&&i(d)){const u=d.parents().find(h=>h.isInstanceOf("text"));u&&(l(u,p),setTimeout(()=>n.select(u),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const tf="rteTinyMce",nf=F.startup,of=`
|
|
805
805
|
.tox .tox-toolbar,
|
|
806
806
|
.tox .tox-toolbar__overflow,
|
|
807
807
|
.tox .tox-toolbar__primary,
|
|
@@ -904,7 +904,7 @@
|
|
|
904
904
|
background-color: var(--gs-theme-cl-prm-bg1);
|
|
905
905
|
border-color: var(--gs-theme-cl-prm-bg3);
|
|
906
906
|
opacity: 0.75;
|
|
907
|
-
}`,ti=new WeakMap,sf=(n,e)=>{ti.set(n,e)},rf=n=>{ti.delete(n)},ni=n=>ti.get(n),Do=n=>{const e=n.target,t=e.closest(".tox"),o=e.matches(".ephox-snooker-resizer-bar");(t||o)&&n.stopPropagation()},Fl=n=>{n.stopPropagation(),n.preventDefault()},lf=(n,e)=>{const t=n.getDoc(),o=n.getWin();if(e!=null&&e.event){const{event:s}=e,{clientX:i,clientY:r}=s;let l;if(t.caretRangeFromPoint)l=t.caretRangeFromPoint(i,r);else if(t.caretPositionFromPoint){const a=t.caretPositionFromPoint(i,r);l=t.createRange(),l==null||l.setStart(a.offsetNode,a.offset)}if(l){const a=o.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(l),n.selection.setRng(l)}}else n.execCommand("SelectAll")},af=n=>{var c,d;const{el:e,editor:t,componentView:o}=n,s=t.runCommand(j.getStateTheme),i=o.model,r={target:e,inline:!0,skin:(s==null?void 0:s.theme)===Or.dark?"oxide-dark":"oxide",menubar:!1,image_advtab:!0,paste_data_images:!0,statusbar:!1,branding:!1,forced_root_block:"div",plugins:"advlist autolink lists link image media table",toolbar_mode:"sliding",toolbar:"bold italic underline strikethrough forecolor backcolor alignleft aligncenter alignright alignjustify link image | fontfamily fontsize bullist numlist outdent indent table"},l=((d=(c=n.pluginOpts)==null?void 0:c.loadConfig)==null?void 0:d.call(c,{config:r,editor:t,componentView:o,component:i}))||{};return{...r,...l}},_l=(n,e=document)=>new Promise((t,o)=>{const s=Array.isArray(n)?[...n]:[n],{head:i}=e,r=l=>{if(l.length){const a=e.createElement("script");a.src=l.shift(),a.onload=r.bind(null,l),a.onerror=o,i.appendChild(a)}else t()};r(s)}),cf=G(function(n,e={}){const t={cdnScript:"https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",...e},{cdnScript:o}=t,s=n.Canvas.events,i=!t.skipCustomTheme,r="gs-plg-tinymce-studio-theme",l=async(d,p)=>{const u=d.ownerDocument,h=u.defaultView,f=p==null?void 0:p.view;if(!h||!f){console.warn("Missing required data",{win:h,componentView:f});return}const m=af({el:d,editor:n,componentView:f,pluginOpts:t}),b=(await h.tinymce.init(m))[0];if(!b)return;const y=(await window.tinymce.init({...m,target:document.createElement("div")}))[0];return b.ui.show(),u.body.addEventListener("mousedown",Do),document.body.addEventListener("mousedown",Do),b.on("Change",()=>Qh(d)),b.on("blur",()=>b.ui.show()),b.on("OpenWindow",function(){var S;const v=(S=u.querySelector(".tox-dialog"))==null?void 0:S.closest(".tox");v&&(v==null?void 0:v.ownerDocument)!==document&&(document.body.appendChild(v),b.once("CloseWindow",()=>{v&&v.ownerDocument===document&&u.body.appendChild(v)}))}),d.addEventListener("dragstart",Fl,{capture:!0}),n.runCommand(j.setStateContextMenu,{enabled:!1}),lf(b,p),{rteEditor:b,rteEditorShallow:y}},a=(d,p)=>{d.ownerDocument.body.removeEventListener("mousedown",Do),document.body.removeEventListener("mousedown",Do),d.removeEventListener("dragstart",Fl,{capture:!0}),n.runCommand(j.setStateContextMenu,{enabled:!0}),p.rteEditor.destroy(),p.rteEditorShallow.destroy()};n.on(s.frameLoad,async({window:d})=>{const p=d.document;_l(o,p)}),n.onReady(()=>{_l(o,document),i&&As(r,of,{target:document.body})}),n.setCustomRte({parseContent:!0,async enable(d,p,u){const h=ni(d);if(h)return h.rteEditor;const f=await l(d,u);return f&&sf(d,f),f==null?void 0:f.rteEditor},disable(d){const p=ni(d);p&&(rf(d),a(d,p))},getContent(d,p,u){var m;const h=ni(d),f=h==null?void 0:h.rteEditor;return f&&!f.isDirty()?u.view.lastContent:f?(m=f.getContent)==null?void 0:m.call(f):d.innerHTML}});const c=Hl(n,t.enableOnClick);W({editor:n,licenseKey:t.licenseKey,plan:nf,pluginName:tf,cleanup:()=>{n.RichTextEditor.customRte=void 0,c()}})});function Q(n){this.content=n}Q.prototype={constructor:Q,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var o=t&&t!=n?this.remove(t):this,s=o.find(n),i=o.content.slice();return s==-1?i.push(t||n,e):(i[s+1]=e,t&&(i[s]=t)),new Q(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Q(t)},addToStart:function(n,e){return new Q([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Q(t)},addBefore:function(n,e,t){var o=this.remove(e),s=o.content.slice(),i=o.find(n);return s.splice(i==-1?s.length:i,0,e,t),new Q(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=Q.from(n),n.size?new Q(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Q.from(n),n.size?new Q(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Q.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}},Q.from=function(n){if(n instanceof Q)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Q(e)};function Gl(n,e,t){for(let o=0;;o++){if(o==n.childCount||o==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(o),i=e.child(o);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){for(let r=0;s.text[r]==i.text[r];r++)t++;return t}if(s.content.size||i.content.size){let r=Gl(s.content,i.content,t+1);if(r!=null)return r}t+=s.nodeSize}}function Wl(n,e,t,o){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:o};let r=n.child(--s),l=e.child(--i),a=r.nodeSize;if(r==l){t-=a,o-=a;continue}if(!r.sameMarkup(l))return{a:t,b:o};if(r.isText&&r.text!=l.text){let c=0,d=Math.min(r.text.length,l.text.length);for(;c<d&&r.text[r.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,o--;return{a:t,b:o}}if(r.content.size||l.content.size){let c=Wl(r.content,l.content,t-1,o-1);if(c)return c}t-=a,o-=a}}class T{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let o=0;o<e.length;o++)this.size+=e[o].nodeSize}nodesBetween(e,t,o,s=0,i){for(let r=0,l=0;l<t;r++){let a=this.content[r],c=l+a.nodeSize;if(c>e&&o(a,s+l,i||null,r)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),o,s+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,o,s){let i="",r=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&o&&(r?r=!1:i+=o),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,o=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(o)&&(s[s.length-1]=t.withText(t.text+o.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new T(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let o=[],s=0;if(t>e)for(let i=0,r=0;r<t;i++){let l=this.content[i],a=r+l.nodeSize;a>e&&((r<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-r),Math.min(l.text.length,t-r)):l=l.cut(Math.max(0,e-r-1),Math.min(l.content.size,t-r-1))),o.push(l),s+=l.nodeSize),r=a}return new T(o,s)}cutByIndex(e,t){return e==t?T.empty:e==0&&t==this.content.length?this:new T(this.content.slice(e,t))}replaceChild(e,t){let o=this.content[e];if(o==t)return this;let s=this.content.slice(),i=this.size+t.nodeSize-o.nodeSize;return s[e]=t,new T(s,i)}addToStart(e){return new T([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new T(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,o=0;t<this.content.length;t++){let s=this.content[t];e(s,o,t),o+=s.nodeSize}}findDiffStart(e,t=0){return Gl(this,e,t)}findDiffEnd(e,t=this.size,o=e.size){return Wl(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 i=this.child(o),r=s+i.nodeSize;if(r>=e)return r==e||t>0?Lo(o+1,r):Lo(o,s);s=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return T.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new T(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return T.empty;let t,o=0;for(let s=0;s<e.length;s++){let i=e[s];o+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(t||(t=e.slice(0,s)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new T(t||e,o)}static from(e){if(!e)return T.empty;if(e instanceof T)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new T([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}T.empty=new T([],0);const oi={index:0,offset:0};function Lo(n,e){return oi.index=n,oi.offset=e,oi}function $o(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(!$o(n[o],e[o]))return!1}else{for(let o in n)if(!(o in e)||!$o(n[o],e[o]))return!1;for(let o in e)if(!(o in n))return!1}return!0}class H{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,o=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!o&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),o=!0),t&&t.push(i)}}return t||(t=e.slice()),o||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&$o(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 H.none;if(e instanceof H)return[e];let t=e.slice();return t.sort((o,s)=>o.type.rank-s.type.rank),t}}H.none=[];class zo 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=ql(this.content,e+this.openStart,t);return o&&new A(o,this.openStart,this.openEnd)}removeBetween(e,t){return new A(jl(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return A.empty;let o=t.openStart||0,s=t.openEnd||0;if(typeof o!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new A(T.fromJSON(e,t.content),o,s)}static maxOpen(e,t=!0){let o=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)o++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new A(e,o,s)}}A.empty=new A(T.empty,0,0);function jl(n,e,t){let{index:o,offset:s}=n.findIndex(e),i=n.maybeChild(o),{index:r,offset:l}=n.findIndex(t);if(s==e||i.isText){if(l!=t&&!n.child(r).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(o!=r)throw new RangeError("Removing non-flat range");return n.replaceChild(o,i.copy(jl(i.content,e-s-1,t-s-1)))}function ql(n,e,t,o){let{index:s,offset:i}=n.findIndex(e),r=n.maybeChild(s);if(i==e||r.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=ql(r.content,e-i-1,t);return l&&n.replaceChild(s,r.copy(l))}function df(n,e,t){if(t.openStart>n.depth)throw new zo("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new zo("Inconsistent open depths");return Ul(n,e,t,0)}function Ul(n,e,t,o){let s=n.index(o),i=n.node(o);if(s==e.index(o)&&o<n.depth-t.openStart){let r=Ul(n,e,t,o+1);return i.copy(i.content.replaceChild(s,r))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==o&&e.depth==o){let r=n.parent,l=r.content;return Nt(r,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:r,end:l}=pf(t,n);return Nt(i,Jl(n,r,l,e,o))}else return Nt(i,Bo(n,e,o))}function Kl(n,e){if(!e.type.compatibleContent(n.type))throw new zo("Cannot join "+e.type.name+" onto "+n.type.name)}function si(n,e,t){let o=n.node(t);return Kl(o,e.node(t)),o}function Pt(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 Ln(n,e,t,o){let s=(e||n).node(t),i=0,r=e?e.index(t):s.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(Pt(n.nodeAfter,o),i++));for(let l=i;l<r;l++)Pt(s.child(l),o);e&&e.depth==t&&e.textOffset&&Pt(e.nodeBefore,o)}function Nt(n,e){return n.type.checkContent(e),n.copy(e)}function Jl(n,e,t,o,s){let i=n.depth>s&&si(n,e,s+1),r=o.depth>s&&si(t,o,s+1),l=[];return Ln(null,n,s,l),i&&r&&e.index(s)==t.index(s)?(Kl(i,r),Pt(Nt(i,Jl(n,e,t,o,s+1)),l)):(i&&Pt(Nt(i,Bo(n,e,s+1)),l),Ln(e,t,s,l),r&&Pt(Nt(r,Bo(t,o,s+1)),l)),Ln(o,null,s,l),new T(l)}function Bo(n,e,t){let o=[];if(Ln(null,n,t,o),n.depth>t){let s=si(n,e,t+1);Pt(Nt(s,Bo(n,e,t+1)),o)}return Ln(e,null,t,o),new T(o)}function pf(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)s=e.node(i).copy(T.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class $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 i=0;i<e;i++)s+=o.child(i).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return H.none;if(this.textOffset)return e.child(t).marks;let o=e.maybeChild(t-1),s=e.maybeChild(t);if(!o){let l=o;o=s,s=l}let i=o.marks;for(var r=0;r<i.length;r++)i[r].type.spec.inclusive===!1&&(!s||!i[r].isInSet(s.marks))&&(i=i[r--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let o=t.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!s||!o[i].isInSet(s.marks))&&(o=o[i--].removeFromSet(o));return o}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let o=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);o>=0;o--)if(e.pos<=this.end(o)&&(!t||t(this.node(o))))return new Vo(this,e,o);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let o=[],s=0,i=t;for(let r=e;;){let{index:l,offset:a}=r.content.findIndex(i),c=i-a;if(o.push(r,l,s+a),!c||(r=r.child(l),r.isText))break;i=c-1,s+=a+1}return new $n(t,o,i)}static resolveCached(e,t){let o=Zl.get(e);if(o)for(let i=0;i<o.elts.length;i++){let r=o.elts[i];if(r.pos==t)return r}else Zl.set(e,o=new uf);let s=o.elts[o.i]=$n.resolve(e,t);return o.i=(o.i+1)%hf,s}}class uf{constructor(){this.elts=[],this.i=0}}const hf=12,Zl=new WeakMap;class Vo{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 ff=Object.create(null);let Ot=class Er{constructor(e,t,o,s=H.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&&$o(this.attrs,t||e.defaultAttrs||ff)&&H.sameSet(this.marks,o||H.none)}copy(e=null){return e==this.content?this:new Er(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Er(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,o=!1){if(e==t)return A.empty;let s=this.resolve(e),i=this.resolve(t),r=o?0:s.sharedDepth(t),l=s.start(r),c=s.node(r).content.cut(s.pos-l,i.pos-l);return new A(c,s.depth-r,i.depth-r)}replace(e,t,o){return df(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,i=>(o.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Yl(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,o=T.empty,s=0,i=o.childCount){let r=this.contentMatchAt(e).matchFragment(o,s,i),l=r&&r.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<i;a++)if(!this.type.allowsMarks(o.child(a).marks))return!1;return!0}canReplaceWith(e,t,o,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(o),r=i&&i.matchFragment(this.content,t);return r?r.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=H.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(!H.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let o;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");o=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,o)}let s=T.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,s,o);return i.type.checkAttrs(i.attrs),i}};Ot.prototype.text=void 0;class Ho extends Ot{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):Yl(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 Ho(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Ho(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 Yl(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class It{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let o=new mf(e,t);if(o.next==null)return It.empty;let s=Xl(o);o.next&&o.err("Unexpected trailing text");let i=wf(xf(s));return Cf(i,o),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,o=e.childCount){let s=this;for(let i=t;s&&i<o;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let o=0;o<e.next.length;o++)if(this.next[t].type==e.next[o].type)return!0;return!1}fillBefore(e,t=!1,o=0){let s=[this];function i(r,l){let a=r.matchFragment(e,o);if(a&&(!t||a.validEnd))return T.from(l.map(c=>c.createAndFill()));for(let c=0;c<r.next.length;c++){let{type:d,next:p}=r.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(p)==-1){s.push(p);let u=i(p,l.concat(d));if(u)return u}}return null}return i(this,[])}findWrapping(e){for(let o=0;o<this.wrapCache.length;o+=2)if(this.wrapCache[o]==e)return this.wrapCache[o+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),o=[{match:this,type:null,via:null}];for(;o.length;){let s=o.shift(),i=s.match;if(i.matchType(e)){let r=[];for(let l=s;l.type;l=l.via)r.push(l.type);return r.reverse()}for(let r=0;r<i.next.length;r++){let{type:l,next:a}=i.next[r];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(o.push({match:l.contentMatch,type:l,via:s}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(o){e.push(o);for(let s=0;s<o.next.length;s++)e.indexOf(o.next[s].next)==-1&&t(o.next[s].next)}return t(this),e.map((o,s)=>{let i=s+(o.validEnd?"*":" ")+" ";for(let r=0;r<o.next.length;r++)i+=(r?", ":"")+o.next[r].type.name+"->"+e.indexOf(o.next[r].next);return i}).join(`
|
|
907
|
+
}`,ti=new WeakMap,sf=(n,e)=>{ti.set(n,e)},rf=n=>{ti.delete(n)},ni=n=>ti.get(n),Do=n=>{const e=n.target,t=e.closest(".tox"),o=e.matches(".ephox-snooker-resizer-bar");(t||o)&&n.stopPropagation()},Fl=n=>{n.stopPropagation(),n.preventDefault()},lf=(n,e)=>{const t=n.getDoc(),o=n.getWin();if(e!=null&&e.event){const{event:s}=e,{clientX:i,clientY:r}=s;let l;if(t.caretRangeFromPoint)l=t.caretRangeFromPoint(i,r);else if(t.caretPositionFromPoint){const a=t.caretPositionFromPoint(i,r);l=t.createRange(),l==null||l.setStart(a.offsetNode,a.offset)}if(l){const a=o.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(l),n.selection.setRng(l)}}else n.execCommand("SelectAll")},af=n=>{var c,d;const{el:e,editor:t,componentView:o}=n,s=t.runCommand(_.getStateTheme),i=o.model,r={target:e,inline:!0,skin:(s==null?void 0:s.theme)===Or.dark?"oxide-dark":"oxide",menubar:!1,image_advtab:!0,paste_data_images:!0,statusbar:!1,branding:!1,forced_root_block:"div",plugins:"advlist autolink lists link image media table",toolbar_mode:"sliding",toolbar:"bold italic underline strikethrough forecolor backcolor alignleft aligncenter alignright alignjustify link image | fontfamily fontsize bullist numlist outdent indent table"},l=((d=(c=n.pluginOpts)==null?void 0:c.loadConfig)==null?void 0:d.call(c,{config:r,editor:t,componentView:o,component:i}))||{};return{...r,...l}},_l=(n,e=document)=>new Promise((t,o)=>{const s=Array.isArray(n)?[...n]:[n],{head:i}=e,r=l=>{if(l.length){const a=e.createElement("script");a.src=l.shift(),a.onload=r.bind(null,l),a.onerror=o,i.appendChild(a)}else t()};r(s)}),cf=W(function(n,e={}){const t={cdnScript:"https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",...e},{cdnScript:o}=t,s=n.Canvas.events,i=!t.skipCustomTheme,r="gs-plg-tinymce-studio-theme",l=async(d,p)=>{const u=d.ownerDocument,h=u.defaultView,f=p==null?void 0:p.view;if(!h||!f){console.warn("Missing required data",{win:h,componentView:f});return}const m=af({el:d,editor:n,componentView:f,pluginOpts:t}),b=(await h.tinymce.init(m))[0];if(!b)return;const y=(await window.tinymce.init({...m,target:document.createElement("div")}))[0];return b.ui.show(),u.body.addEventListener("mousedown",Do),document.body.addEventListener("mousedown",Do),b.on("Change",()=>Qh(d)),b.on("blur",()=>b.ui.show()),b.on("OpenWindow",function(){var S;const v=(S=u.querySelector(".tox-dialog"))==null?void 0:S.closest(".tox");v&&(v==null?void 0:v.ownerDocument)!==document&&(document.body.appendChild(v),b.once("CloseWindow",()=>{v&&v.ownerDocument===document&&u.body.appendChild(v)}))}),d.addEventListener("dragstart",Fl,{capture:!0}),n.runCommand(_.setStateContextMenu,{enabled:!1}),lf(b,p),{rteEditor:b,rteEditorShallow:y}},a=(d,p)=>{d.ownerDocument.body.removeEventListener("mousedown",Do),document.body.removeEventListener("mousedown",Do),d.removeEventListener("dragstart",Fl,{capture:!0}),n.runCommand(_.setStateContextMenu,{enabled:!0}),p.rteEditor.destroy(),p.rteEditorShallow.destroy()};n.on(s.frameLoad,async({window:d})=>{const p=d.document;_l(o,p)}),n.onReady(()=>{_l(o,document),i&&As(r,of,{target:document.body})}),n.setCustomRte({parseContent:!0,async enable(d,p,u){const h=ni(d);if(h)return h.rteEditor;const f=await l(d,u);return f&&sf(d,f),f==null?void 0:f.rteEditor},disable(d){const p=ni(d);p&&(rf(d),a(d,p))},getContent(d,p,u){var m;const h=ni(d),f=h==null?void 0:h.rteEditor;return f&&!f.isDirty()?u.view.lastContent:f?(m=f.getContent)==null?void 0:m.call(f):d.innerHTML}});const c=Hl(n,t.enableOnClick);j({editor:n,licenseKey:t.licenseKey,plan:nf,pluginName:tf,cleanup:()=>{n.RichTextEditor.customRte=void 0,c()}})});function Q(n){this.content=n}Q.prototype={constructor:Q,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var o=t&&t!=n?this.remove(t):this,s=o.find(n),i=o.content.slice();return s==-1?i.push(t||n,e):(i[s+1]=e,t&&(i[s]=t)),new Q(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Q(t)},addToStart:function(n,e){return new Q([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Q(t)},addBefore:function(n,e,t){var o=this.remove(e),s=o.content.slice(),i=o.find(n);return s.splice(i==-1?s.length:i,0,e,t),new Q(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=Q.from(n),n.size?new Q(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Q.from(n),n.size?new Q(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Q.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}},Q.from=function(n){if(n instanceof Q)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Q(e)};function Gl(n,e,t){for(let o=0;;o++){if(o==n.childCount||o==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(o),i=e.child(o);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){for(let r=0;s.text[r]==i.text[r];r++)t++;return t}if(s.content.size||i.content.size){let r=Gl(s.content,i.content,t+1);if(r!=null)return r}t+=s.nodeSize}}function Wl(n,e,t,o){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:o};let r=n.child(--s),l=e.child(--i),a=r.nodeSize;if(r==l){t-=a,o-=a;continue}if(!r.sameMarkup(l))return{a:t,b:o};if(r.isText&&r.text!=l.text){let c=0,d=Math.min(r.text.length,l.text.length);for(;c<d&&r.text[r.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,o--;return{a:t,b:o}}if(r.content.size||l.content.size){let c=Wl(r.content,l.content,t-1,o-1);if(c)return c}t-=a,o-=a}}class T{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let o=0;o<e.length;o++)this.size+=e[o].nodeSize}nodesBetween(e,t,o,s=0,i){for(let r=0,l=0;l<t;r++){let a=this.content[r],c=l+a.nodeSize;if(c>e&&o(a,s+l,i||null,r)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),o,s+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,o,s){let i="",r=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&o&&(r?r=!1:i+=o),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,o=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(o)&&(s[s.length-1]=t.withText(t.text+o.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new T(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let o=[],s=0;if(t>e)for(let i=0,r=0;r<t;i++){let l=this.content[i],a=r+l.nodeSize;a>e&&((r<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-r),Math.min(l.text.length,t-r)):l=l.cut(Math.max(0,e-r-1),Math.min(l.content.size,t-r-1))),o.push(l),s+=l.nodeSize),r=a}return new T(o,s)}cutByIndex(e,t){return e==t?T.empty:e==0&&t==this.content.length?this:new T(this.content.slice(e,t))}replaceChild(e,t){let o=this.content[e];if(o==t)return this;let s=this.content.slice(),i=this.size+t.nodeSize-o.nodeSize;return s[e]=t,new T(s,i)}addToStart(e){return new T([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new T(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,o=0;t<this.content.length;t++){let s=this.content[t];e(s,o,t),o+=s.nodeSize}}findDiffStart(e,t=0){return Gl(this,e,t)}findDiffEnd(e,t=this.size,o=e.size){return Wl(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 i=this.child(o),r=s+i.nodeSize;if(r>=e)return r==e||t>0?Lo(o+1,r):Lo(o,s);s=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return T.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new T(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return T.empty;let t,o=0;for(let s=0;s<e.length;s++){let i=e[s];o+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(t||(t=e.slice(0,s)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new T(t||e,o)}static from(e){if(!e)return T.empty;if(e instanceof T)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new T([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}T.empty=new T([],0);const oi={index:0,offset:0};function Lo(n,e){return oi.index=n,oi.offset=e,oi}function $o(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(!$o(n[o],e[o]))return!1}else{for(let o in n)if(!(o in e)||!$o(n[o],e[o]))return!1;for(let o in e)if(!(o in n))return!1}return!0}class H{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,o=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!o&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),o=!0),t&&t.push(i)}}return t||(t=e.slice()),o||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&$o(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 H.none;if(e instanceof H)return[e];let t=e.slice();return t.sort((o,s)=>o.type.rank-s.type.rank),t}}H.none=[];class zo 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=ql(this.content,e+this.openStart,t);return o&&new A(o,this.openStart,this.openEnd)}removeBetween(e,t){return new A(jl(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return A.empty;let o=t.openStart||0,s=t.openEnd||0;if(typeof o!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new A(T.fromJSON(e,t.content),o,s)}static maxOpen(e,t=!0){let o=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)o++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new A(e,o,s)}}A.empty=new A(T.empty,0,0);function jl(n,e,t){let{index:o,offset:s}=n.findIndex(e),i=n.maybeChild(o),{index:r,offset:l}=n.findIndex(t);if(s==e||i.isText){if(l!=t&&!n.child(r).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(o!=r)throw new RangeError("Removing non-flat range");return n.replaceChild(o,i.copy(jl(i.content,e-s-1,t-s-1)))}function ql(n,e,t,o){let{index:s,offset:i}=n.findIndex(e),r=n.maybeChild(s);if(i==e||r.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=ql(r.content,e-i-1,t);return l&&n.replaceChild(s,r.copy(l))}function df(n,e,t){if(t.openStart>n.depth)throw new zo("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new zo("Inconsistent open depths");return Ul(n,e,t,0)}function Ul(n,e,t,o){let s=n.index(o),i=n.node(o);if(s==e.index(o)&&o<n.depth-t.openStart){let r=Ul(n,e,t,o+1);return i.copy(i.content.replaceChild(s,r))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==o&&e.depth==o){let r=n.parent,l=r.content;return Nt(r,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:r,end:l}=pf(t,n);return Nt(i,Jl(n,r,l,e,o))}else return Nt(i,Bo(n,e,o))}function Kl(n,e){if(!e.type.compatibleContent(n.type))throw new zo("Cannot join "+e.type.name+" onto "+n.type.name)}function si(n,e,t){let o=n.node(t);return Kl(o,e.node(t)),o}function Pt(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 Ln(n,e,t,o){let s=(e||n).node(t),i=0,r=e?e.index(t):s.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(Pt(n.nodeAfter,o),i++));for(let l=i;l<r;l++)Pt(s.child(l),o);e&&e.depth==t&&e.textOffset&&Pt(e.nodeBefore,o)}function Nt(n,e){return n.type.checkContent(e),n.copy(e)}function Jl(n,e,t,o,s){let i=n.depth>s&&si(n,e,s+1),r=o.depth>s&&si(t,o,s+1),l=[];return Ln(null,n,s,l),i&&r&&e.index(s)==t.index(s)?(Kl(i,r),Pt(Nt(i,Jl(n,e,t,o,s+1)),l)):(i&&Pt(Nt(i,Bo(n,e,s+1)),l),Ln(e,t,s,l),r&&Pt(Nt(r,Bo(t,o,s+1)),l)),Ln(o,null,s,l),new T(l)}function Bo(n,e,t){let o=[];if(Ln(null,n,t,o),n.depth>t){let s=si(n,e,t+1);Pt(Nt(s,Bo(n,e,t+1)),o)}return Ln(e,null,t,o),new T(o)}function pf(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)s=e.node(i).copy(T.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class $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 i=0;i<e;i++)s+=o.child(i).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return H.none;if(this.textOffset)return e.child(t).marks;let o=e.maybeChild(t-1),s=e.maybeChild(t);if(!o){let l=o;o=s,s=l}let i=o.marks;for(var r=0;r<i.length;r++)i[r].type.spec.inclusive===!1&&(!s||!i[r].isInSet(s.marks))&&(i=i[r--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let o=t.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!s||!o[i].isInSet(s.marks))&&(o=o[i--].removeFromSet(o));return o}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let o=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);o>=0;o--)if(e.pos<=this.end(o)&&(!t||t(this.node(o))))return new Vo(this,e,o);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let o=[],s=0,i=t;for(let r=e;;){let{index:l,offset:a}=r.content.findIndex(i),c=i-a;if(o.push(r,l,s+a),!c||(r=r.child(l),r.isText))break;i=c-1,s+=a+1}return new $n(t,o,i)}static resolveCached(e,t){let o=Zl.get(e);if(o)for(let i=0;i<o.elts.length;i++){let r=o.elts[i];if(r.pos==t)return r}else Zl.set(e,o=new uf);let s=o.elts[o.i]=$n.resolve(e,t);return o.i=(o.i+1)%hf,s}}class uf{constructor(){this.elts=[],this.i=0}}const hf=12,Zl=new WeakMap;class Vo{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 ff=Object.create(null);let Ot=class Er{constructor(e,t,o,s=H.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&&$o(this.attrs,t||e.defaultAttrs||ff)&&H.sameSet(this.marks,o||H.none)}copy(e=null){return e==this.content?this:new Er(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Er(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,o=!1){if(e==t)return A.empty;let s=this.resolve(e),i=this.resolve(t),r=o?0:s.sharedDepth(t),l=s.start(r),c=s.node(r).content.cut(s.pos-l,i.pos-l);return new A(c,s.depth-r,i.depth-r)}replace(e,t,o){return df(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,i=>(o.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Yl(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,o=T.empty,s=0,i=o.childCount){let r=this.contentMatchAt(e).matchFragment(o,s,i),l=r&&r.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<i;a++)if(!this.type.allowsMarks(o.child(a).marks))return!1;return!0}canReplaceWith(e,t,o,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(o),r=i&&i.matchFragment(this.content,t);return r?r.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=H.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(!H.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let o;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");o=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,o)}let s=T.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,s,o);return i.type.checkAttrs(i.attrs),i}};Ot.prototype.text=void 0;class Ho extends Ot{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):Yl(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 Ho(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Ho(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 Yl(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class It{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let o=new mf(e,t);if(o.next==null)return It.empty;let s=Xl(o);o.next&&o.err("Unexpected trailing text");let i=wf(xf(s));return Cf(i,o),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,o=e.childCount){let s=this;for(let i=t;s&&i<o;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let o=0;o<e.next.length;o++)if(this.next[t].type==e.next[o].type)return!0;return!1}fillBefore(e,t=!1,o=0){let s=[this];function i(r,l){let a=r.matchFragment(e,o);if(a&&(!t||a.validEnd))return T.from(l.map(c=>c.createAndFill()));for(let c=0;c<r.next.length;c++){let{type:d,next:p}=r.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(p)==-1){s.push(p);let u=i(p,l.concat(d));if(u)return u}}return null}return i(this,[])}findWrapping(e){for(let o=0;o<this.wrapCache.length;o+=2)if(this.wrapCache[o]==e)return this.wrapCache[o+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),o=[{match:this,type:null,via:null}];for(;o.length;){let s=o.shift(),i=s.match;if(i.matchType(e)){let r=[];for(let l=s;l.type;l=l.via)r.push(l.type);return r.reverse()}for(let r=0;r<i.next.length;r++){let{type:l,next:a}=i.next[r];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(o.push({match:l.contentMatch,type:l,via:s}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(o){e.push(o);for(let s=0;s<o.next.length;s++)e.indexOf(o.next[s].next)==-1&&t(o.next[s].next)}return t(this),e.map((o,s)=>{let i=s+(o.validEnd?"*":" ")+" ";for(let r=0;r<o.next.length;r++)i+=(r?", ":"")+o.next[r].type.name+"->"+e.indexOf(o.next[r].next);return i}).join(`
|
|
908
908
|
`)}}It.empty=new It(!0);class mf{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Xl(n){let e=[];do e.push(gf(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function gf(n){let e=[];do e.push(yf(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function yf(n){let e=Sf(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=bf(n,e);else break;return e}function Ql(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function bf(n,e){let t=Ql(n),o=t;return n.eat(",")&&(n.next!="}"?o=Ql(n):o=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:o,expr:e}}function vf(n,e){let t=n.nodeTypes,o=t[e];if(o)return[o];let s=[];for(let i in t){let r=t[i];r.isInGroup(e)&&s.push(r)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function Sf(n){if(n.eat("(")){let e=Xl(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=vf(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 xf(n){let e=[[]];return s(i(n,0),t()),e;function t(){return e.push([])-1}function o(r,l,a){let c={term:a,to:l};return e[r].push(c),c}function s(r,l){r.forEach(a=>a.to=l)}function i(r,l){if(r.type=="choice")return r.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(r.type=="seq")for(let a=0;;a++){let c=i(r.exprs[a],l);if(a==r.exprs.length-1)return c;s(c,l=t())}else if(r.type=="star"){let a=t();return o(l,a),s(i(r.expr,a),a),[o(a)]}else if(r.type=="plus"){let a=t();return s(i(r.expr,l),a),s(i(r.expr,a),a),[o(a)]}else{if(r.type=="opt")return[o(l)].concat(i(r.expr,l));if(r.type=="range"){let a=l;for(let c=0;c<r.min;c++){let d=t();s(i(r.expr,a),d),a=d}if(r.max==-1)s(i(r.expr,a),a);else for(let c=r.min;c<r.max;c++){let d=t();o(a,d),s(i(r.expr,a),d),a=d}return[o(a)]}else{if(r.type=="name")return[o(l,void 0,r.value)];throw new Error("Unknown expr type")}}}}function ea(n,e){return e-n}function ta(n,e){let t=[];return o(e),t.sort(ea);function o(s){let i=n[s];if(i.length==1&&!i[0].term)return o(i[0].to);t.push(s);for(let r=0;r<i.length;r++){let{term:l,to:a}=i[r];!l&&t.indexOf(a)==-1&&o(a)}}}function wf(n){let e=Object.create(null);return t(ta(n,0));function t(o){let s=[];o.forEach(r=>{n[r].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<s.length;d++)s[d][0]==l&&(c=s[d][1]);ta(n,a).forEach(d=>{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[o.join(",")]=new It(o.indexOf(n.length-1)>-1);for(let r=0;r<s.length;r++){let l=s[r][1].sort(ea);i.next.push({type:s[r][0],next:e[l.join(",")]||t(l)})}return i}}function Cf(n,e){for(let t=0,o=[n];t<o.length;t++){let s=o[t],i=!s.validEnd,r=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];r.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),o.indexOf(c)==-1&&o.push(c)}i&&e.err("Only non-generatable nodes ("+r.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function na(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 oa(n,e){let t=Object.create(null);for(let o in n){let s=e&&e[o];if(s===void 0){let i=n[o];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+o)}t[o]=s}return t}function sa(n,e,t,o){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let i=n[s];i.validate&&i.validate(e[s])}}function ia(n,e){let t=Object.create(null);if(e)for(let o in e)t[o]=new Ef(n,o,e[o]);return t}let ra=class Ep{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=ia(e,o.attrs),this.defaultAttrs=na(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==It.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:oa(this.attrs,e)}create(e=null,t,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ot(this,this.computeAttrs(e),T.from(t),H.setFrom(o))}createChecked(e=null,t,o){return t=T.from(t),this.checkContent(t),new Ot(this,this.computeAttrs(e),t,H.setFrom(o))}createAndFill(e=null,t,o){if(e=this.computeAttrs(e),t=T.from(t),t.size){let r=this.contentMatch.fillBefore(t);if(!r)return null;t=r.append(t)}let s=this.contentMatch.matchFragment(t),i=s&&s.fillBefore(T.empty,!0);return i?new Ot(this,e,t.append(i),H.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){sa(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:H.none:e}static compile(e,t){let o=Object.create(null);e.forEach((i,r)=>o[i]=new Ep(i,t,r));let s=t.spec.topNode||"doc";if(!o[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let i in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};function kf(n,e,t){let o=t.split("|");return s=>{let i=s===null?"null":typeof s;if(o.indexOf(i)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${n}, got ${i}`)}}class Ef{constructor(e,t,o){this.hasDefault=Object.prototype.hasOwnProperty.call(o,"default"),this.default=o.default,this.validate=typeof o.validate=="string"?kf(e,t,o.validate):o.validate}get isRequired(){return!this.hasDefault}}class Fo{constructor(e,t,o,s){this.name=e,this.rank=t,this.schema=o,this.spec=s,this.attrs=ia(e,s.attrs),this.excluded=null;let i=na(this.attrs);this.instance=i?new H(this,i):null}create(e=null){return!e&&this.instance?this.instance:new H(this,oa(this.attrs,e))}static compile(e,t){let o=Object.create(null),s=0;return e.forEach((i,r)=>o[i]=new Fo(i,s++,t,r)),o}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){sa(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Tf{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=Q.from(e.nodes),t.marks=Q.from(e.marks||{}),this.nodes=ra.compile(this.spec.nodes,this),this.marks=Fo.compile(this.spec.marks,this);let o=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],r=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=o[r]||(o[r]=It.parse(r,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?la(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],r=i.spec.excludes;i.excluded=r==null?[i]:r==""?[]:la(this,r.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,o,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof ra){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 Ho(o,o.defaultAttrs,e,H.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Ot.fromJSON(this,e)}markFromJSON(e){return H.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function la(n,e){let t=[];for(let o=0;o<e.length;o++){let s=e[o],i=n.marks[s],r=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(r=a)}if(!r)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return t}function Mf(n){return n.tag!=null}function Af(n){return n.style!=null}class Rt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let o=this.matchedStyles=[];t.forEach(s=>{if(Mf(s))this.tags.push(s);else if(Af(s)){let i=/[^=]*/.exec(s.style)[0];o.indexOf(i)<0&&o.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let o=new pa(this,t,!1);return o.addAll(e,H.none,t.from,t.to),o.finish()}parseSlice(e,t={}){let o=new pa(this,t,!0);return o.addAll(e,H.none,t.from,t.to),A.maxOpen(o.finish())}matchTag(e,t,o){for(let s=o?this.tags.indexOf(o)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(Of(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let r=i.getAttrs(e);if(r===!1)continue;i.attrs=r||void 0}return i}}}matchStyle(e,t,o,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let r=this.styles[i],l=r.style;if(!(l.indexOf(e)!=0||r.context&&!o.matchesContext(r.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(r.getAttrs){let a=r.getAttrs(t);if(a===!1)continue;r.attrs=a||void 0}return r}}}static schemaRules(e){let t=[];function o(s){let i=s.priority==null?50:s.priority,r=0;for(;r<t.length;r++){let l=t[r];if((l.priority==null?50:l.priority)<i)break}t.splice(r,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(r=>{o(r=ua(r)),r.mark||r.ignore||r.clearMark||(r.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(r=>{o(r=ua(r)),r.node||r.ignore||r.mark||(r.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Rt(e,Rt.schemaRules(e)))}}const aa={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},Pf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ca={ol:!0,ul:!0},_o=1,Go=2,zn=4;function da(n,e,t){return e!=null?(e?_o:0)|(e==="full"?Go:0):n&&n.whitespace=="pre"?_o|Go:t&~zn}class Wo{constructor(e,t,o,s,i,r){this.type=e,this.attrs=t,this.marks=o,this.solid=s,this.options=r,this.content=[],this.activeMarks=H.none,this.match=i||(r&zn?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 i=o;o.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let t=T.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(T.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!aa.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class pa{constructor(e,t,o){this.parser=e,this.options=t,this.isOpen=o,this.open=0;let s=t.topNode,i,r=da(null,t.preserveWhitespace,0)|(o?zn:0);s?i=new Wo(s.type,s.attrs,H.none,!0,t.topMatch||s.type.contentMatch,r):o?i=new Wo(null,null,H.none,!0,null,r):i=new Wo(e.schema.topNodeType,null,H.none,!0,null,r),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let o=e.nodeValue,s=this.top;if(s.options&Go||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(o)){if(s.options&_o)s.options&Go?o=o.replace(/\r\n?/g,`
|
|
909
909
|
`):o=o.replace(/\r?\n|\r/g," ");else if(o=o.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(o)&&this.open==this.nodes.length-1){let i=s.content[s.content.length-1],r=e.previousSibling;(!i||r&&r.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(o=o.slice(1))}o&&this.insertNode(this.parser.schema.text(o),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,o){let s=e.nodeName.toLowerCase(),i;ca.hasOwnProperty(s)&&this.parser.normalizeLists&&Nf(e);let r=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,o));if(r?r.ignore:Pf.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!r||r.skip||r.closeParent){r&&r.closeParent?this.open=Math.max(0,this.open-1):r&&r.skip.nodeType&&(e=r.skip);let l,a=this.top,c=this.needsBlock;if(aa.hasOwnProperty(s))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),l=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);return}let d=r&&r.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),l&&this.sync(a),this.needsBlock=c}else{let l=this.readStyles(e,t);l&&this.addElementByRule(e,r,l,r.consuming===!1?i:void 0)}}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
910
910
|
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let o=e.style;if(o&&o.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],r=o.getPropertyValue(i);if(r)for(let l=void 0;;){let a=this.parser.matchStyle(i,r,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,o,s){let i,r;if(t.node)if(r=this.parser.schema.nodes[t.node],r.isLeaf)this.insertNode(r.create(t.attrs),o)||this.leafFallback(e,o);else{let a=this.enter(r,t.attrs||null,o,t.preserveWhitespace);a&&(i=!0,o=a)}else{let a=this.parser.schema.marks[t.mark];o=o.concat(a.create(t.attrs))}let l=this.top;if(r&&r.isLeaf)this.findInside(e);else if(s)this.addElement(e,o,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,o));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,o),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,o,s){let i=o||0;for(let r=o?e.childNodes[o]:e.firstChild,l=s==null?null:e.childNodes[s];r!=l;r=r.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(r,t);this.findAtPoint(e,i)}findPlace(e,t){let o,s;for(let i=this.open;i>=0;i--){let r=this.nodes[i],l=r.findWrapping(e);if(l&&(!o||o.length>l.length)&&(o=l,s=r,!l.length)||r.solid)break}if(!o)return null;this.sync(s);for(let i=0;i<o.length;i++)t=this.enterInner(o[i],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let o=this.findPlace(e,t);if(o){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let i=H.none;for(let r of o.concat(e.marks))(s.type?s.type.allowsMarkType(r.type):ha(r.type,e.type))&&(i=r.addToSet(i));return s.content.push(e.mark(i)),!0}return!1}enter(e,t,o,s){let i=this.findPlace(e.create(t),o);return i&&(i=this.enterInner(e,t,o,!0,s)),i}enterInner(e,t,o,s=!1,i){this.closeExtra();let r=this.top;r.match=r.match&&r.match.matchType(e);let l=da(e,i,r.options);r.options&zn&&r.content.length==0&&(l|=zn);let a=H.none;return o=o.filter(c=>(r.type?r.type.allowsMarkType(c.type):ha(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Wo(e,t,a,s,null,l)),this.open++,o}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let o=this.nodes[t].content;for(let s=o.length-1;s>=0;s--)e+=o[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let o=0;o<this.find.length;o++)this.find[o].node==e&&this.find[o].offset==t&&(this.find[o].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,o){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(o?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),o=this.options.context,s=!this.isOpen&&(!o||o.parent.type==this.nodes[0].type),i=-(o?o.depth+1:0)+(s?0:1),r=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(r(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:o&&a>=i?o.node(a-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return r(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(o&&o.isTextblock&&o.defaultAttrs)return o}for(let t in this.parser.schema.nodes){let o=this.parser.schema.nodes[t];if(o.isTextblock&&o.defaultAttrs)return o}}}function Nf(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&ca.hasOwnProperty(o)&&t?(t.appendChild(e),e=t):o=="li"?t=e:o&&(t=null)}}function Of(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function ua(n){let e={};for(let t in n)e[t]=n[t];return e}function ha(n,e){let t=e.schema.nodes;for(let o in t){let s=t[o];if(!s.allowsMarkType(n))continue;let i=[],r=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||i.indexOf(d)<0&&r(d))return!0}};if(r(s.contentMatch))return!0}}class Dt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},o){o||(o=ii(t).createDocumentFragment());let s=o,i=[];return e.forEach(r=>{if(i.length||r.marks.length){let l=0,a=0;for(;l<i.length&&a<r.marks.length;){let c=r.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<r.marks.length;){let c=r.marks[a++],d=this.serializeMark(c,r.isInline,t);d&&(i.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(r,t))}),o}serializeNodeInner(e,t){let{dom:o,contentDOM:s}=jo(ii(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return o}serializeNode(e,t={}){let o=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(o),o=i.dom)}return o}serializeMark(e,t,o={}){let s=this.marks[e.type.name];return s&&jo(ii(o),s(e,t),null,e.attrs)}static renderSpec(e,t,o=null,s){return jo(e,t,o,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Dt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=fa(e.nodes);return t.text||(t.text=o=>o.text),t}static marksFromSchema(e){return fa(e.marks)}}function fa(n){let e={};for(let t in n){let o=n[t].spec.toDOM;o&&(e[t]=o)}return e}function ii(n){return n.document||window.document}const ma=new WeakMap;function If(n){let e=ma.get(n);return e===void 0&&ma.set(n,e=Rf(n)),e}function Rf(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 jo(n,e,t,o){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(o&&(i=If(o))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let r=s.indexOf(" ");r>0&&(t=s.slice(0,r),s=s.slice(r+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let p in c)if(c[p]!=null){let u=p.indexOf(" ");u>0?a.setAttributeNS(p.slice(0,u),p.slice(u+1),c[p]):a.setAttribute(p,c[p])}}for(let p=d;p<e.length;p++){let u=e[p];if(u===0){if(p<e.length-1||p>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:f}=jo(n,u,t,o);if(a.appendChild(h),f){if(l)throw new RangeError("Multiple content holes");l=f}}}return{dom:a,contentDOM:l}}const ga=65535,ya=Math.pow(2,16);function Df(n,e){return n+e*ya}function ba(n){return n&ga}function Lf(n){return(n-(n&ga))/ya}const va=1,Sa=2,qo=4,xa=8;class ri{constructor(e,t,o){this.pos=e,this.delInfo=t,this.recover=o}get deleted(){return(this.delInfo&xa)>0}get deletedBefore(){return(this.delInfo&(va|qo))>0}get deletedAfter(){return(this.delInfo&(Sa|qo))>0}get deletedAcross(){return(this.delInfo&qo)>0}}class Se{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Se.empty)return Se.empty}recover(e){let t=0,o=ba(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+Lf(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,o){let s=0,i=this.inverted?2:1,r=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],d=this.ranges[l+r],p=a+c;if(e<=p){let u=c?e==a?-1:e==p?1:t:t,h=a+s+(u<0?0:d);if(o)return h;let f=e==(t<0?a:p)?null:Df(l/3,e-a),m=e==a?Sa:e==p?va:qo;return(t<0?e!=a:e!=p)&&(m|=xa),new ri(h,m,f)}s+=d-c}return o?e+s:new ri(e+s,0,null)}touches(e,t){let o=0,s=ba(t),i=this.inverted?2:1,r=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==s*3)return!0;o+=this.ranges[l+r]-c}return!1}forEach(e){let t=this.inverted?2:1,o=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let r=this.ranges[s],l=r-(this.inverted?i:0),a=r+(this.inverted?0:i),c=this.ranges[s+t],d=this.ranges[s+o];e(l,l+c,a,a+d),i+=d-c}}invert(){return new Se(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Se.empty:new Se(e<0?[0,-e,0]:[0,0,e])}}Se.empty=new Se([]);class cn{constructor(e=[],t,o=0,s=e.length){this.maps=e,this.mirror=t,this.from=o,this.to=s}slice(e=0,t=this.maps.length){return new cn(this.maps,this.mirror,e,t)}copy(){return new cn(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,o=this.maps.length;t<e.maps.length;t++){let s=e.getMirror(t);this.appendMap(e.maps[t],s!=null&&s<t?o+s:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,o=this.maps.length+e.maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e.maps[t].invert(),s!=null&&s>t?o-s-1:void 0)}}invert(){let e=new cn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let o=this.from;o<this.to;o++)e=this.maps[o].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,o){let s=0;for(let i=this.from;i<this.to;i++){let r=this.maps[i],l=r.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this.maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return o?e:new ri(e,s,null)}}const li=Object.create(null);class oe{getMap(){return Se.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let o=li[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 li)throw new RangeError("Duplicate use of step JSON ID "+e);return li[e]=t,t.prototype.jsonID=e,t}}class K{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new K(e,null)}static fail(e){return new K(null,e)}static fromReplace(e,t,o,s){try{return K.ok(e.replace(t,o,s))}catch(i){if(i instanceof zo)return K.fail(i.message);throw i}}}function ai(n,e,t){let o=[];for(let s=0;s<n.childCount;s++){let i=n.child(s);i.content.size&&(i=i.copy(ai(i.content,e,i))),i.isInline&&(i=e(i,t,s)),o.push(i)}return T.fromArray(o)}class rt extends oe{constructor(e,t,o){super(),this.from=e,this.to=t,this.mark=o}apply(e){let t=e.slice(this.from,this.to),o=e.resolve(this.from),s=o.node(o.sharedDepth(this.to)),i=new A(ai(t.content,(r,l)=>!r.isAtom||!l.type.allowsMarkType(this.mark.type)?r:r.mark(this.mark.addToSet(r.marks)),s),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,i)}invert(){return new Ve(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 rt(t.pos,o.pos,this.mark)}merge(e){return e instanceof rt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new rt(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 rt(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("addMark",rt);class Ve extends oe{constructor(e,t,o){super(),this.from=e,this.to=t,this.mark=o}apply(e){let t=e.slice(this.from,this.to),o=new A(ai(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 rt(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 Ve(t.pos,o.pos,this.mark)}merge(e){return e instanceof Ve&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ve(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 Ve(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("removeMark",Ve);class lt extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return K.fromReplace(e,this.pos,this.pos+1,new A(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 lt(this.pos,t.marks[s]);return new lt(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 lt(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 lt(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("addNodeMark",lt);class dn extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return K.fromReplace(e,this.pos,this.pos+1,new A(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 lt(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))}}oe.jsonID("removeNodeMark",dn);class se extends oe{constructor(e,t,o,s=!1){super(),this.from=e,this.to=t,this.slice=o,this.structure=s}apply(e){return this.structure&&ci(e,this.from,this.to)?K.fail("Structure replace would overwrite content"):K.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Se([this.from,this.to-this.from,this.slice.size])}invert(e){return new se(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deletedAcross&&o.deletedAcross?null:new se(t.pos,Math.max(t.pos,o.pos),this.slice)}merge(e){if(!(e instanceof se)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?A.empty:new A(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new se(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?A.empty:new A(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new se(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new se(t.from,t.to,A.fromJSON(e,t.slice),!!t.structure)}}oe.jsonID("replace",se);class ee extends oe{constructor(e,t,o,s,i,r,l=!1){super(),this.from=e,this.to=t,this.gapFrom=o,this.gapTo=s,this.slice=i,this.insert=r,this.structure=l}apply(e){if(this.structure&&(ci(e,this.from,this.gapFrom)||ci(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 Se([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ee(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?o.pos:e.map(this.gapTo,1);return t.deletedAcross&&o.deletedAcross||s<t.pos||i>o.pos?null:new ee(t.pos,o.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ee(t.from,t.to,t.gapFrom,t.gapTo,A.fromJSON(e,t.slice),t.insert,!!t.structure)}}oe.jsonID("replaceAround",ee);function ci(n,e,t){let o=n.resolve(e),s=t-e,i=o.depth;for(;s>0&&i>0&&o.indexAfter(i)==o.node(i).childCount;)i--,s--;if(s>0){let r=o.node(i).maybeChild(o.indexAfter(i));for(;s>0;){if(!r||r.isLeaf)return!0;r=r.firstChild,s--}}return!1}function $f(n,e,t,o){let s=[],i=[],r,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let p=a.marks;if(!o.isInSet(p)&&d.type.allowsMarkType(o.type)){let u=Math.max(c,e),h=Math.min(c+a.nodeSize,t),f=o.addToSet(p);for(let m=0;m<p.length;m++)p[m].isInSet(f)||(r&&r.to==u&&r.mark.eq(p[m])?r.to=h:s.push(r=new Ve(u,h,p[m])));l&&l.to==u?l.to=h:i.push(l=new rt(u,h,o))}}),s.forEach(a=>n.step(a)),i.forEach(a=>n.step(a))}function zf(n,e,t,o){let s=[],i=0;n.doc.nodesBetween(e,t,(r,l)=>{if(!r.isInline)return;i++;let a=null;if(o instanceof Fo){let c=r.marks,d;for(;d=o.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else o?o.isInSet(r.marks)&&(a=[o]):a=r.marks;if(a&&a.length){let c=Math.min(l+r.nodeSize,t);for(let d=0;d<a.length;d++){let p=a[d],u;for(let h=0;h<s.length;h++){let f=s[h];f.step==i-1&&p.eq(s[h].style)&&(u=f)}u?(u.to=c,u.step=i):s.push({style:p,from:Math.max(l,e),to:c,step:i})}}}),s.forEach(r=>n.step(new Ve(r.from,r.to,r.style)))}function di(n,e,t,o=t.contentMatch,s=!0){let i=n.doc.nodeAt(e),r=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),d=l+c.nodeSize,p=o.matchType(c.type);if(!p)r.push(new se(l,d,A.empty));else{o=p;for(let u=0;u<c.marks.length;u++)t.allowsMarkType(c.marks[u].type)||n.step(new Ve(l,d,c.marks[u]));if(s&&c.isText&&t.whitespace!="pre"){let u,h=/\r?\n|\r/g,f;for(;u=h.exec(c.text);)f||(f=new A(T.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),r.push(new se(l+u.index,l+u.index+u[0].length,f))}}l=d}if(!o.validEnd){let a=o.fillBefore(T.empty,!0);n.replace(l,l,new A(a,0,0))}for(let a=r.length-1;a>=0;a--)n.step(r[a])}function Bf(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Uo(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let o=n.depth;;--o){let s=n.$from.node(o),i=n.$from.index(o),r=n.$to.indexAfter(o);if(o<n.depth&&s.canReplace(i,r,t))return o;if(o==0||s.type.spec.isolating||!Bf(s,i,r))break}return null}function Vf(n,e,t){let{$from:o,$to:s,depth:i}=e,r=o.before(i+1),l=s.after(i+1),a=r,c=l,d=T.empty,p=0;for(let f=i,m=!1;f>t;f--)m||o.index(f)>0?(m=!0,d=T.from(o.node(f).copy(d)),p++):a--;let u=T.empty,h=0;for(let f=i,m=!1;f>t;f--)m||s.after(f+1)<s.end(f)?(m=!0,u=T.from(s.node(f).copy(u)),h++):c++;n.step(new ee(a,c,r,l,new A(d.append(u),p,h),d.size-p,!0))}function wa(n,e,t=null,o=n){let s=Hf(n,e),i=s&&Ff(o,e);return i?s.map(Ca).concat({type:e,attrs:t}).concat(i.map(Ca)):null}function Ca(n){return{type:n,attrs:null}}function Hf(n,e){let{parent:t,startIndex:o,endIndex:s}=n,i=t.contentMatchAt(o).findWrapping(e);if(!i)return null;let r=i.length?i[0]:e;return t.canReplaceWith(o,s,r)?i:null}function Ff(n,e){let{parent:t,startIndex:o,endIndex:s}=n,i=t.child(o),r=e.contentMatch.findWrapping(i.type);if(!r)return null;let a=(r.length?r[r.length-1]:e).contentMatch;for(let c=o;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:r}function _f(n,e,t){let o=T.empty;for(let r=t.length-1;r>=0;r--){if(o.size){let l=t[r].type.contentMatch.matchFragment(o);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=T.from(t[r].type.create(t[r].attrs,o))}let s=e.start,i=e.end;n.step(new ee(s,i,s,i,new A(o,0,0),t.length,!0))}function Gf(n,e,t,o,s){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(r,l)=>{let a=typeof s=="function"?s(r):s;if(r.isTextblock&&!r.hasMarkup(o,a)&&Wf(n.doc,n.mapping.slice(i).map(l),o)){let c=null;if(o.schema.linebreakReplacement){let h=o.whitespace=="pre",f=!!o.contentMatch.matchType(o.schema.linebreakReplacement);h&&!f?c=!1:!h&&f&&(c=!0)}c===!1&&Ea(n,r,l,i),di(n,n.mapping.slice(i).map(l,1),o,void 0,c===null);let d=n.mapping.slice(i),p=d.map(l,1),u=d.map(l+r.nodeSize,1);return n.step(new ee(p,u,p+1,u-1,new A(T.from(o.create(a,null,r.marks)),0,0),1,!0)),c===!0&&ka(n,r,l,i),!1}})}function ka(n,e,t,o){e.forEach((s,i)=>{if(s.isText){let r,l=/\r?\n|\r/g;for(;r=l.exec(s.text);){let a=n.mapping.slice(o).map(t+1+i+r.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Ea(n,e,t,o){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let r=n.mapping.slice(o).map(t+1+i);n.replaceWith(r,r+1,e.type.schema.text(`
|
|
@@ -913,7 +913,7 @@
|
|
|
913
913
|
`),p&&f==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:ne(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=h.childNodes[f-1];p=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Re&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||p&&ae)&&zt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&zt(a.node,a.offset,d.focusNode,d.focusOffset))return;let u=!1;if((c.extend||e==t)&&!p){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),u=!0}catch{}}if(!u){if(e>t){let f=l;l=a,a=f}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let o=0,s=0;s<this.children.length;s++){let i=this.children[s],r=o+i.size;if(o==r?e<=r&&t>=o:e<r&&t>o){let l=o+i.border,a=r-i.border;if(e>=l&&t<=a){this.dirty=e==o||t==r?Vt:vc,e==l&&t==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=_e:i.markDirty(e-l,t-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Vt:_e}o=r}this.dirty=Vt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let o=e==1?Vt:vc;t.dirty<o&&(t.dirty=o)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class Sc extends Kn{constructor(e,t,o,s){let i,r=t.type.toDOM;if(typeof r=="function"&&(r=r(o,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(r.nodeType!=1){let l=document.createElement("span");l.appendChild(r),r=l}r.contentEditable="false",r.classList.add("ProseMirror-widget")}super(e,[],r,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Me&&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 ug extends Kn{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 Ht extends Kn{constructor(e,t,o,s,i){super(e,[],o,s),this.mark=t,this.spec=i}static create(e,t,o,s){let i=s.nodeViews[t.type.name],r=i&&i(t,s,o);return(!r||!r.dom)&&(r=Dt.renderSpec(document,t.type.spec.toDOM(t,o),null,t.attrs)),new Ht(e,t,r.dom,r.contentDOM||r.dom,r)}parseRule(){return this.dirty&_e||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=_e&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Me){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=Me}}slice(e,t,o){let s=Ht.create(this.parent,this.mark,!0,o),i=this.children,r=this.size;t<r&&(i=Di(i,t,r,o)),e>0&&(i=Di(i,0,e,o));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class ht extends Kn{constructor(e,t,o,s,i,r,l,a,c){super(e,[],i,r),this.node=t,this.outerDeco=o,this.innerDeco=s,this.nodeDOM=l}static create(e,t,o,s,i,r){let l=i.nodeViews[t.type.name],a,c=l&&l(t,i,()=>{if(!a)return r;if(a.parent)return a.parent.posBeforeChild(a)},o,s),d=c&&c.dom,p=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:p}=Dt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!p&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let u=d;return d=Ec(d,o,t),c?a=new hg(e,t,o,s,d,p||null,u,c,i,r+1):t.isText?new ts(e,t,o,s,d,u,i):new ht(e,t,o,s,d,p||null,u,i,r+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let o=this.children[t];if(this.dom.contains(o.dom.parentNode)){e.contentElement=o.dom.parentNode;break}}e.contentElement||(e.getContent=()=>T.empty)}return e}matchesNode(e,t,o){return this.dirty==Me&&e.eq(this.node)&&ns(t,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let o=this.node.inlineContent,s=t,i=e.composing?this.localCompositionInfo(e,t):null,r=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new mg(this,r&&r.node,e);bg(this.node,this.innerDeco,(c,d,p)=>{c.spec.marks?a.syncToMarks(c.spec.marks,o,e):c.type.side>=0&&!p&&a.syncToMarks(d==this.node.childCount?H.none:this.node.child(d).marks,o,e),a.placeWidget(c,e,s)},(c,d,p,u)=>{a.syncToMarks(c.marks,o,e);let h;a.findNodeMatch(c,d,p,u)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,d,p,h,e)||a.updateNextNode(c,d,p,e,u,s)||a.addNode(c,d,p,e,s),s+=c.nodeSize}),a.syncToMarks([],o,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Vt)&&(r&&this.protectLocalComposition(e,r),Cc(this.contentDOM,this.children,e),bn&&vg(this.dom))}localCompositionInfo(e,t){let{from:o,to:s}=e.state.selection;if(!(e.state.selection instanceof $)||o<t||s>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let r=i.nodeValue,l=Sg(this.node.content,r,o-t,s-t);return l<0?null:{node:i,pos:l,text:r}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:o,text:s}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let r=new ug(this,i,t,s);e.input.compositionNodes.push(r),this.children=Di(this.children,o,o+s.length,e,r)}update(e,t,o,s){return this.dirty==_e||!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=Me}updateOuterDeco(e){if(ns(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,o=this.dom;this.dom=kc(this.dom,this.nodeDOM,Ri(this.outerDeco,this.node,t),Ri(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 xc(n,e,t,o,s){Ec(o,e,n);let i=new ht(void 0,n,e,t,o,o,o,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class ts extends ht{constructor(e,t,o,s,i,r,l){super(e,t,o,s,i,null,r,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,o,s){return this.dirty==_e||this.dirty!=Me&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Me||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=Me,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,o){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,o)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,o){let s=this.node.cut(e,t),i=document.createTextNode(s.text);return new ts(this.parent,s,this.outerDeco,this.innerDeco,i,i,o)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=_e)}get domAtom(){return!1}isText(e){return this.node.text==e}}class wc extends Kn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Me&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class hg extends ht{constructor(e,t,o,s,i,r,l,a,c,d){super(e,t,o,s,i,r,l,c,d),this.spec=a}update(e,t,o,s){if(this.dirty==_e)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,o);return i&&this.updateInner(e,t,o,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,o,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,o,s){this.spec.setSelection?this.spec.setSelection(e,t,o.root):super.setSelection(e,t,o,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Cc(n,e,t){let o=n.firstChild,s=!1;for(let i=0;i<e.length;i++){let r=e[i],l=r.dom;if(l.parentNode==n){for(;l!=o;)o=Tc(o),s=!0;o=o.nextSibling}else s=!0,n.insertBefore(l,o);if(r instanceof Ht){let a=o?o.previousSibling:n.lastChild;Cc(r.contentDOM,r.children,t),o=a?a.nextSibling:n.firstChild}}for(;o;)o=Tc(o),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const Jn=function(n){n&&(this.nodeName=n)};Jn.prototype=Object.create(null);const Ft=[new Jn];function Ri(n,e,t){if(n.length==0)return Ft;let o=t?Ft[0]:new Jn,s=[o];for(let i=0;i<n.length;i++){let r=n[i].type.attrs;if(r){r.nodeName&&s.push(o=new Jn(r.nodeName));for(let l in r){let a=r[l];a!=null&&(t&&s.length==1&&s.push(o=new Jn(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==Ft&&o==Ft)return e;let s=e;for(let i=0;i<o.length;i++){let r=o[i],l=t[i];if(i){let a;l&&l.nodeName==r.nodeName&&s!=n&&(a=s.parentNode)&&a.nodeName.toLowerCase()==r.nodeName||(a=document.createElement(r.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=Ft[0]),s=a}fg(s,l||Ft[0],r)}return s}function fg(n,e,t){for(let o in e)o!="class"&&o!="style"&&o!="nodeName"&&!(o in t)&&n.removeAttribute(o);for(let o in t)o!="class"&&o!="style"&&o!="nodeName"&&t[o]!=e[o]&&n.setAttribute(o,t[o]);if(e.class!=t.class){let o=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<o.length;i++)s.indexOf(o[i])==-1&&n.classList.remove(o[i]);for(let i=0;i<s.length;i++)o.indexOf(s[i])==-1&&n.classList.add(s[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=o.exec(e.style);)n.style.removeProperty(s[1])}t.style&&(n.style.cssText+=t.style)}}function Ec(n,e,t){return kc(n,n,Ft,Ri(e,t,n.nodeType!=1))}function ns(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 Tc(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class mg{constructor(e,t,o){this.lock=t,this.view=o,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=gg(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let o=e;o<t;o++)this.top.children[o].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,o){let s=0,i=this.stack.length>>1,r=Math.min(i,e.length);for(;s<r&&(s==i-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<i;)this.destroyRest(),this.top.dirty=Me,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[i])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Ht.create(this.top,e[i],t,o);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,o,s){let i=-1,r;if(s>=this.preMatch.index&&(r=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&r.matchesNode(e,t,o))i=this.top.children.indexOf(r,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,o)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,o,s,i){let r=this.top.children[s];return r.dirty==_e&&r.dom==r.contentDOM&&(r.dirty=Vt),r.update(e,t,o,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let o=e.pmViewDesc;if(o){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==o)return s}return-1}e=t}}updateNextNode(e,t,o,s,i,r){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof ht){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let d=a.dom,p,u=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=_e&&ns(t,a.outerDeco));if(!u&&a.update(e,t,o,s))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!u&&(p=this.recreateWrapper(a,e,t,o,s,r)))return this.destroyBetween(this.index,l),this.top.children[this.index]=p,p.contentDOM&&(p.dirty=Vt,p.updateChildren(s,r+1),p.dirty=Me),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,o,s,i,r){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ns(o,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=ht.create(this.top,t,o,s,i,r);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,o,s,i){let r=ht.create(this.top,e,t,o,s,i);r.contentDOM&&r.updateChildren(s,i+1),this.top.children.splice(this.index++,0,r),this.changed=!0}placeWidget(e,t,o){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new Sc(this.top,e,t,o);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Ht;)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||ie)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let o=document.createElement(e);e=="IMG"&&(o.className="ProseMirror-separator",o.alt=""),e=="BR"&&(o.className="ProseMirror-trailingBreak");let s=new wc(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 gg(n,e){let t=e,o=t.children.length,s=n.childCount,i=new Map,r=[];e:for(;s>0;){let l;for(;;)if(o){let c=t.children[o-1];if(c instanceof Ht)t=c,o=c.children.length;else{l=c,o--;break}}else{if(t==e)break e;o=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(s-1))break;--s,i.set(l,s),r.push(l)}}return{index:s,matched:i,matches:r.reverse()}}function yg(n,e){return n.type.side-e.type.side}function bg(n,e,t,o){let s=e.locals(n),i=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);o(d,s,e.forChild(i,d),c),i+=d.nodeSize}return}let r=0,l=[],a=null;for(let c=0;;){let d,p;for(;r<s.length&&s[r].to==i;){let g=s[r++];g.widget&&(d?(p||(p=[d])).push(g):d=g)}if(d)if(p){p.sort(yg);for(let g=0;g<p.length;g++)t(p[g],c,!!a)}else t(d,c,!!a);let u,h;if(a)h=-1,u=a,a=null;else if(c<n.childCount)h=c,u=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;r<s.length&&s[r].from<=i&&s[r].to>i;)l.push(s[r++]);let f=i+u.nodeSize;if(u.isText){let g=f;r<s.length&&s[r].from<g&&(g=s[r].from);for(let b=0;b<l.length;b++)l[b].to<g&&(g=l[b].to);g<f&&(a=u.cut(g-i),u=u.cut(0,g-i),f=g,h=-1)}else for(;r<s.length&&s[r].to<f;)r++;let m=u.isInline&&!u.isLeaf?l.filter(g=>!g.inline):l.slice();o(u,m,e.forChild(i,u),h),i=f}}function vg(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 Sg(n,e,t,o){for(let s=0,i=0;s<n.childCount&&i<=o;){let r=n.child(s++),l=i;if(i+=r.nodeSize,!r.isText)continue;let a=r.text;for(;s<n.childCount;){let c=n.child(s++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=t){if(i>=o&&a.slice(o-e.length-l,o-l)==e)return o-e.length;let c=l<o?a.lastIndexOf(e,o-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==o&&a.length>=o+e.length-l&&a.slice(o-l,o-l+e.length)==e)return o}}return-1}function Di(n,e,t,o,s){let i=[];for(let r=0,l=0;r<n.length;r++){let a=n[r],c=l,d=l+=a.size;c>=t||d<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,o)),s&&(i.push(s),s=void 0),d>t&&i.push(a.slice(t-c,a.size,o)))}return i}function Li(n,e=null){let t=n.domSelectionRange(),o=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),i=s&&s.size==0,r=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(r<0)return null;let l=o.resolve(r),a,c;if(es(t)){for(a=r;s&&!s.node;)s=s.parent;let p=s.node;if(s&&p.isAtom&&D.isSelectable(p)&&s.parent&&!(p.isInline&&qm(t.focusNode,t.focusOffset,s.dom))){let u=s.posBefore;c=new D(r==u?l:o.resolve(u))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let p=r,u=r;for(let h=0;h<t.rangeCount;h++){let f=t.getRangeAt(h);p=Math.min(p,n.docView.posFromDOM(f.startContainer,f.startOffset,1)),u=Math.max(u,n.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(p<0)return null;[a,r]=u==n.state.selection.anchor?[u,p]:[p,u],l=o.resolve(r)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=o.resolve(a);if(!c){let p=e=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=zi(n,d,l,p)}return c}function Mc(n){return n.editable?n.hasFocus():Dc(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Qe(n,e=!1){let t=n.state.selection;if(Oc(n,t),!!Mc(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&ie){let o=n.domSelectionRange(),s=n.domObserver.currentSelection;if(o.anchorNode&&s.anchorNode&&zt(o.anchorNode,o.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)wg(n);else{let{anchor:o,head:s}=t,i,r;Ac&&!(t instanceof $)&&(t.$from.parent.inlineContent||(i=Pc(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(r=Pc(n,t.to))),n.docView.setSelection(o,s,n,e),Ac&&(i&&Nc(i),r&&Nc(r)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&xg(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Ac=ae||ie&&lc<63;function Pc(n,e){let{node:t,offset:o}=n.docView.domFromPos(e,0),s=o<t.childNodes.length?t.childNodes[o]:null,i=o?t.childNodes[o-1]:null;if(ae&&s&&s.contentEditable=="false")return $i(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return $i(s);if(i)return $i(i)}}function $i(n){return n.contentEditable="true",ae&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Nc(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function xg(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(()=>{(!Mc(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function wg(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,ne(o)+1):t.setStart(o,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!s&&!n.state.selection.visible&&ge&&pt<=11&&(o.disabled=!0,o.disabled=!1)}function Oc(n,e){if(e instanceof D){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Ic(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Ic(n)}function Ic(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function zi(n,e,t,o){return n.someProp("createSelectionBetween",s=>s(n,e,t))||$.between(e,t,o)}function Rc(n){return n.editable&&!n.hasFocus()?!1:Dc(n)}function Dc(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 Cg(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return zt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Bi(n,e){let{$anchor:t,$head:o}=n.selection,s=e>0?t.max(o):t.min(o),i=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return i&&L.findFrom(i,e)}function ft(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Lc(n,e,t){let o=n.state.selection;if(o instanceof $)if(t.indexOf("s")>-1){let{$head:s}=o,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let r=n.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return ft(n,new $(o.$anchor,r))}else if(o.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=Bi(n.state,e);return s&&s instanceof D?ft(n,s):!1}else if(!(Te&&t.indexOf("m")>-1)){let s=o.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,r;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(r=n.docView.descAt(l))&&!r.contentDOM?D.isSelectable(i)?ft(n,new D(e<0?n.state.doc.resolve(s.pos-i.nodeSize):s)):qn?ft(n,new $(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(o instanceof D&&o.node.isInline)return ft(n,new $(e>0?o.$to:o.$from));{let s=Bi(n.state,e);return s?ft(n,s):!1}}}function ss(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Zn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Sn(n,e){return e<0?kg(n):Eg(n)}function kg(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s,i,r=!1;for(Re&&t.nodeType==1&&o<ss(t)&&Zn(t.childNodes[o],-1)&&(r=!0);;)if(o>0){if(t.nodeType!=1)break;{let l=t.childNodes[o-1];if(Zn(l,-1))s=t,i=--o;else if(l.nodeType==3)t=l,o=t.nodeValue.length;else break}}else{if($c(t))break;{let l=t.previousSibling;for(;l&&Zn(l,-1);)s=t.parentNode,i=ne(l),l=l.previousSibling;if(l)t=l,o=ss(t);else{if(t=t.parentNode,t==n.dom)break;o=0}}}r?Vi(n,t,o):s&&Vi(n,s,i)}function Eg(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s=ss(t),i,r;for(;;)if(o<s){if(t.nodeType!=1)break;let l=t.childNodes[o];if(Zn(l,1))i=t,r=++o;else break}else{if($c(t))break;{let l=t.nextSibling;for(;l&&Zn(l,1);)i=l.parentNode,r=ne(l)+1,l=l.nextSibling;if(l)t=l,o=0,s=ss(t);else{if(t=t.parentNode,t==n.dom)break;o=s=0}}}i&&Vi(n,i,r)}function $c(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Tg(n,e){for(;n&&e==n.childNodes.length&&!jn(n);)e=ne(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 Mg(n,e){for(;n&&!e&&!jn(n);)e=ne(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 Vi(n,e,t){if(e.nodeType!=3){let i,r;(r=Tg(e,t))?(e=r,t=0):(i=Mg(e,t))&&(e=i,t=i.nodeValue.length)}let o=n.domSelection();if(!o)return;if(es(o)){let i=document.createRange();i.setEnd(e,t),i.setStart(e,t),o.removeAllRanges(),o.addRange(i)}else o.extend&&o.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&Qe(n)},50)}function zc(n,e){let t=n.state.doc.resolve(e);if(!(ie||Jm)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),r=(i.top+i.bottom)/2;if(r>s.top&&r<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<t.end()){let i=n.coordsAtPos(e+1),r=(i.top+i.bottom)/2;if(r>s.top&&r<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Bc(n,e,t){let o=n.state.selection;if(o instanceof $&&!o.empty||t.indexOf("s")>-1||Te&&t.indexOf("m")>-1)return!1;let{$from:s,$to:i}=o;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let r=Bi(n.state,e);if(r&&r instanceof D)return ft(n,r)}if(!s.parent.inlineContent){let r=e<0?s:i,l=o instanceof xe?L.near(r,e):L.findFrom(r,e);return l?ft(n,l):!1}return!1}function Vc(n,e){if(!(n.state.selection instanceof $))return!0;let{$head:t,$anchor:o,empty:s}=n.state.selection;if(!t.sameParent(o))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let r=n.state.tr;return e<0?r.delete(t.pos-i.nodeSize,t.pos):r.delete(t.pos,t.pos+i.nodeSize),n.dispatch(r),!0}return!1}function Hc(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Ag(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;Hc(n,o,"true"),setTimeout(()=>Hc(n,o,"false"),20)}return!1}function Pg(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Ng(n,e){let t=e.keyCode,o=Pg(e);if(t==8||Te&&t==72&&o=="c")return Vc(n,-1)||Sn(n,-1);if(t==46&&!e.shiftKey||Te&&t==68&&o=="c")return Vc(n,1)||Sn(n,1);if(t==13||t==27)return!0;if(t==37||Te&&t==66&&o=="c"){let s=t==37?zc(n,n.state.selection.from)=="ltr"?-1:1:-1;return Lc(n,s,o)||Sn(n,s)}else if(t==39||Te&&t==70&&o=="c"){let s=t==39?zc(n,n.state.selection.from)=="ltr"?1:-1:1;return Lc(n,s,o)||Sn(n,s)}else{if(t==38||Te&&t==80&&o=="c")return Bc(n,-1,o)||Sn(n,-1);if(t==40||Te&&t==78&&o=="c")return Ag(n)||Bc(n,1,o)||Sn(n,1);if(o==(Te?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Fc(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:o,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&o.childCount==1&&o.firstChild.childCount==1;){s--,i--;let h=o.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),o=h.content}let r=n.someProp("clipboardSerializer")||Dt.fromSchema(n.state.schema),l=Jc(),a=l.createElement("div");a.appendChild(r.serializeFragment(o,{document:l}));let c=a.firstChild,d,p=0;for(;c&&c.nodeType==1&&(d=Uc[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let f=l.createElement(d[h]);for(;a.firstChild;)f.appendChild(a.firstChild);a.appendChild(f),p++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${p?` -${p}`:""} ${JSON.stringify(t)}`);let u=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
|
|
914
914
|
|
|
915
915
|
`);return{dom:a,text:u,slice:e}}function _c(n,e,t,o,s){let i=s.parent.type.spec.code,r,l;if(!t&&!e)return null;let a=e&&(o||i||!t);if(a){if(n.someProp("transformPastedText",u=>{e=u(e,i||o,n)}),i)return e?new A(T.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
916
|
-
`))),0,0):A.empty;let p=n.someProp("clipboardTextParser",u=>u(e,s,o,n));if(p)l=p;else{let u=s.marks(),{schema:h}=n.state,f=Dt.fromSchema(h);r=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=r.appendChild(document.createElement("p"));m&&g.appendChild(f.serializeNode(h.text(m,u)))})}}else n.someProp("transformPastedHTML",p=>{t=p(t,n)}),r=Dg(t),qn&&Lg(r);let c=r&&r.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let p=+d[3];p>0;p--){let u=r.firstChild;for(;u&&u.nodeType!=1;)u=u.nextSibling;if(!u)break;r=u}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Rt.fromSchema(n.state.schema)).parseSlice(r,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!Og.test(u.parentNode.nodeName)?{ignore:!0}:null}})),d)l=$g(qc(l,+d[1],+d[2]),d[4]);else if(l=A.maxOpen(Ig(l.content,s),!0),l.openStart||l.openEnd){let p=0,u=0;for(let h=l.content.firstChild;p<l.openStart&&!h.type.spec.isolating;p++,h=h.firstChild);for(let h=l.content.lastChild;u<l.openEnd&&!h.type.spec.isolating;u++,h=h.lastChild);l=qc(l,p,u)}return n.someProp("transformPasted",p=>{l=p(l,n)}),l}const Og=/^(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 Ig(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),i,r=[];if(n.forEach(l=>{if(!r)return;let a=s.findWrapping(l.type),c;if(!a)return r=null;if(c=r.length&&i.length&&Wc(a,i,l,r[r.length-1],0))r[r.length-1]=c;else{r.length&&(r[r.length-1]=jc(r[r.length-1],i.length));let d=Gc(l,a);r.push(d),s=s.matchType(d.type),i=a}}),r)return T.from(r)}return n}function Gc(n,e,t=0){for(let o=e.length-1;o>=t;o--)n=e[o].create(null,T.from(n));return n}function Wc(n,e,t,o,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let i=Wc(n,e,t,o.lastChild,s+1);if(i)return o.copy(o.content.replaceChild(o.childCount-1,i));if(o.contentMatchAt(o.childCount).matchType(s==n.length-1?t.type:n[s+1]))return o.copy(o.content.append(T.from(Gc(t,n,s+1))))}}function jc(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,jc(n.lastChild,e-1)),o=n.contentMatchAt(n.childCount).fillBefore(T.empty,!0);return n.copy(t.append(o))}function Hi(n,e,t,o,s,i){let r=e<0?n.firstChild:n.lastChild,l=r.content;return n.childCount>1&&(i=0),s<o-1&&(l=Hi(l,e,t,o,s+1,i)),s>=t&&(l=e<0?r.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(r.contentMatchAt(r.childCount).fillBefore(T.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,r.copy(l))}function qc(n,e,t){return e<n.openStart&&(n=new A(Hi(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new A(Hi(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Uc={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 Kc=null;function Jc(){return Kc||(Kc=document.implementation.createHTMLDocument("title"))}let Fi=null;function Rg(n){let e=window.trustedTypes;return e?(Fi||(Fi=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Fi.createHTML(n)):n}function Dg(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Jc().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(n),s;if((s=o&&Uc[o[1].toLowerCase()])&&(n=s.map(i=>"<"+i+">").join("")+n+s.map(i=>"</"+i+">").reverse().join("")),t.innerHTML=Rg(n),s)for(let i=0;i<s.length;i++)t=t.querySelector(s[i])||t;return t}function Lg(n){let e=n.querySelectorAll(ie?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let o=e[t];o.childNodes.length==1&&o.textContent==" "&&o.parentNode&&o.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),o)}}function $g(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,o;try{o=JSON.parse(e)}catch{return n}let{content:s,openStart:i,openEnd:r}=n;for(let l=o.length-2;l>=0;l-=2){let a=t.nodes[o[l]];if(!a||a.hasRequiredAttrs())break;s=T.from(a.create(o[l+1],s)),i++,r++}return new A(s,i,r)}const ce={},de={},zg={touchstart:!0,touchmove:!0};class Bg{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 Vg(n){for(let e in ce){let t=ce[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=o=>{Fg(n,o)&&!Gi(n,o)&&(n.editable||!(o.type in de))&&t(n,o)},zg[e]?{passive:!0}:void 0)}ae&&n.dom.addEventListener("input",()=>null),_i(n)}function mt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Hg(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 _i(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=o=>Gi(n,o))})}function Gi(n,e){return n.someProp("handleDOMEvents",t=>{let o=t[e.type];return o?o(n,e)||e.defaultPrevented:!1})}function Fg(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){!Gi(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,!Yc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(De&&ie&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),bn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let o=Date.now();n.input.lastIOSEnter=o,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==o&&(n.someProp("handleKeyDown",s=>s(n,Bt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",o=>o(n,t))||Ng(n,t)?t.preventDefault():mt(n,"key")},de.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},de.keypress=(n,e)=>{let t=e;if(Yc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Te&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let o=n.state.selection;if(!(o instanceof $)||!o.$from.sameParent(o.$to)){let s=String.fromCharCode(t.charCode);!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",i=>i(n,o.$from.pos,o.$to.pos,s))&&n.dispatch(n.state.tr.insertText(s).scrollIntoView()),t.preventDefault()}};function is(n){return{left:n.clientX,top:n.clientY}}function Gg(n,e){let t=e.x-n.clientX,o=e.y-n.clientY;return t*t+o*o<100}function Wi(n,e,t,o,s){if(o==-1)return!1;let i=n.state.doc.resolve(o);for(let r=i.depth+1;r>0;r--)if(n.someProp(e,l=>r>i.depth?l(n,t,i.nodeAfter,i.before(r),s,!0):l(n,t,i.node(r),i.before(r),s,!1)))return!0;return!1}function xn(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 Wg(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),o=t.nodeAfter;return o&&o.isAtom&&D.isSelectable(o)?(xn(n,new D(t)),!0):!1}function jg(n,e){if(e==-1)return!1;let t=n.state.selection,o,s;t instanceof D&&(o=t.node);let i=n.state.doc.resolve(e);for(let r=i.depth+1;r>0;r--){let l=r>i.depth?i.nodeAfter:i.node(r);if(D.isSelectable(l)){o&&t.$from.depth>0&&r>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?s=i.before(t.$from.depth):s=i.before(r);break}}return s!=null?(xn(n,D.create(n.state.doc,s)),!0):!1}function qg(n,e,t,o,s){return Wi(n,"handleClickOn",e,t,o)||n.someProp("handleClick",i=>i(n,e,o))||(s?jg(n,t):Wg(n,t))}function Ug(n,e,t,o){return Wi(n,"handleDoubleClickOn",e,t,o)||n.someProp("handleDoubleClick",s=>s(n,e,o))}function Kg(n,e,t,o){return Wi(n,"handleTripleClickOn",e,t,o)||n.someProp("handleTripleClick",s=>s(n,e,o))||Jg(n,t,o)}function Jg(n,e,t){if(t.button!=0)return!1;let o=n.state.doc;if(e==-1)return o.inlineContent?(xn(n,$.create(o,0,o.content.size)),!0):!1;let s=o.resolve(e);for(let i=s.depth+1;i>0;i--){let r=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(r.inlineContent)xn(n,$.create(o,l+1,l+1+r.content.size));else if(D.isSelectable(r))xn(n,D.create(o,l));else continue;return!0}}function ji(n){return rs(n)}const Zc=Te?"metaKey":"ctrlKey";ce.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let o=ji(n),s=Date.now(),i="singleClick";s-n.input.lastClick.time<500&&Gg(t,n.input.lastClick)&&!t[Zc]&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:i};let r=n.posAtCoords(is(t));r&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Zg(n,r,t,!!o)):(i=="doubleClick"?Ug:Kg)(n,r.pos,r.inside,t)?t.preventDefault():mt(n,"pointer"))};class Zg{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[Zc],this.allowDefault=o.shiftKey;let i,r;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),r=t.inside;else{let d=e.state.doc.resolve(t.pos);i=d.parent,r=d.depth?d.before():0}const l=s?null:o.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(o.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof D&&c.from<=r&&c.to>r)&&(this.mightDrag={node:i,pos:r,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Re&&!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)),mt(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(()=>Qe(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(is(e))),this.updateAllowDefault(e),this.allowDefault||!t?mt(this.view,"pointer"):qg(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ae&&this.mightDrag&&!this.mightDrag.node.isAtom||ie&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(xn(this.view,L.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):mt(this.view,"pointer")}move(e){this.updateAllowDefault(e),mt(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(),ji(n),mt(n,"pointer")},ce.touchmove=n=>{n.input.lastTouch=Date.now(),mt(n,"pointer")},ce.contextmenu=n=>ji(n);function Yc(n,e){return n.composing?!0:ae&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Yg=De?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(),rs(n,!0),n.markCursor=null;else if(rs(n,!e.selection.empty),Re&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let o=n.domSelectionRange();for(let s=o.focusNode,i=o.focusOffset;s&&s.nodeType==1&&i!=0;){let r=i<0?s.lastChild:s.childNodes[i-1];if(!r)break;if(r.nodeType==3){let l=n.domSelection();l&&l.collapse(r,r.nodeValue.length);break}else s=r,i=-1}}n.input.composing=!0}Xc(n,Yg)},de.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Xc(n,20))};function Xc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>rs(n),e))}function Qc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Qg());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Xg(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Wm(e.focusNode,e.focusOffset),o=jm(e.focusNode,e.focusOffset);if(t&&o&&t!=o){let s=o.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||o==i)return i;if(!s||!s.isText(o.nodeValue))return o;if(n.input.compositionNode==o){let r=t.pmViewDesc;if(!(!r||!r.isText(t.nodeValue)))return o}}return t||o}function Qg(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function rs(n,e=!1){if(!(De&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Qc(n),e||n.docView&&n.docView.dirty){let t=Li(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 e1(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 Yn=ge&&pt<15||bn&&Zm<604;ce.copy=de.cut=(n,e)=>{let t=e,o=n.state.selection,s=t.type=="cut";if(o.empty)return;let i=Yn?null:t.clipboardData,r=o.content(),{dom:l,text:a}=Fc(n,r);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):e1(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function t1(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function n1(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?Xn(n,o.value,null,s,e):Xn(n,o.textContent,o.innerHTML,s,e)},50)}function Xn(n,e,t,o,s){let i=_c(n,e,t,o,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,i||A.empty)))return!0;if(!i)return!1;let r=t1(i),l=r?n.state.tr.replaceSelectionWith(r,o):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ed(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&&!De)return;let o=Yn?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;o&&Xn(n,ed(o),o.getData("text/html"),s,t)?t.preventDefault():n1(n,t)};class td{constructor(e,t,o){this.slice=e,this.move=t,this.node=o}}const nd=Te?"altKey":"ctrlKey";ce.dragstart=(n,e)=>{let t=e,o=n.input.mouseDown;if(o&&o.done(),!t.dataTransfer)return;let s=n.state.selection,i=s.empty?null:n.posAtCoords(is(t)),r;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof D?s.to-1:s.to))){if(o&&o.mightDrag)r=D.create(n.state.doc,o.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let p=n.docView.nearestDesc(t.target,!0);p&&p.node.type.spec.draggable&&p!=n.docView&&(r=D.create(n.state.doc,p.posBefore))}}let l=(r||n.state.selection).content(),{dom:a,text:c,slice:d}=Fc(n,l);(!t.dataTransfer.files.length||!ie||lc>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Yn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Yn||t.dataTransfer.setData("text/plain",c),n.dragging=new td(d,!t[nd],r)},ce.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},de.dragover=de.dragenter=(n,e)=>e.preventDefault(),de.drop=(n,e)=>{let t=e,o=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let s=n.posAtCoords(is(t));if(!s)return;let i=n.state.doc.resolve(s.pos),r=o&&o.slice;r?n.someProp("transformPasted",f=>{r=f(r,n)}):r=_c(n,ed(t.dataTransfer),Yn?null:t.dataTransfer.getData("text/html"),!1,i);let l=!!(o&&!t[nd]);if(n.someProp("handleDrop",f=>f(n,t,r||A.empty,l))){t.preventDefault();return}if(!r)return;t.preventDefault();let a=r?Yf(n.state.doc,i.pos,r):i.pos;a==null&&(a=i.pos);let c=n.state.tr;if(l){let{node:f}=o;f?f.replace(c):c.deleteSelection()}let d=c.mapping.map(a),p=r.openStart==0&&r.openEnd==0&&r.content.childCount==1,u=c.doc;if(p?c.replaceRangeWith(d,d,r.content.firstChild):c.replaceRange(d,d,r),c.doc.eq(u))return;let h=c.doc.resolve(d);if(p&&D.isSelectable(r.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(r.content.firstChild))c.setSelection(new D(h));else{let f=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,C)=>f=C),c.setSelection(zi(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())&&Qe(n)},20))},ce.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},ce.beforeinput=(n,e)=>{if(ie&&De&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:o}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=o||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,Bt(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 Qn(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 ls{constructor(e,t){this.toDOM=e,this.spec=t||_t,this.side=this.spec.side||0}map(e,t,o,s){let{pos:i,deleted:r}=e.mapResult(t.from+s,this.side<0?-1:1);return r?null:new ye(i-o,i-o,this)}valid(){return!0}eq(e){return this==e||e instanceof ls&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Qn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class gt{constructor(e,t){this.attrs=e,this.spec=t||_t}map(e,t,o,s){let i=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-o,r=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-o;return i>=r?null:new ye(i,r,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof gt&&Qn(this.attrs,e.attrs)&&Qn(this.spec,e.spec)}static is(e){return e.type instanceof gt}destroy(){}}class qi{constructor(e,t){this.attrs=e,this.spec=t||_t}map(e,t,o,s){let i=e.mapResult(t.from+s,1);if(i.deleted)return null;let r=e.mapResult(t.to+s,-1);return r.deleted||r.pos<=i.pos?null:new ye(i.pos-o,r.pos-o,this)}valid(e,t){let{index:o,offset:s}=e.content.findIndex(t.from),i;return s==t.from&&!(i=e.child(o)).isText&&s+i.nodeSize==t.to}eq(e){return this==e||e instanceof qi&&Qn(this.attrs,e.attrs)&&Qn(this.spec,e.spec)}destroy(){}}class ye{constructor(e,t,o){this.from=e,this.to=t,this.type=o}copy(e,t){return new ye(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 ye(e,e,new ls(t,o))}static inline(e,t,o,s){return new ye(e,t,new gt(o,s))}static node(e,t,o,s){return new ye(e,t,new qi(o,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof gt}get widget(){return this.type instanceof ls}}const wn=[],_t={};class U{constructor(e,t){this.local=e.length?e:wn,this.children=t.length?t:wn}static create(e,t){return t.length?as(t,e,0,_t):re}find(e,t,o){let s=[];return this.findInner(e??0,t??1e9,s,0,o),s}findInner(e,t,o,s,i){for(let r=0;r<this.local.length;r++){let l=this.local[r];l.from<=t&&l.to>=e&&(!i||i(l.spec))&&o.push(l.copy(l.from+s,l.to+s))}for(let r=0;r<this.children.length;r+=3)if(this.children[r]<t&&this.children[r+1]>e){let l=this.children[r]+1;this.children[r+2].findInner(e-l,t-l,o,s+l,i)}}map(e,t,o){return this==re||e.maps.length==0?this:this.mapInner(e,t,0,0,o||_t)}mapInner(e,t,o,s,i){let r;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,o,s);a&&a.type.valid(t,a)?(r||(r=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?o1(this.children,r||[],e,t,o,s,i):r?new U(r.sort(Gt),wn):re}add(e,t){return t.length?this==re?U.create(e,t):this.addInner(e,t,0):this}addInner(e,t,o){let s,i=0;e.forEach((l,a)=>{let c=a+o,d;if(d=sd(t,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,d,c+1):s.splice(i,0,a,a+l.nodeSize,as(d,l,c+1,_t)),i+=3}});let r=od(i?id(t):t,-o);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||r.splice(l--,1);return new U(r.length?this.local.concat(r).sort(Gt):this.local,s||this.children)}remove(e){return e.length==0||this==re?this:this.removeInner(e,0)}removeInner(e,t){let o=this.children,s=this.local;for(let i=0;i<o.length;i+=3){let r,l=o[i]+t,a=o[i+1]+t;for(let d=0,p;d<e.length;d++)(p=e[d])&&p.from>l&&p.to<a&&(e[d]=null,(r||(r=[])).push(p));if(!r)continue;o==this.children&&(o=this.children.slice());let c=o[i+2].removeInner(r,l+1);c!=re?o[i+2]=c:(o.splice(i,3),i-=3)}if(s.length){for(let i=0,r;i<e.length;i++)if(r=e[i])for(let l=0;l<s.length;l++)s[l].eq(r,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return o==this.children&&s==this.local?this:s.length||o.length?new U(s,o):re}forChild(e,t){if(this==re)return this;if(t.isLeaf)return U.empty;let o,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(o=this.children[l+2]);break}let i=e+1,r=i+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<r&&a.to>i&&a.type instanceof gt){let c=Math.max(i,a.from)-i,d=Math.min(r,a.to)-i;c<d&&(s||(s=[])).push(a.copy(c,d))}}if(s){let l=new U(s.sort(Gt),wn);return o?new yt([l,o]):l}return o||re}eq(e){if(this==e)return!0;if(!(e instanceof U)||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 Ui(this.localsInner(e))}localsInner(e){if(this==re)return wn;if(e.inlineContent||!this.local.some(gt.is))return this.local;let t=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof gt||t.push(this.local[o]);return t}forEachSet(e){e(this)}}U.empty=new U([],[]),U.removeOverlap=Ui;const re=U.empty;class yt{constructor(e){this.members=e}map(e,t){const o=this.members.map(s=>s.map(e,t,_t));return yt.from(o)}forChild(e,t){if(t.isLeaf)return U.empty;let o=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,t);i!=re&&(i instanceof yt?o=o.concat(i.members):o.push(i))}return yt.from(o)}eq(e){if(!(e instanceof yt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,o=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!t)t=i;else{o&&(t=t.slice(),o=!1);for(let r=0;r<i.length;r++)t.push(i[r])}}return t?Ui(o?t:t.sort(Gt)):wn}static from(e){switch(e.length){case 0:return re;case 1:return e[0];default:return new yt(e.every(t=>t instanceof U)?e:e.reduce((t,o)=>t.concat(o instanceof U?o:o.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function o1(n,e,t,o,s,i,r){let l=n.slice();for(let c=0,d=i;c<t.maps.length;c++){let p=0;t.maps[c].forEach((u,h,f,m)=>{let g=m-f-(h-u);for(let b=0;b<l.length;b+=3){let C=l[b+1];if(C<0||u>C+d-p)continue;let y=l[b]+d-p;h>=y?l[b+1]=u<=y?-2:-1:u>=d&&g&&(l[b]+=g,l[b+1]+=g)}p+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(n[c]+i),p=d-s;if(p<0||p>=o.content.size){a=!0;continue}let u=t.map(n[c+1]+i,-1),h=u-s,{index:f,offset:m}=o.content.findIndex(p),g=o.maybeChild(f);if(g&&m==p&&m+g.nodeSize==h){let b=l[c+2].mapInner(t,g,d+1,n[c]+i+1,r);b!=re?(l[c]=p,l[c+1]=h,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=s1(l,n,e,t,s,i,r),d=as(c,o,0,r);e=d.local;for(let p=0;p<l.length;p+=3)l[p+1]<0&&(l.splice(p,3),p-=3);for(let p=0,u=0;p<d.children.length;p+=3){let h=d.children[p];for(;u<l.length&&l[u]<h;)u+=3;l.splice(u,0,d.children[p],d.children[p+1],d.children[p+2])}}return new U(e.sort(Gt),l)}function od(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 ye(s.from+e,s.to+e,s.type))}return t}function s1(n,e,t,o,s,i,r){function l(a,c){for(let d=0;d<a.local.length;d++){let p=a.local[d].map(o,s,c);p?t.push(p):r.onRemove&&r.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+i+1);return t}function sd(n,e,t){if(e.isLeaf)return null;let o=t+e.nodeSize,s=null;for(let i=0,r;i<n.length;i++)(r=n[i])&&r.from>t&&r.to<o&&((s||(s=[])).push(r),n[i]=null);return s}function id(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function as(n,e,t,o){let s=[],i=!1;e.forEach((l,a)=>{let c=sd(n,l,a+t);if(c){i=!0;let d=as(c,l,t+a+1,o);d!=re&&s.push(a,a+l.nodeSize,d)}});let r=od(i?id(n):n,-t).sort(Gt);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||(o.onRemove&&o.onRemove(r[l].spec),r.splice(l--,1));return r.length||s.length?new U(r,s):re}function Gt(n,e){return n.from-e.from||n.to-e.to}function Ui(n){let e=n;for(let t=0;t<e.length-1;t++){let o=e[t];if(o.from!=o.to)for(let s=t+1;s<e.length;s++){let i=e[s];if(i.from==o.from){i.to!=o.to&&(e==n&&(e=n.slice()),e[s]=i.copy(i.from,o.to),rd(e,s+1,i.copy(o.to,i.to)));continue}else{i.from<o.to&&(e==n&&(e=n.slice()),e[t]=o.copy(o.from,i.from),rd(e,s,o.copy(i.from,o.to)));break}}}return e}function rd(n,e,t){for(;e<n.length&&Gt(t,n[e])>0;)e++;n.splice(e,0,t)}function Ki(n){let e=[];return n.someProp("decorations",t=>{let o=t(n.state);o&&o!=re&&e.push(o)}),n.cursorWrapper&&e.push(U.create(n.state.doc,[n.cursorWrapper.deco])),yt.from(e)}const i1={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},r1=ge&&pt<=11;class l1{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 a1{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new l1,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]);ge&&pt<=11&&o.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),r1&&(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,i1)),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(Rc(this.view)){if(this.suppressingSelectionUpdates)return Qe(this.view);if(ge&&pt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&zt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,o;for(let i=e.focusNode;i;i=Wn(i))t.add(i);for(let i=e.anchorNode;i;i=Wn(i))if(t.has(i)){o=i;break}let s=o&&this.view.docView.nearestDesc(o);if(s&&s.ignoreMutation({type:"selection",target:o.nodeType==3?o.parentNode:o}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let o=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(o)&&Rc(e)&&!this.ignoreSelectionChange(o),i=-1,r=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let p=this.registerMutation(t[d],a);p&&(i=i<0?p.from:Math.min(p.from,i),r=r<0?p.to:Math.max(p.to,r),p.typeOver&&(l=!0))}if(Re&&a.length){let d=a.filter(p=>p.nodeName=="BR");if(d.length==2){let[p,u]=d;p.parentNode&&p.parentNode.parentNode==u.parentNode?u.remove():p.remove()}else{let{focusNode:p}=this.currentSelection;for(let u of d){let h=u.parentNode;h&&h.nodeName=="LI"&&(!p||p1(e,p)!=h)&&u.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&es(o)&&(c=Li(e))&&c.eq(L.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Qe(e),this.currentSelection.set(o),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,r),c1(e)),this.handleDOMChange(i,r,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(o)||Qe(e),this.currentSelection.set(o))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let o=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(o==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!o||o.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let p=e.addedNodes[d];t.push(p),p.nodeType==3&&(this.lastChangedTextNode=p)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(e.target))return{from:o.posBefore,to:o.posAfter};let s=e.previousSibling,i=e.nextSibling;if(ge&&pt<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:p,nextSibling:u}=e.addedNodes[d];(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(s=p),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(i=u)}let r=s&&s.parentNode==e.target?ne(s)+1:0,l=o.localPosFromDOM(e.target,r,-1),a=i&&i.parentNode==e.target?ne(i):e.target.childNodes.length,c=o.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}:(this.lastChangedTextNode=e.target,{from:o.posAtStart,to:o.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let ld=new WeakMap,ad=!1;function c1(n){if(!ld.has(n)&&(ld.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Re,ad)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."),ad=!0}}function cd(n,e){let t=e.startContainer,o=e.startOffset,s=e.endContainer,i=e.endOffset,r=n.domAtPos(n.state.selection.anchor);return zt(r.node,r.offset,s,i)&&([t,o,s,i]=[s,i,t,o]),{anchorNode:t,anchorOffset:o,focusNode:s,focusOffset:i}}function d1(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return cd(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?cd(n,t):null}function p1(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 u1(n,e,t){let{node:o,fromOffset:s,toOffset:i,from:r,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],es(a)||c.push({node:a.focusNode,offset:a.focusOffset})),ie&&n.input.lastKeyCode===8)for(let g=i;g>s;g--){let b=o.childNodes[g-1],C=b.pmViewDesc;if(b.nodeName=="BR"&&!C){i=g;break}if(!C||C.size)break}let p=n.state.doc,u=n.someProp("domParser")||Rt.fromSchema(n.state.schema),h=p.resolve(r),f=null,m=u.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:i,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:h1,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),f={anchor:g+r,head:b+r}}return{doc:m,sel:f,from:r,to:l}}function h1(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 f1=/^(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 m1(n,e,t,o,s){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let E=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,M=Li(n,E);if(M&&!n.state.selection.eq(M)){if(ie&&De&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",N=>N(n,Bt(13,"Enter"))))return;let P=n.state.tr.setSelection(M);E=="pointer"?P.setMeta("pointer",!0):E=="key"&&P.scrollIntoView(),i&&P.setMeta("composition",i),n.dispatch(P)}return}let r=n.state.doc.resolve(e),l=r.sharedDepth(t);e=r.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=u1(n,e,t),d=n.state.doc,p=d.slice(c.from,c.to),u,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(u=n.state.selection.to,h="end"):(u=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let f=b1(p.content,c.doc.content,c.from,u,h);if(f&&n.input.domChangeCount++,(bn&&n.input.lastIOSEnter>Date.now()-225||De)&&s.some(E=>E.nodeType==1&&!f1.test(E.nodeName))&&(!f||f.endA>=f.endB)&&n.someProp("handleKeyDown",E=>E(n,Bt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!f)if(o&&a instanceof $&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))f={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let E=dd(n,n.state.doc,c.sel);if(E&&!E.eq(n.state.selection)){let M=n.state.tr.setSelection(E);i&&M.setMeta("composition",i),n.dispatch(M)}}return}n.state.selection.from<n.state.selection.to&&f.start==f.endB&&n.state.selection instanceof $&&(f.start>n.state.selection.from&&f.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?f.start=n.state.selection.from:f.endA<n.state.selection.to&&f.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(f.endB+=n.state.selection.to-f.endA,f.endA=n.state.selection.to)),ge&&pt<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>c.from&&c.doc.textBetween(f.start-c.from-1,f.start-c.from+1)==" "&&(f.start--,f.endA--,f.endB--);let m=c.doc.resolveNoCache(f.start-c.from),g=c.doc.resolveNoCache(f.endB-c.from),b=d.resolve(f.start),C=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=f.endA,y;if((bn&&n.input.lastIOSEnter>Date.now()-225&&(!C||s.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!C&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(y=L.findFrom(c.doc.resolve(m.pos+1),1,!0))&&y.head==g.pos)&&n.someProp("handleKeyDown",E=>E(n,Bt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>f.start&&y1(d,f.start,f.endA,m,g)&&n.someProp("handleKeyDown",E=>E(n,Bt(8,"Backspace")))){De&&ie&&n.domObserver.suppressSelectionUpdates();return}ie&&De&&f.endB==f.start&&(n.input.lastAndroidDelete=Date.now()),De&&!C&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==f.endA&&(f.endB-=2,g=c.doc.resolveNoCache(f.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(E){return E(n,Bt(13,"Enter"))})},20));let v=f.start,w=f.endA,S,x,k;if(C){if(m.pos==g.pos)ge&&pt<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Qe(n),20)),S=n.state.tr.delete(v,w),x=d.resolve(f.start).marksAcross(d.resolve(f.endA));else if(f.endA==f.endB&&(k=g1(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,f.endA-b.start()))))S=n.state.tr,k.type=="add"?S.addMark(v,w,k.mark):S.removeMark(v,w,k.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let E=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",M=>M(n,v,w,E)))return;S=n.state.tr.insertText(E,v,w)}}if(S||(S=n.state.tr.replace(v,w,c.doc.slice(f.start-c.from,f.endB-c.from))),c.sel){let E=dd(n,S.doc,c.sel);E&&!(ie&&De&&n.composing&&E.empty&&(f.start!=f.endB||n.input.lastAndroidDelete<Date.now()-100)&&(E.head==v||E.head==S.mapping.map(w)-1)||ge&&E.empty&&E.head==v)&&S.setSelection(E)}x&&S.ensureMarks(x),i&&S.setMeta("composition",i),n.dispatch(S.scrollIntoView())}function dd(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:zi(n,e.resolve(t.anchor),e.resolve(t.head))}function g1(n,e){let t=n.firstChild.marks,o=e.firstChild.marks,s=t,i=o,r,l,a;for(let d=0;d<o.length;d++)s=o[d].removeFromSet(s);for(let d=0;d<t.length;d++)i=t[d].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],r="add",a=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&i.length==1)l=i[0],r="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(T.from(c).eq(n))return{mark:l,type:r}}function y1(n,e,t,o,s){if(t-e<=s.pos-o.pos||Ji(o,!0,!1)<s.pos)return!1;let i=n.resolve(e);if(!o.parent.isTextblock){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let r=n.resolve(Ji(i,!0,!0));return!r.parent.isTextblock||r.pos>t||Ji(r,!0,!1)<t?!1:o.parent.content.cut(o.parentOffset).eq(r.parent.content)}function Ji(n,e,t){let o=n.depth,s=e?n.end():n.pos;for(;o>0&&(e||n.indexAfter(o)==n.node(o).childCount);)o--,s++,e=!1;if(t){let i=n.node(o).maybeChild(n.indexAfter(o));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function b1(n,e,t,o,s){let i=n.findDiffStart(e,t);if(i==null)return null;let{a:r,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,i-Math.min(r,l));o-=r+a-i}if(r<i&&n.size<e.size){let a=o<=i&&o>=r?i-o:0;i-=a,i&&i<e.size&&pd(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-r),r=i}else if(l<i){let a=o<=i&&o>=l?i-o:0;i-=a,i&&i<n.size&&pd(n.textBetween(i-1,i+1))&&(i+=a?1:-1),r=i+(r-l),l=i}return{start:i,endA:r,endB:l}}function pd(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 v1{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 Bg,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(gd),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=fd(this),hd(this),this.nodeViews=md(this),this.docView=xc(this.state.doc,ud(this),Ki(this),this.dom,this),this.domObserver=new a1(this,(o,s,i,r)=>m1(this,o,s,i,r)),this.domObserver.start(),Vg(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&&_i(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(gd),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let o in this._props)t[o]=this._props[o];t.state=this.state;for(let o in e)t[o]=e[o];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var o;let s=this.state,i=!1,r=!1;e.storedMarks&&this.composing&&(Qc(this),r=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=md(this);x1(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&_i(this),this.editable=fd(this),hd(this);let a=Ki(this),c=ud(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",p=i||!this.docView.matchesNode(e.doc,c,a);(p||!e.selection.eq(s.selection))&&(r=!0);let u=d=="preserve"&&r&&this.dom.style.overflowAnchor==null&&Qm(this);if(r){this.domObserver.stop();let h=p&&(ge||ie)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&S1(s.selection,e.selection);if(p){let f=ie?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Xg(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=xc(e.doc,c,a,this.dom,this)),f&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Cg(this))?Qe(this,h):(Oc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((o=this.dragging)===null||o===void 0)&&o.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():u&&eg(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof D){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&ac(this,t.getBoundingClientRect(),e)}else ac(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let o=this.directPlugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let o=this.state.plugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let o=this.pluginViews[t];o.update&&o.update(this,e)}}updateDraggedNode(e,t){let o=e.node,s=-1;if(this.state.doc.nodeAt(o.from)==o.node)s=o.from;else{let i=o.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==o.node&&(s=i)}this.dragging=new td(e.slice,e.move,s<0?void 0:D.create(this.state.doc,s))}someProp(e,t){let o=this._props&&this._props[e],s;if(o!=null&&(s=t?t(o):o))return s;for(let r=0;r<this.directPlugins.length;r++){let l=this.directPlugins[r].props[e];if(l!=null&&(s=t?t(l):l))return s}let i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let l=i[r].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(ge){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&&tg(this.dom),Qe(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 rg(this,e)}coordsAtPos(e,t=1){return fc(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 pg(this,t||this.state,e)}pasteHTML(e,t){return Xn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Xn(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Hg(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ki(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,_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&&Um(this.dom.ownerDocument)==this.dom&&d1(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function ud(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"),[ye.node(0,n.state.doc.content.size,e)]}function hd(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:ye.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function fd(n){return!n.someProp("editable",e=>e(n.state)===!1)}function S1(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 md(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 x1(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 gd(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 Zi,Yi;if(typeof WeakMap<"u"){let n=new WeakMap;Zi=e=>n.get(e),Yi=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Zi=o=>{for(let s=0;s<n.length;s+=2)if(n[s]==o)return n[s+1]},Yi=(o,s)=>(t==10&&(t=0),n[t++]=o,n[t++]=s)}var J=class{constructor(n,e,t,o){this.width=n,this.height=e,this.map=t,this.problems=o}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const o=e%this.width,s=e/this.width|0;let i=o+1,r=s+1;for(let l=1;i<this.width&&this.map[e+l]==t;l++)i++;for(let l=1;r<this.height&&this.map[e+this.width*l]==t;l++)r++;return{left:o,top:s,right:i,bottom:r}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:o,right:s,top:i,bottom:r}=this.findCell(n);return e=="horiz"?(t<0?o==0:s==this.width)?null:this.map[i*this.width+(t<0?o-1:s)]:(t<0?i==0:r==this.height)?null:this.map[o+this.width*(t<0?i-1:r)]}rectBetween(n,e){const{left:t,right:o,top:s,bottom:i}=this.findCell(n),{left:r,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,r),top:Math.min(s,a),right:Math.max(o,l),bottom:Math.max(i,c)}}cellsInRect(n){const e=[],t={};for(let o=n.top;o<n.bottom;o++)for(let s=n.left;s<n.right;s++){const i=o*this.width+s,r=this.map[i];t[r]||(t[r]=!0,!(s==n.left&&s&&this.map[i-1]==r||o==n.top&&o&&this.map[i-this.width]==r)&&e.push(r))}return e}positionAt(n,e,t){for(let o=0,s=0;;o++){const i=s+t.child(o).nodeSize;if(o==n){let r=e+n*this.width;const l=(n+1)*this.width;for(;r<l&&this.map[r]<s;)r++;return r==l?i-1:this.map[r]}s=i}}static get(n){return Zi(n)||Yi(n,w1(n))}};function w1(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=C1(n),t=n.childCount,o=[];let s=0,i=null;const r=[];for(let c=0,d=e*t;c<d;c++)o[c]=0;for(let c=0,d=0;c<t;c++){const p=n.child(c);d++;for(let f=0;;f++){for(;s<o.length&&o[s]!=0;)s++;if(f==p.childCount)break;const m=p.child(f),{colspan:g,rowspan:b,colwidth:C}=m.attrs;for(let y=0;y<b;y++){if(y+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:b-y});break}const v=s+y*e;for(let w=0;w<g;w++){o[v+w]==0?o[v+w]=d:(i||(i=[])).push({type:"collision",row:c,pos:d,n:g-w});const S=C&&C[w];if(S){const x=(v+w)%e*2,k=r[x];k==null||k!=S&&r[x+1]==1?(r[x]=S,r[x+1]=1):k==S&&r[x+1]++}}}s+=g,d+=m.nodeSize}const u=(c+1)*e;let h=0;for(;s<u;)o[s++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),d++}const l=new J(e,t,o,i);let a=!1;for(let c=0;!a&&c<r.length;c+=2)r[c]!=null&&r[c+1]<t&&(a=!0);return a&&k1(l,r,n),l}function C1(n){let e=-1,t=!1;for(let o=0;o<n.childCount;o++){const s=n.child(o);let i=0;if(t)for(let r=0;r<o;r++){const l=n.child(r);for(let a=0;a<l.childCount;a++){const c=l.child(a);r+c.attrs.rowspan>o&&(i+=c.attrs.colspan)}}for(let r=0;r<s.childCount;r++){const l=s.child(r);i+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function k1(n,e,t){n.problems||(n.problems=[]);const o={};for(let s=0;s<n.map.length;s++){const i=n.map[s];if(o[i])continue;o[i]=!0;const r=t.nodeAt(i);if(!r)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=r.attrs;for(let c=0;c<a.colspan;c++){const d=(s+c)%n.width,p=e[d*2];p!=null&&(!a.colwidth||a.colwidth[c]!=p)&&((l||(l=E1(a)))[c]=p)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function E1(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function yd(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),o=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(r=>Number(r)):null,s=Number(n.getAttribute("colspan")||1),i={colspan:s,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:o&&o.length==s?o:null};for(const r in e){const l=e[r].getFromDOM,a=l&&l(n);a!=null&&(i[r]=a)}return i}function bd(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 T1(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=>yd(o,e)}],toDOM(o){return["td",bd(o,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:o=>yd(o,e)}],toDOM(o){return["th",bd(o,e),0]}}}}function Ge(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 bt=new _n("selectingCells");function eo(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 cs(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 Xi(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=eo(e.$head)||M1(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function M1(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 Qi(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function A1(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function er(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function vd(n,e,t){const o=n.node(-1),s=J.get(o),i=n.start(-1),r=s.nextCell(n.pos-i,e,t);return r==null?null:n.node(0).resolve(i+r)}function Cn(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 nt extends L{constructor(e,t=e){const o=e.node(-1),s=J.get(o),i=e.start(-1),r=s.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=s.cellsInRect(r).filter(d=>d!=t.pos-i);a.unshift(t.pos-i);const c=a.map(d=>{const p=o.nodeAt(d);if(!p)throw RangeError(`No cell with offset ${d} found`);const u=i+d+1;return new Oa(l.resolve(u),l.resolve(u+p.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const o=e.resolve(t.map(this.$anchorCell.pos)),s=e.resolve(t.map(this.$headCell.pos));if(Qi(o)&&Qi(s)&&er(o,s)){const i=this.$anchorCell.node(-1)!=o.node(-1);return i&&this.isRowSelection()?nt.rowSelection(o,s):i&&this.isColSelection()?nt.colSelection(o,s):new nt(o,s)}return $.between(o,s)}content(){const e=this.$anchorCell.node(-1),t=J.get(e),o=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),i={},r=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let d=a*t.width+s.left,p=s.left;p<s.right;p++,d++){const u=t.map[d];if(i[u])continue;i[u]=!0;const h=t.findCell(u);let f=e.nodeAt(u);if(!f)throw RangeError(`No cell with offset ${u} found`);const m=s.left-h.left,g=h.right-s.right;if(m>0||g>0){let b=f.attrs;if(m>0&&(b=Cn(b,0,m)),g>0&&(b=Cn(b,b.colspan-g,g)),h.left<s.left){if(f=f.type.createAndFill(b),!f)throw RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else f=f.type.create(b,f.content)}if(h.top<s.top||h.bottom>s.bottom){const b={...f.attrs,rowspan:Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top)};h.top<s.top?f=f.type.createAndFill(b):f=f.type.create(b,f.content)}c.push(f)}r.push(e.child(a).copy(T.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:r;return new A(T.from(l),1,1)}replace(e,t=A.empty){const o=e.steps.length,s=this.ranges;for(let r=0;r<s.length;r++){const{$from:l,$to:a}=s[r],c=e.mapping.slice(o);e.replace(c.map(l.pos),c.map(a.pos),r?A.empty:t)}const i=L.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new A(T.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),o=J.get(t),s=this.$anchorCell.start(-1),i=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let r=0;r<i.length;r++)e(t.nodeAt(i[r]),s+i[r])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const o=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const o=e.node(-1),s=J.get(o),i=e.start(-1),r=s.findCell(e.pos-i),l=s.findCell(t.pos-i),a=e.node(0);return r.top<=l.top?(r.top>0&&(e=a.resolve(i+s.map[r.left])),l.bottom<s.height&&(t=a.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(i+s.map[l.left])),r.bottom<s.height&&(e=a.resolve(i+s.map[s.width*(s.height-1)+r.right-1]))),new nt(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=J.get(e),o=this.$anchorCell.start(-1),s=t.colCount(this.$anchorCell.pos-o),i=t.colCount(this.$headCell.pos-o);if(Math.min(s,i)>0)return!1;const r=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(r,l)==t.width}eq(e){return e instanceof nt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const o=e.node(-1),s=J.get(o),i=e.start(-1),r=s.findCell(e.pos-i),l=s.findCell(t.pos-i),a=e.node(0);return r.left<=l.left?(r.left>0&&(e=a.resolve(i+s.map[r.top*s.width])),l.right<s.width&&(t=a.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(i+s.map[l.top*s.width])),r.right<s.width&&(e=a.resolve(i+s.map[s.width*(r.top+1)-1]))),new nt(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new nt(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){return new nt(e.resolve(t),e.resolve(o))}getBookmark(){return new P1(this.$anchorCell.pos,this.$headCell.pos)}};Y.prototype.visible=!1,L.jsonID("cell",Y);var P1=class Tp{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Tp(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&&er(t,o)?new Y(t,o):L.near(o,1)}};function N1(n){if(!(n.selection instanceof Y))return null;const e=[];return n.selection.forEachCell((t,o)=>{e.push(ye.node(o,o+t.nodeSize,{class:"selectedCell"}))}),U.create(n.doc,e)}function O1({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,o=e.pos,s=n.depth;for(;s>=0&&!(n.after(s+1)<n.end(s));s--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,o--);return t==o&&/row|table/.test(n.node(s).type.spec.tableRole)}function I1({$from:n,$to:e}){let t,o;for(let s=n.depth;s>0;s--){const i=n.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){o=i;break}}return t!==o&&e.parentOffset===0}function R1(n,e,t){const o=(e||n).selection,s=(e||n).doc;let i,r;if(o instanceof D&&(r=o.node.type.spec.tableRole)){if(r=="cell"||r=="header_cell")i=Y.create(s,o.from);else if(r=="row"){const l=s.resolve(o.from+1);i=Y.rowSelection(l,l)}else if(!t){const l=J.get(o.node),a=o.from+1,c=a+l.map[l.width*l.height-1];i=Y.create(s,a+1,c)}}else o instanceof $&&O1(o)?i=$.create(s,o.from):o instanceof $&&I1(o)&&(i=$.create(s,o.$from.start(),o.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}var D1=new _n("fix-tables");function Sd(n,e,t,o){const s=n.childCount,i=e.childCount;e:for(let r=0,l=0;r<i;r++){const a=e.child(r);for(let c=l,d=Math.min(s,r+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}o(a,t),l<s&&n.child(l).sameMarkup(a)?Sd(n.child(l),a,t+1,o):a.nodesBetween(0,a.content.size,o,t+1),t+=a.nodeSize}}function L1(n,e){let t;const o=(s,i)=>{s.type.spec.tableRole=="table"&&(t=$1(n,s,i,t))};return e?e.doc!=n.doc&&Sd(e.doc,n.doc,0,o):n.doc.descendants(o),t}function $1(n,e,t,o){const s=J.get(e);if(!s.problems)return o;o||(o=n.tr);const i=[];for(let a=0;a<s.height;a++)i.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const p=d.attrs;for(let u=0;u<p.rowspan;u++)i[c.row+u]+=c.n;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,Cn(p,p.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}}let r,l;for(let a=0;a<i.length;a++)i[a]&&(r==null&&(r=a),l=a);for(let a=0,c=t+1;a<s.height;a++){const d=e.child(a),p=c+d.nodeSize,u=i[a];if(u>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const f=[];for(let g=0;g<u;g++){const b=Ge(n.schema)[h].createAndFill();b&&f.push(b)}const m=(a==0||r==a-1)&&l==a?c+1:p-1;o.insert(o.mapping.map(m),f)}c=p}return o.setMeta(D1,{fixTables:!0})}function xd(n){const e=n.selection,t=Xi(n),o=t.node(-1),s=t.start(-1),i=J.get(o);return{...e instanceof Y?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(t.pos-s),tableStart:s,map:i,table:o}}function z1(n){return function(e,t){if(!cs(e))return!1;if(t){const o=Ge(e.schema),s=xd(e),i=e.tr,r=s.map.cellsInRect(n=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:n=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=r.map(a=>s.table.nodeAt(a));for(let a=0;a<r.length;a++)l[a].type==o.header_cell&&i.setNodeMarkup(s.tableStart+r[a],o.cell,l[a].attrs);if(i.steps.length==0)for(let a=0;a<r.length;a++)i.setNodeMarkup(s.tableStart+r[a],o.header_cell,l[a].attrs);t(i)}return!0}}function wd(n,e,t){const o=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let s=0;s<o.length;s++){const i=e.table.nodeAt(o[s]);if(i&&i.type!==t.header_cell)return!1}return!0}function tr(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?z1(n):function(t,o){if(!cs(t))return!1;if(o){const s=Ge(t.schema),i=xd(t),r=t.tr,l=wd("row",i,s),a=wd("column",i,s),d=(n==="column"?l:n==="row"?a:!1)?1:0,p=n=="column"?{left:0,top:d,right:1,bottom:i.map.height}:n=="row"?{left:d,top:0,right:i.map.width,bottom:1}:i,u=n=="column"?a?s.cell:s.header_cell:n=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(p).forEach(h=>{const f=h+i.tableStart,m=r.doc.nodeAt(f);m&&r.setNodeMarkup(f,u,m.attrs)}),o(r)}return!0}}tr("row",{useDeprecatedLogic:!0}),tr("column",{useDeprecatedLogic:!0}),tr("cell",{useDeprecatedLogic:!0});function B1(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let o=n.index(-1)-1,s=n.before();o>=0;o--){const i=n.node(-1).child(o),r=i.lastChild;if(r)return s-1-r.nodeSize;s-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let o=n.indexAfter(-1),s=n.after();o<t.childCount;o++){const i=t.child(o);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function Cd(n){return function(e,t){if(!cs(e))return!1;const o=B1(Xi(e),n);if(o==null)return!1;if(t){const s=e.doc.resolve(o);t(e.tr.setSelection($.between(s,A1(s))).scrollIntoView())}return!0}}function ds(n,e){const t=n.selection;if(!(t instanceof Y))return!1;if(e){const o=n.tr,s=Ge(n.schema).cell.createAndFill().content;t.forEachCell((i,r)=>{i.content.eq(s)||o.replace(o.mapping.map(r+1),o.mapping.map(r+i.nodeSize-1),new A(s,0,0))}),o.docChanged&&e(o)}return!0}function V1(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:o}=n;for(;e.childCount==1&&(t>0&&o>0||e.child(0).type.spec.tableRole=="table");)t--,o--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,r=s.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),p=a<e.childCount-1?0:Math.max(0,o-1);(d||p)&&(c=nr(Ge(r).row,new A(c,d,p)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||o?nr(Ge(r).row,new A(e,t,o)).content:e);else return null;return H1(r,l)}function H1(n,e){const t=[];for(let s=0;s<e.length;s++){const i=e[s];for(let r=i.childCount-1;r>=0;r--){const{rowspan:l,colspan:a}=i.child(r).attrs;for(let c=s;c<s+l;c++)t[c]=(t[c]||0)+a}}let o=0;for(let s=0;s<t.length;s++)o=Math.max(o,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(T.empty),t[s]<o){const i=Ge(n).cell.createAndFill(),r=[];for(let l=t[s];l<o;l++)r.push(i);e[s]=e[s].append(T.from(r))}return{height:e.length,width:o,rows:e}}function nr(n,e){const t=n.createAndFill();return new Na(t).replace(0,t.content.size,e).doc}function F1({width:n,height:e,rows:t},o,s){if(n!=o){const i=[],r=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=i[l]||0,p=0;d<o;p++){let u=a.child(p%a.childCount);d+u.attrs.colspan>o&&(u=u.type.createChecked(Cn(u.attrs,u.attrs.colspan,d+u.attrs.colspan-o),u.content)),c.push(u),d+=u.attrs.colspan;for(let h=1;h<u.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+u.attrs.colspan}r.push(T.from(c))}t=r,n=o}if(e!=s){const i=[];for(let r=0,l=0;r<s;r++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let p=c.child(d);r+p.attrs.rowspan>s&&(p=p.type.create({...p.attrs,rowspan:Math.max(1,s-p.attrs.rowspan)},p.content)),a.push(p)}i.push(T.from(a))}t=i,e=s}return{width:n,height:e,rows:t}}function _1(n,e,t,o,s,i,r){const l=n.doc.type.schema,a=Ge(l);let c,d;if(s>e.width)for(let p=0,u=0;p<e.height;p++){const h=t.child(p);u+=h.nodeSize;const f=[];let m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=d||(d=a.header_cell.createAndFill());for(let g=e.width;g<s;g++)f.push(m);n.insert(n.mapping.slice(r).map(u-1+o),f)}if(i>e.height){const p=[];for(let f=0,m=(e.height-1)*e.width;f<Math.max(e.width,s);f++){const g=f>=e.width?!1:t.nodeAt(e.map[m+f]).type==a.header_cell;p.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const u=a.row.create(null,T.from(p)),h=[];for(let f=e.height;f<i;f++)h.push(u);n.insert(n.mapping.slice(r).map(o+t.nodeSize-2),h)}return!!(c||d)}function kd(n,e,t,o,s,i,r,l){if(r==0||r==e.height)return!1;let a=!1;for(let c=s;c<i;c++){const d=r*e.width+c,p=e.map[d];if(e.map[d-e.width]==p){a=!0;const u=t.nodeAt(p),{top:h,left:f}=e.findCell(p);n.setNodeMarkup(n.mapping.slice(l).map(p+o),null,{...u.attrs,rowspan:r-h}),n.insert(n.mapping.slice(l).map(e.positionAt(r,f,t)),u.type.createAndFill({...u.attrs,rowspan:h+u.attrs.rowspan-r})),c+=u.attrs.colspan-1}}return a}function Ed(n,e,t,o,s,i,r,l){if(r==0||r==e.width)return!1;let a=!1;for(let c=s;c<i;c++){const d=c*e.width+r,p=e.map[d];if(e.map[d-1]==p){a=!0;const u=t.nodeAt(p),h=e.colCount(p),f=n.mapping.slice(l).map(p+o);n.setNodeMarkup(f,null,Cn(u.attrs,r-h,u.attrs.colspan-(r-h))),n.insert(f+u.nodeSize,u.type.createAndFill(Cn(u.attrs,0,r-h))),c+=u.attrs.rowspan-1}}return a}function Td(n,e,t,o,s){let i=t?n.doc.nodeAt(t-1):n.doc;if(!i)throw new Error("No table found");let r=J.get(i);const{top:l,left:a}=o,c=a+s.width,d=l+s.height,p=n.tr;let u=0;function h(){if(i=t?p.doc.nodeAt(t-1):p.doc,!i)throw new Error("No table found");r=J.get(i),u=p.mapping.maps.length}_1(p,r,i,t,c,d,u)&&h(),kd(p,r,i,t,a,c,l,u)&&h(),kd(p,r,i,t,a,c,d,u)&&h(),Ed(p,r,i,t,l,d,a,u)&&h(),Ed(p,r,i,t,l,d,c,u)&&h();for(let f=l;f<d;f++){const m=r.positionAt(f,a,i),g=r.positionAt(f,c,i);p.replace(p.mapping.slice(u).map(m+t),p.mapping.slice(u).map(g+t),new A(s.rows[f-l],0,0))}h(),p.setSelection(new Y(p.doc.resolve(t+r.positionAt(l,a,i)),p.doc.resolve(t+r.positionAt(d-1,c-1,i)))),e(p)}var G1=nc({ArrowLeft:us("horiz",-1),ArrowRight:us("horiz",1),ArrowUp:us("vert",-1),ArrowDown:us("vert",1),"Shift-ArrowLeft":hs("horiz",-1),"Shift-ArrowRight":hs("horiz",1),"Shift-ArrowUp":hs("vert",-1),"Shift-ArrowDown":hs("vert",1),Backspace:ds,"Mod-Backspace":ds,Delete:ds,"Mod-Delete":ds});function ps(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function us(n,e){return(t,o,s)=>{if(!s)return!1;const i=t.selection;if(i instanceof Y)return ps(t,o,L.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;const r=Md(s,n,e);if(r==null)return!1;if(n=="horiz")return ps(t,o,L.near(t.doc.resolve(i.head+e),e));{const l=t.doc.resolve(r),a=vd(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),ps(t,o,c)}}}function hs(n,e){return(t,o,s)=>{if(!s)return!1;const i=t.selection;let r;if(i instanceof Y)r=i;else{const a=Md(s,n,e);if(a==null)return!1;r=new Y(t.doc.resolve(a))}const l=vd(r.$headCell,n,e);return l?ps(t,o,new Y(r.$anchorCell,l)):!1}}function W1(n,e){const t=n.state.doc,o=eo(t.resolve(e));return o?(n.dispatch(n.state.tr.setSelection(new Y(o))),!0):!1}function j1(n,e,t){if(!cs(n.state))return!1;let o=V1(t);const s=n.state.selection;if(s instanceof Y){o||(o={width:1,height:1,rows:[T.from(nr(Ge(n.state.schema).cell,t))]});const i=s.$anchorCell.node(-1),r=s.$anchorCell.start(-1),l=J.get(i).rectBetween(s.$anchorCell.pos-r,s.$headCell.pos-r);return o=F1(o,l.right-l.left,l.bottom-l.top),Td(n.state,n.dispatch,r,l,o),!0}else if(o){const i=Xi(n.state),r=i.start(-1);return Td(n.state,n.dispatch,r,J.get(i.node(-1)).findCell(i.pos-r),o),!0}else return!1}function q1(n,e){var t;if(e.ctrlKey||e.metaKey)return;const o=Ad(n,e.target);let s;if(e.shiftKey&&n.state.selection instanceof Y)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(s=eo(n.state.selection.$anchor))!=null&&((t=or(n,e))==null?void 0:t.pos)!=s.pos)i(s,e),e.preventDefault();else if(!o)return;function i(a,c){let d=or(n,c);const p=bt.getState(n.state)==null;if(!d||!er(a,d))if(p)d=a;else return;const u=new Y(a,d);if(p||!n.state.selection.eq(u)){const h=n.state.tr.setSelection(u);p&&h.setMeta(bt,a.pos),n.dispatch(h)}}function r(){n.root.removeEventListener("mouseup",r),n.root.removeEventListener("dragstart",r),n.root.removeEventListener("mousemove",l),bt.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(bt,-1))}function l(a){const c=a,d=bt.getState(n.state);let p;if(d!=null)p=n.state.doc.resolve(d);else if(Ad(n,c.target)!=o&&(p=or(n,e),!p))return r();p&&i(p,c)}n.root.addEventListener("mouseup",r),n.root.addEventListener("dragstart",r),n.root.addEventListener("mousemove",l)}function Md(n,e,t){if(!(n.state.selection instanceof $))return null;const{$head:o}=n.state.selection;for(let s=o.depth-1;s>=0;s--){const i=o.node(s);if((t<0?o.index(s):o.indexAfter(s))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=o.before(s),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Ad(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function or(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?eo(n.state.doc.resolve(t.pos)):null}var U1=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")),sr(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,sr(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function sr(n,e,t,o,s,i){var r;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let p=0,u=0;p<d.childCount;p++){const{colspan:h,colwidth:f}=d.child(p).attrs;for(let m=0;m<h;m++,u++){const g=s==u?i:f&&f[m],b=g?g+"px":"";if(l+=g||o,g||(a=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const C=document.createElement("col");C.style.width=b,e.appendChild(C)}}}for(;c;){const p=c.nextSibling;(r=c.parentNode)==null||r.removeChild(c),c=p}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var we=new _n("tableColumnResizing");function K1({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:o=U1,lastColumnResizable:s=!0}={}){const i=new gn({key:we,state:{init(r,l){var a,c;const d=(c=(a=i.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,p=Ge(l.schema).table.name;return o&&d&&(d[p]=(u,h)=>new o(u,t,h)),new J1(-1,!1)},apply(r,l){return l.apply(r)}},props:{attributes:r=>{const l=we.getState(r);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(r,l)=>{Z1(r,l,n,s)},mouseleave:r=>{Y1(r)},mousedown:(r,l)=>{X1(r,l,e,t)}},decorations:r=>{const l=we.getState(r);if(l&&l.activeHandle>-1)return o0(r,l.activeHandle)},nodeViews:{}}});return i}var J1=class Es{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,o=e.getMeta(we);if(o&&o.setHandle!=null)return new Es(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new Es(t.activeHandle,o.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);return Qi(e.doc.resolve(s))||(s=-1),new Es(s,t.dragging)}return t}};function Z1(n,e,t,o){const s=we.getState(n.state);if(s&&!s.dragging){const i=e0(e.target);let r=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?r=Pd(n,e,"left",t):a-e.clientX<=t&&(r=Pd(n,e,"right",t))}if(r!=s.activeHandle){if(!o&&r!==-1){const l=n.state.doc.resolve(r),a=l.node(-1),c=J.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Od(n,r)}}}function Y1(n){const e=we.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Od(n,-1)}function X1(n,e,t,o){var s;const i=(s=n.dom.ownerDocument.defaultView)!=null?s:window,r=we.getState(n.state);if(!r||r.activeHandle==-1||r.dragging)return!1;const l=n.state.doc.nodeAt(r.activeHandle),a=Q1(n,r.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(we,{setDragging:{startX:e.clientX,startWidth:a}}));function c(p){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const u=we.getState(n.state);u!=null&&u.dragging&&(t0(n,u.activeHandle,Nd(u.dragging,p,t)),n.dispatch(n.state.tr.setMeta(we,{setDragging:null})))}function d(p){if(!p.which)return c(p);const u=we.getState(n.state);if(u&&u.dragging){const h=Nd(u.dragging,p,t);Id(n,u.activeHandle,h,o)}}return Id(n,r.activeHandle,a,o),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function Q1(n,e,{colspan:t,colwidth:o}){const s=o&&o[o.length-1];if(s)return s;const i=n.domAtPos(e);let l=i.node.childNodes[i.offset].offsetWidth,a=t;if(o)for(let c=0;c<t;c++)o[c]&&(l-=o[c],a--);return l/a}function e0(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Pd(n,e,t,o){const s=t=="right"?-o:o,i=n.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:r}=i,l=eo(n.state.doc.resolve(r));if(!l)return-1;if(t=="right")return l.pos;const a=J.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 Nd(n,e,t){const o=e.clientX-n.startX;return Math.max(t,n.startWidth+o)}function Od(n,e){n.dispatch(n.state.tr.setMeta(we,{setHandle:e}))}function t0(n,e,t){const o=n.state.doc.resolve(e),s=o.node(-1),i=J.get(s),r=o.start(-1),l=i.colCount(o.pos-r)+o.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<i.height;c++){const d=c*i.width+l;if(c&&i.map[d]==i.map[d-i.width])continue;const p=i.map[d],u=s.nodeAt(p).attrs,h=u.colspan==1?0:l-i.colCount(p);if(u.colwidth&&u.colwidth[h]==t)continue;const f=u.colwidth?u.colwidth.slice():n0(u.colspan);f[h]=t,a.setNodeMarkup(r+p,null,{...u,colwidth:f})}a.docChanged&&n.dispatch(a)}function Id(n,e,t,o){const s=n.state.doc.resolve(e),i=s.node(-1),r=s.start(-1),l=J.get(i).colCount(s.pos-r)+s.nodeAfter.attrs.colspan-1;let a=n.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&sr(i,a.firstChild,a,o,l,t)}function n0(n){return Array(n).fill(0)}function o0(n,e){var t;const o=[],s=n.doc.resolve(e),i=s.node(-1);if(!i)return U.empty;const r=J.get(i),l=s.start(-1),a=r.colCount(s.pos-l)+s.nodeAfter.attrs.colspan-1;for(let c=0;c<r.height;c++){const d=a+c*r.width;if((a==r.width-1||r.map[d]!=r.map[d+1])&&(c==0||r.map[d]!=r.map[d-r.width])){const p=r.map[d],u=l+p+i.nodeAt(p).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",(t=we.getState(n))!=null&&t.dragging&&o.push(ye.node(l+p,l+p+i.nodeAt(p).nodeSize,{class:"column-resize-dragging"})),o.push(ye.widget(u,h))}}return U.create(n.doc,o)}function s0({allowTableNodeSelection:n=!1}={}){return new gn({key:bt,state:{init(){return null},apply(e,t){const o=e.getMeta(bt);if(o!=null)return o==-1?null:o;if(t==null||!e.docChanged)return t;const{deleted:s,pos:i}=e.mapping.mapResult(t);return s?null:i}},props:{decorations:N1,handleDOMEvents:{mousedown:q1},createSelectionBetween(e){return bt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:W1,handleKeyDown:G1,handlePaste:j1},appendTransaction(e,t,o){return R1(o,L1(o,t),n)}})}const to=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},ir=n=>{const{key:e,cssProperty:t,tagName:o="span"}=n,s="value";return{attrs:{...ms,[s]:{default:null}},parseDOM:[{tag:`${o}[${e}]`,getAttrs:i=>({...gs(i),[s]:i.style.getPropertyValue(t)||null})}],toDOM(i){const{[s]:r}=i.attrs,l={...qe(i),[e]:""};return r&&(l.style=`${t}: ${r}`),[o,l,0]}}},Rd="data-gs-mrk-fs",i0="data-gs-mrk-color",r0="data-gs-mrk-bgcolor",Dd="data-gs-mrk-wrap",fs="data-gs-ifrg",et="attrs",ms={[et]:{default:"{}"}},We={[et]:{default:{}}},gs=n=>({[et]:JSON.stringify(to(n))}),je=n=>({attrs:to(n)}),no=n=>e=>[n,e.attrs.attrs,0],qe=n=>n.attrs[et]?JSON.parse(n.attrs[et]):{},l0={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${fs}]`,getAttrs:je}],toDOM:()=>["span",{[fs]:""},0]},div:{group:"block",content:"inline*",attrs:We,parseDOM:[{tag:"div",getAttrs:je}],toDOM:no("div")},paragraph:{group:"block",content:"inline*",attrs:We,parseDOM:[{tag:"p",getAttrs:je}],toDOM:no("p")},orderedList:{group:"block",content:"listItem+",attrs:We,parseDOM:[{tag:"ol",getAttrs:je}],toDOM:no("ol")},bulletList:{group:"block",content:"listItem+",attrs:We,parseDOM:[{tag:"ul",getAttrs:je}],toDOM:no("ul")},listItem:{content:"block*",group:"block",attrs:We,parseDOM:[{tag:"li",getAttrs:je}],toDOM:no("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:We,parseDOM:[{tag:"pre",getAttrs:je}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:We,parseDOM:[{tag:"img[src]",getAttrs:je}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,attrs:We,parseDOM:[{tag:"br",getAttrs:je}],toDOM:n=>["br",{...n.attrs.attrs}]},hardBreak:{inline:!0,group:"inline",selectable:!1,attrs:We,parseDOM:[{tag:"br",getAttrs:je}],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:to(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...T1({tableGroup:"block",cellContent:"block+",cellAttributes:{[et]:{default:We[et].default,getFromDOM:to,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:to(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},oo=(n,e)=>({attrs:ms,parseDOM:n.map(t=>({tag:t,getAttrs:gs})),toDOM:e}),a0=n=>({attrs:{...ms},parseDOM:[{tag:`span[${n}]`,getAttrs:e=>({...gs(e)})}],toDOM(e){return["span",{...qe(e),[n]:!0},0]}}),c0={strong:oo(["strong","b"],n=>["b",qe(n)]),link:oo(["a"],n=>["a",qe(n),0]),em:oo(["em","i"],n=>["em",qe(n)]),underline:oo(["u"],n=>["u",qe(n),0]),strikethrough:oo(["s"],n=>["s",qe(n),0]),wrapStyle:a0(Dd),font_size:{attrs:{...ms,size:{default:null}},parseDOM:[{tag:`span[${Rd}]`,getAttrs:n=>({...gs(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...qe(n),[Rd]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}},color:ir({key:i0,cssProperty:"color"}),bgColor:ir({key:r0,cssProperty:"background-color"})},Ld=new Tf({nodes:l0,marks:c0}),so=new WeakMap,rr=new WeakMap,d0=(n,e,t)=>{so.set(n,{view:e,gjsView:t,initialDoc:e.state.doc}),rr.set(e,{el:n,gjsView:t})},p0=(n,e)=>{so.delete(n),rr.delete(e)},ys=n=>so.get(n),$d=n=>rr.get(n),zd=n=>{const e=ys(n),t=e==null?void 0:e.view,o=e==null?void 0:e.initialDoc;return!(t&&o&&o.eq(t.state.doc))},lr=n=>{var e,t;return(t=(e=$d(n))==null?void 0:e.gjsView)==null?void 0:t.model},u0=n=>n.dispatchEvent(new CustomEvent("input"));function h0(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(fs)){if(t.getAttribute("style")){t.removeAttribute(fs);return}const o=t.parentElement;if(o){for(;t.firstChild;)o.insertBefore(t.firstChild,t);o.removeChild(t)}}else Array.from(t.children).forEach(o=>e(o))};e(n)}const Bd=n=>{n.childNodes.forEach(e=>{if(e.nodeName==="BR"){const{nextSibling:t}=e,o=n.lastChild===e,s=(t==null?void 0:t.nodeType)===Node.ELEMENT_NODE&&(t==null?void 0:t.nodeName)!=="BR";(o||s)&&e.remove()}else Bd(e)})},f0=(n,e)=>{const t=Vd(n);return t&&T0(t)?g0(n,e):t?ja(()=>({type:n.schema.nodes.div}))(n,e):!1},m0=(n,e)=>(t,o)=>{var l;const s=Vd(t),i=so.get(n.el).view,r=(l=e.onEnter)==null?void 0:l.call(e,{...n,node:s,commands:dr(i,n.editor,e),proseMirror:{view:i,dispatch:o}});return r!==void 0?r:f0(t,o)};function Vd(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 g0(n,e){const{selection:t,schema:o,tr:s}=n;s.split(t.from,1);const i=t.from+1,r=s.doc.nodeAt(i),l={...r.attrs.attrs,id:void 0},a=r.textContent.length>0,c=r.textContent.length||0,d=r.textContent||" ",p=o.text(d),u=o.nodes.div.create(l,a?p:[],[]);return s.replaceRangeWith(i,i+c+2,u),s.setSelection($.create(s.doc,i+1)),e==null||e(s.scrollIntoView()),!0}function y0(n,e,t){const{state:o,dispatch:s}=n,{selection:i,tr:r}=o,l=(a,c,d)=>{const p={};return a.split(";").forEach(u=>{const[h,f]=u.split(":").map(m=>m.trim());h&&(p[h]=f)}),p[c]=d,Object.entries(p).map(([u,h])=>`${u}: ${h}`).join("; ")};if(!i.empty||t)r.doc.nodesBetween(i.from,i.to,(a,c)=>{var d,p;if(a.type===o.schema.nodes.image){const u=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}else if(a.type.isBlock){const u=l(((p=a.attrs.attrs)==null?void 0:p.style)||"","text-align",e);Hd(a)?r.setBlockType(i.from,void 0,o.schema.nodes.div,{attrs:{style:u}}):r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}});else{const a=o.doc.resolve(i.from),c=a.start(a.depth),d=o.doc.nodeAt(c);if(d!=null&&d.type.isBlock){const p=l(d.attrs.style||"","text-align",e);r.setNodeMarkup(c,void 0,{...d.attrs,style:p})}}r.docChanged&&s(r.scrollIntoView())}const io=(n,e)=>{const{from:t,to:o}=n.selection;let s=!1;return n.doc.nodesBetween(t,o,i=>{if(s)return!1;i.marks.some(r=>r.type===e)&&(s=!0)}),s};function b0(n){var p,u;const{view:e,href:t,options:o,target:s="_blank"}=n,{state:i,dispatch:r}=e,{schema:l,selection:a,tr:c}=i,d=l.marks.link;try{const h={href:t,target:s},f=((u=(p=o.commandAttrs)==null?void 0:p.link)==null?void 0:u.call(p,h))||h,m=d.create({[et]:JSON.stringify(f)});c.addMark(a.from,a.to,m),r(c.scrollIntoView())}catch(h){console.error("Error applying link mark:",h)}}function v0(n,e){const{state:t,dispatch:o}=n,{selection:s,tr:i}=t;if(s.empty)return;const r=t.schema.marks.font_size;if(!r){console.error("Font size mark is not defined in the schema.");return}i.addMark(s.from,s.to,r.create({size:e})),o(i.scrollIntoView())}function S0(n,e){const{state:t,dispatch:o}=n,{selection:s,tr:i}=t;if(s.empty)return;const r=t.schema.marks.color;if(!r){console.error("Color mark is not defined in the schema.");return}i.addMark(s.from,s.to,r.create({value:e})),o(i.scrollIntoView())}function x0(n,e){const{state:t,dispatch:o}=n,{selection:s,tr:i}=t;if(s.empty)return;const r=t.schema.marks.bgColor;if(!r){console.error("Background color mark is not defined in the schema.");return}i.addMark(s.from,s.to,r.create({value:e})),o(i.scrollIntoView())}const Wt=(n,e)=>{const{doc:t,selection:o}=n.state,s=t.resolve(o.from);for(let i=s.depth;i>0;i--){const r=s.node(i);if(e(r))return{pos:i>0?s.before(i):0,start:s.start(i),depth:i,node:r}}},w0=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 C0(...n){return(e,t)=>{const o=r=>{e=e.apply(r),t==null||t(r)},s=n.pop();return n.reduce((r,l)=>r||l(e,o),!1)&&s!==void 0&&s(e,t)}}const k0=(n,e)=>{const{state:t,dispatch:o}=n;if(e!=null&&e.event){const{event:s}=e,i=n.posAtCoords({left:s.clientX,top:s.clientY});i!=null&&i.pos&&o(t.tr.setSelection($.create(t.doc,i.pos)))}else qa(t,o);setTimeout(()=>setTimeout(()=>n.focus()))},ar=n=>n.isBlock,Hd=n=>n.type.name==="inlineFragment",E0=n=>ar(n)&&!Hd(n),Fd=n=>n.type.name==="bulletList",_d=n=>n.type.name==="orderedList",T0=n=>n.type.name==="heading",M0=n=>Fd(n)||_d(n),Gd=(n,e)=>{var i,r;const t=(i=Wt(n,l=>l.type===e))==null?void 0:i.node,o=n.state.schema.nodes.listItem;let s;return t?s=Ti(o):(r=Wt(n,M0))!=null&&r.node?s=C0(Ti(o),oc(e)):s=oc(e),s(n.state,n.dispatch)},Wd=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(o=>o.type.name===e)},A0=n=>{var r;const{view:e,prop:t,editor:o,propCSS:s}=n,i=(r=Wt(e,E0))==null?void 0:r.node;if(i){const l=i.attrs.attrs||{},a=w0(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""},cr=n=>{const{view:e,prop:t,markName:o,editor:s,propCSS:i}=n,r=Wd(e,o);if(r){const l=r.attrs;if(l[t])return l[t];if(l[et]){const a=qe(r).id;if(a){const c=s.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[i]||""}}}return""},dr=(n,e,t)=>{const{dispatch:o}=n,{nodes:s,marks:i}=n.state.schema,r={text:{selected:()=>{const{selection:l,doc:a}=n.state;return a.textBetween(l.from,l.to," ")},replace:(l,a={})=>{const{state:c}=n,{from:d}=c.selection;let p=c.tr.replaceSelectionWith(c.schema.text(l));a.select&&(p=p.setSelection($.create(p.doc,d,d+l.length))),o==null||o(p)},replaceHtml:l=>{const{schema:a,selection:c,tr:d}=n.state,p=document.createElement("div");p.innerHTML=l;const u=Rt.fromSchema(a).parse(p),{from:h,to:f}=c;return o==null?void 0:o(d.replaceRangeWith(h,f,u).scrollIntoView())},wrapStyle:()=>{const l=lr(n),a=r.text.selected(),c=`i${e.Components._createId().slice(0,4)}`;r.text.replaceHtml(`<span id="${c}" ${Dd}>${a}</span>`),l==null||l.trigger("disable"),setTimeout(()=>{const d=l==null?void 0:l.find(`#${c}`)[0];d&&e.select(d)})},createBreak:()=>{const{state:l}=n,a=l.tr.replaceSelectionWith(s.inlineBreak.create()).scrollIntoView();return o==null?void 0:o(a)}},bold:{toggle:()=>Lt(i.strong)(n.state,o),isActive:()=>io(n.state,i.strong)},italic:{toggle:()=>Lt(i.em)(n.state,o),isActive:()=>io(n.state,i.em)},underline:{toggle:()=>Lt(i.underline)(n.state,o),isActive:()=>io(n.state,i.underline)},strikethrough:{toggle:()=>Lt(i.strikethrough)(n.state,o),isActive:()=>io(n.state,i.strikethrough)},link:{get:()=>{const l=lr(n),a=l==null?void 0:l.getTrait("href");if(l!=null&&l.is("link"))return l.getAttributes();if(a)return{href:a.getValue()};{const c=Wd(n,"link");return c?qe(c):{}}},toggle:()=>Lt(i.link)(n.state,o),isActive:()=>io(n.state,i.link),create:l=>{const a=lr(n),c=a==null?void 0:a.getTrait("href"),{url:d,target:p}=l,u=()=>{var f,m;const h=(m=(f=$d(n))==null?void 0:f.gjsView)==null?void 0:m.el;h&&h.contentEditable!=="true"&&(h.contentEditable="true"),n.focus()};a!=null&&a.is("link")?(a.addAttributes({href:d,target:p}),u()):c?(a==null||a.addAttributes({[c.getName()]:d}),u()):b0({view:n,href:d,target:p,options:t})}},alignText:{get:()=>A0({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:l=>y0(n,l.value,!0)},fontSize:{get:()=>cr({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:l=>v0(n,l.value)},color:{get:()=>cr({view:n,editor:e,markName:"color",prop:"value",propCSS:"color"}),set:l=>S0(n,l.value)},bgColor:{get:()=>cr({view:n,editor:e,markName:"bgColor",prop:"value",propCSS:"background-color"}),set:l=>x0(n,l.value)},image:{open(){const l="assetLayout",{state:a,dispatch:c}=n,{selection:d,doc:p}=a,u=p.textBetween(d.from,d.to," "),h={id:l,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:f=>{const m={alt:u,src:f.asset.getSrc()};c(a.tr.replaceSelectionWith(s.image.createAndFill({attrs:m})))}}};e.runCommand(j.layoutToggle,h)}},heading:{get:()=>{var a;const l=(a=Wt(n,ar))==null?void 0:a.node;return`${(l==null?void 0:l.attrs.level)||""}`},set:({value:l})=>{var d;const{state:a}=n,c=(d=Wt(n,ar))==null?void 0:d.node;vm(a.schema.nodes.heading,{attrs:c==null?void 0:c.attrs.attrs,level:l?parseInt(l,10):0})(a,o)}},listBullet:{isActive:()=>{var l;return!!((l=Wt(n,Fd))!=null&&l.node)},toggle:()=>Gd(n,s.bulletList)},listOrdered:{isActive:()=>{var l;return!!((l=Wt(n,_d))!=null&&l.node)},toggle:()=>Gd(n,s.orderedList)}};return r};class vt{constructor(e,t,o={}){this.match=e,this.match=e,this.handler=typeof t=="string"?P0(t):t,this.undoable=o.undoable!==!1,this.inCode=o.inCode||!1}}function P0(n){return function(e,t,o,s){let i=n;if(t[1]){let r=t[0].lastIndexOf(t[1]);i+=t[0].slice(r+t[1].length),o+=r;let l=o-s;l>0&&(i=t[0].slice(r-l,r)+i,o=s)}return e.tr.insertText(i,o,s)}}const N0=500;function O0({rules:n}){let e=new gn({state:{init(){return null},apply(t,o){let s=t.getMeta(this);return s||(t.selectionSet||t.docChanged?null:o)}},props:{handleTextInput(t,o,s,i){return jd(t,o,s,i,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:o}=t.state.selection;o&&jd(t,o.pos,o.pos,"",n,e)})}}},isInputRules:!0});return e}function jd(n,e,t,o,s,i){if(n.composing)return!1;let r=n.state,l=r.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-N0),l.parentOffset,null,"")+o;for(let c=0;c<s.length;c++){let d=s[c];if(l.parent.type.spec.code){if(!d.inCode)continue}else if(d.inCode==="only")continue;let p=d.match.exec(a),u=p&&d.handler(r,p,e-(p[0].length-o.length),t);if(u)return d.undoable&&u.setMeta(i,{transform:u,from:e,to:t,text:o}),n.dispatch(u),!0}return!1}const I0=new vt(/--$/,"—"),R0=new vt(/\.\.\.$/,"…"),D0=new vt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),L0=new vt(/"$/,"”"),$0=new vt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),z0=new vt(/'$/,"’"),B0=[D0,L0,$0,z0];function pr(n,e,t=null,o){return new vt(n,(s,i,r,l)=>{let a=t instanceof Function?t(i):t,c=s.tr.delete(r,l),d=c.doc.resolve(r),p=d.blockRange(),u=p&&wa(p,e,a);if(!u)return null;c.wrap(p,u);let h=c.doc.resolve(r-1).nodeBefore;return h&&h.type==e&&Ko(c.doc,r-1)&&(!o||o(i,h))&&c.join(r-1),c})}function qd(n,e,t=null){return new vt(n,(o,s,i,r)=>{let l=o.doc.resolve(i),a=t instanceof Function?t(s):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?o.tr.delete(i,r).setBlockType(i,i,e,a):null})}function V0(n){return pr(/^\s*>\s$/,n)}function H0(n){return pr(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function F0(n){return pr(/^\s*([-+*])\s$/,n)}function _0(n){return qd(/^```$/,n)}function G0(n,e){return qd(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function W0(n){const e=B0.concat(R0,I0);let t;return(t=n.nodes.blockquote)&&e.push(V0(t)),(t=n.nodes.orderedList)&&e.push(H0(t)),(t=n.nodes.bulletList)&&e.push(F0(t)),(t=n.nodes.codeBlock)&&e.push(_0(t)),(t=n.nodes.heading)&&e.push(G0(t,6)),O0({rules:e})}const j0="rteProseMirror",q0=F.free,pe="rte:selectionchange",X={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>',color:'<svg viewBox="0 0 24 24"><path d="M9.62,12L12,5.67L14.37,12M11,3L5.5,17H7.75L8.87,14H15.12L16.25,17H18.5L13,3H11Z" /></svg>',bgColor:'<svg viewBox="0 0 24 24"><path d="M19,11.5C19,11.5 17,13.67 17,15A2,2 0 0,0 19,17A2,2 0 0,0 21,15C21,13.67 19,11.5 19,11.5M5.21,10L10,5.21L14.79,10M16.56,8.94L7.62,0L6.21,1.41L8.59,3.79L3.44,8.94C2.85,9.5 2.85,10.47 3.44,11.06L8.94,16.56C9.23,16.85 9.62,17 10,17C10.38,17 10.77,16.85 11.06,16.56L16.56,11.06C17.15,10.47 17.15,9.5 16.56,8.94Z" /></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>'},Ud=n=>({state:e})=>({type:"column",style:{alignItems:"center",background:"none"},children:[{type:"icon",icon:n,size:16},{type:"row",style:{width:16,height:2,backgroundColor:e.value||"currentColor",borderRadius:1}}]}),U0=(n,e)=>{var a;const{editor:t,el:o}=n,s=so.get(o).view,i=dr(s,t,e),r={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},wrapStyle:{id:"wrapper",type:"button",icon:"tag",tooltip:"Wrap for styling",editorEvents:{[pe]:({setState:c})=>{c({disabled:s.state.selection.empty})}},onClick:()=>i.text.wrapStyle()},bold:{id:"bold",icon:X.bold,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.bold.isActive()})}},onClick:({setState:c})=>{i.bold.toggle(),c({active:i.bold.isActive()})}},italic:{id:"italic",icon:X.italic,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.italic.isActive()})}},onClick:({setState:c})=>{i.italic.toggle(),c({active:i.italic.isActive()})}},underline:{id:"underline",icon:X.underline,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.underline.isActive()})}},onClick:({setState:c})=>{i.underline.toggle(),c({active:i.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:X.strikethrough,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.strikethrough.isActive()})}},onClick:({setState:c})=>{i.strikethrough.toggle(),c({active:i.strikethrough.isActive()})}},image:{id:"image",icon:X.image,size:"s",type:"button",onClick:()=>i.image.open()},link:{id:"link",icon:X.link,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.link.isActive(),disabled:s.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,p="linkLayout",u=()=>t.runCommand(j.layoutRemove,{id:p}),h=i.link.get(),f={id:p,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,target:d},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:m=>{m.preventDefault();const g=new FormData(m.currentTarget);i.link.create({url:g.get("url"),target:g.get("target")}),u()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(h==null?void 0:h.href)||"",onChange:({value:m,setState:g})=>g({value:m})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(h==null?void 0:h.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:m,setState:g})=>g({value:m})},{type:"row",style:{gap:10,justifyContent:"end"},children:[i.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{i.link.toggle(),u()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(j.layoutToggle,f)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:X.alignTextLeft},{id:"center",icon:X.alignTextCenter},{id:"right",icon:X.alignTextRight},{id:"justify",icon:X.alignTextJustify}],editorEvents:{[pe]:({setState:c})=>{c({value:i.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.alignText.set({value:c})}},alignTextMenu:{id:"alignTextMenu",type:"buttonMenu",size:"s",value:"",options:[{id:"left",icon:X.alignTextLeft},{id:"center",icon:X.alignTextCenter},{id:"right",icon:X.alignTextRight},{id:"justify",icon:X.alignTextJustify}],editorEvents:{[pe]:({setState:c})=>{c({value:i.alignText.get()})}},onOptionSelect:({option:c,state:d,setState:p})=>{const u=c.id===d.value?"":c.id;p({value:u}),i.alignText.set({value:u})},onClick:({state:c})=>{c.value&&i.alignText.set({value:c.value})}},listBullet:{id:"listBullet",icon:X.listBullet,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.listBullet.isActive()})}},onClick:({setState:c})=>{i.listBullet.toggle(),c({active:i.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:X.listOrdered,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.listOrdered.isActive()})}},onClick:({setState:c})=>{i.listOrdered.toggle(),c({active:i.listOrdered.isActive()})}},heading:{id:"heading",type:"selectField",size:"s",value:"",emptyState:"Heading",options:[{id:"",label:"Normal"},{id:"1",label:"Heading 1"},{id:"2",label:"Heading 2"},{id:"3",label:"Heading 3"},{id:"4",label:"Heading 4"},{id:"5",label:"Heading 5"},{id:"6",label:"Heading 6"}],editorEvents:{[pe]:({setState:c})=>{c({value:i.heading.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.heading.set({value:c}),s.focus()}},fontSize:{id:"fontSize",type:"selectField",size:"s",value:"",emptyState:"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:{[pe]:({setState:c})=>{c({value:i.fontSize.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.fontSize.set({value:c}),s.focus()}},color:{id:"color",type:"buttonMenu",size:"s",value:"",label:Ud(X.color),editorEvents:{[pe]:({setState:c})=>{c({disabled:s.state.selection.empty})}},children:({state:c,setState:d})=>({type:"colorPicker",value:c.value||"",onChange:p=>{const{value:u}=p;d({value:u}),p.setState({value:u}),i.color.set({value:u}),s.focus()}}),onClick:({state:c})=>{c.value&&(i.color.set({value:c.value}),s.focus())}},bgColor:{id:"bgColor",type:"buttonMenu",size:"s",value:"",label:Ud(X.bgColor),editorEvents:{[pe]:({setState:c})=>{c({disabled:s.state.selection.empty})}},children:({state:c,setState:d})=>({type:"colorPicker",value:c.value||"",onChange:p=>{const{value:u}=p;d({value:u}),p.setState({value:u}),i.bgColor.set({value:u}),s.focus()}}),onClick:({state:c})=>{c.value&&(i.bgColor.set({value:c.value}),s.focus())}}},l=[r.bold,r.italic,r.underline,r.strikethrough,r.image,r.link,r.listBullet,r.listOrdered,r.color,r.bgColor,r.alignTextMenu,r.heading,r.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:i,layouts:r,proseMirror:{view:s},items:l}))||l};class K0{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;dr(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 J0=G(function(n,e={}){const t={plugins:l=>l.plugins,...e},o=(l,a)=>{var g,b;const c=((g=t.schema)==null?void 0:g.call(t,{editor:n,schema:Ld,createCustomMark:ir}))||Ld,{nodes:d,marks:p}=c,u={...a,component:a.view.model,editor:n,el:l};Bd(l);const h=Rt.fromSchema(c).parse(l),f=mn.create({doc:h,schema:c,plugins:(b=t.plugins)==null?void 0:b.call(t,{editor:n,Plugin:gn,plugins:[K1(),s0(),W0(c),Nm(),Ei({Tab:Cd(1),"Shift-Tab":Cd(-1)}),Ei({Enter:Gn(Wa,Bm(d.listItem),m0(u,t)),"Shift-Enter":Gn(Ga,(C,y)=>(y&&y(C.tr.replaceSelectionWith(d.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":tc,"Mod-y":wi,"Mod-Shift-z":wi,"Mod-b":Lt(p.strong),"Mod-i":Lt(p.em),"Shift-Tab":Ti(d.listItem),Tab:Fm(d.listItem)}),Ei(xm)]})}),m=new v1({mount:l},{state:f,dispatchTransaction(C){var x;const{state:y}=m,v=y.apply(C),w=!y.doc.eq(v.doc);m.updateState(v);const S=!y.selection.eq(v.selection);w&&(u0(((x=a==null?void 0:a.view)==null?void 0:x.el)||l),m.focus()),(S||w)&&n.trigger(pe)}});return l.__rteView=m,m.setProps({nodeViews:{image(C){return new K0(C,m,n)}}}),m},s=l=>U0(l,t);n.setCustomRte({toolbar:s,parseContent:!0,async enable(l,a,c){const d=ys(l);if(d)return d;const p=o(l,c);return d0(l,p,c.view),k0(p,c),p},disable(l){const a=ys(l),c=a==null?void 0:a.view;if(c){const d=zd(l);return p0(l,c),d||n.once(n.RichTextEditor.events.disable,()=>{a.gjsView.model.trigger("rerender")}),c.destroy(),{forceSync:d}}},getContent(l,a,c){var p;const d=(p=ys(l))==null?void 0:p.view;if(d){const{schema:u,doc:h}=d.state;if(!zd(l))return c.view.lastContent;const f=document.createElement("div"),m=Dt.fromSchema(u).serializeFragment(h.content);return m.childNodes.forEach(g=>{var b;g.nodeType===Node.ELEMENT_NODE&&(g.innerHTML===""?g.innerHTML="<br/>":((b=g.lastChild)==null?void 0:b.nodeName)==="BR"&&g.appendChild(document.createElement("br")))}),f.appendChild(m),h0(f),l.classList.remove("ProseMirror-focused"),f.innerHTML}return l.innerHTML}});const i=Hl(n,t.enableOnClick),r=ef(n,t.disableOnEsc);W({editor:n,licenseKey:t.licenseKey,plan:q0,pluginName:j0,cleanup:()=>{n.RichTextEditor.customRte=void 0,i(),r()}})}),Z0="canvasEmptyState",Y0=F.startup,X0=G(function(n,e={}){const t=new WeakMap,o=new WeakMap,s=new WeakMap,i=new Set,r=new WeakMap,l={emptyStates:[],...e},a=(y,v)=>{let w=!1;const{isValid:S}=v;return Array.isArray(S)?w=S.some(x=>y.is(x)):xt(S)?w=S({component:y,editor:n}):w=y.is(S),w},c=y=>{const v=t.get(y);t.delete(y),v==null||v()},d=y=>{y.views.forEach(v=>c(v)),s.delete(y)},p=y=>{if(!(!y||i.has(y)))try{i.add(y);const v=y.components().length>0,w=s.get(y);if(v&&w)d(y);else if(!v&&!w){const S=r.has(y)?r.get(y):l.emptyStates.find(x=>a(y,x));if(r.set(y,S),!S)return;y.views.forEach(x=>{const k=S.render({editor:n,component:y,componentView:x,mount:E=>{o.set(x,E),s.set(y,!0);const M=x.getChildrenContainer();M==null||M.appendChild(E)},unmount:()=>c(x)});t.set(x,()=>{k==null||k();const E=o.get(x);E==null||E.remove()})})}}finally{i.delete(y)}},u=y=>{s.has(y)&&d(y)},h=({model:y})=>{p(y.getComponent())},f=n.Components.events,m=`${f.update}:components`,g="component:mount",b=n.Canvas.events.frameLoadBody,C=f.removed;n.on(m,p),n.on(g,p),n.on(C,u),n.on(b,h),W({editor:n,licenseKey:l.licenseKey,plan:Y0,pluginName:Z0,cleanup:()=>{n.off(m,p),n.off(g,p),n.off(C,u),n.off(b,h)}})}),Kd="canvasFullSize",Q0=F.startup,ey=(n,e)=>{const{rule:t,ruleView:o}=e,{style:s}=t.attributes;if(s&&s[n]){const i=s[n],r=/([0-9.]+)(vh|dvh|lvh|svh)/g,l=r.test(i),a=o.frameView.model;if(l&&a.hasAutoHeight()){const c=i.replace(r,(p,u)=>`${window.innerHeight*(parseFloat(u)/100)}px`),d=t.toCSS({style:{...s,[n]:c}});e.css=d}}},ty=n=>{["height","min-height","max-height"].forEach(e=>ey(e,n))},ny=G(function(n,e={}){const{Canvas:t,Commands:o,Devices:s,Css:i}=n,r={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...e},{canvasOffsetY:l,canvasOffsetX:a,canvasTransition:c,deviceMaxWidth:d,deviceMinHeigth:p,deviceFixedHeight:u,frameBorderRadius:h,frameTransition:f}=r,m=`${p}px`,g=t.events,b="core:preview",C=`${o.events.stopCommand}${b}`,y=t.getConfig(),v=`${Kd}:disable`,w=s.getAll().map(B=>({...B.attributes})),S=c*1e3,x={x:a,y:l};let k={},E,M;y.scrollableCanvas=!u,s.getAll().map(B=>{!B.get("width")&&B.set("width",`${d}px`),!B.get("height")&&B.set("height",u?"100vh":"auto"),!B.get("minHeight")&&B.set("minHeight",m)});const P=B=>{const be=`${go}canvas-full-size`,ve=document.querySelector(`style[${be}]`);if(B&&ve)return ve.remove();const Ke=ve||document.createElement("style"),Cs=t.getZoomMultiplier();Ke.setAttribute(be,"true"),Ke.innerHTML=`
|
|
916
|
+
`))),0,0):A.empty;let p=n.someProp("clipboardTextParser",u=>u(e,s,o,n));if(p)l=p;else{let u=s.marks(),{schema:h}=n.state,f=Dt.fromSchema(h);r=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=r.appendChild(document.createElement("p"));m&&g.appendChild(f.serializeNode(h.text(m,u)))})}}else n.someProp("transformPastedHTML",p=>{t=p(t,n)}),r=Dg(t),qn&&Lg(r);let c=r&&r.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let p=+d[3];p>0;p--){let u=r.firstChild;for(;u&&u.nodeType!=1;)u=u.nextSibling;if(!u)break;r=u}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Rt.fromSchema(n.state.schema)).parseSlice(r,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!Og.test(u.parentNode.nodeName)?{ignore:!0}:null}})),d)l=$g(qc(l,+d[1],+d[2]),d[4]);else if(l=A.maxOpen(Ig(l.content,s),!0),l.openStart||l.openEnd){let p=0,u=0;for(let h=l.content.firstChild;p<l.openStart&&!h.type.spec.isolating;p++,h=h.firstChild);for(let h=l.content.lastChild;u<l.openEnd&&!h.type.spec.isolating;u++,h=h.lastChild);l=qc(l,p,u)}return n.someProp("transformPasted",p=>{l=p(l,n)}),l}const Og=/^(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 Ig(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),i,r=[];if(n.forEach(l=>{if(!r)return;let a=s.findWrapping(l.type),c;if(!a)return r=null;if(c=r.length&&i.length&&Wc(a,i,l,r[r.length-1],0))r[r.length-1]=c;else{r.length&&(r[r.length-1]=jc(r[r.length-1],i.length));let d=Gc(l,a);r.push(d),s=s.matchType(d.type),i=a}}),r)return T.from(r)}return n}function Gc(n,e,t=0){for(let o=e.length-1;o>=t;o--)n=e[o].create(null,T.from(n));return n}function Wc(n,e,t,o,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let i=Wc(n,e,t,o.lastChild,s+1);if(i)return o.copy(o.content.replaceChild(o.childCount-1,i));if(o.contentMatchAt(o.childCount).matchType(s==n.length-1?t.type:n[s+1]))return o.copy(o.content.append(T.from(Gc(t,n,s+1))))}}function jc(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,jc(n.lastChild,e-1)),o=n.contentMatchAt(n.childCount).fillBefore(T.empty,!0);return n.copy(t.append(o))}function Hi(n,e,t,o,s,i){let r=e<0?n.firstChild:n.lastChild,l=r.content;return n.childCount>1&&(i=0),s<o-1&&(l=Hi(l,e,t,o,s+1,i)),s>=t&&(l=e<0?r.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(r.contentMatchAt(r.childCount).fillBefore(T.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,r.copy(l))}function qc(n,e,t){return e<n.openStart&&(n=new A(Hi(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new A(Hi(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Uc={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 Kc=null;function Jc(){return Kc||(Kc=document.implementation.createHTMLDocument("title"))}let Fi=null;function Rg(n){let e=window.trustedTypes;return e?(Fi||(Fi=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Fi.createHTML(n)):n}function Dg(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Jc().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(n),s;if((s=o&&Uc[o[1].toLowerCase()])&&(n=s.map(i=>"<"+i+">").join("")+n+s.map(i=>"</"+i+">").reverse().join("")),t.innerHTML=Rg(n),s)for(let i=0;i<s.length;i++)t=t.querySelector(s[i])||t;return t}function Lg(n){let e=n.querySelectorAll(ie?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let o=e[t];o.childNodes.length==1&&o.textContent==" "&&o.parentNode&&o.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),o)}}function $g(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,o;try{o=JSON.parse(e)}catch{return n}let{content:s,openStart:i,openEnd:r}=n;for(let l=o.length-2;l>=0;l-=2){let a=t.nodes[o[l]];if(!a||a.hasRequiredAttrs())break;s=T.from(a.create(o[l+1],s)),i++,r++}return new A(s,i,r)}const ce={},de={},zg={touchstart:!0,touchmove:!0};class Bg{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 Vg(n){for(let e in ce){let t=ce[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=o=>{Fg(n,o)&&!Gi(n,o)&&(n.editable||!(o.type in de))&&t(n,o)},zg[e]?{passive:!0}:void 0)}ae&&n.dom.addEventListener("input",()=>null),_i(n)}function mt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Hg(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 _i(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=o=>Gi(n,o))})}function Gi(n,e){return n.someProp("handleDOMEvents",t=>{let o=t[e.type];return o?o(n,e)||e.defaultPrevented:!1})}function Fg(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){!Gi(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,!Yc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(De&&ie&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),bn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let o=Date.now();n.input.lastIOSEnter=o,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==o&&(n.someProp("handleKeyDown",s=>s(n,Bt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",o=>o(n,t))||Ng(n,t)?t.preventDefault():mt(n,"key")},de.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},de.keypress=(n,e)=>{let t=e;if(Yc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Te&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let o=n.state.selection;if(!(o instanceof $)||!o.$from.sameParent(o.$to)){let s=String.fromCharCode(t.charCode);!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",i=>i(n,o.$from.pos,o.$to.pos,s))&&n.dispatch(n.state.tr.insertText(s).scrollIntoView()),t.preventDefault()}};function is(n){return{left:n.clientX,top:n.clientY}}function Gg(n,e){let t=e.x-n.clientX,o=e.y-n.clientY;return t*t+o*o<100}function Wi(n,e,t,o,s){if(o==-1)return!1;let i=n.state.doc.resolve(o);for(let r=i.depth+1;r>0;r--)if(n.someProp(e,l=>r>i.depth?l(n,t,i.nodeAfter,i.before(r),s,!0):l(n,t,i.node(r),i.before(r),s,!1)))return!0;return!1}function xn(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 Wg(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),o=t.nodeAfter;return o&&o.isAtom&&D.isSelectable(o)?(xn(n,new D(t)),!0):!1}function jg(n,e){if(e==-1)return!1;let t=n.state.selection,o,s;t instanceof D&&(o=t.node);let i=n.state.doc.resolve(e);for(let r=i.depth+1;r>0;r--){let l=r>i.depth?i.nodeAfter:i.node(r);if(D.isSelectable(l)){o&&t.$from.depth>0&&r>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?s=i.before(t.$from.depth):s=i.before(r);break}}return s!=null?(xn(n,D.create(n.state.doc,s)),!0):!1}function qg(n,e,t,o,s){return Wi(n,"handleClickOn",e,t,o)||n.someProp("handleClick",i=>i(n,e,o))||(s?jg(n,t):Wg(n,t))}function Ug(n,e,t,o){return Wi(n,"handleDoubleClickOn",e,t,o)||n.someProp("handleDoubleClick",s=>s(n,e,o))}function Kg(n,e,t,o){return Wi(n,"handleTripleClickOn",e,t,o)||n.someProp("handleTripleClick",s=>s(n,e,o))||Jg(n,t,o)}function Jg(n,e,t){if(t.button!=0)return!1;let o=n.state.doc;if(e==-1)return o.inlineContent?(xn(n,$.create(o,0,o.content.size)),!0):!1;let s=o.resolve(e);for(let i=s.depth+1;i>0;i--){let r=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(r.inlineContent)xn(n,$.create(o,l+1,l+1+r.content.size));else if(D.isSelectable(r))xn(n,D.create(o,l));else continue;return!0}}function ji(n){return rs(n)}const Zc=Te?"metaKey":"ctrlKey";ce.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let o=ji(n),s=Date.now(),i="singleClick";s-n.input.lastClick.time<500&&Gg(t,n.input.lastClick)&&!t[Zc]&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:i};let r=n.posAtCoords(is(t));r&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Zg(n,r,t,!!o)):(i=="doubleClick"?Ug:Kg)(n,r.pos,r.inside,t)?t.preventDefault():mt(n,"pointer"))};class Zg{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[Zc],this.allowDefault=o.shiftKey;let i,r;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),r=t.inside;else{let d=e.state.doc.resolve(t.pos);i=d.parent,r=d.depth?d.before():0}const l=s?null:o.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(o.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof D&&c.from<=r&&c.to>r)&&(this.mightDrag={node:i,pos:r,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Re&&!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)),mt(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(()=>Qe(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(is(e))),this.updateAllowDefault(e),this.allowDefault||!t?mt(this.view,"pointer"):qg(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ae&&this.mightDrag&&!this.mightDrag.node.isAtom||ie&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(xn(this.view,L.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):mt(this.view,"pointer")}move(e){this.updateAllowDefault(e),mt(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(),ji(n),mt(n,"pointer")},ce.touchmove=n=>{n.input.lastTouch=Date.now(),mt(n,"pointer")},ce.contextmenu=n=>ji(n);function Yc(n,e){return n.composing?!0:ae&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Yg=De?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(),rs(n,!0),n.markCursor=null;else if(rs(n,!e.selection.empty),Re&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let o=n.domSelectionRange();for(let s=o.focusNode,i=o.focusOffset;s&&s.nodeType==1&&i!=0;){let r=i<0?s.lastChild:s.childNodes[i-1];if(!r)break;if(r.nodeType==3){let l=n.domSelection();l&&l.collapse(r,r.nodeValue.length);break}else s=r,i=-1}}n.input.composing=!0}Xc(n,Yg)},de.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Xc(n,20))};function Xc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>rs(n),e))}function Qc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Qg());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Xg(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Wm(e.focusNode,e.focusOffset),o=jm(e.focusNode,e.focusOffset);if(t&&o&&t!=o){let s=o.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||o==i)return i;if(!s||!s.isText(o.nodeValue))return o;if(n.input.compositionNode==o){let r=t.pmViewDesc;if(!(!r||!r.isText(t.nodeValue)))return o}}return t||o}function Qg(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function rs(n,e=!1){if(!(De&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Qc(n),e||n.docView&&n.docView.dirty){let t=Li(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 e1(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 Yn=ge&&pt<15||bn&&Zm<604;ce.copy=de.cut=(n,e)=>{let t=e,o=n.state.selection,s=t.type=="cut";if(o.empty)return;let i=Yn?null:t.clipboardData,r=o.content(),{dom:l,text:a}=Fc(n,r);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):e1(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function t1(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function n1(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?Xn(n,o.value,null,s,e):Xn(n,o.textContent,o.innerHTML,s,e)},50)}function Xn(n,e,t,o,s){let i=_c(n,e,t,o,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,i||A.empty)))return!0;if(!i)return!1;let r=t1(i),l=r?n.state.tr.replaceSelectionWith(r,o):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ed(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&&!De)return;let o=Yn?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;o&&Xn(n,ed(o),o.getData("text/html"),s,t)?t.preventDefault():n1(n,t)};class td{constructor(e,t,o){this.slice=e,this.move=t,this.node=o}}const nd=Te?"altKey":"ctrlKey";ce.dragstart=(n,e)=>{let t=e,o=n.input.mouseDown;if(o&&o.done(),!t.dataTransfer)return;let s=n.state.selection,i=s.empty?null:n.posAtCoords(is(t)),r;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof D?s.to-1:s.to))){if(o&&o.mightDrag)r=D.create(n.state.doc,o.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let p=n.docView.nearestDesc(t.target,!0);p&&p.node.type.spec.draggable&&p!=n.docView&&(r=D.create(n.state.doc,p.posBefore))}}let l=(r||n.state.selection).content(),{dom:a,text:c,slice:d}=Fc(n,l);(!t.dataTransfer.files.length||!ie||lc>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Yn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Yn||t.dataTransfer.setData("text/plain",c),n.dragging=new td(d,!t[nd],r)},ce.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},de.dragover=de.dragenter=(n,e)=>e.preventDefault(),de.drop=(n,e)=>{let t=e,o=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let s=n.posAtCoords(is(t));if(!s)return;let i=n.state.doc.resolve(s.pos),r=o&&o.slice;r?n.someProp("transformPasted",f=>{r=f(r,n)}):r=_c(n,ed(t.dataTransfer),Yn?null:t.dataTransfer.getData("text/html"),!1,i);let l=!!(o&&!t[nd]);if(n.someProp("handleDrop",f=>f(n,t,r||A.empty,l))){t.preventDefault();return}if(!r)return;t.preventDefault();let a=r?Yf(n.state.doc,i.pos,r):i.pos;a==null&&(a=i.pos);let c=n.state.tr;if(l){let{node:f}=o;f?f.replace(c):c.deleteSelection()}let d=c.mapping.map(a),p=r.openStart==0&&r.openEnd==0&&r.content.childCount==1,u=c.doc;if(p?c.replaceRangeWith(d,d,r.content.firstChild):c.replaceRange(d,d,r),c.doc.eq(u))return;let h=c.doc.resolve(d);if(p&&D.isSelectable(r.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(r.content.firstChild))c.setSelection(new D(h));else{let f=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,C)=>f=C),c.setSelection(zi(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())&&Qe(n)},20))},ce.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},ce.beforeinput=(n,e)=>{if(ie&&De&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:o}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=o||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,Bt(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 Qn(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 ls{constructor(e,t){this.toDOM=e,this.spec=t||_t,this.side=this.spec.side||0}map(e,t,o,s){let{pos:i,deleted:r}=e.mapResult(t.from+s,this.side<0?-1:1);return r?null:new ye(i-o,i-o,this)}valid(){return!0}eq(e){return this==e||e instanceof ls&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Qn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class gt{constructor(e,t){this.attrs=e,this.spec=t||_t}map(e,t,o,s){let i=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-o,r=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-o;return i>=r?null:new ye(i,r,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof gt&&Qn(this.attrs,e.attrs)&&Qn(this.spec,e.spec)}static is(e){return e.type instanceof gt}destroy(){}}class qi{constructor(e,t){this.attrs=e,this.spec=t||_t}map(e,t,o,s){let i=e.mapResult(t.from+s,1);if(i.deleted)return null;let r=e.mapResult(t.to+s,-1);return r.deleted||r.pos<=i.pos?null:new ye(i.pos-o,r.pos-o,this)}valid(e,t){let{index:o,offset:s}=e.content.findIndex(t.from),i;return s==t.from&&!(i=e.child(o)).isText&&s+i.nodeSize==t.to}eq(e){return this==e||e instanceof qi&&Qn(this.attrs,e.attrs)&&Qn(this.spec,e.spec)}destroy(){}}class ye{constructor(e,t,o){this.from=e,this.to=t,this.type=o}copy(e,t){return new ye(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 ye(e,e,new ls(t,o))}static inline(e,t,o,s){return new ye(e,t,new gt(o,s))}static node(e,t,o,s){return new ye(e,t,new qi(o,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof gt}get widget(){return this.type instanceof ls}}const wn=[],_t={};class U{constructor(e,t){this.local=e.length?e:wn,this.children=t.length?t:wn}static create(e,t){return t.length?as(t,e,0,_t):re}find(e,t,o){let s=[];return this.findInner(e??0,t??1e9,s,0,o),s}findInner(e,t,o,s,i){for(let r=0;r<this.local.length;r++){let l=this.local[r];l.from<=t&&l.to>=e&&(!i||i(l.spec))&&o.push(l.copy(l.from+s,l.to+s))}for(let r=0;r<this.children.length;r+=3)if(this.children[r]<t&&this.children[r+1]>e){let l=this.children[r]+1;this.children[r+2].findInner(e-l,t-l,o,s+l,i)}}map(e,t,o){return this==re||e.maps.length==0?this:this.mapInner(e,t,0,0,o||_t)}mapInner(e,t,o,s,i){let r;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,o,s);a&&a.type.valid(t,a)?(r||(r=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?o1(this.children,r||[],e,t,o,s,i):r?new U(r.sort(Gt),wn):re}add(e,t){return t.length?this==re?U.create(e,t):this.addInner(e,t,0):this}addInner(e,t,o){let s,i=0;e.forEach((l,a)=>{let c=a+o,d;if(d=sd(t,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,d,c+1):s.splice(i,0,a,a+l.nodeSize,as(d,l,c+1,_t)),i+=3}});let r=od(i?id(t):t,-o);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||r.splice(l--,1);return new U(r.length?this.local.concat(r).sort(Gt):this.local,s||this.children)}remove(e){return e.length==0||this==re?this:this.removeInner(e,0)}removeInner(e,t){let o=this.children,s=this.local;for(let i=0;i<o.length;i+=3){let r,l=o[i]+t,a=o[i+1]+t;for(let d=0,p;d<e.length;d++)(p=e[d])&&p.from>l&&p.to<a&&(e[d]=null,(r||(r=[])).push(p));if(!r)continue;o==this.children&&(o=this.children.slice());let c=o[i+2].removeInner(r,l+1);c!=re?o[i+2]=c:(o.splice(i,3),i-=3)}if(s.length){for(let i=0,r;i<e.length;i++)if(r=e[i])for(let l=0;l<s.length;l++)s[l].eq(r,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return o==this.children&&s==this.local?this:s.length||o.length?new U(s,o):re}forChild(e,t){if(this==re)return this;if(t.isLeaf)return U.empty;let o,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(o=this.children[l+2]);break}let i=e+1,r=i+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<r&&a.to>i&&a.type instanceof gt){let c=Math.max(i,a.from)-i,d=Math.min(r,a.to)-i;c<d&&(s||(s=[])).push(a.copy(c,d))}}if(s){let l=new U(s.sort(Gt),wn);return o?new yt([l,o]):l}return o||re}eq(e){if(this==e)return!0;if(!(e instanceof U)||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 Ui(this.localsInner(e))}localsInner(e){if(this==re)return wn;if(e.inlineContent||!this.local.some(gt.is))return this.local;let t=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof gt||t.push(this.local[o]);return t}forEachSet(e){e(this)}}U.empty=new U([],[]),U.removeOverlap=Ui;const re=U.empty;class yt{constructor(e){this.members=e}map(e,t){const o=this.members.map(s=>s.map(e,t,_t));return yt.from(o)}forChild(e,t){if(t.isLeaf)return U.empty;let o=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,t);i!=re&&(i instanceof yt?o=o.concat(i.members):o.push(i))}return yt.from(o)}eq(e){if(!(e instanceof yt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,o=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!t)t=i;else{o&&(t=t.slice(),o=!1);for(let r=0;r<i.length;r++)t.push(i[r])}}return t?Ui(o?t:t.sort(Gt)):wn}static from(e){switch(e.length){case 0:return re;case 1:return e[0];default:return new yt(e.every(t=>t instanceof U)?e:e.reduce((t,o)=>t.concat(o instanceof U?o:o.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function o1(n,e,t,o,s,i,r){let l=n.slice();for(let c=0,d=i;c<t.maps.length;c++){let p=0;t.maps[c].forEach((u,h,f,m)=>{let g=m-f-(h-u);for(let b=0;b<l.length;b+=3){let C=l[b+1];if(C<0||u>C+d-p)continue;let y=l[b]+d-p;h>=y?l[b+1]=u<=y?-2:-1:u>=d&&g&&(l[b]+=g,l[b+1]+=g)}p+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(n[c]+i),p=d-s;if(p<0||p>=o.content.size){a=!0;continue}let u=t.map(n[c+1]+i,-1),h=u-s,{index:f,offset:m}=o.content.findIndex(p),g=o.maybeChild(f);if(g&&m==p&&m+g.nodeSize==h){let b=l[c+2].mapInner(t,g,d+1,n[c]+i+1,r);b!=re?(l[c]=p,l[c+1]=h,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=s1(l,n,e,t,s,i,r),d=as(c,o,0,r);e=d.local;for(let p=0;p<l.length;p+=3)l[p+1]<0&&(l.splice(p,3),p-=3);for(let p=0,u=0;p<d.children.length;p+=3){let h=d.children[p];for(;u<l.length&&l[u]<h;)u+=3;l.splice(u,0,d.children[p],d.children[p+1],d.children[p+2])}}return new U(e.sort(Gt),l)}function od(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 ye(s.from+e,s.to+e,s.type))}return t}function s1(n,e,t,o,s,i,r){function l(a,c){for(let d=0;d<a.local.length;d++){let p=a.local[d].map(o,s,c);p?t.push(p):r.onRemove&&r.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+i+1);return t}function sd(n,e,t){if(e.isLeaf)return null;let o=t+e.nodeSize,s=null;for(let i=0,r;i<n.length;i++)(r=n[i])&&r.from>t&&r.to<o&&((s||(s=[])).push(r),n[i]=null);return s}function id(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function as(n,e,t,o){let s=[],i=!1;e.forEach((l,a)=>{let c=sd(n,l,a+t);if(c){i=!0;let d=as(c,l,t+a+1,o);d!=re&&s.push(a,a+l.nodeSize,d)}});let r=od(i?id(n):n,-t).sort(Gt);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||(o.onRemove&&o.onRemove(r[l].spec),r.splice(l--,1));return r.length||s.length?new U(r,s):re}function Gt(n,e){return n.from-e.from||n.to-e.to}function Ui(n){let e=n;for(let t=0;t<e.length-1;t++){let o=e[t];if(o.from!=o.to)for(let s=t+1;s<e.length;s++){let i=e[s];if(i.from==o.from){i.to!=o.to&&(e==n&&(e=n.slice()),e[s]=i.copy(i.from,o.to),rd(e,s+1,i.copy(o.to,i.to)));continue}else{i.from<o.to&&(e==n&&(e=n.slice()),e[t]=o.copy(o.from,i.from),rd(e,s,o.copy(i.from,o.to)));break}}}return e}function rd(n,e,t){for(;e<n.length&&Gt(t,n[e])>0;)e++;n.splice(e,0,t)}function Ki(n){let e=[];return n.someProp("decorations",t=>{let o=t(n.state);o&&o!=re&&e.push(o)}),n.cursorWrapper&&e.push(U.create(n.state.doc,[n.cursorWrapper.deco])),yt.from(e)}const i1={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},r1=ge&&pt<=11;class l1{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 a1{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new l1,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]);ge&&pt<=11&&o.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),r1&&(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,i1)),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(Rc(this.view)){if(this.suppressingSelectionUpdates)return Qe(this.view);if(ge&&pt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&zt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,o;for(let i=e.focusNode;i;i=Wn(i))t.add(i);for(let i=e.anchorNode;i;i=Wn(i))if(t.has(i)){o=i;break}let s=o&&this.view.docView.nearestDesc(o);if(s&&s.ignoreMutation({type:"selection",target:o.nodeType==3?o.parentNode:o}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let o=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(o)&&Rc(e)&&!this.ignoreSelectionChange(o),i=-1,r=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let p=this.registerMutation(t[d],a);p&&(i=i<0?p.from:Math.min(p.from,i),r=r<0?p.to:Math.max(p.to,r),p.typeOver&&(l=!0))}if(Re&&a.length){let d=a.filter(p=>p.nodeName=="BR");if(d.length==2){let[p,u]=d;p.parentNode&&p.parentNode.parentNode==u.parentNode?u.remove():p.remove()}else{let{focusNode:p}=this.currentSelection;for(let u of d){let h=u.parentNode;h&&h.nodeName=="LI"&&(!p||p1(e,p)!=h)&&u.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&es(o)&&(c=Li(e))&&c.eq(L.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Qe(e),this.currentSelection.set(o),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,r),c1(e)),this.handleDOMChange(i,r,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(o)||Qe(e),this.currentSelection.set(o))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let o=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(o==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!o||o.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let p=e.addedNodes[d];t.push(p),p.nodeType==3&&(this.lastChangedTextNode=p)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(e.target))return{from:o.posBefore,to:o.posAfter};let s=e.previousSibling,i=e.nextSibling;if(ge&&pt<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:p,nextSibling:u}=e.addedNodes[d];(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(s=p),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(i=u)}let r=s&&s.parentNode==e.target?ne(s)+1:0,l=o.localPosFromDOM(e.target,r,-1),a=i&&i.parentNode==e.target?ne(i):e.target.childNodes.length,c=o.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}:(this.lastChangedTextNode=e.target,{from:o.posAtStart,to:o.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let ld=new WeakMap,ad=!1;function c1(n){if(!ld.has(n)&&(ld.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Re,ad)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."),ad=!0}}function cd(n,e){let t=e.startContainer,o=e.startOffset,s=e.endContainer,i=e.endOffset,r=n.domAtPos(n.state.selection.anchor);return zt(r.node,r.offset,s,i)&&([t,o,s,i]=[s,i,t,o]),{anchorNode:t,anchorOffset:o,focusNode:s,focusOffset:i}}function d1(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return cd(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?cd(n,t):null}function p1(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 u1(n,e,t){let{node:o,fromOffset:s,toOffset:i,from:r,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],es(a)||c.push({node:a.focusNode,offset:a.focusOffset})),ie&&n.input.lastKeyCode===8)for(let g=i;g>s;g--){let b=o.childNodes[g-1],C=b.pmViewDesc;if(b.nodeName=="BR"&&!C){i=g;break}if(!C||C.size)break}let p=n.state.doc,u=n.someProp("domParser")||Rt.fromSchema(n.state.schema),h=p.resolve(r),f=null,m=u.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:i,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:h1,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),f={anchor:g+r,head:b+r}}return{doc:m,sel:f,from:r,to:l}}function h1(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 f1=/^(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 m1(n,e,t,o,s){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let E=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,M=Li(n,E);if(M&&!n.state.selection.eq(M)){if(ie&&De&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",N=>N(n,Bt(13,"Enter"))))return;let P=n.state.tr.setSelection(M);E=="pointer"?P.setMeta("pointer",!0):E=="key"&&P.scrollIntoView(),i&&P.setMeta("composition",i),n.dispatch(P)}return}let r=n.state.doc.resolve(e),l=r.sharedDepth(t);e=r.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=u1(n,e,t),d=n.state.doc,p=d.slice(c.from,c.to),u,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(u=n.state.selection.to,h="end"):(u=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let f=b1(p.content,c.doc.content,c.from,u,h);if(f&&n.input.domChangeCount++,(bn&&n.input.lastIOSEnter>Date.now()-225||De)&&s.some(E=>E.nodeType==1&&!f1.test(E.nodeName))&&(!f||f.endA>=f.endB)&&n.someProp("handleKeyDown",E=>E(n,Bt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!f)if(o&&a instanceof $&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))f={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let E=dd(n,n.state.doc,c.sel);if(E&&!E.eq(n.state.selection)){let M=n.state.tr.setSelection(E);i&&M.setMeta("composition",i),n.dispatch(M)}}return}n.state.selection.from<n.state.selection.to&&f.start==f.endB&&n.state.selection instanceof $&&(f.start>n.state.selection.from&&f.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?f.start=n.state.selection.from:f.endA<n.state.selection.to&&f.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(f.endB+=n.state.selection.to-f.endA,f.endA=n.state.selection.to)),ge&&pt<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>c.from&&c.doc.textBetween(f.start-c.from-1,f.start-c.from+1)==" "&&(f.start--,f.endA--,f.endB--);let m=c.doc.resolveNoCache(f.start-c.from),g=c.doc.resolveNoCache(f.endB-c.from),b=d.resolve(f.start),C=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=f.endA,y;if((bn&&n.input.lastIOSEnter>Date.now()-225&&(!C||s.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!C&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(y=L.findFrom(c.doc.resolve(m.pos+1),1,!0))&&y.head==g.pos)&&n.someProp("handleKeyDown",E=>E(n,Bt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>f.start&&y1(d,f.start,f.endA,m,g)&&n.someProp("handleKeyDown",E=>E(n,Bt(8,"Backspace")))){De&&ie&&n.domObserver.suppressSelectionUpdates();return}ie&&De&&f.endB==f.start&&(n.input.lastAndroidDelete=Date.now()),De&&!C&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==f.endA&&(f.endB-=2,g=c.doc.resolveNoCache(f.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(E){return E(n,Bt(13,"Enter"))})},20));let v=f.start,w=f.endA,S,x,k;if(C){if(m.pos==g.pos)ge&&pt<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Qe(n),20)),S=n.state.tr.delete(v,w),x=d.resolve(f.start).marksAcross(d.resolve(f.endA));else if(f.endA==f.endB&&(k=g1(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,f.endA-b.start()))))S=n.state.tr,k.type=="add"?S.addMark(v,w,k.mark):S.removeMark(v,w,k.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let E=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",M=>M(n,v,w,E)))return;S=n.state.tr.insertText(E,v,w)}}if(S||(S=n.state.tr.replace(v,w,c.doc.slice(f.start-c.from,f.endB-c.from))),c.sel){let E=dd(n,S.doc,c.sel);E&&!(ie&&De&&n.composing&&E.empty&&(f.start!=f.endB||n.input.lastAndroidDelete<Date.now()-100)&&(E.head==v||E.head==S.mapping.map(w)-1)||ge&&E.empty&&E.head==v)&&S.setSelection(E)}x&&S.ensureMarks(x),i&&S.setMeta("composition",i),n.dispatch(S.scrollIntoView())}function dd(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:zi(n,e.resolve(t.anchor),e.resolve(t.head))}function g1(n,e){let t=n.firstChild.marks,o=e.firstChild.marks,s=t,i=o,r,l,a;for(let d=0;d<o.length;d++)s=o[d].removeFromSet(s);for(let d=0;d<t.length;d++)i=t[d].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],r="add",a=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&i.length==1)l=i[0],r="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(T.from(c).eq(n))return{mark:l,type:r}}function y1(n,e,t,o,s){if(t-e<=s.pos-o.pos||Ji(o,!0,!1)<s.pos)return!1;let i=n.resolve(e);if(!o.parent.isTextblock){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let r=n.resolve(Ji(i,!0,!0));return!r.parent.isTextblock||r.pos>t||Ji(r,!0,!1)<t?!1:o.parent.content.cut(o.parentOffset).eq(r.parent.content)}function Ji(n,e,t){let o=n.depth,s=e?n.end():n.pos;for(;o>0&&(e||n.indexAfter(o)==n.node(o).childCount);)o--,s++,e=!1;if(t){let i=n.node(o).maybeChild(n.indexAfter(o));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function b1(n,e,t,o,s){let i=n.findDiffStart(e,t);if(i==null)return null;let{a:r,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,i-Math.min(r,l));o-=r+a-i}if(r<i&&n.size<e.size){let a=o<=i&&o>=r?i-o:0;i-=a,i&&i<e.size&&pd(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-r),r=i}else if(l<i){let a=o<=i&&o>=l?i-o:0;i-=a,i&&i<n.size&&pd(n.textBetween(i-1,i+1))&&(i+=a?1:-1),r=i+(r-l),l=i}return{start:i,endA:r,endB:l}}function pd(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 v1{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 Bg,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(gd),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=fd(this),hd(this),this.nodeViews=md(this),this.docView=xc(this.state.doc,ud(this),Ki(this),this.dom,this),this.domObserver=new a1(this,(o,s,i,r)=>m1(this,o,s,i,r)),this.domObserver.start(),Vg(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&&_i(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(gd),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let o in this._props)t[o]=this._props[o];t.state=this.state;for(let o in e)t[o]=e[o];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var o;let s=this.state,i=!1,r=!1;e.storedMarks&&this.composing&&(Qc(this),r=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=md(this);x1(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&_i(this),this.editable=fd(this),hd(this);let a=Ki(this),c=ud(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",p=i||!this.docView.matchesNode(e.doc,c,a);(p||!e.selection.eq(s.selection))&&(r=!0);let u=d=="preserve"&&r&&this.dom.style.overflowAnchor==null&&Qm(this);if(r){this.domObserver.stop();let h=p&&(ge||ie)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&S1(s.selection,e.selection);if(p){let f=ie?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Xg(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=xc(e.doc,c,a,this.dom,this)),f&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Cg(this))?Qe(this,h):(Oc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((o=this.dragging)===null||o===void 0)&&o.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():u&&eg(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof D){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&ac(this,t.getBoundingClientRect(),e)}else ac(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let o=this.directPlugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let o=this.state.plugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let o=this.pluginViews[t];o.update&&o.update(this,e)}}updateDraggedNode(e,t){let o=e.node,s=-1;if(this.state.doc.nodeAt(o.from)==o.node)s=o.from;else{let i=o.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==o.node&&(s=i)}this.dragging=new td(e.slice,e.move,s<0?void 0:D.create(this.state.doc,s))}someProp(e,t){let o=this._props&&this._props[e],s;if(o!=null&&(s=t?t(o):o))return s;for(let r=0;r<this.directPlugins.length;r++){let l=this.directPlugins[r].props[e];if(l!=null&&(s=t?t(l):l))return s}let i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let l=i[r].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(ge){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&&tg(this.dom),Qe(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 rg(this,e)}coordsAtPos(e,t=1){return fc(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 pg(this,t||this.state,e)}pasteHTML(e,t){return Xn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Xn(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Hg(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ki(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,_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&&Um(this.dom.ownerDocument)==this.dom&&d1(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function ud(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"),[ye.node(0,n.state.doc.content.size,e)]}function hd(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:ye.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function fd(n){return!n.someProp("editable",e=>e(n.state)===!1)}function S1(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 md(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 x1(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 gd(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 Zi,Yi;if(typeof WeakMap<"u"){let n=new WeakMap;Zi=e=>n.get(e),Yi=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Zi=o=>{for(let s=0;s<n.length;s+=2)if(n[s]==o)return n[s+1]},Yi=(o,s)=>(t==10&&(t=0),n[t++]=o,n[t++]=s)}var J=class{constructor(n,e,t,o){this.width=n,this.height=e,this.map=t,this.problems=o}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const o=e%this.width,s=e/this.width|0;let i=o+1,r=s+1;for(let l=1;i<this.width&&this.map[e+l]==t;l++)i++;for(let l=1;r<this.height&&this.map[e+this.width*l]==t;l++)r++;return{left:o,top:s,right:i,bottom:r}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:o,right:s,top:i,bottom:r}=this.findCell(n);return e=="horiz"?(t<0?o==0:s==this.width)?null:this.map[i*this.width+(t<0?o-1:s)]:(t<0?i==0:r==this.height)?null:this.map[o+this.width*(t<0?i-1:r)]}rectBetween(n,e){const{left:t,right:o,top:s,bottom:i}=this.findCell(n),{left:r,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,r),top:Math.min(s,a),right:Math.max(o,l),bottom:Math.max(i,c)}}cellsInRect(n){const e=[],t={};for(let o=n.top;o<n.bottom;o++)for(let s=n.left;s<n.right;s++){const i=o*this.width+s,r=this.map[i];t[r]||(t[r]=!0,!(s==n.left&&s&&this.map[i-1]==r||o==n.top&&o&&this.map[i-this.width]==r)&&e.push(r))}return e}positionAt(n,e,t){for(let o=0,s=0;;o++){const i=s+t.child(o).nodeSize;if(o==n){let r=e+n*this.width;const l=(n+1)*this.width;for(;r<l&&this.map[r]<s;)r++;return r==l?i-1:this.map[r]}s=i}}static get(n){return Zi(n)||Yi(n,w1(n))}};function w1(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=C1(n),t=n.childCount,o=[];let s=0,i=null;const r=[];for(let c=0,d=e*t;c<d;c++)o[c]=0;for(let c=0,d=0;c<t;c++){const p=n.child(c);d++;for(let f=0;;f++){for(;s<o.length&&o[s]!=0;)s++;if(f==p.childCount)break;const m=p.child(f),{colspan:g,rowspan:b,colwidth:C}=m.attrs;for(let y=0;y<b;y++){if(y+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:b-y});break}const v=s+y*e;for(let w=0;w<g;w++){o[v+w]==0?o[v+w]=d:(i||(i=[])).push({type:"collision",row:c,pos:d,n:g-w});const S=C&&C[w];if(S){const x=(v+w)%e*2,k=r[x];k==null||k!=S&&r[x+1]==1?(r[x]=S,r[x+1]=1):k==S&&r[x+1]++}}}s+=g,d+=m.nodeSize}const u=(c+1)*e;let h=0;for(;s<u;)o[s++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),d++}const l=new J(e,t,o,i);let a=!1;for(let c=0;!a&&c<r.length;c+=2)r[c]!=null&&r[c+1]<t&&(a=!0);return a&&k1(l,r,n),l}function C1(n){let e=-1,t=!1;for(let o=0;o<n.childCount;o++){const s=n.child(o);let i=0;if(t)for(let r=0;r<o;r++){const l=n.child(r);for(let a=0;a<l.childCount;a++){const c=l.child(a);r+c.attrs.rowspan>o&&(i+=c.attrs.colspan)}}for(let r=0;r<s.childCount;r++){const l=s.child(r);i+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function k1(n,e,t){n.problems||(n.problems=[]);const o={};for(let s=0;s<n.map.length;s++){const i=n.map[s];if(o[i])continue;o[i]=!0;const r=t.nodeAt(i);if(!r)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=r.attrs;for(let c=0;c<a.colspan;c++){const d=(s+c)%n.width,p=e[d*2];p!=null&&(!a.colwidth||a.colwidth[c]!=p)&&((l||(l=E1(a)))[c]=p)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function E1(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function yd(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),o=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(r=>Number(r)):null,s=Number(n.getAttribute("colspan")||1),i={colspan:s,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:o&&o.length==s?o:null};for(const r in e){const l=e[r].getFromDOM,a=l&&l(n);a!=null&&(i[r]=a)}return i}function bd(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 T1(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=>yd(o,e)}],toDOM(o){return["td",bd(o,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:o=>yd(o,e)}],toDOM(o){return["th",bd(o,e),0]}}}}function Ge(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 bt=new _n("selectingCells");function eo(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 cs(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 Xi(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=eo(e.$head)||M1(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function M1(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 Qi(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function A1(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function er(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function vd(n,e,t){const o=n.node(-1),s=J.get(o),i=n.start(-1),r=s.nextCell(n.pos-i,e,t);return r==null?null:n.node(0).resolve(i+r)}function Cn(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 nt extends L{constructor(e,t=e){const o=e.node(-1),s=J.get(o),i=e.start(-1),r=s.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=s.cellsInRect(r).filter(d=>d!=t.pos-i);a.unshift(t.pos-i);const c=a.map(d=>{const p=o.nodeAt(d);if(!p)throw RangeError(`No cell with offset ${d} found`);const u=i+d+1;return new Oa(l.resolve(u),l.resolve(u+p.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const o=e.resolve(t.map(this.$anchorCell.pos)),s=e.resolve(t.map(this.$headCell.pos));if(Qi(o)&&Qi(s)&&er(o,s)){const i=this.$anchorCell.node(-1)!=o.node(-1);return i&&this.isRowSelection()?nt.rowSelection(o,s):i&&this.isColSelection()?nt.colSelection(o,s):new nt(o,s)}return $.between(o,s)}content(){const e=this.$anchorCell.node(-1),t=J.get(e),o=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),i={},r=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let d=a*t.width+s.left,p=s.left;p<s.right;p++,d++){const u=t.map[d];if(i[u])continue;i[u]=!0;const h=t.findCell(u);let f=e.nodeAt(u);if(!f)throw RangeError(`No cell with offset ${u} found`);const m=s.left-h.left,g=h.right-s.right;if(m>0||g>0){let b=f.attrs;if(m>0&&(b=Cn(b,0,m)),g>0&&(b=Cn(b,b.colspan-g,g)),h.left<s.left){if(f=f.type.createAndFill(b),!f)throw RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else f=f.type.create(b,f.content)}if(h.top<s.top||h.bottom>s.bottom){const b={...f.attrs,rowspan:Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top)};h.top<s.top?f=f.type.createAndFill(b):f=f.type.create(b,f.content)}c.push(f)}r.push(e.child(a).copy(T.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:r;return new A(T.from(l),1,1)}replace(e,t=A.empty){const o=e.steps.length,s=this.ranges;for(let r=0;r<s.length;r++){const{$from:l,$to:a}=s[r],c=e.mapping.slice(o);e.replace(c.map(l.pos),c.map(a.pos),r?A.empty:t)}const i=L.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new A(T.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),o=J.get(t),s=this.$anchorCell.start(-1),i=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let r=0;r<i.length;r++)e(t.nodeAt(i[r]),s+i[r])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const o=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const o=e.node(-1),s=J.get(o),i=e.start(-1),r=s.findCell(e.pos-i),l=s.findCell(t.pos-i),a=e.node(0);return r.top<=l.top?(r.top>0&&(e=a.resolve(i+s.map[r.left])),l.bottom<s.height&&(t=a.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(i+s.map[l.left])),r.bottom<s.height&&(e=a.resolve(i+s.map[s.width*(s.height-1)+r.right-1]))),new nt(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=J.get(e),o=this.$anchorCell.start(-1),s=t.colCount(this.$anchorCell.pos-o),i=t.colCount(this.$headCell.pos-o);if(Math.min(s,i)>0)return!1;const r=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(r,l)==t.width}eq(e){return e instanceof nt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const o=e.node(-1),s=J.get(o),i=e.start(-1),r=s.findCell(e.pos-i),l=s.findCell(t.pos-i),a=e.node(0);return r.left<=l.left?(r.left>0&&(e=a.resolve(i+s.map[r.top*s.width])),l.right<s.width&&(t=a.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(i+s.map[l.top*s.width])),r.right<s.width&&(e=a.resolve(i+s.map[s.width*(r.top+1)-1]))),new nt(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new nt(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){return new nt(e.resolve(t),e.resolve(o))}getBookmark(){return new P1(this.$anchorCell.pos,this.$headCell.pos)}};Y.prototype.visible=!1,L.jsonID("cell",Y);var P1=class Tp{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Tp(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&&er(t,o)?new Y(t,o):L.near(o,1)}};function N1(n){if(!(n.selection instanceof Y))return null;const e=[];return n.selection.forEachCell((t,o)=>{e.push(ye.node(o,o+t.nodeSize,{class:"selectedCell"}))}),U.create(n.doc,e)}function O1({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,o=e.pos,s=n.depth;for(;s>=0&&!(n.after(s+1)<n.end(s));s--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,o--);return t==o&&/row|table/.test(n.node(s).type.spec.tableRole)}function I1({$from:n,$to:e}){let t,o;for(let s=n.depth;s>0;s--){const i=n.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){o=i;break}}return t!==o&&e.parentOffset===0}function R1(n,e,t){const o=(e||n).selection,s=(e||n).doc;let i,r;if(o instanceof D&&(r=o.node.type.spec.tableRole)){if(r=="cell"||r=="header_cell")i=Y.create(s,o.from);else if(r=="row"){const l=s.resolve(o.from+1);i=Y.rowSelection(l,l)}else if(!t){const l=J.get(o.node),a=o.from+1,c=a+l.map[l.width*l.height-1];i=Y.create(s,a+1,c)}}else o instanceof $&&O1(o)?i=$.create(s,o.from):o instanceof $&&I1(o)&&(i=$.create(s,o.$from.start(),o.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}var D1=new _n("fix-tables");function Sd(n,e,t,o){const s=n.childCount,i=e.childCount;e:for(let r=0,l=0;r<i;r++){const a=e.child(r);for(let c=l,d=Math.min(s,r+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}o(a,t),l<s&&n.child(l).sameMarkup(a)?Sd(n.child(l),a,t+1,o):a.nodesBetween(0,a.content.size,o,t+1),t+=a.nodeSize}}function L1(n,e){let t;const o=(s,i)=>{s.type.spec.tableRole=="table"&&(t=$1(n,s,i,t))};return e?e.doc!=n.doc&&Sd(e.doc,n.doc,0,o):n.doc.descendants(o),t}function $1(n,e,t,o){const s=J.get(e);if(!s.problems)return o;o||(o=n.tr);const i=[];for(let a=0;a<s.height;a++)i.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const p=d.attrs;for(let u=0;u<p.rowspan;u++)i[c.row+u]+=c.n;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,Cn(p,p.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}}let r,l;for(let a=0;a<i.length;a++)i[a]&&(r==null&&(r=a),l=a);for(let a=0,c=t+1;a<s.height;a++){const d=e.child(a),p=c+d.nodeSize,u=i[a];if(u>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const f=[];for(let g=0;g<u;g++){const b=Ge(n.schema)[h].createAndFill();b&&f.push(b)}const m=(a==0||r==a-1)&&l==a?c+1:p-1;o.insert(o.mapping.map(m),f)}c=p}return o.setMeta(D1,{fixTables:!0})}function xd(n){const e=n.selection,t=Xi(n),o=t.node(-1),s=t.start(-1),i=J.get(o);return{...e instanceof Y?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(t.pos-s),tableStart:s,map:i,table:o}}function z1(n){return function(e,t){if(!cs(e))return!1;if(t){const o=Ge(e.schema),s=xd(e),i=e.tr,r=s.map.cellsInRect(n=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:n=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=r.map(a=>s.table.nodeAt(a));for(let a=0;a<r.length;a++)l[a].type==o.header_cell&&i.setNodeMarkup(s.tableStart+r[a],o.cell,l[a].attrs);if(i.steps.length==0)for(let a=0;a<r.length;a++)i.setNodeMarkup(s.tableStart+r[a],o.header_cell,l[a].attrs);t(i)}return!0}}function wd(n,e,t){const o=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let s=0;s<o.length;s++){const i=e.table.nodeAt(o[s]);if(i&&i.type!==t.header_cell)return!1}return!0}function tr(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?z1(n):function(t,o){if(!cs(t))return!1;if(o){const s=Ge(t.schema),i=xd(t),r=t.tr,l=wd("row",i,s),a=wd("column",i,s),d=(n==="column"?l:n==="row"?a:!1)?1:0,p=n=="column"?{left:0,top:d,right:1,bottom:i.map.height}:n=="row"?{left:d,top:0,right:i.map.width,bottom:1}:i,u=n=="column"?a?s.cell:s.header_cell:n=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(p).forEach(h=>{const f=h+i.tableStart,m=r.doc.nodeAt(f);m&&r.setNodeMarkup(f,u,m.attrs)}),o(r)}return!0}}tr("row",{useDeprecatedLogic:!0}),tr("column",{useDeprecatedLogic:!0}),tr("cell",{useDeprecatedLogic:!0});function B1(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let o=n.index(-1)-1,s=n.before();o>=0;o--){const i=n.node(-1).child(o),r=i.lastChild;if(r)return s-1-r.nodeSize;s-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let o=n.indexAfter(-1),s=n.after();o<t.childCount;o++){const i=t.child(o);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function Cd(n){return function(e,t){if(!cs(e))return!1;const o=B1(Xi(e),n);if(o==null)return!1;if(t){const s=e.doc.resolve(o);t(e.tr.setSelection($.between(s,A1(s))).scrollIntoView())}return!0}}function ds(n,e){const t=n.selection;if(!(t instanceof Y))return!1;if(e){const o=n.tr,s=Ge(n.schema).cell.createAndFill().content;t.forEachCell((i,r)=>{i.content.eq(s)||o.replace(o.mapping.map(r+1),o.mapping.map(r+i.nodeSize-1),new A(s,0,0))}),o.docChanged&&e(o)}return!0}function V1(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:o}=n;for(;e.childCount==1&&(t>0&&o>0||e.child(0).type.spec.tableRole=="table");)t--,o--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,r=s.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),p=a<e.childCount-1?0:Math.max(0,o-1);(d||p)&&(c=nr(Ge(r).row,new A(c,d,p)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||o?nr(Ge(r).row,new A(e,t,o)).content:e);else return null;return H1(r,l)}function H1(n,e){const t=[];for(let s=0;s<e.length;s++){const i=e[s];for(let r=i.childCount-1;r>=0;r--){const{rowspan:l,colspan:a}=i.child(r).attrs;for(let c=s;c<s+l;c++)t[c]=(t[c]||0)+a}}let o=0;for(let s=0;s<t.length;s++)o=Math.max(o,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(T.empty),t[s]<o){const i=Ge(n).cell.createAndFill(),r=[];for(let l=t[s];l<o;l++)r.push(i);e[s]=e[s].append(T.from(r))}return{height:e.length,width:o,rows:e}}function nr(n,e){const t=n.createAndFill();return new Na(t).replace(0,t.content.size,e).doc}function F1({width:n,height:e,rows:t},o,s){if(n!=o){const i=[],r=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=i[l]||0,p=0;d<o;p++){let u=a.child(p%a.childCount);d+u.attrs.colspan>o&&(u=u.type.createChecked(Cn(u.attrs,u.attrs.colspan,d+u.attrs.colspan-o),u.content)),c.push(u),d+=u.attrs.colspan;for(let h=1;h<u.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+u.attrs.colspan}r.push(T.from(c))}t=r,n=o}if(e!=s){const i=[];for(let r=0,l=0;r<s;r++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let p=c.child(d);r+p.attrs.rowspan>s&&(p=p.type.create({...p.attrs,rowspan:Math.max(1,s-p.attrs.rowspan)},p.content)),a.push(p)}i.push(T.from(a))}t=i,e=s}return{width:n,height:e,rows:t}}function _1(n,e,t,o,s,i,r){const l=n.doc.type.schema,a=Ge(l);let c,d;if(s>e.width)for(let p=0,u=0;p<e.height;p++){const h=t.child(p);u+=h.nodeSize;const f=[];let m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=d||(d=a.header_cell.createAndFill());for(let g=e.width;g<s;g++)f.push(m);n.insert(n.mapping.slice(r).map(u-1+o),f)}if(i>e.height){const p=[];for(let f=0,m=(e.height-1)*e.width;f<Math.max(e.width,s);f++){const g=f>=e.width?!1:t.nodeAt(e.map[m+f]).type==a.header_cell;p.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const u=a.row.create(null,T.from(p)),h=[];for(let f=e.height;f<i;f++)h.push(u);n.insert(n.mapping.slice(r).map(o+t.nodeSize-2),h)}return!!(c||d)}function kd(n,e,t,o,s,i,r,l){if(r==0||r==e.height)return!1;let a=!1;for(let c=s;c<i;c++){const d=r*e.width+c,p=e.map[d];if(e.map[d-e.width]==p){a=!0;const u=t.nodeAt(p),{top:h,left:f}=e.findCell(p);n.setNodeMarkup(n.mapping.slice(l).map(p+o),null,{...u.attrs,rowspan:r-h}),n.insert(n.mapping.slice(l).map(e.positionAt(r,f,t)),u.type.createAndFill({...u.attrs,rowspan:h+u.attrs.rowspan-r})),c+=u.attrs.colspan-1}}return a}function Ed(n,e,t,o,s,i,r,l){if(r==0||r==e.width)return!1;let a=!1;for(let c=s;c<i;c++){const d=c*e.width+r,p=e.map[d];if(e.map[d-1]==p){a=!0;const u=t.nodeAt(p),h=e.colCount(p),f=n.mapping.slice(l).map(p+o);n.setNodeMarkup(f,null,Cn(u.attrs,r-h,u.attrs.colspan-(r-h))),n.insert(f+u.nodeSize,u.type.createAndFill(Cn(u.attrs,0,r-h))),c+=u.attrs.rowspan-1}}return a}function Td(n,e,t,o,s){let i=t?n.doc.nodeAt(t-1):n.doc;if(!i)throw new Error("No table found");let r=J.get(i);const{top:l,left:a}=o,c=a+s.width,d=l+s.height,p=n.tr;let u=0;function h(){if(i=t?p.doc.nodeAt(t-1):p.doc,!i)throw new Error("No table found");r=J.get(i),u=p.mapping.maps.length}_1(p,r,i,t,c,d,u)&&h(),kd(p,r,i,t,a,c,l,u)&&h(),kd(p,r,i,t,a,c,d,u)&&h(),Ed(p,r,i,t,l,d,a,u)&&h(),Ed(p,r,i,t,l,d,c,u)&&h();for(let f=l;f<d;f++){const m=r.positionAt(f,a,i),g=r.positionAt(f,c,i);p.replace(p.mapping.slice(u).map(m+t),p.mapping.slice(u).map(g+t),new A(s.rows[f-l],0,0))}h(),p.setSelection(new Y(p.doc.resolve(t+r.positionAt(l,a,i)),p.doc.resolve(t+r.positionAt(d-1,c-1,i)))),e(p)}var G1=nc({ArrowLeft:us("horiz",-1),ArrowRight:us("horiz",1),ArrowUp:us("vert",-1),ArrowDown:us("vert",1),"Shift-ArrowLeft":hs("horiz",-1),"Shift-ArrowRight":hs("horiz",1),"Shift-ArrowUp":hs("vert",-1),"Shift-ArrowDown":hs("vert",1),Backspace:ds,"Mod-Backspace":ds,Delete:ds,"Mod-Delete":ds});function ps(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function us(n,e){return(t,o,s)=>{if(!s)return!1;const i=t.selection;if(i instanceof Y)return ps(t,o,L.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;const r=Md(s,n,e);if(r==null)return!1;if(n=="horiz")return ps(t,o,L.near(t.doc.resolve(i.head+e),e));{const l=t.doc.resolve(r),a=vd(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),ps(t,o,c)}}}function hs(n,e){return(t,o,s)=>{if(!s)return!1;const i=t.selection;let r;if(i instanceof Y)r=i;else{const a=Md(s,n,e);if(a==null)return!1;r=new Y(t.doc.resolve(a))}const l=vd(r.$headCell,n,e);return l?ps(t,o,new Y(r.$anchorCell,l)):!1}}function W1(n,e){const t=n.state.doc,o=eo(t.resolve(e));return o?(n.dispatch(n.state.tr.setSelection(new Y(o))),!0):!1}function j1(n,e,t){if(!cs(n.state))return!1;let o=V1(t);const s=n.state.selection;if(s instanceof Y){o||(o={width:1,height:1,rows:[T.from(nr(Ge(n.state.schema).cell,t))]});const i=s.$anchorCell.node(-1),r=s.$anchorCell.start(-1),l=J.get(i).rectBetween(s.$anchorCell.pos-r,s.$headCell.pos-r);return o=F1(o,l.right-l.left,l.bottom-l.top),Td(n.state,n.dispatch,r,l,o),!0}else if(o){const i=Xi(n.state),r=i.start(-1);return Td(n.state,n.dispatch,r,J.get(i.node(-1)).findCell(i.pos-r),o),!0}else return!1}function q1(n,e){var t;if(e.ctrlKey||e.metaKey)return;const o=Ad(n,e.target);let s;if(e.shiftKey&&n.state.selection instanceof Y)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(s=eo(n.state.selection.$anchor))!=null&&((t=or(n,e))==null?void 0:t.pos)!=s.pos)i(s,e),e.preventDefault();else if(!o)return;function i(a,c){let d=or(n,c);const p=bt.getState(n.state)==null;if(!d||!er(a,d))if(p)d=a;else return;const u=new Y(a,d);if(p||!n.state.selection.eq(u)){const h=n.state.tr.setSelection(u);p&&h.setMeta(bt,a.pos),n.dispatch(h)}}function r(){n.root.removeEventListener("mouseup",r),n.root.removeEventListener("dragstart",r),n.root.removeEventListener("mousemove",l),bt.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(bt,-1))}function l(a){const c=a,d=bt.getState(n.state);let p;if(d!=null)p=n.state.doc.resolve(d);else if(Ad(n,c.target)!=o&&(p=or(n,e),!p))return r();p&&i(p,c)}n.root.addEventListener("mouseup",r),n.root.addEventListener("dragstart",r),n.root.addEventListener("mousemove",l)}function Md(n,e,t){if(!(n.state.selection instanceof $))return null;const{$head:o}=n.state.selection;for(let s=o.depth-1;s>=0;s--){const i=o.node(s);if((t<0?o.index(s):o.indexAfter(s))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=o.before(s),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Ad(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function or(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?eo(n.state.doc.resolve(t.pos)):null}var U1=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")),sr(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,sr(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function sr(n,e,t,o,s,i){var r;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let p=0,u=0;p<d.childCount;p++){const{colspan:h,colwidth:f}=d.child(p).attrs;for(let m=0;m<h;m++,u++){const g=s==u?i:f&&f[m],b=g?g+"px":"";if(l+=g||o,g||(a=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const C=document.createElement("col");C.style.width=b,e.appendChild(C)}}}for(;c;){const p=c.nextSibling;(r=c.parentNode)==null||r.removeChild(c),c=p}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var we=new _n("tableColumnResizing");function K1({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:o=U1,lastColumnResizable:s=!0}={}){const i=new gn({key:we,state:{init(r,l){var a,c;const d=(c=(a=i.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,p=Ge(l.schema).table.name;return o&&d&&(d[p]=(u,h)=>new o(u,t,h)),new J1(-1,!1)},apply(r,l){return l.apply(r)}},props:{attributes:r=>{const l=we.getState(r);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(r,l)=>{Z1(r,l,n,s)},mouseleave:r=>{Y1(r)},mousedown:(r,l)=>{X1(r,l,e,t)}},decorations:r=>{const l=we.getState(r);if(l&&l.activeHandle>-1)return o0(r,l.activeHandle)},nodeViews:{}}});return i}var J1=class Es{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,o=e.getMeta(we);if(o&&o.setHandle!=null)return new Es(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new Es(t.activeHandle,o.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);return Qi(e.doc.resolve(s))||(s=-1),new Es(s,t.dragging)}return t}};function Z1(n,e,t,o){const s=we.getState(n.state);if(s&&!s.dragging){const i=e0(e.target);let r=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?r=Pd(n,e,"left",t):a-e.clientX<=t&&(r=Pd(n,e,"right",t))}if(r!=s.activeHandle){if(!o&&r!==-1){const l=n.state.doc.resolve(r),a=l.node(-1),c=J.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Od(n,r)}}}function Y1(n){const e=we.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Od(n,-1)}function X1(n,e,t,o){var s;const i=(s=n.dom.ownerDocument.defaultView)!=null?s:window,r=we.getState(n.state);if(!r||r.activeHandle==-1||r.dragging)return!1;const l=n.state.doc.nodeAt(r.activeHandle),a=Q1(n,r.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(we,{setDragging:{startX:e.clientX,startWidth:a}}));function c(p){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const u=we.getState(n.state);u!=null&&u.dragging&&(t0(n,u.activeHandle,Nd(u.dragging,p,t)),n.dispatch(n.state.tr.setMeta(we,{setDragging:null})))}function d(p){if(!p.which)return c(p);const u=we.getState(n.state);if(u&&u.dragging){const h=Nd(u.dragging,p,t);Id(n,u.activeHandle,h,o)}}return Id(n,r.activeHandle,a,o),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function Q1(n,e,{colspan:t,colwidth:o}){const s=o&&o[o.length-1];if(s)return s;const i=n.domAtPos(e);let l=i.node.childNodes[i.offset].offsetWidth,a=t;if(o)for(let c=0;c<t;c++)o[c]&&(l-=o[c],a--);return l/a}function e0(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Pd(n,e,t,o){const s=t=="right"?-o:o,i=n.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:r}=i,l=eo(n.state.doc.resolve(r));if(!l)return-1;if(t=="right")return l.pos;const a=J.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 Nd(n,e,t){const o=e.clientX-n.startX;return Math.max(t,n.startWidth+o)}function Od(n,e){n.dispatch(n.state.tr.setMeta(we,{setHandle:e}))}function t0(n,e,t){const o=n.state.doc.resolve(e),s=o.node(-1),i=J.get(s),r=o.start(-1),l=i.colCount(o.pos-r)+o.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<i.height;c++){const d=c*i.width+l;if(c&&i.map[d]==i.map[d-i.width])continue;const p=i.map[d],u=s.nodeAt(p).attrs,h=u.colspan==1?0:l-i.colCount(p);if(u.colwidth&&u.colwidth[h]==t)continue;const f=u.colwidth?u.colwidth.slice():n0(u.colspan);f[h]=t,a.setNodeMarkup(r+p,null,{...u,colwidth:f})}a.docChanged&&n.dispatch(a)}function Id(n,e,t,o){const s=n.state.doc.resolve(e),i=s.node(-1),r=s.start(-1),l=J.get(i).colCount(s.pos-r)+s.nodeAfter.attrs.colspan-1;let a=n.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&sr(i,a.firstChild,a,o,l,t)}function n0(n){return Array(n).fill(0)}function o0(n,e){var t;const o=[],s=n.doc.resolve(e),i=s.node(-1);if(!i)return U.empty;const r=J.get(i),l=s.start(-1),a=r.colCount(s.pos-l)+s.nodeAfter.attrs.colspan-1;for(let c=0;c<r.height;c++){const d=a+c*r.width;if((a==r.width-1||r.map[d]!=r.map[d+1])&&(c==0||r.map[d]!=r.map[d-r.width])){const p=r.map[d],u=l+p+i.nodeAt(p).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",(t=we.getState(n))!=null&&t.dragging&&o.push(ye.node(l+p,l+p+i.nodeAt(p).nodeSize,{class:"column-resize-dragging"})),o.push(ye.widget(u,h))}}return U.create(n.doc,o)}function s0({allowTableNodeSelection:n=!1}={}){return new gn({key:bt,state:{init(){return null},apply(e,t){const o=e.getMeta(bt);if(o!=null)return o==-1?null:o;if(t==null||!e.docChanged)return t;const{deleted:s,pos:i}=e.mapping.mapResult(t);return s?null:i}},props:{decorations:N1,handleDOMEvents:{mousedown:q1},createSelectionBetween(e){return bt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:W1,handleKeyDown:G1,handlePaste:j1},appendTransaction(e,t,o){return R1(o,L1(o,t),n)}})}const to=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},ir=n=>{const{key:e,cssProperty:t,tagName:o="span"}=n,s="value";return{attrs:{...ms,[s]:{default:null}},parseDOM:[{tag:`${o}[${e}]`,getAttrs:i=>({...gs(i),[s]:i.style.getPropertyValue(t)||null})}],toDOM(i){const{[s]:r}=i.attrs,l={...qe(i),[e]:""};return r&&(l.style=`${t}: ${r}`),[o,l,0]}}},Rd="data-gs-mrk-fs",i0="data-gs-mrk-color",r0="data-gs-mrk-bgcolor",Dd="data-gs-mrk-wrap",fs="data-gs-ifrg",et="attrs",ms={[et]:{default:"{}"}},We={[et]:{default:{}}},gs=n=>({[et]:JSON.stringify(to(n))}),je=n=>({attrs:to(n)}),no=n=>e=>[n,e.attrs.attrs,0],qe=n=>n.attrs[et]?JSON.parse(n.attrs[et]):{},l0={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${fs}]`,getAttrs:je}],toDOM:()=>["span",{[fs]:""},0]},div:{group:"block",content:"inline*",attrs:We,parseDOM:[{tag:"div",getAttrs:je}],toDOM:no("div")},paragraph:{group:"block",content:"inline*",attrs:We,parseDOM:[{tag:"p",getAttrs:je}],toDOM:no("p")},orderedList:{group:"block",content:"listItem+",attrs:We,parseDOM:[{tag:"ol",getAttrs:je}],toDOM:no("ol")},bulletList:{group:"block",content:"listItem+",attrs:We,parseDOM:[{tag:"ul",getAttrs:je}],toDOM:no("ul")},listItem:{content:"block*",group:"block",attrs:We,parseDOM:[{tag:"li",getAttrs:je}],toDOM:no("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:We,parseDOM:[{tag:"pre",getAttrs:je}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:We,parseDOM:[{tag:"img[src]",getAttrs:je}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,attrs:We,parseDOM:[{tag:"br",getAttrs:je}],toDOM:n=>["br",{...n.attrs.attrs}]},hardBreak:{inline:!0,group:"inline",selectable:!1,attrs:We,parseDOM:[{tag:"br",getAttrs:je}],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:to(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...T1({tableGroup:"block",cellContent:"block+",cellAttributes:{[et]:{default:We[et].default,getFromDOM:to,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:to(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},oo=(n,e)=>({attrs:ms,parseDOM:n.map(t=>({tag:t,getAttrs:gs})),toDOM:e}),a0=n=>({attrs:{...ms},parseDOM:[{tag:`span[${n}]`,getAttrs:e=>({...gs(e)})}],toDOM(e){return["span",{...qe(e),[n]:!0},0]}}),c0={strong:oo(["strong","b"],n=>["b",qe(n)]),link:oo(["a"],n=>["a",qe(n),0]),em:oo(["em","i"],n=>["em",qe(n)]),underline:oo(["u"],n=>["u",qe(n),0]),strikethrough:oo(["s"],n=>["s",qe(n),0]),wrapStyle:a0(Dd),font_size:{attrs:{...ms,size:{default:null}},parseDOM:[{tag:`span[${Rd}]`,getAttrs:n=>({...gs(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...qe(n),[Rd]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}},color:ir({key:i0,cssProperty:"color"}),bgColor:ir({key:r0,cssProperty:"background-color"})},Ld=new Tf({nodes:l0,marks:c0}),so=new WeakMap,rr=new WeakMap,d0=(n,e,t)=>{so.set(n,{view:e,gjsView:t,initialDoc:e.state.doc}),rr.set(e,{el:n,gjsView:t})},p0=(n,e)=>{so.delete(n),rr.delete(e)},ys=n=>so.get(n),$d=n=>rr.get(n),zd=n=>{const e=ys(n),t=e==null?void 0:e.view,o=e==null?void 0:e.initialDoc;return!(t&&o&&o.eq(t.state.doc))},lr=n=>{var e,t;return(t=(e=$d(n))==null?void 0:e.gjsView)==null?void 0:t.model},u0=n=>n.dispatchEvent(new CustomEvent("input"));function h0(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(fs)){if(t.getAttribute("style")){t.removeAttribute(fs);return}const o=t.parentElement;if(o){for(;t.firstChild;)o.insertBefore(t.firstChild,t);o.removeChild(t)}}else Array.from(t.children).forEach(o=>e(o))};e(n)}const Bd=n=>{n.childNodes.forEach(e=>{if(e.nodeName==="BR"){const{nextSibling:t}=e,o=n.lastChild===e,s=(t==null?void 0:t.nodeType)===Node.ELEMENT_NODE&&(t==null?void 0:t.nodeName)!=="BR";(o||s)&&e.remove()}else Bd(e)})},f0=(n,e)=>{const t=Vd(n);return t&&T0(t)?g0(n,e):t?ja(()=>({type:n.schema.nodes.div}))(n,e):!1},m0=(n,e)=>(t,o)=>{var l;const s=Vd(t),i=so.get(n.el).view,r=(l=e.onEnter)==null?void 0:l.call(e,{...n,node:s,commands:dr(i,n.editor,e),proseMirror:{view:i,dispatch:o}});return r!==void 0?r:f0(t,o)};function Vd(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 g0(n,e){const{selection:t,schema:o,tr:s}=n;s.split(t.from,1);const i=t.from+1,r=s.doc.nodeAt(i),l={...r.attrs.attrs,id:void 0},a=r.textContent.length>0,c=r.textContent.length||0,d=r.textContent||" ",p=o.text(d),u=o.nodes.div.create(l,a?p:[],[]);return s.replaceRangeWith(i,i+c+2,u),s.setSelection($.create(s.doc,i+1)),e==null||e(s.scrollIntoView()),!0}function y0(n,e,t){const{state:o,dispatch:s}=n,{selection:i,tr:r}=o,l=(a,c,d)=>{const p={};return a.split(";").forEach(u=>{const[h,f]=u.split(":").map(m=>m.trim());h&&(p[h]=f)}),p[c]=d,Object.entries(p).map(([u,h])=>`${u}: ${h}`).join("; ")};if(!i.empty||t)r.doc.nodesBetween(i.from,i.to,(a,c)=>{var d,p;if(a.type===o.schema.nodes.image){const u=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}else if(a.type.isBlock){const u=l(((p=a.attrs.attrs)==null?void 0:p.style)||"","text-align",e);Hd(a)?r.setBlockType(i.from,void 0,o.schema.nodes.div,{attrs:{style:u}}):r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}});else{const a=o.doc.resolve(i.from),c=a.start(a.depth),d=o.doc.nodeAt(c);if(d!=null&&d.type.isBlock){const p=l(d.attrs.style||"","text-align",e);r.setNodeMarkup(c,void 0,{...d.attrs,style:p})}}r.docChanged&&s(r.scrollIntoView())}const io=(n,e)=>{const{from:t,to:o}=n.selection;let s=!1;return n.doc.nodesBetween(t,o,i=>{if(s)return!1;i.marks.some(r=>r.type===e)&&(s=!0)}),s};function b0(n){var p,u;const{view:e,href:t,options:o,target:s="_blank"}=n,{state:i,dispatch:r}=e,{schema:l,selection:a,tr:c}=i,d=l.marks.link;try{const h={href:t,target:s},f=((u=(p=o.commandAttrs)==null?void 0:p.link)==null?void 0:u.call(p,h))||h,m=d.create({[et]:JSON.stringify(f)});c.addMark(a.from,a.to,m),r(c.scrollIntoView())}catch(h){console.error("Error applying link mark:",h)}}function v0(n,e){const{state:t,dispatch:o}=n,{selection:s,tr:i}=t;if(s.empty)return;const r=t.schema.marks.font_size;if(!r){console.error("Font size mark is not defined in the schema.");return}i.addMark(s.from,s.to,r.create({size:e})),o(i.scrollIntoView())}function S0(n,e){const{state:t,dispatch:o}=n,{selection:s,tr:i}=t;if(s.empty)return;const r=t.schema.marks.color;if(!r){console.error("Color mark is not defined in the schema.");return}i.addMark(s.from,s.to,r.create({value:e})),o(i.scrollIntoView())}function x0(n,e){const{state:t,dispatch:o}=n,{selection:s,tr:i}=t;if(s.empty)return;const r=t.schema.marks.bgColor;if(!r){console.error("Background color mark is not defined in the schema.");return}i.addMark(s.from,s.to,r.create({value:e})),o(i.scrollIntoView())}const Wt=(n,e)=>{const{doc:t,selection:o}=n.state,s=t.resolve(o.from);for(let i=s.depth;i>0;i--){const r=s.node(i);if(e(r))return{pos:i>0?s.before(i):0,start:s.start(i),depth:i,node:r}}},w0=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 C0(...n){return(e,t)=>{const o=r=>{e=e.apply(r),t==null||t(r)},s=n.pop();return n.reduce((r,l)=>r||l(e,o),!1)&&s!==void 0&&s(e,t)}}const k0=(n,e)=>{const{state:t,dispatch:o}=n;if(e!=null&&e.event){const{event:s}=e,i=n.posAtCoords({left:s.clientX,top:s.clientY});i!=null&&i.pos&&o(t.tr.setSelection($.create(t.doc,i.pos)))}else qa(t,o);setTimeout(()=>setTimeout(()=>n.focus()))},ar=n=>n.isBlock,Hd=n=>n.type.name==="inlineFragment",E0=n=>ar(n)&&!Hd(n),Fd=n=>n.type.name==="bulletList",_d=n=>n.type.name==="orderedList",T0=n=>n.type.name==="heading",M0=n=>Fd(n)||_d(n),Gd=(n,e)=>{var i,r;const t=(i=Wt(n,l=>l.type===e))==null?void 0:i.node,o=n.state.schema.nodes.listItem;let s;return t?s=Ti(o):(r=Wt(n,M0))!=null&&r.node?s=C0(Ti(o),oc(e)):s=oc(e),s(n.state,n.dispatch)},Wd=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(o=>o.type.name===e)},A0=n=>{var r;const{view:e,prop:t,editor:o,propCSS:s}=n,i=(r=Wt(e,E0))==null?void 0:r.node;if(i){const l=i.attrs.attrs||{},a=w0(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""},cr=n=>{const{view:e,prop:t,markName:o,editor:s,propCSS:i}=n,r=Wd(e,o);if(r){const l=r.attrs;if(l[t])return l[t];if(l[et]){const a=qe(r).id;if(a){const c=s.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[i]||""}}}return""},dr=(n,e,t)=>{const{dispatch:o}=n,{nodes:s,marks:i}=n.state.schema,r={text:{selected:()=>{const{selection:l,doc:a}=n.state;return a.textBetween(l.from,l.to," ")},replace:(l,a={})=>{const{state:c}=n,{from:d}=c.selection;let p=c.tr.replaceSelectionWith(c.schema.text(l));a.select&&(p=p.setSelection($.create(p.doc,d,d+l.length))),o==null||o(p)},replaceHtml:l=>{const{schema:a,selection:c,tr:d}=n.state,p=document.createElement("div");p.innerHTML=l;const u=Rt.fromSchema(a).parse(p),{from:h,to:f}=c;return o==null?void 0:o(d.replaceRangeWith(h,f,u).scrollIntoView())},wrapStyle:()=>{const l=lr(n),a=r.text.selected(),c=`i${e.Components._createId().slice(0,4)}`;r.text.replaceHtml(`<span id="${c}" ${Dd}>${a}</span>`),l==null||l.trigger("disable"),setTimeout(()=>{const d=l==null?void 0:l.find(`#${c}`)[0];d&&e.select(d)})},createBreak:()=>{const{state:l}=n,a=l.tr.replaceSelectionWith(s.inlineBreak.create()).scrollIntoView();return o==null?void 0:o(a)}},bold:{toggle:()=>Lt(i.strong)(n.state,o),isActive:()=>io(n.state,i.strong)},italic:{toggle:()=>Lt(i.em)(n.state,o),isActive:()=>io(n.state,i.em)},underline:{toggle:()=>Lt(i.underline)(n.state,o),isActive:()=>io(n.state,i.underline)},strikethrough:{toggle:()=>Lt(i.strikethrough)(n.state,o),isActive:()=>io(n.state,i.strikethrough)},link:{get:()=>{const l=lr(n),a=l==null?void 0:l.getTrait("href");if(l!=null&&l.is("link"))return l.getAttributes();if(a)return{href:a.getValue()};{const c=Wd(n,"link");return c?qe(c):{}}},toggle:()=>Lt(i.link)(n.state,o),isActive:()=>io(n.state,i.link),create:l=>{const a=lr(n),c=a==null?void 0:a.getTrait("href"),{url:d,target:p}=l,u=()=>{var f,m;const h=(m=(f=$d(n))==null?void 0:f.gjsView)==null?void 0:m.el;h&&h.contentEditable!=="true"&&(h.contentEditable="true"),n.focus()};a!=null&&a.is("link")?(a.addAttributes({href:d,target:p}),u()):c?(a==null||a.addAttributes({[c.getName()]:d}),u()):b0({view:n,href:d,target:p,options:t})}},alignText:{get:()=>A0({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:l=>y0(n,l.value,!0)},fontSize:{get:()=>cr({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:l=>v0(n,l.value)},color:{get:()=>cr({view:n,editor:e,markName:"color",prop:"value",propCSS:"color"}),set:l=>S0(n,l.value)},bgColor:{get:()=>cr({view:n,editor:e,markName:"bgColor",prop:"value",propCSS:"background-color"}),set:l=>x0(n,l.value)},image:{open(){const l="assetLayout",{state:a,dispatch:c}=n,{selection:d,doc:p}=a,u=p.textBetween(d.from,d.to," "),h={id:l,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:f=>{const m={alt:u,src:f.asset.getSrc()};c(a.tr.replaceSelectionWith(s.image.createAndFill({attrs:m})))}}};e.runCommand(_.layoutToggle,h)}},heading:{get:()=>{var a;const l=(a=Wt(n,ar))==null?void 0:a.node;return`${(l==null?void 0:l.attrs.level)||""}`},set:({value:l})=>{var d;const{state:a}=n,c=(d=Wt(n,ar))==null?void 0:d.node;vm(a.schema.nodes.heading,{attrs:c==null?void 0:c.attrs.attrs,level:l?parseInt(l,10):0})(a,o)}},listBullet:{isActive:()=>{var l;return!!((l=Wt(n,Fd))!=null&&l.node)},toggle:()=>Gd(n,s.bulletList)},listOrdered:{isActive:()=>{var l;return!!((l=Wt(n,_d))!=null&&l.node)},toggle:()=>Gd(n,s.orderedList)}};return r};class vt{constructor(e,t,o={}){this.match=e,this.match=e,this.handler=typeof t=="string"?P0(t):t,this.undoable=o.undoable!==!1,this.inCode=o.inCode||!1}}function P0(n){return function(e,t,o,s){let i=n;if(t[1]){let r=t[0].lastIndexOf(t[1]);i+=t[0].slice(r+t[1].length),o+=r;let l=o-s;l>0&&(i=t[0].slice(r-l,r)+i,o=s)}return e.tr.insertText(i,o,s)}}const N0=500;function O0({rules:n}){let e=new gn({state:{init(){return null},apply(t,o){let s=t.getMeta(this);return s||(t.selectionSet||t.docChanged?null:o)}},props:{handleTextInput(t,o,s,i){return jd(t,o,s,i,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:o}=t.state.selection;o&&jd(t,o.pos,o.pos,"",n,e)})}}},isInputRules:!0});return e}function jd(n,e,t,o,s,i){if(n.composing)return!1;let r=n.state,l=r.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-N0),l.parentOffset,null,"")+o;for(let c=0;c<s.length;c++){let d=s[c];if(l.parent.type.spec.code){if(!d.inCode)continue}else if(d.inCode==="only")continue;let p=d.match.exec(a),u=p&&d.handler(r,p,e-(p[0].length-o.length),t);if(u)return d.undoable&&u.setMeta(i,{transform:u,from:e,to:t,text:o}),n.dispatch(u),!0}return!1}const I0=new vt(/--$/,"—"),R0=new vt(/\.\.\.$/,"…"),D0=new vt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),L0=new vt(/"$/,"”"),$0=new vt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),z0=new vt(/'$/,"’"),B0=[D0,L0,$0,z0];function pr(n,e,t=null,o){return new vt(n,(s,i,r,l)=>{let a=t instanceof Function?t(i):t,c=s.tr.delete(r,l),d=c.doc.resolve(r),p=d.blockRange(),u=p&&wa(p,e,a);if(!u)return null;c.wrap(p,u);let h=c.doc.resolve(r-1).nodeBefore;return h&&h.type==e&&Ko(c.doc,r-1)&&(!o||o(i,h))&&c.join(r-1),c})}function qd(n,e,t=null){return new vt(n,(o,s,i,r)=>{let l=o.doc.resolve(i),a=t instanceof Function?t(s):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?o.tr.delete(i,r).setBlockType(i,i,e,a):null})}function V0(n){return pr(/^\s*>\s$/,n)}function H0(n){return pr(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function F0(n){return pr(/^\s*([-+*])\s$/,n)}function _0(n){return qd(/^```$/,n)}function G0(n,e){return qd(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function W0(n){const e=B0.concat(R0,I0);let t;return(t=n.nodes.blockquote)&&e.push(V0(t)),(t=n.nodes.orderedList)&&e.push(H0(t)),(t=n.nodes.bulletList)&&e.push(F0(t)),(t=n.nodes.codeBlock)&&e.push(_0(t)),(t=n.nodes.heading)&&e.push(G0(t,6)),O0({rules:e})}const j0="rteProseMirror",q0=F.free,pe="rte:selectionchange",X={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>',color:'<svg viewBox="0 0 24 24"><path d="M9.62,12L12,5.67L14.37,12M11,3L5.5,17H7.75L8.87,14H15.12L16.25,17H18.5L13,3H11Z" /></svg>',bgColor:'<svg viewBox="0 0 24 24"><path d="M19,11.5C19,11.5 17,13.67 17,15A2,2 0 0,0 19,17A2,2 0 0,0 21,15C21,13.67 19,11.5 19,11.5M5.21,10L10,5.21L14.79,10M16.56,8.94L7.62,0L6.21,1.41L8.59,3.79L3.44,8.94C2.85,9.5 2.85,10.47 3.44,11.06L8.94,16.56C9.23,16.85 9.62,17 10,17C10.38,17 10.77,16.85 11.06,16.56L16.56,11.06C17.15,10.47 17.15,9.5 16.56,8.94Z" /></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>'},Ud=n=>({state:e})=>({type:"column",style:{alignItems:"center",background:"none"},children:[{type:"icon",icon:n,size:16},{type:"row",style:{width:16,height:2,backgroundColor:e.value||"currentColor",borderRadius:1}}]}),U0=(n,e)=>{var a;const{editor:t,el:o}=n,s=so.get(o).view,i=dr(s,t,e),r={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},wrapStyle:{id:"wrapper",type:"button",icon:"tag",tooltip:"Wrap for styling",editorEvents:{[pe]:({setState:c})=>{c({disabled:s.state.selection.empty})}},onClick:()=>i.text.wrapStyle()},bold:{id:"bold",icon:X.bold,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.bold.isActive()})}},onClick:({setState:c})=>{i.bold.toggle(),c({active:i.bold.isActive()})}},italic:{id:"italic",icon:X.italic,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.italic.isActive()})}},onClick:({setState:c})=>{i.italic.toggle(),c({active:i.italic.isActive()})}},underline:{id:"underline",icon:X.underline,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.underline.isActive()})}},onClick:({setState:c})=>{i.underline.toggle(),c({active:i.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:X.strikethrough,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.strikethrough.isActive()})}},onClick:({setState:c})=>{i.strikethrough.toggle(),c({active:i.strikethrough.isActive()})}},image:{id:"image",icon:X.image,size:"s",type:"button",onClick:()=>i.image.open()},link:{id:"link",icon:X.link,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.link.isActive(),disabled:s.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,p="linkLayout",u=()=>t.runCommand(_.layoutRemove,{id:p}),h=i.link.get(),f={id:p,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,target:d},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:m=>{m.preventDefault();const g=new FormData(m.currentTarget);i.link.create({url:g.get("url"),target:g.get("target")}),u()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(h==null?void 0:h.href)||"",onChange:({value:m,setState:g})=>g({value:m})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(h==null?void 0:h.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:m,setState:g})=>g({value:m})},{type:"row",style:{gap:10,justifyContent:"end"},children:[i.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{i.link.toggle(),u()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(_.layoutToggle,f)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:X.alignTextLeft},{id:"center",icon:X.alignTextCenter},{id:"right",icon:X.alignTextRight},{id:"justify",icon:X.alignTextJustify}],editorEvents:{[pe]:({setState:c})=>{c({value:i.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.alignText.set({value:c})}},alignTextMenu:{id:"alignTextMenu",type:"buttonMenu",size:"s",value:"",options:[{id:"left",icon:X.alignTextLeft},{id:"center",icon:X.alignTextCenter},{id:"right",icon:X.alignTextRight},{id:"justify",icon:X.alignTextJustify}],editorEvents:{[pe]:({setState:c})=>{c({value:i.alignText.get()})}},onOptionSelect:({option:c,state:d,setState:p})=>{const u=c.id===d.value?"":c.id;p({value:u}),i.alignText.set({value:u})},onClick:({state:c})=>{c.value&&i.alignText.set({value:c.value})}},listBullet:{id:"listBullet",icon:X.listBullet,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.listBullet.isActive()})}},onClick:({setState:c})=>{i.listBullet.toggle(),c({active:i.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:X.listOrdered,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.listOrdered.isActive()})}},onClick:({setState:c})=>{i.listOrdered.toggle(),c({active:i.listOrdered.isActive()})}},heading:{id:"heading",type:"selectField",size:"s",value:"",emptyState:"Heading",options:[{id:"",label:"Normal"},{id:"1",label:"Heading 1"},{id:"2",label:"Heading 2"},{id:"3",label:"Heading 3"},{id:"4",label:"Heading 4"},{id:"5",label:"Heading 5"},{id:"6",label:"Heading 6"}],editorEvents:{[pe]:({setState:c})=>{c({value:i.heading.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.heading.set({value:c}),s.focus()}},fontSize:{id:"fontSize",type:"selectField",size:"s",value:"",emptyState:"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:{[pe]:({setState:c})=>{c({value:i.fontSize.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.fontSize.set({value:c}),s.focus()}},color:{id:"color",type:"buttonMenu",size:"s",value:"",label:Ud(X.color),editorEvents:{[pe]:({setState:c})=>{c({disabled:s.state.selection.empty})}},children:({state:c,setState:d})=>({type:"colorPicker",value:c.value||"",onChange:p=>{const{value:u}=p;d({value:u}),p.setState({value:u}),i.color.set({value:u}),s.focus()}}),onClick:({state:c})=>{c.value&&(i.color.set({value:c.value}),s.focus())}},bgColor:{id:"bgColor",type:"buttonMenu",size:"s",value:"",label:Ud(X.bgColor),editorEvents:{[pe]:({setState:c})=>{c({disabled:s.state.selection.empty})}},children:({state:c,setState:d})=>({type:"colorPicker",value:c.value||"",onChange:p=>{const{value:u}=p;d({value:u}),p.setState({value:u}),i.bgColor.set({value:u}),s.focus()}}),onClick:({state:c})=>{c.value&&(i.bgColor.set({value:c.value}),s.focus())}}},l=[r.bold,r.italic,r.underline,r.strikethrough,r.image,r.link,r.listBullet,r.listOrdered,r.color,r.bgColor,r.alignTextMenu,r.heading,r.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:i,layouts:r,proseMirror:{view:s},items:l}))||l};class K0{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;dr(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 J0=W(function(n,e={}){const t={plugins:l=>l.plugins,...e},o=(l,a)=>{var g,b;const c=((g=t.schema)==null?void 0:g.call(t,{editor:n,schema:Ld,createCustomMark:ir}))||Ld,{nodes:d,marks:p}=c,u={...a,component:a.view.model,editor:n,el:l};Bd(l);const h=Rt.fromSchema(c).parse(l),f=mn.create({doc:h,schema:c,plugins:(b=t.plugins)==null?void 0:b.call(t,{editor:n,Plugin:gn,plugins:[K1(),s0(),W0(c),Nm(),Ei({Tab:Cd(1),"Shift-Tab":Cd(-1)}),Ei({Enter:Gn(Wa,Bm(d.listItem),m0(u,t)),"Shift-Enter":Gn(Ga,(C,y)=>(y&&y(C.tr.replaceSelectionWith(d.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":tc,"Mod-y":wi,"Mod-Shift-z":wi,"Mod-b":Lt(p.strong),"Mod-i":Lt(p.em),"Shift-Tab":Ti(d.listItem),Tab:Fm(d.listItem)}),Ei(xm)]})}),m=new v1({mount:l},{state:f,dispatchTransaction(C){var x;const{state:y}=m,v=y.apply(C),w=!y.doc.eq(v.doc);m.updateState(v);const S=!y.selection.eq(v.selection);w&&(u0(((x=a==null?void 0:a.view)==null?void 0:x.el)||l),m.focus()),(S||w)&&n.trigger(pe)}});return l.__rteView=m,m.setProps({nodeViews:{image(C){return new K0(C,m,n)}}}),m},s=l=>U0(l,t);n.setCustomRte({toolbar:s,parseContent:!0,async enable(l,a,c){const d=ys(l);if(d)return d;const p=o(l,c);return d0(l,p,c.view),k0(p,c),p},disable(l){const a=ys(l),c=a==null?void 0:a.view;if(c){const d=zd(l);return p0(l,c),d||n.once(n.RichTextEditor.events.disable,()=>{a.gjsView.model.trigger("rerender")}),c.destroy(),{forceSync:d}}},getContent(l,a,c){var p;const d=(p=ys(l))==null?void 0:p.view;if(d){const{schema:u,doc:h}=d.state;if(!zd(l))return c.view.lastContent;const f=document.createElement("div"),m=Dt.fromSchema(u).serializeFragment(h.content);return m.childNodes.forEach(g=>{var b;g.nodeType===Node.ELEMENT_NODE&&(g.innerHTML===""?g.innerHTML="<br/>":((b=g.lastChild)==null?void 0:b.nodeName)==="BR"&&g.appendChild(document.createElement("br")))}),f.appendChild(m),h0(f),l.classList.remove("ProseMirror-focused"),f.innerHTML}return l.innerHTML}});const i=Hl(n,t.enableOnClick),r=ef(n,t.disableOnEsc);j({editor:n,licenseKey:t.licenseKey,plan:q0,pluginName:j0,cleanup:()=>{n.RichTextEditor.customRte=void 0,i(),r()}})}),Z0="canvasEmptyState",Y0=F.startup,X0=W(function(n,e={}){const t=new WeakMap,o=new WeakMap,s=new WeakMap,i=new Set,r=new WeakMap,l={emptyStates:[],...e},a=(y,v)=>{let w=!1;const{isValid:S}=v;return Array.isArray(S)?w=S.some(x=>y.is(x)):xt(S)?w=S({component:y,editor:n}):w=y.is(S),w},c=y=>{const v=t.get(y);t.delete(y),v==null||v()},d=y=>{y.views.forEach(v=>c(v)),s.delete(y)},p=y=>{if(!(!y||i.has(y)))try{i.add(y);const v=y.components().length>0,w=s.get(y);if(v&&w)d(y);else if(!v&&!w){const S=r.has(y)?r.get(y):l.emptyStates.find(x=>a(y,x));if(r.set(y,S),!S)return;y.views.forEach(x=>{const k=S.render({editor:n,component:y,componentView:x,mount:E=>{o.set(x,E),s.set(y,!0);const M=x.getChildrenContainer();M==null||M.appendChild(E)},unmount:()=>c(x)});t.set(x,()=>{k==null||k();const E=o.get(x);E==null||E.remove()})})}}finally{i.delete(y)}},u=y=>{s.has(y)&&d(y)},h=({model:y})=>{p(y.getComponent())},f=n.Components.events,m=`${f.update}:components`,g="component:mount",b=n.Canvas.events.frameLoadBody,C=f.removed;n.on(m,p),n.on(g,p),n.on(C,u),n.on(b,h),j({editor:n,licenseKey:l.licenseKey,plan:Y0,pluginName:Z0,cleanup:()=>{n.off(m,p),n.off(g,p),n.off(C,u),n.off(b,h)}})}),Kd="canvasFullSize",Q0=F.startup,ey=(n,e)=>{const{rule:t,ruleView:o}=e,{style:s}=t.attributes;if(s&&s[n]){const i=s[n],r=/([0-9.]+)(vh|dvh|lvh|svh)/g,l=r.test(i),a=o.frameView.model;if(l&&a.hasAutoHeight()){const c=i.replace(r,(p,u)=>`${window.innerHeight*(parseFloat(u)/100)}px`),d=t.toCSS({style:{...s,[n]:c}});e.css=d}}},ty=n=>{["height","min-height","max-height"].forEach(e=>ey(e,n))},ny=W(function(n,e={}){const{Canvas:t,Commands:o,Devices:s,Css:i}=n,r={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...e},{canvasOffsetY:l,canvasOffsetX:a,canvasTransition:c,deviceMaxWidth:d,deviceMinHeigth:p,deviceFixedHeight:u,frameBorderRadius:h,frameTransition:f}=r,m=`${p}px`,g=t.events,b="core:preview",C=`${o.events.stopCommand}${b}`,y=t.getConfig(),v=`${Kd}:disable`,w=s.getAll().map(B=>({...B.attributes})),S=c*1e3,x={x:a,y:l};let k={},E,M;y.scrollableCanvas=!u,s.getAll().map(B=>{!B.get("width")&&B.set("width",`${d}px`),!B.get("height")&&B.set("height",u?"100vh":"auto"),!B.get("minHeight")&&B.set("minHeight",m)});const P=B=>{const be=`${go}canvas-full-size`,ve=document.querySelector(`style[${be}]`);if(B&&ve)return ve.remove();const Ke=ve||document.createElement("style"),Cs=t.getZoomMultiplier();Ke.setAttribute(be,"true"),Ke.innerHTML=`
|
|
917
917
|
.gjs-frame-wrapper { transition: width ${f}s !important; }
|
|
918
918
|
.gjs-frame-wrapper__bottom { height: ${l*Cs}px }
|
|
919
919
|
.gjs-frame { border-radius: ${h}px }
|
|
@@ -922,7 +922,7 @@
|
|
|
922
922
|
[data-gjs-type="wrapper"] { min-height: ${m} !important; }
|
|
923
923
|
[data-gjs-type="mjml"] { min-height: ${m} !important; }
|
|
924
924
|
[data-gjs-type="mj-body"] { min-height: ${m} !important; }
|
|
925
|
-
`,!Ke.contains(ks)&&Ke.appendChild(ks)});const N=()=>E.style.display="none",I=()=>E.style.display="",R=()=>{var Ke;if(!u)return;const B=t.getZoomMultiplier(),ve=t.getRect().height*B-l*2;(Ke=s.getSelected())==null||Ke.set("height",`${Math.max(ve,p)}px`),t.fitViewport({zoom:t.getZoom(),gap:x})},
|
|
925
|
+
`,!Ke.contains(ks)&&Ke.appendChild(ks)});const N=()=>E.style.display="none",I=()=>E.style.display="",R=()=>{var Ke;if(!u)return;const B=t.getZoomMultiplier(),ve=t.getRect().height*B-l*2;(Ke=s.getSelected())==null||Ke.set("height",`${Math.max(ve,p)}px`),t.fitViewport({zoom:t.getZoom(),gap:x})},G=En(()=>{t.fitViewport({zoom:B=>B>100?100:B,ignoreHeight:!0,gap:x}),R(),P(),setTimeout(()=>{var be,ve;const{em:B}=n;B.destroyed||((ve=(be=n.getSelected())==null?void 0:be.getEl())==null||ve.scrollIntoView({block:"nearest"}),n.refresh({tools:!0}),I(),o.isActive(b)?B.stopDefault():B.runDefault())},S)},100),ue=(B={})=>{B.options&&B.options.from!=="fitViewport"&&t.fitViewport({zoom:t.getZoom(),ignoreHeight:!0,gap:x})},he=()=>{N(),G()},tt=()=>{k.overflowX="hidden",k.overflowY="auto"},Ce=()=>{M==null||M.disconnect(),G.clear()},Ae=[[s.events.select,he],[g.zoom,ue],[C,tt],[n.events.destroy,Ce],[i.events.mountBefore,ty]];o.add(v,()=>{s.devices.reset(w),y.scrollableCanvas=!1,t.getModel().updateDevice(),t.setZoom(100),t.setCoords(0,0),k.overflowY="hidden",P(!0),Ae.forEach(([B,be])=>n.off(B,be)),Ce(),o.run("studio:canvasReload")}),Ae.forEach(([B,be])=>n.on(B,be)),n.onReady(()=>{const B=t.getElement(),be=t.getFramesEl(),ve=t.getCanvasView();E=t.getSpotsEl(),k=B.style,k.overflowX="hidden",be.style.transition=`transform ${c}s`,document.removeEventListener("keypress",ve.onKeyPress),P(),M=new ResizeObserver(()=>{N(),G()}),M.observe(B.parentElement),G()}),j({editor:n,licenseKey:r.licenseKey,plan:Q0,pluginName:Kd,cleanup:()=>{n.runCommand(v)}})}),ur="canvasGridMode",oy=F.startup,hr="component-grid-mode",ro="grid-mode",lo="gjs-drag-grid-spot",Jd=`${lo}__grid-item`,Zd=`${lo}__grid-target`,Yd=`${lo}__snapped`,sy=`${lo}__container`,iy=()=>{const n="data-gjs-drag-grid-style",e=document,t="var(--gs-theme-cl-cmp-bg1, var(--gjs-color-highlight))",o="var(--gs-theme-cl-cmp-bg2, var(--gjs-color-blue))",s=e.querySelector(`style[${n}]`)||e.createElement("style");s.setAttribute(n,"true"),s.innerHTML=`
|
|
926
926
|
.${Jd} {
|
|
927
927
|
outline: 2px solid ${o};
|
|
928
928
|
background: ${t};
|
|
@@ -947,7 +947,7 @@
|
|
|
947
947
|
outline-offset: -1px;
|
|
948
948
|
opacity: 0.35;
|
|
949
949
|
}
|
|
950
|
-
`,e.head.appendChild(s)};function Xd(n){const{editor:e,type:t}=n,o=dy(e,n.component),s=fr(e,o.component);if(!py(e,o,s,t))return{target:o,container:s,startScroll:np(e).scroll,shadowContainerEl:document.createElement("div"),shadowSnappedEl:document.createElement("div"),shadowTargetEl:document.createElement("div"),spot:e.Canvas.addSpot({type:ro,component:s.component})}}function Qd(n){const{editor:e,shadowTargetEl:t,shadowSnappedEl:o,shadowContainerEl:s,spotEl:i,target:r,container:l}=n,{Canvas:a}=e,c=e.config.stylePrefix;i==null||i.appendChild(s),s==null||s.appendChild(t),s==null||s.appendChild(o),ry(s,l),ly(t,r,l),ay(o,r),cy(s,l.el),r.el.style.opacity="0";const d=a.getSpots().filter(p=>p.type!==ro);e.em.stopDefault({preserveSelected:!0}),a.removeSpots(d),a.startAutoscroll(),a.getBody().classList.add(`${c}is__grabbing`)}function ep(n){const{editor:e,shadowSnappedEl:t,shadowContainerEl:o,target:s,cancelled:i}=n,{Canvas:r}=e,l=e.config.stylePrefix,{component:a}=s;if(!i){const c=window.getComputedStyle(t);a.addStyle({"grid-area":c.gridArea,width:"",height:""})}s.el.style.opacity="",o.contains(t)&&(o==null||o.removeChild(t)),e.getModel().runDefault({preserveSelected:1}),r.stopAutoscroll(),r.getBody().classList.remove(`${l}is__grabbing`),r.removeSpots({type:ro}),e.select(a)}function ry(n,{rows:e,columns:t}){const o=[];for(let s=0;s<t.length;s++){o[s]=[];for(let i=0;i<e.length;i++){const r=document.createElement("div");r.className=Jd,r.style.gridArea=`${i+1} / ${s+1}`,o[s][i]=r,n.appendChild(r)}}return o}function ly(n,e,t){return n.className=Zd,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 ay(n,e){const t=sp(e.el,e.computedStyles);return n.className=Yd,n.style.gridArea=`${t.row.start} / ${t.column.start} / ${t.row.end} / ${t.column.end}`,n}function cy(n,e){const t=window.getComputedStyle(e);n.className=sy,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 tp(n,e){if(e){if(Array.isArray(e))return[...e].pop()}else return[...n.getSelectedAll()].pop();return e}function dy(n,e){const t=tp(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 fr(n,e){const t=e.parent(),o=t.getEl(),s=window.getComputedStyle(o);return{component:t,el:o,offset:n.Canvas.offset(o),computedStyles:s,padding:{top:parseFloat(s.paddingTop),right:parseFloat(s.paddingRight),bottom:parseFloat(s.paddingBottom),left:parseFloat(s.paddingLeft)},columns:s.gridTemplateColumns.split(" ").map(r=>parseFloat(r)),rows:s.gridTemplateRows.split(" ").map(r=>parseFloat(r)),gap:{column:parseInt(s.columnGap),row:parseInt(s.rowGap)}}}function St(n,e,t,o,s=1){let i=0;for(let r=e;r<=n.length;r++){if(i+(n[r-1]+o)*s>t)return r;i+=o+n[r-1]}return n.length+1}function np(n){const{scrollY:e,scrollX:t}=n.Canvas.getWindow();return{scroll:{top:e,left:t}}}function py(n,e,t,o){const s=i=>n.em.logWarning(i);return o==="draggable"&&e.component.get(o)===!1?(s(`[${ur}] The element is not ${o}`),!0):t.computedStyles.display!=="grid"?(s(`[${ur}] The container does not have style display:grid`),!0):!1}function mr(n,e,t={}){const o=tp(n,e),s=o==null?void 0:o.parent(),i=s==null?void 0:s.getEl();if(!s||!i)return!1;const{enableGrid:r}=t,l=window.getComputedStyle(i).display==="grid";return xt(r)?r({component:o,parent:s,isParentGrid:l}):l}const op=n=>n.split(" ").map(e=>parseFloat(e));function sp(n,e){const t=n.ownerDocument.defaultView,o=e||t.getComputedStyle(n),s=o.gridArea.split("/").some(w=>isNaN(parseInt(w.trim()))),i={isComputed:s,raw:o.gridArea};if(!s)return{...i,row:{start:parseInt(o.gridRowStart),end:parseInt(o.gridRowEnd)},column:{start:parseInt(o.gridColumnStart),end:parseInt(o.gridColumnEnd)}};const r=n.parentElement,l=t.getComputedStyle(r),a=parseFloat(l.columnGap)||0,c=parseFloat(l.rowGap)||0,d=op(l.gridTemplateColumns),p=op(l.gridTemplateRows),u=parseFloat(l.paddingLeft)||0,h=parseFloat(l.paddingTop)||0,f=r.getBoundingClientRect(),m=n.getBoundingClientRect(),g=(w,S,x,k,E)=>{let M=1,P=k+E;for(let N=0;N<S.length;N++){const I=S[N],R=P+I;if(w>=P&&w<R)return M;P=R+x,M++}return-1},b=g(m.left,d,a,f.left,u),C=g(m.right-1,d,a,f.left,u)+1,y=g(m.top,p,c,f.top,h),v=g(m.bottom-1,p,c,f.top,h)+1;return{...i,row:{start:y,end:v},column:{start:b,end:C}}}function uy(n){n.Commands.add(hr,{stop(){},run(e,t,o={}){const s=Xd({editor:e,component:o.target,type:"draggable"});if(!s){this.stopCommand();return}const{spot:i,target:r,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c,startScroll:d}=s;let{container:p}=s,u;new e.Utils.Dragger({doc:r.el.ownerDocument,onStart:()=>{u=setTimeout(()=>{Qd({editor:e,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:i.attributes.spotEl,target:r,container:p}),p=fr(e,r.component)},10)},onEnd:(f,m,{cancelled:g})=>{clearTimeout(u),ep({editor:e,shadowSnappedEl:a,shadowContainerEl:l,target:r,cancelled:g}),this.stopCommand(),e.em.set("_cmpDrag",1)},setPosition:({x:f,y:m})=>{const{scroll:g}=np(e),{columns:b,rows:C,gap:y,offset:v,padding:w}=p,{offset:S,margin:x}=r,k=S.top-v.top-w.top-x.top+m-d.top+g.top,E=S.left-v.left-w.left-x.left+f-d.left+g.left,M=Math.min(St(b,1,E,y.column,.5),b.length),P=Math.min(St(C,1,k,y.row,.5),C.length),N=Math.min(St(b,M,S.width,y.column)+1,b.length+1),I=Math.min(St(C,P,S.height,y.row)+1,C.length+1);a.style.gridArea=`${P} / ${M} / ${I} / ${N}`,c.style.top=`${k+w.top}px`,c.style.left=`${E+w.left}px`}}).start(o.event)}})}function hy(n,e){const t=Xd({editor:n,component:e.component,type:"resizable"});if(!t)return;const{onMove:o,onEnd:s}=e.options||{},{spot:i,target:r,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c}=t;let{container:d}=t,p="",u;return{onStart:h=>{p=h.target.dataset.gjsHandler||"",u=setTimeout(()=>{Qd({editor:n,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:i.attributes.spotEl,target:r,container:d}),d=fr(n,r.component)},10),n.trigger("component:resize",{...r,type:"start"})},onEnd:(h,f)=>{const{startDim:m,rectDim:g}=f.resizer,b=JSON.stringify(m)===JSON.stringify(g);clearTimeout(u),ep({editor:n,shadowSnappedEl:a,shadowContainerEl:l,target:r,cancelled:b}),s==null||s(h,f)},onMove:(h,f)=>{const m=sp(a),g=r.margin.left,b=r.margin.top,C=r.margin.bottom,y=r.margin.right,{w:v,t:w,l:S,h:x}=f.resizer.rectDim,k={t:w-b,l:S-g,h:x+b+C,w:v+g+y};p.endsWith("l")&&(m.column.start=St(d.columns,1,k.l-d.offset.left-d.padding.left,d.gap.column,.5)),p.startsWith("t")&&(m.row.start=St(d.rows,1,k.t-d.offset.top-d.padding.top,d.gap.row,.5)),p.endsWith("r")&&(m.column.end=Math.max(St(d.columns,m.column.start,k.w,d.gap.column,.5),m.column.start+1)),p.startsWith("b")&&(m.row.end=Math.max(St(d.rows,m.row.start,k.h,d.gap.row,.5),m.row.start+1)),a.style.gridArea=`${m.row.start} / ${m.column.start} / ${m.row.end} / ${m.column.end}`,c.style.width=`${k.w}px`,c.style.height=`${k.h}px`,c.style.left=`${k.l-d.offset.left}px`,c.style.top=`${k.t-d.offset.top}px`,o==null||o(h,f)}}}const ip=["px","%","em","rem","vw","vh"],fy=(n,e)=>{const t=n.Styles.getSectors().find(o=>!!o.getProperty(e));return{sector:t,property:t?t.getProperty(e):void 0}},my=(n,e)=>fy(n,e),gy=(n,{x:e,y:t,mergable:o}={})=>{const s={property:`${n}-x`,type:"integer",units:ip,...e},i={property:`${n}-y`,type:"integer",units:ip,...t};return{property:n,type:"composite",properties:[s,i],...o&&{fromStyle(r,{name:l,separator:a,property:c}){const[d,p]=c.getProperties(),[u,h]=(r[l]||"").split(a);return{[d.getId()]:r[d.getName()]||u||"",[p.getId()]:r[p.getName()]||h||u||""}},toStyle(r,{name:l,property:a}){const[c,d]=a.getProperties(),p=r[c.getId()],u=r[d.getId()];return{[l]:p===u?p:`${p} ${u}`}}}}},gr={display:["grid"]};function yy(n=""){const e=/^repeat\(\s*(\d+)\s*,\s*(.+)\s*\)$/i,t=/^minmax\(\s*(.+?)\s*,\s*(.+?)\s*\)$/i,o=n.match(e);if(!o)return null;const s=parseInt(o[1],10),i=o[2];let r=i,l=i;const a=i.match(t);return a&&(r=a[1],l=a[2]),{total:s,min:r===l?"":r,max:l}}function by(n={}){let e="",t="",o="",s="";const i=m=>m.split("/").map(g=>g.trim()).filter(Boolean),r=n["grid-area"]||"",l=n["grid-column"]||"",a=n["grid-row"]||"",c=i(r),d=i(l),p=i(a),u=c.length,h=d.length,f=p.length;return u===4?(o=c[0],e=c[1],s=c[2],t=c[3]):u===3?(o=c[0],e=c[1],s=c[2]):u===2?(o=c[0],e=c[1]):u===1&&(o=c[0]),h===2?(e=d[0],t=d[1]):h===1&&(e=d[0]),f===2?(o=p[0],s=p[1]):f===1&&(o=p[0]),{columnStart:e,columnEnd:t,rowStart:o,rowEnd:s}}function rp(n){const{property:e,label:t}=n,o="1",s="1fr";return{property:e,label:t,type:"composite",requires:gr,generic:!0,properties:[{name:" ",property:`${e}-repeat`,type:"number",full:!0,min:1,default:"1"},{label:"Min size",property:`${e}-min`,type:"number",min:0,units:["px","%"],default:"0"},{label:"Max size",property:`${e}-max`,type:"number",min:1,units:["fr","px","%"],default:"1"}],fromStyle(i,r){const{name:l,property:a}=r,[c,d,p]=a.getProperties(),u=i[l],h=yy(u),f=(h==null?void 0:h.max)??s;return{[c.id]:(h==null?void 0:h.total)??o,[d.id]:(h==null?void 0:h.min)??"",[p.id]:f===s?"":f}},toStyle(i,{name:r,property:l}){const[a,c,d]=l.getProperties(),p=i[a.id],u=i[c.id],h=i[d.id]||s,f=u&&h?`minmax(${u}, ${h})`:h;return{[r]:`repeat(${p||o}, ${f})`}}}}function vy(n,e){if(!e.styleableGrid)return;const{property:t,...o}=my(n,"display");if(!t)return;const s=t.getOption("grid"),i=o.sector;s||t.addOption({id:"grid",label:"Grid"}),i.addProperty(rp({label:"Columns",property:"grid-template-columns"}),{}),i.addProperty(rp({label:"Rows",property:"grid-template-rows"}),{}),i.addProperty({id:"grid-gap",requires:gr,...gy("gap",{x:{id:"grid-row-gap",label:"Row",property:"row-gap",min:0,default:"0"},y:{id:"grid-column-gap",label:"Column",property:"column-gap",min:0,default:"0"},mergable:!0})},{}),i.addProperty({type:"composite",property:"grid-area",label:"Grid area",requiresParent:gr,generic:!0,properties:[{label:"Row start",property:"grid-row-start",type:"integer",default:"auto"},{label:"Row end",property:"grid-row-end",type:"integer",default:"auto"},{label:"Column start",property:"grid-column-start",type:"integer",default:"auto"},{label:"Column end",property:"grid-column-end",type:"integer",default:"auto"}],fromStyle(r){const l=by(r);return{"grid-column-start":r["grid-column-start"]||l.columnStart,"grid-column-end":r["grid-column-end"]||l.columnEnd,"grid-row-start":r["grid-row-start"]||l.rowStart,"grid-row-end":r["grid-row-end"]||l.rowEnd}},toStyle(r,{name:l}){const a=r["grid-row-start"]||"auto",c=r["grid-row-end"]||"auto",d=r["grid-column-start"]||"auto",p=r["grid-column-end"]||"auto";return{[l]:`${a} / ${d} / ${c} / ${p}`}}},{})}const Sy=G(function(n,e={}){const t={itemResizable:!0,...e},{Canvas:o,Commands:s,Components:i}=n,{itemResizable:r}=t,l=o.events,a=s.events,c=i.events,d=`${a.runBeforeCommand}tlb-move`,p=`${a.runBeforeCommand}resize`;let u;uy(n);const h=({options:y})=>{mr(n,y.target,t)&&(n.runCommand(hr,{...y}),y.abort=!0)},f=y=>{const{options:v}=y;mr(n,v.component,t)&&(v.options=Object.assign(v.options||{},hy(n,v)))},m=()=>{const y=o.getSpots({type:ro}).pop();if(!y)return;let v=y.attributes.spotEl;v||(v=document.createElement("div"),v.className=lo,y.set({spotEl:v})),Object.entries(y.getStyle()).forEach(([w,S])=>v.style.setProperty(w,S)),u==null||u.appendChild(v)},g=({spot:y})=>{const v=y.attributes.spotEl;y.type!==ro||!v||u==null||u.removeChild(v)};if(r){const y=v=>{const w=xt(r)?r({component:v}):r;return typeof w=="boolean"?w:{tl:!1,tc:!1,tr:!1,cl:!1,cr:!1,bl:!1,bc:!1,br:!1,...w}};n.on(c.resizeInit,v=>{const{component:w}=v;if(mr(n,w,t)){const S=y(w);v.resizable=S}})}const b=[[d,h],[p,f],[l.spot,m],[l.spotRemove,g]];b.forEach(([y,v])=>{n.on(y,v)}),n.onReady(()=>{u=o.getSpotsEl(),iy(),vy(n,t)});const C=()=>{delete n.Commands.commands[hr],b.forEach(([y,v])=>{n.off(y,v)})};W({editor:n,licenseKey:t.licenseKey,plan:oy,pluginName:ur,cleanup:C})}),xy="canvasScreenshot",wy=F.startup;var lp=(n=>(n.screenshot="studioPlugin:screenshot",n))(lp||{});const Cy=async n=>await Op([{id:"html-to-image",src:n}]),ky=async(n,e={},t={})=>{const{cdnScript:o}=t;if(!window.htmlToImage){if(!o)return;await Cy(o)}return new Promise((s,i)=>{(async()=>{try{const{canvasWidth:l,canvasHeight:a,width:c,height:d,type:p,quality:u,addOptions:h}=e,f={pixelRatio:1,width:c,height:d,canvasWidth:l,canvasHeight:a},m=(h==null?void 0:h(f))||f,b=await window.htmlToImage.toCanvas(n,m);b.toBlob(C=>{C?s({file:C,canvas:b}):i(new Error("Failed to create file from canvas"))},p,u)}catch(l){i(l)}})()})},yr=lp.screenshot,Ey=G(function(n,e={}){const{Commands:t,Canvas:o,Storage:s}=n,i=s.events.afterStore,r={cdnScript:"https://cdnjs.cloudflare.com/ajax/libs/html-to-image/1.11.13/html-to-image.min.js",...e};t.add(yr,async(c,d,p)=>{const{el:u,...h}=p;return await ky(u,h,r)});const l=async()=>{var d;const c=o.getBody();if(!c)return n.log("Canvas element not found");try{const p=await n.runCommand(yr,{el:c,canvasWidth:400,canvasHeight:225,width:1200,height:675,type:"image/jpeg"});(d=r.screenshotOnSave)==null||d.call(r,{...p,editor:n})}catch(p){console.error("Screenshot error",p)}};r.screenshotOnSave&&n.on(i,l);const a=()=>{delete t.commands[yr],n.off(i,l)};W({editor:n,licenseKey:e.licenseKey,plan:wy,pluginName:xy,cleanup:a})});var Ue=(n=>(n.panelBlocks="panelBlocks",n.panelPagesLayers="panelPagesLayers",n.panelGlobalStyles="panelGlobalStyles",n.panelSidebarTabs="panelSidebarTabs",n.panelAssets="panelAssets",n.aiChatPanel="aiChatPanel",n.panelDataSources="panelDataSources",n))(Ue||{});const ap="sidebarButtonsTarget",bs=(n,e)=>{const{id:t,icon:o,label:s,tooltip:i,className:r,skipSelfClose:l,removeLayouts:a,layoutComponent:c,layoutCommand:d}=n,{pluginOpts:p,breakpointProps:u}=e,h=t;return{id:cp(t),type:"button",icon:o,tooltip:s||i,className:r,editorEvents:{[`${Nr.layoutToggleId}${h}`]:({fromEvent:f,setState:m,editor:g})=>{m({active:f.isOpen}),setTimeout(()=>g.refresh({tools:!0}),20)}},onClick:({editor:f,state:m})=>{var w;if(m.active&&l)return;const g=(d==null?void 0:d.placer)||{type:"static",layoutId:ap},b={...g,skipCleanup:g.type==="static"},C=a||Object.keys(Ue).filter(S=>S!==h);dp(f,{removeLayouts:C,layout:{placer:b}});const y={id:h,placer:g,header:(d==null?void 0:d.header)??{label:s,close:!l},layout:c,style:{width:280,height:"100%",borderRightWidth:1,...d==null?void 0:d.style}},v=((w=p==null?void 0:p.sidebarLayoutCommand)==null?void 0:w.call(p,{...u,layoutCommand:y,sidebarButtonProps:n}))||y;f.runCommand(j.layoutToggle,{...v})}}},cp=n=>`button__${n}`,dp=(n,e={})=>{(e.removeLayouts||Object.keys(Ue)).forEach(o=>n.runCommand(j.layoutRemove,{id:o,layout:e.layout}))},pp=n=>{const e=(n==null?void 0:n.breakpointTablet)??1024,t=(n==null?void 0:n.breakpointMobile)??768,o={},s=[{id:Ue.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:Ue.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:Ue.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:Ue.panelAssets,icon:'<svg viewBox="0 0 24 24"><path d="M22,16V4A2,2 0 0,0 20,2H8A2,2 0 0,0 6,4V16A2,2 0 0,0 8,18H20A2,2 0 0,0 22,16M11,12L13.03,14.71L16,11L20,16H8M2,6V20A2,2 0 0,0 4,22H18V20H4V6" /></svg>',label:"Assets",layoutComponent:{type:"panelAssets",content:{itemsPerRow:2,header:{addUrl:!1}},style:{padding:7},onSelect:({assetProps:h,editor:f})=>{var C;const m=f.getSelected(),g={type:"image",src:h.src};let b;if(m!=null&&m.is("image"))return m.set("src",h.src);m&&f.Components.canMove(m,g)?b=m.append(g)[0]:m||(b=(C=f.getWrapper())==null?void 0:C.append(g)[0]),b&&f.select(b,{scroll:!0})}}}],i=[...s,{id:Ue.panelSidebarTabs,layoutCommand:{header:!1},icon:'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 0 1-1.5-1.5A1.5 1.5 0 0 1 17.5 9a1.5 1.5 0 0 1 1.5 1.5 1.5 1.5 0 0 1-1.5 1.5m-3-4A1.5 1.5 0 0 1 13 6.5 1.5 1.5 0 0 1 14.5 5 1.5 1.5 0 0 1 16 6.5 1.5 1.5 0 0 1 14.5 8m-5 0A1.5 1.5 0 0 1 8 6.5 1.5 1.5 0 0 1 9.5 5 1.5 1.5 0 0 1 11 6.5 1.5 1.5 0 0 1 9.5 8m-3 4A1.5 1.5 0 0 1 5 10.5 1.5 1.5 0 0 1 6.5 9 1.5 1.5 0 0 1 8 10.5 1.5 1.5 0 0 1 6.5 12M12 3a9 9 0 0 0-9 9 9 9 0 0 0 9 9 1.5 1.5 0 0 0 1.5-1.5c0-.4-.2-.7-.4-1-.2-.3-.4-.6-.4-1a1.5 1.5 0 0 1 1.5-1.5H16a5 5 0 0 0 5-5c0-4.4-4-8-9-8Z"/></svg>',label:"Styles & Props",layoutComponent:{type:"panelSidebarTabs"}}],r={id:ap,type:"column",className:"gs-cmp-layout-sidebar-target",style:{overflow:"hidden"}},l={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},a={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}},c=h=>({breakpoint:h,breakpointTablet:e,breakpointMobile:t}),d=(h,f,m)=>{const g=c(f),b={pluginOpts:n,breakpointProps:g},C=h.map(v=>{const w=bs(v,b);return n!=null&&n.sidebarButton?n.sidebarButton({id:v.id,buttonIds:Ue,buttonProps:w,sidebarButtonProps:v,...g,createSidebarButton:S=>bs({...v,...S},b)}):w}).filter(Boolean);return(n!=null&&n.sidebarButtons?n==null?void 0:n.sidebarButtons({buttonIds:Ue,sidebarButtons:C,...g,createSidebarButton:v=>bs({...v,layoutCommand:{...m==null?void 0:m.layoutCommand,...v.layoutCommand}},b)}):C).filter(Boolean)},p=(h,f,m)=>{var C;const g=c(m),b={pluginOpts:n,breakpointProps:g};return((C=n==null?void 0:n.rootLayout)==null?void 0:C.call(n,{sidebarButtons:f,rootLayout:h,layoutSidebarLeft:l,layoutSidebarTarget:r,...g,createSidebarButton:y=>bs({...y},b)}))??h};if(e){const h=d(i,e);o[e]=p({type:"row",style:{height:"100%"},children:[{...l,children:h},r,a]},h,e)}if(t){const h={placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}},f=i.map(g=>({...g,layoutCommand:h})),m=d(f,t,{layoutCommand:h});o[t]=p({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas",grow:!0},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:m}]},m,t)}const u=d(s,0);return{default:p({type:"row",style:{height:"100%"},children:[{...l,children:u},r,a,{type:"sidebarRight"}]},u,0),responsive:o}},up="layoutSidebarButtons",Ty=F.free,hp=G(function(n,e={}){const{Commands:t}=n,o=t.events,s={...e};(()=>{if(n.runCommand(j.layoutConfigGet)||s.skipLayoutConfig===!0)return;const l=pp(s);n.runCommand(j.layoutConfigSet,{...l})})(),t.add(`${up}:toggleButton`,(r,l,a)=>{const c=document.getElementById(cp(a==null?void 0:a.id));c==null||c.click()}),n.on(`${o.runCommand}core:preview`,()=>{dp(n)}),W({editor:n,licenseKey:s.licenseKey,plan:Ty,pluginName:up,cleanup:()=>{n.runCommand(j.layoutConfigSet)}})});hp.createLayoutConfig=n=>pp(n);const jt="page-break";var Le=(n=>(n.A5="a5",n.A5Portrait="a5-portrait",n.A4="a4",n.A3="a3",n.B5="b5",n.B4="b4",n.letter="letter",n.legal="legal",n.ledger="ledger",n))(Le||{});function br(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 My=(n,e)=>{const{name:t,id:o,width:s,height:i,unit:r}=n,{fixedHeight:l}=e,a=`${s}${r}`,c=`${i}${r}`;return{id:o||t.toLowerCase().replace(/\s/g,"-"),name:`${t} (${a} x ${c})`,sizeH:i,sizeW:s,sizeUnit:r,widthMedia:"",width:a,minHeight:l?"0":`${br(i,r)}px`,height:l?c:void 0}},vr="page-breaks",vs="gjs-page-breaks-spot",Sr=n=>n.type===vr;function Ay(n){const{Devices:e}=n,{height:t,minHeight:o}=e.getSelected().attributes,i=parseFloat(`${t&&t!=="auto"?t:o}`),r=n.getWrapper(),l=r==null?void 0:r.getEl(),a=[];if(!r||!l)return a;const c=l.getBoundingClientRect().height,p=r.findType(jt).map(h=>h.getEl()).filter(Boolean).map(h=>({top:h.offsetTop,height:h.offsetHeight}));let u=0;for(;u<c;){const h=p.find(f=>f.top>u&&f.top<u+i);h?(u=h.top+h.height,a.push(h.top)):(u+=i,u<c&&a.push(u))}return a}function Py(n,e){const{Canvas:t}=n,o=t.events,s=n.events;let i;const r=()=>{As(`${go}preset-printable-spots`,`.${vs} {
|
|
950
|
+
`,e.head.appendChild(s)};function Xd(n){const{editor:e,type:t}=n,o=dy(e,n.component),s=fr(e,o.component);if(!py(e,o,s,t))return{target:o,container:s,startScroll:np(e).scroll,shadowContainerEl:document.createElement("div"),shadowSnappedEl:document.createElement("div"),shadowTargetEl:document.createElement("div"),spot:e.Canvas.addSpot({type:ro,component:s.component})}}function Qd(n){const{editor:e,shadowTargetEl:t,shadowSnappedEl:o,shadowContainerEl:s,spotEl:i,target:r,container:l}=n,{Canvas:a}=e,c=e.config.stylePrefix;i==null||i.appendChild(s),s==null||s.appendChild(t),s==null||s.appendChild(o),ry(s,l),ly(t,r,l),ay(o,r),cy(s,l.el),r.el.style.opacity="0";const d=a.getSpots().filter(p=>p.type!==ro);e.em.stopDefault({preserveSelected:!0}),a.removeSpots(d),a.startAutoscroll(),a.getBody().classList.add(`${c}is__grabbing`)}function ep(n){const{editor:e,shadowSnappedEl:t,shadowContainerEl:o,target:s,cancelled:i}=n,{Canvas:r}=e,l=e.config.stylePrefix,{component:a}=s;if(!i){const c=window.getComputedStyle(t);a.addStyle({"grid-area":c.gridArea,width:"",height:""})}s.el.style.opacity="",o.contains(t)&&(o==null||o.removeChild(t)),e.getModel().runDefault({preserveSelected:1}),r.stopAutoscroll(),r.getBody().classList.remove(`${l}is__grabbing`),r.removeSpots({type:ro}),e.select(a)}function ry(n,{rows:e,columns:t}){const o=[];for(let s=0;s<t.length;s++){o[s]=[];for(let i=0;i<e.length;i++){const r=document.createElement("div");r.className=Jd,r.style.gridArea=`${i+1} / ${s+1}`,o[s][i]=r,n.appendChild(r)}}return o}function ly(n,e,t){return n.className=Zd,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 ay(n,e){const t=sp(e.el,e.computedStyles);return n.className=Yd,n.style.gridArea=`${t.row.start} / ${t.column.start} / ${t.row.end} / ${t.column.end}`,n}function cy(n,e){const t=window.getComputedStyle(e);n.className=sy,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 tp(n,e){if(e){if(Array.isArray(e))return[...e].pop()}else return[...n.getSelectedAll()].pop();return e}function dy(n,e){const t=tp(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 fr(n,e){const t=e.parent(),o=t.getEl(),s=window.getComputedStyle(o);return{component:t,el:o,offset:n.Canvas.offset(o),computedStyles:s,padding:{top:parseFloat(s.paddingTop),right:parseFloat(s.paddingRight),bottom:parseFloat(s.paddingBottom),left:parseFloat(s.paddingLeft)},columns:s.gridTemplateColumns.split(" ").map(r=>parseFloat(r)),rows:s.gridTemplateRows.split(" ").map(r=>parseFloat(r)),gap:{column:parseInt(s.columnGap),row:parseInt(s.rowGap)}}}function St(n,e,t,o,s=1){let i=0;for(let r=e;r<=n.length;r++){if(i+(n[r-1]+o)*s>t)return r;i+=o+n[r-1]}return n.length+1}function np(n){const{scrollY:e,scrollX:t}=n.Canvas.getWindow();return{scroll:{top:e,left:t}}}function py(n,e,t,o){const s=i=>n.em.logWarning(i);return o==="draggable"&&e.component.get(o)===!1?(s(`[${ur}] The element is not ${o}`),!0):t.computedStyles.display!=="grid"?(s(`[${ur}] The container does not have style display:grid`),!0):!1}function mr(n,e,t={}){const o=tp(n,e),s=o==null?void 0:o.parent(),i=s==null?void 0:s.getEl();if(!s||!i)return!1;const{enableGrid:r}=t,l=window.getComputedStyle(i).display==="grid";return xt(r)?r({component:o,parent:s,isParentGrid:l}):l}const op=n=>n.split(" ").map(e=>parseFloat(e));function sp(n,e){const t=n.ownerDocument.defaultView,o=e||t.getComputedStyle(n),s=o.gridArea.split("/").some(w=>isNaN(parseInt(w.trim()))),i={isComputed:s,raw:o.gridArea};if(!s)return{...i,row:{start:parseInt(o.gridRowStart),end:parseInt(o.gridRowEnd)},column:{start:parseInt(o.gridColumnStart),end:parseInt(o.gridColumnEnd)}};const r=n.parentElement,l=t.getComputedStyle(r),a=parseFloat(l.columnGap)||0,c=parseFloat(l.rowGap)||0,d=op(l.gridTemplateColumns),p=op(l.gridTemplateRows),u=parseFloat(l.paddingLeft)||0,h=parseFloat(l.paddingTop)||0,f=r.getBoundingClientRect(),m=n.getBoundingClientRect(),g=(w,S,x,k,E)=>{let M=1,P=k+E;for(let N=0;N<S.length;N++){const I=S[N],R=P+I;if(w>=P&&w<R)return M;P=R+x,M++}return-1},b=g(m.left,d,a,f.left,u),C=g(m.right-1,d,a,f.left,u)+1,y=g(m.top,p,c,f.top,h),v=g(m.bottom-1,p,c,f.top,h)+1;return{...i,row:{start:y,end:v},column:{start:b,end:C}}}function uy(n){n.Commands.add(hr,{stop(){},run(e,t,o={}){const s=Xd({editor:e,component:o.target,type:"draggable"});if(!s){this.stopCommand();return}const{spot:i,target:r,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c,startScroll:d}=s;let{container:p}=s,u;new e.Utils.Dragger({doc:r.el.ownerDocument,onStart:()=>{u=setTimeout(()=>{Qd({editor:e,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:i.attributes.spotEl,target:r,container:p}),p=fr(e,r.component)},10)},onEnd:(f,m,{cancelled:g})=>{clearTimeout(u),ep({editor:e,shadowSnappedEl:a,shadowContainerEl:l,target:r,cancelled:g}),this.stopCommand(),e.em.set("_cmpDrag",1)},setPosition:({x:f,y:m})=>{const{scroll:g}=np(e),{columns:b,rows:C,gap:y,offset:v,padding:w}=p,{offset:S,margin:x}=r,k=S.top-v.top-w.top-x.top+m-d.top+g.top,E=S.left-v.left-w.left-x.left+f-d.left+g.left,M=Math.min(St(b,1,E,y.column,.5),b.length),P=Math.min(St(C,1,k,y.row,.5),C.length),N=Math.min(St(b,M,S.width,y.column)+1,b.length+1),I=Math.min(St(C,P,S.height,y.row)+1,C.length+1);a.style.gridArea=`${P} / ${M} / ${I} / ${N}`,c.style.top=`${k+w.top}px`,c.style.left=`${E+w.left}px`}}).start(o.event)}})}function hy(n,e){const t=Xd({editor:n,component:e.component,type:"resizable"});if(!t)return;const{onMove:o,onEnd:s}=e.options||{},{spot:i,target:r,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c}=t;let{container:d}=t,p="",u;return{onStart:h=>{p=h.target.dataset.gjsHandler||"",u=setTimeout(()=>{Qd({editor:n,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:i.attributes.spotEl,target:r,container:d}),d=fr(n,r.component)},10),n.trigger("component:resize",{...r,type:"start"})},onEnd:(h,f)=>{const{startDim:m,rectDim:g}=f.resizer,b=JSON.stringify(m)===JSON.stringify(g);clearTimeout(u),ep({editor:n,shadowSnappedEl:a,shadowContainerEl:l,target:r,cancelled:b}),s==null||s(h,f)},onMove:(h,f)=>{const m=sp(a),g=r.margin.left,b=r.margin.top,C=r.margin.bottom,y=r.margin.right,{w:v,t:w,l:S,h:x}=f.resizer.rectDim,k={t:w-b,l:S-g,h:x+b+C,w:v+g+y};p.endsWith("l")&&(m.column.start=St(d.columns,1,k.l-d.offset.left-d.padding.left,d.gap.column,.5)),p.startsWith("t")&&(m.row.start=St(d.rows,1,k.t-d.offset.top-d.padding.top,d.gap.row,.5)),p.endsWith("r")&&(m.column.end=Math.max(St(d.columns,m.column.start,k.w,d.gap.column,.5),m.column.start+1)),p.startsWith("b")&&(m.row.end=Math.max(St(d.rows,m.row.start,k.h,d.gap.row,.5),m.row.start+1)),a.style.gridArea=`${m.row.start} / ${m.column.start} / ${m.row.end} / ${m.column.end}`,c.style.width=`${k.w}px`,c.style.height=`${k.h}px`,c.style.left=`${k.l-d.offset.left}px`,c.style.top=`${k.t-d.offset.top}px`,o==null||o(h,f)}}}const ip=["px","%","em","rem","vw","vh"],fy=(n,e)=>{const t=n.Styles.getSectors().find(o=>!!o.getProperty(e));return{sector:t,property:t?t.getProperty(e):void 0}},my=(n,e)=>fy(n,e),gy=(n,{x:e,y:t,mergable:o}={})=>{const s={property:`${n}-x`,type:"integer",units:ip,...e},i={property:`${n}-y`,type:"integer",units:ip,...t};return{property:n,type:"composite",properties:[s,i],...o&&{fromStyle(r,{name:l,separator:a,property:c}){const[d,p]=c.getProperties(),[u,h]=(r[l]||"").split(a);return{[d.getId()]:r[d.getName()]||u||"",[p.getId()]:r[p.getName()]||h||u||""}},toStyle(r,{name:l,property:a}){const[c,d]=a.getProperties(),p=r[c.getId()],u=r[d.getId()];return{[l]:p===u?p:`${p} ${u}`}}}}},gr={display:["grid"]};function yy(n=""){const e=/^repeat\(\s*(\d+)\s*,\s*(.+)\s*\)$/i,t=/^minmax\(\s*(.+?)\s*,\s*(.+?)\s*\)$/i,o=n.match(e);if(!o)return null;const s=parseInt(o[1],10),i=o[2];let r=i,l=i;const a=i.match(t);return a&&(r=a[1],l=a[2]),{total:s,min:r===l?"":r,max:l}}function by(n={}){let e="",t="",o="",s="";const i=m=>m.split("/").map(g=>g.trim()).filter(Boolean),r=n["grid-area"]||"",l=n["grid-column"]||"",a=n["grid-row"]||"",c=i(r),d=i(l),p=i(a),u=c.length,h=d.length,f=p.length;return u===4?(o=c[0],e=c[1],s=c[2],t=c[3]):u===3?(o=c[0],e=c[1],s=c[2]):u===2?(o=c[0],e=c[1]):u===1&&(o=c[0]),h===2?(e=d[0],t=d[1]):h===1&&(e=d[0]),f===2?(o=p[0],s=p[1]):f===1&&(o=p[0]),{columnStart:e,columnEnd:t,rowStart:o,rowEnd:s}}function rp(n){const{property:e,label:t}=n,o="1",s="1fr";return{property:e,label:t,type:"composite",requires:gr,generic:!0,properties:[{name:" ",property:`${e}-repeat`,type:"number",full:!0,min:1,default:"1"},{label:"Min size",property:`${e}-min`,type:"number",min:0,units:["px","%"],default:"0"},{label:"Max size",property:`${e}-max`,type:"number",min:1,units:["fr","px","%"],default:"1"}],fromStyle(i,r){const{name:l,property:a}=r,[c,d,p]=a.getProperties(),u=i[l],h=yy(u),f=(h==null?void 0:h.max)??s;return{[c.id]:(h==null?void 0:h.total)??o,[d.id]:(h==null?void 0:h.min)??"",[p.id]:f===s?"":f}},toStyle(i,{name:r,property:l}){const[a,c,d]=l.getProperties(),p=i[a.id],u=i[c.id],h=i[d.id]||s,f=u&&h?`minmax(${u}, ${h})`:h;return{[r]:`repeat(${p||o}, ${f})`}}}}function vy(n,e){if(!e.styleableGrid)return;const{property:t,...o}=my(n,"display");if(!t)return;const s=t.getOption("grid"),i=o.sector;s||t.addOption({id:"grid",label:"Grid"}),i.addProperty(rp({label:"Columns",property:"grid-template-columns"}),{}),i.addProperty(rp({label:"Rows",property:"grid-template-rows"}),{}),i.addProperty({id:"grid-gap",requires:gr,...gy("gap",{x:{id:"grid-row-gap",label:"Row",property:"row-gap",min:0,default:"0"},y:{id:"grid-column-gap",label:"Column",property:"column-gap",min:0,default:"0"},mergable:!0})},{}),i.addProperty({type:"composite",property:"grid-area",label:"Grid area",requiresParent:gr,generic:!0,properties:[{label:"Row start",property:"grid-row-start",type:"integer",default:"auto"},{label:"Row end",property:"grid-row-end",type:"integer",default:"auto"},{label:"Column start",property:"grid-column-start",type:"integer",default:"auto"},{label:"Column end",property:"grid-column-end",type:"integer",default:"auto"}],fromStyle(r){const l=by(r);return{"grid-column-start":r["grid-column-start"]||l.columnStart,"grid-column-end":r["grid-column-end"]||l.columnEnd,"grid-row-start":r["grid-row-start"]||l.rowStart,"grid-row-end":r["grid-row-end"]||l.rowEnd}},toStyle(r,{name:l}){const a=r["grid-row-start"]||"auto",c=r["grid-row-end"]||"auto",d=r["grid-column-start"]||"auto",p=r["grid-column-end"]||"auto";return{[l]:`${a} / ${d} / ${c} / ${p}`}}},{})}const Sy=W(function(n,e={}){const t={itemResizable:!0,...e},{Canvas:o,Commands:s,Components:i}=n,{itemResizable:r}=t,l=o.events,a=s.events,c=i.events,d=`${a.runBeforeCommand}tlb-move`,p=`${a.runBeforeCommand}resize`;let u;uy(n);const h=({options:y})=>{mr(n,y.target,t)&&(n.runCommand(hr,{...y}),y.abort=!0)},f=y=>{const{options:v}=y;mr(n,v.component,t)&&(v.options=Object.assign(v.options||{},hy(n,v)))},m=()=>{const y=o.getSpots({type:ro}).pop();if(!y)return;let v=y.attributes.spotEl;v||(v=document.createElement("div"),v.className=lo,y.set({spotEl:v})),Object.entries(y.getStyle()).forEach(([w,S])=>v.style.setProperty(w,S)),u==null||u.appendChild(v)},g=({spot:y})=>{const v=y.attributes.spotEl;y.type!==ro||!v||u==null||u.removeChild(v)};if(r){const y=v=>{const w=xt(r)?r({component:v}):r;return typeof w=="boolean"?w:{tl:!1,tc:!1,tr:!1,cl:!1,cr:!1,bl:!1,bc:!1,br:!1,...w}};n.on(c.resizeInit,v=>{const{component:w}=v;if(mr(n,w,t)){const S=y(w);v.resizable=S}})}const b=[[d,h],[p,f],[l.spot,m],[l.spotRemove,g]];b.forEach(([y,v])=>{n.on(y,v)}),n.onReady(()=>{u=o.getSpotsEl(),iy(),vy(n,t)});const C=()=>{delete n.Commands.commands[hr],b.forEach(([y,v])=>{n.off(y,v)})};j({editor:n,licenseKey:t.licenseKey,plan:oy,pluginName:ur,cleanup:C})}),xy="canvasScreenshot",wy=F.startup;var lp=(n=>(n.screenshot="studioPlugin:screenshot",n))(lp||{});const Cy=async n=>await Np([{id:"html-to-image",src:n}]),ky=async(n,e={},t={})=>{const{cdnScript:o}=t;if(!window.htmlToImage){if(!o)return;await Cy(o)}return new Promise((s,i)=>{(async()=>{try{const{canvasWidth:l,canvasHeight:a,width:c,height:d,type:p,quality:u,addOptions:h}=e,f={pixelRatio:1,width:c,height:d,canvasWidth:l,canvasHeight:a},m=(h==null?void 0:h(f))||f,b=await window.htmlToImage.toCanvas(n,m);b.toBlob(C=>{C?s({file:C,canvas:b}):i(new Error("Failed to create file from canvas"))},p,u)}catch(l){i(l)}})()})},yr=lp.screenshot,Ey=W(function(n,e={}){const{Commands:t,Canvas:o,Storage:s}=n,i=s.events.afterStore,r={cdnScript:"https://cdnjs.cloudflare.com/ajax/libs/html-to-image/1.11.13/html-to-image.min.js",...e};t.add(yr,async(c,d,p)=>{const{el:u,...h}=p;return await ky(u,h,r)});const l=async()=>{var d;const c=o.getBody();if(!c)return n.log("Canvas element not found");try{const p=await n.runCommand(yr,{el:c,canvasWidth:400,canvasHeight:225,width:1200,height:675,type:"image/jpeg"});(d=r.screenshotOnSave)==null||d.call(r,{...p,editor:n})}catch(p){console.error("Screenshot error",p)}};r.screenshotOnSave&&n.on(i,l);const a=()=>{delete t.commands[yr],n.off(i,l)};j({editor:n,licenseKey:e.licenseKey,plan:wy,pluginName:xy,cleanup:a})});var Ue=(n=>(n.panelBlocks="panelBlocks",n.panelPagesLayers="panelPagesLayers",n.panelGlobalStyles="panelGlobalStyles",n.panelSidebarTabs="panelSidebarTabs",n.panelAssets="panelAssets",n.aiChatPanel="aiChatPanel",n.panelDataSources="panelDataSources",n))(Ue||{});const ap="sidebarButtonsTarget",bs=(n,e)=>{const{id:t,icon:o,label:s,tooltip:i,className:r,skipSelfClose:l,removeLayouts:a,layoutComponent:c,layoutCommand:d}=n,{pluginOpts:p,breakpointProps:u}=e,h=t;return{id:cp(t),type:"button",icon:o,tooltip:s||i,className:r,editorEvents:{[`${Nr.layoutToggleId}${h}`]:({fromEvent:f,setState:m,editor:g})=>{m({active:f.isOpen}),setTimeout(()=>g.refresh({tools:!0}),20)}},onClick:({editor:f,state:m})=>{var w;if(m.active&&l)return;const g=(d==null?void 0:d.placer)||{type:"static",layoutId:ap},b={...g,skipCleanup:g.type==="static"},C=a||Object.keys(Ue).filter(S=>S!==h);dp(f,{removeLayouts:C,layout:{placer:b}});const y={id:h,placer:g,header:(d==null?void 0:d.header)??{label:s,close:!l},layout:c,style:{width:280,height:"100%",borderRightWidth:1,...d==null?void 0:d.style}},v=((w=p==null?void 0:p.sidebarLayoutCommand)==null?void 0:w.call(p,{...u,layoutCommand:y,sidebarButtonProps:n}))||y;f.runCommand(_.layoutToggle,{...v})}}},cp=n=>`button__${n}`,dp=(n,e={})=>{(e.removeLayouts||Object.keys(Ue)).forEach(o=>n.runCommand(_.layoutRemove,{id:o,layout:e.layout}))},pp=n=>{const e=(n==null?void 0:n.breakpointTablet)??1024,t=(n==null?void 0:n.breakpointMobile)??768,o={},s=[{id:Ue.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:Ue.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:Ue.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:Ue.panelAssets,icon:'<svg viewBox="0 0 24 24"><path d="M22,16V4A2,2 0 0,0 20,2H8A2,2 0 0,0 6,4V16A2,2 0 0,0 8,18H20A2,2 0 0,0 22,16M11,12L13.03,14.71L16,11L20,16H8M2,6V20A2,2 0 0,0 4,22H18V20H4V6" /></svg>',label:"Assets",layoutComponent:{type:"panelAssets",content:{itemsPerRow:2,header:{addUrl:!1}},style:{padding:7},onSelect:({assetProps:h,editor:f})=>{var C;const m=f.getSelected(),g={type:"image",src:h.src};let b;if(m!=null&&m.is("image"))return m.set("src",h.src);m&&f.Components.canMove(m,g)?b=m.append(g)[0]:m||(b=(C=f.getWrapper())==null?void 0:C.append(g)[0]),b&&f.select(b,{scroll:!0})}}}],i=[...s,{id:Ue.panelSidebarTabs,layoutCommand:{header:!1},icon:'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 0 1-1.5-1.5A1.5 1.5 0 0 1 17.5 9a1.5 1.5 0 0 1 1.5 1.5 1.5 1.5 0 0 1-1.5 1.5m-3-4A1.5 1.5 0 0 1 13 6.5 1.5 1.5 0 0 1 14.5 5 1.5 1.5 0 0 1 16 6.5 1.5 1.5 0 0 1 14.5 8m-5 0A1.5 1.5 0 0 1 8 6.5 1.5 1.5 0 0 1 9.5 5 1.5 1.5 0 0 1 11 6.5 1.5 1.5 0 0 1 9.5 8m-3 4A1.5 1.5 0 0 1 5 10.5 1.5 1.5 0 0 1 6.5 9 1.5 1.5 0 0 1 8 10.5 1.5 1.5 0 0 1 6.5 12M12 3a9 9 0 0 0-9 9 9 9 0 0 0 9 9 1.5 1.5 0 0 0 1.5-1.5c0-.4-.2-.7-.4-1-.2-.3-.4-.6-.4-1a1.5 1.5 0 0 1 1.5-1.5H16a5 5 0 0 0 5-5c0-4.4-4-8-9-8Z"/></svg>',label:"Styles & Props",layoutComponent:{type:"panelSidebarTabs"}}],r={id:ap,type:"column",className:"gs-cmp-layout-sidebar-target",style:{overflow:"hidden"}},l={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},a={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}},c=h=>({breakpoint:h,breakpointTablet:e,breakpointMobile:t}),d=(h,f,m)=>{const g=c(f),b={pluginOpts:n,breakpointProps:g},C=h.map(v=>{const w=bs(v,b);return n!=null&&n.sidebarButton?n.sidebarButton({id:v.id,buttonIds:Ue,buttonProps:w,sidebarButtonProps:v,...g,createSidebarButton:S=>bs({...v,...S},b)}):w}).filter(Boolean);return(n!=null&&n.sidebarButtons?n==null?void 0:n.sidebarButtons({buttonIds:Ue,sidebarButtons:C,...g,createSidebarButton:v=>bs({...v,layoutCommand:{...m==null?void 0:m.layoutCommand,...v.layoutCommand}},b)}):C).filter(Boolean)},p=(h,f,m)=>{var C;const g=c(m),b={pluginOpts:n,breakpointProps:g};return((C=n==null?void 0:n.rootLayout)==null?void 0:C.call(n,{sidebarButtons:f,rootLayout:h,layoutSidebarLeft:l,layoutSidebarTarget:r,...g,createSidebarButton:y=>bs({...y},b)}))??h};if(e){const h=d(i,e);o[e]=p({type:"row",style:{height:"100%"},children:[{...l,children:h},r,a]},h,e)}if(t){const h={placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}},f=i.map(g=>({...g,layoutCommand:h})),m=d(f,t,{layoutCommand:h});o[t]=p({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas",grow:!0},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:m}]},m,t)}const u=d(s,0);return{default:p({type:"row",style:{height:"100%"},children:[{...l,children:u},r,a,{type:"sidebarRight"}]},u,0),responsive:o}},up="layoutSidebarButtons",Ty=F.free,hp=W(function(n,e={}){const{Commands:t}=n,o=t.events,s={...e};(()=>{if(n.runCommand(_.layoutConfigGet)||s.skipLayoutConfig===!0)return;const l=pp(s);n.runCommand(_.layoutConfigSet,{...l})})(),t.add(`${up}:toggleButton`,(r,l,a)=>{const c=document.getElementById(cp(a==null?void 0:a.id));c==null||c.click()}),n.on(`${o.runCommand}core:preview`,()=>{dp(n)}),j({editor:n,licenseKey:s.licenseKey,plan:Ty,pluginName:up,cleanup:()=>{n.runCommand(_.layoutConfigSet)}})});hp.createLayoutConfig=n=>pp(n);const jt="page-break";var Le=(n=>(n.A5="a5",n.A5Portrait="a5-portrait",n.A4="a4",n.A3="a3",n.B5="b5",n.B4="b4",n.letter="letter",n.legal="legal",n.ledger="ledger",n))(Le||{});function br(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 My=(n,e)=>{const{name:t,id:o,width:s,height:i,unit:r}=n,{fixedHeight:l}=e,a=`${s}${r}`,c=`${i}${r}`;return{id:o||t.toLowerCase().replace(/\s/g,"-"),name:`${t} (${a} x ${c})`,sizeH:i,sizeW:s,sizeUnit:r,widthMedia:"",width:a,minHeight:l?"0":`${br(i,r)}px`,height:l?c:void 0}},vr="page-breaks",vs="gjs-page-breaks-spot",Sr=n=>n.type===vr;function Ay(n){const{Devices:e}=n,{height:t,minHeight:o}=e.getSelected().attributes,i=parseFloat(`${t&&t!=="auto"?t:o}`),r=n.getWrapper(),l=r==null?void 0:r.getEl(),a=[];if(!r||!l)return a;const c=l.getBoundingClientRect().height,p=r.findType(jt).map(h=>h.getEl()).filter(Boolean).map(h=>({top:h.offsetTop,height:h.offsetHeight}));let u=0;for(;u<c;){const h=p.find(f=>f.top>u&&f.top<u+i);h?(u=h.top+h.height,a.push(h.top)):(u+=i,u<c&&a.push(u))}return a}function Py(n,e){const{Canvas:t}=n,o=t.events,s=n.events;let i;const r=()=>{As(`${go}preset-printable-spots`,`.${vs} {
|
|
951
951
|
position: absolute;
|
|
952
952
|
left: 0;
|
|
953
953
|
width: 100%;
|
|
@@ -965,7 +965,7 @@
|
|
|
965
965
|
right: 0;
|
|
966
966
|
transform: translate(100%, -50%);
|
|
967
967
|
}
|
|
968
|
-
`,{target:window.document.head})},l=()=>{if(e.enablePageBreaksSpot===!1)return;const g={id:vr,type:vr,component:n.getWrapper()};return t.getSpots(g).pop()||t.addSpot(g)},a=({spot:g})=>{const{spotEl:b}=g.attributes;!Sr(g)||!b||!i||i.removeChild(b)},c=({spot:g})=>{if(!Sr(g)||!i)return;let{spotEl:b}=g.attributes;b||(b=document.createElement("div"),b.className=`${vs}__items`,g.set({spotEl:b})),i.appendChild(b)},d=({spot:g})=>{const{spotEl:b,pageBreaks:C=[]}=g.attributes;!Sr(g)||!b||!i||(Object.entries(g.getStyle()).forEach(([y,v])=>b.style.setProperty(y,v)),b.innerHTML="",C.forEach((y,v)=>{const w=document.createElement("div");w.setAttribute("data-page-number",`${v+2}`),w.className=vs,w.style.top=`${y}px`,b.appendChild(w)}))},p=En(()=>{if(n.em.destroyed)return;const g=l();g&&g.set({pageBreaks:Ay(n),up:(g.attributes.up||0)+1})},150),u=En(p,200),h=()=>{i=t.getSpotsEl(),l()},f=()=>{const g=l();g&&g.set({up:(g.attributes.up||0)+1})},m=[["component:input",p],["frame:scroll",f],[s.update,p],[o.spotAdd,c],[o.spotUpdate,d],[o.spotRemove,a],[o.frameLoadBody,h]];return m.forEach(([g,b])=>n.on(g,b)),n.onReady(()=>{r(),new ResizeObserver(f).observe(t.getElement().parentElement)}),()=>{m.forEach(([g,b])=>n.off(g,b)),p.clear(),u.clear()}}var xr=(n=>(n.print="presetPrintable:print",n))(xr||{});const fp=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 Ny(n,e){const{Commands:t,Pages:o}=n;return t.add(xr.print,async(s,i,r={})=>{const l={page:r.allPages?void 0:o.getSelected(),styles:"inline",optionsHtml:{exporter:null}},c=(await t.run(
|
|
968
|
+
`,{target:window.document.head})},l=()=>{if(e.enablePageBreaksSpot===!1)return;const g={id:vr,type:vr,component:n.getWrapper()};return t.getSpots(g).pop()||t.addSpot(g)},a=({spot:g})=>{const{spotEl:b}=g.attributes;!Sr(g)||!b||!i||i.removeChild(b)},c=({spot:g})=>{if(!Sr(g)||!i)return;let{spotEl:b}=g.attributes;b||(b=document.createElement("div"),b.className=`${vs}__items`,g.set({spotEl:b})),i.appendChild(b)},d=({spot:g})=>{const{spotEl:b,pageBreaks:C=[]}=g.attributes;!Sr(g)||!b||!i||(Object.entries(g.getStyle()).forEach(([y,v])=>b.style.setProperty(y,v)),b.innerHTML="",C.forEach((y,v)=>{const w=document.createElement("div");w.setAttribute("data-page-number",`${v+2}`),w.className=vs,w.style.top=`${y}px`,b.appendChild(w)}))},p=En(()=>{if(n.em.destroyed)return;const g=l();g&&g.set({pageBreaks:Ay(n),up:(g.attributes.up||0)+1})},150),u=En(p,200),h=()=>{i=t.getSpotsEl(),l()},f=()=>{const g=l();g&&g.set({up:(g.attributes.up||0)+1})},m=[["component:input",p],["frame:scroll",f],[s.update,p],[o.spotAdd,c],[o.spotUpdate,d],[o.spotRemove,a],[o.frameLoadBody,h]];return m.forEach(([g,b])=>n.on(g,b)),n.onReady(()=>{r(),new ResizeObserver(f).observe(t.getElement().parentElement)}),()=>{m.forEach(([g,b])=>n.off(g,b)),p.clear(),u.clear()}}var xr=(n=>(n.print="presetPrintable:print",n))(xr||{});const fp=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 Ny(n,e){const{Commands:t,Pages:o}=n;return t.add(xr.print,async(s,i,r={})=>{const l={page:r.allPages?void 0:o.getSelected(),styles:"inline",optionsHtml:{exporter:null}},c=(await t.run(_.projectFiles,l)).filter(u=>u.filename.endsWith(".html")),d=c.map(u=>u.content).join('<div style="break-before: page;"></div>'),p=[];if(r.separatePrints)for(const u of c)p.push(await fp(u));else p.push(await fp({content:d,filename:"",mimeType:""}));for(const u of p){const h=u.contentWindow;h.focus(),h.print()}setTimeout(()=>p.forEach(u=>u.remove()),1e3)}),t.add("presetPrintable:exp",async s=>{await Ts("https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"),await Ts("https://cdn.jsdelivr.net/npm/jspdf@3.0.0/dist/jspdf.umd.min.js");const{Devices:i,Canvas:r}=s,{sizeW:l,sizeH:a,sizeUnit:c}=i.getSelected().attributes,d=r.getFrameEl().contentDocument,p="px",u=[br(l,c),br(a,c)],h=new window.jspdf.jsPDF({unit:p,format:u}),f=d.body;h.html(f,{callback:m=>m.save()})}),()=>{delete n.Commands.commands[xr.print]}}function Oy(n,e){const{blockPageBreak:t={}}=e,{Components:o,Blocks:s}=n,i="Page Break",r=`${ke}${jt}`;return o.addType(jt,{block:t&&{label:i,media:'<svg viewBox="0 0 24 24"><path d="M18 20H6v-2H4v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2h-2v2M14 2H6a2 2 0 0 0-2 2v8h2V4h8v4h4v4h2V8l-6-6m-3 14H8v-2h3v2m5 0h-3v-2h3v2M3 14h3v2H3v-2m18 2h-3v-2h3v2Z"/></svg>',category:"Extra",select:!0,...t},isComponent:$e(jt),model:{defaults:{name:i,classes:r,attributes:{[Pe]:jt},emptyState:!0,stylable:!1,droppable:!1,draggable:Ms("wrapper"),styles:`.${r} { break-before: page; }`,traits:[]}}}),()=>{o.removeType(jt),s.remove(jt)}}const Iy="presetPrintable",Ry=F.free,Dy=W(function(n,e={}){var S;const t={selectedDevice:Le.A4,...e},{Canvas:o,Devices:s,Blocks:i}=n,r=o.events,l=n.events,a=t.selectedDevice||s.getConfig().default,c=[{id:Le.A5,name:"A5",width:148,height:210,unit:"mm"},{id:Le.A5Portrait,name:"A5 Portrait",width:210,height:148,unit:"mm"},{id:Le.A4,name:"A4",width:210,height:297,unit:"mm"},{id:Le.A3,name:"A3",width:297,height:420,unit:"mm"},{id:Le.B5,name:"B5",width:176,height:250,unit:"mm"},{id:Le.B4,name:"B4",width:250,height:353,unit:"mm"},{id:Le.letter,name:"Letter",width:8.5,height:11,unit:"in"},{id:Le.legal,name:"Legal",width:8.5,height:14,unit:"in"},{id:Le.ledger,name:"Ledger",width:11,height:17,unit:"in"}],p=(((S=t.devices)==null?void 0:S.call(t,{items:c}))||c).map(x=>My(x,t));s.devices.reset(p);const u=a&&s.get(a)||s.getAll().at(0);s.select(u),["map","video"].forEach(x=>i.remove(x));const f=(x={})=>{const k="page-rule",{rules:E}=n.Css,{width:M,height:P,minHeight:N}=s.getSelected().attributes,I=P&&P!=="auto"?P:N,R=E.where({id:k}).pop(),G=R||E.add({id:k,selectors:[],selectorsAdd:"@page"},{at:0});(x.fromDeviceChange||!R)&&G.addStyle({size:`${M} ${I}`,...!R&&{margin:"0"}})},m=(x,k={})=>{const E=x.document,{minHeight:M}=s.getSelected().attributes,N=`
|
|
969
969
|
${!!parseFloat(`${M}`)?`
|
|
970
970
|
[data-gjs-type="wrapper"] { min-height: ${M}; }
|
|
971
971
|
`:`
|
|
@@ -978,7 +978,7 @@
|
|
|
978
978
|
height: 100dvh;
|
|
979
979
|
}
|
|
980
980
|
`}
|
|
981
|
-
`;As(`${go}preset-printable`,N,{doc:E,target:E.head}),f(k)};n.on(r.frameLoadBody,x=>{const k=x.window;if(m(k),t.fixedHeight){const M=x.model.getComponent().getEl();M==null||M.addEventListener("scroll",P=>{const N=P.target;N.scrollTop>0&&N.scrollTo(0,0)})}}),n.on(s.events.select,()=>{var k;const x=(k=o.getFrameEl().contentDocument)==null?void 0:k.defaultView;x&&m(x,{fromDeviceChange:!0})});const g=()=>{const k=n.Css.getRules().filter(E=>E.selectorsToString()==="body").pop();k==null||k.addStyle({"margin-top":"","margin-right":"","margin-bottom":"","margin-left":"",margin:"0"})},b=[[l.projectLoad,g]];b.forEach(([x,k])=>n.on(x,k));const C=Py(n,t),y=Ny(n),v=Oy(n,t);n.onReady(()=>{n.UndoManager.clear()});const w=()=>{b.forEach(([x,k])=>n.off(x,k)),C(),y(),v()};n.on(l.destroy,w),
|
|
981
|
+
`;As(`${go}preset-printable`,N,{doc:E,target:E.head}),f(k)};n.on(r.frameLoadBody,x=>{const k=x.window;if(m(k),t.fixedHeight){const M=x.model.getComponent().getEl();M==null||M.addEventListener("scroll",P=>{const N=P.target;N.scrollTop>0&&N.scrollTo(0,0)})}}),n.on(s.events.select,()=>{var k;const x=(k=o.getFrameEl().contentDocument)==null?void 0:k.defaultView;x&&m(x,{fromDeviceChange:!0})});const g=()=>{const k=n.Css.getRules().filter(E=>E.selectorsToString()==="body").pop();k==null||k.addStyle({"margin-top":"","margin-right":"","margin-bottom":"","margin-left":"",margin:"0"})},b=[[l.projectLoad,g]];b.forEach(([x,k])=>n.on(x,k));const C=Py(n,t),y=Ny(n),v=Oy(n,t);n.onReady(()=>{n.UndoManager.clear()});const w=()=>{b.forEach(([x,k])=>n.off(x,k)),C(),y(),v()};n.on(l.destroy,w),j({editor:n,licenseKey:t.licenseKey,plan:Ry,pluginName:Iy,cleanup:w})}),Ly=n=>{const e=n;return e.logicalOperator==="and"||e.logicalOperator==="or"},mp=(n,e)=>(n.config.optsHtml={...n.config.optsHtml,exporter:e},()=>{n.config.optsHtml.exporter=void 0}),gp=(n,e)=>{const t=s=>{const{input:i}=s,{contains:r}=e;(!r||i.includes(r))&&(s.input=e.importer.import(i))},o=n.Parser.events.htmlBefore;return n.on(o,t),()=>{n.off(o,t)}};class $y{getVariableSyntax({dataResolver:e}){const{defaultValue:t}=e,o=this.getFullPath(e),s=t?` || \`${t}\``:"";return`<%= ${o}${s} %>`}getCollectionStartSyntax({dataResolver:e}){const{collectionId:t,dataSource:o,startIndex:s,endIndex:i}=e,r=(o==null?void 0:o.path)||t||"",l=this._sanitizeVariableName(t);let a="";if(s!==void 0||i!==void 0){const c=s??0,d=i!==void 0?i:"";a=`.slice(${c}${d!==""?`, ${d}`:""})`}return`<% ${r}${a}.forEach(function(currentItem, index, arr) {
|
|
982
982
|
const startIndex = parseInt(${s??0}, 10);
|
|
983
983
|
const endIndex = startIndex + arr.length;
|
|
984
984
|
const ${l}={ currentItem, currentIndex: startIndex + index, remainingItems: endIndex - (startIndex + index)} %>`}_sanitizeVariableName(e){return e.replace(/[^a-zA-Z0-9_$]/g,"_")}getCollectionEndSyntax(){return"<% }) %>"}getConditionalStartSyntax({dataResolver:e}){return`<% if (${this._parseCondition(e.condition)}) { %>`}getConditionElseSyntax(){return"<% } else { %>"}getConditionalEndSyntax(){return"<% } %>"}getFullPath({collectionId:e,path:t,variableType:o}){return(e?[this._sanitizeVariableName(e),o,t].filter(Boolean).join("."):t)||""}_parseCondition(e){if(!e)return"";if(Ly(e)){const t=e.statements.map(i=>this._parseCondition(i)),o=zy[e.logicalOperator];let s=t.length>1?`(${t.join(`)${o}(`)})`:t[0];return e.logicalOperator==="xor"&&(s=`!!(${s})`),s}else{const t=this._parseValue(e.left),o=this._parseValue(e.right);switch(e.operator){case"equals":return`${t} === ${o}`;case">":case"<":case">=":case"<=":case"=":case"!=":return`${t} ${e.operator} ${o}`;case"contains":return`${t}?.includes(${o})`;case"startsWith":return`${t}?.startsWith(${o})`;case"endsWith":return`${t}?.endsWith(${o})`;case"equalsIgnoreCase":return`${t}?.toLowerCase() === ${o}?.toLowerCase()`;case"trimEquals":return`${t}?.trim() === ${o}?.trim()`;case"isTruthy":return`!!${t}`;case"isFalsy":return`!${t}`;case"isDefined":return`${t} !== undefined`;case"isNull":return`${t} === null`;case"isUndefined":return`${t} === undefined`;case"isArray":return`Array.isArray(${t})`;case"isObject":return`typeof ${t} === 'object' && ${t} !== null && !Array.isArray(${t})`;case"isString":return`typeof ${t} === 'string'`;case"isNumber":return`typeof ${t} === 'number' && !isNaN(${t})`;case"isBoolean":return`typeof ${t} === 'boolean'`;default:return`${t} ${e.operator} ${o}`}}}_parseValue(e){return typeof e=="object"?this.getFullPath(e):typeof e=="string"?`'${e.replace(/'/g,"\\'")}'`:String(e)}}const zy={and:"&&",or:"||",xor:"^"},By=["===","==","!==","!=","<=",">=","<",">","&&","||"],Vy={"===":"=","==":"=","!==":"!=","!=":"!=","<=":"<=",">=":">=","<":"<",">":">","&&":"&&","||":"||"};class Hy{constructor(){this.messages=[],this.collectionStack=[]}import(e){this.messages=[],this.collectionStack=[];try{const t=this.parseEjsTemplate(e);return this.astToGrapesJS(t)}catch(t){return console.error("Error during import:",t),this.addMessage("error",`Error during import: ${t instanceof Error?t.message:String(t)}`),""}}parseEjsTemplate(e){const t=[];let o=0;for(;o<e.length;){const s=e.indexOf("<%",o);if(s===-1){o<e.length&&t.push(this.createAppendLiteral(e.slice(o)));break}s>o&&t.push(this.createAppendLiteral(e.slice(o,s)));const i=e.indexOf("%>",s);if(i===-1)throw new Error("Unclosed EJS tag");const r=e.slice(s+2,i).trim();if(o=i+2,r.startsWith("=")||r.startsWith("-")){const l=r.slice(1).trim();t.push(this.createAppendExpression(l))}else{if(r.startsWith("#"))continue;if(r.startsWith("if")){const l=this.parseIfStatement(r,e,o);t.push(l),o=l.endPos||o}else if(r.startsWith("for")){const l=this.parseForStatement(r,e,o);t.push(l),o=l.endPos||o}else{const l=r.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);if(l){const a=l[1],c=l[2],d=this.parseForEachStatement(a,c,e,o);t.push(d),o=d.endPos||o}else this.addMessage("info",`Unsupported scriptlet content: ${r}`)}}}return{type:"Program",body:t}}createAppendLiteral(e){return{type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"Identifier",name:"__append"},arguments:[{type:"Literal",value:e}]}}}createAppendExpression(e){return{type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"Identifier",name:"__append"},arguments:[this.parseJsExpression(e)]}}}parseIfStatement(e,t,o){const s=e.match(/if\s*\((.*)\)\s*\{?/);if(!s)throw new Error("Invalid if statement syntax");const i=this.parseJsExpression(s[1]),{body:r,endPos:l}=this.parseTemplateBlock(t,o);let a=null,c=l;const d=t.indexOf("<%",c);if(d===c){const p=t.indexOf("%>",d);if(p!==-1){const u=t.slice(d+2,p).trim(),h=p+2-d;if(u.startsWith("} else if")){c=d+h;const f=u.substring(u.indexOf("if")).trim(),m=this.parseIfStatement(f,t,c);a={type:"IfStatement",test:m.test,consequent:m.consequent,alternate:m.alternate},c=m.endPos}else if(u.startsWith("} else")){c=d+h;const{body:f,endPos:m}=this.parseTemplateBlock(t,c);a={type:"BlockStatement",body:f},c=m;const g=t.indexOf("<%",c),b=t.indexOf("%>",g);g===c&&t.slice(g+2,b).trim()==="}"&&(c=b+2)}else u==="}"&&(c=d+h)}}return{type:"IfStatement",test:i,consequent:{type:"BlockStatement",body:r},alternate:a,endPos:c}}parseForStatement(e,t,o){const s=e.match(/for\s*\((.*)\)\s*\{?/);if(!s)throw new Error("Invalid for statement syntax");const i=s[1].split("of");if(i.length!==2)throw new Error("Only for...of loops are supported");const r=i[0].trim().replace(/^let\s+|^const\s+|^var\s+/,""),l=i[1].trim(),{body:a,endPos:c}=this.parseTemplateBlock(t,o);return{type:"ForStatement",init:{type:"VariableDeclaration",kind:"let",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:r},init:this.parseJsExpression(l)}]},test:null,update:null,body:{type:"BlockStatement",body:a},endPos:(()=>{const d=t.indexOf("<%",c),p=t.indexOf("%>",d);return d===c&&t.slice(d+2,p).trim()==="}"?p+2:c})()}}parseForEachStatement(e,t,o,s){const{body:i,endPos:r}=this.parseTemplateBlock(o,s);return{type:"ForEachStatement",collection:this.parseJsExpression(e),itemIdentifier:{type:"Identifier",name:t},body:{type:"BlockStatement",body:i},endPos:(()=>{const l=o.indexOf("<%",r),a=o.indexOf("%>",l);return l===r&&o.slice(l+2,a).trim()==="}"?a+2:r})()}}parseTemplateBlock(e,t){const o=[];let s=t;for(;s<e.length;){const i=e.indexOf("<%",s);if(i===-1){s<e.length&&o.push(this.createAppendLiteral(e.slice(s))),s=e.length;break}i>s&&o.push(this.createAppendLiteral(e.slice(s,i)));const r=e.indexOf("%>",i);if(r===-1)throw new Error("Unclosed EJS tag within block");const l=e.slice(i+2,r).trim();if(l==="}"||l.startsWith("} else")){s=i;break}if(s=r+2,l.startsWith("=")||l.startsWith("-")){const a=l.slice(1).trim();o.push(this.createAppendExpression(a))}else{if(l.startsWith("#"))continue;if(l.startsWith("if")){const a=this.parseIfStatement(l,e,s);o.push(a),s=a.endPos||s}else if(l.startsWith("for")){const a=this.parseForStatement(l,e,s);o.push(a),s=a.endPos||s}else{const a=l.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);if(a){const c=a[1],d=a[2],p=this.parseForEachStatement(c,d,e,s);o.push(p),s=p.endPos||s}else this.addMessage("info",`Unsupported scriptlet content within block: ${l}`)}}}return{body:o,endPos:s}}parseJsExpression(e){if(/^(['"]).*\1$/.test(e))return{type:"Literal",value:e.slice(1,-1)};if(/^-?\d+$/.test(e))return{type:"Literal",value:parseInt(e,10)};if(/^-?\d+\.\d+$/.test(e))return{type:"Literal",value:parseFloat(e)};if(e==="true"||e==="false")return{type:"Literal",value:e==="true"};for(const s of By){const i=e.lastIndexOf(s);if(i>0&&e[i-1]!=="!"&&e[i-1]!=="="&&e[i-1]!=="<"&&e[i-1]!==">")return{type:s==="&&"||s==="||"?"LogicalExpression":"BinaryExpression",operator:Vy[s],left:this.parseJsExpression(e.slice(0,i).trim()),right:this.parseJsExpression(e.slice(i+s.length).trim())}}const t=e.indexOf("."),o=e.indexOf("[");if(t>0&&(o===-1||t<o)||o>0&&(t===-1||o<t)){const s=t>0&&(o===-1||t<o)?t:o;let i,r,l=!1;if(s===t)i=e.slice(0,t),r={type:"Identifier",name:e.slice(t+1)},l=!1;else{i=e.slice(0,o);const a=e.indexOf("]",o);if(a===-1)throw new Error("Unclosed bracket in expression");const c=e.slice(o+1,a);r=/^(['"]).*\1$/.test(c)||/^-?\d+(\.\d+)?$/.test(c)?this.parseJsExpression(c):{type:"Identifier",name:c},l=!0}return{type:"MemberExpression",object:this.parseJsExpression(i),property:r,computed:l}}return{type:"Identifier",name:e}}astToGrapesJS(e){switch(e.type){case"Program":return this.handleProgram(e);case"VariableDeclaration":return this.handleVariableDeclaration(e);case"ExpressionStatement":return this.handleExpressionStatement(e);case"IfStatement":return this.handleIfStatement(e);case"ForStatement":return this.handleForStatement(e);case"ForEachStatement":return this.handleForEachStatement(e);case"BlockStatement":return this.handleBlockStatement(e);case"Literal":return this.handleLiteral(e);case"Identifier":return this.handleIdentifier(e);case"MemberExpression":return this.handleMemberExpression(e);case"BinaryExpression":return this.handleBinaryExpression(e);case"LogicalExpression":return this.handleLogicalExpression(e);case"CallExpression":return this.handleCallExpression(e);default:return this.addMessage("warning",`Unsupported node type: ${e.type}`),""}}handleProgram(e){let t="";for(const o of e.body)t+=this.astToGrapesJS(o);return t}handleVariableDeclaration(e){return""}handleExpressionStatement(e){return e.expression.type==="CallExpression"&&e.expression.callee.type==="Identifier"&&e.expression.callee.name==="__append"&&e.expression.arguments.length>0?this.astToGrapesJS(e.expression.arguments[0]):""}handleIfStatement(e){const t=this.getConditionExpression(e.test),o=this.astToGrapesJS(e.consequent);let s="";return e.alternate&&(s=this.astToGrapesJS(e.alternate)),`
|
|
@@ -998,7 +998,7 @@ const ${l}={ currentItem, currentIndex: startIndex + index, remainingItems: endI
|
|
|
998
998
|
${i}
|
|
999
999
|
</data-collection-item>
|
|
1000
1000
|
</data-collection>
|
|
1001
|
-
`}handleBlockStatement(e){let t="";for(const o of e.body)t+=this.astToGrapesJS(o);return t}handleLiteral(e){return String(e.value??"")}handleIdentifier(e){let t={path:e.name};if(this.collectionStack.length>0){const o=this.collectionStack[this.collectionStack.length-1];e.name===o&&(t={collectionId:o,variableType:"currentItem"})}return`<data-variable data-gjs-data-resolver='${JSON.stringify(t)}'></data-variable>`}handleMemberExpression(e,t={}){let s={path:this.getExpressionString(e),...t};if(this.collectionStack.length>0){const i=this.collectionStack[this.collectionStack.length-1];let r=e;const l=[];for(;r.type==="MemberExpression";)r.property.type==="Identifier"&&!r.computed?l.unshift(r.property.name):r.property.type==="Literal"&&r.computed?l.unshift(String(r.property.value)):l.unshift(this.getExpressionString(r.property)),r=r.object;if(r.type==="Identifier"&&r.name===i){const a=l.join(".");s={...t,collectionId:i,variableType:"currentItem",path:a}}}return`<data-variable data-gjs-data-resolver='${JSON.stringify(s)}'></data-variable>`}handleBinaryExpression(e){return`${this.getExpressionString(e.left)} ${e.operator} ${this.getExpressionString(e.right)}`}handleLogicalExpression(e){return e.operator==="||"&&e.right.type==="Literal"?this.handleMemberExpression(e.left,{defaultValue:e.right.value}):`${this.getExpressionString(e.left)} ${e.operator} ${this.getExpressionString(e.right)}`}handleCallExpression(e){var t;if(e.callee.type==="Identifier"&&e.callee.name==="include"){const o=((t=e.arguments[0])==null?void 0:t.type)==="Literal"?String(e.arguments[0].value):"";return this.addMessage("info",`Partial includes are not fully supported: ${o}`),""}return""}getConditionExpression(e){if(e.type==="Identifier")return{logicalOperator:"and",statements:[{left:{type:"data-variable",path:e.name},operator:"isTruthy"}]};if(e.type==="MemberExpression"){let t=this.getExpressionString(e),o="isTruthy";return t.startsWith("!!")?(o="isTruthy",t=t.slice(2)):t.startsWith("!")&&(o="isFalsy",t=t.slice(1)),{logicalOperator:"and",statements:[{left:{type:"data-variable",path:t},operator:o}]}}if(e.type==="BinaryExpression"||e.type==="LogicalExpression"){const t=this.getConditionExpression(e.left),o=this.getConditionExpression(e.right);return`${t} ${e.operator} ${o}`}return e.type==="Literal"?typeof e.value=="string"?`'${e.value}'`:String(e.value??""):this.getExpressionString(e)}getExpressionString(e){switch(e.type){case"Identifier":return e.name;case"Literal":return String(e.value??"");case"MemberExpression":{const t=this.getExpressionString(e.object),o=this.getExpressionString(e.property);return e.computed?`${t}[${o}]`:`${t}.${o}`}case"BinaryExpression":{const t=this.getExpressionString(e.left),o=this.getExpressionString(e.right);return`${t} ${e.operator} ${o}`}case"LogicalExpression":{const t=this.getExpressionString(e.left),o=this.getExpressionString(e.right);return`${t} ${e.operator} ${o}`}default:return this.addMessage("warning",`Unsupported expression type for getExpressionString: ${e.type}`),""}}addMessage(e,t){this.messages.push({type:e,message:t})}}const Fy="dataSourceEjs",_y=F.startup,Gy=
|
|
1001
|
+
`}handleBlockStatement(e){let t="";for(const o of e.body)t+=this.astToGrapesJS(o);return t}handleLiteral(e){return String(e.value??"")}handleIdentifier(e){let t={path:e.name};if(this.collectionStack.length>0){const o=this.collectionStack[this.collectionStack.length-1];e.name===o&&(t={collectionId:o,variableType:"currentItem"})}return`<data-variable data-gjs-data-resolver='${JSON.stringify(t)}'></data-variable>`}handleMemberExpression(e,t={}){let s={path:this.getExpressionString(e),...t};if(this.collectionStack.length>0){const i=this.collectionStack[this.collectionStack.length-1];let r=e;const l=[];for(;r.type==="MemberExpression";)r.property.type==="Identifier"&&!r.computed?l.unshift(r.property.name):r.property.type==="Literal"&&r.computed?l.unshift(String(r.property.value)):l.unshift(this.getExpressionString(r.property)),r=r.object;if(r.type==="Identifier"&&r.name===i){const a=l.join(".");s={...t,collectionId:i,variableType:"currentItem",path:a}}}return`<data-variable data-gjs-data-resolver='${JSON.stringify(s)}'></data-variable>`}handleBinaryExpression(e){return`${this.getExpressionString(e.left)} ${e.operator} ${this.getExpressionString(e.right)}`}handleLogicalExpression(e){return e.operator==="||"&&e.right.type==="Literal"?this.handleMemberExpression(e.left,{defaultValue:e.right.value}):`${this.getExpressionString(e.left)} ${e.operator} ${this.getExpressionString(e.right)}`}handleCallExpression(e){var t;if(e.callee.type==="Identifier"&&e.callee.name==="include"){const o=((t=e.arguments[0])==null?void 0:t.type)==="Literal"?String(e.arguments[0].value):"";return this.addMessage("info",`Partial includes are not fully supported: ${o}`),""}return""}getConditionExpression(e){if(e.type==="Identifier")return{logicalOperator:"and",statements:[{left:{type:"data-variable",path:e.name},operator:"isTruthy"}]};if(e.type==="MemberExpression"){let t=this.getExpressionString(e),o="isTruthy";return t.startsWith("!!")?(o="isTruthy",t=t.slice(2)):t.startsWith("!")&&(o="isFalsy",t=t.slice(1)),{logicalOperator:"and",statements:[{left:{type:"data-variable",path:t},operator:o}]}}if(e.type==="BinaryExpression"||e.type==="LogicalExpression"){const t=this.getConditionExpression(e.left),o=this.getConditionExpression(e.right);return`${t} ${e.operator} ${o}`}return e.type==="Literal"?typeof e.value=="string"?`'${e.value}'`:String(e.value??""):this.getExpressionString(e)}getExpressionString(e){switch(e.type){case"Identifier":return e.name;case"Literal":return String(e.value??"");case"MemberExpression":{const t=this.getExpressionString(e.object),o=this.getExpressionString(e.property);return e.computed?`${t}[${o}]`:`${t}.${o}`}case"BinaryExpression":{const t=this.getExpressionString(e.left),o=this.getExpressionString(e.right);return`${t} ${e.operator} ${o}`}case"LogicalExpression":{const t=this.getExpressionString(e.left),o=this.getExpressionString(e.right);return`${t} ${e.operator} ${o}`}default:return this.addMessage("warning",`Unsupported expression type for getExpressionString: ${e.type}`),""}}addMessage(e,t){this.messages.push({type:e,message:t})}}const Fy="dataSourceEjs",_y=F.startup,Gy=W(function(n,e={}){const t=mp(n,new $y),o=gp(n,{contains:"<%",importer:new Hy});j({editor:n,licenseKey:e.licenseKey,plan:_y,pluginName:Fy,cleanup:()=>{t(),o()}})}),yp={equals:"equals",isTruthy:"isTruthy",isFalsy:"isFalsy",isDefined:"isDefined",isNull:"isNull",isUndefined:"isUndefined",isArray:"isArray",isObject:"isObject",isString:"isString",isNumber:"isNumber",isBoolean:"isBoolean",isDefaultValue:"isDefaultValue"},Wy={...yp,...{">":"numGt","<":"numLt",">=":"numGte","<=":"numLte","=":"numEq","!=":"numNeq"},...{contains:"strContains",startsWith:"strStartsWith",endsWith:"strEndsWith",equalsIgnoreCase:"strEqualsIgnoreCase",trimEquals:"strTrimEquals"}};class jy{getHelperId(e){return Wy[e]||e}getFullPath({collectionId:e,path:t}){let o=t;return e&&(o=[this._sanitizeVariableName(e),t].filter(Boolean).join(".")),o||""}getVariableSyntax({dataResolver:e}){const{defaultValue:t}=e,o=this.getFullPath(e);return t?`{{#if ${o}}}{{{${o}}}}{{else}}${t}{{/if}}`:`{{{${o}}}}`}getCollectionStartSyntax({dataResolver:e}){const{collectionId:t,dataSource:o}=e,s=o==null?void 0:o.path;let i="";if(e.startIndex!==void 0||e.endIndex!==void 0){const c=e.startIndex??0,d=e.endIndex!==void 0?e.endIndex:"";d!==""?i=` (slice ${s} ${c} ${d})`:i=` (slice ${s} ${c})`}const l=` as |${this._sanitizeVariableName(t)}|`;return`{{#each ${i||s}${l}}}`}getCollectionEndSyntax(){return"{{/each}}"}getConditionalStartSyntax({dataResolver:e}){const t=e.condition;if(!t)return"";const o=t,s=t;if(s.statements&&s.logicalOperator==="and"||s.logicalOperator==="or"){const{statements:i}=s,r=s.logicalOperator,l=i.map(c=>this._parseCondition(c)).join(" ");return`{{#if ${i.length>1?`(${r} ${l})`:l}}}`}else return`{{#if ${this._parseCondition(o)}}}`}_parseCondition(e){if(!e)return"";const t=e,o=e;if(o.statements&&o.logicalOperator==="and"||o.logicalOperator==="or"){const{statements:s}=o,i=o.logicalOperator,r=o.statements.map(l=>this._parseCondition(l)).join(" ");return s.length>1?`(${i} ${r})`:r}else{const s=t.operator,i=this.getHelperId(s),r=this._parseValue(t.left),l=this._parseValue(t.right);return this.getExpressionStr(i,r,l)}}getExpressionStr(e,t,o){return yp[e]?e==="isTruthy"?t:e==="isFalsy"?`!${t}`:`${e} ${t}`:`(${e} ${t} ${o})`}_parseValue(e){return typeof e=="object"?this.getFullPath(e):typeof e=="string"?`'${e.replace(/'/g,"\\'")}'`:String(e)}_sanitizeVariableName(e){return e.replace(/[^a-zA-Z0-9_$]/g,"_")}getConditionElseSyntax(){return"{{else}}"}getConditionalEndSyntax(){return"{{/if}}"}}class qy{constructor(){this.messages=[],this.collectionStack=[]}import(e){this.messages=[],this.collectionStack=[];const t=this.parse(e);return this.astToGrapesJS(t)}parse(e){try{return kn.parse(e)}catch(t){if(t instanceof Error&&t.message.includes("Parse error")){const o=t.message.match(/line (\d+)/),s=o?parseInt(o[1]):0,i=t.message.match(/column (\d+)/),r=i?parseInt(i[1]):0;throw new Error(`Handlebars syntax error at line ${s}, column ${r}: ${t.message}`)}throw t}}astToGrapesJS(e){switch(e.type){case"Program":return this.handleProgram(e);case"ContentStatement":return this.handleContentStatement(e);case"MustacheStatement":return this.handleMustacheStatement(e);case"BlockStatement":return this.handleBlockStatement(e);case"PartialStatement":return this.handlePartialStatement(e);case"CommentStatement":return this.handleCommentStatement(e);case"ElementNode":return this.handleElementNode(e);case"TextNode":return this.handleTextNode(e);default:return this.addMessage("warning",`Unsupported node type: ${e.type}`,e.loc),""}}handleProgram(e){let t="";if(e.body)for(const o of e.body)t+=this.astToGrapesJS(o);return t}handleContentStatement(e){return e.value||""}handleMustacheStatement(e,t={}){const o=this.getExpressionString(e.path),s={...t};return this.collectionStack.length>0?this.processPathWithCollectionContext(o,s):s.path=o,`<data-variable data-gjs-data-resolver='${JSON.stringify(s)}'></data-variable>`}processPathWithCollectionContext(e,t){e.startsWith("@")?this.handleDirectCollectionReference(e,t):this.handleRelativePathReference(e,t)}handleDirectCollectionReference(e,t){if(this.isSpecialIterationVariable(e)){this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length-1],e,t);return}const[o,...s]=e.substring(1).split("/"),i=s.join(".");this.collectionStack.includes(o)?this.setCurrentItemResolver(o,i,t):this.handleParentReferenceFallback(e,t)}isSpecialIterationVariable(e){return["index","@index","key","@key"].includes(e)}setSpecialVariableResolver(e,t,o){o.collectionId=e;const s={index:"currentIndex","@index":"currentIndex",key:"currentKey","@key":"currentKey"};o.variableType=s[t]}setCurrentItemResolver(e,t,o){o.collectionId=e,o.variableType="currentItem",t&&(o.path=t)}handleRelativePathReference(e,t){const o=wr(e),{parentLevel:s,remainingPathParts:i}=this.calculateParentLevel(o),r=i.join("."),l=this.collectionStack.length-1-s;l>=0&&l<this.collectionStack.length?this.resolveRelativePath(r,l,t):t.path=i.join(".")}calculateParentLevel(e){const t=this.collectionStack.findLastIndex(i=>i===e[0]);if(t!==-1)return{parentLevel:this.collectionStack.length-1-t,remainingPathParts:e.slice(1)};let o=0;const s=[...e];for(;s[0]==="..";)o++,s.shift();return{parentLevel:o,remainingPathParts:s}}resolveRelativePath(e,t,o){const s=this.collectionStack[t];o.collectionId=s,o.variableType="currentItem",e!=="this"&&(o.path=e.startsWith("this.")?e.split(".").slice(1).join("."):e)}handleParentReferenceFallback(e,t){const o=wr(e),{parentLevel:s,remainingPathParts:i}=this.calculateParentLevel(o),r=i.join("."),l=this.collectionStack.length-1-s;l>=0&&l<this.collectionStack.length?this.resolveRelativePath(r,l,t):t.path=i.join(".")}handleBlockStatement(e){const t=e.path.original;switch(t){case"if":case"unless":return this.handleConditionalBlock(e,t);case"each":return this.handleEachBlock(e);default:return this.addMessage("warning",`Unsupported block helper: ${t}`,e.loc),this.handleGenericBlock(e)}}handleConditionalBlock(e,t){const i={logicalOperator:"and",statements:[{left:{type:"data-variable",path:this.getExpressionString(e.params[0])},operator:t==="unless"?"isFalsy":"isTruthy"}]},r=this.handleProgram(e.program),l=e.inverse?this.handleProgram(e.inverse):"";return`
|
|
1002
1002
|
<data-condition data-gjs-data-resolver='${JSON.stringify({condition:i})}'>
|
|
1003
1003
|
<data-condition-true-content>${r}</data-condition-true-content>
|
|
1004
1004
|
<data-condition-false-content>${l}</data-condition-false-content>
|
|
@@ -1007,4 +1007,4 @@ const ${l}={ currentItem, currentIndex: startIndex + index, remainingItems: endI
|
|
|
1007
1007
|
<data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:t},collectionId:o})}'>
|
|
1008
1008
|
<data-collection-item>${s}</data-collection-item>
|
|
1009
1009
|
</data-collection>
|
|
1010
|
-
`}handleCommentStatement(e){return`<!--${e.value}-->`}handleElementNode(e){let t="";if(e.attributes)for(const 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 wr=n=>{if(n==null||n==="")return[];if(n===".")return["this"];if(n===".."||n==="../")return[".."];if(n.startsWith("../")){const r=n.substring(3);return["..",...wr(r)]}const e=[];let t=0,o=n.replace(/\[(?:(['"])(.*?)\1|([^\]]*))\]/g,(r,l,a,c)=>{const d=a!==void 0?a:c||"";return e[t]=d,`__HANDLEBARS_PLACEHOLDER_${t++}__`});o=o.replace(/\//g,".");const s=o.split("."),i=[];for(const r of s){const l=/^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(r);if(l){const a=parseInt(l[1],10);i.push(e[a])}else r!==""&&i.push(r)}return i},Uy="dataSourceHandlebars",Ky=F.startup,Jy=G(function(n,e={}){const t=mp(n,new jy),o=gp(n,{contains:"{{",importer:new qy});W({editor:n,licenseKey:e.licenseKey,plan:Ky,pluginName:Uy,cleanup:()=>{t(),o()}})}),Zy=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)},bp="youtube-video",Yy=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:o="high"}=n,s=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=Zy(l);return`${c}?${d}`},i=l=>{var a,c,d;return((a=l[o])==null?void 0:a.url)||((c=l.high)==null?void 0:c.url)||((d=l.medium)==null?void 0:d.url)||l.default.url},r=l=>{const a=i(l.snippet.thumbnails);return{id:l.id.videoId,src:`https://www.youtube.com/watch?v=${l.id.videoId}`,name:l.snippet.title,type:bp,customData:{thumbnailUrl:a,videoItem:l}}};return{id:"youtube",types:[bp],label:({editor:l})=>l.I18n.t("youtubeAssetProvider.providerLabel"),search:{reloadOnInput:!0,debounceMs:1e3},async onLoad({searchValue:l,pageCustomData:a}){var m;const c={maxResults:25,q:l,pageToken:a==null?void 0:a.token,type:["video"],key:e},d=t==null?void 0:t({searchValue:l}),p={...c,...d};p.part?p.part.includes("snippet")||p.part.push("snippet"):p.part=["snippet"];const h=await(await fetch(s(p))).json();return(m=h.items)!=null&&m.length?{items:h.items.map(r),nextPageCustomData:{token:h.nextPageToken},isLastPage:!h.nextPageToken}:{items:[],isLastPage:!0}},itemLayout:({assetProps:l,onSelect:a})=>({type:"column",onClick:()=>a(l),htmlAttrs:{title:l.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"custom",render:()=>{var c;return`<img src="${(c=l.customData)==null?void 0:c.thumbnailUrl}" alt="${l.name}" style="width: 100%; height: 100px; object-fit: cover">`}},{type:"text",content:l.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingLeft:8,paddingRight:8}}]})}},Xy={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},Qy="youtubeAssetProvider",eb=F.startup,tb=G(function(n,e){var c;const{skipVideoComponent:t,i18n:o={}}=e,s=Yy(e);n.runCommand(j.assetProviderAdd,{provider:s});const i="search-on-youtube",r="video",l=(c=n.Components.getType(r))==null?void 0:c.model.prototype,a=d=>{n.Assets.open({modalTitle:n.I18n.t("youtubeAssetProvider.modalTitle"),providerId:s.id,typeId:s.types[0],providers:[],types:[],select:p=>{n.Assets.close(),d.set({videoId:p.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})};!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){const[d,...p]=l.getYoutubeTraits.apply(this);return[d,{id:i,type:"button",label:n.I18n.t("youtubeAssetProvider.searchBtn"),command:()=>a(this)},...p]}},view:{events:()=>({dblclick:"onActive"}),onActive(){const{model:d}=this,p=d.get("provider")||"";p!=null&&p.startsWith("yt")&&a(d)}}}),n.I18n.addMessages({en:Xy,...o}),W({editor:n,licenseKey:e.licenseKey,plan:eb,pluginName:Qy,cleanup:()=>{n.runCommand(j.assetProviderRemove,{id:s.id}),!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){return l.getYoutubeTraits.apply(this).filter(d=>d.id!==i)}}})}})}),ao=n=>n.replaceAll('"',"").replaceAll("'",""),Cr=n=>n.includes(",")?n:/\s/.test(n)?`'${ao(n)}'`:ao(n),vp=(n,e,t)=>({family:n,variant:e,...t}),Sp=(n,e)=>{n=Cr(n);const{menuVariant:t,variants:o}=e;return{family:n,familyLabel:ao(n),menuVariant:t&&vp(Cr(`menuFont-${ao(n)}`),"regular",t),variants:Object.assign({},...Object.entries(o).map(([s,i])=>({[s]:vp(n,s,i)})))}},xp=(n,e)=>{var l;const t=Sp(n.family,n),o=t.menuVariant??((l=Object.values(t.variants))==null?void 0:l[0]);if(!o)return"Arial, Helvetica, sans-serif";const{source:s,descriptors:i}=o,r=ao(o.family);if(!e){const a=new FontFace(r,`url("${s}")`,i),c=Array.from(document.fonts.values()).filter(d=>d.family===r);for(const d of c)document.fonts.delete(d);document.fonts.add(a),a.load().catch(()=>{})}return Cr(r)},nb=n=>{const{family:e,menu:t,axes:o}=n,s=!!o,i=Object.assign({},...n.variants.map(r=>{var d,p;let l,a;if(s){const u=o.find(h=>h.tag==="wght");if(u){const{start:h,end:f}=u;l=`${h} ${f}`}}return l||(l=((d=r.match(/\d+/))==null?void 0:d[0])??"400"),a=((p=r.match(/[a-zA-Z]+/))==null?void 0:p[0])==="italic"?"italic":void 0,{[r]:{source:n.files[r],descriptors:{style:a,weight:l}}}}));return Sp(e,{menuVariant:{source:t},variants:i})},ob=n=>({id:`${n.family}/${n.version}`,type:"font",src:n.menu,name:n.family,customData:{font:nb(n),needsLoading:!0}}),sb=n=>{const{font:e}=n.customData;return n.customData.needsLoading?(n.customData.needsLoading=!1,xp(e)):xp(e,!0)};let co;const ib=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)},rb=n=>{const{apiKey:e,searchParams:t}=n,o=(s={})=>{const i="https://www.googleapis.com/webfonts/v1/webfonts",r=ib(s);return`${i}?${r}`};return{id:"google-fonts",types:["font"],label:({editor:s})=>s.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var c;if(co)return co;const s={key:e,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},i=t==null?void 0:t(),r={...s,...i},a=await(await fetch(o(r))).json();return(c=a.items)!=null&&c.length?(co=a.items.map(ob),co):[]},itemLayout:s=>{const i=co.find(l=>l.id===s.assetProps.id),r=sb(i);return{type:"column",onClick:()=>s.onSelect(i),htmlAttrs:{title:i.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:i.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:r,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}},{type:"text",content:i.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"16px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},lb={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},ab="googleFontsAssetProvider",cb=F.startup,db=G(function(n,e){const{i18n:t={}}=e,o=rb(e);n.runCommand(j.assetProviderAdd,{provider:o}),n.I18n.addMessages({en:lb,...t}),W({editor:n,licenseKey:e.licenseKey,plan:cb,pluginName:ab,cleanup:()=>{n.runCommand(j.assetProviderRemove,{id:o.id})}})}),pb="canvasAbsoluteMode",ub=F.startup,hb=(n,e,t)=>{var c,d;const o=t.enableAbsolute??(p=>p.hasAbsolute),i=(Array.isArray(e)?e:e?[e]:[...n.getSelectedAll()])[0],r=((d=(c=i==null?void 0:i.delegate)==null?void 0:c.move)==null?void 0:d.call(c,i))||i;if(!r)return;const l=r.getEl();return{result:xt(o)?o({component:r,hasAbsolute:!!l&&getComputedStyle(l).position==="absolute"}):!1,component:r,dmode:r.get("dmode")}};function Ss({guideMatched:n,canvasView:e}){var M;const t=n.guide.x===void 0?"y":"x";let o=0,s=0,i=0,r=0;const{guide:l,matched:a}=n,c=e.getElBoxRect(l.componentView.el),d=e.getElBoxRect(((M=a.componentView)==null?void 0:M.el)||a.componentEl),p=c.y,u=c.y+c.height,h=c.x,f=c.x+c.width,m=d.y,g=d.y+d.height,b=d.x,C=d.x+d.width,y=Math.max(0,p-g),v=Math.max(0,m-u),w=Math.max(0,h-C),S=Math.max(0,b-f),x=y>v,k=w>S,E=l.type;return t==="x"&&(E==="l"?(o=h,x?(s=g,i=y):(s=u,i=v)):E==="r"?(o=f,x?(s=g,i=y):(s=u,i=v)):E==="x"&&(o=h-(h-f)/2,x?(s=g,i=y):(s=u,i=v))),t==="y"&&(E==="t"?(s=p,k?(o=C,r=w):(o=f,r=S)):E==="b"?(s=u,k?(o=C,r=w):(o=f,r=S)):E==="y"&&(s=p-(p-u)/2,k?(o=C,r=w):(o=f,r=S))),{axis:t,x:o,y:s,width:r,height:i}}function fb({guideMatched:n,component:e,canvasView:t}){const o=n.guide.x===void 0?"x":"y",{guide:s,matched:i}=n,r=s.type,l=i.type,a=t.getElementPos(s.componentView.el).rect,c=t.getElementPos(i.componentView.el).rect;if(o==="x"){const d=a.height,p=c.top,u=c.top+c.height;let h=0;r==="t"?l==="t"?h=p-d:l==="b"?h=u-d:l==="y"&&(h=p-d-(p-u)/2):r==="b"?l==="t"?h=p-d*2:l==="b"?h=u-d*2:l==="y"&&(h=p-d*2-(p-u)/2):r==="y"&&(l==="t"?h=p-d*1.5:l==="b"?h=u-d*1.5:l==="y"&&(h=p-d*1.5-(p-u)/2)),e.addStyle({top:`${h-5}px`},{partial:!0})}if(o==="y"){const d=a.width,p=c.left,u=c.left+c.width;let h=0;r==="l"?l==="l"?h=p:l==="r"?h=u:l==="x"&&(h=p-(p-u)/2):r==="r"?l==="l"?h=p-d:l==="r"?h=u-d:l==="x"&&(h=p-d-(p-u)/2):r==="x"&&(l==="l"?h=p-d/2:l==="r"&&(h=u-d/2)),e.addStyle({left:`${h}px`},{partial:!0})}}function wp({snapping:n,editor:e,props:t}){var P,N;const{command:o,guidesMatched:s}=t,i=t.component,r=i.getEl(),l=e.Canvas.getCanvasView(),{x:a,y:c}=n??{x:10,y:10},d=o.opts.event,p=d.clientX,u=d.clientY;if(!i.__lastSnappedPosition){const I=l.getElBoxRect(r),R=p-I.x,_=u-I.y;i.__lastSnappedPosition={left:I.x,top:I.y},i.__dragOffset={x:R,y:_}}const h=((P=i.__dragOffset)==null?void 0:P.x)||0,f=((N=i.__dragOffset)==null?void 0:N.y)||0,m=i.__lastSnappedPosition,g=p-m.left-h,b=u-m.top-f;let C=m.left,y=m.top;const v=s==null?void 0:s[0],w=(v==null?void 0:v.guide.type)==="l",S=(v==null?void 0:v.guide.type)==="x",x=(v==null?void 0:v.guide.type)==="r",k=(v==null?void 0:v.guide.type)==="t",E=(v==null?void 0:v.guide.type)==="b",M=(v==null?void 0:v.guide.type)==="y";if(v){const{x:I,y:R}=Ss({guideMatched:v,canvasView:l}),_=r.offsetWidth,ue=r.offsetHeight;w?C=I:x?C=I-_:S?C=I-_/2:k?y=R:E?y=R-ue:M&&(y=R-ue/2),i.__lastSnappedGuideMatched=v}else Math.abs(g)>=a&&(C=Math.round((m.left+g)/a)*a,i.__lastSnappedGuideMatched=null),Math.abs(b)>=c&&(y=Math.round((m.top+b)/c)*c,i.__lastSnappedGuideMatched=null);return i.addStyle({left:`${C}px`,top:`${y}px`},{partial:!0}),i.__lastSnappedPosition={left:C,top:y},{x:C,y,guideMatched:i.__lastSnappedGuideMatched}}function mb({snapping:n,props:e,editor:t}){const{x:o,y:s}=wp({snapping:n,props:e,editor:t}),i=e.component;i.addStyle({left:`${o}px`,top:`${s}px`}),delete i.__lastSnappedPosition,delete i.__lastSnappedGuideMatched}const gb="core:component-drag",yb="studio:setDragAbsolute",bb="dmode:start",Cp="dmode:move",kp="dmode:end",kr="dragAbsolute",vb="select",Sb="hover",xb="spacing",wb=G(function(n,e={}){const{Commands:t}=n,o=t.events,s=t.getConfig().defaultOptions??{},i=`${o.runBeforeCommand}tlb-move`;s[gb]={run:x=>({...x,skipGuidesRender:!0})};const{snapping:r,locking:l,globalAbsolute:a=!0}=e;a&&n.setDragMode("absolute");const c=!!(r!=null&&r.x||r!=null&&r.y),d=!!(l!=null&&l.x||l!=null&&l.y),{Canvas:p}=n;let u=null;const h=x=>{const{component:k,guidesMatched:E,command:M}=x,P=k.view,N=n.Canvas.getCanvasView(),I=k.getEl();let R=E.map(he=>he.matched.componentEl),_=E.map(he=>Ss({guideMatched:he,canvasView:N}));if(c){const{guideMatched:he}=wp({snapping:r,props:x,editor:n});he?(R=[he.matched.componentEl],_=[Ss({guideMatched:he,canvasView:N})]):(R=[],_=[])}if(d)if(M.opts.event.shiftKey)if(!u)u=E[0];else{const tt=u,Ce=tt.guide.x===void 0?"x":"y";(Ce==="x"&&(l==null?void 0:l.x)||Ce==="y"&&(l==null?void 0:l.y))&&(fb({guideMatched:tt,component:k,canvasView:N}),R=[tt.matched.componentEl],_=[Ss({guideMatched:tt,canvasView:N})])}else u=null;const ue={id:kr,type:kr,component:k,componentView:P,originComponent:I,matchedComponents:R,originMatchedDistances:_};p.addSpot(ue)},f=({enabled:x})=>{n.runCommand(yb,{enabled:x})},m=({type:x})=>{p.removeSpots({type:x})},g=()=>{m({type:vb}),m({type:Sb}),m({type:xb})},b=x=>{f({enabled:!0}),h(x),g()},C=x=>{h(x),g()},y=x=>{m({type:kr}),c&&mb({snapping:r,props:x,editor:n}),f({enabled:!1})},S=[[bb,x=>{b(x),n.on(Cp,C);const k=()=>{y(x),n.off(Cp,C),n.off(kp,k)};n.on(kp,k)}],[i,x=>{if(a)return;const k=x.options.target,E=hb(n,k,e);E!=null&&E.result&&!E.dmode&&(x.options.mode="absolute")}]];S.forEach(([x,k])=>n.on(x,k)),W({editor:n,licenseKey:e.licenseKey,plan:ub,pluginName:pb,cleanup:()=>{f({enabled:!1}),S.forEach(([x,k])=>n.off(x,k))}})});V.accordionComponent=vh,V.animationComponent=Jh,V.canvasAbsoluteMode=wb,V.canvasEmptyState=X0,V.canvasFullSize=ny,V.canvasGridMode=Sy,V.canvasScreenshot=Ey,V.dataSourceEjs=Gy,V.dataSourceHandlebars=Jy,V.dialogComponent=Wp,V.flexComponent=Hh,V.fsLightboxComponent=Vu,V.googleFontsAssetProvider=db,V.iconifyComponent=ou,V.layoutSidebarButtons=hp,V.lightGalleryComponent=Ju,V.listPagesComponent=Lu,V.presetPrintable=Dy,V.rteProseMirror=J0,V.rteTinyMce=cf,V.shapeDividerComponent=Xh,V.swiperComponent=dh,V.tableComponent=Au,V.youtubeAssetProvider=tb,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})});
|
|
1010
|
+
`}handleCommentStatement(e){return`<!--${e.value}-->`}handleElementNode(e){let t="";if(e.attributes)for(const s of e.attributes)s.value.type==="TextNode"?t+=` ${s.name}="${s.value.chars}"`:(this.addMessage("warning",`Complex attribute values not fully supported: ${s.name}`,e.loc),t+=` ${s.name}="${this.getExpressionString(s.value)}"`);let o="";if(e.children)for(const s of e.children)o+=this.astToGrapesJS(s);return`<${e.tag}${t}>${o}</${e.tag}>`}handleTextNode(e){return e.chars||""}handlePartialStatement(e){return this.addMessage("warning",`Partials are not fully supported: ${e.name.original}`,e.loc),`{{> ${e.name.original}}}`}handleGenericBlock(e){const t=this.handleProgram(e.program);return`<!-- Unsupported block: ${e.path.original} -->${t}`}getExpressionString(e){return e.type==="PathExpression"?e.original:e.type==="StringLiteral"?e.value:e.type==="NumberLiteral"?e.value.toString():e.type==="BooleanLiteral"?e.value?"true":"false":e.type==="SubExpression"?this.getExpressionString(e.params[0]):e.type==="Hash"?`{${e.pairs.map(o=>`${o.key}=${this.getExpressionString(o.value)}`).join(", ")}}`:(this.addMessage("warning",`Complex expression type not fully supported: ${e.type}`,e.loc),"")}addMessage(e,t,o){this.messages.push({type:e,message:t,location:o?{line:o.start.line,column:o.start.column}:void 0})}}const wr=n=>{if(n==null||n==="")return[];if(n===".")return["this"];if(n===".."||n==="../")return[".."];if(n.startsWith("../")){const r=n.substring(3);return["..",...wr(r)]}const e=[];let t=0,o=n.replace(/\[(?:(['"])(.*?)\1|([^\]]*))\]/g,(r,l,a,c)=>{const d=a!==void 0?a:c||"";return e[t]=d,`__HANDLEBARS_PLACEHOLDER_${t++}__`});o=o.replace(/\//g,".");const s=o.split("."),i=[];for(const r of s){const l=/^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(r);if(l){const a=parseInt(l[1],10);i.push(e[a])}else r!==""&&i.push(r)}return i},Uy="dataSourceHandlebars",Ky=F.startup,Jy=W(function(n,e={}){const t=mp(n,new jy),o=gp(n,{contains:"{{",importer:new qy});j({editor:n,licenseKey:e.licenseKey,plan:Ky,pluginName:Uy,cleanup:()=>{t(),o()}})}),Zy=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)},bp="youtube-video",Yy=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:o="high"}=n,s=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=Zy(l);return`${c}?${d}`},i=l=>{var a,c,d;return((a=l[o])==null?void 0:a.url)||((c=l.high)==null?void 0:c.url)||((d=l.medium)==null?void 0:d.url)||l.default.url},r=l=>{const a=i(l.snippet.thumbnails);return{id:l.id.videoId,src:`https://www.youtube.com/watch?v=${l.id.videoId}`,name:l.snippet.title,type:bp,customData:{thumbnailUrl:a,videoItem:l}}};return{id:"youtube",types:[bp],label:({editor:l})=>l.I18n.t("youtubeAssetProvider.providerLabel"),search:{reloadOnInput:!0,debounceMs:1e3},async onLoad({searchValue:l,pageCustomData:a}){var m;const c={maxResults:25,q:l,pageToken:a==null?void 0:a.token,type:["video"],key:e},d=t==null?void 0:t({searchValue:l}),p={...c,...d};p.part?p.part.includes("snippet")||p.part.push("snippet"):p.part=["snippet"];const h=await(await fetch(s(p))).json();return(m=h.items)!=null&&m.length?{items:h.items.map(r),nextPageCustomData:{token:h.nextPageToken},isLastPage:!h.nextPageToken}:{items:[],isLastPage:!0}},itemLayout:({assetProps:l,onSelect:a})=>({type:"column",onClick:()=>a(l),htmlAttrs:{title:l.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"custom",render:()=>{var c;return`<img src="${(c=l.customData)==null?void 0:c.thumbnailUrl}" alt="${l.name}" style="width: 100%; height: 100px; object-fit: cover">`}},{type:"text",content:l.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingLeft:8,paddingRight:8}}]})}},Xy={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},Qy="youtubeAssetProvider",eb=F.startup,tb=W(function(n,e){var c;const{skipVideoComponent:t,i18n:o={}}=e,s=Yy(e);n.runCommand(_.assetProviderAdd,{provider:s});const i="search-on-youtube",r="video",l=(c=n.Components.getType(r))==null?void 0:c.model.prototype,a=d=>{n.Assets.open({modalTitle:n.I18n.t("youtubeAssetProvider.modalTitle"),providerId:s.id,typeId:s.types[0],providers:[],types:[],select:p=>{n.Assets.close(),d.set({videoId:p.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})};!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){const[d,...p]=l.getYoutubeTraits.apply(this);return[d,{id:i,type:"button",label:n.I18n.t("youtubeAssetProvider.searchBtn"),command:()=>a(this)},...p]}},view:{events:()=>({dblclick:"onActive"}),onActive(){const{model:d}=this,p=d.get("provider")||"";p!=null&&p.startsWith("yt")&&a(d)}}}),n.I18n.addMessages({en:Xy,...o}),j({editor:n,licenseKey:e.licenseKey,plan:eb,pluginName:Qy,cleanup:()=>{n.runCommand(_.assetProviderRemove,{id:s.id}),!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){return l.getYoutubeTraits.apply(this).filter(d=>d.id!==i)}}})}})}),ao=n=>n.replaceAll('"',"").replaceAll("'",""),Cr=n=>n.includes(",")?n:/\s/.test(n)?`'${ao(n)}'`:ao(n),vp=(n,e,t)=>({family:n,variant:e,...t}),Sp=(n,e)=>{n=Cr(n);const{menuVariant:t,variants:o}=e;return{family:n,familyLabel:ao(n),menuVariant:t&&vp(Cr(`menuFont-${ao(n)}`),"regular",t),variants:Object.assign({},...Object.entries(o).map(([s,i])=>({[s]:vp(n,s,i)})))}},xp=(n,e)=>{var l;const t=Sp(n.family,n),o=t.menuVariant??((l=Object.values(t.variants))==null?void 0:l[0]);if(!o)return"Arial, Helvetica, sans-serif";const{source:s,descriptors:i}=o,r=ao(o.family);if(!e){const a=new FontFace(r,`url("${s}")`,i),c=Array.from(document.fonts.values()).filter(d=>d.family===r);for(const d of c)document.fonts.delete(d);document.fonts.add(a),a.load().catch(()=>{})}return Cr(r)},nb=n=>{const{family:e,menu:t,axes:o}=n,s=!!o,i=Object.assign({},...n.variants.map(r=>{var d,p;let l,a;if(s){const u=o.find(h=>h.tag==="wght");if(u){const{start:h,end:f}=u;l=`${h} ${f}`}}return l||(l=((d=r.match(/\d+/))==null?void 0:d[0])??"400"),a=((p=r.match(/[a-zA-Z]+/))==null?void 0:p[0])==="italic"?"italic":void 0,{[r]:{source:n.files[r],descriptors:{style:a,weight:l}}}}));return Sp(e,{menuVariant:{source:t},variants:i})},ob=n=>({id:`${n.family}/${n.version}`,type:"font",src:n.menu,name:n.family,customData:{font:nb(n),needsLoading:!0}}),sb=n=>{const{font:e}=n.customData;return n.customData.needsLoading?(n.customData.needsLoading=!1,xp(e)):xp(e,!0)};let co;const ib=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)},rb=n=>{const{apiKey:e,searchParams:t}=n,o=(s={})=>{const i="https://www.googleapis.com/webfonts/v1/webfonts",r=ib(s);return`${i}?${r}`};return{id:"google-fonts",types:["font"],label:({editor:s})=>s.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var c;if(co)return co;const s={key:e,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},i=t==null?void 0:t(),r={...s,...i},a=await(await fetch(o(r))).json();return(c=a.items)!=null&&c.length?(co=a.items.map(ob),co):[]},itemLayout:s=>{const i=co.find(l=>l.id===s.assetProps.id),r=sb(i);return{type:"column",onClick:()=>s.onSelect(i),htmlAttrs:{title:i.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:i.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:r,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}},{type:"text",content:i.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"16px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},lb={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},ab="googleFontsAssetProvider",cb=F.startup,db=W(function(n,e){const{i18n:t={}}=e,o=rb(e);n.runCommand(_.assetProviderAdd,{provider:o}),n.I18n.addMessages({en:lb,...t}),j({editor:n,licenseKey:e.licenseKey,plan:cb,pluginName:ab,cleanup:()=>{n.runCommand(_.assetProviderRemove,{id:o.id})}})}),pb="canvasAbsoluteMode",ub=F.startup,hb=(n,e,t)=>{var c,d;const o=t.enableAbsolute??(p=>p.hasAbsolute),i=(Array.isArray(e)?e:e?[e]:[...n.getSelectedAll()])[0],r=((d=(c=i==null?void 0:i.delegate)==null?void 0:c.move)==null?void 0:d.call(c,i))||i;if(!r)return;const l=r.getEl();return{result:xt(o)?o({component:r,hasAbsolute:!!l&&getComputedStyle(l).position==="absolute"}):!1,component:r,dmode:r.get("dmode")}};function Ss({guideMatched:n,canvasView:e}){var M;const t=n.guide.x===void 0?"y":"x";let o=0,s=0,i=0,r=0;const{guide:l,matched:a}=n,c=e.getElBoxRect(l.componentView.el),d=e.getElBoxRect(((M=a.componentView)==null?void 0:M.el)||a.componentEl),p=c.y,u=c.y+c.height,h=c.x,f=c.x+c.width,m=d.y,g=d.y+d.height,b=d.x,C=d.x+d.width,y=Math.max(0,p-g),v=Math.max(0,m-u),w=Math.max(0,h-C),S=Math.max(0,b-f),x=y>v,k=w>S,E=l.type;return t==="x"&&(E==="l"?(o=h,x?(s=g,i=y):(s=u,i=v)):E==="r"?(o=f,x?(s=g,i=y):(s=u,i=v)):E==="x"&&(o=h-(h-f)/2,x?(s=g,i=y):(s=u,i=v))),t==="y"&&(E==="t"?(s=p,k?(o=C,r=w):(o=f,r=S)):E==="b"?(s=u,k?(o=C,r=w):(o=f,r=S)):E==="y"&&(s=p-(p-u)/2,k?(o=C,r=w):(o=f,r=S))),{axis:t,x:o,y:s,width:r,height:i}}function fb({guideMatched:n,component:e,canvasView:t}){const o=n.guide.x===void 0?"x":"y",{guide:s,matched:i}=n,r=s.type,l=i.type,a=t.getElementPos(s.componentView.el).rect,c=t.getElementPos(i.componentView.el).rect;if(o==="x"){const d=a.height,p=c.top,u=c.top+c.height;let h=0;r==="t"?l==="t"?h=p-d:l==="b"?h=u-d:l==="y"&&(h=p-d-(p-u)/2):r==="b"?l==="t"?h=p-d*2:l==="b"?h=u-d*2:l==="y"&&(h=p-d*2-(p-u)/2):r==="y"&&(l==="t"?h=p-d*1.5:l==="b"?h=u-d*1.5:l==="y"&&(h=p-d*1.5-(p-u)/2)),e.addStyle({top:`${h-5}px`},{partial:!0})}if(o==="y"){const d=a.width,p=c.left,u=c.left+c.width;let h=0;r==="l"?l==="l"?h=p:l==="r"?h=u:l==="x"&&(h=p-(p-u)/2):r==="r"?l==="l"?h=p-d:l==="r"?h=u-d:l==="x"&&(h=p-d-(p-u)/2):r==="x"&&(l==="l"?h=p-d/2:l==="r"&&(h=u-d/2)),e.addStyle({left:`${h}px`},{partial:!0})}}function wp({snapping:n,editor:e,props:t}){var P,N;const{command:o,guidesMatched:s}=t,i=t.component,r=i.getEl(),l=e.Canvas.getCanvasView(),{x:a,y:c}=n??{x:10,y:10},d=o.opts.event,p=d.clientX,u=d.clientY;if(!i.__lastSnappedPosition){const I=l.getElBoxRect(r),R=p-I.x,G=u-I.y;i.__lastSnappedPosition={left:I.x,top:I.y},i.__dragOffset={x:R,y:G}}const h=((P=i.__dragOffset)==null?void 0:P.x)||0,f=((N=i.__dragOffset)==null?void 0:N.y)||0,m=i.__lastSnappedPosition,g=p-m.left-h,b=u-m.top-f;let C=m.left,y=m.top;const v=s==null?void 0:s[0],w=(v==null?void 0:v.guide.type)==="l",S=(v==null?void 0:v.guide.type)==="x",x=(v==null?void 0:v.guide.type)==="r",k=(v==null?void 0:v.guide.type)==="t",E=(v==null?void 0:v.guide.type)==="b",M=(v==null?void 0:v.guide.type)==="y";if(v){const{x:I,y:R}=Ss({guideMatched:v,canvasView:l}),G=r.offsetWidth,ue=r.offsetHeight;w?C=I:x?C=I-G:S?C=I-G/2:k?y=R:E?y=R-ue:M&&(y=R-ue/2),i.__lastSnappedGuideMatched=v}else Math.abs(g)>=a&&(C=Math.round((m.left+g)/a)*a,i.__lastSnappedGuideMatched=null),Math.abs(b)>=c&&(y=Math.round((m.top+b)/c)*c,i.__lastSnappedGuideMatched=null);return i.addStyle({left:`${C}px`,top:`${y}px`},{partial:!0}),i.__lastSnappedPosition={left:C,top:y},{x:C,y,guideMatched:i.__lastSnappedGuideMatched}}function mb({snapping:n,props:e,editor:t}){const{x:o,y:s}=wp({snapping:n,props:e,editor:t}),i=e.component;i.addStyle({left:`${o}px`,top:`${s}px`}),delete i.__lastSnappedPosition,delete i.__lastSnappedGuideMatched}const gb="core:component-drag",yb="studio:setDragAbsolute",bb="dmode:start",Cp="dmode:move",kp="dmode:end",kr="dragAbsolute",vb="select",Sb="hover",xb="spacing",wb=W(function(n,e={}){const{Commands:t}=n,o=t.events,s=t.getConfig().defaultOptions??{},i=`${o.runBeforeCommand}tlb-move`;s[gb]={run:x=>({...x,skipGuidesRender:!0})};const{snapping:r,locking:l,globalAbsolute:a=!0}=e;a&&n.setDragMode("absolute");const c=!!(r!=null&&r.x||r!=null&&r.y),d=!!(l!=null&&l.x||l!=null&&l.y),{Canvas:p}=n;let u=null;const h=x=>{const{component:k,guidesMatched:E,command:M}=x,P=k.view,N=n.Canvas.getCanvasView(),I=k.getEl();let R=E.map(he=>he.matched.componentEl),G=E.map(he=>Ss({guideMatched:he,canvasView:N}));if(c){const{guideMatched:he}=wp({snapping:r,props:x,editor:n});he?(R=[he.matched.componentEl],G=[Ss({guideMatched:he,canvasView:N})]):(R=[],G=[])}if(d)if(M.opts.event.shiftKey)if(!u)u=E[0];else{const tt=u,Ce=tt.guide.x===void 0?"x":"y";(Ce==="x"&&(l==null?void 0:l.x)||Ce==="y"&&(l==null?void 0:l.y))&&(fb({guideMatched:tt,component:k,canvasView:N}),R=[tt.matched.componentEl],G=[Ss({guideMatched:tt,canvasView:N})])}else u=null;const ue={id:kr,type:kr,component:k,componentView:P,originComponent:I,matchedComponents:R,originMatchedDistances:G};p.addSpot(ue)},f=({enabled:x})=>{n.runCommand(yb,{enabled:x})},m=({type:x})=>{p.removeSpots({type:x})},g=()=>{m({type:vb}),m({type:Sb}),m({type:xb})},b=x=>{f({enabled:!0}),h(x),g()},C=x=>{h(x),g()},y=x=>{m({type:kr}),c&&mb({snapping:r,props:x,editor:n}),f({enabled:!1})},S=[[bb,x=>{b(x),n.on(Cp,C);const k=()=>{y(x),n.off(Cp,C),n.off(kp,k)};n.on(kp,k)}],[i,x=>{if(a)return;const k=x.options.target,E=hb(n,k,e);E!=null&&E.result&&!E.dmode&&(x.options.mode="absolute")}]];S.forEach(([x,k])=>n.on(x,k)),j({editor:n,licenseKey:e.licenseKey,plan:ub,pluginName:pb,cleanup:()=>{f({enabled:!1}),S.forEach(([x,k])=>n.off(x,k))}})});V.accordionComponent=vh,V.animationComponent=Jh,V.canvasAbsoluteMode=wb,V.canvasEmptyState=X0,V.canvasFullSize=ny,V.canvasGridMode=Sy,V.canvasScreenshot=Ey,V.dataSourceEjs=Gy,V.dataSourceHandlebars=Jy,V.dialogComponent=Wp,V.flexComponent=Hh,V.fsLightboxComponent=Vu,V.googleFontsAssetProvider=db,V.iconifyComponent=ou,V.layoutSidebarButtons=hp,V.lightGalleryComponent=Ju,V.listPagesComponent=Lu,V.presetPrintable=Dy,V.rteProseMirror=J0,V.rteTinyMce=cf,V.shapeDividerComponent=Xh,V.swiperComponent=dh,V.tableComponent=Au,V.youtubeAssetProvider=tb,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})});
|