@prismicio/editor-fields 0.4.67-alpha.5 → 0.4.68
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/core/MediaLibrary/hooks/mediaLibraryData.d.ts +13 -13
- package/dist/core/MediaLibrary/hooks/tagData.d.ts +3 -3
- package/dist/core/MediaLibrary/hooks/useMediaLibraryUpload.d.ts +1 -1
- package/dist/core/MediaLibrary/hooks/useSelectedMedia.d.ts +1 -1
- package/dist/core/service/customType.d.ts +9 -9
- package/dist/core/service/document.d.ts +85 -85
- package/dist/core/service/documentSearch.d.ts +15 -15
- package/dist/core/service/repository.d.ts +6 -6
- package/dist/core/service/role.d.ts +10 -10
- package/dist/fields/ImageField/useImageField.d.ts +1 -1
- package/dist/fields/ImageField/useImageFieldImageUpload.d.ts +1 -1
- package/dist/fields/IntegrationField/integrationData.d.ts +5 -5
- package/dist/fields/LinkField/Documents/documentsData.d.ts +4 -4
- package/dist/fields/RichTextField/coreExtensions/ListItem.d.ts +4 -4
- package/dist/fields/RichTextField/extensions/Image/useImageView.d.ts +1 -1
- package/dist/fields/RichTextField/extensions/Table/plugins/{TableHandles/TableHandlesPlugin.d.ts → tableHandles/tableHandlesPlugin.d.ts} +1 -4
- package/dist/fields/RichTextField/extensions/Table/{TableCell/plugins/TableHandles → plugins/tableHandles}/utils.d.ts +1 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +17 -30
- package/dist/slices/utils.d.ts +4 -4
- package/package.json +4 -4
- package/dist/fields/RichTextField/extensions/Table/TableCell/plugins/TableHandles/TableHandlesPlugin.d.ts +0 -8
- package/dist/fields/RichTextField/extensions/Table/TableCell/plugins/TableHandles/events.d.ts +0 -19
- package/dist/fields/RichTextField/extensions/Table/TableCell/plugins/TableHandles/index.d.ts +0 -1
- package/dist/fields/RichTextField/extensions/Table/TableCell/plugins/index.d.ts +0 -1
- package/dist/fields/RichTextField/extensions/Table/TableControlsWrapper.d.ts +0 -3
- package/dist/fields/RichTextField/extensions/Table/plugins/TableHandles/TableHandlesPluginDef.d.ts +0 -8
- package/dist/fields/RichTextField/extensions/Table/plugins/TableHandles/TableHandlesPluginView.d.ts +0 -34
- package/dist/fields/RichTextField/extensions/Table/plugins/TableHandles/TableHandlesPluginViewClass.d.ts +0 -34
- package/dist/fields/RichTextField/extensions/Table/plugins/TableHandles/utils.d.ts +0 -23
- /package/dist/fields/RichTextField/extensions/Table/plugins/{TableHandles → tableHandles}/index.d.ts +0 -0
- /package/dist/fields/RichTextField/extensions/Table/{TableCell/plugins/TableHandles/TableHandlesPluginView.d.ts → plugins/tableHandles/tableHandlesPluginView.d.ts} +0 -0
package/dist/index.cjs.js
CHANGED
|
@@ -135,4 +135,4 @@ npx @slicemachine/init@latest --repository ${i??"<my-project>"}`,language:"bash"
|
|
|
135
135
|
|
|
136
136
|
`);return!o||!a?!1:e.chain().command(({tr:s})=>(s.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;const{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:o}=n;if(!o||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const s=i.after();return s===void 0?!1:r.nodeAt(s)?e.commands.command(({tr:c})=>(c.setSelection(Fe.near(r.resolve(s))),!0)):e.commands.exitCode()}}},addInputRules(){return[Fx({find:B9e,type:this.type,getAttributes:e=>({language:e[1]})}),Fx({find:P9e,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new dn({key:new qn("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;const n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,o=i==null?void 0:i.mode;if(!n||!o)return!1;const{tr:a,schema:s}=e.state,l=s.text(n.replace(/\r\n?/g,`
|
|
137
137
|
`));return a.replaceSelectionWith(this.type.create({language:o},l)),a.selection.$from.parent.type!==this.type&&a.setSelection($e.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta("paste",!0),e.dispatch(a),!0}}})]}}),py=W9e.extend({name:"preformatted",addAttributes(){return{language:{default:null,parseHTML:e=>{var o;const{languageClassPrefix:t}=this.options,i=[...((o=e.firstElementChild)==null?void 0:o.classList)||[]].filter(a=>a.startsWith(t)).map(a=>a.replace(t,""))[0];return i||null},renderHTML:e=>e.language?{class:this.options.languageClassPrefix+e.language}:null}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({HTMLAttributes:e}){return["pre",Ut(this.options.HTMLAttributes),["code",e,0]]}}).configure({exitOnTripleEnter:!1}),N9e={fromPrismic(e){return function(t){var r;const n=$c.converter.fromPrismic(e)(py.name,t,!0);return(r=e.nodes[py.name])==null?void 0:r.create(Ea.fromPrismic(t),n)}},toPrismic(e){return $c.converter.toPrismic(e,fe.RichTextNodeType.preformatted,Ea.toPrismic(e))}},K9e=new og([fe.RichTextNodeType.preformatted],py.name,py,N9e,"",!0),TZ=K9e;function IZ(e){const{editor:t,getPos:n,node:r}=e,[i,o]=I.useState(!1);return I.useEffect(()=>{function a(){const{from:l,to:c}=t.state.selection,u=n(),f=n()+r.nodeSize,p=l<=u&&c>=f;o(p)}function s(){o(!1)}return t.on("blur",s),t.on("selectionUpdate",a),()=>{t.off("blur",s),t.off("selectionUpdate",a)}},[t,n,r.nodeSize]),{selected:i}}function q9e(e,t,n){const{node:r}=e,i=r.attrs.content,o=ze.useStableCallback(e.updateAttributes),a=ze.useDebounceState({initialState:(i==null?void 0:i.embed_url)??"",startTransition:I.startTransition});function s(u){o({content:u})}function l(u){a.set(u),ai.toURL(u)||s(void 0)}const{onKeyDown:c}=V9e(e,a.value,t,n);return{inputRef:t,containerRef:n,onKeyDown:c,url:a.value,urlChanged:l,onContentChange:s,debouncedUrl:a.debouncedValue,content:e.node.attrs.content}}function V9e(e,t,n,r){const{editor:i,getPos:o,node:a}=e,[s,l]=I.useState(!0);I.useEffect(()=>{!s||!e.editor.isFocused||A.handleEditorFlushSyncError(()=>{var u;return(u=n.current)==null?void 0:u.focus()})},[n,s,e.editor.isFocused]);function c(u){const f=o(),p=o()+a.nodeSize;u.code==="Enter"&&(l(!1),i.chain().insertContentAt(p,{type:"paragraph"}).focus(p+1).run()),u.code==="Backspace"&&t===""&&i.chain().deleteRange({from:f,to:p}).focus(p+1).run(),u.code==="ArrowUp"&&(l(!1),i.chain().focus(f-1).run()),u.code==="ArrowDown"&&(l(!1),i.chain().focus(p+1).run())}return{containerRef:r,inputRef:n,onKeyDown:c}}function z9e(e){const t=I.useRef(null),n=I.useRef(null),{onKeyDown:r,url:i,urlChanged:o,onContentChange:a,debouncedUrl:s,content:l}=q9e(e,t,n),{selected:c}=IZ(e);return d.jsx(JJ,{className:"custom-embed",children:d.jsxs("div",{contentEditable:"false",suppressContentEditableWarning:!0,children:[d.jsxs(A.Box,{flexGrow:1,alignItems:"center",children:[d.jsx(A.Icon,{size:"small",name:"cloud",color:"grey11"}),d.jsx(A.Box,{flexGrow:1,height:40,ref:n,children:d.jsx(Rl,{id:"id",ref:t,value:i,variant:ai.toURL(i)?"link":"normal",placeholder:"Paste your link here",onValueChange:o,onKeyDown:r})})]}),ai.toURL(i)&&d.jsx(oY,{selected:c,debouncedUrl:s,onContentChange:a,content:l})]})})}const Hx=gn.create({name:"embed",group:"block",atom:!0,content:"block*",marks:"",addAttributes(){return{content:{default:void 0}}},addCommands(){return{setEmbed:()=>({tr:e,dispatch:t})=>{const n=this.type.create();return t&&e.replaceSelectionWith(n),!0}}},parseHTML(){return[{tag:"embed"}]},renderHTML(){return["embed"]},addNodeView(){return XJ(z9e)}}),Q9e={fromPrismic(e){return function(t){var n;return(n=e.nodes[Hx.name])==null?void 0:n.create({content:t.data})}},toPrismic(e){return e.attrs.content===void 0?{type:"embed",data:{type:"embed",embed_url:"",__TYPE__:"EmbedContent",all:[]}}:{type:"embed",data:{...e.attrs.content}}}},RZ=new a4e([fe.RichTextNodeType.embed],Hx.name,Hx,Q9e),H9e=gn.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,Ut(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>Fx({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),Yx="heading";function IC(e){switch(e){case 1:return fe.RichTextNodeType.heading1;case 2:return fe.RichTextNodeType.heading2;case 3:return fe.RichTextNodeType.heading3;case 4:return fe.RichTextNodeType.heading4;case 5:return fe.RichTextNodeType.heading5;case 6:return fe.RichTextNodeType.heading6}}function ND(e){return{fullName:IC(e),level:e}}const EZ=[1,2,3,4,5,6];function $Z(e,t=EZ){const n=new RegExp(`^heading([${t.join(",")}]){1}$`),r=e.match(n);if(!r||!r[1])return;const i=parseInt(r[1]);return{fullName:IC(i),level:i}}function kZ(e,t){const n=e.level;if(t.includes(n))return{fullName:IC(n),level:n}}const Y9e=e=>{const t=e[0]??1;return{fromPrismic(n){return function(r){var a;const i=$c.converter.fromPrismic(n)(Yx,r),o=$Z(r.type,e)||ND(t);return(a=n.nodes[Yx])==null?void 0:a.create({level:o.level,...Ea.fromPrismic(r)},i)}},toPrismic(n){const{fullName:r}=kZ(n.attrs,e)||ND(t);return $c.converter.toPrismic(n,r,Ea.toPrismic(n))}}};function G9e(e){return e?e.size?Array.from(e.values()).reduce((n,r)=>{const i=$Z(r);return i?[...n,i.level]:n},[]).sort((n,r)=>n-r):[]:EZ}function J9e(e){return H9e.extend({name:"heading"}).configure({levels:e})}const Kl={name:Yx,build:e=>{const t=G9e(e);if(!t)return;const n=t.map(r=>IC(r));return new l4e(n,J9e(t),t,Y9e(t),r=>{const i=kZ(r,t);return i&&`Heading ${i.level}`})}};function Z9e(e){const{content:t,thumbnail:n,imageViewProps:{getPos:r,updateAttributes:i,editor:o,node:a}}=e,[s,l]=I.useTransition();function c(g){l(()=>i({content:g}))}function u(g){const y=Ng(g),C=r()+a.nodeSize;c({...t,...y}),o.chain().focus(C+1).run()}function f({croppedImages:g}){if(!t)return;const y=g[n.name];if(!y)return;const C=hY({content:t,croppedImage:y});C!==t&&c(C)}function p(){const g=r(),y=r()+a.nodeSize;o.chain().deleteRange({from:g,to:y}).focus(y).run()}const{uploadImage:h,isUploadingImage:m}=RY({onMediaSelected:u});return{onMediaSelected:u,onCropperDialogClose:f,isUpdating:s,updateContent:c,onClear:p,uploadImage:h,isUploadingImage:m}}function X9e(e){const{node:t}=e,n=t.attrs.content,{selected:r}=IZ(e),i=I.useRef(null),o={width:void 0,height:void 0,name:hp},{onMediaSelected:a,onCropperDialogClose:s,isUpdating:l,updateContent:c,onClear:u,uploadImage:f,isUploadingImage:p}=Z9e({content:n,thumbnail:o,imageViewProps:e}),[h,m]=I.useState(!1),g="Feature image",y=(n==null?void 0:n.width)===0&&(n==null?void 0:n.height)===0,C=n&&!y?[`${n.width}×${n.height}px`]:[],x={thumbnail:o,contentView:n,labels:sx(o,n,n)};I.useLayoutEffect(()=>{var S;const v=(S=i==null?void 0:i.current)==null?void 0:S.closest(`.${OZ}`);Pg.isHTMLElement(v)&&v.style.removeProperty("min-height")},[]);const b=p||l;return d.jsx(JJ,{children:d.jsx(dY,{ref:i,isMediaDialogOpen:h,selected:r,onMediaSelected:a,onMediaDialogOpenChange:m,children:d.jsx(I.Suspense,{fallback:n8e,children:n!=null&&n.url?d.jsx(IY,{allContentViews:[n],content:n,contentView:n,fieldLabel:g,imageLabel:C,initialImages:[x],isUpdating:b,readOnly:!1,thumbnailName:o.name,onClear:u,onContentChange:c,onCropperDialogClose:s,onMediaDialogOpenChange:m}):d.jsx(fY,{uploadImage:f,isUploading:p,disabled:h,children:d.jsx(lY,{fieldLabel:g,isUpdating:b,readOnly:!1,onMediaDialogOpenChange:m})})})})})}const OZ="imageViewNodeWrapper",MZ=144,e8e=94;function t8e(e){return(e?e8e:MZ)+12+12+1+1}const n8e=d.jsx("div",{style:{height:MZ}}),Gx=gn.create({name:"image",group:"block",atom:!0,addAttributes(){return{content:{default:void 0}}},addCommands(){return{setImage:()=>e=>{const{dispatch:t,tr:n}=e,r=this.type.create();return t&&n.replaceSelectionWith(r),!0}}},parseHTML(){return[{tag:"image"}]},renderHTML({HTMLAttributes:e}){return["image",e]},addNodeView(){return function(t){const n=t.node.attrs.content===void 0;return XJ(X9e,{attrs:{style:`min-height: ${t8e(n)}px`,class:OZ}})(t)}}}),r8e={fromPrismic(e){return function(t){var n;return(n=e.nodes[Gx.name])==null?void 0:n.create({content:t.data})}},toPrismic(e){if(e.attrs.content!==void 0)return{type:"image",data:{...e.attrs.content}}}},FZ=new s4e([fe.RichTextNodeType.image],Gx.name,Gx,r8e),i8e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,o8e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,a8e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,s8e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,l8e=tg.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>e.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",Ut(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Xv({find:i8e,type:this.type}),Xv({find:a8e,type:this.type})]},addPasteRules(){return[ty({find:o8e,type:this.type}),ty({find:s8e,type:this.type})]}});class c8e{constructor(t,n,r){$t(this,"extType",Lu.Mark);$t(this,"richTextNodeTypes",[fe.RichTextNodeType.em]);this.name=t,this.component=n,this.converter=r}}const jZ="em",LZ=l8e.extend({name:jZ}),u8e={fromPrismic(e){return function(){var t;return(t=e.marks[LZ.name])==null?void 0:t.create()}},toPrismic(){}},d8e=new c8e(jZ,LZ,u8e),GF=d8e;class f8e{constructor(t,n,r){$t(this,"extType",Lu.Mark);$t(this,"richTextNodeTypes",[]);this.name=t,this.component=n,this.converter=r}}const DZ="label",Jx=tg.create({name:DZ,priority:1e3,keepOnSplit:!1,inclusive:!1,addOptions(){return{htmlAttributes:{style:"background-color: hsl(251, 89%, 96%); border: 1px dashed rgba(68, 53, 146, 0.4); border-radius: 0px 2px 2px 2px"}}},addAttributes(){return{label:{default:""}}},addCommands(){return{setLabel:e=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMark(this.name,e).run(),unsetLabel:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},renderHTML({HTMLAttributes:e}){return["span",Ut(this.options.htmlAttributes,e),0]}}),p8e={fromPrismic(e){return function(t){var i;const n=t.data,r={type:Jx.name,label:n};return(i=e.marks[Jx.name])==null?void 0:i.create(r)}},toPrismic(e){return e.attrs.label}},JF=new f8e(DZ,Jx,p8e);class h8e{constructor(t,n,r){$t(this,"extType",Lu.Mark);$t(this,"richTextNodeTypes",[fe.RichTextNodeType.hyperlink]);this.name=t,this.component=n,this.converter=r}}const UZ="hyperlink",Aa=tg.create({name:UZ,priority:1e3,keepOnSplit:!1,inclusive:!1,addOptions(){return{openOnClick:!1,linkOnPaste:!0,autolink:!0,protocols:[],htmlAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null,id:""},validate:void 0}},addAttributes(){return{href:{default:""},id:{default:""},target:{default:"_blank"},rel:{default:"noopener noreferrer nofollow"},class:{default:null},media:{default:null}}},parseHTML(){return[{tag:'a[href]:not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:e}){return["a",Ut(this.options.htmlAttributes,e),0]},addCommands(){return{setWebLink:e=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMark(this.name,e).setMeta("preventAutolink",!0).run(),setDocumentLink:e=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMark(this.name,e).setMeta("preventAutolink",!0).run(),setMediaLink:e=>({chain:t})=>{const n=Zx(wY({media:e.media}).value);return t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMark(this.name,{media:n}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}}}),A8e={fromPrismic(e){return function(t){var r,i,o,a;const n=t.data;if(n.__TYPE__==="DocumentLink"){const s={type:Aa.name,id:n.id};return(r=e.marks[Aa.name])==null?void 0:r.create(s)}if(n.__TYPE__==="ImageLink"){const s={type:Aa.name,media:Zx(n)};return(i=e.marks[Aa.name])==null?void 0:i.create(s)}if(n.__TYPE__==="FileLink"){const s={type:Aa.name,media:Zx(n)};return(o=e.marks[Aa.name])==null?void 0:o.create(s)}if(n.__TYPE__==="ExternalLink"){const s={type:Aa.name,url:n.url,href:n.url,target:n.target};return(a=e.marks[Aa.name])==null?void 0:a.create(s)}}},toPrismic(e){return e.attrs.media?PZ(e.attrs.media):e.attrs.id?{__TYPE__:"DocumentLink",id:e.attrs.id}:{__TYPE__:"ExternalLink",url:e.attrs.href,target:e.attrs.target}}},BZ=new h8e(UZ,Aa,A8e);function Zx(e){return JSON.stringify(e)}function PZ(e){return JSON.parse(e)}const m8e="listItem",KD="textStyle",qD=/^(\d+)\.\s$/,g8e=gn.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:void 0,parseHTML:e=>e.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:e}){const{start:t,...n}=e;return t===1?["ol",Ut(this.options.HTMLAttributes,n),0]:["ol",Ut(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(m8e,this.editor.getAttributes(KD)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=ey({find:qD,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=ey({find:qD,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(KD)}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1],editor:this.editor})),[e]}}),Xx=g8e.extend({name:"orderedList",addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1}}},renderHTML({HTMLAttributes:e}){const{start:t,...n}=e;return t===1?["ol",Ut(this.options.HTMLAttributes,n),0]:["ol",Ut(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}}}).configure({itemTypeName:"listItem"}),v8e={fromPrismic(e){return function(t){var r;const n=Ud.converter.fromPrismic(e)(t);if(n)return(r=e.nodes[Xx.name])==null?void 0:r.create(Ea.fromPrismic(t),n)}},toPrismic(e){return Hs.children.map(e,t=>Ud.converter.toPrismic(t,fe.RichTextNodeType.orderedList).filter(Hi.isDefined)).flat()}},y8e=new KF([fe.RichTextNodeType.orderedList],Xx.name,Xx,v8e),hy=y8e,WZ=65535,NZ=Math.pow(2,16);function b8e(e,t){return e+t*NZ}function VD(e){return e&WZ}function C8e(e){return(e-(e&WZ))/NZ}const KZ=1,qZ=2,sv=4,VZ=8;class e_{constructor(t,n,r){this.pos=t,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&VZ)>0}get deletedBefore(){return(this.delInfo&(KZ|sv))>0}get deletedAfter(){return(this.delInfo&(qZ|sv))>0}get deletedAcross(){return(this.delInfo&sv)>0}}class ni{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&ni.empty)return ni.empty}recover(t){let n=0,r=VD(t);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+C8e(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,r){let i=0,o=this.inverted?2:1,a=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let l=this.ranges[s]-(this.inverted?i:0);if(l>t)break;let c=this.ranges[s+o],u=this.ranges[s+a],f=l+c;if(t<=f){let p=c?t==l?-1:t==f?1:n:n,h=l+i+(p<0?0:u);if(r)return h;let m=t==(n<0?l:f)?null:b8e(s/3,t-l),g=t==l?qZ:t==f?KZ:sv;return(n<0?t!=l:t!=f)&&(g|=VZ),new e_(h,g,m)}i+=u-c}return r?t+i:new e_(t+i,0,null)}touches(t,n){let r=0,i=VD(n),o=this.inverted?2:1,a=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let l=this.ranges[s]-(this.inverted?r:0);if(l>t)break;let c=this.ranges[s+o],u=l+c;if(t<=u&&s==i*3)return!0;r+=this.ranges[s+a]-c}return!1}forEach(t){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let a=this.ranges[i],s=a-(this.inverted?o:0),l=a+(this.inverted?0:o),c=this.ranges[i+n],u=this.ranges[i+r];t(s,s+c,l,l+u),o+=u-c}}invert(){return new ni(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?ni.empty:new ni(t<0?[0,-t,0]:[0,0,t])}}ni.empty=new ni([]);class nh{constructor(t=[],n,r=0,i=t.length){this.maps=t,this.mirror=n,this.from=r,this.to=i}slice(t=0,n=this.maps.length){return new nh(this.maps,this.mirror,t,n)}copy(){return new nh(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(t,n){this.to=this.maps.push(t),n!=null&&this.setMirror(this.maps.length-1,n)}appendMapping(t){for(let n=0,r=this.maps.length;n<t.maps.length;n++){let i=t.getMirror(n);this.appendMap(t.maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(t){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==t)return this.mirror[n+(n%2?-1:1)]}}setMirror(t,n){this.mirror||(this.mirror=[]),this.mirror.push(t,n)}appendMappingInverted(t){for(let n=t.maps.length-1,r=this.maps.length+t.maps.length;n>=0;n--){let i=t.getMirror(n);this.appendMap(t.maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let t=new nh;return t.appendMappingInverted(this),t}map(t,n=1){if(this.mirror)return this._map(t,n,!0);for(let r=this.from;r<this.to;r++)t=this.maps[r].map(t,n);return t}mapResult(t,n=1){return this._map(t,n,!1)}_map(t,n,r){let i=0;for(let o=this.from;o<this.to;o++){let a=this.maps[o],s=a.mapResult(t,n);if(s.recover!=null){let l=this.getMirror(o);if(l!=null&&l>o&&l<this.to){o=l,t=this.maps[l].recover(s.recover);continue}}i|=s.delInfo,t=s.pos}return r?t:new e_(t,i,null)}}const Sw=Object.create(null);class lr{getMap(){return ni.empty}merge(t){return null}static fromJSON(t,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Sw[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(t,n)}static jsonID(t,n){if(t in Sw)throw new RangeError("Duplicate use of step JSON ID "+t);return Sw[t]=n,n.prototype.jsonID=t,n}}class en{constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new en(t,null)}static fail(t){return new en(null,t)}static fromReplace(t,n,r,i){try{return en.ok(t.replace(n,r,i))}catch(o){if(o instanceof _c)return en.fail(o.message);throw o}}}function ZF(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let o=e.child(i);o.content.size&&(o=o.copy(ZF(o.content,t,o))),o.isInline&&(o=t(o,n,i)),r.push(o)}return K.fromArray(r)}class Os extends lr{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=t.resolve(this.from),i=r.node(r.sharedDepth(this.to)),o=new q(ZF(n.content,(a,s)=>!a.isAtom||!s.type.allowsMarkType(this.mark.type)?a:a.mark(this.mark.addToSet(a.marks)),i),n.openStart,n.openEnd);return en.fromReplace(t,this.from,this.to,o)}invert(){return new Io(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Os(n.pos,r.pos,this.mark)}merge(t){return t instanceof Os&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Os(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Os(n.from,n.to,t.markFromJSON(n.mark))}}lr.jsonID("addMark",Os);class Io extends lr{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=new q(ZF(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),t),n.openStart,n.openEnd);return en.fromReplace(t,this.from,this.to,r)}invert(){return new Os(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Io(n.pos,r.pos,this.mark)}merge(t){return t instanceof Io&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Io(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Io(n.from,n.to,t.markFromJSON(n.mark))}}lr.jsonID("removeMark",Io);class Ms extends lr{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return en.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return en.fromReplace(t,this.pos,this.pos+1,new q(K.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new Ms(this.pos,n.marks[i]);return new Ms(this.pos,this.mark)}}return new Pd(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new Ms(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Ms(n.pos,t.markFromJSON(n.mark))}}lr.jsonID("addNodeMark",Ms);class Pd extends lr{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return en.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return en.fromReplace(t,this.pos,this.pos+1,new q(K.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Ms(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new Pd(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Pd(n.pos,t.markFromJSON(n.mark))}}lr.jsonID("removeNodeMark",Pd);class dr extends lr{constructor(t,n,r,i=!1){super(),this.from=t,this.to=n,this.slice=r,this.structure=i}apply(t){return this.structure&&t_(t,this.from,this.to)?en.fail("Structure replace would overwrite content"):en.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new ni([this.from,this.to-this.from,this.slice.size])}invert(t){return new dr(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new dr(n.pos,Math.max(n.pos,r.pos),this.slice)}merge(t){if(!(t instanceof dr)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?q.empty:new q(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new dr(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?q.empty:new q(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new dr(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new dr(n.from,n.to,q.fromJSON(t,n.slice),!!n.structure)}}lr.jsonID("replace",dr);class Oo extends lr{constructor(t,n,r,i,o,a,s=!1){super(),this.from=t,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=o,this.insert=a,this.structure=s}apply(t){if(this.structure&&(t_(t,this.from,this.gapFrom)||t_(t,this.gapTo,this.to)))return en.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return en.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?en.fromReplace(t,this.from,this.to,r):en.fail("Content does not fit in gap")}getMap(){return new ni([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new Oo(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||o>r.pos?null:new Oo(n.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Oo(n.from,n.to,n.gapFrom,n.gapTo,q.fromJSON(t,n.slice),n.insert,!!n.structure)}}lr.jsonID("replaceAround",Oo);function t_(e,t,n){let r=e.resolve(t),i=n-t,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let a=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,i--}}return!1}function S8e(e,t,n,r){let i=[],o=[],a,s;e.doc.nodesBetween(t,n,(l,c,u)=>{if(!l.isInline)return;let f=l.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let p=Math.max(c,t),h=Math.min(c+l.nodeSize,n),m=r.addToSet(f);for(let g=0;g<f.length;g++)f[g].isInSet(m)||(a&&a.to==p&&a.mark.eq(f[g])?a.to=h:i.push(a=new Io(p,h,f[g])));s&&s.to==p?s.to=h:o.push(s=new Os(p,h,r))}}),i.forEach(l=>e.step(l)),o.forEach(l=>e.step(l))}function w8e(e,t,n,r){let i=[],o=0;e.doc.nodesBetween(t,n,(a,s)=>{if(!a.isInline)return;o++;let l=null;if(r instanceof lC){let c=a.marks,u;for(;u=r.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(a.marks)&&(l=[r]):l=a.marks;if(l&&l.length){let c=Math.min(s+a.nodeSize,n);for(let u=0;u<l.length;u++){let f=l[u],p;for(let h=0;h<i.length;h++){let m=i[h];m.step==o-1&&f.eq(i[h].style)&&(p=m)}p?(p.to=c,p.step=o):i.push({style:f,from:Math.max(s,t),to:c,step:o})}}}),i.forEach(a=>e.step(new Io(a.from,a.to,a.style)))}function XF(e,t,n,r=n.contentMatch,i=!0){let o=e.doc.nodeAt(t),a=[],s=t+1;for(let l=0;l<o.childCount;l++){let c=o.child(l),u=s+c.nodeSize,f=r.matchType(c.type);if(!f)a.push(new dr(s,u,q.empty));else{r=f;for(let p=0;p<c.marks.length;p++)n.allowsMarkType(c.marks[p].type)||e.step(new Io(s,u,c.marks[p]));if(i&&c.isText&&n.whitespace!="pre"){let p,h=/\r?\n|\r/g,m;for(;p=h.exec(c.text);)m||(m=new q(K.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),a.push(new dr(s+p.index,s+p.index+p[0].length,m))}}s=u}if(!r.validEnd){let l=r.fillBefore(K.empty,!0);e.replace(s,s,new q(l,0,0))}for(let l=a.length-1;l>=0;l--)e.step(a[l])}function x8e(e,t,n){let{$from:r,$to:i,depth:o}=t,a=r.before(o+1),s=i.after(o+1),l=a,c=s,u=K.empty,f=0;for(let m=o,g=!1;m>n;m--)g||r.index(m)>0?(g=!0,u=K.from(r.node(m).copy(u)),f++):l--;let p=K.empty,h=0;for(let m=o,g=!1;m>n;m--)g||i.after(m+1)<i.end(m)?(g=!0,p=K.from(i.node(m).copy(p)),h++):c++;e.step(new Oo(l,c,a,s,new q(u.append(p),f,h),u.size-f,!0))}function _8e(e,t,n){let r=K.empty;for(let a=n.length-1;a>=0;a--){if(r.size){let s=n[a].type.contentMatch.matchFragment(r);if(!s||!s.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=K.from(n[a].type.create(n[a].attrs,r))}let i=t.start,o=t.end;e.step(new Oo(i,o,i,o,new q(r,0,0),n.length,!0))}function T8e(e,t,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=e.steps.length;e.doc.nodesBetween(t,n,(a,s)=>{let l=typeof i=="function"?i(a):i;if(a.isTextblock&&!a.hasMarkup(r,l)&&I8e(e.doc,e.mapping.slice(o).map(s),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!m?c=!1:!h&&m&&(c=!0)}c===!1&&QZ(e,a,s,o),XF(e,e.mapping.slice(o).map(s,1),r,void 0,c===null);let u=e.mapping.slice(o),f=u.map(s,1),p=u.map(s+a.nodeSize,1);return e.step(new Oo(f,p,f+1,p-1,new q(K.from(r.create(l,null,a.marks)),0,0),1,!0)),c===!0&&zZ(e,a,s,o),!1}})}function zZ(e,t,n,r){t.forEach((i,o)=>{if(i.isText){let a,s=/\r?\n|\r/g;for(;a=s.exec(i.text);){let l=e.mapping.slice(r).map(n+1+o+a.index);e.replaceWith(l,l+1,t.type.schema.linebreakReplacement.create())}}})}function QZ(e,t,n,r){t.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let a=e.mapping.slice(r).map(n+1+o);e.replaceWith(a,a+1,t.type.schema.text(`
|
|
138
|
-
`))}})}function I8e(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function R8e(e,t,n,r,i){let o=e.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let a=n.create(r,null,i||o.marks);if(o.isLeaf)return e.replaceWith(t,t+o.nodeSize,a);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new Oo(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new q(K.from(a),0,0),1,!0))}function E8e(e,t,n=1,r){let i=e.doc.resolve(t),o=K.empty,a=K.empty;for(let s=i.depth,l=i.depth-n,c=n-1;s>l;s--,c--){o=K.from(i.node(s).copy(o));let u=r&&r[c];a=K.from(u?u.type.create(u.attrs,a):i.node(s).copy(a))}e.step(new dr(t,t,new q(o.append(a),n,n),!0))}function $8e(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,o=e.doc.resolve(t-n),a=o.node().type;if(i&&a.inlineContent){let u=a.whitespace=="pre",f=!!a.contentMatch.matchType(i);u&&!f?r=!1:!u&&f&&(r=!0)}let s=e.steps.length;if(r===!1){let u=e.doc.resolve(t+n);QZ(e,u.node(),u.before(),s)}a.inlineContent&&XF(e,t+n-1,a,o.node().contentMatchAt(o.index()),r==null);let l=e.mapping.slice(s),c=l.map(t-n);if(e.step(new dr(c,l.map(t+n,-1),q.empty,!0)),r===!0){let u=e.doc.resolve(c);zZ(e,u.node(),u.before(),e.steps.length)}return e}function k8e(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,n))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,n))return r.after(i+1);if(o<r.node(i).childCount)return null}return null}function O8e(e,t,n=t,r=q.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),o=e.resolve(n);return HZ(i,o,r)?new dr(t,n,r):new M8e(i,o,r).fit()}function HZ(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}class M8e{constructor(t,n,r){this.$from=t,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=K.empty;for(let i=0;i<=t.depth;i++){let o=t.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(t.indexAfter(i))})}for(let i=t.depth;i>0;i--)this.placed=K.from(t.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(t<0?this.$to:r.doc.resolve(t));if(!i)return null;let o=this.placed,a=r.depth,s=i.depth;for(;a&&s&&o.childCount==1;)o=o.firstChild.content,a--,s--;let l=new q(o,a,s);return t>-1?new Oo(r.pos,t,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new dr(r.pos,i.pos,l):null}findFittable(){let t=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<t;r++){let o=n.firstChild;if(n.childCount>1&&(i=0),o.type.spec.isolating&&i<=r){t=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?t:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=ww(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let a=i.firstChild;for(let s=this.depth;s>=0;s--){let{type:l,match:c}=this.frontier[s],u,f=null;if(n==1&&(a?c.matchType(a.type)||(f=c.fillBefore(K.from(a),!1)):o&&l.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:s,parent:o,inject:f};if(n==2&&a&&(u=c.findWrapping(a.type)))return{sliceDepth:r,frontierDepth:s,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:t,openStart:n,openEnd:r}=this.unplaced,i=ww(t,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new q(t,n+1,Math.max(r,i.size+n>=t.size-r?n+1:0)),!0)}dropNode(){let{content:t,openStart:n,openEnd:r}=this.unplaced,i=ww(t,n);if(i.childCount<=1&&n>0){let o=t.size-n<=n+i.size;this.unplaced=new q(Vp(t,n-1,1),n-1,o?n-1:r)}else this.unplaced=new q(Vp(t,n,1),n,r)}placeNodes({sliceDepth:t,frontierDepth:n,parent:r,inject:i,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let g=0;g<o.length;g++)this.openFrontierNode(o[g]);let a=this.unplaced,s=r?r.content:a.content,l=a.openStart-t,c=0,u=[],{match:f,type:p}=this.frontier[n];if(i){for(let g=0;g<i.childCount;g++)u.push(i.child(g));f=f.matchFragment(i)}let h=s.size+t-(a.content.size-a.openEnd);for(;c<s.childCount;){let g=s.child(c),y=f.matchType(g.type);if(!y)break;c++,(c>1||l==0||g.content.size)&&(f=y,u.push(YZ(g.mark(p.allowedMarks(g.marks)),c==1?l:0,c==s.childCount?h:-1)))}let m=c==s.childCount;m||(h=-1),this.placed=zp(this.placed,n,K.from(u)),this.frontier[n].match=f,m&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=s;g<h;g++){let C=y.lastChild;this.frontier.push({type:C.type,match:C.contentMatchAt(C.childCount)}),y=C.content}this.unplaced=m?t==0?q.empty:new q(Vp(a.content,t-1,1),t-1,h<0?a.openEnd:t-1):new q(Vp(a.content,t,c),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],n;if(!t.type.isTextblock||!xw(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(t){e:for(let n=Math.min(this.depth,t.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],o=n<t.depth&&t.end(n+1)==t.pos+(t.depth-(n+1)),a=xw(t,n,i,r,o);if(a){for(let s=n-1;s>=0;s--){let{match:l,type:c}=this.frontier[s],u=xw(t,s,c,l,!0);if(!u||u.childCount)continue e}return{depth:n,fit:a,move:o?t.doc.resolve(t.after(n+1)):t}}}}close(t){let n=this.findCloseLevel(t);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=zp(this.placed,n.depth,n.fit)),t=n.move;for(let r=n.depth+1;r<=t.depth;r++){let i=t.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,t.index(r));this.openFrontierNode(i.type,i.attrs,o)}return t}openFrontierNode(t,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(t),this.placed=zp(this.placed,this.depth,K.from(t.create(n,r))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(K.empty,!0);n.childCount&&(this.placed=zp(this.placed,this.frontier.length,n))}}function Vp(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Vp(e.firstChild.content,t-1,n)))}function zp(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(zp(e.lastChild.content,t-1,n)))}function ww(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function YZ(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,YZ(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(K.empty,!0)))),e.copy(r)}function xw(e,t,n,r,i){let o=e.node(t),a=i?e.indexAfter(t):e.index(t);if(a==o.childCount&&!n.compatibleContent(o.type))return null;let s=r.fillBefore(o.content,!0,a);return s&&!F8e(n,o.content,a)?s:null}function F8e(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function j8e(e){return e.spec.defining||e.spec.definingForContent}function L8e(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),o=e.doc.resolve(n);if(HZ(i,o,r))return e.step(new dr(t,n,r));let a=JZ(i,e.doc.resolve(n));a[a.length-1]==0&&a.pop();let s=-(i.depth+1);a.unshift(s);for(let p=i.depth,h=i.pos-1;p>0;p--,h--){let m=i.node(p).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;a.indexOf(p)>-1?s=p:i.before(p)==h&&a.splice(1,0,-p)}let l=a.indexOf(s),c=[],u=r.openStart;for(let p=r.content,h=0;;h++){let m=p.firstChild;if(c.push(m),h==r.openStart)break;p=m.content}for(let p=u-1;p>=0;p--){let h=c[p],m=j8e(h.type);if(m&&!h.sameMarkup(i.node(Math.abs(s)-1)))u=p;else if(m||!h.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let h=(p+u+1)%(r.openStart+1),m=c[h];if(m)for(let g=0;g<a.length;g++){let y=a[(g+l)%a.length],C=!0;y<0&&(C=!1,y=-y);let x=i.node(y-1),b=i.index(y-1);if(x.canReplaceWith(b,b,m.type,m.marks))return e.replace(i.before(y),C?o.after(y):n,new q(GZ(r.content,0,r.openStart,h),h,r.openEnd))}}let f=e.steps.length;for(let p=a.length-1;p>=0&&(e.replace(t,n,r),!(e.steps.length>f));p--){let h=a[p];h<0||(t=i.before(h),n=o.after(h))}}function GZ(e,t,n,r,i){if(t<n){let o=e.firstChild;e=e.replaceChild(0,o.copy(GZ(o.content,t+1,n,r,o)))}if(t>r){let o=i.contentMatchAt(0),a=o.fillBefore(e).append(e);e=a.append(o.matchFragment(a).fillBefore(K.empty,!0))}return e}function D8e(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=k8e(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new q(K.from(r),0,0))}function U8e(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n),o=JZ(r,i);for(let a=0;a<o.length;a++){let s=o[a],l=a==o.length-1;if(l&&s==0||r.node(s).type.contentMatch.validEnd)return e.delete(r.start(s),i.end(s));if(s>0&&(l||r.node(s-1).canReplace(r.index(s-1),i.indexAfter(s-1))))return e.delete(r.before(s),i.after(s))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function JZ(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let o=e.start(i);if(o<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(o==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==o-1)&&n.push(i)}return n}class ud extends lr{constructor(t,n,r){super(),this.pos=t,this.attr=n,this.value=r}apply(t){let n=t.nodeAt(this.pos);if(!n)return en.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return en.fromReplace(t,this.pos,this.pos+1,new q(K.from(i),0,n.isLeaf?0:1))}getMap(){return ni.empty}invert(t){return new ud(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new ud(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ud(n.pos,n.attr,n.value)}}lr.jsonID("attr",ud);class Yh extends lr{constructor(t,n){super(),this.attr=t,this.value=n}apply(t){let n=Object.create(null);for(let i in t.attrs)n[i]=t.attrs[i];n[this.attr]=this.value;let r=t.type.create(n,t.content,t.marks);return en.ok(r)}getMap(){return ni.empty}invert(t){return new Yh(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Yh(n.attr,n.value)}}lr.jsonID("docAttr",Yh);let Wd=class extends Error{};Wd=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n};Wd.prototype=Object.create(Error.prototype);Wd.prototype.constructor=Wd;Wd.prototype.name="TransformError";class B8e{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new nh}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let n=this.maybeStep(t);if(n.failed)throw new Wd(n.failed);return this}maybeStep(t){let n=t.apply(this.doc);return n.failed||this.addStep(t,n.doc),n}get docChanged(){return this.steps.length>0}addStep(t,n){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=n}replace(t,n=t,r=q.empty){let i=O8e(this.doc,t,n,r);return i&&this.step(i),this}replaceWith(t,n,r){return this.replace(t,n,new q(K.from(r),0,0))}delete(t,n){return this.replace(t,n,q.empty)}insert(t,n){return this.replaceWith(t,t,n)}replaceRange(t,n,r){return L8e(this,t,n,r),this}replaceRangeWith(t,n,r){return D8e(this,t,n,r),this}deleteRange(t,n){return U8e(this,t,n),this}lift(t,n){return x8e(this,t,n),this}join(t,n=1){return $8e(this,t,n),this}wrap(t,n){return _8e(this,t,n),this}setBlockType(t,n=t,r,i=null){return T8e(this,t,n,r,i),this}setNodeMarkup(t,n,r=null,i){return R8e(this,t,n,r,i),this}setNodeAttribute(t,n,r){return this.step(new ud(t,n,r)),this}setDocAttribute(t,n){return this.step(new Yh(t,n)),this}addNodeMark(t,n){return this.step(new Ms(t,n)),this}removeNodeMark(t,n){if(!(n instanceof xt)){let r=this.doc.nodeAt(t);if(!r)throw new RangeError("No node at position "+t);if(n=n.isInSet(r.marks),!n)return this}return this.step(new Pd(t,n)),this}split(t,n=1,r){return E8e(this,t,n,r),this}addMark(t,n,r){return S8e(this,t,n,r),this}removeMark(t,n,r){return w8e(this,t,n,r),this}clearIncompatible(t,n,r){return XF(this,t,n,r),this}}var n_,r_;if(typeof WeakMap<"u"){let e=new WeakMap;n_=t=>e.get(t),r_=(t,n)=>(e.set(t,n),n)}else{const e=[];let n=0;n_=r=>{for(let i=0;i<e.length;i+=2)if(e[i]==r)return e[i+1]},r_=(r,i)=>(n==10&&(n=0),e[n++]=r,e[n++]=i)}var gt=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){const n=this.map[t];if(n!=e)continue;const r=t%this.width,i=t/this.width|0;let o=r+1,a=i+1;for(let s=1;o<this.width&&this.map[t+s]==n;s++)o++;for(let s=1;a<this.height&&this.map[t+this.width*s]==n;s++)a++;return{left:r,top:i,right:o,bottom:a}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){const{left:r,right:i,top:o,bottom:a}=this.findCell(e);return t=="horiz"?(n<0?r==0:i==this.width)?null:this.map[o*this.width+(n<0?r-1:i)]:(n<0?o==0:a==this.height)?null:this.map[r+this.width*(n<0?o-1:a)]}rectBetween(e,t){const{left:n,right:r,top:i,bottom:o}=this.findCell(e),{left:a,right:s,top:l,bottom:c}=this.findCell(t);return{left:Math.min(n,a),top:Math.min(i,l),right:Math.max(r,s),bottom:Math.max(o,c)}}cellsInRect(e){const t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){const o=r*this.width+i,a=this.map[o];n[a]||(n[a]=!0,!(i==e.left&&i&&this.map[o-1]==a||r==e.top&&r&&this.map[o-this.width]==a)&&t.push(a))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){const o=i+n.child(r).nodeSize;if(r==e){let a=t+e*this.width;const s=(e+1)*this.width;for(;a<s&&this.map[a]<i;)a++;return a==s?o-1:this.map[a]}i=o}}static get(e){return n_(e)||r_(e,P8e(e))}};function P8e(e){if(e.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+e.type.name);const t=W8e(e),n=e.childCount,r=[];let i=0,o=null;const a=[];for(let c=0,u=t*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){const f=e.child(c);u++;for(let m=0;;m++){for(;i<r.length&&r[i]!=0;)i++;if(m==f.childCount)break;const g=f.child(m),{colspan:y,rowspan:C,colwidth:x}=g.attrs;for(let b=0;b<C;b++){if(b+c>=n){(o||(o=[])).push({type:"overlong_rowspan",pos:u,n:C-b});break}const v=i+b*t;for(let S=0;S<y;S++){r[v+S]==0?r[v+S]=u:(o||(o=[])).push({type:"collision",row:c,pos:u,n:y-S});const w=x&&x[S];if(w){const T=(v+S)%t*2,R=a[T];R==null||R!=w&&a[T+1]==1?(a[T]=w,a[T+1]=1):R==w&&a[T+1]++}}}i+=y,u+=g.nodeSize}const p=(c+1)*t;let h=0;for(;i<p;)r[i++]==0&&h++;h&&(o||(o=[])).push({type:"missing",row:c,n:h}),u++}(t===0||n===0)&&(o||(o=[])).push({type:"zero_sized"});const s=new gt(t,n,r,o);let l=!1;for(let c=0;!l&&c<a.length;c+=2)a[c]!=null&&a[c+1]<n&&(l=!0);return l&&N8e(s,a,e),s}function W8e(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){const i=e.child(r);let o=0;if(n)for(let a=0;a<r;a++){const s=e.child(a);for(let l=0;l<s.childCount;l++){const c=s.child(l);a+c.attrs.rowspan>r&&(o+=c.attrs.colspan)}}for(let a=0;a<i.childCount;a++){const s=i.child(a);o+=s.attrs.colspan,s.attrs.rowspan>1&&(n=!0)}t==-1?t=o:t!=o&&(t=Math.max(t,o))}return t}function N8e(e,t,n){e.problems||(e.problems=[]);const r={};for(let i=0;i<e.map.length;i++){const o=e.map[i];if(r[o])continue;r[o]=!0;const a=n.nodeAt(o);if(!a)throw new RangeError(`No cell with offset ${o} found`);let s=null;const l=a.attrs;for(let c=0;c<l.colspan;c++){const u=(i+c)%e.width,f=t[u*2];f!=null&&(!l.colwidth||l.colwidth[c]!=f)&&((s||(s=K8e(l)))[c]=f)}s&&e.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:s})}}function K8e(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function nr(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(const n in e.nodes){const r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var Ts=new qn("selectingCells");function mp(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return e.node(0).resolve(e.before(t+1));return null}function q8e(e){for(let t=e.depth;t>0;t--){const n=e.node(t).type.spec.tableRole;if(n==="cell"||n==="header_cell")return e.node(t)}return null}function mr(e){const t=e.selection.$head;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="row")return!0;return!1}function RC(e){const t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&t.node.type.spec.tableRole=="cell")return t.$anchor;const n=mp(t.$head)||V8e(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function V8e(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){const r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){const r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n-t.nodeSize)}}function i_(e){return e.parent.type.spec.tableRole=="row"&&!!e.nodeAfter}function z8e(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function ej(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function ZZ(e,t,n){const r=e.node(-1),i=gt.get(r),o=e.start(-1),a=i.nextCell(e.pos-o,t,n);return a==null?null:e.node(0).resolve(o+a)}function Oc(e,t,n=1){const r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function XZ(e,t,n=1){const r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<n;i++)r.colwidth.splice(t,0,0)}return r}function Q8e(e,t,n){const r=nr(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var ut=class ma extends Fe{constructor(t,n=t){const r=t.node(-1),i=gt.get(r),o=t.start(-1),a=i.rectBetween(t.pos-o,n.pos-o),s=t.node(0),l=i.cellsInRect(a).filter(u=>u!=n.pos-o);l.unshift(n.pos-o);const c=l.map(u=>{const f=r.nodeAt(u);if(!f)throw RangeError(`No cell with offset ${u} found`);const p=o+u+1;return new aG(s.resolve(p),s.resolve(p+f.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=t,this.$headCell=n}map(t,n){const r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(i_(r)&&i_(i)&&ej(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?ma.rowSelection(r,i):o&&this.isColSelection()?ma.colSelection(r,i):new ma(r,i)}return $e.between(r,i)}content(){const t=this.$anchorCell.node(-1),n=gt.get(t),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},a=[];for(let l=i.top;l<i.bottom;l++){const c=[];for(let u=l*n.width+i.left,f=i.left;f<i.right;f++,u++){const p=n.map[u];if(o[p])continue;o[p]=!0;const h=n.findCell(p);let m=t.nodeAt(p);if(!m)throw RangeError(`No cell with offset ${p} found`);const g=i.left-h.left,y=h.right-i.right;if(g>0||y>0){let C=m.attrs;if(g>0&&(C=Oc(C,0,g)),y>0&&(C=Oc(C,C.colspan-y,y)),h.left<i.left){if(m=m.type.createAndFill(C),!m)throw RangeError(`Could not create cell with attrs ${JSON.stringify(C)}`)}else m=m.type.create(C,m.content)}if(h.top<i.top||h.bottom>i.bottom){const C={...m.attrs,rowspan:Math.min(h.bottom,i.bottom)-Math.max(h.top,i.top)};h.top<i.top?m=m.type.createAndFill(C):m=m.type.create(C,m.content)}c.push(m)}a.push(t.child(l).copy(K.from(c)))}const s=this.isColSelection()&&this.isRowSelection()?t:a;return new q(K.from(s),1,1)}replace(t,n=q.empty){const r=t.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){const{$from:s,$to:l}=i[a],c=t.mapping.slice(r);t.replace(c.map(s.pos),c.map(l.pos),a?q.empty:n)}const o=Fe.findFrom(t.doc.resolve(t.mapping.slice(r).map(this.to)),-1);o&&t.setSelection(o)}replaceWith(t,n){this.replace(t,new q(K.from(n),0,0))}forEachCell(t){const n=this.$anchorCell.node(-1),r=gt.get(n),i=this.$anchorCell.start(-1),o=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let a=0;a<o.length;a++)t(n.nodeAt(o[a]),i+o[a])}isColSelection(){const t=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(t,n)>0)return!1;const r=t+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){const r=t.node(-1),i=gt.get(r),o=t.start(-1),a=i.findCell(t.pos-o),s=i.findCell(n.pos-o),l=t.node(0);return a.top<=s.top?(a.top>0&&(t=l.resolve(o+i.map[a.left])),s.bottom<i.height&&(n=l.resolve(o+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=l.resolve(o+i.map[s.left])),a.bottom<i.height&&(t=l.resolve(o+i.map[i.width*(i.height-1)+a.right-1]))),new ma(t,n)}isRowSelection(){const t=this.$anchorCell.node(-1),n=gt.get(t),r=this.$anchorCell.start(-1),i=n.colCount(this.$anchorCell.pos-r),o=n.colCount(this.$headCell.pos-r);if(Math.min(i,o)>0)return!1;const a=i+this.$anchorCell.nodeAfter.attrs.colspan,s=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,s)==n.width}eq(t){return t instanceof ma&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){const r=t.node(-1),i=gt.get(r),o=t.start(-1),a=i.findCell(t.pos-o),s=i.findCell(n.pos-o),l=t.node(0);return a.left<=s.left?(a.left>0&&(t=l.resolve(o+i.map[a.top*i.width])),s.right<i.width&&(n=l.resolve(o+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=l.resolve(o+i.map[s.top*i.width])),a.right<i.width&&(t=l.resolve(o+i.map[i.width*(a.top+1)-1]))),new ma(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new ma(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new ma(t.resolve(n),t.resolve(r))}getBookmark(){return new H8e(this.$anchorCell.pos,this.$headCell.pos)}};ut.prototype.visible=!1;Fe.jsonID("cell",ut);var H8e=class eX{constructor(t,n){this.anchor=t,this.head=n}map(t){return new eX(t.map(this.anchor),t.map(this.head))}resolve(t){const n=t.resolve(this.anchor),r=t.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&ej(n,r)?new ut(n,r):Fe.near(r,1)}};function Y8e(e){if(!(e.selection instanceof ut))return null;const t=[];return e.selection.forEachCell((n,r)=>{t.push(Jn.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Ot.create(e.doc,t)}function G8e({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let o=t.depth;o>=0&&!(t.before(o+1)>t.start(o));o--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function J8e({$from:e,$to:t}){let n,r;for(let i=e.depth;i>0;i--){const o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}for(let i=t.depth;i>0;i--){const o=t.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return n!==r&&t.parentOffset===0}function Z8e(e,t,n){const r=(t||e).selection,i=(t||e).doc;let o,a;if(r instanceof we&&(a=r.node.type.spec.tableRole)){if(a=="cell"||a=="header_cell")o=ut.create(i,r.from);else if(a=="row"){const s=i.resolve(r.from+1);o=ut.rowSelection(s,s)}else if(!n){const s=gt.get(r.node),l=r.from+1,c=l+s.map[s.width*s.height-1];o=ut.create(i,l+1,c)}}else r instanceof $e&&G8e(r)?o=$e.create(i,r.from):r instanceof $e&&J8e(r)&&(o=$e.create(i,r.$from.start(),r.$from.end()));return o&&(t||(t=e.tr)).setSelection(o),t}var X8e=new qn("fix-tables");function tX(e,t,n,r){const i=e.childCount,o=t.childCount;e:for(let a=0,s=0;a<o;a++){const l=t.child(a);for(let c=s,u=Math.min(i,a+3);c<u;c++)if(e.child(c)==l){s=c+1,n+=l.nodeSize;continue e}r(l,n),s<i&&e.child(s).sameMarkup(l)?tX(e.child(s),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function nX(e,t){let n;const r=(i,o)=>{i.type.spec.tableRole=="table"&&(n=eqe(e,i,o,n))};return t?t.doc!=e.doc&&tX(t.doc,e.doc,0,r):e.doc.descendants(r),n}function eqe(e,t,n,r){const i=gt.get(t);if(!i.problems)return r;r||(r=e.tr);const o=[];for(let l=0;l<i.height;l++)o.push(0);for(let l=0;l<i.problems.length;l++){const c=i.problems[l];if(c.type=="collision"){const u=t.nodeAt(c.pos);if(!u)continue;const f=u.attrs;for(let p=0;p<f.rowspan;p++)o[c.row+p]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Oc(f,f.colspan-c.n,c.n))}else if(c.type=="missing")o[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=t.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=t.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(n);r.delete(u,u+t.nodeSize)}}let a,s;for(let l=0;l<o.length;l++)o[l]&&(a==null&&(a=l),s=l);for(let l=0,c=n+1;l<i.height;l++){const u=t.child(l),f=c+u.nodeSize,p=o[l];if(p>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);const m=[];for(let y=0;y<p;y++){const C=nr(e.schema)[h].createAndFill();C&&m.push(C)}const g=(l==0||a==l-1)&&s==l?c+1:f-1;r.insert(r.mapping.map(g),m)}c=f}return r.setMeta(X8e,{fixTables:!0})}function Ur(e){const t=e.selection,n=RC(e),r=n.node(-1),i=n.start(-1),o=gt.get(r);return{...t instanceof ut?o.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):o.findCell(n.pos-i),tableStart:i,map:o,table:r}}function tj(e,{map:t,tableStart:n,table:r},i){let o=i>0?-1:0;Q8e(t,r,i+o)&&(o=i==0||i==t.width?null:0);for(let a=0;a<t.height;a++){const s=a*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){const l=t.map[s],c=r.nodeAt(l);e.setNodeMarkup(e.mapping.map(n+l),null,XZ(c.attrs,i-t.colCount(l))),a+=c.attrs.rowspan-1}else{const l=o==null?nr(r.type.schema).cell:r.nodeAt(t.map[s+o]).type,c=t.positionAt(a,i,r);e.insert(e.mapping.map(n+c),l.createAndFill())}}return e}function tqe(e,t){if(!mr(e))return!1;if(t){const n=Ur(e);t(tj(e.tr,n,n.left))}return!0}function nqe(e,t){if(!mr(e))return!1;if(t){const n=Ur(e);t(tj(e.tr,n,n.right))}return!0}function rqe(e,{map:t,table:n,tableStart:r},i){const o=e.mapping.maps.length;for(let a=0;a<t.height;){const s=a*t.width+i,l=t.map[s],c=n.nodeAt(l),u=c.attrs;if(i>0&&t.map[s-1]==l||i<t.width-1&&t.map[s+1]==l)e.setNodeMarkup(e.mapping.slice(o).map(r+l),null,Oc(u,i-t.colCount(l)));else{const f=e.mapping.slice(o).map(r+l);e.delete(f,f+c.nodeSize)}a+=u.rowspan}}function iqe(e,t){if(!mr(e))return!1;if(t){const n=Ur(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;rqe(r,n,i),i!=n.left;i--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw RangeError("No table found");n.table=o,n.map=gt.get(o)}t(r)}return!0}function oqe(e,t,n){var r;const i=nr(t.type.schema).header_cell;for(let o=0;o<e.width;o++)if(((r=t.nodeAt(e.map[o+n*e.width]))==null?void 0:r.type)!=i)return!1;return!0}function nj(e,{map:t,tableStart:n,table:r},i){var o;let a=n;for(let c=0;c<i;c++)a+=r.child(c).nodeSize;const s=[];let l=i>0?-1:0;oqe(t,r,i+l)&&(l=i==0||i==t.height?null:0);for(let c=0,u=t.width*i;c<t.width;c++,u++)if(i>0&&i<t.height&&t.map[u]==t.map[u-t.width]){const f=t.map[u],p=r.nodeAt(f).attrs;e.setNodeMarkup(n+f,null,{...p,rowspan:p.rowspan+1}),c+=p.colspan-1}else{const f=l==null?nr(r.type.schema).cell:(o=r.nodeAt(t.map[u+l*t.width]))==null?void 0:o.type,p=f==null?void 0:f.createAndFill();p&&s.push(p)}return e.insert(a,nr(r.type.schema).row.create(null,s)),e}function aqe(e,t){if(!mr(e))return!1;if(t){const n=Ur(e);t(nj(e.tr,n,n.top))}return!0}function sqe(e,t){if(!mr(e))return!1;if(t){const n=Ur(e);t(nj(e.tr,n,n.bottom))}return!0}function lqe(e,{map:t,table:n,tableStart:r},i){let o=0;for(let c=0;c<i;c++)o+=n.child(c).nodeSize;const a=o+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(o+r,a+r);const l=new Set;for(let c=0,u=i*t.width;c<t.width;c++,u++){const f=t.map[u];if(!l.has(f)){if(l.add(f),i>0&&f==t.map[u-t.width]){const p=n.nodeAt(f).attrs;e.setNodeMarkup(e.mapping.slice(s).map(f+r),null,{...p,rowspan:p.rowspan-1}),c+=p.colspan-1}else if(i<t.height&&f==t.map[u+t.width]){const p=n.nodeAt(f),h=p.attrs,m=p.type.create({...h,rowspan:p.attrs.rowspan-1},p.content),g=t.positionAt(i+1,c,n);e.insert(e.mapping.slice(s).map(r+g),m),c+=h.colspan-1}}}}function cqe(e,t){if(!mr(e))return!1;if(t){const n=Ur(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;lqe(r,n,i),i!=n.top;i--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw RangeError("No table found");n.table=o,n.map=gt.get(n.table)}t(r)}return!0}function zD(e){const t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function uqe({width:e,height:t,map:n},r){let i=r.top*e+r.left,o=i,a=(r.bottom-1)*e+r.left,s=i+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&n[o]==n[o-1]||r.right<e&&n[s]==n[s+1])return!0;o+=e,s+=e}for(let l=r.left;l<r.right;l++){if(r.top>0&&n[i]==n[i-e]||r.bottom<t&&n[a]==n[a+e])return!0;i++,a++}return!1}function QD(e,t){const n=e.selection;if(!(n instanceof ut)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Ur(e),{map:i}=r;if(uqe(i,r))return!1;if(t){const o=e.tr,a={};let s=K.empty,l,c;for(let u=r.top;u<r.bottom;u++)for(let f=r.left;f<r.right;f++){const p=i.map[u*i.width+f],h=r.table.nodeAt(p);if(!(a[p]||!h))if(a[p]=!0,l==null)l=p,c=h;else{zD(h)||(s=s.append(h.content));const m=o.mapping.map(p+r.tableStart);o.delete(m,m+h.nodeSize)}}if(l==null||c==null)return!0;if(o.setNodeMarkup(l+r.tableStart,null,{...XZ(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),s.size){const u=l+1+c.content.size,f=zD(c)?l+1:u;o.replaceWith(f+r.tableStart,u+r.tableStart,s)}o.setSelection(new ut(o.doc.resolve(l+r.tableStart))),t(o)}return!0}function HD(e,t){const n=nr(e.schema);return dqe(({node:r})=>n[r.type.spec.tableRole])(e,t)}function dqe(e){return(t,n)=>{var r;const i=t.selection;let o,a;if(i instanceof ut){if(i.$anchorCell.pos!=i.$headCell.pos)return!1;o=i.$anchorCell.nodeAfter,a=i.$anchorCell.pos}else{if(o=q8e(i.$from),!o)return!1;a=(r=mp(i.$from))==null?void 0:r.pos}if(o==null||a==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let s=o.attrs;const l=[],c=s.colwidth;s.rowspan>1&&(s={...s,rowspan:1}),s.colspan>1&&(s={...s,colspan:1});const u=Ur(t),f=t.tr;for(let h=0;h<u.right-u.left;h++)l.push(c?{...s,colwidth:c&&c[h]?[c[h]]:null}:s);let p;for(let h=u.top;h<u.bottom;h++){let m=u.map.positionAt(h,u.left,u.table);h==u.top&&(m+=o.nodeSize);for(let g=u.left,y=0;g<u.right;g++,y++)g==u.left&&h==u.top||f.insert(p=f.mapping.map(m+u.tableStart,1),e({node:o,row:h,col:g}).createAndFill(l[y]))}f.setNodeMarkup(a,e({node:o,row:u.top,col:u.left}),l[0]),i instanceof ut&&f.setSelection(new ut(f.doc.resolve(i.$anchorCell.pos),p?f.doc.resolve(p):void 0)),n(f)}return!0}}function fqe(e,t){return function(n,r){if(!mr(n))return!1;const i=RC(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){const o=n.tr;n.selection instanceof ut?n.selection.forEachCell((a,s)=>{a.attrs[e]!==t&&o.setNodeMarkup(s,null,{...a.attrs,[e]:t})}):o.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(o)}return!0}}function pqe(e){return function(t,n){if(!mr(t))return!1;if(n){const r=nr(t.schema),i=Ur(t),o=t.tr,a=i.map.cellsInRect(e=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=a.map(l=>i.table.nodeAt(l));for(let l=0;l<a.length;l++)s[l].type==r.header_cell&&o.setNodeMarkup(i.tableStart+a[l],r.cell,s[l].attrs);if(o.steps.length==0)for(let l=0;l<a.length;l++)o.setNodeMarkup(i.tableStart+a[l],r.header_cell,s[l].attrs);n(o)}return!0}}function YD(e,t,n){const r=t.map.cellsInRect({left:0,top:0,right:e=="row"?t.map.width:1,bottom:e=="column"?t.map.height:1});for(let i=0;i<r.length;i++){const o=t.table.nodeAt(r[i]);if(o&&o.type!==n.header_cell)return!1}return!0}function Gh(e,t){return t=t||{useDeprecatedLogic:!1},t.useDeprecatedLogic?pqe(e):function(n,r){if(!mr(n))return!1;if(r){const i=nr(n.schema),o=Ur(n),a=n.tr,s=YD("row",o,i),l=YD("column",o,i),u=(e==="column"?s:e==="row"?l:!1)?1:0,f=e=="column"?{left:0,top:u,right:1,bottom:o.map.height}:e=="row"?{left:u,top:0,right:o.map.width,bottom:1}:o,p=e=="column"?l?i.cell:i.header_cell:e=="row"?s?i.cell:i.header_cell:i.cell;o.map.cellsInRect(f).forEach(h=>{const m=h+o.tableStart,g=a.doc.nodeAt(m);g&&a.setNodeMarkup(m,p,g.attrs)}),r(a)}return!0}}Gh("row",{useDeprecatedLogic:!0});Gh("column",{useDeprecatedLogic:!0});var hqe=Gh("cell",{useDeprecatedLogic:!0});function Aqe(e,t){if(t<0){const n=e.nodeBefore;if(n)return e.pos-n.nodeSize;for(let r=e.index(-1)-1,i=e.before();r>=0;r--){const o=e.node(-1).child(r),a=o.lastChild;if(a)return i-1-a.nodeSize;i-=o.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;const n=e.node(-1);for(let r=e.indexAfter(-1),i=e.after();r<n.childCount;r++){const o=n.child(r);if(o.childCount)return i+1;i+=o.nodeSize}}return null}function GD(e){return function(t,n){if(!mr(t))return!1;const r=Aqe(RC(t),e);if(r==null)return!1;if(n){const i=t.doc.resolve(r);n(t.tr.setSelection($e.between(i,z8e(i))).scrollIntoView())}return!0}}function mqe(e,t){const n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Lg(e,t){const n=e.selection;if(!(n instanceof ut))return!1;if(t){const r=e.tr,i=nr(e.schema).cell.createAndFill().content;n.forEachCell((o,a)=>{o.content.eq(i)||r.replace(r.mapping.map(a+1),r.mapping.map(a+o.nodeSize-1),new q(i,0,0))}),r.docChanged&&t(r)}return!0}function gqe(e){if(!e.size)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole=="table");)n--,r--,t=t.child(0).content;const i=t.child(0),o=i.type.spec.tableRole,a=i.type.schema,s=[];if(o=="row")for(let l=0;l<t.childCount;l++){let c=t.child(l).content;const u=l?0:Math.max(0,n-1),f=l<t.childCount-1?0:Math.max(0,r-1);(u||f)&&(c=o_(nr(a).row,new q(c,u,f)).content),s.push(c)}else if(o=="cell"||o=="header_cell")s.push(n||r?o_(nr(a).row,new q(t,n,r)).content:t);else return null;return vqe(a,s)}function vqe(e,t){const n=[];for(let i=0;i<t.length;i++){const o=t[i];for(let a=o.childCount-1;a>=0;a--){const{rowspan:s,colspan:l}=o.child(a).attrs;for(let c=i;c<i+s;c++)n[c]=(n[c]||0)+l}}let r=0;for(let i=0;i<n.length;i++)r=Math.max(r,n[i]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(K.empty),n[i]<r){const o=nr(e).cell.createAndFill(),a=[];for(let s=n[i];s<r;s++)a.push(o);t[i]=t[i].append(K.from(a))}return{height:t.length,width:r,rows:t}}function o_(e,t){const n=e.createAndFill();return new B8e(n).replace(0,n.content.size,t).doc}function yqe({width:e,height:t,rows:n},r,i){if(e!=r){const o=[],a=[];for(let s=0;s<n.length;s++){const l=n[s],c=[];for(let u=o[s]||0,f=0;u<r;f++){let p=l.child(f%l.childCount);u+p.attrs.colspan>r&&(p=p.type.createChecked(Oc(p.attrs,p.attrs.colspan,u+p.attrs.colspan-r),p.content)),c.push(p),u+=p.attrs.colspan;for(let h=1;h<p.attrs.rowspan;h++)o[s+h]=(o[s+h]||0)+p.attrs.colspan}a.push(K.from(c))}n=a,e=r}if(t!=i){const o=[];for(let a=0,s=0;a<i;a++,s++){const l=[],c=n[s%t];for(let u=0;u<c.childCount;u++){let f=c.child(u);a+f.attrs.rowspan>i&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,i-f.attrs.rowspan)},f.content)),l.push(f)}o.push(K.from(l))}n=o,t=i}return{width:e,height:t,rows:n}}function bqe(e,t,n,r,i,o,a){const s=e.doc.type.schema,l=nr(s);let c,u;if(i>t.width)for(let f=0,p=0;f<t.height;f++){const h=n.child(f);p+=h.nodeSize;const m=[];let g;h.lastChild==null||h.lastChild.type==l.cell?g=c||(c=l.cell.createAndFill()):g=u||(u=l.header_cell.createAndFill());for(let y=t.width;y<i;y++)m.push(g);e.insert(e.mapping.slice(a).map(p-1+r),m)}if(o>t.height){const f=[];for(let m=0,g=(t.height-1)*t.width;m<Math.max(t.width,i);m++){const y=m>=t.width?!1:n.nodeAt(t.map[g+m]).type==l.header_cell;f.push(y?u||(u=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}const p=l.row.create(null,K.from(f)),h=[];for(let m=t.height;m<o;m++)h.push(p);e.insert(e.mapping.slice(a).map(r+n.nodeSize-2),h)}return!!(c||u)}function JD(e,t,n,r,i,o,a,s){if(a==0||a==t.height)return!1;let l=!1;for(let c=i;c<o;c++){const u=a*t.width+c,f=t.map[u];if(t.map[u-t.width]==f){l=!0;const p=n.nodeAt(f),{top:h,left:m}=t.findCell(f);e.setNodeMarkup(e.mapping.slice(s).map(f+r),null,{...p.attrs,rowspan:a-h}),e.insert(e.mapping.slice(s).map(t.positionAt(a,m,n)),p.type.createAndFill({...p.attrs,rowspan:h+p.attrs.rowspan-a})),c+=p.attrs.colspan-1}}return l}function ZD(e,t,n,r,i,o,a,s){if(a==0||a==t.width)return!1;let l=!1;for(let c=i;c<o;c++){const u=c*t.width+a,f=t.map[u];if(t.map[u-1]==f){l=!0;const p=n.nodeAt(f),h=t.colCount(f),m=e.mapping.slice(s).map(f+r);e.setNodeMarkup(m,null,Oc(p.attrs,a-h,p.attrs.colspan-(a-h))),e.insert(m+p.nodeSize,p.type.createAndFill(Oc(p.attrs,0,a-h))),c+=p.attrs.rowspan-1}}return l}function XD(e,t,n,r,i){let o=n?e.doc.nodeAt(n-1):e.doc;if(!o)throw new Error("No table found");let a=gt.get(o);const{top:s,left:l}=r,c=l+i.width,u=s+i.height,f=e.tr;let p=0;function h(){if(o=n?f.doc.nodeAt(n-1):f.doc,!o)throw new Error("No table found");a=gt.get(o),p=f.mapping.maps.length}bqe(f,a,o,n,c,u,p)&&h(),JD(f,a,o,n,l,c,s,p)&&h(),JD(f,a,o,n,l,c,u,p)&&h(),ZD(f,a,o,n,s,u,l,p)&&h(),ZD(f,a,o,n,s,u,c,p)&&h();for(let m=s;m<u;m++){const g=a.positionAt(m,l,o),y=a.positionAt(m,c,o);f.replace(f.mapping.slice(p).map(g+n),f.mapping.slice(p).map(y+n),new q(i.rows[m-s],0,0))}h(),f.setSelection(new ut(f.doc.resolve(n+a.positionAt(s,l,o)),f.doc.resolve(n+a.positionAt(u-1,c-1,o)))),t(f)}var Cqe=FG({ArrowLeft:Dg("horiz",-1),ArrowRight:Dg("horiz",1),ArrowUp:Dg("vert",-1),ArrowDown:Dg("vert",1),"Shift-ArrowLeft":Ug("horiz",-1),"Shift-ArrowRight":Ug("horiz",1),"Shift-ArrowUp":Ug("vert",-1),"Shift-ArrowDown":Ug("vert",1),Backspace:Lg,"Mod-Backspace":Lg,Delete:Lg,"Mod-Delete":Lg});function lv(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function Dg(e,t){return(n,r,i)=>{if(!i)return!1;const o=n.selection;if(o instanceof ut)return lv(n,r,Fe.near(o.$headCell,t));if(e!="horiz"&&!o.empty)return!1;const a=rX(i,e,t);if(a==null)return!1;if(e=="horiz")return lv(n,r,Fe.near(n.doc.resolve(o.head+t),t));{const s=n.doc.resolve(a),l=ZZ(s,e,t);let c;return l?c=Fe.near(l,1):t<0?c=Fe.near(n.doc.resolve(s.before(-1)),-1):c=Fe.near(n.doc.resolve(s.after(-1)),1),lv(n,r,c)}}}function Ug(e,t){return(n,r,i)=>{if(!i)return!1;const o=n.selection;let a;if(o instanceof ut)a=o;else{const l=rX(i,e,t);if(l==null)return!1;a=new ut(n.doc.resolve(l))}const s=ZZ(a.$headCell,e,t);return s?lv(n,r,new ut(a.$anchorCell,s)):!1}}function Sqe(e,t){const n=e.state.doc,r=mp(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new ut(r))),!0):!1}function wqe(e,t,n){if(!mr(e.state))return!1;let r=gqe(n);const i=e.state.selection;if(i instanceof ut){r||(r={width:1,height:1,rows:[K.from(o_(nr(e.state.schema).cell,n))]});const o=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),s=gt.get(o).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=yqe(r,s.right-s.left,s.bottom-s.top),XD(e.state,e.dispatch,a,s,r),!0}else if(r){const o=RC(e.state),a=o.start(-1);return XD(e.state,e.dispatch,a,gt.get(o.node(-1)).findCell(o.pos-a),r),!0}else return!1}function xqe(e,t){var n;if(t.ctrlKey||t.metaKey)return;const r=eU(e,t.target);let i;if(t.shiftKey&&e.state.selection instanceof ut)o(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&(i=mp(e.state.selection.$anchor))!=null&&((n=_w(e,t))==null?void 0:n.pos)!=i.pos)o(i,t),t.preventDefault();else if(!r)return;function o(l,c){let u=_w(e,c);const f=Ts.getState(e.state)==null;if(!u||!ej(l,u))if(f)u=l;else return;const p=new ut(l,u);if(f||!e.state.selection.eq(p)){const h=e.state.tr.setSelection(p);f&&h.setMeta(Ts,l.pos),e.dispatch(h)}}function a(){e.root.removeEventListener("mouseup",a),e.root.removeEventListener("dragstart",a),e.root.removeEventListener("mousemove",s),Ts.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(Ts,-1))}function s(l){const c=l,u=Ts.getState(e.state);let f;if(u!=null)f=e.state.doc.resolve(u);else if(eU(e,c.target)!=r&&(f=_w(e,t),!f))return a();f&&o(f,c)}e.root.addEventListener("mouseup",a),e.root.addEventListener("dragstart",a),e.root.addEventListener("mousemove",s)}function rX(e,t,n){if(!(e.state.selection instanceof $e))return null;const{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const s=r.before(i),l=t=="vert"?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(l)?s:null}}return null}function eU(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName=="TD"||t.nodeName=="TH")return t;return null}function _w(e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});return n&&n?mp(e.state.doc.resolve(n.pos)):null}var iX=class{constructor(t,n){this.node=t,this.defaultCellMinWidth=n,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",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),a_(t,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,a_(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function a_(e,t,n,r,i,o){var a;let s=0,l=!0,c=t.firstChild;const u=e.firstChild;if(u){for(let f=0,p=0;f<u.childCount;f++){const{colspan:h,colwidth:m}=u.child(f).attrs;for(let g=0;g<h;g++,p++){const y=i==p?o:m&&m[g],C=y?y+"px":"";if(s+=y||r,y||(l=!1),c)c.style.width!=C&&(c.style.width=C),c=c.nextSibling;else{const x=document.createElement("col");x.style.width=C,t.appendChild(x)}}}for(;c;){const f=c.nextSibling;(a=c.parentNode)==null||a.removeChild(c),c=f}l?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}var ri=new qn("tableColumnResizing");function oX({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=iX,lastColumnResizable:i=!0}={}){const o=new dn({key:ri,state:{init(a,s){var l,c;const u=(c=(l=o.spec)==null?void 0:l.props)==null?void 0:c.nodeViews,f=nr(s.schema).table.name;return r&&u&&(u[f]=(p,h)=>new r(p,n,h)),new _qe(-1,!1)},apply(a,s){return s.apply(a)}},props:{attributes:a=>{const s=ri.getState(a);return s&&s.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(a,s)=>{Tqe(a,s,e,i)},mouseleave:a=>{Iqe(a)},mousedown:(a,s)=>{Rqe(a,s,t,n)}},decorations:a=>{const s=ri.getState(a);if(s&&s.activeHandle>-1)return Mqe(a,s.activeHandle)},nodeViews:{}}});return o}var _qe=class cv{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(t){const n=this,r=t.getMeta(ri);if(r&&r.setHandle!=null)return new cv(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new cv(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let i=t.mapping.map(n.activeHandle,-1);return i_(t.doc.resolve(i))||(i=-1),new cv(i,n.dragging)}return n}};function Tqe(e,t,n,r){if(!e.editable)return;const i=ri.getState(e.state);if(i&&!i.dragging){const o=$qe(t.target);let a=-1;if(o){const{left:s,right:l}=o.getBoundingClientRect();t.clientX-s<=n?a=tU(e,t,"left",n):l-t.clientX<=n&&(a=tU(e,t,"right",n))}if(a!=i.activeHandle){if(!r&&a!==-1){const s=e.state.doc.resolve(a),l=s.node(-1),c=gt.get(l),u=s.start(-1);if(c.colCount(s.pos-u)+s.nodeAfter.attrs.colspan-1==c.width-1)return}aX(e,a)}}}function Iqe(e){if(!e.editable)return;const t=ri.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&aX(e,-1)}function Rqe(e,t,n,r){var i;if(!e.editable)return!1;const o=(i=e.dom.ownerDocument.defaultView)!=null?i:window,a=ri.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;const s=e.state.doc.nodeAt(a.activeHandle),l=Eqe(e,a.activeHandle,s.attrs);e.dispatch(e.state.tr.setMeta(ri,{setDragging:{startX:t.clientX,startWidth:l}}));function c(f){o.removeEventListener("mouseup",c),o.removeEventListener("mousemove",u);const p=ri.getState(e.state);p!=null&&p.dragging&&(kqe(e,p.activeHandle,nU(p.dragging,f,n)),e.dispatch(e.state.tr.setMeta(ri,{setDragging:null})))}function u(f){if(!f.which)return c(f);const p=ri.getState(e.state);if(p&&p.dragging){const h=nU(p.dragging,f,n);rU(e,p.activeHandle,h,r)}}return rU(e,a.activeHandle,l,r),o.addEventListener("mouseup",c),o.addEventListener("mousemove",u),t.preventDefault(),!0}function Eqe(e,t,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const o=e.domAtPos(t);let s=o.node.childNodes[o.offset].offsetWidth,l=n;if(r)for(let c=0;c<n;c++)r[c]&&(s-=r[c],l--);return s/l}function $qe(e){for(;e&&e.nodeName!="TD"&&e.nodeName!="TH";)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}function tU(e,t,n,r){const i=n=="right"?-r:r,o=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!o)return-1;const{pos:a}=o,s=mp(e.state.doc.resolve(a));if(!s)return-1;if(n=="right")return s.pos;const l=gt.get(s.node(-1)),c=s.start(-1),u=l.map.indexOf(s.pos-c);return u%l.width==0?-1:c+l.map[u-1]}function nU(e,t,n){const r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function aX(e,t){e.dispatch(e.state.tr.setMeta(ri,{setHandle:t}))}function kqe(e,t,n){const r=e.state.doc.resolve(t),i=r.node(-1),o=gt.get(i),a=r.start(-1),s=o.colCount(r.pos-a)+r.nodeAfter.attrs.colspan-1,l=e.state.tr;for(let c=0;c<o.height;c++){const u=c*o.width+s;if(c&&o.map[u]==o.map[u-o.width])continue;const f=o.map[u],p=i.nodeAt(f).attrs,h=p.colspan==1?0:s-o.colCount(f);if(p.colwidth&&p.colwidth[h]==n)continue;const m=p.colwidth?p.colwidth.slice():Oqe(p.colspan);m[h]=n,l.setNodeMarkup(a+f,null,{...p,colwidth:m})}l.docChanged&&e.dispatch(l)}function rU(e,t,n,r){const i=e.state.doc.resolve(t),o=i.node(-1),a=i.start(-1),s=gt.get(o).colCount(i.pos-a)+i.nodeAfter.attrs.colspan-1;let l=e.domAtPos(i.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&a_(o,l.firstChild,l,r,s,n)}function Oqe(e){return Array(e).fill(0)}function Mqe(e,t){var n;const r=[],i=e.doc.resolve(t),o=i.node(-1);if(!o)return Ot.empty;const a=gt.get(o),s=i.start(-1),l=a.colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1;for(let c=0;c<a.height;c++){const u=l+c*a.width;if((l==a.width-1||a.map[u]!=a.map[u+1])&&(c==0||a.map[u]!=a.map[u-a.width])){const f=a.map[u],p=s+f+o.nodeAt(f).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",(n=ri.getState(e))!=null&&n.dragging&&r.push(Jn.node(s+f,s+f+o.nodeAt(f).nodeSize,{class:"column-resize-dragging"})),r.push(Jn.widget(p,h))}}return Ot.create(e.doc,r)}function sX({allowTableNodeSelection:e=!1}={}){return new dn({key:Ts,state:{init(){return null},apply(t,n){const r=t.getMeta(Ts);if(r!=null)return r==-1?null:r;if(n==null||!t.docChanged)return n;const{deleted:i,pos:o}=t.mapping.mapResult(n);return i?null:o}},props:{decorations:Y8e,handleDOMEvents:{mousedown:xqe},createSelectionBetween(t){return Ts.getState(t.state)!=null?t.state.selection:null},handleTripleClick:Sqe,handleKeyDown:Cqe,handlePaste:wqe},appendTransaction(t,n,r){return Z8e(r,nX(r,n),e)}})}function s_(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function iU(e,t,n,r,i,o){var a;let s=0,l=!0,c=t.firstChild;const u=e.firstChild;if(u!==null)for(let f=0,p=0;f<u.childCount;f+=1){const{colspan:h,colwidth:m}=u.child(f).attrs;for(let g=0;g<h;g+=1,p+=1){const y=i===p?o:m&&m[g],C=y?`${y}px`:"";if(s+=y||r,y||(l=!1),c){if(c.style.width!==C){const[x,b]=s_(r,y);c.style.setProperty(x,b)}c=c.nextSibling}else{const x=document.createElement("col"),[b,v]=s_(r,y);x.style.setProperty(b,v),t.appendChild(x)}}}for(;c;){const f=c.nextSibling;(a=c.parentNode)===null||a===void 0||a.removeChild(c),c=f}l?(n.style.width=`${s}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${s}px`)}let Fqe=class{constructor(t,n){this.node=t,this.cellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),iU(t,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,iU(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){return t.type==="attributes"&&(t.target===this.table||this.colgroup.contains(t.target))}};function jqe(e,t,n,r){let i=0,o=!0;const a=[],s=e.firstChild;if(!s)return{};for(let f=0,p=0;f<s.childCount;f+=1){const{colspan:h,colwidth:m}=s.child(f).attrs;for(let g=0;g<h;g+=1,p+=1){const y=n===p?r:m&&m[g];i+=y||t,y||(o=!1);const[C,x]=s_(t,y);a.push(["col",{style:`${C}: ${x}`}])}}const l=o?`${i}px`:"",c=o?"":`${i}px`;return{colgroup:["colgroup",{},...a],tableWidth:l,tableMinWidth:c}}function oU(e,t){return t?e.createChecked(null,t):e.createAndFill()}function Lqe(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;const t={};return Object.keys(e.nodes).forEach(n=>{const r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function Dqe(e,t,n,r,i){const o=Lqe(e),a=[],s=[];for(let c=0;c<n;c+=1){const u=oU(o.cell,i);if(u&&s.push(u),r){const f=oU(o.header_cell,i);f&&a.push(f)}}const l=[];for(let c=0;c<t;c+=1)l.push(o.row.createChecked(null,r&&c===0?a:s));return o.table.createChecked(null,l)}function Uqe(e){return e instanceof ut}const Bg=({editor:e})=>{const{selection:t}=e.state;if(!Uqe(t))return!1;let n=0;const r=bJ(t.ranges[0].$from,o=>o.type.name==="table");return r==null||r.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(n+=1)}),n===t.ranges.length?(e.commands.deleteTable(),!0):!1},Bqe=gn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:Fqe,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:e,HTMLAttributes:t}){const{colgroup:n,tableWidth:r,tableMinWidth:i}=jqe(e,this.options.cellMinWidth);return["table",Ut(this.options.HTMLAttributes,t,{style:r?`width: ${r}`:`min-width: ${i}`}),n,["tbody",0]]},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:o})=>{const a=Dqe(o.schema,e,t,n);if(i){const s=r.selection.from+1;r.replaceSelectionWith(a).scrollIntoView().setSelection($e.near(r.doc.resolve(s)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>tqe(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>nqe(e,t),deleteColumn:()=>({state:e,dispatch:t})=>iqe(e,t),addRowBefore:()=>({state:e,dispatch:t})=>aqe(e,t),addRowAfter:()=>({state:e,dispatch:t})=>sqe(e,t),deleteRow:()=>({state:e,dispatch:t})=>cqe(e,t),deleteTable:()=>({state:e,dispatch:t})=>mqe(e,t),mergeCells:()=>({state:e,dispatch:t})=>QD(e,t),splitCell:()=>({state:e,dispatch:t})=>HD(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>Gh("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>Gh("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>hqe(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>QD(e,t)?!0:HD(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>fqe(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>GD(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>GD(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&nX(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){const r=ut.create(t.doc,e.anchorCell,e.headCell);t.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Bg,"Mod-Backspace":Bg,Delete:Bg,"Mod-Delete":Bg}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[oX({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],sX({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(e){const t={name:e.name,options:e.options,storage:e.storage};return{tableRole:Pe(ce(e,"tableRole",t))}}});function lX(e,t){switch(t.type){case"hyperlink":case"paragraph":case"strong":case"em":return jr.converter.fromPrismic(e)(t);default:return}}function cX(e){const{title:t,className:n,onClick:r,tabIndex:i,onMouseDown:o,...a}=e,s=document.createElement("button");return s.className=n,s.setAttribute("type","button"),s.setAttribute("title",t),s.setAttribute("aria-label",t),s.setAttribute("tabIndex","0"),o&&s.addEventListener("mousedown",l=>{const c=l.currentTarget;o(l,c)}),s.addEventListener("click",l=>{const c=l.currentTarget;r(l,c)}),Object.entries(a).forEach(([l,c])=>{s.setAttribute(l,c.toString())}),s}function uX(e){const t=document.createElement("div");return t.innerHTML=e,t.firstChild?t.firstChild:null}class qi extends CustomEvent{constructor({name:t,detail:n}){super(t,{detail:n})}static dispatch(t,n){const{editor:r,...i}=n;r.view.dom.dispatchEvent(new qi({name:t,detail:i}))}static listen(t,n){const{editor:r,callback:i}=n,o=new AbortController;return r.view.dom.addEventListener(t,a=>{const{detail:s}=a;s&&i(s)},{signal:o.signal}),()=>o.abort()}}const Pqe=50,Wqe=25;function EC(e,t){const n=e.nodes[t];if(!n)throw new Error(`Unwanted state: ${t} not found in schema.`);return n}function Ml(e){return ju(t=>t.type.spec.tableRole&&t.type.spec.tableRole==="table")(e)}function dX(e){return ju(t=>t.type.name==="tableRow")(e)}function Nqe(e){return ju(t=>t.type.name==="tableCell"||t.type.name==="tableHeader")(e)}const Kqe={cell:Nqe,row:dX,table:Ml};function rj(e,...t){const n={};for(let r=0;r<t.length;r++){const i=t[r];i&&(n[i]=Kqe[i](e))}return n}function fX(e){var n;const t=(n=Ml(e.state.selection))==null?void 0:n.node;return t&&t.firstChild&&t.type.name==="table"?t.firstChild.childCount:0}function pX(e){var n;const t=(n=Ml(e.state.selection))==null?void 0:n.node;return t&&t.type.name==="table"?t.childCount:0}function Tw(e){return fX(e)>=Wqe}function Iw(e){return pX(e)>=Pqe}function ij(e,t){const{index:n,tr:r}=t,i=Ml(r.selection);if(!i)return r;const o=gt.get(i.node),a=e==="row";if(n<0||n>=(a?o.height:o.width))return r;const s=a?0:n,l=a?n:0,c=a?o.width:n+1,u=a?n+1:o.height,f=o.map[l*o.width+s],p=o.map[(u-1)*o.width+(c-1)];if(!f||!p)return r;const h=i.start+f,m=i.start+p,g=r.doc.resolve(h),y=r.doc.resolve(m);return r.setSelection(new ut(y,g))}function qqe(e){return ij("row",e)}function Vqe(e){return ij("column",e)}function zqe(e){const{direction:t,state:n}=e,{map:r,table:i,tableStart:o,top:a}=Ur(n);if(t==="up"&&a===0||t==="down"&&a>=r.height-1)return;const{tr:s}=n,l=t==="up"?a-1:a+1;let c=o;for(let h=0;h<a;h++)c+=i.child(h).nodeSize;let u=o;for(let h=0;h<l;h++)u+=i.child(h).nodeSize;const f=i.child(a),p=i.child(l);switch(t){case"up":s.replaceWith(c,c+f.nodeSize,p),s.replaceWith(u,u+p.nodeSize,f);break;case"down":s.replaceWith(u,u+p.nodeSize,f),s.replaceWith(c,c+f.nodeSize,p);break}return{tr:s,index:l}}function Qqe(e){const{direction:t,state:n}=e,{map:r,table:i,left:o}=Ur(n);if(t==="left"&&o===0||t==="right"&&o>=r.width-1)return;const{tr:a}=n,s=t==="left"?o-1:o+1;for(let l=0;l<i.children.length;l++){const c=i.children[l];if(!c)return;const u=c.child(o),f=r.map[l*r.width+o];if(!f)return;const p=c.child(s),h=r.map[l*r.width+s];if(!h)return;switch(t){case"left":{a.replaceWith(f,f+u.nodeSize,p),a.replaceWith(h,h+p.nodeSize,u);break}case"right":{a.replaceWith(h,h+p.nodeSize,u),a.replaceWith(f,f+u.nodeSize,p);break}}}return{tr:a,index:s}}const hX="data-prismic-table-handle";function Hqe(e){return t=>{const n=Ml(t);if(n){const r=gt.get(n.node);return(Array.isArray(e)?e:Array.from([e])).reduce((o,a)=>{if(a>=0&&a<=r.width-1){const s=r.cellsInRect({left:a,right:a+1,top:0,bottom:r.height});return o.concat(s.flatMap(l=>{const c=n.node.nodeAt(l),u=l+n.start;return{pos:u,start:u+1,node:c}}))}return o},[])}return null}}function Yqe(e){return t=>{const n=Ml(t);if(n){const r=gt.get(n.node);return(Array.isArray(e)?e:Array.from([e])).reduce((o,a)=>{if(a>=0&&a<=r.height-1){const s=r.cellsInRect({left:0,right:r.width,top:a,bottom:a+1});return o.concat(s.map(l=>{const c=n.node.nodeAt(l),u=l+n.start;return{pos:u,start:u+1,node:c}}))}return o},[])}return null}}function aU(e){const{element:t,type:n}=e,r=t.querySelector(`[${hX}="${n}"]`);if(!r)throw new Error(`No ${n} handle found`);return r}function sU(e){const{type:t,editor:n,rowIndex:r,columnIndex:i}=e,o=cX({title:`Select ${t} & show options`,className:tZ(A.tableFieldStyles.tableHandle,A.tableFieldStyles[`table${Zn.capitalize(t)}Handle`]),[hX]:t,"aria-expanded":!1,onMouseDown:s=>{s.preventDefault(),s.stopImmediatePropagation();const l=t==="row"?r:i;n.view.dispatch(ij(t,{index:l,tr:n.state.tr}))},onClick:(s,l)=>{s.preventDefault(),s.stopImmediatePropagation(),qi.dispatch("handleClick",{type:t,editor:n,referenceElement:l})}}),a=uX(A.rawDragIndicatorIcon);return a&&o.appendChild(a),o}class Gqe{constructor(t){$t(this,"abortController",new AbortController);$t(this,"currentRowHandle",null);$t(this,"currentColumnHandle",null);$t(this,"showCurrentHandles",t=>{try{const n=t.target,r=t.currentTarget;Zqe(r),this.hidePreviousHandles();const i=lU("cell",n),o=this.getRowHandle(i),a=this.getColumnHandle(r,i);this.displayHandle(o),this.displayHandle(a),this.currentColumnHandle=a,this.currentRowHandle=o}catch{}});$t(this,"hidePreviousHandles",()=>{this.currentRowHandle&&this.hideHandle(this.currentRowHandle),this.currentColumnHandle&&this.hideHandle(this.currentColumnHandle)});this.view=t,this.update(this.view)}update(t){this.attachEventListeners(t.dom)}destroy(){this.abortController.abort()}attachEventListeners(t){this.abortController.signal.aborted||this.abortController.abort(),this.abortController=new AbortController;const{signal:n}=this.abortController;t.querySelectorAll("table").forEach(r=>{r.addEventListener("mouseover",this.showCurrentHandles,{signal:n}),r.addEventListener("mouseleave",this.hidePreviousHandles,{signal:n})})}getRowHandle(t){const n=lU("row",t),r=aU({element:n,type:"row"});if(!r)throw new Error("No row handle found");return r}getColumnHandle(t,n){const r=n.cellIndex+1,i=t.querySelector(`tr > th:nth-child(${r}), tr > td:nth-child(${r})`);if(!i)throw new Error("No header cell found");const o=aU({element:i,type:"column"});if(!o)throw new Error("No column handle found");return o}displayHandle(t){t.classList.add(A.tableFieldStyles.tableHandleVisible)}hideHandle(t){t.classList.remove(A.tableFieldStyles.tableHandleVisible)}}const Jqe={cell:["TD","TH"],row:["TR"]};function lU(e,t){const n=Jqe[e];for(const r of n){const i=t.closest(r);if(i)return i}throw new Error(`Failed to find closest ${e}`)}function Zqe(e){if(!e||e.tagName!=="TABLE")throw new Error("Element is not a table")}function Xqe(e){const{editor:t,name:n}=e;return new dn({key:new qn("tableCellHandles"),view:r=>new Gqe(r),state:{init:(r,i)=>cU({editor:t,name:n,state:i}),apply:(r,i,o,a)=>r.docChanged?cU({editor:t,name:n,state:a}):i.map(r.mapping,r.doc)},props:{decorations(r){return this.getState(r)}}})}function cU(e){const{editor:t,state:n}=e,r=[],i=Hqe(0)(n.selection);i&&i.forEach(({pos:a},s)=>{r.push(Jn.widget(a+1,()=>sU({type:"row",editor:t,columnIndex:0,rowIndex:s})))});const o=Yqe(0)(n.selection);return o&&o.forEach(({pos:a},s)=>{r.push(Jn.widget(a+1,()=>sU({type:"column",editor:t,columnIndex:s,rowIndex:0})))}),Ot.create(n.doc,r)}const e7e=gn.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:e}){return["td",Ut(this.options.HTMLAttributes,e),0]}}),oj=$.object({key:$.string().nullish(),colspan:$.number().nullish(),rowspan:$.number().nullish(),colwidth:$.array($.number()).nullish()}),AX=e7e.extend({name:"tableCell",addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),key:{default:null}}}}),uU={fromPrismic(e){return function(t){const n=EC(e,AX.name),r=t.columnWidth?[t.columnWidth]:null;return n.create({colspan:1,rowspan:1,colwidth:r,key:t.key},t.content.value.flatMap(i=>lX(e,i)??[]))}},toPrismic(e){const t=[];e.content.forEach(i=>{const o=jr.converter.toPrismic(i);ue.TextBlock.is(o)&&t.push(o)});const n=oj.parse(e.attrs),[r]=n.colwidth??[];return{key:n.key??crypto.randomUUID(),type:"tableCell",content:{__TYPE__:"StructuredTextContent",value:t},columnWidth:r}}},t7e=gn.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:e}){return["th",Ut(this.options.HTMLAttributes,e),0]}}),mX=t7e.extend({name:"tableHeader",addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),key:{default:null}}}}),dU={fromPrismic(e){return function(t){const n=EC(e,mX.name),r=t.columnWidth?[t.columnWidth]:null;return n.create({colspan:1,rowspan:1,colwidth:r,key:t.key},t.content.value.flatMap(i=>lX(e,i)??[]))}},toPrismic(e){const t=[];e.content.forEach(i=>{const o=jr.converter.toPrismic(i);ue.TextBlock.is(o)&&t.push(o)});const n=oj.parse(e.attrs),[r]=n.colwidth??[];return{key:n.key??crypto.randomUUID(),type:"tableHeader",content:{__TYPE__:"StructuredTextContent",value:t},columnWidth:r}}},gX=gn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",Ut(this.options.HTMLAttributes,e),0]}}),n7e=gX.extend({name:"tableRow",addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),key:{default:null}}}}),fU={fromPrismic(e){return function(t){return EC(e,gX.name).create({key:t.key},t.content.map(r=>{switch(r.type){case"tableHeader":return dU.fromPrismic(e)(r);case"tableCell":return uU.fromPrismic(e)(r)}}))}},toPrismic(e){const t=oj.parse(e.attrs),n=[];return e.content.forEach(r=>{switch(r.type.name){case"tableHeader":{n.push(dU.toPrismic(r));break}case"tableCell":{n.push(uU.toPrismic(r));break}}}),{key:t.key??crypto.randomUUID(),type:"tableRow",content:n}}};class r7e extends iX{constructor(t,n){const{node:r,editor:i}=t,{defaultCellMinWidth:o}=n;super(r,o);const a=document.createElement("div");a.classList.add(A.tableFieldStyles.tableWithControls);const s=document.createElement("div");s.classList.add(A.tableFieldStyles.tableOuterWrapper),s.appendChild(this.dom);const l=pU({editor:i,type:"column",onAfterCommand:()=>a.scrollLeft=a.scrollWidth});s.appendChild(l),a.appendChild(s);const c=pU({editor:i,type:"row"});a.appendChild(c),this.dom=a}ignoreMutation(t){return t.target.closest(`.${A.tableFieldStyles.tableOuterWrapper}`)?super.ignoreMutation(t):!0}}function pU(e){const{type:t,editor:n,onAfterCommand:r}=e,i=Zn.capitalize(t),o=cX({title:`Add ${t}`,className:A.tableFieldStyles[`addTable${i}Button`],onClick:()=>{n.commands[`add${i}ToEnd`](),r==null||r()}}),a=uX(A.rawAddIcon);return a&&o.appendChild(a),o}const Ay=Bqe.extend({name:"table",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),resizable:!0,defaultCellMinWidth:120}},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),addRowAfter:()=>t=>{var r,i,o;const{editor:n}=t;return Iw(n)?(qi.dispatch("addAtLimit",{editor:n,type:"row"}),!1):((o=(r=this.parent)==null?void 0:(i=r.call(this)).addRowAfter)==null?void 0:o.call(i)(t))??!1},addRowBefore:()=>t=>{var r,i,o;const{editor:n}=t;return Iw(n)?(qi.dispatch("addAtLimit",{editor:n,type:"row"}),!1):((o=(r=this.parent)==null?void 0:(i=r.call(this)).addRowBefore)==null?void 0:o.call(i)(t))??!1},addRowToEnd:()=>({dispatch:t,state:n,editor:r})=>{if(!mr(n))return!1;if(Iw(r))return qi.dispatch("addAtLimit",{editor:r,type:"row"}),!1;if(t){const i=Ur(n),o=i.map.height;t(nj(n.tr,i,o))}return!0},addColumnAfter:()=>t=>{var r,i,o;const{editor:n}=t;return Tw(n)?(qi.dispatch("addAtLimit",{editor:n,type:"column"}),!1):((o=(r=this.parent)==null?void 0:(i=r.call(this)).addColumnAfter)==null?void 0:o.call(i)(t))??!1},addColumnBefore:()=>t=>{var r,i,o;const{editor:n}=t;return Tw(n)?(qi.dispatch("addAtLimit",{editor:n,type:"column"}),!1):((o=(r=this.parent)==null?void 0:(i=r.call(this)).addColumnBefore)==null?void 0:o.call(i)(t))??!1},addColumnToEnd:()=>({dispatch:t,state:n,editor:r})=>{if(!mr(n))return!1;if(Tw(r))return qi.dispatch("addAtLimit",{editor:r,type:"column"}),!1;if(t){const i=Ur(n),o=i.map.width;t(tj(n.tr,i,o))}return!0},moveRow:t=>({dispatch:n,state:r})=>{if(!mr(r))return!1;if(n){i7e();const i=zqe({direction:t,state:r});if(!i)return!1;const o=qqe(i);n(o)}return!0},moveColumn:t=>({dispatch:n,state:r})=>{if(!mr(r))return!1;if(n){const i=Qqe({direction:t,state:r});if(!i)return!1;const o=Vqe(i);n(o)}return!0}}},addNodeView(){return e=>new r7e(e,this.options)},addKeyboardShortcuts(){var e;return{...(e=this.parent)==null?void 0:e.call(this),Backspace:()=>!1,"Mod-Backspace":()=>!1,Delete:()=>!1,"Mod-Delete":()=>!1}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[oX(this.options)]:[],sX(this.options),o7e(),Xqe({editor:this.editor,name:this.name})]}});function i7e(){if(!window.getSelection)return;const e=window.getSelection();e!=null&&e.empty?e.empty():e!=null&&e.removeAllRanges&&e.removeAllRanges()}function o7e(){return new dn({filterTransaction(e,t){for(const n of e.steps){const i=a7e(t,n.from);if(i&&i.type.name===Ay.name)return!1}return!0}})}function a7e(e,t){try{return e.doc.nodeAt(t)}catch{return null}}const s7e={fromPrismic(e){return function(t){return EC(e,Ay.name).create({},t.content.map(fU.fromPrismic(e)))}},toPrismic(e){var n;const t=((n=e.content.firstChild)==null?void 0:n.type.name)===Ay.name?e.content.firstChild:e;return{type:"table",content:Hs.children.map(t,r=>fU.toPrismic(r))}}},l7e=new c4e([lc.table],lc.table,[Ay,n7e,mX,AX],s7e),vX=[qF,GF,BZ],yX=[...vX,JF];function bX(e){return X6e(e)?[...vX,jr,l7e].filter(Hi.isDefined):[jr,fy,hy,Kl.build(e),TZ,RZ,FZ,...yX].filter(Hi.isDefined)}const CX=[{nodeType:fe.RichTextNodeType.paragraph,icon:"textFields",isActive:e=>e.isActive(jr.name)&&!e.isActive(fy.name)&&!e.isActive(hy.name),runCommands:Wt((e,t)=>e.clearNodes().setDirection(Ki(t))),shortText:"par",text:"Paragraph"},{nodeType:fe.RichTextNodeType.heading1,icon:"looks1",isActive:e=>e.isActive(Kl.name,{level:1}),runCommands:Wt((e,t)=>e.setHeading({level:1}).setDirection(Ki(t))),shortText:"h1",text:"Heading 1"},{nodeType:fe.RichTextNodeType.heading2,icon:"looks2",isActive:e=>e.isActive(Kl.name,{level:2}),runCommands:Wt((e,t)=>e.setHeading({level:2}).setDirection(Ki(t))),shortText:"h2",text:"Heading 2"},{nodeType:fe.RichTextNodeType.heading3,icon:"looks3",isActive:e=>e.isActive(Kl.name,{level:3}),runCommands:Wt((e,t)=>e.setHeading({level:3}).setDirection(Ki(t))),shortText:"h3",text:"Heading 3"},{nodeType:fe.RichTextNodeType.heading4,icon:"looks4",isActive:e=>e.isActive(Kl.name,{level:4}),runCommands:Wt((e,t)=>e.setHeading({level:4}).setDirection(Ki(t))),shortText:"h4",text:"Heading 4"},{nodeType:fe.RichTextNodeType.heading5,icon:"looks5",isActive:e=>e.isActive(Kl.name,{level:5}),runCommands:Wt((e,t)=>e.setHeading({level:5}).setDirection(Ki(t))),shortText:"h5",text:"Heading 5"},{nodeType:fe.RichTextNodeType.heading6,icon:"looks6",isActive:e=>e.isActive(Kl.name,{level:6}),runCommands:Wt((e,t)=>e.setHeading({level:6}).setDirection(Ki(t))),shortText:"h6",text:"Heading 6"},{nodeType:fe.RichTextNodeType.list,icon:"formatListBulleted",isActive:e=>e.isActive(fy.name),runCommands:Wt((e,t)=>e.toggleBulletList().setDirection(Ki(t))),shortText:"bull",text:"Bulleted list"},{nodeType:fe.RichTextNodeType.orderedList,icon:"formatListNumbered",isActive:e=>e.isActive(hy.name),runCommands:Wt((e,t)=>e.toggleOrderedList().setDirection(Ki(t))),shortText:"num",text:"Numbered list"},{nodeType:fe.RichTextNodeType.preformatted,icon:"dataObject",isActive:e=>e.isActive(TZ.name),runCommands:Wt((e,t)=>e.setCodeBlock().setDirection(Ki(t))),shortText:"code",text:"Code"},{nodeType:fe.RichTextNodeType.embed,icon:"cloud",isActive:e=>e.isActive(RZ.name),runCommands:Wt(e=>e.setEmbed()),shortText:"emb",text:"Embed"},{nodeType:fe.RichTextNodeType.image,icon:"image",isActive:e=>e.isActive(FZ.name),runCommands:Wt(e=>e.setImage()),shortText:"img",text:"Image"}],c7e=[{nodeType:fe.RichTextNodeType.strong,icon:"formatBold",isActive:e=>e.isActive(qF.name),runCommands:Wt(e=>e.toggleBold())},{nodeType:fe.RichTextNodeType.em,icon:"formatItalic",isActive:e=>e.isActive(GF.name),runCommands:Wt(e=>e.toggleItalic())}],u7e=[{nodeType:fe.RichTextNodeType.rtl,icon:"formatTextDirectionRToL",isActive:e=>e.isActive({[ya]:Jl}),runCommands:Wt((e,t)=>e.toggleDirection(Ki(t)))}];function Wt(e){return(t,n={})=>{let r=n.can===!0?t.can().chain():t.chain().focus();return n.deleteRange!==void 0&&(r=r.deleteRange(n.deleteRange)),n.can?d7e(t,r,e):e(r,t).run()}}function Ki(e){const t=e.state.selection.$from.parent.attrs;return Ea.parseNodeAttrsDirection(t)}function uv(e,t){return e.filter(n=>t.includes(n.nodeType))}function d7e(e,t,n){try{return n(t,e).run()}catch{return!1}}function f7e(e){const{items:t,editor:n}=e;return t.length===0?null:d.jsxs(d.Fragment,{children:[t.map(r=>d.jsx(A.ToolbarToggleButton,{disabled:!r.runCommands(n,{can:!0}),onPressedChange:()=>{r.runCommands(n)},pressed:r.isActive(n),startIcon:r.icon},r.nodeType)),d.jsx(A.ToolbarSeparator,{})]})}function p7e(e){const{labels:t,editor:n}=e,r=n.getAttributes("label").label;return d.jsxs(d.Fragment,{children:[d.jsxs(A.DropdownMenu,{children:[d.jsx(A.DropdownMenuTrigger,{disabled:t.length===0,children:d.jsx(A.Button,{endIcon:"arrowDropDown",size:"small",color:"grey",children:hU(r??"Labels")})}),d.jsx(A.DropdownMenuContent,{align:"start",asPortal:!1,maxHeight:256,avoidCollisions:!1,children:t.map((i,o)=>{const a=r===i;return d.jsx(A.DropdownMenuItem,{onSelect:()=>a?n.commands.unsetLabel():h7e(n,i),endIcon:a&&d.jsx(A.Icon,{name:"check",size:"extraSmall"}),children:hU(i)},`${i}-${o}`)})})]}),d.jsx(A.ToolbarSeparator,{})]})}function h7e(e,t){Wt(r=>r.setLabel({label:t}))(e)}function hU(e){return Zn.overflow(e,20)}function A7e(e){const{editor:t}=e,n=t.getAttributes("label");if(!n.label)return null;const r=n.label;return d.jsx(A.Box,{backgroundColor:"purple9",padding:{block:2,inline:4},alignItems:"center",borderRadius:{topLeft:2,topRight:2,bottomRight:2},maxWidth:125,children:d.jsx(A.Text,{color:"white",variant:"small",noWrap:!0,children:r})})}function m7e(e){const{disabled:t,showWebLinkModal:n,showDocumentsLinkModal:r,showMediaLinkModal:i}=g7e(e);return d.jsxs(d.Fragment,{children:[d.jsxs(A.ToolbarButtonGroup,{density:"compact",children:[d.jsx(A.ToolbarButton,{disabled:t,startIcon:"link",onClick:n},fe.RichTextNodeType.hyperlink),d.jsxs(A.DropdownMenu,{children:[d.jsx(A.DropdownMenuTrigger,{children:d.jsx(A.ToolbarButton,{startIcon:"arrowDropDown"})}),d.jsxs(A.DropdownMenuContent,{align:"end",asPortal:!1,children:[d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"public"}),onSelect:n,children:"Link to web page"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"description"}),onSelect:r,children:"Link to document"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"image"}),onSelect:i,children:"Link to media"})]})]})]}),d.jsx(A.ToolbarSeparator,{})]})}function g7e(e){const{editor:t,setModal:n}=e;function r(){n("webLink")}function i(){n("documentLink")}function o(){n("mediaLink")}return{disabled:!Wt(s=>s.setWebLink({href:""}))(t,{can:!0}),showWebLinkModal:r,showDocumentsLinkModal:i,showMediaLinkModal:o}}function v7e(e){const{docId:t,onEdit:n,onUnlink:r}=e,i=y7e(t),o=be();if(!i)return null;const a=i.versions[0],s=oF({status:a==null?void 0:a.status,releaseId:(a==null?void 0:a.status)==="release"?a.release_id:void 0,documentId:i.id,versionId:a==null?void 0:a.version_id,baseUrl:o.baseUrl}),l=(a==null?void 0:a.preview_summary)??"",c=(a==null?void 0:a.custom_type_label)??"";return d.jsx(xc,{url:s,title:i.title,subTitle:c,description:l,onEdit:n,onUnlink:r,largeIconName:"description"})}function y7e(e){const t=be();t.searchDocuments||At("searchDocuments");const{coreApiBaseUrl:n,authStrategy:r}=t;return Xe.useRequest(Qm,[n,r,e])}function b7e(e){const{editor:t}=e,{searchDocuments:n}=be(),r=t.getAttributes(fe.RichTextNodeType.hyperlink);if(r.id&&n){const i=r.id;return d.jsx(C7e,{docId:i,...e})}if(r.href){const i=r.href;return d.jsx(S7e,{url:i,...e})}if(r.media){const i=PZ(r.media);return d.jsx(w7e,{media:i,...e})}return null}function C7e(e){const{editor:t,onEditDocumentLink:n,docId:r}=e;return d.jsx(A.ErrorBoundary,{renderError:()=>d.jsx(xc,{title:"Failed to Load Linked Document Data",error:!0,onEdit:n,onUnlink:()=>uc(t)}),children:d.jsx(I.Suspense,{fallback:d.jsx(xc,{loading:!0,onEdit:n,onUnlink:()=>uc(t)}),children:d.jsx(v7e,{docId:r,onEdit:n,onUnlink:()=>uc(t)})})})}function S7e(e){const{url:t,editor:n,onEditWebLink:r}=e,i=ai.toURL(t);return i?d.jsx(xc,{url:t,title:ai.getUrlTitle(i),subTitle:t,onEdit:r,onUnlink:()=>uc(n)}):d.jsx(xc,{url:t,subTitle:t,onEdit:r,onUnlink:()=>uc(n)})}function w7e(e){const{media:t,editor:n,onEditMediaLink:r}=e;return ue.FilledImageLinkContent.is(t)?d.jsx(SY,{url:t.url,title:t.name,subTitle:`${t.width} x ${t.height} pixels`,onEdit:r,onUnlink:()=>uc(n)}):ue.FilledFileLinkContent.is(t)?d.jsx(xc,{url:t.url,title:t.name,subTitle:x7e({filename:t.name}),largeIconName:"insertDriveFile",onEdit:r,onUnlink:()=>uc(n)}):null}function uc(e){Wt(n=>n.unsetLink())(e)}function x7e(e){const{filename:t}=e,n=t.split(".").pop();return n?n.toLowerCase():""}function _7e(e){const{open:t}=e,{onOpenChange:n,onSelectDocument:r}=T7e(e);return d.jsx(vY,{open:t,onOpenChange:n,onSelectDocument:r})}function T7e(e){const{editor:t,setOpen:n}=e;function r(o){Wt(s=>s.extendMarkRange(fe.RichTextNodeType.hyperlink).setDocumentLink({id:o}))(t),n(!1)}function i(o){n(o)}return{onSelectDocument:r,onOpenChange:i}}function I7e(e){const{open:t}=e,{onOpenChange:n,onMediaSelected:r}=R7e(e);return d.jsx(uF,{open:t,onOpenChange:n,onMediaSelected:r,assetType:"all"})}function R7e(e){const{editor:t,setOpen:n}=e;function r(i){Wt(a=>a.extendMarkRange(fe.RichTextNodeType.hyperlink).setMediaLink({media:i}))(t),n(!1)}return{onMediaSelected:r,onOpenChange:n}}function E7e(e){const{open:t,setOpen:n}=e,{url:r,setUrl:i,openInNewTab:o,setOpenInNewTab:a,disabled:s,onUpdate:l}=$7e(e);return d.jsxs(A.Dialog,{open:t,onOpenChange:n,size:"small",noDescription:!0,children:[d.jsx(A.DialogHeader,{title:"Set Link URL"}),d.jsxs(A.DialogContent,{padding:16,children:[d.jsx(A.FormInput,{value:r,onValueChange:i,placeholder:"Paste URL",icon:"public"}),r&&d.jsx(A.InlineLabel,{value:"Open in new tab",children:d.jsx(A.Checkbox,{checked:o,onCheckedChange:a})})]}),d.jsxs(A.DialogActions,{children:[d.jsx(A.DialogCancelButton,{}),d.jsx(A.DialogActionButton,{onClick:l,disabled:s,children:"Update"})]})]})}function $7e(e){const{editor:t,open:n,setOpen:r}=e,i=k7e(t),[o,a]=I.useState(i.url),[s,l]=I.useState(i.openInNewTab);ze.useOnChange(n,()=>{n&&(a(i.url),l(i.openInNewTab))});const c=!o||o===i.url&&s===i.openInNewTab;function u(){const f=s?"_blank":"_self";Wt(p=>p.extendMarkRange(fe.RichTextNodeType.hyperlink).setWebLink({href:o,target:f}))(t),r(!1)}return{url:o,setUrl:a,openInNewTab:s,disabled:c,setOpenInNewTab:l,onUpdate:u}}function k7e(e){const t=e.getAttributes(fe.RichTextNodeType.hyperlink);return{url:t.href??"",openInNewTab:t.target==="_blank"}}function O7e(e){const{items:t,editor:n}=e;return t.length===0?null:d.jsxs(d.Fragment,{children:[d.jsx(A.ToolbarToggleButtonGroup,{onValueChange:r=>{t.forEach(i=>{(i.isActive(n)&&!r.includes(i.nodeType)||!i.isActive(n)&&r.includes(i.nodeType))&&i.runCommands(n)})},type:"multiple",value:t.filter(r=>r.isActive(n)).map(r=>r.nodeType),children:t.map(r=>d.jsx(A.ToolbarToggleButtonGroupItem,{disabled:!r.runCommands(n,{can:!0}),startIcon:r.icon,value:r.nodeType},r.nodeType))},"mark"),d.jsx(A.ToolbarSeparator,{})]})}function M7e(e){var r;const{items:t,editor:n}=e;return t.length===0?null:d.jsxs(d.Fragment,{children:[d.jsxs(A.DropdownMenu,{children:[d.jsx(A.DropdownMenuTrigger,{disabled:t.length===1,children:d.jsx(A.Button,{endIcon:"arrowDropDown",size:"small",color:"grey",children:((r=t.find(i=>i.isActive(n)))==null?void 0:r.text)??""})}),d.jsx(A.DropdownMenuContent,{align:"start",asPortal:!1,maxHeight:256,avoidCollisions:!1,children:t.map(i=>d.jsx(A.DropdownMenuItem,{onSelect:()=>{i.runCommands(n)},children:i.text},i.nodeType))})]}),d.jsx(A.ToolbarSeparator,{})]})}function Rw(e){return{duration:100,hideOnClick:!0,offset:e,placement:"top-start",appendTo:document.querySelector("body > div")??"parent"}}function F7e(e){const{editor:t,nodeTypes:n,labels:r,hideDisabledOptions:i=!1}=e,[o,a]=I.useState(),s=n.includes(fe.RichTextNodeType.hyperlink),l=!o,{shouldShowBubbleMenu:c,shouldshowPopover:u}=L7e({editor:t}),[f,p]=I.useState(!0);I.useEffect(()=>{p(!1)},[]);function h(y){a(y?"webLink":void 0)}function m(y){a(y?"documentLink":void 0)}function g(y){a(y?"mediaLink":void 0)}return f?null:d.jsxs(d.Fragment,{children:[d.jsx(fw,{editor:t,tippyOptions:Rw([-48,0]),shouldShow:c,children:l&&d.jsx(j7e,{editor:t,nodeTypes:n,labels:r,setModal:a,hideDisabledOptions:i})}),d.jsx(fw,{editor:t,tippyOptions:Rw([-48,0]),shouldShow:y=>u(y,"hyperlink"),children:l&&d.jsx(b7e,{editor:t,onEditWebLink:()=>a("webLink"),onEditDocumentLink:()=>a("documentLink"),onEditMediaLink:()=>a("mediaLink")})}),d.jsx(fw,{editor:t,tippyOptions:Rw([0,0]),shouldShow:y=>u(y,"label"),children:d.jsx(A7e,{editor:t})}),s&&d.jsxs(d.Fragment,{children:[d.jsx(E7e,{open:o==="webLink",setOpen:h,editor:t}),d.jsx(_7e,{open:o==="documentLink",setOpen:m,editor:t}),d.jsx(I7e,{open:o==="mediaLink",setOpen:g,editor:t})]})]})}function j7e(e){const{editor:t,nodeTypes:n,labels:r,setModal:i,hideDisabledOptions:o}=e,a=n.includes("hyperlink"),s=r.length>0,l=uv(CX,n),c=uv(c7e,n),u=uv(u7e,n),f=o&&l.length===1?0:l.length,p=f+c.length+u.length+Number(a);return p===0?null:d.jsxs(A.Toolbar,{children:[f>0&&d.jsx(M7e,{items:l,editor:t}),s&&d.jsx(p7e,{labels:r,editor:t}),d.jsx(O7e,{items:c,editor:t}),a&&d.jsx(m7e,{editor:t,setModal:i}),d.jsx(f7e,{items:u,editor:t}),p>1&&d.jsx(A.ToolbarButton,{onClick:()=>{t.chain().focus().clearNodes().unsetAllMarks().run()},startIcon:"formatClear"},"clear")]})}function L7e(e){const{editor:t}=e;function n(i){const{view:o,state:a,from:s,to:l}=i;if(!o.hasFocus())return!1;const{doc:c,selection:u}=a;return!(t.isActive(fe.RichTextNodeType.preformatted)||u.empty||c.textBetween(s,l).length===0)}function r(i,o){const{view:a,state:s,from:l,to:c}=i,u=a.state.doc.nodeAt(l),{doc:f,selection:p}=s;return!p.empty||f.textBetween(l,c).length>0?!1:!!(u!=null&&u.marks.some(m=>m.type.name===o))}return{shouldShowBubbleMenu:n,shouldshowPopover:r}}const D7e=["id","data-state","aria-expanded","aria-controls","aria-haspopup"],SX=I.forwardRef(function(t,n){const{anchorElement:r,...i}=t;I.useEffect(()=>{if(r)for(const[a,s]of Object.entries(i))U7e(a,s)&&B7e(r,a,s)},[i,r]);function o(){!r||typeof n!="function"||n(r)}return d.jsx("div",{ref:o,style:{display:"none"}})});function U7e(e,t){return D7e.includes(e)?typeof t=="boolean"||typeof t=="number"||typeof t=="string":!1}function B7e(e,t,n){n!=null&&n!==""?e.setAttribute(t,n.toString()):e.removeAttribute(t)}function P7e(e){const{table:t,row:n}=rj(e.state.selection,"table","row");return!t||!n?{isFirstRow:!1,isLastRow:!1}:{isFirstRow:t.node.firstChild===n.node,isLastRow:t.node.lastChild===n.node}}function W7e(e){const{table:t,row:n}=rj(e.state.selection,"table","row");return!t||!n?!1:t.node.child(1)===n.node}const wX=e=>{var r;const t=(r=Ml(e.state.selection))==null?void 0:r.node;if(!t||t.type.name!=="table")return!1;const n=t.firstChild;if(!n||n.type.name!=="tableRow")return!1;for(let i=0;i<n.childCount;i++){const o=n.child(i);if((o==null?void 0:o.type.name)!=="tableHeader")return!1}return!0},N7e=e=>pX(e)===1;function K7e(e){const{table:t,cell:n}=rj(e.state.selection,"table","cell");return!t||!n?!1:t.node.child(0).child(1)===n.node}function q7e(e){var r;const t=(r=dX(e.state.selection))==null?void 0:r.node,n=e.state.selection.$from.index(-1);return t?{isFirstColumn:n===0,isLastColumn:n===t.childCount-1}:{isFirstColumn:!1,isLastColumn:!1}}const xX=e=>{var n;const t=(n=Ml(e.state.selection))==null?void 0:n.node;if(!t||t.type.name!=="table")return!1;for(let r=0;r<t.childCount;r++){const o=t.child(r).firstChild;if((o==null?void 0:o.type.name)!=="tableHeader")return!1}return!0},V7e=e=>fX(e)===1;function z7e(e){const{editor:t,open:n,onOpenChange:r,triggerElement:i}=e,o=xX(t),a=V7e(t),s=q7e(t);function l(){const m=wX(t);t.commands.deleteColumn(),r==null||r(!1),a&&o&&(c(),m||t.commands.toggleHeaderRow())}function c(){t.commands.toggleHeaderColumn()}function u(){o&&s.isFirstColumn?t.chain().toggleHeaderColumn().addColumnBefore().toggleHeaderColumn().run():t.commands.addColumnBefore(),r==null||r(!1)}function f(){t.commands.addColumnAfter(),r==null||r(!1)}function p(){const m=o&&K7e(t),g=t.chain();m?g.toggleHeaderColumn().moveColumn("left").toggleHeaderColumn():g.moveColumn("left"),g.run(),r==null||r(!1)}function h(){const m=o&&s.isFirstColumn,g=t.chain();m?g.toggleHeaderColumn().moveColumn("right").toggleHeaderColumn():g.moveColumn("right"),g.run(),r==null||r(!1)}return d.jsxs(A.DropdownMenu,{open:n,onOpenChange:r,modal:!0,children:[d.jsx(A.DropdownMenuTrigger,{children:d.jsx(SX,{anchorElement:i})}),d.jsxs(A.DropdownMenuContent,{align:"start",side:"right",sideOffset:4,children:[d.jsx(A.DropdownMenuLabel,{children:d.jsx(A.Text,{color:"grey11",variant:"small",children:"Column options"})}),s.isFirstColumn&&d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"viewDay"}),onSelect:c,disabled:a,children:d.jsxs(A.Box,{gap:12,alignItems:"center",children:["Header Column",d.jsx(A.Switch,{size:"extraSmall",checked:o})]})}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"arrowBack"}),onSelect:u,children:"Insert Left"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"arrowForward"}),onSelect:f,children:"Insert Right"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"moveLeft"}),onSelect:p,disabled:s.isFirstColumn,children:"Move Left"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"moveRight"}),onSelect:h,disabled:s.isLastColumn,children:"Move Right"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"delete"}),onSelect:l,disabled:a,children:"Delete Column"})]})]})}function Q7e(e){const{editor:t,open:n,onOpenChange:r,triggerElement:i}=e,o=wX(t),a=N7e(t),s=P7e(t);function l(){const m=xX(t);t.commands.deleteRow(),r==null||r(!1),a&&o&&(c(),m||t.commands.toggleHeaderColumn())}function c(){t.commands.toggleHeaderRow()}function u(){o&&s.isFirstRow?t.chain().toggleHeaderRow().addRowBefore().toggleHeaderRow().run():t.commands.addRowBefore(),r==null||r(!1)}function f(){t.commands.addRowAfter(),r==null||r(!1)}function p(){const m=o&&W7e(t),g=t.chain();m?g.toggleHeaderRow().moveRow("up").toggleHeaderRow():g.moveRow("up"),g.run(),r==null||r(!1)}function h(){const m=o&&s.isFirstRow,g=t.chain();m?g.toggleHeaderRow().moveRow("down").toggleHeaderRow():g.moveRow("down"),g.run(),r==null||r(!1)}return d.jsxs(A.DropdownMenu,{open:n,onOpenChange:r,modal:!0,children:[d.jsx(A.DropdownMenuTrigger,{children:d.jsx(SX,{anchorElement:i})}),d.jsxs(A.DropdownMenuContent,{align:"start",side:"right",sideOffset:4,children:[d.jsx(A.DropdownMenuLabel,{children:d.jsx(A.Text,{color:"grey11",variant:"small",children:"Row options"})}),s.isFirstRow&&d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"viewDay"}),onSelect:c,disabled:a,children:d.jsxs(A.Box,{gap:12,alignItems:"center",children:[d.jsx(A.Text,{noWrap:!0,children:"Header row"}),d.jsx(A.Switch,{size:"extraSmall",checked:o})]})}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"arrowUpward"}),onSelect:u,children:"Insert Above"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"arrowDownward"}),onSelect:f,children:"Insert Below"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"moveUp"}),onSelect:p,disabled:s.isFirstRow,children:"Move Up"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"moveDown"}),onSelect:h,disabled:s.isLastRow,children:"Move Down"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"delete"}),onSelect:l,disabled:a,children:"Delete Row"})]})]})}function H7e(e){return d.jsxs(d.Fragment,{children:[d.jsx(Y7e,{...e}),d.jsx(G7e,{...e})]})}function Y7e(e){const{editor:t}=e,{triggerElement:n,open:r,onOpenChange:i}=_X("row",t);return d.jsx(Q7e,{open:r,editor:t,triggerElement:n,onOpenChange:i})}function G7e(e){const{editor:t}=e,{triggerElement:n,open:r,onOpenChange:i}=_X("column",t);return d.jsx(z7e,{open:r,editor:t,triggerElement:n,onOpenChange:i})}function _X(e,t){const[n,r]=I.useState(),[i,o]=I.useState(!1);return I.useEffect(()=>qi.listen("handleClick",{editor:t,callback:a=>{a.type===e&&(r(a.referenceElement),setTimeout(()=>o(!0),0))}}),[t,e]),{open:i,onOpenChange:o,triggerElement:n}}function J7e(e){const{editor:t}=e,{open:n,onOpenChange:r}=Z7e(t);return d.jsx(A.Toast,{title:"You've reached the limit (50 rows / 25 columns).",action:{title:"Need more?",onClick:()=>window.open("https://community.prismic.io/t/how-should-the-table-field-evolve-your-call/18542","_blank")},open:n,onOpenChange:r,anchor:d.jsx(A.Box,{position:"fixed",left:0,right:0,bottom:72}),cancel:{onClick:()=>r(!1)}})}function Z7e(e){const[t,n]=I.useState(!1),{onAnalyticsEvent:r}=be();return I.useEffect(()=>qi.listen("addAtLimit",{editor:e,callback:i=>{r==null||r("Table Limit Reached",{type:i.type}),n(!0)}}),[e,r]),{open:t,onOpenChange:n}}function TX(e){const{content:t,field:n,id:r,readOnly:i,padding:o="normal",scroll:a="hidden",shouldReturnEmptyContent:s=!1}=e,l=X7e(n),c=t&&Wx.converter(l.nodeExtensions).fromPrismic(l.schema,l.nodeTypes,t),u=ze.useStableCallback(e.onContentChange),f=A.useEditor({content:c==null?void 0:c.toJSON(),editable:!i,editorProps:{attributes:{class:tZ(o==="zero"?A.contentEditableNoPaddingClass:A.contentEditableClass,A.contentEditableMultilinePlaceholderClass),id:r,tabIndex:"0"}},extensions:l.allComponents,injectCSS:!1,onUpdate({editor:p}){if(p.isEmpty&&!s)return u(void 0);const h=Wx.converter(l.nodeExtensions).toPrismic(p.state.doc);u(h)}},[l,i]);return d.jsxs(A.Field,{display:a==="x-auto"?"grid":"flex",children:[d.jsx(A.FieldLabel,{htmlFor:r,children:Tr(n)}),d.jsxs(A.FieldControl,{children:[f.isEditable&&d.jsx(F7e,{editor:f,nodeTypes:l.names,labels:l.labels,hideDisabledOptions:!0}),f.isEditable&&l.names.includes("table")&&d.jsxs(d.Fragment,{children:[d.jsx(H7e,{editor:f}),d.jsx(J7e,{editor:f})]}),d.jsx(q6e,{editor:f,style:{width:"100%"}})]})]})}function X7e(e){var n,r;const t=`${((n=e.config)==null?void 0:n.multi)??""}-${((r=e.config)==null?void 0:r.single)??""}`;return I.useMemo(()=>{var m;const{extensions:i,nodeTypes:o}=d4e(e.config),a=i.filter(eVe),s=i.flatMap(g=>g.richTextNodeTypes);o.has(xD)&&s.push(xD);const l=i.flatMap(g=>g.component),c=i.filter(tVe).map(g=>g.name),u=[...l,...j9e(e,a),V4e.configure({supportedExtensionNames:c}),n5e,G3e],f=u.map(g=>g.name),p=f3e(u),h=nVe((m=e.config)==null?void 0:m.labels);return{allComponents:u,extensionNames:f,nodeTypes:o,nodeExtensions:a,names:s,schema:p,labels:h}},[t])}function eVe(e){return e.extType===Lu.Node}function tVe(e){return!(e.extType!==Lu.Node||e.nodeType!==Gl.Text||e.lockedFormat)}function nVe(e){return Array.from(e??[])}function rVe(e){const{content:t,field:n,id:r,readOnly:i,onContentChange:o}=e,{placeholder:a,options:s}=n.config??{},l=!!(s!=null&&s.includes("")),c=aVe(n),u=iVe({content:t,placeholder:a,defaultValue:c,canHaveEmptyValue:l}),f=a&&c===void 0||a===void 0&&!l;return d.jsxs(A.Field,{children:[d.jsx(A.FieldIcon,{name:"arrowDropDownCircle"}),d.jsx(A.FieldLabel,{htmlFor:r,children:Tr(n)}),d.jsx(A.FieldControl,{children:d.jsxs(A.Select,{id:r,size:"large",color:"grey",value:u,disabled:i,renderTrigger:()=>d.jsx(A.SelectGhostTrigger,{id:r}),onValueChange:p=>{o(oVe({value:p,placeholder:a}))},children:[f&&d.jsx(A.SelectItem,{value:a||my,children:a||""}),s==null?void 0:s.map(p=>d.jsx(A.SelectItem,{value:p||my,children:p},p))]})})]})}function iVe(e){const{content:t,placeholder:n,defaultValue:r,canHaveEmptyValue:i}=e;let{value:o}=t??{};return o===""&&i?my:(o===""&&(o=void 0),o??r??n??"")}function oVe(e){const{placeholder:t}=e;let{value:n}=e;if(n!==t)return n===my&&(n=""),{__TYPE__:"FieldContent",type:"Select",value:n}}function aVe(e){var t,n;return((t=e.config)==null?void 0:t.default_value)===void 0||(n=e.config.options)==null?void 0:n[0]}const my=" ",AU=IX(2,3),sVe={__TYPE__:"TableContent",content:IX(1,1)};function lVe(e){const{field:t,content:n,onContentChange:r,...i}=e;function o(a){if(!a)return r(sVe);e.onContentChange(dVe(a))}return d.jsx(TX,{...i,field:fVe(t),content:cVe(n),onContentChange:o,shouldReturnEmptyContent:!0,scroll:"x-auto",padding:"zero"})}function IX(e,t){return Array.from({length:e},()=>({key:crypto.randomUUID(),type:"tableRow",content:Array.from({length:t},()=>({key:crypto.randomUUID(),type:"tableCell",content:{__TYPE__:"StructuredTextContent",value:[{type:"paragraph",content:{text:""}}]}}))}))}function cVe(e){return{__TYPE__:"StructuredTextContent",value:[{type:"table",content:uVe(e)}]}}function uVe(e){const t=ue.TableContent.decode(e);return t._tag==="Left"||!t.right.content.some(r=>r.content.some(i=>i.content.value.some(({type:o})=>o)))?AU:t.right.content}function dVe(e){return{__TYPE__:"TableContent",content:e.value.flatMap(t=>t.type==="table"?t.content:[])}}function fVe(e){var t;return{...fe.TableCell,config:{...fe.TableCell.config,label:(t=e.config)==null?void 0:t.label,allowTargetBlank:!0,multi:[fe.TableCell.config.multi,lc.table].join(",")}}}function pVe(e){const{id:t,readOnly:n,field:r,content:i,onContentChange:o}=e,a=i!=null&&i.value?u_.dateFromISOString(i.value):void 0;return d.jsxs(A.Field,{children:[d.jsx(A.FieldIcon,{name:"event"}),d.jsx(A.FieldLabel,{id:t,children:Tr(r)}),d.jsx(A.FieldControl,{children:d.jsx(A.Box,{padding:{left:4,right:12},width:"100%",flexDirection:"column",justifyContent:"center",children:d.jsx(A.DateInput,{mode:"date-time","aria-labelledby":t,disabled:n,value:a,onValueChange:s=>o(hVe(s))})})})]})}function hVe(e){if(e)return{__TYPE__:"FieldContent",type:"Timestamp",value:AVe(e)}}function AVe(e){const t=`${e.getUTCFullYear()}`.padStart(4,"0"),n=`${e.getUTCMonth()+1}`.padStart(2,"0"),r=`${e.getUTCDate()}`.padStart(2,"0"),i=`${e.getUTCHours()}`.padStart(2,"0"),o=`${e.getUTCMinutes()}`.padStart(2,"0");return`${t}-${n}-${r}T${i}:${o}:00+00:00`}function $C(e){const{id:t,readOnly:n,content:r,nestableWidget:i}=e,o=ze.useStableCallback(e.onContentChange);return I.useMemo(()=>{const a={id:t,readOnly:n,onContentChange:o};return i.type==="Boolean"?d.jsx($Ue,{...a,field:i,content:ue.isBooleanContent(r)?r:void 0}):i.type==="Date"?d.jsx(FUe,{...a,field:i,content:ue.isDateContent(r)?r:void 0}):i.type==="Timestamp"?d.jsx(pVe,{...a,field:i,content:ue.isTimestampContent(r)?r:void 0}):i.type==="Image"?d.jsx(APe,{...a,field:i,content:ue.isImageContent(r)?r:void 0}):i.type==="Link"?d.jsx($Pe,{...a,field:i,content:r}):i.type==="Number"?d.jsx(kPe,{...a,field:i,content:ue.isNumberContent(r)?r:void 0}):i.type==="StructuredText"?d.jsx(TX,{...a,field:i,content:ue.isRichTextContent(r)?r:void 0}):i.type==="Select"?d.jsx(rVe,{...a,field:i,content:ue.isSelectContent(r)?r:void 0}):i.type==="Text"?d.jsx(kY,{...a,field:i,content:ue.isTextContent(r)?r:void 0}):i.type==="Embed"?d.jsx(VUe,{...a,field:i,content:ue.isEmbedContent(r)?r:void 0}):i.type==="Color"?d.jsx(OUe,{...a,field:i,content:ue.isColorContent(r)?r:void 0}):i.type==="GeoPoint"?d.jsx(zUe,{...a,field:i,content:ue.isGeoPointContent(r)?r:void 0}):i.type==="IntegrationFields"?d.jsx(RPe,{...a,field:i,content:ue.isIntegrationFieldContent(r)?r:void 0}):i.type==="Table"?d.jsx(lVe,{...a,field:i,content:ue.isTableContent(r)?r:void 0}):null},[r,t,i,o,n])}function mVe(e){const{content:t,id:n,nonRepeatableZone:r,onContentChange:i,readOnly:o}=e,a=I.useMemo(()=>Object.entries(r),[r]);return d.jsx(d.Fragment,{children:a.map(([s,l])=>{const c=t[s];return d.jsx($C,{id:`${n}.${s}`,readOnly:o,nestableWidget:l,content:ue.isNestableContent(c)?c:void 0,onContentChange:u=>{i(gVe(t,s,u))}},s)})})}function gVe(e,t,n){return n?{...e,[t]:n}:Nd.removeKey(e,t)}function aj(e){var o,a;const{group:t,content:n,onContentChange:r,...i}=e;return d.jsx(TUe,{children:d.jsx(sj,{...i,title:l_(t),addItemButtonTitle:`Add item in "${l_(t)}"`,repeatable:((o=t.config)==null?void 0:o.repeat)!==!1,repeatableZone:((a=t.config)==null?void 0:a.fields)??{},content:n==null?void 0:n.value,onContentChange:s=>{r({__TYPE__:"GroupContentType",value:s})}})})}function l_(e){var t;return((t=e.config)==null?void 0:t.label)??e.fieldset??e.type}function RX(e){const{id:t,readOnly:n,content:r,widget:i}=e,o=ze.useStableCallback(e.onContentChange);return I.useMemo(()=>{const a={id:t,readOnly:n,onContentChange:o};return i.type==="Group"?d.jsx(aj,{...a,group:i,content:ue.isGroupContent(r)?r:void 0}):d.jsx($C,{...a,nestableWidget:i,content:ue.isNestableContent(r)?r:void 0})},[r,t,i,o,n])}function sj(e){const{id:t,title:n,addItemButtonTitle:r,content:i,onContentChange:o,readOnly:a,repeatable:s=!0,repeatableZone:l}=e,c=Object.entries(l);let u=i??[bVe];!s&&u.length>1&&(u=u.slice(0,1));const{scrollOffsetTop:f}=be(),p=I.useRef(new WeakMap);vVe(p.current,u);function h(x){return p.current.get(x)??"!bugged!"}function m(x){const b=c_();o(_t.insertAtIndex(u,x,b))}function g(x){const{index:b,offset:v}=x;o(_t.move(u,b,b+v))}function y(x){o(_t.removeIndex(u,x))}function C(x,b,v,S){const w=SVe(x,[v,S]),T=CVe(u,[b,w]);yVe(p.current,x,w),o(T)}return Object.keys(l).length===0?null:d.jsx(A.Group,{title:n??"Repeatable zone",addItemButtonTitle:r??"Add item in repeatable zone",items:u,maxItems:s?void 0:1,getItemKey:h,onAddItem:m,dnd:{scrollOffsetTop:f,onReorder:o,renderDragPreview:({index:x})=>d.jsx(wVe,{title:n??"Repeatable zone",index:x}),renderDropIndicator:xVe},children:(x,b)=>{const v=new Map(x.value),S=h(x);return d.jsx(A.LazyRender,{keepLoaded:!0,loadWhenSearching:!0,children:d.jsx(A.GroupItem,{index:b,title:`${b+1} • Item`,onMove:g,onDelete:y,children:c.map(([w,T])=>d.jsx(RX,{id:`${t}[${S}].${w}`,content:v.get(w),widget:T,onContentChange:R=>C(x,b,w,R),readOnly:a},w))})})}})}function vVe(e,t){t.forEach(n=>{e.has(n)||e.set(n,BX.uniqueNumber())})}function yVe(e,t,n){const r=e.get(t);r!==void 0&&e.set(n,r)}const bVe={__TYPE__:"GroupItemContent",value:[]};function CVe(e,t){const[n,r]=t;return r?e.map((i,o)=>o===n?r:i):e.filter((i,o)=>o!==n)}function SVe(e,t){const[n,r]=t;if(!r){const o=e.value.filter(([a])=>a!==n);return c_(o)}const i=Array.from(new Map(e.value).set(n,r));return c_(i)}function c_(e=[]){return{__TYPE__:"GroupItemContent",value:e}}function wVe(e){const{title:t,index:n}=e;return d.jsxs(A.Box,{padding:{block:8,inline:12},backgroundColor:"grey3",border:!0,borderRadius:6,alignItems:"center",justifyContent:"space-between",width:"100%",children:[d.jsxs("div",{children:[d.jsx(A.Text,{variant:"smallBold",color:"grey11",children:t??"Repeatable zone"}),d.jsxs(A.Text,{variant:"small",color:"grey11",children:[n+1," • Item"]})]}),d.jsx(A.Icon,{name:"dragIndicator",size:"small",color:"grey8"})]})}function xVe(e){const{isDropTarget:t,itemIndex:n,position:r}=e,i=t?d.jsx(A.Line,{color:"purple",thickness:2,sx:{position:"absolute",left:0,right:0,bottom:n===0&&r==="before"?0:void 0}},"line"):void 0;return d.jsx(A.AnimatedElement,{enterDuration:150,children:i})}function _Ve(e){const{compositeSlice:t,content:n,onContentChange:r,sliceKey:i,id:o,readOnly:a,header:s}=e,l=sC();function c(){i&&l.update({id:i,requestedFrom:"sliceFieldSet"})}return d.jsxs(A.FieldSet,{id:i&&aC("sliceFieldSet",i),selected:i?l.isSelected(i):!1,onFocus:c,legend:TVe(t),header:s,children:[d.jsx(mVe,{id:o,readOnly:a,nonRepeatableZone:t["non-repeat"]??{},content:n.nonRepeat,onContentChange:u=>{r({...n,nonRepeat:u})}}),d.jsx(sj,{id:o,readOnly:a,repeatableZone:t.repeat??{},content:n.repeat,onContentChange:u=>{r({...n,repeat:u})}})]})}function TVe(e){var t;return((t=e.config)==null?void 0:t.label)??e.fieldset??e.type}const EX={__TYPE__:"ImageContent",edit:{background:"",crop:{x:0,y:0},zoom:0},height:0,width:0,origin:{height:0,width:0,id:"",url:""},url:""};function IVe(e){const{field:t}=e;if(t.type==="Image")return EX}function RVe(e){const{content:t,legacySlice:n,sliceKey:r,id:i,readOnly:o,onContentChange:a,header:s}=e,l=sC();function c(){r&&l.update({id:r,requestedFrom:"sliceFieldSet"})}const u=n.type==="Group"?l_(n):Tr(n);return d.jsx(A.FieldSet,{id:r&&aC("sliceFieldSet",r),selected:r?l.isSelected(r):!1,onFocus:c,legend:u,header:s,children:n.type==="Group"?d.jsx(aj,{id:i,readOnly:o,onContentChange:a,group:n,content:ue.isGroupContent(t)?t:void 0}):d.jsx($C,{id:i,readOnly:o,nestableWidget:n,content:ue.isNestableContent(t)?t:void 0,onContentChange:f=>{const p=IVe({field:n});!f&&p&&a(p),f&&a(f)}})})}function EVe(e){const{content:t,id:n,slicePrimaryZone:r,onContentChange:i,readOnly:o}=e,a=I.useMemo(()=>Object.entries(r),[r]);return d.jsx(d.Fragment,{children:a.map(([s,l])=>{const c=t[s];return d.jsx(RX,{id:`${n}.${s}`,readOnly:o,widget:l,content:ue.isSlicePrimaryContent(c)?c:void 0,onContentChange:u=>{i($Ve(t,s,u))}},s)})})}function $Ve(e,t,n){return n?{...e,[t]:n}:Nd.removeKey(e,t)}function $X(e){const{config:t,content:n,sliceKey:r,readOnly:i=!1,sharedSlice:o,onContentChange:a,...s}=e,l=kVe(o,n.variation),c=I.useId(),f={id:s.id??c,readOnly:i},p=sC();function h(){r&&p.update({id:r,requestedFrom:"sliceFieldSet"})}return l===void 0?null:d.jsx(yy.Provider,{value:t,children:d.jsx(_Ue,{children:d.jsxs(A.FieldSet,{id:r&&aC("sliceFieldSet",r),selected:r?p.isSelected(r):!1,onFocus:h,legend:OVe(o,l),children:[d.jsx(A.LazyRender,{heightEstimate:400,gap:16,keepLoaded:!0,loadWhenSearching:!0,children:d.jsx(EVe,{...f,slicePrimaryZone:l.primary??{},content:n.primary,onContentChange:m=>{a({...n,primary:m})}})}),d.jsx(sj,{...f,repeatableZone:l.items??{},content:n.items,onContentChange:m=>{a({...n,items:m})}})]})})})}function kVe(e,t){return I.useMemo(()=>e.variations.find(n=>n.id===t),[e,t])}function OVe(e,t){return[e.name,t.name].join(" • ")}function mU(e){var l,c;const{sliceZone:t,onChange:n,slices:r,sliceContent:i}=e,o=(c=(l=t.config)==null?void 0:l.labels)==null?void 0:c[i.name];if(!o)return null;const a=o.find(u=>u.name===i.maybeLabel);function s(u){const f=r.value.map(p=>p.key===i.key?{...p,maybeLabel:u}:p);n({...r,value:f})}return d.jsxs(d.Fragment,{children:[d.jsx(A.Text,{component:"span",variant:"smallBold",children:"•"}),d.jsxs(A.DropdownMenu,{children:[d.jsx(A.DropdownMenuTrigger,{children:d.jsx(A.Button,{color:"grey",size:"small",endIcon:"arrowDropDown",invisible:!0,children:(a==null?void 0:a.display)??"Slice variation"})}),d.jsxs(A.DropdownMenuContent,{align:"start",maxHeight:256,children:[d.jsx(A.DropdownMenuItem,{onSelect:()=>s(void 0),endIcon:i.maybeLabel===void 0?d.jsx(A.Icon,{name:"check"}):void 0,children:"..."}),o==null?void 0:o.map(u=>d.jsx(A.DropdownMenuItem,{onSelect:()=>s(u.name),endIcon:u.name===i.maybeLabel?d.jsx(A.Icon,{name:"check"}):void 0,children:u.display??"[Missing display value]"},u.name))]})]})]})}function MVe(e){const{content:t,id:n,onContentChange:r,readOnly:i,sliceZone:o}=e,a=be();return d.jsx(d.Fragment,{children:t==null?void 0:t.value.map((s,l)=>{var p,h;const c=(h=(p=o.config)==null?void 0:p.choices)==null?void 0:h[s.name];if(c===void 0)return null;const u=s.widget,f={id:`${n}[${s.key}]`,key:s.key,sliceKey:s.key,onContentChange:m=>{const g={...s,widget:m},y=FVe(t,[l,g]);r(y)},readOnly:i};return c.type==="SharedSlice"?ue.isSharedSliceContent(u)?d.jsx($X,{...f,config:a,sharedSlice:c,content:u}):null:c.type==="Slice"?ue.isCompositeSliceContent(u)?d.jsx(_Ve,{...f,compositeSlice:c,content:u,header:d.jsx(mU,{sliceContent:s,sliceZone:o,slices:t,onChange:r})}):null:ue.isSimpleSliceContent(u)?d.jsx(RVe,{...f,legacySlice:c,content:u,header:d.jsx(mU,{sliceContent:s,sliceZone:o,slices:t,onChange:r})}):null})})}function FVe(e,[t,n]){return{__TYPE__:"SliceContentType",value:e.value.map((r,i)=>i===t?n:r)}}function jVe(e){const{content:t,metadataFieldType:n,documentId:r,documentContent:i,documentCustomType:o,documentLocale:a,...s}=e,{showAlert:l}=A.useAlert(),[c,u]=I.useState(!1),f=be(),p=I.useMemo(()=>IQ(i,o),[i,o]),h=RQ(p);async function m(){if(!f.aiSeoMetadataEnabled)return;const{trackMetadataGeneration:g,authStrategy:y,documentBaseUrl:C,repository:x}=f;u(!0);try{const b=await TQ(x,C,y,{pageTextContent:p,contentLocale:a});e.onContentChange({__TYPE__:"FieldContent",type:"Text",value:b[n]}),g({documentId:r,locale:a,suggestion:b[n],type:n})}catch{l({id:n,title:"Error",subtitle:`Failed to generate SEO metadata for ${gU[n]}`})}u(!1)}return d.jsx(kY,{...s,content:t,placeholder:`${gU[n]}..`,endAdornment:d.jsxs(d.Fragment,{children:[d.jsx(ZH,{type:n,value:(t==null?void 0:t.value)||""}),d.jsx(A.Tooltip,{content:h?"Generate SEO metadata from your page content.":"Your page content is too short to generate SEO metadata.",children:d.jsx(A.Button,{disabled:!h,onClick:m,size:"small",color:"grey",startIcon:"autoFixHigh",loading:c,sx:{alignSelf:"center",marginInline:8},children:"Generate"})})]})})}const gU={[oa]:"Meta title",[As]:"Meta description"};function LVe(e){const{id:t,field:n,content:r,onContentChange:i}=e,o=ze.useDebounceState({state:(r==null?void 0:r.value)??"",synchronize:!0}),{onEditUID:a}=I.useContext(eY);function s(c){a();const u=Zn.slugify(c);i(BVe(u)),o.set(u)}function l(c){s(c.clipboardData.getData("Text").trim()),c.preventDefault()}return d.jsxs(A.Field,{children:[d.jsx(A.FieldIcon,{name:"tag"}),d.jsx(A.FieldLabel,{htmlFor:t,children:Tr(n)}),d.jsx(A.FieldControl,{children:d.jsx(Rl,{id:t,variant:"success",placeholder:Ou(n,"Enter a unique identifier"),value:o.value,onPaste:l,onValueChange:s,endAdornment:d.jsx(A.AnimatedElement,{enterDuration:150,children:d.jsx(DVe,{uid:o.debouncedValue})})})})]})}function DVe(e){const{uid:t}=e,n=be();return t?n.uidField?d.jsx(A.ErrorBoundary,{children:d.jsx(I.Suspense,{children:d.jsx(UVe,{uid:t})})}):null:d.jsx(A.Badge,{color:"tomato",title:"Required",size:"medium"})}function UVe(e){const t=PVe(e),n=be();if(!t.documentId)return null;const r=oF({status:t.status,releaseId:t.releaseId,documentId:t.documentId,versionId:t.versionId,baseUrl:n.baseUrl});return d.jsx("a",{href:r.href,target:"_blank",rel:"noreferrer",children:d.jsx(A.Badge,{color:"tomato",size:"medium",title:d.jsxs(A.Text,{color:"tomato11",variant:"small",children:["Value already used in"," ",d.jsx(A.Text,{color:"tomato11",variant:"small",underline:!0,children:"another document"})]})})})}function BVe(e){return e===""?void 0:{__TYPE__:"UIDContent",value:e}}function PVe(e){var p,h,m,g;const{uid:t}=e,n=be();n.uidField||At("uidField");const{coreApiBaseUrl:r,authStrategy:i,customTypeId:o,localeId:a,documentId:s}=n,{data:l}=JM({baseUrl:r,authStrategy:i,uids:[t]}),c=l.results,f=nY({customTypeId:o,languageId:a,documentsWithUid:c,documentId:s,uid:t})[0];return f?{documentId:f.id,versionId:(p=f.versions[0])==null?void 0:p.version_id,status:(h=f.versions[0])==null?void 0:h.status,releaseId:((m=f.versions[0])==null?void 0:m.status)==="release"?(g=f.versions[0])==null?void 0:g.release_id:void 0}:{}}function WVe(e){const{id:t,readOnly:n,staticZone:r,content:i,onContentChange:o,documentId:a,documentContent:s,documentCustomType:l,documentLocale:c}=e,u=be(),f=I.useMemo(()=>Object.entries(r),[r]),p=I.useRef(i);if(I.useEffect(()=>{p.current=i},[i]),f.length===0)return null;const h=KVe(f),m=Lv(i[oa])||"Meta title..",g=Lv(i[As])||"Meta description..";return d.jsxs(A.FieldSet,{legend:"Page data",children:[h&&d.jsx(XH,{title:m,description:g}),f.map(([y,C])=>{const x={id:`${t}.${y}`,onContentChange:v=>{const{[y]:S,...w}=p.current;o({...w,...v!==void 0&&{[y]:v}})},readOnly:n},b=i[y];return C.type==="UID"?I.createElement(LVe,{...x,content:ue.isUIDContent(b)?b:void 0,key:y,field:C}):C.type==="Group"?I.createElement(aj,{...x,content:ue.isGroupContent(b)?b:void 0,group:C,key:y}):u.aiSeoMetadataEnabled&&NVe(y)&&C.type==="Text"?I.createElement(jVe,{...x,content:ue.isTextContent(b)?b:void 0,field:C,key:y,metadataFieldType:y,documentId:a,documentContent:s,documentCustomType:l,documentLocale:c}):I.createElement($C,{...x,content:ue.isNestableContent(b)?b:void 0,key:y,nestableWidget:C})})]})}function NVe(e){return e===oa||e===As}const KVe=e=>{var t,n;return((t=e[0])==null?void 0:t[0])===oa&&((n=e[1])==null?void 0:n[0])===As};function qVe(e){const{id:t,readOnly:n,section:r,content:i,onContentChange:o,documentId:a,documentContent:s,documentCustomType:l,documentLocale:c}=e,[u,f]=zVe(r),[p,h]=QVe(i);return d.jsxs("div",{style:{display:"flex",flexDirection:"column",position:"relative",zIndex:0},children:[d.jsx(WVe,{id:t,readOnly:n,staticZone:u,documentId:a,content:p,onContentChange:m=>o({...h,...m}),documentContent:s,documentCustomType:l,documentLocale:c}),f.map(([m,g])=>{const y=h[m];return d.jsx(MVe,{id:`${t}.${m}`,readOnly:n,sliceZone:g,content:y,onContentChange:C=>o({...p,...h,[m]:C})},m)})]})}function VVe(e){return e.type==="Choice"||e.type==="Slices"}function zVe(e){return Object.entries(e).reduce(([t,n],[r,i])=>(VVe(i)?n.push([r,i]):Object.assign(t,{[r]:i}),[t,n]),[{},[]])}function QVe(e){return Object.entries(e).reduce(([t,n],[r,i])=>{const o={[r]:i};return Object.assign(ue.isSlicesContent(i)?n:t,o),[t,n]},[{},{}])}function HVe(e){const{config:t,readOnly:n=!1,customType:r,sectionName:i,documentId:o,content:a,locale:s,onContentChange:l}=e,c=I.useId();if(Nd.isEmpty(r.json))return null;const u=YVe(r,i),[f,p]=GVe(u,a);return d.jsx(yy.Provider,{value:t,children:d.jsx(xUe,{customTypeFormat:r.format,children:d.jsx(qVe,{id:c,readOnly:n,section:u,documentId:o,content:f,onContentChange:h=>l({...p,...h}),documentContent:a,documentCustomType:r,documentLocale:s})})})}function YVe(e,t){const n=e.json[t];if(n===void 0)throw new Error(`Cannot find a section with name '${t}'.`);return n}function GVe(e,t){return Object.entries(t).reduce(([n,r],[i,o])=>{const a=e[i]!==void 0,s={[i]:o};return[{...n,...a?s:{}},{...r,...a?{}:s}]},[{},{}])}exports.APIExplorer=C2e;exports.DeferredCodeBlock=Dv;exports.DocumentEditor=HVe;exports.EditorConfigContext=yy;exports.EditorErrorBoundary=T2e;exports.MediaLibrary=JH;exports.MetadataBadge=ZH;exports.MetadataPreview=XH;exports.OnboardingGuide=AUe;exports.OnboardingStepId=Yje;exports.SelectionManagerProvider=bH;exports.SharedSliceEditor=$X;exports.SliceSelectionContext=rY;exports.TeamSpace=iC;exports.UIDContext=eY;exports.createSearchParams=UQ;exports.createTeamSpace=hLe;exports.defaultGroupContentWithOneItem=gH;exports.defaultImageContentWidget=EX;exports.deleteTeamSpace=mLe;exports.documentKeys=To;exports.documentMetaSchema=YM;exports.documentSchema=Uje;exports.documentStatus=vH;exports.extractTextFromField=Lv;exports.fetchCustomTypes=Ije;exports.frameworkCreateProjectCodeSnippet=bU;exports.frameworkLabels=yU;exports.generateSEOMetadata=TQ;exports.getConflictingUidDocuments=nY;exports.getCustomTypesOptions=zm;exports.getDocumentById=Qm;exports.getDocumentList=GM;exports.getDocumentListOptions=BQ;exports.getOnboarding=Gje;exports.getPageTextContent=IQ;exports.getProfile=eH;exports.getRepository=rC;exports.getRepositoryTags=VQ;exports.getRepositoryV2=Hje;exports.getRoleLabel=tLe;exports.getRoles=GQ;exports.getRolesOptions=lLe;exports.getSliceSelectionDOMId=aC;exports.getTeamSpaces=JQ;exports.getTeamSpacesOptions=fLe;exports.hasUIDField=tY;exports.invalidateCustomTypes=Eje;exports.invalidateDocumentListData=Wje;exports.isAdminRole=Xje;exports.isDocumentSearchVersion=nx;exports.isDocumentVersion=FQ;exports.isMissingUID=CUe;exports.isPageContentRelevantForAISeo=RQ;exports.isValidSimulatorURL=qQ;exports.languageSchema=HM;exports.makeSearchFullTextDocumentsQueryString=DQ;exports.metaDescriptionConfig=Fh;exports.metaDescriptionProperty=As;exports.metaTitleConfig=Mh;exports.metaTitleProperty=oa;exports.onboardingStateSchema=QQ;exports.onboardingToggleResultSchema=YQ;exports.onboardingToggleStepResultSchema=HQ;exports.prefetchCustomTypes=Tje;exports.prefetchStaticCustomType=Mje;exports.prepareDocumentForSave=S2e;exports.profileResponse=XQ;exports.repositoryFramework=nC;exports.repositorySchemaV2=zQ;exports.roleMap=yLe;exports.searchDocumentStatus=ax;exports.searchDocuments=PQ;exports.searchDocumentsQueryOptions=WQ;exports.searchFullTextDocuments=LQ;exports.sliceItemContentSchema=Bje;exports.suppressErrors=_te;exports.throwConfigError=At;exports.toggleOnboarding=Zje;exports.toggleOnboardingStep=Jje;exports.updateDocumentListData=Pje;exports.updateRoles=cLe;exports.updateTeamSpace=ALe;exports.useCustomType=Rje;exports.useCustomTypes=tC;exports.useDocumentList=JM;exports.useInvalidateRoles=uLe;exports.useInvalidateTeamSpaces=pLe;exports.useProfile=eF;exports.useSelectionManager=Il;exports.useSliceSelection=sC;exports.useStaticCustomType=Oje;
|
|
138
|
+
`))}})}function I8e(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function R8e(e,t,n,r,i){let o=e.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let a=n.create(r,null,i||o.marks);if(o.isLeaf)return e.replaceWith(t,t+o.nodeSize,a);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new Oo(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new q(K.from(a),0,0),1,!0))}function E8e(e,t,n=1,r){let i=e.doc.resolve(t),o=K.empty,a=K.empty;for(let s=i.depth,l=i.depth-n,c=n-1;s>l;s--,c--){o=K.from(i.node(s).copy(o));let u=r&&r[c];a=K.from(u?u.type.create(u.attrs,a):i.node(s).copy(a))}e.step(new dr(t,t,new q(o.append(a),n,n),!0))}function $8e(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,o=e.doc.resolve(t-n),a=o.node().type;if(i&&a.inlineContent){let u=a.whitespace=="pre",f=!!a.contentMatch.matchType(i);u&&!f?r=!1:!u&&f&&(r=!0)}let s=e.steps.length;if(r===!1){let u=e.doc.resolve(t+n);QZ(e,u.node(),u.before(),s)}a.inlineContent&&XF(e,t+n-1,a,o.node().contentMatchAt(o.index()),r==null);let l=e.mapping.slice(s),c=l.map(t-n);if(e.step(new dr(c,l.map(t+n,-1),q.empty,!0)),r===!0){let u=e.doc.resolve(c);zZ(e,u.node(),u.before(),e.steps.length)}return e}function k8e(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,n))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,n))return r.after(i+1);if(o<r.node(i).childCount)return null}return null}function O8e(e,t,n=t,r=q.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),o=e.resolve(n);return HZ(i,o,r)?new dr(t,n,r):new M8e(i,o,r).fit()}function HZ(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}class M8e{constructor(t,n,r){this.$from=t,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=K.empty;for(let i=0;i<=t.depth;i++){let o=t.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(t.indexAfter(i))})}for(let i=t.depth;i>0;i--)this.placed=K.from(t.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(t<0?this.$to:r.doc.resolve(t));if(!i)return null;let o=this.placed,a=r.depth,s=i.depth;for(;a&&s&&o.childCount==1;)o=o.firstChild.content,a--,s--;let l=new q(o,a,s);return t>-1?new Oo(r.pos,t,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new dr(r.pos,i.pos,l):null}findFittable(){let t=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<t;r++){let o=n.firstChild;if(n.childCount>1&&(i=0),o.type.spec.isolating&&i<=r){t=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?t:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=ww(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let a=i.firstChild;for(let s=this.depth;s>=0;s--){let{type:l,match:c}=this.frontier[s],u,f=null;if(n==1&&(a?c.matchType(a.type)||(f=c.fillBefore(K.from(a),!1)):o&&l.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:s,parent:o,inject:f};if(n==2&&a&&(u=c.findWrapping(a.type)))return{sliceDepth:r,frontierDepth:s,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:t,openStart:n,openEnd:r}=this.unplaced,i=ww(t,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new q(t,n+1,Math.max(r,i.size+n>=t.size-r?n+1:0)),!0)}dropNode(){let{content:t,openStart:n,openEnd:r}=this.unplaced,i=ww(t,n);if(i.childCount<=1&&n>0){let o=t.size-n<=n+i.size;this.unplaced=new q(Vp(t,n-1,1),n-1,o?n-1:r)}else this.unplaced=new q(Vp(t,n,1),n,r)}placeNodes({sliceDepth:t,frontierDepth:n,parent:r,inject:i,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let g=0;g<o.length;g++)this.openFrontierNode(o[g]);let a=this.unplaced,s=r?r.content:a.content,l=a.openStart-t,c=0,u=[],{match:f,type:p}=this.frontier[n];if(i){for(let g=0;g<i.childCount;g++)u.push(i.child(g));f=f.matchFragment(i)}let h=s.size+t-(a.content.size-a.openEnd);for(;c<s.childCount;){let g=s.child(c),y=f.matchType(g.type);if(!y)break;c++,(c>1||l==0||g.content.size)&&(f=y,u.push(YZ(g.mark(p.allowedMarks(g.marks)),c==1?l:0,c==s.childCount?h:-1)))}let m=c==s.childCount;m||(h=-1),this.placed=zp(this.placed,n,K.from(u)),this.frontier[n].match=f,m&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=s;g<h;g++){let C=y.lastChild;this.frontier.push({type:C.type,match:C.contentMatchAt(C.childCount)}),y=C.content}this.unplaced=m?t==0?q.empty:new q(Vp(a.content,t-1,1),t-1,h<0?a.openEnd:t-1):new q(Vp(a.content,t,c),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],n;if(!t.type.isTextblock||!xw(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(t){e:for(let n=Math.min(this.depth,t.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],o=n<t.depth&&t.end(n+1)==t.pos+(t.depth-(n+1)),a=xw(t,n,i,r,o);if(a){for(let s=n-1;s>=0;s--){let{match:l,type:c}=this.frontier[s],u=xw(t,s,c,l,!0);if(!u||u.childCount)continue e}return{depth:n,fit:a,move:o?t.doc.resolve(t.after(n+1)):t}}}}close(t){let n=this.findCloseLevel(t);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=zp(this.placed,n.depth,n.fit)),t=n.move;for(let r=n.depth+1;r<=t.depth;r++){let i=t.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,t.index(r));this.openFrontierNode(i.type,i.attrs,o)}return t}openFrontierNode(t,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(t),this.placed=zp(this.placed,this.depth,K.from(t.create(n,r))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(K.empty,!0);n.childCount&&(this.placed=zp(this.placed,this.frontier.length,n))}}function Vp(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Vp(e.firstChild.content,t-1,n)))}function zp(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(zp(e.lastChild.content,t-1,n)))}function ww(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function YZ(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,YZ(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(K.empty,!0)))),e.copy(r)}function xw(e,t,n,r,i){let o=e.node(t),a=i?e.indexAfter(t):e.index(t);if(a==o.childCount&&!n.compatibleContent(o.type))return null;let s=r.fillBefore(o.content,!0,a);return s&&!F8e(n,o.content,a)?s:null}function F8e(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function j8e(e){return e.spec.defining||e.spec.definingForContent}function L8e(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),o=e.doc.resolve(n);if(HZ(i,o,r))return e.step(new dr(t,n,r));let a=JZ(i,e.doc.resolve(n));a[a.length-1]==0&&a.pop();let s=-(i.depth+1);a.unshift(s);for(let p=i.depth,h=i.pos-1;p>0;p--,h--){let m=i.node(p).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;a.indexOf(p)>-1?s=p:i.before(p)==h&&a.splice(1,0,-p)}let l=a.indexOf(s),c=[],u=r.openStart;for(let p=r.content,h=0;;h++){let m=p.firstChild;if(c.push(m),h==r.openStart)break;p=m.content}for(let p=u-1;p>=0;p--){let h=c[p],m=j8e(h.type);if(m&&!h.sameMarkup(i.node(Math.abs(s)-1)))u=p;else if(m||!h.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let h=(p+u+1)%(r.openStart+1),m=c[h];if(m)for(let g=0;g<a.length;g++){let y=a[(g+l)%a.length],C=!0;y<0&&(C=!1,y=-y);let x=i.node(y-1),b=i.index(y-1);if(x.canReplaceWith(b,b,m.type,m.marks))return e.replace(i.before(y),C?o.after(y):n,new q(GZ(r.content,0,r.openStart,h),h,r.openEnd))}}let f=e.steps.length;for(let p=a.length-1;p>=0&&(e.replace(t,n,r),!(e.steps.length>f));p--){let h=a[p];h<0||(t=i.before(h),n=o.after(h))}}function GZ(e,t,n,r,i){if(t<n){let o=e.firstChild;e=e.replaceChild(0,o.copy(GZ(o.content,t+1,n,r,o)))}if(t>r){let o=i.contentMatchAt(0),a=o.fillBefore(e).append(e);e=a.append(o.matchFragment(a).fillBefore(K.empty,!0))}return e}function D8e(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=k8e(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new q(K.from(r),0,0))}function U8e(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n),o=JZ(r,i);for(let a=0;a<o.length;a++){let s=o[a],l=a==o.length-1;if(l&&s==0||r.node(s).type.contentMatch.validEnd)return e.delete(r.start(s),i.end(s));if(s>0&&(l||r.node(s-1).canReplace(r.index(s-1),i.indexAfter(s-1))))return e.delete(r.before(s),i.after(s))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function JZ(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let o=e.start(i);if(o<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(o==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==o-1)&&n.push(i)}return n}class ud extends lr{constructor(t,n,r){super(),this.pos=t,this.attr=n,this.value=r}apply(t){let n=t.nodeAt(this.pos);if(!n)return en.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return en.fromReplace(t,this.pos,this.pos+1,new q(K.from(i),0,n.isLeaf?0:1))}getMap(){return ni.empty}invert(t){return new ud(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new ud(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ud(n.pos,n.attr,n.value)}}lr.jsonID("attr",ud);class Yh extends lr{constructor(t,n){super(),this.attr=t,this.value=n}apply(t){let n=Object.create(null);for(let i in t.attrs)n[i]=t.attrs[i];n[this.attr]=this.value;let r=t.type.create(n,t.content,t.marks);return en.ok(r)}getMap(){return ni.empty}invert(t){return new Yh(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Yh(n.attr,n.value)}}lr.jsonID("docAttr",Yh);let Wd=class extends Error{};Wd=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n};Wd.prototype=Object.create(Error.prototype);Wd.prototype.constructor=Wd;Wd.prototype.name="TransformError";class B8e{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new nh}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let n=this.maybeStep(t);if(n.failed)throw new Wd(n.failed);return this}maybeStep(t){let n=t.apply(this.doc);return n.failed||this.addStep(t,n.doc),n}get docChanged(){return this.steps.length>0}addStep(t,n){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=n}replace(t,n=t,r=q.empty){let i=O8e(this.doc,t,n,r);return i&&this.step(i),this}replaceWith(t,n,r){return this.replace(t,n,new q(K.from(r),0,0))}delete(t,n){return this.replace(t,n,q.empty)}insert(t,n){return this.replaceWith(t,t,n)}replaceRange(t,n,r){return L8e(this,t,n,r),this}replaceRangeWith(t,n,r){return D8e(this,t,n,r),this}deleteRange(t,n){return U8e(this,t,n),this}lift(t,n){return x8e(this,t,n),this}join(t,n=1){return $8e(this,t,n),this}wrap(t,n){return _8e(this,t,n),this}setBlockType(t,n=t,r,i=null){return T8e(this,t,n,r,i),this}setNodeMarkup(t,n,r=null,i){return R8e(this,t,n,r,i),this}setNodeAttribute(t,n,r){return this.step(new ud(t,n,r)),this}setDocAttribute(t,n){return this.step(new Yh(t,n)),this}addNodeMark(t,n){return this.step(new Ms(t,n)),this}removeNodeMark(t,n){if(!(n instanceof xt)){let r=this.doc.nodeAt(t);if(!r)throw new RangeError("No node at position "+t);if(n=n.isInSet(r.marks),!n)return this}return this.step(new Pd(t,n)),this}split(t,n=1,r){return E8e(this,t,n,r),this}addMark(t,n,r){return S8e(this,t,n,r),this}removeMark(t,n,r){return w8e(this,t,n,r),this}clearIncompatible(t,n,r){return XF(this,t,n,r),this}}var n_,r_;if(typeof WeakMap<"u"){let e=new WeakMap;n_=t=>e.get(t),r_=(t,n)=>(e.set(t,n),n)}else{const e=[];let n=0;n_=r=>{for(let i=0;i<e.length;i+=2)if(e[i]==r)return e[i+1]},r_=(r,i)=>(n==10&&(n=0),e[n++]=r,e[n++]=i)}var gt=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){const n=this.map[t];if(n!=e)continue;const r=t%this.width,i=t/this.width|0;let o=r+1,a=i+1;for(let s=1;o<this.width&&this.map[t+s]==n;s++)o++;for(let s=1;a<this.height&&this.map[t+this.width*s]==n;s++)a++;return{left:r,top:i,right:o,bottom:a}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){const{left:r,right:i,top:o,bottom:a}=this.findCell(e);return t=="horiz"?(n<0?r==0:i==this.width)?null:this.map[o*this.width+(n<0?r-1:i)]:(n<0?o==0:a==this.height)?null:this.map[r+this.width*(n<0?o-1:a)]}rectBetween(e,t){const{left:n,right:r,top:i,bottom:o}=this.findCell(e),{left:a,right:s,top:l,bottom:c}=this.findCell(t);return{left:Math.min(n,a),top:Math.min(i,l),right:Math.max(r,s),bottom:Math.max(o,c)}}cellsInRect(e){const t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){const o=r*this.width+i,a=this.map[o];n[a]||(n[a]=!0,!(i==e.left&&i&&this.map[o-1]==a||r==e.top&&r&&this.map[o-this.width]==a)&&t.push(a))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){const o=i+n.child(r).nodeSize;if(r==e){let a=t+e*this.width;const s=(e+1)*this.width;for(;a<s&&this.map[a]<i;)a++;return a==s?o-1:this.map[a]}i=o}}static get(e){return n_(e)||r_(e,P8e(e))}};function P8e(e){if(e.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+e.type.name);const t=W8e(e),n=e.childCount,r=[];let i=0,o=null;const a=[];for(let c=0,u=t*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){const f=e.child(c);u++;for(let m=0;;m++){for(;i<r.length&&r[i]!=0;)i++;if(m==f.childCount)break;const g=f.child(m),{colspan:y,rowspan:C,colwidth:x}=g.attrs;for(let b=0;b<C;b++){if(b+c>=n){(o||(o=[])).push({type:"overlong_rowspan",pos:u,n:C-b});break}const v=i+b*t;for(let S=0;S<y;S++){r[v+S]==0?r[v+S]=u:(o||(o=[])).push({type:"collision",row:c,pos:u,n:y-S});const w=x&&x[S];if(w){const T=(v+S)%t*2,R=a[T];R==null||R!=w&&a[T+1]==1?(a[T]=w,a[T+1]=1):R==w&&a[T+1]++}}}i+=y,u+=g.nodeSize}const p=(c+1)*t;let h=0;for(;i<p;)r[i++]==0&&h++;h&&(o||(o=[])).push({type:"missing",row:c,n:h}),u++}(t===0||n===0)&&(o||(o=[])).push({type:"zero_sized"});const s=new gt(t,n,r,o);let l=!1;for(let c=0;!l&&c<a.length;c+=2)a[c]!=null&&a[c+1]<n&&(l=!0);return l&&N8e(s,a,e),s}function W8e(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){const i=e.child(r);let o=0;if(n)for(let a=0;a<r;a++){const s=e.child(a);for(let l=0;l<s.childCount;l++){const c=s.child(l);a+c.attrs.rowspan>r&&(o+=c.attrs.colspan)}}for(let a=0;a<i.childCount;a++){const s=i.child(a);o+=s.attrs.colspan,s.attrs.rowspan>1&&(n=!0)}t==-1?t=o:t!=o&&(t=Math.max(t,o))}return t}function N8e(e,t,n){e.problems||(e.problems=[]);const r={};for(let i=0;i<e.map.length;i++){const o=e.map[i];if(r[o])continue;r[o]=!0;const a=n.nodeAt(o);if(!a)throw new RangeError(`No cell with offset ${o} found`);let s=null;const l=a.attrs;for(let c=0;c<l.colspan;c++){const u=(i+c)%e.width,f=t[u*2];f!=null&&(!l.colwidth||l.colwidth[c]!=f)&&((s||(s=K8e(l)))[c]=f)}s&&e.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:s})}}function K8e(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function nr(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(const n in e.nodes){const r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var Ts=new qn("selectingCells");function mp(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return e.node(0).resolve(e.before(t+1));return null}function q8e(e){for(let t=e.depth;t>0;t--){const n=e.node(t).type.spec.tableRole;if(n==="cell"||n==="header_cell")return e.node(t)}return null}function mr(e){const t=e.selection.$head;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="row")return!0;return!1}function RC(e){const t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&t.node.type.spec.tableRole=="cell")return t.$anchor;const n=mp(t.$head)||V8e(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function V8e(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){const r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){const r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n-t.nodeSize)}}function i_(e){return e.parent.type.spec.tableRole=="row"&&!!e.nodeAfter}function z8e(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function ej(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function ZZ(e,t,n){const r=e.node(-1),i=gt.get(r),o=e.start(-1),a=i.nextCell(e.pos-o,t,n);return a==null?null:e.node(0).resolve(o+a)}function Oc(e,t,n=1){const r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function XZ(e,t,n=1){const r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<n;i++)r.colwidth.splice(t,0,0)}return r}function Q8e(e,t,n){const r=nr(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var ut=class ma extends Fe{constructor(t,n=t){const r=t.node(-1),i=gt.get(r),o=t.start(-1),a=i.rectBetween(t.pos-o,n.pos-o),s=t.node(0),l=i.cellsInRect(a).filter(u=>u!=n.pos-o);l.unshift(n.pos-o);const c=l.map(u=>{const f=r.nodeAt(u);if(!f)throw RangeError(`No cell with offset ${u} found`);const p=o+u+1;return new aG(s.resolve(p),s.resolve(p+f.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=t,this.$headCell=n}map(t,n){const r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(i_(r)&&i_(i)&&ej(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?ma.rowSelection(r,i):o&&this.isColSelection()?ma.colSelection(r,i):new ma(r,i)}return $e.between(r,i)}content(){const t=this.$anchorCell.node(-1),n=gt.get(t),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},a=[];for(let l=i.top;l<i.bottom;l++){const c=[];for(let u=l*n.width+i.left,f=i.left;f<i.right;f++,u++){const p=n.map[u];if(o[p])continue;o[p]=!0;const h=n.findCell(p);let m=t.nodeAt(p);if(!m)throw RangeError(`No cell with offset ${p} found`);const g=i.left-h.left,y=h.right-i.right;if(g>0||y>0){let C=m.attrs;if(g>0&&(C=Oc(C,0,g)),y>0&&(C=Oc(C,C.colspan-y,y)),h.left<i.left){if(m=m.type.createAndFill(C),!m)throw RangeError(`Could not create cell with attrs ${JSON.stringify(C)}`)}else m=m.type.create(C,m.content)}if(h.top<i.top||h.bottom>i.bottom){const C={...m.attrs,rowspan:Math.min(h.bottom,i.bottom)-Math.max(h.top,i.top)};h.top<i.top?m=m.type.createAndFill(C):m=m.type.create(C,m.content)}c.push(m)}a.push(t.child(l).copy(K.from(c)))}const s=this.isColSelection()&&this.isRowSelection()?t:a;return new q(K.from(s),1,1)}replace(t,n=q.empty){const r=t.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){const{$from:s,$to:l}=i[a],c=t.mapping.slice(r);t.replace(c.map(s.pos),c.map(l.pos),a?q.empty:n)}const o=Fe.findFrom(t.doc.resolve(t.mapping.slice(r).map(this.to)),-1);o&&t.setSelection(o)}replaceWith(t,n){this.replace(t,new q(K.from(n),0,0))}forEachCell(t){const n=this.$anchorCell.node(-1),r=gt.get(n),i=this.$anchorCell.start(-1),o=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let a=0;a<o.length;a++)t(n.nodeAt(o[a]),i+o[a])}isColSelection(){const t=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(t,n)>0)return!1;const r=t+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){const r=t.node(-1),i=gt.get(r),o=t.start(-1),a=i.findCell(t.pos-o),s=i.findCell(n.pos-o),l=t.node(0);return a.top<=s.top?(a.top>0&&(t=l.resolve(o+i.map[a.left])),s.bottom<i.height&&(n=l.resolve(o+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=l.resolve(o+i.map[s.left])),a.bottom<i.height&&(t=l.resolve(o+i.map[i.width*(i.height-1)+a.right-1]))),new ma(t,n)}isRowSelection(){const t=this.$anchorCell.node(-1),n=gt.get(t),r=this.$anchorCell.start(-1),i=n.colCount(this.$anchorCell.pos-r),o=n.colCount(this.$headCell.pos-r);if(Math.min(i,o)>0)return!1;const a=i+this.$anchorCell.nodeAfter.attrs.colspan,s=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,s)==n.width}eq(t){return t instanceof ma&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){const r=t.node(-1),i=gt.get(r),o=t.start(-1),a=i.findCell(t.pos-o),s=i.findCell(n.pos-o),l=t.node(0);return a.left<=s.left?(a.left>0&&(t=l.resolve(o+i.map[a.top*i.width])),s.right<i.width&&(n=l.resolve(o+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=l.resolve(o+i.map[s.top*i.width])),a.right<i.width&&(t=l.resolve(o+i.map[i.width*(a.top+1)-1]))),new ma(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new ma(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new ma(t.resolve(n),t.resolve(r))}getBookmark(){return new H8e(this.$anchorCell.pos,this.$headCell.pos)}};ut.prototype.visible=!1;Fe.jsonID("cell",ut);var H8e=class eX{constructor(t,n){this.anchor=t,this.head=n}map(t){return new eX(t.map(this.anchor),t.map(this.head))}resolve(t){const n=t.resolve(this.anchor),r=t.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&ej(n,r)?new ut(n,r):Fe.near(r,1)}};function Y8e(e){if(!(e.selection instanceof ut))return null;const t=[];return e.selection.forEachCell((n,r)=>{t.push(Jn.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Ot.create(e.doc,t)}function G8e({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let o=t.depth;o>=0&&!(t.before(o+1)>t.start(o));o--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function J8e({$from:e,$to:t}){let n,r;for(let i=e.depth;i>0;i--){const o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}for(let i=t.depth;i>0;i--){const o=t.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return n!==r&&t.parentOffset===0}function Z8e(e,t,n){const r=(t||e).selection,i=(t||e).doc;let o,a;if(r instanceof we&&(a=r.node.type.spec.tableRole)){if(a=="cell"||a=="header_cell")o=ut.create(i,r.from);else if(a=="row"){const s=i.resolve(r.from+1);o=ut.rowSelection(s,s)}else if(!n){const s=gt.get(r.node),l=r.from+1,c=l+s.map[s.width*s.height-1];o=ut.create(i,l+1,c)}}else r instanceof $e&&G8e(r)?o=$e.create(i,r.from):r instanceof $e&&J8e(r)&&(o=$e.create(i,r.$from.start(),r.$from.end()));return o&&(t||(t=e.tr)).setSelection(o),t}var X8e=new qn("fix-tables");function tX(e,t,n,r){const i=e.childCount,o=t.childCount;e:for(let a=0,s=0;a<o;a++){const l=t.child(a);for(let c=s,u=Math.min(i,a+3);c<u;c++)if(e.child(c)==l){s=c+1,n+=l.nodeSize;continue e}r(l,n),s<i&&e.child(s).sameMarkup(l)?tX(e.child(s),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function nX(e,t){let n;const r=(i,o)=>{i.type.spec.tableRole=="table"&&(n=eqe(e,i,o,n))};return t?t.doc!=e.doc&&tX(t.doc,e.doc,0,r):e.doc.descendants(r),n}function eqe(e,t,n,r){const i=gt.get(t);if(!i.problems)return r;r||(r=e.tr);const o=[];for(let l=0;l<i.height;l++)o.push(0);for(let l=0;l<i.problems.length;l++){const c=i.problems[l];if(c.type=="collision"){const u=t.nodeAt(c.pos);if(!u)continue;const f=u.attrs;for(let p=0;p<f.rowspan;p++)o[c.row+p]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Oc(f,f.colspan-c.n,c.n))}else if(c.type=="missing")o[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=t.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=t.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(n);r.delete(u,u+t.nodeSize)}}let a,s;for(let l=0;l<o.length;l++)o[l]&&(a==null&&(a=l),s=l);for(let l=0,c=n+1;l<i.height;l++){const u=t.child(l),f=c+u.nodeSize,p=o[l];if(p>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);const m=[];for(let y=0;y<p;y++){const C=nr(e.schema)[h].createAndFill();C&&m.push(C)}const g=(l==0||a==l-1)&&s==l?c+1:f-1;r.insert(r.mapping.map(g),m)}c=f}return r.setMeta(X8e,{fixTables:!0})}function Ur(e){const t=e.selection,n=RC(e),r=n.node(-1),i=n.start(-1),o=gt.get(r);return{...t instanceof ut?o.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):o.findCell(n.pos-i),tableStart:i,map:o,table:r}}function tj(e,{map:t,tableStart:n,table:r},i){let o=i>0?-1:0;Q8e(t,r,i+o)&&(o=i==0||i==t.width?null:0);for(let a=0;a<t.height;a++){const s=a*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){const l=t.map[s],c=r.nodeAt(l);e.setNodeMarkup(e.mapping.map(n+l),null,XZ(c.attrs,i-t.colCount(l))),a+=c.attrs.rowspan-1}else{const l=o==null?nr(r.type.schema).cell:r.nodeAt(t.map[s+o]).type,c=t.positionAt(a,i,r);e.insert(e.mapping.map(n+c),l.createAndFill())}}return e}function tqe(e,t){if(!mr(e))return!1;if(t){const n=Ur(e);t(tj(e.tr,n,n.left))}return!0}function nqe(e,t){if(!mr(e))return!1;if(t){const n=Ur(e);t(tj(e.tr,n,n.right))}return!0}function rqe(e,{map:t,table:n,tableStart:r},i){const o=e.mapping.maps.length;for(let a=0;a<t.height;){const s=a*t.width+i,l=t.map[s],c=n.nodeAt(l),u=c.attrs;if(i>0&&t.map[s-1]==l||i<t.width-1&&t.map[s+1]==l)e.setNodeMarkup(e.mapping.slice(o).map(r+l),null,Oc(u,i-t.colCount(l)));else{const f=e.mapping.slice(o).map(r+l);e.delete(f,f+c.nodeSize)}a+=u.rowspan}}function iqe(e,t){if(!mr(e))return!1;if(t){const n=Ur(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;rqe(r,n,i),i!=n.left;i--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw RangeError("No table found");n.table=o,n.map=gt.get(o)}t(r)}return!0}function oqe(e,t,n){var r;const i=nr(t.type.schema).header_cell;for(let o=0;o<e.width;o++)if(((r=t.nodeAt(e.map[o+n*e.width]))==null?void 0:r.type)!=i)return!1;return!0}function nj(e,{map:t,tableStart:n,table:r},i){var o;let a=n;for(let c=0;c<i;c++)a+=r.child(c).nodeSize;const s=[];let l=i>0?-1:0;oqe(t,r,i+l)&&(l=i==0||i==t.height?null:0);for(let c=0,u=t.width*i;c<t.width;c++,u++)if(i>0&&i<t.height&&t.map[u]==t.map[u-t.width]){const f=t.map[u],p=r.nodeAt(f).attrs;e.setNodeMarkup(n+f,null,{...p,rowspan:p.rowspan+1}),c+=p.colspan-1}else{const f=l==null?nr(r.type.schema).cell:(o=r.nodeAt(t.map[u+l*t.width]))==null?void 0:o.type,p=f==null?void 0:f.createAndFill();p&&s.push(p)}return e.insert(a,nr(r.type.schema).row.create(null,s)),e}function aqe(e,t){if(!mr(e))return!1;if(t){const n=Ur(e);t(nj(e.tr,n,n.top))}return!0}function sqe(e,t){if(!mr(e))return!1;if(t){const n=Ur(e);t(nj(e.tr,n,n.bottom))}return!0}function lqe(e,{map:t,table:n,tableStart:r},i){let o=0;for(let c=0;c<i;c++)o+=n.child(c).nodeSize;const a=o+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(o+r,a+r);const l=new Set;for(let c=0,u=i*t.width;c<t.width;c++,u++){const f=t.map[u];if(!l.has(f)){if(l.add(f),i>0&&f==t.map[u-t.width]){const p=n.nodeAt(f).attrs;e.setNodeMarkup(e.mapping.slice(s).map(f+r),null,{...p,rowspan:p.rowspan-1}),c+=p.colspan-1}else if(i<t.height&&f==t.map[u+t.width]){const p=n.nodeAt(f),h=p.attrs,m=p.type.create({...h,rowspan:p.attrs.rowspan-1},p.content),g=t.positionAt(i+1,c,n);e.insert(e.mapping.slice(s).map(r+g),m),c+=h.colspan-1}}}}function cqe(e,t){if(!mr(e))return!1;if(t){const n=Ur(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;lqe(r,n,i),i!=n.top;i--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw RangeError("No table found");n.table=o,n.map=gt.get(n.table)}t(r)}return!0}function zD(e){const t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function uqe({width:e,height:t,map:n},r){let i=r.top*e+r.left,o=i,a=(r.bottom-1)*e+r.left,s=i+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&n[o]==n[o-1]||r.right<e&&n[s]==n[s+1])return!0;o+=e,s+=e}for(let l=r.left;l<r.right;l++){if(r.top>0&&n[i]==n[i-e]||r.bottom<t&&n[a]==n[a+e])return!0;i++,a++}return!1}function QD(e,t){const n=e.selection;if(!(n instanceof ut)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Ur(e),{map:i}=r;if(uqe(i,r))return!1;if(t){const o=e.tr,a={};let s=K.empty,l,c;for(let u=r.top;u<r.bottom;u++)for(let f=r.left;f<r.right;f++){const p=i.map[u*i.width+f],h=r.table.nodeAt(p);if(!(a[p]||!h))if(a[p]=!0,l==null)l=p,c=h;else{zD(h)||(s=s.append(h.content));const m=o.mapping.map(p+r.tableStart);o.delete(m,m+h.nodeSize)}}if(l==null||c==null)return!0;if(o.setNodeMarkup(l+r.tableStart,null,{...XZ(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),s.size){const u=l+1+c.content.size,f=zD(c)?l+1:u;o.replaceWith(f+r.tableStart,u+r.tableStart,s)}o.setSelection(new ut(o.doc.resolve(l+r.tableStart))),t(o)}return!0}function HD(e,t){const n=nr(e.schema);return dqe(({node:r})=>n[r.type.spec.tableRole])(e,t)}function dqe(e){return(t,n)=>{var r;const i=t.selection;let o,a;if(i instanceof ut){if(i.$anchorCell.pos!=i.$headCell.pos)return!1;o=i.$anchorCell.nodeAfter,a=i.$anchorCell.pos}else{if(o=q8e(i.$from),!o)return!1;a=(r=mp(i.$from))==null?void 0:r.pos}if(o==null||a==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let s=o.attrs;const l=[],c=s.colwidth;s.rowspan>1&&(s={...s,rowspan:1}),s.colspan>1&&(s={...s,colspan:1});const u=Ur(t),f=t.tr;for(let h=0;h<u.right-u.left;h++)l.push(c?{...s,colwidth:c&&c[h]?[c[h]]:null}:s);let p;for(let h=u.top;h<u.bottom;h++){let m=u.map.positionAt(h,u.left,u.table);h==u.top&&(m+=o.nodeSize);for(let g=u.left,y=0;g<u.right;g++,y++)g==u.left&&h==u.top||f.insert(p=f.mapping.map(m+u.tableStart,1),e({node:o,row:h,col:g}).createAndFill(l[y]))}f.setNodeMarkup(a,e({node:o,row:u.top,col:u.left}),l[0]),i instanceof ut&&f.setSelection(new ut(f.doc.resolve(i.$anchorCell.pos),p?f.doc.resolve(p):void 0)),n(f)}return!0}}function fqe(e,t){return function(n,r){if(!mr(n))return!1;const i=RC(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){const o=n.tr;n.selection instanceof ut?n.selection.forEachCell((a,s)=>{a.attrs[e]!==t&&o.setNodeMarkup(s,null,{...a.attrs,[e]:t})}):o.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(o)}return!0}}function pqe(e){return function(t,n){if(!mr(t))return!1;if(n){const r=nr(t.schema),i=Ur(t),o=t.tr,a=i.map.cellsInRect(e=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=a.map(l=>i.table.nodeAt(l));for(let l=0;l<a.length;l++)s[l].type==r.header_cell&&o.setNodeMarkup(i.tableStart+a[l],r.cell,s[l].attrs);if(o.steps.length==0)for(let l=0;l<a.length;l++)o.setNodeMarkup(i.tableStart+a[l],r.header_cell,s[l].attrs);n(o)}return!0}}function YD(e,t,n){const r=t.map.cellsInRect({left:0,top:0,right:e=="row"?t.map.width:1,bottom:e=="column"?t.map.height:1});for(let i=0;i<r.length;i++){const o=t.table.nodeAt(r[i]);if(o&&o.type!==n.header_cell)return!1}return!0}function Gh(e,t){return t=t||{useDeprecatedLogic:!1},t.useDeprecatedLogic?pqe(e):function(n,r){if(!mr(n))return!1;if(r){const i=nr(n.schema),o=Ur(n),a=n.tr,s=YD("row",o,i),l=YD("column",o,i),u=(e==="column"?s:e==="row"?l:!1)?1:0,f=e=="column"?{left:0,top:u,right:1,bottom:o.map.height}:e=="row"?{left:u,top:0,right:o.map.width,bottom:1}:o,p=e=="column"?l?i.cell:i.header_cell:e=="row"?s?i.cell:i.header_cell:i.cell;o.map.cellsInRect(f).forEach(h=>{const m=h+o.tableStart,g=a.doc.nodeAt(m);g&&a.setNodeMarkup(m,p,g.attrs)}),r(a)}return!0}}Gh("row",{useDeprecatedLogic:!0});Gh("column",{useDeprecatedLogic:!0});var hqe=Gh("cell",{useDeprecatedLogic:!0});function Aqe(e,t){if(t<0){const n=e.nodeBefore;if(n)return e.pos-n.nodeSize;for(let r=e.index(-1)-1,i=e.before();r>=0;r--){const o=e.node(-1).child(r),a=o.lastChild;if(a)return i-1-a.nodeSize;i-=o.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;const n=e.node(-1);for(let r=e.indexAfter(-1),i=e.after();r<n.childCount;r++){const o=n.child(r);if(o.childCount)return i+1;i+=o.nodeSize}}return null}function GD(e){return function(t,n){if(!mr(t))return!1;const r=Aqe(RC(t),e);if(r==null)return!1;if(n){const i=t.doc.resolve(r);n(t.tr.setSelection($e.between(i,z8e(i))).scrollIntoView())}return!0}}function mqe(e,t){const n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Lg(e,t){const n=e.selection;if(!(n instanceof ut))return!1;if(t){const r=e.tr,i=nr(e.schema).cell.createAndFill().content;n.forEachCell((o,a)=>{o.content.eq(i)||r.replace(r.mapping.map(a+1),r.mapping.map(a+o.nodeSize-1),new q(i,0,0))}),r.docChanged&&t(r)}return!0}function gqe(e){if(!e.size)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole=="table");)n--,r--,t=t.child(0).content;const i=t.child(0),o=i.type.spec.tableRole,a=i.type.schema,s=[];if(o=="row")for(let l=0;l<t.childCount;l++){let c=t.child(l).content;const u=l?0:Math.max(0,n-1),f=l<t.childCount-1?0:Math.max(0,r-1);(u||f)&&(c=o_(nr(a).row,new q(c,u,f)).content),s.push(c)}else if(o=="cell"||o=="header_cell")s.push(n||r?o_(nr(a).row,new q(t,n,r)).content:t);else return null;return vqe(a,s)}function vqe(e,t){const n=[];for(let i=0;i<t.length;i++){const o=t[i];for(let a=o.childCount-1;a>=0;a--){const{rowspan:s,colspan:l}=o.child(a).attrs;for(let c=i;c<i+s;c++)n[c]=(n[c]||0)+l}}let r=0;for(let i=0;i<n.length;i++)r=Math.max(r,n[i]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(K.empty),n[i]<r){const o=nr(e).cell.createAndFill(),a=[];for(let s=n[i];s<r;s++)a.push(o);t[i]=t[i].append(K.from(a))}return{height:t.length,width:r,rows:t}}function o_(e,t){const n=e.createAndFill();return new B8e(n).replace(0,n.content.size,t).doc}function yqe({width:e,height:t,rows:n},r,i){if(e!=r){const o=[],a=[];for(let s=0;s<n.length;s++){const l=n[s],c=[];for(let u=o[s]||0,f=0;u<r;f++){let p=l.child(f%l.childCount);u+p.attrs.colspan>r&&(p=p.type.createChecked(Oc(p.attrs,p.attrs.colspan,u+p.attrs.colspan-r),p.content)),c.push(p),u+=p.attrs.colspan;for(let h=1;h<p.attrs.rowspan;h++)o[s+h]=(o[s+h]||0)+p.attrs.colspan}a.push(K.from(c))}n=a,e=r}if(t!=i){const o=[];for(let a=0,s=0;a<i;a++,s++){const l=[],c=n[s%t];for(let u=0;u<c.childCount;u++){let f=c.child(u);a+f.attrs.rowspan>i&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,i-f.attrs.rowspan)},f.content)),l.push(f)}o.push(K.from(l))}n=o,t=i}return{width:e,height:t,rows:n}}function bqe(e,t,n,r,i,o,a){const s=e.doc.type.schema,l=nr(s);let c,u;if(i>t.width)for(let f=0,p=0;f<t.height;f++){const h=n.child(f);p+=h.nodeSize;const m=[];let g;h.lastChild==null||h.lastChild.type==l.cell?g=c||(c=l.cell.createAndFill()):g=u||(u=l.header_cell.createAndFill());for(let y=t.width;y<i;y++)m.push(g);e.insert(e.mapping.slice(a).map(p-1+r),m)}if(o>t.height){const f=[];for(let m=0,g=(t.height-1)*t.width;m<Math.max(t.width,i);m++){const y=m>=t.width?!1:n.nodeAt(t.map[g+m]).type==l.header_cell;f.push(y?u||(u=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}const p=l.row.create(null,K.from(f)),h=[];for(let m=t.height;m<o;m++)h.push(p);e.insert(e.mapping.slice(a).map(r+n.nodeSize-2),h)}return!!(c||u)}function JD(e,t,n,r,i,o,a,s){if(a==0||a==t.height)return!1;let l=!1;for(let c=i;c<o;c++){const u=a*t.width+c,f=t.map[u];if(t.map[u-t.width]==f){l=!0;const p=n.nodeAt(f),{top:h,left:m}=t.findCell(f);e.setNodeMarkup(e.mapping.slice(s).map(f+r),null,{...p.attrs,rowspan:a-h}),e.insert(e.mapping.slice(s).map(t.positionAt(a,m,n)),p.type.createAndFill({...p.attrs,rowspan:h+p.attrs.rowspan-a})),c+=p.attrs.colspan-1}}return l}function ZD(e,t,n,r,i,o,a,s){if(a==0||a==t.width)return!1;let l=!1;for(let c=i;c<o;c++){const u=c*t.width+a,f=t.map[u];if(t.map[u-1]==f){l=!0;const p=n.nodeAt(f),h=t.colCount(f),m=e.mapping.slice(s).map(f+r);e.setNodeMarkup(m,null,Oc(p.attrs,a-h,p.attrs.colspan-(a-h))),e.insert(m+p.nodeSize,p.type.createAndFill(Oc(p.attrs,0,a-h))),c+=p.attrs.rowspan-1}}return l}function XD(e,t,n,r,i){let o=n?e.doc.nodeAt(n-1):e.doc;if(!o)throw new Error("No table found");let a=gt.get(o);const{top:s,left:l}=r,c=l+i.width,u=s+i.height,f=e.tr;let p=0;function h(){if(o=n?f.doc.nodeAt(n-1):f.doc,!o)throw new Error("No table found");a=gt.get(o),p=f.mapping.maps.length}bqe(f,a,o,n,c,u,p)&&h(),JD(f,a,o,n,l,c,s,p)&&h(),JD(f,a,o,n,l,c,u,p)&&h(),ZD(f,a,o,n,s,u,l,p)&&h(),ZD(f,a,o,n,s,u,c,p)&&h();for(let m=s;m<u;m++){const g=a.positionAt(m,l,o),y=a.positionAt(m,c,o);f.replace(f.mapping.slice(p).map(g+n),f.mapping.slice(p).map(y+n),new q(i.rows[m-s],0,0))}h(),f.setSelection(new ut(f.doc.resolve(n+a.positionAt(s,l,o)),f.doc.resolve(n+a.positionAt(u-1,c-1,o)))),t(f)}var Cqe=FG({ArrowLeft:Dg("horiz",-1),ArrowRight:Dg("horiz",1),ArrowUp:Dg("vert",-1),ArrowDown:Dg("vert",1),"Shift-ArrowLeft":Ug("horiz",-1),"Shift-ArrowRight":Ug("horiz",1),"Shift-ArrowUp":Ug("vert",-1),"Shift-ArrowDown":Ug("vert",1),Backspace:Lg,"Mod-Backspace":Lg,Delete:Lg,"Mod-Delete":Lg});function lv(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function Dg(e,t){return(n,r,i)=>{if(!i)return!1;const o=n.selection;if(o instanceof ut)return lv(n,r,Fe.near(o.$headCell,t));if(e!="horiz"&&!o.empty)return!1;const a=rX(i,e,t);if(a==null)return!1;if(e=="horiz")return lv(n,r,Fe.near(n.doc.resolve(o.head+t),t));{const s=n.doc.resolve(a),l=ZZ(s,e,t);let c;return l?c=Fe.near(l,1):t<0?c=Fe.near(n.doc.resolve(s.before(-1)),-1):c=Fe.near(n.doc.resolve(s.after(-1)),1),lv(n,r,c)}}}function Ug(e,t){return(n,r,i)=>{if(!i)return!1;const o=n.selection;let a;if(o instanceof ut)a=o;else{const l=rX(i,e,t);if(l==null)return!1;a=new ut(n.doc.resolve(l))}const s=ZZ(a.$headCell,e,t);return s?lv(n,r,new ut(a.$anchorCell,s)):!1}}function Sqe(e,t){const n=e.state.doc,r=mp(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new ut(r))),!0):!1}function wqe(e,t,n){if(!mr(e.state))return!1;let r=gqe(n);const i=e.state.selection;if(i instanceof ut){r||(r={width:1,height:1,rows:[K.from(o_(nr(e.state.schema).cell,n))]});const o=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),s=gt.get(o).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=yqe(r,s.right-s.left,s.bottom-s.top),XD(e.state,e.dispatch,a,s,r),!0}else if(r){const o=RC(e.state),a=o.start(-1);return XD(e.state,e.dispatch,a,gt.get(o.node(-1)).findCell(o.pos-a),r),!0}else return!1}function xqe(e,t){var n;if(t.ctrlKey||t.metaKey)return;const r=eU(e,t.target);let i;if(t.shiftKey&&e.state.selection instanceof ut)o(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&(i=mp(e.state.selection.$anchor))!=null&&((n=_w(e,t))==null?void 0:n.pos)!=i.pos)o(i,t),t.preventDefault();else if(!r)return;function o(l,c){let u=_w(e,c);const f=Ts.getState(e.state)==null;if(!u||!ej(l,u))if(f)u=l;else return;const p=new ut(l,u);if(f||!e.state.selection.eq(p)){const h=e.state.tr.setSelection(p);f&&h.setMeta(Ts,l.pos),e.dispatch(h)}}function a(){e.root.removeEventListener("mouseup",a),e.root.removeEventListener("dragstart",a),e.root.removeEventListener("mousemove",s),Ts.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(Ts,-1))}function s(l){const c=l,u=Ts.getState(e.state);let f;if(u!=null)f=e.state.doc.resolve(u);else if(eU(e,c.target)!=r&&(f=_w(e,t),!f))return a();f&&o(f,c)}e.root.addEventListener("mouseup",a),e.root.addEventListener("dragstart",a),e.root.addEventListener("mousemove",s)}function rX(e,t,n){if(!(e.state.selection instanceof $e))return null;const{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const s=r.before(i),l=t=="vert"?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(l)?s:null}}return null}function eU(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName=="TD"||t.nodeName=="TH")return t;return null}function _w(e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});return n&&n?mp(e.state.doc.resolve(n.pos)):null}var iX=class{constructor(t,n){this.node=t,this.defaultCellMinWidth=n,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",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),a_(t,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,a_(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function a_(e,t,n,r,i,o){var a;let s=0,l=!0,c=t.firstChild;const u=e.firstChild;if(u){for(let f=0,p=0;f<u.childCount;f++){const{colspan:h,colwidth:m}=u.child(f).attrs;for(let g=0;g<h;g++,p++){const y=i==p?o:m&&m[g],C=y?y+"px":"";if(s+=y||r,y||(l=!1),c)c.style.width!=C&&(c.style.width=C),c=c.nextSibling;else{const x=document.createElement("col");x.style.width=C,t.appendChild(x)}}}for(;c;){const f=c.nextSibling;(a=c.parentNode)==null||a.removeChild(c),c=f}l?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}var ri=new qn("tableColumnResizing");function oX({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=iX,lastColumnResizable:i=!0}={}){const o=new dn({key:ri,state:{init(a,s){var l,c;const u=(c=(l=o.spec)==null?void 0:l.props)==null?void 0:c.nodeViews,f=nr(s.schema).table.name;return r&&u&&(u[f]=(p,h)=>new r(p,n,h)),new _qe(-1,!1)},apply(a,s){return s.apply(a)}},props:{attributes:a=>{const s=ri.getState(a);return s&&s.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(a,s)=>{Tqe(a,s,e,i)},mouseleave:a=>{Iqe(a)},mousedown:(a,s)=>{Rqe(a,s,t,n)}},decorations:a=>{const s=ri.getState(a);if(s&&s.activeHandle>-1)return Mqe(a,s.activeHandle)},nodeViews:{}}});return o}var _qe=class cv{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(t){const n=this,r=t.getMeta(ri);if(r&&r.setHandle!=null)return new cv(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new cv(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let i=t.mapping.map(n.activeHandle,-1);return i_(t.doc.resolve(i))||(i=-1),new cv(i,n.dragging)}return n}};function Tqe(e,t,n,r){if(!e.editable)return;const i=ri.getState(e.state);if(i&&!i.dragging){const o=$qe(t.target);let a=-1;if(o){const{left:s,right:l}=o.getBoundingClientRect();t.clientX-s<=n?a=tU(e,t,"left",n):l-t.clientX<=n&&(a=tU(e,t,"right",n))}if(a!=i.activeHandle){if(!r&&a!==-1){const s=e.state.doc.resolve(a),l=s.node(-1),c=gt.get(l),u=s.start(-1);if(c.colCount(s.pos-u)+s.nodeAfter.attrs.colspan-1==c.width-1)return}aX(e,a)}}}function Iqe(e){if(!e.editable)return;const t=ri.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&aX(e,-1)}function Rqe(e,t,n,r){var i;if(!e.editable)return!1;const o=(i=e.dom.ownerDocument.defaultView)!=null?i:window,a=ri.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;const s=e.state.doc.nodeAt(a.activeHandle),l=Eqe(e,a.activeHandle,s.attrs);e.dispatch(e.state.tr.setMeta(ri,{setDragging:{startX:t.clientX,startWidth:l}}));function c(f){o.removeEventListener("mouseup",c),o.removeEventListener("mousemove",u);const p=ri.getState(e.state);p!=null&&p.dragging&&(kqe(e,p.activeHandle,nU(p.dragging,f,n)),e.dispatch(e.state.tr.setMeta(ri,{setDragging:null})))}function u(f){if(!f.which)return c(f);const p=ri.getState(e.state);if(p&&p.dragging){const h=nU(p.dragging,f,n);rU(e,p.activeHandle,h,r)}}return rU(e,a.activeHandle,l,r),o.addEventListener("mouseup",c),o.addEventListener("mousemove",u),t.preventDefault(),!0}function Eqe(e,t,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const o=e.domAtPos(t);let s=o.node.childNodes[o.offset].offsetWidth,l=n;if(r)for(let c=0;c<n;c++)r[c]&&(s-=r[c],l--);return s/l}function $qe(e){for(;e&&e.nodeName!="TD"&&e.nodeName!="TH";)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}function tU(e,t,n,r){const i=n=="right"?-r:r,o=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!o)return-1;const{pos:a}=o,s=mp(e.state.doc.resolve(a));if(!s)return-1;if(n=="right")return s.pos;const l=gt.get(s.node(-1)),c=s.start(-1),u=l.map.indexOf(s.pos-c);return u%l.width==0?-1:c+l.map[u-1]}function nU(e,t,n){const r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function aX(e,t){e.dispatch(e.state.tr.setMeta(ri,{setHandle:t}))}function kqe(e,t,n){const r=e.state.doc.resolve(t),i=r.node(-1),o=gt.get(i),a=r.start(-1),s=o.colCount(r.pos-a)+r.nodeAfter.attrs.colspan-1,l=e.state.tr;for(let c=0;c<o.height;c++){const u=c*o.width+s;if(c&&o.map[u]==o.map[u-o.width])continue;const f=o.map[u],p=i.nodeAt(f).attrs,h=p.colspan==1?0:s-o.colCount(f);if(p.colwidth&&p.colwidth[h]==n)continue;const m=p.colwidth?p.colwidth.slice():Oqe(p.colspan);m[h]=n,l.setNodeMarkup(a+f,null,{...p,colwidth:m})}l.docChanged&&e.dispatch(l)}function rU(e,t,n,r){const i=e.state.doc.resolve(t),o=i.node(-1),a=i.start(-1),s=gt.get(o).colCount(i.pos-a)+i.nodeAfter.attrs.colspan-1;let l=e.domAtPos(i.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&a_(o,l.firstChild,l,r,s,n)}function Oqe(e){return Array(e).fill(0)}function Mqe(e,t){var n;const r=[],i=e.doc.resolve(t),o=i.node(-1);if(!o)return Ot.empty;const a=gt.get(o),s=i.start(-1),l=a.colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1;for(let c=0;c<a.height;c++){const u=l+c*a.width;if((l==a.width-1||a.map[u]!=a.map[u+1])&&(c==0||a.map[u]!=a.map[u-a.width])){const f=a.map[u],p=s+f+o.nodeAt(f).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",(n=ri.getState(e))!=null&&n.dragging&&r.push(Jn.node(s+f,s+f+o.nodeAt(f).nodeSize,{class:"column-resize-dragging"})),r.push(Jn.widget(p,h))}}return Ot.create(e.doc,r)}function sX({allowTableNodeSelection:e=!1}={}){return new dn({key:Ts,state:{init(){return null},apply(t,n){const r=t.getMeta(Ts);if(r!=null)return r==-1?null:r;if(n==null||!t.docChanged)return n;const{deleted:i,pos:o}=t.mapping.mapResult(n);return i?null:o}},props:{decorations:Y8e,handleDOMEvents:{mousedown:xqe},createSelectionBetween(t){return Ts.getState(t.state)!=null?t.state.selection:null},handleTripleClick:Sqe,handleKeyDown:Cqe,handlePaste:wqe},appendTransaction(t,n,r){return Z8e(r,nX(r,n),e)}})}function s_(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function iU(e,t,n,r,i,o){var a;let s=0,l=!0,c=t.firstChild;const u=e.firstChild;if(u!==null)for(let f=0,p=0;f<u.childCount;f+=1){const{colspan:h,colwidth:m}=u.child(f).attrs;for(let g=0;g<h;g+=1,p+=1){const y=i===p?o:m&&m[g],C=y?`${y}px`:"";if(s+=y||r,y||(l=!1),c){if(c.style.width!==C){const[x,b]=s_(r,y);c.style.setProperty(x,b)}c=c.nextSibling}else{const x=document.createElement("col"),[b,v]=s_(r,y);x.style.setProperty(b,v),t.appendChild(x)}}}for(;c;){const f=c.nextSibling;(a=c.parentNode)===null||a===void 0||a.removeChild(c),c=f}l?(n.style.width=`${s}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${s}px`)}let Fqe=class{constructor(t,n){this.node=t,this.cellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),iU(t,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,iU(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){return t.type==="attributes"&&(t.target===this.table||this.colgroup.contains(t.target))}};function jqe(e,t,n,r){let i=0,o=!0;const a=[],s=e.firstChild;if(!s)return{};for(let f=0,p=0;f<s.childCount;f+=1){const{colspan:h,colwidth:m}=s.child(f).attrs;for(let g=0;g<h;g+=1,p+=1){const y=n===p?r:m&&m[g];i+=y||t,y||(o=!1);const[C,x]=s_(t,y);a.push(["col",{style:`${C}: ${x}`}])}}const l=o?`${i}px`:"",c=o?"":`${i}px`;return{colgroup:["colgroup",{},...a],tableWidth:l,tableMinWidth:c}}function oU(e,t){return t?e.createChecked(null,t):e.createAndFill()}function Lqe(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;const t={};return Object.keys(e.nodes).forEach(n=>{const r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function Dqe(e,t,n,r,i){const o=Lqe(e),a=[],s=[];for(let c=0;c<n;c+=1){const u=oU(o.cell,i);if(u&&s.push(u),r){const f=oU(o.header_cell,i);f&&a.push(f)}}const l=[];for(let c=0;c<t;c+=1)l.push(o.row.createChecked(null,r&&c===0?a:s));return o.table.createChecked(null,l)}function Uqe(e){return e instanceof ut}const Bg=({editor:e})=>{const{selection:t}=e.state;if(!Uqe(t))return!1;let n=0;const r=bJ(t.ranges[0].$from,o=>o.type.name==="table");return r==null||r.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(n+=1)}),n===t.ranges.length?(e.commands.deleteTable(),!0):!1},Bqe=gn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:Fqe,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:e,HTMLAttributes:t}){const{colgroup:n,tableWidth:r,tableMinWidth:i}=jqe(e,this.options.cellMinWidth);return["table",Ut(this.options.HTMLAttributes,t,{style:r?`width: ${r}`:`min-width: ${i}`}),n,["tbody",0]]},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:o})=>{const a=Dqe(o.schema,e,t,n);if(i){const s=r.selection.from+1;r.replaceSelectionWith(a).scrollIntoView().setSelection($e.near(r.doc.resolve(s)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>tqe(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>nqe(e,t),deleteColumn:()=>({state:e,dispatch:t})=>iqe(e,t),addRowBefore:()=>({state:e,dispatch:t})=>aqe(e,t),addRowAfter:()=>({state:e,dispatch:t})=>sqe(e,t),deleteRow:()=>({state:e,dispatch:t})=>cqe(e,t),deleteTable:()=>({state:e,dispatch:t})=>mqe(e,t),mergeCells:()=>({state:e,dispatch:t})=>QD(e,t),splitCell:()=>({state:e,dispatch:t})=>HD(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>Gh("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>Gh("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>hqe(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>QD(e,t)?!0:HD(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>fqe(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>GD(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>GD(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&nX(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){const r=ut.create(t.doc,e.anchorCell,e.headCell);t.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Bg,"Mod-Backspace":Bg,Delete:Bg,"Mod-Delete":Bg}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[oX({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],sX({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(e){const t={name:e.name,options:e.options,storage:e.storage};return{tableRole:Pe(ce(e,"tableRole",t))}}});function lX(e,t){switch(t.type){case"hyperlink":case"paragraph":case"strong":case"em":return jr.converter.fromPrismic(e)(t);default:return}}function cX(e){const{title:t,className:n,onClick:r,tabIndex:i,onMouseDown:o,...a}=e,s=document.createElement("button");return s.className=n,s.setAttribute("type","button"),s.setAttribute("title",t),s.setAttribute("aria-label",t),s.setAttribute("tabIndex","0"),o&&s.addEventListener("mousedown",l=>{const c=l.currentTarget;o(l,c)}),s.addEventListener("click",l=>{const c=l.currentTarget;r(l,c)}),Object.entries(a).forEach(([l,c])=>{s.setAttribute(l,c.toString())}),s}function uX(e){const t=document.createElement("div");return t.innerHTML=e,t.firstChild?t.firstChild:null}class qi extends CustomEvent{constructor({name:t,detail:n}){super(t,{detail:n})}static dispatch(t,n){const{editor:r,...i}=n;r.view.dom.dispatchEvent(new qi({name:t,detail:i}))}static listen(t,n){const{editor:r,callback:i}=n,o=new AbortController;return r.view.dom.addEventListener(t,a=>{const{detail:s}=a;s&&i(s)},{signal:o.signal}),()=>o.abort()}}const Pqe=50,Wqe=25;function EC(e,t){const n=e.nodes[t];if(!n)throw new Error(`Unwanted state: ${t} not found in schema.`);return n}function Ml(e){return ju(t=>t.type.spec.tableRole&&t.type.spec.tableRole==="table")(e)}function dX(e){return ju(t=>t.type.name==="tableRow")(e)}function Nqe(e){return ju(t=>t.type.name==="tableCell"||t.type.name==="tableHeader")(e)}const Kqe={cell:Nqe,row:dX,table:Ml};function rj(e,...t){const n={};for(let r=0;r<t.length;r++){const i=t[r];i&&(n[i]=Kqe[i](e))}return n}function fX(e){var n;const t=(n=Ml(e.state.selection))==null?void 0:n.node;return t&&t.firstChild&&t.type.name==="table"?t.firstChild.childCount:0}function pX(e){var n;const t=(n=Ml(e.state.selection))==null?void 0:n.node;return t&&t.type.name==="table"?t.childCount:0}function Tw(e){return fX(e)>=Wqe}function Iw(e){return pX(e)>=Pqe}function ij(e,t){const{index:n,tr:r}=t,i=Ml(r.selection);if(!i)return r;const o=gt.get(i.node),a=e==="row";if(n<0||n>=(a?o.height:o.width))return r;const s=a?0:n,l=a?n:0,c=a?o.width:n+1,u=a?n+1:o.height,f=o.map[l*o.width+s],p=o.map[(u-1)*o.width+(c-1)];if(!f||!p)return r;const h=i.start+f,m=i.start+p,g=r.doc.resolve(h),y=r.doc.resolve(m);return r.setSelection(new ut(y,g))}function qqe(e){return ij("row",e)}function Vqe(e){return ij("column",e)}function zqe(e){const{direction:t,state:n}=e,{map:r,table:i,tableStart:o,top:a}=Ur(n);if(t==="up"&&a===0||t==="down"&&a>=r.height-1)return;const{tr:s}=n,l=t==="up"?a-1:a+1;let c=o;for(let h=0;h<a;h++)c+=i.child(h).nodeSize;let u=o;for(let h=0;h<l;h++)u+=i.child(h).nodeSize;const f=i.child(a),p=i.child(l);switch(t){case"up":s.replaceWith(c,c+f.nodeSize,p),s.replaceWith(u,u+p.nodeSize,f);break;case"down":s.replaceWith(u,u+p.nodeSize,f),s.replaceWith(c,c+f.nodeSize,p);break}return{tr:s,index:l}}function Qqe(e){const{direction:t,state:n}=e,{map:r,table:i,left:o}=Ur(n);if(t==="left"&&o===0||t==="right"&&o>=r.width-1)return;const{tr:a}=n,s=t==="left"?o-1:o+1;for(let l=0;l<i.children.length;l++){const c=i.children[l];if(!c)return;const u=c.child(o),f=r.map[l*r.width+o];if(!f)return;const p=c.child(s),h=r.map[l*r.width+s];if(!h)return;switch(t){case"left":{a.replaceWith(f,f+u.nodeSize,p),a.replaceWith(h,h+p.nodeSize,u);break}case"right":{a.replaceWith(h,h+p.nodeSize,u),a.replaceWith(f,f+u.nodeSize,p);break}}}return{tr:a,index:s}}const hX="data-prismic-table-handle";function Hqe(e){return t=>{const n=Ml(t);if(n){const r=gt.get(n.node);return(Array.isArray(e)?e:Array.from([e])).reduce((o,a)=>{if(a>=0&&a<=r.width-1){const s=r.cellsInRect({left:a,right:a+1,top:0,bottom:r.height});return o.concat(s.flatMap(l=>{const c=n.node.nodeAt(l),u=l+n.start;return{pos:u,start:u+1,node:c}}))}return o},[])}return null}}function Yqe(e){return t=>{const n=Ml(t);if(n){const r=gt.get(n.node);return(Array.isArray(e)?e:Array.from([e])).reduce((o,a)=>{if(a>=0&&a<=r.height-1){const s=r.cellsInRect({left:0,right:r.width,top:a,bottom:a+1});return o.concat(s.map(l=>{const c=n.node.nodeAt(l),u=l+n.start;return{pos:u,start:u+1,node:c}}))}return o},[])}return null}}function aU(e){const{element:t,type:n}=e,r=t.querySelector(`[${hX}="${n}"]`);if(!r)throw new Error(`No ${n} handle found`);return r}function sU(e){const{type:t,editor:n,index:r}=e,i=cX({title:`Select ${t} & show options`,className:tZ(A.tableFieldStyles.tableHandle,A.tableFieldStyles[`table${Zn.capitalize(t)}Handle`]),[hX]:t,"aria-expanded":!1,onMouseDown:a=>{a.preventDefault(),a.stopImmediatePropagation(),n.view.dispatch(ij(t,{index:r,tr:n.state.tr}))},onClick:(a,s)=>{a.preventDefault(),a.stopImmediatePropagation(),qi.dispatch("handleClick",{type:t,editor:n,referenceElement:s})}}),o=uX(A.rawDragIndicatorIcon);return o&&i.appendChild(o),i}class Gqe{constructor(t){$t(this,"abortController",new AbortController);$t(this,"currentRowHandle",null);$t(this,"currentColumnHandle",null);$t(this,"showCurrentHandles",t=>{try{const n=t.target,r=t.currentTarget;Zqe(r),this.hidePreviousHandles();const i=lU("cell",n),o=this.getRowHandle(i),a=this.getColumnHandle(r,i);this.displayHandle(o),this.displayHandle(a),this.currentColumnHandle=a,this.currentRowHandle=o}catch{}});$t(this,"hidePreviousHandles",()=>{this.currentRowHandle&&this.hideHandle(this.currentRowHandle),this.currentColumnHandle&&this.hideHandle(this.currentColumnHandle)});this.view=t,this.update(this.view)}update(t){this.attachEventListeners(t.dom)}destroy(){this.abortController.abort()}attachEventListeners(t){this.abortController.signal.aborted||this.abortController.abort(),this.abortController=new AbortController;const{signal:n}=this.abortController;t.querySelectorAll("table").forEach(r=>{r.addEventListener("mouseover",this.showCurrentHandles,{signal:n}),r.addEventListener("mouseleave",this.hidePreviousHandles,{signal:n})})}getRowHandle(t){const n=lU("row",t),r=aU({element:n,type:"row"});if(!r)throw new Error("No row handle found");return r}getColumnHandle(t,n){const r=n.cellIndex+1,i=t.querySelector(`tr > th:nth-child(${r}), tr > td:nth-child(${r})`);if(!i)throw new Error("No header cell found");const o=aU({element:i,type:"column"});if(!o)throw new Error("No column handle found");return o}displayHandle(t){t.classList.add(A.tableFieldStyles.tableHandleVisible)}hideHandle(t){t.classList.remove(A.tableFieldStyles.tableHandleVisible)}}const Jqe={cell:["TD","TH"],row:["TR"]};function lU(e,t){const n=Jqe[e];for(const r of n){const i=t.closest(r);if(i)return i}throw new Error(`Failed to find closest ${e}`)}function Zqe(e){if(!e||e.tagName!=="TABLE")throw new Error("Element is not a table")}function Xqe(e){return new dn({key:new qn("tableCellHandles"),view:t=>new Gqe(t),state:{init:(t,n)=>cU({editor:e,state:n}),apply:(t,n,r,i)=>t.docChanged?cU({editor:e,state:i}):n.map(t.mapping,t.doc)},props:{decorations(t){return this.getState(t)}}})}function cU(e){const{editor:t,state:n}=e,r=[],i=Hqe(0)(n.selection);i&&i.forEach(({pos:a},s)=>{r.push(Jn.widget(a+1,()=>sU({type:"row",editor:t,index:s})))});const o=Yqe(0)(n.selection);return o&&o.forEach(({pos:a},s)=>{r.push(Jn.widget(a+1,()=>sU({type:"column",editor:t,index:s})))}),Ot.create(n.doc,r)}const e7e=gn.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:e}){return["td",Ut(this.options.HTMLAttributes,e),0]}}),oj=$.object({key:$.string().nullish(),colspan:$.number().nullish(),rowspan:$.number().nullish(),colwidth:$.array($.number()).nullish()}),AX=e7e.extend({name:"tableCell",addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),key:{default:null}}}}),uU={fromPrismic(e){return function(t){const n=EC(e,AX.name),r=t.columnWidth?[t.columnWidth]:null;return n.create({colspan:1,rowspan:1,colwidth:r,key:t.key},t.content.value.flatMap(i=>lX(e,i)??[]))}},toPrismic(e){const t=[];e.content.forEach(i=>{const o=jr.converter.toPrismic(i);ue.TextBlock.is(o)&&t.push(o)});const n=oj.parse(e.attrs),[r]=n.colwidth??[];return{key:n.key??crypto.randomUUID(),type:"tableCell",content:{__TYPE__:"StructuredTextContent",value:t},columnWidth:r}}},t7e=gn.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:e}){return["th",Ut(this.options.HTMLAttributes,e),0]}}),mX=t7e.extend({name:"tableHeader",addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),key:{default:null}}}}),dU={fromPrismic(e){return function(t){const n=EC(e,mX.name),r=t.columnWidth?[t.columnWidth]:null;return n.create({colspan:1,rowspan:1,colwidth:r,key:t.key},t.content.value.flatMap(i=>lX(e,i)??[]))}},toPrismic(e){const t=[];e.content.forEach(i=>{const o=jr.converter.toPrismic(i);ue.TextBlock.is(o)&&t.push(o)});const n=oj.parse(e.attrs),[r]=n.colwidth??[];return{key:n.key??crypto.randomUUID(),type:"tableHeader",content:{__TYPE__:"StructuredTextContent",value:t},columnWidth:r}}},gX=gn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",Ut(this.options.HTMLAttributes,e),0]}}),n7e=gX.extend({name:"tableRow",addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),key:{default:null}}}}),fU={fromPrismic(e){return function(t){return EC(e,gX.name).create({key:t.key},t.content.map(r=>{switch(r.type){case"tableHeader":return dU.fromPrismic(e)(r);case"tableCell":return uU.fromPrismic(e)(r)}}))}},toPrismic(e){const t=oj.parse(e.attrs),n=[];return e.content.forEach(r=>{switch(r.type.name){case"tableHeader":{n.push(dU.toPrismic(r));break}case"tableCell":{n.push(uU.toPrismic(r));break}}}),{key:t.key??crypto.randomUUID(),type:"tableRow",content:n}}};class r7e extends iX{constructor(t,n){const{node:r,editor:i}=t,{defaultCellMinWidth:o}=n;super(r,o);const a=document.createElement("div");a.classList.add(A.tableFieldStyles.tableWithControls);const s=document.createElement("div");s.classList.add(A.tableFieldStyles.tableOuterWrapper),s.appendChild(this.dom);const l=pU({editor:i,type:"column",onAfterCommand:()=>a.scrollLeft=a.scrollWidth});s.appendChild(l),a.appendChild(s);const c=pU({editor:i,type:"row"});a.appendChild(c),this.dom=a}ignoreMutation(t){return t.target.closest(`.${A.tableFieldStyles.tableOuterWrapper}`)?super.ignoreMutation(t):!0}}function pU(e){const{type:t,editor:n,onAfterCommand:r}=e,i=Zn.capitalize(t),o=cX({title:`Add ${t}`,className:A.tableFieldStyles[`addTable${i}Button`],onClick:()=>{n.commands[`add${i}ToEnd`](),r==null||r()}}),a=uX(A.rawAddIcon);return a&&o.appendChild(a),o}const Ay=Bqe.extend({name:"table",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),resizable:!0,defaultCellMinWidth:120}},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),addRowAfter:()=>t=>{var r,i,o;const{editor:n}=t;return Iw(n)?(qi.dispatch("addAtLimit",{editor:n,type:"row"}),!1):((o=(r=this.parent)==null?void 0:(i=r.call(this)).addRowAfter)==null?void 0:o.call(i)(t))??!1},addRowBefore:()=>t=>{var r,i,o;const{editor:n}=t;return Iw(n)?(qi.dispatch("addAtLimit",{editor:n,type:"row"}),!1):((o=(r=this.parent)==null?void 0:(i=r.call(this)).addRowBefore)==null?void 0:o.call(i)(t))??!1},addRowToEnd:()=>({dispatch:t,state:n,editor:r})=>{if(!mr(n))return!1;if(Iw(r))return qi.dispatch("addAtLimit",{editor:r,type:"row"}),!1;if(t){const i=Ur(n),o=i.map.height;t(nj(n.tr,i,o))}return!0},addColumnAfter:()=>t=>{var r,i,o;const{editor:n}=t;return Tw(n)?(qi.dispatch("addAtLimit",{editor:n,type:"column"}),!1):((o=(r=this.parent)==null?void 0:(i=r.call(this)).addColumnAfter)==null?void 0:o.call(i)(t))??!1},addColumnBefore:()=>t=>{var r,i,o;const{editor:n}=t;return Tw(n)?(qi.dispatch("addAtLimit",{editor:n,type:"column"}),!1):((o=(r=this.parent)==null?void 0:(i=r.call(this)).addColumnBefore)==null?void 0:o.call(i)(t))??!1},addColumnToEnd:()=>({dispatch:t,state:n,editor:r})=>{if(!mr(n))return!1;if(Tw(r))return qi.dispatch("addAtLimit",{editor:r,type:"column"}),!1;if(t){const i=Ur(n),o=i.map.width;t(tj(n.tr,i,o))}return!0},moveRow:t=>({dispatch:n,state:r})=>{if(!mr(r))return!1;if(n){i7e();const i=zqe({direction:t,state:r});if(!i)return!1;const o=qqe(i);n(o)}return!0},moveColumn:t=>({dispatch:n,state:r})=>{if(!mr(r))return!1;if(n){const i=Qqe({direction:t,state:r});if(!i)return!1;const o=Vqe(i);n(o)}return!0}}},addNodeView(){return e=>new r7e(e,this.options)},addKeyboardShortcuts(){var e;return{...(e=this.parent)==null?void 0:e.call(this),Backspace:()=>!1,"Mod-Backspace":()=>!1,Delete:()=>!1,"Mod-Delete":()=>!1}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[oX(this.options)]:[],sX(this.options),Xqe(this.editor),o7e()]}});function i7e(){if(!window.getSelection)return;const e=window.getSelection();e!=null&&e.empty?e.empty():e!=null&&e.removeAllRanges&&e.removeAllRanges()}function o7e(){return new dn({filterTransaction(e,t){for(const n of e.steps){const i=a7e(t,n.from);if(i&&i.type.name===Ay.name)return!1}return!0}})}function a7e(e,t){try{return e.doc.nodeAt(t)}catch{return null}}const s7e={fromPrismic(e){return function(t){return EC(e,Ay.name).create({},t.content.map(fU.fromPrismic(e)))}},toPrismic(e){var n;const t=((n=e.content.firstChild)==null?void 0:n.type.name)===Ay.name?e.content.firstChild:e;return{type:"table",content:Hs.children.map(t,r=>fU.toPrismic(r))}}},l7e=new c4e([lc.table],lc.table,[Ay,n7e,mX,AX],s7e),vX=[qF,GF,BZ],yX=[...vX,JF];function bX(e){return X6e(e)?[...vX,jr,l7e].filter(Hi.isDefined):[jr,fy,hy,Kl.build(e),TZ,RZ,FZ,...yX].filter(Hi.isDefined)}const CX=[{nodeType:fe.RichTextNodeType.paragraph,icon:"textFields",isActive:e=>e.isActive(jr.name)&&!e.isActive(fy.name)&&!e.isActive(hy.name),runCommands:Wt((e,t)=>e.clearNodes().setDirection(Ki(t))),shortText:"par",text:"Paragraph"},{nodeType:fe.RichTextNodeType.heading1,icon:"looks1",isActive:e=>e.isActive(Kl.name,{level:1}),runCommands:Wt((e,t)=>e.setHeading({level:1}).setDirection(Ki(t))),shortText:"h1",text:"Heading 1"},{nodeType:fe.RichTextNodeType.heading2,icon:"looks2",isActive:e=>e.isActive(Kl.name,{level:2}),runCommands:Wt((e,t)=>e.setHeading({level:2}).setDirection(Ki(t))),shortText:"h2",text:"Heading 2"},{nodeType:fe.RichTextNodeType.heading3,icon:"looks3",isActive:e=>e.isActive(Kl.name,{level:3}),runCommands:Wt((e,t)=>e.setHeading({level:3}).setDirection(Ki(t))),shortText:"h3",text:"Heading 3"},{nodeType:fe.RichTextNodeType.heading4,icon:"looks4",isActive:e=>e.isActive(Kl.name,{level:4}),runCommands:Wt((e,t)=>e.setHeading({level:4}).setDirection(Ki(t))),shortText:"h4",text:"Heading 4"},{nodeType:fe.RichTextNodeType.heading5,icon:"looks5",isActive:e=>e.isActive(Kl.name,{level:5}),runCommands:Wt((e,t)=>e.setHeading({level:5}).setDirection(Ki(t))),shortText:"h5",text:"Heading 5"},{nodeType:fe.RichTextNodeType.heading6,icon:"looks6",isActive:e=>e.isActive(Kl.name,{level:6}),runCommands:Wt((e,t)=>e.setHeading({level:6}).setDirection(Ki(t))),shortText:"h6",text:"Heading 6"},{nodeType:fe.RichTextNodeType.list,icon:"formatListBulleted",isActive:e=>e.isActive(fy.name),runCommands:Wt((e,t)=>e.toggleBulletList().setDirection(Ki(t))),shortText:"bull",text:"Bulleted list"},{nodeType:fe.RichTextNodeType.orderedList,icon:"formatListNumbered",isActive:e=>e.isActive(hy.name),runCommands:Wt((e,t)=>e.toggleOrderedList().setDirection(Ki(t))),shortText:"num",text:"Numbered list"},{nodeType:fe.RichTextNodeType.preformatted,icon:"dataObject",isActive:e=>e.isActive(TZ.name),runCommands:Wt((e,t)=>e.setCodeBlock().setDirection(Ki(t))),shortText:"code",text:"Code"},{nodeType:fe.RichTextNodeType.embed,icon:"cloud",isActive:e=>e.isActive(RZ.name),runCommands:Wt(e=>e.setEmbed()),shortText:"emb",text:"Embed"},{nodeType:fe.RichTextNodeType.image,icon:"image",isActive:e=>e.isActive(FZ.name),runCommands:Wt(e=>e.setImage()),shortText:"img",text:"Image"}],c7e=[{nodeType:fe.RichTextNodeType.strong,icon:"formatBold",isActive:e=>e.isActive(qF.name),runCommands:Wt(e=>e.toggleBold())},{nodeType:fe.RichTextNodeType.em,icon:"formatItalic",isActive:e=>e.isActive(GF.name),runCommands:Wt(e=>e.toggleItalic())}],u7e=[{nodeType:fe.RichTextNodeType.rtl,icon:"formatTextDirectionRToL",isActive:e=>e.isActive({[ya]:Jl}),runCommands:Wt((e,t)=>e.toggleDirection(Ki(t)))}];function Wt(e){return(t,n={})=>{let r=n.can===!0?t.can().chain():t.chain().focus();return n.deleteRange!==void 0&&(r=r.deleteRange(n.deleteRange)),n.can?d7e(t,r,e):e(r,t).run()}}function Ki(e){const t=e.state.selection.$from.parent.attrs;return Ea.parseNodeAttrsDirection(t)}function uv(e,t){return e.filter(n=>t.includes(n.nodeType))}function d7e(e,t,n){try{return n(t,e).run()}catch{return!1}}function f7e(e){const{items:t,editor:n}=e;return t.length===0?null:d.jsxs(d.Fragment,{children:[t.map(r=>d.jsx(A.ToolbarToggleButton,{disabled:!r.runCommands(n,{can:!0}),onPressedChange:()=>{r.runCommands(n)},pressed:r.isActive(n),startIcon:r.icon},r.nodeType)),d.jsx(A.ToolbarSeparator,{})]})}function p7e(e){const{labels:t,editor:n}=e,r=n.getAttributes("label").label;return d.jsxs(d.Fragment,{children:[d.jsxs(A.DropdownMenu,{children:[d.jsx(A.DropdownMenuTrigger,{disabled:t.length===0,children:d.jsx(A.Button,{endIcon:"arrowDropDown",size:"small",color:"grey",children:hU(r??"Labels")})}),d.jsx(A.DropdownMenuContent,{align:"start",asPortal:!1,maxHeight:256,avoidCollisions:!1,children:t.map((i,o)=>{const a=r===i;return d.jsx(A.DropdownMenuItem,{onSelect:()=>a?n.commands.unsetLabel():h7e(n,i),endIcon:a&&d.jsx(A.Icon,{name:"check",size:"extraSmall"}),children:hU(i)},`${i}-${o}`)})})]}),d.jsx(A.ToolbarSeparator,{})]})}function h7e(e,t){Wt(r=>r.setLabel({label:t}))(e)}function hU(e){return Zn.overflow(e,20)}function A7e(e){const{editor:t}=e,n=t.getAttributes("label");if(!n.label)return null;const r=n.label;return d.jsx(A.Box,{backgroundColor:"purple9",padding:{block:2,inline:4},alignItems:"center",borderRadius:{topLeft:2,topRight:2,bottomRight:2},maxWidth:125,children:d.jsx(A.Text,{color:"white",variant:"small",noWrap:!0,children:r})})}function m7e(e){const{disabled:t,showWebLinkModal:n,showDocumentsLinkModal:r,showMediaLinkModal:i}=g7e(e);return d.jsxs(d.Fragment,{children:[d.jsxs(A.ToolbarButtonGroup,{density:"compact",children:[d.jsx(A.ToolbarButton,{disabled:t,startIcon:"link",onClick:n},fe.RichTextNodeType.hyperlink),d.jsxs(A.DropdownMenu,{children:[d.jsx(A.DropdownMenuTrigger,{children:d.jsx(A.ToolbarButton,{startIcon:"arrowDropDown"})}),d.jsxs(A.DropdownMenuContent,{align:"end",asPortal:!1,children:[d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"public"}),onSelect:n,children:"Link to web page"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"description"}),onSelect:r,children:"Link to document"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"image"}),onSelect:i,children:"Link to media"})]})]})]}),d.jsx(A.ToolbarSeparator,{})]})}function g7e(e){const{editor:t,setModal:n}=e;function r(){n("webLink")}function i(){n("documentLink")}function o(){n("mediaLink")}return{disabled:!Wt(s=>s.setWebLink({href:""}))(t,{can:!0}),showWebLinkModal:r,showDocumentsLinkModal:i,showMediaLinkModal:o}}function v7e(e){const{docId:t,onEdit:n,onUnlink:r}=e,i=y7e(t),o=be();if(!i)return null;const a=i.versions[0],s=oF({status:a==null?void 0:a.status,releaseId:(a==null?void 0:a.status)==="release"?a.release_id:void 0,documentId:i.id,versionId:a==null?void 0:a.version_id,baseUrl:o.baseUrl}),l=(a==null?void 0:a.preview_summary)??"",c=(a==null?void 0:a.custom_type_label)??"";return d.jsx(xc,{url:s,title:i.title,subTitle:c,description:l,onEdit:n,onUnlink:r,largeIconName:"description"})}function y7e(e){const t=be();t.searchDocuments||At("searchDocuments");const{coreApiBaseUrl:n,authStrategy:r}=t;return Xe.useRequest(Qm,[n,r,e])}function b7e(e){const{editor:t}=e,{searchDocuments:n}=be(),r=t.getAttributes(fe.RichTextNodeType.hyperlink);if(r.id&&n){const i=r.id;return d.jsx(C7e,{docId:i,...e})}if(r.href){const i=r.href;return d.jsx(S7e,{url:i,...e})}if(r.media){const i=PZ(r.media);return d.jsx(w7e,{media:i,...e})}return null}function C7e(e){const{editor:t,onEditDocumentLink:n,docId:r}=e;return d.jsx(A.ErrorBoundary,{renderError:()=>d.jsx(xc,{title:"Failed to Load Linked Document Data",error:!0,onEdit:n,onUnlink:()=>uc(t)}),children:d.jsx(I.Suspense,{fallback:d.jsx(xc,{loading:!0,onEdit:n,onUnlink:()=>uc(t)}),children:d.jsx(v7e,{docId:r,onEdit:n,onUnlink:()=>uc(t)})})})}function S7e(e){const{url:t,editor:n,onEditWebLink:r}=e,i=ai.toURL(t);return i?d.jsx(xc,{url:t,title:ai.getUrlTitle(i),subTitle:t,onEdit:r,onUnlink:()=>uc(n)}):d.jsx(xc,{url:t,subTitle:t,onEdit:r,onUnlink:()=>uc(n)})}function w7e(e){const{media:t,editor:n,onEditMediaLink:r}=e;return ue.FilledImageLinkContent.is(t)?d.jsx(SY,{url:t.url,title:t.name,subTitle:`${t.width} x ${t.height} pixels`,onEdit:r,onUnlink:()=>uc(n)}):ue.FilledFileLinkContent.is(t)?d.jsx(xc,{url:t.url,title:t.name,subTitle:x7e({filename:t.name}),largeIconName:"insertDriveFile",onEdit:r,onUnlink:()=>uc(n)}):null}function uc(e){Wt(n=>n.unsetLink())(e)}function x7e(e){const{filename:t}=e,n=t.split(".").pop();return n?n.toLowerCase():""}function _7e(e){const{open:t}=e,{onOpenChange:n,onSelectDocument:r}=T7e(e);return d.jsx(vY,{open:t,onOpenChange:n,onSelectDocument:r})}function T7e(e){const{editor:t,setOpen:n}=e;function r(o){Wt(s=>s.extendMarkRange(fe.RichTextNodeType.hyperlink).setDocumentLink({id:o}))(t),n(!1)}function i(o){n(o)}return{onSelectDocument:r,onOpenChange:i}}function I7e(e){const{open:t}=e,{onOpenChange:n,onMediaSelected:r}=R7e(e);return d.jsx(uF,{open:t,onOpenChange:n,onMediaSelected:r,assetType:"all"})}function R7e(e){const{editor:t,setOpen:n}=e;function r(i){Wt(a=>a.extendMarkRange(fe.RichTextNodeType.hyperlink).setMediaLink({media:i}))(t),n(!1)}return{onMediaSelected:r,onOpenChange:n}}function E7e(e){const{open:t,setOpen:n}=e,{url:r,setUrl:i,openInNewTab:o,setOpenInNewTab:a,disabled:s,onUpdate:l}=$7e(e);return d.jsxs(A.Dialog,{open:t,onOpenChange:n,size:"small",noDescription:!0,children:[d.jsx(A.DialogHeader,{title:"Set Link URL"}),d.jsxs(A.DialogContent,{padding:16,children:[d.jsx(A.FormInput,{value:r,onValueChange:i,placeholder:"Paste URL",icon:"public"}),r&&d.jsx(A.InlineLabel,{value:"Open in new tab",children:d.jsx(A.Checkbox,{checked:o,onCheckedChange:a})})]}),d.jsxs(A.DialogActions,{children:[d.jsx(A.DialogCancelButton,{}),d.jsx(A.DialogActionButton,{onClick:l,disabled:s,children:"Update"})]})]})}function $7e(e){const{editor:t,open:n,setOpen:r}=e,i=k7e(t),[o,a]=I.useState(i.url),[s,l]=I.useState(i.openInNewTab);ze.useOnChange(n,()=>{n&&(a(i.url),l(i.openInNewTab))});const c=!o||o===i.url&&s===i.openInNewTab;function u(){const f=s?"_blank":"_self";Wt(p=>p.extendMarkRange(fe.RichTextNodeType.hyperlink).setWebLink({href:o,target:f}))(t),r(!1)}return{url:o,setUrl:a,openInNewTab:s,disabled:c,setOpenInNewTab:l,onUpdate:u}}function k7e(e){const t=e.getAttributes(fe.RichTextNodeType.hyperlink);return{url:t.href??"",openInNewTab:t.target==="_blank"}}function O7e(e){const{items:t,editor:n}=e;return t.length===0?null:d.jsxs(d.Fragment,{children:[d.jsx(A.ToolbarToggleButtonGroup,{onValueChange:r=>{t.forEach(i=>{(i.isActive(n)&&!r.includes(i.nodeType)||!i.isActive(n)&&r.includes(i.nodeType))&&i.runCommands(n)})},type:"multiple",value:t.filter(r=>r.isActive(n)).map(r=>r.nodeType),children:t.map(r=>d.jsx(A.ToolbarToggleButtonGroupItem,{disabled:!r.runCommands(n,{can:!0}),startIcon:r.icon,value:r.nodeType},r.nodeType))},"mark"),d.jsx(A.ToolbarSeparator,{})]})}function M7e(e){var r;const{items:t,editor:n}=e;return t.length===0?null:d.jsxs(d.Fragment,{children:[d.jsxs(A.DropdownMenu,{children:[d.jsx(A.DropdownMenuTrigger,{disabled:t.length===1,children:d.jsx(A.Button,{endIcon:"arrowDropDown",size:"small",color:"grey",children:((r=t.find(i=>i.isActive(n)))==null?void 0:r.text)??""})}),d.jsx(A.DropdownMenuContent,{align:"start",asPortal:!1,maxHeight:256,avoidCollisions:!1,children:t.map(i=>d.jsx(A.DropdownMenuItem,{onSelect:()=>{i.runCommands(n)},children:i.text},i.nodeType))})]}),d.jsx(A.ToolbarSeparator,{})]})}function Rw(e){return{duration:100,hideOnClick:!0,offset:e,placement:"top-start",appendTo:document.querySelector("body > div")??"parent"}}function F7e(e){const{editor:t,nodeTypes:n,labels:r,hideDisabledOptions:i=!1}=e,[o,a]=I.useState(),s=n.includes(fe.RichTextNodeType.hyperlink),l=!o,{shouldShowBubbleMenu:c,shouldshowPopover:u}=L7e({editor:t}),[f,p]=I.useState(!0);I.useEffect(()=>{p(!1)},[]);function h(y){a(y?"webLink":void 0)}function m(y){a(y?"documentLink":void 0)}function g(y){a(y?"mediaLink":void 0)}return f?null:d.jsxs(d.Fragment,{children:[d.jsx(fw,{editor:t,tippyOptions:Rw([-48,0]),shouldShow:c,children:l&&d.jsx(j7e,{editor:t,nodeTypes:n,labels:r,setModal:a,hideDisabledOptions:i})}),d.jsx(fw,{editor:t,tippyOptions:Rw([-48,0]),shouldShow:y=>u(y,"hyperlink"),children:l&&d.jsx(b7e,{editor:t,onEditWebLink:()=>a("webLink"),onEditDocumentLink:()=>a("documentLink"),onEditMediaLink:()=>a("mediaLink")})}),d.jsx(fw,{editor:t,tippyOptions:Rw([0,0]),shouldShow:y=>u(y,"label"),children:d.jsx(A7e,{editor:t})}),s&&d.jsxs(d.Fragment,{children:[d.jsx(E7e,{open:o==="webLink",setOpen:h,editor:t}),d.jsx(_7e,{open:o==="documentLink",setOpen:m,editor:t}),d.jsx(I7e,{open:o==="mediaLink",setOpen:g,editor:t})]})]})}function j7e(e){const{editor:t,nodeTypes:n,labels:r,setModal:i,hideDisabledOptions:o}=e,a=n.includes("hyperlink"),s=r.length>0,l=uv(CX,n),c=uv(c7e,n),u=uv(u7e,n),f=o&&l.length===1?0:l.length,p=f+c.length+u.length+Number(a);return p===0?null:d.jsxs(A.Toolbar,{children:[f>0&&d.jsx(M7e,{items:l,editor:t}),s&&d.jsx(p7e,{labels:r,editor:t}),d.jsx(O7e,{items:c,editor:t}),a&&d.jsx(m7e,{editor:t,setModal:i}),d.jsx(f7e,{items:u,editor:t}),p>1&&d.jsx(A.ToolbarButton,{onClick:()=>{t.chain().focus().clearNodes().unsetAllMarks().run()},startIcon:"formatClear"},"clear")]})}function L7e(e){const{editor:t}=e;function n(i){const{view:o,state:a,from:s,to:l}=i;if(!o.hasFocus())return!1;const{doc:c,selection:u}=a;return!(t.isActive(fe.RichTextNodeType.preformatted)||u.empty||c.textBetween(s,l).length===0)}function r(i,o){const{view:a,state:s,from:l,to:c}=i,u=a.state.doc.nodeAt(l),{doc:f,selection:p}=s;return!p.empty||f.textBetween(l,c).length>0?!1:!!(u!=null&&u.marks.some(m=>m.type.name===o))}return{shouldShowBubbleMenu:n,shouldshowPopover:r}}const D7e=["id","data-state","aria-expanded","aria-controls","aria-haspopup"],SX=I.forwardRef(function(t,n){const{anchorElement:r,...i}=t;I.useEffect(()=>{if(r)for(const[a,s]of Object.entries(i))U7e(a,s)&&B7e(r,a,s)},[i,r]);function o(){!r||typeof n!="function"||n(r)}return d.jsx("div",{ref:o,style:{display:"none"}})});function U7e(e,t){return D7e.includes(e)?typeof t=="boolean"||typeof t=="number"||typeof t=="string":!1}function B7e(e,t,n){n!=null&&n!==""?e.setAttribute(t,n.toString()):e.removeAttribute(t)}function P7e(e){const{table:t,row:n}=rj(e.state.selection,"table","row");return!t||!n?{isFirstRow:!1,isLastRow:!1}:{isFirstRow:t.node.firstChild===n.node,isLastRow:t.node.lastChild===n.node}}function W7e(e){const{table:t,row:n}=rj(e.state.selection,"table","row");return!t||!n?!1:t.node.child(1)===n.node}const wX=e=>{var r;const t=(r=Ml(e.state.selection))==null?void 0:r.node;if(!t||t.type.name!=="table")return!1;const n=t.firstChild;if(!n||n.type.name!=="tableRow")return!1;for(let i=0;i<n.childCount;i++){const o=n.child(i);if((o==null?void 0:o.type.name)!=="tableHeader")return!1}return!0},N7e=e=>pX(e)===1;function K7e(e){const{table:t,cell:n}=rj(e.state.selection,"table","cell");return!t||!n?!1:t.node.child(0).child(1)===n.node}function q7e(e){var r;const t=(r=dX(e.state.selection))==null?void 0:r.node,n=e.state.selection.$from.index(-1);return t?{isFirstColumn:n===0,isLastColumn:n===t.childCount-1}:{isFirstColumn:!1,isLastColumn:!1}}const xX=e=>{var n;const t=(n=Ml(e.state.selection))==null?void 0:n.node;if(!t||t.type.name!=="table")return!1;for(let r=0;r<t.childCount;r++){const o=t.child(r).firstChild;if((o==null?void 0:o.type.name)!=="tableHeader")return!1}return!0},V7e=e=>fX(e)===1;function z7e(e){const{editor:t,open:n,onOpenChange:r,triggerElement:i}=e,o=xX(t),a=V7e(t),s=q7e(t);function l(){const m=wX(t);t.commands.deleteColumn(),r==null||r(!1),a&&o&&(c(),m||t.commands.toggleHeaderRow())}function c(){t.commands.toggleHeaderColumn()}function u(){o&&s.isFirstColumn?t.chain().toggleHeaderColumn().addColumnBefore().toggleHeaderColumn().run():t.commands.addColumnBefore(),r==null||r(!1)}function f(){t.commands.addColumnAfter(),r==null||r(!1)}function p(){const m=o&&K7e(t),g=t.chain();m?g.toggleHeaderColumn().moveColumn("left").toggleHeaderColumn():g.moveColumn("left"),g.run(),r==null||r(!1)}function h(){const m=o&&s.isFirstColumn,g=t.chain();m?g.toggleHeaderColumn().moveColumn("right").toggleHeaderColumn():g.moveColumn("right"),g.run(),r==null||r(!1)}return d.jsxs(A.DropdownMenu,{open:n,onOpenChange:r,modal:!0,children:[d.jsx(A.DropdownMenuTrigger,{children:d.jsx(SX,{anchorElement:i})}),d.jsxs(A.DropdownMenuContent,{align:"start",side:"right",sideOffset:4,children:[d.jsx(A.DropdownMenuLabel,{children:d.jsx(A.Text,{color:"grey11",variant:"small",children:"Column options"})}),s.isFirstColumn&&d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"viewDay"}),onSelect:c,disabled:a,children:d.jsxs(A.Box,{gap:12,alignItems:"center",children:["Header Column",d.jsx(A.Switch,{size:"extraSmall",checked:o})]})}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"arrowBack"}),onSelect:u,children:"Insert Left"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"arrowForward"}),onSelect:f,children:"Insert Right"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"moveLeft"}),onSelect:p,disabled:s.isFirstColumn,children:"Move Left"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"moveRight"}),onSelect:h,disabled:s.isLastColumn,children:"Move Right"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"delete"}),onSelect:l,disabled:a,children:"Delete Column"})]})]})}function Q7e(e){const{editor:t,open:n,onOpenChange:r,triggerElement:i}=e,o=wX(t),a=N7e(t),s=P7e(t);function l(){const m=xX(t);t.commands.deleteRow(),r==null||r(!1),a&&o&&(c(),m||t.commands.toggleHeaderColumn())}function c(){t.commands.toggleHeaderRow()}function u(){o&&s.isFirstRow?t.chain().toggleHeaderRow().addRowBefore().toggleHeaderRow().run():t.commands.addRowBefore(),r==null||r(!1)}function f(){t.commands.addRowAfter(),r==null||r(!1)}function p(){const m=o&&W7e(t),g=t.chain();m?g.toggleHeaderRow().moveRow("up").toggleHeaderRow():g.moveRow("up"),g.run(),r==null||r(!1)}function h(){const m=o&&s.isFirstRow,g=t.chain();m?g.toggleHeaderRow().moveRow("down").toggleHeaderRow():g.moveRow("down"),g.run(),r==null||r(!1)}return d.jsxs(A.DropdownMenu,{open:n,onOpenChange:r,modal:!0,children:[d.jsx(A.DropdownMenuTrigger,{children:d.jsx(SX,{anchorElement:i})}),d.jsxs(A.DropdownMenuContent,{align:"start",side:"right",sideOffset:4,children:[d.jsx(A.DropdownMenuLabel,{children:d.jsx(A.Text,{color:"grey11",variant:"small",children:"Row options"})}),s.isFirstRow&&d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"viewDay"}),onSelect:c,disabled:a,children:d.jsxs(A.Box,{gap:12,alignItems:"center",children:[d.jsx(A.Text,{noWrap:!0,children:"Header row"}),d.jsx(A.Switch,{size:"extraSmall",checked:o})]})}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"arrowUpward"}),onSelect:u,children:"Insert Above"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"arrowDownward"}),onSelect:f,children:"Insert Below"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"moveUp"}),onSelect:p,disabled:s.isFirstRow,children:"Move Up"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"moveDown"}),onSelect:h,disabled:s.isLastRow,children:"Move Down"}),d.jsx(A.DropdownMenuItem,{startIcon:d.jsx(A.Icon,{name:"delete"}),onSelect:l,disabled:a,children:"Delete Row"})]})]})}function H7e(e){return d.jsxs(d.Fragment,{children:[d.jsx(Y7e,{...e}),d.jsx(G7e,{...e})]})}function Y7e(e){const{editor:t}=e,{triggerElement:n,open:r,onOpenChange:i}=_X("row",t);return d.jsx(Q7e,{open:r,editor:t,triggerElement:n,onOpenChange:i})}function G7e(e){const{editor:t}=e,{triggerElement:n,open:r,onOpenChange:i}=_X("column",t);return d.jsx(z7e,{open:r,editor:t,triggerElement:n,onOpenChange:i})}function _X(e,t){const[n,r]=I.useState(),[i,o]=I.useState(!1);return I.useEffect(()=>qi.listen("handleClick",{editor:t,callback:a=>{a.type===e&&(r(a.referenceElement),setTimeout(()=>o(!0),0))}}),[t,e]),{open:i,onOpenChange:o,triggerElement:n}}function J7e(e){const{editor:t}=e,{open:n,onOpenChange:r}=Z7e(t);return d.jsx(A.Toast,{title:"You've reached the limit (50 rows / 25 columns).",action:{title:"Need more?",onClick:()=>window.open("https://community.prismic.io/t/how-should-the-table-field-evolve-your-call/18542","_blank")},open:n,onOpenChange:r,anchor:d.jsx(A.Box,{position:"fixed",left:0,right:0,bottom:72}),cancel:{onClick:()=>r(!1)}})}function Z7e(e){const[t,n]=I.useState(!1),{onAnalyticsEvent:r}=be();return I.useEffect(()=>qi.listen("addAtLimit",{editor:e,callback:i=>{r==null||r("Table Limit Reached",{type:i.type}),n(!0)}}),[e,r]),{open:t,onOpenChange:n}}function TX(e){const{content:t,field:n,id:r,readOnly:i,padding:o="normal",scroll:a="hidden",shouldReturnEmptyContent:s=!1}=e,l=X7e(n),c=t&&Wx.converter(l.nodeExtensions).fromPrismic(l.schema,l.nodeTypes,t),u=ze.useStableCallback(e.onContentChange),f=A.useEditor({content:c==null?void 0:c.toJSON(),editable:!i,editorProps:{attributes:{class:tZ(o==="zero"?A.contentEditableNoPaddingClass:A.contentEditableClass,A.contentEditableMultilinePlaceholderClass),id:r,tabIndex:"0"}},extensions:l.allComponents,injectCSS:!1,onUpdate({editor:p}){if(p.isEmpty&&!s)return u(void 0);const h=Wx.converter(l.nodeExtensions).toPrismic(p.state.doc);u(h)}},[l,i]);return d.jsxs(A.Field,{display:a==="x-auto"?"grid":"flex",children:[d.jsx(A.FieldLabel,{htmlFor:r,children:Tr(n)}),d.jsxs(A.FieldControl,{children:[f.isEditable&&d.jsx(F7e,{editor:f,nodeTypes:l.names,labels:l.labels,hideDisabledOptions:!0}),f.isEditable&&l.names.includes("table")&&d.jsxs(d.Fragment,{children:[d.jsx(H7e,{editor:f}),d.jsx(J7e,{editor:f})]}),d.jsx(q6e,{editor:f,style:{width:"100%"}})]})]})}function X7e(e){var n,r;const t=`${((n=e.config)==null?void 0:n.multi)??""}-${((r=e.config)==null?void 0:r.single)??""}`;return I.useMemo(()=>{var m;const{extensions:i,nodeTypes:o}=d4e(e.config),a=i.filter(eVe),s=i.flatMap(g=>g.richTextNodeTypes);o.has(xD)&&s.push(xD);const l=i.flatMap(g=>g.component),c=i.filter(tVe).map(g=>g.name),u=[...l,...j9e(e,a),V4e.configure({supportedExtensionNames:c}),n5e,G3e],f=u.map(g=>g.name),p=f3e(u),h=nVe((m=e.config)==null?void 0:m.labels);return{allComponents:u,extensionNames:f,nodeTypes:o,nodeExtensions:a,names:s,schema:p,labels:h}},[t])}function eVe(e){return e.extType===Lu.Node}function tVe(e){return!(e.extType!==Lu.Node||e.nodeType!==Gl.Text||e.lockedFormat)}function nVe(e){return Array.from(e??[])}function rVe(e){const{content:t,field:n,id:r,readOnly:i,onContentChange:o}=e,{placeholder:a,options:s}=n.config??{},l=!!(s!=null&&s.includes("")),c=aVe(n),u=iVe({content:t,placeholder:a,defaultValue:c,canHaveEmptyValue:l}),f=a&&c===void 0||a===void 0&&!l;return d.jsxs(A.Field,{children:[d.jsx(A.FieldIcon,{name:"arrowDropDownCircle"}),d.jsx(A.FieldLabel,{htmlFor:r,children:Tr(n)}),d.jsx(A.FieldControl,{children:d.jsxs(A.Select,{id:r,size:"large",color:"grey",value:u,disabled:i,renderTrigger:()=>d.jsx(A.SelectGhostTrigger,{id:r}),onValueChange:p=>{o(oVe({value:p,placeholder:a}))},children:[f&&d.jsx(A.SelectItem,{value:a||my,children:a||""}),s==null?void 0:s.map(p=>d.jsx(A.SelectItem,{value:p||my,children:p},p))]})})]})}function iVe(e){const{content:t,placeholder:n,defaultValue:r,canHaveEmptyValue:i}=e;let{value:o}=t??{};return o===""&&i?my:(o===""&&(o=void 0),o??r??n??"")}function oVe(e){const{placeholder:t}=e;let{value:n}=e;if(n!==t)return n===my&&(n=""),{__TYPE__:"FieldContent",type:"Select",value:n}}function aVe(e){var t,n;return((t=e.config)==null?void 0:t.default_value)===void 0||(n=e.config.options)==null?void 0:n[0]}const my=" ",AU=IX(2,3),sVe={__TYPE__:"TableContent",content:IX(1,1)};function lVe(e){const{field:t,content:n,onContentChange:r,...i}=e;function o(a){if(!a)return r(sVe);e.onContentChange(dVe(a))}return d.jsx(TX,{...i,field:fVe(t),content:cVe(n),onContentChange:o,shouldReturnEmptyContent:!0,scroll:"x-auto",padding:"zero"})}function IX(e,t){return Array.from({length:e},()=>({key:crypto.randomUUID(),type:"tableRow",content:Array.from({length:t},()=>({key:crypto.randomUUID(),type:"tableCell",content:{__TYPE__:"StructuredTextContent",value:[{type:"paragraph",content:{text:""}}]}}))}))}function cVe(e){return{__TYPE__:"StructuredTextContent",value:[{type:"table",content:uVe(e)}]}}function uVe(e){const t=ue.TableContent.decode(e);return t._tag==="Left"||!t.right.content.some(r=>r.content.some(i=>i.content.value.some(({type:o})=>o)))?AU:t.right.content}function dVe(e){return{__TYPE__:"TableContent",content:e.value.flatMap(t=>t.type==="table"?t.content:[])}}function fVe(e){var t;return{...fe.TableCell,config:{...fe.TableCell.config,label:(t=e.config)==null?void 0:t.label,allowTargetBlank:!0,multi:[fe.TableCell.config.multi,lc.table].join(",")}}}function pVe(e){const{id:t,readOnly:n,field:r,content:i,onContentChange:o}=e,a=i!=null&&i.value?u_.dateFromISOString(i.value):void 0;return d.jsxs(A.Field,{children:[d.jsx(A.FieldIcon,{name:"event"}),d.jsx(A.FieldLabel,{id:t,children:Tr(r)}),d.jsx(A.FieldControl,{children:d.jsx(A.Box,{padding:{left:4,right:12},width:"100%",flexDirection:"column",justifyContent:"center",children:d.jsx(A.DateInput,{mode:"date-time","aria-labelledby":t,disabled:n,value:a,onValueChange:s=>o(hVe(s))})})})]})}function hVe(e){if(e)return{__TYPE__:"FieldContent",type:"Timestamp",value:AVe(e)}}function AVe(e){const t=`${e.getUTCFullYear()}`.padStart(4,"0"),n=`${e.getUTCMonth()+1}`.padStart(2,"0"),r=`${e.getUTCDate()}`.padStart(2,"0"),i=`${e.getUTCHours()}`.padStart(2,"0"),o=`${e.getUTCMinutes()}`.padStart(2,"0");return`${t}-${n}-${r}T${i}:${o}:00+00:00`}function $C(e){const{id:t,readOnly:n,content:r,nestableWidget:i}=e,o=ze.useStableCallback(e.onContentChange);return I.useMemo(()=>{const a={id:t,readOnly:n,onContentChange:o};return i.type==="Boolean"?d.jsx($Ue,{...a,field:i,content:ue.isBooleanContent(r)?r:void 0}):i.type==="Date"?d.jsx(FUe,{...a,field:i,content:ue.isDateContent(r)?r:void 0}):i.type==="Timestamp"?d.jsx(pVe,{...a,field:i,content:ue.isTimestampContent(r)?r:void 0}):i.type==="Image"?d.jsx(APe,{...a,field:i,content:ue.isImageContent(r)?r:void 0}):i.type==="Link"?d.jsx($Pe,{...a,field:i,content:r}):i.type==="Number"?d.jsx(kPe,{...a,field:i,content:ue.isNumberContent(r)?r:void 0}):i.type==="StructuredText"?d.jsx(TX,{...a,field:i,content:ue.isRichTextContent(r)?r:void 0}):i.type==="Select"?d.jsx(rVe,{...a,field:i,content:ue.isSelectContent(r)?r:void 0}):i.type==="Text"?d.jsx(kY,{...a,field:i,content:ue.isTextContent(r)?r:void 0}):i.type==="Embed"?d.jsx(VUe,{...a,field:i,content:ue.isEmbedContent(r)?r:void 0}):i.type==="Color"?d.jsx(OUe,{...a,field:i,content:ue.isColorContent(r)?r:void 0}):i.type==="GeoPoint"?d.jsx(zUe,{...a,field:i,content:ue.isGeoPointContent(r)?r:void 0}):i.type==="IntegrationFields"?d.jsx(RPe,{...a,field:i,content:ue.isIntegrationFieldContent(r)?r:void 0}):i.type==="Table"?d.jsx(lVe,{...a,field:i,content:ue.isTableContent(r)?r:void 0}):null},[r,t,i,o,n])}function mVe(e){const{content:t,id:n,nonRepeatableZone:r,onContentChange:i,readOnly:o}=e,a=I.useMemo(()=>Object.entries(r),[r]);return d.jsx(d.Fragment,{children:a.map(([s,l])=>{const c=t[s];return d.jsx($C,{id:`${n}.${s}`,readOnly:o,nestableWidget:l,content:ue.isNestableContent(c)?c:void 0,onContentChange:u=>{i(gVe(t,s,u))}},s)})})}function gVe(e,t,n){return n?{...e,[t]:n}:Nd.removeKey(e,t)}function aj(e){var o,a;const{group:t,content:n,onContentChange:r,...i}=e;return d.jsx(TUe,{children:d.jsx(sj,{...i,title:l_(t),addItemButtonTitle:`Add item in "${l_(t)}"`,repeatable:((o=t.config)==null?void 0:o.repeat)!==!1,repeatableZone:((a=t.config)==null?void 0:a.fields)??{},content:n==null?void 0:n.value,onContentChange:s=>{r({__TYPE__:"GroupContentType",value:s})}})})}function l_(e){var t;return((t=e.config)==null?void 0:t.label)??e.fieldset??e.type}function RX(e){const{id:t,readOnly:n,content:r,widget:i}=e,o=ze.useStableCallback(e.onContentChange);return I.useMemo(()=>{const a={id:t,readOnly:n,onContentChange:o};return i.type==="Group"?d.jsx(aj,{...a,group:i,content:ue.isGroupContent(r)?r:void 0}):d.jsx($C,{...a,nestableWidget:i,content:ue.isNestableContent(r)?r:void 0})},[r,t,i,o,n])}function sj(e){const{id:t,title:n,addItemButtonTitle:r,content:i,onContentChange:o,readOnly:a,repeatable:s=!0,repeatableZone:l}=e,c=Object.entries(l);let u=i??[bVe];!s&&u.length>1&&(u=u.slice(0,1));const{scrollOffsetTop:f}=be(),p=I.useRef(new WeakMap);vVe(p.current,u);function h(x){return p.current.get(x)??"!bugged!"}function m(x){const b=c_();o(_t.insertAtIndex(u,x,b))}function g(x){const{index:b,offset:v}=x;o(_t.move(u,b,b+v))}function y(x){o(_t.removeIndex(u,x))}function C(x,b,v,S){const w=SVe(x,[v,S]),T=CVe(u,[b,w]);yVe(p.current,x,w),o(T)}return Object.keys(l).length===0?null:d.jsx(A.Group,{title:n??"Repeatable zone",addItemButtonTitle:r??"Add item in repeatable zone",items:u,maxItems:s?void 0:1,getItemKey:h,onAddItem:m,dnd:{scrollOffsetTop:f,onReorder:o,renderDragPreview:({index:x})=>d.jsx(wVe,{title:n??"Repeatable zone",index:x}),renderDropIndicator:xVe},children:(x,b)=>{const v=new Map(x.value),S=h(x);return d.jsx(A.LazyRender,{keepLoaded:!0,loadWhenSearching:!0,children:d.jsx(A.GroupItem,{index:b,title:`${b+1} • Item`,onMove:g,onDelete:y,children:c.map(([w,T])=>d.jsx(RX,{id:`${t}[${S}].${w}`,content:v.get(w),widget:T,onContentChange:R=>C(x,b,w,R),readOnly:a},w))})})}})}function vVe(e,t){t.forEach(n=>{e.has(n)||e.set(n,BX.uniqueNumber())})}function yVe(e,t,n){const r=e.get(t);r!==void 0&&e.set(n,r)}const bVe={__TYPE__:"GroupItemContent",value:[]};function CVe(e,t){const[n,r]=t;return r?e.map((i,o)=>o===n?r:i):e.filter((i,o)=>o!==n)}function SVe(e,t){const[n,r]=t;if(!r){const o=e.value.filter(([a])=>a!==n);return c_(o)}const i=Array.from(new Map(e.value).set(n,r));return c_(i)}function c_(e=[]){return{__TYPE__:"GroupItemContent",value:e}}function wVe(e){const{title:t,index:n}=e;return d.jsxs(A.Box,{padding:{block:8,inline:12},backgroundColor:"grey3",border:!0,borderRadius:6,alignItems:"center",justifyContent:"space-between",width:"100%",children:[d.jsxs("div",{children:[d.jsx(A.Text,{variant:"smallBold",color:"grey11",children:t??"Repeatable zone"}),d.jsxs(A.Text,{variant:"small",color:"grey11",children:[n+1," • Item"]})]}),d.jsx(A.Icon,{name:"dragIndicator",size:"small",color:"grey8"})]})}function xVe(e){const{isDropTarget:t,itemIndex:n,position:r}=e,i=t?d.jsx(A.Line,{color:"purple",thickness:2,sx:{position:"absolute",left:0,right:0,bottom:n===0&&r==="before"?0:void 0}},"line"):void 0;return d.jsx(A.AnimatedElement,{enterDuration:150,children:i})}function _Ve(e){const{compositeSlice:t,content:n,onContentChange:r,sliceKey:i,id:o,readOnly:a,header:s}=e,l=sC();function c(){i&&l.update({id:i,requestedFrom:"sliceFieldSet"})}return d.jsxs(A.FieldSet,{id:i&&aC("sliceFieldSet",i),selected:i?l.isSelected(i):!1,onFocus:c,legend:TVe(t),header:s,children:[d.jsx(mVe,{id:o,readOnly:a,nonRepeatableZone:t["non-repeat"]??{},content:n.nonRepeat,onContentChange:u=>{r({...n,nonRepeat:u})}}),d.jsx(sj,{id:o,readOnly:a,repeatableZone:t.repeat??{},content:n.repeat,onContentChange:u=>{r({...n,repeat:u})}})]})}function TVe(e){var t;return((t=e.config)==null?void 0:t.label)??e.fieldset??e.type}const EX={__TYPE__:"ImageContent",edit:{background:"",crop:{x:0,y:0},zoom:0},height:0,width:0,origin:{height:0,width:0,id:"",url:""},url:""};function IVe(e){const{field:t}=e;if(t.type==="Image")return EX}function RVe(e){const{content:t,legacySlice:n,sliceKey:r,id:i,readOnly:o,onContentChange:a,header:s}=e,l=sC();function c(){r&&l.update({id:r,requestedFrom:"sliceFieldSet"})}const u=n.type==="Group"?l_(n):Tr(n);return d.jsx(A.FieldSet,{id:r&&aC("sliceFieldSet",r),selected:r?l.isSelected(r):!1,onFocus:c,legend:u,header:s,children:n.type==="Group"?d.jsx(aj,{id:i,readOnly:o,onContentChange:a,group:n,content:ue.isGroupContent(t)?t:void 0}):d.jsx($C,{id:i,readOnly:o,nestableWidget:n,content:ue.isNestableContent(t)?t:void 0,onContentChange:f=>{const p=IVe({field:n});!f&&p&&a(p),f&&a(f)}})})}function EVe(e){const{content:t,id:n,slicePrimaryZone:r,onContentChange:i,readOnly:o}=e,a=I.useMemo(()=>Object.entries(r),[r]);return d.jsx(d.Fragment,{children:a.map(([s,l])=>{const c=t[s];return d.jsx(RX,{id:`${n}.${s}`,readOnly:o,widget:l,content:ue.isSlicePrimaryContent(c)?c:void 0,onContentChange:u=>{i($Ve(t,s,u))}},s)})})}function $Ve(e,t,n){return n?{...e,[t]:n}:Nd.removeKey(e,t)}function $X(e){const{config:t,content:n,sliceKey:r,readOnly:i=!1,sharedSlice:o,onContentChange:a,...s}=e,l=kVe(o,n.variation),c=I.useId(),f={id:s.id??c,readOnly:i},p=sC();function h(){r&&p.update({id:r,requestedFrom:"sliceFieldSet"})}return l===void 0?null:d.jsx(yy.Provider,{value:t,children:d.jsx(_Ue,{children:d.jsxs(A.FieldSet,{id:r&&aC("sliceFieldSet",r),selected:r?p.isSelected(r):!1,onFocus:h,legend:OVe(o,l),children:[d.jsx(A.LazyRender,{heightEstimate:400,gap:16,keepLoaded:!0,loadWhenSearching:!0,children:d.jsx(EVe,{...f,slicePrimaryZone:l.primary??{},content:n.primary,onContentChange:m=>{a({...n,primary:m})}})}),d.jsx(sj,{...f,repeatableZone:l.items??{},content:n.items,onContentChange:m=>{a({...n,items:m})}})]})})})}function kVe(e,t){return I.useMemo(()=>e.variations.find(n=>n.id===t),[e,t])}function OVe(e,t){return[e.name,t.name].join(" • ")}function mU(e){var l,c;const{sliceZone:t,onChange:n,slices:r,sliceContent:i}=e,o=(c=(l=t.config)==null?void 0:l.labels)==null?void 0:c[i.name];if(!o)return null;const a=o.find(u=>u.name===i.maybeLabel);function s(u){const f=r.value.map(p=>p.key===i.key?{...p,maybeLabel:u}:p);n({...r,value:f})}return d.jsxs(d.Fragment,{children:[d.jsx(A.Text,{component:"span",variant:"smallBold",children:"•"}),d.jsxs(A.DropdownMenu,{children:[d.jsx(A.DropdownMenuTrigger,{children:d.jsx(A.Button,{color:"grey",size:"small",endIcon:"arrowDropDown",invisible:!0,children:(a==null?void 0:a.display)??"Slice variation"})}),d.jsxs(A.DropdownMenuContent,{align:"start",maxHeight:256,children:[d.jsx(A.DropdownMenuItem,{onSelect:()=>s(void 0),endIcon:i.maybeLabel===void 0?d.jsx(A.Icon,{name:"check"}):void 0,children:"..."}),o==null?void 0:o.map(u=>d.jsx(A.DropdownMenuItem,{onSelect:()=>s(u.name),endIcon:u.name===i.maybeLabel?d.jsx(A.Icon,{name:"check"}):void 0,children:u.display??"[Missing display value]"},u.name))]})]})]})}function MVe(e){const{content:t,id:n,onContentChange:r,readOnly:i,sliceZone:o}=e,a=be();return d.jsx(d.Fragment,{children:t==null?void 0:t.value.map((s,l)=>{var p,h;const c=(h=(p=o.config)==null?void 0:p.choices)==null?void 0:h[s.name];if(c===void 0)return null;const u=s.widget,f={id:`${n}[${s.key}]`,key:s.key,sliceKey:s.key,onContentChange:m=>{const g={...s,widget:m},y=FVe(t,[l,g]);r(y)},readOnly:i};return c.type==="SharedSlice"?ue.isSharedSliceContent(u)?d.jsx($X,{...f,config:a,sharedSlice:c,content:u}):null:c.type==="Slice"?ue.isCompositeSliceContent(u)?d.jsx(_Ve,{...f,compositeSlice:c,content:u,header:d.jsx(mU,{sliceContent:s,sliceZone:o,slices:t,onChange:r})}):null:ue.isSimpleSliceContent(u)?d.jsx(RVe,{...f,legacySlice:c,content:u,header:d.jsx(mU,{sliceContent:s,sliceZone:o,slices:t,onChange:r})}):null})})}function FVe(e,[t,n]){return{__TYPE__:"SliceContentType",value:e.value.map((r,i)=>i===t?n:r)}}function jVe(e){const{content:t,metadataFieldType:n,documentId:r,documentContent:i,documentCustomType:o,documentLocale:a,...s}=e,{showAlert:l}=A.useAlert(),[c,u]=I.useState(!1),f=be(),p=I.useMemo(()=>IQ(i,o),[i,o]),h=RQ(p);async function m(){if(!f.aiSeoMetadataEnabled)return;const{trackMetadataGeneration:g,authStrategy:y,documentBaseUrl:C,repository:x}=f;u(!0);try{const b=await TQ(x,C,y,{pageTextContent:p,contentLocale:a});e.onContentChange({__TYPE__:"FieldContent",type:"Text",value:b[n]}),g({documentId:r,locale:a,suggestion:b[n],type:n})}catch{l({id:n,title:"Error",subtitle:`Failed to generate SEO metadata for ${gU[n]}`})}u(!1)}return d.jsx(kY,{...s,content:t,placeholder:`${gU[n]}..`,endAdornment:d.jsxs(d.Fragment,{children:[d.jsx(ZH,{type:n,value:(t==null?void 0:t.value)||""}),d.jsx(A.Tooltip,{content:h?"Generate SEO metadata from your page content.":"Your page content is too short to generate SEO metadata.",children:d.jsx(A.Button,{disabled:!h,onClick:m,size:"small",color:"grey",startIcon:"autoFixHigh",loading:c,sx:{alignSelf:"center",marginInline:8},children:"Generate"})})]})})}const gU={[oa]:"Meta title",[As]:"Meta description"};function LVe(e){const{id:t,field:n,content:r,onContentChange:i}=e,o=ze.useDebounceState({state:(r==null?void 0:r.value)??"",synchronize:!0}),{onEditUID:a}=I.useContext(eY);function s(c){a();const u=Zn.slugify(c);i(BVe(u)),o.set(u)}function l(c){s(c.clipboardData.getData("Text").trim()),c.preventDefault()}return d.jsxs(A.Field,{children:[d.jsx(A.FieldIcon,{name:"tag"}),d.jsx(A.FieldLabel,{htmlFor:t,children:Tr(n)}),d.jsx(A.FieldControl,{children:d.jsx(Rl,{id:t,variant:"success",placeholder:Ou(n,"Enter a unique identifier"),value:o.value,onPaste:l,onValueChange:s,endAdornment:d.jsx(A.AnimatedElement,{enterDuration:150,children:d.jsx(DVe,{uid:o.debouncedValue})})})})]})}function DVe(e){const{uid:t}=e,n=be();return t?n.uidField?d.jsx(A.ErrorBoundary,{children:d.jsx(I.Suspense,{children:d.jsx(UVe,{uid:t})})}):null:d.jsx(A.Badge,{color:"tomato",title:"Required",size:"medium"})}function UVe(e){const t=PVe(e),n=be();if(!t.documentId)return null;const r=oF({status:t.status,releaseId:t.releaseId,documentId:t.documentId,versionId:t.versionId,baseUrl:n.baseUrl});return d.jsx("a",{href:r.href,target:"_blank",rel:"noreferrer",children:d.jsx(A.Badge,{color:"tomato",size:"medium",title:d.jsxs(A.Text,{color:"tomato11",variant:"small",children:["Value already used in"," ",d.jsx(A.Text,{color:"tomato11",variant:"small",underline:!0,children:"another document"})]})})})}function BVe(e){return e===""?void 0:{__TYPE__:"UIDContent",value:e}}function PVe(e){var p,h,m,g;const{uid:t}=e,n=be();n.uidField||At("uidField");const{coreApiBaseUrl:r,authStrategy:i,customTypeId:o,localeId:a,documentId:s}=n,{data:l}=JM({baseUrl:r,authStrategy:i,uids:[t]}),c=l.results,f=nY({customTypeId:o,languageId:a,documentsWithUid:c,documentId:s,uid:t})[0];return f?{documentId:f.id,versionId:(p=f.versions[0])==null?void 0:p.version_id,status:(h=f.versions[0])==null?void 0:h.status,releaseId:((m=f.versions[0])==null?void 0:m.status)==="release"?(g=f.versions[0])==null?void 0:g.release_id:void 0}:{}}function WVe(e){const{id:t,readOnly:n,staticZone:r,content:i,onContentChange:o,documentId:a,documentContent:s,documentCustomType:l,documentLocale:c}=e,u=be(),f=I.useMemo(()=>Object.entries(r),[r]),p=I.useRef(i);if(I.useEffect(()=>{p.current=i},[i]),f.length===0)return null;const h=KVe(f),m=Lv(i[oa])||"Meta title..",g=Lv(i[As])||"Meta description..";return d.jsxs(A.FieldSet,{legend:"Page data",children:[h&&d.jsx(XH,{title:m,description:g}),f.map(([y,C])=>{const x={id:`${t}.${y}`,onContentChange:v=>{const{[y]:S,...w}=p.current;o({...w,...v!==void 0&&{[y]:v}})},readOnly:n},b=i[y];return C.type==="UID"?I.createElement(LVe,{...x,content:ue.isUIDContent(b)?b:void 0,key:y,field:C}):C.type==="Group"?I.createElement(aj,{...x,content:ue.isGroupContent(b)?b:void 0,group:C,key:y}):u.aiSeoMetadataEnabled&&NVe(y)&&C.type==="Text"?I.createElement(jVe,{...x,content:ue.isTextContent(b)?b:void 0,field:C,key:y,metadataFieldType:y,documentId:a,documentContent:s,documentCustomType:l,documentLocale:c}):I.createElement($C,{...x,content:ue.isNestableContent(b)?b:void 0,key:y,nestableWidget:C})})]})}function NVe(e){return e===oa||e===As}const KVe=e=>{var t,n;return((t=e[0])==null?void 0:t[0])===oa&&((n=e[1])==null?void 0:n[0])===As};function qVe(e){const{id:t,readOnly:n,section:r,content:i,onContentChange:o,documentId:a,documentContent:s,documentCustomType:l,documentLocale:c}=e,[u,f]=zVe(r),[p,h]=QVe(i);return d.jsxs("div",{style:{display:"flex",flexDirection:"column",position:"relative",zIndex:0},children:[d.jsx(WVe,{id:t,readOnly:n,staticZone:u,documentId:a,content:p,onContentChange:m=>o({...h,...m}),documentContent:s,documentCustomType:l,documentLocale:c}),f.map(([m,g])=>{const y=h[m];return d.jsx(MVe,{id:`${t}.${m}`,readOnly:n,sliceZone:g,content:y,onContentChange:C=>o({...p,...h,[m]:C})},m)})]})}function VVe(e){return e.type==="Choice"||e.type==="Slices"}function zVe(e){return Object.entries(e).reduce(([t,n],[r,i])=>(VVe(i)?n.push([r,i]):Object.assign(t,{[r]:i}),[t,n]),[{},[]])}function QVe(e){return Object.entries(e).reduce(([t,n],[r,i])=>{const o={[r]:i};return Object.assign(ue.isSlicesContent(i)?n:t,o),[t,n]},[{},{}])}function HVe(e){const{config:t,readOnly:n=!1,customType:r,sectionName:i,documentId:o,content:a,locale:s,onContentChange:l}=e,c=I.useId();if(Nd.isEmpty(r.json))return null;const u=YVe(r,i),[f,p]=GVe(u,a);return d.jsx(yy.Provider,{value:t,children:d.jsx(xUe,{customTypeFormat:r.format,children:d.jsx(qVe,{id:c,readOnly:n,section:u,documentId:o,content:f,onContentChange:h=>l({...p,...h}),documentContent:a,documentCustomType:r,documentLocale:s})})})}function YVe(e,t){const n=e.json[t];if(n===void 0)throw new Error(`Cannot find a section with name '${t}'.`);return n}function GVe(e,t){return Object.entries(t).reduce(([n,r],[i,o])=>{const a=e[i]!==void 0,s={[i]:o};return[{...n,...a?s:{}},{...r,...a?{}:s}]},[{},{}])}exports.APIExplorer=C2e;exports.DeferredCodeBlock=Dv;exports.DocumentEditor=HVe;exports.EditorConfigContext=yy;exports.EditorErrorBoundary=T2e;exports.MediaLibrary=JH;exports.MetadataBadge=ZH;exports.MetadataPreview=XH;exports.OnboardingGuide=AUe;exports.OnboardingStepId=Yje;exports.SelectionManagerProvider=bH;exports.SharedSliceEditor=$X;exports.SliceSelectionContext=rY;exports.TeamSpace=iC;exports.UIDContext=eY;exports.createSearchParams=UQ;exports.createTeamSpace=hLe;exports.defaultGroupContentWithOneItem=gH;exports.defaultImageContentWidget=EX;exports.deleteTeamSpace=mLe;exports.documentKeys=To;exports.documentMetaSchema=YM;exports.documentSchema=Uje;exports.documentStatus=vH;exports.extractTextFromField=Lv;exports.fetchCustomTypes=Ije;exports.frameworkCreateProjectCodeSnippet=bU;exports.frameworkLabels=yU;exports.generateSEOMetadata=TQ;exports.getConflictingUidDocuments=nY;exports.getCustomTypesOptions=zm;exports.getDocumentById=Qm;exports.getDocumentList=GM;exports.getDocumentListOptions=BQ;exports.getOnboarding=Gje;exports.getPageTextContent=IQ;exports.getProfile=eH;exports.getRepository=rC;exports.getRepositoryTags=VQ;exports.getRepositoryV2=Hje;exports.getRoleLabel=tLe;exports.getRoles=GQ;exports.getRolesOptions=lLe;exports.getSliceSelectionDOMId=aC;exports.getTeamSpaces=JQ;exports.getTeamSpacesOptions=fLe;exports.hasUIDField=tY;exports.invalidateCustomTypes=Eje;exports.invalidateDocumentListData=Wje;exports.isAdminRole=Xje;exports.isDocumentSearchVersion=nx;exports.isDocumentVersion=FQ;exports.isMissingUID=CUe;exports.isPageContentRelevantForAISeo=RQ;exports.isValidSimulatorURL=qQ;exports.languageSchema=HM;exports.makeSearchFullTextDocumentsQueryString=DQ;exports.metaDescriptionConfig=Fh;exports.metaDescriptionProperty=As;exports.metaTitleConfig=Mh;exports.metaTitleProperty=oa;exports.onboardingStateSchema=QQ;exports.onboardingToggleResultSchema=YQ;exports.onboardingToggleStepResultSchema=HQ;exports.prefetchCustomTypes=Tje;exports.prefetchStaticCustomType=Mje;exports.prepareDocumentForSave=S2e;exports.profileResponse=XQ;exports.repositoryFramework=nC;exports.repositorySchemaV2=zQ;exports.roleMap=yLe;exports.searchDocumentStatus=ax;exports.searchDocuments=PQ;exports.searchDocumentsQueryOptions=WQ;exports.searchFullTextDocuments=LQ;exports.sliceItemContentSchema=Bje;exports.suppressErrors=_te;exports.throwConfigError=At;exports.toggleOnboarding=Zje;exports.toggleOnboardingStep=Jje;exports.updateDocumentListData=Pje;exports.updateRoles=cLe;exports.updateTeamSpace=ALe;exports.useCustomType=Rje;exports.useCustomTypes=tC;exports.useDocumentList=JM;exports.useInvalidateRoles=uLe;exports.useInvalidateTeamSpaces=pLe;exports.useProfile=eF;exports.useSelectionManager=Il;exports.useSliceSelection=sC;exports.useStaticCustomType=Oje;
|